@dakota-xyz/ts-sdk 2.0.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
  /**
@@ -678,12 +725,88 @@ var CustomersResource = class extends BaseResource {
678
725
  path: `/customers/${customerId}`
679
726
  });
680
727
  }
728
+ /**
729
+ * Delete a customer record.
730
+ *
731
+ * Soft-deletes the customer. Blocked with a 409 if the customer still has
732
+ * associated accounts, or is referenced as a sub-client by another customer.
733
+ *
734
+ * @param customerId - Customer ID (KSUID)
735
+ *
736
+ * @example
737
+ * ```typescript
738
+ * await client.customers.delete('cust_abc123');
739
+ * ```
740
+ */
741
+ async delete(customerId) {
742
+ await this.transport.request({
743
+ method: "DELETE",
744
+ path: `/customers/${customerId}`
745
+ });
746
+ }
747
+ /**
748
+ * List a customer's capabilities and what is still needed to unlock each.
749
+ *
750
+ * Returns the customer's rails (e.g. `international_wire`) with a status and
751
+ * the OUTSTANDING requirements — terms to accept, documents to upload — that
752
+ * gate them. Partner-agnostic: requirements are keyed by an opaque terms id
753
+ * or document type, never a provider or partner name.
754
+ *
755
+ * @param customerId - Customer ID (KSUID)
756
+ * @returns The customer's capabilities and their outstanding requirements
757
+ *
758
+ * @example
759
+ * ```typescript
760
+ * const { capabilities } = await client.customers.getCapabilities(customerId);
761
+ * for (const cap of capabilities) {
762
+ * if (cap.status !== 'action_required') continue;
763
+ * for (const req of cap.requirements) {
764
+ * console.log(`${cap.capability}: ${req.title} → ${req.url}`);
765
+ * }
766
+ * }
767
+ * ```
768
+ */
769
+ async getCapabilities(customerId) {
770
+ return this.transport.request({
771
+ method: "GET",
772
+ path: `/customers/${customerId}/capabilities`
773
+ });
774
+ }
775
+ /**
776
+ * Mint a fresh application link for re-engaging an APPROVED customer.
777
+ *
778
+ * Issues a new onboarding token for an existing approved customer's
779
+ * application and returns the rebuilt `application_url` — use it when the
780
+ * original token has expired and the customer needs to come back through
781
+ * the hosted flow (e.g. to accept outstanding partner disclosures).
782
+ *
783
+ * @param customerId - Customer ID (KSUID)
784
+ * @param options - Request options (e.g., custom idempotency key)
785
+ * @returns The rebuilt application URL
786
+ *
787
+ * @example
788
+ * ```typescript
789
+ * const { application_url } = await client.customers.reEngage(customerId);
790
+ * ```
791
+ */
792
+ async reEngage(customerId, options) {
793
+ return this.transport.request({
794
+ method: "POST",
795
+ path: `/customers/${customerId}/re-engagement`,
796
+ idempotencyKey: options?.idempotencyKey,
797
+ timeout: options?.timeout
798
+ });
799
+ }
681
800
  /**
682
801
  * Update the sub-client association for a customer.
683
802
  *
684
803
  * Associates or disassociates a customer with a sub-client.
685
804
  * Set `sub_client_id` to associate, or set it to `null` to disassociate.
686
805
  *
806
+ * @deprecated The sub-client association can only be set when a customer is
807
+ * created (`is_sub_client` / `sub_client_id` on `create`) and can no longer
808
+ * be changed afterwards — this endpoint now returns 400.
809
+ *
687
810
  * @param customerId - Customer ID (KSUID)
688
811
  * @param data - Sub-client association data
689
812
  * @param options - Request options (e.g., custom idempotency key)
@@ -707,7 +830,8 @@ var CustomersResource = class extends BaseResource {
707
830
  method: "PATCH",
708
831
  path: `/customers/${customerId}/sub-client`,
709
832
  body: data,
710
- idempotencyKey: options?.idempotencyKey
833
+ idempotencyKey: options?.idempotencyKey,
834
+ timeout: options?.timeout
711
835
  });
712
836
  }
713
837
  /**
@@ -757,7 +881,96 @@ var CustomersResource = class extends BaseResource {
757
881
  method: "POST",
758
882
  path: "/customers/bulk-import-sumsub-tokens",
759
883
  body: data,
760
- idempotencyKey: options?.idempotencyKey
884
+ idempotencyKey: options?.idempotencyKey,
885
+ timeout: options?.timeout
886
+ });
887
+ }
888
+ /**
889
+ * Import customers from Persona Connect share tokens (`cnst_...`).
890
+ *
891
+ * Unlike the Sumsub import, Persona redemption is asynchronous on Persona's
892
+ * side, so this returns a JOB immediately (HTTP 202). Poll
893
+ * `getPersonaImportJob` for per-token results. Up to 5,000 tokens per
894
+ * request — split larger migrations into multiple batches.
895
+ *
896
+ * Tokens are validated and de-duplicated up front, and a skipped token
897
+ * never blocks an accepted one. A `skipped` entry is about the token STRING
898
+ * (malformed, duplicated in the batch, or already imported) — it is never a
899
+ * compliance decision about a person or application.
900
+ *
901
+ * @param data - The share tokens to import
902
+ * @param options - Request options (e.g., custom idempotency key)
903
+ * @returns The queued job, with any tokens that could not be enqueued
904
+ *
905
+ * @example
906
+ * ```typescript
907
+ * const job = await client.customers.importPersonaTokens({
908
+ * tokens: ['cnst_ABC123def456', 'cnst_GHI789jkl012'],
909
+ * });
910
+ * console.log(`${job.accepted}/${job.total} queued as ${job.job_id}`);
911
+ * ```
912
+ */
913
+ async importPersonaTokens(data, options) {
914
+ return this.transport.request({
915
+ method: "POST",
916
+ path: "/customers/import-persona-tokens",
917
+ body: data,
918
+ idempotencyKey: options?.idempotencyKey,
919
+ timeout: options?.timeout
920
+ });
921
+ }
922
+ /**
923
+ * List this client's Persona share-token import jobs, newest first.
924
+ *
925
+ * This endpoint pages on its own cursor (`starting_after` + `has_more`), not
926
+ * the standard list envelope, so it returns a single page rather than an
927
+ * async iterator.
928
+ *
929
+ * @param params - Optional `limit` and `starting_after` job-id cursor
930
+ * @returns One page of job summaries plus a `has_more` flag
931
+ *
932
+ * @example
933
+ * ```typescript
934
+ * const { jobs, has_more } = await client.customers.listPersonaImportJobs({ limit: 20 });
935
+ * ```
936
+ */
937
+ async listPersonaImportJobs(params) {
938
+ return this.transport.request({
939
+ method: "GET",
940
+ path: "/customers/persona-import-jobs",
941
+ query: { ...params }
942
+ });
943
+ }
944
+ /**
945
+ * Get a Persona import job's status and its per-token results.
946
+ *
947
+ * Result rows page on a row-index cursor: pass the last row's `index` as
948
+ * `results_after_index` while `has_more_results` is true.
949
+ *
950
+ * @param jobId - Import job ID (`pij_...`)
951
+ * @param params - Optional `results_limit` (1-500) and `results_after_index`
952
+ * @returns Job status, row counts, and one page of result rows
953
+ *
954
+ * @example
955
+ * ```typescript
956
+ * let after: number | undefined;
957
+ * do {
958
+ * const job = await client.customers.getPersonaImportJob(jobId, {
959
+ * results_after_index: after,
960
+ * });
961
+ * for (const row of job.results ?? []) {
962
+ * if (row.state === 'failed') console.error(row.token, row.error);
963
+ * after = row.index;
964
+ * }
965
+ * if (!job.has_more_results) break;
966
+ * } while (true);
967
+ * ```
968
+ */
969
+ async getPersonaImportJob(jobId, params) {
970
+ return this.transport.request({
971
+ method: "GET",
972
+ path: `/customers/persona-import-jobs/${jobId}`,
973
+ query: { ...params }
761
974
  });
762
975
  }
