@dakota-xyz/ts-sdk 2.1.0 → 2.1.1

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.js CHANGED
@@ -136,6 +136,8 @@ var AuthMode = /* @__PURE__ */ ((AuthMode2) => {
136
136
  AuthMode2["ApplicationToken"] = "application_token";
137
137
  return AuthMode2;
138
138
  })(AuthMode || {});
139
+ var DEFAULT_TIMEOUT_MS = 15e3;
140
+ var AGENTIC_MODEL_TIMEOUT_MS = 18e4;
139
141
  var DEFAULT_RETRY_POLICY = {
140
142
  maxAttempts: 3,
141
143
  initialBackoffMs: 200,
@@ -193,7 +195,8 @@ function resolveConfig(config) {
193
195
  const env = config.environment ?? "sandbox" /* Sandbox */;
194
196
  baseURL = getEnvironmentURL(env);
195
197
  }
196
- const timeout = config.timeout ?? 15e3;
198
+ const timeoutWasExplicit = config.timeout !== void 0;
199
+ const timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
197
200
  if (timeout <= 0) {
198
201
  throw new ConfigurationError("Timeout must be greater than zero");
199
202
  }
@@ -220,6 +223,7 @@ function resolveConfig(config) {
220
223
  baseURL,
221
224
  authMode,
222
225
  timeout,
226
+ timeoutWasExplicit,
223
227
  retryPolicy,
224
228
  logger: config.logger ?? noopLogger,
225
229
  automaticIdempotency: config.automaticIdempotency ?? true,
@@ -245,12 +249,16 @@ var Transport = class {
245
249
  const url = this.buildURL(path, query);
246
250
  const requestHeaders = this.buildHeaders(method, path, headers, idempotencyKey);
247
251
  const requestBody = body !== void 0 ? JSON.stringify(body) : void 0;
248
- return this.executeWithRetry(url, {
249
- method,
250
- headers: requestHeaders,
251
- body: requestBody,
252
- signal
253
- });
252
+ return this.executeWithRetry(
253
+ url,
254
+ {
255
+ method,
256
+ headers: requestHeaders,
257
+ body: requestBody,
258
+ signal
259
+ },
260
+ this.resolveTimeout(options)
261
+ );
254
262
  }
255
263
  /**
256
264
  * Build the full URL with query parameters.
@@ -316,17 +324,47 @@ var Transport = class {
316
324
  break;
317
325
  }
318
326
  }
327
+ /**
328
+ * Resolve the deadline for one request, most specific intent first:
329
+ *
330
+ * 1. the caller's per-request `timeout`
331
+ * 2. an explicit client-wide `timeout`
332
+ * 3. the endpoint's own default (slow endpoints raise their own)
333
+ * 4. the client-wide default
334
+ *
335
+ * (2) sits above (3) on purpose: a caller who configured a timeout chose
336
+ * it, and an endpoint must not quietly overrule that. (3) exists so the
337
+ * far more common caller — the one who configured nothing — gets a
338
+ * deadline that matches what the endpoint actually does.
339
+ */
340
+ resolveTimeout(options) {
341
+ if (options.timeout !== void 0) {
342
+ return options.timeout;
343
+ }
344
+ if (this.config.timeoutWasExplicit) {
345
+ return this.config.timeout;
346
+ }
347
+ return options.endpointTimeout ?? this.config.timeout;
348
+ }
319
349
  /**
320
350
  * Execute request with exponential backoff retry.
351
+ *
352
+ * `timeout` is per ATTEMPT, not per call: each attempt gets its own
353
+ * deadline, so a request that keeps timing out can take up to
354
+ * `timeout × maxAttempts` before it throws.
321
355
  */
322
- async executeWithRetry(url, init) {
356
+ async executeWithRetry(url, init, timeout) {
323
357
  const { maxAttempts, initialBackoffMs, maxBackoffMs } = this.config.retryPolicy;
324
358
  const method = init.method ?? "GET";
325
359
  let lastError;
326
360
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
361
+ let timedOut = false;
327
362
  try {
328
363
  const controller = new AbortController();
329
- const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
364
+ const timeoutId = setTimeout(() => {
365
+ timedOut = true;
366
+ controller.abort();
367
+ }, timeout);
330
368
  const signal = init.signal ? this.mergeAbortSignals(init.signal, controller.signal) : controller.signal;
331
369
  this.logRequest(method, url, attempt);
332
370
  const response = await this.config.fetch(url, {
@@ -356,8 +394,13 @@ var Transport = class {
356
394
  if (error instanceof APIError) {
357
395
  throw error;
358
396
  }
359
- if (error instanceof Error && error.name === "AbortError") {
360
- lastError = new TransportError("Request timed out", error);
397
+ if (error instanceof Error && error.name === "AbortError" && timedOut) {
398
+ lastError = new TransportError(
399
+ `Request timed out after ${timeout}ms. This is the SDK's client-side deadline, not a server error \u2014 raise it with \`new DakotaClient({ timeout })\`, or per call with \`{ timeout }\` in the request options. Agent conversations are the usual cause: pass \`{ timeout }\` to \`newAgentConversation\`.`,
400
+ error
401
+ );
402
+ } else if (error instanceof Error && error.name === "AbortError") {
403
+ throw new TransportError("Request aborted by caller", error);
361
404
  } else if (error instanceof Error) {
362
405
  lastError = new TransportError("Network error", error);
363
406
  } else {
@@ -581,6 +624,9 @@ var BaseResource = class {
581
624
  path,
582
625
  query
583
626
  });
627
+ if (Array.isArray(response)) {
628
+ return { data: response, meta: void 0 };
629
+ }
584
630
  return {
585
631
  data: response.data ?? [],
586
632
  meta: response.meta
@@ -632,7 +678,8 @@ var CustomersResource = class extends BaseResource {
632
678
  method: "POST",
633
679
  path: "/customers",
634
680
  body: data,
635
- idempotencyKey: options?.idempotencyKey
681
+ idempotencyKey: options?.idempotencyKey,
682
+ timeout: options?.timeout
636
683
  });
637
684
  }
638
685
  /**
@@ -746,7 +793,8 @@ var CustomersResource = class extends BaseResource {
746
793
  return this.transport.request({
747
794
  method: "POST",
748
795
  path: `/customers/${customerId}/re-engagement`,
749
- idempotencyKey: options?.idempotencyKey
796
+ idempotencyKey: options?.idempotencyKey,
797
+ timeout: options?.timeout
750
798
  });
751
799
  }
752
800
  /**
@@ -782,7 +830,8 @@ var CustomersResource = class extends BaseResource {
782
830
  method: "PATCH",
783
831
  path: `/customers/${customerId}/sub-client`,
784
832
  body: data,
785
- idempotencyKey: options?.idempotencyKey
833
+ idempotencyKey: options?.idempotencyKey,
834
+ timeout: options?.timeout
786
835
  });
787
836
  }
788
837
  /**
@@ -832,7 +881,8 @@ var CustomersResource = class extends BaseResource {
832
881
  method: "POST",
833
882
  path: "/customers/bulk-import-sumsub-tokens",
834
883
  body: data,
835
- idempotencyKey: options?.idempotencyKey
884
+ idempotencyKey: options?.idempotencyKey,
885
+ timeout: options?.timeout
836
886
  });
837
887
  }
838
888
  /**
@@ -865,7 +915,8 @@ var CustomersResource = class extends BaseResource {
865
915
  method: "POST",
866
916
  path: "/customers/import-persona-tokens",
867
917
  body: data,
868
- idempotencyKey: options?.idempotencyKey
918
+ idempotencyKey: options?.idempotencyKey,
919
+ timeout: options?.timeout
869
920
  });
870
921
  }
871
922
  /**
@@ -947,7 +998,8 @@ var RecipientsResource = class extends BaseResource {
947
998
  method: "POST",
948
999
  path: `/customers/${customerId}/recipients`,
949
1000
  body: data,
950
- idempotencyKey: options?.idempotencyKey
1001
+ idempotencyKey: options?.idempotencyKey,
1002
+ timeout: options?.timeout
951
1003
  });
952
1004
  }
953
1005
  /**
@@ -1003,7 +1055,8 @@ var RecipientsResource = class extends BaseResource {
1003
1055
  method: "PUT",
1004
1056
  path: `/recipients/${recipientId}`,
1005
1057
  body: data,
1006
- idempotencyKey: options?.idempotencyKey
1058
+ idempotencyKey: options?.idempotencyKey,
1059
+ timeout: options?.timeout
1007
1060
  });
1008
1061
  }
1009
1062
  /**
@@ -1069,7 +1122,8 @@ var DestinationsResource = class extends BaseResource {
1069
1122
  method: "POST",
1070
1123
  path: `/recipients/${recipientId}/destinations`,
1071
1124
  body: data,
1072
- idempotencyKey: options?.idempotencyKey
1125
+ idempotencyKey: options?.idempotencyKey,
1126
+ timeout: options?.timeout
1073
1127
  });
1074
1128
  }
1075
1129
  /**
@@ -1157,7 +1211,8 @@ var AccountsResource = class extends BaseResource {
1157
1211
  method: "POST",
1158
1212
  path: "/accounts",
1159
1213
  body: data,
1160
- idempotencyKey: options?.idempotencyKey
1214
+ idempotencyKey: options?.idempotencyKey,
1215
+ timeout: options?.timeout
1161
1216
  });
1162
1217
  }
1163
1218
  /**
@@ -1216,7 +1271,8 @@ var AccountsResource = class extends BaseResource {
1216
1271
  method: "PATCH",
1217
1272
  path: `/accounts/${accountId}`,
1218
1273
  body: data,
1219
- idempotencyKey: options?.idempotencyKey
1274
+ idempotencyKey: options?.idempotencyKey,
1275
+ timeout: options?.timeout
1220
1276
  });
1221
1277
  }
1222
1278
  /**
@@ -1276,7 +1332,8 @@ var TransactionsResource = class extends BaseResource {
1276
1332
  method: "POST",
1277
1333
  path: "/transactions",
1278
1334
  body: data,
1279
- idempotencyKey: options?.idempotencyKey
1335
+ idempotencyKey: options?.idempotencyKey,
1336
+ timeout: options?.timeout
1280
1337
  });
1281
1338
  }
1282
1339
  /**
@@ -1346,7 +1403,8 @@ var TransactionsResource = class extends BaseResource {
1346
1403
  return this.transport.request({
1347
1404
  method: "POST",
1348
1405
  path: `/transactions/${transactionId}/cancellations`,
1349
- idempotencyKey: options?.idempotencyKey
1406
+ idempotencyKey: options?.idempotencyKey,
1407
+ timeout: options?.timeout
1350
1408
  });
1351
1409
  }
1352
1410
  };
@@ -1399,7 +1457,8 @@ var WalletsResource = class extends BaseResource {
1399
1457
  method: "POST",
1400
1458
  path: "/wallets",
1401
1459
  body: data,
1402
- idempotencyKey: options?.idempotencyKey
1460
+ idempotencyKey: options?.idempotencyKey,
1461
+ timeout: options?.timeout
1403
1462
  });
1404
1463
  }
1405
1464
  /**
@@ -1521,7 +1580,8 @@ var WalletsResource = class extends BaseResource {
1521
1580
  method: "POST",
1522
1581
  path: `/wallets/${walletId}/transactions`,
1523
1582
  body: data,
1524
- idempotencyKey: options?.idempotencyKey
1583
+ idempotencyKey: options?.idempotencyKey,
1584
+ timeout: options?.timeout
1525
1585
  });
1526
1586
  }
1527
1587
  };
@@ -1588,7 +1648,8 @@ var ApplicationsResource = class extends BaseResource {
1588
1648
  method: "POST",
1589
1649
  path: `/applications/${applicationId}/submissions`,
1590
1650
  body: data ?? {},
1591
- idempotencyKey: options?.idempotencyKey
1651
+ idempotencyKey: options?.idempotencyKey,
1652
+ timeout: options?.timeout
1592
1653
  });
1593
1654
  }
1594
1655
  // ==========================================================================
@@ -1608,7 +1669,8 @@ var ApplicationsResource = class extends BaseResource {
1608
1669
  method: "PUT",
1609
1670
  path: `/applications/${applicationId}/business-details`,
1610
1671
  body: data,
1611
- idempotencyKey: options?.idempotencyKey
1672
+ idempotencyKey: options?.idempotencyKey,
1673
+ timeout: options?.timeout
1612
1674
  });
1613
1675
  }
1614
1676
  // ==========================================================================
@@ -1629,7 +1691,8 @@ var ApplicationsResource = class extends BaseResource {
1629
1691
  method: "PUT",
1630
1692
  path: `/applications/${applicationId}/individual-details`,
1631
1693
  body: data,
1632
- idempotencyKey: options?.idempotencyKey
1694
+ idempotencyKey: options?.idempotencyKey,
1695
+ timeout: options?.timeout
1633
1696
  });
1634
1697
  }
1635
1698
  // ==========================================================================
@@ -1647,7 +1710,8 @@ var ApplicationsResource = class extends BaseResource {
1647
1710
  method: "POST",
1648
1711
  path: `/applications/${applicationId}/associated-individuals`,
1649
1712
  body: data,
1650
- idempotencyKey: options?.idempotencyKey
1713
+ idempotencyKey: options?.idempotencyKey,
1714
+ timeout: options?.timeout
1651
1715
  });
1652
1716
  }
1653
1717
  /**
@@ -1665,7 +1729,8 @@ var ApplicationsResource = class extends BaseResource {
1665
1729
  method: "PUT",
1666
1730
  path: `/applications/${applicationId}/associated-individuals/${individualId}`,
1667
1731
  body: data,
1668
- idempotencyKey: options?.idempotencyKey
1732
+ idempotencyKey: options?.idempotencyKey,
1733
+ timeout: options?.timeout
1669
1734
  });
1670
1735
  }
1671
1736
  /**
@@ -1704,7 +1769,8 @@ var ApplicationsResource = class extends BaseResource {
1704
1769
  method: "POST",
1705
1770
  path: `/applications/${applicationId}/attestations`,
1706
1771
  body: data,
1707
- idempotencyKey: options?.idempotencyKey
1772
+ idempotencyKey: options?.idempotencyKey,
1773
+ timeout: options?.timeout
1708
1774
  });
1709
1775
  }
1710
1776
  // ==========================================================================
@@ -1736,7 +1802,8 @@ var ApplicationsResource = class extends BaseResource {
1736
1802
  method: "PUT",
1737
1803
  path: `/applications/${applicationId}/edd`,
1738
1804
  body: data,
1739
- idempotencyKey: options?.idempotencyKey
1805
+ idempotencyKey: options?.idempotencyKey,
1806
+ timeout: options?.timeout
1740
1807
  });
1741
1808
  }
1742
1809
  // ==========================================================================
@@ -1757,7 +1824,8 @@ var ApplicationsResource = class extends BaseResource {
1757
1824
  method: "POST",
1758
1825
  path: `/applications/${applicationId}/documents`,
1759
1826
  body: data,
1760
- idempotencyKey: options?.idempotencyKey
1827
+ idempotencyKey: options?.idempotencyKey,
1828
+ timeout: options?.timeout
1761
1829
  });
1762
1830
  }
1763
1831
  /**
@@ -1817,7 +1885,8 @@ var ApplicationsResource = class extends BaseResource {
1817
1885
  method: "POST",
1818
1886
  path: `/applications/${applicationId}/documents/${documentId}/verifications`,
1819
1887
  body: _data ?? {},
1820
- idempotencyKey: options?.idempotencyKey
1888
+ idempotencyKey: options?.idempotencyKey,
1889
+ timeout: options?.timeout
1821
1890
  });
1822
1891
  }
1823
1892
  /**
@@ -1835,7 +1904,8 @@ var ApplicationsResource = class extends BaseResource {
1835
1904
  method: "POST",
1836
1905
  path: `/applications/${applicationId}/document-uploads`,
1837
1906
  body: data,
1838
- idempotencyKey: options?.idempotencyKey
1907
+ idempotencyKey: options?.idempotencyKey,
1908
+ timeout: options?.timeout
1839
1909
  });
1840
1910
  }
1841
1911
  // ==========================================================================
@@ -1858,7 +1928,8 @@ var ApplicationsResource = class extends BaseResource {
1858
1928
  method: "POST",
1859
1929
  path: `/applications/${applicationId}/associated-individuals/${individualId}/documents`,
1860
1930
  body: data,
1861
- idempotencyKey: options?.idempotencyKey
1931
+ idempotencyKey: options?.idempotencyKey,
1932
+ timeout: options?.timeout
1862
1933
  });
1863
1934
  }
1864
1935
  /**
@@ -1877,7 +1948,8 @@ var ApplicationsResource = class extends BaseResource {
1877
1948
  method: "POST",
1878
1949
  path: `/applications/${applicationId}/associated-individuals/${individualId}/document-uploads`,
1879
1950
  body: data,
1880
- idempotencyKey: options?.idempotencyKey
1951
+ idempotencyKey: options?.idempotencyKey,
1952
+ timeout: options?.timeout
1881
1953
  });
1882
1954
  }
1883
1955
  };
@@ -1895,7 +1967,8 @@ var PoliciesResource = class extends BaseResource {
1895
1967
  method: "POST",
1896
1968
  path: "/policies",
1897
1969
  body: data,
1898
- idempotencyKey: options?.idempotencyKey
1970
+ idempotencyKey: options?.idempotencyKey,
1971
+ timeout: options?.timeout
1899
1972
  });
1900
1973
  }
1901
1974
  /**
@@ -1934,7 +2007,8 @@ var PoliciesResource = class extends BaseResource {
1934
2007
  method: "DELETE",
1935
2008
  path: `/policies/${policyId}`,
1936
2009
  body: options?.endorsement,
1937
- idempotencyKey: options?.idempotencyKey
2010
+ idempotencyKey: options?.idempotencyKey,
2011
+ timeout: options?.timeout
1938
2012
  });
1939
2013
  }
1940
2014
  /**
@@ -1949,7 +2023,8 @@ var PoliciesResource = class extends BaseResource {
1949
2023
  method: "POST",
1950
2024
  path: `/policies/${policyId}/rules`,
1951
2025
  body: options?.endorsement ?? data,
1952
- idempotencyKey: options?.idempotencyKey
2026
+ idempotencyKey: options?.idempotencyKey,
2027
+ timeout: options?.timeout
1953
2028
  });
1954
2029
  }
1955
2030
  /**
@@ -1965,7 +2040,8 @@ var PoliciesResource = class extends BaseResource {
1965
2040
  method: "PATCH",
1966
2041
  path: `/policies/${policyId}/rules/${ruleId}`,
1967
2042
  body: options?.endorsement ?? data,
1968
- idempotencyKey: options?.idempotencyKey
2043
+ idempotencyKey: options?.idempotencyKey,
2044
+ timeout: options?.timeout
1969
2045
  });
1970
2046
  }
1971
2047
  /**
@@ -1984,7 +2060,8 @@ var PoliciesResource = class extends BaseResource {
1984
2060
  method: "DELETE",
1985
2061
  path: `/policies/${policyId}/rules/${ruleId}`,
1986
2062
  body: options?.endorsement,
1987
- idempotencyKey: options?.idempotencyKey
2063
+ idempotencyKey: options?.idempotencyKey,
2064
+ timeout: options?.timeout
1988
2065
  });
1989
2066
  }
1990
2067
  /**
@@ -2017,7 +2094,8 @@ var PoliciesResource = class extends BaseResource {
2017
2094
  method: "PUT",
2018
2095
  path: `/policies/${policyId}/wallets/${walletId}`,
2019
2096
  body: options?.endorsement,
2020
- idempotencyKey: options?.idempotencyKey
2097
+ idempotencyKey: options?.idempotencyKey,
2098
+ timeout: options?.timeout
2021
2099
  });
2022
2100
  }
2023
2101
  /**
@@ -2036,7 +2114,8 @@ var PoliciesResource = class extends BaseResource {
2036
2114
  method: "DELETE",
2037
2115
  path: `/policies/${policyId}/wallets/${walletId}`,
2038
2116
  body: options?.endorsement,
2039
- idempotencyKey: options?.idempotencyKey
2117
+ idempotencyKey: options?.idempotencyKey,
2118
+ timeout: options?.timeout
2040
2119
  });
2041
2120
  }
2042
2121
  };
@@ -2054,7 +2133,8 @@ var SignerGroupsResource = class extends BaseResource {
2054
2133
  method: "POST",
2055
2134
  path: "/signer-groups",
2056
2135
  body: data,
2057
- idempotencyKey: options?.idempotencyKey
2136
+ idempotencyKey: options?.idempotencyKey,
2137
+ timeout: options?.timeout
2058
2138
  });
2059
2139
  }
2060
2140
  /**
@@ -2108,7 +2188,8 @@ var SignerGroupsResource = class extends BaseResource {
2108
2188
  method: "POST",
2109
2189
  path: `/signer-groups/${signerGroupId}/signers`,
2110
2190
  body: data,
2111
- idempotencyKey: options?.idempotencyKey
2191
+ idempotencyKey: options?.idempotencyKey,
2192
+ timeout: options?.timeout
2112
2193
  });
2113
2194
  }
2114
2195
  /**
@@ -2124,7 +2205,8 @@ var SignerGroupsResource = class extends BaseResource {
2124
2205
  await this.transport.request({
2125
2206
  method: "DELETE",
2126
2207
  path: `/signer-groups/${signerGroupId}/signers/${signerId}`,
2127
- idempotencyKey: options?.idempotencyKey
2208
+ idempotencyKey: options?.idempotencyKey,
2209
+ timeout: options?.timeout
2128
2210
  });
2129
2211
  }
2130
2212
  /**
@@ -2157,7 +2239,8 @@ var SignerGroupsResource = class extends BaseResource {
2157
2239
  method: "PUT",
2158
2240
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
2159
2241
  body: options?.endorsement,
2160
- idempotencyKey: options?.idempotencyKey
2242
+ idempotencyKey: options?.idempotencyKey,
2243
+ timeout: options?.timeout
2161
2244
  });
2162
2245
  }
2163
2246
  /**
@@ -2176,7 +2259,8 @@ var SignerGroupsResource = class extends BaseResource {
2176
2259
  method: "DELETE",
2177
2260
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
2178
2261
  body: options?.endorsement,
2179
- idempotencyKey: options?.idempotencyKey
2262
+ idempotencyKey: options?.idempotencyKey,
2263
+ timeout: options?.timeout
2180
2264
  });
2181
2265
  }
2182
2266
  /**
@@ -2203,7 +2287,8 @@ var SignersResource = class extends BaseResource {
2203
2287
  method: "POST",
2204
2288
  path: "/signers",
2205
2289
  body: data,
2206
- idempotencyKey: options?.idempotencyKey
2290
+ idempotencyKey: options?.idempotencyKey,
2291
+ timeout: options?.timeout
2207
2292
  });
2208
2293
  }
2209
2294
  /**
@@ -2234,7 +2319,8 @@ var ApiKeysResource = class extends BaseResource {
2234
2319
  method: "POST",
2235
2320
  path: "/api-keys",
2236
2321
  body: data,
2237
- idempotencyKey: options?.idempotencyKey
2322
+ idempotencyKey: options?.idempotencyKey,
2323
+ timeout: options?.timeout
2238
2324
  });
2239
2325
  }
2240
2326
  /**
@@ -2282,7 +2368,8 @@ var ApiKeysResource = class extends BaseResource {
2282
2368
  method: "POST",
2283
2369
  path: "/api-keys/admin",
2284
2370
  body: data,
2285
- idempotencyKey: options?.idempotencyKey
2371
+ idempotencyKey: options?.idempotencyKey,
2372
+ timeout: options?.timeout
2286
2373
  });
2287
2374
  }
2288
2375
  };
@@ -2300,7 +2387,8 @@ var UsersResource = class extends BaseResource {
2300
2387
  method: "POST",
2301
2388
  path: "/users",
2302
2389
  body: data,
2303
- idempotencyKey: options?.idempotencyKey
2390
+ idempotencyKey: options?.idempotencyKey,
2391
+ timeout: options?.timeout
2304
2392
  });
2305
2393
  }
2306
2394
  /**
@@ -2323,7 +2411,8 @@ var UsersResource = class extends BaseResource {
2323
2411
  method: "PATCH",
2324
2412
  path: `/users/${userId}`,
2325
2413
  body: data,
2326
- idempotencyKey: options?.idempotencyKey
2414
+ idempotencyKey: options?.idempotencyKey,
2415
+ timeout: options?.timeout
2327
2416
  });
2328
2417
  }
2329
2418
  /**
@@ -2352,7 +2441,8 @@ var WebhooksResource = class extends BaseResource {
2352
2441
  method: "POST",
2353
2442
  path: "/webhooks/targets",
2354
2443
  body: data,
2355
- idempotencyKey: options?.idempotencyKey
2444
+ idempotencyKey: options?.idempotencyKey,
2445
+ timeout: options?.timeout
2356
2446
  });
2357
2447
  }
2358
2448
  /**
@@ -2388,7 +2478,8 @@ var WebhooksResource = class extends BaseResource {
2388
2478
  method: "PATCH",
2389
2479
  path: `/webhooks/targets/${targetId}`,
2390
2480
  body: data,
2391
- idempotencyKey: options?.idempotencyKey
2481
+ idempotencyKey: options?.idempotencyKey,
2482
+ timeout: options?.timeout
2392
2483
  });
2393
2484
  }
2394
2485
  /**
@@ -2465,7 +2556,8 @@ var WebhooksResource = class extends BaseResource {
2465
2556
  return this.transport.request({
2466
2557
  method: "POST",
2467
2558
  path: `/webhooks/events/${eventId}/replay`,
2468
- idempotencyKey: options?.idempotencyKey
2559
+ idempotencyKey: options?.idempotencyKey,
2560
+ timeout: options?.timeout
2469
2561
  });
2470
2562
  }
2471
2563
  };
@@ -2576,7 +2668,8 @@ var SandboxResource = class extends BaseResource {
2576
2668
  method: "POST",
2577
2669
  path: "/sandbox/simulate/inbound",
2578
2670
  body: data,
2579
- idempotencyKey: options?.idempotencyKey
2671
+ idempotencyKey: options?.idempotencyKey,
2672
+ timeout: options?.timeout
2580
2673
  });
2581
2674
  }
2582
2675
  /**
@@ -2625,7 +2718,8 @@ var SandboxResource = class extends BaseResource {
2625
2718
  method: "POST",
2626
2719
  path: "/sandbox/simulate/onboarding",
2627
2720
  body: data,
2628
- idempotencyKey: options?.idempotencyKey
2721
+ idempotencyKey: options?.idempotencyKey,
2722
+ timeout: options?.timeout
2629
2723
  });
2630
2724
  }
2631
2725
  /**
@@ -2673,7 +2767,8 @@ var SandboxResource = class extends BaseResource {
2673
2767
  method: "POST",
2674
2768
  path: `/sandbox/simulations/${simulationId}/advance`,
2675
2769
  body: data,
2676
- idempotencyKey: options?.idempotencyKey
2770
+ idempotencyKey: options?.idempotencyKey,
2771
+ timeout: options?.timeout
2677
2772
  });
2678
2773
  }
2679
2774
  /**
@@ -2722,7 +2817,8 @@ var SelfServeResource = class extends BaseResource {
2722
2817
  method: "POST",
2723
2818
  path: "/self-serve/credits/purchase",
2724
2819
  body: data,
2725
- idempotencyKey: options?.idempotencyKey
2820
+ idempotencyKey: options?.idempotencyKey,
2821
+ timeout: options?.timeout
2726
2822
  });
2727
2823
  }
2728
2824
  /**
@@ -2868,7 +2964,8 @@ var FeePayoutDestinationResource = class extends BaseResource {
2868
2964
  method: "PUT",
2869
2965
  path: "/fee-payout-destination",
2870
2966
  body: data,
2871
- idempotencyKey: options?.idempotencyKey
2967
+ idempotencyKey: options?.idempotencyKey,
2968
+ timeout: options?.timeout
2872
2969
  });
2873
2970
  }
2874
2971
  /**
@@ -2902,7 +2999,8 @@ var PaymentAgentsResource = class extends BaseResource {
2902
2999
  method: "POST",
2903
3000
  path: "/payment-agents",
2904
3001
  body: data,
2905
- idempotencyKey: options?.idempotencyKey
3002
+ idempotencyKey: options?.idempotencyKey,
3003
+ timeout: options?.timeout
2906
3004
  });
2907
3005
  }
2908
3006
  /**
@@ -2941,7 +3039,8 @@ var PaymentAgentsResource = class extends BaseResource {
2941
3039
  return this.transport.request({
2942
3040
  method: "POST",
2943
3041
  path: `/payment-agents/${paymentAgentId}/revoke`,
2944
- idempotencyKey: options?.idempotencyKey
3042
+ idempotencyKey: options?.idempotencyKey,
3043
+ timeout: options?.timeout
2945
3044
  });
2946
3045
  }
2947
3046
  /**
@@ -2953,6 +3052,12 @@ var PaymentAgentsResource = class extends BaseResource {
2953
3052
  * `AgentConversation` for multi-turn chat; use this directly only for
2954
3053
  * one-shot proposals.
2955
3054
  *
3055
+ * SLOW BY NATURE. A turn is a sequence of model calls — read the payees,
3056
+ * check balances, draft, revise — so a multi-payee request legitimately
3057
+ * runs minutes. It therefore defaults to {@link AGENTIC_MODEL_TIMEOUT_MS}
3058
+ * rather than the client's ordinary deadline. Pass `{ timeout }` to
3059
+ * change it for one call; an explicit client-wide `timeout` still wins.
3060
+ *
2956
3061
  * @param paymentAgentId - Payment agent ID
2957
3062
  * @param data - Prompt and/or messages
2958
3063
  * @returns Proposals (at high confidence) and/or a conversational reply
@@ -2962,7 +3067,9 @@ var PaymentAgentsResource = class extends BaseResource {
2962
3067
  method: "POST",
2963
3068
  path: `/payment-agents/${paymentAgentId}/proposals`,
2964
3069
  body: data,
2965
- idempotencyKey: options?.idempotencyKey
3070
+ idempotencyKey: options?.idempotencyKey,
3071
+ timeout: options?.timeout,
3072
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
2966
3073
  });
2967
3074
  }
2968
3075
  /**
@@ -3016,7 +3123,8 @@ var InstructionsResource = class extends BaseResource {
3016
3123
  method: "POST",
3017
3124
  path: "/instructions",
3018
3125
  body: data,
3019
- idempotencyKey: options?.idempotencyKey
3126
+ idempotencyKey: options?.idempotencyKey,
3127
+ timeout: options?.timeout
3020
3128
  });
3021
3129
  }
3022
3130
  /**
@@ -3077,7 +3185,8 @@ var MandatesResource = class extends BaseResource {
3077
3185
  method: "POST",
3078
3186
  path: "/mandates",
3079
3187
  body: data,
3080
- idempotencyKey: options?.idempotencyKey
3188
+ idempotencyKey: options?.idempotencyKey,
3189
+ timeout: options?.timeout
3081
3190
  });
3082
3191
  }
3083
3192
  /**
@@ -3095,7 +3204,8 @@ var MandatesResource = class extends BaseResource {
3095
3204
  method: "POST",
3096
3205
  path: `/mandates/${mandateId}/approve`,
3097
3206
  body: data,
3098
- idempotencyKey: options?.idempotencyKey
3207
+ idempotencyKey: options?.idempotencyKey,
3208
+ timeout: options?.timeout
3099
3209
  });
3100
3210
  }
3101
3211
  /**
@@ -3113,7 +3223,8 @@ var MandatesResource = class extends BaseResource {
3113
3223
  method: "POST",
3114
3224
  path: `/mandates/${mandateId}/cancel`,
3115
3225
  body: data,
3116
- idempotencyKey: options?.idempotencyKey
3226
+ idempotencyKey: options?.idempotencyKey,
3227
+ timeout: options?.timeout
3117
3228
  });
3118
3229
  }
3119
3230
  /**
@@ -3159,7 +3270,8 @@ var MandatesResource = class extends BaseResource {
3159
3270
  method: "POST",
3160
3271
  path: `/mandates/${mandateId}/amend`,
3161
3272
  body: data,
3162
- idempotencyKey: options?.idempotencyKey
3273
+ idempotencyKey: options?.idempotencyKey,
3274
+ timeout: options?.timeout
3163
3275
  });
3164
3276
  }
3165
3277
  /**
@@ -3245,7 +3357,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
3245
3357
  method: "POST",
3246
3358
  path: "/scheduled-payments",
3247
3359
  body: data,
3248
- idempotencyKey: options?.idempotencyKey
3360
+ idempotencyKey: options?.idempotencyKey,
3361
+ timeout: options?.timeout
3249
3362
  });
3250
3363
  }
3251
3364
  /**
@@ -3261,7 +3374,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
3261
3374
  await this.transport.request({
3262
3375
  method: "POST",
3263
3376
  path: `/scheduled-payments/${scheduledPaymentId}/cancel`,
3264
- idempotencyKey: options?.idempotencyKey
3377
+ idempotencyKey: options?.idempotencyKey,
3378
+ timeout: options?.timeout
3265
3379
  });
3266
3380
  }
3267
3381
  };
@@ -3297,6 +3411,10 @@ var InsightsResource = class extends BaseResource {
3297
3411
  * never moves money. Rate-limited per customer (hourly burst + daily
3298
3412
  * window) — a 429 means back off and retry later.
3299
3413
  *
3414
+ * Model-backed, so it defaults to {@link AGENTIC_MODEL_TIMEOUT_MS} rather
3415
+ * than the client's ordinary deadline. Pass `{ timeout }` to change it for
3416
+ * one call; an explicit client-wide `timeout` still wins.
3417
+ *
3300
3418
  * @param customerId - Customer ID
3301
3419
  * @param data - The conversation so far (1–40 messages)
3302
3420
  * @returns The assistant's reply (+ how the boundary screen treated the turn)
@@ -3306,7 +3424,9 @@ var InsightsResource = class extends BaseResource {
3306
3424
  method: "POST",
3307
3425
  path: `/customers/${customerId}/insights/chat`,
3308
3426
  body: data,
3309
- idempotencyKey: options?.idempotencyKey
3427
+ idempotencyKey: options?.idempotencyKey,
3428
+ timeout: options?.timeout,
3429
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
3310
3430
  });
3311
3431
  }
3312
3432
  };
@@ -3316,11 +3436,13 @@ var AgentConversation = class {
3316
3436
  client;
3317
3437
  paymentAgentId;
3318
3438
  timezone;
3439
+ timeout;
3319
3440
  history = [];
3320
3441
  constructor(client, paymentAgentId, history, options) {
3321
3442
  this.client = client;
3322
3443
  this.paymentAgentId = paymentAgentId;
3323
3444
  this.timezone = options?.timezone;
3445
+ this.timeout = options?.timeout;
3324
3446
  if (history && history.length > 0) {
3325
3447
  this.history = history.map(cloneMessage);
3326
3448
  }
@@ -3361,12 +3483,16 @@ var AgentConversation = class {
3361
3483
  }
3362
3484
  let result;
3363
3485
  try {
3364
- result = await this.client.paymentAgents.createProposals(this.paymentAgentId, {
3365
- messages,
3366
- // Resent on EVERY turn — the endpoint is stateless, so a zone given
3367
- // once would be forgotten on the next one.
3368
- ...this.timezone ? { timezone: this.timezone } : {}
3369
- });
3486
+ result = await this.client.paymentAgents.createProposals(
3487
+ this.paymentAgentId,
3488
+ {
3489
+ messages,
3490
+ // Resent on EVERY turn — the endpoint is stateless, so a zone given
3491
+ // once would be forgotten on the next one.
3492
+ ...this.timezone ? { timezone: this.timezone } : {}
3493
+ },
3494
+ this.timeout !== void 0 ? { timeout: this.timeout } : void 0
3495
+ );
3370
3496
  } catch (err) {
3371
3497
  this.history.pop();
3372
3498
  throw err;