using Sdt.Config;
using Sdt.Runner;

namespace Sdt.Core.Debug;

public sealed record DebugRunResult(
    bool Success,
    ExecutionStopReason? StopReason,
    string Message,
    DebugProfileDefinition Profile,
    RunResult? RunResult,
    IReadOnlyList<string> OutputLines,
    IReadOnlyList<ProbeResult> Probes);

public sealed record DiagnosticsBundleResult(
    bool Success,
    string BundleDirectory,
    string? ZipPath,
    string Message);

public sealed record DiagnosticsBundleRequest(
    string Category,
    string ProjectRoot,
    string SummaryMessage,
    IReadOnlyList<string> OutputLines,
    IReadOnlyList<WorkflowStepResult> WorkflowSteps,
    IReadOnlyList<ProbeResult> Probes,
    DebugDiagnosticsOptions DiagnosticsOptions,
    DevToolConfig Config,
    ExecutionStopReason? StopReason = null,
    RunResult? DebugRun = null,
    DebugProfileDefinition? DebugProfile = null);

public interface IDebugProfileRunner
{
    Task<DebugRunResult> RunAsync(
        DebugProfileDefinition profile,
        DevToolConfig config,
        string projectRoot,
        bool verbose,
        Func<string, InstallPlan, Task<bool>> confirmInstallAsync,
        Action<string, bool> onOutput,
        Action<RunEvent>? onEvent = null,
        CancellationToken cancellationToken = default);
}

public interface IDiagnosticsBundleService
{
    Task<DiagnosticsBundleResult> WriteBundleAsync(
        DiagnosticsBundleRequest request,
        CancellationToken cancellationToken = default);
}