763
976
  };
@@ -785,7 +998,8 @@ var RecipientsResource = class extends BaseResource {
785
998
  method: "POST",
786
999
  path: `/customers/${customerId}/recipients`,
787
1000
  body: data,
788
- idempotencyKey: options?.idempotencyKey
1001
+ idempotencyKey: options?.idempotencyKey,
1002
+ timeout: options?.timeout
789
1003
  });
790
1004
  }
791
1005
  /**
@@ -841,7 +1055,8 @@ var RecipientsResource = class extends BaseResource {
841
1055
  method: "PUT",
842
1056
  path: `/recipients/${recipientId}`,
843
1057
  body: data,
844
- idempotencyKey: options?.idempotencyKey
1058
+ idempotencyKey: options?.idempotencyKey,
1059
+ timeout: options?.timeout
845
1060
  });
846
1061
  }
847
1062
  /**
@@ -907,7 +1122,8 @@ var DestinationsResource = class extends BaseResource {
907
1122
  method: "POST",
908
1123
  path: `/recipients/${recipientId}/destinations`,
909
1124
  body: data,
910
- idempotencyKey: options?.idempotencyKey
1125
+ idempotencyKey: options?.idempotencyKey,
1126
+ timeout: options?.timeout
911
1127
  });
912
1128
  }
913
1129
  /**
@@ -995,7 +1211,8 @@ var AccountsResource = class extends BaseResource {
995
1211
  method: "POST",
996
1212
  path: "/accounts",
997
1213
  body: data,
998
- idempotencyKey: options?.idempotencyKey
1214
+ idempotencyKey: options?.idempotencyKey,
1215
+ timeout: options?.timeout
999
1216
  });
1000
1217
  }
1001
1218
  /**
@@ -1054,7 +1271,8 @@ var AccountsResource = class extends BaseResource {
1054
1271
  method: "PATCH",
1055
1272
  path: `/accounts/${accountId}`,
1056
1273
  body: data,
1057
- idempotencyKey: options?.idempotencyKey
1274
+ idempotencyKey: options?.idempotencyKey,
1275
+ timeout: options?.timeout
1058
1276
  });
1059
1277
  }
1060
1278
  /**
@@ -1114,7 +1332,8 @@ var TransactionsResource = class extends BaseResource {
1114
1332
  method: "POST",
1115
1333
  path: "/transactions",
1116
1334
  body: data,
1117
- idempotencyKey: options?.idempotencyKey
1335
+ idempotencyKey: options?.idempotencyKey,
1336
+ timeout: options?.timeout
1118
1337
  });
1119
1338
  }
1120
1339
  /**
@@ -1184,7 +1403,8 @@ var TransactionsResource = class extends BaseResource {
1184
1403
  return this.transport.request({
1185
1404
  method: "POST",
1186
1405
  path: `/transactions/${transactionId}/cancellations`,
1187
- idempotencyKey: options?.idempotencyKey
1406
+ idempotencyKey: options?.idempotencyKey,
1407
+ timeout: options?.timeout
1188
1408
  });
1189
1409
  }
1190
1410
  };
@@ -1237,7 +1457,8 @@ var WalletsResource = class extends BaseResource {
1237
1457
  method: "POST",
1238
1458
  path: "/wallets",
1239
1459
  body: data,
1240
- idempotencyKey: options?.idempotencyKey
1460
+ idempotencyKey: options?.idempotencyKey,
1461
+ timeout: options?.timeout
1241
1462
  });
1242
1463
  }
1243
1464
  /**
@@ -1359,7 +1580,8 @@ var WalletsResource = class extends BaseResource {
1359
1580
  method: "POST",
1360
1581
  path: `/wallets/${walletId}/transactions`,
1361
1582
  body: data,
1362
- idempotencyKey: options?.idempotencyKey
1583
+ idempotencyKey: options?.idempotencyKey,
1584
+ timeout: options?.timeout
1363
1585
  });
1364
1586
  }
1365
1587
  };
@@ -1426,7 +1648,8 @@ var ApplicationsResource = class extends BaseResource {
1426
1648
  method: "POST",
1427
1649
  path: `/applications/${applicationId}/submissions`,
1428
1650
  body: data ?? {},
1429
- idempotencyKey: options?.idempotencyKey
1651
+ idempotencyKey: options?.idempotencyKey,
1652
+ timeout: options?.timeout
1430
1653
  });
1431
1654
  }
1432
1655
  // ==========================================================================
@@ -1446,7 +1669,8 @@ var ApplicationsResource = class extends BaseResource {
1446
1669
  method: "PUT",
1447
1670
  path: `/applications/${applicationId}/business-details`,
1448
1671
  body: data,
1449
- idempotencyKey: options?.idempotencyKey
1672
+ idempotencyKey: options?.idempotencyKey,
1673
+ timeout: options?.timeout
1450
1674
  });
1451
1675
  }
1452
1676
  // ==========================================================================
@@ -1467,7 +1691,8 @@ var ApplicationsResource = class extends BaseResource {
1467
1691
  method: "PUT",
1468
1692
  path: `/applications/${applicationId}/individual-details`,
1469
1693
  body: data,
1470
- idempotencyKey: options?.idempotencyKey
1694
+ idempotencyKey: options?.idempotencyKey,
1695
+ timeout: options?.timeout
1471
1696
  });
1472
1697
  }
1473
1698
  // ==========================================================================
@@ -1485,7 +1710,8 @@ var ApplicationsResource = class extends BaseResource {
1485
1710
  method: "POST",
1486
1711
  path: `/applications/${applicationId}/associated-individuals`,
1487
1712
  body: data,
1488
- idempotencyKey: options?.idempotencyKey
1713
+ idempotencyKey: options?.idempotencyKey,
1714
+ timeout: options?.timeout
1489
1715
  });
1490
1716
  }
1491
1717
  /**
@@ -1503,7 +1729,8 @@ var ApplicationsResource = class extends BaseResource {
1503
1729
  method: "PUT",
1504
1730
  path: `/applications/${applicationId}/associated-individuals/${individualId}`,
1505
1731
  body: data,
1506
- idempotencyKey: options?.idempotencyKey
1732
+ idempotencyKey: options?.idempotencyKey,
1733
+ timeout: options?.timeout
1507
1734
  });
1508
1735
  }
1509
1736
  /**
@@ -1524,15 +1751,26 @@ var ApplicationsResource = class extends BaseResource {
1524
1751
  /**
1525
1752
  * Submit an attestation for an application.
1526
1753
  *
1754
+ * Additionally supplying `disclosure_id` (a terms key the provider
1755
+ * declared, e.g. `partner_disclosures`) and `disclosure_version` records the
1756
+ * attestation as a PARTNER DISCLOSURE acknowledgment instead of a standard
1757
+ * onboarding one: acceptance is stamped `customer_online`, the
1758
+ * partner-onboarding substatus advances, and an already-approved
1759
+ * application is reprovisioned. The API stays partner-agnostic — callers
1760
+ * supply a terms key and version, never a partner name. Get the outstanding
1761
+ * ones from `customers.getCapabilities(customerId)`.
1762
+ *
1527
1763
  * @param applicationId - Application ID
1528
- * @param data - Attestation data (type, timestamp, applicant_id)
1764
+ * @param data - Attestation data (type, timestamp, applicant_id), plus
1765
+ * `disclosure_id` + `disclosure_version` to accept a partner disclosure
1529
1766
  */
