package com.correx.core.events.events

import com.correx.core.approvals.Tier
import com.correx.core.events.serialization.AnyMapSerializer
import com.correx.core.events.types.ToolInvocationId
import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

@Serializable
data class ToolReceipt(
    val invocationId: ToolInvocationId,
    val toolName: String,
    val exitCode: Int,
    val outputSummary: String,
    @Serializable(with = AnyMapSerializer::class)
    val structuredOutput: Map<String, Any> = emptyMap(),
    val affectedEntities: List<String> = emptyList(),
    val durationMs: Long,
    val tier: Tier,
    val timestamp: Instant,
    val diff: String? = null,
    // Artifact-store hash of the FULL tool output when it was truncated for model context (the
    // outputSummary above is a bounded preview). Null when nothing was truncated. Lets an agent
    // retrieve everything via the tool_output tool without bloating the event log with raw output.
    val fullOutputHash: String? = null,
)
