@dakota-xyz/ts-sdk 3.0.0 → 3.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 +140 -32
- package/dist/index.d.mts +4510 -1042
- package/dist/index.d.ts +4510 -1042
- package/dist/index.js +196 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +196 -26
- package/dist/index.mjs.map +1 -1
- package/dist/webhook/index.d.mts +176 -1
- package/dist/webhook/index.d.ts +176 -1
- package/dist/webhook/index.js +7 -0
- package/dist/webhook/index.js.map +1 -1
- package/dist/webhook/index.mjs +7 -0
- package/dist/webhook/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -275,7 +275,7 @@ var Transport = class {
|
|
|
275
275
|
* Make an HTTP request with automatic retry and error handling.
|
|
276
276
|
*/
|
|
277
277
|
async request(options) {
|
|
278
|
-
const { method, path, body, query, headers, idempotencyKey, signal } = options;
|
|
278
|
+
const { method, path, body, query, headers, idempotencyKey, signal, noContent } = options;
|
|
279
279
|
const url = this.buildURL(path, query);
|
|
280
280
|
const requestHeaders = this.buildHeaders(method, path, headers, idempotencyKey);
|
|
281
281
|
const requestBody = body !== void 0 ? JSON.stringify(body) : void 0;
|
|
@@ -287,7 +287,8 @@ var Transport = class {
|
|
|
287
287
|
body: requestBody,
|
|
288
288
|
signal
|
|
289
289
|
},
|
|
290
|
-
this.resolveTimeout(options)
|
|
290
|
+
this.resolveTimeout(options),
|
|
291
|
+
noContent === true
|
|
291
292
|
);
|
|
292
293
|
}
|
|
293
294
|
/**
|
|
@@ -383,7 +384,7 @@ var Transport = class {
|
|
|
383
384
|
* deadline, so a request that keeps timing out can take up to
|
|
384
385
|
* `timeout × maxAttempts` before it throws.
|
|
385
386
|
*/
|
|
386
|
-
async executeWithRetry(url, init, timeout) {
|
|
387
|
+
async executeWithRetry(url, init, timeout, noContent = false) {
|
|
387
388
|
const { maxAttempts, initialBackoffMs, maxBackoffMs } = this.config.retryPolicy;
|
|
388
389
|
const method = init.method ?? "GET";
|
|
389
390
|
let lastError;
|
|
@@ -404,7 +405,7 @@ var Transport = class {
|
|
|
404
405
|
clearTimeout(timeoutId);
|
|
405
406
|
this.logResponse(method, url, response.status, attempt);
|
|
406
407
|
if (response.ok) {
|
|
407
|
-
if (response.status === 204) {
|
|
408
|
+
if (response.status === 204 || noContent) {
|
|
408
409
|
return void 0;
|
|
409
410
|
}
|
|
410
411
|
return await response.json();
|
|
@@ -870,6 +871,42 @@ var CustomersResource = class extends BaseResource {
|
|
|
870
871
|
timeout: options?.timeout
|
|
871
872
|
});
|
|
872
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* Withdraw a customer's onboarding application.
|
|
876
|
+
*
|
|
877
|
+
* Closes the application when the customer will not or cannot continue —
|
|
878
|
+
* for example after a request for information they chose not to answer.
|
|
879
|
+
*
|
|
880
|
+
* Withdrawal is FINAL. The application and its entities are recorded as
|
|
881
|
+
* withdrawn, the customer's `status` becomes `withdrawn`, and onboarding
|
|
882
|
+
* that customer again requires a new application. An application that
|
|
883
|
+
* already has a decision returns a 409.
|
|
884
|
+
*
|
|
885
|
+
* Emits `customer.application.withdrawn`.
|
|
886
|
+
*
|
|
887
|
+
* @param customerId - Customer ID (KSUID)
|
|
888
|
+
* @param applicationId - The customer's onboarding application ID
|
|
889
|
+
* @param data - Optional `reason`, recorded for audit and shown to reviewers
|
|
890
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* await client.customers.withdrawApplication(customerId, applicationId, {
|
|
895
|
+
* reason: 'Customer opted not to proceed',
|
|
896
|
+
* });
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
async withdrawApplication(customerId, applicationId, data = {}, options) {
|
|
900
|
+
await this.transport.request({
|
|
901
|
+
method: "POST",
|
|
902
|
+
path: `/customers/${customerId}/applications/${applicationId}/withdraw`,
|
|
903
|
+
body: data,
|
|
904
|
+
idempotencyKey: options?.idempotencyKey,
|
|
905
|
+
timeout: options?.timeout,
|
|
906
|
+
// The platform answers a bare 200 with no body.
|
|
907
|
+
noContent: true
|
|
908
|
+
});
|
|
909
|
+
}
|
|
873
910
|
/**
|
|
874
911
|
* Update the sub-client association for a customer.
|
|
875
912
|
*
|
|
@@ -1340,11 +1377,18 @@ var AccountsResource = class extends BaseResource {
|
|
|
1340
1377
|
* @param data - Update data
|
|
1341
1378
|
* @returns Updated account
|
|
1342
1379
|
*
|
|
1380
|
+
* Only the developer fee can be updated, and setting one kind replaces the
|
|
1381
|
+
* other. `developer_fee_fixed` is a decimal string in units of the asset
|
|
1382
|
+
* deposited (at most 2 decimals, greater than 0); it applies to future
|
|
1383
|
+
* deposits only.
|
|
1384
|
+
*
|
|
1343
1385
|
* @example
|
|
1344
1386
|
* ```typescript
|
|
1345
1387
|
* const account = await client.accounts.update(accountId, {
|
|
1346
|
-
*
|
|
1388
|
+
* account_type: 'onramp',
|
|
1389
|
+
* developer_fee_fixed: '10.00',
|
|
1347
1390
|
* });
|
|
1391
|
+
* console.log(account.minimum_deposit); // '10.01'
|
|
1348
1392
|
* ```
|
|
1349
1393
|
*/
|
|
1350
1394
|
async update(accountId, data, options) {
|
|
@@ -2929,6 +2973,65 @@ var RDMarketingFeeResource = class extends BaseResource {
|
|
|
2929
2973
|
path: `/rd-marketing-fee/statements/${month}`
|
|
2930
2974
|
});
|
|
2931
2975
|
}
|
|
2976
|
+
/**
|
|
2977
|
+
* The wallet this client's RD marketing fee is sent to.
|
|
2978
|
+
*
|
|
2979
|
+
* A **404** here is the ordinary state for a client who has not registered
|
|
2980
|
+
* one yet — not an error. A **403** means the client is not in the
|
|
2981
|
+
* programme at all.
|
|
2982
|
+
*
|
|
2983
|
+
* @returns The registered destination: always on Base (`eip155:8453`)
|
|
2984
|
+
*
|
|
2985
|
+
* @example
|
|
2986
|
+
* ```typescript
|
|
2987
|
+
* try {
|
|
2988
|
+
* const dest = await client.rdMarketingFee.getPayoutDestination();
|
|
2989
|
+
* console.log(dest.address);
|
|
2990
|
+
* } catch (error) {
|
|
2991
|
+
* if (error instanceof APIError && error.statusCode === 404) {
|
|
2992
|
+
* // Nothing registered yet — prompt for one.
|
|
2993
|
+
* }
|
|
2994
|
+
* }
|
|
2995
|
+
* ```
|
|
2996
|
+
*/
|
|
2997
|
+
async getPayoutDestination() {
|
|
2998
|
+
return this.transport.request({
|
|
2999
|
+
method: "GET",
|
|
3000
|
+
path: "/rd-marketing-fee/payout-destination"
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Register, or replace, the wallet the RD marketing fee is sent to.
|
|
3005
|
+
*
|
|
3006
|
+
* RD exists only on Base, so the chain is not a parameter — only an EVM
|
|
3007
|
+
* `address`. There is one destination per client, so this REPLACES any
|
|
3008
|
+
* existing one. Emits `rd_payout_destination.updated`.
|
|
3009
|
+
*
|
|
3010
|
+
* This is a SEPARATE registration from the developer-fee payout
|
|
3011
|
+
* destination (`client.feePayoutDestination`): the two programmes pay
|
|
3012
|
+
* different assets and are set independently.
|
|
3013
|
+
*
|
|
3014
|
+
* @param data - The EVM address on Base to pay the fee to
|
|
3015
|
+
* @param options - Request options (e.g., custom idempotency key)
|
|
3016
|
+
* @returns The stored destination
|
|
3017
|
+
*
|
|
3018
|
+
* @example
|
|
3019
|
+
* ```typescript
|
|
3020
|
+
* const dest = await client.rdMarketingFee.setPayoutDestination({
|
|
3021
|
+
* address: '0x1234567890123456789012345678901234567890',
|
|
3022
|
+
* });
|
|
3023
|
+
* console.log(dest.chain); // 'eip155:8453'
|
|
3024
|
+
* ```
|
|
3025
|
+
*/
|
|
3026
|
+
async setPayoutDestination(data, options) {
|
|
3027
|
+
return this.transport.request({
|
|
3028
|
+
method: "PUT",
|
|
3029
|
+
path: "/rd-marketing-fee/payout-destination",
|
|
3030
|
+
body: data,
|
|
3031
|
+
idempotencyKey: options?.idempotencyKey,
|
|
3032
|
+
timeout: options?.timeout
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
2932
3035
|
};
|
|
2933
3036
|
|
|
2934
3037
|
// src/client/resources/sandbox.ts
|
|
@@ -2941,9 +3044,13 @@ var SandboxResource = class extends BaseResource {
|
|
|
2941
3044
|
*
|
|
2942
3045
|
* | Type | Required Fields |
|
|
2943
3046
|
* |------|-----------------|
|
|
2944
|
-
* | `ach_inbound`, `
|
|
2945
|
-
* | `crypto_inbound` | `
|
|
2946
|
-
* | `*_outbound_*`, `*_reversal` | `
|
|
3047
|
+
* | `ach_inbound`, `fedwire_inbound`, `swift_inbound`, `fednow_inbound` | `account_id` |
|
|
3048
|
+
* | `crypto_inbound` | `wallet_address` |
|
|
3049
|
+
* | `*_outbound_*`, `*_reversal` | `account_id` + `one_off_transaction_id` |
|
|
3050
|
+
*
|
|
3051
|
+
* `swift_inbound` and `fedwire_inbound` behave identically: the rail a
|
|
3052
|
+
* deposit books on is derived from the RECEIVING account, so pick the
|
|
3053
|
+
* account, not the type, to choose between a SWIFT and a Fedwire deposit.
|
|
2947
3054
|
*
|
|
2948
3055
|
* @param data - Simulation request data
|
|
2949
3056
|
* @returns Simulation response with ID and state
|
|
@@ -2972,11 +3079,13 @@ var SandboxResource = class extends BaseResource {
|
|
|
2972
3079
|
* destination_payment_rail: 'ach',
|
|
2973
3080
|
* });
|
|
2974
3081
|
*
|
|
2975
|
-
* // Simulate the ACH settlement
|
|
3082
|
+
* // Simulate the ACH settlement. `account_id` is the offramp account that
|
|
3083
|
+
* // funded the transaction.
|
|
2976
3084
|
* await client.sandbox.simulateInbound({
|
|
2977
3085
|
* simulation_id: `sim_${Date.now()}`,
|
|
2978
3086
|
* type: 'ach_outbound_settled',
|
|
2979
|
-
*
|
|
3087
|
+
* account_id: 'acc_456',
|
|
3088
|
+
* one_off_transaction_id: tx.id,
|
|
2980
3089
|
* amount: '100.00',
|
|
2981
3090
|
* currency: 'USD',
|
|
2982
3091
|
* });
|
|
@@ -2987,7 +3096,7 @@ var SandboxResource = class extends BaseResource {
|
|
|
2987
3096
|
* const result = await client.sandbox.simulateInbound({
|
|
2988
3097
|
* simulation_id: `sim_${Date.now()}`,
|
|
2989
3098
|
* type: 'crypto_inbound',
|
|
2990
|
-
*
|
|
3099
|
+
* wallet_address: '0x165cd37b4c644c2921454429e7f9358d18a45e14',
|
|
2991
3100
|
* amount: '500.00',
|
|
2992
3101
|
* currency: 'USDC',
|
|
2993
3102
|
* });
|
|
@@ -3467,14 +3576,22 @@ var InstructionsResource = class extends BaseResource {
|
|
|
3467
3576
|
*
|
|
3468
3577
|
* One optional field shapes the actuation:
|
|
3469
3578
|
*
|
|
3470
|
-
* - `
|
|
3471
|
-
* crypto payout, `
|
|
3472
|
-
*
|
|
3473
|
-
*
|
|
3474
|
-
*
|
|
3475
|
-
*
|
|
3476
|
-
*
|
|
3477
|
-
*
|
|
3579
|
+
* - `developer_fee_defaults` declares your fee PER PAYOUT TYPE —
|
|
3580
|
+
* `swap` for a crypto payout, `offramp` for a bank payout — each as
|
|
3581
|
+
* a percentage (`developer_fee_bps`) or a flat amount per payment
|
|
3582
|
+
* (`developer_fee_fixed`, a decimal string in units of the asset
|
|
3583
|
+
* deposited, added on top of the amount), never both. They are
|
|
3584
|
+
* independent, so one conversation can charge a swap and stay silent
|
|
3585
|
+
* about a bank payout in the same turn. Omit a payout type (or set its
|
|
3586
|
+
* `developer_fee_bps` to zero) and it carries no fee: nothing is
|
|
3587
|
+
* charged, nothing is added to the amount, and the agent is told
|
|
3588
|
+
* nothing about a fee it could mention. Both are
|
|
3589
|
+
* DEFAULTS for the auto-accounts this request creates — an action-level
|
|
3590
|
+
* `developer_fee_bps` or `developer_fee_fixed` still wins outright.
|
|
3591
|
+
*
|
|
3592
|
+
* It replaces the deprecated `developer_fee` (`swap_bps` /
|
|
3593
|
+
* `offramp_bps`), which the platform still accepts. Send one or the
|
|
3594
|
+
* other: both is a 400.
|
|
3478
3595
|
*
|
|
3479
3596
|
* The vocabulary the actuation is judged against comes from the policy
|
|
3480
3597
|
* registered with `client.agenticPolicy.set()` — the same one the drafting
|
|
@@ -3667,11 +3784,17 @@ var MandatesResource = class extends BaseResource {
|
|
|
3667
3784
|
* it at its due date, days later, with the payee unpaid.
|
|
3668
3785
|
*
|
|
3669
3786
|
* Advisory — nothing here reserves budget, and the gate remains the
|
|
3670
|
-
* authority at fire time.
|
|
3671
|
-
*
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3674
|
-
*
|
|
3787
|
+
* authority at fire time. Three things to honour when reading a line:
|
|
3788
|
+
*
|
|
3789
|
+
* - An ABSENT `remaining_amount` / `remaining_count` means "not capped",
|
|
3790
|
+
* never "nothing left" — EXCEPT on a `per_target` line with
|
|
3791
|
+
* `prior_scope: true`. That line's spend was booked under an earlier
|
|
3792
|
+
* version's target scope (before a `target_type` amendment) and no
|
|
3793
|
+
* current target claims it: the spend is real and still counts toward
|
|
3794
|
+
* the aggregate caps, but no payment can consume the bucket, so absent
|
|
3795
|
+
* remaining_* there means NO headroom. Never set on aggregate lines.
|
|
3796
|
+
* - A `remaining_amount` of `'?'` means the figure could not be summed and
|
|
3797
|
+
* MUST be treated as no headroom (the gate fails closed on the same data).
|
|
3675
3798
|
*
|
|
3676
3799
|
* @param mandateId - Mandate ID
|
|
3677
3800
|
* @returns Per-target and aggregate budget lines, as of a stated instant
|
|
@@ -3679,8 +3802,11 @@ var MandatesResource = class extends BaseResource {
|
|
|
3679
3802
|
* @example
|
|
3680
3803
|
* ```typescript
|
|
3681
3804
|
* const budget = await client.mandates.getBudget(mandateId);
|
|
3682
|
-
* for (const line of budget.aggregate) {
|
|
3683
|
-
*
|
|
3805
|
+
* for (const line of [...budget.per_target, ...budget.aggregate]) {
|
|
3806
|
+
* const headroom = line.prior_scope
|
|
3807
|
+
* ? 'none (prior scope)'
|
|
3808
|
+
* : (line.remaining_amount ?? 'uncapped');
|
|
3809
|
+
* console.log(line.target ?? '(all payees)', line.bucket, headroom);
|
|
3684
3810
|
* }
|
|
3685
3811
|
* ```
|
|
3686
3812
|
*/
|
|
@@ -3767,6 +3893,47 @@ var InsightsResource = class extends BaseResource {
|
|
|
3767
3893
|
path: `/customers/${customerId}/insights`
|
|
3768
3894
|
});
|
|
3769
3895
|
}
|
|
3896
|
+
/**
|
|
3897
|
+
* Get the client-level portfolio insight report.
|
|
3898
|
+
*
|
|
3899
|
+
* The client-scope companion of {@link get}: one deterministic, read-only
|
|
3900
|
+
* report over ALL of the caller's customers' agentic activity. Items reuse
|
|
3901
|
+
* the customer report's shape, plus `customer_id` (omitted on
|
|
3902
|
+
* cross-customer aggregates) and `responsibility` (a grouping label for
|
|
3903
|
+
* filtering — not ownership). On top of the items the report carries
|
|
3904
|
+
* dashboard-shaped data: KPI `metrics` with previous-window values for
|
|
3905
|
+
* trend deltas, daily `series` for charts, and a per-customer roll-up in
|
|
3906
|
+
* `customers` sorted worst-first.
|
|
3907
|
+
*
|
|
3908
|
+
* Every filter is optional and only NARROWS the report; the response shape
|
|
3909
|
+
* never changes. The report scans at most 100 customers per request —
|
|
3910
|
+
* `snapshot.customers.scanned < total` says it was computed over a prefix
|
|
3911
|
+
* of the book, never silently.
|
|
3912
|
+
*
|
|
3913
|
+
* A 404 means agentic payments are not enabled for the key, or the
|
|
3914
|
+
* `customer_id` filter names an unknown customer.
|
|
3915
|
+
*
|
|
3916
|
+
* @param params - Optional filters and the report window
|
|
3917
|
+
* @returns The client's portfolio insight report
|
|
3918
|
+
*
|
|
3919
|
+
* @example
|
|
3920
|
+
* ```typescript
|
|
3921
|
+
* const report = await client.insights.getClientReport({
|
|
3922
|
+
* severity: 'critical,warn',
|
|
3923
|
+
* window_days: 30,
|
|
3924
|
+
* });
|
|
3925
|
+
* for (const row of report.customers) {
|
|
3926
|
+
* if (row.item_counts.critical > 0) console.log(row.customer_id, row.name);
|
|
3927
|
+
* }
|
|
3928
|
+
* ```
|
|
3929
|
+
*/
|
|
3930
|
+
async getClientReport(params) {
|
|
3931
|
+
return this.transport.request({
|
|
3932
|
+
method: "GET",
|
|
3933
|
+
path: "/insights",
|
|
3934
|
+
query: { ...params }
|
|
3935
|
+
});
|
|
3936
|
+
}
|
|
3770
3937
|
};
|
|
3771
3938
|
|
|
3772
3939
|
// src/client/resources/agentic-policy.ts
|
|
@@ -3852,6 +4019,7 @@ var AgentConversation = class {
|
|
|
3852
4019
|
paymentAgentId;
|
|
3853
4020
|
timezone;
|
|
3854
4021
|
timeout;
|
|
4022
|
+
developerFeeDefaults;
|
|
3855
4023
|
developerFee;
|
|
3856
4024
|
history = [];
|
|
3857
4025
|
constructor(client, paymentAgentId, history, options) {
|
|
@@ -3859,6 +4027,7 @@ var AgentConversation = class {
|
|
|
3859
4027
|
this.paymentAgentId = paymentAgentId;
|
|
3860
4028
|
this.timezone = options?.timezone;
|
|
3861
4029
|
this.timeout = options?.timeout;
|
|
4030
|
+
this.developerFeeDefaults = options?.developerFeeDefaults;
|
|
3862
4031
|
this.developerFee = options?.developerFee;
|
|
3863
4032
|
if (history && history.length > 0) {
|
|
3864
4033
|
this.history = history.map(cloneMessage);
|
|
@@ -3907,6 +4076,7 @@ var AgentConversation = class {
|
|
|
3907
4076
|
// Resent on EVERY turn — the endpoint is stateless, so a value
|
|
3908
4077
|
// given once would be forgotten on the next one.
|
|
3909
4078
|
...this.timezone ? { timezone: this.timezone } : {},
|
|
4079
|
+
...this.developerFeeDefaults ? { developer_fee_defaults: this.developerFeeDefaults } : {},
|
|
3910
4080
|
...this.developerFee ? { developer_fee: this.developerFee } : {}
|
|
3911
4081
|
},
|
|
3912
4082
|
this.timeout !== void 0 ? { timeout: this.timeout } : void 0
|