1530
1767
  async submitAttestation(applicationId, data, options) {
1531
1768
  await this.transport.request({
1532
1769
  method: "POST",
1533
1770
  path: `/applications/${applicationId}/attestations`,
1534
1771
  body: data,
1535
- idempotencyKey: options?.idempotencyKey
1772
+ idempotencyKey: options?.idempotencyKey,
1773
+ timeout: options?.timeout
1536
1774
  });
1537
1775
  }
1538
1776
  // ==========================================================================
@@ -1564,7 +1802,8 @@ var ApplicationsResource = class extends BaseResource {
1564
1802
  method: "PUT",
1565
1803
  path: `/applications/${applicationId}/edd`,
1566
1804
  body: data,
1567
- idempotencyKey: options?.idempotencyKey
1805
+ idempotencyKey: options?.idempotencyKey,
1806
+ timeout: options?.timeout
1568
1807
  });
1569
1808
  }
1570
1809
  // ==========================================================================
@@ -1585,7 +1824,8 @@ var ApplicationsResource = class extends BaseResource {
1585
1824
  method: "POST",
1586
1825
  path: `/applications/${applicationId}/documents`,
1587
1826
  body: data,
1588
- idempotencyKey: options?.idempotencyKey
1827
+ idempotencyKey: options?.idempotencyKey,
1828
+ timeout: options?.timeout
1589
1829
  });
1590
1830
  }
