import { type JSONValue } from './types/json.js'; import { loadStateFromJSONSymbol, stateToJSONSymbol, type StateSerializable } from './types/serializable.js'; /** * Key-value storage for application state outside conversation context. * State is not passed to the model during inference but is accessible * by tools (via ToolContext) and application logic. * * All values are deep copied on get/set operations to prevent reference mutations. * Values must be JSON serializable. * * @example * ```typescript * const state = new StateStore({ userId: 'user-123' }) * state.set('sessionId', 'session-456') * const userId = state.get('userId') // 'user-123' * ``` */ export declare class StateStore implements StateSerializable { private _state; /** * Creates a new StateStore instance. * * @param initialState - Optional initial state values * @throws Error if initialState is not JSON serializable */ constructor(initialState?: Record); /** * Get a state value by key with optional type-safe property lookup. * Returns a deep copy to prevent mutations. * * @typeParam TState - The complete state interface type * @typeParam K - The property key (inferred from argument) * @param key - Key to retrieve specific value * @returns The value for the key, or undefined if key doesn't exist * * @example * ```typescript * // Typed usage * const user = state.get('user') // { name: string; age: number } | undefined * * // Untyped usage * const value = state.get('someKey') // JSONValue | undefined * ``` */ get(key: K): TState[K] | undefined; get(key: string): JSONValue | undefined; /** * Set a state value with optional type-safe property validation. * Validates JSON serializability and stores a deep copy. * * @typeParam TState - The complete state interface type * @typeParam K - The property key (inferred from argument) * @param key - The key to set * @param value - The value to store (must be JSON serializable) * @throws Error if value is not JSON serializable * * @example * ```typescript * // Typed usage * state.set('user', { name: 'Alice', age: 25 }) * * // Untyped usage * state.set('someKey', { any: 'value' }) * ``` */ set(key: K, value: TState[K]): void; set(key: string, value: unknown): void; /** * Delete a state value by key with optional type-safe property validation. * * @typeParam TState - The complete state interface type * @typeParam K - The property key (inferred from argument) * @param key - The key to delete * * @example * ```typescript * // Typed usage * state.delete('user') * * // Untyped usage * state.delete('someKey') * ``` */ delete(key: K): void; delete(key: string): void; /** * Clear all state values. */ clear(): void; /** * Get a copy of all state as an object. * * @returns Deep copy of all state */ getAll(): Record; /** * Get all state keys. * * @returns Array of state keys */ keys(): string[]; /** * Returns the serialized state as JSON value. * * @returns Deep copy of all state */ [stateToJSONSymbol](): JSONValue; /** * Loads state from a previously serialized JSON value. * * @param json - The serialized state to load */ [loadStateFromJSONSymbol](json: JSONValue): void; } //# sourceMappingURL=state-store.d.ts.map