using System.Text.Json.Nodes;

namespace Nexus.Api.Models;

public sealed record OpenClawAgentFileSummaryDto(
    string Name,
    bool Missing,
    long? Size,
    DateTimeOffset? UpdatedAt,
    string? ContentHash);

public sealed record OpenClawAgentFileCollectionDto(
    string AgentId,
    IReadOnlyList<OpenClawAgentFileSummaryDto> Files,
    DateTimeOffset CheckedAt);

public sealed record OpenClawAgentFileDto(
    string AgentId,
    string Name,
    bool Missing,
    long? Size,
    DateTimeOffset? UpdatedAt,
    string? Content,
    string ContentHash,
    DateTimeOffset CheckedAt);

public sealed record UpdateOpenClawAgentFileRequest(
    string Content,
    string ExpectedHash);

public sealed record OpenClawAgentFileWriteDto(
    bool Ok,
    string State,
    string Message,
    OpenClawAgentFileDto File,
    bool Verified,
    string IdempotencyKey,
    string CorrelationId,
    DateTimeOffset CompletedAt,
    OperationResultDto? Operation = null);

public sealed record OpenClawWorkspaceEntryDto(
    string Path,
    string Name,
    string Kind,
    long? Size,
    DateTimeOffset? UpdatedAt);

public sealed record OpenClawWorkspaceCollectionDto(
    string AgentId,
    string Path,
    string? ParentPath,
    IReadOnlyList<OpenClawWorkspaceEntryDto> Entries,
    int TotalEntries,
    int Offset,
    DateTimeOffset CheckedAt);

public sealed record OpenClawWorkspaceFileDto(
    string AgentId,
    string Path,
    string Name,
    long Size,
    DateTimeOffset? UpdatedAt,
    string MimeType,
    string Encoding,
    string Content,
    string ContentHash,
    DateTimeOffset CheckedAt);

public sealed record OpenClawConfigSchemaChildDto(
    string Key,
    string Path,
    JsonNode? Type,
    bool Required,
    bool HasChildren,
    string? ReloadKind,
    JsonNode? Hint);

public sealed record OpenClawConfigSchemaLookupDto(
    string Path,
    JsonNode? Schema,
    string? ReloadKind,
    JsonNode? Hint,
    IReadOnlyList<OpenClawConfigSchemaChildDto> Children,
    DateTimeOffset CheckedAt);

public sealed record OpenClawConfigSnapshotDto(
    bool Exists,
    bool Valid,
    string? Hash,
    JsonNode? Config,
    JsonNode? Issues,
    JsonNode? Warnings,
    DateTimeOffset CheckedAt);

public sealed record PatchOpenClawConfigRequest(
    JsonNode Patch,
    string BaseHash,
    IReadOnlyList<string>? ReplacePaths = null,
    string? Note = null,
    int? RestartDelayMs = null);

public sealed record OpenClawConfigPatchDto(
    bool Ok,
    string State,
    string Message,
    OpenClawConfigSnapshotDto Snapshot,
    JsonNode? Restart,
    bool Verified,
    string IdempotencyKey,
    string CorrelationId,
    DateTimeOffset CompletedAt,
    OperationResultDto? Operation = null);

public sealed record OpenClawAgentConfigurationErrorDto(
    string Code,
    string Message,
    string? RequiredMethod = null,
    string? RequiredScope = null);