1591
1831
  /**
@@ -1645,7 +1885,8 @@ var ApplicationsResource = class extends BaseResource {
1645
1885
  method: "POST",
1646
1886
  path: `/applications/${applicationId}/documents/${documentId}/verifications`,
1647
1887
  body: _data ?? {},
1648
- idempotencyKey: options?.idempotencyKey
1888
+ idempotencyKey: options?.idempotencyKey,
1889
+ timeout: options?.timeout
1649
1890
  });
1650
1891
  }
1651
1892
  /**
@@ -1663,7 +1904,8 @@ var ApplicationsResource = class extends BaseResource {
1663
1904
  method: "POST",
1664
1905
  path: `/applications/${applicationId}/document-uploads`,
1665
1906
  body: data,
1666
- idempotencyKey: options?.idempotencyKey
1907
+ idempotencyKey: options?.idempotencyKey,
1908
+ timeout: options?.timeout
1667
1909
  });
1668
1910
  }
1669
1911
  // ==========================================================================
@@ -1686,7 +1928,8 @@ var ApplicationsResource = class extends BaseResource {
1686
1928
  method: "POST",
1687
1929
  path: `/applications/${applicationId}/associated-individuals/${individualId}/documents`,
1688
1930
  body: data,
1689
- idempotencyKey: options?.idempotencyKey
1931
+ idempotencyKey: options?.idempotencyKey,
1932
+ timeout: options?.timeout
1690
1933
  });
1691
1934
  }
1692
1935
  /**
@@ -1705,7 +1948,8 @@ var ApplicationsResource = class extends BaseResource {
1705
1948
  method: "POST",
1706
1949
  path: `/applications/${applicationId}/associated-individuals/${individualId}/document-uploads`,
1707
1950
  body: data,
1708
- idempotencyKey: options?.idempotencyKey
1951
+ idempotencyKey: options?.idempotencyKey,
1952
+ timeout: options?.timeout
1709
1953
  });
1710
1954
  }
1711
1955
  };
@@ -1723,7 +1967,8 @@ var PoliciesResource = class extends BaseResource {
1723
1967
  method: "POST",
1724
1968
  path: "/policies",
1725
1969
  body: data,
1726
- idempotencyKey: options?.idempotencyKey
1970
+ idempotencyKey: options?.idempotencyKey,
1971
+ timeout: options?.timeout
1727
1972
  });
1728
1973
  }
1729
1974
  /**
@@ -1762,7 +2007,8 @@ var PoliciesResource = class extends BaseResource {
1762
2007
  method: "DELETE",
1763
2008
  path: `/policies/${policyId}`,
1764
2009
  body: options?.endorsement,
1765
- idempotencyKey: options?.idempotencyKey
2010
+ idempotencyKey: options?.idempotencyKey,
2011
+ timeout: options?.timeout
1766
2012
  });
1767
2013
  }
1768
2014
  /**
@@ -1777,7 +2023,8 @@ var PoliciesResource = class extends BaseResource {
1777
2023
  method: "POST",
1778
2024
  path: `/policies/${policyId}/rules`,
1779
2025
  body: options?.endorsement ?? data,
1780
- idempotencyKey: options?.idempotencyKey
2026
+ idempotencyKey: options?.idempotencyKey,
2027
+ timeout: options?.timeout
1781
2028
  });
1782
2029
  }
1783
2030
  /**
@@ -1793,7 +2040,8 @@ var PoliciesResource = class extends BaseResource {
1793
2040
  method: "PATCH",
1794
2041
  path: `/policies/${policyId}/rules/${ruleId}`,
1795
2042
  body: options?.endorsement ?? data,
1796
- idempotencyKey: options?.idempotencyKey
2043
+ idempotencyKey: options?.idempotencyKey,
2044
+ timeout: options?.timeout
1797
2045
  });
1798
2046
  }
1799
2047
  /**
@@ -1812,7 +2060,8 @@ var PoliciesResource = class extends BaseResource {
1812
2060
  method: "DELETE",
1813
2061
  path: `/policies/${policyId}/rules/${ruleId}`,
1814
2062
  body: options?.endorsement,
1815
- idempotencyKey: options?.idempotencyKey
2063
+ idempotencyKey: options?.idempotencyKey,
2064
+ timeout: options?.timeout
1816
2065
  });
1817
2066
  }
1818
2067
  /**
@@ -1845,7 +2094,8 @@ var PoliciesResource = class extends BaseResource {
1845
2094
  method: "PUT",
1846
2095
  path: `/policies/${policyId}/wallets/${walletId}`,
1847
2096
  body: options?.endorsement,
1848
- idempotencyKey: options?.idempotencyKey
2097
+ idempotencyKey: options?.idempotencyKey,
2098
+ timeout: options?.timeout
1849
2099
  });
1850
2100
  }
1851
2101
  /**
@@ -1864,7 +2114,8 @@ var PoliciesResource = class extends BaseResource {
1864
2114
  method: "DELETE",
1865
2115
  path: `/policies/${policyId}/wallets/${walletId}`,
1866
2116
  body: options?.endorsement,
1867
- idempotencyKey: options?.idempotencyKey
2117
+ idempotencyKey: options?.idempotencyKey,
2118
+ timeout: options?.timeout
1868
2119
  });
1869
2120
  }
1870
2121
  };
@@ -1882,7 +2133,8 @@ var SignerGroupsResource = class extends BaseResource {
1882
2133
  method: "POST",
1883
2134
  path: "/signer-groups",
1884
2135
  body: data,
1885
- idempotencyKey: options?.idempotencyKey
2136
+ idempotencyKey: options?.idempotencyKey,
2137
+ timeout: options?.timeout
1886
2138
  });
1887
2139
  }
1888
2140
  /**
@@ -1897,13 +2149,27 @@ var SignerGroupsResource = class extends BaseResource {
1897
2149
  /**
1898
2150
  * Get a signer group by ID.
1899
2151
  *
2152
+ * Pass `{ include_removed: true }` to also get a `removed_members` array of
2153
+ * signers that were removed from this group, each carrying its `removed_at`
2154
+ * timestamp. Defaults to active members only.
2155
+ *
1900
2156
  * @param signerGroupId - Signer group ID
2157
+ * @param params - Optional `{ include_removed }`
1901
2158
  * @returns Signer group record
2159
+ *
2160
+ * @example
2161
+ * ```typescript
2162
+ * const group = await client.signerGroups.get(groupId, { include_removed: true });
2163
+ * for (const s of group.removed_members ?? []) {
2164
+ * console.log(s.name, 'removed at', s.removed_at);
2165
+ * }
2166
+ * ```
1902
2167
  */
