import { z } from 'zod'; import { type PathCtx } from '../config/paths.js'; /** * A pending request for a RUNNING session to switch accounts in place. The * dashboard (Enter) and `ccx use` write it; the live `ccx run` session polls it * and, when it can honor it, swaps credentials and resumes the same conversation * on the requested account. File-based IPC, same pattern as the events log. */ /** * `mode` decides HOW a running session honors the switch: * - 'seamless' (default): swap the credential file under the running process; it * re-reads within ~30s (its cache TTL), so the SAME session moves to the new * account with no restart and nothing lost. * - 'restart': end the process and relaunch, resuming this conversation, on the new * account (instant, but reloads the TUI and loses live state). */ declare const SwitchRequestSchema: z.ZodObject<{ account: z.ZodString; at: z.ZodNumber; mode: z.ZodOptional>; }, "strip", z.ZodTypeAny, { at: number; account: string; mode?: "seamless" | "restart" | undefined; }, { at: number; account: string; mode?: "seamless" | "restart" | undefined; }>; export type SwitchRequest = z.infer; export type SwitchMode = 'seamless' | 'restart'; /** * Ask a running session to switch to `account` (seamless by default). With a * `targetPid`, only the session with that pid honours it; without one, any * running session will. */ export declare function writeSwitchRequest(account: string, at: number, mode?: SwitchMode, c?: PathCtx, targetPid?: number): void; /** * The pending request for this session, or null. Pass the session's own `pid` to * read its per-session request; omit it for the broadcast one. A malformed file * is ignored (never crashes a live session). */ export declare function readSwitchRequest(c?: PathCtx, pid?: number): SwitchRequest | null; /** Remove the pending request (best effort). Pass `pid` to clear a per-session one. */ export declare function clearSwitchRequest(c?: PathCtx, pid?: number): void; export interface SwitchDecision { /** Account to switch the running session to, or null to stay put. */ switchTo: string | null; /** Whether the request has been handled and should be cleared from disk. */ consume: boolean; } /** * Decide what a running session should do with a pending request. Pure so the * lifecycle is fully testable: * - no request -> do nothing, nothing to clear * - already on it -> satisfied, clear it (so a later cap-rotation cannot be * yanked back by a stale same-account request) * - target unusable -> cannot honor (logged out / unknown), clear it so it * does not linger * - otherwise -> switch to it, clear it (fire once) */ export declare function decideSwitch(request: SwitchRequest | null, currentAccount: string, canUse: (account: string) => boolean): SwitchDecision; export {};