@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.mjs CHANGED
@@ -1203,6 +1203,14 @@ var AccountsResource = class extends BaseResource {
1203
1203
  * });
1204
1204
  * // Returns: { bank_account: { bank_name, aba_routing_number, account_number } } - customer sends USD here
1205
1205
  * ```
1206
+ *
1207
+ * @remarks
1208
+ * `max_transactions` caps how many transactions the account may ever
1209
+ * create — `1` makes it a one-off. Know what reaching the cap does before
1210
+ * you set one: further deposits are **refused, not returned**. The funds
1211
+ * still arrive and are then held pending manual intervention, with nothing
1212
+ * converted, nothing forwarded, and no transaction on the account for
1213
+ * them. Stop sending to the deposit details once the cap is reached.
1206
1214
  */
1207
1215
  async create(data, options) {
1208
1216
  return this.transport.request({
@@ -3056,6 +3064,15 @@ var PaymentAgentsResource = class extends BaseResource {
3056
3064
  * rather than the client's ordinary deadline. Pass `{ timeout }` to
3057
3065
  * change it for one call; an explicit client-wide `timeout` still wins.
3058
3066
  *
3067
+ * The result may carry `blockers` ALONGSIDE proposals — they are not
3068
+ * alternatives. Branch on `blocker.code`, not on `reply`, and ignore codes
3069
+ * you do not recognize.
3070
+ *
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.
3075
+ *
3059
3076
  * @param paymentAgentId - Payment agent ID
3060
3077
  * @param data - Prompt and/or messages
3061
3078
  * @returns Proposals (at high confidence) and/or a conversational reply
@@ -3112,6 +3129,19 @@ var InstructionsResource = class extends BaseResource {
3112
3129
  /**
3113
3130
  * Accept proposals — actuate them into persisted instructions.
3114
3131
  *
3132
+ * Two optional fields shape the actuation:
3133
+ *
3134
+ * - `developer_fee` declares your fee PER PAYOUT TYPE — `swap_bps` for a
3135
+ * crypto payout, `offramp_bps` for a bank payout. They are independent,
3136
+ * so one conversation can charge a swap and stay silent about a bank
3137
+ * payout in the same turn. Omit a rate (or send zero) and that payout
3138
+ * type carries no fee: nothing is charged, nothing is added to the
3139
+ * amount, and the agent is told nothing about a fee it could mention.
3140
+ * Both are DEFAULTS for the auto-accounts this request creates — an
3141
+ * 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()`.
3144
+ *
3115
3145
  * @param data - The payment agent id and the proposals to accept
3116
3146
  * @returns instruction_ids + the mandates the batch drafted (in full
3117
3147
  * wire shape; sign the §8 approval immediately)
@@ -3429,18 +3459,94 @@ var InsightsResource = class extends BaseResource {
3429
3459
  }
3430
3460
  };
3431
3461
 
3462
+ // src/client/resources/agentic-policy.ts
3463
+ var AgenticPolicyResource = class extends BaseResource {
3464
+ /**
3465
+ * Get the policy registered for the client behind your API key.
3466
+ *
3467
+ * A 404 here is the DEFAULT, not an error condition: with no registration
3468
+ * and no per-request policy the agent drafts on platform defaults, exactly
3469
+ * as it did before registration existed.
3470
+ *
3471
+ * @returns The normalized registered policy + its timestamps
3472
+ *
3473
+ * @example
3474
+ * ```typescript
3475
+ * try {
3476
+ * const { policy } = await client.agenticPolicy.get();
3477
+ * console.log(policy.labels);
3478
+ * } catch (e) {
3479
+ * if (e instanceof APIError && e.statusCode === 404) {
3480
+ * // No registration — platform defaults apply.
3481
+ * }
3482
+ * }
3483
+ * ```
3484
+ */
3485
+ async get() {
3486
+ return this.transport.request({
3487
+ method: "GET",
3488
+ path: "/agentic-policy"
3489
+ });
3490
+ }
3491
+ /**
3492
+ * Register — or fully replace — this client's agentic policy.
3493
+ *
3494
+ * Declaring the vocabulary once removes a silent failure mode. Sending
3495
+ * `client_policy` in each proposals request still works and still wins, but
3496
+ * FORGETTING to send it fails silently: the agent just narrates in the
3497
+ * platform's nouns again ("destination", "mandate") and nothing errors
3498
+ * anywhere. A registration makes that impossible.
3499
+ *
3500
+ * FULL REPLACE, not a merge — the registration IS your declared vocabulary,
3501
+ * so an omitted field means you no longer want it, and an empty body (`{}`)
3502
+ * clears the registration back to platform defaults.
3503
+ *
3504
+ * Validated exactly like the per-request copy, so an unknown key, an
3505
+ * unsupported value, or a label for an unimplemented concept is a 400 HERE,
3506
+ * at registration — not a surprise on a customer's first conversation.
3507
+ *
3508
+ * The client comes from your API key; there is no id to pass.
3509
+ *
3510
+ * @param policy - The complete policy (`{}` clears it)
3511
+ * @param options - Request options (e.g., custom idempotency key)
3512
+ * @returns The normalized stored policy + its timestamps
3513
+ *
3514
+ * @example
3515
+ * ```typescript
3516
+ * await client.agenticPolicy.set({
3517
+ * payee_model: 'flat',
3518
+ * payout_assets: ['USDC', 'USDT'],
3519
+ * labels: { limit: 'spending limit', payee: 'recipient', limit_unit: 'USD' },
3520
+ * payout_route: 'conversion_account_only',
3521
+ * mandate_strategy: 'external_only',
3522
+ * });
3523
+ * ```
3524
+ */
3525
+ async set(policy, options) {
3526
+ return this.transport.request({
3527
+ method: "PUT",
3528
+ path: "/agentic-policy",
3529
+ body: policy,
3530
+ idempotencyKey: options?.idempotencyKey,
3531
+ timeout: options?.timeout
3532
+ });
3533
+ }
3534
+ };
3535
+
3432
3536
  // src/agentic/chat.ts
