using System.Text.Json;

namespace Nexus.Api.Models;

/// <summary>
/// Transport-safe reference to a Nexus or OpenClaw-owned entity. Routing stays
/// a frontend concern, so this contract deliberately contains no URL.
/// </summary>
public sealed record EntityRefDto(
    string Type,
    string Id,
    string? Label = null);

public sealed record OperationResultDto(
    string OperationId,
    string Status,
    int Revision,
    EntityRefDto? PrimaryRef,
    IReadOnlyList<EntityRefDto> AffectedRefs,
    string? TraceId);

/// <summary>
/// Content-minimized event sent to authenticated Mission Control clients.
/// Payloads may carry state and correlation metadata, but never prompts,
/// credentials, markdown content, tool arguments, or entity names.
/// </summary>
public sealed record DomainEventDto(
    long Sequence,
    string EventType,
    EntityRefDto Entity,
    int EntityRevision,
    DateTimeOffset OccurredAt,
    JsonElement Payload);

public static class DomainEventTypes
{
    public const string ResyncRequired = "resync_required";
}
