@owney/sdk 0.7.28 → 0.7.29-beta.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.cjs CHANGED
@@ -1529,12 +1529,16 @@ var ZyfaiAgent = class _ZyfaiAgent {
1529
1529
  }
1530
1530
  // --- IAgent: Account lifecycle ---
1531
1531
  async activateAgent(state, chainId) {
1532
+ const startedAt = Date.now();
1532
1533
  try {
1533
1534
  debugLog("zyfai:activation", "starting", {
1534
1535
  walletAddress: state.walletAddress,
1535
1536
  chainId
1536
1537
  });
1537
1538
  await this.connectAuth(state, chainId);
1539
+ debugLog("zyfai:activation", "signed in", {
1540
+ ms: Date.now() - startedAt
1541
+ });
1538
1542
  const validChainId = isValidChainId(chainId);
1539
1543
  await Promise.all([
1540
1544
  this.ensureProtocolsSynced(validChainId, "USDC"),
@@ -1545,7 +1549,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
1545
1549
  // validator, so pool-wallet users see no prompt. Non-fatal.
1546
1550
  this.ensureSessionKeyIfDeployed(validChainId)
1547
1551
  ]);
1548
- debugLog("zyfai:activation", "completed", { chainId: validChainId });
1552
+ debugLog("zyfai:activation", "completed", {
1553
+ chainId: validChainId,
1554
+ ms: Date.now() - startedAt
1555
+ });
1549
1556
  } catch (error) {
1550
1557
  throw error;
1551
1558
  }
@@ -2231,8 +2238,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
2231
2238
  }
2232
2239
  // --- IAgent: Portfolio reads ---
2233
2240
  async getBalances(state, chainId) {
2241
+ const startedAt = Date.now();
2234
2242
  const { smartWallet, chainId: validChainId } = await this.resolveSmartWallet(state, chainId);
2235
2243
  const raw = await this.sdk.getPortfolio(this.getAddress());
2244
+ debugLog("zyfai:balances", "read", { ms: Date.now() - startedAt });
2236
2245
  return mapBalances(raw, validChainId, smartWallet);
2237
2246
  }
