import type { SnapshotStorage } from './storage.js';
import type { SnapshotTriggerCallback } from './types.js';
import type { Plugin } from '../plugins/plugin.js';
import type { LocalAgent } from '../types/agent.js';
import type { MultiAgentPlugin, MultiAgent } from '../multiagent/index.js';
import { MultiAgentState } from '../multiagent/state.js';
import type { Graph } from '../multiagent/graph.js';
import type { Swarm } from '../multiagent/swarm.js';
/**
 * Controls when `snapshot_latest` is saved automatically for agents.
 *
 * There are two kinds of snapshots:
 * - **`snapshot_latest`**: A single mutable snapshot that is overwritten on each save. Used to
 *   resume the most recent conversation state (e.g. after a crash or restart). Always reflects
 *   the last saved point in time.
 * - **Immutable snapshots**: Append-only snapshots with unique IDs (UUID v7), created only when
 *   `snapshotTrigger` fires. Used for checkpointing — you can restore to any prior state, not
 *   just the latest.
 *
 * `SaveLatestStrategy` controls how frequently `snapshot_latest` is updated:
 * - `'invocation'`: after every agent invocation completes (default; balances durability and I/O)
 * - `'message'`: after every message added (most durable, highest I/O)
 * - `'trigger'`: only when a `snapshotTrigger` fires (or manually via `saveSnapshot`)
 *
 * Under `'invocation'` and `'message'`, guardrail redactions are persisted immediately so
 * pre-redaction content never sits at rest. Under `'trigger'`, the caller's `snapshotTrigger`
 * stays in control; redactions are only flushed if the trigger fires or `saveSnapshot` is called.
 */
export type SaveLatestStrategy = 'message' | 'invocation' | 'trigger';
/**
 * Controls when `snapshot_latest` is saved for multi-agent orchestrators.
 *
 * - `'node'`: after every node invocation completes (default; enables resume
 *   from the last completed node after a crash or restart)
 * - `'invocation'`: after every orchestrator invocation completes (lower I/O,
 *   but only captures state at orchestrator invocation boundaries)
 */
export type MultiAgentSaveLatestStrategy = 'node' | 'invocation';
export interface SessionManagerConfig {
    /** Pluggable storage backends for snapshot persistence. Defaults to FileStorage in Node.js; required in browser environments. */
    storage: {
        snapshot: SnapshotStorage;
    };
    /** Unique session identifier. Defaults to `'default-session'`. */
    sessionId?: string;
    /** When to save snapshot_latest. Default: `'invocation'` (after each agent invocation completes). See {@link SaveLatestStrategy} for details. */
    saveLatestOn?: SaveLatestStrategy;
    /** Callback invoked after each invocation to decide whether to create an immutable snapshot. */
    snapshotTrigger?: SnapshotTriggerCallback;
    /**
     * When to save snapshot_latest for multi-agent orchestrators.
     * Default: `'node'` (after each node invocation completes).
     * See {@link MultiAgentSaveLatestStrategy} for details.
     */
    multiAgentSaveLatestOn?: MultiAgentSaveLatestStrategy;
}
/**
 * Manages session persistence for agents, enabling conversation state
 * to be saved and restored across invocations using pluggable storage backends.
 *
 * Also supports multi-agent orchestrators (Graph, Swarm) via the MultiAgentPlugin interface.
 * Scope is auto-detected based on whether initAgent or initMultiAgent is called.
 *
 * @example
 * ```typescript
 * import { SessionManager, FileStorage } from '@strands-agents/sdk'
 *
 * const session = new SessionManager({
 *   sessionId: 'my-session',
 *   storage: { snapshot: new FileStorage() },
 * })
 * const agent = new Agent({ sessionManager: session })
 * ```
 */
export declare class SessionManager implements Plugin, MultiAgentPlugin {
    private readonly _sessionId;
    private readonly _storage;
    private readonly _saveLatestOn;
    private readonly _snapshotTrigger?;
    private readonly _multiAgentSaveLatestOn;
    private _multiAgentRestoredIds;
    /**
     * Unique identifier for this plugin.
     */
    get name(): string;
    constructor(config: SessionManagerConfig);
    /** Initializes the plugin by registering lifecycle hook callbacks. */
    initAgent(agent: LocalAgent): void;
    private _location;
    /** Saves a snapshot of the target's current state. */
    saveSnapshot(params: {
        target: LocalAgent;
        isLatest: boolean;
    }): Promise<void>;
    saveSnapshot(params: {
        target: Graph | Swarm;
        state?: MultiAgentState;
        isLatest: boolean;
    }): Promise<void>;
    /** Deletes all snapshots and manifests for this session from storage. */
    deleteSession(): Promise<void>;
    /** Lists all available immutable snapshot IDs for the given agent target. */
    listSnapshotIds(params: {
        target: LocalAgent;
        limit?: number;
        startAfter?: string;
    }): Promise<string[]>;
    /** Loads a snapshot from storage and restores it into the target. Returns false if no snapshot exists. */
    restoreSnapshot(params: {
        target: LocalAgent;
        snapshotId?: string;
    }): Promise<boolean>;
    restoreSnapshot(params: {
        target: Graph | Swarm;
        state?: MultiAgentState;
        snapshotId?: string;
    }): Promise<boolean>;
    /** Restores session state on agent initialization. */
    private _onAgentInitialized;
    /** Saves latest on invocation and fires the snapshot trigger if configured. */
    private _onAfterAgentInvocation;
    private _onMessageAdded;
    /**
     * Saves snapshot when a message is redacted after a model call.
     * Critical for ensuring guardrail redactions are persisted immediately.
     */
    private _onAfterModelCall;
    /** Captures one snapshot and writes it to both immutable history and snapshot_latest. */
    private _saveImmutableAndLatest;
    /** Initializes the multi-agent plugin by registering orchestrator lifecycle hooks. */
    initMultiAgent(orchestrator: MultiAgent): void;
    private _multiAgentLocation;
    /** Restores orchestrator state on first invocation (loads snapshot from storage once per orchestrator, then no-ops). */
    private _onBeforeMultiAgentInvocation;
    /** Saves latest orchestrator snapshot after each node completes. */
    private _onAfterNodeCall;
    /** Saves latest orchestrator snapshot after invocation completes. */
    private _onAfterMultiAgentInvocation;
}
//# sourceMappingURL=session-manager.d.ts.map