3433
3537
  var AgentConversation = class {
3434
3538
  client;
3435
3539
  paymentAgentId;
3436
3540
  timezone;
3437
3541
  timeout;
3542
+ clientPolicy;
3438
3543
  history = [];
3439
3544
  constructor(client, paymentAgentId, history, options) {
3440
3545
  this.client = client;
3441
3546
  this.paymentAgentId = paymentAgentId;
3442
3547
  this.timezone = options?.timezone;
3443
3548
  this.timeout = options?.timeout;
3549
+ this.clientPolicy = options?.clientPolicy;
3444
3550
  if (history && history.length > 0) {
3445
3551
  this.history = history.map(cloneMessage);
3446
3552
  }
@@ -3486,8 +3592,11 @@ var AgentConversation = class {
3486
3592
  {
3487
3593
  messages,
3488
3594
  // Resent on EVERY turn — the endpoint is stateless, so a zone given
3489
- // once would be forgotten on the next one.
3490
- ...this.timezone ? { timezone: this.timezone } : {}
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).
3598
+ ...this.timezone ? { timezone: this.timezone } : {},
3599
+ ...this.clientPolicy ? { client_policy: this.clientPolicy } : {}
3491
3600
  },
3492
3601
  this.timeout !== void 0 ? { timeout: this.timeout } : void 0
3493
3602
  );
@@ -3499,6 +3608,8 @@ var AgentConversation = class {
3499
3608
  reply: result.reply ?? "",
3500
3609
  proposals: result.proposals ? [...result.proposals] : [],
3501
3610
  hasProposals: !!result.proposals && result.proposals.length > 0,
3611
+ blockers: result.blockers ? [...result.blockers] : [],
3612
+ hasBlockers: !!result.blockers && result.blockers.length > 0,
3502
3613
  conversationStatus: result.conversation_status ?? ""
3503
3614
  };
3504
3615
  let assistant = turn.reply;
@@ -3642,6 +3753,8 @@ var DakotaClient = class {
3642
3753
  scheduledPayments;
3643
3754
  /** Insights API (ALPHA) - read-only advisory reporting over agentic activity */
3644
3755
  insights;
3756
+ /** Agentic Policy API (ALPHA) - register the vocabulary the agent speaks for your product */
3757
+ agenticPolicy;
3645
3758
  /**
3646
3759
  * Create a new Dakota client.
3647
3760
  *
@@ -3701,6 +3814,7 @@ var DakotaClient = class {
3701
3814
  this.mandates = new MandatesResource(this.transport);
3702
3815
  this.scheduledPayments = new ScheduledPaymentsResource(this.transport);
3703
3816
  this.insights = new InsightsResource(this.transport);
3817
+ this.agenticPolicy = new AgenticPolicyResource(this.transport);
3704
3818
  }
3705
3819
  // ==========================================================================
3706
3820
  // Agentic Payments high-level helpers (ALPHA)
@@ -4002,6 +4116,6 @@ function verifyMandateSignature(publicKeyBase64, payload, signatureBase64) {
4002
4116
  }
4003
4117
  }
4004
4118
 
4005
- export { APIError, AccountsResource, AgentConversation, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, FeePayoutDestinationResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateAmendSignPayload, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
4119
+ export { APIError, AccountsResource, AgentConversation, AgenticPolicyResource, ApiKeysResource, ApplicationsResource, AuthMode, AutoTransactionsResource, ConfigurationError, CustomersResource, DEFAULT_RETRY_POLICY, DakotaClient, DestinationsResource, Environment, EventsResource, FeePayoutDestinationResource, InfoResource, InsightsResource, InstructionsResource, MandatesResource, P256MandateSigner, PaginatedIterator, PaymentAgentsResource, PoliciesResource, RecipientsResource, SandboxResource, ScheduledPaymentsResource, SelfServeResource, SignerGroupsResource, SignersResource, TransactionsResource, TransportError, UsersResource, WalletsResource, WebhooksResource, addPolicyRulePayload, attachGroupPayload, attachPolicyPayload, attachUserToWallet, canonicalJSON, consoleLogger, deletePolicyPayload, detachGroupPayload, detachPolicyPayload, detachUserFromWallet, getEnvironmentURL, mandateAmendSignPayload, mandateSignPayload, noopLogger, paginate, removePolicyRulePayload, updatePolicyRulePayload, verifyMandateSignature };
4006
4120
  //# sourceMappingURL=index.mjs.map
4007
4121
  //# sourceMappingURL=index.mjs.map