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