/**
 * 4Runr OS State Store
 *
 * Central state management - single source of truth
 * All runtime state lives here, not scattered across modules
 *
 * ARCHITECTURE:
 * - This is the runtime state store (in-memory)
 * - For persistent state (last agent, last run, etc.), see state.ts
 *
 * USAGE:
 * - Read state: const state = getState()
 * - Update state: updateAppState({ field: value })
 * - Never mutate state directly - always use updateAppState()
 *
 * EXTENSION:
 * - To add new state, add it to AppState interface
 * - Update syncStateToStore() in index.ts if needed (during migration)
 * - See CONTRIBUTING-CLI.md for full extension recipe
 */
/**
 * Global state store
 * Access via getState() and updateState()
 */
let appState = {
    systemReady: false,
    currentView: 'BOOT',
    gatewayClient: null,
    gatewayConnected: false,
    gatewayUrl: null,
    localMode: false,
    currentUser: null,
    sessionCheckInterval: null,
    customAgents: new Map(),
    runHistory: [],
    currentRun: {
        runId: null,
        agentName: null,
        startedAt: null,
    },
    firstRunCompleted: false,
    chatMode: false,
    operationEvents: [],
};
/**
 * Get current state (read-only)
 * Use this to read state in UI renderers and commands
 */
export function getState() {
    return appState;
}
/**
 * Update app state (immutable update)
 * Returns new state object, doesn't mutate original
 *
 * NOTE: This is for runtime state. For persistent state (last agent, etc.),
 * use updateState from state.ts
 */
export function updateAppState(updates) {
    appState = { ...appState, ...updates };
    return appState;
}
/**
 * Reset state (for testing or fresh start)
 */
export function resetState() {
    appState = {
        systemReady: false,
        currentView: 'BOOT',
        gatewayClient: null,
        gatewayConnected: false,
        gatewayUrl: null,
        localMode: false,
        currentUser: null,
        sessionCheckInterval: null,
        customAgents: new Map(),
        runHistory: [],
        currentRun: {
            runId: null,
            agentName: null,
            startedAt: null,
        },
        firstRunCompleted: false,
        chatMode: false,
        operationEvents: [],
    };
}
//# sourceMappingURL=store.js.map