@conto_finance/sdk 0.3.1 → 0.5.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.
package/dist/index.d.mts CHANGED
@@ -5,6 +5,11 @@ interface ApiErrorMetadata {
5
5
  retryAfter?: number;
6
6
  retryGuidance?: string;
7
7
  actionUrl?: string;
8
+ fieldErrors?: Array<{
9
+ field: string;
10
+ message: string;
11
+ }>;
12
+ reasons?: string[];
8
13
  }
9
14
 
10
15
  /**
@@ -68,6 +73,8 @@ type AgentAttestationMode = 'KEY_ONLY' | 'SIGNED_REQUEST' | 'SIGNED_REQUEST_WITH
68
73
  type DelegationType = 'FULL' | 'LIMITED' | 'VIEW_ONLY' | 'PREAPPROVED' | 'ALLOWLIST';
69
74
  type ChainType = 'EVM' | 'SOLANA';
70
75
  type CustomerCustodyMode = 'MANAGED' | 'EXTERNAL' | 'SMART_CONTRACT';
76
+ type CustomerWalletControlModel = 'CONTO_MANAGED' | 'ORGANIZATION_CONTROLLED' | 'EXTERNAL' | 'CONTRACT_ENFORCED';
77
+ type CustomerWalletKeyAccess = 'NO_SELF_SERVICE_EXPORT' | 'OWNER_AUTHORIZED_EXPORT' | 'EXPORT_RECONCILIATION_REQUIRED' | 'CUSTOMER_CONTROLLED' | 'CONTRACT_ADMINISTRATED' | 'EXPORTED';
71
78
  /** @deprecated Use CustomerCustodyMode. */
72
79
  type CustodyType = CustomerCustodyMode;
73
80
  type WalletType = 'EOA' | 'SMART_WALLET' | 'MULTISIG';
@@ -190,6 +197,8 @@ interface AgentWalletLink {
190
197
  usdcBalance: number;
191
198
  status: string;
192
199
  custodyMode?: CustomerCustodyMode;
200
+ controlModel?: CustomerWalletControlModel;
201
+ keyAccess?: CustomerWalletKeyAccess;
193
202
  };
194
203
  createdAt: string;
195
204
  updatedAt: string;
