@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/README.md +75 -1
- package/dist/index.d.mts +600 -7
- package/dist/index.d.ts +600 -7
- package/dist/index.js +320 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +320 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
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(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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(() =>
|
|
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(
|
|
397
|
+
if (error instanceof Error && error.name === "AbortError" && timedOut) {
|
|
398
|
+
lastError = new TransportError(
|
|
399
|
+
`Request timed out after ${timeout}ms. This is the SDK's client-side deadline, not a server error \u2014 raise it with \`new DakotaClient({ timeout })\`, or per call with \`{ timeout }\` in the request options. Agent conversations are the usual cause: pass \`{ timeout }\` to \`newAgentConversation\`.`,
|
|
400
|
+
error
|
|
401
|
+
);
|
|
402
|
+
} else if (error instanceof Error && error.name === "AbortError") {
|
|
403
|
+
throw new TransportError("Request aborted by caller", error);
|
|
361
404
|
} else if (error instanceof Error) {
|
|
362
405
|
lastError = new TransportError("Network error", error);
|
|
363
406
|
} else {
|
|
@@ -581,6 +624,9 @@ var BaseResource = class {
|
|
|
581
624
|
path,
|
|
582
625
|
query
|
|
583
626
|
});
|
|
627
|
+
if (Array.isArray(response)) {
|
|
628
|
+
return { data: response, meta: void 0 };
|
|
629
|
+
}
|
|
584
630
|
return {
|
|
585
631
|
data: response.data ?? [],
|
|
586
632
|
meta: response.meta
|
|
@@ -632,7 +678,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
632
678
|
method: "POST",
|
|
633
679
|
path: "/customers",
|
|
634
680
|
body: data,
|
|
635
|
-
idempotencyKey: options?.idempotencyKey
|
|
681
|
+
idempotencyKey: options?.idempotencyKey,
|
|
682
|
+
timeout: options?.timeout
|
|
636
683
|
});
|
|
637
684
|
}
|
|
638
685
|
/**
|
|
@@ -746,7 +793,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
746
793
|
return this.transport.request({
|
|
747
794
|
method: "POST",
|
|
748
795
|
path: `/customers/${customerId}/re-engagement`,
|
|
749
|
-
idempotencyKey: options?.idempotencyKey
|
|
796
|
+
idempotencyKey: options?.idempotencyKey,
|
|
797
|
+
timeout: options?.timeout
|
|
750
798
|
});
|
|
751
799
|
}
|
|
752
800
|
/**
|
|
@@ -782,7 +830,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
782
830
|
method: "PATCH",
|
|
783
831
|
path: `/customers/${customerId}/sub-client`,
|
|
784
832
|
body: data,
|
|
785
|
-
idempotencyKey: options?.idempotencyKey
|
|
833
|
+
idempotencyKey: options?.idempotencyKey,
|
|
834
|
+
timeout: options?.timeout
|
|
786
835
|
});
|
|
787
836
|
}
|
|
788
837
|
/**
|
|
@@ -832,7 +881,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
832
881
|
method: "POST",
|
|
833
882
|
path: "/customers/bulk-import-sumsub-tokens",
|
|
834
883
|
body: data,
|
|
835
|
-
idempotencyKey: options?.idempotencyKey
|
|
884
|
+
idempotencyKey: options?.idempotencyKey,
|
|
885
|
+
timeout: options?.timeout
|
|
836
886
|
});
|
|
837
887
|
}
|
|
838
888
|
/**
|
|
@@ -865,7 +915,8 @@ var CustomersResource = class extends BaseResource {
|
|
|
865
915
|
method: "POST",
|
|
866
916
|
path: "/customers/import-persona-tokens",
|
|
867
917
|
body: data,
|
|
868
|
-
idempotencyKey: options?.idempotencyKey
|
|
918
|
+
idempotencyKey: options?.idempotencyKey,
|
|
919
|
+
timeout: options?.timeout
|
|
869
920
|
});
|
|
870
921
|
}
|
|
871
922
|
/**
|
|
@@ -947,7 +998,8 @@ var RecipientsResource = class extends BaseResource {
|
|
|
947
998
|
method: "POST",
|
|
948
999
|
path: `/customers/${customerId}/recipients`,
|
|
949
1000
|
body: data,
|
|
950
|
-
idempotencyKey: options?.idempotencyKey
|
|
1001
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1002
|
+
timeout: options?.timeout
|
|
951
1003
|
});
|
|
952
1004
|
}
|
|
953
1005
|
/**
|
|
@@ -1003,7 +1055,8 @@ var RecipientsResource = class extends BaseResource {
|
|
|
1003
1055
|
method: "PUT",
|
|
1004
1056
|
path: `/recipients/${recipientId}`,
|
|
1005
1057
|
body: data,
|
|
1006
|
-
idempotencyKey: options?.idempotencyKey
|
|
1058
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1059
|
+
timeout: options?.timeout
|
|
1007
1060
|
});
|
|
1008
1061
|
}
|
|
1009
1062
|
/**
|
|
@@ -1069,7 +1122,8 @@ var DestinationsResource = class extends BaseResource {
|
|
|
1069
1122
|
method: "POST",
|
|
1070
1123
|
path: `/recipients/${recipientId}/destinations`,
|
|
1071
1124
|
body: data,
|
|
1072
|
-
idempotencyKey: options?.idempotencyKey
|
|
1125
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1126
|
+
timeout: options?.timeout
|
|
1073
1127
|
});
|
|
1074
1128
|
}
|
|
1075
1129
|
/**
|
|
@@ -1151,13 +1205,22 @@ var AccountsResource = class extends BaseResource {
|
|
|
1151
1205
|
* });
|
|
1152
1206
|
* // Returns: { bank_account: { bank_name, aba_routing_number, account_number } } - customer sends USD here
|
|
1153
1207
|
* ```
|
|
1208
|
+
*
|
|
1209
|
+
* @remarks
|
|
1210
|
+
* `max_transactions` caps how many transactions the account may ever
|
|
1211
|
+
* create — `1` makes it a one-off. Know what reaching the cap does before
|
|
1212
|
+
* you set one: further deposits are **refused, not returned**. The funds
|
|
1213
|
+
* still arrive and are then held pending manual intervention, with nothing
|
|
1214
|
+
* converted, nothing forwarded, and no transaction on the account for
|
|
1215
|
+
* them. Stop sending to the deposit details once the cap is reached.
|
|
1154
1216
|
*/
|
|
1155
1217
|
async create(data, options) {
|
|
1156
1218
|
return this.transport.request({
|
|
1157
1219
|
method: "POST",
|
|
1158
1220
|
path: "/accounts",
|
|
1159
1221
|
body: data,
|
|
1160
|
-
idempotencyKey: options?.idempotencyKey
|
|
1222
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1223
|
+
timeout: options?.timeout
|
|
1161
1224
|
});
|
|
1162
1225
|
}
|
|
1163
1226
|
/**
|
|
@@ -1216,7 +1279,8 @@ var AccountsResource = class extends BaseResource {
|
|
|
1216
1279
|
method: "PATCH",
|
|
1217
1280
|
path: `/accounts/${accountId}`,
|
|
1218
1281
|
body: data,
|
|
1219
|
-
idempotencyKey: options?.idempotencyKey
|
|
1282
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1283
|
+
timeout: options?.timeout
|
|
1220
1284
|
});
|
|
1221
1285
|
}
|
|
1222
1286
|
/**
|
|
@@ -1276,7 +1340,8 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1276
1340
|
method: "POST",
|
|
1277
1341
|
path: "/transactions",
|
|
1278
1342
|
body: data,
|
|
1279
|
-
idempotencyKey: options?.idempotencyKey
|
|
1343
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1344
|
+
timeout: options?.timeout
|
|
1280
1345
|
});
|
|
1281
1346
|
}
|
|
1282
1347
|
/**
|
|
@@ -1346,7 +1411,8 @@ var TransactionsResource = class extends BaseResource {
|
|
|
1346
1411
|
return this.transport.request({
|
|
1347
1412
|
method: "POST",
|
|
1348
1413
|
path: `/transactions/${transactionId}/cancellations`,
|
|
1349
|
-
idempotencyKey: options?.idempotencyKey
|
|
1414
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1415
|
+
timeout: options?.timeout
|
|
1350
1416
|
});
|
|
1351
1417
|
}
|
|
1352
1418
|
};
|
|
@@ -1399,7 +1465,8 @@ var WalletsResource = class extends BaseResource {
|
|
|
1399
1465
|
method: "POST",
|
|
1400
1466
|
path: "/wallets",
|
|
1401
1467
|
body: data,
|
|
1402
|
-
idempotencyKey: options?.idempotencyKey
|
|
1468
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1469
|
+
timeout: options?.timeout
|
|
1403
1470
|
});
|
|
1404
1471
|
}
|
|
1405
1472
|
/**
|
|
@@ -1521,7 +1588,8 @@ var WalletsResource = class extends BaseResource {
|
|
|
1521
1588
|
method: "POST",
|
|
1522
1589
|
path: `/wallets/${walletId}/transactions`,
|
|
1523
1590
|
body: data,
|
|
1524
|
-
idempotencyKey: options?.idempotencyKey
|
|
1591
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1592
|
+
timeout: options?.timeout
|
|
1525
1593
|
});
|
|
1526
1594
|
}
|
|
1527
1595
|
};
|
|
@@ -1588,7 +1656,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1588
1656
|
method: "POST",
|
|
1589
1657
|
path: `/applications/${applicationId}/submissions`,
|
|
1590
1658
|
body: data ?? {},
|
|
1591
|
-
idempotencyKey: options?.idempotencyKey
|
|
1659
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1660
|
+
timeout: options?.timeout
|
|
1592
1661
|
});
|
|
1593
1662
|
}
|
|
1594
1663
|
// ==========================================================================
|
|
@@ -1608,7 +1677,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1608
1677
|
method: "PUT",
|
|
1609
1678
|
path: `/applications/${applicationId}/business-details`,
|
|
1610
1679
|
body: data,
|
|
1611
|
-
idempotencyKey: options?.idempotencyKey
|
|
1680
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1681
|
+
timeout: options?.timeout
|
|
1612
1682
|
});
|
|
1613
1683
|
}
|
|
1614
1684
|
// ==========================================================================
|
|
@@ -1629,7 +1699,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1629
1699
|
method: "PUT",
|
|
1630
1700
|
path: `/applications/${applicationId}/individual-details`,
|
|
1631
1701
|
body: data,
|
|
1632
|
-
idempotencyKey: options?.idempotencyKey
|
|
1702
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1703
|
+
timeout: options?.timeout
|
|
1633
1704
|
});
|
|
1634
1705
|
}
|
|
1635
1706
|
// ==========================================================================
|
|
@@ -1647,7 +1718,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1647
1718
|
method: "POST",
|
|
1648
1719
|
path: `/applications/${applicationId}/associated-individuals`,
|
|
1649
1720
|
body: data,
|
|
1650
|
-
idempotencyKey: options?.idempotencyKey
|
|
1721
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1722
|
+
timeout: options?.timeout
|
|
1651
1723
|
});
|
|
1652
1724
|
}
|
|
1653
1725
|
/**
|
|
@@ -1665,7 +1737,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1665
1737
|
method: "PUT",
|
|
1666
1738
|
path: `/applications/${applicationId}/associated-individuals/${individualId}`,
|
|
1667
1739
|
body: data,
|
|
1668
|
-
idempotencyKey: options?.idempotencyKey
|
|
1740
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1741
|
+
timeout: options?.timeout
|
|
1669
1742
|
});
|
|
1670
1743
|
}
|
|
1671
1744
|
/**
|
|
@@ -1704,7 +1777,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1704
1777
|
method: "POST",
|
|
1705
1778
|
path: `/applications/${applicationId}/attestations`,
|
|
1706
1779
|
body: data,
|
|
1707
|
-
idempotencyKey: options?.idempotencyKey
|
|
1780
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1781
|
+
timeout: options?.timeout
|
|
1708
1782
|
});
|
|
1709
1783
|
}
|
|
1710
1784
|
// ==========================================================================
|
|
@@ -1736,7 +1810,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1736
1810
|
method: "PUT",
|
|
1737
1811
|
path: `/applications/${applicationId}/edd`,
|
|
1738
1812
|
body: data,
|
|
1739
|
-
idempotencyKey: options?.idempotencyKey
|
|
1813
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1814
|
+
timeout: options?.timeout
|
|
1740
1815
|
});
|
|
1741
1816
|
}
|
|
1742
1817
|
// ==========================================================================
|
|
@@ -1757,7 +1832,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1757
1832
|
method: "POST",
|
|
1758
1833
|
path: `/applications/${applicationId}/documents`,
|
|
1759
1834
|
body: data,
|
|
1760
|
-
idempotencyKey: options?.idempotencyKey
|
|
1835
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1836
|
+
timeout: options?.timeout
|
|
1761
1837
|
});
|
|
1762
1838
|
}
|
|
1763
1839
|
/**
|
|
@@ -1817,7 +1893,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1817
1893
|
method: "POST",
|
|
1818
1894
|
path: `/applications/${applicationId}/documents/${documentId}/verifications`,
|
|
1819
1895
|
body: _data ?? {},
|
|
1820
|
-
idempotencyKey: options?.idempotencyKey
|
|
1896
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1897
|
+
timeout: options?.timeout
|
|
1821
1898
|
});
|
|
1822
1899
|
}
|
|
1823
1900
|
/**
|
|
@@ -1835,7 +1912,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1835
1912
|
method: "POST",
|
|
1836
1913
|
path: `/applications/${applicationId}/document-uploads`,
|
|
1837
1914
|
body: data,
|
|
1838
|
-
idempotencyKey: options?.idempotencyKey
|
|
1915
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1916
|
+
timeout: options?.timeout
|
|
1839
1917
|
});
|
|
1840
1918
|
}
|
|
1841
1919
|
// ==========================================================================
|
|
@@ -1858,7 +1936,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1858
1936
|
method: "POST",
|
|
1859
1937
|
path: `/applications/${applicationId}/associated-individuals/${individualId}/documents`,
|
|
1860
1938
|
body: data,
|
|
1861
|
-
idempotencyKey: options?.idempotencyKey
|
|
1939
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1940
|
+
timeout: options?.timeout
|
|
1862
1941
|
});
|
|
1863
1942
|
}
|
|
1864
1943
|
/**
|
|
@@ -1877,7 +1956,8 @@ var ApplicationsResource = class extends BaseResource {
|
|
|
1877
1956
|
method: "POST",
|
|
1878
1957
|
path: `/applications/${applicationId}/associated-individuals/${individualId}/document-uploads`,
|
|
1879
1958
|
body: data,
|
|
1880
|
-
idempotencyKey: options?.idempotencyKey
|
|
1959
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1960
|
+
timeout: options?.timeout
|
|
1881
1961
|
});
|
|
1882
1962
|
}
|
|
1883
1963
|
};
|
|
@@ -1895,7 +1975,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1895
1975
|
method: "POST",
|
|
1896
1976
|
path: "/policies",
|
|
1897
1977
|
body: data,
|
|
1898
|
-
idempotencyKey: options?.idempotencyKey
|
|
1978
|
+
idempotencyKey: options?.idempotencyKey,
|
|
1979
|
+
timeout: options?.timeout
|
|
1899
1980
|
});
|
|
1900
1981
|
}
|
|
1901
1982
|
/**
|
|
@@ -1934,7 +2015,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1934
2015
|
method: "DELETE",
|
|
1935
2016
|
path: `/policies/${policyId}`,
|
|
1936
2017
|
body: options?.endorsement,
|
|
1937
|
-
idempotencyKey: options?.idempotencyKey
|
|
2018
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2019
|
+
timeout: options?.timeout
|
|
1938
2020
|
});
|
|
1939
2021
|
}
|
|
1940
2022
|
/**
|
|
@@ -1949,7 +2031,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1949
2031
|
method: "POST",
|
|
1950
2032
|
path: `/policies/${policyId}/rules`,
|
|
1951
2033
|
body: options?.endorsement ?? data,
|
|
1952
|
-
idempotencyKey: options?.idempotencyKey
|
|
2034
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2035
|
+
timeout: options?.timeout
|
|
1953
2036
|
});
|
|
1954
2037
|
}
|
|
1955
2038
|
/**
|
|
@@ -1965,7 +2048,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1965
2048
|
method: "PATCH",
|
|
1966
2049
|
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1967
2050
|
body: options?.endorsement ?? data,
|
|
1968
|
-
idempotencyKey: options?.idempotencyKey
|
|
2051
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2052
|
+
timeout: options?.timeout
|
|
1969
2053
|
});
|
|
1970
2054
|
}
|
|
1971
2055
|
/**
|
|
@@ -1984,7 +2068,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
1984
2068
|
method: "DELETE",
|
|
1985
2069
|
path: `/policies/${policyId}/rules/${ruleId}`,
|
|
1986
2070
|
body: options?.endorsement,
|
|
1987
|
-
idempotencyKey: options?.idempotencyKey
|
|
2071
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2072
|
+
timeout: options?.timeout
|
|
1988
2073
|
});
|
|
1989
2074
|
}
|
|
1990
2075
|
/**
|
|
@@ -2017,7 +2102,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
2017
2102
|
method: "PUT",
|
|
2018
2103
|
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
2019
2104
|
body: options?.endorsement,
|
|
2020
|
-
idempotencyKey: options?.idempotencyKey
|
|
2105
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2106
|
+
timeout: options?.timeout
|
|
2021
2107
|
});
|
|
2022
2108
|
}
|
|
2023
2109
|
/**
|
|
@@ -2036,7 +2122,8 @@ var PoliciesResource = class extends BaseResource {
|
|
|
2036
2122
|
method: "DELETE",
|
|
2037
2123
|
path: `/policies/${policyId}/wallets/${walletId}`,
|
|
2038
2124
|
body: options?.endorsement,
|
|
2039
|
-
idempotencyKey: options?.idempotencyKey
|
|
2125
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2126
|
+
timeout: options?.timeout
|
|
2040
2127
|
});
|
|
2041
2128
|
}
|
|
2042
2129
|
};
|
|
@@ -2054,7 +2141,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2054
2141
|
method: "POST",
|
|
2055
2142
|
path: "/signer-groups",
|
|
2056
2143
|
body: data,
|
|
2057
|
-
idempotencyKey: options?.idempotencyKey
|
|
2144
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2145
|
+
timeout: options?.timeout
|
|
2058
2146
|
});
|
|
2059
2147
|
}
|
|
2060
2148
|
/**
|
|
@@ -2108,7 +2196,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2108
2196
|
method: "POST",
|
|
2109
2197
|
path: `/signer-groups/${signerGroupId}/signers`,
|
|
2110
2198
|
body: data,
|
|
2111
|
-
idempotencyKey: options?.idempotencyKey
|
|
2199
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2200
|
+
timeout: options?.timeout
|
|
2112
2201
|
});
|
|
2113
2202
|
}
|
|
2114
2203
|
/**
|
|
@@ -2124,7 +2213,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2124
2213
|
await this.transport.request({
|
|
2125
2214
|
method: "DELETE",
|
|
2126
2215
|
path: `/signer-groups/${signerGroupId}/signers/${signerId}`,
|
|
2127
|
-
idempotencyKey: options?.idempotencyKey
|
|
2216
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2217
|
+
timeout: options?.timeout
|
|
2128
2218
|
});
|
|
2129
2219
|
}
|
|
2130
2220
|
/**
|
|
@@ -2157,7 +2247,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2157
2247
|
method: "PUT",
|
|
2158
2248
|
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
2159
2249
|
body: options?.endorsement,
|
|
2160
|
-
idempotencyKey: options?.idempotencyKey
|
|
2250
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2251
|
+
timeout: options?.timeout
|
|
2161
2252
|
});
|
|
2162
2253
|
}
|
|
2163
2254
|
/**
|
|
@@ -2176,7 +2267,8 @@ var SignerGroupsResource = class extends BaseResource {
|
|
|
2176
2267
|
method: "DELETE",
|
|
2177
2268
|
path: `/wallets/${walletId}/signer-groups/${signerGroupId}`,
|
|
2178
2269
|
body: options?.endorsement,
|
|
2179
|
-
idempotencyKey: options?.idempotencyKey
|
|
2270
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2271
|
+
timeout: options?.timeout
|
|
2180
2272
|
});
|
|
2181
2273
|
}
|
|
2182
2274
|
/**
|
|
@@ -2203,7 +2295,8 @@ var SignersResource = class extends BaseResource {
|
|
|
2203
2295
|
method: "POST",
|
|
2204
2296
|
path: "/signers",
|
|
2205
2297
|
body: data,
|
|
2206
|
-
idempotencyKey: options?.idempotencyKey
|
|
2298
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2299
|
+
timeout: options?.timeout
|
|
2207
2300
|
});
|
|
2208
2301
|
}
|
|
2209
2302
|
/**
|
|
@@ -2234,7 +2327,8 @@ var ApiKeysResource = class extends BaseResource {
|
|
|
2234
2327
|
method: "POST",
|
|
2235
2328
|
path: "/api-keys",
|
|
2236
2329
|
body: data,
|
|
2237
|
-
idempotencyKey: options?.idempotencyKey
|
|
2330
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2331
|
+
timeout: options?.timeout
|
|
2238
2332
|
});
|
|
2239
2333
|
}
|
|
2240
2334
|
/**
|
|
@@ -2282,7 +2376,8 @@ var ApiKeysResource = class extends BaseResource {
|
|
|
2282
2376
|
method: "POST",
|
|
2283
2377
|
path: "/api-keys/admin",
|
|
2284
2378
|
body: data,
|
|
2285
|
-
idempotencyKey: options?.idempotencyKey
|
|
2379
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2380
|
+
timeout: options?.timeout
|
|
2286
2381
|
});
|
|
2287
2382
|
}
|
|
2288
2383
|
};
|
|
@@ -2300,7 +2395,8 @@ var UsersResource = class extends BaseResource {
|
|
|
2300
2395
|
method: "POST",
|
|
2301
2396
|
path: "/users",
|
|
2302
2397
|
body: data,
|
|
2303
|
-
idempotencyKey: options?.idempotencyKey
|
|
2398
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2399
|
+
timeout: options?.timeout
|
|
2304
2400
|
});
|
|
2305
2401
|
}
|
|
2306
2402
|
/**
|
|
@@ -2323,7 +2419,8 @@ var UsersResource = class extends BaseResource {
|
|
|
2323
2419
|
method: "PATCH",
|
|
2324
2420
|
path: `/users/${userId}`,
|
|
2325
2421
|
body: data,
|
|
2326
|
-
idempotencyKey: options?.idempotencyKey
|
|
2422
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2423
|
+
timeout: options?.timeout
|
|
2327
2424
|
});
|
|
2328
2425
|
}
|
|
2329
2426
|
/**
|
|
@@ -2352,7 +2449,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2352
2449
|
method: "POST",
|
|
2353
2450
|
path: "/webhooks/targets",
|
|
2354
2451
|
body: data,
|
|
2355
|
-
idempotencyKey: options?.idempotencyKey
|
|
2452
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2453
|
+
timeout: options?.timeout
|
|
2356
2454
|
});
|
|
2357
2455
|
}
|
|
2358
2456
|
/**
|
|
@@ -2388,7 +2486,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2388
2486
|
method: "PATCH",
|
|
2389
2487
|
path: `/webhooks/targets/${targetId}`,
|
|
2390
2488
|
body: data,
|
|
2391
|
-
idempotencyKey: options?.idempotencyKey
|
|
2489
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2490
|
+
timeout: options?.timeout
|
|
2392
2491
|
});
|
|
2393
2492
|
}
|
|
2394
2493
|
/**
|
|
@@ -2465,7 +2564,8 @@ var WebhooksResource = class extends BaseResource {
|
|
|
2465
2564
|
return this.transport.request({
|
|
2466
2565
|
method: "POST",
|
|
2467
2566
|
path: `/webhooks/events/${eventId}/replay`,
|
|
2468
|
-
idempotencyKey: options?.idempotencyKey
|
|
2567
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2568
|
+
timeout: options?.timeout
|
|
2469
2569
|
});
|
|
2470
2570
|
}
|
|
2471
2571
|
};
|
|
@@ -2576,7 +2676,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2576
2676
|
method: "POST",
|
|
2577
2677
|
path: "/sandbox/simulate/inbound",
|
|
2578
2678
|
body: data,
|
|
2579
|
-
idempotencyKey: options?.idempotencyKey
|
|
2679
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2680
|
+
timeout: options?.timeout
|
|
2580
2681
|
});
|
|
2581
2682
|
}
|
|
2582
2683
|
/**
|
|
@@ -2625,7 +2726,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2625
2726
|
method: "POST",
|
|
2626
2727
|
path: "/sandbox/simulate/onboarding",
|
|
2627
2728
|
body: data,
|
|
2628
|
-
idempotencyKey: options?.idempotencyKey
|
|
2729
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2730
|
+
timeout: options?.timeout
|
|
2629
2731
|
});
|
|
2630
2732
|
}
|
|
2631
2733
|
/**
|
|
@@ -2673,7 +2775,8 @@ var SandboxResource = class extends BaseResource {
|
|
|
2673
2775
|
method: "POST",
|
|
2674
2776
|
path: `/sandbox/simulations/${simulationId}/advance`,
|
|
2675
2777
|
body: data,
|
|
2676
|
-
idempotencyKey: options?.idempotencyKey
|
|
2778
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2779
|
+
timeout: options?.timeout
|
|
2677
2780
|
});
|
|
2678
2781
|
}
|
|
2679
2782
|
/**
|
|
@@ -2722,7 +2825,8 @@ var SelfServeResource = class extends BaseResource {
|
|
|
2722
2825
|
method: "POST",
|
|
2723
2826
|
path: "/self-serve/credits/purchase",
|
|
2724
2827
|
body: data,
|
|
2725
|
-
idempotencyKey: options?.idempotencyKey
|
|
2828
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2829
|
+
timeout: options?.timeout
|
|
2726
2830
|
});
|
|
2727
2831
|
}
|
|
2728
2832
|
/**
|
|
@@ -2868,7 +2972,8 @@ var FeePayoutDestinationResource = class extends BaseResource {
|
|
|
2868
2972
|
method: "PUT",
|
|
2869
2973
|
path: "/fee-payout-destination",
|
|
2870
2974
|
body: data,
|
|
2871
|
-
idempotencyKey: options?.idempotencyKey
|
|
2975
|
+
idempotencyKey: options?.idempotencyKey,
|
|
2976
|
+
timeout: options?.timeout
|
|
2872
2977
|
});
|
|
2873
2978
|
}
|
|
2874
2979
|
/**
|
|
@@ -2902,7 +3007,8 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2902
3007
|
method: "POST",
|
|
2903
3008
|
path: "/payment-agents",
|
|
2904
3009
|
body: data,
|
|
2905
|
-
idempotencyKey: options?.idempotencyKey
|
|
3010
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3011
|
+
timeout: options?.timeout
|
|
2906
3012
|
});
|
|
2907
3013
|
}
|
|
2908
3014
|
/**
|
|
@@ -2941,7 +3047,8 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2941
3047
|
return this.transport.request({
|
|
2942
3048
|
method: "POST",
|
|
2943
3049
|
path: `/payment-agents/${paymentAgentId}/revoke`,
|
|
2944
|
-
idempotencyKey: options?.idempotencyKey
|
|
3050
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3051
|
+
timeout: options?.timeout
|
|
2945
3052
|
});
|
|
2946
3053
|
}
|
|
2947
3054
|
/**
|
|
@@ -2953,6 +3060,21 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2953
3060
|
* `AgentConversation` for multi-turn chat; use this directly only for
|
|
2954
3061
|
* one-shot proposals.
|
|
2955
3062
|
*
|
|
3063
|
+
* SLOW BY NATURE. A turn is a sequence of model calls — read the payees,
|
|
3064
|
+
* check balances, draft, revise — so a multi-payee request legitimately
|
|
3065
|
+
* runs minutes. It therefore defaults to {@link AGENTIC_MODEL_TIMEOUT_MS}
|
|
3066
|
+
* rather than the client's ordinary deadline. Pass `{ timeout }` to
|
|
3067
|
+
* change it for one call; an explicit client-wide `timeout` still wins.
|
|
3068
|
+
*
|
|
3069
|
+
* The result may carry `blockers` ALONGSIDE proposals — they are not
|
|
3070
|
+
* alternatives. Branch on `blocker.code`, not on `reply`, and ignore codes
|
|
3071
|
+
* you do not recognize.
|
|
3072
|
+
*
|
|
3073
|
+
* `data.client_policy` is a DEVELOPMENT override of the vocabulary the
|
|
3074
|
+
* agent drafts under; prefer registering it once with
|
|
3075
|
+
* `client.agenticPolicy.set()`, since forgetting to send it here fails
|
|
3076
|
+
* silently.
|
|
3077
|
+
*
|
|
2956
3078
|
* @param paymentAgentId - Payment agent ID
|
|
2957
3079
|
* @param data - Prompt and/or messages
|
|
2958
3080
|
* @returns Proposals (at high confidence) and/or a conversational reply
|
|
@@ -2962,7 +3084,9 @@ var PaymentAgentsResource = class extends BaseResource {
|
|
|
2962
3084
|
method: "POST",
|
|
2963
3085
|
path: `/payment-agents/${paymentAgentId}/proposals`,
|
|
2964
3086
|
body: data,
|
|
2965
|
-
idempotencyKey: options?.idempotencyKey
|
|
3087
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3088
|
+
timeout: options?.timeout,
|
|
3089
|
+
endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
|
|
2966
3090
|
});
|
|
2967
3091
|
}
|
|
2968
3092
|
/**
|
|
@@ -3007,6 +3131,19 @@ var InstructionsResource = class extends BaseResource {
|
|
|
3007
3131
|
/**
|
|
3008
3132
|
* Accept proposals — actuate them into persisted instructions.
|
|
3009
3133
|
*
|
|
3134
|
+
* Two optional fields shape the actuation:
|
|
3135
|
+
*
|
|
3136
|
+
* - `developer_fee` declares your fee PER PAYOUT TYPE — `swap_bps` for a
|
|
3137
|
+
* crypto payout, `offramp_bps` for a bank payout. They are independent,
|
|
3138
|
+
* so one conversation can charge a swap and stay silent about a bank
|
|
3139
|
+
* payout in the same turn. Omit a rate (or send zero) and that payout
|
|
3140
|
+
* type carries no fee: nothing is charged, nothing is added to the
|
|
3141
|
+
* amount, and the agent is told nothing about a fee it could mention.
|
|
3142
|
+
* Both are DEFAULTS for the auto-accounts this request creates — an
|
|
3143
|
+
* action-level `fee_bps` still wins outright.
|
|
3144
|
+
* - `client_policy` is the same development override the proposals call
|
|
3145
|
+
* takes. Prefer registering it once with `client.agenticPolicy.set()`.
|
|
3146
|
+
*
|
|
3010
3147
|
* @param data - The payment agent id and the proposals to accept
|
|
3011
3148
|
* @returns instruction_ids + the mandates the batch drafted (in full
|
|
3012
3149
|
* wire shape; sign the §8 approval immediately)
|
|
@@ -3016,7 +3153,8 @@ var InstructionsResource = class extends BaseResource {
|
|
|
3016
3153
|
method: "POST",
|
|
3017
3154
|
path: "/instructions",
|
|
3018
3155
|
body: data,
|
|
3019
|
-
idempotencyKey: options?.idempotencyKey
|
|
3156
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3157
|
+
timeout: options?.timeout
|
|
3020
3158
|
});
|
|
3021
3159
|
}
|
|
3022
3160
|
/**
|
|
@@ -3077,7 +3215,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3077
3215
|
method: "POST",
|
|
3078
3216
|
path: "/mandates",
|
|
3079
3217
|
body: data,
|
|
3080
|
-
idempotencyKey: options?.idempotencyKey
|
|
3218
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3219
|
+
timeout: options?.timeout
|
|
3081
3220
|
});
|
|
3082
3221
|
}
|
|
3083
3222
|
/**
|
|
@@ -3095,7 +3234,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3095
3234
|
method: "POST",
|
|
3096
3235
|
path: `/mandates/${mandateId}/approve`,
|
|
3097
3236
|
body: data,
|
|
3098
|
-
idempotencyKey: options?.idempotencyKey
|
|
3237
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3238
|
+
timeout: options?.timeout
|
|
3099
3239
|
});
|
|
3100
3240
|
}
|
|
3101
3241
|
/**
|
|
@@ -3113,7 +3253,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3113
3253
|
method: "POST",
|
|
3114
3254
|
path: `/mandates/${mandateId}/cancel`,
|
|
3115
3255
|
body: data,
|
|
3116
|
-
idempotencyKey: options?.idempotencyKey
|
|
3256
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3257
|
+
timeout: options?.timeout
|
|
3117
3258
|
});
|
|
3118
3259
|
}
|
|
3119
3260
|
/**
|
|
@@ -3159,7 +3300,8 @@ var MandatesResource = class extends BaseResource {
|
|
|
3159
3300
|
method: "POST",
|
|
3160
3301
|
path: `/mandates/${mandateId}/amend`,
|
|
3161
3302
|
body: data,
|
|
3162
|
-
idempotencyKey: options?.idempotencyKey
|
|
3303
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3304
|
+
timeout: options?.timeout
|
|
3163
3305
|
});
|
|
3164
3306
|
}
|
|
3165
3307
|
/**
|
|
@@ -3245,7 +3387,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
|
|
|
3245
3387
|
method: "POST",
|
|
3246
3388
|
path: "/scheduled-payments",
|
|
3247
3389
|
body: data,
|
|
3248
|
-
idempotencyKey: options?.idempotencyKey
|
|
3390
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3391
|
+
timeout: options?.timeout
|
|
3249
3392
|
});
|
|
3250
3393
|
}
|
|
3251
3394
|
/**
|
|
@@ -3261,7 +3404,8 @@ var ScheduledPaymentsResource = class extends BaseResource {
|
|
|
3261
3404
|
await this.transport.request({
|
|
3262
3405
|
method: "POST",
|
|
3263
3406
|
path: `/scheduled-payments/${scheduledPaymentId}/cancel`,
|
|
3264
|
-
idempotencyKey: options?.idempotencyKey
|
|
3407
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3408
|
+
timeout: options?.timeout
|
|
3265
3409
|
});
|
|
3266
3410
|
}
|
|
3267
3411
|
};
|
|
@@ -3297,6 +3441,10 @@ var InsightsResource = class extends BaseResource {
|
|
|
3297
3441
|
* never moves money. Rate-limited per customer (hourly burst + daily
|
|
3298
3442
|
* window) — a 429 means back off and retry later.
|
|
3299
3443
|
*
|
|
3444
|
+
* Model-backed, so it defaults to {@link AGENTIC_MODEL_TIMEOUT_MS} rather
|
|
3445
|
+
* than the client's ordinary deadline. Pass `{ timeout }` to change it for
|
|
3446
|
+
* one call; an explicit client-wide `timeout` still wins.
|
|
3447
|
+
*
|
|
3300
3448
|
* @param customerId - Customer ID
|
|
3301
3449
|
* @param data - The conversation so far (1–40 messages)
|
|
3302
3450
|
* @returns The assistant's reply (+ how the boundary screen treated the turn)
|
|
@@ -3306,7 +3454,83 @@ var InsightsResource = class extends BaseResource {
|
|
|
3306
3454
|
method: "POST",
|
|
3307
3455
|
path: `/customers/${customerId}/insights/chat`,
|
|
3308
3456
|
body: data,
|
|
3309
|
-
idempotencyKey: options?.idempotencyKey
|
|
3457
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3458
|
+
timeout: options?.timeout,
|
|
3459
|
+
endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
|
|
3464
|
+
// src/client/resources/agentic-policy.ts
|
|
3465
|
+
var AgenticPolicyResource = class extends BaseResource {
|
|
3466
|
+
/**
|
|
3467
|
+
* Get the policy registered for this client.
|
|
3468
|
+
*
|
|
3469
|
+
* A 404 here is the DEFAULT, not an error condition: with no registration
|
|
3470
|
+
* and no per-request policy the agent drafts on platform defaults, exactly
|
|
3471
|
+
* as it did before registration existed.
|
|
3472
|
+
*
|
|
3473
|
+
* @param clientId - Your client ID
|
|
3474
|
+
* @returns The normalized registered policy + its timestamps
|
|
3475
|
+
*
|
|
3476
|
+
* @example
|
|
3477
|
+
* ```typescript
|
|
3478
|
+
* try {
|
|
3479
|
+
* const { policy } = await client.agenticPolicy.get(clientId);
|
|
3480
|
+
* console.log(policy.labels);
|
|
3481
|
+
* } catch (e) {
|
|
3482
|
+
* if (e instanceof APIError && e.statusCode === 404) {
|
|
3483
|
+
* // No registration — platform defaults apply.
|
|
3484
|
+
* }
|
|
3485
|
+
* }
|
|
3486
|
+
* ```
|
|
3487
|
+
*/
|
|
3488
|
+
async get(clientId) {
|
|
3489
|
+
return this.transport.request({
|
|
3490
|
+
method: "GET",
|
|
3491
|
+
path: `/clients/${clientId}/agentic-policy`
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
/**
|
|
3495
|
+
* Register — or fully replace — this client's agentic policy.
|
|
3496
|
+
*
|
|
3497
|
+
* Declaring the vocabulary once removes a silent failure mode. Sending
|
|
3498
|
+
* `client_policy` in each proposals request still works and still wins, but
|
|
3499
|
+
* FORGETTING to send it fails silently: the agent just narrates in the
|
|
3500
|
+
* platform's nouns again ("destination", "mandate") and nothing errors
|
|
3501
|
+
* anywhere. A registration makes that impossible.
|
|
3502
|
+
*
|
|
3503
|
+
* FULL REPLACE, not a merge — the registration IS your declared vocabulary,
|
|
3504
|
+
* so an omitted field means you no longer want it, and an empty body (`{}`)
|
|
3505
|
+
* clears the registration back to platform defaults.
|
|
3506
|
+
*
|
|
3507
|
+
* Validated exactly like the per-request copy, so an unknown key, an
|
|
3508
|
+
* unsupported value, or a label for an unimplemented concept is a 400 HERE,
|
|
3509
|
+
* at registration — not a surprise on a customer's first conversation.
|
|
3510
|
+
*
|
|
3511
|
+
* @param clientId - Your client ID
|
|
3512
|
+
* @param policy - The complete policy (`{}` clears it)
|
|
3513
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
3514
|
+
* @returns The normalized stored policy + its timestamps
|
|
3515
|
+
*
|
|
3516
|
+
* @example
|
|
3517
|
+
* ```typescript
|
|
3518
|
+
* await client.agenticPolicy.set(clientId, {
|
|
3519
|
+
* payee_model: 'flat',
|
|
3520
|
+
* payout_assets: ['USDC', 'USDT'],
|
|
3521
|
+
* labels: { limit: 'spending limit', payee: 'recipient', limit_unit: 'USD' },
|
|
3522
|
+
* payout_route: 'conversion_account_only',
|
|
3523
|
+
* mandate_strategy: 'external_only',
|
|
3524
|
+
* });
|
|
3525
|
+
* ```
|
|
3526
|
+
*/
|
|
3527
|
+
async set(clientId, policy, options) {
|
|
3528
|
+
return this.transport.request({
|
|
3529
|
+
method: "PUT",
|
|
3530
|
+
path: `/clients/${clientId}/agentic-policy`,
|
|
3531
|
+
body: policy,
|
|
3532
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3533
|
+
timeout: options?.timeout
|
|
3310
3534
|
});
|
|
3311
3535
|
}
|
|
3312
3536
|
};
|
|
@@ -3316,11 +3540,15 @@ var AgentConversation = class {
|
|
|
3316
3540
|
client;
|
|
3317
3541
|
paymentAgentId;
|
|
3318
3542
|
timezone;
|
|
3543
|
+
timeout;
|
|
3544
|
+
clientPolicy;
|
|
3319
3545
|
history = [];
|
|
3320
3546
|
constructor(client, paymentAgentId, history, options) {
|
|
3321
3547
|
this.client = client;
|
|
3322
3548
|
this.paymentAgentId = paymentAgentId;
|
|
3323
3549
|
this.timezone = options?.timezone;
|
|
3550
|
+
this.timeout = options?.timeout;
|
|
3551
|
+
this.clientPolicy = options?.clientPolicy;
|
|
3324
3552
|
if (history && history.length > 0) {
|
|
3325
3553
|
this.history = history.map(cloneMessage);
|
|
3326
3554
|
}
|
|
@@ -3361,12 +3589,19 @@ var AgentConversation = class {
|
|
|
3361
3589
|
}
|
|
3362
3590
|
let result;
|
|
3363
3591
|
try {
|
|
3364
|
-
result = await this.client.paymentAgents.createProposals(
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3592
|
+
result = await this.client.paymentAgents.createProposals(
|
|
3593
|
+
this.paymentAgentId,
|
|
3594
|
+
{
|
|
3595
|
+
messages,
|
|
3596
|
+
// Resent on EVERY turn — the endpoint is stateless, so a zone given
|
|
3597
|
+
// once would be forgotten on the next one. Same for the policy
|
|
3598
|
+
// override: an omitted one silently falls back to the client's
|
|
3599
|
+
// registration (or platform defaults).
|
|
3600
|
+
...this.timezone ? { timezone: this.timezone } : {},
|
|
3601
|
+
...this.clientPolicy ? { client_policy: this.clientPolicy } : {}
|
|
3602
|
+
},
|
|
3603
|
+
this.timeout !== void 0 ? { timeout: this.timeout } : void 0
|
|
3604
|
+
);
|
|
3370
3605
|
} catch (err) {
|
|
3371
3606
|
this.history.pop();
|
|
3372
3607
|
throw err;
|
|
@@ -3375,6 +3610,8 @@ var AgentConversation = class {
|
|
|
3375
3610
|
reply: result.reply ?? "",
|
|
3376
3611
|
proposals: result.proposals ? [...result.proposals] : [],
|
|
3377
3612
|
hasProposals: !!result.proposals && result.proposals.length > 0,
|
|
3613
|
+
blockers: result.blockers ? [...result.blockers] : [],
|
|
3614
|
+
hasBlockers: !!result.blockers && result.blockers.length > 0,
|
|
3378
3615
|
conversationStatus: result.conversation_status ?? ""
|
|
3379
3616
|
};
|
|
3380
3617
|
let assistant = turn.reply;
|
|
@@ -3518,6 +3755,8 @@ var DakotaClient = class {
|
|
|
3518
3755
|
scheduledPayments;
|
|
3519
3756
|
/** Insights API (ALPHA) - read-only advisory reporting over agentic activity */
|
|
3520
3757
|
insights;
|
|
3758
|
+
/** Agentic Policy API (ALPHA) - register the vocabulary the agent speaks for your product */
|
|
3759
|
+
agenticPolicy;
|
|
3521
3760
|
/**
|
|
3522
3761
|
* Create a new Dakota client.
|
|
3523
3762
|
*
|
|
@@ -3577,6 +3816,7 @@ var DakotaClient = class {
|
|
|
3577
3816
|
this.mandates = new MandatesResource(this.transport);
|
|
3578
3817
|
this.scheduledPayments = new ScheduledPaymentsResource(this.transport);
|
|
3579
3818
|
this.insights = new InsightsResource(this.transport);
|
|
3819
|
+
this.agenticPolicy = new AgenticPolicyResource(this.transport);
|
|
3580
3820
|
}
|
|
3581
3821
|
// ==========================================================================
|
|
3582
3822
|
// Agentic Payments high-level helpers (ALPHA)
|
|
@@ -3881,6 +4121,7 @@ function verifyMandateSignature(publicKeyBase64, payload, signatureBase64) {
|
|
|
3881
4121
|
exports.APIError = APIError;
|
|
3882
4122
|
exports.AccountsResource = AccountsResource;
|
|
3883
4123
|
exports.AgentConversation = AgentConversation;
|
|
4124
|
+
exports.AgenticPolicyResource = AgenticPolicyResource;
|
|
3884
4125
|
exports.ApiKeysResource = ApiKeysResource;
|
|
3885
4126
|
exports.ApplicationsResource = ApplicationsResource;
|
|
3886
4127
|
exports.AuthMode = AuthMode;
|