BareGit
#pragma once

#include <optional>
#include <string>
#include <variant>

#include <nlohmann/json.hpp>

#include "message.hpp"

namespace agent_smith
{

/// A text fragment received from an LLM streaming response.
struct StreamTokenDelta
{
    /// The newly generated text fragment.
    std::string text;
};

/// A complete tool-call identity received from an LLM streaming response.
struct StreamToolCallStarted
{
    /// Server-generated identifier for this tool invocation.
    std::string id;

    /// Name of the requested tool.
    std::string name;

    /// Position of the tool call in the streamed response.
    int index = 0;
};

/// A tool call whose buffered arguments have become valid JSON.
struct StreamToolCallCompleted
{
    /// Position of the tool call in the streamed response.
    int index = 0;

    /// Fully parsed function arguments.
    nlohmann::json arguments;
};

/// Marks the final event from an LLM streaming response.
struct StreamFinished
{
    /// Provider-supplied reason the response finished.
    std::string finish_reason;

    /// Token accounting emitted by the provider, when available.
    std::optional<TokenUsage> usage;
};

/// One typed event emitted while an LLM streaming response is active.
using StreamEvent = std::variant<StreamTokenDelta, StreamToolCallStarted,
                                 StreamToolCallCompleted, StreamFinished>;

} // namespace agent_smith