@naturalpay/sdk 0.1.4 → 0.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/dist/index.d.cts CHANGED
@@ -145,11 +145,17 @@ interface PaymentCreateParams {
145
145
  agentId?: string;
146
146
  /** Payment amount in minor units (cents). 5000 = $50.00. */
147
147
  amount: number;
148
- customerPartyId: string;
148
+ /** Sender party ID (pty_xxx). Omit to send from your own wallet; provide for delegated payments on behalf of a customer. */
149
+ customerPartyId?: string;
149
150
  /** Recipient email, phone number, or party ID (pty_xxx). */
150
151
  recipient: string;
151
- /** Payment memo/description. */
152
- memo: string;
152
+ /**
153
+ * Human-readable description of the payment's purpose. Required for all SDK
154
+ * callers. For agent-initiated payments, write a rich rationale (≥20 chars
155
+ * recommended) so the user can confidently approve and the audit trail is
156
+ * legible.
157
+ */
158
+ description: string;
153
159
  /** Currency code (default: USD). */
154
160
  currency?: string;
155
161
  idempotencyKey: string;
@@ -175,8 +181,9 @@ interface Transaction {
175
181
  amount: number;
176
182
  currency: string;
177
183
  status: string;
184
+ escalationId?: string;
185
+ disputeId?: string;
178
186
  description?: string;
179
- memo?: string;
180
187
  createdAt: string;
181
188
  updatedAt?: string;
182
189
  isDelegated: boolean;
@@ -184,6 +191,8 @@ interface Transaction {
184
191
  customerAgentId?: string;
185
192
  senderName?: string;
186
193
  recipientName?: string;
194
+ initiatorName?: string;
195
+ initiatorIsAgent?: boolean;
187
196
  transactionType: string;
188
197
  category: string;
189
198
  direction: string;
@@ -191,7 +200,7 @@ interface Transaction {
191
200
  destinationPartyId?: string;
192
201
  sourceWalletId?: string;
193
202
  destinationWalletId?: string;
194
- /** Internal instance ID (ins_xxx) assigned by server. */
203
+ /** Present on payment creation responses when agent instance metadata was supplied. */
195
204
  instanceId?: string;
196
205
  /** Claim link URL for unclaimed payments. */
197
206
  claimLink?: string;
@@ -246,9 +255,9 @@ interface AmountInfo {
246
255
  interface BalanceBreakdown {
247
256
  operatingFunded: AmountInfo;
248
257
  operatingAdvanced: AmountInfo;
249
- escrowFundedSettled: AmountInfo;
250
- escrowAdvanced: AmountInfo;
251
- holdsOutbound: AmountInfo;
258
+ pendingIn: AmountInfo;
259
+ pendingOut: AmountInfo;
260
+ held: AmountInfo;
252
261
  }
253
262
  interface AccountBalance {
254
263
  walletId: string;
@@ -532,9 +541,8 @@ interface CustomerPartyInfo {
532
541
  }
533
542
  interface Customer {
534
543
  id: string;
535
- type: 'party' | 'delegationInvitation';
544
+ type: 'party';
536
545
  party?: CustomerPartyInfo;
537
- email?: string;
538
546
  status: string;
539
547
  permissions: string[];
540
548
  createdAt: string;
@@ -542,6 +550,14 @@ interface Customer {
542
550
  walletAvailableDollars?: string;
543
551
  walletAccess: 'granted' | 'denied' | 'noWallet';
544
552
  }
553
+ interface PendingInvitation {
554
+ id: string;
555
+ type: 'delegationInvitation';
556
+ email?: string;
557
+ status: string;
558
+ permissions: string[];
559
+ createdAt: string;
560
+ }
545
561
  interface CustomerListParams {
546
562
  limit?: number;
547
563
  cursor?: string;
@@ -557,6 +573,11 @@ interface CustomerListResponse {
557
573
  hasMore: boolean;
558
574
  nextCursor?: string | null;
559
575
  }
576
+ interface PendingInvitationListResponse {
577
+ items: PendingInvitation[];
578
+ hasMore: boolean;
579
+ nextCursor?: string | null;
580
+ }
560
581
 
561
582
  /**
562
583
  * Customers resource.
@@ -564,12 +585,16 @@ interface CustomerListResponse {
564
585
 
565
586
  declare class CustomersResource extends BaseResource {
566
587
  /**
567
- * List customers who have delegated access to the partner.
588
+ * List active customers who have delegated access to the partner.
568
589
  *
569
- * @param params - Pagination parameters
570
- * @returns CustomerListResponse with items, hasMore, nextCursor
590
+ * Returns only accepted delegations. Use {@link listInvitations} for pending
591
+ * invitations that have not yet been accepted.
571
592
  */
572
593
  list(params?: CustomerListParams): Promise<CustomerListResponse>;
594
+ /**
595
+ * List pending customer invitations you've sent that have not yet been accepted.
596
+ */
597
+ listInvitations(params?: CustomerListParams): Promise<PendingInvitationListResponse>;
573
598
  }
574
599
 
575
600
  /**
@@ -593,7 +618,7 @@ interface NaturalClientOptions extends HTTPClientOptions {
593
618
  * amount: 5000,
594
619
  * customerPartyId: 'pty_xxx',
595
620
  * recipient: 'alice@example.com',
596
- * memo: 'For consulting',
621
+ * description: 'For consulting',
597
622
  * idempotencyKey: 'unique-key-for-this-payment',
598
623
  * });
599
624
  *
@@ -637,6 +662,29 @@ type ToolCallId = string & {
637
662
  readonly __brand: 'ToolCallId';
638
663
  };
639
664
 
665
+ /**
666
+ * Natural's canonical tool-name vocabulary.
667
+ *
668
+ * These are the names Natural recognizes on the `X-Tool-Call` header and
669
+ * displays in admin audit views. The `runWithToolCall` helper accepts only
670
+ * these names, so callers typing a custom label get a TypeScript error at the
671
+ * call site — the SDK is the single source of truth.
672
+ *
673
+ * When Natural adds or renames a tool, update this constant in the same
674
+ * change. Callers with their own caller-side metadata should use the
675
+ * `developer_context` field instead.
676
+ */
677
+ declare const NATURAL_TOOL_NAMES: {
678
+ readonly CREATE_PAYMENT: "create_payment";
679
+ readonly GET_PAYMENT_STATUS: "get_payment_status";
680
+ readonly GET_ACCOUNT_BALANCE: "get_account_balance";
681
+ readonly LIST_TRANSACTIONS: "list_transactions";
682
+ readonly LIST_AGENTS: "list_agents";
683
+ readonly LIST_CUSTOMERS: "list_customers";
684
+ readonly LIST_CUSTOMER_INVITATIONS: "list_customer_invitations";
685
+ };
686
+ type NaturalToolName = (typeof NATURAL_TOOL_NAMES)[keyof typeof NATURAL_TOOL_NAMES];
687
+
640
688
  /**
641
689
  * Tool call context for MCP server -> HTTP layer communication.
642
690
  *
@@ -662,11 +710,13 @@ declare function getToolCallHeader(): string | undefined;
662
710
  * pick up the tool call data and send it as the X-Tool-Call header.
663
711
  *
664
712
  * @param toolCallId - Unique ID for this invocation (tc_<uuid>).
665
- * @param name - Tool name (e.g. "create_payment").
713
+ * @param name - Canonical Natural tool name (see `NATURAL_TOOL_NAMES`).
714
+ * Custom caller-side labels are not accepted here; use the
715
+ * `developer_context` field for caller-side metadata.
666
716
  * @param args - Raw tool arguments.
667
717
  * @param fn - The function to execute within the context.
668
718
  */
669
- declare function runWithToolCall<T>(toolCallId: ToolCallId, name: string, args: Record<string, unknown>, fn: () => T): T;
719
+ declare function runWithToolCall<T>(toolCallId: ToolCallId, name: NaturalToolName, args: Record<string, unknown>, fn: () => T): T;
670
720
 
671
721
  /**
672
722
  * Structured logging for Natural Payments SDK.
@@ -876,4 +926,4 @@ declare function verifyWebhookSignature(body: string | Buffer | Uint8Array, head
876
926
  */
877
927
  declare const VERSION = "0.1.4";
878
928
 
879
- export { type AccountBalance, type Agent, type AgentConfig, type AgentConfigDict, type AgentCreateParams, type AgentCreateResponse, type AgentDelegation, type AgentDelegationListParams, type AgentDelegationListResponse, type AgentDeleteOptions, type AgentGetOptions, type AgentListParams, type AgentListResponse, type AgentStatus, type AgentUpdateParams, type AgentUpdateResponse, type AmountInfo, AuthenticationError, type BalanceBreakdown, type Customer, type CustomerListParams, type CustomerListResponse, type CustomerPartyInfo, type InstanceId, InsufficientFundsError, InvalidRequestError, type LogLevel, Logger, type ModelUsage, type ModelUsageDict, NaturalClient, type NaturalClientOptions, NaturalError, type PaymentCreateParams, PaymentError, RateLimitError, RecipientNotFoundError, ServerError, type ToolCallId, type TraceId, type Transaction, type TransactionGetParams, type TransactionListParams, type TransactionListResponse, TransactionTypeFilter, VERSION, type VerifyWebhookOptions, WebhookVerificationError, type WithdrawParams, type WithdrawResponse, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
929
+ export { type AccountBalance, type Agent, type AgentConfig, type AgentConfigDict, type AgentCreateParams, type AgentCreateResponse, type AgentDelegation, type AgentDelegationListParams, type AgentDelegationListResponse, type AgentDeleteOptions, type AgentGetOptions, type AgentListParams, type AgentListResponse, type AgentStatus, type AgentUpdateParams, type AgentUpdateResponse, type AmountInfo, AuthenticationError, type BalanceBreakdown, type Customer, type CustomerListParams, type CustomerListResponse, type CustomerPartyInfo, type InstanceId, InsufficientFundsError, InvalidRequestError, type LogLevel, Logger, type ModelUsage, type ModelUsageDict, NATURAL_TOOL_NAMES, NaturalClient, type NaturalClientOptions, NaturalError, type NaturalToolName, type PaymentCreateParams, PaymentError, type PendingInvitation, type PendingInvitationListResponse, RateLimitError, RecipientNotFoundError, ServerError, type ToolCallId, type TraceId, type Transaction, type TransactionGetParams, type TransactionListParams, type TransactionListResponse, TransactionTypeFilter, VERSION, type VerifyWebhookOptions, WebhookVerificationError, type WithdrawParams, type WithdrawResponse, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -145,11 +145,17 @@ interface PaymentCreateParams {
145
145
  agentId?: string;
146
146
  /** Payment amount in minor units (cents). 5000 = $50.00. */
147
147
  amount: number;
148
- customerPartyId: string;
148
+ /** Sender party ID (pty_xxx). Omit to send from your own wallet; provide for delegated payments on behalf of a customer. */
149
+ customerPartyId?: string;
149
150
  /** Recipient email, phone number, or party ID (pty_xxx). */
150
151
  recipient: string;
151
- /** Payment memo/description. */
152
- memo: string;
152
+ /**
153
+ * Human-readable description of the payment's purpose. Required for all SDK
154
+ * callers. For agent-initiated payments, write a rich rationale (≥20 chars
155
+ * recommended) so the user can confidently approve and the audit trail is
156
+ * legible.
157
+ */
158
+ description: string;
153
159
  /** Currency code (default: USD). */
154
160
  currency?: string;
155
161
  idempotencyKey: string;
@@ -175,8 +181,9 @@ interface Transaction {
175
181
  amount: number;
176
182
  currency: string;
177
183
  status: string;
184
+ escalationId?: string;
185
+ disputeId?: string;
178
186
  description?: string;
179
- memo?: string;
180
187
  createdAt: string;
181
188
  updatedAt?: string;
182
189
  isDelegated: boolean;
@@ -184,6 +191,8 @@ interface Transaction {
184
191
  customerAgentId?: string;
185
192
  senderName?: string;
186
193
  recipientName?: string;
194
+ initiatorName?: string;
195
+ initiatorIsAgent?: boolean;
187
196
  transactionType: string;
188
197
  category: string;
189
198
  direction: string;
@@ -191,7 +200,7 @@ interface Transaction {
191
200
  destinationPartyId?: string;
192
201
  sourceWalletId?: string;
193
202
  destinationWalletId?: string;
194
- /** Internal instance ID (ins_xxx) assigned by server. */
203
+ /** Present on payment creation responses when agent instance metadata was supplied. */
195
204
  instanceId?: string;
196
205
  /** Claim link URL for unclaimed payments. */
197
206
  claimLink?: string;
@@ -246,9 +255,9 @@ interface AmountInfo {
246
255
  interface BalanceBreakdown {
247
256
  operatingFunded: AmountInfo;
248
257
  operatingAdvanced: AmountInfo;
249
- escrowFundedSettled: AmountInfo;
250
- escrowAdvanced: AmountInfo;
251
- holdsOutbound: AmountInfo;
258
+ pendingIn: AmountInfo;
259
+ pendingOut: AmountInfo;
260
+ held: AmountInfo;
252
261
  }
253
262
  interface AccountBalance {
254
263
  walletId: string;
@@ -532,9 +541,8 @@ interface CustomerPartyInfo {
532
541
  }
533
542
  interface Customer {
534
543
  id: string;
535
- type: 'party' | 'delegationInvitation';
544
+ type: 'party';
536
545
  party?: CustomerPartyInfo;
537
- email?: string;
538
546
  status: string;
539
547
  permissions: string[];
540
548
  createdAt: string;
@@ -542,6 +550,14 @@ interface Customer {
542
550
  walletAvailableDollars?: string;
543
551
  walletAccess: 'granted' | 'denied' | 'noWallet';
544
552
  }
553
+ interface PendingInvitation {
554
+ id: string;
555
+ type: 'delegationInvitation';
556
+ email?: string;
557
+ status: string;
558
+ permissions: string[];
559
+ createdAt: string;
560
+ }
545
561
  interface CustomerListParams {
546
562
  limit?: number;
547
563
  cursor?: string;
@@ -557,6 +573,11 @@ interface CustomerListResponse {
557
573
  hasMore: boolean;
558
574
  nextCursor?: string | null;
559
575
  }
576
+ interface PendingInvitationListResponse {
577
+ items: PendingInvitation[];
578
+ hasMore: boolean;
579
+ nextCursor?: string | null;
580
+ }
560
581
 
561
582
  /**
562
583
  * Customers resource.
@@ -564,12 +585,16 @@ interface CustomerListResponse {
564
585
 
565
586
  declare class CustomersResource extends BaseResource {
566
587
  /**
567
- * List customers who have delegated access to the partner.
588
+ * List active customers who have delegated access to the partner.
568
589
  *
569
- * @param params - Pagination parameters
570
- * @returns CustomerListResponse with items, hasMore, nextCursor
590
+ * Returns only accepted delegations. Use {@link listInvitations} for pending
591
+ * invitations that have not yet been accepted.
571
592
  */
572
593
  list(params?: CustomerListParams): Promise<CustomerListResponse>;
594
+ /**
595
+ * List pending customer invitations you've sent that have not yet been accepted.
596
+ */
597
+ listInvitations(params?: CustomerListParams): Promise<PendingInvitationListResponse>;
573
598
  }
574
599
 
575
600
  /**
@@ -593,7 +618,7 @@ interface NaturalClientOptions extends HTTPClientOptions {
593
618
  * amount: 5000,
594
619
  * customerPartyId: 'pty_xxx',
595
620
  * recipient: 'alice@example.com',
596
- * memo: 'For consulting',
621
+ * description: 'For consulting',
597
622
  * idempotencyKey: 'unique-key-for-this-payment',
598
623
  * });
599
624
  *
@@ -637,6 +662,29 @@ type ToolCallId = string & {
637
662
  readonly __brand: 'ToolCallId';
638
663
  };
639
664
 
665
+ /**
666
+ * Natural's canonical tool-name vocabulary.
667
+ *
668
+ * These are the names Natural recognizes on the `X-Tool-Call` header and
669
+ * displays in admin audit views. The `runWithToolCall` helper accepts only
670
+ * these names, so callers typing a custom label get a TypeScript error at the
671
+ * call site — the SDK is the single source of truth.
672
+ *
673
+ * When Natural adds or renames a tool, update this constant in the same
674
+ * change. Callers with their own caller-side metadata should use the
675
+ * `developer_context` field instead.
676
+ */
677
+ declare const NATURAL_TOOL_NAMES: {
678
+ readonly CREATE_PAYMENT: "create_payment";
679
+ readonly GET_PAYMENT_STATUS: "get_payment_status";
680
+ readonly GET_ACCOUNT_BALANCE: "get_account_balance";
681
+ readonly LIST_TRANSACTIONS: "list_transactions";
682
+ readonly LIST_AGENTS: "list_agents";
683
+ readonly LIST_CUSTOMERS: "list_customers";
684
+ readonly LIST_CUSTOMER_INVITATIONS: "list_customer_invitations";
685
+ };
686
+ type NaturalToolName = (typeof NATURAL_TOOL_NAMES)[keyof typeof NATURAL_TOOL_NAMES];
687
+
640
688
  /**
641
689
  * Tool call context for MCP server -> HTTP layer communication.
642
690
  *
@@ -662,11 +710,13 @@ declare function getToolCallHeader(): string | undefined;
662
710
  * pick up the tool call data and send it as the X-Tool-Call header.
663
711
  *
664
712
  * @param toolCallId - Unique ID for this invocation (tc_<uuid>).
665
- * @param name - Tool name (e.g. "create_payment").
713
+ * @param name - Canonical Natural tool name (see `NATURAL_TOOL_NAMES`).
714
+ * Custom caller-side labels are not accepted here; use the
715
+ * `developer_context` field for caller-side metadata.
666
716
  * @param args - Raw tool arguments.
667
717
  * @param fn - The function to execute within the context.
668
718
  */
669
- declare function runWithToolCall<T>(toolCallId: ToolCallId, name: string, args: Record<string, unknown>, fn: () => T): T;
719
+ declare function runWithToolCall<T>(toolCallId: ToolCallId, name: NaturalToolName, args: Record<string, unknown>, fn: () => T): T;
670
720
 
671
721
  /**
672
722
  * Structured logging for Natural Payments SDK.
@@ -876,4 +926,4 @@ declare function verifyWebhookSignature(body: string | Buffer | Uint8Array, head
876
926
  */
877
927
  declare const VERSION = "0.1.4";
878
928
 
879
- export { type AccountBalance, type Agent, type AgentConfig, type AgentConfigDict, type AgentCreateParams, type AgentCreateResponse, type AgentDelegation, type AgentDelegationListParams, type AgentDelegationListResponse, type AgentDeleteOptions, type AgentGetOptions, type AgentListParams, type AgentListResponse, type AgentStatus, type AgentUpdateParams, type AgentUpdateResponse, type AmountInfo, AuthenticationError, type BalanceBreakdown, type Customer, type CustomerListParams, type CustomerListResponse, type CustomerPartyInfo, type InstanceId, InsufficientFundsError, InvalidRequestError, type LogLevel, Logger, type ModelUsage, type ModelUsageDict, NaturalClient, type NaturalClientOptions, NaturalError, type PaymentCreateParams, PaymentError, RateLimitError, RecipientNotFoundError, ServerError, type ToolCallId, type TraceId, type Transaction, type TransactionGetParams, type TransactionListParams, type TransactionListResponse, TransactionTypeFilter, VERSION, type VerifyWebhookOptions, WebhookVerificationError, type WithdrawParams, type WithdrawResponse, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
929
+ export { type AccountBalance, type Agent, type AgentConfig, type AgentConfigDict, type AgentCreateParams, type AgentCreateResponse, type AgentDelegation, type AgentDelegationListParams, type AgentDelegationListResponse, type AgentDeleteOptions, type AgentGetOptions, type AgentListParams, type AgentListResponse, type AgentStatus, type AgentUpdateParams, type AgentUpdateResponse, type AmountInfo, AuthenticationError, type BalanceBreakdown, type Customer, type CustomerListParams, type CustomerListResponse, type CustomerPartyInfo, type InstanceId, InsufficientFundsError, InvalidRequestError, type LogLevel, Logger, type ModelUsage, type ModelUsageDict, NATURAL_TOOL_NAMES, NaturalClient, type NaturalClientOptions, NaturalError, type NaturalToolName, type PaymentCreateParams, PaymentError, type PendingInvitation, type PendingInvitationListResponse, RateLimitError, RecipientNotFoundError, ServerError, type ToolCallId, type TraceId, type Transaction, type TransactionGetParams, type TransactionListParams, type TransactionListResponse, TransactionTypeFilter, VERSION, type VerifyWebhookOptions, WebhookVerificationError, type WithdrawParams, type WithdrawResponse, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -877,8 +877,9 @@ function unwrapTransactionResource(resource) {
877
877
  amount: Number(attributes.amount),
878
878
  currency: String(attributes.currency),
879
879
  status: String(attributes.status),
880
+ escalationId: attributes.escalationId != null ? String(attributes.escalationId) : void 0,
881
+ disputeId: attributes.disputeId != null ? String(attributes.disputeId) : void 0,
880
882
  description: attributes.description != null ? String(attributes.description) : void 0,
881
- memo: attributes.memo != null ? String(attributes.memo) : void 0,
882
883
  createdAt: String(attributes.createdAt),
883
884
  updatedAt: attributes.updatedAt != null ? String(attributes.updatedAt) : void 0,
884
885
  isDelegated: Boolean(attributes.isDelegated),
@@ -886,6 +887,8 @@ function unwrapTransactionResource(resource) {
886
887
  customerAgentId: attributes.customerAgentId != null ? String(attributes.customerAgentId) : void 0,
887
888
  senderName: attributes.senderName != null ? String(attributes.senderName) : void 0,
888
889
  recipientName: attributes.recipientName != null ? String(attributes.recipientName) : void 0,
890
+ initiatorName: attributes.initiatorName != null ? String(attributes.initiatorName) : void 0,
891
+ initiatorIsAgent: attributes.initiatorIsAgent != null ? Boolean(attributes.initiatorIsAgent) : void 0,
889
892
  transactionType: String(attributes.transactionType),
890
893
  category: String(attributes.category),
891
894
  direction: String(attributes.direction),
@@ -1000,8 +1003,6 @@ function unwrapPaymentResponse(response) {
1000
1003
  transactionType: String(attributes.transactionType ?? "payment"),
1001
1004
  category: String(attributes.category ?? "sent"),
1002
1005
  direction: String(attributes.direction ?? "OUTBOUND"),
1003
- // Mirror description into memo for payment convenience.
1004
- memo: base.description,
1005
1006
  // Payments use customerParty/counterparty relationship keys,
1006
1007
  // falling back to the generic sourceParty/destinationParty.
1007
1008
  sourcePartyId: relationships?.customerParty?.data?.id ?? base.sourcePartyId,
@@ -1025,9 +1026,9 @@ var PaymentsResource = class extends BaseResource {
1025
1026
  amount: params.amount,
1026
1027
  currency: params.currency ?? "USD",
1027
1028
  counterparty: recipient,
1028
- customerPartyId: params.customerPartyId
1029
+ description: params.description,
1030
+ ...params.customerPartyId != null ? { customerPartyId: params.customerPartyId } : {}
1029
1031
  };
1030
- attributes["description"] = params.memo;
1031
1032
  const body = { data: { attributes } };
1032
1033
  const headers = {
1033
1034
  "Idempotency-Key": params.idempotencyKey
@@ -1076,9 +1077,9 @@ function unwrapBalance(response) {
1076
1077
  const breakdown = {
1077
1078
  operatingFunded: toAmountInfo(rawBreakdown?.operatingFunded),
1078
1079
  operatingAdvanced: toAmountInfo(rawBreakdown?.operatingAdvanced),
1079
- escrowFundedSettled: toAmountInfo(rawBreakdown?.escrowFundedSettled),
1080
- escrowAdvanced: toAmountInfo(rawBreakdown?.escrowAdvanced),
1081
- holdsOutbound: toAmountInfo(rawBreakdown?.holdsOutbound)
1080
+ pendingIn: toAmountInfo(rawBreakdown?.pendingIn),
1081
+ pendingOut: toAmountInfo(rawBreakdown?.pendingOut),
1082
+ held: toAmountInfo(rawBreakdown?.held)
1082
1083
  };
1083
1084
  return {
1084
1085
  walletId: id,
@@ -1456,18 +1457,14 @@ var DelegationsResource = class extends BaseResource {
1456
1457
  };
1457
1458
 
1458
1459
  // src/resources/customers.ts
1459
- var VALID_CUSTOMER_TYPES = /* @__PURE__ */ new Set(["party", "delegationInvitation"]);
1460
1460
  var VALID_WALLET_ACCESS = /* @__PURE__ */ new Set(["granted", "denied", "noWallet"]);
1461
- function isCustomerType(value) {
1462
- return VALID_CUSTOMER_TYPES.has(value);
1463
- }
1464
1461
  function isWalletAccess(value) {
1465
1462
  return typeof value === "string" && VALID_WALLET_ACCESS.has(value);
1466
1463
  }
1467
1464
  function unwrapCustomerResource(resource) {
1468
- if (!isCustomerType(resource.type) || !resource.attributes) {
1465
+ if (resource.type !== "party" || !resource.attributes) {
1469
1466
  throw new NaturalError(
1470
- `Unexpected resource format: expected type "party" or "delegationInvitation", got "${resource.type}"`
1467
+ `Unexpected resource format: expected type "party", got "${resource.type}"`
1471
1468
  );
1472
1469
  }
1473
1470
  const { id, attributes } = resource;
@@ -1478,9 +1475,8 @@ function unwrapCustomerResource(resource) {
1478
1475
  } : void 0;
1479
1476
  return {
1480
1477
  id,
1481
- type: resource.type,
1478
+ type: "party",
1482
1479
  party,
1483
- email: typeof attributes.email === "string" ? attributes.email : void 0,
1484
1480
  status: typeof attributes.status === "string" ? attributes.status : "",
1485
1481
  permissions: Array.isArray(attributes.permissions) ? attributes.permissions : [],
1486
1482
  createdAt: typeof attributes.createdAt === "string" ? attributes.createdAt : "",
@@ -1489,6 +1485,22 @@ function unwrapCustomerResource(resource) {
1489
1485
  walletAccess: isWalletAccess(attributes.walletAccess) ? attributes.walletAccess : "denied"
1490
1486
  };
1491
1487
  }
1488
+ function unwrapPendingInvitationResource(resource) {
1489
+ if (resource.type !== "delegationInvitation" || !resource.attributes) {
1490
+ throw new NaturalError(
1491
+ `Unexpected resource format: expected type "delegationInvitation", got "${resource.type}"`
1492
+ );
1493
+ }
1494
+ const { id, attributes } = resource;
1495
+ return {
1496
+ id,
1497
+ type: "delegationInvitation",
1498
+ email: typeof attributes.email === "string" ? attributes.email : void 0,
1499
+ status: typeof attributes.status === "string" ? attributes.status : "",
1500
+ permissions: Array.isArray(attributes.permissions) ? attributes.permissions : [],
1501
+ createdAt: typeof attributes.createdAt === "string" ? attributes.createdAt : ""
1502
+ };
1503
+ }
1492
1504
  function unwrapCustomerList(response) {
1493
1505
  if (!response?.data || !Array.isArray(response.data)) {
1494
1506
  throw new NaturalError(
@@ -1502,34 +1514,59 @@ function unwrapCustomerList(response) {
1502
1514
  nextCursor: pagination.nextCursor ?? null
1503
1515
  };
1504
1516
  }
1517
+ function unwrapPendingInvitationList(response) {
1518
+ if (!response?.data || !Array.isArray(response.data)) {
1519
+ throw new NaturalError(
1520
+ 'Unexpected response format: missing "data" array in pending invitation list response'
1521
+ );
1522
+ }
1523
+ const pagination = response.meta?.pagination ?? {};
1524
+ return {
1525
+ items: response.data.map(unwrapPendingInvitationResource),
1526
+ hasMore: pagination.hasMore ?? false,
1527
+ nextCursor: pagination.nextCursor ?? null
1528
+ };
1529
+ }
1530
+ function buildRequest(params) {
1531
+ const headers = {};
1532
+ if (params?.agentId) {
1533
+ headers["X-Agent-ID"] = params.agentId;
1534
+ }
1535
+ if (params?.instanceId) {
1536
+ headers["X-Instance-ID"] = params.instanceId;
1537
+ }
1538
+ if (params?.traceId) {
1539
+ headers["X-Trace-ID"] = sanitizeHeaderValue(params.traceId);
1540
+ }
1541
+ const queryParams = {
1542
+ limit: params?.limit,
1543
+ cursor: params?.cursor
1544
+ };
1545
+ return {
1546
+ params: queryParams,
1547
+ headers: Object.keys(headers).length > 0 ? headers : void 0
1548
+ };
1549
+ }
1505
1550
  var CustomersResource = class extends BaseResource {
1506
1551
  /**
1507
- * List customers who have delegated access to the partner.
1552
+ * List active customers who have delegated access to the partner.
1508
1553
  *
1509
- * @param params - Pagination parameters
1510
- * @returns CustomerListResponse with items, hasMore, nextCursor
1554
+ * Returns only accepted delegations. Use {@link listInvitations} for pending
1555
+ * invitations that have not yet been accepted.
1511
1556
  */
1512
1557
  async list(params) {
1513
- const headers = {};
1514
- if (params?.agentId) {
1515
- headers["X-Agent-ID"] = params.agentId;
1516
- }
1517
- if (params?.instanceId) {
1518
- headers["X-Instance-ID"] = params.instanceId;
1519
- }
1520
- if (params?.traceId) {
1521
- headers["X-Trace-ID"] = sanitizeHeaderValue(params.traceId);
1522
- }
1523
- const queryParams = {
1524
- limit: params?.limit,
1525
- cursor: params?.cursor
1526
- };
1527
- const response = await this.http.get("/customers", {
1528
- params: queryParams,
1529
- headers: Object.keys(headers).length > 0 ? headers : void 0
1530
- });
1558
+ const request = buildRequest(params);
1559
+ const response = await this.http.get("/customers", request);
1531
1560
  return unwrapCustomerList(response);
1532
1561
  }
1562
+ /**
1563
+ * List pending customer invitations you've sent that have not yet been accepted.
1564
+ */
1565
+ async listInvitations(params) {
1566
+ const request = buildRequest(params);
1567
+ const response = await this.http.get("/customers/invitations", request);
1568
+ return unwrapPendingInvitationList(response);
1569
+ }
1533
1570
  };
1534
1571
 
1535
1572
  // src/client.ts
@@ -1565,6 +1602,17 @@ var NaturalClient = class {
1565
1602
  this.customers = new CustomersResource(this.http);
1566
1603
  }
1567
1604
  };
1605
+
1606
+ // src/tool-names.ts
1607
+ var NATURAL_TOOL_NAMES = {
1608
+ CREATE_PAYMENT: "create_payment",
1609
+ GET_PAYMENT_STATUS: "get_payment_status",
1610
+ GET_ACCOUNT_BALANCE: "get_account_balance",
1611
+ LIST_TRANSACTIONS: "list_transactions",
1612
+ LIST_AGENTS: "list_agents",
1613
+ LIST_CUSTOMERS: "list_customers",
1614
+ LIST_CUSTOMER_INVITATIONS: "list_customer_invitations"
1615
+ };
1568
1616
  var WHSEC_PREFIX = "whsec_";
1569
1617
  var DEFAULT_TOLERANCE_SECONDS = 300;
1570
1618
  function getHeader(headers, name) {
@@ -1652,6 +1700,6 @@ var TransactionTypeFilter = /* @__PURE__ */ ((TransactionTypeFilter2) => {
1652
1700
  return TransactionTypeFilter2;
1653
1701
  })(TransactionTypeFilter || {});
1654
1702
 
1655
- export { AuthenticationError, InsufficientFundsError, InvalidRequestError, NaturalClient, NaturalError, PaymentError, RateLimitError, RecipientNotFoundError, ServerError, TransactionTypeFilter, VERSION, WebhookVerificationError, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
1703
+ export { AuthenticationError, InsufficientFundsError, InvalidRequestError, NATURAL_TOOL_NAMES, NaturalClient, NaturalError, PaymentError, RateLimitError, RecipientNotFoundError, ServerError, TransactionTypeFilter, VERSION, WebhookVerificationError, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
1656
1704
  //# sourceMappingURL=index.js.map
1657
1705
  //# sourceMappingURL=index.js.map