1903
- async get(signerGroupId) {
2168
+ async get(signerGroupId, params) {
1904
2169
  return this.transport.request({
1905
2170
  method: "GET",
1906
- path: `/signer-groups/${signerGroupId}`
2171
+ path: `/signer-groups/${signerGroupId}`,
2172
+ query: { ...params }
1907
2173
  });
1908
2174
  }
1909
2175
  /**
@@ -1922,14 +2188,16 @@ var SignerGroupsResource = class extends BaseResource {
1922
2188
  method: "POST",
1923
2189
  path: `/signer-groups/${signerGroupId}/signers`,
1924
2190
  body: data,
1925
- idempotencyKey: options?.idempotencyKey
2191
+ idempotencyKey: options?.idempotencyKey,
2192
+ timeout: options?.timeout
1926
2193
  });
1927
2194
  }
1928
2195
  /**
1929
2196
  * Remove a signer from a group.
1930
2197
  *
1931
2198
  * @param signerGroupId - Signer group ID
1932
- * @param signerId - Signer ID
2199
+ * @param signerId - The signer's KSUID `signer_id` — NOT its public key.
2200
+ * (The standalone `client.signers.delete()` takes the public key instead.)
1933
2201
  * @param options - Optional request options (e.g. an explicit idempotency
1934
2202
  * key — the platform requires one on this DELETE)
1935
2203
  */
@@ -1937,7 +2205,8 @@ var SignerGroupsResource = class extends BaseResource {
1937
2205
  await this.transport.request({
1938
2206
  method: "DELETE",
1939
2207
  path: `/signer-groups/${signerGroupId}/signers/${signerId}`,
1940
- idempotencyKey: options?.idempotencyKey
2208
+ idempotencyKey: options?.idempotencyKey,
2209
+ timeout: options?.timeout
1941
2210
  });
1942
2211
  }
1943
2212
  /**
@@ -1970,7 +2239,8 @@ var SignerGroupsResource = class extends BaseResource {
1970
2239
  method: "PUT",
1971
2240
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
1972
2241
  body: options?.endorsement,
1973
- idempotencyKey: options?.idempotencyKey
2242
+ idempotencyKey: options?.idempotencyKey,
2243
+ timeout: options?.timeout
1974
2244
  });
1975
2245
  }
1976
2246
  /**
@@ -1989,7 +2259,8 @@ var SignerGroupsResource = class extends BaseResource {
1989
2259
  method: "DELETE",
1990
2260
  path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
1991
2261
  body: options?.endorsement,
1992
- idempotencyKey: options?.idempotencyKey
2262
+ idempotencyKey: options?.idempotencyKey,
2263
+ timeout: options?.timeout
1993
2264
  });
1994
2265
  }
1995
2266
  /**
@@ -2016,7 +2287,8 @@ var SignersResource = class extends BaseResource {
2016
2287
  method: "POST",
2017
2288
  path: "/signers",
2018
2289
  body: data,
2019
- idempotencyKey: options?.idempotencyKey
2290
+ idempotencyKey: options?.idempotencyKey,
2291
+ timeout: options?.timeout
2020
2292
  });
2021
2293
  }
2022
2294
  /**
@@ -2047,7 +2319,8 @@ var ApiKeysResource = class extends BaseResource {
2047
2319
  method: "POST",
2048
2320
  path: "/api-keys",
2049
2321
  body: data,
2050
- idempotencyKey: options?.idempotencyKey
2322
+ idempotencyKey: options?.idempotencyKey,
2323
+ timeout: options?.timeout
2051
2324
  });
2052
2325
  }
2053
2326
  /**
@@ -2095,7 +2368,8 @@ var ApiKeysResource = class extends BaseResource {
2095
2368
  method: "POST",
2096
2369
  path: "/api-keys/admin",
2097
2370
  body: data,
2098
- idempotencyKey: options?.idempotencyKey
2371
+ idempotencyKey: options?.idempotencyKey,
2372
+ timeout: options?.timeout
2099
2373
  });
2100
2374
  }
2101
2375
  };
@@ -2113,7 +2387,8 @@ var UsersResource = class extends BaseResource {
2113
2387
  method: "POST",
2114
2388
  path: "/users",
2115
2389
  body: data,
2116
- idempotencyKey: options?.idempotencyKey
2390
+ idempotencyKey: options?.idempotencyKey,
2391
+ timeout: options?.timeout
2117
2392
  });
2118
2393
  }
2119
2394
  /**
@@ -2136,7 +2411,8 @@ var UsersResource = class extends BaseResource {
2136
2411
  method: "PATCH",
2137
2412
  path: `/users/${userId}`,
2138
2413
  body: data,
2139
- idempotencyKey: options?.idempotencyKey
2414
+ idempotencyKey: options?.idempotencyKey,
2415
+ timeout: options?.timeout
2140
2416
  });
2141
2417
  }
2142
2418
  /**
@@ -2165,7 +2441,8 @@ var WebhooksResource = class extends BaseResource {
2165
2441
  method: "POST",
2166
2442
  path: "/webhooks/targets",
2167
2443
  body: data,
2168
- idempotencyKey: options?.idempotencyKey
2444
+ idempotencyKey: options?.idempotencyKey,
2445
+ timeout: options?.timeout
2169
2446
  });
2170
2447
  }
2171
2448
  /**
@@ -2201,7 +2478,8 @@ var WebhooksResource = class extends BaseResource {
2201
2478
  method: "PATCH",
2202
2479
  path: `/webhooks/targets/${targetId}`,
2203
2480
  body: data,
2204
- idempotencyKey: options?.idempotencyKey
2481
+ idempotencyKey: options?.idempotencyKey,
2482
+ timeout: options?.timeout
2205
2483
  });
2206
2484
  }
2207
2485
  /**
@@ -2278,7 +2556,8 @@ var WebhooksResource = class extends BaseResource {
2278
2556
  return this.transport.request({
2279
2557
  method: "POST",
2280
2558
  path: `/webhooks/events/${eventId}/replay`,
2281
- idempotencyKey: options?.idempotencyKey
2559
+ idempotencyKey: options?.idempotencyKey,
2560
+ timeout: options?.timeout
2282
2561
  });
2283
2562
  }
2284
2563
  };
@@ -2389,7 +2668,8 @@ var SandboxResource = class extends BaseResource {
2389
2668
  method: "POST",
2390
2669
  path: "/sandbox/simulate/inbound",
2391
2670
  body: data,
2392
- idempotencyKey: options?.idempotencyKey
2671
+ idempotencyKey: options?.idempotencyKey,
2672
+ timeout: options?.timeout
2393
2673
  });
2394
2674
  }
2395
2675
  /**
@@ -2438,7 +2718,8 @@ var SandboxResource = class extends BaseResource {
2438
2718
  method: "POST",
2439
2719
  path: "/sandbox/simulate/onboarding",
2440
2720
  body: data,
2441
- idempotencyKey: options?.idempotencyKey
2721
+ idempotencyKey: options?.idempotencyKey,
2722
+ timeout: options?.timeout
2442
2723
  });
2443
2724
  }
2444
2725
  /**
@@ -2486,7 +2767,8 @@ var SandboxResource = class extends BaseResource {
2486
2767
  method: "POST",
2487
2768
  path: `/sandbox/simulations/${simulationId}/advance`,
2488
2769
  body: data,
2489
- idempotencyKey: options?.idempotencyKey
2770
+ idempotencyKey: options?.idempotencyKey,
2771
+ timeout: options?.timeout
2490
2772
  });
2491
2773
  }
2492
2774
  /**
@@ -2535,7 +2817,8 @@ var SelfServeResource = class extends BaseResource {
2535
2817
  method: "POST",
2536
2818
  path: "/self-serve/credits/purchase",
2537
2819
  body: data,
2538
- idempotencyKey: options?.idempotencyKey
2820
+ idempotencyKey: options?.idempotencyKey,
2821
+ timeout: options?.timeout
2539
2822
  });
2540
2823
  }
2541
2824
  /**
@@ -2634,6 +2917,75 @@ var SelfServeResource = class extends BaseResource {
2634
2917
  }
2635
2918
  };
2636
2919
 
2920
+ // src/client/resources/fee-payout-destination.ts
2921
+ var FeePayoutDestinationResource = class extends BaseResource {
2922
+ /**
2923
+ * Get the destination registered to receive your developer-fee payouts.
2924
+ *
2925
+ * @returns The registered destination
2926
+ *
2927
+ * @example
2928
+ * ```typescript
2929
+ * const dest = await client.feePayoutDestination.get();
2930
+ * console.log(dest.chain, dest.wallet_address);
2931
+ * ```
2932
+ */
2933
+ async get() {
2934
+ return this.transport.request({
2935
+ method: "GET",
2936
+ path: "/fee-payout-destination"
2937
+ });
2938
+ }
2939
+ /**
2940
+ * Register or replace your fee payout destination.
2941
+ *
2942
+ * There is exactly one destination per organization, so this REPLACES any
2943
+ * existing one. Emits `fee_payout_destination.updated`.
2944
+ *
2945
+ * `chain` is a CAIP-2 chain id (e.g. `eip155:8453`) from the supported
2946
+ * networks list — see `client.info.getNetworks()`.
2947
+ *
2948
+ * @param data - The USDC wallet to pay fees to
2949
+ * @param options - Request options (e.g., custom idempotency key)
2950
+ * @returns The stored destination
2951
+ *
2952
+ * @example
2953
+ * ```typescript
2954
+ * const dest = await client.feePayoutDestination.set({
2955
+ * usdc_wallet: {
2956
+ * chain: 'eip155:8453',
2957
+ * address: '0x1234567890123456789012345678901234567890',
2958
+ * },
2959
+ * });
2960
+ * ```
2961
+ */
2962
+ async set(data, options) {
2963
+ return this.transport.request({
2964
+ method: "PUT",
2965
+ path: "/fee-payout-destination",
2966
+ body: data,
2967
+ idempotencyKey: options?.idempotencyKey,
2968
+ timeout: options?.timeout
2969
+ });
2970
+ }
2971
+ /**
2972
+ * Remove the registered fee payout destination, if one exists.
2973
+ *
2974
+ * Emits `fee_payout_destination.deleted`.
2975
+ *
2976
+ * @example
2977
+ * ```typescript
2978
+ * await client.feePayoutDestination.delete();
2979
+ * ```
2980
+ */
2981
+ async delete() {
2982
+ await this.transport.request({
2983
+ method: "DELETE",
2984
+ path: "/fee-payout-destination"
2985
+ });
2986
+ }
2987
+ };
2988
+
2637
2989
  // src/client/resources/payment-agents.ts