2238
2247
  earningsKey(state, chainId, smartWallet) {
@@ -5034,8 +5043,9 @@ var OwneySDK = class {
5034
5043
  * that support the given chainId (incompatible agents are silently skipped).
5035
5044
  * If provided, ALL specified agents must support the chainId or the call
5036
5045
  * throws before activating any agent.
5046
+ * @param options - Optional. `onAgentsSelected` fires once reads can start.
5037
5047
  */
5038
- async activateAgent(chainId, agentId) {
5048
+ async activateAgent(chainId, agentId, options = {}) {
5039
5049
  const state = this.requireState();
5040
5050
  await this.ensureAgentsInitialized();
5041
5051
  if (agentId !== void 0) {
@@ -5071,6 +5081,7 @@ var OwneySDK = class {
5071
5081
  this.activeAgents.add(id);
5072
5082
  }
5073
5083
  state.chainId = chainId;
5084
+ options.onAgentsSelected?.();
5074
5085
  await this.activateAgentsInTurn(agents, state, chainId);
5075
5086
  return;
5076
5087
  }
@@ -5089,6 +5100,7 @@ var OwneySDK = class {
5089
5100
  this.activeAgents.add(agent.id);
5090
5101
  }
5091
5102
  state.chainId = chainId;
5103
+ options.onAgentsSelected?.();
5092
5104
  const enabledCompatible = compatible.filter(
5093
5105
  (agent) => !this.isAgentDisabled(agent.id)
5094
5106
  );
package/dist/index.d.cts CHANGED
@@ -326,6 +326,15 @@ type AvailableAgent = {
326
326
  supportedChainIds: readonly number[];
327
327
  supportedAssets: readonly AgentSupportedAssets[];
328
328
  };
329
+ type ActivateAgentOptions = {
330
+ /**
331
+ * Called once the chain and agents are registered, before any agent signs in
332
+ * or runs its setup. From then on reads such as `getBalances` are safe to
333
+ * start: each agent's reads wait on that agent's own sign-in, so they share
334
+ * the activation's one wallet prompt instead of waiting for all of setup.
335
+ */
336
+ onAgentsSelected?: () => void;
337
+ };
329
338
  type AvailableAgentsOptions = {
330
339
  chainId?: number;
331
340
  asset?: Asset;
@@ -1260,8 +1269,9 @@ declare class OwneySDK {
1260
1269
  * that support the given chainId (incompatible agents are silently skipped).
1261
1270
  * If provided, ALL specified agents must support the chainId or the call
1262
1271
  * throws before activating any agent.
1272
+ * @param options - Optional. `onAgentsSelected` fires once reads can start.
1263
1273
  */
1264
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
1274
+ activateAgent(chainId: number, agentId?: AgentId[], options?: ActivateAgentOptions): Promise<void>;
1265
1275
  /**
1266
1276
  * Activate agents ONE AT A TIME, each followed by its org policy.
1267
1277
  *
@@ -1979,4 +1989,4 @@ type StoredOrder = {
1979
1989
  */
1980
1990
  declare function listOrders(now?: number): StoredOrder[];
1981
1991
 
1982
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
1992
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
package/dist/index.d.ts CHANGED
@@ -326,6 +326,15 @@ type AvailableAgent = {
326
326
  supportedChainIds: readonly number[];
327
327
  supportedAssets: readonly AgentSupportedAssets[];
328
328
  };
329
+ type ActivateAgentOptions = {
330
+ /**
331
+ * Called once the chain and agents are registered, before any agent signs in
332
+ * or runs its setup. From then on reads such as `getBalances` are safe to
333
+ * start: each agent's reads wait on that agent's own sign-in, so they share
334
+ * the activation's one wallet prompt instead of waiting for all of setup.
335
+ */
336
+ onAgentsSelected?: () => void;
337
+ };
329
338
  type AvailableAgentsOptions = {
330
339
  chainId?: number;
331
340
  asset?: Asset;
@@ -1260,8 +1269,9 @@ declare class OwneySDK {
1260
1269
  * that support the given chainId (incompatible agents are silently skipped).
1261
1270
  * If provided, ALL specified agents must support the chainId or the call
1262
1271
  * throws before activating any agent.
1272
+ * @param options - Optional. `onAgentsSelected` fires once reads can start.
1263
1273
  */
1264
- activateAgent(chainId: number, agentId?: AgentId[]): Promise<void>;
1274
+ activateAgent(chainId: number, agentId?: AgentId[], options?: ActivateAgentOptions): Promise<void>;
1265
1275
  /**
1266
1276
  * Activate agents ONE AT A TIME, each followed by its org policy.
1267
1277
  *
@@ -1979,4 +1989,4 @@ type StoredOrder = {
1979
1989
  */
1980
1990
  declare function listOrders(now?: number): StoredOrder[];
1981
1991
 
1982
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
1992
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, 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 ApyCoverage, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OrgPoolPolicy, type OrgPoolSelection, 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 OwneyWithdrawAllLeg, type OwneyWithdrawAllResult, type OwneyWithdrawResult, type PendingDeposit, type PoolCatalogProtocol, type PoolSelectionStrategy, type RebalanceLog, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
package/dist/index.js CHANGED
@@ -1489,12 +1489,16 @@ var ZyfaiAgent = class _ZyfaiAgent {
1489
1489
  }
1490
1490
  // --- IAgent: Account lifecycle ---
1491
1491
  async activateAgent(state, chainId) {
1492
+ const startedAt = Date.now();
1492
1493
  try {
1493
1494
  debugLog("zyfai:activation", "starting", {
1494
1495
  walletAddress: state.walletAddress,
1495
1496
  chainId
1496
1497
  });
1497
1498
  await this.connectAuth(state, chainId);
1499
+ debugLog("zyfai:activation", "signed in", {
1500
+ ms: Date.now() - startedAt
1501
+ });
1498
1502
  const validChainId = isValidChainId(chainId);
1499
1503
  await Promise.all([
1500
1504
  this.ensureProtocolsSynced(validChainId, "USDC"),
@@ -1505,7 +1509,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
1505
1509
  // validator, so pool-wallet users see no prompt. Non-fatal.
1506
1510
  this.ensureSessionKeyIfDeployed(validChainId)
1507
1511
  ]);
1508
- debugLog("zyfai:activation", "completed", { chainId: validChainId });
1512
+ debugLog("zyfai:activation", "completed", {
1513
+ chainId: validChainId,
1514
+ ms: Date.now() - startedAt
1515
+ });
1509
1516
  } catch (error) {
1510
1517
  throw error;
1511
1518
  }
@@ -2191,8 +2198,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
2191
2198
  }
2192
2199
  // --- IAgent: Portfolio reads ---
2193
2200
  async getBalances(state, chainId) {
2201
+ const startedAt = Date.now();
2194
2202
  const { smartWallet, chainId: validChainId } = await this.resolveSmartWallet(state, chainId);
2195
2203
  const raw = await this.sdk.getPortfolio(this.getAddress());
2204
+ debugLog("zyfai:balances", "read", { ms: Date.now() - startedAt });
2196
2205
  return mapBalances(raw, validChainId, smartWallet);
2197
2206
  }
2198
2207
  earningsKey(state, chainId, smartWallet) {
@@ -5015,8 +5024,9 @@ var OwneySDK = class {
5015
5024
  * that support the given chainId (incompatible agents are silently skipped).
5016
5025
  * If provided, ALL specified agents must support the chainId or the call
5017
5026
  * throws before activating any agent.
5027
+ * @param options - Optional. `onAgentsSelected` fires once reads can start.
5018
5028
  */
5019
- async activateAgent(chainId, agentId) {
5029
+ async activateAgent(chainId, agentId, options = {}) {
5020
5030
  const state = this.requireState();
5021
5031
  await this.ensureAgentsInitialized();
5022
5032
  if (agentId !== void 0) {
@@ -5052,6 +5062,7 @@ var OwneySDK = class {
5052
5062
  this.activeAgents.add(id);
5053
5063
  }
5054
5064
  state.chainId = chainId;
5065
+ options.onAgentsSelected?.();
5055
5066
  await this.activateAgentsInTurn(agents, state, chainId);
5056
5067
  return;
5057
5068
  }
@@ -5070,6 +5081,7 @@ var OwneySDK = class {
5070
5081
  this.activeAgents.add(agent.id);
5071
5082
  }
5072
5083
  state.chainId = chainId;
5084
+ options.onAgentsSelected?.();
5073
5085
  const enabledCompatible = compatible.filter(
5074
5086
  (agent) => !this.isAgentDisabled(agent.id)
5075
5087
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.28",
3
+ "version": "0.7.29-beta.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",