@dakota-xyz/ts-sdk 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -37,6 +37,26 @@ var APIError = class _APIError extends Error {
37
37
  rawBody;
38
38
  /** Whether this error is safe to retry */
39
39
  retryable;
40
+ /**
41
+ * A plain-language rendition of the problem, written for the END CUSTOMER,
42
+ * when one exists for this error.
43
+ *
44
+ * `message` names request fields and actions so a machine caller can
45
+ * self-correct. This says the same thing without API vocabulary. Show it
46
+ * when relaying an error into a human surface (chat, email, UI), and fall
47
+ * back to `message` when it is null.
48
+ */
49
+ userMessage;
50
+ /**
51
+ * A link the customer can follow to CLEAR this error, present only on
52
+ * problems with a concrete self-service remedy.
53
+ *
54
+ * Today `terms-not-accepted` returns one, pointing at the hosted flow where
55
+ * the outstanding agreement can be signed. It is token-gated and usable
56
+ * as-is — send the customer to it rather than parsing one out of the
57
+ * message.
58
+ */
59
+ resolutionUrl;
40
60
  constructor(statusCode, code, message, options) {
41
61
  super(message);
42
62
  this.name = "APIError";
@@ -46,6 +66,8 @@ var APIError = class _APIError extends Error {
46
66
  this.requestId = options?.requestId ?? null;
47
67
  this.rawBody = options?.rawBody ?? null;
48
68
  this.retryable = RETRYABLE_STATUS_CODES.has(statusCode);
69
+ this.userMessage = options?.userMessage ?? null;
70
+ this.resolutionUrl = options?.resolutionUrl ?? null;
49
71
  if (Error.captureStackTrace) {
50
72
  Error.captureStackTrace(this, _APIError);
51
73
  }
@@ -59,6 +81,8 @@ var APIError = class _APIError extends Error {
59
81
  let code = `http_${response.status}`;
60
82
  let message = response.statusText || "Unknown error";
61
83
  let details = null;
84
+ let userMessage = null;
85
+ let resolutionUrl = null;
62
86
  try {
63
87
  rawBody = await response.text();
64
88
  const parsed = JSON.parse(rawBody);
@@ -84,12 +108,20 @@ var APIError = class _APIError extends Error {
84
108
  if (parsed.details && typeof parsed.details === "object") {
85
109
  details = parsed.details;
86
110
  }
111
+ if (typeof parsed.user_message === "string") {
112
+ userMessage = parsed.user_message;
113
+ }
114
+ if (typeof parsed.resolution_url === "string") {
115
+ resolutionUrl = parsed.resolution_url;
116
+ }
87
117
  } catch {
88
118
  }
89
119
  return new _APIError(response.status, code, message, {
90
120
  details,
91
121
  requestId,
92
- rawBody
122
+ rawBody,
123
+ userMessage,
124
+ resolutionUrl
93
125
  });
94
126
  }
95
127
  toString() {
@@ -603,8 +635,12 @@ var BaseResource = class {
603
635
  }
604
636
  /**
605
637
  * Create a paginated iterator for a list endpoint.
638
+ *
639
+ * `inspectMeta` is called with each page's raw `meta` before the page is
640
+ * yielded, for endpoints whose meta says something the caller must act on.
641
+ * Throw from it to fail the page.
606
642
  */
607
- paginate(path, params, cursorExtractor) {
643
+ paginate(path, params, cursorExtractor, inspectMeta) {
608
644
  const fetcher = async (cursor) => {
609
645
  const query = {};
610
646
  if (params) {
@@ -623,8 +659,10 @@ var BaseResource = class {
623
659
  query
624
660
  });
625
661
  if (Array.isArray(response)) {
662
+ inspectMeta?.(void 0);
626
663
  return { data: response, meta: void 0 };
627
664
  }
665
+ inspectMeta?.(response.meta);
628
666
  return {
629
667
  data: response.data ?? [],
630
668
  meta: response.meta
@@ -698,6 +736,11 @@ var CustomersResource = class extends BaseResource {
698
736
  * // With filters
699
737
  * const active = client.customers.list({ kyb_status: 'active' });
700
738
  *
739
+ * // Several statuses at once — one comma-separated string, not an array
740
+ * const needsAttention = client.customers.list({
741
+ * status: 'info_requested,frozen',
742
+ * });
743
+ *
701
744
  * // Collect all to array
702
745
  * const all = await client.customers.list().toArray();
703
746
  * ```
@@ -705,6 +748,38 @@ var CustomersResource = class extends BaseResource {
705
748
  list(params) {
706
749
  return this.paginate("/customers", params);
707
750
  }
751
+ /**
752
+ * One page of customers, with the per-status counts.
753
+ *
754
+ * {@link list} iterates rows and drops the envelope, so `status_counts` —
755
+ * the counts a dashboard's status header renders — is unreachable through
756
+ * it. This returns the raw page instead: same filters, one request, no
757
+ * iteration.
758
+ *
759
+ * The counts are computed under the same filters but IGNORING the `status`
760
+ * selection, so every chip keeps its count while one of them is the active
761
+ * filter.
762
+ *
763
+ * @param params - The same filters {@link list} accepts
764
+ * @returns One page: rows, pagination meta, and `status_counts`
765
+ *
766
+ * @example
767
+ * ```typescript
768
+ * const page = await client.customers.listPage({ limit: 25 });
769
+ * console.log(page.status_counts?.info_requested ?? 0);
770
+ * for (const customer of page.data) {
771
+ * console.log(customer.name, customer.status);
772
+ * }
773
+ * ```
774
+ */
775
+ async listPage(params) {
776
+ const page = await this.transport.request({
777
+ method: "GET",
778
+ path: "/customers",
779
+ query: params
780
+ });
781
+ return { ...page, data: page.data ?? [] };
782
+ }
708
783
  /**
709
784
  * Get a customer by ID.
710
785
  *
@@ -1343,25 +1418,56 @@ var TransactionsResource = class extends BaseResource {
1343
1418
  });
1344
1419
  }
1345
1420
  /**
1346
- * List one-off transactions.
1421
+ * List transactions.
1422
+ *
1423
+ * `GET /transactions` serves three resource families from one path, and the
1424
+ * family decides the row shape — so the family you ask for decides what this
1425
+ * iterator yields:
1426
+ *
1427
+ * | `transaction_type` | Yields |
1428
+ * |--------------------|--------|
1429
+ * | omitted or `'one_off'` | {@link OneOffTransaction} |
1430
+ * | `'wallet'` | {@link WalletTransaction} |
1431
+ * | `'auto_account'` | {@link AutoTransaction} (requires `customer_id`) |
1432
+ *
1433
+ * **The family is always named on the wire.** Left to the server, it is
1434
+ * INFERRED from the other filters, and `customer_id` on its own infers
1435
+ * `auto_account` — so `list({ customer_id })` would return that customer's
1436
+ * auto-account transactions while this method's type promised one-off ones.
1437
+ * Those rows parse into `OneOffTransaction` with missing fields rather than
1438
+ * failing, so nothing surfaced the substitution. Omitting the family here
1439
+ * therefore sends `transaction_type=one_off` rather than leaving it open.
1440
+ *
1441
+ * The family the server reports back (`meta.transaction_type`) is checked
1442
+ * against the one requested, and a mismatch throws instead of yielding rows
1443
+ * of the wrong shape.
1347
1444
  *
1348
1445
  * @param params - Filter and pagination parameters
1349
- * @returns Async iterator of transactions
1446
+ * @returns Async iterator over the requested family
1350
1447
  *
1351
1448
  * @example
1352
1449
  * ```typescript
1353
- * // List all transactions
1450
+ * // One-off transactions (the default family)
1354
1451
  * for await (const tx of client.transactions.list()) {
1355
1452
  * console.log(tx.id, tx.status);
1356
1453
  * }
1357
1454
  *
1358
- * // Filter by customer and status
1455
+ * // This customer's ONE-OFF transactions
1359
1456
  * const completed = client.transactions.list({
1360
1457
  * customer_id: customerId,
1361
1458
  * status: 'completed',
1362
1459
  * });
1363
1460
  *
1364
- * // Wallet-scoped filters (require transaction_type: 'wallet')
1461
+ * // This customer's AUTO-ACCOUNT transactions — a different family,
1462
+ * // and a different row shape
1463
+ * for await (const tx of client.transactions.list({
1464
+ * transaction_type: 'auto_account',
1465
+ * customer_id: customerId,
1466
+ * })) {
1467
+ * console.log(tx.id);
1468
+ * }
1469
+ *
1470
+ * // Wallet transactions
1365
1471
  * const sent = client.transactions.list({
1366
1472
  * transaction_type: 'wallet',
1367
1473
  * wallet_id: walletId,
@@ -1370,7 +1476,13 @@ var TransactionsResource = class extends BaseResource {
1370
1476
  * ```
1371
1477
  */
1372
1478
  list(params) {
1373
- return this.paginate("/transactions", params);
1479
+ const requested = params?.transaction_type ?? "one_off";
1480
+ return this.paginate(
1481
+ "/transactions",
1482
+ { ...params, transaction_type: requested },
1483
+ void 0,
1484
+ (meta) => assertFamily(meta, requested)
1485
+ );
1374
1486
  }
1375
1487
  /**
1376
1488
  * Get a transaction by ID.
@@ -1414,12 +1526,36 @@ var TransactionsResource = class extends BaseResource {
1414
1526
  });
1415
1527
  }
1416
1528
  };
1529
+ function assertFamily(meta, requested) {
1530
+ const served = meta?.transaction_type;
1531
+ if (typeof served !== "string" || served === requested) return;
1532
+ throw new APIError(
1533
+ 200,
1534
+ "transaction_family_mismatch",
1535
+ `Asked for ${requested} transactions but the server listed ${served}. The rows in this page are not the shape this iterator yields, so they are not returned.`,
1536
+ { details: { requested, served } }
1537
+ );
1538
+ }
1417
1539
  var AutoTransactionsResource = class extends BaseResource {
1418
1540
  /**
1419
1541
  * List auto transactions.
1420
1542
  *
1421
- * @param params - Pagination parameters
1543
+ * `statuses` and `types` take a comma-separated string, not an array, and
1544
+ * `start_date` / `end_date` are Unix epoch SECONDS rather than the ISO
1545
+ * strings the other list endpoints take.
1546
+ *
1547
+ * @param params - Filter and pagination parameters
1422
1548
  * @returns Async iterator of auto transactions
1549
+ *
1550
+ * @example
1551
+ * ```typescript
1552
+ * const recent = client.autoTransactions.list({
1553
+ * auto_account_id: accountId,
1554
+ * statuses: 'pending,processing',
1555
+ * start_date: Math.floor(Date.now() / 1000) - 86_400,
1556
+ * sort_dir: 'desc',
1557
+ * });
1558
+ * ```
1423
1559
  */
1424
1560
  list(params) {
1425
1561
  return this.paginate("/auto-transactions", params);
@@ -1633,13 +1769,32 @@ var ApplicationsResource = class extends BaseResource {
1633
1769
  /**
1634
1770
  * Get an application by ID.
1635
1771
  *
1772
+ * `include` inlines extra sections — a comma-separated list of `entities`,
1773
+ * `validation`, `edd`, `attestations`, or `all`. Each adds weight, and
1774
+ * `'all'` carries the full KYB record including every associated
1775
+ * individual's date of birth, nationality and email, so ask for what the
1776
+ * page renders.
1777
+ *
1778
+ * To render an accept-agreements page, use {@link getLegalAcceptance}
1779
+ * instead: it returns exactly that page's inputs and none of the personal
1780
+ * data.
1781
+ *
1636
1782
  * @param applicationId - Application ID
1783
+ * @param params - Optional `{ include }`
1637
1784
  * @returns Application record
1785
+ *
1786
+ * @example
1787
+ * ```typescript
1788
+ * const app = await client.applications.get(applicationId, {
1789
+ * include: 'entities,validation',
1790
+ * });
1791
+ * ```
1638
1792
  */
1639
- async get(applicationId) {
1793
+ async get(applicationId, params) {
1640
1794
  return this.transport.request({
1641
1795
  method: "GET",
1642
- path: `/applications/${applicationId}`
1796
+ path: `/applications/${applicationId}`,
1797
+ query: { ...params }
1643
1798
  });
1644
1799
  }
1645
1800
  /**
@@ -1754,6 +1909,48 @@ var ApplicationsResource = class extends BaseResource {
1754
1909
  // ==========================================================================
1755
1910
  // Attestations
1756
1911
  // ==========================================================================
1912
+ /**
1913
+ * What this application still needs to accept, and who may accept it.
1914
+ *
1915
+ * Exactly what an accept-agreements page renders, and deliberately nothing
1916
+ * more. `get(applicationId)` would answer with the full KYB record — the
1917
+ * business entity, and every associated individual's date of birth,
1918
+ * nationality and email — none of which that page displays. The link that
1919
+ * reaches this endpoint is EMAILED and travels in a URL query string, so its
1920
+ * credential is scoped to this call and the attestation submission, and
1921
+ * cannot read the application.
1922
+ *
1923
+ * Authenticates with an Application Token (`X-Application-Token`), including
1924
+ * the narrow legal-acceptance token a terms refusal issues.
1925
+ *
1926
+ * The documents come back as identity only. Fetch the text to display with
1927
+ * `client.legal.get(key)`, then pass the `version` you displayed back as
1928
+ * `legal_document_version` on {@link submitAttestation}.
1929
+ *
1930
+ * @param applicationId - Application ID
1931
+ * @returns Outstanding agreements, prior acceptances, and permitted attestors
1932
+ *
1933
+ * @example
1934
+ * ```typescript
1935
+ * const ctx = await client.applications.getLegalAcceptance(applicationId);
1936
+ *
1937
+ * for (const doc of ctx.outstanding_documents) {
1938
+ * const text = await client.legal.get(doc.key, doc.version);
1939
+ * render(text.content);
1940
+ * }
1941
+ *
1942
+ * // A business may have several control persons; an individual application
1943
+ * // has exactly one permissible attestor, so there is nobody to pick.
1944
+ * const attestor =
1945
+ * ctx.application_type === 'individual' ? ctx.attestors[0] : await pick(ctx.attestors);
1946
+ * ```
1947
+ */
1948
+ async getLegalAcceptance(applicationId) {
1949
+ return this.transport.request({
1950
+ method: "GET",
1951
+ path: `/applications/${applicationId}/legal-acceptance`
1952
+ });
1953
+ }
1757
1954
  /**
1758
1955
  * Submit an attestation for an application.
1759
1956
  *
@@ -2607,6 +2804,133 @@ var InfoResource = class extends BaseResource {
2607
2804
  }
2608
2805
  };
2609
2806
 
2807
+ // src/client/resources/legal.ts
2808
+ var LegalResource = class extends BaseResource {
2809
+ /**
2810
+ * List the revision of every legal document currently in force.
2811
+ *
2812
+ * An INDEX, not a bundle: each entry names a document and its in-force
2813
+ * revision, without the text. Fetch {@link get} for the one document you
2814
+ * are about to display — inlining every document would put the whole corpus
2815
+ * on every call.
2816
+ *
2817
+ * Not safe to cache indefinitely: it names whichever revision is in force
2818
+ * NOW, and that changes when a new one is published. A specific
2819
+ * `(key, version)` from {@link get} is a different matter — revisions are
2820
+ * immutable, so that text can be cached for as long as you like.
2821
+ *
2822
+ * @returns The in-force revision of each document, without its text
2823
+ *
2824
+ * @example
2825
+ * ```typescript
2826
+ * for (const doc of await client.legal.list()) {
2827
+ * console.log(doc.key, doc.version, doc.title);
2828
+ * }
2829
+ * ```
2830
+ */
2831
+ async list() {
2832
+ const response = await this.transport.request({
2833
+ method: "GET",
2834
+ path: "/legal/documents"
2835
+ });
2836
+ return response.data ?? [];
2837
+ }
2838
+ /**
2839
+ * Get one legal document — the revision in force, or a specific one.
2840
+ *
2841
+ * Pass the `version` you displayed back as `legal_document_version` when
2842
+ * submitting an attestation, so the acceptance record names the exact text
2843
+ * the customer saw rather than whichever revision happened to be current
2844
+ * when the request arrived.
2845
+ *
2846
+ * @param documentKey - Document identifier, e.g. `'dakota_tos'`
2847
+ * @param version - A specific published revision. Omit for the one in force
2848
+ * @returns The requested revision, including its text
2849
+ *
2850
+ * @example
2851
+ * ```typescript
2852
+ * const tos = await client.legal.get('dakota_tos');
2853
+ * render(tos.content);
2854
+ *
2855
+ * await client.applications.submitAttestation(applicationId, {
2856
+ * attestation_type: 'terms_of_service',
2857
+ * legal_document_version: tos.version, // records what they actually saw
2858
+ * // ...
2859
+ * });
2860
+ * ```
2861
+ */
2862
+ async get(documentKey, version) {
2863
+ return this.transport.request({
2864
+ method: "GET",
2865
+ path: `/legal/documents/${documentKey}`,
2866
+ query: version !== void 0 ? { version } : void 0
2867
+ });
2868
+ }
2869
+ };
2870
+
2871
+ // src/client/resources/rd-marketing-fee.ts
2872
+ var RDMarketingFeeResource = class extends BaseResource {
2873
+ /**
2874
+ * The months this client has a statement for, newest first.
2875
+ *
2876
+ * Runs from the start of their contract to the running month, and the
2877
+ * RUNNING month IS included. It cannot be priced yet — the bank's interest
2878
+ * posts in the month after it is earned — but the balance is real and
2879
+ * accruing, and a client checking mid-month has to be able to see it. Its
2880
+ * fee figures come back absent rather than zero.
2881
+ *
2882
+ * An EMPTY list means the contract is real but no month has started yet.
2883
+ * That is different from a 404, which means no contract at all.
2884
+ *
2885
+ * @returns Statement months as `YYYY-MM-DD` (first day of the month, UTC)
2886
+ *
2887
+ * @example
2888
+ * ```typescript
2889
+ * const months = await client.rdMarketingFee.listMonths();
2890
+ * if (months.length === 0) {
2891
+ * // Contract starts next month or later — "starting soon", not an error.
2892
+ * }
2893
+ * ```
2894
+ */
2895
+ async listMonths() {
2896
+ const response = await this.transport.request({
2897
+ method: "GET",
2898
+ path: "/rd-marketing-fee/statements"
2899
+ });
2900
+ return response.months ?? [];
2901
+ }
2902
+ /**
2903
+ * One month's statement — one row per calendar day: the date, the RD
2904
+ * balance, and that day's fee.
2905
+ *
2906
+ * The rows are the STORED daily principals, read rather than recomputed, so
2907
+ * what the client reads and what Dakota priced cannot drift.
2908
+ *
2909
+ * Absent is not zero. A balance is absent when the day has not been derived
2910
+ * yet and `'0'` when the client genuinely held no RD; fees are absent for
2911
+ * every day of a month whose rate has not been derived. Neither unknown is
2912
+ * reported as a zero, so render an absent figure as unknown rather than
2913
+ * defaulting it.
2914
+ *
2915
+ * @param month - First day of the month, UTC, as `YYYY-MM-DD`
2916
+ * @returns The month's statement, one row per day
2917
+ *
2918
+ * @example
2919
+ * ```typescript
2920
+ * const statement = await client.rdMarketingFee.getStatement('2026-08-01');
2921
+ * for (const day of statement.daily) {
2922
+ * console.log(day.date, day.balance_minor ?? 'not yet derived');
2923
+ * }
2924
+ * ```
2925
+ */
2926
+ async getStatement(month) {
2927
+ return this.transport.request({
2928
+ method: "GET",
2929
+ path: `/rd-marketing-fee/statements/${month}`
2930
+ });
2931
+ }
2932
+ };
2933
+
2610
2934
  // src/client/resources/sandbox.ts
2611
2935
  var SandboxResource = class extends BaseResource {
2612
2936
  /**
@@ -2866,11 +3190,23 @@ var SelfServeResource = class extends BaseResource {
2866
3190
  * type: 'purchase',
2867
3191
  * limit: 50,
2868
3192
  * });
3193
+ *
3194
+ * // Paging: carry BOTH halves of the cursor. Entries written in one
3195
+ * // transaction share a created_at, so a page boundary inside such a
3196
+ * // group drops rows when only `cursor` is sent.
3197
+ * const last = purchases.entries[purchases.entries.length - 1];
3198
+ * const next = await client.selfServe.listLedger({
3199
+ * type: 'purchase',
3200
+ * limit: 50,
3201
+ * cursor: last.created_at,
3202
+ * cursor_id: last.id,
3203
+ * });
2869
3204
  * ```
2870
3205
  */
2871
3206
  async listLedger(params) {
2872
3207
  const query = {};
2873
3208
  if (params?.cursor !== void 0) query.cursor = params.cursor;
3209
+ if (params?.cursor_id !== void 0) query.cursor_id = params.cursor_id;
2874
3210
  if (params?.limit !== void 0) query.limit = params.limit;
2875
3211
  if (params?.type !== void 0) query.type = params.type;
2876
3212
  return this.transport.request({
@@ -3068,10 +3404,10 @@ var PaymentAgentsResource = class extends BaseResource {
3068
3404
  * alternatives. Branch on `blocker.code`, not on `reply`, and ignore codes
3069
3405
  * you do not recognize.
3070
3406
  *
3071
- * `data.client_policy` is a DEVELOPMENT override of the vocabulary the
3072
- * agent drafts under; prefer registering it once with
3073
- * `client.agenticPolicy.set()`, since forgetting to send it here fails
3074
- * silently.
3407
+ * The vocabulary the agent drafts under is the one registered with
3408
+ * `client.agenticPolicy.set()`. It is not a property of this request —
3409
+ * a policy sent here is ignored, which is why the option to send one is
3410
+ * gone.
3075
3411
  *
3076
3412
  * @param paymentAgentId - Payment agent ID
3077
3413
  * @param data - Prompt and/or messages
@@ -3129,7 +3465,7 @@ var InstructionsResource = class extends BaseResource {
3129
3465
  /**
3130
3466
  * Accept proposals — actuate them into persisted instructions.
3131
3467
  *
3132
- * Two optional fields shape the actuation:
3468
+ * One optional field shapes the actuation:
3133
3469
  *
3134
3470
  * - `developer_fee` declares your fee PER PAYOUT TYPE — `swap_bps` for a
3135
3471
  * crypto payout, `offramp_bps` for a bank payout. They are independent,
@@ -3139,8 +3475,10 @@ var InstructionsResource = class extends BaseResource {
3139
3475
  * amount, and the agent is told nothing about a fee it could mention.
3140
3476
  * Both are DEFAULTS for the auto-accounts this request creates — an
3141
3477
  * action-level `fee_bps` still wins outright.
3142
- * - `client_policy` is the same development override the proposals call
3143
- * takes. Prefer registering it once with `client.agenticPolicy.set()`.
3478
+ *
3479
+ * The vocabulary the actuation is judged against comes from the policy
3480
+ * registered with `client.agenticPolicy.set()` — the same one the drafting
3481
+ * turn used, which is the point of registering it rather than sending it.
3144
3482
  *
3145
3483
  * @param data - The payment agent id and the proposals to accept
3146
3484
  * @returns instruction_ids + the mandates the batch drafted (in full
@@ -3429,52 +3767,23 @@ var InsightsResource = class extends BaseResource {
3429
3767
  path: `/customers/${customerId}/insights`
3430
3768
  });
3431
3769
  }
3432
- /**
3433
- * Ask about the customer's account.
3434
- *
3435
- * A read-only, advisory conversation. Stateless: send the conversation so
3436
- * far in `messages` on each call; the response is the assistant's next
3437
- * plain-text `reply`. The assistant narrates the same deterministic report
3438
- * {@link get} returns — it never originates a number, never proposes, and
3439
- * never moves money. Rate-limited per customer (hourly burst + daily
3440
- * window) — a 429 means back off and retry later.
3441
- *
3442
- * Model-backed, so it defaults to {@link AGENTIC_MODEL_TIMEOUT_MS} rather
3443
- * than the client's ordinary deadline. Pass `{ timeout }` to change it for
3444
- * one call; an explicit client-wide `timeout` still wins.
3445
- *
3446
- * @param customerId - Customer ID
3447
- * @param data - The conversation so far (1–40 messages)
3448
- * @returns The assistant's reply (+ how the boundary screen treated the turn)
3449
- */
3450
- async chat(customerId, data, options) {
3451
- return this.transport.request({
3452
- method: "POST",
3453
- path: `/customers/${customerId}/insights/chat`,
3454
- body: data,
3455
- idempotencyKey: options?.idempotencyKey,
3456
- timeout: options?.timeout,
3457
- endpointTimeout: AGENTIC_MODEL_TIMEOUT_MS
3458
- });
3459
- }
3460
3770
  };
3461
3771
 
3462
3772
  // src/client/resources/agentic-policy.ts
3463
3773
  var AgenticPolicyResource = class extends BaseResource {
3464
3774
  /**
3465
- * Get the policy registered for this client.
3775
+ * Get the policy registered for the client behind your API key.
3466
3776
  *
3467
3777
  * A 404 here is the DEFAULT, not an error condition: with no registration
3468
3778
  * and no per-request policy the agent drafts on platform defaults, exactly
3469
3779
  * as it did before registration existed.
3470
3780
  *
3471
- * @param clientId - Your client ID
3472
3781
  * @returns The normalized registered policy + its timestamps
3473
3782
  *
3474
3783
  * @example
3475
3784
  * ```typescript
3476
3785
  * try {
3477
- * const { policy } = await client.agenticPolicy.get(clientId);
3786
+ * const { policy } = await client.agenticPolicy.get();
3478
3787
  * console.log(policy.labels);
3479
3788
  * } catch (e) {
3480
3789
  * if (e instanceof APIError && e.statusCode === 404) {
@@ -3483,20 +3792,22 @@ var AgenticPolicyResource = class extends BaseResource {
3483
3792
  * }
3484
3793
  * ```
3485
3794
  */
3486
- async get(clientId) {
3795
+ async get() {
3487
3796
  return this.transport.request({
3488
3797
  method: "GET",
3489
- path: `/clients/${clientId}/agentic-policy`
3798
+ path: "/agentic-policy"
3490
3799
  });
3491
3800
  }
3492
3801
  /**
3493
3802
  * Register — or fully replace — this client's agentic policy.
3494
3803
  *
3495
- * Declaring the vocabulary once removes a silent failure mode. Sending
3496
- * `client_policy` in each proposals request still works and still wins, but
3497
- * FORGETTING to send it fails silently: the agent just narrates in the
3498
- * platform's nouns again ("destination", "mandate") and nothing errors
3499
- * anywhere. A registration makes that impossible.
3804
+ * Registration is the ONLY way to set a policy. A policy is a property of
3805
+ * the CLIENT, not of a request: carried per request, a drafting turn and
3806
+ * the accept that followed it could be judged by different rules. The
3807
+ * platform accordingly stopped reading `client_policy` from request bodies,
3808
+ * and one sent there is now ignored — silently, since the agent simply
3809
+ * narrates in the platform's nouns again ("destination", "mandate") with no
3810
+ * error anywhere. Registering once removes that failure mode.
3500
3811
  *
3501
3812
  * FULL REPLACE, not a merge — the registration IS your declared vocabulary,
3502
3813
  * so an omitted field means you no longer want it, and an empty body (`{}`)
@@ -3506,14 +3817,15 @@ var AgenticPolicyResource = class extends BaseResource {
3506
3817
  * unsupported value, or a label for an unimplemented concept is a 400 HERE,
3507
3818
  * at registration — not a surprise on a customer's first conversation.
3508
3819
  *
3509
- * @param clientId - Your client ID
3820
+ * The client comes from your API key; there is no id to pass.
3821
+ *
3510
3822
  * @param policy - The complete policy (`{}` clears it)
3511
3823
  * @param options - Request options (e.g., custom idempotency key)
3512
3824
  * @returns The normalized stored policy + its timestamps
3513
3825
  *
3514
3826
  * @example
3515
3827
  * ```typescript
3516
- * await client.agenticPolicy.set(clientId, {
3828
+ * await client.agenticPolicy.set({
3517
3829
  * payee_model: 'flat',
3518
3830
  * payout_assets: ['USDC', 'USDT'],
3519
3831
  * labels: { limit: 'spending limit', payee: 'recipient', limit_unit: 'USD' },
@@ -3522,10 +3834,10 @@ var AgenticPolicyResource = class extends BaseResource {
3522
3834
  * });
3523
3835
  * ```
3524
3836
  */
3525
- async set(clientId, policy, options) {
3837
+ async set(policy, options) {
3526
3838
  return this.transport.request({
3527
3839
  method: "PUT",
3528
- path: `/clients/${clientId}/agentic-policy`,
3840
+ path: "/agentic-policy",
3529
3841
  body: policy,
3530
3842
  idempotencyKey: options?.idempotencyKey,
3531
3843
  timeout: options?.timeout
@@ -3534,19 +3846,20 @@ var AgenticPolicyResource = class extends BaseResource {
3534
3846
  };
3535
3847
 
3536
3848
  // src/agentic/chat.ts
3849
+ var REJECTED_INPUT = "rejected_input";
3537
3850
  var AgentConversation = class {
3538
3851
  client;
3539
3852
  paymentAgentId;
3540
3853
  timezone;
3541
3854
  timeout;
3542
- clientPolicy;
3855
+ developerFee;
3543
3856
  history = [];
3544
3857
  constructor(client, paymentAgentId, history, options) {
3545
3858
  this.client = client;
3546
3859
  this.paymentAgentId = paymentAgentId;
3547
3860
  this.timezone = options?.timezone;
3548
3861
  this.timeout = options?.timeout;
3549
- this.clientPolicy = options?.clientPolicy;
3862
+ this.developerFee = options?.developerFee;
3550
3863
  if (history && history.length > 0) {
3551
3864
  this.history = history.map(cloneMessage);
3552
3865
  }
@@ -3591,12 +3904,10 @@ var AgentConversation = class {
3591
3904
  this.paymentAgentId,
3592
3905
  {
3593
3906
  messages,
3594
- // Resent on EVERY turn — the endpoint is stateless, so a zone given
3595
- // once would be forgotten on the next one. Same for the policy
3596
- // override: an omitted one silently falls back to the client's
3597
- // registration (or platform defaults).
3907
+ // Resent on EVERY turn — the endpoint is stateless, so a value
3908
+ // given once would be forgotten on the next one.
3598
3909
  ...this.timezone ? { timezone: this.timezone } : {},
3599
- ...this.clientPolicy ? { client_policy: this.clientPolicy } : {}
3910
+ ...this.developerFee ? { developer_fee: this.developerFee } : {}
3600
3911
  },
3601
3912
  this.timeout !== void 0 ? { timeout: this.timeout } : void 0
3602
3913
  );
@@ -3612,6 +3923,10 @@ var AgentConversation = class {
3612
3923
  hasBlockers: !!result.blockers && result.blockers.length > 0,
3613
3924
  conversationStatus: result.conversation_status ?? ""
3614
3925
  };
3926
+ if (turn.conversationStatus === REJECTED_INPUT) {
3927
+ this.history.pop();
3928
+ return turn;
3929
+ }
3615
3930
  let assistant = turn.reply;
3616
3931
  if (!assistant) {
3617
3932
  assistant = turn.hasProposals ? "(drafted proposals for your review)" : "(no reply)";
@@ -3737,6 +4052,10 @@ var DakotaClient = class {
3737
4052
  webhooks;
3738
4053
  /** Info API - query platform capabilities */
3739
4054
  info;
4055
+ /** Legal API - the published terms customers accept (unauthenticated) */
4056
+ legal;
4057
+ /** RD Marketing Fee API - this client's reserve-management statements */
4058
+ rdMarketingFee;
3740
4059
  /** Sandbox API - testing simulations (sandbox only) */
3741
4060
  sandbox;
3742
4061
  /** Self-Serve Credits API - manage prepaid transfer credits */
@@ -3806,6 +4125,8 @@ var DakotaClient = class {
3806
4125
  this.users = new UsersResource(this.transport);
3807
4126
  this.webhooks = new WebhooksResource(this.transport);
3808
4127
  this.info = new InfoResource(this.transport);
4128
+ this.legal = new LegalResource(this.transport);
4129
+ this.rdMarketingFee = new RDMarketingFeeResource(this.transport);
3809
4130
  this.sandbox = new SandboxResource(this.transport);
3810
4131
  this.selfServe = new SelfServeResource(this.transport);
3811
4132
  this.feePayoutDestination = new FeePayoutDestinationResource(this.transport);