package com.github.nullptroma.wallenc.domain.tasks

import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.CoroutineDispatcher
import java.util.UUID

interface ITaskOrchestrator {
    val pipelineState: StateFlow<PipelineState>
    val logLines: StateFlow<List<TaskLogLine>>
    val foregroundUi: StateFlow<TaskForegroundUiState>

    fun enqueue(
        title: String,
        dispatcher: CoroutineDispatcher,
        work: PipelineWork,
        busyStorageUuid: UUID? = null,
        locksVaultStorageList: Boolean = false,
    ): TaskId

    fun cancel(taskId: TaskId): Boolean

    fun cancelAll()

    /** Запись в общий лог пайплайна вне контекста [TaskContext] (например, WorkManager sync). */
    fun appendPipelineLog(level: TaskLogLevel, key: TaskLogKey)
}