2638
2990
  var PaymentAgentsResource = class extends BaseResource {
2639
2991
  /**
@@ -2647,7 +2999,8 @@ var PaymentAgentsResource = class extends BaseResource {
2647
2999
  method: "POST",
2648
3000
  path: "/payment-agents",
2649
3001
  body: data,
2650
- idempotencyKey: options?.idempotencyKey
3002
+ idempotencyKey: options?.idempotencyKey,
3003
+ timeout: options?.timeout
2651
3004
  });
2652
3005
  }
2653
3006
  /**
@@ -2686,7 +3039,8 @@ var PaymentAgentsResource = class extends BaseResource {
2686
3039
  return this.transport.request({
2687
3040
  method: "POST",
2688
3041
  path: `/payment-agents/${paymentAgentId}/revoke`,
2689
- idempotencyKey: options?.idempotencyKey
3042
+ idempotencyKey: options?.idempotencyKey,
3043
+ timeout: options?.timeout
2690
3044
  });
2691
3045
  }
2692
3046
  /**
@@ -2698,6 +3052,12 @@ var PaymentAgentsResource = class extends BaseResource {
2698
3052
  * `AgentConversation` for multi-turn chat; use this directly only for
2699
3053
  * one-shot proposals.
2700
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
+ *
2701
3061
  * @param paymentAgentId - Payment agent ID
2702
3062
  * @param data - Prompt and/or messages
2703
3063
  * @returns Proposals (at high confidence) and/or a conversational reply
@@ -2707,7 +3067,44 @@ var PaymentAgentsResource = class extends BaseResource {
2707
3067
  method: "POST",
2708
3068
  path: `/payment-agents/${paymentAgentId}/proposals`,
2709
3069
  body: data,
2710
- idempotencyKey: options?.idempotencyKey
3070
+ idempotencyKey: options?.idempotencyKey,
3071
+ timeout: options?.timeout,
3072
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
3073
+ });
3074
+ }
3075
+ /**
3076
+ * Live progress of an in-flight drafting turn.
3077
+ *
3078
+ * A multi-payee drafting turn legitimately runs minutes (several sequential
3079
+ * model calls). While a `createProposals` call is in flight, poll this every
3080
+ * few seconds to show the customer what the agent is doing right now.
3081
+ *
3082
+ * Advisory display only. `active: false` means no turn is currently
3083
+ * publishing progress for this agent — idle, just finished, or served by
3084
+ * another instance — so fall back to a generic spinner. Never gate any
3085
+ * behaviour on this endpoint.
3086
+ *
3087
+ * The snapshot is coarse and customer-safe: a phase enum, one human
3088
+ * sentence, and the model round. Tool counts only — never payee names,
3089
+ * amounts, or addresses.
3090
+ *
3091
+ * @param paymentAgentId - Payment agent ID
3092
+ * @returns The current progress snapshot
3093
+ *
3094
+ * @example
3095
+ * ```typescript
3096
+ * const pending = client.paymentAgents.createProposals(agentId, { prompt });
3097
+ * const poll = setInterval(async () => {
3098
+ * const p = await client.paymentAgents.getProposalsProgress(agentId);
3099
+ * if (p.active) console.log(p.detail);
3100
+ * }, 3000);
3101
+ * const result = await pending.finally(() => clearInterval(poll));
3102
+ * ```
3103
+ */
3104
+ async getProposalsProgress(paymentAgentId) {
3105
+ return this.transport.request({
3106
+ method: "GET",
3107
+ path: `/payment-agents/${paymentAgentId}/proposals/progress`
2711
3108
  });
2712
3109
  }
2713
3110
  };
@@ -2726,7 +3123,8 @@ var InstructionsResource = class extends BaseResource {
2726
3123
  method: "POST",
2727
3124
  path: "/instructions",
2728
3125
  body: data,
2729
- idempotencyKey: options?.idempotencyKey
3126
+ idempotencyKey: options?.idempotencyKey,
3127
+ timeout: options?.timeout
2730
3128
  });
2731
3129
  }
