@owney/sdk 0.7.16 → 0.7.17-beta.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.d.cts CHANGED
@@ -65,6 +65,18 @@ type AgentSupportedAssets = {
65
65
  readonly chain?: string;
66
66
  readonly assets: readonly AgentSupportedAsset[];
67
67
  };
68
+ type AvailableAgent = {
69
+ id: AgentId;
70
+ isEnabled: boolean;
71
+ supportedChainIds: readonly number[];
72
+ supportedAssets: readonly AgentSupportedAssets[];
73
+ };
74
+ type AvailableAgentsOptions = {
75
+ chainId?: number;
76
+ asset?: Asset;
77
+ /** Disabled agents are omitted by default because they cannot accept funds. */
78
+ includeDisabled?: boolean;
79
+ };
68
80
  type DailyApyDays = "7D" | "14D" | "30D";
69
81
  type HistoryFilters = {
70
82
  fromDate?: string;
@@ -174,11 +186,16 @@ interface OwneyMultiDepositResult {
174
186
  interface AgentWithdrawResult {
175
187
  txHash?: string;
176
188
  type: "full" | "partial";
189
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
177
190
  amount: string;
178
191
  }
179
192
  interface OwneyWithdrawResult {
180
193
  agentResult: Record<AgentId, AgentWithdrawResult>;
181
- totalWithdrawn: string;
194
+ /**
195
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
196
+ * amount is not yet known. An accepted request is not proof of settlement.
197
+ */
198
+ totalWithdrawn: string | null;
182
199
  }
183
200
  interface OwneyToken {
184
201
  chain: OwneySupportedChains;
@@ -242,6 +259,10 @@ interface OwneyBalances {
242
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
243
260
  totalBalanceAsset: string;
244
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
263
+ agentErrors?: Record<AgentId, string>;
264
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
+ agentRetryAt?: Record<AgentId, number>;
245
266
  }
246
267
  interface AgentEarnings {
247
268
  smartWallet: `0x${string}`;
@@ -445,6 +466,9 @@ declare class OwneySDK {
445
466
  private cachedWethSponsoredCallback;
446
467
  private paymasterServiceUrl?;
447
468
  private cachedSponsoredCallsCallbacks;
469
+ private readonly agentReads;
470
+ private readonly activationChecks;
471
+ private readAgent;
448
472
  private initializingAgentsPromise;
449
473
  constructor(config: OwneySDKConfig);
450
474
  /**
@@ -511,6 +535,11 @@ declare class OwneySDK {
511
535
  private applyOrgPolicyTo;
512
536
  private ensureAgentsInitialized;
513
537
  private createAgent;
538
+ /**
539
+ * Discover the agents actually returned by routing for this organization.
540
+ * Consumers should use this instead of hardcoding a global agent roster.
541
+ */
542
+ getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
514
543
  /**
515
544
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
516
545
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -542,7 +571,7 @@ declare class OwneySDK {
542
571
  */
543
572
  private activateAgentsInTurn;
544
573
  /**
545
- * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
574
+ * Deposit into a specific agent, or distribute across all eligible agents.
546
575
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
547
576
  * @param options - Deposit parameters
548
577
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
@@ -550,7 +579,8 @@ declare class OwneySDK {
550
579
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
551
580
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
552
581
  * split amount and smart wallet address — expect multiple wallet prompts.
553
- * @param options.agentId - Optional. Target agent. Omit to split equally across all agents.
582
+ * @param options.agentId - Optional explicit target. Otherwise split equally,
583
+ * or fund remaining agents when a recovery deposit cannot meet every minimum.
554
584
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
555
585
  */
556
586
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
@@ -692,7 +722,7 @@ declare class OwneySDK {
692
722
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
693
723
  }
694
724
 
695
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
725
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
696
726
  declare class OwneyError extends Error {
697
727
  readonly code: OwneyErrorCode;
698
728
  readonly details?: Record<string, unknown>;
@@ -758,4 +788,4 @@ type OwneySIWXConfig = {
758
788
  */
759
789
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
760
790
 
761
- export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
791
+ export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
package/dist/index.d.ts CHANGED
@@ -65,6 +65,18 @@ type AgentSupportedAssets = {
65
65
  readonly chain?: string;
66
66
  readonly assets: readonly AgentSupportedAsset[];
67
67
  };
68
+ type AvailableAgent = {
69
+ id: AgentId;
70
+ isEnabled: boolean;
71
+ supportedChainIds: readonly number[];
72
+ supportedAssets: readonly AgentSupportedAssets[];
73
+ };
74
+ type AvailableAgentsOptions = {
75
+ chainId?: number;
76
+ asset?: Asset;
77
+ /** Disabled agents are omitted by default because they cannot accept funds. */
78
+ includeDisabled?: boolean;
79
+ };
68
80
  type DailyApyDays = "7D" | "14D" | "30D";
69
81
  type HistoryFilters = {
70
82
  fromDate?: string;
@@ -174,11 +186,16 @@ interface OwneyMultiDepositResult {
174
186
  interface AgentWithdrawResult {
175
187
  txHash?: string;
176
188
  type: "full" | "partial";
189
+ /** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
177
190
  amount: string;
178
191
  }
179
192
  interface OwneyWithdrawResult {
180
193
  agentResult: Record<AgentId, AgentWithdrawResult>;
181
- totalWithdrawn: string;
194
+ /**
195
+ * Sum of reported smallest-unit amounts; null when a full withdrawal's
196
+ * amount is not yet known. An accepted request is not proof of settlement.
197
+ */
198
+ totalWithdrawn: string | null;
182
199
  }
183
200
  interface OwneyToken {
184
201
  chain: OwneySupportedChains;
@@ -242,6 +259,10 @@ interface OwneyBalances {
242
259
  /** Asset that `totalBalance` is denominated in. Currently always `"usdc"`. */
243
260
  totalBalanceAsset: string;
244
261
  agentBalances: Record<AgentId, AgentBalance>;
262
+ /** Omitted agents failed to load; they must not be interpreted as zero. */
263
+ agentErrors?: Record<AgentId, string>;
264
+ /** Absolute provider cooldown deadlines (Unix milliseconds). */
265
+ agentRetryAt?: Record<AgentId, number>;
245
266
  }
246
267
  interface AgentEarnings {
247
268
  smartWallet: `0x${string}`;
@@ -445,6 +466,9 @@ declare class OwneySDK {
445
466
  private cachedWethSponsoredCallback;
446
467
  private paymasterServiceUrl?;
447
468
  private cachedSponsoredCallsCallbacks;
469
+ private readonly agentReads;
470
+ private readonly activationChecks;
471
+ private readAgent;
448
472
  private initializingAgentsPromise;
449
473
  constructor(config: OwneySDKConfig);
450
474
  /**
@@ -511,6 +535,11 @@ declare class OwneySDK {
511
535
  private applyOrgPolicyTo;
512
536
  private ensureAgentsInitialized;
513
537
  private createAgent;
538
+ /**
539
+ * Discover the agents actually returned by routing for this organization.
540
+ * Consumers should use this instead of hardcoding a global agent roster.
541
+ */
542
+ getAvailableAgents(options?: AvailableAgentsOptions): Promise<AvailableAgent[]>;
514
543
  /**
515
544
  * Activate the user's smart wallet for the specified agents, or all chain-compatible agents if omitted.
516
545
  * Deploys the Safe contract and creates a session key if not already set up.
@@ -542,7 +571,7 @@ declare class OwneySDK {
542
571
  */
543
572
  private activateAgentsInTurn;
544
573
  /**
545
- * Deposit funds into a specific agent, or split equally across all agents if agentId is omitted.
574
+ * Deposit into a specific agent, or distribute across all eligible agents.
546
575
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
547
576
  * @param options - Deposit parameters
548
577
  * @param options.amount - Amount to deposit in smallest unit (e.g. "100000000" for 100 USDC)
@@ -550,7 +579,8 @@ declare class OwneySDK {
550
579
  * @param options.depositCallback - Callback that performs the token transfer and returns a tx hash.
551
580
  * When agentId is omitted, this callback is invoked once per eligible agent with that agent's
552
581
  * split amount and smart wallet address — expect multiple wallet prompts.
553
- * @param options.agentId - Optional. Target agent. Omit to split equally across all agents.
582
+ * @param options.agentId - Optional explicit target. Otherwise split equally,
583
+ * or fund remaining agents when a recovery deposit cannot meet every minimum.
554
584
  * @returns {OwneyDepositResult} for a single agent, or {OwneyMultiDepositResult} with per-agent results
555
585
  */
556
586
  deposit(options: DepositOptions): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
@@ -692,7 +722,7 @@ declare class OwneySDK {
692
722
  getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
693
723
  }
694
724
 
695
- type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
725
+ type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
696
726
  declare class OwneyError extends Error {
697
727
  readonly code: OwneyErrorCode;
698
728
  readonly details?: Record<string, unknown>;
@@ -758,4 +788,4 @@ type OwneySIWXConfig = {
758
788
  */
759
789
  declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
760
790
 
761
- export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
791
+ export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };