package com.correx.core.events.events

import com.correx.core.events.types.SessionId
import com.correx.core.events.types.TaskId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("ChatSessionStarted")
data class ChatSessionStartedEvent(
    val sessionId: SessionId,
) : EventPayload

/**
 * Records, in the session's own stream, that this run claimed [taskId] and is working it with the
 * declared [affectedPaths] write scope — a session-local fact so the gates know the active task
 * without scanning task streams. Re-emitted when the claimant edits affected_paths, so the folded
 * scope stays current; SessionContextProjection takes the most recent.
 */
@Serializable
@SerialName("SessionWorkingTask")
data class SessionWorkingTaskEvent(
    val sessionId: SessionId,
    val taskId: TaskId,
    val affectedPaths: List<String> = emptyList(),
) : EventPayload

@Serializable
@SerialName("SessionWorkspaceBound")
data class SessionWorkspaceBoundEvent(
    val sessionId: SessionId,
    val workspaceRoot: String,
    val allowedPaths: List<String>,
) : EventPayload

@Serializable
@SerialName("OperatorProfileBound")
data class OperatorProfileBoundEvent(
    val sessionId: SessionId,
    val about: String,
    val approvalMode: String,
    val preferredModels: List<String>,
    val conventions: List<String>,
) : EventPayload

@Serializable
@SerialName("ProjectProfileBound")
data class ProjectProfileBoundEvent(
    val sessionId: SessionId,
    val workspaceRoot: String,
    val about: String,
    val conventions: List<String>,
    val commands: Map<String, String>,
) : EventPayload

@Serializable
@SerialName("AgentInstructionsBound")
data class AgentInstructionsBoundEvent(
    val sessionId: SessionId,
    val workspaceRoot: String,
    val sources: List<String>, // file names found, e.g. ["CLAUDE.md","AGENTS.md"]
    val content: String,       // concatenated, header-labeled instructions
) : EventPayload
