@owney/sdk 0.7.32-beta.10 → 0.7.32-beta.12

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
@@ -429,10 +429,9 @@ interface ConnectionState {
429
429
  chainId: number | null;
430
430
  /**
431
431
  * Reads under this state use a saved sign-in only: an agent never opens a
432
- * wallet prompt for them and fails instead. Set by the whole-portfolio reads
433
- * of an agent that is not active on the connection chain, and by every read
434
- * of an agent that did not sign in this session (it failed while another
435
- * agent signed in, or the user cancelled its sign-in).
432
+ * wallet prompt for them and fails instead. The client sets it on every
433
+ * read (balances, earnings, history...). Connect/activation and user actions
434
+ * (deposit, withdraw) run without it, so they may still ask for a sign-in.
436
435
  */
437
436
  promptless?: boolean;
438
437
  }
@@ -711,7 +710,7 @@ interface IAgent {
711
710
  after: string[];
712
711
  beforeRequest?: () => void;
713
712
  }): Promise<ZyfaiHandoffAnswer>;
714
- disconnect(): Promise<void>;
713
+ disconnect(options?: DisconnectOptions): Promise<void>;
715
714
  /**
716
715
  * Ready the user's account for every asset the agent supports on `chainId`,
717
716
  * `asset` first. A failure the provider says will not go away (the user can
@@ -837,6 +836,12 @@ interface IAgent {
837
836
  * account was not created through Owney (AGENT_ACCOUNT_NOT_OWNEY). Optional.
838
837
  */
839
838
  setAccountRefusedListener?(listener: (() => void) | undefined): void;
839
+ /**
840
+ * Called each time the agent drops a saved sign-in its server refused,
841
+ * outside connect (a read or a withdrawal). Not called where the sign-in is
842
+ * renewed (connect, deposit). Optional.
843
+ */
844
+ setSignInRefusedListener?(listener: (() => void) | undefined): void;
840
845
  /**
841
846
  * May this wallet's account use Owney with this agent? Run at connect for
842
847
  * every agent about to activate, before any agent activates or is read.
@@ -846,6 +851,14 @@ interface IAgent {
846
851
  * checked.
847
852
  */
848
853
  checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
854
+ /**
855
+ * Would this agent ask the wallet to sign in for this wallet and chain right
856
+ * now? Read from what it has saved; it never prompts and never calls the
857
+ * network. Connect counts the sign-ins it will ask for from this
858
+ * (`OwneySDK.onSignInProgress`). Optional; without it the agent is counted
859
+ * as not needing one.
860
+ */
861
+ needsSignIn?(state: ConnectionState, chainId: number): boolean;
849
862
  /**
850
863
  * A small, never-prompting read of the provider's earnings bookkeeping for a
851
864
  * `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
@@ -898,6 +911,15 @@ type AgentApyOptions = {
898
911
  chainId?: number;
899
912
  };
900
913
 
914
+ /** Options for `OwneySDK.disconnect` and `IAgent.disconnect`. */
915
+ type DisconnectOptions = {
916
+ /**
917
+ * Keep each agent's saved sign-ins (browser storage) so a later connect for
918
+ * the same wallet needs no new signature. Everything held in memory is
919
+ * still dropped. Default false: saved sign-ins are deleted.
920
+ */
921
+ keepSignIns?: boolean;
922
+ };
901
923
  type AgentId = "zyfai" | "yieldseeker";
902
924
  type Asset = string;
