/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { ITask, TaskGraph } from "@workglow/task-graph"; import type { Dispatch, SetStateAction } from "react"; export interface CliTaskLine { readonly id: string; /** Task class type name. Identity for renderer dispatch — never shown to the user. */ readonly type: string; /** What the row displays: the instance's `title` when set, else {@link CliTaskLine.type}. */ readonly label: string; status: string; progress?: number; message?: string; } export interface CliLogLine { readonly id: number; readonly text: string; } /** * Two instances of one task class are two different jobs (downloading different * files, say), so rows are labelled by the instance's `title` — set per instance * via task config — and fall back to the class type name when there is none. */ export declare function cliTaskLabel(task: ITask): string; /** Per-index row for iterator tasks (MapTask, ReduceTask, …) shown under the parent task line. */ export interface IterationSlotRow { readonly index: number; status: "pending" | "running" | "completed"; /** 0–100 from `iteration_progress` (inner cloned graph). */ progress?: number; message?: string; /** Live clone for this iteration; render its tasks as ordinary rows. */ readonly graph?: TaskGraph; } /** * Map/Reduce children in the CLI: at most `concurrencyLimit` rows — the number * the iterator actually has in flight. Prefer currently-running iterations; * when fewer than the cap are running (including after the map finishes), fill * with the most recently completed so the tree is not an empty parent. */ export declare function visibleIterationSlots(slots: readonly IterationSlotRow[], concurrencyLimit: number | undefined): IterationSlotRow[]; /** * Above this iteration count we stop retaining a per-index slot array and track * only the currently-running iterations. A `.forEach()` over a worklist that can * be hundreds of thousands (or millions) of items long would otherwise (a) * allocate an N-length array and (b) copy it on every iteration event — O(N) per * event, O(N²) over the run — freezing the render thread. The parent task row * already shows overall progress and a "Map X/N" message (emitted by the * iterator's aggregate progress), so retaining completed/pending rows for huge * loops buys nothing. Small loops keep the full completed→running→pending view. */ export declare const FULL_SLOT_TRACKING_MAX = 200; /** Hard cap on running rows rendered/retained, independent of concurrency. */ export declare const MAX_RUNNING_ROWS = 64; /** * Overlay live clone graphs from the iterator onto event-driven slots. Nested * Maps often fire `iteration_start` before the CLI poll attaches listeners; * the iterator keeps those clones so a late row can still render them. */ export declare function mergeLiveIterationGraphs(slots: readonly IterationSlotRow[] | undefined, task: ITask): IterationSlotRow[]; export declare function registerIterationListeners(task: ITask, taskId: string, setIterationSlots: Dispatch>>): () => void; /** * Subscribes to per-task status/progress and aggregate graph progress for a {@link TaskGraph}. * Handles tasks added mid-run via `task_added`. */ export declare function subscribeTaskGraphForCli(graph: TaskGraph, setTaskInfos: Dispatch>>, setCompletedLogs: Dispatch> | undefined, setOverallProgress: Dispatch>, setIterationSlots?: Dispatch>>): () => void;