/**
 * Conversation domain state — tracks the active turn lifecycle,
 * message buffer, streaming deltas, and tool dispatch state.
 */
function makeEmptyUsage() {
    return { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, reasoningTokens: 0 };
}
/**
 * Returns the default initial state for the conversation domain.
 */
export function createInitialConversationState() {
    return {
        revision: 0,
        lastUpdatedAt: 0,
        source: 'init',
        turnState: 'idle',
        currentTurnId: undefined,
        turnStartedAt: undefined,
        turnEndedAt: undefined,
        lastTurnError: undefined,
        lastTurnStopReason: undefined,
        lastTurnResponse: undefined,
        lastPreflightFailure: undefined,
        totalTurns: 0,
        stream: {
            accumulated: '',
            reasoningAccumulated: '',
            partialToolPreview: undefined,
            deltaCount: 0,
            firstDeltaAt: undefined,
            lastDeltaAt: undefined,
        },
        activeToolCalls: new Map(),
        toolCallsThisTurn: 0,
        lastToolReconciliation: undefined,
        currentTurnUsage: makeEmptyUsage(),
        sessionUsage: makeEmptyUsage(),
        estimatedContextTokens: 0,
        contextWarningActive: false,
        messageCount: 0,
    };
}