2732
3130
  /**
@@ -2787,7 +3185,8 @@ var MandatesResource = class extends BaseResource {
2787
3185
  method: "POST",
2788
3186
  path: "/mandates",
2789
3187
  body: data,
2790
- idempotencyKey: options?.idempotencyKey
3188
+ idempotencyKey: options?.idempotencyKey,
3189
+ timeout: options?.timeout
2791
3190
  });
2792
3191
  }
2793
3192
  /**
@@ -2805,7 +3204,8 @@ var MandatesResource = class extends BaseResource {
2805
3204
  method: "POST",
2806
3205
  path: `/mandates/${mandateId}/approve`,
2807
3206
  body: data,
2808
- idempotencyKey: options?.idempotencyKey
3207
+ idempotencyKey: options?.idempotencyKey,
3208
+ timeout: options?.timeout
2809
3209
  });
2810
3210
  }
2811
3211
  /**
@@ -2823,7 +3223,105 @@ var MandatesResource = class extends BaseResource {
2823
3223
  method: "POST",
2824
3224
  path: `/mandates/${mandateId}/cancel`,
2825
3225
  body: data,
2826
- idempotencyKey: options?.idempotencyKey
3226
+ idempotencyKey: options?.idempotencyKey,
3227
+ timeout: options?.timeout
3228
+ });
3229
+ }
3230
+ /**
3231
+ * Amend a mandate — append a new signed version of its rule.
3232
+ *
3233
+ * Carries a changed rule into force with ONE signature and WITHOUT resetting
3234
+ * the spend already made in the current window: usage accrues to the
3235
+ * MANDATE, so an agent that has spent 9,000 of a 10,000 monthly limit and is
3236
+ * amended to 20,000 has 11,000 left, not 20,000.
3237
+ *
3238
+ * The `rule` is stored and verified VERBATIM — this endpoint does not
3239
+ * normalize it. It must already be canonical: `window` present and non-empty
3240
+ * (send `'NONE'` for a lifetime window), `targets` as recipient ids rather
3241
+ * than payee names, and `asset` uppercase. `target_type`, `window`, `asset`
3242
+ * and `network_id` must also match the current version exactly; only the
3243
+ * amount fields and `targets` may differ. Anything else is a 400 naming the
3244
+ * offending field.
3245
+ *
3246
+ * Build `signature` from `mandateAmendSignPayload(mandate, version, rule)` —
3247
+ * the amend payload commits to the version being created, so a signature for
3248
+ * v2 can never be replayed to append v3.
3249
+ *
3250
+ * @param mandateId - Mandate ID
3251
+ * @param data - Amending signer public key + signature + the complete NEW rule
3252
+ * @returns The mandate at its new current version
3253
+ *
3254
+ * @example
3255
+ * ```typescript
3256
+ * const mandate = await client.mandates.get(mandateId);
3257
+ * const nextVersion = (mandate.version ?? 1) + 1;
3258
+ * const rule = { ...mandate.rule, max_amount_in_window: '20000' };
3259
+ * const payload = mandateAmendSignPayload(mandate, nextVersion, rule);
3260
+ *
3261
+ * const amended = await client.mandates.amend(mandateId, {
3262
+ * signer_public_key: signer.publicKeyBase64(),
3263
+ * signature: await signer.sign(payload),
3264
+ * rule,
3265
+ * });
3266
+ * ```
3267
+ */
3268
+ async amend(mandateId, data, options) {
3269
+ return this.transport.request({
3270
+ method: "POST",
3271
+ path: `/mandates/${mandateId}/amend`,
3272
+ body: data,
3273
+ idempotencyKey: options?.idempotencyKey,
3274
+ timeout: options?.timeout
3275
+ });
3276
+ }
3277
+ /**
3278
+ * List a mandate's versions, oldest first.
3279
+ *
3280
+ * The append-only history of every rule that was ever in force under this
3281
+ * mandate, and the §8 signer that put each one there. Versions are
3282
+ * immutable, so a rule listed here never changes — this is what makes an
3283
+ * executed payment's `mandate_version` audit stamp legible.
3284
+ *
3285
+ * @param mandateId - Mandate ID
3286
+ * @returns Every version, oldest first
3287
+ */
3288
+ async listVersions(mandateId) {
3289
+ return this.transport.request({
3290
+ method: "GET",
3291
+ path: `/mandates/${mandateId}/versions`
3292
+ });
3293
+ }
3294
+ /**
3295
+ * Get a mandate's remaining budget right now.
3296
+ *
3297
+ * The mandate's `rule` gives the ceilings; this gives the CONSUMPTION — what
3298
+ * has already been spent, what is earmarked by scheduled payments that have
3299
+ * not fired yet, and therefore what is left. Read it before scheduling:
3300
+ * otherwise an over-budget payment is only discovered when the gate denies
3301
+ * it at its due date, days later, with the payee unpaid.
3302
+ *
3303
+ * Advisory — nothing here reserves budget, and the gate remains the
3304
+ * authority at fire time. Two things to honour when reading a line:
3305
+ * an ABSENT `remaining_amount` / `remaining_count` means "not capped", never
3306
+ * "nothing left"; a `remaining_amount` of `'?'` means the figure could not
3307
+ * be summed and MUST be treated as no headroom (the gate fails closed on the
3308
+ * same data).
3309
+ *
3310
+ * @param mandateId - Mandate ID
3311
+ * @returns Per-target and aggregate budget lines, as of a stated instant
3312
+ *
3313
+ * @example
3314
+ * ```typescript
3315
+ * const budget = await client.mandates.getBudget(mandateId);
3316
+ * for (const line of budget.aggregate) {
3317
+ * console.log(line.bucket, line.remaining_amount ?? 'uncapped');
3318
+ * }
3319
+ * ```
3320
+ */
3321
+ async getBudget(mandateId) {
3322
+ return this.transport.request({
3323
+ method: "GET",
3324
+ path: `/mandates/${mandateId}/budget`
2827
3325
  });
2828
3326
  }
2829
3327
  };
@@ -2859,7 +3357,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
2859
3357
  method: "POST",
2860
3358
  path: "/scheduled-payments",
2861
3359
  body: data,
2862
- idempotencyKey: options?.idempotencyKey
3360
+ idempotencyKey: options?.idempotencyKey,
3361
+ timeout: options?.timeout
2863
3362
  });
2864
3363
  }
