/**
 * @fileoverview Application state type definitions.
 *
 * Defines the top-level persisted state structure (AppState) which composes
 * types from multiple domains: SessionState (session), TaskState (task),
 * RalphLoopState (ralph), and RespawnConfig (respawn).
 *
 * Key exports:
 * - AppState — root state object (sessions, tasks, ralphLoop, config, globalStats, tokenStats)
 * - AppConfig — app configuration including default RespawnConfig
 * - GlobalStats — cumulative usage stats across all sessions (lifetime)
 * - TokenStats / TokenUsageEntry — daily token usage history
 * - DEFAULT_CONFIG — default AppConfig values
 * - createInitialState() — factory for fresh AppState
 *
 * Persisted to `~/.codeman/state.json` via StateStore (debounced 500ms writes).
 * Served at `GET /api/status` (full state) and `GET /api/config` (config subset).
 *
 * Cross-domain imports: SessionState, TaskState, RalphLoopState, RespawnConfig.
 */
// ========== Default Configuration ==========
/**
 * Default application configuration values
 */
export const DEFAULT_CONFIG = {
    pollIntervalMs: 1000,
    defaultTimeoutMs: 300000, // 5 minutes
    maxConcurrentSessions: 5,
    stateFilePath: '',
    respawn: {
        idleTimeoutMs: 5000, // 5 seconds of no activity after prompt
        updatePrompt: 'update all the docs and CLAUDE.md',
        interStepDelayMs: 1000, // 1 second between steps
        enabled: false, // disabled by default
        sendClear: true, // send /clear after update prompt
        sendInit: true, // send /init after /clear
    },
    lastUsedCase: null,
    ralphEnabled: false,
};
/**
 * Creates initial application state
 * @returns Fresh application state with defaults
 */
export function createInitialState() {
    return {
        sessions: {},
        tasks: {},
        ralphLoop: {
            status: 'stopped',
            startedAt: null,
            minDurationMs: null,
            tasksCompleted: 0,
            tasksGenerated: 0,
            lastCheckAt: null,
        },
        config: { ...DEFAULT_CONFIG },
        globalStats: createInitialGlobalStats(),
    };
}
/**
 * Creates initial global stats object
 * @returns Fresh global stats with zero values
 */
export function createInitialGlobalStats() {
    const now = Date.now();
    return {
        totalInputTokens: 0,
        totalOutputTokens: 0,
        totalCost: 0,
        totalSessionsCreated: 0,
        firstRecordedAt: now,
        lastUpdatedAt: now,
    };
}
//# sourceMappingURL=app-state.js.map