@dakota-xyz/ts-sdk 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -134,6 +134,8 @@ var AuthMode = /* @__PURE__ */ ((AuthMode2) => {
134
134
  AuthMode2["ApplicationToken"] = "application_token";
135
135
  return AuthMode2;
136
136
  })(AuthMode || {});
137
+ var DEFAULT_TIMEOUT_MS = 15e3;
138
+ var AGENTIC_MODEL_TIMEOUT_MS = 18e4;
137
139
  var DEFAULT_RETRY_POLICY = {
138
140
  maxAttempts: 3,
139
141
  initialBackoffMs: 200,
@@ -191,7 +193,8 @@ function resolveConfig(config) {
191
193
  const env = config.environment ?? "sandbox" /* Sandbox */;
192
194
  baseURL = getEnvironmentURL(env);
193
195
  }
194
- const timeout = config.timeout ?? 15e3;
196
+ const timeoutWasExplicit = config.timeout !== void 0;
197
+ const timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
195
198
  if (timeout <= 0) {
196
199
  throw new ConfigurationError("Timeout must be greater than zero");
197
200
  }
@@ -218,6 +221,7 @@ function resolveConfig(config) {
218
221
  baseURL,
219
222
  authMode,
220
223
  timeout,
224
+ timeoutWasExplicit,
221
225
  retryPolicy,
222
226
  logger: config.logger ?? noopLogger,
223
227
  automaticIdempotency: config.automaticIdempotency ?? true,
@@ -243,12 +247,16 @@ var Transport = class {
243
247
  const url = this.buildURL(path, query);
244
248
  const requestHeaders = this.buildHeaders(method, path, headers, idempotencyKey);
245
249
  const requestBody = body !== void 0 ? JSON.stringify(body) : void 0;
246
- return this.executeWithRetry(url, {
247
- method,
248
- headers: requestHeaders,
249
- body: requestBody,
250
- signal
251
- });
250
+ return this.executeWithRetry(
251
+ url,
252
+ {
253
+ method,
254
+ headers: requestHeaders,
255
+ body: requestBody,
256
+ signal
257
+ },
258
+ this.resolveTimeout(options)
259
+ );
252
260
  }
253
261
  /**
254
262
  * Build the full URL with query parameters.
@@ -314,17 +322,47 @@ var Transport = class {
314
322
  break;
315
323
  }
316
324
  }
325
+ /**
326
+ * Resolve the deadline for one request, most specific intent first:
327
+ *
328
+ * 1. the caller's per-request `timeout`
329
+ * 2. an explicit client-wide `timeout`
330
+ * 3. the endpoint's own default (slow endpoints raise their own)
331
+ * 4. the client-wide default
332
+ *
333
+ * (2) sits above (3) on purpose: a caller who configured a timeout chose
334
+ * it, and an endpoint must not quietly overrule that. (3) exists so the
335
+ * far more common caller — the one who configured nothing — gets a
336
+ * deadline that matches what the endpoint actually does.
337
+ */
338
+ resolveTimeout(options) {
339
+ if (options.timeout !== void 0) {
340
+ return options.timeout;
341
+ }
342
+ if (this.config.timeoutWasExplicit) {
343
+ return this.config.timeout;
344
+ }
345
+ return options.endpointTimeout ?? this.config.timeout;
346
+ }
317
347
  /**
318
348
  * Execute request with exponential backoff retry.
349
+ *
350
+ * `timeout` is per ATTEMPT, not per call: each attempt gets its own
351
+ * deadline, so a request that keeps timing out can take up to
352
+ * `timeout × maxAttempts` before it throws.
319
353
  */
320
- async executeWithRetry(url, init) {
354
+ async executeWithRetry(url, init, timeout) {
321
355
  const { maxAttempts, initialBackoffMs, maxBackoffMs } = this.config.retryPolicy;
322
356
  const method = init.method ?? "GET";
323
357
  let lastError;
324
358
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
359
+ let timedOut = false;
325
360
  try {
326
361
  const controller = new AbortController();
327
- const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
362
+ const timeoutId = setTimeout(() => {
363
+ timedOut = true;
364
+ controller.abort();
365
+ }, timeout);
328
366
  const signal = init.signal ? this.mergeAbortSignals(init.signal, controller.signal) : controller.signal;
329
367
  this.logRequest(method, url, attempt);
330
368
  const response = await this.config.fetch(url, {
@@ -354,8 +392,13 @@ var Transport = class {
354
392
  if (error instanceof APIError) {
355
393
  throw error;
356
394
  }
357
- if (error instanceof Error && error.name === "AbortError") {
358
- lastError = new TransportError("Request timed out", error);
395
+ if (error instanceof Error && error.name === "AbortError" && timedOut) {
396
+ lastError = new TransportError(
397
+ `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\`.`,
398
+ error
399
+ );
400
+ } else if (error instanceof Error && error.name === "AbortError") {
401
+ throw new TransportError("Request aborted by caller", error);
359
402
  } else if (error instanceof Error) {
360
403
  lastError = new TransportError("Network error", error);
361
404
  } else {
@@ -579,6 +622,9 @@ var BaseResource = class {
579
622
  path,
580
623
  query
581
624
  });
625
+ if (Array.isArray(response)) {
626
+ return { data: response, meta: void 0 };
627
+ }
582
628
  return {
583
629
  data: response.data ?? [],
584
630
  meta: response.meta
@@ -630,7 +676,8 @@ var CustomersResource = class extends BaseResource {
630
676
  method: "POST",
631
677
  path: "/customers",
632
678
  body: data,
633
- idempotencyKey: options?.idempotencyKey
679
+ idempotencyKey: options?.idempotencyKey,
680
+ timeout: options?.timeout
634
681
  });
635
682
  }
636
683
  /**
@@ -744,7 +791,8 @@ var CustomersResource = class extends BaseResource {
744
791
  return this.transport.request({
745
792
  method: "POST",
746
793
  path: `/customers/${customerId}/re-engagement`,
747
- idempotencyKey: options?.idempotencyKey
794
+ idempotencyKey: options?.idempotencyKey,
795
+ timeout: options?.timeout
748
796
  });
749
797
  }
750
798
  /**
@@ -780,7 +828,8 @@ var CustomersResource = class extends BaseResource {
780
828
  method: "PATCH",
781
829
  path: `/customers/${customerId}/sub-client`,
782
830
  body: data,
783
- idempotencyKey: options?.idempotencyKey
831
+ idempotencyKey: options?.idempotencyKey,
832
+ timeout: options?.timeout
784
833
  });
785
834
  }
786
835
  /**
@@ -830,7 +879,8 @@ var CustomersResource = class extends BaseResource {
830
879
  method: "POST",
831
880
  path: "/customers/bulk-import-sumsub-tokens",
832
881
  body: data,
833
- idempotencyKey: options?.idempotencyKey
882
+ idempotencyKey: options?.idempotencyKey,
883
+ timeout: options?.timeout
834
884
  });
835
885
  }
836
886
  /**
@@ -863,7 +913,8 @@ var CustomersResource = class extends BaseResource {
863
913
  method: "POST",
864
914
  path: "/customers/import-persona-tokens",
865
915
  body: data,
866
- idempotencyKey: options?.idempotencyKey
916
+ idempotencyKey: options?.idempotencyKey,
917
+ timeout: options?.timeout
867
918
  });
868
919
  }
869
920
  /**
@@ -945,7 +996,8 @@ var RecipientsResource = class extends BaseResource {
945
996
  method: "POST",
946
997
  path: `/customers/${customerId}/recipients`,
947
998
  body: data,
948
- idempotencyKey: options?.idempotencyKey
999
+ idempotencyKey: options?.idempotencyKey,
1000
+ timeout: options?.timeout
949
1001
  });
950
1002
  }
951
1003
  /**
@@ -1001,7 +1053,8 @@ var RecipientsResource = class extends BaseResource {
1001
1053
  method: "PUT",
1002
1054
  path: `/recipients/${recipientId}`,
1003
1055
  body: data,
1004
- idempotencyKey: options?.idempotencyKey
1056
+ idempotencyKey: options?.idempotencyKey,
1057
+ timeout: options?.timeout
1005
1058
  });
1006
1059
  }
1007
1060
  /**
@@ -1067,7 +1120,8 @@ var DestinationsResource = class extends BaseResource {
1067
1120
  method: "POST",
1068
1121
  path: `/recipients/${recipientId}/destinations`,
1069
1122
  body: data,
1070
- idempotencyKey: options?.idempotencyKey
1123
+ idempotencyKey: options?.idempotencyKey,
1124
+ timeout: options?.timeout
1071
1125
  });
1072
1126
  }
1073
1127
  /**
@@ -1149,13 +1203,22 @@ var AccountsResource = class extends BaseResource {
1149
1203
  * });
1150
1204
  * // Returns: { bank_account: { bank_name, aba_routing_number, account_number } } - customer sends USD here
1151
1205
  * ```
1206
+ *
1207
+ * @remarks
1208
+ * `max_transactions` caps how many transactions the account may ever
1209
+ * create — `1` makes it a one-off. Know what reaching the cap does before
1210
+ * you set one: further deposits are **refused, not returned**. The funds
1211
+ * still arrive and are then held pending manual intervention, with nothing
1212
+ * converted, nothing forwarded, and no transaction on the account for
1213
+ * them. Stop sending to the deposit details once the cap is reached.
1152
1214
  */
1153
1215
  async create(data, options) {
1154
1216
  return this.transport.request({
1155
1217
  method: "POST",
1156
1218
  path: "/accounts",
1157
1219
  body: data,
1158
- idempotencyKey: options?.idempotencyKey
1220
+ idempotencyKey: options?.idempotencyKey,
1221
+ timeout: options?.timeout
1159
1222
  });
1160
1223
  }
1161
1224
  /**
@@ -1214,7 +1277,8 @@ var AccountsResource = class extends BaseResource {
1214
1277
  method: "PATCH",
1215
1278
  path: `/accounts/${accountId}`,
1216
1279
  body: data,
1217
- idempotencyKey: options?.idempotencyKey
1280
+ idempotencyKey: options?.idempotencyKey,
1281
+ timeout: options?.timeout
1218
1282
  });
1219
1283
  }
1220
1284
  /**
@@ -1274,7 +1338,8 @@ var TransactionsResource = class extends BaseResource {
1274
1338
  method: "POST",
1275
1339
  path: "/transactions",
1276
1340
  body: data,
1277
- idempotencyKey: options?.idempotencyKey
1341
+ idempotencyKey: options?.idempotencyKey,
1342
+ timeout: options?.timeout
1278
1343
  });
1279
1344
  }
1280
1345
  /**
@@ -1344,7 +1409,8 @@ var TransactionsResource = class extends BaseResource {
1344
1409
  return this.transport.request({
1345
1410
  method: "POST",
1346
1411
  path: `/transactions/${transactionId}/cancellations`,
1347
- idempotencyKey: options?.idempotencyKey
1412
+ idempotencyKey: options?.idempotencyKey,
1413
+ timeout: options?.timeout
1348
1414
  });
1349
1415
  }
1350
1416
  };
@@ -1397,7 +1463,8 @@ var WalletsResource = class extends BaseResource {
1397
1463
  method: "POST",
1398
1464
  path: "/wallets",
1399
1465
  body: data,
1400
- idempotencyKey: options?.idempotencyKey
1466
+ idempotencyKey: options?.idempotencyKey,
1467
+ timeout: options?.timeout
1401
1468
  });
1402
1469
  }
1403
1470
  /**
@@ -1519,7 +1586,8 @@ var WalletsResource = class extends BaseResource {
1519
1586
  method: "POST",
1520
1587
  path: `/wallets/${walletId}/transactions`,
1521
1588
  body: data,
1522
- idempotencyKey: options?.idempotencyKey
1589
+ idempotencyKey: options?.idempotencyKey,
1590
+ timeout: options?.timeout
1523
1591
  });
1524
1592
  }
1525
1593
  };
@@ -1586,7 +1654,8 @@ var ApplicationsResource = class extends BaseResource {
1586
1654
  method: "POST",
1587
1655
  path: `/applications/${applicationId}/submissions`,
1588
1656
  body: data ?? {},
1589
- idempotencyKey: options?.idempotencyKey
1657
+ idempotencyKey: options?.idempotencyKey,
1658
+ timeout: options?.timeout
1590
1659
  });
1591
1660
  }
1592
1661
  // ==========================================================================
@@ -1606,7 +1675,8 @@ var ApplicationsResource = class extends BaseResource {
1606
1675
  method: "PUT",
1607
1676
  path: `/applications/${applicationId}/business-details`,
1608
1677
  body: data,
1609
- idempotencyKey: options?.idempotencyKey
1678
+ idempotencyKey: options?.idempotencyKey,
1679
+ timeout: options?.timeout
1610
1680
  });
1611
1681
  }
1612
1682
  // ==========================================================================
@@ -1627,7 +1697,8 @@ var ApplicationsResource = class extends BaseResource {
1627
1697
  method: "PUT",
1628
1698
  path: `/applications/${applicationId}/individual-details`,
1629
1699
  body: data,
1630
- idempotencyKey: options?.idempotencyKey
1700
+ idempotencyKey: options?.idempotencyKey,
1701
+ timeout: options?.timeout
1631
1702
  });
1632
1703
  }
1633
1704
  // ==========================================================================
@@ -1645,7 +1716,8 @@ var ApplicationsResource = class extends BaseResource {
1645
1716
  method: "POST",
1646
1717
  path: `/applications/${applicationId}/associated-individuals`,
1647
1718
  body: data,
1648
- idempotencyKey: options?.idempotencyKey
1719
+ idempotencyKey: options?.idempotencyKey,
1720
+ timeout: options?.timeout
1649
1721
  });
1650
1722
  }
1651
1723
  /**
@@ -1663,7 +1735,8 @@ var ApplicationsResource = class extends BaseResource {
1663
1735
  method: "PUT",
1664
1736
  path: `/applications/${applicationId}/associated-individuals/${individualId}`,
1665
1737
  body: data,
1666
- idempotencyKey: options?.idempotencyKey
1738
+ idempotencyKey: options?.idempotencyKey,
1739
+ timeout: options?.timeout
1667
1740
  });
1668
1741
  }
1669
1742
  /**
@@ -1702,7 +1775,8 @@ var ApplicationsResource = class extends BaseResource {
1702
1775
  method: "POST",
1703
1776
  path: `/applications/${applicationId}/attestations`,
1704
1777
  body: data,
1705
- idempotencyKey: options?.idempotencyKey
1778
+ idempotencyKey: options?.idempotencyKey,
1779
+ timeout: options?.timeout
1706
1780
  });
1707
1781
  }
1708
1782
  // ==========================================================================
@@ -1734,7 +1808,8 @@ var ApplicationsResource = class extends BaseResource {
1734
1808
  method: "PUT",
1735
1809
  path: `/applications/${applicationId}/edd`,
1736
1810
  body: data,
1737
- idempotencyKey: options?.idempotencyKey
1811
+ idempotencyKey: options?.idempotencyKey,
1812
+ timeout: options?.timeout
1738
1813
  });
1739
1814
  }
1740
1815
  // ==========================================================================
@@ -1755,7 +1830,8 @@ var ApplicationsResource = class extends BaseResource {
1755
1830
  method: "POST",
1756
1831
  path: `/applications/${applicationId}/documents`,
1757
1832
  body: data,
1758
- idempotencyKey: options?.idempotencyKey
1833
+ idempotencyKey: options?.idempotencyKey,
1834
+ timeout: options?.timeout
1759
1835
  });
1760
1836
  }
1761
1837
  /**
@@ -1815,7 +1891,8 @@ var ApplicationsResource = class extends BaseResource {
1815
1891
  method: "POST",
1816
1892
  path: `/applications/${applicationId}/documents/${documentId}/verifications`,
1817
1893
  body: _data ?? {},
1818
- idempotencyKey: options?.idempotencyKey
1894
+ idempotencyKey: options?.idempotencyKey,
1895
+ timeout: options?.timeout
1819
1896
  });
1820
1897
  }
1821
1898
  /**
@@ -1833,7 +1910,8 @@ var ApplicationsResource = class extends BaseResource {
1833
1910
  method: "POST",
1834
1911
  path: `/applications/${applicationId}/document-uploads`,
1835
1912
  body: data,
1836
- idempotencyKey: options?.idempotencyKey
1913
+ idempotencyKey: options?.idempotencyKey,
1914
+ timeout: options?.timeout
1837
1915
  });
1838
1916
  }
1839
1917
  // ==========================================================================
@@ -1856,7 +1934,8 @@ var ApplicationsResource = class extends BaseResource {
1856
1934
  method: "POST",
1857
1935
  path: `/applications/${applicationId}/associated-individuals/${individualId}/documents`,
1858
1936
  body: data,
1859
- idempotencyKey: options?.idempotencyKey
1937
+ idempotencyKey: options?.idempotencyKey,
1938
+ timeout: options?.timeout
1860
1939
  });
1861
1940
  }
1862
1941
  /**
@@ -1875,7 +1954,8 @@ var ApplicationsResource = class extends BaseResource {
1875
1954
  method: "POST",
1876
1955
  path: `/applications/${applicationId}/associated-individuals/${individualId}/document-uploads`,
1877
1956
  body: data,
1878
- idempotencyKey: options?.idempotencyKey
1957
+ idempotencyKey: options?.idempotencyKey,
1958
+ timeout: options?.timeout
1879
1959
  });
1880
1960
  }
1881
1961
  };
@@ -1893,7 +1973,8 @@ var PoliciesResource = class extends BaseResource {
1893
1973
  method: "POST",
1894
1974
  path: "/policies",
1895
1975
  body: data,
1896
- idempotencyKey: options?.idempotencyKey
1976
+ idempotencyKey: options?.idempotencyKey,
1977
+ timeout: options?.timeout
1897
1978
  });
1898
1979
  }
1899
1980
  /**
@@ -1932,7 +2013,8 @@ var PoliciesResource = class extends BaseResource {
1932
2013
  method: "DELETE",
1933
2014
  path: `/policies/${policyId}`,
1934
2015
  body: options?.endorsement,
1935
- idempotencyKey: options?.idempotencyKey
2016
+ idempotencyKey: options?.idempotencyKey,
2017
+ timeout: options?.timeout
1936
2018
  });
1937
2019
  }
1938
2020
  /**
@@ -1947,7 +2029,8 @@ var PoliciesResource = class extends BaseResource {
1947
2029
  method: "POST",
1948
2030
  path: `/policies/${policyId}/rules`,
1949
2031
  body: options?.endorsement ?? data,
1950
- idempotencyKey: options?.idempotencyKey
2032
+ idempotencyKey: options?.idempotencyKey,
2033
+ timeout: options?.timeout
1951
2034
  });
1952
2035
  }
1953
2036
  /**
@@ -1963,7 +2046,8 @@ var PoliciesResource = class extends BaseResource {
1963
2046
  method: "PATCH",
1964
2047
  path: `/policies/${policyId}/rules/${ruleId}`,
1965
2048
  body: options?.endorsement ?? data,
1966
- idempotencyKey: options?.idempotencyKey
2049
+ idempotencyKey: options?.idempotencyKey,
2050
+ timeout: options?.timeout
1967
2051
  });
1968
2052
  }
1969
2053
  /**
@@ -1982,7 +2066,8 @@ var PoliciesResource = class extends BaseResource {
1982
2066
  method: "DELETE",
1983
2067
  path: `/policies/${policyId}/rules/${ruleId}`,
1984
2068
  body: options?.endorsement,
1985
- idempotencyKey: options?.idempotencyKey
2069
+ idempotencyKey: options?.idempotencyKey,
2070
+ timeout: options?.timeout
1986
2071
  });
1987
2072
  }
1988
2073
  /**
@@ -2015,7 +2100,8 @@ var PoliciesResource = class extends BaseResource {
2015
2100
  method: "PUT",
2016
2101
  path: `/policies/${policyId}/wallets/${walletId}`,
2017
2102
  body: options?.endorsement,
2018
- idempotencyKey: options?.idempotencyKey
2103
+ idempotencyKey: options?.idempotencyKey,
2104
+ timeout: options?.timeout
2019
2105
  });
2020
2106
  }
2021
2107
  /**
@@ -2034,7 +2120,8 @@ var PoliciesResource = class extends BaseResource {
2034
2120
  method: "DELETE",
2035
2121
  path: `/policies/${policyId}/wallets/${walletId}`,
2036
2122
  body: options?.endorsement,
2037
- idempotencyKey: options?.idempotencyKey
2123
+ idempotencyKey: options?.idempotencyKey,
2124
+ timeout: options?.timeout
2038
2125
  });
2039
2126
  }
2040
2127
  };
@@ -2052,7 +2139,8 @@ var SignerGroupsResource = class extends BaseResource {
2052
2139
  method: "POST",
2053
2140
  path: "/signer-groups",
2054
2141
  body: data,
2055
- idempotencyKey: options?.idempotencyKey
2142
+ idempotencyKey: options?.idempotencyKey,
2143
+ timeout: options?.timeout
2056
2144
  });
2057
2145
  }
2058
2146
  /**
@@ -2106,7 +2194,8 @@ var SignerGroupsResource = class extends BaseResource {
2106
2194
  method: "POST",
2107
2195
  path: `/signer-groups/${signerGroupId}/signers`,
2108
2196
  body: data,
2109
- idempotencyKey: options?.idempotencyKey
2197
+ idempotencyKey: options?.idempotencyKey,
2198
+ timeout: options?.timeout
2110
2199
  });
2111
2200
  }
2112
2201
  /**
@@ -2122,7 +2211,8 @@ var SignerGroupsResource = class extends BaseResource {
2122
2211
  await this.transport.request({
2123
2212
  method: "DELETE",
2124
2213
  path: `/signer-groups/${signerGroupId}/signers/${signerId}`,
2125
- idempotencyKey: options?.idempotencyKey
2214
+ idempotencyKey: options?.idempotencyKey,
2215
+ timeout: options?.timeout
2126
2216
  });
2127
2217
  }
2128
2218
  /**
@@ -2155,7 +2245,8 @@ var SignerGroupsResource = class extends BaseResource {
2155
2245
  method: "PUT",
2156
2246
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
2157
2247
  body: options?.endorsement,
2158
- idempotencyKey: options?.idempotencyKey
2248
+ idempotencyKey: options?.idempotencyKey,
2249
+ timeout: options?.timeout
2159
2250
  });
2160
2251
  }
2161
2252
  /**
@@ -2174,7 +2265,8 @@ var SignerGroupsResource = class extends BaseResource {
2174
2265
  method: "DELETE",
2175
2266
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
2176
2267
  body: options?.endorsement,
2177
- idempotencyKey: options?.idempotencyKey
2268
+ idempotencyKey: options?.idempotencyKey,
2269
+ timeout: options?.timeout
2178
2270
  });
2179
2271
  }
2180
2272
  /**
@@ -2201,7 +2293,8 @@ var SignersResource = class extends BaseResource {
2201
2293
  method: "POST",
2202
2294
  path: "/signers",
2203
2295
  body: data,
2204
- idempotencyKey: options?.idempotencyKey
2296
+ idempotencyKey: options?.idempotencyKey,
2297
+ timeout: options?.timeout
2205
2298
  });
2206
2299
  }
2207
2300
  /**
@@ -2232,7 +2325,8 @@ var ApiKeysResource = class extends BaseResource {
2232
2325
  method: "POST",
2233
2326
  path: "/api-keys",
2234
2327
  body: data,
2235
- idempotencyKey: options?.idempotencyKey
2328
+ idempotencyKey: options?.idempotencyKey,
2329
+ timeout: options?.timeout
2236
2330
  });
2237
2331
  }
2238
2332
  /**
@@ -2280,7 +2374,8 @@ var ApiKeysResource = class extends BaseResource {
2280
2374
  method: "POST",
2281
2375
  path: "/api-keys/admin",
2282
2376
  body: data,
2283
- idempotencyKey: options?.idempotencyKey
2377
+ idempotencyKey: options?.idempotencyKey,
2378
+ timeout: options?.timeout
2284
2379
  });
2285
2380
  }
2286
2381
  };
@@ -2298,7 +2393,8 @@ var UsersResource = class extends BaseResource {
2298
2393
  method: "POST",
2299
2394
  path: "/users",
2300
2395
  body: data,
2301
- idempotencyKey: options?.idempotencyKey
2396
+ idempotencyKey: options?.idempotencyKey,
2397
+ timeout: options?.timeout
2302
2398
  });
2303
2399
  }
2304
2400
  /**
@@ -2321,7 +2417,8 @@ var UsersResource = class extends BaseResource {
2321
2417
  method: "PATCH",
2322
2418
  path: `/users/${userId}`,
2323
2419
  body: data,
2324
- idempotencyKey: options?.idempotencyKey
2420
+ idempotencyKey: options?.idempotencyKey,
2421
+ timeout: options?.timeout
2325
2422
  });
2326
2423
  }
2327
2424
  /**
@@ -2350,7 +2447,8 @@ var WebhooksResource = class extends BaseResource {
2350
2447
  method: "POST",
2351
2448
  path: "/webhooks/targets",
2352
2449
  body: data,
2353
- idempotencyKey: options?.idempotencyKey
2450
+ idempotencyKey: options?.idempotencyKey,
2451
+ timeout: options?.timeout
2354
2452
  });
2355
2453
  }
2356
2454
  /**
@@ -2386,7 +2484,8 @@ var WebhooksResource = class extends BaseResource {
2386
2484
  method: "PATCH",
2387
2485
  path: `/webhooks/targets/${targetId}`,
2388
2486
  body: data,
2389
- idempotencyKey: options?.idempotencyKey
2487
+ idempotencyKey: options?.idempotencyKey,
2488
+ timeout: options?.timeout
2390
2489
  });
2391
2490
  }
2392
2491
  /**
@@ -2463,7 +2562,8 @@ var WebhooksResource = class extends BaseResource {
2463
2562
  return this.transport.request({
2464
2563
  method: "POST",
2465
2564
  path: `/webhooks/events/${eventId}/replay`,
2466
- idempotencyKey: options?.idempotencyKey
2565
+ idempotencyKey: options?.idempotencyKey,
2566
+ timeout: options?.timeout
2467
2567
  });
2468
2568
  }
2469
2569
  };
@@ -2574,7 +2674,8 @@ var SandboxResource = class extends BaseResource {
2574
2674
  method: "POST",
2575
2675
  path: "/sandbox/simulate/inbound",
2576
2676
  body: data,
2577
- idempotencyKey: options?.idempotencyKey
2677
+ idempotencyKey: options?.idempotencyKey,
2678
+ timeout: options?.timeout
2578
2679
  });
2579
2680
  }
2580
2681
  /**
@@ -2623,7 +2724,8 @@ var SandboxResource = class extends BaseResource {
2623
2724
  method: "POST",
2624
2725
  path: "/sandbox/simulate/onboarding",
2625
2726
  body: data,
2626
- idempotencyKey: options?.idempotencyKey
2727
+ idempotencyKey: options?.idempotencyKey,
2728
+ timeout: options?.timeout
2627
2729
  });
2628
2730
  }
2629
2731
  /**
@@ -2671,7 +2773,8 @@ var SandboxResource = class extends BaseResource {
2671
2773
  method: "POST",
2672
2774
  path: `/sandbox/simulations/${simulationId}/advance`,
2673
2775
  body: data,
2674
- idempotencyKey: options?.idempotencyKey
2776
+ idempotencyKey: options?.idempotencyKey,
2777
+ timeout: options?.timeout
2675
2778
  });
2676
2779
  }
2677
2780
  /**
@@ -2720,7 +2823,8 @@ var SelfServeResource = class extends BaseResource {
2720
2823
  method: "POST",
2721
2824
  path: "/self-serve/credits/purchase",
2722
2825
  body: data,
2723
- idempotencyKey: options?.idempotencyKey
2826
+ idempotencyKey: options?.idempotencyKey,
2827
+ timeout: options?.timeout
2724
2828
  });
2725
2829
  }
2726
2830
  /**
@@ -2866,7 +2970,8 @@ var FeePayoutDestinationResource = class extends BaseResource {
2866
2970
  method: "PUT",
2867
2971
  path: "/fee-payout-destination",
2868
2972
  body: data,
2869
- idempotencyKey: options?.idempotencyKey
2973
+ idempotencyKey: options?.idempotencyKey,
2974
+ timeout: options?.timeout
2870
2975
  });
2871
2976
  }
2872
2977
  /**
@@ -2900,7 +3005,8 @@ var PaymentAgentsResource = class extends BaseResource {
2900
3005
  method: "POST",
2901
3006
  path: "/payment-agents",
2902
3007
  body: data,
2903
- idempotencyKey: options?.idempotencyKey
3008
+ idempotencyKey: options?.idempotencyKey,
3009
+ timeout: options?.timeout
2904
3010
  });
2905
3011
  }
2906
3012
  /**
@@ -2939,7 +3045,8 @@ var PaymentAgentsResource = class extends BaseResource {
2939
3045
  return this.transport.request({
2940
3046
  method: "POST",
2941
3047
  path: `/payment-agents/${paymentAgentId}/revoke`,
2942
- idempotencyKey: options?.idempotencyKey
3048
+ idempotencyKey: options?.idempotencyKey,
3049
+ timeout: options?.timeout
2943
3050
  });
2944
3051
  }
2945
3052
  /**
@@ -2951,6 +3058,21 @@ var PaymentAgentsResource = class extends BaseResource {
2951
3058
  * `AgentConversation` for multi-turn chat; use this directly only for
2952
3059
  * one-shot proposals.
2953
3060
  *
3061
+ * SLOW BY NATURE. A turn is a sequence of model calls — read the payees,
3062
+ * check balances, draft, revise — so a multi-payee request legitimately
3063
+ * runs minutes. It therefore defaults to {@link AGENTIC_MODEL_TIMEOUT_MS}
3064
+ * rather than the client's ordinary deadline. Pass `{ timeout }` to
3065
+ * change it for one call; an explicit client-wide `timeout` still wins.
3066
+ *
3067
+ * The result may carry `blockers` ALONGSIDE proposals — they are not
3068
+ * alternatives. Branch on `blocker.code`, not on `reply`, and ignore codes
3069
+ * you do not recognize.
3070
+ *
3071
+ * `data.client_policy` is a DEVELOPMENT override of the vocabulary the
3072
+ * agent drafts under; prefer registering it once with
3073
+ * `client.agenticPolicy.set()`, since forgetting to send it here fails
3074
+ * silently.
3075
+ *
2954
3076
  * @param paymentAgentId - Payment agent ID
2955
3077
  * @param data - Prompt and/or messages
2956
3078
  * @returns Proposals (at high confidence) and/or a conversational reply
@@ -2960,7 +3082,9 @@ var PaymentAgentsResource = class extends BaseResource {
2960
3082
  method: "POST",
2961
3083
  path: `/payment-agents/${paymentAgentId}/proposals`,
2962
3084
  body: data,
2963
- idempotencyKey: options?.idempotencyKey
3085
+ idempotencyKey: options?.idempotencyKey,
3086
+ timeout: options?.timeout,
3087
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
2964
3088
  });
2965
3089
  }
2966
3090
  /**
@@ -3005,6 +3129,19 @@ var InstructionsResource = class extends BaseResource {
3005
3129
  /**
3006
3130
  * Accept proposals — actuate them into persisted instructions.
3007
3131
  *
3132
+ * Two optional fields shape the actuation:
3133
+ *
3134
+ * - `developer_fee` declares your fee PER PAYOUT TYPE — `swap_bps` for a
3135
+ * crypto payout, `offramp_bps` for a bank payout. They are independent,
3136
+ * so one conversation can charge a swap and stay silent about a bank
3137
+ * payout in the same turn. Omit a rate (or send zero) and that payout
3138
+ * type carries no fee: nothing is charged, nothing is added to the
3139
+ * amount, and the agent is told nothing about a fee it could mention.
3140
+ * Both are DEFAULTS for the auto-accounts this request creates — an
3141
+ * action-level `fee_bps` still wins outright.
3142
+ * - `client_policy` is the same development override the proposals call
3143
+ * takes. Prefer registering it once with `client.agenticPolicy.set()`.
3144
+ *
3008
3145
  * @param data - The payment agent id and the proposals to accept
3009
3146
  * @returns instruction_ids + the mandates the batch drafted (in full
3010
3147
  * wire shape; sign the §8 approval immediately)
@@ -3014,7 +3151,8 @@ var InstructionsResource = class extends BaseResource {
3014
3151
  method: "POST",
3015
3152
  path: "/instructions",
3016
3153
  body: data,
3017
- idempotencyKey: options?.idempotencyKey
3154
+ idempotencyKey: options?.idempotencyKey,
3155
+ timeout: options?.timeout
3018
3156
  });
3019
3157
  }
3020
3158
  /**
@@ -3075,7 +3213,8 @@ var MandatesResource = class extends BaseResource {
3075
3213
  method: "POST",
3076
3214
  path: "/mandates",
3077
3215
  body: data,
3078
- idempotencyKey: options?.idempotencyKey
3216
+ idempotencyKey: options?.idempotencyKey,
3217
+ timeout: options?.timeout
3079
3218
  });
3080
3219
  }
3081
3220
  /**
@@ -3093,7 +3232,8 @@ var MandatesResource = class extends BaseResource {
3093
3232
  method: "POST",
3094
3233
  path: `/mandates/${mandateId}/approve`,
3095
3234
  body: data,
3096
- idempotencyKey: options?.idempotencyKey
3235
+ idempotencyKey: options?.idempotencyKey,
3236
+ timeout: options?.timeout
3097
3237
  });
3098
3238
  }
3099
3239
  /**
@@ -3111,7 +3251,8 @@ var MandatesResource = class extends BaseResource {
3111
3251
  method: "POST",
3112
3252
  path: `/mandates/${mandateId}/cancel`,
3113
3253
  body: data,
3114
- idempotencyKey: options?.idempotencyKey
3254
+ idempotencyKey: options?.idempotencyKey,
3255
+ timeout: options?.timeout
3115
3256
  });
3116
3257
  }
3117
3258
  /**
@@ -3157,7 +3298,8 @@ var MandatesResource = class extends BaseResource {
3157
3298
  method: "POST",
3158
3299
  path: `/mandates/${mandateId}/amend`,
3159
3300
  body: data,
3160
- idempotencyKey: options?.idempotencyKey
3301
+ idempotencyKey: options?.idempotencyKey,
3302
+ timeout: options?.timeout
3161
3303
  });
3162
3304
  }
3163
3305
  /**
@@ -3243,7 +3385,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
3243
3385
  method: "POST",
3244
3386
  path: "/scheduled-payments",
3245
3387
  body: data,
3246
- idempotencyKey: options?.idempotencyKey
3388
+ idempotencyKey: options?.idempotencyKey,
3389
+ timeout: options?.timeout
3247
3390
  });
3248
3391
  }
3249
3392
  /**
@@ -3259,7 +3402,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
3259
3402
  await this.transport.request({
3260
3403
  method: "POST",
3261
3404
  path: `/scheduled-payments/${scheduledPaymentId}/cancel`,
3262
- idempotencyKey: options?.idempotencyKey
3405
+ idempotencyKey: options?.idempotencyKey,
3406
+ timeout: options?.timeout
3263
3407
  });
3264
3408
  }
3265
3409
  };
@@ -3295,6 +3439,10 @@ var InsightsResource = class extends BaseResource {
3295
3439
  * never moves money. Rate-limited per customer (hourly burst + daily
3296
3440
  * window) — a 429 means back off and retry later.
3297
3441
  *
3442
+ * Model-backed, so it defaults to {@link AGENTIC_MODEL_TIMEOUT_MS} rather
3443
+ * than the client's ordinary deadline. Pass `{ timeout }` to change it for
3444
+ * one call; an explicit client-wide `timeout` still wins.
3445
+ *
3298
3446
  * @param customerId - Customer ID
3299
3447
  * @param data - The conversation so far (1–40 messages)
3300
3448
  * @returns The assistant's reply (+ how the boundary screen treated the turn)
@@ -3304,7 +3452,83 @@ var InsightsResource = class extends BaseResource {
3304
3452
  method: "POST",
3305
3453
  path: `/customers/${customerId}/insights/chat`,
3306
3454
  body: data,
3307
- idempotencyKey: options?.idempotencyKey
3455
+ idempotencyKey: options?.idempotencyKey,
3456
+ timeout: options?.timeout,
3457
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
3458
+ });
3459
+ }
3460
+ };
3461
+
3462
+ // src/client/resources/agentic-policy.ts
3463
+ var AgenticPolicyResource = class extends BaseResource {
3464
+ /**
3465
+ * Get the policy registered for this client.
3466
+ *
3467
+ * A 404 here is the DEFAULT, not an error condition: with no registration
3468
+ * and no per-request policy the agent drafts on platform defaults, exactly
3469
+ * as it did before registration existed.
3470
+ *
3471
+ * @param clientId - Your client ID
3472
+ * @returns The normalized registered policy + its timestamps
3473
+ *
3474
+ * @example
3475
+ * ```typescript
3476
+ * try {
3477
+ * const { policy } = await client.agenticPolicy.get(clientId);
3478
+ * console.log(policy.labels);
3479
+ * } catch (e) {
3480
+ * if (e instanceof APIError && e.statusCode === 404) {
3481
+ * // No registration — platform defaults apply.
3482
+ * }
3483
+ * }
3484
+ * ```
3485
+ */
3486
+ async get(clientId) {
3487
+ return this.transport.request({
3488
+ method: "GET",
3489
+ path: `/clients/${clientId}/agentic-policy`
3490
+ });
3491
+ }
3492
+ /**
3493
+ * Register — or fully replace — this client's agentic policy.
3494
+ *
3495
+ * Declaring the vocabulary once removes a silent failure mode. Sending
3496
+ * `client_policy` in each proposals request still works and still wins, but
3497
+ * FORGETTING to send it fails silently: the agent just narrates in the
3498
+ * platform's nouns again ("destination", "mandate") and nothing errors
3499
+ * anywhere. A registration makes that impossible.
3500
+ *
3501
+ * FULL REPLACE, not a merge — the registration IS your declared vocabulary,
3502
+ * so an omitted field means you no longer want it, and an empty body (`{}`)
3503
+ * clears the registration back to platform defaults.
3504
+ *
3505
+ * Validated exactly like the per-request copy, so an unknown key, an
3506
+ * unsupported value, or a label for an unimplemented concept is a 400 HERE,
3507
+ * at registration — not a surprise on a customer's first conversation.
3508
+ *
3509
+ * @param clientId - Your client ID
3510
+ * @param policy - The complete policy (`{}` clears it)
3511
+ * @param options - Request options (e.g., custom idempotency key)
3512
+ * @returns The normalized stored policy + its timestamps
3513
+ *
3514
+ * @example
3515
+ * ```typescript
3516
+ * await client.agenticPolicy.set(clientId, {
3517
+ * payee_model: 'flat',
3518
+ * payout_assets: ['USDC', 'USDT'],
3519
+ * labels: { limit: 'spending limit', payee: 'recipient', limit_unit: 'USD' },
3520
+ * payout_route: 'conversion_account_only',
3521
+ * mandate_strategy: 'external_only',
3522
+ * });
3523
+ * ```
3524
+ */
3525
+ async set(clientId, policy, options) {
3526
+ return this.transport.request({
3527
+ method: "PUT",
3528
+ path: `/clients/${clientId}/agentic-policy`,
3529
+ body: policy,
3530
+ idempotencyKey: options?.idempotencyKey,
3531
+ timeout: options?.timeout
3308
3532
  });
3309
3533
  }
3310
3534
  };
@@ -3314,11 +3538,15 @@ var AgentConversation = class {
3314
3538
  client;
3315
3539
  paymentAgentId;
3316
3540
  timezone;
3541
+ timeout;
3542
+ clientPolicy;
3317
3543
  history = [];
3318
3544
  constructor(client, paymentAgentId, history, options) {
3319
3545
  this.client = client;
3320
3546
  this.paymentAgentId = paymentAgentId;
3321
3547
  this.timezone = options?.timezone;
3548
+ this.timeout = options?.timeout;
3549
+ this.clientPolicy = options?.clientPolicy;
3322
3550
  if (history && history.length > 0) {
3323
3551
  this.history = history.map(cloneMessage);
3324
3552
  }
@@ -3359,12 +3587,19 @@ var AgentConversation = class {
3359
3587
  }
3360
3588
  let result;
3361
3589
  try {
3362
- result = await this.client.paymentAgents.createProposals(this.paymentAgentId, {
3363
- messages,
3364
- // Resent on EVERY turn — the endpoint is stateless, so a zone given
3365
- // once would be forgotten on the next one.
3366
- ...this.timezone ? { timezone: this.timezone } : {}
3367
- });
3590
+ result = await this.client.paymentAgents.createProposals(
3591
+ this.paymentAgentId,
3592
+ {
3593
+ messages,
3594
+ // Resent on EVERY turn — the endpoint is stateless, so a zone given
3595
+ // once would be forgotten on the next one. Same for the policy
3596
+ // override: an omitted one silently falls back to the client's
3597
+ // registration (or platform defaults).
3598
+ ...this.timezone ? { timezone: this.timezone } : {},
3599
+ ...this.clientPolicy ? { client_policy: this.clientPolicy } : {}
3600
+ },
3601
+ this.timeout !== void 0 ? { timeout: this.timeout } : void 0
3602
+ );
3368
3603
  } catch (err) {
3369
3604
  this.history.pop();
3370
3605
  throw err;
@@ -3373,6 +3608,8 @@ var AgentConversation = class {
3373
3608
  reply: result.reply ?? "",
3374
3609
  proposals: result.proposals ? [...result.proposals] : [],
3375
3610
  hasProposals: !!result.proposals && result.proposals.length > 0,
3611
+ blockers: result.blockers ? [...result.blockers] : [],
3612
+ hasBlockers: !!result.blockers && result.blockers.length > 0,
3376
3613
  conversationStatus: result.conversation_status ?? ""
3377
3614
  };
3378
3615
  let assistant = turn.reply;
@@ -3516,6 +3753,8 @@ var DakotaClient = class {
3516
3753
  scheduledPayments;
3517
3754
  /** Insights API (ALPHA) - read-only advisory reporting over agentic activity */
3518
3755
  insights;
3756
+ /** Agentic Policy API (ALPHA) - register the vocabulary the agent speaks for your product */
3757
+ agenticPolicy;
3519
3758
  /**
3520
3759
  * Create a new Dakota client.
3521
3760
  *
@@ -3575,6 +3814,7 @@ var DakotaClient = class {
3575
3814
  this.mandates = new MandatesResource(this.transport);
3576
3815
  this.scheduledPayments = new ScheduledPaymentsResource(this.transport);
3577
3816
  this.insights = new InsightsResource(this.transport);
3817
+ this.agenticPolicy = new AgenticPolicyResource(this.transport);
3578
3818
  }
3579
3819
  // ==========================================================================
3580
3820
  // Agentic Payments high-level helpers (ALPHA)
@@ -3876,6 +4116,6 @@ function verifyMandateSignature(publicKeyBase64, payload, signatureBase64) {
3876
4116
  }
3877
4117
  }
3878
4118
 
3879
- export { APIError, AccountsResource, AgentConversation, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, FeePayoutDestinationResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateAmendSignPayload, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
4119
+ export { APIError, AccountsResource, AgentConversation, AgenticPolicyResource, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, FeePayoutDestinationResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateAmendSignPayload, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
3880
4120
  //# sourceMappingURL=index.mjs.map
3881
4121
  //# sourceMappingURL=index.mjs.map