2865
3364
  /**
@@ -2875,7 +3374,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
2875
3374
  await this.transport.request({
2876
3375
  method: "POST",
2877
3376
  path: `/scheduled-payments/${scheduledPaymentId}/cancel`,
2878
- idempotencyKey: options?.idempotencyKey
3377
+ idempotencyKey: options?.idempotencyKey,
3378
+ timeout: options?.timeout
2879
3379
  });
2880
3380
  }
2881
3381
  };
@@ -2911,6 +3411,10 @@ var InsightsResource = class extends BaseResource {
2911
3411
  * never moves money. Rate-limited per customer (hourly burst + daily
2912
3412
  * window) — a 429 means back off and retry later.
2913
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
+ *
2914
3418
  * @param customerId - Customer ID
2915
3419
  * @param data - The conversation so far (1–40 messages)
2916
3420
  * @returns The assistant's reply (+ how the boundary screen treated the turn)
@@ -2920,7 +3424,9 @@ var InsightsResource = class extends BaseResource {
2920
3424
  method: "POST",
2921
3425
  path: `/customers/${customerId}/insights/chat`,
2922
3426
  body: data,
2923
- idempotencyKey: options?.idempotencyKey
3427
+ idempotencyKey: options?.idempotencyKey,
3428
+ timeout: options?.timeout,
3429
+ endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
2924
3430
  });
2925
3431
  }
2926
3432
  };
@@ -2929,10 +3435,14 @@ var InsightsResource = class extends BaseResource {
2929
3435
  var AgentConversation = class {
2930
3436
  client;
2931
3437
  paymentAgentId;
3438
+ timezone;
3439
+ timeout;
2932
3440
  history = [];
2933
- constructor(client, paymentAgentId, history) {
3441
+ constructor(client, paymentAgentId, history, options) {
2934
3442
  this.client = client;
2935
3443
  this.paymentAgentId = paymentAgentId;
3444
+ this.timezone = options?.timezone;
3445
+ this.timeout = options?.timeout;
2936
3446
  if (history && history.length > 0) {
2937
3447
  this.history = history.map(cloneMessage);
2938
3448
  }
@@ -2973,9 +3483,16 @@ var AgentConversation = class {
2973
3483
  }
2974
3484
  let result;
2975
3485
  try {
2976
- result = await this.client.paymentAgents.createProposals(this.paymentAgentId, {
2977
- messages
2978
- });
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
+ );
2979
3496
  } catch (err) {
2980
3497
  this.history.pop();
2981
3498
  throw err;
@@ -3115,6 +3632,8 @@ var DakotaClient = class {
3115
3632
  sandbox;
3116
3633
  /** Self-Serve Credits API - manage prepaid transfer credits */
3117
3634
  selfServe;
3635
+ /** Fee Payout Destination API - where Dakota pays your accrued developer fees */
3636
+ feePayoutDestination;
3118
3637
  /** Payment Agents API (ALPHA) - hosted signing agents that draft payments */
3119
3638
  paymentAgents;
3120
3639
  /** Instructions API (ALPHA) - accept and inspect actuated proposals */
@@ -3178,6 +3697,7 @@ var DakotaClient = class {
3178
3697
  this.info = new InfoResource(this.transport);
3179
3698
  this.sandbox = new SandboxResource(this.transport);
3180
3699
  this.selfServe = new SelfServeResource(this.transport);
3700
+ this.feePayoutDestination = new FeePayoutDestinationResource(this.transport);
3181
3701
  this.paymentAgents = new PaymentAgentsResource(this.transport);
3182
3702
  this.instructions = new InstructionsResource(this.transport);
3183
3703
  this.mandates = new MandatesResource(this.transport);
@@ -3194,17 +3714,24 @@ var DakotaClient = class {
3194
3714
  /**
3195
3715
  * Start a fresh multi-turn conversation with a payment agent.
3196
3716
  *
3717
+ * Pass `{ timezone }` (an IANA zone) so the agent resolves "tomorrow" and
3718
+ * "10 am" in the customer's local time rather than UTC. The conversation
3719
+ * resends it on every turn.
3720
+ *
3197
3721
  * @see AgentConversation
3198
3722
  */
3199
- newAgentConversation(paymentAgentId) {
3200
- return new AgentConversation(this, paymentAgentId);
3723
+ newAgentConversation(paymentAgentId, options) {
3724
+ return new AgentConversation(this, paymentAgentId, void 0, options);
3201
3725
  }
3202
3726
  /**
3203
3727
  * Rebuild a conversation from a persisted transcript (oldest first) —
3204
3728
  * for backends that store the history between requests.
3729
+ *
3730
+ * A stateless backend must pass `{ timezone }` again here: the transcript
3731
+ * carries the messages, not the zone.
3205
3732
  */
3206
- resumeAgentConversation(paymentAgentId, history) {
3207
- return new AgentConversation(this, paymentAgentId, history);
3733
+ resumeAgentConversation(paymentAgentId, history, options) {
3734
+ return new AgentConversation(this, paymentAgentId, history, options);
3208
3735
  }
3209
3736
  /**
3210
3737
  * Grant a principal (user or agent — both are just signers) permission to
@@ -3291,6 +3818,27 @@ function mandateSignPayload(mandate, action) {
3291
3818
  });
3292
3819
  return new TextEncoder().encode(encoded);
3293
3820
  }
3821
+ function mandateAmendSignPayload(mandate, version, rule) {
3822
+ if (!mandate.id) {
3823
+ throw new Error("mandate has no id");
3824
+ }
3825
+ if (!mandate.bound_signer_id) {
3826
+ throw new Error("mandate has no bound_signer_id");
3827
+ }
3828
+ if (!Number.isInteger(version) || version < 2) {
3829
+ throw new Error("amend version must be an integer >= 2 (the version being created)");
3830
+ }
3831
+ const encoded = canonicalJSON({
3832
+ action: "amend",
3833
+ id: mandate.id,
3834
+ bound_signer: mandate.bound_signer_id,
3835
+ rule,
3836
+ valid_from: mandate.valid_from ?? 0,
3837
+ valid_until: mandate.valid_until ?? 0,
3838
+ version
3839
+ });
3840
+ return new TextEncoder().encode(encoded);
3841
+ }
3294
3842
  function attachGroupPayload(walletId, groupId, idempotencyKey) {
3295
3843
  return textBytes(
3296
3844
  canonicalJSON({
@@ -3470,6 +4018,7 @@ exports.DakotaClient = DakotaClient;
3470
4018
  exports.DestinationsResource = DestinationsResource;
3471
4019
  exports.Environment = Environment;
3472
4020
  exports.EventsResource = EventsResource;
4021
+ exports.FeePayoutDestinationResource = FeePayoutDestinationResource;
3473
4022
  exports.InfoResource = InfoResource;
3474
4023
  exports.InsightsResource = InsightsResource;
3475
4024
  exports.InstructionsResource = InstructionsResource;
@@ -3500,6 +4049,7 @@ exports.detachGroupPayload = detachGroupPayload;
3500
4049
  exports.detachPolicyPayload = detachPolicyPayload;
3501
4050
  exports.detachUserFromWallet = detachUserFromWallet;
3502
4051
  exports.getEnvironmentURL = getEnvironmentURL;
4052
+ exports.mandateAmendSignPayload = mandateAmendSignPayload;
3503
4053
  exports.mandateSignPayload = mandateSignPayload;
3504
4054
  exports.noopLogger = noopLogger;
3505
4055
  exports.paginate = paginate;