@@ -439,6 +448,8 @@ interface Wallet {
439
448
  chainId: string;
440
449
  walletType: WalletType;
441
450
  custodyMode: CustomerCustodyMode;
451
+ controlModel: CustomerWalletControlModel;
452
+ keyAccess: CustomerWalletKeyAccess;
442
453
  usdcBalance: number;
443
454
  status: WalletStatus;
444
455
  createdAt: string;
@@ -450,6 +461,8 @@ interface CreateWalletInput {
450
461
  chainType?: ChainType;
451
462
  chainId?: string;
452
463
  custodyMode?: Extract<CustomerCustodyMode, 'MANAGED' | 'EXTERNAL'>;
464
+ /** Root authority for a newly created managed wallet. */
465
+ controlModel?: Extract<CustomerWalletControlModel, 'CONTO_MANAGED' | 'ORGANIZATION_CONTROLLED'>;
453
466
  walletType?: WalletType;
454
467
  address?: string;
455
468
  }
@@ -476,6 +489,8 @@ interface ProvisionWalletResult {
476
489
  chainId: string;
477
490
  chainType: string;
478
491
  custodyMode: CustomerCustodyMode;
492
+ controlModel?: CustomerWalletControlModel;
493
+ keyAccess?: CustomerWalletKeyAccess;
479
494
  balance: number;
480
495
  currency: string;
481
496
  };
@@ -569,6 +584,94 @@ interface UpdatePolicyRuleInput {
569
584
  value?: string;
570
585
  action?: RuleAction;
571
586
  }
587
+ type PolicyVersionChangeType = 'CREATED' | 'UPDATED' | 'RULES_CHANGED' | 'ROLLED_BACK';
588
+ interface PolicyVersionSnapshotRule {
589
+ ruleType: string;
590
+ operator: string;
591
+ value: string;
592
+ action: string;
593
+ }
594
+ interface PolicyVersionSnapshot {
595
+ name: string;
596
+ description: string | null;
597
+ policyType: string;
598
+ scope: 'organization' | 'assigned';
599
+ priority: number;
600
+ isActive: boolean;
601
+ rules: PolicyVersionSnapshotRule[];
602
+ }
603
+ interface PolicyVersionSummary {
604
+ version: number;
605
+ changeType: PolicyVersionChangeType;
606
+ note: string | null;
607
+ createdBy: string | null;
608
+ createdByType: string | null;
609
+ createdAt: string;
610
+ rulesCount: number;
611
+ }
612
+ interface PolicyVersionDetail extends Omit<PolicyVersionSummary, 'rulesCount'> {
613
+ snapshot: PolicyVersionSnapshot;
614
+ }
615
+ interface ListPolicyVersionsResponse {
616
+ versions: PolicyVersionSummary[];
617
+ total: number;
618
+ limit: number;
619
+ offset: number;
620
+ }
621
+ interface PolicyVersionFieldChange {
622
+ field: string;
623
+ from: unknown;
624
+ to: unknown;
625
+ }
626
+ interface PolicyVersionDiff {
627
+ fields: PolicyVersionFieldChange[];
628
+ rulesAdded: PolicyVersionSnapshotRule[];
629
+ rulesRemoved: PolicyVersionSnapshotRule[];
630
+ unchanged: boolean;
631
+ }
632
+ interface ComparePolicyVersionsResponse {
633
+ from: number;
634
+ to: number;
635
+ diff: PolicyVersionDiff;
636
+ }
637
+ interface RollbackPolicyVersionResponse extends Policy {
638
+ restoredFromVersion: number;
639
+ newVersion: number | null;
640
+ }
641
+ type StripeLinkCheckoutReadinessStatus = 'NOT_READY' | 'READY_FOR_VERIFICATION' | 'VERIFIED' | 'VERIFICATION_FAILED';
642
+ type StripeLinkCheckoutVerification = 'NOT_RUN' | 'NOT_READY' | 'VERIFIED' | 'ACCOUNT_MISMATCH' | 'PROVIDER_UNAVAILABLE';
643
+ /**
644
+ * Non-identifying readiness projection for the configured Stripe Link
645
+ * Checkout adapter. Merchant/account identifiers, URLs, credentials, hashes,
646
+ * Stripe objects, and raw provider errors are intentionally absent.
647
+ */
648
+ interface StripeLinkCheckoutReadiness {
649
+ readonly status: StripeLinkCheckoutReadinessStatus;
650
+ readonly mode: 'TEST' | 'LIVE' | null;
651
+ readonly checks: {
652
+ readonly providerEnabled: boolean;
653
+ readonly checkoutEnabled: boolean;
654
+ readonly organizationAllowed: boolean;
655
+ readonly configurationValid: boolean;
656
+ readonly accountVerified: boolean;
657
+ };
658
+ readonly canVerify: boolean;
659
+ readonly verifiedAt: string | null;
660
+ readonly verification: StripeLinkCheckoutVerification;
661
+ readonly scope: {
662
+ readonly configuredMerchantCheckoutOnly: true;
663
+ readonly statement: string;
664
+ };
665
+ readonly link: {
666
+ readonly eligibilityGuaranteed: false;
667
+ readonly displayGuaranteed: false;
668
+ readonly selectionGuaranteed: false;
669
+ readonly statement: string;
670
+ };
671
+ }
672
+ interface StripeLinkCheckoutReadinessResult {
673
+ readonly readiness: StripeLinkCheckoutReadiness;
674
+ }
572
675
  declare class ContoAdmin {
573
676
  private orgApiKey;
574
677
  private baseUrl;
@@ -578,10 +681,22 @@ declare class ContoAdmin {
578
681
  cards: AdminCardsClient;
579
682
  policies: PoliciesClient;
580
683
  team: TeamClient;
684
+ paymentRails: PaymentRailsClient;
581
685
  constructor(config: ContoAdminConfig);
582
686
  /** Make an authenticated request to the Conto API */
583
687
  request<T>(method: string, path: string, body?: Record<string, unknown>): Promise<T>;
584
688
  }
689
+ declare class PaymentRailsClient {
690
+ private client;
691
+ constructor(client: ContoAdmin);
692
+ /** Read gate and configuration readiness without calling Stripe. */
693
+ getStripeLinkCheckoutReadiness(): Promise<StripeLinkCheckoutReadinessResult>;
694
+ /**
695
+ * Ask Conto to verify that its configured Stripe credential resolves to its
696
+ * configured merchant account. This call never returns either identifier.
697
+ */
698
+ verifyStripeLinkCheckoutAccount(): Promise<StripeLinkCheckoutReadinessResult>;
699
+ }
585
700
  declare class AdminCardsClient {
586
701
  private client;
587
702
  constructor(client: ContoAdmin);
@@ -752,6 +867,20 @@ declare class PoliciesClient {
752
867
  success: boolean;
753
868
  deletedCount: number;
754
869
  }>;
870
+ /** List the version history for a policy (newest first). */
871
+ listVersions(policyId: string, params?: PaginationParams): Promise<ListPolicyVersionsResponse>;
872
+ /** Get a single version's snapshot. */
873
+ getVersion(policyId: string, version: number): Promise<PolicyVersionDetail>;
874
+ /** Diff two versions of a policy. */
875
+ compareVersions(policyId: string, from: number, to: number): Promise<ComparePolicyVersionsResponse>;
876
+ /**
877
+ * Restore an earlier version. Appends a new ROLLED_BACK version. If the
878
+ * organization requires governance approval for policy changes, the API
879
+ * returns a pending-approval response instead of applying the rollback.
880
+ */
881
+ rollbackVersion(policyId: string, version: number, options?: {
882
+ note?: string;
883
+ }): Promise<RollbackPolicyVersionResponse>;
755
884
  }
756
885
  declare class TeamClient {
757
886
  private client;
@@ -762,6 +891,68 @@ declare class TeamClient {
762
891
  }>;
763
892
  }
764
893
 
894
+ type BrowserCheckoutTargetVerificationCode = 'BROWSER_CHECKOUT_TARGET_INVALID' | 'BROWSER_CHECKOUT_TARGET_NOT_FOUND' | 'BROWSER_CHECKOUT_TARGET_CHANGED' | 'BROWSER_CHECKOUT_TARGET_DISABLED';
895
+ declare class BrowserCheckoutTargetVerificationError extends Error {
896
+ readonly code: BrowserCheckoutTargetVerificationCode;
897
+ constructor(code: BrowserCheckoutTargetVerificationCode, message: string);
898
+ }
899
+ /**
900
+ * Credential-free description of one payment-sensitive DOM target. The
901
+ * snapshot is created during proposal discovery and recomputed by the
902
+ * privileged browser process immediately before dispatch.
903
+ */
904
+ interface BrowserCheckoutTargetSnapshot {
905
+ /** Current top-level page URL. Fragments are ignored. */
906
+ pageUrl: string;
907
+ /** Runtime-owned exact locator identity, such as a stable DOM path. */
908
+ locator: string;
909
+ tagName: string;
910
+ role?: string;
911
+ accessibleName?: string;
912
+ /** Resolved navigation target for anchors or controls, when present. */
913
+ targetUrl?: string;
914
+ /** Resolved form submission target, when present. */
915
+ formAction?: string;
916
+ /** Whether the exact control declares a new browsing context such as target=_blank. */
917
+ opensNewPage?: boolean;
918
+ disabled: boolean;
919
+ }
920
+ interface VerifiedBrowserCheckoutTarget<T> {
921
+ snapshot: BrowserCheckoutTargetSnapshot;
922
+ /** Performs the one payment-sensitive side effect and observes its result. */
923
+ dispatch(): Promise<GuardedBrowserDispatchResult<T>>;
924
+ }
925
+ /** Port implemented inside the isolated browser process. */
926
+ interface BrowserCheckoutTargetResolver<T> {
927
+ resolve(input: {
928
+ authorization: CheckoutActionAuthorization;
929
+ browserSessionId: string;
930
+ action: AgentCheckoutAction | BrowserCheckoutAction;
931
+ }): Promise<VerifiedBrowserCheckoutTarget<T> | null>;
932
+ }
933
+ interface CanonicalBrowserCheckoutTargetSnapshot {
934
+ pageUrl: string;
935
+ locator: string;
936
+ tagName: string;
937
+ role: string | null;
938
+ accessibleName: string | null;
939
+ targetUrl: string | null;
940
+ formAction: string | null;
941
+ opensNewPage: boolean;
942
+ disabled: boolean;
943
+ }
944
+ declare function canonicalizeBrowserCheckoutTarget(snapshot: BrowserCheckoutTargetSnapshot): CanonicalBrowserCheckoutTargetSnapshot;
945
+ /**
946
+ * Generates the exact opaque fingerprint sent as action.targetFingerprint.
947
+ * The raw DOM locator and target details stay inside the customer runtime.
948
+ */
949
+ declare function fingerprintBrowserCheckoutTarget(snapshot: BrowserCheckoutTargetSnapshot): string;
950
+ /**
951
+ * Creates a driver that re-resolves and verifies the exact DOM target after
952
+ * Conto's one-use claim and before the payment-sensitive browser side effect.
953
+ */
954
+ declare function createVerifiedBrowserCheckoutDriver<T>(resolver: BrowserCheckoutTargetResolver<T>): PrivilegedBrowserCheckoutDriver<T>;
955
+
765
956
  /**
766
957
  * Conto SDK
767
958
  *
@@ -837,11 +1028,110 @@ interface PaymentRequestInput {
837
1028
  /** Client-supplied key for idempotent retries */
838
1029
  idempotencyKey?: string;
839
1030
  }
1031
+ interface AgentSetupResult {
1032
+ agent: {
1033
+ id: string;
1034
+ name: string;
1035
+ status: 'active' | 'paused' | 'unavailable';
1036
+ lastActiveAt: string | null;
1037
+ createdAt: string;
1038
+ };
1039
+ wallets: Array<{
1040
+ id: string;
1041
+ address: string;
1042
+ custodyMode: CustomerCustodyMode;
1043
+ chainId: string;
1044
+ chainName: string;
1045
+ chainType: string;
1046
+ isTestnet: boolean;
1047
+ balance: number;
1048
+ currency: string;
1049
+ status: 'active' | 'paused' | 'unavailable';
1050
+ limits: {
1051
+ perTransaction: number | null;
1052
+ daily: number | null;
1053
+ weekly: number | null;
1054
+ monthly: number | null;
1055
+ };
1056
+ spent: {
1057
+ today: number;
1058
+ thisWeek: number;
1059
+ thisMonth: number;
1060
+ };
1061
+ }>;
1062
+ policies: Array<{
1063
+ id: string;
1064
+ name: string;
1065
+ description: string | null;
1066
+ scope: 'organization' | 'assigned';
1067
+ appliesVia: string[];
1068
+ walletIds: string[];
1069
+ }>;
1070
+ counterparties: Array<{
1071
+ id: string;
1072
+ name: string;
1073
+ address: string;
1074
+ category: string;
1075
+ trustScore: number;
1076
+ trustLevel: 'trusted' | 'verified' | 'blocked' | 'unverified';
1077
+ transactionCount: number;
1078
+ totalVolume: number;
1079
+ }>;
1080
+ scopes: string[];
1081
+ }
1082
+ interface ExternalWalletApprovalInput {
1083
+ amount: number;
1084
+ senderAddress: string;
1085
+ recipientAddress: string;
1086
+ /** Numeric chain ID accepted by the external approval endpoint. */
1087
+ chainId: number | `${number}`;
1088
+ recipientName?: string;
1089
+ purpose?: string;
1090
+ category?: string;
1091
+ context?: PaymentRequestInput['context'];
1092
+ }
1093
+ interface ExternalWalletApprovalResult {
1094
+ approved: boolean;
1095
+ decision: 'approved' | 'review_required' | 'declined';
1096
+ status: 'ready_to_send' | 'review_required' | 'declined';
1097
+ /** Budget denials can occur before a request is created. */
1098
+ approvalId?: string;
1099
+ approvalToken?: string;
1100
+ expiresAt?: string;
1101
+ confirmUrl?: string;
1102
+ statusUrl?: string;
1103
+ approvalRequestId?: string;
1104
+ reasons: string[];
1105
+ reasonCodes: string[];
1106
+ requiresHumanApproval: boolean;
1107
+ network?: {
1108
+ type: 'evm' | 'solana';
1109
+ id: string;
1110
+ };
1111
+ }
1112
+ interface ExternalWalletConfirmationInput {
1113
+ txHash: string;
1114
+ approvalToken?: string;
1115
+ }
1116
+ interface ExternalWalletConfirmationResult {
1117
+ accepted: true;
1118
+ confirmed: false;
1119
+ requestId: string;
1120
+ transactionId: string;
1121
+ status: 'processing';
1122
+ txHash: string;
1123
+ network: {
1124
+ type: 'evm' | 'solana';
1125
+ id: string;
1126
+ };
1127
+ explorerUrl: string;
1128
+ statusUrl: string;
1129
+ }
840
1130
  interface PaymentRequestResult {
841
1131
  /** Unique request ID - use this to execute or check status */
842
1132
  requestId: string;
843
1133
  /** Current status */
844
- status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'ACTION_REQUIRED' | 'PROCESSING';
1134
+ status: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL' | 'PROCESSING';
845
1135
  /** Requested amount */
846
1136
  amount: number;
847
1137
  /** Currency selected for the payment */
@@ -864,7 +1154,8 @@ interface PaymentRequestResult {
864
1154
  receipt?: {
865
1155
  /** Stable Conto transaction ID for status checks and reconciliation */
866
1156
  transactionId: string;
867
- txHash: string;
1157
+ /** Present only for an onchain transfer. Simulations use transactionId. */
1158
+ txHash?: string;
868
1159
  /** Whether this receipt represents live settlement or a test-mode payment */
869
1160
  settlementMode: 'live' | 'test';
870
1161
  explorerUrl?: string;
@@ -885,7 +1176,8 @@ interface PaymentExecuteResult {
885
1176
  receipt: {
886
1177
  /** Stable Conto transaction ID for status checks and reconciliation */
887
1178
  transactionId: string;
888
- txHash: string;
1179
+ /** Present only for an onchain transfer. Simulations use transactionId. */
1180
+ txHash?: string;
889
1181
  /** Whether this receipt represents live settlement or a test-mode payment */
890
1182
  settlementMode: 'live' | 'test';
891
1183
  explorerUrl?: string;
@@ -893,7 +1185,9 @@ interface PaymentExecuteResult {
893
1185
  }
894
1186
  interface PaymentStatusResult {
895
1187
  requestId: string;
896
- status: 'approved' | 'declined' | 'review_required' | 'action_required' | 'reconciliation_required' | 'processing' | 'completed' | 'failed' | 'expired';
1188
+ /** Unknown for legacy records without execution evidence, or before execution. */
1189
+ settlementMode: 'live' | 'test' | 'unknown';
1190
+ status: 'approved' | 'declined' | 'review_required' | 'reconciliation_required' | 'processing' | 'completed' | 'failed' | 'expired';
897
1191
  amount: number;
898
1192
  currency: string;
899
1193
  recipient: string;
@@ -902,13 +1196,11 @@ interface PaymentStatusResult {
902
1196
  category: string | null;
903
1197
  expiresAt: string | null;
904
1198
  createdAt: string;
905
- action: {
906
- type: 'complete_verification';
907
- url: string;
908
- } | null;
1199
+ action: null;
909
1200
  transaction: {
910
1201
  /** Stable Conto transaction ID */
911
1202
  id: string;
1203
+ settlementMode: 'live' | 'test' | 'unknown';
912
1204
  txHash: string | null;
913
1205
  status: 'processing' | 'completed' | 'failed';
914
1206
  confirmedAt: string | null;
@@ -1039,6 +1331,8 @@ interface ExternalCardConfirmationResult {
1039
1331
  */
1040
1332
  interface ApprovedExternalCardExecution {
1041
1333
  requestId: string;
1334
+ /** Stable purchase key to pass through to the customer payment processor. */
1335
+ idempotencyKey: string;
1042
1336
  cardId: string;
1043
1337
  amount: number;
1044
1338
  currency: 'USD';
@@ -1063,10 +1357,529 @@ interface ControlledExternalCardPaymentResult<TReceipt = unknown> {
1063
1357
  confirmation: ExternalCardConfirmationResult;
1064
1358
  receipt: TReceipt;
1065
1359
  }
1360
+ interface ConnectedCardDrawMerchant {
1361
+ /** Merchant name for policy evaluation. */
1362
+ merchantName?: string;
1363
+ /** Network merchant identifier. */
1364
+ merchantId?: string;
1365
+ /** Four-digit MCC string (e.g. "5411"). */
1366
+ merchantCategory?: string;
1367
+ /** Two- or three-letter country code. */
1368
+ merchantCountry?: string;
1369
+ }
1370
+ interface ConnectedCardDrawInput {
1371
+ /** Connected card id delegated to this agent. */
1372
+ cardId: string;
1373
+ /** Verified mandate id the draw is charged against. */
1374
+ mandateId: string;
1375
+ /**
1376
+ * Stable 8 to 128 character key. The server is idempotent on this key: a
1377
+ * replay of the same key returns the decision WITHOUT the credential, so
1378
+ * reuse it only to reconcile the exact same draw, never to fetch the card
1379
+ * material again.
1380
+ */
1381
+ idempotencyKey: string;
1382
+ /** Integer amount in minor units (cents), greater than zero. */
1383
+ amountMinor: number;
1384
+ /** Only USD is supported. Defaults to USD. */
1385
+ currency?: 'USD';
1386
+ merchant: ConnectedCardDrawMerchant;
1387
+ }
1388
+ /**
1389
+ * Live single-use card material returned by {@link ConnectedCardsClient.draw}.
1390
+ *
1391
+ * CREDENTIAL SAFETY (this is the product boundary): these fields are the real,
1392
+ * usable card. They are returned exactly ONCE, on the successful mint, and can
1393
+ * never be re-fetched. A replay of the same idempotencyKey returns the decision
1394
+ * with no `credential`. Use these fields in-process at the intended merchant
1395
+ * checkout only. Never log, print, serialize, persist, cache, or send them
1396
+ * anywhere else. Do not place this object in an error, a Sentry breadcrumb, an
1397
+ * analytics event, or any structured output that a host might record.
1398
+ */
1399
+ interface ConnectedCardCredential {
1400
+ /** The card number (PAN). Live card material. */
1401
+ number: string;
1402
+ /** The card security value. Live card material. */
1403
+ securityValue: string;
1404
+ expirationMonth: string;
1405
+ expirationYear: string;
1406
+ cardholderName?: string;
1407
+ }
1408
+ interface ConnectedCardDrawResult {
1409
+ requestId: string;
1410
+ /** True when this draw has issued a credential, including a replay without the secret. */
1411
+ minted: boolean;
1412
+ /** True when this call replayed a prior draw for the same idempotencyKey. */
1413
+ replayed: boolean;
1414
+ decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
1415
+ reasons: string[];
1416
+ /** Present when the draw outcome is ambiguous and needs reconciliation. */
1417
+ reconciliationRequired?: boolean;
1418
+ /**
1419
+ * Live single-use card material. Present ONLY on a successful mint and
1420
+ * returned exactly once. Absent on a replay, a denial, or a review decision.
1421
+ * See {@link ConnectedCardCredential} for the handling rules.
1422
+ */
1423
+ credential?: ConnectedCardCredential;
1424
+ /** Provider expiration of the one-time credential; present with a fresh credential. */
1425
+ credentialExpiresAt?: string;
1426
+ }
1427
+ interface ConnectedCardMandateMerchant {
1428
+ name: string | null;
1429
+ categoryCode: string | null;
1430
+ countryCode: string | null;
1431
+ checkoutOrigin: string | null;
1432
+ }
1433
+ interface ConnectedCardMandate {
1434
+ id: string;
1435
+ providerReferenceId: string;
1436
+ bindingId: string;
1437
+ status: string;
1438
+ verificationStatus: string;
1439
+ amountMinor: number;
1440
+ currency: string;
1441
+ description: string;
1442
+ merchant: ConnectedCardMandateMerchant;
1443
+ expiresAt: string;
1444
+ verifiedAt: string | null;
1445
+ exhaustedAt: string | null;
1446
+ revokedAt: string | null;
1447
+ createdAt: string;
1448
+ updatedAt: string;
1449
+ }
1450
+ interface ConnectedCardBrief {
1451
+ last4: string;
1452
+ brand: string | null;
1453
+ fundingType: string;
1454
+ cardType: string;
1455
+ status: string;
1456
+ spendLimitDaily: number | null;
1457
+ spendLimitWeekly: number | null;
1458
+ spendLimitMonthly: number | null;
1459
+ spendLimitPerTx: number | null;
1460
+ }
1461
+ interface ConnectedCardReference {
1462
+ id: string;
1463
+ provider: string;
1464
+ lifecycleState: string;
1465
+ railStatus: string | null;
1466
+ }
1467
+ interface ConnectedCardDrawable {
1468
+ bindingId: string;
1469
+ agentId: string;
1470
+ status: string;
1471
+ cardId: string;
1472
+ reference: ConnectedCardReference;
1473
+ card: ConnectedCardBrief;
1474
+ mandates: ConnectedCardMandate[];
1475
+ createdAt: string;
1476
+ updatedAt: string;
1477
+ }
1478
+ interface ConnectedCardListResult {
1479
+ /** Masked drawable cards and their active mandates. No PAN or provider token. */
1480
+ cards: ConnectedCardDrawable[];
1481
+ }
1482
+ interface StripeLinkPaymentMethod {
1483
+ id: string;
1484
+ type: string;
1485
+ isDefault: boolean;
1486
+ displayLabel: string;
1487
+ last4?: string;
1488
+ eligibleCredentialTypes: string[];
1489
+ }
1490
+ interface ListStripeLinkPaymentMethodsResult {
1491
+ /** Authenticated tenant context, returned so operators can verify a target before writes. */
1492
+ organizationId: string;
1493
+ connectionId: string;
1494
+ /** Masked Link payment methods eligible for the bound agent. */
1495
+ paymentMethods: StripeLinkPaymentMethod[];
1496
+ }
1497
+ type CommerceTotalType = 'subtotal' | 'tax' | 'total' | 'items_base_amount' | 'items_discount' | 'discount' | 'fulfillment' | 'shipping' | 'fee' | 'gift_wrap' | 'tip' | 'store_credit';
1498
+ interface CommerceLineItemInput {
1499
+ name: string;
1500
+ quantity: number;
1501
+ unitAmountMinor: number;
1502
+ description?: string;
1503
+ sku?: string;
1504
+ productUrl?: string;
1505
+ }
1506
+ interface CommerceTotalInput {
1507
+ type: CommerceTotalType;
1508
+ label: string;
1509
+ amountMinor: number;
1510
+ }
1511
+ interface CommerceFulfillmentInput {
1512
+ recipient?: string;
1513
+ addressLine1?: string;
1514
+ addressLine2?: string;
1515
+ locality?: string;
1516
+ region?: string;
1517
+ postalCode?: string;
1518
+ countryCode?: string;
1519
+ }
1520
+ /** Exact Stripe Link purchase intent evaluated and bound by Conto policy. */
1521
+ interface BeginCommerceExecutionCommonInput {
1522
+ /** Stable key for this exact intent. Reuse it when reconciling or retrying begin. */
1523
+ idempotencyKey: string;
1524
+ intentId?: string;
1525
+ /** Integer amount in minor units (cents). */
1526
+ amountMinor: number;
1527
+ currency: 'USD';
1528
+ purpose: string;
1529
+ /** Optional semantic policy category, such as OFFICE_SUPPLIES. */
1530
+ category?: string;
1531
+ cart: {
1532
+ lineItems: CommerceLineItemInput[];
1533
+ totals: CommerceTotalInput[];
1534
+ fulfillment?: CommerceFulfillmentInput;
1535
+ };
1536
+ providerPresentation: {
1537
+ approvalSummary: string;
1538
+ lineItemLabels: string[];
1539
+ };
1540
+ }
1541
+ type AgentCheckoutActionKind = 'INITIATE_CHECKOUT' | 'OPEN_LINK' | 'CONFIRM_PAYMENT' | 'PLACE_ORDER';
1542
+ interface BrowserCheckoutAction {
1543
+ kind: AgentCheckoutActionKind;
1544
+ checkoutMethod: CommerceCheckoutMethod;
1545
+ pageUrl: string;
1546
+ /** Runtime-generated fingerprint of the exact DOM/action target. */
1547
+ targetFingerprint: string;
1548
+ targetUrl?: string;
1549
+ targetLabel?: string;
1550
+ }
1551
+ interface AgentCheckoutAction extends Omit<BrowserCheckoutAction, 'checkoutMethod'> {
1552
+ /** @deprecated Compatibility marker for executionMethod: 'AGENT_CHECKOUT'. */
1553
+ provider: 'STRIPE_LINK';
1554
+ checkoutMethod?: CommerceCheckoutMethod;
1555
+ }
1556
+ type BeginConnectedLinkExecutionInput = BeginCommerceExecutionCommonInput & {
1557
+ connectionId: string;
1558
+ paymentMethodId: string;
1559
+ };
1560
+ type BeginCommerceExecutionInput = (BeginConnectedLinkExecutionInput & {
1561
+ /** Primary path: the server resolves the immutable Stripe seller profile. */
1562
+ executionMethod: 'STRIPE_PAYMENT_INTENT';
1563
+ counterparty: {
1564
+ canonicalId: string;
1565
+ displayName: string;
1566
+ };
1567
+ }) | (BeginConnectedLinkExecutionInput & {
1568
+ /** Optional compatibility transport for a configured MPP merchant. */
1569
+ executionMethod?: 'MPP';
1570
+ counterparty: {
1571
+ canonicalId: string;
1572
+ displayName: string;
1573
+ checkoutUrl: string;
1574
+ mppNetworkId: string;
1575
+ };
1576
+ }) | (BeginCommerceExecutionCommonInput & {
1577
+ /** Public Stripe-hosted Checkout with Link offered when eligible. */
1578
+ executionMethod: 'LINK_CHECKOUT';
1579
+ counterparty: {
1580
+ /** Identifier for the merchant profile configured by the Conto operator. */
1581
+ canonicalId: string;
1582
+ };
1583
+ }) | (BeginCommerceExecutionCommonInput & {
1584
+ /** Merchant-independent guard for an exact privileged browser action. */
1585
+ executionMethod: 'AGENT_CHECKOUT';
1586
+ browserSessionId: string;
1587
+ action: AgentCheckoutAction;
1588
+ counterparty: {
1589
+ canonicalId: string;
1590
+ displayName: string;
1591
+ checkoutUrl: string;
1592
+ };
1593
+ }) | (BeginCommerceExecutionCommonInput & {
1594
+ /** Provider-neutral guard for one exact privileged browser action. */
1595
+ executionMethod: 'BROWSER_CHECKOUT';
1596
+ browserSessionId: string;
1597
+ action: BrowserCheckoutAction;
1598
+ counterparty: {
1599
+ canonicalId: string;
1600
+ displayName: string;
1601
+ checkoutUrl: string;
1602
+ };
1603
+ });
1604
+ type CommerceExecutionStatus = 'DRAFT' | 'ACTION_REQUIRED' | 'AUTHORIZING' | 'AWAITING_APPROVAL' | 'READY' | 'PROCESSING' | 'SETTLED' | 'COMPLETED' | 'DENIED' | 'CANCELLED' | 'FAILED' | 'RETURNED' | 'EXPIRED' | 'NEEDS_RECONCILIATION';
1605
+ type CommerceExecutionProvider = 'STABLECOIN' | 'TOKENIZED_CARD' | 'STRIPE_LINK';
1606
+ type CommerceExecutionChannel = 'BROWSER' | 'MERCHANT_API' | 'CREDENTIAL_BROKER' | 'BANK_API' | 'WALLET_SIGNER';
1607
+ type CommerceCheckoutMethod = 'LINK' | 'CARD' | 'SHOP_PAY' | 'PAYPAL';
1608
+ type CommerceSettlementRail = 'CARD' | 'ACH' | 'WIRE' | 'STABLECOIN';
1609
+ type CommerceProposalState = 'DRAFT' | 'NEEDS_CONTEXT' | 'READY_FOR_POLICY' | 'CANCELLED';
1610
+ type CommerceProposalMissingFact = 'AGENT' | 'AMOUNT' | 'CURRENCY' | 'PURPOSE' | 'COUNTERPARTY_ID' | 'COUNTERPARTY_NAME' | 'CART_LINE_ITEMS' | 'CART_TOTAL' | 'PROVIDER_PRESENTATION';
1611
+ type CommerceFactSource = 'USER_ASSERTED' | 'AGENT_INFERRED' | 'BROWSER_OBSERVED' | 'MERCHANT_SIGNED' | 'PROVIDER_CONFIRMED' | 'ISSUER_CONFIRMED';
1612
+ type CommerceFactConfidence = 'LOW' | 'MEDIUM' | 'HIGH' | 'VERIFIED';
1613
+ type CommerceProposalFactKey = 'AMOUNT' | 'CURRENCY' | 'PURPOSE' | 'CATEGORY' | 'COUNTERPARTY' | 'CART' | 'EXECUTION';
1614
+ interface CommerceFactProvenanceInput {
1615
+ source: CommerceFactSource;
1616
+ confidence: CommerceFactConfidence;
1617
+ observedAt?: string;
1618
+ evidenceFingerprint?: string;
1619
+ }
1620
+ interface NormalizeCommerceProposalInput {
1621
+ /** Stable caller-selected key for this evolving proposal. */
1622
+ proposalKey: string;
1623
+ proposalId?: string;
1624
+ /** Zero for a caller-confirmed create, or the exact revision being replaced. */
1625
+ expectedRevision?: number;
1626
+ draft?: boolean;
1627
+ amountMinor?: number;
1628
+ maximumAmountMinor?: number;
1629
+ currency?: string;
1630
+ purpose?: string;
1631
+ category?: string;
1632
+ counterparty?: {
1633
+ canonicalId?: string;
1634
+ displayName?: string;
1635
+ checkoutUrl?: string;
1636
+ };
1637
+ cart?: {
1638
+ lineItems?: CommerceLineItemInput[];
1639
+ totals?: CommerceTotalInput[];
1640
+ fulfillment?: CommerceFulfillmentInput;
1641
+ };
1642
+ providerPresentation?: {
1643
+ approvalSummary: string;
1644
+ lineItemLabels: string[];
1645
+ };
1646
+ execution?: {
1647
+ executionChannel?: CommerceExecutionChannel;
1648
+ checkoutMethod?: CommerceCheckoutMethod;
1649
+ settlementRail?: CommerceSettlementRail;
1650
+ };
1651
+ provenance?: Partial<Record<CommerceProposalFactKey, CommerceFactProvenanceInput>>;
1652
+ /** Organization-registered semantic facts validated before policy evaluation. */
1653
+ extensions?: Array<{
1654
+ namespace: string;
1655
+ value: unknown;
1656
+ }>;
1657
+ }
1658
+ interface CommerceContextRequirement {
1659
+ fact: CommerceProposalMissingFact;
1660
+ reasonCode: `MISSING_${CommerceProposalMissingFact}`;
1661
+ prompt: string;
1662
+ }
1663
+ interface CommerceProposalResolution {
1664
+ proposal: {
1665
+ id: string;
1666
+ organizationId: string;
1667
+ actorUserId: string;
1668
+ agentId?: string;
1669
+ state: CommerceProposalState;
1670
+ amountMinor?: number;
1671
+ maximumAmountMinor?: number;
1672
+ currency?: string;
1673
+ purpose?: string;
1674
+ category?: string;
1675
+ counterparty?: NormalizeCommerceProposalInput['counterparty'];
1676
+ cart?: NormalizeCommerceProposalInput['cart'];
1677
+ providerPresentation?: NormalizeCommerceProposalInput['providerPresentation'];
1678
+ execution?: NormalizeCommerceProposalInput['execution'];
1679
+ provenance: Partial<Record<CommerceProposalFactKey, CommerceFactProvenanceInput>>;
1680
+ extensions: Array<{
1681
+ namespace: string;
1682
+ value: unknown;
1683
+ schemaRevision?: number;
1684
+ schemaFingerprint?: string;
1685
+ }>;
1686
+ missingFacts: CommerceProposalMissingFact[];
1687
+ };
1688
+ proposalFingerprint: string;
1689
+ /** Durable, monotonically increasing proposal revision. */
1690
+ revision: number;
1691
+ /** True only when this request created the proposal head. */
1692
+ created: boolean;
1693
+ outcome: 'NEEDS_CONTEXT' | 'READY_FOR_POLICY';
1694
+ requirements: CommerceContextRequirement[];
1695
+ nextAction: 'COLLECT_CONTEXT' | 'BEGIN_POLICY_EVALUATION';
1696
+ }
1697
+ type CommerceExecutionAdapterKind = 'STABLECOIN' | 'TOKENIZED_CARD' | 'STRIPE_LINK' | 'LINK_CHECKOUT' | 'CHECKOUT_GUARD';
1698
+ type CommerceExecutionSourceKind = 'STABLECOIN_WALLET' | 'TOKENIZED_CARD' | 'STRIPE_LINK' | 'STRIPE_LINK_CHECKOUT' | 'AGENT_BROWSER_CHECKOUT';
1699
+ type CommerceExecutionArtifactKind = 'CARD' | 'LINK_PAY_TOKEN' | 'SHARED_PAYMENT_TOKEN';
1700
+ type CommerceExecutionDeliveryMode = 'SERVER_ONLY_ARTIFACT' | 'PROVIDER_DIRECT' | 'USER_INTERACTIVE';
1701
+ type CommerceExecutionConstraint = 'AMOUNT' | 'CURRENCY' | 'COUNTERPARTY' | 'CART' | 'PURPOSE' | 'EXPIRY' | 'SINGLE_USE';
1702
+ type CommerceExecutionConstraintCoverageLevel = 'UNSUPPORTED' | 'OBSERVE_ONLY' | 'CONTO_PRECHECK' | 'PROVIDER_ENFORCED';
1703
+ type CommerceExecutionConstraintCoverage = Readonly<Record<CommerceExecutionConstraint, CommerceExecutionConstraintCoverageLevel>>;
1704
+ /** Provider-independent, allowlisted evidence. It contains no Link credential material. */
1705
+ interface CommerceExecutionEvidence {
1706
+ schemaVersion: 'conto.commerce-evidence.v1';
1707
+ traceId: string;
1708
+ executionId: string;
1709
+ intentId: string;
1710
+ organizationId: string;
1711
+ actorUserId: string;
1712
+ agentId?: string;
1713
+ provider: CommerceExecutionProvider;
1714
+ sourceKind: CommerceExecutionSourceKind;
1715
+ amountMinor: number;
1716
+ currency: string;
1717
+ purpose: string;
1718
+ counterpartyId: string;
1719
+ counterpartyName: string;
1720
+ intentFingerprint: string;
1721
+ policyDecisionId: string;
1722
+ policySnapshotHash: string;
1723
+ grantId: string;
1724
+ deliveryMode?: CommerceExecutionDeliveryMode;
1725
+ artifactKind?: CommerceExecutionArtifactKind;
1726
+ enforcementCoverage?: CommerceExecutionConstraintCoverage;
1727
+ status: CommerceExecutionStatus;
1728
+ providerStatus?: string;
1729
+ providerReference?: string;
1730
+ transactionReference?: string;
1731
+ checkoutReference?: string;
1732
+ /** Actual method observed after Stripe settlement; Link cannot be forced to display or win. */
1733
+ actualPaymentMethod?: 'LINK' | 'CARD';
1734
+ browserAction?: {
1735
+ kind: AgentCheckoutActionKind;
1736
+ provider: 'STRIPE_LINK';
1737
+ checkoutMethod?: CommerceCheckoutMethod;
1738
+ trustPolicyRevision?: number;
1739
+ trustPolicyFingerprint?: string;
1740
+ merchantOrigin: string;
1741
+ actionFingerprint: string;
1742
+ };
1743
+ refund?: {
1744
+ amountMinor: number;
1745
+ currency: string;
1746
+ state: string;
1747
+ };
1748
+ }
1749
+ /** Safe execution projection. Raw provider responses and payment artifacts are excluded. */
1750
+ interface CommerceExecution {
1751
+ id: string;
1752
+ intentId: string;
1753
+ organizationId: string;
1754
+ agentId?: string;
1755
+ provider: CommerceExecutionProvider;
1756
+ /** Execution path selected before settlement; distinct from actualPaymentMethod. */
1757
+ executionAdapter: CommerceExecutionAdapterKind;
1758
+ /** Provider-neutral channel that must consume the Conto authorization. */
1759
+ executionChannel: CommerceExecutionChannel;
1760
+ /** Selected checkout method, or the method observed after a dynamic checkout settles. */
1761
+ checkoutMethod?: CommerceCheckoutMethod;
1762
+ /** Expected settlement rail when the current execution source establishes it. */
1763
+ settlementRail?: CommerceSettlementRail;
1764
+ status: CommerceExecutionStatus;
1765
+ providerStatus?: string;
1766
+ providerReference?: string;
1767
+ /** Sanitized Link approval or Stripe-hosted Checkout URL. */
1768
+ approvalUrl?: string;
1769
+ artifactKind?: CommerceExecutionArtifactKind;
1770
+ deliveryMode?: CommerceExecutionDeliveryMode;
1771
+ amountMinor: number;
1772
+ currency: string;
1773
+ purpose: string;
1774
+ category?: string;
1775
+ counterparty: {
1776
+ id: string;
1777
+ name: string;
1778
+ };
1779
+ evidence: CommerceExecutionEvidence;
1780
+ evidenceFingerprint: string;
1781
+ }
1782
+ interface CommerceExecutionResult {
1783
+ execution: CommerceExecution;
1784
+ }
1785
+ interface ExecuteCommerceExecutionResult extends CommerceExecutionResult {
1786
+ checkout: {
1787
+ submitted: boolean;
1788
+ deliveryMode: 'SERVER_ONLY_ARTIFACT';
1789
+ accepted: boolean;
1790
+ } | {
1791
+ submitted: true;
1792
+ deliveryMode: 'PROVIDER_DIRECT';
1793
+ };
1794
+ }
1795
+ interface CheckoutActionAuthorization {
1796
+ /** Durable single-use record consumed by the privileged browser runtime. */
1797
+ authorizationId: string;
1798
+ executionId: string;
1799
+ browserSessionId: string;
1800
+ grantId: string;
1801
+ intentFingerprint: string;
1802
+ actionFingerprint: string;
1803
+ merchantOrigin: string;
1804
+ actionKind: AgentCheckoutActionKind;
1805
+ provider: 'STRIPE_LINK';
1806
+ checkoutMethod?: CommerceCheckoutMethod;
1807
+ expiresAt: string;
1808
+ singleUse: true;
1809
+ }
1810
+ interface AuthorizeCheckoutActionResult extends CommerceExecutionResult {
1811
+ authorization: CheckoutActionAuthorization;
1812
+ }
1813
+ interface BrowserActionClaimResult {
1814
+ authorization: {
1815
+ authorizationId: string;
1816
+ state: 'DISPATCHING';
1817
+ actionFingerprint: string;
1818
+ expiresAt: string;
1819
+ };
1820
+ }
1821
+ interface BrowserActionFinalizeResult {
1822
+ authorization: {
1823
+ authorizationId: string;
1824
+ state: 'CONSUMED' | 'INDETERMINATE';
1825
+ };
1826
+ }
1827
+ interface BrowserActionDispatchObservationInput {
1828
+ reference: string;
1829
+ observedAt: string;
1830
+ pageUrl: string;
1831
+ }
1832
+ interface GuardCheckoutResult<T> extends AuthorizeCheckoutActionResult {
1833
+ result: T;
1834
+ }
1835
+ interface GuardedBrowserDispatchResult<T> {
1836
+ result: T;
1837
+ observation: BrowserActionDispatchObservationInput;
1838
+ }
1839
+ type GuardedCheckoutInput = Extract<BeginCommerceExecutionInput, {
1840
+ executionMethod: 'AGENT_CHECKOUT' | 'BROWSER_CHECKOUT';
1841
+ }>;
1842
+ /** Privileged runtime port; the agent model must not receive this driver directly. */
1843
+ interface PrivilegedBrowserCheckoutDriver<T> {
1844
+ dispatch(input: {
1845
+ authorization: CheckoutActionAuthorization;
1846
+ browserSessionId: string;
1847
+ action: AgentCheckoutAction | BrowserCheckoutAction;
1848
+ }): Promise<GuardedBrowserDispatchResult<T>>;
1849
+ }
1850
+ interface RunGuardedCheckoutResult<T> extends GuardCheckoutResult<T> {
1851
+ dispatchAttemptId: string;
1852
+ observation: BrowserActionDispatchObservationInput;
1853
+ }
1066
1854
  interface ProtocolPreAuthorizeResult {
1067
1855
  authorized: boolean;
1068
1856
  decision: 'approved' | 'declined' | 'review_required';
1069
1857
  message: string;
1858
+ /**
1859
+ * Present when authorized. Pass grantId and grantSignature to record(). A
1860
+ * record without a valid, unexpired grant is accepted but treated as a policy
1861
+ * bypass: the payment is flagged and the owner is alerted. The organization
1862
+ * can also have the agent frozen automatically.
1863
+ */
1864
+ grantId?: string;
1865
+ grantSignature?: string;
1866
+ /** ISO timestamp. Record the payment before this time. */
1867
+ grantExpiresAt?: string;
1868
+ }
1869
+ interface ProtocolRecordGrant {
1870
+ /** grantId from the approved preAuthorize() response. */
1871
+ grantId?: string;
1872
+ /** grantSignature from the approved preAuthorize() response. */
1873
+ grantSignature?: string;
1874
+ }
1875
+ interface ProtocolRecordGrantResult {
1876
+ /** Grant consumed by this record. */
1877
+ grantId?: string;
1878
+ /** True when the payment was recorded without a valid grant. */
1879
+ policyBypass?: true;
1880
+ bypassReason?: 'GRANT_MISSING' | 'GRANT_INVALID' | 'GRANT_EXPIRED';
1881
+ /** True when the organization freezes agents on bypass and this record froze it. */
1882
+ agentFrozen?: boolean;
1070
1883
  }
1071
1884
  interface X402PreAuthorizeInput {
1072
1885
  amount: number;
@@ -1076,8 +1889,15 @@ interface X402PreAuthorizeInput {
1076
1889
  department?: string;
1077
1890
  project?: string;
1078
1891
  };
1892
+ facilitator?: string;
1893
+ scheme?: string;
1079
1894
  /** Customer-supplied ID used to group authorization, recording, and spend reporting. */
1080
1895
  sessionId?: string;
1896
+ paymentId?: string;
1897
+ /** Exact wallet address that will sign. Provide together with network. */
1898
+ payerAddress?: string;
1899
+ /** CAIP-2 network from the x402 challenge, for example eip155:8453. */
1900
+ network?: string;
1081
1901
  }
1082
1902
  interface X402PreAuthorizeResult extends ProtocolPreAuthorizeResult {
1083
1903
  x402: {
@@ -1086,7 +1906,55 @@ interface X402PreAuthorizeResult extends ProtocolPreAuthorizeResult {
1086
1906
  sessionId?: string;
1087
1907
  };
1088
1908
  }
1089
- interface X402RecordInput {
1909
+ /** The accepted entry from a 402 challenge (x402 "exact" scheme on EVM). */
1910
+ interface X402PaymentRequirements {
1911
+ scheme: 'exact' | (string & {});
1912
+ /** Network as the challenge sent it: CAIP-2 (eip155:8453) or an x402 v1 name (base). */
1913
+ network: string;
1914
+ /** v1: amount in token base units, as an integer string. */
1915
+ maxAmountRequired?: string;
1916
+ /** v2: amount in token base units, as an integer string. */
1917
+ amount?: string;
1918
+ /** Token contract. Conto signs only for managed USDC. */
1919
+ asset: string;
1920
+ payTo: string;
1921
+ maxTimeoutSeconds: number;
1922
+ resource?: string;
1923
+ /** EIP-712 domain of the token. */
1924
+ extra?: {
1925
+ name?: string;
1926
+ version?: string;
1927
+ [key: string]: unknown;
1928
+ };
1929
+ [key: string]: unknown;
1930
+ }
1931
+ interface X402PayInput extends X402PreAuthorizeInput {
1932
+ /** x402 protocol version of the challenge. Defaults to 1. */
1933
+ x402Version?: 1 | 2;
1934
+ paymentRequirements: X402PaymentRequirements;
1935
+ }
1936
+ interface X402Authorization {
1937
+ from: string;
1938
+ to: string;
1939
+ value: string;
1940
+ validAfter: string;
1941
+ validBefore: string;
1942
+ nonce: string;
1943
+ }
1944
+ interface X402PayResult extends ProtocolPreAuthorizeResult {
1945
+ x402: {
1946
+ serviceDomain?: string;
1947
+ amount: number;
1948
+ sessionId?: string;
1949
+ };
1950
+ /** Present when authorized: send as this header when retrying the resource request. */
1951
+ paymentHeaderName?: 'X-PAYMENT' | 'PAYMENT-SIGNATURE';
1952
+ /** Present when authorized: base64 payment payload signed by Conto. */
1953
+ xPaymentHeader?: string;
1954
+ /** Present when authorized: the EIP-3009 authorization Conto signed. */
1955
+ authorization?: X402Authorization;
1956
+ }
1957
+ interface X402RecordInput extends ProtocolRecordGrant {
1090
1958
  amount: number;
1091
1959
  currency?: string;
1092
1960
  recipientAddress: string;
@@ -1096,6 +1964,10 @@ interface X402RecordInput {
1096
1964
  paymentId: string;
1097
1965
  /** Customer-supplied ID used to group related x402 payments. */
1098
1966
  sessionId?: string;
1967
+ /** Exact wallet address that signed. Provide together with network. */
1968
+ payerAddress?: string;
1969
+ /** CAIP-2 network from the x402 challenge, for example eip155:8453. */
1970
+ network?: string;
1099
1971
  context?: {
1100
1972
  department?: string;
1101
1973
  project?: string;
@@ -1106,7 +1978,7 @@ interface X402RecordInput {
1106
1978
  paymentId: string;
1107
1979
  }>;
1108
1980
  }
1109
- interface X402RecordResult {
1981
+ interface X402RecordResult extends ProtocolRecordGrantResult {
1110
1982
  recorded: true;
1111
1983
  confirmed: true;
1112
1984
  txHash: string;
@@ -1125,6 +1997,10 @@ interface MppPreAuthorizeInput {
1125
1997
  depositAmount?: number;
1126
1998
  /** Customer-supplied ID used to group authorization, recording, and spend reporting. */
1127
1999
  sessionId?: string;
2000
+ scheme?: string;
2001
+ credentialId?: string;
2002
+ challengeId?: string;
2003
+ paymentMethod?: string;
1128
2004
  }
1129
2005
  interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
1130
2006
  mpp: {
@@ -1133,7 +2009,7 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
1133
2009
  sessionId?: string;
1134
2010
  };
1135
2011
  }
1136
- interface MppRecordInput {
2012
+ interface MppRecordInput extends ProtocolRecordGrant {
1137
2013
  amount: number;
1138
2014
  currency?: string;
1139
2015
  recipientAddress: string;
@@ -1149,13 +2025,17 @@ interface MppRecordInput {
1149
2025
  };
1150
2026
  paymentReceipt?: string;
1151
2027
  intent?: 'charge' | 'session';
2028
+ scheme?: string;
2029
+ challengeId?: string;
2030
+ paymentMethod?: string;
2031
+ depositAmount?: number;
1152
2032
  batchItems?: Array<{
1153
2033
  amount: number;
1154
2034
  resourceUrl: string;
1155
2035
  credentialId: string;
1156
2036
  }>;
1157
2037
  }
1158
- interface MppRecordResult {
2038
+ interface MppRecordResult extends ProtocolRecordGrantResult {
1159
2039
  recorded: true;
1160
2040
  txHash?: string;
1161
2041
  explorerUrl?: string;
@@ -1226,6 +2106,8 @@ declare class ContoError extends Error {
1226
2106
  readonly retryAfter?: number;
1227
2107
  readonly retryGuidance?: string;
1228
2108
  readonly actionUrl?: string;
2109
+ readonly fieldErrors?: ApiErrorMetadata['fieldErrors'];
2110
+ readonly reasons?: string[];
1229
2111
  constructor(message: string, metadata: ApiErrorMetadata);
1230
2112
  }
1231
2113
  /**
@@ -1238,6 +2120,23 @@ declare class ExternalCardConfirmationPendingError<TReceipt = unknown> extends C
1238
2120
  readonly receipt: TReceipt;
1239
2121
  constructor(requestId: string, confirmationInput: ExternalCardConfirmationInput, receipt: TReceipt);
1240
2122
  }
2123
+ /**
2124
+ * The privileged browser action ran, but Conto did not acknowledge its final
2125
+ * observation. Retry finalizeBrowserAction with these exact fields; never run
2126
+ * the browser action again.
2127
+ */
2128
+ declare class BrowserActionFinalizationPendingError<TResult = unknown> extends ContoError {
2129
+ readonly authorizationId: string;
2130
+ readonly dispatchAttemptId: string;
2131
+ readonly result: TResult;
2132
+ readonly observation: BrowserActionDispatchObservationInput;
2133
+ constructor(input: {
2134
+ authorizationId: string;
2135
+ dispatchAttemptId: string;
2136
+ result: TResult;
2137
+ observation: BrowserActionDispatchObservationInput;
2138
+ });
2139
+ }
1241
2140
  interface ContoRequestOptions {
1242
2141
  /** Set only when repeating this request cannot create an additional side effect. */
1243
2142
  idempotent?: boolean;
@@ -1250,10 +2149,85 @@ declare class Conto {
1250
2149
  private timeout;
1251
2150
  payments: PaymentsClient;
1252
2151
  cards: CardsClient;
2152
+ connectedCards: ConnectedCardsClient;
1253
2153
  x402: X402Client;
1254
2154
  mpp: MppClient;
1255
2155
  constructor(config: ContoConfig);
1256
- /** Make an authenticated request to the Giro API */
2156
+ /**
2157
+ * List masked Link payment methods for a session-created connection that is
2158
+ * explicitly bound to this agent. No Link token or payment artifact is
2159
+ * returned through the agent SDK.
2160
+ */
2161
+ listStripeLinkPaymentMethods(connectionId: string): Promise<ListStripeLinkPaymentMethodsResult>;
2162
+ /**
2163
+ * Normalize and durably revise a partial agent purchase proposal without
2164
+ * creating a payment side effect. Missing facts return as NEEDS_CONTEXT
2165
+ * requirements; changed writes require the exact prior revision.
2166
+ */
2167
+ normalizeCommerceProposal(input: NormalizeCommerceProposalInput): Promise<CommerceProposalResolution>;
2168
+ /** Reload one durable proposal head in this agent and tenant scope. */
2169
+ getCommerceProposal(proposalId: string): Promise<CommerceProposalResolution>;
2170
+ /**
2171
+ * Evaluate policy and begin one exact Stripe Link commerce intent.
2172
+ *
2173
+ * The stable idempotency key makes transport retries safe. Reusing it with a
2174
+ * different intent is rejected by the API.
2175
+ */
2176
+ beginCommerceExecution(input: BeginCommerceExecutionInput): Promise<CommerceExecutionResult>;
2177
+ /** Atomically consume the Conto authorization for one exact browser action. */
2178
+ authorizeCheckoutAction(executionId: string, browserSessionId: string, action: AgentCheckoutAction | BrowserCheckoutAction): Promise<AuthorizeCheckoutActionResult>;
2179
+ /** Claim a durable browser action for one stable privileged-runtime attempt. */
2180
+ claimBrowserAction(authorizationId: string, dispatchAttemptId: string, browserSessionId: string, action: AgentCheckoutAction | BrowserCheckoutAction): Promise<BrowserActionClaimResult>;
2181
+ /** Finalize the exact dispatch attempt; this never performs the browser side effect. */
2182
+ finalizeBrowserAction(authorizationId: string, input: {
2183
+ dispatchAttemptId: string;
2184
+ outcome: 'CONSUMED' | 'INDETERMINATE';
2185
+ observation?: BrowserActionDispatchObservationInput;
2186
+ }): Promise<BrowserActionFinalizeResult>;
2187
+ /**
2188
+ * Own the complete privileged-browser enforcement sequence. The stable
2189
+ * dispatchAttemptId must be persisted by the runtime before this call.
2190
+ */
2191
+ runGuardedCheckout<T>(input: GuardedCheckoutInput, runtime: {
2192
+ dispatchAttemptId: string;
2193
+ execute: (authorization: CheckoutActionAuthorization) => Promise<GuardedBrowserDispatchResult<T>>;
2194
+ }): Promise<RunGuardedCheckoutResult<T>>;
2195
+ /**
2196
+ * Reference privileged-driver integration. Only this wrapper should be
2197
+ * exposed as the agent's payment-sensitive browser tool.
2198
+ */
2199
+ runGuardedCheckoutWithDriver<T>(input: GuardedCheckoutInput, runtime: {
2200
+ dispatchAttemptId: string;
2201
+ driver: PrivilegedBrowserCheckoutDriver<T>;
2202
+ }): Promise<RunGuardedCheckoutResult<T>>;
2203
+ /**
2204
+ * Policy-check and authorize an exact action before invoking a legacy callback.
2205
+ * @deprecated Use runGuardedCheckout so the durable claim and final
2206
+ * observation cannot be omitted.
2207
+ */
2208
+ guardCheckout<T>(input: GuardedCheckoutInput, executor: (authorization: CheckoutActionAuthorization) => Promise<T>): Promise<GuardCheckoutResult<T>>;
2209
+ /** Read one agent-scoped commerce execution and its normalized evidence. */
2210
+ getCommerceExecution(executionId: string): Promise<CommerceExecutionResult>;
2211
+ /**
2212
+ * Observe Link state and reconcile terminal accounting. This operation is
2213
+ * safe to retry because it does not request another checkout execution.
2214
+ */
2215
+ refreshCommerceExecution(executionId: string): Promise<CommerceExecutionResult>;
2216
+ /**
2217
+ * Execute the approved provider-direct or server-only checkout handoff. Transport retries are
2218
+ * deliberately disabled. Read or refresh the execution after an ambiguous
2219
+ * failure before taking another execution action.
2220
+ */
2221
+ executeCommerceExecution(executionId: string): Promise<ExecuteCommerceExecutionResult>;
2222
+ /**
2223
+ * Request cancellation and release reserved spend after Link confirms it.
2224
+ * Transport retries are disabled because a lost provider response requires
2225
+ * reconciliation.
2226
+ */
2227
+ cancelCommerceExecution(executionId: string): Promise<CommerceExecutionResult>;
2228
+ /** Read credentials, linked wallets, effective policies, and scopes without creating a payment. */
2229
+ setup(): Promise<AgentSetupResult>;
2230
+ /** Make an authenticated request to the Conto API */
1257
2231
  request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
1258
2232
  }
1259
2233
  /** Agent client for the cooperative external-card policy overlay. */
@@ -1290,9 +2264,76 @@ declare class ControlledExternalCardPaymentTool<TReceipt = unknown> {
1290
2264
  constructor(cardsClient: CardsClient, executor: ExternalCardExecutor<TReceipt>);
1291
2265
  pay(input: ExternalCardApprovalInput): Promise<ControlledExternalCardPaymentResult<TReceipt>>;
1292
2266
  }
2267
+ /**
2268
+ * Agent client for connected cards (gated pilot).
2269
+ *
2270
+ * A connected card is a customer card enrolled through the provider and
2271
+ * delegated to this agent. `draw` mints one single-use credential against a
2272
+ * verified mandate; `list` returns the masked cards and mandates the agent may
2273
+ * draw against. This is a separate rail from {@link CardsClient}: it does not
2274
+ * share endpoints, scopes, or types with the external-card policy overlay.
2275
+ *
2276
+ * These methods return 404 until the tenant is enabled for the pilot.
2277
+ */
2278
+ declare class ConnectedCardsClient {
2279
+ private client;
2280
+ constructor(client: Conto);
2281
+ /**
2282
+ * Draw one single-use card credential against a verified mandate.
2283
+ *
2284
+ * On an APPROVED, minted draw the result carries live card material in
2285
+ * `credential`, returned exactly ONCE.
2286
+ *
2287
+ * CREDENTIAL SAFETY (load-bearing): the credential is the real, usable card.
2288
+ * It is revealed a single time and cannot be re-fetched. Use it in-process at
2289
+ * the intended merchant checkout only. Never log, print, serialize, persist,
2290
+ * cache, or forward it, and never place it in an error, a monitoring event,
2291
+ * or any other sink. See {@link ConnectedCardCredential}.
2292
+ *
2293
+ * Transport-level retry is deliberately OFF for this call. The server is
2294
+ * idempotent on `idempotencyKey`, so an automatic retry after a successful
2295
+ * mint would replay the draw and return the decision WITHOUT the credential,
2296
+ * silently losing the one-shot card material. If a `draw` fails ambiguously,
2297
+ * do not blindly retry: check the outcome, and reuse the same
2298
+ * `idempotencyKey` only to reconcile the same draw.
2299
+ *
2300
+ * @example
2301
+ * ```typescript
2302
+ * const draw = await conto.connectedCards.draw({
2303
+ * cardId: 'cmm59z8fj000l49h7bjqza11p',
2304
+ * mandateId: 'cmm5a1b2c000m49h7defgh22q',
2305
+ * idempotencyKey: 'checkout_01J8...',
2306
+ * amountMinor: 4999,
2307
+ * merchant: { merchantName: 'Example Store', merchantCategory: '5311' },
2308
+ * });
2309
+ * if (draw.decision === 'APPROVED' && draw.credential) {
2310
+ * // Keep the credential in memory, acknowledge receipt, then use it at checkout.
2311
+ * await conto.connectedCards.acknowledgeDelivery(draw.requestId);
2312
+ * // Do not log or store draw.credential.
2313
+ * }
2314
+ * ```
2315
+ */
2316
+ draw(input: ConnectedCardDrawInput): Promise<ConnectedCardDrawResult>;
2317
+ /**
2318
+ * List the connected cards and active mandates this agent may draw against.
2319
+ *
2320
+ * The response is masked: no PAN and no provider tokens. This is a read-only
2321
+ * GET, so transport retry on transient failures is safe.
2322
+ */
2323
+ /** Record receipt after a fresh draw. Does not confirm checkout or payment settlement. */
2324
+ acknowledgeDelivery(requestId: string): Promise<{
2325
+ acknowledged: boolean;
2326
+ settlementVerified: false;
2327
+ }>;
2328
+ list(): Promise<ConnectedCardListResult>;
2329
+ }
1293
2330
  /** Client for payment operations */
1294
2331
  declare class PaymentsClient {
1295
2332
  private client;
2333
+ /** Authorize an externally signed transfer. This write is not automatically retried. */
2334
+ approve(input: ExternalWalletApprovalInput): Promise<ExternalWalletApprovalResult>;
2335
+ /** Record an existing transfer. Never sends funds; reconcile conflicts using status(). */
2336
+ confirm(requestId: string, input: ExternalWalletConfirmationInput): Promise<ExternalWalletConfirmationResult>;
1296
2337
  constructor(client: Conto);
1297
2338
  /**
1298
2339
  * Request authorization for a payment.
@@ -1388,6 +2429,16 @@ declare class X402Client {
1388
2429
  private client;
1389
2430
  constructor(client: Conto);
1390
2431
  preAuthorize(input: X402PreAuthorizeInput): Promise<X402PreAuthorizeResult>;
2432
+ /**
2433
+ * Conto-signed x402 for Privy-managed EVM wallets. Conto evaluates the
2434
+ * payment exactly like preAuthorize() and, only when approved, signs the
2435
+ * EIP-3009 authorization for the approved payee and amount. Retry the
2436
+ * resource request with `paymentHeaderName: xPaymentHeader`, then call
2437
+ * record() with the returned grant. Not retried automatically: a grant is
2438
+ * signed at most once, and a repeat returns 409 GRANT_ALREADY_SIGNED.
2439
+ * External wallets get 409 MANAGED_SIGNING_UNAVAILABLE; use preAuthorize().
2440
+ */
2441
+ pay(input: X402PayInput): Promise<X402PayResult>;
1391
2442
  record(input: X402RecordInput): Promise<X402RecordResult>;
1392
2443
  budget(options?: {
1393
2444
  sessionId?: string;
@@ -1411,4 +2462,4 @@ declare class MppClient {
1411
2462
  }): Promise<ProtocolServicesResult>;
1412
2463
  }
1413
2464
 
1414
- export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentExternalCard, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, CardsClient, type ChainType, Conto, ContoAdmin, type ContoAdminConfig, ContoAdminError, type ContoConfig, ContoError, type ContoRequestOptions, type ControlledExternalCardPaymentResult, ControlledExternalCardPaymentTool, type CreateAgentInput, type CreatePolicyInput, type CreatePolicyRuleInput, type CreateSdkKeyInput, type CreateSdkKeyResult, type CreateWalletInput, type CustodyType, type CustomerCustodyMode, type DelegationType, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RuleAction, type RuleOperator, type RuleType, type SdkKey, type SdkKeyType, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402BudgetResult, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, Conto as default };
2465
+ export { type AdminExternalCardOverlayEnforcement, type Agent, type AgentCheckoutAction, type AgentCheckoutActionKind, type AgentExternalCard, type AgentSetupResult, type AgentStatus, type AgentType, type AgentWalletLink, type ApprovedExternalCardExecution, type AssignExternalCardInput, type AssignedPolicy, type AuthorizeCheckoutActionResult, type BeginCommerceExecutionInput, type BrowserActionClaimResult, type BrowserActionDispatchObservationInput, BrowserActionFinalizationPendingError, type BrowserActionFinalizeResult, type BrowserCheckoutAction, type BrowserCheckoutTargetResolver, type BrowserCheckoutTargetSnapshot, type BrowserCheckoutTargetVerificationCode, BrowserCheckoutTargetVerificationError, type CanonicalBrowserCheckoutTargetSnapshot, CardsClient, type ChainType, type CheckoutActionAuthorization, type CommerceCheckoutMethod, type CommerceContextRequirement, type CommerceExecution, type CommerceExecutionAdapterKind, type CommerceExecutionArtifactKind, type CommerceExecutionChannel, type CommerceExecutionConstraint, type CommerceExecutionConstraintCoverage, type CommerceExecutionConstraintCoverageLevel, type CommerceExecutionDeliveryMode, type CommerceExecutionEvidence, type CommerceExecutionProvider, type CommerceExecutionResult, type CommerceExecutionSourceKind, type CommerceExecutionStatus, type CommerceFactConfidence, type CommerceFactProvenanceInput, type CommerceFactSource, type CommerceFulfillmentInput, type CommerceLineItemInput, type CommerceProposalFactKey, type CommerceProposalMissingFact, type CommerceProposalResolution, type CommerceProposalState, type CommerceSettlementRail, type CommerceTotalInput, type CommerceTotalType, type ComparePolicyVersionsResponse, type ConnectedCardBrief, type ConnectedCardCredential, type ConnectedCardDrawInput, type ConnectedCardDrawMerchant, type ConnectedCardDrawResult, type ConnectedCardDrawable, type ConnectedCardListResult, type ConnectedCardMandate, type ConnectedCardMandateMerchant, type ConnectedCardReference, ConnectedCardsClient, Conto, ContoAdmin, type ContoAdminConfig, ContoAdminError, type ContoConfig, ContoError, type ContoRequestOptions, type ControlledExternalCardPaymentResult, ControlledExternalCardPaymentTool, type CreateAgentInput, type CreatePolicyInput, type CreatePolicyRuleInput, type CreateSdkKeyInput, type CreateSdkKeyResult, type CreateWalletInput, type CustodyType, type CustomerCustodyMode, type CustomerWalletControlModel, type CustomerWalletKeyAccess, type DelegationType, type ExecuteCommerceExecutionResult, type ExternalCard, type ExternalCardApprovalInput, type ExternalCardApprovalResult, type ExternalCardConfirmationInput, ExternalCardConfirmationPendingError, type ExternalCardConfirmationResult, type ExternalCardExecutionClaimResult, type ExternalCardExecutionResult, type ExternalCardExecutor, type ExternalCardOverlayEnforcement, type ExternalCardRequestStatusResult, type ExternalWalletApprovalInput, type ExternalWalletApprovalResult, type ExternalWalletConfirmationInput, type ExternalWalletConfirmationResult, type FreezeAgentInput, Conto as Giro, type ContoConfig as GiroConfig, ContoError as GiroError, type GuardCheckoutResult, type GuardedBrowserDispatchResult, type GuardedCheckoutInput, type LinkWalletInput, type ListAgentsParams, type ListAgentsResponse, type ListPoliciesParams, type ListPoliciesResponse, type ListPolicyVersionsResponse, type ListStripeLinkPaymentMethodsResult, type ListWalletsParams, type ListWalletsResponse, type MppBudgetResult, type MppPreAuthorizeInput, type MppPreAuthorizeResult, type MppRecordInput, type MppRecordResult, type NormalizeCommerceProposalInput, type OrganizationMember, type PaginatedResponse, type PaginationParams, type PauseExternalCardAssignmentResult, type PaymentExecuteResult, type PaymentRequestInput, type PaymentRequestResult, type PaymentStatusResult, type Policy, type PolicyRule, type PolicyType, type PolicyVersionChangeType, type PolicyVersionDetail, type PolicyVersionDiff, type PolicyVersionFieldChange, type PolicyVersionSnapshot, type PolicyVersionSnapshotRule, type PolicyVersionSummary, type PrivilegedBrowserCheckoutDriver, type ProtocolBudgetResult, type ProtocolPreAuthorizeResult, type ProtocolRecordGrant, type ProtocolRecordGrantResult, type ProtocolServiceSummary, type ProtocolServicesResult, type ProvisionWalletResult, type RefreshBalanceResult, type RegisterExternalCardInput, type RollbackPolicyVersionResponse, type RuleAction, type RuleOperator, type RuleType, type RunGuardedCheckoutResult, type SdkKey, type SdkKeyType, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type UnfreezeAgentInput, type UpdateAgentInput, type UpdateExternalCardAssignmentInput, type UpdatePolicyInput, type UpdatePolicyRuleInput, type UpdateWalletInput, type VerifiedBrowserCheckoutTarget, type Wallet, type WalletChainBalanceSnapshot, type WalletStatus, type WalletType, type X402Authorization, type X402BudgetResult, type X402PayInput, type X402PayResult, type X402PaymentRequirements, type X402PreAuthorizeInput, type X402PreAuthorizeResult, type X402RecordInput, type X402RecordResult, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget };