@conto_finance/sdk 0.5.3 → 0.5.5

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.
@@ -69,6 +69,7 @@ interface BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig {
69
69
  maxSessions?: number;
70
70
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
71
71
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
72
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
72
73
  /** Dedicated service credential. Conto and Browserbase API keys are rejected. */
73
74
  token: string;
74
75
  maxBodyBytes?: number;
@@ -69,6 +69,7 @@ interface BrowserbaseGuardedPlaywrightCheckoutRuntimeHostConfig {
69
69
  maxSessions?: number;
70
70
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
71
71
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
72
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
72
73
  /** Dedicated service credential. Conto and Browserbase API keys are rejected. */
73
74
  token: string;
74
75
  maxBodyBytes?: number;
@@ -585,6 +585,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
585
585
  "dispatchAttemptId",
586
586
  255
587
587
  );
588
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
589
+ throw Object.assign(
590
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
591
+ { code: "CONFLICT", status: 409 }
592
+ );
593
+ }
588
594
  return config.conto.runGuardedCheckoutWithDriver(input, {
589
595
  dispatchAttemptId,
590
596
  driver: adapter.driver
@@ -919,6 +925,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
919
925
  pageForSession: browserSessions.pageForSession,
920
926
  targetStore,
921
927
  dispatchAttemptFor: config.dispatchAttemptFor,
928
+ claimDispatchAttempt: config.claimDispatchAttempt,
922
929
  clickTimeoutMs: config.clickTimeoutMs,
923
930
  popupTimeoutMs: config.popupTimeoutMs,
924
931
  targetTtlMs: config.targetTtlMs,
@@ -1242,7 +1249,7 @@ function safeRuntimeError(error) {
1242
1249
  return httpJson(error.status, { code: error.code });
1243
1250
  }
1244
1251
  const record = error && typeof error === "object" ? error : void 0;
1245
- const candidateCode = record?.code;
1252
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1246
1253
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1247
1254
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1248
1255
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -1928,6 +1935,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
1928
1935
  },
1929
1936
  targetStore: config.targetStore,
1930
1937
  dispatchAttemptFor: config.dispatchAttemptFor,
1938
+ claimDispatchAttempt: config.claimDispatchAttempt,
1931
1939
  token: config.token,
1932
1940
  maxBodyBytes: config.maxBodyBytes,
1933
1941
  clickTimeoutMs: config.clickTimeoutMs,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createGuardedPlaywrightCheckoutRuntimeHost
3
- } from "./chunk-HM4EG5MH.mjs";
3
+ } from "./chunk-VSIO6PYA.mjs";
4
4
  import "./chunk-O5RAAB2U.mjs";
5
- import "./chunk-B7F5QLE5.mjs";
5
+ import "./chunk-WSIKPUZJ.mjs";
6
6
 
7
7
  // src/browserbase.ts
8
8
  import { createHmac, timingSafeEqual } from "crypto";
@@ -551,6 +551,7 @@ function createBrowserbaseGuardedPlaywrightCheckoutRuntimeHost(config) {
551
551
  },
552
552
  targetStore: config.targetStore,
553
553
  dispatchAttemptFor: config.dispatchAttemptFor,
554
+ claimDispatchAttempt: config.claimDispatchAttempt,
554
555
  token: config.token,
555
556
  maxBodyBytes: config.maxBodyBytes,
556
557
  clickTimeoutMs: config.clickTimeoutMs,
@@ -1,4 +1,4 @@
1
- import "./chunk-B7F5QLE5.mjs";
1
+ import "./chunk-WSIKPUZJ.mjs";
2
2
 
3
3
  // src/checkout-verifier.ts
4
4
  import { createHash, randomUUID } from "crypto";
@@ -447,6 +447,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
447
447
  "dispatchAttemptId",
448
448
  255
449
449
  );
450
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
451
+ throw Object.assign(
452
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
453
+ { code: "CONFLICT", status: 409 }
454
+ );
455
+ }
450
456
  return config.conto.runGuardedCheckoutWithDriver(input, {
451
457
  dispatchAttemptId,
452
458
  driver: adapter.driver
@@ -781,6 +787,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
781
787
  pageForSession: browserSessions.pageForSession,
782
788
  targetStore,
783
789
  dispatchAttemptFor: config.dispatchAttemptFor,
790
+ claimDispatchAttempt: config.claimDispatchAttempt,
784
791
  clickTimeoutMs: config.clickTimeoutMs,
785
792
  popupTimeoutMs: config.popupTimeoutMs,
786
793
  targetTtlMs: config.targetTtlMs,
@@ -1104,7 +1111,7 @@ function safeRuntimeError(error) {
1104
1111
  return httpJson(error.status, { code: error.code });
1105
1112
  }
1106
1113
  const record = error && typeof error === "object" ? error : void 0;
1107
- const candidateCode = record?.code;
1114
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1108
1115
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1109
1116
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1110
1117
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
7
10
  var __commonJS = (cb, mod) => function __require() {
8
11
  try {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -27,8 +30,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
31
  mod
29
32
  ));
33
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
35
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
30
37
 
31
38
  export {
32
39
  __commonJS,
33
- __toESM
40
+ __toESM,
41
+ __privateGet,
42
+ __privateAdd,
43
+ __privateSet
34
44
  };
package/dist/index.d.mts CHANGED
@@ -673,7 +673,7 @@ interface StripeLinkCheckoutReadinessResult {
673
673
  readonly readiness: StripeLinkCheckoutReadiness;
674
674
  }
675
675
  declare class ContoAdmin {
676
- private orgApiKey;
676
+ #private;
677
677
  private baseUrl;
678
678
  private timeout;
679
679
  agents: AgentsClient;
@@ -1028,6 +1028,92 @@ interface PaymentRequestInput {
1028
1028
  /** Client-supplied key for idempotent retries */
1029
1029
  idempotencyKey?: string;
1030
1030
  }
1031
+ /** Whether a path works: `unknown` means Conto has no evidence either way. */
1032
+ type SetupCapabilityState = 'yes' | 'no' | 'unknown';
1033
+ /**
1034
+ * Stable setup issue codes. New codes can appear within a diagnostics version,
1035
+ * so handle an unrecognized code by its `severity` and `actor`.
1036
+ */
1037
+ type SetupDiagnosticIssueCode = 'AGENT_PAUSED' | 'AGENT_FROZEN' | 'AGENT_UNAVAILABLE' | 'SDK_KEY_EXPIRED' | 'SDK_KEY_REVOKED' | 'SCOPE_MISSING' | 'NO_WALLET' | 'WALLET_PAUSED' | 'WALLET_UNAVAILABLE' | 'WALLET_VIEW_ONLY' | 'WALLET_UNFUNDED' | 'MAINNET_REQUIRES_PROD_AGENT' | 'LIVE_PAYMENTS_PAUSED' | 'LIVE_PAYMENTS_UNAVAILABLE' | 'EXTERNAL_SIGNER_REQUIRED' | 'SANDBOX_UNCLAIMED' | 'SANDBOX_EXPIRED' | (string & {});
1038
+ /** A next step: a documented command, an API call, or a dashboard page for an owner. */
1039
+ type SetupDiagnosticAction = {
1040
+ type: 'command';
1041
+ command: string;
1042
+ description: string;
1043
+ } | {
1044
+ type: 'api';
1045
+ method: 'GET' | 'POST' | 'PATCH';
1046
+ /** Relative to the Conto base URL. Segments in braces are placeholders. */
1047
+ href: string;
1048
+ credential: 'sdk_key' | 'sandbox_api_key' | 'organization_api_key';
1049
+ requiredScope: string | null;
1050
+ description: string;
1051
+ } | {
1052
+ type: 'owner_url';
1053
+ /** A dashboard page, relative to the Conto base URL. */
1054
+ url: string;
1055
+ description: string;
1056
+ };
1057
+ interface SetupDiagnosticIssue {
1058
+ code: SetupDiagnosticIssueCode;
1059
+ /** `error` blocks a capability of the resource. `info` explains how a path works. */
1060
+ severity: 'error' | 'warning' | 'info';
1061
+ /** Who can resolve it: the agent with its own credentials, or an owner. */
1062
+ actor: 'agent' | 'owner';
1063
+ resource: {
1064
+ type: 'agent' | 'wallet' | 'sdk_key' | 'organization';
1065
+ id: string | null;
1066
+ };
1067
+ message: string;
1068
+ /** The missing scope for SCOPE_MISSING, otherwise null. */
1069
+ requiredScope: string | null;
1070
+ actions: SetupDiagnosticAction[];
1071
+ }
1072
+ interface SetupWalletDiagnostics {
1073
+ walletId: string;
1074
+ /** `simulated` sandbox, `managed` by Conto, `external` signer, or `unknown`. */
1075
+ executionMode: 'simulated' | 'managed' | 'external' | 'unknown';
1076
+ network: 'testnet' | 'mainnet';
1077
+ /** `not_checked`: Conto does not read this wallet's balance. */
1078
+ funding: 'not_required' | 'funded' | 'unfunded' | 'not_checked';
1079
+ walletLimits: boolean;
1080
+ canRequest: SetupCapabilityState;
1081
+ canExecute: SetupCapabilityState;
1082
+ issueCodes: SetupDiagnosticIssueCode[];
1083
+ }
1084
+ interface SetupCardDiagnostics {
1085
+ availability: 'available' | 'unavailable';
1086
+ reason: 'sandbox_organization' | 'disabled' | 'plan' | null;
1087
+ assignedCards: number;
1088
+ activeAuthorizations: number;
1089
+ canUse: 'yes' | 'no';
1090
+ }
1091
+ /** Versioned setup diagnostics from `GET /api/sdk/setup`. */
1092
+ interface SetupDiagnostics {
1093
+ version: 'conto.setup-diagnostics.v1';
1094
+ environment: {
1095
+ kind: 'anonymous_sandbox' | 'claimed_sandbox' | 'account';
1096
+ settlement: 'simulated' | 'per_wallet';
1097
+ agentEnvironment: 'DEV' | 'STAGING' | 'PROD';
1098
+ sandboxExpiresAt: string | null;
1099
+ } | null;
1100
+ status: {
1101
+ authenticated: boolean;
1102
+ canRequest: SetupCapabilityState;
1103
+ canExecute: SetupCapabilityState;
1104
+ ownerActionRequired: boolean;
1105
+ };
1106
+ wallets: SetupWalletDiagnostics[];
1107
+ /** Test and live cards, reported apart from wallets. */
1108
+ connectedCards: {
1109
+ test: SetupCardDiagnostics;
1110
+ live: SetupCardDiagnostics;
1111
+ } | null;
1112
+ controls: {
1113
+ effectivePolicies: number;
1114
+ } | null;
1115
+ issues: SetupDiagnosticIssue[];
1116
+ }
1031
1117
  interface AgentSetupResult {
1032
1118
  agent: {
1033
1119
  id: string;
@@ -1078,6 +1164,11 @@ interface AgentSetupResult {
1078
1164
  totalVolume: number;
1079
1165
  }>;
1080
1166
  scopes: string[];
1167
+ /**
1168
+ * What this key can do and what needs an owner. Null when the server could
1169
+ * not compute it for this request. Absent from servers that predate it.
1170
+ */
1171
+ diagnostics?: SetupDiagnostics | null;
1081
1172
  }
1082
1173
  interface ExternalWalletApprovalInput {
1083
1174
  amount: number;
@@ -1486,6 +1577,90 @@ interface ConnectedCardListResult {
1486
1577
  /** Masked drawable cards and their active mandates. No PAN or provider token. */
1487
1578
  cards: ConnectedCardDrawable[];
1488
1579
  }
1580
+ /**
1581
+ * The opaque single-use token a test-card draw returns once. Not card data, and
1582
+ * accepted only by {@link TestCardsClient.checkout}. Handle it the way you would
1583
+ * a live credential: keep it out of logs, errors, and model context.
1584
+ */
1585
+ interface TestCardCredential {
1586
+ token: string;
1587
+ format: 'test_token';
1588
+ }
1589
+ interface TestCardDrawResult {
1590
+ environment: 'test';
1591
+ requestId: string;
1592
+ minted: boolean;
1593
+ replayed: boolean;
1594
+ decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
1595
+ reasons: string[];
1596
+ reconciliationRequired?: boolean;
1597
+ /** Present only on the response that issues it. A replay never returns it again. */
1598
+ testCredential?: TestCardCredential;
1599
+ credentialExpiresAt?: string;
1600
+ notice?: string;
1601
+ }
1602
+ interface TestMerchantProduct {
1603
+ sku: string;
1604
+ name: string;
1605
+ unitAmountMinor: number;
1606
+ }
1607
+ interface TestMerchant {
1608
+ key: string;
1609
+ name: string;
1610
+ categoryCode: string;
1611
+ countryCode: string;
1612
+ products: TestMerchantProduct[];
1613
+ }
1614
+ interface TestCardDrawable extends ConnectedCardDrawable {
1615
+ environment: 'test';
1616
+ label: string;
1617
+ }
1618
+ interface TestCardListResult {
1619
+ environment: 'test';
1620
+ cards: TestCardDrawable[];
1621
+ merchants: TestMerchant[];
1622
+ }
1623
+ interface TestCheckoutInput {
1624
+ requestId: string;
1625
+ /** The `testCredential.token` from the draw. */
1626
+ credential: string;
1627
+ /** Items from the test merchant's catalog. Omit to buy one line for the authorized amount. */
1628
+ items?: Array<{
1629
+ sku: string;
1630
+ quantity: number;
1631
+ }>;
1632
+ }
1633
+ interface TestCardReceipt {
1634
+ environment: 'test';
1635
+ simulated: true;
1636
+ settlementMode: 'test';
1637
+ notice: string;
1638
+ orderId: string;
1639
+ orderNumber: string;
1640
+ requestId: string;
1641
+ transactionId: string;
1642
+ agentId: string;
1643
+ cardId: string;
1644
+ merchant: {
1645
+ key: string;
1646
+ name: string;
1647
+ };
1648
+ items: Array<{
1649
+ sku: string;
1650
+ name: string;
1651
+ quantity: number;
1652
+ unitAmountMinor: number;
1653
+ amountMinor: number;
1654
+ }>;
1655
+ amountMinor: number;
1656
+ currency: string;
1657
+ createdAt: string;
1658
+ }
1659
+ interface TestCheckoutResult extends TestCardReceipt {
1660
+ /** True when this credential already completed this checkout. Nothing new was recorded. */
1661
+ replayed: boolean;
1662
+ status: 'COMPLETED';
1663
+ }
1489
1664
  interface StripeLinkPaymentMethod {
1490
1665
  id: string;
1491
1666
  type: string;
@@ -2023,6 +2198,12 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
2023
2198
  };
2024
2199
  }
2025
2200
  interface MppRecordInput extends ProtocolRecordGrant {
2201
+ /**
2202
+ * Amount the service charged. Must be positive, except `0` on a session's
2203
+ * closing record (`closeSession: true`) when the session charged nothing
2204
+ * more. That close needs `grantId` and `grantSignature` and takes no
2205
+ * `txHash`, `paymentReceipt`, or `batchItems`.
2206
+ */
2026
2207
  amount: number;
2027
2208
  currency?: string;
2028
2209
  recipientAddress: string;
@@ -2049,7 +2230,9 @@ interface MppRecordInput extends ProtocolRecordGrant {
2049
2230
  }>;
2050
2231
  /**
2051
2232
  * Send true on the final record of a session (`intent: 'session'`). Conto
2052
- * closes the session and releases the unused part of its grant.
2233
+ * closes the session and releases the unused part of its grant. Send it
2234
+ * with `amount: 0` when the session has nothing more to charge. Repeating
2235
+ * that close returns the same result.
2053
2236
  */
2054
2237
  closeSession?: boolean;
2055
2238
  }
@@ -2058,6 +2241,8 @@ interface MppRecordResult extends ProtocolRecordGrantResult {
2058
2241
  txHash?: string;
2059
2242
  explorerUrl?: string;
2060
2243
  sessionId?: string;
2244
+ /** True when a record with `amount: 0` closed the session. No transaction was recorded. */
2245
+ sessionClosed?: true;
2061
2246
  }
2062
2247
  interface ProtocolBudgetResult {
2063
2248
  spend: {
@@ -2162,12 +2347,13 @@ interface ContoRequestOptions {
2162
2347
  maxRetries?: number;
2163
2348
  }
2164
2349
  declare class Conto {
2165
- private apiKey;
2350
+ #private;
2166
2351
  private baseUrl;
2167
2352
  private timeout;
2168
2353
  payments: PaymentsClient;
2169
2354
  cards: CardsClient;
2170
2355
  connectedCards: ConnectedCardsClient;
2356
+ testCards: TestCardsClient;
2171
2357
  x402: X402Client;
2172
2358
  mpp: MppClient;
2173
2359
  constructor(config: ContoConfig);
@@ -2243,7 +2429,10 @@ declare class Conto {
2243
2429
  * reconciliation.
2244
2430
  */
2245
2431
  cancelCommerceExecution(executionId: string): Promise<CommerceExecutionResult>;
2246
- /** Read credentials, linked wallets, effective policies, and scopes without creating a payment. */
2432
+ /**
2433
+ * Read credentials, linked wallets, effective policies, scopes, and setup
2434
+ * diagnostics without creating a payment.
2435
+ */
2247
2436
  setup(): Promise<AgentSetupResult>;
2248
2437
  /** Make an authenticated request to the Conto API */
2249
2438
  request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
@@ -2345,6 +2534,37 @@ declare class ConnectedCardsClient {
2345
2534
  }>;
2346
2535
  list(): Promise<ConnectedCardListResult>;
2347
2536
  }
2537
+ /**
2538
+ * Test cards: try card controls with simulated purchases. See the section
2539
+ * comment above {@link TestCardCredential}.
2540
+ */
2541
+ declare class TestCardsClient {
2542
+ private client;
2543
+ constructor(client: Conto);
2544
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
2545
+ list(): Promise<TestCardListResult>;
2546
+ /**
2547
+ * Request a single-use test credential. Same rules as
2548
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
2549
+ * no automatic transport retry, and after a human approves a review, resend
2550
+ * the identical request with the same key.
2551
+ */
2552
+ draw(input: ConnectedCardDrawInput): Promise<TestCardDrawResult>;
2553
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
2554
+ acknowledgeDelivery(requestId: string): Promise<{
2555
+ environment: 'test';
2556
+ acknowledged: boolean;
2557
+ settlementVerified: false;
2558
+ }>;
2559
+ /**
2560
+ * Complete a simulated purchase at the Conto test merchant with the test
2561
+ * credential. Retrying with the same draw and credential returns the same
2562
+ * receipt with `replayed: true`, so this call is safe to retry.
2563
+ */
2564
+ checkout(input: TestCheckoutInput): Promise<TestCheckoutResult>;
2565
+ /** Read back one of this agent's simulated receipts. */
2566
+ receipt(orderId: string): Promise<TestCardReceipt>;
2567
+ }
2348
2568
  /** Client for payment operations */
2349
2569
  declare class PaymentsClient {
2350
2570
  private client;
@@ -2482,4 +2702,4 @@ declare class MppClient {
2482
2702
  }): Promise<ProtocolServicesResult>;
2483
2703
  }
2484
2704
 
2485
- 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 };
2705
+ 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 SetupCapabilityState, type SetupCardDiagnostics, type SetupDiagnosticAction, type SetupDiagnosticIssue, type SetupDiagnosticIssueCode, type SetupDiagnostics, type SetupWalletDiagnostics, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type TestCardCredential, type TestCardDrawResult, type TestCardDrawable, type TestCardListResult, type TestCardReceipt, TestCardsClient, type TestCheckoutInput, type TestCheckoutResult, type TestMerchant, type TestMerchantProduct, 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 };
package/dist/index.d.ts CHANGED
@@ -673,7 +673,7 @@ interface StripeLinkCheckoutReadinessResult {
673
673
  readonly readiness: StripeLinkCheckoutReadiness;
674
674
  }
675
675
  declare class ContoAdmin {
676
- private orgApiKey;
676
+ #private;
677
677
  private baseUrl;
678
678
  private timeout;
679
679
  agents: AgentsClient;
@@ -1028,6 +1028,92 @@ interface PaymentRequestInput {
1028
1028
  /** Client-supplied key for idempotent retries */
1029
1029
  idempotencyKey?: string;
1030
1030
  }
1031
+ /** Whether a path works: `unknown` means Conto has no evidence either way. */
1032
+ type SetupCapabilityState = 'yes' | 'no' | 'unknown';
1033
+ /**
1034
+ * Stable setup issue codes. New codes can appear within a diagnostics version,
1035
+ * so handle an unrecognized code by its `severity` and `actor`.
1036
+ */
1037
+ type SetupDiagnosticIssueCode = 'AGENT_PAUSED' | 'AGENT_FROZEN' | 'AGENT_UNAVAILABLE' | 'SDK_KEY_EXPIRED' | 'SDK_KEY_REVOKED' | 'SCOPE_MISSING' | 'NO_WALLET' | 'WALLET_PAUSED' | 'WALLET_UNAVAILABLE' | 'WALLET_VIEW_ONLY' | 'WALLET_UNFUNDED' | 'MAINNET_REQUIRES_PROD_AGENT' | 'LIVE_PAYMENTS_PAUSED' | 'LIVE_PAYMENTS_UNAVAILABLE' | 'EXTERNAL_SIGNER_REQUIRED' | 'SANDBOX_UNCLAIMED' | 'SANDBOX_EXPIRED' | (string & {});
1038
+ /** A next step: a documented command, an API call, or a dashboard page for an owner. */
1039
+ type SetupDiagnosticAction = {
1040
+ type: 'command';
1041
+ command: string;
1042
+ description: string;
1043
+ } | {
1044
+ type: 'api';
1045
+ method: 'GET' | 'POST' | 'PATCH';
1046
+ /** Relative to the Conto base URL. Segments in braces are placeholders. */
1047
+ href: string;
1048
+ credential: 'sdk_key' | 'sandbox_api_key' | 'organization_api_key';
1049
+ requiredScope: string | null;
1050
+ description: string;
1051
+ } | {
1052
+ type: 'owner_url';
1053
+ /** A dashboard page, relative to the Conto base URL. */
1054
+ url: string;
1055
+ description: string;
1056
+ };
1057
+ interface SetupDiagnosticIssue {
1058
+ code: SetupDiagnosticIssueCode;
1059
+ /** `error` blocks a capability of the resource. `info` explains how a path works. */
1060
+ severity: 'error' | 'warning' | 'info';
1061
+ /** Who can resolve it: the agent with its own credentials, or an owner. */
1062
+ actor: 'agent' | 'owner';
1063
+ resource: {
1064
+ type: 'agent' | 'wallet' | 'sdk_key' | 'organization';
1065
+ id: string | null;
1066
+ };
1067
+ message: string;
1068
+ /** The missing scope for SCOPE_MISSING, otherwise null. */
1069
+ requiredScope: string | null;
1070
+ actions: SetupDiagnosticAction[];
1071
+ }
1072
+ interface SetupWalletDiagnostics {
1073
+ walletId: string;
1074
+ /** `simulated` sandbox, `managed` by Conto, `external` signer, or `unknown`. */
1075
+ executionMode: 'simulated' | 'managed' | 'external' | 'unknown';
1076
+ network: 'testnet' | 'mainnet';
1077
+ /** `not_checked`: Conto does not read this wallet's balance. */
1078
+ funding: 'not_required' | 'funded' | 'unfunded' | 'not_checked';
1079
+ walletLimits: boolean;
1080
+ canRequest: SetupCapabilityState;
1081
+ canExecute: SetupCapabilityState;
1082
+ issueCodes: SetupDiagnosticIssueCode[];
1083
+ }
1084
+ interface SetupCardDiagnostics {
1085
+ availability: 'available' | 'unavailable';
1086
+ reason: 'sandbox_organization' | 'disabled' | 'plan' | null;
1087
+ assignedCards: number;
1088
+ activeAuthorizations: number;
1089
+ canUse: 'yes' | 'no';
1090
+ }
1091
+ /** Versioned setup diagnostics from `GET /api/sdk/setup`. */
1092
+ interface SetupDiagnostics {
1093
+ version: 'conto.setup-diagnostics.v1';
1094
+ environment: {
1095
+ kind: 'anonymous_sandbox' | 'claimed_sandbox' | 'account';
1096
+ settlement: 'simulated' | 'per_wallet';
1097
+ agentEnvironment: 'DEV' | 'STAGING' | 'PROD';
1098
+ sandboxExpiresAt: string | null;
1099
+ } | null;
1100
+ status: {
1101
+ authenticated: boolean;
1102
+ canRequest: SetupCapabilityState;
1103
+ canExecute: SetupCapabilityState;
1104
+ ownerActionRequired: boolean;
1105
+ };
1106
+ wallets: SetupWalletDiagnostics[];
1107
+ /** Test and live cards, reported apart from wallets. */
1108
+ connectedCards: {
1109
+ test: SetupCardDiagnostics;
1110
+ live: SetupCardDiagnostics;
1111
+ } | null;
1112
+ controls: {
1113
+ effectivePolicies: number;
1114
+ } | null;
1115
+ issues: SetupDiagnosticIssue[];
1116
+ }
1031
1117
  interface AgentSetupResult {
1032
1118
  agent: {
1033
1119
  id: string;
@@ -1078,6 +1164,11 @@ interface AgentSetupResult {
1078
1164
  totalVolume: number;
1079
1165
  }>;
1080
1166
  scopes: string[];
1167
+ /**
1168
+ * What this key can do and what needs an owner. Null when the server could
1169
+ * not compute it for this request. Absent from servers that predate it.
1170
+ */
1171
+ diagnostics?: SetupDiagnostics | null;
1081
1172
  }
1082
1173
  interface ExternalWalletApprovalInput {
1083
1174
  amount: number;
@@ -1486,6 +1577,90 @@ interface ConnectedCardListResult {
1486
1577
  /** Masked drawable cards and their active mandates. No PAN or provider token. */
1487
1578
  cards: ConnectedCardDrawable[];
1488
1579
  }
1580
+ /**
1581
+ * The opaque single-use token a test-card draw returns once. Not card data, and
1582
+ * accepted only by {@link TestCardsClient.checkout}. Handle it the way you would
1583
+ * a live credential: keep it out of logs, errors, and model context.
1584
+ */
1585
+ interface TestCardCredential {
1586
+ token: string;
1587
+ format: 'test_token';
1588
+ }
1589
+ interface TestCardDrawResult {
1590
+ environment: 'test';
1591
+ requestId: string;
1592
+ minted: boolean;
1593
+ replayed: boolean;
1594
+ decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
1595
+ reasons: string[];
1596
+ reconciliationRequired?: boolean;
1597
+ /** Present only on the response that issues it. A replay never returns it again. */
1598
+ testCredential?: TestCardCredential;
1599
+ credentialExpiresAt?: string;
1600
+ notice?: string;
1601
+ }
1602
+ interface TestMerchantProduct {
1603
+ sku: string;
1604
+ name: string;
1605
+ unitAmountMinor: number;
1606
+ }
1607
+ interface TestMerchant {
1608
+ key: string;
1609
+ name: string;
1610
+ categoryCode: string;
1611
+ countryCode: string;
1612
+ products: TestMerchantProduct[];
1613
+ }
1614
+ interface TestCardDrawable extends ConnectedCardDrawable {
1615
+ environment: 'test';
1616
+ label: string;
1617
+ }
1618
+ interface TestCardListResult {
1619
+ environment: 'test';
1620
+ cards: TestCardDrawable[];
1621
+ merchants: TestMerchant[];
1622
+ }
1623
+ interface TestCheckoutInput {
1624
+ requestId: string;
1625
+ /** The `testCredential.token` from the draw. */
1626
+ credential: string;
1627
+ /** Items from the test merchant's catalog. Omit to buy one line for the authorized amount. */
1628
+ items?: Array<{
1629
+ sku: string;
1630
+ quantity: number;
1631
+ }>;
1632
+ }
1633
+ interface TestCardReceipt {
1634
+ environment: 'test';
1635
+ simulated: true;
1636
+ settlementMode: 'test';
1637
+ notice: string;
1638
+ orderId: string;
1639
+ orderNumber: string;
1640
+ requestId: string;
1641
+ transactionId: string;
1642
+ agentId: string;
1643
+ cardId: string;
1644
+ merchant: {
1645
+ key: string;
1646
+ name: string;
1647
+ };
1648
+ items: Array<{
1649
+ sku: string;
1650
+ name: string;
1651
+ quantity: number;
1652
+ unitAmountMinor: number;
1653
+ amountMinor: number;
1654
+ }>;
1655
+ amountMinor: number;
1656
+ currency: string;
1657
+ createdAt: string;
1658
+ }
1659
+ interface TestCheckoutResult extends TestCardReceipt {
1660
+ /** True when this credential already completed this checkout. Nothing new was recorded. */
1661
+ replayed: boolean;
1662
+ status: 'COMPLETED';
1663
+ }
1489
1664
  interface StripeLinkPaymentMethod {
1490
1665
  id: string;
1491
1666
  type: string;
@@ -2023,6 +2198,12 @@ interface MppPreAuthorizeResult extends ProtocolPreAuthorizeResult {
2023
2198
  };
2024
2199
  }
2025
2200
  interface MppRecordInput extends ProtocolRecordGrant {
2201
+ /**
2202
+ * Amount the service charged. Must be positive, except `0` on a session's
2203
+ * closing record (`closeSession: true`) when the session charged nothing
2204
+ * more. That close needs `grantId` and `grantSignature` and takes no
2205
+ * `txHash`, `paymentReceipt`, or `batchItems`.
2206
+ */
2026
2207
  amount: number;
2027
2208
  currency?: string;
2028
2209
  recipientAddress: string;
@@ -2049,7 +2230,9 @@ interface MppRecordInput extends ProtocolRecordGrant {
2049
2230
  }>;
2050
2231
  /**
2051
2232
  * Send true on the final record of a session (`intent: 'session'`). Conto
2052
- * closes the session and releases the unused part of its grant.
2233
+ * closes the session and releases the unused part of its grant. Send it
2234
+ * with `amount: 0` when the session has nothing more to charge. Repeating
2235
+ * that close returns the same result.
2053
2236
  */
2054
2237
  closeSession?: boolean;
2055
2238
  }
@@ -2058,6 +2241,8 @@ interface MppRecordResult extends ProtocolRecordGrantResult {
2058
2241
  txHash?: string;
2059
2242
  explorerUrl?: string;
2060
2243
  sessionId?: string;
2244
+ /** True when a record with `amount: 0` closed the session. No transaction was recorded. */
2245
+ sessionClosed?: true;
2061
2246
  }
2062
2247
  interface ProtocolBudgetResult {
2063
2248
  spend: {
@@ -2162,12 +2347,13 @@ interface ContoRequestOptions {
2162
2347
  maxRetries?: number;
2163
2348
  }
2164
2349
  declare class Conto {
2165
- private apiKey;
2350
+ #private;
2166
2351
  private baseUrl;
2167
2352
  private timeout;
2168
2353
  payments: PaymentsClient;
2169
2354
  cards: CardsClient;
2170
2355
  connectedCards: ConnectedCardsClient;
2356
+ testCards: TestCardsClient;
2171
2357
  x402: X402Client;
2172
2358
  mpp: MppClient;
2173
2359
  constructor(config: ContoConfig);
@@ -2243,7 +2429,10 @@ declare class Conto {
2243
2429
  * reconciliation.
2244
2430
  */
2245
2431
  cancelCommerceExecution(executionId: string): Promise<CommerceExecutionResult>;
2246
- /** Read credentials, linked wallets, effective policies, and scopes without creating a payment. */
2432
+ /**
2433
+ * Read credentials, linked wallets, effective policies, scopes, and setup
2434
+ * diagnostics without creating a payment.
2435
+ */
2247
2436
  setup(): Promise<AgentSetupResult>;
2248
2437
  /** Make an authenticated request to the Conto API */
2249
2438
  request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
@@ -2345,6 +2534,37 @@ declare class ConnectedCardsClient {
2345
2534
  }>;
2346
2535
  list(): Promise<ConnectedCardListResult>;
2347
2536
  }
2537
+ /**
2538
+ * Test cards: try card controls with simulated purchases. See the section
2539
+ * comment above {@link TestCardCredential}.
2540
+ */
2541
+ declare class TestCardsClient {
2542
+ private client;
2543
+ constructor(client: Conto);
2544
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
2545
+ list(): Promise<TestCardListResult>;
2546
+ /**
2547
+ * Request a single-use test credential. Same rules as
2548
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
2549
+ * no automatic transport retry, and after a human approves a review, resend
2550
+ * the identical request with the same key.
2551
+ */
2552
+ draw(input: ConnectedCardDrawInput): Promise<TestCardDrawResult>;
2553
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
2554
+ acknowledgeDelivery(requestId: string): Promise<{
2555
+ environment: 'test';
2556
+ acknowledged: boolean;
2557
+ settlementVerified: false;
2558
+ }>;
2559
+ /**
2560
+ * Complete a simulated purchase at the Conto test merchant with the test
2561
+ * credential. Retrying with the same draw and credential returns the same
2562
+ * receipt with `replayed: true`, so this call is safe to retry.
2563
+ */
2564
+ checkout(input: TestCheckoutInput): Promise<TestCheckoutResult>;
2565
+ /** Read back one of this agent's simulated receipts. */
2566
+ receipt(orderId: string): Promise<TestCardReceipt>;
2567
+ }
2348
2568
  /** Client for payment operations */
2349
2569
  declare class PaymentsClient {
2350
2570
  private client;
@@ -2482,4 +2702,4 @@ declare class MppClient {
2482
2702
  }): Promise<ProtocolServicesResult>;
2483
2703
  }
2484
2704
 
2485
- 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 };
2705
+ 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 SetupCapabilityState, type SetupCardDiagnostics, type SetupDiagnosticAction, type SetupDiagnosticIssue, type SetupDiagnosticIssueCode, type SetupDiagnostics, type SetupWalletDiagnostics, type StripeLinkCheckoutReadiness, type StripeLinkCheckoutReadinessResult, type StripeLinkCheckoutReadinessStatus, type StripeLinkCheckoutVerification, type StripeLinkPaymentMethod, type TestCardCredential, type TestCardDrawResult, type TestCardDrawable, type TestCardListResult, type TestCardReceipt, TestCardsClient, type TestCheckoutInput, type TestCheckoutResult, type TestMerchant, type TestMerchantProduct, 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 };
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  try {
10
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -33,13 +36,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
36
  mod
34
37
  ));
35
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
40
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
41
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
42
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
43
 
37
44
  // package.json
38
45
  var require_package = __commonJS({
39
46
  "package.json"(exports2, module2) {
40
47
  module2.exports = {
41
48
  name: "@conto_finance/sdk",
42
- version: "0.5.3",
49
+ version: "0.5.5",
43
50
  description: "Conto SDK for AI agent payment authorization",
44
51
  main: "./dist/index.js",
45
52
  module: "./dist/index.mjs",
@@ -154,6 +161,7 @@ __export(index_exports, {
154
161
  ControlledExternalCardPaymentTool: () => ControlledExternalCardPaymentTool,
155
162
  ExternalCardConfirmationPendingError: () => ExternalCardConfirmationPendingError,
156
163
  Giro: () => Conto,
164
+ TestCardsClient: () => TestCardsClient,
157
165
  canonicalizeBrowserCheckoutTarget: () => canonicalizeBrowserCheckoutTarget,
158
166
  createVerifiedBrowserCheckoutDriver: () => createVerifiedBrowserCheckoutDriver,
159
167
  default: () => index_default,
@@ -511,8 +519,11 @@ var ContoAdminError = class extends Error {
511
519
  this.retryGuidance = metadata.retryGuidance;
512
520
  }
513
521
  };
522
+ var _orgApiKey;
514
523
  var ContoAdmin = class {
515
524
  constructor(config) {
525
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
526
+ __privateAdd(this, _orgApiKey);
516
527
  if (!config.orgApiKey) {
517
528
  throw new Error("Organization API key is required");
518
529
  }
@@ -526,7 +537,7 @@ var ContoAdmin = class {
526
537
  "Invalid API key format. Expected organization API key starting with conto_xxx..."
527
538
  );
528
539
  }
529
- this.orgApiKey = config.orgApiKey;
540
+ __privateSet(this, _orgApiKey, config.orgApiKey);
530
541
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
531
542
  assertSecureBaseUrl(this.baseUrl);
532
543
  this.timeout = config.timeout || 3e4;
@@ -550,7 +561,7 @@ var ContoAdmin = class {
550
561
  {
551
562
  method: normalizedMethod,
552
563
  headers: {
553
- Authorization: `Bearer ${this.orgApiKey}`,
564
+ Authorization: `Bearer ${__privateGet(this, _orgApiKey)}`,
554
565
  "Content-Type": "application/json",
555
566
  "User-Agent": `@conto_finance/sdk-admin/${import_package_version.SDK_PACKAGE_VERSION}`
556
567
  },
@@ -590,6 +601,7 @@ var ContoAdmin = class {
590
601
  }
591
602
  }
592
603
  };
604
+ _orgApiKey = new WeakMap();
593
605
  var PaymentRailsClient = class {
594
606
  constructor(client) {
595
607
  this.client = client;
@@ -1027,14 +1039,6 @@ var TeamClient = class {
1027
1039
  };
1028
1040
 
1029
1041
  // src/index.ts
1030
- if (process.env.SENTRY_DSN) {
1031
- Sentry2.init({
1032
- dsn: process.env.SENTRY_DSN,
1033
- environment: process.env.NODE_ENV || "production",
1034
- tracesSampleRate: 0.05,
1035
- enableLogs: true
1036
- });
1037
- }
1038
1042
  function isValidBrowserActionObservation(value) {
1039
1043
  if (!value || typeof value !== "object") return false;
1040
1044
  const observation = value;
@@ -1136,21 +1140,25 @@ function rethrowAmbiguousCommerceMutation(error, executionId, action) {
1136
1140
  }
1137
1141
  throw error;
1138
1142
  }
1143
+ var _apiKey;
1139
1144
  var Conto = class {
1140
1145
  constructor(config) {
1146
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
1147
+ __privateAdd(this, _apiKey);
1141
1148
  if (!config.apiKey) {
1142
1149
  throw new Error("API key is required");
1143
1150
  }
1144
1151
  if (!config.apiKey.startsWith("conto_agent_")) {
1145
1152
  throw new Error("Invalid API key format. Expected conto_agent_xxx...");
1146
1153
  }
1147
- this.apiKey = config.apiKey;
1154
+ __privateSet(this, _apiKey, config.apiKey);
1148
1155
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
1149
1156
  assertSecureBaseUrl(this.baseUrl);
1150
1157
  this.timeout = config.timeout || 3e4;
1151
1158
  this.payments = new PaymentsClient(this);
1152
1159
  this.cards = new CardsClient(this);
1153
1160
  this.connectedCards = new ConnectedCardsClient(this);
1161
+ this.testCards = new TestCardsClient(this);
1154
1162
  this.x402 = new X402Client(this);
1155
1163
  this.mpp = new MppClient(this);
1156
1164
  }
@@ -1425,7 +1433,10 @@ var Conto = class {
1425
1433
  rethrowAmbiguousCommerceMutation(error, executionId, "cancel");
1426
1434
  }
1427
1435
  }
1428
- /** Read credentials, linked wallets, effective policies, and scopes without creating a payment. */
1436
+ /**
1437
+ * Read credentials, linked wallets, effective policies, scopes, and setup
1438
+ * diagnostics without creating a payment.
1439
+ */
1429
1440
  async setup() {
1430
1441
  return this.request("GET", "/api/sdk/setup");
1431
1442
  }
@@ -1442,7 +1453,7 @@ var Conto = class {
1442
1453
  {
1443
1454
  method: normalizedMethod,
1444
1455
  headers: {
1445
- Authorization: `Bearer ${this.apiKey}`,
1456
+ Authorization: `Bearer ${__privateGet(this, _apiKey)}`,
1446
1457
  "Content-Type": "application/json",
1447
1458
  "User-Agent": `@conto_finance/sdk/${import_package_version2.SDK_PACKAGE_VERSION}`
1448
1459
  },
@@ -1482,6 +1493,7 @@ var Conto = class {
1482
1493
  }
1483
1494
  }
1484
1495
  };
1496
+ _apiKey = new WeakMap();
1485
1497
  var CardsClient = class {
1486
1498
  constructor(client) {
1487
1499
  this.client = client;
@@ -1718,6 +1730,65 @@ var ConnectedCardsClient = class {
1718
1730
  return this.client.request("GET", "/api/sdk/connected-cards");
1719
1731
  }
1720
1732
  };
1733
+ var TestCardsClient = class {
1734
+ constructor(client) {
1735
+ this.client = client;
1736
+ }
1737
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
1738
+ async list() {
1739
+ return this.client.request("GET", "/api/sdk/connected-cards/test");
1740
+ }
1741
+ /**
1742
+ * Request a single-use test credential. Same rules as
1743
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
1744
+ * no automatic transport retry, and after a human approves a review, resend
1745
+ * the identical request with the same key.
1746
+ */
1747
+ async draw(input) {
1748
+ const idempotencyKey = input.idempotencyKey?.trim();
1749
+ if (!idempotencyKey || idempotencyKey.length < 8 || idempotencyKey.length > 128) {
1750
+ throw new ContoError("idempotencyKey must contain 8 to 128 characters", {
1751
+ code: "INVALID_IDEMPOTENCY_KEY",
1752
+ status: 0,
1753
+ retryGuidance: "Generate one stable identifier per purchase and reuse it only to resume the same purchase."
1754
+ });
1755
+ }
1756
+ return this.client.request("POST", "/api/sdk/connected-cards/test/draws", {
1757
+ ...input,
1758
+ idempotencyKey,
1759
+ currency: input.currency ?? "USD"
1760
+ });
1761
+ }
1762
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
1763
+ async acknowledgeDelivery(requestId) {
1764
+ return this.client.request(
1765
+ "POST",
1766
+ `/api/sdk/connected-cards/test/draws/${encodeURIComponent(requestId)}/acknowledge`,
1767
+ {},
1768
+ { idempotent: true }
1769
+ );
1770
+ }
1771
+ /**
1772
+ * Complete a simulated purchase at the Conto test merchant with the test
1773
+ * credential. Retrying with the same draw and credential returns the same
1774
+ * receipt with `replayed: true`, so this call is safe to retry.
1775
+ */
1776
+ async checkout(input) {
1777
+ return this.client.request(
1778
+ "POST",
1779
+ "/api/sdk/connected-cards/test/checkout",
1780
+ { ...input },
1781
+ { idempotent: true }
1782
+ );
1783
+ }
1784
+ /** Read back one of this agent's simulated receipts. */
1785
+ async receipt(orderId) {
1786
+ return this.client.request(
1787
+ "GET",
1788
+ `/api/sdk/connected-cards/test/orders/${encodeURIComponent(orderId)}`
1789
+ );
1790
+ }
1791
+ };
1721
1792
  function approvalRetryGuidance(requestId) {
1722
1793
  const id = JSON.stringify(requestId);
1723
1794
  return `An approver in Conto executes the payment when they approve it. After approval, call payments.execute(${id}) or payments.status(${id}) to get the receipt. Do not request the payment again.`;
@@ -2041,6 +2112,7 @@ var index_default = Conto;
2041
2112
  ControlledExternalCardPaymentTool,
2042
2113
  ExternalCardConfirmationPendingError,
2043
2114
  Giro,
2115
+ TestCardsClient,
2044
2116
  canonicalizeBrowserCheckoutTarget,
2045
2117
  createVerifiedBrowserCheckoutDriver,
2046
2118
  fingerprintBrowserCheckoutTarget
package/dist/index.mjs CHANGED
@@ -6,15 +6,18 @@ import {
6
6
  } from "./chunk-O5RAAB2U.mjs";
7
7
  import {
8
8
  __commonJS,
9
+ __privateAdd,
10
+ __privateGet,
11
+ __privateSet,
9
12
  __toESM
10
- } from "./chunk-B7F5QLE5.mjs";
13
+ } from "./chunk-WSIKPUZJ.mjs";
11
14
 
12
15
  // package.json
13
16
  var require_package = __commonJS({
14
17
  "package.json"(exports, module) {
15
18
  module.exports = {
16
19
  name: "@conto_finance/sdk",
17
- version: "0.5.3",
20
+ version: "0.5.5",
18
21
  description: "Conto SDK for AI agent payment authorization",
19
22
  main: "./dist/index.js",
20
23
  module: "./dist/index.mjs",
@@ -350,8 +353,11 @@ var ContoAdminError = class extends Error {
350
353
  this.retryGuidance = metadata.retryGuidance;
351
354
  }
352
355
  };
356
+ var _orgApiKey;
353
357
  var ContoAdmin = class {
354
358
  constructor(config) {
359
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
360
+ __privateAdd(this, _orgApiKey);
355
361
  if (!config.orgApiKey) {
356
362
  throw new Error("Organization API key is required");
357
363
  }
@@ -365,7 +371,7 @@ var ContoAdmin = class {
365
371
  "Invalid API key format. Expected organization API key starting with conto_xxx..."
366
372
  );
367
373
  }
368
- this.orgApiKey = config.orgApiKey;
374
+ __privateSet(this, _orgApiKey, config.orgApiKey);
369
375
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
370
376
  assertSecureBaseUrl(this.baseUrl);
371
377
  this.timeout = config.timeout || 3e4;
@@ -389,7 +395,7 @@ var ContoAdmin = class {
389
395
  {
390
396
  method: normalizedMethod,
391
397
  headers: {
392
- Authorization: `Bearer ${this.orgApiKey}`,
398
+ Authorization: `Bearer ${__privateGet(this, _orgApiKey)}`,
393
399
  "Content-Type": "application/json",
394
400
  "User-Agent": `@conto_finance/sdk-admin/${import_package_version.SDK_PACKAGE_VERSION}`
395
401
  },
@@ -429,6 +435,7 @@ var ContoAdmin = class {
429
435
  }
430
436
  }
431
437
  };
438
+ _orgApiKey = new WeakMap();
432
439
  var PaymentRailsClient = class {
433
440
  constructor(client) {
434
441
  this.client = client;
@@ -866,14 +873,6 @@ var TeamClient = class {
866
873
  };
867
874
 
868
875
  // src/index.ts
869
- if (process.env.SENTRY_DSN) {
870
- Sentry2.init({
871
- dsn: process.env.SENTRY_DSN,
872
- environment: process.env.NODE_ENV || "production",
873
- tracesSampleRate: 0.05,
874
- enableLogs: true
875
- });
876
- }
877
876
  function isValidBrowserActionObservation(value) {
878
877
  if (!value || typeof value !== "object") return false;
879
878
  const observation = value;
@@ -975,21 +974,25 @@ function rethrowAmbiguousCommerceMutation(error, executionId, action) {
975
974
  }
976
975
  throw error;
977
976
  }
977
+ var _apiKey;
978
978
  var Conto = class {
979
979
  constructor(config) {
980
+ // An ECMAScript private field, so logging or serializing a client never prints the key.
981
+ __privateAdd(this, _apiKey);
980
982
  if (!config.apiKey) {
981
983
  throw new Error("API key is required");
982
984
  }
983
985
  if (!config.apiKey.startsWith("conto_agent_")) {
984
986
  throw new Error("Invalid API key format. Expected conto_agent_xxx...");
985
987
  }
986
- this.apiKey = config.apiKey;
988
+ __privateSet(this, _apiKey, config.apiKey);
987
989
  this.baseUrl = (config.baseUrl || "https://conto.finance").replace(/\/$/, "");
988
990
  assertSecureBaseUrl(this.baseUrl);
989
991
  this.timeout = config.timeout || 3e4;
990
992
  this.payments = new PaymentsClient(this);
991
993
  this.cards = new CardsClient(this);
992
994
  this.connectedCards = new ConnectedCardsClient(this);
995
+ this.testCards = new TestCardsClient(this);
993
996
  this.x402 = new X402Client(this);
994
997
  this.mpp = new MppClient(this);
995
998
  }
@@ -1264,7 +1267,10 @@ var Conto = class {
1264
1267
  rethrowAmbiguousCommerceMutation(error, executionId, "cancel");
1265
1268
  }
1266
1269
  }
1267
- /** Read credentials, linked wallets, effective policies, and scopes without creating a payment. */
1270
+ /**
1271
+ * Read credentials, linked wallets, effective policies, scopes, and setup
1272
+ * diagnostics without creating a payment.
1273
+ */
1268
1274
  async setup() {
1269
1275
  return this.request("GET", "/api/sdk/setup");
1270
1276
  }
@@ -1281,7 +1287,7 @@ var Conto = class {
1281
1287
  {
1282
1288
  method: normalizedMethod,
1283
1289
  headers: {
1284
- Authorization: `Bearer ${this.apiKey}`,
1290
+ Authorization: `Bearer ${__privateGet(this, _apiKey)}`,
1285
1291
  "Content-Type": "application/json",
1286
1292
  "User-Agent": `@conto_finance/sdk/${import_package_version2.SDK_PACKAGE_VERSION}`
1287
1293
  },
@@ -1321,6 +1327,7 @@ var Conto = class {
1321
1327
  }
1322
1328
  }
1323
1329
  };
1330
+ _apiKey = new WeakMap();
1324
1331
  var CardsClient = class {
1325
1332
  constructor(client) {
1326
1333
  this.client = client;
@@ -1557,6 +1564,65 @@ var ConnectedCardsClient = class {
1557
1564
  return this.client.request("GET", "/api/sdk/connected-cards");
1558
1565
  }
1559
1566
  };
1567
+ var TestCardsClient = class {
1568
+ constructor(client) {
1569
+ this.client = client;
1570
+ }
1571
+ /** The agent's test cards and active test authorizations, plus the test merchants. */
1572
+ async list() {
1573
+ return this.client.request("GET", "/api/sdk/connected-cards/test");
1574
+ }
1575
+ /**
1576
+ * Request a single-use test credential. Same rules as
1577
+ * {@link ConnectedCardsClient.draw}: one stable idempotency key per purchase,
1578
+ * no automatic transport retry, and after a human approves a review, resend
1579
+ * the identical request with the same key.
1580
+ */
1581
+ async draw(input) {
1582
+ const idempotencyKey = input.idempotencyKey?.trim();
1583
+ if (!idempotencyKey || idempotencyKey.length < 8 || idempotencyKey.length > 128) {
1584
+ throw new ContoError("idempotencyKey must contain 8 to 128 characters", {
1585
+ code: "INVALID_IDEMPOTENCY_KEY",
1586
+ status: 0,
1587
+ retryGuidance: "Generate one stable identifier per purchase and reuse it only to resume the same purchase."
1588
+ });
1589
+ }
1590
+ return this.client.request("POST", "/api/sdk/connected-cards/test/draws", {
1591
+ ...input,
1592
+ idempotencyKey,
1593
+ currency: input.currency ?? "USD"
1594
+ });
1595
+ }
1596
+ /** Record receipt of a test credential. Not a checkout and not a payment. */
1597
+ async acknowledgeDelivery(requestId) {
1598
+ return this.client.request(
1599
+ "POST",
1600
+ `/api/sdk/connected-cards/test/draws/${encodeURIComponent(requestId)}/acknowledge`,
1601
+ {},
1602
+ { idempotent: true }
1603
+ );
1604
+ }
1605
+ /**
1606
+ * Complete a simulated purchase at the Conto test merchant with the test
1607
+ * credential. Retrying with the same draw and credential returns the same
1608
+ * receipt with `replayed: true`, so this call is safe to retry.
1609
+ */
1610
+ async checkout(input) {
1611
+ return this.client.request(
1612
+ "POST",
1613
+ "/api/sdk/connected-cards/test/checkout",
1614
+ { ...input },
1615
+ { idempotent: true }
1616
+ );
1617
+ }
1618
+ /** Read back one of this agent's simulated receipts. */
1619
+ async receipt(orderId) {
1620
+ return this.client.request(
1621
+ "GET",
1622
+ `/api/sdk/connected-cards/test/orders/${encodeURIComponent(orderId)}`
1623
+ );
1624
+ }
1625
+ };
1560
1626
  function approvalRetryGuidance(requestId) {
1561
1627
  const id = JSON.stringify(requestId);
1562
1628
  return `An approver in Conto executes the payment when they approve it. After approval, call payments.execute(${id}) or payments.status(${id}) to get the receipt. Do not request the payment again.`;
@@ -1879,6 +1945,7 @@ export {
1879
1945
  ControlledExternalCardPaymentTool,
1880
1946
  ExternalCardConfirmationPendingError,
1881
1947
  Conto as Giro,
1948
+ TestCardsClient,
1882
1949
  canonicalizeBrowserCheckoutTarget,
1883
1950
  createVerifiedBrowserCheckoutDriver,
1884
1951
  index_default as default,
@@ -91,6 +91,8 @@ interface GuardedPlaywrightCheckoutRuntimeConfig extends PlaywrightCheckoutAdapt
91
91
  browserSessionId: string;
92
92
  targetFingerprint: string;
93
93
  }): Promise<string>;
94
+ /** Atomically starts an attempt once across runtime instances. Never release after a failure. */
95
+ claimDispatchAttempt?(dispatchAttemptId: string): Promise<boolean>;
94
96
  }
95
97
  /**
96
98
  * Safe façade to expose as the agent's checkout capability. It intentionally
@@ -191,6 +193,7 @@ interface GuardedPlaywrightCheckoutRuntimeHostConfig {
191
193
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
192
194
  /** Atomically loads or creates one stable attempt for the checkout intent. */
193
195
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
196
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
194
197
  /** Dedicated service credential. Conto API keys are rejected. */
195
198
  token: string;
196
199
  maxBodyBytes?: number;
@@ -91,6 +91,8 @@ interface GuardedPlaywrightCheckoutRuntimeConfig extends PlaywrightCheckoutAdapt
91
91
  browserSessionId: string;
92
92
  targetFingerprint: string;
93
93
  }): Promise<string>;
94
+ /** Atomically starts an attempt once across runtime instances. Never release after a failure. */
95
+ claimDispatchAttempt?(dispatchAttemptId: string): Promise<boolean>;
94
96
  }
95
97
  /**
96
98
  * Safe façade to expose as the agent's checkout capability. It intentionally
@@ -191,6 +193,7 @@ interface GuardedPlaywrightCheckoutRuntimeHostConfig {
191
193
  targetStore: EncryptedPlaywrightCheckoutTargetStoreConfig;
192
194
  /** Atomically loads or creates one stable attempt for the checkout intent. */
193
195
  dispatchAttemptFor: GuardedPlaywrightCheckoutRuntimeConfig['dispatchAttemptFor'];
196
+ claimDispatchAttempt?: GuardedPlaywrightCheckoutRuntimeConfig['claimDispatchAttempt'];
194
197
  /** Dedicated service credential. Conto API keys are rejected. */
195
198
  token: string;
196
199
  maxBodyBytes?: number;
@@ -585,6 +585,12 @@ function createGuardedPlaywrightCheckoutRuntime(config) {
585
585
  "dispatchAttemptId",
586
586
  255
587
587
  );
588
+ if (config.claimDispatchAttempt && !await config.claimDispatchAttempt(dispatchAttemptId)) {
589
+ throw Object.assign(
590
+ new Error("This dispatch attempt has already started. Reconcile before another action."),
591
+ { code: "CONFLICT", status: 409 }
592
+ );
593
+ }
588
594
  return config.conto.runGuardedCheckoutWithDriver(input, {
589
595
  dispatchAttemptId,
590
596
  driver: adapter.driver
@@ -919,6 +925,7 @@ function createGuardedPlaywrightCheckoutRuntimeHost(config) {
919
925
  pageForSession: browserSessions.pageForSession,
920
926
  targetStore,
921
927
  dispatchAttemptFor: config.dispatchAttemptFor,
928
+ claimDispatchAttempt: config.claimDispatchAttempt,
922
929
  clickTimeoutMs: config.clickTimeoutMs,
923
930
  popupTimeoutMs: config.popupTimeoutMs,
924
931
  targetTtlMs: config.targetTtlMs,
@@ -1242,7 +1249,7 @@ function safeRuntimeError(error) {
1242
1249
  return httpJson(error.status, { code: error.code });
1243
1250
  }
1244
1251
  const record = error && typeof error === "object" ? error : void 0;
1245
- const candidateCode = record?.code;
1252
+ const candidateCode = record?.code === "POLICY_VIOLATION" ? "POLICY_DENIED" : record?.code === "APPROVAL_REQUIRED" ? "REQUIRES_APPROVAL" : record?.code;
1246
1253
  const code = typeof candidateCode === "string" && SAFE_RUNTIME_ERROR_CODES.has(candidateCode) ? candidateCode : "SERVER_ERROR";
1247
1254
  let status = typeof record?.status === "number" ? record.status : code.startsWith("BROWSER_") ? 409 : 500;
1248
1255
  if (!Number.isInteger(status) || status < 400 || status > 599) status = 409;
@@ -7,9 +7,9 @@ import {
7
7
  createPlaywrightCdpSessionRegistry,
8
8
  createPlaywrightCheckoutAdapter,
9
9
  createPlaywrightSessionObserver
10
- } from "./chunk-HM4EG5MH.mjs";
10
+ } from "./chunk-VSIO6PYA.mjs";
11
11
  import "./chunk-O5RAAB2U.mjs";
12
- import "./chunk-B7F5QLE5.mjs";
12
+ import "./chunk-WSIKPUZJ.mjs";
13
13
  export {
14
14
  createEncryptedPlaywrightCheckoutTargetStore,
15
15
  createGuardedPlaywrightCheckoutHttpHandler,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conto_finance/sdk",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Conto SDK for AI agent payment authorization",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",