903
925
  type AgentSupportedAsset = {
@@ -928,6 +950,23 @@ type ActivateAgentOptions = {
928
950
  */
929
951
  onAgentsSelected?: () => void;
930
952
  };
953
+ /**
954
+ * One step of the sign-ins a connect asks for (`OwneySDK.onSignInProgress`).
955
+ * The plan is the agents whose `needsSignIn` said yes when the connect began:
956
+ * `total`. `"waiting"` comes right before the step that signs an agent in,
957
+ * `"signed"` when it returns, and `"finished"` once: right after the last
958
+ * planned sign-in, or when the connect ends before that (cancelled, failed, or
959
+ * the wallet changed).
960
+ */
961
+ type SignInProgress = {
962
+ state: "waiting" | "signed" | "finished";
963
+ /** Sign-ins this connect asks for. */
964
+ total: number;
965
+ /** Sign-ins finished so far. */
966
+ done: number;
967
+ /** The agent this step is for; absent on `"finished"`. */
968
+ agentId?: AgentId;
969
+ };
931
970
  type AvailableAgentsOptions = {
932
971
  chainId?: number;
933
972
  asset?: Asset;
@@ -1977,14 +2016,8 @@ declare class OwneySDK {
1977
2016
  */
1978
2017
  private disabledAgents;
1979
2018
  private readonly accountRefusedListeners;
1980
- /**
1981
- * Agents whose sign-in the user cancelled this session (the wallet rejected
1982
- * the prompt), keyed by chain. Until the app ends the session they are read
1983
- * from a saved sign-in only (`readStateFor`), so no read reopens the prompt
1984
- * the user cancelled. A later successful activation of the agent removes
1985
- * it, and `disconnect()` or a different wallet's `connect()` clears the map.
1986
- */
1987
- private declinedSignIns;
2019
+ private readonly signInRefusedListeners;
2020
+ private readonly signInProgressListeners;
1988
2021
  private state;
1989
2022
  private connectionRevision;
1990
2023
  private disconnectingAgents;
@@ -2076,6 +2109,37 @@ declare class OwneySDK {
2076
2109
  * each time an agent maps such a refusal. Returns the unsubscribe function.
2077
2110
  */
2078
2111
  onAccountRefused(listener: (agentId: AgentId) => void): () => void;
2112
+ /**
2113
+ * Listens for an agent dropping a saved sign-in its server refused, outside
2114
+ * connect (a read or a withdrawal found it refused). The agent will not
2115
+ * sign in again by itself; the next sign-in is the user's. Not fired where a
2116
+ * refused sign-in is renewed (connect, deposit). Returns the unsubscribe
2117
+ * function.
2118
+ */
2119
+ onSignInRefused(listener: (agentId: AgentId) => void): () => void;
2120
+ /**
2121
+ * Listens for the sign-ins a connect asks for (`SignInProgress`): which
2122
+ * agents will ask the wallet to sign in, and each one as it starts and ends,
2123
+ * then `"finished"` after the last one (or when the connect ends first).
2124
+ * Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
2125
+ * function.
2126
+ */
2127
+ onSignInProgress(listener: (progress: SignInProgress) => void): () => void;
2128
+ /**
2129
+ * The agents that would ask the wallet to sign in on `chainId` right now:
2130
+ * enabled agents on that chain whose `needsSignIn` says yes. One with no
2131
+ * such check counts as no; one that throws counts as yes, so an unknown
2132
+ * answer never lets the app retry quietly into a prompt. Never prompts and
2133
+ * never calls the network. Empty before connect.
2134
+ */
2135
+ signInsNeeded(chainId: number): AgentId[];
2136
+ /**
2137
+ * The sign-ins this connect asks for: the agents whose `needsSignIn` says
2138
+ * yes now (one that throws counts as no). Each is announced at its first
2139
+ * step (its account check, or its activation when it has none) and counted
2140
+ * once.
2141
+ */
2142
+ private planSignIns;
2079
2143
  /** Wires the optional hooks the SDK offers an agent. */
2080
2144
  private attachAgentHooks;
2081
2145
  /**
@@ -2097,7 +2161,7 @@ declare class OwneySDK {
2097
2161
  * Disconnect from all agents and clear connection state.
2098
2162
  * After calling this, `connect()` must be called again before using agent methods.
2099
2163
  */
2100
- disconnect(): Promise<void>;
2164
+ disconnect(options?: DisconnectOptions): Promise<void>;
2101
2165
  private clearConnectionState;
2102
2166
  private disconnectAgents;
2103
2167
  private isAgentDisabled;
@@ -2120,12 +2184,11 @@ declare class OwneySDK {
2120
2184
  */
2121
2185
  private hasNoAgentForSlot;
2122
2186
  /**
2123
- * The state an agent's reads use. An agent whose sign-in the user cancelled
2124
- * on the connection chain this session is read from a saved sign-in only,
2125
- * as `offChainPortfolioAgents` reads: a read that would need a wallet
2126
- * prompt fails for that agent instead of reopening the prompt the user
2127
- * cancelled. A later successful activation of the agent, or `disconnect()`,
2128
- * lifts it.
2187
+ * The state every agent read uses: promptless, so a read uses a saved
2188
+ * sign-in only and never opens a wallet prompt. A read that would need one
2189
+ * fails for that agent instead; the app keeps the last known value and
2190
+ * retries later. Only connect/activation and user actions (deposit,
2191
+ * withdraw) may ask the wallet to sign in, and they use the plain state.
2129
2192
  */
2130
2193
  private readStateFor;
2131
2194
  /**
@@ -2255,6 +2318,7 @@ declare class OwneySDK {
2255
2318
  * activation, with nothing activated.
2256
2319
  */
2257
2320
  private activateAgentsInTurn;
2321
+ private activatePlannedAgents;
2258
2322
  /**
2259
2323
  * Deposit into a specific agent, or distribute across all eligible agents.
2260
2324
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
@@ -3239,6 +3303,15 @@ declare class YieldseekerAgent implements IAgent {
3239
3303
  private readonly balanceContexts;
3240
3304
  private readonly balanceVaults;
3241
3305
  private readonly users;
3306
+ /**
3307
+ * Agent wallets (lowercase) this page started releasing vault funds from for
3308
+ * a withdrawal, and when. Until the payout is done the released money sits
3309
+ * in the agent wallet, so no deposit notice may go out (it would be
3310
+ * reinvested). The ledger shows the same once it lists the withdrawal.
3311
+ */
3312
+ private readonly releasingWallets;
3313
+ /** One login (and, for a new wallet, one create) per wallet and chain at a time. */
3314
+ private readonly pendingUsers;
3242
3315
  private readonly pendingAgents;
3243
3316
  private readonly pendingWalletContexts;
3244
3317
  private readonly readCache;
@@ -3260,6 +3333,7 @@ declare class YieldseekerAgent implements IAgent {
3260
3333
  private readonly settlementChecks;
3261
3334
  private ledgerAccess?;
3262
3335
  private accountRefusedListener?;
3336
+ private signInRefusedListener?;
3263
3337
  private readonly ledgerReads;
3264
3338
  /** contextKey -> movements this instance started settling (by tx hash) and how they refresh:
3265
3339
  * awaiting the ledger, refreshed when ready (ledger), or on the timed backoff (legacy). */
@@ -3331,7 +3405,12 @@ declare class YieldseekerAgent implements IAgent {
3331
3405
  txHash: Hex;
3332
3406
  status: YieldseekerWalletStatus;
3333
3407
  }>;
3334
- disconnect(): Promise<void>;
3408
+ disconnect(options?: DisconnectOptions): Promise<void>;
3409
+ /**
3410
+ * Whether connecting now would ask the wallet to sign in: no reusable saved
3411
+ * sign-in for this wallet and chain. Never prompts; reads only what is saved.
3412
+ */
3413
+ needsSignIn(state: ConnectionState, chainId: number): boolean;
3335
3414
  /**
3336
3415
  * The connect's account check (2026-11-13), run before any agent activates:
3337
3416
  * sign in (a saved sign-in, else login-with-wallet, else POST /users for a
@@ -3392,7 +3471,9 @@ declare class YieldseekerAgent implements IAgent {
3392
3471
  * left idle. While it has not, Yieldseeker is told again, up to
3393
3472
  * DEPOSIT_NOTICE_ATTEMPTS calls in all; a failed call (network, server, rate
3394
3473
  * limit) is sent again after a wait. Within an hour of a withdrawal it is
3395
- * told once, since nothing can move yet. Uses the agent this session already
3474
+ * told once, since nothing can move yet. While a withdrawal from the agent
3475
+ * wallet is under way it is not told at all: its released funds wait in that
3476
+ * wallet for the payout, and a notice would reinvest them (ROUT-790). Uses the agent this session already
3396
3477
  * knows for the asset and the saved sign-in only: never prompts, never
3397
3478
  * throws. Each call is reported through `onNotice`.
3398
3479
  */
@@ -3413,6 +3494,13 @@ declare class YieldseekerAgent implements IAgent {
3413
3494
  * confirmed withdrawal, if that is still ahead; null when there was none in
3414
3495
  * the last hour or the ledger cannot say.
3415
3496
  */
3497
+ /**
3498
+ * A withdrawal from this agent wallet that has started but not finished,
3499
+ * within the last hour: released by this page, or listed on the ledger with
3500
+ * the agent's leg still created, submitted or unknown. Older unfinished rows
3501
+ * do not count, so a stuck record cannot hold deposits back for good.
3502
+ */
3503
+ private withdrawalUnderWay;
3416
3504
  private withdrawalCooldownEnd;
3417
3505
  /**
3418
3506
  * The agent wallet's base-asset balance and the platform fee Yieldseeker has
@@ -3683,6 +3771,13 @@ declare class YieldseekerAgent implements IAgent {
3683
3771
  private reportAccount;
3684
3772
  private contextForAgent;
3685
3773
  private resolveUser;
3774
+ /**
3775
+ * `login-with-wallet`, and `POST /users` for a wallet without an account.
3776
+ * Both draw on Yieldseeker's per-IP sign-in allowance, which all our users
3777
+ * share: while a 429's pause lasts nothing is sent, and a new 429 starts one.
3778
+ */
3779
+ private signInUser;
3780
+ private signInRateLimited;
3686
3781
  private forgetUser;
3687
3782
  private ensureAgent;
3688
3783
  private findAgent;
@@ -3729,6 +3824,7 @@ declare class YieldseekerAgent implements IAgent {
3729
3824
  private loadPortfolioParts;
3730
3825
  private deployAgent;
3731
3826
  setAccountRefusedListener(listener: (() => void) | undefined): void;
3827
+ setSignInRefusedListener(listener: (() => void) | undefined): void;
3732
3828
  setFundingLedgerAccess(access: AgentFundingLedgerAccess | undefined): void;
3733
3829
  private historyKey;
3734
3830
  /** Funding-ledger rows for this slot, cached 15 s. Never throws: null on any failure. */
@@ -3995,4 +4091,4 @@ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
3995
4091
  * Older builds do not export this. */
3996
4092
  declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
3997
4093
 
3998
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, 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 ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, 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 ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
4094
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, 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 ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type DisconnectOptions, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, 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 ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SignInProgress, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
package/dist/index.d.ts CHANGED
@@ -429,10 +429,9 @@ interface ConnectionState {
429
429
  chainId: number | null;
430
430
  /**
431
431
  * Reads under this state use a saved sign-in only: an agent never opens a
432
- * wallet prompt for them and fails instead. Set by the whole-portfolio reads
433
- * of an agent that is not active on the connection chain, and by every read
434
- * of an agent that did not sign in this session (it failed while another
435
- * agent signed in, or the user cancelled its sign-in).
432
+ * wallet prompt for them and fails instead. The client sets it on every
433
+ * read (balances, earnings, history...). Connect/activation and user actions
434
+ * (deposit, withdraw) run without it, so they may still ask for a sign-in.
436
435
  */
437
436
  promptless?: boolean;
438
437
  }
@@ -711,7 +710,7 @@ interface IAgent {
711
710
  after: string[];
712
711
  beforeRequest?: () => void;
713
712
  }): Promise<ZyfaiHandoffAnswer>;
714
- disconnect(): Promise<void>;
713
+ disconnect(options?: DisconnectOptions): Promise<void>;
715
714
  /**
716
715
  * Ready the user's account for every asset the agent supports on `chainId`,
717
716
  * `asset` first. A failure the provider says will not go away (the user can
@@ -837,6 +836,12 @@ interface IAgent {
837
836
  * account was not created through Owney (AGENT_ACCOUNT_NOT_OWNEY). Optional.
838
837
  */
839
838
  setAccountRefusedListener?(listener: (() => void) | undefined): void;
839
+ /**
840
+ * Called each time the agent drops a saved sign-in its server refused,
841
+ * outside connect (a read or a withdrawal). Not called where the sign-in is
842
+ * renewed (connect, deposit). Optional.
843
+ */
844
+ setSignInRefusedListener?(listener: (() => void) | undefined): void;
840
845
  /**
841
846
  * May this wallet's account use Owney with this agent? Run at connect for
842
847
  * every agent about to activate, before any agent activates or is read.
@@ -846,6 +851,14 @@ interface IAgent {
846
851
  * checked.
847
852
  */
848
853
  checkAccount?(state: ConnectionState, chainId: number): Promise<void>;
854
+ /**
855
+ * Would this agent ask the wallet to sign in for this wallet and chain right
856
+ * now? Read from what it has saved; it never prompts and never calls the
857
+ * network. Connect counts the sign-ins it will ask for from this
858
+ * (`OwneySDK.onSignInProgress`). Optional; without it the agent is counted
859
+ * as not needing one.
860
+ */
861
+ needsSignIn?(state: ConnectionState, chainId: number): boolean;
849
862
  /**
850
863
  * A small, never-prompting read of the provider's earnings bookkeeping for a
851
864
  * `provider.sample` ledger event (Zyfai). Null when unavailable; never throws.
@@ -898,6 +911,15 @@ type AgentApyOptions = {
898
911
  chainId?: number;
899
912
  };
900
913
 
914
+ /** Options for `OwneySDK.disconnect` and `IAgent.disconnect`. */
915
+ type DisconnectOptions = {
916
+ /**
917
+ * Keep each agent's saved sign-ins (browser storage) so a later connect for
918
+ * the same wallet needs no new signature. Everything held in memory is
919
+ * still dropped. Default false: saved sign-ins are deleted.
920
+ */
921
+ keepSignIns?: boolean;
922
+ };
901
923
  type AgentId = "zyfai" | "yieldseeker";
902
924
  type Asset = string;
903
925
  type AgentSupportedAsset = {
@@ -928,6 +950,23 @@ type ActivateAgentOptions = {
928
950
  */
929
951
  onAgentsSelected?: () => void;
930
952
  };
953
+ /**
954
+ * One step of the sign-ins a connect asks for (`OwneySDK.onSignInProgress`).
955
+ * The plan is the agents whose `needsSignIn` said yes when the connect began:
956
+ * `total`. `"waiting"` comes right before the step that signs an agent in,
957
+ * `"signed"` when it returns, and `"finished"` once: right after the last
958
+ * planned sign-in, or when the connect ends before that (cancelled, failed, or
959
+ * the wallet changed).
960
+ */
961
+ type SignInProgress = {
962
+ state: "waiting" | "signed" | "finished";
963
+ /** Sign-ins this connect asks for. */
964
+ total: number;
965
+ /** Sign-ins finished so far. */
966
+ done: number;
967
+ /** The agent this step is for; absent on `"finished"`. */
968
+ agentId?: AgentId;
969
+ };
931
970
  type AvailableAgentsOptions = {
932
971
  chainId?: number;
933
972
  asset?: Asset;
@@ -1977,14 +2016,8 @@ declare class OwneySDK {
1977
2016
  */
1978
2017
  private disabledAgents;
1979
2018
  private readonly accountRefusedListeners;
1980
- /**
1981
- * Agents whose sign-in the user cancelled this session (the wallet rejected
1982
- * the prompt), keyed by chain. Until the app ends the session they are read
1983
- * from a saved sign-in only (`readStateFor`), so no read reopens the prompt
1984
- * the user cancelled. A later successful activation of the agent removes
1985
- * it, and `disconnect()` or a different wallet's `connect()` clears the map.
1986
- */
1987
- private declinedSignIns;
2019
+ private readonly signInRefusedListeners;
2020
+ private readonly signInProgressListeners;
1988
2021
  private state;
1989
2022
  private connectionRevision;
1990
2023
  private disconnectingAgents;
@@ -2076,6 +2109,37 @@ declare class OwneySDK {
2076
2109
  * each time an agent maps such a refusal. Returns the unsubscribe function.
2077
2110
  */
2078
2111
  onAccountRefused(listener: (agentId: AgentId) => void): () => void;
2112
+ /**
2113
+ * Listens for an agent dropping a saved sign-in its server refused, outside
2114
+ * connect (a read or a withdrawal found it refused). The agent will not
2115
+ * sign in again by itself; the next sign-in is the user's. Not fired where a
2116
+ * refused sign-in is renewed (connect, deposit). Returns the unsubscribe
2117
+ * function.
2118
+ */
2119
+ onSignInRefused(listener: (agentId: AgentId) => void): () => void;
2120
+ /**
2121
+ * Listens for the sign-ins a connect asks for (`SignInProgress`): which
2122
+ * agents will ask the wallet to sign in, and each one as it starts and ends,
2123
+ * then `"finished"` after the last one (or when the connect ends first).
2124
+ * Nothing is sent when no agent needs a sign-in. Returns the unsubscribe
2125
+ * function.
2126
+ */
2127
+ onSignInProgress(listener: (progress: SignInProgress) => void): () => void;
2128
+ /**
2129
+ * The agents that would ask the wallet to sign in on `chainId` right now:
2130
+ * enabled agents on that chain whose `needsSignIn` says yes. One with no
2131
+ * such check counts as no; one that throws counts as yes, so an unknown
2132
+ * answer never lets the app retry quietly into a prompt. Never prompts and
2133
+ * never calls the network. Empty before connect.
2134
+ */
2135
+ signInsNeeded(chainId: number): AgentId[];
2136
+ /**
2137
+ * The sign-ins this connect asks for: the agents whose `needsSignIn` says
2138
+ * yes now (one that throws counts as no). Each is announced at its first
2139
+ * step (its account check, or its activation when it has none) and counted
2140
+ * once.
2141
+ */
2142
+ private planSignIns;
2079
2143
  /** Wires the optional hooks the SDK offers an agent. */
2080
2144
  private attachAgentHooks;
2081
2145
  /**
@@ -2097,7 +2161,7 @@ declare class OwneySDK {
2097
2161
  * Disconnect from all agents and clear connection state.
2098
2162
  * After calling this, `connect()` must be called again before using agent methods.
2099
2163
  */
2100
- disconnect(): Promise<void>;
2164
+ disconnect(options?: DisconnectOptions): Promise<void>;
2101
2165
  private clearConnectionState;
2102
2166
  private disconnectAgents;
2103
2167
  private isAgentDisabled;
@@ -2120,12 +2184,11 @@ declare class OwneySDK {
2120
2184
  */
2121
2185
  private hasNoAgentForSlot;
2122
2186
  /**
2123
- * The state an agent's reads use. An agent whose sign-in the user cancelled
2124
- * on the connection chain this session is read from a saved sign-in only,
2125
- * as `offChainPortfolioAgents` reads: a read that would need a wallet
2126
- * prompt fails for that agent instead of reopening the prompt the user
2127
- * cancelled. A later successful activation of the agent, or `disconnect()`,
2128
- * lifts it.
2187
+ * The state every agent read uses: promptless, so a read uses a saved
2188
+ * sign-in only and never opens a wallet prompt. A read that would need one
2189
+ * fails for that agent instead; the app keeps the last known value and
2190
+ * retries later. Only connect/activation and user actions (deposit,
2191
+ * withdraw) may ask the wallet to sign in, and they use the plain state.
2129
2192
  */
2130
2193
  private readStateFor;
2131
2194
  /**
@@ -2255,6 +2318,7 @@ declare class OwneySDK {
2255
2318
  * activation, with nothing activated.
2256
2319
  */
2257
2320
  private activateAgentsInTurn;
2321
+ private activatePlannedAgents;
2258
2322
  /**
2259
2323
  * Deposit into a specific agent, or distribute across all eligible agents.
2260
2324
  * Validates that the asset is supported and amount meets minimums for the target agent(s).
@@ -3239,6 +3303,15 @@ declare class YieldseekerAgent implements IAgent {
3239
3303
  private readonly balanceContexts;
3240
3304
  private readonly balanceVaults;
3241
3305
  private readonly users;
3306
+ /**
3307
+ * Agent wallets (lowercase) this page started releasing vault funds from for
3308
+ * a withdrawal, and when. Until the payout is done the released money sits
3309
+ * in the agent wallet, so no deposit notice may go out (it would be
3310
+ * reinvested). The ledger shows the same once it lists the withdrawal.
3311
+ */
3312
+ private readonly releasingWallets;
3313
+ /** One login (and, for a new wallet, one create) per wallet and chain at a time. */
3314
+ private readonly pendingUsers;
3242
3315
  private readonly pendingAgents;
3243
3316
  private readonly pendingWalletContexts;
3244
3317
  private readonly readCache;
@@ -3260,6 +3333,7 @@ declare class YieldseekerAgent implements IAgent {
3260
3333
  private readonly settlementChecks;
3261
3334
  private ledgerAccess?;
3262
3335
  private accountRefusedListener?;
3336
+ private signInRefusedListener?;
3263
3337
  private readonly ledgerReads;
3264
3338
  /** contextKey -> movements this instance started settling (by tx hash) and how they refresh:
3265
3339
  * awaiting the ledger, refreshed when ready (ledger), or on the timed backoff (legacy). */
@@ -3331,7 +3405,12 @@ declare class YieldseekerAgent implements IAgent {
3331
3405
  txHash: Hex;
3332
3406
  status: YieldseekerWalletStatus;
3333
3407
  }>;
3334
- disconnect(): Promise<void>;
3408
+ disconnect(options?: DisconnectOptions): Promise<void>;
3409
+ /**
3410
+ * Whether connecting now would ask the wallet to sign in: no reusable saved
3411
+ * sign-in for this wallet and chain. Never prompts; reads only what is saved.
3412
+ */
3413
+ needsSignIn(state: ConnectionState, chainId: number): boolean;
3335
3414
  /**
3336
3415
  * The connect's account check (2026-11-13), run before any agent activates:
3337
3416
  * sign in (a saved sign-in, else login-with-wallet, else POST /users for a
@@ -3392,7 +3471,9 @@ declare class YieldseekerAgent implements IAgent {
3392
3471
  * left idle. While it has not, Yieldseeker is told again, up to
3393
3472
  * DEPOSIT_NOTICE_ATTEMPTS calls in all; a failed call (network, server, rate
3394
3473
  * limit) is sent again after a wait. Within an hour of a withdrawal it is
3395
- * told once, since nothing can move yet. Uses the agent this session already
3474
+ * told once, since nothing can move yet. While a withdrawal from the agent
3475
+ * wallet is under way it is not told at all: its released funds wait in that
3476
+ * wallet for the payout, and a notice would reinvest them (ROUT-790). Uses the agent this session already
3396
3477
  * knows for the asset and the saved sign-in only: never prompts, never
3397
3478
  * throws. Each call is reported through `onNotice`.
3398
3479
  */
@@ -3413,6 +3494,13 @@ declare class YieldseekerAgent implements IAgent {
3413
3494
  * confirmed withdrawal, if that is still ahead; null when there was none in
3414
3495
  * the last hour or the ledger cannot say.
3415
3496
  */
3497
+ /**
3498
+ * A withdrawal from this agent wallet that has started but not finished,
3499
+ * within the last hour: released by this page, or listed on the ledger with
3500
+ * the agent's leg still created, submitted or unknown. Older unfinished rows
3501
+ * do not count, so a stuck record cannot hold deposits back for good.
3502
+ */
3503
+ private withdrawalUnderWay;
3416
3504
  private withdrawalCooldownEnd;
3417
3505
  /**
3418
3506
  * The agent wallet's base-asset balance and the platform fee Yieldseeker has
@@ -3683,6 +3771,13 @@ declare class YieldseekerAgent implements IAgent {
3683
3771
  private reportAccount;
3684
3772
  private contextForAgent;
3685
3773
  private resolveUser;
3774
+ /**
3775
+ * `login-with-wallet`, and `POST /users` for a wallet without an account.
3776
+ * Both draw on Yieldseeker's per-IP sign-in allowance, which all our users
3777
+ * share: while a 429's pause lasts nothing is sent, and a new 429 starts one.
3778
+ */
3779
+ private signInUser;
3780
+ private signInRateLimited;
3686
3781
  private forgetUser;
3687
3782
  private ensureAgent;
3688
3783
  private findAgent;
@@ -3729,6 +3824,7 @@ declare class YieldseekerAgent implements IAgent {
3729
3824
  private loadPortfolioParts;
3730
3825
  private deployAgent;
3731
3826
  setAccountRefusedListener(listener: (() => void) | undefined): void;
3827
+ setSignInRefusedListener(listener: (() => void) | undefined): void;
3732
3828
  setFundingLedgerAccess(access: AgentFundingLedgerAccess | undefined): void;
3733
3829
  private historyKey;
3734
3830
  /** Funding-ledger rows for this slot, cached 15 s. Never throws: null on any failure. */
@@ -3995,4 +4091,4 @@ declare const YIELDSEEKER_WITHDRAW_SERVER_SUBMIT: 1;
3995
4091
  * Older builds do not export this. */
3996
4092
  declare const FUNDING_DEPOSIT_RECOVERY_REPORT: 1;
3997
4093
 
3998
- export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, 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 ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, 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 ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };
4094
+ export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type ActivateAgentOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentFundingLedgerAccess, 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 ApyIncentive, type Asset, type AssetDailyEarnings, type AssetReadMetadata, type AvailableAgent, type AvailableAgentsOptions, type AvailablePool, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositAuthorizationReference, type DepositCallback, type DepositOptions, type DepositReplacementValidation, type DisconnectOptions, FUNDING_DEPOSIT_RECOVERY_REPORT, FUSION_SECRET_SERVER_PUBLISH, type FundingEvidence, type FundingOperationKind, type FundingOperationLeg, type FundingOperationRow, type FundingProgress, type FundingStage, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LedgerLegReport, 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 ProviderSnapshotSample, type RebalanceLog, type ReservationAgent, type ReservationReleaseReason, type RpcUrlsConfig, SDK_VERSION, SPONSORED_DEPOSIT_SERVER_BROADCAST, type SavedPoolSelection, type SignInProgress, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type UnsignedUserOperationEvidence, type UserPoolSelection, type UserPoolSelectionRequest, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, type WithdrawalCompletion, type WithdrawalCompletionContext, type WithdrawalPayoutCandidate, type WithdrawalPayoutScan, type WithdrawalReservationConflict, type WithdrawalReservationMode, type WithdrawalReservationOptions, type WithdrawalSwapRecovery, YIELDSEEKER_WITHDRAW_SERVER_SUBMIT, YieldseekerAgent, type YieldseekerWalletStatus, ZYFAI_REGISTRATION_NOT_SENT_CODES, ZYFAI_SERVER_TASKS, ZYFAI_WITHDRAWAL_NOT_SENT_CODES, ZYFAI_WITHDRAW_DISPATCH_CHECKPOINT, type ZyfaiDepositPlacement, type ZyfaiRpcUrlsConfig, type ZyfaiWithdrawalLifecycle, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, switchWalletConnectChain, updateWithdrawSwap };