@dakota-xyz/ts-sdk 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1205,6 +1205,14 @@ var AccountsResource = class extends BaseResource {
1205
1205
  * });
1206
1206
  * // Returns: { bank_account: { bank_name, aba_routing_number, account_number } } - customer sends USD here
1207
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.
1208
1216
  */
1209
1217
  async create(data, options) {
1210
1218
  return this.transport.request({
@@ -3058,6 +3066,15 @@ var PaymentAgentsResource = class extends BaseResource {
3058
3066
  * rather than the client's ordinary deadline. Pass `{ timeout }` to
3059
3067
  * change it for one call; an explicit client-wide `timeout` still wins.
3060
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
+ *
3061
3078
  * @param paymentAgentId - Payment agent ID
3062
3079
  * @param data - Prompt and/or messages
3063
3080
  * @returns Proposals (at high confidence) and/or a conversational reply
@@ -3114,6 +3131,19 @@ var InstructionsResource = class extends BaseResource {
3114
3131
  /**
3115
3132
  * Accept proposals — actuate them into persisted instructions.
3116
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
+ *
3117
3147
  * @param data - The payment agent id and the proposals to accept
3118
3148
  * @returns instruction_ids + the mandates the batch drafted (in full
3119
3149
  * wire shape; sign the §8 approval immediately)
@@ -3431,18 +3461,94 @@ var InsightsResource = class extends BaseResource {
3431
3461
  }
3432
3462
  };
3433
3463
 
3464
+ // src/client/resources/agentic-policy.ts
3465
+ var AgenticPolicyResource = class extends BaseResource {
3466
+ /**
3467
+ * Get the policy registered for the client behind your API key.
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
+ * @returns The normalized registered policy + its timestamps
3474
+ *
3475
+ * @example
3476
+ * ```typescript
3477
+ * try {
3478
+ * const { policy } = await client.agenticPolicy.get();
3479
+ * console.log(policy.labels);
3480
+ * } catch (e) {
3481
+ * if (e instanceof APIError && e.statusCode === 404) {
3482
+ * // No registration — platform defaults apply.
3483
+ * }
3484
+ * }
3485
+ * ```
3486
+ */
3487
+ async get() {
3488
+ return this.transport.request({
3489
+ method: "GET",
3490
+ path: "/agentic-policy"
3491
+ });
3492
+ }
3493
+ /**
3494
+ * Register — or fully replace — this client's agentic policy.
3495
+ *
3496
+ * Declaring the vocabulary once removes a silent failure mode. Sending
3497
+ * `client_policy` in each proposals request still works and still wins, but
3498
+ * FORGETTING to send it fails silently: the agent just narrates in the
3499
+ * platform's nouns again ("destination", "mandate") and nothing errors
3500
+ * anywhere. A registration makes that impossible.
3501
+ *
3502
+ * FULL REPLACE, not a merge — the registration IS your declared vocabulary,
3503
+ * so an omitted field means you no longer want it, and an empty body (`{}`)
3504
+ * clears the registration back to platform defaults.
3505
+ *
3506
+ * Validated exactly like the per-request copy, so an unknown key, an
3507
+ * unsupported value, or a label for an unimplemented concept is a 400 HERE,
3508
+ * at registration — not a surprise on a customer's first conversation.
3509
+ *
3510
+ * The client comes from your API key; there is no id to pass.
3511
+ *
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({
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(policy, options) {
3528
+ return this.transport.request({
3529
+ method: "PUT",
3530
+ path: "/agentic-policy",
3531
+ body: policy,
3532
+ idempotencyKey: options?.idempotencyKey,
3533
+ timeout: options?.timeout
3534
+ });
3535
+ }
3536
+ };
3537
+
3434
3538
  // src/agentic/chat.ts
3435
3539
  var AgentConversation = class {
3436
3540
  client;
3437
3541
  paymentAgentId;
3438
3542
  timezone;
3439
3543
  timeout;
3544
+ clientPolicy;
3440
3545
  history = [];
3441
3546
  constructor(client, paymentAgentId, history, options) {
3442
3547
  this.client = client;
3443
3548
  this.paymentAgentId = paymentAgentId;
3444
3549
  this.timezone = options?.timezone;
3445
3550
  this.timeout = options?.timeout;
3551
+ this.clientPolicy = options?.clientPolicy;
3446
3552
  if (history && history.length > 0) {
3447
3553
  this.history = history.map(cloneMessage);
3448
3554
  }
@@ -3488,8 +3594,11 @@ var AgentConversation = class {
3488
3594
  {
3489
3595
  messages,
3490
3596
  // Resent on EVERY turn — the endpoint is stateless, so a zone given
3491
- // once would be forgotten on the next one.
3492
- ...this.timezone ? { timezone: this.timezone } : {}
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 } : {}
3493
3602
  },
3494
3603
  this.timeout !== void 0 ? { timeout: this.timeout } : void 0
3495
3604
  );
@@ -3501,6 +3610,8 @@ var AgentConversation = class {
3501
3610
  reply: result.reply ?? "",
3502
3611
  proposals: result.proposals ? [...result.proposals] : [],
3503
3612
  hasProposals: !!result.proposals && result.proposals.length > 0,
3613
+ blockers: result.blockers ? [...result.blockers] : [],
3614
+ hasBlockers: !!result.blockers && result.blockers.length > 0,
3504
3615
  conversationStatus: result.conversation_status ?? ""
3505
3616
  };
3506
3617
  let assistant = turn.reply;
@@ -3644,6 +3755,8 @@ var DakotaClient = class {
3644
3755
  scheduledPayments;
3645
3756
  /** Insights API (ALPHA) - read-only advisory reporting over agentic activity */
3646
3757
  insights;
3758
+ /** Agentic Policy API (ALPHA) - register the vocabulary the agent speaks for your product */
3759
+ agenticPolicy;
3647
3760
  /**
3648
3761
  * Create a new Dakota client.
3649
3762
  *
@@ -3703,6 +3816,7 @@ var DakotaClient = class {
3703
3816
  this.mandates = new MandatesResource(this.transport);
3704
3817
  this.scheduledPayments = new ScheduledPaymentsResource(this.transport);
3705
3818
  this.insights = new InsightsResource(this.transport);
3819
+ this.agenticPolicy = new AgenticPolicyResource(this.transport);
3706
3820
  }
3707
3821
  // ==========================================================================
3708
3822
  // Agentic Payments high-level helpers (ALPHA)
@@ -4007,6 +4121,7 @@ function verifyMandateSignature(publicKeyBase64, payload, signatureBase64) {
4007
4121
  exports.APIError = APIError;
4008
4122
  exports.AccountsResource = AccountsResource;
4009
4123
  exports.AgentConversation = AgentConversation;
4124
+ exports.AgenticPolicyResource = AgenticPolicyResource;
4010
4125
  exports.ApiKeysResource = ApiKeysResource;
4011
4126
  exports.ApplicationsResource = ApplicationsResource;
4012
4127
  exports.AuthMode = AuthMode;