@workglow/task-graph 0.0.125 → 0.0.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bun.js.map CHANGED
@@ -1,48 +1,47 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/task/TaskTypes.ts", "../src/task-graph/Dataflow.ts", "../src/task-graph/GraphSchemaUtils.ts", "../src/task/TaskError.ts", "../src/storage/TaskOutputRepository.ts", "../src/task/InputResolver.ts", "../src/task/StreamTypes.ts", "../src/task/TaskRunner.ts", "../src/task/Task.ts", "../src/task/ConditionUtils.ts", "../src/task/ConditionalTask.ts", "../src/task-graph/TaskGraphScheduler.ts", "../src/task-graph/TaskGraphRunner.ts", "../src/task/GraphAsTaskRunner.ts", "../src/task/GraphAsTask.ts", "../src/task-graph/Conversions.ts", "../src/task-graph/TaskGraphEvents.ts", "../src/task-graph/TaskGraph.ts", "../src/common.ts", "../src/task-graph/GraphToWorkflowCode.ts", "../src/task-graph/Workflow.ts", "../src/task/index.ts", "../src/task/FallbackTask.ts", "../src/task/FallbackTaskRunner.ts", "../src/task/IteratorTask.ts", "../src/task/IteratorTaskRunner.ts", "../src/task/WhileTask.ts", "../src/task/WhileTaskRunner.ts", "../src/task/iterationSchema.ts", "../src/task/JobQueueFactory.ts", "../src/task/JobQueueTask.ts", "../src/task/TaskQueueRegistry.ts", "../src/task/MapTask.ts", "../src/task/ReduceTask.ts", "../src/task/TaskJSON.ts", "../src/task/TaskRegistry.ts", "../src/storage/TaskGraphRepository.ts", "../src/storage/TaskGraphTabularRepository.ts", "../src/storage/TaskOutputTabularRepository.ts"],
3
+ "sources": ["../src/task-graph/Dataflow.ts", "../src/task/TaskTypes.ts", "../src/task-graph/GraphSchemaUtils.ts", "../src/task-graph/TaskGraph.ts", "../src/task/GraphAsTask.ts", "../src/task-graph/TaskGraphRunner.ts", "../src/storage/TaskOutputRepository.ts", "../src/task/ConditionalTask.ts", "../src/task/ConditionUtils.ts", "../src/task/Task.ts", "../src/task/TaskError.ts", "../src/task/TaskRunner.ts", "../src/task/InputResolver.ts", "../src/task/StreamTypes.ts", "../src/task-graph/TaskGraphScheduler.ts", "../src/task/GraphAsTaskRunner.ts", "../src/task-graph/Conversions.ts", "../src/task-graph/TaskGraphEvents.ts", "../src/task-graph/Workflow.ts", "../src/task-graph/GraphToWorkflowCode.ts", "../src/task/FallbackTaskRunner.ts", "../src/task/FallbackTask.ts", "../src/task/IteratorTaskRunner.ts", "../src/task/IteratorTask.ts", "../src/task/WhileTaskRunner.ts", "../src/task/WhileTask.ts", "../src/task/iterationSchema.ts", "../src/task/JobQueueFactory.ts", "../src/task/JobQueueTask.ts", "../src/task/TaskQueueRegistry.ts", "../src/task/MapTask.ts", "../src/task/ReduceTask.ts", "../src/task/TaskRegistry.ts", "../src/task/TaskJSON.ts", "../src/task/index.ts", "../src/storage/TaskGraphRepository.ts", "../src/storage/TaskGraphTabularRepository.ts", "../src/storage/TaskOutputTabularRepository.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { type DataPortSchema, type FromSchema, StripJSONSchema } from \"@workglow/util/schema\";\nimport type { Task } from \"./Task\";\n\n/**\n * Enum representing the possible states of a task\n *\n * PENDING -> PROCESSING -> COMPLETED\n * PENDING -> PROCESSING -> STREAMING -> COMPLETED\n * PENDING -> PROCESSING -> ABORTING -> FAILED\n * PENDING -> PROCESSING -> FAILED\n * PENDING -> DISABLED\n */\nexport type TaskStatus =\n | \"PENDING\"\n | \"DISABLED\"\n | \"PROCESSING\"\n | \"STREAMING\"\n | \"COMPLETED\"\n | \"ABORTING\"\n | \"FAILED\";\n\nexport const TaskStatus = {\n /** Task is created but not yet started */\n PENDING: \"PENDING\",\n /** Task is disabled due to conditional logic */\n DISABLED: \"DISABLED\",\n /** Task is currently running */\n PROCESSING: \"PROCESSING\",\n /** Task has begun producing streaming output chunks */\n STREAMING: \"STREAMING\",\n /** Task has completed successfully */\n COMPLETED: \"COMPLETED\",\n /** Task is in the process of being aborted */\n ABORTING: \"ABORTING\",\n /** Task has failed */\n FAILED: \"FAILED\",\n} as const satisfies Record<TaskStatus, TaskStatus>;\n\n// ========================================================================\n// Core Task Data Types\n// ========================================================================\n\nexport interface DataPorts extends StripJSONSchema<Record<string, any>> {\n [key: string]: unknown;\n}\n\n/** Type for task input data */\nexport type TaskInput = DataPorts;\n\n/** Type for task output data */\nexport type TaskOutput = DataPorts;\n\nexport type CompoundTaskOutput =\n | {\n outputs: TaskOutput[];\n }\n | {\n [key: string]: unknown | unknown[] | undefined;\n };\n\n/** Type for task type names */\nexport type TaskTypeName = string;\n\n// ========================================================================\n// Task Configuration Schema and Types\n// ========================================================================\n\n/**\n * Base JSON Schema for task configuration.\n * Exported so subclasses can compose their own schema with:\n * `...TaskConfigSchema[\"properties\"]`\n *\n * Fields:\n * - id: unique task identifier (any type)\n * - title: human-readable name for the task instance (overrides static title)\n * - description: human-readable description (overrides static description)\n * - cacheable: design-time cache flag (runtime override goes in IRunConfig)\n * - inputSchema: dynamic input schema override (for tasks like InputTask)\n * - outputSchema: dynamic output schema override (for tasks like OutputTask)\n * - extras: arbitrary user data serialized with the task JSON\n * - timeout: max execution time in milliseconds (auto-aborts with TaskTimeoutError)\n */\nexport const TaskConfigSchema = {\n type: \"object\",\n properties: {\n id: {\n \"x-ui-hidden\": true,\n },\n title: { type: \"string\" },\n description: { type: \"string\" },\n cacheable: { type: \"boolean\" },\n timeout: { type: \"number\", description: \"Max execution time in milliseconds\" },\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n outputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n extras: {\n type: \"object\",\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\ntype BaseFromSchema = FromSchema<typeof TaskConfigSchema>;\n\n/**\n * Base type for task configuration, derived from TaskConfigSchema.\n * Use `TaskConfigSchema` when building JSON schemas in subclasses.\n * Use this type when declaring the Config generic parameter.\n */\nexport type TaskConfig = Omit<BaseFromSchema, \"id\" | \"inputSchema\" | \"outputSchema\"> & {\n /** Unique identifier for the task (uuid4 by default) */\n id?: unknown;\n /** Dynamic input schema override for the task instance */\n inputSchema?: DataPortSchema;\n /** Dynamic output schema override for the task instance */\n outputSchema?: DataPortSchema;\n};\n\n/** Type for task ID */\nexport type TaskIdType = Task<TaskInput, TaskOutput, TaskConfig>[\"config\"][\"id\"];\n",
6
5
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { areSemanticallyCompatible } from \"@workglow/util/schema\";\nimport { EventEmitter } from \"@workglow/util\";\nimport { type StreamEvent } from \"../task/StreamTypes\";\nimport { TaskError } from \"../task/TaskError\";\nimport { DataflowJson } from \"../task/TaskJSON\";\nimport { TaskIdType, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport {\n DataflowEventListener,\n DataflowEventListeners,\n DataflowEventParameters,\n DataflowEvents,\n} from \"./DataflowEvents\";\nimport { TaskGraph } from \"./TaskGraph\";\n\nexport type DataflowIdType = `${string}[${string}] ==> ${string}[${string}]`;\n\nexport const DATAFLOW_ALL_PORTS = \"*\";\nexport const DATAFLOW_ERROR_PORT = \"[error]\";\n\n/**\n * Represents a data flow between two tasks, indicating how one task's output is used as input for another task\n */\nexport class Dataflow {\n constructor(\n public sourceTaskId: TaskIdType,\n public sourceTaskPortId: string,\n public targetTaskId: TaskIdType,\n public targetTaskPortId: string\n ) {}\n public static createId(\n sourceTaskId: TaskIdType,\n sourceTaskPortId: string,\n targetTaskId: TaskIdType,\n targetTaskPortId: string\n ): DataflowIdType {\n return `${sourceTaskId}[${sourceTaskPortId}] ==> ${targetTaskId}[${targetTaskPortId}]`;\n }\n get id(): DataflowIdType {\n return Dataflow.createId(\n this.sourceTaskId,\n this.sourceTaskPortId,\n this.targetTaskId,\n this.targetTaskPortId\n );\n }\n public value: any = undefined;\n public status: TaskStatus = TaskStatus.PENDING;\n public error: TaskError | undefined;\n\n /**\n * Active stream for this dataflow edge.\n * Set when a streaming upstream task begins producing chunks.\n * Multiple downstream consumers can each get an independent reader via tee().\n */\n public stream: ReadableStream<StreamEvent> | undefined = undefined;\n\n /**\n * Sets the active stream on this dataflow.\n * @param stream The ReadableStream of StreamEvents from the upstream task\n */\n public setStream(stream: ReadableStream<StreamEvent>): void {\n this.stream = stream;\n }\n\n /**\n * Gets the active stream from this dataflow, or undefined if not streaming.\n */\n public getStream(): ReadableStream<StreamEvent> | undefined {\n return this.stream;\n }\n\n /**\n * Consumes the active stream to completion and materializes the value.\n *\n * Accumulation of text-delta chunks is the responsibility of the **source\n * task** (via TaskRunner.executeStreamingTask when shouldAccumulate=true).\n * When accumulation is needed the source task emits an enriched finish event\n * that carries the fully-assembled port data. All downstream edges share that\n * enriched event through tee'd ReadableStreams, so no edge needs to\n * re-accumulate independently.\n *\n * This method therefore only reads snapshot and finish events:\n * - **snapshot**: used for replace-mode tasks that emit incremental snapshots.\n * - **finish**: the primary materialization path; carries complete data when\n * the source task accumulated, or provider-level data otherwise.\n * - text-delta / object-delta: ignored here (handled by source task).\n *\n * After consumption the stream reference is cleared. Calling this method on\n * a dataflow that has no stream is a no-op.\n */\n public async awaitStreamValue(): Promise<void> {\n if (!this.stream) return;\n\n const reader = this.stream.getReader();\n let lastSnapshotData: any = undefined;\n let finishData: any = undefined;\n let streamError: Error | undefined;\n\n try {\n while (true) {\n const { done, value: event } = await reader.read();\n if (done) break;\n\n switch (event.type) {\n case \"snapshot\":\n lastSnapshotData = event.data;\n break;\n case \"finish\":\n finishData = event.data;\n break;\n case \"error\":\n streamError = event.error;\n break;\n // text-delta, object-delta: source task handles accumulation\n }\n }\n } finally {\n reader.releaseLock();\n this.stream = undefined;\n }\n\n if (streamError) {\n this.error = streamError as TaskError;\n this.setStatus(TaskStatus.FAILED);\n throw streamError;\n }\n\n // Priority: snapshot > finish.\n // The source task enriches the finish event with accumulated text when\n // shouldAccumulate=true, so finishData carries complete port data.\n if (lastSnapshotData !== undefined) {\n this.setPortData(lastSnapshotData);\n } else if (finishData !== undefined) {\n this.setPortData(finishData);\n }\n }\n\n public reset() {\n this.status = TaskStatus.PENDING;\n this.error = undefined;\n this.value = undefined;\n this.stream = undefined;\n this.emit(\"reset\");\n this.emit(\"status\", this.status);\n }\n\n public setStatus(status: TaskStatus) {\n if (status === this.status) return;\n this.status = status;\n switch (status) {\n case TaskStatus.PROCESSING:\n this.emit(\"start\");\n break;\n case TaskStatus.STREAMING:\n this.emit(\"streaming\");\n break;\n case TaskStatus.COMPLETED:\n this.emit(\"complete\");\n break;\n case TaskStatus.ABORTING:\n this.emit(\"abort\");\n break;\n case TaskStatus.PENDING:\n this.emit(\"reset\");\n break;\n case TaskStatus.FAILED:\n this.emit(\"error\", this.error!);\n break;\n case TaskStatus.DISABLED:\n this.emit(\"disabled\");\n break;\n }\n this.emit(\"status\", this.status);\n }\n\n setPortData(entireDataBlock: any) {\n if (this.sourceTaskPortId === DATAFLOW_ALL_PORTS) {\n this.value = entireDataBlock;\n } else if (this.sourceTaskPortId === DATAFLOW_ERROR_PORT) {\n this.error = entireDataBlock;\n } else {\n this.value = entireDataBlock[this.sourceTaskPortId];\n }\n }\n\n getPortData(): TaskOutput {\n let result: TaskOutput;\n if (this.targetTaskPortId === DATAFLOW_ALL_PORTS) {\n result = this.value;\n } else if (this.targetTaskPortId === DATAFLOW_ERROR_PORT) {\n result = { [DATAFLOW_ERROR_PORT]: this.error };\n } else {\n result = { [this.targetTaskPortId]: this.value };\n }\n return result;\n }\n\n toJSON(): DataflowJson {\n return {\n sourceTaskId: this.sourceTaskId,\n sourceTaskPortId: this.sourceTaskPortId,\n targetTaskId: this.targetTaskId,\n targetTaskPortId: this.targetTaskPortId,\n };\n }\n\n semanticallyCompatible(\n graph: TaskGraph,\n dataflow: Dataflow\n ): \"static\" | \"runtime\" | \"incompatible\" {\n // TODO(str): this is inefficient\n const targetSchema = graph.getTask(dataflow.targetTaskId)!.inputSchema();\n const sourceSchema = graph.getTask(dataflow.sourceTaskId)!.outputSchema();\n\n if (typeof targetSchema === \"boolean\") {\n if (targetSchema === false) {\n return \"incompatible\";\n }\n return \"static\";\n }\n if (typeof sourceSchema === \"boolean\") {\n if (sourceSchema === false) {\n return \"incompatible\";\n }\n return \"runtime\";\n }\n\n let targetSchemaProperty =\n DATAFLOW_ALL_PORTS === dataflow.targetTaskPortId\n ? true // Accepts any schema (equivalent to Type.Any())\n : (targetSchema.properties as any)?.[dataflow.targetTaskPortId];\n // If the specific property doesn't exist but additionalProperties is true,\n // treat it as accepting any schema\n if (targetSchemaProperty === undefined && targetSchema.additionalProperties === true) {\n targetSchemaProperty = true;\n }\n let sourceSchemaProperty =\n DATAFLOW_ALL_PORTS === dataflow.sourceTaskPortId\n ? true // Accepts any schema (equivalent to Type.Any())\n : (sourceSchema.properties as any)?.[dataflow.sourceTaskPortId];\n // If the specific property doesn't exist but additionalProperties is true,\n // treat it as outputting any schema\n if (sourceSchemaProperty === undefined && sourceSchema.additionalProperties === true) {\n sourceSchemaProperty = true;\n }\n\n const semanticallyCompatible = areSemanticallyCompatible(\n sourceSchemaProperty,\n targetSchemaProperty\n );\n\n return semanticallyCompatible;\n }\n\n // ========================================================================\n // Event handling methods\n // ========================================================================\n\n /**\n * Event emitter for dataflow events\n */\n public get events(): EventEmitter<DataflowEventListeners> {\n if (!this._events) {\n this._events = new EventEmitter<DataflowEventListeners>();\n }\n return this._events;\n }\n protected _events: EventEmitter<DataflowEventListeners> | undefined;\n\n public subscribe<Event extends DataflowEvents>(\n name: Event,\n fn: DataflowEventListener<Event>\n ): () => void {\n return this.events.subscribe(name, fn);\n }\n\n /**\n * Registers an event listener\n */\n public on<Event extends DataflowEvents>(name: Event, fn: DataflowEventListener<Event>): void {\n this.events.on(name, fn);\n }\n\n /**\n * Removes an event listener\n */\n public off<Event extends DataflowEvents>(name: Event, fn: DataflowEventListener<Event>): void {\n this.events.off(name, fn);\n }\n\n /**\n * Registers a one-time event listener\n */\n public once<Event extends DataflowEvents>(name: Event, fn: DataflowEventListener<Event>): void {\n this.events.once(name, fn);\n }\n\n /**\n * Returns a promise that resolves when the specified event is emitted\n */\n public waitOn<Event extends DataflowEvents>(\n name: Event\n ): Promise<DataflowEventParameters<Event>> {\n return this.events.waitOn(name) as Promise<DataflowEventParameters<Event>>;\n }\n\n /**\n * Emits an event\n */\n public emit<Event extends DataflowEvents>(\n name: Event,\n ...args: DataflowEventParameters<Event>\n ): void {\n this._events?.emit(name, ...args);\n }\n}\n\n/**\n * Represents a data flow between two tasks, indicating how one task's output is used as input for another task\n *\n * This is a helper class that parses a data flow id string into a Dataflow object\n *\n * @param dataflow - The data flow string, e.g. \"sourceTaskId[sourceTaskPortId] ==> targetTaskId[targetTaskPortId]\"\n */\nexport class DataflowArrow extends Dataflow {\n constructor(dataflow: DataflowIdType) {\n // Parse the dataflow string using regex\n const pattern =\n /^([a-zA-Z0-9-]+?)\\[([a-zA-Z0-9-]+?)\\] ==> ([a-zA-Z0-9-]+?)\\[([a-zA-Z0-9-]+?)\\]$/;\n const match = dataflow.match(pattern);\n\n if (!match) {\n throw new Error(`Invalid dataflow format: ${dataflow}`);\n }\n\n const [, sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId] = match;\n super(sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId);\n }\n}\n",
6
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { type DataPortSchema, type FromSchema, StripJSONSchema } from \"@workglow/util/schema\";\nimport type { Task } from \"./Task\";\n\n/**\n * Enum representing the possible states of a task\n *\n * PENDING -> PROCESSING -> COMPLETED\n * PENDING -> PROCESSING -> STREAMING -> COMPLETED\n * PENDING -> PROCESSING -> ABORTING -> FAILED\n * PENDING -> PROCESSING -> FAILED\n * PENDING -> DISABLED\n */\nexport type TaskStatus =\n | \"PENDING\"\n | \"DISABLED\"\n | \"PROCESSING\"\n | \"STREAMING\"\n | \"COMPLETED\"\n | \"ABORTING\"\n | \"FAILED\";\n\nexport const TaskStatus = {\n /** Task is created but not yet started */\n PENDING: \"PENDING\",\n /** Task is disabled due to conditional logic */\n DISABLED: \"DISABLED\",\n /** Task is currently running */\n PROCESSING: \"PROCESSING\",\n /** Task has begun producing streaming output chunks */\n STREAMING: \"STREAMING\",\n /** Task has completed successfully */\n COMPLETED: \"COMPLETED\",\n /** Task is in the process of being aborted */\n ABORTING: \"ABORTING\",\n /** Task has failed */\n FAILED: \"FAILED\",\n} as const satisfies Record<TaskStatus, TaskStatus>;\n\n// ========================================================================\n// Core Task Data Types\n// ========================================================================\n\nexport interface DataPorts extends StripJSONSchema<Record<string, any>> {\n [key: string]: unknown;\n}\n\n/** Type for task input data */\nexport type TaskInput = DataPorts;\n\n/** Type for task output data */\nexport type TaskOutput = DataPorts;\n\nexport type CompoundTaskOutput =\n | {\n outputs: TaskOutput[];\n }\n | {\n [key: string]: unknown | unknown[] | undefined;\n };\n\n/** Type for task type names */\nexport type TaskTypeName = string;\n\n// ========================================================================\n// Task Configuration Schema and Types\n// ========================================================================\n\n/**\n * Base JSON Schema for task configuration.\n * Exported so subclasses can compose their own schema with:\n * `...TaskConfigSchema[\"properties\"]`\n *\n * Fields:\n * - id: unique task identifier (any type)\n * - title: human-readable name for the task instance (overrides static title)\n * - description: human-readable description (overrides static description)\n * - cacheable: design-time cache flag (runtime override goes in IRunConfig)\n * - inputSchema: dynamic input schema override (for tasks like InputTask)\n * - outputSchema: dynamic output schema override (for tasks like OutputTask)\n * - extras: arbitrary user data serialized with the task JSON\n * - timeout: max execution time in milliseconds (auto-aborts with TaskTimeoutError)\n */\nexport const TaskConfigSchema = {\n type: \"object\",\n properties: {\n id: {\n \"x-ui-hidden\": true,\n },\n title: { type: \"string\" },\n description: { type: \"string\" },\n cacheable: { type: \"boolean\" },\n timeout: { type: \"number\", description: \"Max execution time in milliseconds\" },\n inputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n outputSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n extras: {\n type: \"object\",\n additionalProperties: true,\n \"x-ui-hidden\": true,\n },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\ntype BaseFromSchema = FromSchema<typeof TaskConfigSchema>;\n\n/**\n * Base type for task configuration, derived from TaskConfigSchema.\n * Use `TaskConfigSchema` when building JSON schemas in subclasses.\n * Use this type when declaring the Config generic parameter.\n */\nexport type TaskConfig = Omit<BaseFromSchema, \"id\" | \"inputSchema\" | \"outputSchema\"> & {\n /** Unique identifier for the task (uuid4 by default) */\n id?: unknown;\n /** Dynamic input schema override for the task instance */\n inputSchema?: DataPortSchema;\n /** Dynamic output schema override for the task instance */\n outputSchema?: DataPortSchema;\n};\n\n/** Type for task ID */\nexport type TaskIdType = Task<TaskInput, TaskOutput, TaskConfig>[\"config\"][\"id\"];\n",
7
7
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { uuid4 } from \"@workglow/util\";\nimport { DATAFLOW_ALL_PORTS } from \"./Dataflow\";\nimport type { TaskGraph } from \"./TaskGraph\";\nimport type { TaskIdType } from \"../task/TaskTypes\";\nimport type {\n DataflowJson,\n JsonTaskItem,\n TaskGraphItemJson,\n TaskGraphJson,\n} from \"../task/TaskJSON\";\n\nexport interface GraphSchemaOptions {\n /**\n * When true, annotate each property with `x-source-task-id` or `x-source-task-ids`\n * to identify which task(s) the property originates from.\n */\n readonly trackOrigins?: boolean;\n}\n\n/**\n * Calculates the depth (longest path from any starting node) for each task in the graph.\n * @returns A map of task IDs to their depths\n */\nexport function calculateNodeDepths(graph: TaskGraph): Map<TaskIdType, number> {\n const depths = new Map<TaskIdType, number>();\n const tasks = graph.getTasks();\n\n // Initialize all depths to 0\n for (const task of tasks) {\n depths.set(task.id, 0);\n }\n\n // Use topological sort to calculate depths in order\n const sortedTasks = graph.topologicallySortedNodes();\n\n for (const task of sortedTasks) {\n const currentDepth = depths.get(task.id) || 0;\n const targetTasks = graph.getTargetTasks(task.id);\n\n // Update depths of all target tasks\n for (const targetTask of targetTasks) {\n const targetDepth = depths.get(targetTask.id) || 0;\n depths.set(targetTask.id, Math.max(targetDepth, currentDepth + 1));\n }\n }\n\n return depths;\n}\n\n/**\n * Computes the input schema for a graph by examining root tasks (no incoming edges)\n * and non-root tasks with unsatisfied required inputs.\n *\n * When `options.trackOrigins` is true, each property is annotated with\n * `x-source-task-id` (single origin) or `x-source-task-ids` (multiple origins).\n */\nexport function computeGraphInputSchema(\n graph: TaskGraph,\n options?: GraphSchemaOptions\n): DataPortSchema {\n const trackOrigins = options?.trackOrigins ?? false;\n const properties: Record<string, any> = {};\n const required: string[] = [];\n // Track which task IDs contribute each property name\n const propertyOrigins: Record<string, TaskIdType[]> = {};\n\n // Get all tasks in the graph\n const tasks = graph.getTasks();\n\n // Identify starting nodes: tasks with no incoming dataflows\n const startingNodes = tasks.filter((task) => graph.getSourceDataflows(task.id).length === 0);\n\n // Collect all properties from root tasks\n for (const task of startingNodes) {\n const taskInputSchema = task.inputSchema();\n if (typeof taskInputSchema === \"boolean\") {\n if (taskInputSchema === false) {\n continue;\n }\n if (taskInputSchema === true) {\n properties[DATAFLOW_ALL_PORTS] = {};\n continue;\n }\n }\n const taskProperties = taskInputSchema.properties || {};\n\n for (const [inputName, inputProp] of Object.entries(taskProperties)) {\n if (!properties[inputName]) {\n properties[inputName] = inputProp;\n\n if (taskInputSchema.required && taskInputSchema.required.includes(inputName)) {\n required.push(inputName);\n }\n\n if (trackOrigins) {\n propertyOrigins[inputName] = [task.id];\n }\n } else if (trackOrigins) {\n propertyOrigins[inputName].push(task.id);\n }\n }\n }\n\n // For non-root tasks, collect only REQUIRED properties not satisfied by dataflows.\n const sourceIds = new Set(startingNodes.map((t) => t.id));\n for (const task of tasks) {\n if (sourceIds.has(task.id)) continue;\n\n const taskInputSchema = task.inputSchema();\n if (typeof taskInputSchema === \"boolean\") continue;\n\n const requiredKeys = new Set<string>((taskInputSchema.required as string[] | undefined) || []);\n if (requiredKeys.size === 0) continue;\n\n const connectedPorts = new Set(\n graph.getSourceDataflows(task.id).map((df) => df.targetTaskPortId)\n );\n\n for (const key of requiredKeys) {\n if (connectedPorts.has(key)) continue;\n if (properties[key]) {\n // Property already collected — track additional origin\n if (trackOrigins) {\n propertyOrigins[key].push(task.id);\n }\n continue;\n }\n\n // Skip if the task already has a default value for this property\n if (task.defaults && task.defaults[key] !== undefined) continue;\n\n const prop = (taskInputSchema.properties || {})[key];\n if (!prop || typeof prop === \"boolean\") continue;\n\n properties[key] = prop;\n if (!required.includes(key)) {\n required.push(key);\n }\n\n if (trackOrigins) {\n propertyOrigins[key] = [task.id];\n }\n }\n }\n\n // Apply origin annotations\n if (trackOrigins) {\n for (const [propName, origins] of Object.entries(propertyOrigins)) {\n const prop = properties[propName];\n if (!prop || typeof prop === \"boolean\") continue;\n if (origins.length === 1) {\n properties[propName] = { ...prop, \"x-source-task-id\": origins[0] };\n } else {\n properties[propName] = { ...prop, \"x-source-task-ids\": origins };\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n}\n\n/**\n * Computes the output schema for a graph by examining leaf tasks (no outgoing edges)\n * at the maximum depth level.\n *\n * When `options.trackOrigins` is true, each property is annotated with\n * `x-source-task-id` (single origin) or `x-source-task-ids` (multiple origins).\n */\nexport function computeGraphOutputSchema(\n graph: TaskGraph,\n options?: GraphSchemaOptions\n): DataPortSchema {\n const trackOrigins = options?.trackOrigins ?? false;\n const properties: Record<string, any> = {};\n const required: string[] = [];\n // Track which task IDs contribute each property name\n const propertyOrigins: Record<string, TaskIdType[]> = {};\n\n // Find all ending nodes (nodes with no outgoing dataflows)\n const tasks = graph.getTasks();\n const endingNodes = tasks.filter((task) => graph.getTargetDataflows(task.id).length === 0);\n\n // Calculate depths for all nodes\n const depths = calculateNodeDepths(graph);\n\n // Find the maximum depth among ending nodes\n const maxDepth = Math.max(...endingNodes.map((task) => depths.get(task.id) || 0));\n\n // Filter ending nodes to only those at the maximum depth (last level)\n const lastLevelNodes = endingNodes.filter((task) => depths.get(task.id) === maxDepth);\n\n // Count how many ending nodes produce each property\n const propertyCount: Record<string, number> = {};\n const propertySchema: Record<string, any> = {};\n\n for (const task of lastLevelNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") {\n if (taskOutputSchema === false) {\n continue;\n }\n if (taskOutputSchema === true) {\n properties[DATAFLOW_ALL_PORTS] = {};\n continue;\n }\n }\n const taskProperties = taskOutputSchema.properties || {};\n\n for (const [outputName, outputProp] of Object.entries(taskProperties)) {\n propertyCount[outputName] = (propertyCount[outputName] || 0) + 1;\n if (!propertySchema[outputName]) {\n propertySchema[outputName] = outputProp;\n }\n if (trackOrigins) {\n if (!propertyOrigins[outputName]) {\n propertyOrigins[outputName] = [task.id];\n } else {\n propertyOrigins[outputName].push(task.id);\n }\n }\n }\n }\n\n // Build the final schema: properties produced by multiple nodes become arrays\n for (const [outputName] of Object.entries(propertyCount)) {\n const outputProp = propertySchema[outputName];\n\n if (lastLevelNodes.length === 1) {\n properties[outputName] = outputProp;\n } else {\n properties[outputName] = {\n type: \"array\",\n items: outputProp as any,\n };\n }\n }\n\n // Apply origin annotations\n if (trackOrigins) {\n for (const [propName, origins] of Object.entries(propertyOrigins)) {\n const prop = properties[propName];\n if (!prop || typeof prop === \"boolean\") continue;\n if (origins.length === 1) {\n properties[propName] = { ...prop, \"x-source-task-id\": origins[0] };\n } else {\n properties[propName] = { ...prop, \"x-source-task-ids\": origins };\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties: false,\n } as DataPortSchema;\n}\n\n// ========================================================================\n// Boundary Node Injection\n// ========================================================================\n\n/**\n * Strips `x-source-task-id` and `x-source-task-ids` annotations from schema properties.\n */\nfunction stripOriginAnnotations(schema: DataPortSchema): DataPortSchema {\n if (typeof schema === \"boolean\" || !schema || typeof schema !== \"object\") return schema;\n const properties = schema.properties;\n if (!properties) return schema;\n\n const strippedProperties: Record<string, any> = {};\n for (const [key, prop] of Object.entries(properties)) {\n if (!prop || typeof prop !== \"object\") {\n strippedProperties[key] = prop;\n continue;\n }\n const {\n \"x-source-task-id\": _id,\n \"x-source-task-ids\": _ids,\n ...rest\n } = prop as Record<string, any>;\n strippedProperties[key] = rest;\n }\n\n return { ...schema, properties: strippedProperties } as DataPortSchema;\n}\n\n/**\n * Extracts origin task IDs from a schema property's `x-source-task-id` or `x-source-task-ids`.\n */\nfunction getOriginTaskIds(prop: Record<string, any>): TaskIdType[] {\n if (prop[\"x-source-task-ids\"]) {\n return prop[\"x-source-task-ids\"] as TaskIdType[];\n }\n if (prop[\"x-source-task-id\"] !== undefined) {\n return [prop[\"x-source-task-id\"] as TaskIdType];\n }\n return [];\n}\n\n/**\n * Adds synthetic InputTask and OutputTask boundary nodes to a TaskGraphJson.\n * The boundary nodes represent the graph's external interface.\n *\n * InputTask is placed first in the tasks array, OutputTask last.\n * Per-property dataflows connect them to the origin tasks using origin tracking annotations.\n */\nexport function addBoundaryNodesToGraphJson(json: TaskGraphJson, graph: TaskGraph): TaskGraphJson {\n const hasInputTask = json.tasks.some((t) => t.type === \"InputTask\");\n const hasOutputTask = json.tasks.some((t) => t.type === \"OutputTask\");\n\n // Skip entirely if both boundary tasks already exist\n if (hasInputTask && hasOutputTask) {\n return json;\n }\n\n const inputSchema = !hasInputTask\n ? computeGraphInputSchema(graph, { trackOrigins: true })\n : undefined;\n const outputSchema = !hasOutputTask\n ? computeGraphOutputSchema(graph, { trackOrigins: true })\n : undefined;\n\n const prependTasks: TaskGraphItemJson[] = [];\n const appendTasks: TaskGraphItemJson[] = [];\n const inputDataflows: DataflowJson[] = [];\n const outputDataflows: DataflowJson[] = [];\n\n if (!hasInputTask && inputSchema) {\n const inputTaskId = uuid4();\n const strippedInputSchema = stripOriginAnnotations(inputSchema);\n\n prependTasks.push({\n id: inputTaskId,\n type: \"InputTask\",\n config: {\n inputSchema: strippedInputSchema,\n outputSchema: strippedInputSchema,\n },\n });\n\n // Create per-property dataflows from InputTask to origin tasks\n if (typeof inputSchema !== \"boolean\" && inputSchema.properties) {\n for (const [propName, prop] of Object.entries(inputSchema.properties)) {\n if (!prop || typeof prop === \"boolean\") continue;\n const origins = getOriginTaskIds(prop as Record<string, any>);\n for (const originId of origins) {\n inputDataflows.push({\n sourceTaskId: inputTaskId,\n sourceTaskPortId: propName,\n targetTaskId: originId,\n targetTaskPortId: propName,\n });\n }\n }\n }\n }\n\n if (!hasOutputTask && outputSchema) {\n const outputTaskId = uuid4();\n const strippedOutputSchema = stripOriginAnnotations(outputSchema);\n\n appendTasks.push({\n id: outputTaskId,\n type: \"OutputTask\",\n config: {\n inputSchema: strippedOutputSchema,\n outputSchema: strippedOutputSchema,\n },\n });\n\n // Create per-property dataflows from origin tasks to OutputTask\n if (typeof outputSchema !== \"boolean\" && outputSchema.properties) {\n for (const [propName, prop] of Object.entries(outputSchema.properties)) {\n if (!prop || typeof prop === \"boolean\") continue;\n const origins = getOriginTaskIds(prop as Record<string, any>);\n for (const originId of origins) {\n outputDataflows.push({\n sourceTaskId: originId,\n sourceTaskPortId: propName,\n targetTaskId: outputTaskId,\n targetTaskPortId: propName,\n });\n }\n }\n }\n }\n\n return {\n tasks: [...prependTasks, ...json.tasks, ...appendTasks],\n dataflows: [...inputDataflows, ...json.dataflows, ...outputDataflows],\n };\n}\n\n/**\n * Adds synthetic InputTask and OutputTask boundary nodes to a dependency JSON items array.\n * Per-property dependencies connect them to the origin tasks using origin tracking annotations.\n */\nexport function addBoundaryNodesToDependencyJson(\n items: JsonTaskItem[],\n graph: TaskGraph\n): JsonTaskItem[] {\n const hasInputTask = items.some((t) => t.type === \"InputTask\");\n const hasOutputTask = items.some((t) => t.type === \"OutputTask\");\n\n // Skip entirely if both boundary tasks already exist\n if (hasInputTask && hasOutputTask) {\n return items;\n }\n\n const prependItems: JsonTaskItem[] = [];\n const appendItems: JsonTaskItem[] = [];\n\n if (!hasInputTask) {\n const inputSchema = computeGraphInputSchema(graph, { trackOrigins: true });\n const inputTaskId = uuid4();\n const strippedInputSchema = stripOriginAnnotations(inputSchema);\n\n prependItems.push({\n id: inputTaskId,\n type: \"InputTask\",\n config: {\n inputSchema: strippedInputSchema,\n outputSchema: strippedInputSchema,\n },\n });\n\n // Build dependencies for items that receive data from InputTask\n if (typeof inputSchema !== \"boolean\" && inputSchema.properties) {\n for (const [propName, prop] of Object.entries(inputSchema.properties)) {\n if (!prop || typeof prop === \"boolean\") continue;\n const origins = getOriginTaskIds(prop as Record<string, any>);\n for (const originId of origins) {\n const targetItem = items.find((item) => item.id === originId);\n if (!targetItem) continue;\n if (!targetItem.dependencies) {\n targetItem.dependencies = {};\n }\n const existing = targetItem.dependencies[propName];\n const dep = { id: inputTaskId, output: propName };\n if (!existing) {\n targetItem.dependencies[propName] = dep;\n } else if (Array.isArray(existing)) {\n existing.push(dep);\n } else {\n targetItem.dependencies[propName] = [existing, dep];\n }\n }\n }\n }\n }\n\n if (!hasOutputTask) {\n const outputSchema = computeGraphOutputSchema(graph, { trackOrigins: true });\n const outputTaskId = uuid4();\n const strippedOutputSchema = stripOriginAnnotations(outputSchema);\n\n // Build dependencies for OutputTask from origin tasks\n const outputDependencies: JsonTaskItem[\"dependencies\"] = {};\n if (typeof outputSchema !== \"boolean\" && outputSchema.properties) {\n for (const [propName, prop] of Object.entries(outputSchema.properties)) {\n if (!prop || typeof prop === \"boolean\") continue;\n const origins = getOriginTaskIds(prop as Record<string, any>);\n if (origins.length === 1) {\n outputDependencies[propName] = { id: origins[0], output: propName };\n } else if (origins.length > 1) {\n outputDependencies[propName] = origins.map((id) => ({ id, output: propName }));\n }\n }\n }\n\n appendItems.push({\n id: outputTaskId,\n type: \"OutputTask\",\n config: {\n inputSchema: strippedOutputSchema,\n outputSchema: strippedOutputSchema,\n },\n ...(Object.keys(outputDependencies).length > 0 ? { dependencies: outputDependencies } : {}),\n });\n }\n\n return [...prependItems, ...items, ...appendItems];\n}\n",
8
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { JobError } from \"@workglow/job-queue\";\nimport { BaseError } from \"@workglow/util\";\n\nexport class TaskError extends BaseError {\n static readonly type: string = \"TaskError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task configuration error\n *\n */\nexport class TaskConfigurationError extends TaskError {\n static readonly type: string = \"TaskConfigurationError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task workflow error\n */\nexport class WorkflowError extends TaskError {\n static readonly type: string = \"WorkflowError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by a task being aborted\n *\n * Examples: task.abort() was called, or some other reason an abort signal was received\n */\nexport class TaskAbortedError extends TaskError {\n static readonly type: string = \"TaskAbortedError\";\n constructor(message: string = \"Task aborted\") {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by a task exceeding its timeout\n *\n * Examples: task.runConfig.timeout exceeded during execution\n */\nexport class TaskTimeoutError extends TaskAbortedError {\n static readonly type: string = \"TaskTimeoutError\";\n constructor(timeoutMs?: number) {\n super(timeoutMs ? `Task timed out after ${timeoutMs}ms` : \"Task timed out\");\n }\n}\n\n/**\n * A task error that is caused by a task failing\n *\n * Examples: task.run() threw an error\n */\nexport class TaskFailedError extends TaskError {\n static readonly type: string = \"TaskFailedError\";\n constructor(message: string = \"Task failed\") {\n super(message);\n }\n}\n\nexport class JobTaskFailedError extends TaskFailedError {\n static readonly type: string = \"JobTaskFailedError\";\n public jobError: JobError;\n constructor(err: JobError) {\n super(String(err));\n this.jobError = err;\n }\n}\n\n/**\n * A task error that is caused by an error converting JSON to a Task\n */\nexport class TaskJSONError extends TaskError {\n static readonly type: string = \"TaskJSONError\";\n constructor(message: string = \"Error converting JSON to a Task\") {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by invalid input data\n *\n * Examples: task.run() received invalid input data\n */\nexport class TaskInvalidInputError extends TaskError {\n static readonly type: string = \"TaskInvalidInputError\";\n constructor(message: string = \"Invalid input data\") {\n super(message);\n }\n}\n",
8
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DirectedAcyclicGraph } from \"@workglow/util/graph\";\nimport { EventEmitter, ServiceRegistry, uuid4 } from \"@workglow/util\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { ITask } from \"../task/ITask\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport type { TaskIdType, TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { ensureTask, type PipeFunction } from \"./Conversions\";\nimport { Dataflow, type DataflowIdType } from \"./Dataflow\";\nimport { addBoundaryNodesToDependencyJson, addBoundaryNodesToGraphJson } from \"./GraphSchemaUtils\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport {\n EventTaskGraphToDagMapping,\n GraphEventDagEvents,\n GraphEventDagParameters,\n TaskGraphEventListener,\n TaskGraphEvents,\n TaskGraphEventStatusParameters,\n TaskGraphStatusEvents,\n TaskGraphStatusListeners,\n} from \"./TaskGraphEvents\";\nimport {\n CompoundMergeStrategy,\n GraphResult,\n type GraphResultArray,\n TaskGraphRunner,\n} from \"./TaskGraphRunner\";\n\n/**\n * Configuration for running a task graph\n */\nexport interface TaskGraphRunConfig {\n /** Optional output cache to use for this task graph */\n outputCache?: TaskOutputRepository | boolean;\n /** Optional signal to abort the task graph */\n parentSignal?: AbortSignal;\n /** Optional service registry to use for this task graph (creates child from global if not provided) */\n registry?: ServiceRegistry;\n /**\n * When true, streaming leaf tasks (no outgoing edges) accumulate their full\n * output so the workflow return value is complete. Defaults to true.\n * Pass false for subgraph runs where the parent handles streaming via\n * subscriptions and does not rely on the return value for stream data.\n */\n accumulateLeafOutputs?: boolean;\n}\n\nexport interface TaskGraphRunReactiveConfig extends TaskGraphRunConfig {\n /** Optional service registry to use for this task graph */\n registry?: ServiceRegistry;\n}\n\nclass TaskGraphDAG extends DirectedAcyclicGraph<\n ITask<any, any, any>,\n Dataflow,\n TaskIdType,\n DataflowIdType\n> {\n constructor() {\n super(\n (task: ITask<any, any, any>) => task.id,\n (dataflow: Dataflow) => dataflow.id\n );\n }\n}\n\ninterface TaskGraphConstructorConfig {\n outputCache?: TaskOutputRepository;\n dag?: TaskGraphDAG;\n}\n\n/**\n * Represents a task graph, a directed acyclic graph of tasks and data flows\n */\nexport class TaskGraph implements ITaskGraph {\n /** Optional output cache to use for this task graph */\n public outputCache?: TaskOutputRepository;\n\n /**\n * Constructor for TaskGraph\n * @param config Configuration for the task graph\n */\n constructor({ outputCache, dag }: TaskGraphConstructorConfig = {}) {\n this.outputCache = outputCache;\n this._dag = dag || new TaskGraphDAG();\n }\n\n private _dag: TaskGraphDAG;\n\n private _runner: TaskGraphRunner | undefined;\n public get runner(): TaskGraphRunner {\n if (!this._runner) {\n this._runner = new TaskGraphRunner(this, this.outputCache);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n /**\n * Runs the task graph\n * @param config Configuration for the graph run\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskError if any tasks have failed\n */\n public run<ExecuteOutput extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config: TaskGraphRunConfig = {}\n ): Promise<GraphResultArray<ExecuteOutput>> {\n return this.runner.runGraph<ExecuteOutput>(input, {\n outputCache: config?.outputCache || this.outputCache,\n parentSignal: config?.parentSignal || undefined,\n accumulateLeafOutputs: config?.accumulateLeafOutputs,\n registry: config?.registry,\n });\n }\n\n /**\n * Runs the task graph reactively\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskError if any tasks have failed\n */\n public runReactive<Output extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config: TaskGraphRunConfig = {}\n ): Promise<GraphResultArray<Output>> {\n return this.runner.runGraphReactive<Output>(input, config);\n }\n\n /**\n * Merges the execute output to the run output\n * @param results The execute output\n * @param compoundMerge The compound merge strategy to use\n * @returns The run output\n */\n\n public mergeExecuteOutputsToRunOutput<\n ExecuteOutput extends TaskOutput,\n Merge extends CompoundMergeStrategy = CompoundMergeStrategy,\n >(\n results: GraphResultArray<ExecuteOutput>,\n compoundMerge: Merge\n ): GraphResult<ExecuteOutput, Merge> {\n return this.runner.mergeExecuteOutputsToRunOutput(results, compoundMerge);\n }\n\n /**\n * Aborts the task graph\n */\n public abort() {\n this.runner.abort();\n }\n\n /**\n * Disables the task graph\n */\n public async disable() {\n await this.runner.disable();\n }\n\n /**\n * Retrieves a task from the task graph by its id\n * @param id The id of the task to retrieve\n * @returns The task with the given id, or undefined if not found\n */\n public getTask(id: TaskIdType): ITask<any, any, any> | undefined {\n return this._dag.getNode(id);\n }\n\n /**\n * Retrieves all tasks in the task graph\n * @returns An array of tasks in the task graph\n */\n public getTasks(): ITask<any, any, any>[] {\n return this._dag.getNodes();\n }\n\n /**\n * Retrieves all tasks in the task graph topologically sorted\n * @returns An array of tasks in the task graph topologically sorted\n */\n public topologicallySortedNodes(): ITask<any, any, any>[] {\n return this._dag.topologicallySortedNodes();\n }\n\n /**\n * Adds a task to the task graph\n * @param task The task to add\n * @returns The current task graph\n */\n public addTask(fn: PipeFunction<any, any>, config?: any): unknown;\n public addTask(task: ITask<any, any, any>): unknown;\n public addTask(task: ITask<any, any, any> | PipeFunction<any, any>, config?: any): unknown {\n return this._dag.addNode(ensureTask(task, config));\n }\n\n /**\n * Adds multiple tasks to the task graph\n * @param tasks The tasks to add\n * @returns The current task graph\n */\n public addTasks(tasks: PipeFunction<any, any>[]): unknown[];\n public addTasks(tasks: ITask<any, any, any>[]): unknown[];\n public addTasks(tasks: ITask<any, any, any>[] | PipeFunction<any, any>[]): unknown[] {\n return this._dag.addNodes(tasks.map(ensureTask));\n }\n\n /**\n * Adds a data flow to the task graph\n * @param dataflow The data flow to add\n * @returns The current task graph\n */\n public addDataflow(dataflow: Dataflow) {\n return this._dag.addEdge(dataflow.sourceTaskId, dataflow.targetTaskId, dataflow);\n }\n\n /**\n * Adds multiple data flows to the task graph\n * @param dataflows The data flows to add\n * @returns The current task graph\n */\n public addDataflows(dataflows: Dataflow[]) {\n const addedEdges = dataflows.map<[s: unknown, t: unknown, e: Dataflow]>((edge) => {\n return [edge.sourceTaskId, edge.targetTaskId, edge];\n });\n return this._dag.addEdges(addedEdges);\n }\n\n /**\n * Retrieves a data flow from the task graph by its id\n * @param id The id of the data flow to retrieve\n * @returns The data flow with the given id, or undefined if not found\n */\n public getDataflow(id: DataflowIdType): Dataflow | undefined {\n // @ts-ignore\n for (const i in this._dag.adjacency) {\n // @ts-ignore\n for (const j in this._dag.adjacency[i]) {\n // @ts-ignore\n const maybeEdges = this._dag.adjacency[i][j];\n if (maybeEdges !== null) {\n for (const edge of maybeEdges) {\n // @ts-ignore\n if (this._dag.edgeIdentity(edge, \"\", \"\") == id) {\n return edge;\n }\n }\n }\n }\n }\n }\n\n /**\n * Retrieves all data flows in the task graph\n * @returns An array of data flows in the task graph\n */\n public getDataflows(): Dataflow[] {\n return this._dag.getEdges().map((edge) => edge[2]);\n }\n\n /**\n * Removes a data flow from the task graph\n * @param dataflow The data flow to remove\n * @returns The current task graph\n */\n public removeDataflow(dataflow: Dataflow) {\n return this._dag.removeEdge(dataflow.sourceTaskId, dataflow.targetTaskId, dataflow.id);\n }\n\n /**\n * Retrieves the data flows that are sources of a given task\n * @param taskId The id of the task to retrieve sources for\n * @returns An array of data flows that are sources of the given task\n */\n public getSourceDataflows(taskId: unknown): Dataflow[] {\n return this._dag.inEdges(taskId).map(([, , dataflow]) => dataflow);\n }\n\n /**\n * Retrieves the data flows that are targets of a given task\n * @param taskId The id of the task to retrieve targets for\n * @returns An array of data flows that are targets of the given task\n */\n public getTargetDataflows(taskId: unknown): Dataflow[] {\n return this._dag.outEdges(taskId).map(([, , dataflow]) => dataflow);\n }\n\n /**\n * Retrieves the tasks that are sources of a given task\n * @param taskId The id of the task to retrieve sources for\n * @returns An array of tasks that are sources of the given task\n */\n public getSourceTasks(taskId: unknown): ITask<any, any, any>[] {\n return this.getSourceDataflows(taskId).map((dataflow) => this.getTask(dataflow.sourceTaskId)!);\n }\n\n /**\n * Retrieves the tasks that are targets of a given task\n * @param taskId The id of the task to retrieve targets for\n * @returns An array of tasks that are targets of the given task\n */\n public getTargetTasks(taskId: unknown): ITask<any, any, any>[] {\n return this.getTargetDataflows(taskId).map((dataflow) => this.getTask(dataflow.targetTaskId)!);\n }\n\n /**\n * Removes a task from the task graph\n * @param taskId The id of the task to remove\n * @returns The current task graph\n */\n public removeTask(taskId: unknown) {\n return this._dag.removeNode(taskId);\n }\n\n public resetGraph() {\n this.runner.resetGraph(this, uuid4());\n }\n\n /**\n * Converts the task graph to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns A TaskGraphJson object representing the tasks and dataflows\n */\n public toJSON(options?: TaskGraphJsonOptions): TaskGraphJson {\n const tasks = this.getTasks().map((node) => node.toJSON(options));\n const dataflows = this.getDataflows().map((df) => df.toJSON());\n let json: TaskGraphJson = {\n tasks,\n dataflows,\n };\n if (options?.withBoundaryNodes) {\n json = addBoundaryNodesToGraphJson(json, this);\n }\n return json;\n }\n\n /**\n * Converts the task graph to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns An array of JsonTaskItem objects, each representing a task and its dependencies\n */\n public toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem[] {\n const tasks = this.getTasks().flatMap((node) => node.toDependencyJSON(options));\n this.getDataflows().forEach((df) => {\n const target = tasks.find((node) => node.id === df.targetTaskId)!;\n if (!target.dependencies) {\n target.dependencies = {};\n }\n const targetDeps = target.dependencies[df.targetTaskPortId];\n if (!targetDeps) {\n target.dependencies[df.targetTaskPortId] = {\n id: df.sourceTaskId,\n output: df.sourceTaskPortId,\n };\n } else {\n if (Array.isArray(targetDeps)) {\n targetDeps.push({\n id: df.sourceTaskId,\n output: df.sourceTaskPortId,\n });\n } else {\n target.dependencies[df.targetTaskPortId] = [\n targetDeps,\n { id: df.sourceTaskId, output: df.sourceTaskPortId },\n ];\n }\n }\n });\n if (options?.withBoundaryNodes) {\n return addBoundaryNodesToDependencyJson(tasks, this);\n }\n return tasks;\n }\n\n // ========================================================================\n // Event handling\n // ========================================================================\n\n /**\n * Event emitter for task lifecycle events\n */\n public get events(): EventEmitter<TaskGraphStatusListeners> {\n if (!this._events) {\n this._events = new EventEmitter<TaskGraphStatusListeners>();\n }\n return this._events;\n }\n protected _events: EventEmitter<TaskGraphStatusListeners> | undefined;\n\n /**\n * Subscribes to an event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n * @returns a function to unsubscribe from the event\n */\n public subscribe<Event extends TaskGraphEvents>(\n name: Event,\n fn: TaskGraphEventListener<Event>\n ): () => void {\n this.on(name, fn);\n return () => this.off(name, fn);\n }\n\n /**\n * Subscribes to status changes on all tasks (existing and future)\n * @param callback - Function called when any task's status changes\n * @param callback.taskId - The ID of the task whose status changed\n * @param callback.status - The new status of the task\n * @returns a function to unsubscribe from all task status events\n */\n public subscribeToTaskStatus(\n callback: (taskId: TaskIdType, status: TaskStatus) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to status events on all existing tasks\n const tasks = this.getTasks();\n tasks.forEach((task) => {\n const unsub = task.subscribe(\"status\", (status) => {\n callback(task.id, status);\n });\n unsubscribes.push(unsub);\n });\n\n const handleTaskAdded = (taskId: TaskIdType) => {\n const task = this.getTask(taskId);\n if (!task || typeof task.subscribe !== \"function\") return;\n\n const unsub = task.subscribe(\"status\", (status) => {\n callback(task.id, status);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"task_added\", handleTaskAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to progress updates on all tasks (existing and future)\n * @param callback - Function called when any task reports progress\n * @param callback.taskId - The ID of the task reporting progress\n * @param callback.progress - The progress value (0-100)\n * @param callback.message - Optional progress message\n * @param callback.args - Additional arguments passed with the progress update\n * @returns a function to unsubscribe from all task progress events\n */\n public subscribeToTaskProgress(\n callback: (taskId: TaskIdType, progress: number, message?: string, ...args: any[]) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to progress events on all existing tasks\n const tasks = this.getTasks();\n tasks.forEach((task) => {\n const unsub = task.subscribe(\"progress\", (progress, message, ...args) => {\n callback(task.id, progress, message, ...args);\n });\n unsubscribes.push(unsub);\n });\n\n const handleTaskAdded = (taskId: TaskIdType) => {\n const task = this.getTask(taskId);\n if (!task || typeof task.subscribe !== \"function\") return;\n\n const unsub = task.subscribe(\"progress\", (progress, message, ...args) => {\n callback(task.id, progress, message, ...args);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"task_added\", handleTaskAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to status changes on all dataflows (existing and future)\n * @param callback - Function called when any dataflow's status changes\n * @param callback.dataflowId - The ID of the dataflow whose status changed\n * @param callback.status - The new status of the dataflow\n * @returns a function to unsubscribe from all dataflow status events\n */\n public subscribeToDataflowStatus(\n callback: (dataflowId: DataflowIdType, status: TaskStatus) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to status events on all existing dataflows\n const dataflows = this.getDataflows();\n dataflows.forEach((dataflow) => {\n const unsub = dataflow.subscribe(\"status\", (status) => {\n callback(dataflow.id, status);\n });\n unsubscribes.push(unsub);\n });\n\n const handleDataflowAdded = (dataflowId: DataflowIdType) => {\n const dataflow = this.getDataflow(dataflowId);\n if (!dataflow || typeof dataflow.subscribe !== \"function\") return;\n\n const unsub = dataflow.subscribe(\"status\", (status) => {\n callback(dataflow.id, status);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"dataflow_added\", handleDataflowAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to streaming events on the task graph.\n * Listens for task_stream_start, task_stream_chunk, and task_stream_end\n * events emitted by the TaskGraphRunner during streaming task execution.\n *\n * @param callbacks - Object with optional callbacks for each streaming event\n * @returns a function to unsubscribe from all streaming events\n */\n public subscribeToTaskStreaming(callbacks: {\n onStreamStart?: (taskId: TaskIdType) => void;\n onStreamChunk?: (taskId: TaskIdType, event: StreamEvent) => void;\n onStreamEnd?: (taskId: TaskIdType, output: Record<string, any>) => void;\n }): () => void {\n const unsubscribes: (() => void)[] = [];\n\n if (callbacks.onStreamStart) {\n const unsub = this.subscribe(\"task_stream_start\", callbacks.onStreamStart);\n unsubscribes.push(unsub);\n }\n\n if (callbacks.onStreamChunk) {\n const unsub = this.subscribe(\"task_stream_chunk\", callbacks.onStreamChunk);\n unsubscribes.push(unsub);\n }\n\n if (callbacks.onStreamEnd) {\n const unsub = this.subscribe(\"task_stream_end\", callbacks.onStreamEnd);\n unsubscribes.push(unsub);\n }\n\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Registers an event listener for the specified event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n */\n on<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // Safe cast: TaskGraph dag events (task_added, etc.) have the same signature as\n // the underlying DAG events (node-added, etc.) - both pass IDs, not full objects\n return this._dag.on(dagEvent, fn as Parameters<typeof this._dag.on>[1]);\n }\n return this.events.on(\n name as TaskGraphStatusEvents,\n fn as TaskGraphEventListener<TaskGraphStatusEvents>\n );\n }\n\n /**\n * Removes an event listener for the specified event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n */\n off<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // Safe cast: TaskGraph dag events (task_added, etc.) have the same signature as\n // the underlying DAG events (node-added, etc.) - both pass IDs, not full objects\n return this._dag.off(dagEvent, fn as Parameters<typeof this._dag.off>[1]);\n }\n return this.events.off(\n name as TaskGraphStatusEvents,\n fn as TaskGraphEventListener<TaskGraphStatusEvents>\n );\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n emit<E extends GraphEventDagEvents>(name: E, ...args: GraphEventDagParameters<E>): void;\n emit<E extends TaskGraphStatusEvents>(name: E, ...args: TaskGraphEventStatusParameters<E>): void;\n emit(name: string, ...args: any[]): void {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // @ts-ignore\n return this.emit_dag(name, ...args);\n } else {\n // @ts-ignore\n return this.emit_local(name, ...args);\n }\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n protected emit_local<Event extends TaskGraphStatusEvents>(\n name: Event,\n ...args: TaskGraphEventStatusParameters<Event>\n ) {\n return this.events?.emit(name, ...args);\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n protected emit_dag<Event extends GraphEventDagEvents>(\n name: Event,\n ...args: GraphEventDagParameters<Event>\n ) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n // Safe cast: GraphEventDagParameters matches the DAG's emit parameters (both are ID-based)\n return this._dag.emit(dagEvent, ...(args as unknown as [unknown]));\n }\n}\n\n/**\n * Super simple helper if you know the input and output handles, and there is only one each\n *\n * @param tasks\n * @param inputHandle\n * @param outputHandle\n * @returns\n */\nfunction serialGraphEdges(\n tasks: ITask<any, any, any>[],\n inputHandle: string,\n outputHandle: string\n): Dataflow[] {\n const edges: Dataflow[] = [];\n for (let i = 0; i < tasks.length - 1; i++) {\n edges.push(new Dataflow(tasks[i].id, inputHandle, tasks[i + 1].id, outputHandle));\n }\n return edges;\n}\n\n/**\n * Super simple helper if you know the input and output handles, and there is only one each\n *\n * @param tasks\n * @param inputHandle\n * @param outputHandle\n * @returns\n */\nexport function serialGraph(\n tasks: ITask<any, any, any>[],\n inputHandle: string,\n outputHandle: string\n): TaskGraph {\n const graph = new TaskGraph();\n graph.addTasks(tasks);\n graph.addDataflows(serialGraphEdges(tasks, inputHandle, outputHandle));\n return graph;\n}\n",
9
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { compileSchema, type DataPortSchema, type SchemaNode } from \"@workglow/util/schema\";\nimport { computeGraphInputSchema, computeGraphOutputSchema } from \"../task-graph/GraphSchemaUtils\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { CompoundMergeStrategy, PROPERTY_ARRAY } from \"../task-graph/TaskGraphRunner\";\nimport type { CreateLoopWorkflow } from \"../task-graph/Workflow\";\nimport { GraphAsTaskRunner } from \"./GraphAsTaskRunner\";\nimport type { IExecuteContext } from \"./ITask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { Task } from \"./Task\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport {\n TaskConfigSchema,\n type TaskConfig,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\nexport const graphAsTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...TaskConfigSchema[\"properties\"],\n compoundMerge: { type: \"string\", \"x-ui-hidden\": true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\nexport type GraphAsTaskConfig = TaskConfig & {\n /** subGraph is extracted in the constructor before validation — not in the JSON schema */\n subGraph?: TaskGraph;\n compoundMerge?: CompoundMergeStrategy;\n};\n\n/**\n * A task that contains a subgraph of tasks\n */\nexport class GraphAsTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends GraphAsTaskConfig = GraphAsTaskConfig,\n> extends Task<Input, Output, Config> {\n // ========================================================================\n // Static properties - should be overridden by subclasses\n // ========================================================================\n\n public static type: TaskTypeName = \"GraphAsTask\";\n public static title: string = \"Group\";\n public static description: string = \"A group of tasks that are executed together\";\n public static category: string = \"Flow Control\";\n public static compoundMerge: CompoundMergeStrategy = PROPERTY_ARRAY;\n\n /** This task has dynamic schemas that change based on the subgraph structure */\n public static hasDynamicSchemas: boolean = true;\n\n // ========================================================================\n // Constructor\n // ========================================================================\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n const { subGraph, ...rest } = config;\n super(input, rest as Config);\n if (subGraph) {\n this.subGraph = subGraph;\n }\n this.regenerateGraph();\n }\n\n // ========================================================================\n // TaskRunner delegation - Executes and manages the task\n // ========================================================================\n\n declare _runner: GraphAsTaskRunner<Input, Output, Config>;\n\n /**\n * Task runner for handling the task execution\n */\n override get runner(): GraphAsTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new GraphAsTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Static to Instance conversion methods\n // ========================================================================\n\n public static configSchema(): DataPortSchema {\n return graphAsTaskConfigSchema;\n }\n\n public get compoundMerge(): CompoundMergeStrategy {\n return this.config?.compoundMerge || (this.constructor as typeof GraphAsTask).compoundMerge;\n }\n\n public get cacheable(): boolean {\n return (\n this.runConfig?.cacheable ??\n this.config?.cacheable ??\n ((this.constructor as typeof GraphAsTask).cacheable && !this.hasChildren())\n );\n }\n\n // ========================================================================\n // Input/Output handling\n // ========================================================================\n\n /**\n * Override inputSchema to compute it dynamically from the subgraph at runtime.\n * For root tasks (no incoming edges) all input properties are collected.\n * For non-root tasks, only REQUIRED properties that are not satisfied by\n * any internal dataflow are added — this ensures that required inputs are\n * included in the graph's input schema without pulling in every optional\n * downstream property.\n */\n public inputSchema(): DataPortSchema {\n // If there's no subgraph or it has no children, fall back to the static schema\n if (!this.hasChildren()) {\n return (this.constructor as typeof Task).inputSchema();\n }\n\n return computeGraphInputSchema(this.subGraph);\n }\n\n protected _inputSchemaNode: SchemaNode | undefined;\n /**\n * Gets the compiled input schema\n */\n protected override getInputSchemaNode(): SchemaNode {\n // every graph as task is different, so we need to compile the schema for each one\n if (!this._inputSchemaNode) {\n try {\n const dataPortSchema = this.inputSchema();\n const schemaNode = Task.generateInputSchemaNode(dataPortSchema);\n this._inputSchemaNode = schemaNode;\n } catch (error) {\n // If compilation fails, fall back to accepting any object structure\n // This is a safety net for schemas that json-schema-library can't compile\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to permissive validation:`,\n error\n );\n this._inputSchemaNode = compileSchema({});\n }\n }\n return this._inputSchemaNode!;\n }\n\n /**\n\n * Override outputSchema to compute it dynamically from the subgraph at runtime\n * The output schema depends on the compoundMerge strategy and the nodes at the last level\n */\n\n public override outputSchema(): DataPortSchema {\n // If there's no subgraph or it has no children, fall back to the static schema\n if (!this.hasChildren()) {\n return (this.constructor as typeof Task).outputSchema();\n }\n\n return computeGraphOutputSchema(this.subGraph);\n }\n\n /**\n * Resets input data to defaults\n */\n public resetInputData(): void {\n super.resetInputData();\n if (this.hasChildren()) {\n this.subGraph!.getTasks().forEach((node) => {\n node.resetInputData();\n });\n this.subGraph!.getDataflows().forEach((dataflow) => {\n dataflow.reset();\n });\n }\n }\n\n // ========================================================================\n // Streaming pass-through\n // ========================================================================\n\n /**\n * Stream pass-through for compound tasks: runs the subgraph and forwards\n * streaming events from ending nodes to the outer graph. Also re-yields\n * any input streams from upstream for cases where this GraphAsTask is\n * itself downstream of another streaming task.\n */\n async *executeStream(input: Input, context: IExecuteContext): AsyncIterable<StreamEvent<Output>> {\n // Forward upstream input streams first (pass-through from outer graph)\n if (context.inputStreams) {\n for (const [, stream] of context.inputStreams) {\n const reader = stream.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value.type === \"finish\") continue;\n yield value as StreamEvent<Output>;\n }\n } finally {\n reader.releaseLock();\n }\n }\n }\n\n // Run the subgraph and forward streaming events from ending nodes\n if (this.hasChildren()) {\n const endingNodeIds = new Set<unknown>();\n const tasks = this.subGraph.getTasks();\n for (const task of tasks) {\n if (this.subGraph.getTargetDataflows(task.id).length === 0) {\n endingNodeIds.add(task.id);\n }\n }\n\n const eventQueue: StreamEvent<Output>[] = [];\n let resolveWaiting: (() => void) | undefined;\n let subgraphDone = false;\n\n const unsub = this.subGraph.subscribeToTaskStreaming({\n onStreamChunk: (taskId, event) => {\n if (endingNodeIds.has(taskId) && event.type !== \"finish\") {\n eventQueue.push(event as StreamEvent<Output>);\n resolveWaiting?.();\n }\n },\n });\n\n const runPromise = this.subGraph\n .run<Output>(input, { parentSignal: context.signal, accumulateLeafOutputs: false })\n .then((results) => {\n subgraphDone = true;\n resolveWaiting?.();\n return results;\n });\n\n // Yield events as they arrive from ending nodes\n while (!subgraphDone) {\n if (eventQueue.length === 0) {\n await new Promise<void>((resolve) => {\n resolveWaiting = resolve;\n });\n }\n while (eventQueue.length > 0) {\n yield eventQueue.shift()!;\n }\n }\n // Drain any remaining events\n while (eventQueue.length > 0) {\n yield eventQueue.shift()!;\n }\n\n unsub();\n\n const results = await runPromise;\n const mergedOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n yield { type: \"finish\", data: mergedOutput } as StreamFinish<Output>;\n } else {\n yield { type: \"finish\", data: input as unknown as Output } as StreamFinish<Output>;\n }\n }\n\n // ========================================================================\n // Compound task methods\n // ========================================================================\n\n /**\n * Regenerates the subtask graph and emits a \"regenerate\" event\n *\n * Subclasses should override this method to implement the actual graph\n * regeneration logic, but all they need to do is call this method to\n * emit the \"regenerate\" event.\n */\n public regenerateGraph(): void {\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n // ========================================================================\n // Serialization methods\n // ========================================================================\n\n /**\n * Serializes the task and its subtasks into a format that can be stored\n * @returns The serialized task and subtasks\n */\n public override toJSON(options?: TaskGraphJsonOptions): TaskGraphItemJson {\n let json = super.toJSON(options);\n const hasChildren = this.hasChildren();\n if (hasChildren) {\n json = {\n ...json,\n merge: this.compoundMerge,\n subgraph: this.subGraph!.toJSON(options),\n };\n }\n return json;\n }\n\n /**\n * Converts the task to a JSON format suitable for dependency tracking\n * @returns The task and subtasks in JSON thats easier for humans to read\n */\n public override toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem {\n const json = this.toJSON(options);\n if (this.hasChildren()) {\n if (\"subgraph\" in json) {\n delete json.subgraph;\n }\n return { ...json, subtasks: this.subGraph!.toDependencyJSON(options) };\n }\n return json;\n }\n}\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a group that wraps inner tasks in a GraphAsTask subgraph.\n * Use .endGroup() to close the group and return to the parent workflow.\n */\n group: CreateLoopWorkflow<TaskInput, TaskOutput, GraphAsTaskConfig>;\n\n /**\n * Ends the group and returns to the parent workflow.\n */\n endGroup(): Workflow;\n }\n}\n\n// Prototype assignments live in Workflow.ts (bottom of file) to avoid\n// circular-dependency issues at module evaluation time.\n",
10
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n collectPropertyValues,\n ConvertAllToOptionalArray,\n getLogger,\n getTelemetryProvider,\n globalServiceRegistry,\n ServiceRegistry,\n SpanStatusCode,\n uuid4,\n type ISpan,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport { ITask } from \"../task/ITask\";\nimport {\n edgeNeedsAccumulation,\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n type StreamEvent,\n} from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport { TaskAbortedError, TaskConfigurationError, TaskError } from \"../task/TaskError\";\nimport { TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport { TaskGraph, TaskGraphRunConfig, TaskGraphRunReactiveConfig } from \"./TaskGraph\";\nimport { DependencyBasedScheduler, TopologicalScheduler } from \"./TaskGraphScheduler\";\n\n/**\n * Tasks that inherit {@link Task.prototype.execute} without declaring their own `execute` on the\n * subclass prototype are omitted from graph-level progress averaging (they keep default 0% until\n * complete and would dilute the bar).\n */\nexport function taskPrototypeHasOwnExecute(task: ITask): boolean {\n const Ctor = task.constructor as typeof Task;\n return Object.hasOwn(Ctor.prototype, \"execute\");\n}\n\nexport type GraphSingleTaskResult<T> = {\n id: unknown;\n type: String;\n data: T;\n};\nexport type GraphResultArray<T> = Array<GraphSingleTaskResult<T>>;\nexport type PropertyArrayGraphResult<T> = ConvertAllToOptionalArray<T>;\nexport type AnyGraphResult<T> = PropertyArrayGraphResult<T> | GraphResultArray<T>;\n\nexport const PROPERTY_ARRAY = \"PROPERTY_ARRAY\" as const;\nexport const GRAPH_RESULT_ARRAY = \"GRAPH_RESULT_ARRAY\" as const;\n\nexport type GraphResultMap<T> = {\n // array of results with id for tasks that created them -- output is an array of {id, type, data}[]\n [GRAPH_RESULT_ARRAY]: GraphResultArray<T>;\n // property-array -- output is consolidation of each output property, with duplicate properties turned into an array\n [PROPERTY_ARRAY]: PropertyArrayGraphResult<T>;\n};\n\n/**\n * Enum representing the possible compound merge strategies\n */\nexport type CompoundMergeStrategy = typeof PROPERTY_ARRAY | typeof GRAPH_RESULT_ARRAY;\n\nexport type GraphResult<\n Output,\n Merge extends CompoundMergeStrategy,\n> = GraphResultMap<Output>[Merge];\n\n/**\n * Class for running a task graph\n * Manages the execution of tasks in a task graph, including caching\n */\nexport class TaskGraphRunner {\n /**\n * Whether the task graph is currently running\n */\n protected running = false;\n protected reactiveRunning = false;\n\n /**\n * The task graph to run\n */\n public readonly graph: TaskGraph;\n\n /**\n * Output cache repository\n */\n protected outputCache?: TaskOutputRepository;\n /**\n * Whether leaf tasks (no outgoing edges) should accumulate their streaming\n * output. True by default so workflow return values are complete.\n */\n protected accumulateLeafOutputs: boolean = true;\n /**\n * Service registry for this graph run\n */\n protected registry: ServiceRegistry = globalServiceRegistry;\n /**\n * AbortController for cancelling graph execution\n */\n protected abortController: AbortController | undefined;\n\n /**\n * Maps to track task execution state\n */\n protected inProgressTasks: Map<unknown, Promise<TaskOutput>> = new Map();\n protected inProgressFunctions: Map<unknown, Promise<any>> = new Map();\n protected failedTaskErrors: Map<unknown, TaskError> = new Map();\n\n /**\n * Active telemetry span for the current graph run.\n */\n protected telemetrySpan?: ISpan;\n\n /**\n * Constructor for TaskGraphRunner\n * @param graph The task graph to run\n * @param outputCache The task output repository to use for caching task outputs\n * @param processScheduler The scheduler to use for task execution\n * @param reactiveScheduler The scheduler to use for reactive task execution\n */\n constructor(\n graph: TaskGraph,\n outputCache?: TaskOutputRepository,\n protected processScheduler = new DependencyBasedScheduler(graph),\n protected reactiveScheduler = new TopologicalScheduler(graph)\n ) {\n this.graph = graph;\n graph.outputCache = outputCache;\n this.handleProgress = this.handleProgress.bind(this);\n }\n\n /**\n * Unique ID for the current run, used for timing labels.\n */\n protected runId: string = \"\";\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n public async runGraph<ExecuteOutput extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config?: TaskGraphRunConfig\n ): Promise<GraphResultArray<ExecuteOutput>> {\n await this.handleStart(config);\n\n const results: GraphResultArray<ExecuteOutput> = [];\n let error: TaskError | undefined;\n\n try {\n // TODO: A different graph runner may chunk tasks that are in parallel\n // rather them all currently available\n for await (const task of this.processScheduler.tasks()) {\n if (this.abortController?.signal.aborted) {\n break;\n }\n\n if (this.failedTaskErrors.size > 0) {\n break;\n }\n\n const isRootTask = this.graph.getSourceDataflows(task.id).length === 0;\n\n const runAsync = async () => {\n let errorRouted = false;\n try {\n // Only filter input for non-root tasks; root tasks get the full input\n const taskInput = isRootTask ? input : this.filterInputForTask(task, input);\n\n const taskPromise = this.runTask(task, taskInput);\n this.inProgressTasks!.set(task.id, taskPromise);\n const taskResult = await taskPromise;\n\n if (this.graph.getTargetDataflows(task.id).length === 0) {\n // we save the results of all the leaves\n results.push(taskResult as GraphSingleTaskResult<ExecuteOutput>);\n }\n } catch (error) {\n if (this.hasErrorOutputEdges(task)) {\n // Route the error through error-port dataflows instead of failing the graph.\n // pushErrorOutputToEdges sets edge statuses directly (COMPLETED for error\n // edges, DISABLED for normal edges), so we skip the normal status push.\n errorRouted = true;\n this.pushErrorOutputToEdges(task);\n } else {\n this.failedTaskErrors.set(task.id, error as TaskError);\n }\n } finally {\n // IMPORTANT: Push status to edges BEFORE notifying scheduler\n // This ensures dataflow statuses (including DISABLED) are set\n // before the scheduler checks which tasks are ready.\n // Skip normal status push when error routing already set edge statuses.\n if (!errorRouted) {\n this.pushStatusFromNodeToEdges(this.graph, task);\n this.pushErrorFromNodeToEdges(this.graph, task);\n }\n this.processScheduler.onTaskCompleted(task.id);\n }\n };\n\n // Start task execution without awaiting\n // so we can have many tasks running in parallel\n // but keep track of them to make sure they get awaited\n // otherwise, things will finish after this promise is resolved\n this.inProgressFunctions.set(Symbol(task.id as string), runAsync());\n }\n } catch (err) {\n error = err as Error;\n getLogger().error(\"Error running graph\", { error });\n }\n // Wait for all tasks to complete since we did not await runAsync()/this.runTaskWithProvenance()\n await Promise.allSettled(Array.from(this.inProgressTasks.values()));\n // Clean up stragglers to avoid unhandled promise rejections\n await Promise.allSettled(Array.from(this.inProgressFunctions.values()));\n\n if (this.failedTaskErrors.size > 0) {\n const latestError = this.failedTaskErrors.values().next().value!;\n this.handleError(latestError);\n throw latestError;\n }\n if (this.abortController?.signal.aborted) {\n await this.handleAbort();\n throw new TaskAbortedError();\n }\n\n await this.handleComplete();\n\n return results;\n }\n\n /**\n * Runs the task graph in a reactive manner\n * @param input Optional input to pass to root tasks (tasks with no incoming dataflows)\n * @param config Optional configuration for the reactive run. Supports overriding the\n * ServiceRegistry (`registry`), providing an output cache (`outputCache`), passing an\n * abort signal (`parentSignal`), and controlling whether streaming leaf task outputs are\n * accumulated into the return value (`accumulateLeafOutputs`).\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskConfigurationError if the graph is already running reactively\n */\n public async runGraphReactive<Output extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config?: TaskGraphRunReactiveConfig\n ): Promise<GraphResultArray<Output>> {\n await this.handleStartReactive(config);\n\n const results: GraphResultArray<Output> = [];\n try {\n for await (const task of this.reactiveScheduler.tasks()) {\n const isRootTask = this.graph.getSourceDataflows(task.id).length === 0;\n\n if (task.status === TaskStatus.PENDING) {\n task.resetInputData();\n this.copyInputFromEdgesToNode(task);\n // TODO: cacheable here??\n // if (task.cacheable) {\n // const results = await this.outputCache?.getOutput(\n // (task.constructor as any).type,\n // task.runInputData\n // );\n // if (results) {\n // task.runOutputData = results;\n // }\n // }\n }\n\n // For root tasks (no incoming dataflows), apply the input parameter\n // This is important for GraphAsTask subgraphs where the InputTask needs\n // to receive the parent's input values\n const taskInput = isRootTask ? input : {};\n\n const taskResult = await task.runReactive(taskInput);\n\n await this.pushOutputFromNodeToEdges(task, taskResult);\n if (this.graph.getTargetDataflows(task.id).length === 0) {\n results.push({\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: taskResult as Output,\n });\n }\n }\n await this.handleCompleteReactive();\n return results;\n } catch (error) {\n await this.handleErrorReactive();\n throw error;\n }\n }\n\n /**\n * Aborts the task graph execution\n */\n public abort(): void {\n this.abortController?.abort();\n }\n\n /**\n * Disables the task graph execution\n */\n public async disable(): Promise<void> {\n await this.handleDisable();\n }\n\n /**\n * Filters graph-level input to only include properties that are not connected via dataflows for a given task\n * @param task The task to filter input for\n * @param input The graph-level input\n * @returns Filtered input containing only unconnected properties\n */\n protected filterInputForTask(task: ITask, input: TaskInput): TaskInput {\n // Get all inputs that are connected to this task via dataflows\n const sourceDataflows = this.graph.getSourceDataflows(task.id);\n const connectedInputs = new Set(sourceDataflows.map((df) => df.targetTaskPortId));\n\n // If DATAFLOW_ALL_PORTS (\"*\") is in the set, all inputs are connected\n const allPortsConnected = connectedInputs.has(DATAFLOW_ALL_PORTS);\n\n // Filter out connected inputs from the graph input\n const filteredInput: TaskInput = {};\n for (const [key, value] of Object.entries(input)) {\n // Skip this input if it's explicitly connected OR if all ports are connected\n if (!connectedInputs.has(key) && !allPortsConnected) {\n filteredInput[key] = value;\n }\n }\n\n return filteredInput;\n }\n\n /**\n * Adds input data to a task.\n * Delegates to {@link Task.addInput} for the actual merging logic.\n *\n * @param task The task to add input data to\n * @param overrides The input data to override (or add to if an array)\n */\n public addInputData(task: ITask, overrides: Partial<TaskInput> | undefined): void {\n if (!overrides) return;\n\n const changed = task.addInput(overrides);\n\n // TODO(str): This is a hack.\n if (changed && \"regenerateGraph\" in task && typeof task.regenerateGraph === \"function\") {\n task.regenerateGraph();\n }\n }\n\n // ========================================================================\n // Protected Handlers\n // ========================================================================\n public mergeExecuteOutputsToRunOutput<\n ExecuteOutput extends TaskOutput,\n Merge extends CompoundMergeStrategy = CompoundMergeStrategy,\n >(\n results: GraphResultArray<ExecuteOutput>,\n compoundMerge: Merge\n ): GraphResult<ExecuteOutput, Merge> {\n if (compoundMerge === GRAPH_RESULT_ARRAY) {\n return results as GraphResult<ExecuteOutput, Merge>;\n }\n\n if (compoundMerge === PROPERTY_ARRAY) {\n let fixedOutput = {} as PropertyArrayGraphResult<ExecuteOutput>;\n const outputs = results.map((result: any) => result.data);\n if (outputs.length === 1) {\n fixedOutput = outputs[0];\n } else if (outputs.length > 1) {\n const collected = collectPropertyValues<ExecuteOutput>(outputs as ExecuteOutput[]);\n if (Object.keys(collected).length > 0) {\n fixedOutput = collected;\n }\n }\n return fixedOutput as GraphResult<ExecuteOutput, Merge>;\n }\n throw new TaskConfigurationError(`Unknown compound merge strategy: ${compoundMerge}`);\n }\n\n /**\n * Copies input data from edges to a task\n * @param task The task to copy input data to\n */\n protected copyInputFromEdgesToNode(task: ITask) {\n const dataflows = this.graph.getSourceDataflows(task.id);\n for (const dataflow of dataflows) {\n this.addInputData(task, dataflow.getPortData());\n }\n }\n\n /**\n * Pushes the output of a task to its target tasks\n * @param node The task that produced the output\n * @param results The output of the task\n */\n protected async pushOutputFromNodeToEdges(node: ITask, results: TaskOutput) {\n const dataflows = this.graph.getTargetDataflows(node.id);\n for (const dataflow of dataflows) {\n const compatibility = dataflow.semanticallyCompatible(this.graph, dataflow);\n getLogger().debug(\"pushOutputFromNodeToEdges\", {\n dataflowId: dataflow.id,\n compatibility,\n resultsKeys: Object.keys(results),\n });\n if (compatibility === \"static\") {\n dataflow.setPortData(results);\n } else if (compatibility === \"runtime\") {\n const task = this.graph.getTask(dataflow.targetTaskId)!;\n const narrowed = await task.narrowInput({ ...results }, this.registry);\n dataflow.setPortData(narrowed);\n } else {\n // Warn only when we had data to push; empty results (e.g. progress mid-run) are expected\n const resultsKeys = Object.keys(results);\n if (resultsKeys.length > 0) {\n getLogger().warn(\"pushOutputFromNodeToEdge not compatible, not setting port data\", {\n dataflowId: dataflow.id,\n compatibility,\n resultsKeys,\n });\n }\n }\n }\n }\n\n /**\n * Pushes the status of a task to its target edges\n * @param node The task that produced the status\n *\n * For ConditionalTask, this method handles selective dataflow status:\n * - Active branch dataflows get COMPLETED status\n * - Inactive branch dataflows get DISABLED status\n */\n protected pushStatusFromNodeToEdges(graph: TaskGraph, node: ITask, status?: TaskStatus): void {\n if (!node?.config?.id) return;\n\n const dataflows = graph.getTargetDataflows(node.id);\n const effectiveStatus = status ?? node.status;\n\n // Check if this is a ConditionalTask with selective branching\n if (node instanceof ConditionalTask && effectiveStatus === TaskStatus.COMPLETED) {\n // Build a map of output port -> branch ID for lookup\n const branches = node.config.branches ?? [];\n const portToBranch = new Map<string, string>();\n for (const branch of branches) {\n portToBranch.set(branch.outputPort, branch.id);\n }\n\n const activeBranches = node.getActiveBranches();\n\n for (const dataflow of dataflows) {\n const branchId = portToBranch.get(dataflow.sourceTaskPortId);\n if (branchId !== undefined) {\n // This dataflow is from a branch port\n if (activeBranches.has(branchId)) {\n // Branch is active - dataflow gets completed status\n dataflow.setStatus(TaskStatus.COMPLETED);\n } else {\n // Branch is inactive - dataflow gets disabled status\n dataflow.setStatus(TaskStatus.DISABLED);\n }\n } else {\n // Not a branch port (e.g., _activeBranches metadata) - use normal status\n dataflow.setStatus(effectiveStatus);\n }\n }\n\n // Cascade disabled status to downstream tasks\n this.propagateDisabledStatus(graph);\n return;\n }\n\n // Default behavior for non-conditional tasks\n dataflows.forEach((dataflow) => {\n dataflow.setStatus(effectiveStatus);\n });\n }\n\n /**\n * Pushes the error of a task to its target edges\n * @param node The task that produced the error\n */\n protected pushErrorFromNodeToEdges(graph: TaskGraph, node: ITask): void {\n if (!node?.config?.id) return;\n graph.getTargetDataflows(node.id).forEach((dataflow) => {\n dataflow.error = node.error;\n });\n }\n\n /**\n * Returns true if the task has any outgoing dataflow edges that use the\n * error output port (`[error]`). These edges indicate that the task's\n * errors should be routed to downstream handler tasks instead of failing\n * the entire graph.\n */\n protected hasErrorOutputEdges(task: ITask): boolean {\n const dataflows = this.graph.getTargetDataflows(task.id);\n return dataflows.some((df) => df.sourceTaskPortId === DATAFLOW_ERROR_PORT);\n }\n\n /**\n * Routes a failed task's error through its error-port dataflow edges.\n *\n * For each outgoing dataflow:\n * - Error-port edges (`[error]`) receive the error data and get COMPLETED status\n * - Non-error-port edges get DISABLED status (the task didn't produce normal output)\n *\n * After setting edge statuses, propagateDisabledStatus() cascades DISABLED\n * through any downstream tasks that only had non-error inputs from this task.\n */\n protected pushErrorOutputToEdges(task: ITask): void {\n const taskError = task.error;\n const errorData = {\n error: taskError?.message ?? \"Unknown error\",\n errorType: (taskError?.constructor as { type?: string })?.type ?? \"TaskError\",\n };\n\n const dataflows = this.graph.getTargetDataflows(task.id);\n for (const df of dataflows) {\n if (df.sourceTaskPortId === DATAFLOW_ERROR_PORT) {\n // Route error data to the error-port edge\n df.value = errorData;\n df.setStatus(TaskStatus.COMPLETED);\n } else {\n // Normal output edges are disabled — this task didn't produce output\n df.setStatus(TaskStatus.DISABLED);\n }\n }\n\n // Cascade disabled status to downstream tasks whose ALL inputs are now disabled\n this.propagateDisabledStatus(this.graph);\n }\n\n /**\n * Propagates DISABLED status through the graph.\n *\n * When a task's ALL incoming dataflows are DISABLED, that task becomes unreachable\n * and should also be disabled. This cascades through the graph until no more\n * tasks can be disabled.\n *\n * This is used by ConditionalTask to disable downstream tasks on inactive branches.\n *\n * @param graph The task graph to propagate disabled status through\n */\n protected propagateDisabledStatus(graph: TaskGraph): void {\n let changed = true;\n\n // Keep iterating until no more changes (fixed-point iteration)\n while (changed) {\n changed = false;\n\n for (const task of graph.getTasks()) {\n // Only consider tasks that are still pending\n if (task.status !== TaskStatus.PENDING) {\n continue;\n }\n\n const incomingDataflows = graph.getSourceDataflows(task.id);\n\n // Skip tasks with no incoming dataflows (root tasks)\n if (incomingDataflows.length === 0) {\n continue;\n }\n\n // Check if ALL incoming dataflows are DISABLED\n const allDisabled = incomingDataflows.every((df) => df.status === TaskStatus.DISABLED);\n\n if (allDisabled) {\n // This task is unreachable - disable it synchronously\n // Set status directly to avoid async issues\n task.status = TaskStatus.DISABLED;\n task.progress = 100;\n task.completedAt = new Date();\n task.emit(\"disabled\");\n task.emit(\"status\", task.status);\n\n // Propagate disabled status to its outgoing dataflows\n graph.getTargetDataflows(task.id).forEach((dataflow) => {\n dataflow.setStatus(TaskStatus.DISABLED);\n });\n\n // Mark as completed in scheduler so it doesn't wait for this task\n this.processScheduler.onTaskCompleted(task.id);\n\n changed = true;\n }\n }\n }\n }\n\n /**\n * Determines whether a streaming task needs to accumulate its text-delta\n * chunks into an enriched finish event. Accumulation is needed when:\n *\n * 1. Output caching is active (the cached value must be fully materialised).\n * 2. Any outgoing dataflow edge connects a streaming output port to an input\n * port that is not streaming with the same mode (i.e. the downstream task\n * cannot consume a raw stream and needs a completed value).\n *\n * When accumulation is required the source task runs with shouldAccumulate=true,\n * emitting an enriched finish event that carries all accumulated port text.\n * All downstream dataflow edges share that event via tee'd streams so no\n * edge needs to re-accumulate independently.\n */\n protected taskNeedsAccumulation(task: ITask): boolean {\n if (this.outputCache) return true;\n\n const outEdges = this.graph.getTargetDataflows(task.id);\n if (outEdges.length === 0) return this.accumulateLeafOutputs;\n\n const outSchema = task.outputSchema();\n\n for (const df of outEdges) {\n if (df.sourceTaskPortId === DATAFLOW_ALL_PORTS) {\n // Conservative: if any streaming output port exists, accumulate.\n // This covers the case where all-ports edges fan into non-streaming tasks.\n if (getStreamingPorts(outSchema).length > 0) return true;\n continue;\n }\n\n const targetTask = this.graph.getTask(df.targetTaskId);\n if (!targetTask) continue;\n const inSchema = targetTask.inputSchema();\n\n if (edgeNeedsAccumulation(outSchema, df.sourceTaskPortId, inSchema, df.targetTaskPortId)) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Runs a task\n * @param task The task to run\n * @param input The input for the task\n * @returns The output of the task\n */\n protected async runTask<T>(task: ITask, input: TaskInput): Promise<GraphSingleTaskResult<T>> {\n const isStreamable = isTaskStreamable(task);\n\n // For pass-through streaming tasks: if the task is streamable and has\n // streaming input edges, tee each stream so one copy is forwarded to\n // the task's executeStream() (via inputStreams) while the other stays\n // on the edge for materialization by awaitStreamInputs.\n if (isStreamable) {\n const dataflows = this.graph.getSourceDataflows(task.id);\n const streamingEdges = dataflows.filter((df) => df.stream !== undefined);\n if (streamingEdges.length > 0) {\n const inputStreams = new Map<string, ReadableStream<StreamEvent>>();\n for (const df of streamingEdges) {\n const stream = df.stream!;\n const [forwardCopy, materializeCopy] = stream.tee();\n inputStreams.set(df.targetTaskPortId, forwardCopy);\n df.setStream(materializeCopy);\n }\n task.runner.inputStreams = inputStreams;\n }\n }\n\n // Await any active streams on input dataflow edges so their values\n // are materialized before we read them. This applies to ALL downstream\n // tasks (both streaming and non-streaming) because copyInputFromEdgesToNode\n // reads via getPortData() which requires materialized values.\n // Streaming downstream tasks are still unblocked early by the scheduler\n // (they can start setup while upstream is streaming), but their actual\n // input data waits for upstream completion.\n await this.awaitStreamInputs(task);\n\n this.copyInputFromEdgesToNode(task);\n\n if (isStreamable) {\n return this.runStreamingTask<T>(task, input);\n }\n\n const results = await task.runner.run(input, {\n // Pass `false` when no cache so TaskRunner.handleStart explicitly clears\n // its own cached reference (undefined would leave the old value intact).\n outputCache: this.outputCache ?? false,\n updateProgress: async (task: ITask, progress: number, message?: string, ...args: any[]) =>\n await this.handleProgress(task, progress, message, ...args),\n registry: this.registry,\n });\n\n await this.pushOutputFromNodeToEdges(task, results);\n\n return {\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: results as T,\n };\n }\n\n /**\n * For non-streaming downstream tasks, awaits completion of any active\n * streams on input dataflow edges, materializing their values.\n *\n * Streaming upstream tasks set a ReadableStream on outgoing edges.\n * Non-streaming downstream tasks cannot consume streams directly, so\n * this method reads each stream to completion and accumulates the\n * value (via Dataflow.awaitStreamValue) before the task reads its\n * inputs through the normal getPortData() path.\n */\n protected async awaitStreamInputs(task: ITask): Promise<void> {\n const dataflows = this.graph.getSourceDataflows(task.id);\n const streamPromises = dataflows\n .filter((df) => df.stream !== undefined)\n .map((df) => df.awaitStreamValue());\n if (streamPromises.length > 0) {\n await Promise.all(streamPromises);\n }\n }\n\n /**\n * Runs a streaming task within the DAG.\n * Listens for stream events to:\n * - Notify the scheduler when streaming begins (unblocking downstream streamable tasks)\n * - Push stream data to outgoing dataflow edges\n * - Have the source task accumulate and emit enriched finish events for\n * non-streaming downstream tasks (when taskNeedsAccumulation() is true)\n */\n protected async runStreamingTask<T>(\n task: ITask,\n input: TaskInput\n ): Promise<GraphSingleTaskResult<T>> {\n const streamMode = getOutputStreamMode(task.outputSchema());\n const shouldAccumulate = this.taskNeedsAccumulation(task);\n\n let streamingNotified = false;\n\n const onStatus = (status: TaskStatus) => {\n if (status === TaskStatus.STREAMING && !streamingNotified) {\n streamingNotified = true;\n this.pushStatusFromNodeToEdges(this.graph, task, TaskStatus.STREAMING);\n this.pushStreamToEdges(task, streamMode);\n this.processScheduler.onTaskStreaming(task.id);\n }\n };\n\n const onStreamStart = () => {\n this.graph.emit(\"task_stream_start\", task.id);\n };\n\n const onStreamChunk = (event: StreamEvent) => {\n this.graph.emit(\"task_stream_chunk\", task.id, event);\n };\n\n const onStreamEnd = (output: Record<string, any>) => {\n this.graph.emit(\"task_stream_end\", task.id, output);\n };\n\n task.on(\"status\", onStatus);\n task.on(\"stream_start\", onStreamStart);\n task.on(\"stream_chunk\", onStreamChunk);\n task.on(\"stream_end\", onStreamEnd);\n\n try {\n const results = await task.runner.run(input, {\n outputCache: this.outputCache ?? false,\n shouldAccumulate,\n updateProgress: async (task: ITask, progress: number, message?: string, ...args: any[]) =>\n await this.handleProgress(task, progress, message, ...args),\n registry: this.registry,\n });\n\n await this.pushOutputFromNodeToEdges(task, results);\n\n return {\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: results as T,\n };\n } finally {\n task.off(\"status\", onStatus);\n task.off(\"stream_start\", onStreamStart);\n task.off(\"stream_chunk\", onStreamChunk);\n task.off(\"stream_end\", onStreamEnd);\n }\n }\n\n /**\n * Returns true if an event carries a port-specific delta (text-delta or object-delta).\n */\n private static isPortDelta(event: StreamEvent): event is StreamEvent & { port: string } {\n return event.type === \"text-delta\" || event.type === \"object-delta\";\n }\n\n /**\n * Creates a ReadableStream from task streaming events, optionally filtered\n * to a single port. When `portId` is undefined (DATAFLOW_ALL_PORTS), all\n * events pass through. When set, only delta events matching the port plus\n * control events (finish, error, snapshot) are enqueued.\n */\n private createStreamFromTaskEvents(task: ITask, portId?: string): ReadableStream<StreamEvent> {\n return new ReadableStream<StreamEvent>({\n start: (controller) => {\n const onChunk = (event: StreamEvent) => {\n try {\n if (\n portId !== undefined &&\n TaskGraphRunner.isPortDelta(event) &&\n event.port !== portId\n ) {\n return;\n }\n controller.enqueue(event);\n } catch {\n // Stream may be closed\n }\n };\n const onEnd = () => {\n try {\n controller.close();\n } catch {\n // Stream may already be closed\n }\n task.off(\"stream_chunk\", onChunk);\n task.off(\"stream_end\", onEnd);\n };\n task.on(\"stream_chunk\", onChunk);\n task.on(\"stream_end\", onEnd);\n },\n });\n }\n\n /**\n * Pushes stream events from a streaming task to its outgoing dataflow edges.\n * Creates per-port filtered ReadableStreams for specific-port edges and\n * unfiltered streams for DATAFLOW_ALL_PORTS edges. Within each port group,\n * uses tee() for fan-out to multiple consumers.\n */\n protected pushStreamToEdges(task: ITask, streamMode: string): void {\n const targetDataflows = this.graph.getTargetDataflows(task.id);\n if (targetDataflows.length === 0) return;\n\n // Group edges by their source port\n const groups = new Map<string, typeof targetDataflows>();\n for (const df of targetDataflows) {\n const key = df.sourceTaskPortId;\n let group = groups.get(key);\n if (!group) {\n group = [];\n groups.set(key, group);\n }\n group.push(df);\n }\n\n for (const [portKey, edges] of groups) {\n const filterPort = portKey === DATAFLOW_ALL_PORTS ? undefined : portKey;\n const stream = this.createStreamFromTaskEvents(task, filterPort);\n\n if (edges.length === 1) {\n edges[0].setStream(stream);\n } else {\n let currentStream = stream;\n for (let i = 0; i < edges.length; i++) {\n if (i === edges.length - 1) {\n edges[i].setStream(currentStream);\n } else {\n const [s1, s2] = currentStream.tee();\n edges[i].setStream(s1);\n currentStream = s2;\n }\n }\n }\n }\n }\n\n /**\n * Resets a task\n * @param graph The task graph to reset\n * @param task The task to reset\n * @param runId The run ID\n */\n protected resetTask(graph: TaskGraph, task: ITask, runId: string) {\n task.status = TaskStatus.PENDING;\n task.resetInputData();\n task.runOutputData = {};\n task.error = undefined;\n task.progress = 0;\n task.runConfig = { ...task.runConfig, runnerId: runId };\n this.pushStatusFromNodeToEdges(graph, task);\n this.pushErrorFromNodeToEdges(graph, task);\n task.emit(\"reset\");\n task.emit(\"status\", task.status);\n }\n\n /**\n * Resets the task graph, recursively\n * @param graph The task graph to reset\n */\n public resetGraph(graph: TaskGraph, runnerId: string) {\n graph.getTasks().forEach((node) => {\n this.resetTask(graph, node, runnerId);\n node.regenerateGraph();\n if (node.hasChildren()) {\n this.resetGraph(node.subGraph, runnerId);\n }\n });\n graph.getDataflows().forEach((dataflow) => {\n dataflow.reset();\n });\n }\n\n /**\n * Handles the start of task graph execution\n * @param parentSignal Optional abort signal from parent\n */\n protected async handleStart(config?: TaskGraphRunConfig): Promise<void> {\n // Setup registry - create child from global if not provided\n if (config?.registry !== undefined) {\n this.registry = config.registry;\n } else if (this.registry === undefined) {\n // Create a child container that inherits from global but allows overrides\n this.registry = new ServiceRegistry(globalServiceRegistry.container.createChildContainer());\n }\n\n this.accumulateLeafOutputs = config?.accumulateLeafOutputs !== false;\n\n if (config?.outputCache !== undefined) {\n if (typeof config.outputCache === \"boolean\") {\n if (config.outputCache === true) {\n this.outputCache = this.registry.get(TASK_OUTPUT_REPOSITORY);\n } else {\n this.outputCache = undefined;\n }\n } else {\n this.outputCache = config.outputCache;\n }\n this.graph.outputCache = this.outputCache;\n }\n // Prevent reentrancy\n if (this.running || this.reactiveRunning) {\n throw new TaskConfigurationError(\"Graph is already running\");\n }\n\n this.running = true;\n this.abortController = new AbortController();\n this.abortController.signal.addEventListener(\"abort\", () => {\n this.handleAbort();\n });\n\n if (config?.parentSignal?.aborted) {\n this.abortController.abort(); // Immediately abort if the parent is already aborted\n return;\n } else {\n config?.parentSignal?.addEventListener(\n \"abort\",\n () => {\n this.abortController?.abort();\n },\n { once: true }\n );\n }\n\n this.runId = uuid4();\n this.resetGraph(this.graph, this.runId);\n this.processScheduler.reset();\n this.inProgressTasks.clear();\n this.inProgressFunctions.clear();\n this.failedTaskErrors.clear();\n\n // Start telemetry span for the graph run\n const telemetry = getTelemetryProvider();\n if (telemetry.isEnabled) {\n this.telemetrySpan = telemetry.startSpan(\"workglow.graph.run\", {\n attributes: {\n \"workglow.graph.run_id\": this.runId,\n \"workglow.graph.task_count\": this.graph.getTasks().length,\n \"workglow.graph.dataflow_count\": this.graph.getDataflows().length,\n },\n });\n }\n\n this.graph.emit(\"start\");\n }\n\n protected async handleStartReactive(config?: TaskGraphRunConfig): Promise<void> {\n if (this.reactiveRunning) {\n throw new TaskConfigurationError(\"Graph is already running reactively\");\n }\n\n // Use explicit registry if provided; otherwise keep the existing one\n // (which is either globalServiceRegistry by default, or whatever handleStart set).\n if (config?.registry !== undefined) {\n this.registry = config.registry;\n }\n\n this.reactiveScheduler.reset();\n this.reactiveRunning = true;\n }\n\n /**\n * Handles the completion of task graph execution\n */\n protected async handleComplete(): Promise<void> {\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.OK);\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"complete\");\n }\n\n protected async handleCompleteReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles errors during task graph execution\n */\n protected async handleError(error: TaskError): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {\n return task.abort();\n }\n })\n );\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, error.message);\n this.telemetrySpan.setAttributes({ \"workglow.graph.error\": error.message });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"error\", error);\n }\n\n protected async handleErrorReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task graph abortion\n */\n protected async handleAbort(): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {\n return task.abort();\n }\n })\n );\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, \"aborted\");\n this.telemetrySpan.addEvent(\"workglow.graph.aborted\");\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"abort\");\n }\n\n protected async handleAbortReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task graph disabling\n */\n protected async handleDisable(): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PENDING) {\n return task.disable();\n }\n })\n );\n this.running = false;\n this.graph.emit(\"disabled\");\n }\n\n /**\n * Handles progress updates for the task graph by averaging `progress` across tasks whose class\n * declares its own `execute` ({@link taskPrototypeHasOwnExecute}). Other nodes are ignored.\n * @param progress Progress value (0-100)\n * @param message Optional message\n * @param args Additional arguments\n */\n protected async handleProgress(\n task: ITask,\n progress: number,\n message?: string,\n ...args: any[]\n ): Promise<void> {\n const contributors = this.graph.getTasks().filter(taskPrototypeHasOwnExecute);\n if (contributors.length > 1) {\n const sum = contributors.reduce((acc, t) => acc + t.progress, 0);\n progress = Math.round(sum / contributors.length);\n } else if (contributors.length === 1) {\n const [only] = contributors;\n progress = only.progress;\n }\n this.pushStatusFromNodeToEdges(this.graph, task);\n // Emit aggregate progress before awaiting output push so UIs (and task `emit(\"progress\")` in\n // TaskRunner) are not blocked when pushOutput/narrowInput is slow or stalls mid-run.\n this.graph.emit(\"graph_progress\", progress, message, args);\n // Only push output when the task has produced data; progress can fire mid-run with empty runOutputData\n if (task.runOutputData && Object.keys(task.runOutputData).length > 0) {\n await this.pushOutputFromNodeToEdges(task, task.runOutputData);\n }\n }\n}\n",
9
11
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken, EventEmitter, EventParameters } from \"@workglow/util\";\nimport { TaskInput, TaskOutput } from \"../task/TaskTypes\";\n\n/**\n * Service token for TaskOutputRepository\n */\nexport const TASK_OUTPUT_REPOSITORY = createServiceToken<TaskOutputRepository>(\n \"taskgraph.taskOutputRepository\"\n);\n\nexport type TaskOutputEventListeners = {\n output_saved: (taskType: string) => void;\n output_retrieved: (taskType: string) => void;\n output_cleared: () => void;\n output_pruned: () => void;\n};\n\nexport type TaskOutputEvents = keyof TaskOutputEventListeners;\n\nexport type TaskOutputEventListener<Event extends TaskOutputEvents> =\n TaskOutputEventListeners[Event];\n\nexport type TaskOutputEventParameters<Event extends TaskOutputEvents> = EventParameters<\n TaskOutputEventListeners,\n Event\n>;\n\n/**\n * Abstract class for managing task outputs in a repository\n * Provides methods for saving, retrieving, and clearing task outputs\n */\nexport abstract class TaskOutputRepository {\n /**\n * Whether to compress the output\n */\n outputCompression: boolean;\n\n /**\n * Constructor for the TaskOutputRepository\n * @param options The options for the repository\n */\n constructor({ outputCompression = true }) {\n this.outputCompression = outputCompression;\n }\n\n private get events() {\n if (!this._events) {\n this._events = new EventEmitter<TaskOutputEventListeners>();\n }\n return this._events;\n }\n private _events: EventEmitter<TaskOutputEventListeners> | undefined;\n\n /**\n * Registers an event listener for a specific event\n * @param name The event name to listen for\n * @param fn The callback function to execute when the event occurs\n */\n on<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>) {\n this.events.on(name, fn);\n }\n\n /**\n * Removes an event listener for a specific event\n * @param name The event name to stop listening for\n * @param fn The callback function to remove\n */\n off<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>) {\n this.events.off(name, fn);\n }\n\n /**\n * Returns a promise that resolves when the event is emitted\n * @param name The event name to listen for\n * @returns a promise that resolves to the event parameters\n */\n waitOn<Event extends TaskOutputEvents>(name: Event) {\n return this.events.waitOn(name) as Promise<TaskOutputEventParameters<Event>>;\n }\n\n /**\n * Emits an event (if there are listeners)\n * @param name The event name to emit\n * @param args The event parameters\n */\n emit<Event extends TaskOutputEvents>(name: Event, ...args: TaskOutputEventParameters<Event>) {\n this._events?.emit(name, ...args);\n }\n\n /**\n * Saves a task output to the repository\n * @param taskType The type of task to save the output for\n * @param inputs The input parameters for the task\n * @param output The task output to save\n */\n abstract saveOutput(\n taskType: string,\n inputs: TaskInput,\n output: TaskOutput,\n createdAt?: Date // for testing purposes\n ): Promise<void>;\n\n /**\n * Retrieves a task output from the repository\n * @param taskType The type of task to retrieve the output for\n * @param inputs The input parameters for the task\n * @returns The retrieved task output, or undefined if not found\n */\n abstract getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined>;\n\n /**\n * Clears all task outputs from the repository\n * @emits output_cleared when the operation completes\n */\n abstract clear(): Promise<void>;\n\n /**\n * Returns the number of task outputs stored in the repository\n * @returns The count of stored task outputs\n */\n abstract size(): Promise<number>;\n\n /**\n * Clear all task outputs from the repository that are older than the given date\n * @param olderThanInMs The time in milliseconds to clear task outputs older than\n */\n abstract clearOlderThan(olderThanInMs: number): Promise<void>;\n}\n",
12
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { getLogger } from \"@workglow/util\";\nimport { evaluateCondition, getNestedValue, type UIConditionConfig } from \"./ConditionUtils\";\nimport type { IExecuteContext } from \"./ITask\";\nimport { Task } from \"./Task\";\nimport {\n TaskConfigSchema,\n type TaskConfig,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\n// ============================================================================\n// Types and Interfaces\n// ============================================================================\n\n/**\n * A predicate function that evaluates whether a branch condition is met.\n * Receives the task's input data and returns true if the branch should be active.\n *\n * @template Input - The input type for the conditional task\n * @param input - The input data to evaluate\n * @returns true if the branch condition is met, false otherwise\n *\n * @example\n * ```typescript\n * // Simple numeric comparison\n * const isHighValue: ConditionFn<{ value: number }> = (input) => input.value > 100;\n *\n * // String equality check\n * const isAdmin: ConditionFn<{ role: string }> = (input) => input.role === \"admin\";\n *\n * // Complex boolean logic\n * const isEligible: ConditionFn<{ age: number; verified: boolean }> = (input) =>\n * input.age >= 18 && input.verified;\n * ```\n */\nexport type ConditionFn<Input> = (input: Input) => boolean;\n\n/**\n * Configuration for a single branch in a ConditionalTask.\n *\n * Each branch represents a possible path through the conditional logic.\n * When the condition evaluates to true, the branch becomes active and\n * its output port will receive the task's input data.\n *\n * @template Input - The input type for the conditional task\n *\n * @example\n * ```typescript\n * const highValueBranch: BranchConfig<{ amount: number }> = {\n * id: \"high\",\n * condition: (input) => input.amount > 1000,\n * outputPort: \"highValue\"\n * };\n * ```\n */\nexport interface BranchConfig<Input> {\n /** Unique identifier for this branch within the task */\n readonly id: string;\n\n /** Predicate function that determines if this branch is active */\n readonly condition: ConditionFn<Input>;\n\n /** Name of the output port that will receive data when this branch is active */\n readonly outputPort: string;\n}\n\n/**\n * Configuration interface for ConditionalTask.\n *\n * Extends the base TaskConfig with conditional-specific options including\n * branch definitions, default branch handling, and execution mode.\n *\n * @example\n * ```typescript\n * const config: ConditionalTaskConfig = {\n * id: \"router\",\n * branches: [\n * { id: \"premium\", condition: (i) => i.tier === \"premium\", outputPort: \"premium\" },\n * { id: \"standard\", condition: (i) => i.tier === \"standard\", outputPort: \"standard\" },\n * ],\n * defaultBranch: \"standard\",\n * exclusive: true, // Only first matching branch activates\n * };\n * ```\n */\nexport const conditionalTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...TaskConfigSchema[\"properties\"],\n branches: { type: \"array\", items: {} },\n defaultBranch: { type: \"string\" },\n exclusive: { type: \"boolean\" },\n conditionConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\nexport type ConditionalTaskConfig = TaskConfig & {\n /** Branches may contain ConditionFn functions — not JSON-schema-representable */\n readonly branches?: BranchConfig<any>[];\n readonly defaultBranch?: string;\n readonly exclusive?: boolean;\n /** Serializable UI condition configuration used to build branches at runtime. */\n readonly conditionConfig?: UIConditionConfig;\n};\n\n// ============================================================================\n// ConditionalTask Class\n// ============================================================================\n\n/**\n * A task that evaluates conditions to determine which downstream paths are active.\n *\n * ConditionalTask implements conditional branching within a task graph, similar to\n * if/then/else or switch/case statements. It evaluates configured conditions against\n * its input and selectively enables output ports for active branches while disabling\n * dataflows to inactive branches.\n *\n * ## Key Features\n *\n * - **Condition-based routing**: Route data to different downstream tasks based on input values\n * - **Exclusive mode**: Act as a switch/case where only the first matching branch activates\n * - **Multi-path mode**: Enable multiple branches simultaneously when conditions match\n * - **Default branch**: Specify a fallback branch when no conditions match\n * - **Disabled propagation**: Inactive branches result in DISABLED status for downstream tasks\n *\n * ## Execution Modes\n *\n * ### Exclusive Mode (default)\n * In exclusive mode (`exclusive: true`), the task behaves like a switch statement.\n * Branches are evaluated in order, and only the first matching branch becomes active.\n * This is useful for mutually exclusive paths.\n *\n * ### Multi-Path Mode\n * In multi-path mode (`exclusive: false`), all branches whose conditions evaluate\n * to true become active simultaneously. This enables fan-out patterns where the\n * same input triggers multiple downstream processing paths.\n *\n * ## Output Behavior\n *\n * For each active branch, the task passes through its entire input to that branch's\n * output port. Inactive branches receive no data, and their outgoing dataflows are\n * set to DISABLED status, which cascades to downstream tasks that have no other\n * active inputs.\n *\n * @template Input - The input type for the task\n * @template Output - The output type for the task\n * @template Config - The configuration type (must extend ConditionalTaskConfig)\n *\n * @example\n * ```typescript\n * // Simple if/else routing based on a numeric threshold\n * const thresholdRouter = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"high\", condition: (i) => i.value > 100, outputPort: \"highPath\" },\n * { id: \"low\", condition: (i) => i.value <= 100, outputPort: \"lowPath\" },\n * ],\n * }\n * );\n *\n * // Switch/case style routing based on string enum\n * const statusRouter = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"active\", condition: (i) => i.status === \"active\", outputPort: \"active\" },\n * { id: \"pending\", condition: (i) => i.status === \"pending\", outputPort: \"pending\" },\n * { id: \"inactive\", condition: (i) => i.status === \"inactive\", outputPort: \"inactive\" },\n * ],\n * defaultBranch: \"inactive\",\n * exclusive: true,\n * }\n * );\n *\n * // Multi-path fan-out for parallel processing\n * const fanOut = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"log\", condition: () => true, outputPort: \"logger\" },\n * { id: \"process\", condition: () => true, outputPort: \"processor\" },\n * { id: \"archive\", condition: (i) => i.shouldArchive, outputPort: \"archiver\" },\n * ],\n * exclusive: false, // All matching branches activate\n * }\n * );\n * ```\n */\nexport class ConditionalTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends ConditionalTaskConfig = ConditionalTaskConfig,\n> extends Task<Input, Output, Config> {\n /** Task type identifier for serialization and registry lookup */\n static type: TaskTypeName = \"ConditionalTask\";\n\n /** Category for UI organization and filtering */\n static category = \"Flow Control\";\n\n /** Human-readable title for display in UIs */\n static title = \"Condition\";\n static description = \"Route data based on conditions\";\n\n /** This task has dynamic schemas that change based on branch configuration */\n static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return conditionalTaskConfigSchema;\n }\n\n /**\n * Set of branch IDs that are currently active after execution.\n * Populated during execute() and used by the graph runner to\n * determine which dataflows should be enabled vs disabled.\n */\n public activeBranches: Set<string> = new Set();\n\n // ========================================================================\n // Execution methods\n // ========================================================================\n\n /**\n * Evaluates branch conditions and determines which branches are active.\n * Only active branches will have their output ports populated.\n *\n * @param input - The input data to evaluate conditions against\n * @param context - Execution context with signal and progress callback\n * @returns Output with active branch data and metadata\n */\n /**\n * Builds runtime branch configs from serialized UI condition config.\n */\n private buildBranchesFromConditionConfig(\n conditionConfig: UIConditionConfig\n ): BranchConfig<Input>[] {\n if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {\n return [\n {\n id: \"default\",\n condition: () => true,\n outputPort: \"1\",\n },\n ];\n }\n\n return conditionConfig.branches.map((branch, index) => ({\n id: branch.id,\n outputPort: String(index + 1),\n condition: (inputData: Input): boolean => {\n const fieldValue = getNestedValue(inputData as Record<string, unknown>, branch.field);\n return evaluateCondition(fieldValue, branch.operator, branch.value);\n },\n }));\n }\n\n /**\n * Resolves the effective branches to evaluate.\n * Uses config.branches if they have condition functions,\n * otherwise falls back to conditionConfig from input or extras.\n */\n private resolveBranches(input: Input): {\n branches: BranchConfig<Input>[];\n isExclusive: boolean;\n defaultBranch: string | undefined;\n fromConditionConfig: boolean;\n } {\n const configBranches = this.config.branches ?? [];\n\n // If config branches have condition functions, use them directly\n if (configBranches.length > 0 && typeof configBranches[0].condition === \"function\") {\n return {\n branches: configBranches,\n isExclusive: this.config.exclusive ?? true,\n defaultBranch: this.config.defaultBranch,\n fromConditionConfig: false,\n };\n }\n\n // Try to find serialized conditionConfig from input or config\n const conditionConfig =\n ((input as Record<string, unknown>).conditionConfig as UIConditionConfig | undefined) ??\n this.config.conditionConfig;\n\n if (conditionConfig) {\n return {\n branches: this.buildBranchesFromConditionConfig(conditionConfig),\n isExclusive: conditionConfig.exclusive ?? true,\n defaultBranch: conditionConfig.defaultBranch,\n fromConditionConfig: true,\n };\n }\n\n // Fallback: use config branches even if they lack conditions\n return {\n branches: configBranches,\n isExclusive: this.config.exclusive ?? true,\n defaultBranch: this.config.defaultBranch,\n fromConditionConfig: false,\n };\n }\n\n public async execute(input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (context.signal?.aborted) {\n return undefined;\n }\n\n // Clear previous branch activation state\n this.activeBranches.clear();\n\n const { branches, isExclusive, defaultBranch, fromConditionConfig } =\n this.resolveBranches(input);\n\n // Evaluate each branch condition\n for (const branch of branches) {\n try {\n const isActive = branch.condition(input);\n if (isActive) {\n this.activeBranches.add(branch.id);\n if (isExclusive) {\n // In exclusive mode, stop at first match\n break;\n }\n }\n } catch (error) {\n // If condition throws, treat it as false (branch not taken)\n getLogger().warn(`Condition evaluation failed for branch \"${branch.id}\":`, { error });\n }\n }\n\n // If no branch matched and there's a default, use it\n if (this.activeBranches.size === 0 && defaultBranch) {\n const defaultBranchExists = branches.some((b) => b.id === defaultBranch);\n if (defaultBranchExists) {\n this.activeBranches.add(defaultBranch);\n }\n }\n\n // Build output: if from conditionConfig, use the UI-style output building\n if (fromConditionConfig) {\n return this.buildConditionConfigOutput(input, branches, isExclusive);\n }\n\n // Build output: pass through input to active branch ports\n return this.buildOutput(input);\n }\n\n /**\n * Builds output in the UI-style format where inputs are passed through\n * with numbered suffixes based on matched branches.\n */\n protected buildConditionConfigOutput(\n input: Input,\n branches: BranchConfig<Input>[],\n isExclusive: boolean\n ): Output {\n const output: Record<string, unknown> = {};\n\n // Remove conditionConfig from pass-through data\n const { conditionConfig, ...passThrough } = input as Record<string, unknown>;\n const inputKeys = Object.keys(passThrough);\n\n // Find matched branch number\n let matchedBranchNumber: number | null = null;\n for (let i = 0; i < branches.length; i++) {\n if (this.activeBranches.has(branches[i].id)) {\n if (matchedBranchNumber === null) {\n matchedBranchNumber = i + 1;\n }\n }\n }\n\n if (isExclusive) {\n if (matchedBranchNumber !== null) {\n for (const key of inputKeys) {\n output[`${key}_${matchedBranchNumber}`] = passThrough[key];\n }\n } else {\n for (const key of inputKeys) {\n output[`${key}_else`] = passThrough[key];\n }\n }\n } else {\n for (let i = 0; i < branches.length; i++) {\n if (this.activeBranches.has(branches[i].id)) {\n for (const key of inputKeys) {\n output[`${key}_${i + 1}`] = passThrough[key];\n }\n }\n }\n }\n\n return output as Output;\n }\n\n /**\n * Builds the output object with data routed to active branch ports.\n * Each active branch's output port receives the full input data.\n *\n * @param input - The input data to pass through to active branches\n * @returns Output object with active branch ports populated\n */\n protected buildOutput(input: Input): Output {\n const output: Record<string, unknown> = {\n _activeBranches: Array.from(this.activeBranches),\n };\n\n const branches = this.config.branches ?? [];\n\n // For each active branch, populate its output port with the input data\n for (const branch of branches) {\n if (this.activeBranches.has(branch.id)) {\n // Pass through all input properties to the active branch's output port\n output[branch.outputPort] = { ...input };\n }\n }\n\n return output as Output;\n }\n\n // ========================================================================\n // Branch information methods\n // ========================================================================\n\n /**\n * Checks if a specific branch is currently active.\n *\n * @param branchId - The ID of the branch to check\n * @returns true if the branch is active, false otherwise\n *\n * @example\n * ```typescript\n * await conditionalTask.run({ value: 150 });\n * if (conditionalTask.isBranchActive(\"high\")) {\n * console.log(\"High value path was taken\");\n * }\n * ```\n */\n public isBranchActive(branchId: string): boolean {\n return this.activeBranches.has(branchId);\n }\n\n /**\n * Gets the set of currently active branch IDs.\n * Returns a new Set to prevent external modification.\n *\n * @returns Set of active branch IDs\n */\n public getActiveBranches(): Set<string> {\n return new Set(this.activeBranches);\n }\n\n /**\n * Gets a map of output port names to their active status.\n * Useful for inspecting which output ports will have data.\n *\n * @returns Map of output port name to boolean active status\n *\n * @example\n * ```typescript\n * const portStatus = conditionalTask.getPortActiveStatus();\n * for (const [port, isActive] of portStatus) {\n * console.log(`Port ${port}: ${isActive ? \"active\" : \"inactive\"}`);\n * }\n * ```\n */\n public getPortActiveStatus(): Map<string, boolean> {\n const status = new Map<string, boolean>();\n const branches = this.config.branches ?? [];\n\n for (const branch of branches) {\n status.set(branch.outputPort, this.activeBranches.has(branch.id));\n }\n\n return status;\n }\n\n // ========================================================================\n // Schema methods\n // ========================================================================\n\n /**\n * Generates the output schema dynamically based on configured branches.\n * Each branch's output port is defined as an object type that will\n * receive the pass-through input data when active.\n *\n * @returns JSON Schema for the task's output\n */\n static outputSchema(): DataPortSchema {\n // Base schema - actual properties are determined by branch configuration\n return {\n type: \"object\",\n properties: {\n _activeBranches: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"List of active branch IDs after condition evaluation\",\n },\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance method to get output schema with branch-specific ports.\n * Dynamically generates properties based on the configured branches.\n *\n * @returns JSON Schema for the task's output including branch ports\n */\n outputSchema(): DataPortSchema {\n const branches = this.config?.branches ?? [];\n const properties: Record<string, any> = {\n _activeBranches: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"List of active branch IDs after condition evaluation\",\n },\n };\n\n // Add each branch's output port to the schema\n for (const branch of branches) {\n properties[branch.outputPort] = {\n type: \"object\",\n description: `Output for branch \"${branch.id}\" when active`,\n additionalProperties: true,\n };\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n\n /**\n * Returns schema indicating the task accepts any input.\n * ConditionalTask passes through its input to active branches,\n * so it doesn't constrain the input type.\n *\n * @returns Schema that accepts any input\n */\n static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance method returning schema that accepts any input.\n *\n * @returns Schema that accepts any input\n */\n inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n}\n",
13
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Comparison operators supported by the UI condition builder.\n */\nexport type ComparisonOperator =\n | \"equals\"\n | \"not_equals\"\n | \"greater_than\"\n | \"greater_or_equal\"\n | \"less_than\"\n | \"less_or_equal\"\n | \"contains\"\n | \"starts_with\"\n | \"ends_with\"\n | \"is_empty\"\n | \"is_not_empty\"\n | \"is_true\"\n | \"is_false\";\n\n/**\n * Serialized condition branch configuration from the UI builder.\n * Used by ConditionalTask to auto-build runtime condition functions.\n */\nexport interface UIConditionBranch {\n id: string;\n field: string;\n operator: ComparisonOperator;\n value: string;\n}\n\n/**\n * Serialized condition configuration from the UI builder.\n * Used by ConditionalTask to auto-build runtime branch configs.\n */\nexport interface UIConditionConfig {\n branches: UIConditionBranch[];\n exclusive: boolean;\n defaultBranch?: string;\n}\n\n/**\n * Evaluates a condition based on operator type.\n *\n * @param fieldValue - The value of the field being tested\n * @param operator - The comparison operator to apply\n * @param compareValue - The value to compare against (always a string from the UI)\n * @returns true if the condition is met, false otherwise\n */\nexport function evaluateCondition(\n fieldValue: unknown,\n operator: ComparisonOperator,\n compareValue: string\n): boolean {\n // Handle null/undefined\n if (fieldValue === null || fieldValue === undefined) {\n switch (operator) {\n case \"is_empty\":\n return true;\n case \"is_not_empty\":\n return false;\n case \"is_true\":\n return false;\n case \"is_false\":\n return true;\n default:\n return false;\n }\n }\n\n const strValue = String(fieldValue);\n const numValue = Number(fieldValue);\n\n switch (operator) {\n case \"equals\":\n // Try numeric comparison first, then string\n if (!isNaN(numValue) && !isNaN(Number(compareValue))) {\n return numValue === Number(compareValue);\n }\n return strValue === compareValue;\n\n case \"not_equals\":\n if (!isNaN(numValue) && !isNaN(Number(compareValue))) {\n return numValue !== Number(compareValue);\n }\n return strValue !== compareValue;\n\n case \"greater_than\":\n return numValue > Number(compareValue);\n\n case \"greater_or_equal\":\n return numValue >= Number(compareValue);\n\n case \"less_than\":\n return numValue < Number(compareValue);\n\n case \"less_or_equal\":\n return numValue <= Number(compareValue);\n\n case \"contains\":\n return strValue.toLowerCase().includes(compareValue.toLowerCase());\n\n case \"starts_with\":\n return strValue.toLowerCase().startsWith(compareValue.toLowerCase());\n\n case \"ends_with\":\n return strValue.toLowerCase().endsWith(compareValue.toLowerCase());\n\n case \"is_empty\":\n return strValue === \"\" || (Array.isArray(fieldValue) && fieldValue.length === 0);\n\n case \"is_not_empty\":\n return strValue !== \"\" && !(Array.isArray(fieldValue) && fieldValue.length === 0);\n\n case \"is_true\":\n return Boolean(fieldValue) === true;\n\n case \"is_false\":\n return Boolean(fieldValue) === false;\n\n default:\n return false;\n }\n}\n\n/**\n * Get a value from a nested object using dot notation.\n * e.g., \"user.name\" would get obj.user.name\n *\n * @param obj - The object to read from\n * @param path - Dot-separated path to the value\n * @returns The value at the path, or undefined if any segment is missing\n */\nexport function getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n\n return current;\n}\n",
14
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { compileSchema, type DataPortSchema, type SchemaNode } from \"@workglow/util/schema\";\nimport { deepEqual, EventEmitter, uuid4, type ServiceRegistry } from \"@workglow/util\";\nimport { DATAFLOW_ALL_PORTS } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport type { IExecuteContext, IExecuteReactiveContext, IRunConfig, ITask } from \"./ITask\";\nimport {\n TaskAbortedError,\n TaskConfigurationError,\n TaskError,\n TaskInvalidInputError,\n} from \"./TaskError\";\nimport {\n type TaskEventListener,\n type TaskEventListeners,\n type TaskEventParameters,\n type TaskEvents,\n} from \"./TaskEvents\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport { TaskRunner } from \"./TaskRunner\";\nimport {\n TaskConfigSchema,\n TaskStatus,\n type TaskConfig,\n type TaskIdType,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\n/**\n * Base class for all tasks that implements the ITask interface.\n * This abstract class provides common functionality for both simple and compound tasks.\n *\n * The Task class is responsible for:\n * 1. Defining what a task is (inputs, outputs, configuration)\n * 2. Providing the execution logic (via execute and executeReactive)\n * 3. Delegating the running logic to a TaskRunner\n */\nexport class Task<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends TaskConfig = TaskConfig,\n> implements ITask<Input, Output, Config> {\n // ========================================================================\n // Static properties - should be overridden by subclasses\n // ========================================================================\n\n /**\n * The type identifier for this task class\n */\n public static type: TaskTypeName = \"Task\";\n\n /**\n * The category this task belongs to\n */\n public static category: string = \"Hidden\";\n\n /**\n * The title of this task\n */\n public static title: string = \"\";\n\n /**\n * The description of this task\n */\n public static description: string = \"\";\n\n /**\n * Whether this task has side effects\n */\n public static cacheable: boolean = true;\n\n /**\n * Whether this task has dynamic input/output schemas that can change at runtime.\n * Tasks with dynamic schemas should override instance methods for inputSchema() and/or outputSchema()\n * and emit 'schemaChange' events when their schemas change.\n */\n public static hasDynamicSchemas: boolean = false;\n\n /**\n * When true, dynamically added input ports (via the universal \"Add Input\" handle in the builder)\n * are mirrored as output ports of the same name and type. Set this on pass-through tasks that\n * forward their additional inputs to their outputs unchanged.\n */\n public static passthroughInputsToOutputs: boolean = false;\n\n /**\n * When true, this task can be saved as a custom task with a preset configuration.\n * Tasks that have meaningful user-facing config options beyond the base fields should set this.\n */\n public static customizable: boolean = false;\n\n /**\n * Input schema for this task\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Output schema for this task\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Config schema for this task. Subclasses that add config properties MUST override this\n * and spread TaskConfigSchema[\"properties\"] into their own properties object.\n */\n public static configSchema(): DataPortSchema {\n return TaskConfigSchema;\n }\n\n // ========================================================================\n // Task Execution Methods - Core logic provided by subclasses\n // ========================================================================\n\n /**\n * The actual task execution logic for subclasses to override\n *\n * @param input The input to the task\n * @param config The configuration for the task\n * @throws TaskError if the task fails\n * @returns The output of the task or undefined if no changes\n */\n public async execute(_input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (context.signal?.aborted) {\n throw new TaskAbortedError(\"Task aborted\");\n }\n return undefined;\n }\n\n /**\n * Default implementation of executeReactive that does nothing.\n * Subclasses should override this to provide actual reactive functionality.\n *\n * This is generally for UI updating, and should be lightweight.\n * @param input The input to the task\n * @param output The current output of the task\n * @returns The updated output of the task or undefined if no changes\n */\n public async executeReactive(\n _input: Input,\n output: Output,\n _context: IExecuteReactiveContext\n ): Promise<Output | undefined> {\n return output;\n }\n\n // ========================================================================\n // TaskRunner delegation - Executes and manages the task\n // ========================================================================\n\n /**\n * Task runner for handling the task execution\n */\n protected _runner: TaskRunner<Input, Output, Config> | undefined;\n\n /**\n * Gets the task runner instance\n * Creates a new one if it doesn't exist\n */\n public get runner(): TaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new TaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n /**\n * Runs the task and returns the output\n * Delegates to the task runner\n *\n * @param overrides Optional input overrides\n * @param runConfig Optional per-call run configuration (merged with task's runConfig)\n * @throws TaskError if the task fails\n * @returns The task output\n */\n async run(overrides: Partial<Input> = {}, runConfig: Partial<IRunConfig> = {}): Promise<Output> {\n return this.runner.run(overrides, { ...this.runConfig, ...runConfig });\n }\n\n /**\n * Runs the task in reactive mode\n * Delegates to the task runner\n *\n * @param overrides Optional input overrides\n * @returns The task output\n */\n public async runReactive(overrides: Partial<Input> = {}): Promise<Output> {\n return this.runner.runReactive(overrides);\n }\n\n /**\n * Aborts task execution\n * Delegates to the task runner\n */\n public abort(): void {\n this.runner.abort();\n }\n\n /**\n * Disables task execution\n * Delegates to the task runner\n */\n public async disable(): Promise<void> {\n await this.runner.disable();\n }\n\n // ========================================================================\n // Static to Instance conversion methods\n // ========================================================================\n\n /**\n * Gets input schema for this task\n */\n public inputSchema(): DataPortSchema {\n return (this.constructor as typeof Task).inputSchema();\n }\n\n /**\n * Gets output schema for this task\n */\n public outputSchema(): DataPortSchema {\n return (this.constructor as typeof Task).outputSchema();\n }\n\n /**\n * Gets config schema for this task\n */\n public configSchema(): DataPortSchema {\n return (this.constructor as typeof Task).configSchema();\n }\n\n public get type(): TaskTypeName {\n return (this.constructor as typeof Task).type;\n }\n\n public get category(): string {\n return (this.constructor as typeof Task).category;\n }\n\n public get title(): string {\n return this.config?.title ?? (this.constructor as typeof Task).title;\n }\n\n public get description(): string {\n return this.config?.description ?? (this.constructor as typeof Task).description;\n }\n\n public get cacheable(): boolean {\n return (\n this.runConfig?.cacheable ??\n this.config?.cacheable ??\n (this.constructor as typeof Task).cacheable\n );\n }\n\n // ========================================================================\n // Instance properties using @template types\n // ========================================================================\n\n /**\n * Default input values for this task.\n * If no overrides at run time, then this would be equal to the input.\n * resetInputData() will reset inputs to these defaults.\n */\n defaults: Record<string, any>;\n\n /**\n * The input to the task at the time of the task run.\n * This takes defaults from construction time and overrides from run time.\n * It is the input that created the output.\n */\n runInputData: Record<string, any> = {};\n\n /**\n * The output of the task at the time of the task run.\n * This is the result of the task execution.\n */\n runOutputData: Record<string, any> = {};\n\n // ========================================================================\n // Task state properties\n // ========================================================================\n\n /**\n * The configuration of the task\n */\n config: Config;\n\n /**\n * Task id from config (read-only).\n */\n public get id(): unknown {\n return this.config.id;\n }\n\n /**\n * Runtime configuration (not serialized with the task).\n * Set via the constructor's third argument or mutated by the graph runner.\n */\n runConfig: Partial<IRunConfig> = {};\n\n /**\n * Current status of the task\n */\n status: TaskStatus = TaskStatus.PENDING;\n\n /**\n * Progress of the task (0-100)\n */\n progress: number = 0;\n\n /**\n * When the task was created\n */\n createdAt: Date = new Date();\n\n /**\n * When the task started execution\n */\n startedAt?: Date;\n\n /**\n * When the task completed execution\n */\n completedAt?: Date;\n\n /**\n * Error that occurred during task execution, if any\n */\n error?: TaskError;\n\n /**\n * Event emitter for task lifecycle events\n */\n public get events(): EventEmitter<TaskEventListeners> {\n if (!this._events) {\n this._events = new EventEmitter<TaskEventListeners>();\n }\n return this._events;\n }\n protected _events: EventEmitter<TaskEventListeners> | undefined;\n\n /**\n * Creates a new task instance\n *\n * @param callerDefaultInputs Default input values provided by the caller\n * @param config Configuration for the task\n */\n constructor(\n callerDefaultInputs: Partial<Input> = {},\n config: Partial<Config> = {},\n runConfig: Partial<IRunConfig> = {}\n ) {\n // Initialize input defaults\n const inputDefaults = this.getDefaultInputsFromStaticInputDefinitions();\n const mergedDefaults = Object.assign(inputDefaults, callerDefaultInputs);\n // Strip symbol properties (like [$JSONSchema]) before storing defaults\n this.defaults = this.stripSymbols(mergedDefaults) as Record<string, any>;\n this.resetInputData();\n\n // Setup configuration defaults (title comes from static class property as fallback)\n const title = (this.constructor as typeof Task).title || undefined;\n const baseConfig = Object.assign(\n {\n ...(title ? { title } : {}),\n },\n config\n ) as Config;\n if (baseConfig.id === undefined) {\n (baseConfig as Record<string, unknown>).id = uuid4();\n }\n this.config = this.validateAndApplyConfigDefaults(baseConfig);\n\n // Store runtime configuration\n this.runConfig = runConfig;\n }\n\n // ========================================================================\n // Input/Output handling\n // ========================================================================\n\n /**\n * Gets default input values from input schema\n */\n getDefaultInputsFromStaticInputDefinitions(): Partial<Input> {\n const schema = this.inputSchema();\n if (typeof schema === \"boolean\") {\n return {};\n }\n try {\n const compiledSchema = this.getInputSchemaNode();\n const defaultData = compiledSchema.getData(undefined, {\n addOptionalProps: true,\n removeInvalidData: false,\n useTypeDefaults: false,\n });\n return (defaultData || {}) as Partial<Input>;\n } catch (error) {\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to manual extraction:`,\n error\n );\n // Fallback to manual extraction if compilation fails\n return Object.entries(schema.properties || {}).reduce<Record<string, any>>(\n (acc, [id, prop]) => {\n const defaultValue = (prop as any).default;\n if (defaultValue !== undefined) {\n acc[id] = defaultValue;\n }\n return acc;\n },\n {}\n ) as Partial<Input>;\n }\n }\n\n /**\n * Resets input data to defaults\n */\n public resetInputData(): void {\n this.runInputData = this.smartClone(this.defaults) as Record<string, any>;\n }\n\n /**\n * Smart clone that deep-clones plain objects and arrays while preserving\n * class instances (objects with non-Object prototype) by reference.\n * Detects and throws an error on circular references.\n *\n * This is necessary because:\n * - structuredClone cannot clone class instances (methods are lost)\n * - JSON.parse/stringify loses methods and fails on circular references\n * - Class instances like repositories should be passed by reference\n *\n * This breaks the idea of everything being json serializable, but it allows\n * more efficient use cases. Do be careful with this though! Use sparingly.\n *\n * @param obj The object to clone\n * @param visited Set of objects in the current cloning path (for circular reference detection)\n * @returns A cloned object with class instances preserved by reference\n */\n private smartClone(obj: any, visited: WeakSet<object> = new WeakSet()): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // Primitives (string, number, boolean, symbol, bigint) are returned as-is\n if (typeof obj !== \"object\") {\n return obj;\n }\n\n // Check for circular references\n if (visited.has(obj)) {\n throw new TaskConfigurationError(\n \"Circular reference detected in input data. \" +\n \"Cannot clone objects with circular references.\"\n );\n }\n\n // Clone TypedArrays (Float32Array, Int8Array, etc.) to avoid shared-mutation\n // between defaults and runInputData, while preserving DataView by reference.\n if (ArrayBuffer.isView(obj)) {\n // Preserve DataView instances by reference (constructor signature differs)\n if (typeof DataView !== \"undefined\" && obj instanceof DataView) {\n return obj;\n }\n // For TypedArrays, create a new instance with the same data\n const typedArray = obj as any;\n return new (typedArray.constructor as any)(typedArray);\n }\n\n // Preserve class instances (objects with non-Object/non-Array prototype)\n // This includes repository instances, custom classes, etc.\n if (!Array.isArray(obj)) {\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n return obj; // Pass by reference\n }\n }\n\n // Add object to visited set before recursing\n visited.add(obj);\n\n try {\n // Deep clone arrays, preserving class instances within\n if (Array.isArray(obj)) {\n return obj.map((item) => this.smartClone(item, visited));\n }\n\n // Deep clone plain objects\n const result: Record<string, any> = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = this.smartClone(obj[key], visited);\n }\n }\n return result;\n } finally {\n // Remove from visited set after processing to allow the same object\n // in different branches (non-circular references)\n visited.delete(obj);\n }\n }\n\n /**\n * Sets the default input values for the task\n *\n * @param defaults The default input values to set\n */\n public setDefaults(defaults: Partial<Input>): void {\n // Strip symbol properties (like [$JSONSchema]) before storing defaults\n this.defaults = this.stripSymbols(defaults) as Partial<Input>;\n }\n\n /**\n * Sets input values for the task\n *\n * @param input Input values to set\n */\n public setInput(input: Partial<Input>): void {\n const schema = this.inputSchema();\n if (typeof schema === \"boolean\") {\n if (schema === true) {\n for (const [inputId, value] of Object.entries(input)) {\n if (value !== undefined) {\n this.runInputData[inputId] = value;\n }\n }\n }\n return;\n }\n const properties = schema.properties || {};\n\n // Copy explicitly defined properties\n for (const [inputId, prop] of Object.entries(properties)) {\n if (input[inputId] !== undefined) {\n this.runInputData[inputId] = input[inputId];\n } else if (this.runInputData[inputId] === undefined && (prop as any).default !== undefined) {\n this.runInputData[inputId] = (prop as any).default;\n }\n }\n\n // If additionalProperties is true, also copy any additional input properties\n if (schema.additionalProperties) {\n for (const [inputId, value] of Object.entries(input)) {\n if (!(inputId in properties)) {\n this.runInputData[inputId] = value;\n }\n }\n }\n }\n\n /**\n * Adds/merges input data during graph execution.\n * Unlike {@link setInput}, this method:\n * - Detects changes using deep equality\n * - Accumulates array values (appends rather than replaces)\n * - Handles DATAFLOW_ALL_PORTS for pass-through\n * - Handles additionalProperties for dynamic schemas\n *\n * @param overrides The input data to merge\n * @returns true if any input data was changed, false otherwise\n */\n public addInput(overrides: Partial<Input> | undefined): boolean {\n if (!overrides) return false;\n\n let changed = false;\n const inputSchema = this.inputSchema();\n\n if (typeof inputSchema === \"boolean\") {\n if (inputSchema === false) {\n return false;\n }\n // Schema is `true` - accept any input\n for (const [key, value] of Object.entries(overrides)) {\n if (!deepEqual(this.runInputData[key], value)) {\n this.runInputData[key] = value;\n changed = true;\n }\n }\n return changed;\n }\n\n const properties = inputSchema.properties || {};\n\n for (const [inputId, prop] of Object.entries(properties)) {\n if (inputId === DATAFLOW_ALL_PORTS) {\n this.runInputData = { ...this.runInputData, ...overrides };\n changed = true;\n } else {\n if (overrides[inputId] === undefined) continue;\n const isArray =\n (prop as any)?.type === \"array\" ||\n ((prop as any)?.type === \"any\" &&\n (Array.isArray(overrides[inputId]) || Array.isArray(this.runInputData[inputId])));\n\n if (isArray) {\n const existingItems = Array.isArray(this.runInputData[inputId])\n ? this.runInputData[inputId]\n : this.runInputData[inputId] !== undefined\n ? [this.runInputData[inputId]]\n : [];\n const newitems = [...existingItems];\n\n const overrideItem = overrides[inputId];\n if (Array.isArray(overrideItem)) {\n newitems.push(...overrideItem);\n } else {\n newitems.push(overrideItem);\n }\n this.runInputData[inputId] = newitems;\n changed = true;\n } else {\n if (!deepEqual(this.runInputData[inputId], overrides[inputId])) {\n this.runInputData[inputId] = overrides[inputId];\n changed = true;\n }\n }\n }\n }\n\n // If additionalProperties is true, also accept any additional input properties\n if (inputSchema.additionalProperties) {\n for (const [inputId, value] of Object.entries(overrides)) {\n if (!(inputId in properties)) {\n if (!deepEqual(this.runInputData[inputId], value)) {\n this.runInputData[inputId] = value;\n changed = true;\n }\n }\n }\n }\n\n return changed;\n }\n\n /**\n * Stub for narrowing input. Override in subclasses for custom logic.\n * @param input The input to narrow\n * @param _registry Optional service registry for lookups\n * @returns The (possibly narrowed) input\n */\n public async narrowInput(\n input: Partial<Input>,\n _registry: ServiceRegistry\n ): Promise<Partial<Input>> {\n return input;\n }\n\n // ========================================================================\n // Event handling methods\n // ========================================================================\n\n /**\n * Subscribes to an event\n */\n public subscribe<Event extends TaskEvents>(\n name: Event,\n fn: TaskEventListener<Event>\n ): () => void {\n return this.events.subscribe(name, fn);\n }\n\n /**\n * Registers an event listener\n */\n public on<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.on(name, fn);\n }\n\n /**\n * Removes an event listener\n */\n public off<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.off(name, fn);\n }\n\n /**\n * Registers a one-time event listener\n */\n public once<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.once(name, fn);\n }\n\n /**\n * Returns a promise that resolves when the specified event is emitted\n */\n public waitOn<Event extends TaskEvents>(name: Event): Promise<TaskEventParameters<Event>> {\n return this.events.waitOn(name) as Promise<TaskEventParameters<Event>>;\n }\n\n /**\n * Emits an event\n */\n public emit<Event extends TaskEvents>(name: Event, ...args: TaskEventParameters<Event>): void {\n // Route through `events` so the emitter exists: `this._events?.emit` dropped progress when\n // nothing had accessed `task.events` yet (e.g. parent MapTask before CLI wired listeners).\n this.events.emit(name, ...args);\n }\n\n /**\n * Emits a schemaChange event when the task's input or output schema changes.\n * This should be called by tasks with dynamic schemas when their configuration\n * changes in a way that affects their schemas.\n *\n * @param inputSchema - The new input schema (optional, will use current schema if not provided)\n * @param outputSchema - The new output schema (optional, will use current schema if not provided)\n */\n protected emitSchemaChange(inputSchema?: DataPortSchema, outputSchema?: DataPortSchema): void {\n const finalInputSchema = inputSchema ?? this.inputSchema();\n const finalOutputSchema = outputSchema ?? this.outputSchema();\n this.emit(\"schemaChange\", finalInputSchema, finalOutputSchema);\n }\n\n // ========================================================================\n // Input validation methods\n // ========================================================================\n\n /**\n * Gets the compiled config schema node, or undefined if no configSchema is defined.\n *\n * The compiled schema is cached directly on the concrete class object (not in a shared\n * inherited Map) so that each subclass always uses its own configSchema() result.\n * A shared Map keyed only by type name can be poisoned if a different class computes\n * and caches the schema first — e.g., due to cross-package static-method resolution\n * inconsistencies in bundled outputs.\n */\n private static getConfigSchemaNode(): SchemaNode | undefined {\n const schema = this.configSchema();\n if (!schema) return undefined;\n // Use Object.hasOwn so each class gets its own entry rather than inheriting\n // from a parent class that already cached under the same key.\n if (!Object.hasOwn(this, \"__compiledConfigSchema\")) {\n try {\n const schemaNode =\n typeof schema === \"boolean\"\n ? compileSchema(schema ? {} : { not: {} })\n : compileSchema(schema);\n Object.defineProperty(this, \"__compiledConfigSchema\", {\n value: schemaNode,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n console.warn(`Failed to compile config schema for ${this.type}:`, error);\n return undefined;\n }\n }\n return (this as any).__compiledConfigSchema as SchemaNode;\n }\n\n /**\n * Validates config against configSchema.\n * Returns config as-is; throws on validation errors.\n * Returns config as-is if no configSchema is defined.\n */\n private validateAndApplyConfigDefaults(config: Config): Config {\n const ctor = this.constructor as typeof Task;\n const schemaNode = ctor.getConfigSchemaNode();\n if (!schemaNode) return config;\n\n const result = schemaNode.validate(config);\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => {\n const path = (e as any).data?.pointer || \"\";\n return `${e.message}${path ? ` (${path})` : \"\"}`;\n });\n throw new TaskConfigurationError(\n `[${ctor.name}] Configuration Error: ${errorMessages.join(\", \")}`\n );\n }\n\n return config;\n }\n\n protected static generateInputSchemaNode(schema: DataPortSchema) {\n if (typeof schema === \"boolean\") {\n if (schema === false) {\n return compileSchema({ not: {} });\n }\n return compileSchema({});\n }\n return compileSchema(schema);\n }\n\n /**\n * Gets the compiled input schema, cached per class (not in a shared inherited Map).\n * Uses Object.hasOwn so each subclass stores its own compiled schema and never\n * picks up a stale entry cached by a different class with the same type name.\n */\n protected static getInputSchemaNode(): SchemaNode {\n if (!Object.hasOwn(this, \"__compiledInputSchema\")) {\n const dataPortSchema = this.inputSchema();\n const schemaNode = this.generateInputSchemaNode(dataPortSchema);\n try {\n Object.defineProperty(this, \"__compiledInputSchema\", {\n value: schemaNode,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n // If compilation fails, fall back to accepting any object structure\n // This is a safety net for schemas that json-schema-library can't compile\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to permissive validation:`,\n error\n );\n Object.defineProperty(this, \"__compiledInputSchema\", {\n value: compileSchema({}),\n writable: true,\n configurable: true,\n enumerable: false,\n });\n }\n }\n return (this as any).__compiledInputSchema as SchemaNode;\n }\n\n protected getInputSchemaNode(): SchemaNode {\n return (this.constructor as typeof Task).getInputSchemaNode();\n }\n\n /**\n * Validates an input data object against the task's input schema\n */\n public async validateInput(input: Input): Promise<boolean> {\n if (typeof input !== \"object\" || input === null) {\n throw new TaskInvalidInputError(\"Input must be an object\");\n }\n const ctor = this.constructor as typeof Task;\n let schemaNode: SchemaNode;\n if (ctor.hasDynamicSchemas) {\n // Dynamic-schema tasks use instance inputSchema() (e.g. config.inputSchema), not the static fallback.\n // The cached getInputSchemaNode uses static inputSchema() which would reject valid instance-specific inputs.\n const instanceSchema = this.inputSchema();\n schemaNode = ctor.generateInputSchemaNode(instanceSchema);\n } else {\n schemaNode = this.getInputSchemaNode();\n }\n const result = schemaNode.validate(input);\n\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => {\n const path = e.data.pointer || \"\";\n return `${e.message}${path ? ` (${path})` : \"\"}`;\n });\n throw new TaskInvalidInputError(\n `Input ${JSON.stringify(Object.keys(input))} does not match schema: ${errorMessages.join(\", \")}`\n );\n }\n\n return true;\n }\n\n // ========================================================================\n // Serialization methods\n // ========================================================================\n\n /**\n * Strips symbol properties from an object to make it serializable\n * @param obj The object to strip symbols from\n * @returns A new object without symbol properties\n */\n private stripSymbols(obj: any): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n // Preserve TypedArrays (Float32Array, Int8Array, etc.)\n if (ArrayBuffer.isView(obj)) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map((item) => this.stripSymbols(item));\n }\n if (typeof obj === \"object\") {\n const result: Record<string, any> = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = this.stripSymbols(obj[key]);\n }\n }\n return result;\n }\n return obj;\n }\n\n /**\n * Serializes the task and its subtasks into a format that can be stored\n * @param _options Options controlling serialization (used by subclasses)\n * @returns The serialized task and subtasks\n */\n public toJSON(_options?: TaskGraphJsonOptions): TaskGraphItemJson {\n const ctor = this.constructor as typeof Task;\n\n // Build config by extracting only serializable properties defined in the configSchema.\n // We filter through the schema to avoid accidentally including non-serializable\n // values (e.g. functions like WhileTask.condition) or internal-only properties\n // that were never part of the serialized output and that consuming applications\n // don't expect (e.g. `queue` from JobQueueTask).\n const schema = ctor.configSchema();\n const schemaProperties =\n typeof schema !== \"boolean\" && schema?.properties\n ? (schema.properties as Record<string, Record<string, unknown>>)\n : {};\n\n const config: Record<string, unknown> = {};\n for (const [key, propSchema] of Object.entries(schemaProperties)) {\n if (key === \"id\") continue;\n // Skip internal properties marked as hidden (e.g. queue, compoundMerge)\n // except inputSchema/outputSchema/extras which are needed for task reconstruction\n if (\n propSchema?.[\"x-ui-hidden\"] === true &&\n key !== \"inputSchema\" &&\n key !== \"outputSchema\" &&\n key !== \"extras\"\n ) {\n continue;\n }\n const value = (this.config as Record<string, unknown>)[key];\n if (value === undefined) continue;\n // Skip non-serializable values (functions, symbols, etc.)\n if (typeof value === \"function\" || typeof value === \"symbol\") continue;\n config[key] = value;\n }\n\n // Omit title/description when they match the static class defaults\n if (config.title === ctor.title) delete config.title;\n if (config.description === ctor.description) delete config.description;\n\n // Omit empty extras\n const extras = config.extras as Record<string, unknown> | undefined;\n if (!extras || Object.keys(extras).length === 0) delete config.extras;\n\n const base: TaskGraphItemJson = {\n id: this.id,\n type: this.type,\n defaults: this.defaults,\n };\n if (Object.keys(config).length > 0) {\n base.config = config;\n }\n return this.stripSymbols(base) as TaskGraphItemJson;\n }\n\n /**\n * Converts the task to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (used by subclasses)\n * @returns The task and subtasks in JSON thats easier for humans to read\n */\n public toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem {\n const json = this.toJSON(options);\n return json;\n }\n\n // ========================================================================\n // Internal graph methods\n // ========================================================================\n\n /**\n * Checks if the task has children. Useful to gate to use of the internal subGraph\n * as this will return without creating a new graph if graph is non-existent .\n *\n * @returns True if the task has children, otherwise false\n */\n public hasChildren(): boolean {\n return (\n this._subGraph !== undefined &&\n this._subGraph !== null &&\n this._subGraph.getTasks().length > 0\n );\n }\n\n private _taskAddedListener: (taskId: TaskIdType) => void = () => {\n this.emit(\"regenerate\");\n };\n\n /**\n * The internal task graph containing subtasks\n *\n * In the base case, these may just be incidental tasks that are not part of the task graph\n * but are used to manage the task's state as part of task execution. Therefore, the graph\n * is not used by the default runner.\n */\n protected _subGraph: TaskGraph | undefined = undefined;\n\n /**\n * Sets the subtask graph for the compound task\n * @param subGraph The subtask graph to set\n */\n set subGraph(subGraph: TaskGraph) {\n if (this._subGraph) {\n this._subGraph.off(\"task_added\", this._taskAddedListener);\n }\n this._subGraph = subGraph;\n this._subGraph.on(\"task_added\", this._taskAddedListener);\n }\n\n /**\n * The internal task graph containing subtasks\n *\n * In the base case, these may just be incidental tasks that are not part of the task graph\n * but are used to manage the task's state as part of task execution. Therefore, the graph\n * is not used by the default runner.\n *\n * Creates a new graph if one doesn't exist.\n *\n * @returns The task graph\n */\n get subGraph(): TaskGraph {\n if (!this._subGraph) {\n this._subGraph = new TaskGraph();\n this._subGraph.on(\"task_added\", this._taskAddedListener);\n }\n return this._subGraph;\n }\n\n /**\n * Regenerates the task graph, which is internal state to execute() with config.own()\n *\n * This is a destructive operation that removes all dataflows and tasks from the graph.\n * It is used to reset the graph to a clean state.\n *\n * GraphAsTask and others override this and do not call super\n */\n public regenerateGraph(): void {\n if (this.hasChildren()) {\n for (const dataflow of this.subGraph.getDataflows()) {\n this.subGraph.removeDataflow(dataflow);\n }\n for (const child of this.subGraph.getTasks()) {\n this.subGraph.removeTask(child.id);\n }\n }\n this.events.emit(\"regenerate\");\n }\n}\n",
15
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { JobError } from \"@workglow/job-queue\";\nimport { BaseError } from \"@workglow/util\";\n\nexport class TaskError extends BaseError {\n static readonly type: string = \"TaskError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task configuration error\n *\n */\nexport class TaskConfigurationError extends TaskError {\n static readonly type: string = \"TaskConfigurationError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task workflow error\n */\nexport class WorkflowError extends TaskError {\n static readonly type: string = \"WorkflowError\";\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by a task being aborted\n *\n * Examples: task.abort() was called, or some other reason an abort signal was received\n */\nexport class TaskAbortedError extends TaskError {\n static readonly type: string = \"TaskAbortedError\";\n constructor(message: string = \"Task aborted\") {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by a task exceeding its timeout\n *\n * Examples: task.runConfig.timeout exceeded during execution\n */\nexport class TaskTimeoutError extends TaskAbortedError {\n static readonly type: string = \"TaskTimeoutError\";\n constructor(timeoutMs?: number) {\n super(timeoutMs ? `Task timed out after ${timeoutMs}ms` : \"Task timed out\");\n }\n}\n\n/**\n * A task error that is caused by a task failing\n *\n * Examples: task.run() threw an error\n */\nexport class TaskFailedError extends TaskError {\n static readonly type: string = \"TaskFailedError\";\n constructor(message: string = \"Task failed\") {\n super(message);\n }\n}\n\nexport class JobTaskFailedError extends TaskFailedError {\n static readonly type: string = \"JobTaskFailedError\";\n public jobError: JobError;\n constructor(err: JobError) {\n super(String(err));\n this.jobError = err;\n }\n}\n\n/**\n * A task error that is caused by an error converting JSON to a Task\n */\nexport class TaskJSONError extends TaskError {\n static readonly type: string = \"TaskJSONError\";\n constructor(message: string = \"Error converting JSON to a Task\") {\n super(message);\n }\n}\n\n/**\n * A task error that is caused by invalid input data\n *\n * Examples: task.run() received invalid input data\n */\nexport class TaskInvalidInputError extends TaskError {\n static readonly type: string = \"TaskInvalidInputError\";\n constructor(message: string = \"Invalid input data\") {\n super(message);\n }\n}\n",
16
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n getTelemetryProvider,\n globalServiceRegistry,\n ServiceRegistry,\n SpanStatusCode,\n type ISpan,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ensureTask, type Taskish } from \"../task-graph/Conversions\";\nimport { resolveSchemaInputs } from \"./InputResolver\";\nimport { IRunConfig, ITask } from \"./ITask\";\nimport { ITaskRunner } from \"./ITaskRunner\";\nimport {\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n type StreamEvent,\n type StreamMode,\n} from \"./StreamTypes\";\nimport { Task } from \"./Task\";\nimport {\n TaskAbortedError,\n TaskError,\n TaskFailedError,\n TaskInvalidInputError,\n TaskTimeoutError,\n} from \"./TaskError\";\nimport { TaskConfig, TaskInput, TaskOutput, TaskStatus } from \"./TaskTypes\";\n\n/**\n * Type guard that checks whether a value is an ITask-like object with a mutable `runConfig`.\n */\nfunction hasRunConfig(i: unknown): i is { runConfig: Partial<IRunConfig> } {\n return i !== null && typeof i === \"object\" && \"runConfig\" in (i as object);\n}\n\n/**\n * Responsible for running tasks\n * Manages the execution lifecycle of individual tasks\n */\nexport class TaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends TaskConfig = TaskConfig,\n> implements ITaskRunner<Input, Output, Config> {\n /**\n * Whether the task is currently running\n */\n protected running = false;\n protected reactiveRunning = false;\n\n /**\n * The task to run\n */\n public readonly task: ITask<Input, Output, Config>;\n\n /**\n * AbortController for cancelling task execution\n */\n protected abortController?: AbortController;\n\n /**\n * The output cache for the task\n */\n protected outputCache?: TaskOutputRepository;\n\n /**\n * The service registry for the task\n */\n protected registry: ServiceRegistry = globalServiceRegistry;\n\n /**\n * Input streams for pass-through streaming tasks.\n * Set by the graph runner before executing a streaming task that has\n * upstream streaming edges. Keyed by input port name.\n */\n public inputStreams?: Map<string, ReadableStream<StreamEvent>>;\n\n /**\n * Timer handle for task-level timeout. Set when `IRunConfig.timeout` is\n * provided and cleared on completion, error, or abort.\n */\n protected timeoutTimer?: ReturnType<typeof setTimeout>;\n\n /**\n * When a timeout triggers the abort, this holds the TaskTimeoutError so\n * handleAbort() can surface the correct error type instead of a generic\n * TaskAbortedError.\n */\n protected pendingTimeoutError?: TaskTimeoutError;\n\n /**\n * Whether the streaming task runner should accumulate text-delta chunks and\n * emit an enriched finish event. Set from IRunConfig.shouldAccumulate.\n * Defaults to true so standalone task execution is backward-compatible.\n * The graph runner sets this to false when no downstream edge needs\n * materialized data (no cache, all downstream tasks are also streaming).\n */\n protected shouldAccumulate: boolean = true;\n\n /**\n * Active telemetry span for the current task run.\n */\n protected telemetrySpan?: ISpan;\n\n /**\n * Constructor for TaskRunner\n * @param task The task to run\n */\n constructor(task: ITask<Input, Output, Config>) {\n this.task = task;\n this.own = this.own.bind(this);\n this.handleProgress = this.handleProgress.bind(this);\n }\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n /**\n * Runs the task and returns the output\n * @param overrides Optional input overrides\n * @param config Optional configuration overrides\n * @returns The task output\n */\n async run(overrides: Partial<Input> = {}, config: IRunConfig = {}): Promise<Output> {\n await this.handleStart(config);\n\n try {\n this.task.setInput(overrides);\n\n // Resolve schema-annotated inputs (models, repositories) before validation\n const schema = (this.task.constructor as typeof Task).inputSchema();\n this.task.runInputData = (await resolveSchemaInputs(\n this.task.runInputData as Record<string, unknown>,\n schema,\n { registry: this.registry }\n )) as Input;\n\n const inputs: Input = this.task.runInputData as Input;\n const isValid = await this.task.validateInput(inputs);\n if (!isValid) {\n throw new TaskInvalidInputError(\"Invalid input data\");\n }\n\n if (this.abortController?.signal.aborted) {\n await this.handleAbort();\n throw new TaskAbortedError(\"Promise for task created and aborted before run\");\n }\n\n let outputs: Output | undefined;\n\n const isStreamable = isTaskStreamable(this.task);\n\n if (this.task.cacheable) {\n outputs = (await this.outputCache?.getOutput(this.task.type, inputs)) as Output;\n if (outputs) {\n this.telemetrySpan?.addEvent(\"workglow.task.cache_hit\");\n if (isStreamable) {\n this.task.runOutputData = outputs;\n this.task.emit(\"stream_start\");\n this.task.emit(\"stream_chunk\", { type: \"finish\", data: outputs } as StreamEvent);\n this.task.emit(\"stream_end\", outputs);\n this.task.runOutputData = await this.executeTaskReactive(inputs, outputs);\n } else {\n this.task.runOutputData = await this.executeTaskReactive(inputs, outputs);\n }\n }\n }\n if (!outputs) {\n if (isStreamable) {\n outputs = await this.executeStreamingTask(inputs);\n } else {\n outputs = await this.executeTask(inputs);\n }\n if (this.task.cacheable && outputs !== undefined) {\n await this.outputCache?.saveOutput(this.task.type, inputs, outputs);\n }\n this.task.runOutputData = outputs ?? ({} as Output);\n }\n\n await this.handleComplete();\n\n return this.task.runOutputData as Output;\n } catch (err: any) {\n await this.handleError(err);\n // If a timeout triggered the abort, throw the TaskTimeoutError instead\n // of the generic TaskAbortedError that the task's execute() may have thrown.\n throw this.task.error instanceof TaskTimeoutError ? this.task.error : err;\n }\n }\n\n /**\n * Runs the task in reactive mode\n * @param overrides Optional input overrides\n * @returns The task output\n */\n public async runReactive(overrides: Partial<Input> = {}): Promise<Output> {\n if (this.task.status === TaskStatus.PROCESSING) {\n return this.task.runOutputData as Output;\n }\n this.task.setInput(overrides);\n\n // Resolve schema-annotated inputs (models, repositories) before validation\n const schema = (this.task.constructor as typeof Task).inputSchema();\n this.task.runInputData = (await resolveSchemaInputs(\n this.task.runInputData as Record<string, unknown>,\n schema,\n { registry: this.registry }\n )) as Input;\n\n await this.handleStartReactive();\n\n try {\n const inputs: Input = this.task.runInputData as Input;\n const isValid = await this.task.validateInput(inputs);\n if (!isValid) {\n throw new TaskInvalidInputError(\"Invalid input data\");\n }\n\n const resultReactive = await this.executeTaskReactive(\n inputs,\n this.task.runOutputData as Output\n );\n\n this.task.runOutputData = resultReactive;\n\n await this.handleCompleteReactive();\n } catch (err: any) {\n await this.handleErrorReactive();\n } finally {\n return this.task.runOutputData as Output;\n }\n }\n\n /**\n * Aborts task execution\n */\n public abort(): void {\n if (this.task.hasChildren()) {\n this.task.subGraph.abort();\n }\n this.abortController?.abort();\n }\n\n // ========================================================================\n // Protected methods\n // ========================================================================\n\n protected own<T extends Taskish<any, any>>(i: T): T {\n const task = ensureTask(i, { isOwned: true });\n this.task.subGraph.addTask(task);\n // Propagate parent registry and abort signal to owned ITask instances so\n // that calling task.run() on the returned value inherits this execution context.\n if (hasRunConfig(i)) {\n Object.assign(i.runConfig, {\n registry: this.registry,\n signal: this.abortController?.signal,\n });\n }\n return i;\n }\n\n /**\n * Protected method to execute a task by delegating back to the task itself.\n */\n protected async executeTask(input: Input): Promise<Output | undefined> {\n const result = await this.task.execute(input, {\n signal: this.abortController!.signal,\n updateProgress: this.handleProgress.bind(this),\n own: this.own,\n registry: this.registry,\n });\n return await this.executeTaskReactive(input, result || ({} as Output));\n }\n\n /**\n * Protected method for reactive execution delegation\n */\n protected async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n const reactiveResult = await this.task.executeReactive(input, output, { own: this.own });\n return Object.assign({}, output, reactiveResult ?? {}) as Output;\n }\n\n /**\n * Executes a streaming task by consuming its executeStream() async iterable.\n *\n * When `shouldAccumulate` is true (default, set by graph runner when any downstream\n * edge needs materialized data, or when caching is on):\n * - text-delta chunks are accumulated per-port into a Map\n * - the raw finish event is NOT emitted; instead an enriched finish event is\n * emitted with the accumulated text merged in, so downstream dataflows can\n * materialize values without re-accumulating on their own\n *\n * When `shouldAccumulate` is false (set by graph runner when all downstream edges\n * are also streaming and no cache is needed):\n * - all events including the raw finish are emitted as-is (pure pass-through)\n * - no accumulation Map is maintained\n */\n protected async executeStreamingTask(input: Input): Promise<Output | undefined> {\n const streamMode: StreamMode = getOutputStreamMode(this.task.outputSchema());\n if (streamMode === \"append\") {\n const ports = getStreamingPorts(this.task.outputSchema());\n if (ports.length === 0) {\n throw new TaskError(\n `Task ${this.task.type} declares append streaming but no output port has x-stream: \"append\"`\n );\n }\n }\n if (streamMode === \"object\") {\n const ports = getStreamingPorts(this.task.outputSchema());\n if (ports.length === 0) {\n throw new TaskError(\n `Task ${this.task.type} declares object streaming but no output port has x-stream: \"object\"`\n );\n }\n }\n\n const accumulated = this.shouldAccumulate ? new Map<string, string>() : undefined;\n const accumulatedObjects = this.shouldAccumulate\n ? new Map<string, Record<string, unknown> | unknown[]>()\n : undefined;\n let chunkCount = 0;\n let finalOutput: Output | undefined;\n\n this.task.emit(\"stream_start\");\n\n const stream = this.task.executeStream!(input, {\n signal: this.abortController!.signal,\n updateProgress: this.handleProgress.bind(this),\n own: this.own,\n registry: this.registry,\n inputStreams: this.inputStreams,\n });\n\n for await (const event of stream) {\n chunkCount++;\n\n if (chunkCount === 1) {\n this.task.status = TaskStatus.STREAMING;\n this.task.emit(\"status\", this.task.status);\n }\n\n // For snapshot events, update runOutputData BEFORE emitting stream_chunk\n // so listeners see the latest snapshot when they handle the event\n if (event.type === \"snapshot\") {\n this.task.runOutputData = event.data as Output;\n }\n\n switch (event.type) {\n case \"text-delta\": {\n if (accumulated) {\n accumulated.set(event.port, (accumulated.get(event.port) ?? \"\") + event.textDelta);\n }\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"object-delta\": {\n if (accumulatedObjects) {\n accumulatedObjects.set(event.port, event.objectDelta);\n }\n // Update runOutputData progressively so listeners see growing state\n this.task.runOutputData = {\n ...this.task.runOutputData,\n [event.port]: event.objectDelta,\n } as Output;\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"snapshot\": {\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"finish\": {\n if (accumulated || accumulatedObjects) {\n // Emit an enriched finish event: merge accumulated deltas into\n // the finish payload so downstream dataflows get complete port data\n // without needing to re-accumulate themselves.\n const merged: Record<string, unknown> = { ...(event.data || {}) };\n if (accumulated) {\n for (const [port, text] of accumulated) {\n if (text.length > 0) merged[port] = text;\n }\n }\n if (accumulatedObjects) {\n for (const [port, obj] of accumulatedObjects) {\n merged[port] = obj;\n }\n }\n finalOutput = merged as unknown as Output;\n this.task.emit(\"stream_chunk\", { type: \"finish\", data: merged } as StreamEvent);\n } else {\n // No accumulation: emit the raw finish event and use it directly\n finalOutput = event.data as Output;\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n }\n break;\n }\n case \"error\": {\n throw event.error;\n }\n }\n }\n\n // Check if the task was aborted during streaming\n if (this.abortController?.signal.aborted) {\n throw new TaskAbortedError(\"Task aborted during streaming\");\n }\n\n if (finalOutput !== undefined) {\n this.task.runOutputData = finalOutput;\n }\n\n this.task.emit(\"stream_end\", this.task.runOutputData as Output);\n\n const reactiveResult = await this.executeTaskReactive(\n input,\n (this.task.runOutputData as Output) || ({} as Output)\n );\n return reactiveResult;\n }\n\n // ========================================================================\n // Protected Handlers\n // ========================================================================\n\n /**\n * Handles task start\n */\n protected async handleStart(config: IRunConfig = {}): Promise<void> {\n if (this.task.status === TaskStatus.PROCESSING) return;\n\n this.running = true;\n\n this.task.startedAt = new Date();\n this.task.progress = 0;\n this.task.status = TaskStatus.PROCESSING;\n\n this.abortController = new AbortController();\n this.abortController.signal.addEventListener(\"abort\", () => {\n this.handleAbort();\n });\n\n // If a parent signal is provided (e.g. set by context.own()), link it so\n // that aborting the parent also aborts this task.\n if (config.signal?.aborted) {\n this.abortController.abort();\n } else if (config.signal) {\n config.signal.addEventListener(\"abort\", () => this.abortController!.abort(), { once: true });\n }\n\n const cache = config.outputCache ?? this.task.runConfig?.outputCache;\n if (cache === true) {\n let instance = globalServiceRegistry.get(TASK_OUTPUT_REPOSITORY);\n this.outputCache = instance;\n } else if (cache === false) {\n this.outputCache = undefined;\n } else if (cache instanceof TaskOutputRepository) {\n this.outputCache = cache;\n }\n\n // shouldAccumulate defaults to true (backward-compatible for standalone runs)\n this.shouldAccumulate = config.shouldAccumulate !== false;\n\n // Start timeout timer if configured (timeout is a design-time config property)\n const timeout = (this.task.config as Record<string, unknown>).timeout as number | undefined;\n if (timeout !== undefined && timeout > 0) {\n this.pendingTimeoutError = new TaskTimeoutError(timeout);\n this.timeoutTimer = setTimeout(() => {\n this.abort();\n }, timeout);\n }\n\n if (config.updateProgress) {\n this.updateProgress = config.updateProgress;\n }\n\n if (config.registry) {\n this.registry = config.registry;\n }\n\n // Start telemetry span\n const telemetry = getTelemetryProvider();\n if (telemetry.isEnabled) {\n this.telemetrySpan = telemetry.startSpan(\"workglow.task.run\", {\n attributes: {\n \"workglow.task.type\": this.task.type,\n \"workglow.task.id\": String(this.task.config.id),\n \"workglow.task.cacheable\": this.task.cacheable,\n \"workglow.task.title\": this.task.title || undefined,\n },\n });\n }\n\n this.task.emit(\"start\");\n this.task.emit(\"status\", this.task.status);\n }\n private updateProgress = async (\n _task: ITask,\n _progress: number,\n _message?: string,\n ..._args: any[]\n ) => {};\n\n protected async handleStartReactive(): Promise<void> {\n this.reactiveRunning = true;\n }\n\n /**\n * Clears the timeout timer if one is active.\n */\n protected clearTimeoutTimer(): void {\n if (this.timeoutTimer !== undefined) {\n clearTimeout(this.timeoutTimer);\n this.timeoutTimer = undefined;\n }\n }\n\n /**\n * Handles task abort\n */\n protected async handleAbort(): Promise<void> {\n if (this.task.status === TaskStatus.ABORTING) return;\n this.clearTimeoutTimer();\n this.task.status = TaskStatus.ABORTING;\n this.task.progress = 100;\n // Use the pending timeout error if the abort was triggered by a timeout\n this.task.error = this.pendingTimeoutError ?? new TaskAbortedError();\n this.pendingTimeoutError = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, \"aborted\");\n this.telemetrySpan.addEvent(\"workglow.task.aborted\", {\n \"workglow.task.error\": this.task.error.message,\n });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"abort\", this.task.error);\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleAbortReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task completion\n */\n protected async handleComplete(): Promise<void> {\n if (this.task.status === TaskStatus.COMPLETED) return;\n this.clearTimeoutTimer();\n this.pendingTimeoutError = undefined;\n\n this.task.completedAt = new Date();\n this.task.progress = 100;\n this.task.status = TaskStatus.COMPLETED;\n this.abortController = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.OK);\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"complete\");\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleCompleteReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n protected async handleDisable(): Promise<void> {\n if (this.task.status === TaskStatus.DISABLED) return;\n this.task.status = TaskStatus.DISABLED;\n this.task.progress = 100;\n this.task.completedAt = new Date();\n this.abortController = undefined;\n this.task.emit(\"disabled\");\n this.task.emit(\"status\", this.task.status);\n }\n\n public async disable(): Promise<void> {\n await this.handleDisable();\n }\n\n /**\n * Handles task error\n * @param err Error that occurred\n */\n protected async handleError(err: Error): Promise<void> {\n if (err instanceof TaskAbortedError) return this.handleAbort();\n if (this.task.status === TaskStatus.FAILED) return;\n this.clearTimeoutTimer();\n this.pendingTimeoutError = undefined;\n if (this.task.hasChildren()) {\n this.task.subGraph!.abort();\n }\n\n this.task.completedAt = new Date();\n this.task.progress = 100;\n this.task.status = TaskStatus.FAILED;\n this.task.error =\n err instanceof TaskError ? err : new TaskFailedError(err?.message || \"Task failed\");\n this.abortController = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, this.task.error.message);\n this.telemetrySpan.setAttributes({ \"workglow.task.error\": this.task.error.message });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"error\", this.task.error);\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleErrorReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task progress update\n * @param progress Progress value (0-100)\n * @param args Additional arguments\n */\n protected async handleProgress(\n progress: number,\n message?: string,\n ...args: any[]\n ): Promise<void> {\n this.task.progress = progress;\n // Emit before graph-level work (e.g. pushOutputFromNodeToEdges) so listeners are not stalled.\n this.task.emit(\"progress\", progress, message, ...args);\n await this.updateProgress(this.task, progress, message, ...args);\n }\n}\n",
10
17
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport type { ServiceRegistry } from \"@workglow/util\";\nimport { getInputResolvers } from \"@workglow/util\";\n\n/**\n * Configuration for the input resolver\n */\nexport interface InputResolverConfig {\n readonly registry: ServiceRegistry;\n}\n\n/**\n * Extracts the format string from a schema, handling oneOf/anyOf wrappers.\n */\nfunction getSchemaFormat(schema: unknown): string | undefined {\n if (typeof schema !== \"object\" || schema === null) return undefined;\n\n const s = schema as Record<string, unknown>;\n\n // Direct format\n if (typeof s.format === \"string\") return s.format;\n\n // Check oneOf/anyOf for format\n const variants = (s.oneOf ?? s.anyOf) as unknown[] | undefined;\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n if (typeof variant === \"object\" && variant !== null) {\n const v = variant as Record<string, unknown>;\n if (typeof v.format === \"string\") return v.format;\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Extracts the object-typed schema from a property schema, handling oneOf/anyOf wrappers.\n * This is needed for patterns like `oneOf: [{ type: \"string\" }, { type: \"object\", properties: {...} }]`\n * where the model can be either a string ID or an inline config object.\n */\nfunction getObjectSchema(\n schema: unknown\n): (Record<string, unknown> & { properties: Record<string, unknown> }) | undefined {\n if (typeof schema !== \"object\" || schema === null) return undefined;\n\n const s = schema as Record<string, unknown>;\n\n // Direct object schema with properties\n if (s.type === \"object\" && s.properties && typeof s.properties === \"object\") {\n return s as Record<string, unknown> & { properties: Record<string, unknown> };\n }\n\n // Check oneOf/anyOf for object variant\n const variants = (s.oneOf ?? s.anyOf) as unknown[] | undefined;\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n if (typeof variant === \"object\" && variant !== null) {\n const v = variant as Record<string, unknown>;\n if (v.type === \"object\" && v.properties && typeof v.properties === \"object\") {\n return v as Record<string, unknown> & { properties: Record<string, unknown> };\n }\n }\n }\n }\n\n return undefined;\n}\n\n/**\n * Gets the format prefix from a format string.\n * For \"model:TextEmbedding\" returns \"model\"\n * For \"storage:tabular\" returns \"storage\"\n */\nfunction getFormatPrefix(format: string): string {\n const colonIndex = format.indexOf(\":\");\n return colonIndex >= 0 ? format.substring(0, colonIndex) : format;\n}\n\n/**\n * Resolves schema-annotated inputs by looking up string IDs from registries.\n * String values with matching format annotations are resolved to their instances.\n * Non-string values (objects/instances) are passed through unchanged.\n *\n * @param input The task input object\n * @param schema The task's input schema\n * @param config Configuration including the service registry\n * @returns The input with resolved values\n *\n * @example\n * ```typescript\n * // In TaskRunner.run()\n * const resolvedInput = await resolveSchemaInputs(\n * this.task.runInputData,\n * (this.task.constructor as typeof Task).inputSchema(),\n * { registry: this.registry }\n * );\n * ```\n */\nexport async function resolveSchemaInputs<T extends Record<string, unknown>>(\n input: T,\n schema: DataPortSchema,\n config: InputResolverConfig\n): Promise<T> {\n if (typeof schema === \"boolean\") return input;\n\n const properties = schema.properties;\n if (!properties || typeof properties !== \"object\") return input;\n\n const resolvers = getInputResolvers();\n const resolved: Record<string, unknown> = { ...input };\n\n for (const [key, propSchema] of Object.entries(properties)) {\n let value = resolved[key];\n\n // Phase 1: Resolve format-annotated string values\n const format = getSchemaFormat(propSchema);\n if (format) {\n // Try full format first (e.g., \"dataset:document-chunk\"), then fall back to prefix (e.g., \"dataset\")\n let resolver = resolvers.get(format);\n if (!resolver) {\n const prefix = getFormatPrefix(format);\n resolver = resolvers.get(prefix);\n }\n\n if (resolver) {\n // Handle string values\n if (typeof value === \"string\") {\n value = await resolver(value, format, config.registry);\n resolved[key] = value;\n }\n // Handle arrays - resolve string elements and pass through non-string elements unchanged\n else if (Array.isArray(value) && value.some((item) => typeof item === \"string\")) {\n const results = await Promise.all(\n value.map((item) =>\n typeof item === \"string\" ? resolver(item, format, config.registry) : item\n )\n );\n value = results.filter((result) => result !== undefined);\n resolved[key] = value;\n }\n }\n }\n\n // Phase 2: Recurse into object values if the schema defines nested properties\n if (\n value !== null &&\n value !== undefined &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n const objectSchema = getObjectSchema(propSchema);\n if (objectSchema) {\n resolved[key] = await resolveSchemaInputs(\n value as Record<string, unknown>,\n objectSchema as DataPortSchema,\n config\n );\n }\n }\n }\n\n return resolved as T;\n}\n",
11
18
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema, JsonSchema } from \"@workglow/util/schema\";\n\n/**\n * Stream mode determines how a task's streaming output is interpreted:\n * - `none`: No streaming (default). `execute()` returns `Promise<Output>`.\n * - `append`: Each chunk is a delta (e.g., a new token).\n * - `replace`: Each chunk is a corrected/revised snapshot of the complete output so far.\n * - `object`: Each chunk is a progressively more complete partial object snapshot.\n * - `mixed`: Multiple ports use different stream modes (e.g., append + object).\n *\n * Declared per-port via the `x-stream` schema extension property.\n * Absent `x-stream` = `\"none\"`.\n */\nexport type StreamMode = \"none\" | \"append\" | \"replace\" | \"object\" | \"mixed\";\n\n/**\n * Append mode: delta chunk (consumer accumulates).\n * `port` identifies which output port this delta belongs to.\n */\nexport type StreamTextDelta = {\n type: \"text-delta\";\n port: string;\n textDelta: string;\n};\n\n/**\n * Object delta for structured/object streaming.\n * `port` identifies which output port this delta belongs to.\n * Each `objectDelta` is a progressively more complete partial object snapshot.\n * Consumers should replace (not merge) their state with the latest delta.\n */\nexport type StreamObjectDelta = {\n type: \"object-delta\";\n port: string;\n objectDelta: Record<string, unknown> | unknown[];\n};\n\n/**\n * Replace mode: full snapshot chunk (replaces previous state).\n */\nexport type StreamSnapshot<Output = Record<string, any>> = {\n type: \"snapshot\";\n data: Output;\n};\n\n/**\n * Signals that the stream has finished. In append mode, the runner\n * accumulates text-delta chunks into the append port (determined by\n * the output schema's `x-stream: \"append\"` annotation); `data` may\n * carry additional fields (merged into the final output).\n * In replace mode, `data` contains the final output.\n */\nexport type StreamFinish<Output = Record<string, any>> = {\n type: \"finish\";\n data: Output;\n};\n\n/**\n * Signals that the stream encountered an error.\n */\nexport type StreamError = {\n type: \"error\";\n error: Error;\n};\n\n/**\n * Discriminated union of all stream event types.\n * Used as the element type for `AsyncIterable<StreamEvent>` streams\n * flowing through the DAG.\n */\nexport type StreamEvent<Output = Record<string, any>> =\n | StreamTextDelta\n | StreamObjectDelta\n | StreamSnapshot<Output>\n | StreamFinish<Output>\n | StreamError;\n\n// ========================================================================\n// Port-level stream helpers\n// ========================================================================\n\n/**\n * Reads the `x-stream` value from a specific port property in a DataPortSchema.\n * Returns `\"none\"` when the property or the `x-stream` annotation is absent.\n *\n * @param schema - The task's input or output DataPortSchema\n * @param portId - The property name (port ID) to inspect\n * @returns The StreamMode declared on that port\n */\nexport function getPortStreamMode(schema: DataPortSchema | JsonSchema, portId: string): StreamMode {\n if (typeof schema === \"boolean\") return \"none\";\n const prop = (schema.properties as Record<string, any>)?.[portId];\n if (!prop || typeof prop === \"boolean\") return \"none\";\n const xStream = prop[\"x-stream\"];\n if (xStream === \"append\" || xStream === \"replace\" || xStream === \"object\") return xStream;\n return \"none\";\n}\n\n/**\n * Returns all ports that declare an `x-stream` annotation, along with their mode.\n *\n * @param schema - The task's output (or input) DataPortSchema\n * @returns Array of `{ port, mode }` for every annotated port\n */\nexport function getStreamingPorts(\n schema: DataPortSchema\n): Array<{ port: string; mode: StreamMode }> {\n if (typeof schema === \"boolean\") return [];\n const props = schema.properties;\n if (!props) return [];\n\n const result: Array<{ port: string; mode: StreamMode }> = [];\n for (const [name, prop] of Object.entries(props)) {\n if (!prop || typeof prop === \"boolean\") continue;\n const xStream = (prop as any)[\"x-stream\"];\n if (xStream === \"append\" || xStream === \"replace\" || xStream === \"object\") {\n result.push({ port: name, mode: xStream });\n }\n }\n return result;\n}\n\n/**\n * Returns the dominant output stream mode for a task by inspecting its output schema.\n * Returns `\"mixed\"` when ports use different modes (e.g., append + object).\n * Returns `\"none\"` if no output port declares streaming.\n */\nexport function getOutputStreamMode(outputSchema: DataPortSchema): StreamMode {\n const ports = getStreamingPorts(outputSchema);\n if (ports.length === 0) return \"none\";\n\n const mode = ports[0].mode;\n for (let i = 1; i < ports.length; i++) {\n if (ports[i].mode !== mode) {\n return \"mixed\";\n }\n }\n return mode;\n}\n\n/**\n * Determines whether a task supports streaming by checking if any output port\n * has an `x-stream` annotation AND the task implements `executeStream()`.\n *\n * @param task - The task to inspect (must have `outputSchema()` and optionally `executeStream`)\n * @returns true if the task can produce streaming output\n */\nexport function isTaskStreamable(task: {\n outputSchema(): DataPortSchema;\n executeStream?: (...args: any[]) => any;\n}): boolean {\n if (typeof task.executeStream !== \"function\") return false;\n return getOutputStreamMode(task.outputSchema()) !== \"none\";\n}\n\n/**\n * Returns the port ID (property name) of the first output port that declares\n * `x-stream: \"append\"`, or `undefined` if no such port exists.\n *\n * @param schema - The task's output DataPortSchema\n * @returns The port name with append streaming, or undefined\n */\nexport function getAppendPortId(schema: DataPortSchema): string | undefined {\n if (typeof schema === \"boolean\") return undefined;\n const props = schema.properties;\n if (!props) return undefined;\n\n for (const [name, prop] of Object.entries(props)) {\n if (!prop || typeof prop === \"boolean\") continue;\n if ((prop as any)[\"x-stream\"] === \"append\") return name;\n }\n return undefined;\n}\n\n/**\n * Determines whether a dataflow edge needs to accumulate stream events\n * into a materialized value for the target port.\n *\n * Accumulation is needed when:\n * - The source output port declares streaming (`x-stream` is set)\n * - AND the target input port does NOT accept the same stream mode\n *\n * @param sourceSchema - Output schema of the source task\n * @param sourcePort - Port ID on the source task\n * @param targetSchema - Input schema of the target task\n * @param targetPort - Port ID on the target task\n * @returns true if the edge should accumulate; false if stream can pass through\n */\nexport function edgeNeedsAccumulation(\n sourceSchema: DataPortSchema,\n sourcePort: string,\n targetSchema: DataPortSchema,\n targetPort: string\n): boolean {\n const sourceMode = getPortStreamMode(sourceSchema, sourcePort);\n if (sourceMode === \"none\") return false;\n const targetMode = getPortStreamMode(targetSchema, targetPort);\n return sourceMode !== targetMode;\n}\n\n/**\n * Returns the port ID (property name) of the first output port that declares\n * `x-stream: \"object\"`, or `undefined` if no such port exists.\n *\n * @param schema - The task's output DataPortSchema\n * @returns The port name with object streaming, or undefined\n */\nexport function getObjectPortId(schema: DataPortSchema): string | undefined {\n if (typeof schema === \"boolean\") return undefined;\n const props = schema.properties;\n if (!props) return undefined;\n\n for (const [name, prop] of Object.entries(props)) {\n if (!prop || typeof prop === \"boolean\") continue;\n if ((prop as any)[\"x-stream\"] === \"object\") return name;\n }\n return undefined;\n}\n\n/**\n * Returns a map of port names to their JSON Schemas for every output port\n * that declares `\"x-structured-output\": true`.\n *\n * @param schema - The task's output DataPortSchema\n * @returns Map of port-name → JSON Schema for structured output ports\n */\nexport function getStructuredOutputSchemas(schema: DataPortSchema): Map<string, JsonSchema> {\n const result = new Map<string, JsonSchema>();\n if (typeof schema === \"boolean\") return result;\n const props = schema.properties;\n if (!props) return result;\n\n for (const [name, prop] of Object.entries(props)) {\n if (!prop || typeof prop === \"boolean\") continue;\n if ((prop as any)[\"x-structured-output\"] === true) {\n result.set(name, prop as JsonSchema);\n }\n }\n return result;\n}\n\n/**\n * Returns true if the schema has any output port with `\"x-structured-output\": true`.\n */\nexport function hasStructuredOutput(schema: DataPortSchema): boolean {\n return getStructuredOutputSchemas(schema).size > 0;\n}\n",
12
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n getTelemetryProvider,\n globalServiceRegistry,\n ServiceRegistry,\n SpanStatusCode,\n type ISpan,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ensureTask, type Taskish } from \"../task-graph/Conversions\";\nimport { resolveSchemaInputs } from \"./InputResolver\";\nimport { IRunConfig, ITask } from \"./ITask\";\nimport { ITaskRunner } from \"./ITaskRunner\";\nimport {\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n type StreamEvent,\n type StreamMode,\n} from \"./StreamTypes\";\nimport { Task } from \"./Task\";\nimport {\n TaskAbortedError,\n TaskError,\n TaskFailedError,\n TaskInvalidInputError,\n TaskTimeoutError,\n} from \"./TaskError\";\nimport { TaskConfig, TaskInput, TaskOutput, TaskStatus } from \"./TaskTypes\";\n\n/**\n * Type guard that checks whether a value is an ITask-like object with a mutable `runConfig`.\n */\nfunction hasRunConfig(i: unknown): i is { runConfig: Partial<IRunConfig> } {\n return i !== null && typeof i === \"object\" && \"runConfig\" in (i as object);\n}\n\n/**\n * Responsible for running tasks\n * Manages the execution lifecycle of individual tasks\n */\nexport class TaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends TaskConfig = TaskConfig,\n> implements ITaskRunner<Input, Output, Config> {\n /**\n * Whether the task is currently running\n */\n protected running = false;\n protected reactiveRunning = false;\n\n /**\n * The task to run\n */\n public readonly task: ITask<Input, Output, Config>;\n\n /**\n * AbortController for cancelling task execution\n */\n protected abortController?: AbortController;\n\n /**\n * The output cache for the task\n */\n protected outputCache?: TaskOutputRepository;\n\n /**\n * The service registry for the task\n */\n protected registry: ServiceRegistry = globalServiceRegistry;\n\n /**\n * Input streams for pass-through streaming tasks.\n * Set by the graph runner before executing a streaming task that has\n * upstream streaming edges. Keyed by input port name.\n */\n public inputStreams?: Map<string, ReadableStream<StreamEvent>>;\n\n /**\n * Timer handle for task-level timeout. Set when `IRunConfig.timeout` is\n * provided and cleared on completion, error, or abort.\n */\n protected timeoutTimer?: ReturnType<typeof setTimeout>;\n\n /**\n * When a timeout triggers the abort, this holds the TaskTimeoutError so\n * handleAbort() can surface the correct error type instead of a generic\n * TaskAbortedError.\n */\n protected pendingTimeoutError?: TaskTimeoutError;\n\n /**\n * Whether the streaming task runner should accumulate text-delta chunks and\n * emit an enriched finish event. Set from IRunConfig.shouldAccumulate.\n * Defaults to true so standalone task execution is backward-compatible.\n * The graph runner sets this to false when no downstream edge needs\n * materialized data (no cache, all downstream tasks are also streaming).\n */\n protected shouldAccumulate: boolean = true;\n\n /**\n * Active telemetry span for the current task run.\n */\n protected telemetrySpan?: ISpan;\n\n /**\n * Constructor for TaskRunner\n * @param task The task to run\n */\n constructor(task: ITask<Input, Output, Config>) {\n this.task = task;\n this.own = this.own.bind(this);\n this.handleProgress = this.handleProgress.bind(this);\n }\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n /**\n * Runs the task and returns the output\n * @param overrides Optional input overrides\n * @param config Optional configuration overrides\n * @returns The task output\n */\n async run(overrides: Partial<Input> = {}, config: IRunConfig = {}): Promise<Output> {\n await this.handleStart(config);\n\n try {\n this.task.setInput(overrides);\n\n // Resolve schema-annotated inputs (models, repositories) before validation\n const schema = (this.task.constructor as typeof Task).inputSchema();\n this.task.runInputData = (await resolveSchemaInputs(\n this.task.runInputData as Record<string, unknown>,\n schema,\n { registry: this.registry }\n )) as Input;\n\n const inputs: Input = this.task.runInputData as Input;\n const isValid = await this.task.validateInput(inputs);\n if (!isValid) {\n throw new TaskInvalidInputError(\"Invalid input data\");\n }\n\n if (this.abortController?.signal.aborted) {\n await this.handleAbort();\n throw new TaskAbortedError(\"Promise for task created and aborted before run\");\n }\n\n let outputs: Output | undefined;\n\n const isStreamable = isTaskStreamable(this.task);\n\n if (this.task.cacheable) {\n outputs = (await this.outputCache?.getOutput(this.task.type, inputs)) as Output;\n if (outputs) {\n this.telemetrySpan?.addEvent(\"workglow.task.cache_hit\");\n if (isStreamable) {\n this.task.runOutputData = outputs;\n this.task.emit(\"stream_start\");\n this.task.emit(\"stream_chunk\", { type: \"finish\", data: outputs } as StreamEvent);\n this.task.emit(\"stream_end\", outputs);\n this.task.runOutputData = await this.executeTaskReactive(inputs, outputs);\n } else {\n this.task.runOutputData = await this.executeTaskReactive(inputs, outputs);\n }\n }\n }\n if (!outputs) {\n if (isStreamable) {\n outputs = await this.executeStreamingTask(inputs);\n } else {\n outputs = await this.executeTask(inputs);\n }\n if (this.task.cacheable && outputs !== undefined) {\n await this.outputCache?.saveOutput(this.task.type, inputs, outputs);\n }\n this.task.runOutputData = outputs ?? ({} as Output);\n }\n\n await this.handleComplete();\n\n return this.task.runOutputData as Output;\n } catch (err: any) {\n await this.handleError(err);\n // If a timeout triggered the abort, throw the TaskTimeoutError instead\n // of the generic TaskAbortedError that the task's execute() may have thrown.\n throw this.task.error instanceof TaskTimeoutError ? this.task.error : err;\n }\n }\n\n /**\n * Runs the task in reactive mode\n * @param overrides Optional input overrides\n * @returns The task output\n */\n public async runReactive(overrides: Partial<Input> = {}): Promise<Output> {\n if (this.task.status === TaskStatus.PROCESSING) {\n return this.task.runOutputData as Output;\n }\n this.task.setInput(overrides);\n\n // Resolve schema-annotated inputs (models, repositories) before validation\n const schema = (this.task.constructor as typeof Task).inputSchema();\n this.task.runInputData = (await resolveSchemaInputs(\n this.task.runInputData as Record<string, unknown>,\n schema,\n { registry: this.registry }\n )) as Input;\n\n await this.handleStartReactive();\n\n try {\n const inputs: Input = this.task.runInputData as Input;\n const isValid = await this.task.validateInput(inputs);\n if (!isValid) {\n throw new TaskInvalidInputError(\"Invalid input data\");\n }\n\n const resultReactive = await this.executeTaskReactive(\n inputs,\n this.task.runOutputData as Output\n );\n\n this.task.runOutputData = resultReactive;\n\n await this.handleCompleteReactive();\n } catch (err: any) {\n await this.handleErrorReactive();\n } finally {\n return this.task.runOutputData as Output;\n }\n }\n\n /**\n * Aborts task execution\n */\n public abort(): void {\n if (this.task.hasChildren()) {\n this.task.subGraph.abort();\n }\n this.abortController?.abort();\n }\n\n // ========================================================================\n // Protected methods\n // ========================================================================\n\n protected own<T extends Taskish<any, any>>(i: T): T {\n const task = ensureTask(i, { isOwned: true });\n this.task.subGraph.addTask(task);\n // Propagate parent registry and abort signal to owned ITask instances so\n // that calling task.run() on the returned value inherits this execution context.\n if (hasRunConfig(i)) {\n Object.assign(i.runConfig, {\n registry: this.registry,\n signal: this.abortController?.signal,\n });\n }\n return i;\n }\n\n /**\n * Protected method to execute a task by delegating back to the task itself.\n */\n protected async executeTask(input: Input): Promise<Output | undefined> {\n const result = await this.task.execute(input, {\n signal: this.abortController!.signal,\n updateProgress: this.handleProgress.bind(this),\n own: this.own,\n registry: this.registry,\n });\n return await this.executeTaskReactive(input, result || ({} as Output));\n }\n\n /**\n * Protected method for reactive execution delegation\n */\n protected async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n const reactiveResult = await this.task.executeReactive(input, output, { own: this.own });\n return Object.assign({}, output, reactiveResult ?? {}) as Output;\n }\n\n /**\n * Executes a streaming task by consuming its executeStream() async iterable.\n *\n * When `shouldAccumulate` is true (default, set by graph runner when any downstream\n * edge needs materialized data, or when caching is on):\n * - text-delta chunks are accumulated per-port into a Map\n * - the raw finish event is NOT emitted; instead an enriched finish event is\n * emitted with the accumulated text merged in, so downstream dataflows can\n * materialize values without re-accumulating on their own\n *\n * When `shouldAccumulate` is false (set by graph runner when all downstream edges\n * are also streaming and no cache is needed):\n * - all events including the raw finish are emitted as-is (pure pass-through)\n * - no accumulation Map is maintained\n */\n protected async executeStreamingTask(input: Input): Promise<Output | undefined> {\n const streamMode: StreamMode = getOutputStreamMode(this.task.outputSchema());\n if (streamMode === \"append\") {\n const ports = getStreamingPorts(this.task.outputSchema());\n if (ports.length === 0) {\n throw new TaskError(\n `Task ${this.task.type} declares append streaming but no output port has x-stream: \"append\"`\n );\n }\n }\n if (streamMode === \"object\") {\n const ports = getStreamingPorts(this.task.outputSchema());\n if (ports.length === 0) {\n throw new TaskError(\n `Task ${this.task.type} declares object streaming but no output port has x-stream: \"object\"`\n );\n }\n }\n\n const accumulated = this.shouldAccumulate ? new Map<string, string>() : undefined;\n const accumulatedObjects = this.shouldAccumulate\n ? new Map<string, Record<string, unknown> | unknown[]>()\n : undefined;\n let chunkCount = 0;\n let finalOutput: Output | undefined;\n\n this.task.emit(\"stream_start\");\n\n const stream = this.task.executeStream!(input, {\n signal: this.abortController!.signal,\n updateProgress: this.handleProgress.bind(this),\n own: this.own,\n registry: this.registry,\n inputStreams: this.inputStreams,\n });\n\n for await (const event of stream) {\n chunkCount++;\n\n if (chunkCount === 1) {\n this.task.status = TaskStatus.STREAMING;\n this.task.emit(\"status\", this.task.status);\n }\n\n // For snapshot events, update runOutputData BEFORE emitting stream_chunk\n // so listeners see the latest snapshot when they handle the event\n if (event.type === \"snapshot\") {\n this.task.runOutputData = event.data as Output;\n }\n\n switch (event.type) {\n case \"text-delta\": {\n if (accumulated) {\n accumulated.set(event.port, (accumulated.get(event.port) ?? \"\") + event.textDelta);\n }\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"object-delta\": {\n if (accumulatedObjects) {\n accumulatedObjects.set(event.port, event.objectDelta);\n }\n // Update runOutputData progressively so listeners see growing state\n this.task.runOutputData = {\n ...this.task.runOutputData,\n [event.port]: event.objectDelta,\n } as Output;\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"snapshot\": {\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n const progress = Math.min(99, Math.round(100 * (1 - Math.exp(-0.05 * chunkCount))));\n await this.handleProgress(progress);\n break;\n }\n case \"finish\": {\n if (accumulated || accumulatedObjects) {\n // Emit an enriched finish event: merge accumulated deltas into\n // the finish payload so downstream dataflows get complete port data\n // without needing to re-accumulate themselves.\n const merged: Record<string, unknown> = { ...(event.data || {}) };\n if (accumulated) {\n for (const [port, text] of accumulated) {\n if (text.length > 0) merged[port] = text;\n }\n }\n if (accumulatedObjects) {\n for (const [port, obj] of accumulatedObjects) {\n merged[port] = obj;\n }\n }\n finalOutput = merged as unknown as Output;\n this.task.emit(\"stream_chunk\", { type: \"finish\", data: merged } as StreamEvent);\n } else {\n // No accumulation: emit the raw finish event and use it directly\n finalOutput = event.data as Output;\n this.task.emit(\"stream_chunk\", event as StreamEvent);\n }\n break;\n }\n case \"error\": {\n throw event.error;\n }\n }\n }\n\n // Check if the task was aborted during streaming\n if (this.abortController?.signal.aborted) {\n throw new TaskAbortedError(\"Task aborted during streaming\");\n }\n\n if (finalOutput !== undefined) {\n this.task.runOutputData = finalOutput;\n }\n\n this.task.emit(\"stream_end\", this.task.runOutputData as Output);\n\n const reactiveResult = await this.executeTaskReactive(\n input,\n (this.task.runOutputData as Output) || ({} as Output)\n );\n return reactiveResult;\n }\n\n // ========================================================================\n // Protected Handlers\n // ========================================================================\n\n /**\n * Handles task start\n */\n protected async handleStart(config: IRunConfig = {}): Promise<void> {\n if (this.task.status === TaskStatus.PROCESSING) return;\n\n this.running = true;\n\n this.task.startedAt = new Date();\n this.task.progress = 0;\n this.task.status = TaskStatus.PROCESSING;\n\n this.abortController = new AbortController();\n this.abortController.signal.addEventListener(\"abort\", () => {\n this.handleAbort();\n });\n\n // If a parent signal is provided (e.g. set by context.own()), link it so\n // that aborting the parent also aborts this task.\n if (config.signal?.aborted) {\n this.abortController.abort();\n } else if (config.signal) {\n config.signal.addEventListener(\"abort\", () => this.abortController!.abort(), { once: true });\n }\n\n const cache = config.outputCache ?? this.task.runConfig?.outputCache;\n if (cache === true) {\n let instance = globalServiceRegistry.get(TASK_OUTPUT_REPOSITORY);\n this.outputCache = instance;\n } else if (cache === false) {\n this.outputCache = undefined;\n } else if (cache instanceof TaskOutputRepository) {\n this.outputCache = cache;\n }\n\n // shouldAccumulate defaults to true (backward-compatible for standalone runs)\n this.shouldAccumulate = config.shouldAccumulate !== false;\n\n // Start timeout timer if configured (timeout is a design-time config property)\n const timeout = (this.task.config as Record<string, unknown>).timeout as number | undefined;\n if (timeout !== undefined && timeout > 0) {\n this.pendingTimeoutError = new TaskTimeoutError(timeout);\n this.timeoutTimer = setTimeout(() => {\n this.abort();\n }, timeout);\n }\n\n if (config.updateProgress) {\n this.updateProgress = config.updateProgress;\n }\n\n if (config.registry) {\n this.registry = config.registry;\n }\n\n // Start telemetry span\n const telemetry = getTelemetryProvider();\n if (telemetry.isEnabled) {\n this.telemetrySpan = telemetry.startSpan(\"workglow.task.run\", {\n attributes: {\n \"workglow.task.type\": this.task.type,\n \"workglow.task.id\": String(this.task.config.id),\n \"workglow.task.cacheable\": this.task.cacheable,\n \"workglow.task.title\": this.task.title || undefined,\n },\n });\n }\n\n this.task.emit(\"start\");\n this.task.emit(\"status\", this.task.status);\n }\n private updateProgress = async (\n _task: ITask,\n _progress: number,\n _message?: string,\n ..._args: any[]\n ) => {};\n\n protected async handleStartReactive(): Promise<void> {\n this.reactiveRunning = true;\n }\n\n /**\n * Clears the timeout timer if one is active.\n */\n protected clearTimeoutTimer(): void {\n if (this.timeoutTimer !== undefined) {\n clearTimeout(this.timeoutTimer);\n this.timeoutTimer = undefined;\n }\n }\n\n /**\n * Handles task abort\n */\n protected async handleAbort(): Promise<void> {\n if (this.task.status === TaskStatus.ABORTING) return;\n this.clearTimeoutTimer();\n this.task.status = TaskStatus.ABORTING;\n this.task.progress = 100;\n // Use the pending timeout error if the abort was triggered by a timeout\n this.task.error = this.pendingTimeoutError ?? new TaskAbortedError();\n this.pendingTimeoutError = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, \"aborted\");\n this.telemetrySpan.addEvent(\"workglow.task.aborted\", {\n \"workglow.task.error\": this.task.error.message,\n });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"abort\", this.task.error);\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleAbortReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task completion\n */\n protected async handleComplete(): Promise<void> {\n if (this.task.status === TaskStatus.COMPLETED) return;\n this.clearTimeoutTimer();\n this.pendingTimeoutError = undefined;\n\n this.task.completedAt = new Date();\n this.task.progress = 100;\n this.task.status = TaskStatus.COMPLETED;\n this.abortController = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.OK);\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"complete\");\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleCompleteReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n protected async handleDisable(): Promise<void> {\n if (this.task.status === TaskStatus.DISABLED) return;\n this.task.status = TaskStatus.DISABLED;\n this.task.progress = 100;\n this.task.completedAt = new Date();\n this.abortController = undefined;\n this.task.emit(\"disabled\");\n this.task.emit(\"status\", this.task.status);\n }\n\n public async disable(): Promise<void> {\n await this.handleDisable();\n }\n\n /**\n * Handles task error\n * @param err Error that occurred\n */\n protected async handleError(err: Error): Promise<void> {\n if (err instanceof TaskAbortedError) return this.handleAbort();\n if (this.task.status === TaskStatus.FAILED) return;\n this.clearTimeoutTimer();\n this.pendingTimeoutError = undefined;\n if (this.task.hasChildren()) {\n this.task.subGraph!.abort();\n }\n\n this.task.completedAt = new Date();\n this.task.progress = 100;\n this.task.status = TaskStatus.FAILED;\n this.task.error =\n err instanceof TaskError ? err : new TaskFailedError(err?.message || \"Task failed\");\n this.abortController = undefined;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, this.task.error.message);\n this.telemetrySpan.setAttributes({ \"workglow.task.error\": this.task.error.message });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.task.emit(\"error\", this.task.error);\n this.task.emit(\"status\", this.task.status);\n }\n\n protected async handleErrorReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task progress update\n * @param progress Progress value (0-100)\n * @param args Additional arguments\n */\n protected async handleProgress(\n progress: number,\n message?: string,\n ...args: any[]\n ): Promise<void> {\n this.task.progress = progress;\n // Emit before graph-level work (e.g. pushOutputFromNodeToEdges) so listeners are not stalled.\n this.task.emit(\"progress\", progress, message, ...args);\n await this.updateProgress(this.task, progress, message, ...args);\n }\n}\n",
13
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { compileSchema, type DataPortSchema, type SchemaNode } from \"@workglow/util/schema\";\nimport { deepEqual, EventEmitter, uuid4, type ServiceRegistry } from \"@workglow/util\";\nimport { DATAFLOW_ALL_PORTS } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport type { IExecuteContext, IExecuteReactiveContext, IRunConfig, ITask } from \"./ITask\";\nimport {\n TaskAbortedError,\n TaskConfigurationError,\n TaskError,\n TaskInvalidInputError,\n} from \"./TaskError\";\nimport {\n type TaskEventListener,\n type TaskEventListeners,\n type TaskEventParameters,\n type TaskEvents,\n} from \"./TaskEvents\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport { TaskRunner } from \"./TaskRunner\";\nimport {\n TaskConfigSchema,\n TaskStatus,\n type TaskConfig,\n type TaskIdType,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\n/**\n * Base class for all tasks that implements the ITask interface.\n * This abstract class provides common functionality for both simple and compound tasks.\n *\n * The Task class is responsible for:\n * 1. Defining what a task is (inputs, outputs, configuration)\n * 2. Providing the execution logic (via execute and executeReactive)\n * 3. Delegating the running logic to a TaskRunner\n */\nexport class Task<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends TaskConfig = TaskConfig,\n> implements ITask<Input, Output, Config> {\n // ========================================================================\n // Static properties - should be overridden by subclasses\n // ========================================================================\n\n /**\n * The type identifier for this task class\n */\n public static type: TaskTypeName = \"Task\";\n\n /**\n * The category this task belongs to\n */\n public static category: string = \"Hidden\";\n\n /**\n * The title of this task\n */\n public static title: string = \"\";\n\n /**\n * The description of this task\n */\n public static description: string = \"\";\n\n /**\n * Whether this task has side effects\n */\n public static cacheable: boolean = true;\n\n /**\n * Whether this task has dynamic input/output schemas that can change at runtime.\n * Tasks with dynamic schemas should override instance methods for inputSchema() and/or outputSchema()\n * and emit 'schemaChange' events when their schemas change.\n */\n public static hasDynamicSchemas: boolean = false;\n\n /**\n * When true, dynamically added input ports (via the universal \"Add Input\" handle in the builder)\n * are mirrored as output ports of the same name and type. Set this on pass-through tasks that\n * forward their additional inputs to their outputs unchanged.\n */\n public static passthroughInputsToOutputs: boolean = false;\n\n /**\n * When true, this task can be saved as a custom task with a preset configuration.\n * Tasks that have meaningful user-facing config options beyond the base fields should set this.\n */\n public static customizable: boolean = false;\n\n /**\n * Input schema for this task\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Output schema for this task\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Config schema for this task. Subclasses that add config properties MUST override this\n * and spread TaskConfigSchema[\"properties\"] into their own properties object.\n */\n public static configSchema(): DataPortSchema {\n return TaskConfigSchema;\n }\n\n // ========================================================================\n // Task Execution Methods - Core logic provided by subclasses\n // ========================================================================\n\n /**\n * The actual task execution logic for subclasses to override\n *\n * @param input The input to the task\n * @param config The configuration for the task\n * @throws TaskError if the task fails\n * @returns The output of the task or undefined if no changes\n */\n public async execute(_input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (context.signal?.aborted) {\n throw new TaskAbortedError(\"Task aborted\");\n }\n return undefined;\n }\n\n /**\n * Default implementation of executeReactive that does nothing.\n * Subclasses should override this to provide actual reactive functionality.\n *\n * This is generally for UI updating, and should be lightweight.\n * @param input The input to the task\n * @param output The current output of the task\n * @returns The updated output of the task or undefined if no changes\n */\n public async executeReactive(\n _input: Input,\n output: Output,\n _context: IExecuteReactiveContext\n ): Promise<Output | undefined> {\n return output;\n }\n\n // ========================================================================\n // TaskRunner delegation - Executes and manages the task\n // ========================================================================\n\n /**\n * Task runner for handling the task execution\n */\n protected _runner: TaskRunner<Input, Output, Config> | undefined;\n\n /**\n * Gets the task runner instance\n * Creates a new one if it doesn't exist\n */\n public get runner(): TaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new TaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n /**\n * Runs the task and returns the output\n * Delegates to the task runner\n *\n * @param overrides Optional input overrides\n * @param runConfig Optional per-call run configuration (merged with task's runConfig)\n * @throws TaskError if the task fails\n * @returns The task output\n */\n async run(overrides: Partial<Input> = {}, runConfig: Partial<IRunConfig> = {}): Promise<Output> {\n return this.runner.run(overrides, { ...this.runConfig, ...runConfig });\n }\n\n /**\n * Runs the task in reactive mode\n * Delegates to the task runner\n *\n * @param overrides Optional input overrides\n * @returns The task output\n */\n public async runReactive(overrides: Partial<Input> = {}): Promise<Output> {\n return this.runner.runReactive(overrides);\n }\n\n /**\n * Aborts task execution\n * Delegates to the task runner\n */\n public abort(): void {\n this.runner.abort();\n }\n\n /**\n * Disables task execution\n * Delegates to the task runner\n */\n public async disable(): Promise<void> {\n await this.runner.disable();\n }\n\n // ========================================================================\n // Static to Instance conversion methods\n // ========================================================================\n\n /**\n * Gets input schema for this task\n */\n public inputSchema(): DataPortSchema {\n return (this.constructor as typeof Task).inputSchema();\n }\n\n /**\n * Gets output schema for this task\n */\n public outputSchema(): DataPortSchema {\n return (this.constructor as typeof Task).outputSchema();\n }\n\n /**\n * Gets config schema for this task\n */\n public configSchema(): DataPortSchema {\n return (this.constructor as typeof Task).configSchema();\n }\n\n public get type(): TaskTypeName {\n return (this.constructor as typeof Task).type;\n }\n\n public get category(): string {\n return (this.constructor as typeof Task).category;\n }\n\n public get title(): string {\n return this.config?.title ?? (this.constructor as typeof Task).title;\n }\n\n public get description(): string {\n return this.config?.description ?? (this.constructor as typeof Task).description;\n }\n\n public get cacheable(): boolean {\n return (\n this.runConfig?.cacheable ??\n this.config?.cacheable ??\n (this.constructor as typeof Task).cacheable\n );\n }\n\n // ========================================================================\n // Instance properties using @template types\n // ========================================================================\n\n /**\n * Default input values for this task.\n * If no overrides at run time, then this would be equal to the input.\n * resetInputData() will reset inputs to these defaults.\n */\n defaults: Record<string, any>;\n\n /**\n * The input to the task at the time of the task run.\n * This takes defaults from construction time and overrides from run time.\n * It is the input that created the output.\n */\n runInputData: Record<string, any> = {};\n\n /**\n * The output of the task at the time of the task run.\n * This is the result of the task execution.\n */\n runOutputData: Record<string, any> = {};\n\n // ========================================================================\n // Task state properties\n // ========================================================================\n\n /**\n * The configuration of the task\n */\n config: Config;\n\n /**\n * Task id from config (read-only).\n */\n public get id(): unknown {\n return this.config.id;\n }\n\n /**\n * Runtime configuration (not serialized with the task).\n * Set via the constructor's third argument or mutated by the graph runner.\n */\n runConfig: Partial<IRunConfig> = {};\n\n /**\n * Current status of the task\n */\n status: TaskStatus = TaskStatus.PENDING;\n\n /**\n * Progress of the task (0-100)\n */\n progress: number = 0;\n\n /**\n * When the task was created\n */\n createdAt: Date = new Date();\n\n /**\n * When the task started execution\n */\n startedAt?: Date;\n\n /**\n * When the task completed execution\n */\n completedAt?: Date;\n\n /**\n * Error that occurred during task execution, if any\n */\n error?: TaskError;\n\n /**\n * Event emitter for task lifecycle events\n */\n public get events(): EventEmitter<TaskEventListeners> {\n if (!this._events) {\n this._events = new EventEmitter<TaskEventListeners>();\n }\n return this._events;\n }\n protected _events: EventEmitter<TaskEventListeners> | undefined;\n\n /**\n * Creates a new task instance\n *\n * @param callerDefaultInputs Default input values provided by the caller\n * @param config Configuration for the task\n */\n constructor(\n callerDefaultInputs: Partial<Input> = {},\n config: Partial<Config> = {},\n runConfig: Partial<IRunConfig> = {}\n ) {\n // Initialize input defaults\n const inputDefaults = this.getDefaultInputsFromStaticInputDefinitions();\n const mergedDefaults = Object.assign(inputDefaults, callerDefaultInputs);\n // Strip symbol properties (like [$JSONSchema]) before storing defaults\n this.defaults = this.stripSymbols(mergedDefaults) as Record<string, any>;\n this.resetInputData();\n\n // Setup configuration defaults (title comes from static class property as fallback)\n const title = (this.constructor as typeof Task).title || undefined;\n const baseConfig = Object.assign(\n {\n ...(title ? { title } : {}),\n },\n config\n ) as Config;\n if (baseConfig.id === undefined) {\n (baseConfig as Record<string, unknown>).id = uuid4();\n }\n this.config = this.validateAndApplyConfigDefaults(baseConfig);\n\n // Store runtime configuration\n this.runConfig = runConfig;\n }\n\n // ========================================================================\n // Input/Output handling\n // ========================================================================\n\n /**\n * Gets default input values from input schema\n */\n getDefaultInputsFromStaticInputDefinitions(): Partial<Input> {\n const schema = this.inputSchema();\n if (typeof schema === \"boolean\") {\n return {};\n }\n try {\n const compiledSchema = this.getInputSchemaNode();\n const defaultData = compiledSchema.getData(undefined, {\n addOptionalProps: true,\n removeInvalidData: false,\n useTypeDefaults: false,\n });\n return (defaultData || {}) as Partial<Input>;\n } catch (error) {\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to manual extraction:`,\n error\n );\n // Fallback to manual extraction if compilation fails\n return Object.entries(schema.properties || {}).reduce<Record<string, any>>(\n (acc, [id, prop]) => {\n const defaultValue = (prop as any).default;\n if (defaultValue !== undefined) {\n acc[id] = defaultValue;\n }\n return acc;\n },\n {}\n ) as Partial<Input>;\n }\n }\n\n /**\n * Resets input data to defaults\n */\n public resetInputData(): void {\n this.runInputData = this.smartClone(this.defaults) as Record<string, any>;\n }\n\n /**\n * Smart clone that deep-clones plain objects and arrays while preserving\n * class instances (objects with non-Object prototype) by reference.\n * Detects and throws an error on circular references.\n *\n * This is necessary because:\n * - structuredClone cannot clone class instances (methods are lost)\n * - JSON.parse/stringify loses methods and fails on circular references\n * - Class instances like repositories should be passed by reference\n *\n * This breaks the idea of everything being json serializable, but it allows\n * more efficient use cases. Do be careful with this though! Use sparingly.\n *\n * @param obj The object to clone\n * @param visited Set of objects in the current cloning path (for circular reference detection)\n * @returns A cloned object with class instances preserved by reference\n */\n private smartClone(obj: any, visited: WeakSet<object> = new WeakSet()): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // Primitives (string, number, boolean, symbol, bigint) are returned as-is\n if (typeof obj !== \"object\") {\n return obj;\n }\n\n // Check for circular references\n if (visited.has(obj)) {\n throw new TaskConfigurationError(\n \"Circular reference detected in input data. \" +\n \"Cannot clone objects with circular references.\"\n );\n }\n\n // Clone TypedArrays (Float32Array, Int8Array, etc.) to avoid shared-mutation\n // between defaults and runInputData, while preserving DataView by reference.\n if (ArrayBuffer.isView(obj)) {\n // Preserve DataView instances by reference (constructor signature differs)\n if (typeof DataView !== \"undefined\" && obj instanceof DataView) {\n return obj;\n }\n // For TypedArrays, create a new instance with the same data\n const typedArray = obj as any;\n return new (typedArray.constructor as any)(typedArray);\n }\n\n // Preserve class instances (objects with non-Object/non-Array prototype)\n // This includes repository instances, custom classes, etc.\n if (!Array.isArray(obj)) {\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n return obj; // Pass by reference\n }\n }\n\n // Add object to visited set before recursing\n visited.add(obj);\n\n try {\n // Deep clone arrays, preserving class instances within\n if (Array.isArray(obj)) {\n return obj.map((item) => this.smartClone(item, visited));\n }\n\n // Deep clone plain objects\n const result: Record<string, any> = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = this.smartClone(obj[key], visited);\n }\n }\n return result;\n } finally {\n // Remove from visited set after processing to allow the same object\n // in different branches (non-circular references)\n visited.delete(obj);\n }\n }\n\n /**\n * Sets the default input values for the task\n *\n * @param defaults The default input values to set\n */\n public setDefaults(defaults: Partial<Input>): void {\n // Strip symbol properties (like [$JSONSchema]) before storing defaults\n this.defaults = this.stripSymbols(defaults) as Partial<Input>;\n }\n\n /**\n * Sets input values for the task\n *\n * @param input Input values to set\n */\n public setInput(input: Partial<Input>): void {\n const schema = this.inputSchema();\n if (typeof schema === \"boolean\") {\n if (schema === true) {\n for (const [inputId, value] of Object.entries(input)) {\n if (value !== undefined) {\n this.runInputData[inputId] = value;\n }\n }\n }\n return;\n }\n const properties = schema.properties || {};\n\n // Copy explicitly defined properties\n for (const [inputId, prop] of Object.entries(properties)) {\n if (input[inputId] !== undefined) {\n this.runInputData[inputId] = input[inputId];\n } else if (this.runInputData[inputId] === undefined && (prop as any).default !== undefined) {\n this.runInputData[inputId] = (prop as any).default;\n }\n }\n\n // If additionalProperties is true, also copy any additional input properties\n if (schema.additionalProperties) {\n for (const [inputId, value] of Object.entries(input)) {\n if (!(inputId in properties)) {\n this.runInputData[inputId] = value;\n }\n }\n }\n }\n\n /**\n * Adds/merges input data during graph execution.\n * Unlike {@link setInput}, this method:\n * - Detects changes using deep equality\n * - Accumulates array values (appends rather than replaces)\n * - Handles DATAFLOW_ALL_PORTS for pass-through\n * - Handles additionalProperties for dynamic schemas\n *\n * @param overrides The input data to merge\n * @returns true if any input data was changed, false otherwise\n */\n public addInput(overrides: Partial<Input> | undefined): boolean {\n if (!overrides) return false;\n\n let changed = false;\n const inputSchema = this.inputSchema();\n\n if (typeof inputSchema === \"boolean\") {\n if (inputSchema === false) {\n return false;\n }\n // Schema is `true` - accept any input\n for (const [key, value] of Object.entries(overrides)) {\n if (!deepEqual(this.runInputData[key], value)) {\n this.runInputData[key] = value;\n changed = true;\n }\n }\n return changed;\n }\n\n const properties = inputSchema.properties || {};\n\n for (const [inputId, prop] of Object.entries(properties)) {\n if (inputId === DATAFLOW_ALL_PORTS) {\n this.runInputData = { ...this.runInputData, ...overrides };\n changed = true;\n } else {\n if (overrides[inputId] === undefined) continue;\n const isArray =\n (prop as any)?.type === \"array\" ||\n ((prop as any)?.type === \"any\" &&\n (Array.isArray(overrides[inputId]) || Array.isArray(this.runInputData[inputId])));\n\n if (isArray) {\n const existingItems = Array.isArray(this.runInputData[inputId])\n ? this.runInputData[inputId]\n : this.runInputData[inputId] !== undefined\n ? [this.runInputData[inputId]]\n : [];\n const newitems = [...existingItems];\n\n const overrideItem = overrides[inputId];\n if (Array.isArray(overrideItem)) {\n newitems.push(...overrideItem);\n } else {\n newitems.push(overrideItem);\n }\n this.runInputData[inputId] = newitems;\n changed = true;\n } else {\n if (!deepEqual(this.runInputData[inputId], overrides[inputId])) {\n this.runInputData[inputId] = overrides[inputId];\n changed = true;\n }\n }\n }\n }\n\n // If additionalProperties is true, also accept any additional input properties\n if (inputSchema.additionalProperties) {\n for (const [inputId, value] of Object.entries(overrides)) {\n if (!(inputId in properties)) {\n if (!deepEqual(this.runInputData[inputId], value)) {\n this.runInputData[inputId] = value;\n changed = true;\n }\n }\n }\n }\n\n return changed;\n }\n\n /**\n * Stub for narrowing input. Override in subclasses for custom logic.\n * @param input The input to narrow\n * @param _registry Optional service registry for lookups\n * @returns The (possibly narrowed) input\n */\n public async narrowInput(\n input: Partial<Input>,\n _registry: ServiceRegistry\n ): Promise<Partial<Input>> {\n return input;\n }\n\n // ========================================================================\n // Event handling methods\n // ========================================================================\n\n /**\n * Subscribes to an event\n */\n public subscribe<Event extends TaskEvents>(\n name: Event,\n fn: TaskEventListener<Event>\n ): () => void {\n return this.events.subscribe(name, fn);\n }\n\n /**\n * Registers an event listener\n */\n public on<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.on(name, fn);\n }\n\n /**\n * Removes an event listener\n */\n public off<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.off(name, fn);\n }\n\n /**\n * Registers a one-time event listener\n */\n public once<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n this.events.once(name, fn);\n }\n\n /**\n * Returns a promise that resolves when the specified event is emitted\n */\n public waitOn<Event extends TaskEvents>(name: Event): Promise<TaskEventParameters<Event>> {\n return this.events.waitOn(name) as Promise<TaskEventParameters<Event>>;\n }\n\n /**\n * Emits an event\n */\n public emit<Event extends TaskEvents>(name: Event, ...args: TaskEventParameters<Event>): void {\n // Route through `events` so the emitter exists: `this._events?.emit` dropped progress when\n // nothing had accessed `task.events` yet (e.g. parent MapTask before CLI wired listeners).\n this.events.emit(name, ...args);\n }\n\n /**\n * Emits a schemaChange event when the task's input or output schema changes.\n * This should be called by tasks with dynamic schemas when their configuration\n * changes in a way that affects their schemas.\n *\n * @param inputSchema - The new input schema (optional, will use current schema if not provided)\n * @param outputSchema - The new output schema (optional, will use current schema if not provided)\n */\n protected emitSchemaChange(inputSchema?: DataPortSchema, outputSchema?: DataPortSchema): void {\n const finalInputSchema = inputSchema ?? this.inputSchema();\n const finalOutputSchema = outputSchema ?? this.outputSchema();\n this.emit(\"schemaChange\", finalInputSchema, finalOutputSchema);\n }\n\n // ========================================================================\n // Input validation methods\n // ========================================================================\n\n /**\n * Gets the compiled config schema node, or undefined if no configSchema is defined.\n *\n * The compiled schema is cached directly on the concrete class object (not in a shared\n * inherited Map) so that each subclass always uses its own configSchema() result.\n * A shared Map keyed only by type name can be poisoned if a different class computes\n * and caches the schema first — e.g., due to cross-package static-method resolution\n * inconsistencies in bundled outputs.\n */\n private static getConfigSchemaNode(): SchemaNode | undefined {\n const schema = this.configSchema();\n if (!schema) return undefined;\n // Use Object.hasOwn so each class gets its own entry rather than inheriting\n // from a parent class that already cached under the same key.\n if (!Object.hasOwn(this, \"__compiledConfigSchema\")) {\n try {\n const schemaNode =\n typeof schema === \"boolean\"\n ? compileSchema(schema ? {} : { not: {} })\n : compileSchema(schema);\n Object.defineProperty(this, \"__compiledConfigSchema\", {\n value: schemaNode,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n console.warn(`Failed to compile config schema for ${this.type}:`, error);\n return undefined;\n }\n }\n return (this as any).__compiledConfigSchema as SchemaNode;\n }\n\n /**\n * Validates config against configSchema.\n * Returns config as-is; throws on validation errors.\n * Returns config as-is if no configSchema is defined.\n */\n private validateAndApplyConfigDefaults(config: Config): Config {\n const ctor = this.constructor as typeof Task;\n const schemaNode = ctor.getConfigSchemaNode();\n if (!schemaNode) return config;\n\n const result = schemaNode.validate(config);\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => {\n const path = (e as any).data?.pointer || \"\";\n return `${e.message}${path ? ` (${path})` : \"\"}`;\n });\n throw new TaskConfigurationError(\n `[${ctor.name}] Configuration Error: ${errorMessages.join(\", \")}`\n );\n }\n\n return config;\n }\n\n protected static generateInputSchemaNode(schema: DataPortSchema) {\n if (typeof schema === \"boolean\") {\n if (schema === false) {\n return compileSchema({ not: {} });\n }\n return compileSchema({});\n }\n return compileSchema(schema);\n }\n\n /**\n * Gets the compiled input schema, cached per class (not in a shared inherited Map).\n * Uses Object.hasOwn so each subclass stores its own compiled schema and never\n * picks up a stale entry cached by a different class with the same type name.\n */\n protected static getInputSchemaNode(): SchemaNode {\n if (!Object.hasOwn(this, \"__compiledInputSchema\")) {\n const dataPortSchema = this.inputSchema();\n const schemaNode = this.generateInputSchemaNode(dataPortSchema);\n try {\n Object.defineProperty(this, \"__compiledInputSchema\", {\n value: schemaNode,\n writable: true,\n configurable: true,\n enumerable: false,\n });\n } catch (error) {\n // If compilation fails, fall back to accepting any object structure\n // This is a safety net for schemas that json-schema-library can't compile\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to permissive validation:`,\n error\n );\n Object.defineProperty(this, \"__compiledInputSchema\", {\n value: compileSchema({}),\n writable: true,\n configurable: true,\n enumerable: false,\n });\n }\n }\n return (this as any).__compiledInputSchema as SchemaNode;\n }\n\n protected getInputSchemaNode(): SchemaNode {\n return (this.constructor as typeof Task).getInputSchemaNode();\n }\n\n /**\n * Validates an input data object against the task's input schema\n */\n public async validateInput(input: Input): Promise<boolean> {\n if (typeof input !== \"object\" || input === null) {\n throw new TaskInvalidInputError(\"Input must be an object\");\n }\n const ctor = this.constructor as typeof Task;\n let schemaNode: SchemaNode;\n if (ctor.hasDynamicSchemas) {\n // Dynamic-schema tasks use instance inputSchema() (e.g. config.inputSchema), not the static fallback.\n // The cached getInputSchemaNode uses static inputSchema() which would reject valid instance-specific inputs.\n const instanceSchema = this.inputSchema();\n schemaNode = ctor.generateInputSchemaNode(instanceSchema);\n } else {\n schemaNode = this.getInputSchemaNode();\n }\n const result = schemaNode.validate(input);\n\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => {\n const path = e.data.pointer || \"\";\n return `${e.message}${path ? ` (${path})` : \"\"}`;\n });\n throw new TaskInvalidInputError(\n `Input ${JSON.stringify(Object.keys(input))} does not match schema: ${errorMessages.join(\", \")}`\n );\n }\n\n return true;\n }\n\n // ========================================================================\n // Serialization methods\n // ========================================================================\n\n /**\n * Strips symbol properties from an object to make it serializable\n * @param obj The object to strip symbols from\n * @returns A new object without symbol properties\n */\n private stripSymbols(obj: any): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n // Preserve TypedArrays (Float32Array, Int8Array, etc.)\n if (ArrayBuffer.isView(obj)) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map((item) => this.stripSymbols(item));\n }\n if (typeof obj === \"object\") {\n const result: Record<string, any> = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n result[key] = this.stripSymbols(obj[key]);\n }\n }\n return result;\n }\n return obj;\n }\n\n /**\n * Serializes the task and its subtasks into a format that can be stored\n * @param _options Options controlling serialization (used by subclasses)\n * @returns The serialized task and subtasks\n */\n public toJSON(_options?: TaskGraphJsonOptions): TaskGraphItemJson {\n const ctor = this.constructor as typeof Task;\n\n // Build config by extracting only serializable properties defined in the configSchema.\n // We filter through the schema to avoid accidentally including non-serializable\n // values (e.g. functions like WhileTask.condition) or internal-only properties\n // that were never part of the serialized output and that consuming applications\n // don't expect (e.g. `queue` from JobQueueTask).\n const schema = ctor.configSchema();\n const schemaProperties =\n typeof schema !== \"boolean\" && schema?.properties\n ? (schema.properties as Record<string, Record<string, unknown>>)\n : {};\n\n const config: Record<string, unknown> = {};\n for (const [key, propSchema] of Object.entries(schemaProperties)) {\n if (key === \"id\") continue;\n // Skip internal properties marked as hidden (e.g. queue, compoundMerge)\n // except inputSchema/outputSchema/extras which are needed for task reconstruction\n if (\n propSchema?.[\"x-ui-hidden\"] === true &&\n key !== \"inputSchema\" &&\n key !== \"outputSchema\" &&\n key !== \"extras\"\n ) {\n continue;\n }\n const value = (this.config as Record<string, unknown>)[key];\n if (value === undefined) continue;\n // Skip non-serializable values (functions, symbols, etc.)\n if (typeof value === \"function\" || typeof value === \"symbol\") continue;\n config[key] = value;\n }\n\n // Omit title/description when they match the static class defaults\n if (config.title === ctor.title) delete config.title;\n if (config.description === ctor.description) delete config.description;\n\n // Omit empty extras\n const extras = config.extras as Record<string, unknown> | undefined;\n if (!extras || Object.keys(extras).length === 0) delete config.extras;\n\n const base: TaskGraphItemJson = {\n id: this.id,\n type: this.type,\n defaults: this.defaults,\n };\n if (Object.keys(config).length > 0) {\n base.config = config;\n }\n return this.stripSymbols(base) as TaskGraphItemJson;\n }\n\n /**\n * Converts the task to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (used by subclasses)\n * @returns The task and subtasks in JSON thats easier for humans to read\n */\n public toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem {\n const json = this.toJSON(options);\n return json;\n }\n\n // ========================================================================\n // Internal graph methods\n // ========================================================================\n\n /**\n * Checks if the task has children. Useful to gate to use of the internal subGraph\n * as this will return without creating a new graph if graph is non-existent .\n *\n * @returns True if the task has children, otherwise false\n */\n public hasChildren(): boolean {\n return (\n this._subGraph !== undefined &&\n this._subGraph !== null &&\n this._subGraph.getTasks().length > 0\n );\n }\n\n private _taskAddedListener: (taskId: TaskIdType) => void = () => {\n this.emit(\"regenerate\");\n };\n\n /**\n * The internal task graph containing subtasks\n *\n * In the base case, these may just be incidental tasks that are not part of the task graph\n * but are used to manage the task's state as part of task execution. Therefore, the graph\n * is not used by the default runner.\n */\n protected _subGraph: TaskGraph | undefined = undefined;\n\n /**\n * Sets the subtask graph for the compound task\n * @param subGraph The subtask graph to set\n */\n set subGraph(subGraph: TaskGraph) {\n if (this._subGraph) {\n this._subGraph.off(\"task_added\", this._taskAddedListener);\n }\n this._subGraph = subGraph;\n this._subGraph.on(\"task_added\", this._taskAddedListener);\n }\n\n /**\n * The internal task graph containing subtasks\n *\n * In the base case, these may just be incidental tasks that are not part of the task graph\n * but are used to manage the task's state as part of task execution. Therefore, the graph\n * is not used by the default runner.\n *\n * Creates a new graph if one doesn't exist.\n *\n * @returns The task graph\n */\n get subGraph(): TaskGraph {\n if (!this._subGraph) {\n this._subGraph = new TaskGraph();\n this._subGraph.on(\"task_added\", this._taskAddedListener);\n }\n return this._subGraph;\n }\n\n /**\n * Regenerates the task graph, which is internal state to execute() with config.own()\n *\n * This is a destructive operation that removes all dataflows and tasks from the graph.\n * It is used to reset the graph to a clean state.\n *\n * GraphAsTask and others override this and do not call super\n */\n public regenerateGraph(): void {\n if (this.hasChildren()) {\n for (const dataflow of this.subGraph.getDataflows()) {\n this.subGraph.removeDataflow(dataflow);\n }\n for (const child of this.subGraph.getTasks()) {\n this.subGraph.removeTask(child.id);\n }\n }\n this.events.emit(\"regenerate\");\n }\n}\n",
14
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * Comparison operators supported by the UI condition builder.\n */\nexport type ComparisonOperator =\n | \"equals\"\n | \"not_equals\"\n | \"greater_than\"\n | \"greater_or_equal\"\n | \"less_than\"\n | \"less_or_equal\"\n | \"contains\"\n | \"starts_with\"\n | \"ends_with\"\n | \"is_empty\"\n | \"is_not_empty\"\n | \"is_true\"\n | \"is_false\";\n\n/**\n * Serialized condition branch configuration from the UI builder.\n * Used by ConditionalTask to auto-build runtime condition functions.\n */\nexport interface UIConditionBranch {\n id: string;\n field: string;\n operator: ComparisonOperator;\n value: string;\n}\n\n/**\n * Serialized condition configuration from the UI builder.\n * Used by ConditionalTask to auto-build runtime branch configs.\n */\nexport interface UIConditionConfig {\n branches: UIConditionBranch[];\n exclusive: boolean;\n defaultBranch?: string;\n}\n\n/**\n * Evaluates a condition based on operator type.\n *\n * @param fieldValue - The value of the field being tested\n * @param operator - The comparison operator to apply\n * @param compareValue - The value to compare against (always a string from the UI)\n * @returns true if the condition is met, false otherwise\n */\nexport function evaluateCondition(\n fieldValue: unknown,\n operator: ComparisonOperator,\n compareValue: string\n): boolean {\n // Handle null/undefined\n if (fieldValue === null || fieldValue === undefined) {\n switch (operator) {\n case \"is_empty\":\n return true;\n case \"is_not_empty\":\n return false;\n case \"is_true\":\n return false;\n case \"is_false\":\n return true;\n default:\n return false;\n }\n }\n\n const strValue = String(fieldValue);\n const numValue = Number(fieldValue);\n\n switch (operator) {\n case \"equals\":\n // Try numeric comparison first, then string\n if (!isNaN(numValue) && !isNaN(Number(compareValue))) {\n return numValue === Number(compareValue);\n }\n return strValue === compareValue;\n\n case \"not_equals\":\n if (!isNaN(numValue) && !isNaN(Number(compareValue))) {\n return numValue !== Number(compareValue);\n }\n return strValue !== compareValue;\n\n case \"greater_than\":\n return numValue > Number(compareValue);\n\n case \"greater_or_equal\":\n return numValue >= Number(compareValue);\n\n case \"less_than\":\n return numValue < Number(compareValue);\n\n case \"less_or_equal\":\n return numValue <= Number(compareValue);\n\n case \"contains\":\n return strValue.toLowerCase().includes(compareValue.toLowerCase());\n\n case \"starts_with\":\n return strValue.toLowerCase().startsWith(compareValue.toLowerCase());\n\n case \"ends_with\":\n return strValue.toLowerCase().endsWith(compareValue.toLowerCase());\n\n case \"is_empty\":\n return strValue === \"\" || (Array.isArray(fieldValue) && fieldValue.length === 0);\n\n case \"is_not_empty\":\n return strValue !== \"\" && !(Array.isArray(fieldValue) && fieldValue.length === 0);\n\n case \"is_true\":\n return Boolean(fieldValue) === true;\n\n case \"is_false\":\n return Boolean(fieldValue) === false;\n\n default:\n return false;\n }\n}\n\n/**\n * Get a value from a nested object using dot notation.\n * e.g., \"user.name\" would get obj.user.name\n *\n * @param obj - The object to read from\n * @param path - Dot-separated path to the value\n * @returns The value at the path, or undefined if any segment is missing\n */\nexport function getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n\n return current;\n}\n",
15
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { getLogger } from \"@workglow/util\";\nimport { evaluateCondition, getNestedValue, type UIConditionConfig } from \"./ConditionUtils\";\nimport type { IExecuteContext } from \"./ITask\";\nimport { Task } from \"./Task\";\nimport {\n TaskConfigSchema,\n type TaskConfig,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\n// ============================================================================\n// Types and Interfaces\n// ============================================================================\n\n/**\n * A predicate function that evaluates whether a branch condition is met.\n * Receives the task's input data and returns true if the branch should be active.\n *\n * @template Input - The input type for the conditional task\n * @param input - The input data to evaluate\n * @returns true if the branch condition is met, false otherwise\n *\n * @example\n * ```typescript\n * // Simple numeric comparison\n * const isHighValue: ConditionFn<{ value: number }> = (input) => input.value > 100;\n *\n * // String equality check\n * const isAdmin: ConditionFn<{ role: string }> = (input) => input.role === \"admin\";\n *\n * // Complex boolean logic\n * const isEligible: ConditionFn<{ age: number; verified: boolean }> = (input) =>\n * input.age >= 18 && input.verified;\n * ```\n */\nexport type ConditionFn<Input> = (input: Input) => boolean;\n\n/**\n * Configuration for a single branch in a ConditionalTask.\n *\n * Each branch represents a possible path through the conditional logic.\n * When the condition evaluates to true, the branch becomes active and\n * its output port will receive the task's input data.\n *\n * @template Input - The input type for the conditional task\n *\n * @example\n * ```typescript\n * const highValueBranch: BranchConfig<{ amount: number }> = {\n * id: \"high\",\n * condition: (input) => input.amount > 1000,\n * outputPort: \"highValue\"\n * };\n * ```\n */\nexport interface BranchConfig<Input> {\n /** Unique identifier for this branch within the task */\n readonly id: string;\n\n /** Predicate function that determines if this branch is active */\n readonly condition: ConditionFn<Input>;\n\n /** Name of the output port that will receive data when this branch is active */\n readonly outputPort: string;\n}\n\n/**\n * Configuration interface for ConditionalTask.\n *\n * Extends the base TaskConfig with conditional-specific options including\n * branch definitions, default branch handling, and execution mode.\n *\n * @example\n * ```typescript\n * const config: ConditionalTaskConfig = {\n * id: \"router\",\n * branches: [\n * { id: \"premium\", condition: (i) => i.tier === \"premium\", outputPort: \"premium\" },\n * { id: \"standard\", condition: (i) => i.tier === \"standard\", outputPort: \"standard\" },\n * ],\n * defaultBranch: \"standard\",\n * exclusive: true, // Only first matching branch activates\n * };\n * ```\n */\nexport const conditionalTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...TaskConfigSchema[\"properties\"],\n branches: { type: \"array\", items: {} },\n defaultBranch: { type: \"string\" },\n exclusive: { type: \"boolean\" },\n conditionConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\nexport type ConditionalTaskConfig = TaskConfig & {\n /** Branches may contain ConditionFn functions — not JSON-schema-representable */\n readonly branches?: BranchConfig<any>[];\n readonly defaultBranch?: string;\n readonly exclusive?: boolean;\n /** Serializable UI condition configuration used to build branches at runtime. */\n readonly conditionConfig?: UIConditionConfig;\n};\n\n// ============================================================================\n// ConditionalTask Class\n// ============================================================================\n\n/**\n * A task that evaluates conditions to determine which downstream paths are active.\n *\n * ConditionalTask implements conditional branching within a task graph, similar to\n * if/then/else or switch/case statements. It evaluates configured conditions against\n * its input and selectively enables output ports for active branches while disabling\n * dataflows to inactive branches.\n *\n * ## Key Features\n *\n * - **Condition-based routing**: Route data to different downstream tasks based on input values\n * - **Exclusive mode**: Act as a switch/case where only the first matching branch activates\n * - **Multi-path mode**: Enable multiple branches simultaneously when conditions match\n * - **Default branch**: Specify a fallback branch when no conditions match\n * - **Disabled propagation**: Inactive branches result in DISABLED status for downstream tasks\n *\n * ## Execution Modes\n *\n * ### Exclusive Mode (default)\n * In exclusive mode (`exclusive: true`), the task behaves like a switch statement.\n * Branches are evaluated in order, and only the first matching branch becomes active.\n * This is useful for mutually exclusive paths.\n *\n * ### Multi-Path Mode\n * In multi-path mode (`exclusive: false`), all branches whose conditions evaluate\n * to true become active simultaneously. This enables fan-out patterns where the\n * same input triggers multiple downstream processing paths.\n *\n * ## Output Behavior\n *\n * For each active branch, the task passes through its entire input to that branch's\n * output port. Inactive branches receive no data, and their outgoing dataflows are\n * set to DISABLED status, which cascades to downstream tasks that have no other\n * active inputs.\n *\n * @template Input - The input type for the task\n * @template Output - The output type for the task\n * @template Config - The configuration type (must extend ConditionalTaskConfig)\n *\n * @example\n * ```typescript\n * // Simple if/else routing based on a numeric threshold\n * const thresholdRouter = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"high\", condition: (i) => i.value > 100, outputPort: \"highPath\" },\n * { id: \"low\", condition: (i) => i.value <= 100, outputPort: \"lowPath\" },\n * ],\n * }\n * );\n *\n * // Switch/case style routing based on string enum\n * const statusRouter = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"active\", condition: (i) => i.status === \"active\", outputPort: \"active\" },\n * { id: \"pending\", condition: (i) => i.status === \"pending\", outputPort: \"pending\" },\n * { id: \"inactive\", condition: (i) => i.status === \"inactive\", outputPort: \"inactive\" },\n * ],\n * defaultBranch: \"inactive\",\n * exclusive: true,\n * }\n * );\n *\n * // Multi-path fan-out for parallel processing\n * const fanOut = new ConditionalTask(\n * {},\n * {\n * branches: [\n * { id: \"log\", condition: () => true, outputPort: \"logger\" },\n * { id: \"process\", condition: () => true, outputPort: \"processor\" },\n * { id: \"archive\", condition: (i) => i.shouldArchive, outputPort: \"archiver\" },\n * ],\n * exclusive: false, // All matching branches activate\n * }\n * );\n * ```\n */\nexport class ConditionalTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends ConditionalTaskConfig = ConditionalTaskConfig,\n> extends Task<Input, Output, Config> {\n /** Task type identifier for serialization and registry lookup */\n static type: TaskTypeName = \"ConditionalTask\";\n\n /** Category for UI organization and filtering */\n static category = \"Flow Control\";\n\n /** Human-readable title for display in UIs */\n static title = \"Condition\";\n static description = \"Route data based on conditions\";\n\n /** This task has dynamic schemas that change based on branch configuration */\n static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return conditionalTaskConfigSchema;\n }\n\n /**\n * Set of branch IDs that are currently active after execution.\n * Populated during execute() and used by the graph runner to\n * determine which dataflows should be enabled vs disabled.\n */\n public activeBranches: Set<string> = new Set();\n\n // ========================================================================\n // Execution methods\n // ========================================================================\n\n /**\n * Evaluates branch conditions and determines which branches are active.\n * Only active branches will have their output ports populated.\n *\n * @param input - The input data to evaluate conditions against\n * @param context - Execution context with signal and progress callback\n * @returns Output with active branch data and metadata\n */\n /**\n * Builds runtime branch configs from serialized UI condition config.\n */\n private buildBranchesFromConditionConfig(\n conditionConfig: UIConditionConfig\n ): BranchConfig<Input>[] {\n if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {\n return [\n {\n id: \"default\",\n condition: () => true,\n outputPort: \"1\",\n },\n ];\n }\n\n return conditionConfig.branches.map((branch, index) => ({\n id: branch.id,\n outputPort: String(index + 1),\n condition: (inputData: Input): boolean => {\n const fieldValue = getNestedValue(inputData as Record<string, unknown>, branch.field);\n return evaluateCondition(fieldValue, branch.operator, branch.value);\n },\n }));\n }\n\n /**\n * Resolves the effective branches to evaluate.\n * Uses config.branches if they have condition functions,\n * otherwise falls back to conditionConfig from input or extras.\n */\n private resolveBranches(input: Input): {\n branches: BranchConfig<Input>[];\n isExclusive: boolean;\n defaultBranch: string | undefined;\n fromConditionConfig: boolean;\n } {\n const configBranches = this.config.branches ?? [];\n\n // If config branches have condition functions, use them directly\n if (configBranches.length > 0 && typeof configBranches[0].condition === \"function\") {\n return {\n branches: configBranches,\n isExclusive: this.config.exclusive ?? true,\n defaultBranch: this.config.defaultBranch,\n fromConditionConfig: false,\n };\n }\n\n // Try to find serialized conditionConfig from input or config\n const conditionConfig =\n ((input as Record<string, unknown>).conditionConfig as UIConditionConfig | undefined) ??\n this.config.conditionConfig;\n\n if (conditionConfig) {\n return {\n branches: this.buildBranchesFromConditionConfig(conditionConfig),\n isExclusive: conditionConfig.exclusive ?? true,\n defaultBranch: conditionConfig.defaultBranch,\n fromConditionConfig: true,\n };\n }\n\n // Fallback: use config branches even if they lack conditions\n return {\n branches: configBranches,\n isExclusive: this.config.exclusive ?? true,\n defaultBranch: this.config.defaultBranch,\n fromConditionConfig: false,\n };\n }\n\n public async execute(input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (context.signal?.aborted) {\n return undefined;\n }\n\n // Clear previous branch activation state\n this.activeBranches.clear();\n\n const { branches, isExclusive, defaultBranch, fromConditionConfig } =\n this.resolveBranches(input);\n\n // Evaluate each branch condition\n for (const branch of branches) {\n try {\n const isActive = branch.condition(input);\n if (isActive) {\n this.activeBranches.add(branch.id);\n if (isExclusive) {\n // In exclusive mode, stop at first match\n break;\n }\n }\n } catch (error) {\n // If condition throws, treat it as false (branch not taken)\n getLogger().warn(`Condition evaluation failed for branch \"${branch.id}\":`, { error });\n }\n }\n\n // If no branch matched and there's a default, use it\n if (this.activeBranches.size === 0 && defaultBranch) {\n const defaultBranchExists = branches.some((b) => b.id === defaultBranch);\n if (defaultBranchExists) {\n this.activeBranches.add(defaultBranch);\n }\n }\n\n // Build output: if from conditionConfig, use the UI-style output building\n if (fromConditionConfig) {\n return this.buildConditionConfigOutput(input, branches, isExclusive);\n }\n\n // Build output: pass through input to active branch ports\n return this.buildOutput(input);\n }\n\n /**\n * Builds output in the UI-style format where inputs are passed through\n * with numbered suffixes based on matched branches.\n */\n protected buildConditionConfigOutput(\n input: Input,\n branches: BranchConfig<Input>[],\n isExclusive: boolean\n ): Output {\n const output: Record<string, unknown> = {};\n\n // Remove conditionConfig from pass-through data\n const { conditionConfig, ...passThrough } = input as Record<string, unknown>;\n const inputKeys = Object.keys(passThrough);\n\n // Find matched branch number\n let matchedBranchNumber: number | null = null;\n for (let i = 0; i < branches.length; i++) {\n if (this.activeBranches.has(branches[i].id)) {\n if (matchedBranchNumber === null) {\n matchedBranchNumber = i + 1;\n }\n }\n }\n\n if (isExclusive) {\n if (matchedBranchNumber !== null) {\n for (const key of inputKeys) {\n output[`${key}_${matchedBranchNumber}`] = passThrough[key];\n }\n } else {\n for (const key of inputKeys) {\n output[`${key}_else`] = passThrough[key];\n }\n }\n } else {\n for (let i = 0; i < branches.length; i++) {\n if (this.activeBranches.has(branches[i].id)) {\n for (const key of inputKeys) {\n output[`${key}_${i + 1}`] = passThrough[key];\n }\n }\n }\n }\n\n return output as Output;\n }\n\n /**\n * Builds the output object with data routed to active branch ports.\n * Each active branch's output port receives the full input data.\n *\n * @param input - The input data to pass through to active branches\n * @returns Output object with active branch ports populated\n */\n protected buildOutput(input: Input): Output {\n const output: Record<string, unknown> = {\n _activeBranches: Array.from(this.activeBranches),\n };\n\n const branches = this.config.branches ?? [];\n\n // For each active branch, populate its output port with the input data\n for (const branch of branches) {\n if (this.activeBranches.has(branch.id)) {\n // Pass through all input properties to the active branch's output port\n output[branch.outputPort] = { ...input };\n }\n }\n\n return output as Output;\n }\n\n // ========================================================================\n // Branch information methods\n // ========================================================================\n\n /**\n * Checks if a specific branch is currently active.\n *\n * @param branchId - The ID of the branch to check\n * @returns true if the branch is active, false otherwise\n *\n * @example\n * ```typescript\n * await conditionalTask.run({ value: 150 });\n * if (conditionalTask.isBranchActive(\"high\")) {\n * console.log(\"High value path was taken\");\n * }\n * ```\n */\n public isBranchActive(branchId: string): boolean {\n return this.activeBranches.has(branchId);\n }\n\n /**\n * Gets the set of currently active branch IDs.\n * Returns a new Set to prevent external modification.\n *\n * @returns Set of active branch IDs\n */\n public getActiveBranches(): Set<string> {\n return new Set(this.activeBranches);\n }\n\n /**\n * Gets a map of output port names to their active status.\n * Useful for inspecting which output ports will have data.\n *\n * @returns Map of output port name to boolean active status\n *\n * @example\n * ```typescript\n * const portStatus = conditionalTask.getPortActiveStatus();\n * for (const [port, isActive] of portStatus) {\n * console.log(`Port ${port}: ${isActive ? \"active\" : \"inactive\"}`);\n * }\n * ```\n */\n public getPortActiveStatus(): Map<string, boolean> {\n const status = new Map<string, boolean>();\n const branches = this.config.branches ?? [];\n\n for (const branch of branches) {\n status.set(branch.outputPort, this.activeBranches.has(branch.id));\n }\n\n return status;\n }\n\n // ========================================================================\n // Schema methods\n // ========================================================================\n\n /**\n * Generates the output schema dynamically based on configured branches.\n * Each branch's output port is defined as an object type that will\n * receive the pass-through input data when active.\n *\n * @returns JSON Schema for the task's output\n */\n static outputSchema(): DataPortSchema {\n // Base schema - actual properties are determined by branch configuration\n return {\n type: \"object\",\n properties: {\n _activeBranches: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"List of active branch IDs after condition evaluation\",\n },\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance method to get output schema with branch-specific ports.\n * Dynamically generates properties based on the configured branches.\n *\n * @returns JSON Schema for the task's output including branch ports\n */\n outputSchema(): DataPortSchema {\n const branches = this.config?.branches ?? [];\n const properties: Record<string, any> = {\n _activeBranches: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"List of active branch IDs after condition evaluation\",\n },\n };\n\n // Add each branch's output port to the schema\n for (const branch of branches) {\n properties[branch.outputPort] = {\n type: \"object\",\n description: `Output for branch \"${branch.id}\" when active`,\n additionalProperties: true,\n };\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n\n /**\n * Returns schema indicating the task accepts any input.\n * ConditionalTask passes through its input to active branches,\n * so it doesn't constrain the input type.\n *\n * @returns Schema that accepts any input\n */\n static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance method returning schema that accepts any input.\n *\n * @returns Schema that accepts any input\n */\n inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n}\n",
16
19
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ITask } from \"../task/ITask\";\nimport { getPortStreamMode } from \"../task/StreamTypes\";\nimport { TaskStatus } from \"../task/TaskTypes\";\nimport { TaskGraph } from \"./TaskGraph\";\n\n/**\n * Interface for task graph schedulers\n */\nexport interface ITaskGraphScheduler {\n /**\n * Gets an async iterator of tasks that can be executed\n * @returns AsyncIterator of tasks that resolves to each task when it's ready\n */\n tasks(): AsyncIterableIterator<ITask>;\n\n /**\n * Notifies the scheduler that a task has completed\n * @param taskId The ID of the completed task\n */\n onTaskCompleted(taskId: unknown): void;\n\n /**\n * Notifies the scheduler that a task has begun streaming output.\n * Streaming tasks may unblock downstream streamable tasks early.\n * @param taskId The ID of the streaming task\n */\n onTaskStreaming(taskId: unknown): void;\n\n /**\n * Resets the scheduler state\n */\n reset(): void;\n}\n\n/**\n * Sequential scheduler that executes one task at a time in topological order\n * Useful for debugging and understanding task execution flow\n */\nexport class TopologicalScheduler implements ITaskGraphScheduler {\n private sortedNodes: ITask[];\n private currentIndex: number;\n\n constructor(private dag: TaskGraph) {\n this.sortedNodes = [];\n this.currentIndex = 0;\n this.reset();\n }\n\n async *tasks(): AsyncIterableIterator<ITask> {\n while (this.currentIndex < this.sortedNodes.length) {\n yield this.sortedNodes[this.currentIndex++];\n }\n }\n\n onTaskCompleted(taskId: unknown): void {\n // Topological scheduler doesn't need to track individual task completion\n }\n\n onTaskStreaming(taskId: unknown): void {\n // Topological scheduler doesn't support streaming-aware scheduling\n }\n\n reset(): void {\n this.sortedNodes = this.dag.topologicallySortedNodes();\n this.currentIndex = 0;\n }\n}\n\n/**\n * Event-driven scheduler that executes tasks as soon as their dependencies are satisfied\n * Most efficient for parallel execution but requires completion notifications\n */\nexport class DependencyBasedScheduler implements ITaskGraphScheduler {\n private completedTasks: Set<unknown>;\n private streamingTasks: Set<unknown>;\n private pendingTasks: Set<ITask>;\n private nextResolver: ((task: ITask | null) => void) | null = null;\n\n constructor(private dag: TaskGraph) {\n this.completedTasks = new Set();\n this.streamingTasks = new Set();\n this.pendingTasks = new Set();\n this.reset();\n }\n\n private isTaskReady(task: ITask): boolean {\n // DISABLED tasks are never ready - they should be skipped\n if (task.status === TaskStatus.DISABLED) {\n return false;\n }\n\n const sourceDataflows = this.dag.getSourceDataflows(task.id);\n\n // If task has incoming dataflows, check if all are DISABLED\n // (In that case, task will be disabled by propagateDisabledStatus, not ready to run)\n if (sourceDataflows.length > 0) {\n const allIncomingDisabled = sourceDataflows.every((df) => df.status === TaskStatus.DISABLED);\n if (allIncomingDisabled) {\n return false;\n }\n }\n\n // A task is ready if all its non-disabled dependencies are completed.\n // DISABLED dataflows are considered \"satisfied\" (their branch was not taken).\n //\n // Per-edge streaming: when the source output port AND the target input port\n // both declare matching `x-stream`, the dependency can be satisfied by\n // STREAMING status (not just COMPLETED). Edges where the target port does\n // NOT accept streams still require full completion.\n const activeDataflows = sourceDataflows.filter((df) => df.status !== TaskStatus.DISABLED);\n\n return activeDataflows.every((df) => {\n const depId = df.sourceTaskId;\n if (this.completedTasks.has(depId)) return true;\n\n // Check if this specific edge supports stream pass-through\n if (this.streamingTasks.has(depId)) {\n const sourceTask = this.dag.getTask(depId);\n if (sourceTask) {\n const sourceMode = getPortStreamMode(sourceTask.outputSchema(), df.sourceTaskPortId);\n const targetMode = getPortStreamMode(task.inputSchema(), df.targetTaskPortId);\n if (sourceMode !== \"none\" && sourceMode === targetMode) {\n return true;\n }\n }\n }\n\n return false;\n });\n }\n\n private async waitForNextTask(): Promise<ITask | null> {\n if (this.pendingTasks.size === 0) return null;\n\n // Remove any disabled tasks from pending (they were disabled by propagateDisabledStatus)\n for (const task of Array.from(this.pendingTasks)) {\n if (task.status === TaskStatus.DISABLED) {\n this.pendingTasks.delete(task);\n }\n }\n\n if (this.pendingTasks.size === 0) return null;\n\n const readyTask = Array.from(this.pendingTasks).find((task) => this.isTaskReady(task));\n if (readyTask) {\n this.pendingTasks.delete(readyTask);\n return readyTask;\n }\n\n // If there are pending tasks but none are ready, wait for task completion\n if (this.pendingTasks.size > 0) {\n return new Promise((resolve) => {\n this.nextResolver = resolve;\n });\n }\n\n return null;\n }\n\n async *tasks(): AsyncIterableIterator<ITask> {\n while (this.pendingTasks.size > 0) {\n const task = await this.waitForNextTask();\n if (task) {\n yield task;\n } else {\n break;\n }\n }\n }\n\n onTaskCompleted(taskId: unknown): void {\n this.completedTasks.add(taskId);\n\n // Remove any disabled tasks from pending\n for (const task of Array.from(this.pendingTasks)) {\n if (task.status === TaskStatus.DISABLED) {\n this.pendingTasks.delete(task);\n }\n }\n\n // Check if any pending tasks are now ready\n if (this.nextResolver) {\n const readyTask = Array.from(this.pendingTasks).find((task) => this.isTaskReady(task));\n if (readyTask) {\n this.pendingTasks.delete(readyTask);\n const resolver = this.nextResolver;\n this.nextResolver = null;\n resolver(readyTask);\n } else if (this.pendingTasks.size === 0) {\n // No more pending tasks - resolve with null to signal completion\n const resolver = this.nextResolver;\n this.nextResolver = null;\n resolver(null);\n }\n }\n }\n\n onTaskStreaming(taskId: unknown): void {\n this.streamingTasks.add(taskId);\n\n // Remove any disabled tasks from pending\n for (const task of Array.from(this.pendingTasks)) {\n if (task.status === TaskStatus.DISABLED) {\n this.pendingTasks.delete(task);\n }\n }\n\n // Check if any pending streamable tasks are now ready\n // (they can start when deps are STREAMING, not just COMPLETED)\n if (this.nextResolver) {\n const readyTask = Array.from(this.pendingTasks).find((task) => this.isTaskReady(task));\n if (readyTask) {\n this.pendingTasks.delete(readyTask);\n const resolver = this.nextResolver;\n this.nextResolver = null;\n resolver(readyTask);\n }\n }\n }\n\n reset(): void {\n this.completedTasks.clear();\n this.streamingTasks.clear();\n this.pendingTasks = new Set(this.dag.topologicallySortedNodes());\n this.nextResolver = null;\n }\n}\n",
17
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n collectPropertyValues,\n ConvertAllToOptionalArray,\n getLogger,\n getTelemetryProvider,\n globalServiceRegistry,\n ServiceRegistry,\n SpanStatusCode,\n uuid4,\n type ISpan,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport { ITask } from \"../task/ITask\";\nimport {\n edgeNeedsAccumulation,\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n type StreamEvent,\n} from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport { TaskAbortedError, TaskConfigurationError, TaskError } from \"../task/TaskError\";\nimport { TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport { TaskGraph, TaskGraphRunConfig, TaskGraphRunReactiveConfig } from \"./TaskGraph\";\nimport { DependencyBasedScheduler, TopologicalScheduler } from \"./TaskGraphScheduler\";\n\n/**\n * Tasks that inherit {@link Task.prototype.execute} without declaring their own `execute` on the\n * subclass prototype are omitted from graph-level progress averaging (they keep default 0% until\n * complete and would dilute the bar).\n */\nexport function taskPrototypeHasOwnExecute(task: ITask): boolean {\n const Ctor = task.constructor as typeof Task;\n return Object.hasOwn(Ctor.prototype, \"execute\");\n}\n\nexport type GraphSingleTaskResult<T> = {\n id: unknown;\n type: String;\n data: T;\n};\nexport type GraphResultArray<T> = Array<GraphSingleTaskResult<T>>;\nexport type PropertyArrayGraphResult<T> = ConvertAllToOptionalArray<T>;\nexport type AnyGraphResult<T> = PropertyArrayGraphResult<T> | GraphResultArray<T>;\n\nexport const PROPERTY_ARRAY = \"PROPERTY_ARRAY\" as const;\nexport const GRAPH_RESULT_ARRAY = \"GRAPH_RESULT_ARRAY\" as const;\n\nexport type GraphResultMap<T> = {\n // array of results with id for tasks that created them -- output is an array of {id, type, data}[]\n [GRAPH_RESULT_ARRAY]: GraphResultArray<T>;\n // property-array -- output is consolidation of each output property, with duplicate properties turned into an array\n [PROPERTY_ARRAY]: PropertyArrayGraphResult<T>;\n};\n\n/**\n * Enum representing the possible compound merge strategies\n */\nexport type CompoundMergeStrategy = typeof PROPERTY_ARRAY | typeof GRAPH_RESULT_ARRAY;\n\nexport type GraphResult<\n Output,\n Merge extends CompoundMergeStrategy,\n> = GraphResultMap<Output>[Merge];\n\n/**\n * Class for running a task graph\n * Manages the execution of tasks in a task graph, including caching\n */\nexport class TaskGraphRunner {\n /**\n * Whether the task graph is currently running\n */\n protected running = false;\n protected reactiveRunning = false;\n\n /**\n * The task graph to run\n */\n public readonly graph: TaskGraph;\n\n /**\n * Output cache repository\n */\n protected outputCache?: TaskOutputRepository;\n /**\n * Whether leaf tasks (no outgoing edges) should accumulate their streaming\n * output. True by default so workflow return values are complete.\n */\n protected accumulateLeafOutputs: boolean = true;\n /**\n * Service registry for this graph run\n */\n protected registry: ServiceRegistry = globalServiceRegistry;\n /**\n * AbortController for cancelling graph execution\n */\n protected abortController: AbortController | undefined;\n\n /**\n * Maps to track task execution state\n */\n protected inProgressTasks: Map<unknown, Promise<TaskOutput>> = new Map();\n protected inProgressFunctions: Map<unknown, Promise<any>> = new Map();\n protected failedTaskErrors: Map<unknown, TaskError> = new Map();\n\n /**\n * Active telemetry span for the current graph run.\n */\n protected telemetrySpan?: ISpan;\n\n /**\n * Constructor for TaskGraphRunner\n * @param graph The task graph to run\n * @param outputCache The task output repository to use for caching task outputs\n * @param processScheduler The scheduler to use for task execution\n * @param reactiveScheduler The scheduler to use for reactive task execution\n */\n constructor(\n graph: TaskGraph,\n outputCache?: TaskOutputRepository,\n protected processScheduler = new DependencyBasedScheduler(graph),\n protected reactiveScheduler = new TopologicalScheduler(graph)\n ) {\n this.graph = graph;\n graph.outputCache = outputCache;\n this.handleProgress = this.handleProgress.bind(this);\n }\n\n /**\n * Unique ID for the current run, used for timing labels.\n */\n protected runId: string = \"\";\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n public async runGraph<ExecuteOutput extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config?: TaskGraphRunConfig\n ): Promise<GraphResultArray<ExecuteOutput>> {\n await this.handleStart(config);\n\n const results: GraphResultArray<ExecuteOutput> = [];\n let error: TaskError | undefined;\n\n try {\n // TODO: A different graph runner may chunk tasks that are in parallel\n // rather them all currently available\n for await (const task of this.processScheduler.tasks()) {\n if (this.abortController?.signal.aborted) {\n break;\n }\n\n if (this.failedTaskErrors.size > 0) {\n break;\n }\n\n const isRootTask = this.graph.getSourceDataflows(task.id).length === 0;\n\n const runAsync = async () => {\n let errorRouted = false;\n try {\n // Only filter input for non-root tasks; root tasks get the full input\n const taskInput = isRootTask ? input : this.filterInputForTask(task, input);\n\n const taskPromise = this.runTask(task, taskInput);\n this.inProgressTasks!.set(task.id, taskPromise);\n const taskResult = await taskPromise;\n\n if (this.graph.getTargetDataflows(task.id).length === 0) {\n // we save the results of all the leaves\n results.push(taskResult as GraphSingleTaskResult<ExecuteOutput>);\n }\n } catch (error) {\n if (this.hasErrorOutputEdges(task)) {\n // Route the error through error-port dataflows instead of failing the graph.\n // pushErrorOutputToEdges sets edge statuses directly (COMPLETED for error\n // edges, DISABLED for normal edges), so we skip the normal status push.\n errorRouted = true;\n this.pushErrorOutputToEdges(task);\n } else {\n this.failedTaskErrors.set(task.id, error as TaskError);\n }\n } finally {\n // IMPORTANT: Push status to edges BEFORE notifying scheduler\n // This ensures dataflow statuses (including DISABLED) are set\n // before the scheduler checks which tasks are ready.\n // Skip normal status push when error routing already set edge statuses.\n if (!errorRouted) {\n this.pushStatusFromNodeToEdges(this.graph, task);\n this.pushErrorFromNodeToEdges(this.graph, task);\n }\n this.processScheduler.onTaskCompleted(task.id);\n }\n };\n\n // Start task execution without awaiting\n // so we can have many tasks running in parallel\n // but keep track of them to make sure they get awaited\n // otherwise, things will finish after this promise is resolved\n this.inProgressFunctions.set(Symbol(task.id as string), runAsync());\n }\n } catch (err) {\n error = err as Error;\n getLogger().error(\"Error running graph\", { error });\n }\n // Wait for all tasks to complete since we did not await runAsync()/this.runTaskWithProvenance()\n await Promise.allSettled(Array.from(this.inProgressTasks.values()));\n // Clean up stragglers to avoid unhandled promise rejections\n await Promise.allSettled(Array.from(this.inProgressFunctions.values()));\n\n if (this.failedTaskErrors.size > 0) {\n const latestError = this.failedTaskErrors.values().next().value!;\n this.handleError(latestError);\n throw latestError;\n }\n if (this.abortController?.signal.aborted) {\n await this.handleAbort();\n throw new TaskAbortedError();\n }\n\n await this.handleComplete();\n\n return results;\n }\n\n /**\n * Runs the task graph in a reactive manner\n * @param input Optional input to pass to root tasks (tasks with no incoming dataflows)\n * @param config Optional configuration for the reactive run. Supports overriding the\n * ServiceRegistry (`registry`), providing an output cache (`outputCache`), passing an\n * abort signal (`parentSignal`), and controlling whether streaming leaf task outputs are\n * accumulated into the return value (`accumulateLeafOutputs`).\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskConfigurationError if the graph is already running reactively\n */\n public async runGraphReactive<Output extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config?: TaskGraphRunReactiveConfig\n ): Promise<GraphResultArray<Output>> {\n await this.handleStartReactive(config);\n\n const results: GraphResultArray<Output> = [];\n try {\n for await (const task of this.reactiveScheduler.tasks()) {\n const isRootTask = this.graph.getSourceDataflows(task.id).length === 0;\n\n if (task.status === TaskStatus.PENDING) {\n task.resetInputData();\n this.copyInputFromEdgesToNode(task);\n // TODO: cacheable here??\n // if (task.cacheable) {\n // const results = await this.outputCache?.getOutput(\n // (task.constructor as any).type,\n // task.runInputData\n // );\n // if (results) {\n // task.runOutputData = results;\n // }\n // }\n }\n\n // For root tasks (no incoming dataflows), apply the input parameter\n // This is important for GraphAsTask subgraphs where the InputTask needs\n // to receive the parent's input values\n const taskInput = isRootTask ? input : {};\n\n const taskResult = await task.runReactive(taskInput);\n\n await this.pushOutputFromNodeToEdges(task, taskResult);\n if (this.graph.getTargetDataflows(task.id).length === 0) {\n results.push({\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: taskResult as Output,\n });\n }\n }\n await this.handleCompleteReactive();\n return results;\n } catch (error) {\n await this.handleErrorReactive();\n throw error;\n }\n }\n\n /**\n * Aborts the task graph execution\n */\n public abort(): void {\n this.abortController?.abort();\n }\n\n /**\n * Disables the task graph execution\n */\n public async disable(): Promise<void> {\n await this.handleDisable();\n }\n\n /**\n * Filters graph-level input to only include properties that are not connected via dataflows for a given task\n * @param task The task to filter input for\n * @param input The graph-level input\n * @returns Filtered input containing only unconnected properties\n */\n protected filterInputForTask(task: ITask, input: TaskInput): TaskInput {\n // Get all inputs that are connected to this task via dataflows\n const sourceDataflows = this.graph.getSourceDataflows(task.id);\n const connectedInputs = new Set(sourceDataflows.map((df) => df.targetTaskPortId));\n\n // If DATAFLOW_ALL_PORTS (\"*\") is in the set, all inputs are connected\n const allPortsConnected = connectedInputs.has(DATAFLOW_ALL_PORTS);\n\n // Filter out connected inputs from the graph input\n const filteredInput: TaskInput = {};\n for (const [key, value] of Object.entries(input)) {\n // Skip this input if it's explicitly connected OR if all ports are connected\n if (!connectedInputs.has(key) && !allPortsConnected) {\n filteredInput[key] = value;\n }\n }\n\n return filteredInput;\n }\n\n /**\n * Adds input data to a task.\n * Delegates to {@link Task.addInput} for the actual merging logic.\n *\n * @param task The task to add input data to\n * @param overrides The input data to override (or add to if an array)\n */\n public addInputData(task: ITask, overrides: Partial<TaskInput> | undefined): void {\n if (!overrides) return;\n\n const changed = task.addInput(overrides);\n\n // TODO(str): This is a hack.\n if (changed && \"regenerateGraph\" in task && typeof task.regenerateGraph === \"function\") {\n task.regenerateGraph();\n }\n }\n\n // ========================================================================\n // Protected Handlers\n // ========================================================================\n public mergeExecuteOutputsToRunOutput<\n ExecuteOutput extends TaskOutput,\n Merge extends CompoundMergeStrategy = CompoundMergeStrategy,\n >(\n results: GraphResultArray<ExecuteOutput>,\n compoundMerge: Merge\n ): GraphResult<ExecuteOutput, Merge> {\n if (compoundMerge === GRAPH_RESULT_ARRAY) {\n return results as GraphResult<ExecuteOutput, Merge>;\n }\n\n if (compoundMerge === PROPERTY_ARRAY) {\n let fixedOutput = {} as PropertyArrayGraphResult<ExecuteOutput>;\n const outputs = results.map((result: any) => result.data);\n if (outputs.length === 1) {\n fixedOutput = outputs[0];\n } else if (outputs.length > 1) {\n const collected = collectPropertyValues<ExecuteOutput>(outputs as ExecuteOutput[]);\n if (Object.keys(collected).length > 0) {\n fixedOutput = collected;\n }\n }\n return fixedOutput as GraphResult<ExecuteOutput, Merge>;\n }\n throw new TaskConfigurationError(`Unknown compound merge strategy: ${compoundMerge}`);\n }\n\n /**\n * Copies input data from edges to a task\n * @param task The task to copy input data to\n */\n protected copyInputFromEdgesToNode(task: ITask) {\n const dataflows = this.graph.getSourceDataflows(task.id);\n for (const dataflow of dataflows) {\n this.addInputData(task, dataflow.getPortData());\n }\n }\n\n /**\n * Pushes the output of a task to its target tasks\n * @param node The task that produced the output\n * @param results The output of the task\n */\n protected async pushOutputFromNodeToEdges(node: ITask, results: TaskOutput) {\n const dataflows = this.graph.getTargetDataflows(node.id);\n for (const dataflow of dataflows) {\n const compatibility = dataflow.semanticallyCompatible(this.graph, dataflow);\n getLogger().debug(\"pushOutputFromNodeToEdges\", {\n dataflowId: dataflow.id,\n compatibility,\n resultsKeys: Object.keys(results),\n });\n if (compatibility === \"static\") {\n dataflow.setPortData(results);\n } else if (compatibility === \"runtime\") {\n const task = this.graph.getTask(dataflow.targetTaskId)!;\n const narrowed = await task.narrowInput({ ...results }, this.registry);\n dataflow.setPortData(narrowed);\n } else {\n // Warn only when we had data to push; empty results (e.g. progress mid-run) are expected\n const resultsKeys = Object.keys(results);\n if (resultsKeys.length > 0) {\n getLogger().warn(\"pushOutputFromNodeToEdge not compatible, not setting port data\", {\n dataflowId: dataflow.id,\n compatibility,\n resultsKeys,\n });\n }\n }\n }\n }\n\n /**\n * Pushes the status of a task to its target edges\n * @param node The task that produced the status\n *\n * For ConditionalTask, this method handles selective dataflow status:\n * - Active branch dataflows get COMPLETED status\n * - Inactive branch dataflows get DISABLED status\n */\n protected pushStatusFromNodeToEdges(graph: TaskGraph, node: ITask, status?: TaskStatus): void {\n if (!node?.config?.id) return;\n\n const dataflows = graph.getTargetDataflows(node.id);\n const effectiveStatus = status ?? node.status;\n\n // Check if this is a ConditionalTask with selective branching\n if (node instanceof ConditionalTask && effectiveStatus === TaskStatus.COMPLETED) {\n // Build a map of output port -> branch ID for lookup\n const branches = node.config.branches ?? [];\n const portToBranch = new Map<string, string>();\n for (const branch of branches) {\n portToBranch.set(branch.outputPort, branch.id);\n }\n\n const activeBranches = node.getActiveBranches();\n\n for (const dataflow of dataflows) {\n const branchId = portToBranch.get(dataflow.sourceTaskPortId);\n if (branchId !== undefined) {\n // This dataflow is from a branch port\n if (activeBranches.has(branchId)) {\n // Branch is active - dataflow gets completed status\n dataflow.setStatus(TaskStatus.COMPLETED);\n } else {\n // Branch is inactive - dataflow gets disabled status\n dataflow.setStatus(TaskStatus.DISABLED);\n }\n } else {\n // Not a branch port (e.g., _activeBranches metadata) - use normal status\n dataflow.setStatus(effectiveStatus);\n }\n }\n\n // Cascade disabled status to downstream tasks\n this.propagateDisabledStatus(graph);\n return;\n }\n\n // Default behavior for non-conditional tasks\n dataflows.forEach((dataflow) => {\n dataflow.setStatus(effectiveStatus);\n });\n }\n\n /**\n * Pushes the error of a task to its target edges\n * @param node The task that produced the error\n */\n protected pushErrorFromNodeToEdges(graph: TaskGraph, node: ITask): void {\n if (!node?.config?.id) return;\n graph.getTargetDataflows(node.id).forEach((dataflow) => {\n dataflow.error = node.error;\n });\n }\n\n /**\n * Returns true if the task has any outgoing dataflow edges that use the\n * error output port (`[error]`). These edges indicate that the task's\n * errors should be routed to downstream handler tasks instead of failing\n * the entire graph.\n */\n protected hasErrorOutputEdges(task: ITask): boolean {\n const dataflows = this.graph.getTargetDataflows(task.id);\n return dataflows.some((df) => df.sourceTaskPortId === DATAFLOW_ERROR_PORT);\n }\n\n /**\n * Routes a failed task's error through its error-port dataflow edges.\n *\n * For each outgoing dataflow:\n * - Error-port edges (`[error]`) receive the error data and get COMPLETED status\n * - Non-error-port edges get DISABLED status (the task didn't produce normal output)\n *\n * After setting edge statuses, propagateDisabledStatus() cascades DISABLED\n * through any downstream tasks that only had non-error inputs from this task.\n */\n protected pushErrorOutputToEdges(task: ITask): void {\n const taskError = task.error;\n const errorData = {\n error: taskError?.message ?? \"Unknown error\",\n errorType: (taskError?.constructor as { type?: string })?.type ?? \"TaskError\",\n };\n\n const dataflows = this.graph.getTargetDataflows(task.id);\n for (const df of dataflows) {\n if (df.sourceTaskPortId === DATAFLOW_ERROR_PORT) {\n // Route error data to the error-port edge\n df.value = errorData;\n df.setStatus(TaskStatus.COMPLETED);\n } else {\n // Normal output edges are disabled — this task didn't produce output\n df.setStatus(TaskStatus.DISABLED);\n }\n }\n\n // Cascade disabled status to downstream tasks whose ALL inputs are now disabled\n this.propagateDisabledStatus(this.graph);\n }\n\n /**\n * Propagates DISABLED status through the graph.\n *\n * When a task's ALL incoming dataflows are DISABLED, that task becomes unreachable\n * and should also be disabled. This cascades through the graph until no more\n * tasks can be disabled.\n *\n * This is used by ConditionalTask to disable downstream tasks on inactive branches.\n *\n * @param graph The task graph to propagate disabled status through\n */\n protected propagateDisabledStatus(graph: TaskGraph): void {\n let changed = true;\n\n // Keep iterating until no more changes (fixed-point iteration)\n while (changed) {\n changed = false;\n\n for (const task of graph.getTasks()) {\n // Only consider tasks that are still pending\n if (task.status !== TaskStatus.PENDING) {\n continue;\n }\n\n const incomingDataflows = graph.getSourceDataflows(task.id);\n\n // Skip tasks with no incoming dataflows (root tasks)\n if (incomingDataflows.length === 0) {\n continue;\n }\n\n // Check if ALL incoming dataflows are DISABLED\n const allDisabled = incomingDataflows.every((df) => df.status === TaskStatus.DISABLED);\n\n if (allDisabled) {\n // This task is unreachable - disable it synchronously\n // Set status directly to avoid async issues\n task.status = TaskStatus.DISABLED;\n task.progress = 100;\n task.completedAt = new Date();\n task.emit(\"disabled\");\n task.emit(\"status\", task.status);\n\n // Propagate disabled status to its outgoing dataflows\n graph.getTargetDataflows(task.id).forEach((dataflow) => {\n dataflow.setStatus(TaskStatus.DISABLED);\n });\n\n // Mark as completed in scheduler so it doesn't wait for this task\n this.processScheduler.onTaskCompleted(task.id);\n\n changed = true;\n }\n }\n }\n }\n\n /**\n * Determines whether a streaming task needs to accumulate its text-delta\n * chunks into an enriched finish event. Accumulation is needed when:\n *\n * 1. Output caching is active (the cached value must be fully materialised).\n * 2. Any outgoing dataflow edge connects a streaming output port to an input\n * port that is not streaming with the same mode (i.e. the downstream task\n * cannot consume a raw stream and needs a completed value).\n *\n * When accumulation is required the source task runs with shouldAccumulate=true,\n * emitting an enriched finish event that carries all accumulated port text.\n * All downstream dataflow edges share that event via tee'd streams so no\n * edge needs to re-accumulate independently.\n */\n protected taskNeedsAccumulation(task: ITask): boolean {\n if (this.outputCache) return true;\n\n const outEdges = this.graph.getTargetDataflows(task.id);\n if (outEdges.length === 0) return this.accumulateLeafOutputs;\n\n const outSchema = task.outputSchema();\n\n for (const df of outEdges) {\n if (df.sourceTaskPortId === DATAFLOW_ALL_PORTS) {\n // Conservative: if any streaming output port exists, accumulate.\n // This covers the case where all-ports edges fan into non-streaming tasks.\n if (getStreamingPorts(outSchema).length > 0) return true;\n continue;\n }\n\n const targetTask = this.graph.getTask(df.targetTaskId);\n if (!targetTask) continue;\n const inSchema = targetTask.inputSchema();\n\n if (edgeNeedsAccumulation(outSchema, df.sourceTaskPortId, inSchema, df.targetTaskPortId)) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Runs a task\n * @param task The task to run\n * @param input The input for the task\n * @returns The output of the task\n */\n protected async runTask<T>(task: ITask, input: TaskInput): Promise<GraphSingleTaskResult<T>> {\n const isStreamable = isTaskStreamable(task);\n\n // For pass-through streaming tasks: if the task is streamable and has\n // streaming input edges, tee each stream so one copy is forwarded to\n // the task's executeStream() (via inputStreams) while the other stays\n // on the edge for materialization by awaitStreamInputs.\n if (isStreamable) {\n const dataflows = this.graph.getSourceDataflows(task.id);\n const streamingEdges = dataflows.filter((df) => df.stream !== undefined);\n if (streamingEdges.length > 0) {\n const inputStreams = new Map<string, ReadableStream<StreamEvent>>();\n for (const df of streamingEdges) {\n const stream = df.stream!;\n const [forwardCopy, materializeCopy] = stream.tee();\n inputStreams.set(df.targetTaskPortId, forwardCopy);\n df.setStream(materializeCopy);\n }\n task.runner.inputStreams = inputStreams;\n }\n }\n\n // Await any active streams on input dataflow edges so their values\n // are materialized before we read them. This applies to ALL downstream\n // tasks (both streaming and non-streaming) because copyInputFromEdgesToNode\n // reads via getPortData() which requires materialized values.\n // Streaming downstream tasks are still unblocked early by the scheduler\n // (they can start setup while upstream is streaming), but their actual\n // input data waits for upstream completion.\n await this.awaitStreamInputs(task);\n\n this.copyInputFromEdgesToNode(task);\n\n if (isStreamable) {\n return this.runStreamingTask<T>(task, input);\n }\n\n const results = await task.runner.run(input, {\n // Pass `false` when no cache so TaskRunner.handleStart explicitly clears\n // its own cached reference (undefined would leave the old value intact).\n outputCache: this.outputCache ?? false,\n updateProgress: async (task: ITask, progress: number, message?: string, ...args: any[]) =>\n await this.handleProgress(task, progress, message, ...args),\n registry: this.registry,\n });\n\n await this.pushOutputFromNodeToEdges(task, results);\n\n return {\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: results as T,\n };\n }\n\n /**\n * For non-streaming downstream tasks, awaits completion of any active\n * streams on input dataflow edges, materializing their values.\n *\n * Streaming upstream tasks set a ReadableStream on outgoing edges.\n * Non-streaming downstream tasks cannot consume streams directly, so\n * this method reads each stream to completion and accumulates the\n * value (via Dataflow.awaitStreamValue) before the task reads its\n * inputs through the normal getPortData() path.\n */\n protected async awaitStreamInputs(task: ITask): Promise<void> {\n const dataflows = this.graph.getSourceDataflows(task.id);\n const streamPromises = dataflows\n .filter((df) => df.stream !== undefined)\n .map((df) => df.awaitStreamValue());\n if (streamPromises.length > 0) {\n await Promise.all(streamPromises);\n }\n }\n\n /**\n * Runs a streaming task within the DAG.\n * Listens for stream events to:\n * - Notify the scheduler when streaming begins (unblocking downstream streamable tasks)\n * - Push stream data to outgoing dataflow edges\n * - Have the source task accumulate and emit enriched finish events for\n * non-streaming downstream tasks (when taskNeedsAccumulation() is true)\n */\n protected async runStreamingTask<T>(\n task: ITask,\n input: TaskInput\n ): Promise<GraphSingleTaskResult<T>> {\n const streamMode = getOutputStreamMode(task.outputSchema());\n const shouldAccumulate = this.taskNeedsAccumulation(task);\n\n let streamingNotified = false;\n\n const onStatus = (status: TaskStatus) => {\n if (status === TaskStatus.STREAMING && !streamingNotified) {\n streamingNotified = true;\n this.pushStatusFromNodeToEdges(this.graph, task, TaskStatus.STREAMING);\n this.pushStreamToEdges(task, streamMode);\n this.processScheduler.onTaskStreaming(task.id);\n }\n };\n\n const onStreamStart = () => {\n this.graph.emit(\"task_stream_start\", task.id);\n };\n\n const onStreamChunk = (event: StreamEvent) => {\n this.graph.emit(\"task_stream_chunk\", task.id, event);\n };\n\n const onStreamEnd = (output: Record<string, any>) => {\n this.graph.emit(\"task_stream_end\", task.id, output);\n };\n\n task.on(\"status\", onStatus);\n task.on(\"stream_start\", onStreamStart);\n task.on(\"stream_chunk\", onStreamChunk);\n task.on(\"stream_end\", onStreamEnd);\n\n try {\n const results = await task.runner.run(input, {\n outputCache: this.outputCache ?? false,\n shouldAccumulate,\n updateProgress: async (task: ITask, progress: number, message?: string, ...args: any[]) =>\n await this.handleProgress(task, progress, message, ...args),\n registry: this.registry,\n });\n\n await this.pushOutputFromNodeToEdges(task, results);\n\n return {\n id: task.id,\n type: (task.constructor as any).runtype || (task.constructor as any).type,\n data: results as T,\n };\n } finally {\n task.off(\"status\", onStatus);\n task.off(\"stream_start\", onStreamStart);\n task.off(\"stream_chunk\", onStreamChunk);\n task.off(\"stream_end\", onStreamEnd);\n }\n }\n\n /**\n * Returns true if an event carries a port-specific delta (text-delta or object-delta).\n */\n private static isPortDelta(event: StreamEvent): event is StreamEvent & { port: string } {\n return event.type === \"text-delta\" || event.type === \"object-delta\";\n }\n\n /**\n * Creates a ReadableStream from task streaming events, optionally filtered\n * to a single port. When `portId` is undefined (DATAFLOW_ALL_PORTS), all\n * events pass through. When set, only delta events matching the port plus\n * control events (finish, error, snapshot) are enqueued.\n */\n private createStreamFromTaskEvents(task: ITask, portId?: string): ReadableStream<StreamEvent> {\n return new ReadableStream<StreamEvent>({\n start: (controller) => {\n const onChunk = (event: StreamEvent) => {\n try {\n if (\n portId !== undefined &&\n TaskGraphRunner.isPortDelta(event) &&\n event.port !== portId\n ) {\n return;\n }\n controller.enqueue(event);\n } catch {\n // Stream may be closed\n }\n };\n const onEnd = () => {\n try {\n controller.close();\n } catch {\n // Stream may already be closed\n }\n task.off(\"stream_chunk\", onChunk);\n task.off(\"stream_end\", onEnd);\n };\n task.on(\"stream_chunk\", onChunk);\n task.on(\"stream_end\", onEnd);\n },\n });\n }\n\n /**\n * Pushes stream events from a streaming task to its outgoing dataflow edges.\n * Creates per-port filtered ReadableStreams for specific-port edges and\n * unfiltered streams for DATAFLOW_ALL_PORTS edges. Within each port group,\n * uses tee() for fan-out to multiple consumers.\n */\n protected pushStreamToEdges(task: ITask, streamMode: string): void {\n const targetDataflows = this.graph.getTargetDataflows(task.id);\n if (targetDataflows.length === 0) return;\n\n // Group edges by their source port\n const groups = new Map<string, typeof targetDataflows>();\n for (const df of targetDataflows) {\n const key = df.sourceTaskPortId;\n let group = groups.get(key);\n if (!group) {\n group = [];\n groups.set(key, group);\n }\n group.push(df);\n }\n\n for (const [portKey, edges] of groups) {\n const filterPort = portKey === DATAFLOW_ALL_PORTS ? undefined : portKey;\n const stream = this.createStreamFromTaskEvents(task, filterPort);\n\n if (edges.length === 1) {\n edges[0].setStream(stream);\n } else {\n let currentStream = stream;\n for (let i = 0; i < edges.length; i++) {\n if (i === edges.length - 1) {\n edges[i].setStream(currentStream);\n } else {\n const [s1, s2] = currentStream.tee();\n edges[i].setStream(s1);\n currentStream = s2;\n }\n }\n }\n }\n }\n\n /**\n * Resets a task\n * @param graph The task graph to reset\n * @param task The task to reset\n * @param runId The run ID\n */\n protected resetTask(graph: TaskGraph, task: ITask, runId: string) {\n task.status = TaskStatus.PENDING;\n task.resetInputData();\n task.runOutputData = {};\n task.error = undefined;\n task.progress = 0;\n task.runConfig = { ...task.runConfig, runnerId: runId };\n this.pushStatusFromNodeToEdges(graph, task);\n this.pushErrorFromNodeToEdges(graph, task);\n task.emit(\"reset\");\n task.emit(\"status\", task.status);\n }\n\n /**\n * Resets the task graph, recursively\n * @param graph The task graph to reset\n */\n public resetGraph(graph: TaskGraph, runnerId: string) {\n graph.getTasks().forEach((node) => {\n this.resetTask(graph, node, runnerId);\n node.regenerateGraph();\n if (node.hasChildren()) {\n this.resetGraph(node.subGraph, runnerId);\n }\n });\n graph.getDataflows().forEach((dataflow) => {\n dataflow.reset();\n });\n }\n\n /**\n * Handles the start of task graph execution\n * @param parentSignal Optional abort signal from parent\n */\n protected async handleStart(config?: TaskGraphRunConfig): Promise<void> {\n // Setup registry - create child from global if not provided\n if (config?.registry !== undefined) {\n this.registry = config.registry;\n } else if (this.registry === undefined) {\n // Create a child container that inherits from global but allows overrides\n this.registry = new ServiceRegistry(globalServiceRegistry.container.createChildContainer());\n }\n\n this.accumulateLeafOutputs = config?.accumulateLeafOutputs !== false;\n\n if (config?.outputCache !== undefined) {\n if (typeof config.outputCache === \"boolean\") {\n if (config.outputCache === true) {\n this.outputCache = this.registry.get(TASK_OUTPUT_REPOSITORY);\n } else {\n this.outputCache = undefined;\n }\n } else {\n this.outputCache = config.outputCache;\n }\n this.graph.outputCache = this.outputCache;\n }\n // Prevent reentrancy\n if (this.running || this.reactiveRunning) {\n throw new TaskConfigurationError(\"Graph is already running\");\n }\n\n this.running = true;\n this.abortController = new AbortController();\n this.abortController.signal.addEventListener(\"abort\", () => {\n this.handleAbort();\n });\n\n if (config?.parentSignal?.aborted) {\n this.abortController.abort(); // Immediately abort if the parent is already aborted\n return;\n } else {\n config?.parentSignal?.addEventListener(\n \"abort\",\n () => {\n this.abortController?.abort();\n },\n { once: true }\n );\n }\n\n this.runId = uuid4();\n this.resetGraph(this.graph, this.runId);\n this.processScheduler.reset();\n this.inProgressTasks.clear();\n this.inProgressFunctions.clear();\n this.failedTaskErrors.clear();\n\n // Start telemetry span for the graph run\n const telemetry = getTelemetryProvider();\n if (telemetry.isEnabled) {\n this.telemetrySpan = telemetry.startSpan(\"workglow.graph.run\", {\n attributes: {\n \"workglow.graph.run_id\": this.runId,\n \"workglow.graph.task_count\": this.graph.getTasks().length,\n \"workglow.graph.dataflow_count\": this.graph.getDataflows().length,\n },\n });\n }\n\n this.graph.emit(\"start\");\n }\n\n protected async handleStartReactive(config?: TaskGraphRunConfig): Promise<void> {\n if (this.reactiveRunning) {\n throw new TaskConfigurationError(\"Graph is already running reactively\");\n }\n\n // Use explicit registry if provided; otherwise keep the existing one\n // (which is either globalServiceRegistry by default, or whatever handleStart set).\n if (config?.registry !== undefined) {\n this.registry = config.registry;\n }\n\n this.reactiveScheduler.reset();\n this.reactiveRunning = true;\n }\n\n /**\n * Handles the completion of task graph execution\n */\n protected async handleComplete(): Promise<void> {\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.OK);\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"complete\");\n }\n\n protected async handleCompleteReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles errors during task graph execution\n */\n protected async handleError(error: TaskError): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {\n return task.abort();\n }\n })\n );\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, error.message);\n this.telemetrySpan.setAttributes({ \"workglow.graph.error\": error.message });\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"error\", error);\n }\n\n protected async handleErrorReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task graph abortion\n */\n protected async handleAbort(): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {\n return task.abort();\n }\n })\n );\n this.running = false;\n\n if (this.telemetrySpan) {\n this.telemetrySpan.setStatus(SpanStatusCode.ERROR, \"aborted\");\n this.telemetrySpan.addEvent(\"workglow.graph.aborted\");\n this.telemetrySpan.end();\n this.telemetrySpan = undefined;\n }\n\n this.graph.emit(\"abort\");\n }\n\n protected async handleAbortReactive(): Promise<void> {\n this.reactiveRunning = false;\n }\n\n /**\n * Handles task graph disabling\n */\n protected async handleDisable(): Promise<void> {\n await Promise.allSettled(\n this.graph.getTasks().map(async (task: ITask) => {\n if (task.status === TaskStatus.PENDING) {\n return task.disable();\n }\n })\n );\n this.running = false;\n this.graph.emit(\"disabled\");\n }\n\n /**\n * Handles progress updates for the task graph by averaging `progress` across tasks whose class\n * declares its own `execute` ({@link taskPrototypeHasOwnExecute}). Other nodes are ignored.\n * @param progress Progress value (0-100)\n * @param message Optional message\n * @param args Additional arguments\n */\n protected async handleProgress(\n task: ITask,\n progress: number,\n message?: string,\n ...args: any[]\n ): Promise<void> {\n const contributors = this.graph.getTasks().filter(taskPrototypeHasOwnExecute);\n if (contributors.length > 1) {\n const sum = contributors.reduce((acc, t) => acc + t.progress, 0);\n progress = Math.round(sum / contributors.length);\n } else if (contributors.length === 1) {\n const [only] = contributors;\n progress = only.progress;\n }\n this.pushStatusFromNodeToEdges(this.graph, task);\n // Emit aggregate progress before awaiting output push so UIs (and task `emit(\"progress\")` in\n // TaskRunner) are not blocked when pushOutput/narrowInput is slow or stalls mid-run.\n this.graph.emit(\"graph_progress\", progress, message, args);\n // Only push output when the task has produced data; progress can fire mid-run with empty runOutputData\n if (task.runOutputData && Object.keys(task.runOutputData).length > 0) {\n await this.pushOutputFromNodeToEdges(task, task.runOutputData);\n }\n }\n}\n",
18
20
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { GraphResultArray } from \"../task-graph/TaskGraphRunner\";\nimport { GraphAsTask } from \"./GraphAsTask\";\nimport { TaskRunner } from \"./TaskRunner\";\nimport { TaskConfig, TaskInput, TaskOutput } from \"./TaskTypes\";\n\nexport class GraphAsTaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends TaskConfig = TaskConfig,\n> extends TaskRunner<Input, Output, Config> {\n declare task: GraphAsTask<Input, Output, Config>;\n\n /**\n * Protected method to execute a task subgraph by delegating back to the task itself.\n */\n protected async executeTaskChildren(input: Input): Promise<GraphResultArray<Output>> {\n const unsubscribe = this.task.subGraph!.subscribe(\n \"graph_progress\",\n (progress: number, message?: string, ...args: any[]) => {\n this.task.emit(\"progress\", progress, message, ...args);\n }\n );\n const results = await this.task.subGraph!.run<Output>(input, {\n parentSignal: this.abortController?.signal,\n outputCache: this.outputCache,\n registry: this.registry,\n });\n unsubscribe();\n return results;\n }\n /**\n * Protected method for reactive execution delegation\n *\n * For GraphAsTask, we pass the parent's runInputData to the subgraph's runReactive.\n * This ensures that root tasks in the subgraph (like InputTask) receive the\n * parent's input values after resetInputData() is called.\n */\n protected async executeTaskChildrenReactive(): Promise<GraphResultArray<Output>> {\n return this.task.subGraph!.runReactive<Output>(this.task.runInputData, {\n registry: this.registry,\n });\n }\n\n protected async handleDisable(): Promise<void> {\n if (this.task.hasChildren()) {\n await this.task.subGraph!.disable();\n }\n super.handleDisable();\n }\n\n // ========================================================================\n // TaskRunner method overrides and helpers\n // ========================================================================\n\n /**\n * Execute the task\n */\n protected async executeTask(input: Input): Promise<Output | undefined> {\n if (this.task.hasChildren()) {\n const runExecuteOutputData = await this.executeTaskChildren(input);\n this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(\n runExecuteOutputData,\n this.task.compoundMerge\n );\n } else {\n const result = await super.executeTask(input);\n this.task.runOutputData = result ?? ({} as Output);\n }\n return this.task.runOutputData as Output;\n }\n\n /**\n * Execute the task reactively\n */\n public async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n if (this.task.hasChildren()) {\n const reactiveResults = await this.executeTaskChildrenReactive();\n this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(\n reactiveResults,\n this.task.compoundMerge\n );\n } else {\n const reactiveResults = await super.executeTaskReactive(input, output);\n this.task.runOutputData = Object.assign({}, output, reactiveResults ?? {}) as Output;\n }\n return this.task.runOutputData as Output;\n }\n}\n",
19
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { compileSchema, type DataPortSchema, type SchemaNode } from \"@workglow/util/schema\";\nimport { computeGraphInputSchema, computeGraphOutputSchema } from \"../task-graph/GraphSchemaUtils\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { CompoundMergeStrategy, PROPERTY_ARRAY } from \"../task-graph/TaskGraphRunner\";\nimport type { CreateLoopWorkflow } from \"../task-graph/Workflow\";\nimport { GraphAsTaskRunner } from \"./GraphAsTaskRunner\";\nimport type { IExecuteContext } from \"./ITask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { Task } from \"./Task\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport {\n TaskConfigSchema,\n type TaskConfig,\n type TaskInput,\n type TaskOutput,\n type TaskTypeName,\n} from \"./TaskTypes\";\n\nexport const graphAsTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...TaskConfigSchema[\"properties\"],\n compoundMerge: { type: \"string\", \"x-ui-hidden\": true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\nexport type GraphAsTaskConfig = TaskConfig & {\n /** subGraph is extracted in the constructor before validation — not in the JSON schema */\n subGraph?: TaskGraph;\n compoundMerge?: CompoundMergeStrategy;\n};\n\n/**\n * A task that contains a subgraph of tasks\n */\nexport class GraphAsTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends GraphAsTaskConfig = GraphAsTaskConfig,\n> extends Task<Input, Output, Config> {\n // ========================================================================\n // Static properties - should be overridden by subclasses\n // ========================================================================\n\n public static type: TaskTypeName = \"GraphAsTask\";\n public static title: string = \"Group\";\n public static description: string = \"A group of tasks that are executed together\";\n public static category: string = \"Flow Control\";\n public static compoundMerge: CompoundMergeStrategy = PROPERTY_ARRAY;\n\n /** This task has dynamic schemas that change based on the subgraph structure */\n public static hasDynamicSchemas: boolean = true;\n\n // ========================================================================\n // Constructor\n // ========================================================================\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n const { subGraph, ...rest } = config;\n super(input, rest as Config);\n if (subGraph) {\n this.subGraph = subGraph;\n }\n this.regenerateGraph();\n }\n\n // ========================================================================\n // TaskRunner delegation - Executes and manages the task\n // ========================================================================\n\n declare _runner: GraphAsTaskRunner<Input, Output, Config>;\n\n /**\n * Task runner for handling the task execution\n */\n override get runner(): GraphAsTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new GraphAsTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Static to Instance conversion methods\n // ========================================================================\n\n public static configSchema(): DataPortSchema {\n return graphAsTaskConfigSchema;\n }\n\n public get compoundMerge(): CompoundMergeStrategy {\n return this.config?.compoundMerge || (this.constructor as typeof GraphAsTask).compoundMerge;\n }\n\n public get cacheable(): boolean {\n return (\n this.runConfig?.cacheable ??\n this.config?.cacheable ??\n ((this.constructor as typeof GraphAsTask).cacheable && !this.hasChildren())\n );\n }\n\n // ========================================================================\n // Input/Output handling\n // ========================================================================\n\n /**\n * Override inputSchema to compute it dynamically from the subgraph at runtime.\n * For root tasks (no incoming edges) all input properties are collected.\n * For non-root tasks, only REQUIRED properties that are not satisfied by\n * any internal dataflow are added — this ensures that required inputs are\n * included in the graph's input schema without pulling in every optional\n * downstream property.\n */\n public inputSchema(): DataPortSchema {\n // If there's no subgraph or it has no children, fall back to the static schema\n if (!this.hasChildren()) {\n return (this.constructor as typeof Task).inputSchema();\n }\n\n return computeGraphInputSchema(this.subGraph);\n }\n\n protected _inputSchemaNode: SchemaNode | undefined;\n /**\n * Gets the compiled input schema\n */\n protected override getInputSchemaNode(): SchemaNode {\n // every graph as task is different, so we need to compile the schema for each one\n if (!this._inputSchemaNode) {\n try {\n const dataPortSchema = this.inputSchema();\n const schemaNode = Task.generateInputSchemaNode(dataPortSchema);\n this._inputSchemaNode = schemaNode;\n } catch (error) {\n // If compilation fails, fall back to accepting any object structure\n // This is a safety net for schemas that json-schema-library can't compile\n console.warn(\n `Failed to compile input schema for ${this.type}, falling back to permissive validation:`,\n error\n );\n this._inputSchemaNode = compileSchema({});\n }\n }\n return this._inputSchemaNode!;\n }\n\n /**\n\n * Override outputSchema to compute it dynamically from the subgraph at runtime\n * The output schema depends on the compoundMerge strategy and the nodes at the last level\n */\n\n public override outputSchema(): DataPortSchema {\n // If there's no subgraph or it has no children, fall back to the static schema\n if (!this.hasChildren()) {\n return (this.constructor as typeof Task).outputSchema();\n }\n\n return computeGraphOutputSchema(this.subGraph);\n }\n\n /**\n * Resets input data to defaults\n */\n public resetInputData(): void {\n super.resetInputData();\n if (this.hasChildren()) {\n this.subGraph!.getTasks().forEach((node) => {\n node.resetInputData();\n });\n this.subGraph!.getDataflows().forEach((dataflow) => {\n dataflow.reset();\n });\n }\n }\n\n // ========================================================================\n // Streaming pass-through\n // ========================================================================\n\n /**\n * Stream pass-through for compound tasks: runs the subgraph and forwards\n * streaming events from ending nodes to the outer graph. Also re-yields\n * any input streams from upstream for cases where this GraphAsTask is\n * itself downstream of another streaming task.\n */\n async *executeStream(input: Input, context: IExecuteContext): AsyncIterable<StreamEvent<Output>> {\n // Forward upstream input streams first (pass-through from outer graph)\n if (context.inputStreams) {\n for (const [, stream] of context.inputStreams) {\n const reader = stream.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n if (value.type === \"finish\") continue;\n yield value as StreamEvent<Output>;\n }\n } finally {\n reader.releaseLock();\n }\n }\n }\n\n // Run the subgraph and forward streaming events from ending nodes\n if (this.hasChildren()) {\n const endingNodeIds = new Set<unknown>();\n const tasks = this.subGraph.getTasks();\n for (const task of tasks) {\n if (this.subGraph.getTargetDataflows(task.id).length === 0) {\n endingNodeIds.add(task.id);\n }\n }\n\n const eventQueue: StreamEvent<Output>[] = [];\n let resolveWaiting: (() => void) | undefined;\n let subgraphDone = false;\n\n const unsub = this.subGraph.subscribeToTaskStreaming({\n onStreamChunk: (taskId, event) => {\n if (endingNodeIds.has(taskId) && event.type !== \"finish\") {\n eventQueue.push(event as StreamEvent<Output>);\n resolveWaiting?.();\n }\n },\n });\n\n const runPromise = this.subGraph\n .run<Output>(input, { parentSignal: context.signal, accumulateLeafOutputs: false })\n .then((results) => {\n subgraphDone = true;\n resolveWaiting?.();\n return results;\n });\n\n // Yield events as they arrive from ending nodes\n while (!subgraphDone) {\n if (eventQueue.length === 0) {\n await new Promise<void>((resolve) => {\n resolveWaiting = resolve;\n });\n }\n while (eventQueue.length > 0) {\n yield eventQueue.shift()!;\n }\n }\n // Drain any remaining events\n while (eventQueue.length > 0) {\n yield eventQueue.shift()!;\n }\n\n unsub();\n\n const results = await runPromise;\n const mergedOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n yield { type: \"finish\", data: mergedOutput } as StreamFinish<Output>;\n } else {\n yield { type: \"finish\", data: input as unknown as Output } as StreamFinish<Output>;\n }\n }\n\n // ========================================================================\n // Compound task methods\n // ========================================================================\n\n /**\n * Regenerates the subtask graph and emits a \"regenerate\" event\n *\n * Subclasses should override this method to implement the actual graph\n * regeneration logic, but all they need to do is call this method to\n * emit the \"regenerate\" event.\n */\n public regenerateGraph(): void {\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n // ========================================================================\n // Serialization methods\n // ========================================================================\n\n /**\n * Serializes the task and its subtasks into a format that can be stored\n * @returns The serialized task and subtasks\n */\n public override toJSON(options?: TaskGraphJsonOptions): TaskGraphItemJson {\n let json = super.toJSON(options);\n const hasChildren = this.hasChildren();\n if (hasChildren) {\n json = {\n ...json,\n merge: this.compoundMerge,\n subgraph: this.subGraph!.toJSON(options),\n };\n }\n return json;\n }\n\n /**\n * Converts the task to a JSON format suitable for dependency tracking\n * @returns The task and subtasks in JSON thats easier for humans to read\n */\n public override toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem {\n const json = this.toJSON(options);\n if (this.hasChildren()) {\n if (\"subgraph\" in json) {\n delete json.subgraph;\n }\n return { ...json, subtasks: this.subGraph!.toDependencyJSON(options) };\n }\n return json;\n }\n}\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a group that wraps inner tasks in a GraphAsTask subgraph.\n * Use .endGroup() to close the group and return to the parent workflow.\n */\n group: CreateLoopWorkflow<TaskInput, TaskOutput, GraphAsTaskConfig>;\n\n /**\n * Ends the group and returns to the parent workflow.\n */\n endGroup(): Workflow;\n }\n}\n\n// Prototype assignments live in Workflow.ts (bottom of file) to avoid\n// circular-dependency issues at module evaluation time.\n",
20
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport type { GraphAsTask } from \"../task/GraphAsTask\";\nimport type { IExecuteContext, ITask } from \"../task/ITask\";\nimport { Task } from \"../task/Task\";\nimport type { DataPorts } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS } from \"./Dataflow\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport type { IWorkflow } from \"./IWorkflow\";\nimport { TaskGraph } from \"./TaskGraph\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type PipeFunction<I extends DataPorts = any, O extends DataPorts = any> = (\n input: I,\n context: IExecuteContext\n) => O | Promise<O>;\n\nexport type Taskish<A extends DataPorts = DataPorts, B extends DataPorts = DataPorts> =\n | PipeFunction<A, B>\n | ITask<A, B>\n | ITaskGraph\n | IWorkflow<A, B>;\n\n// ============================================================================\n// Wrapper classes (lazily initialized to avoid circular dependency with\n// GraphAsTask — which transitively imports Workflow which imports this file)\n// ============================================================================\n\ntype GraphAsTaskConstructor = typeof GraphAsTask;\n\nlet _OwnGraphTask: GraphAsTaskConstructor;\nlet _OwnWorkflowTask: GraphAsTaskConstructor;\nlet _GraphTask: GraphAsTaskConstructor;\nlet _ConvWorkflowTask: GraphAsTaskConstructor;\n\nfunction getWrapperClasses() {\n if (!_OwnGraphTask) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const GaT = (require(\"../task/GraphAsTask\") as { GraphAsTask: GraphAsTaskConstructor })\n .GraphAsTask;\n\n class ListeningGraphAsTask extends GaT<any, any> {\n constructor(input: any, config: any) {\n super(input, config);\n this.subGraph.on(\"start\", () => {\n this.emit(\"start\");\n });\n this.subGraph.on(\"complete\", () => {\n this.emit(\"complete\");\n });\n this.subGraph.on(\"error\", (e) => {\n this.emit(\"error\", e);\n });\n }\n }\n\n class OwnGraphTask extends ListeningGraphAsTask {\n public static readonly type = \"Own[Graph]\";\n }\n\n class OwnWorkflowTask extends ListeningGraphAsTask {\n public static readonly type = \"Own[Workflow]\";\n }\n\n class GraphTask extends GaT {\n public static readonly type = \"Graph\";\n }\n\n class ConvWorkflowTask extends GaT {\n public static readonly type = \"Workflow\";\n }\n\n _OwnGraphTask = OwnGraphTask as unknown as GraphAsTaskConstructor;\n _OwnWorkflowTask = OwnWorkflowTask as unknown as GraphAsTaskConstructor;\n _GraphTask = GraphTask as unknown as GraphAsTaskConstructor;\n _ConvWorkflowTask = ConvWorkflowTask as unknown as GraphAsTaskConstructor;\n }\n}\n\n// ============================================================================\n// ensureTask — converts Taskish values into ITask instances\n// ============================================================================\n\nfunction convertPipeFunctionToTask<I extends DataPorts, O extends DataPorts>(\n fn: PipeFunction<I, O>,\n config?: any\n): ITask<I, O> {\n class QuickTask extends Task<I, O> {\n public static type = fn.name ? `𝑓 ${fn.name}` : \"𝑓\";\n public static inputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n };\n public static outputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n };\n public static cacheable = false;\n public async execute(input: I, context: IExecuteContext) {\n return fn(input, context);\n }\n }\n return new QuickTask({}, config);\n}\n\n/**\n * Checks if a value implements the IWorkflow interface (has a `graph` property\n * that is a TaskGraph and a `run` method). Used instead of `instanceof Workflow`\n * to avoid a circular dependency with the Workflow module.\n */\nfunction isWorkflowLike(arg: unknown): arg is IWorkflow {\n return (\n arg != null &&\n typeof arg === \"object\" &&\n \"graph\" in arg &&\n arg.graph instanceof TaskGraph &&\n \"run\" in arg &&\n typeof arg.run === \"function\"\n );\n}\n\nexport function ensureTask<I extends DataPorts, O extends DataPorts>(\n arg: Taskish<I, O>,\n config: any = {}\n): ITask<any, any, any> {\n if (arg instanceof Task) {\n return arg;\n }\n if (arg instanceof TaskGraph) {\n getWrapperClasses();\n const { isOwned, ...cleanConfig } = config;\n if (isOwned) {\n return new _OwnGraphTask({}, { ...cleanConfig, subGraph: arg });\n } else {\n return new _GraphTask({}, { ...cleanConfig, subGraph: arg });\n }\n }\n if (isWorkflowLike(arg)) {\n getWrapperClasses();\n const { isOwned, ...cleanConfig } = config;\n if (isOwned) {\n return new _OwnWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });\n } else {\n return new _ConvWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });\n }\n }\n return convertPipeFunctionToTask(arg as PipeFunction<I, O>, config);\n}\n",
21
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { GraphAsTask } from \"../task/GraphAsTask\";\nimport type { IExecuteContext, ITask } from \"../task/ITask\";\nimport { Task } from \"../task/Task\";\nimport type { DataPorts } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS } from \"./Dataflow\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport type { IWorkflow } from \"./IWorkflow\";\nimport { TaskGraph } from \"./TaskGraph\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type PipeFunction<I extends DataPorts = any, O extends DataPorts = any> = (\n input: I,\n context: IExecuteContext\n) => O | Promise<O>;\n\nexport type Taskish<A extends DataPorts = DataPorts, B extends DataPorts = DataPorts> =\n | PipeFunction<A, B>\n | ITask<A, B>\n | ITaskGraph\n | IWorkflow<A, B>;\n\n// ============================================================================\n// Wrapper classes (lazily initialized so GraphAsTask is not needed until\n// ensureTask wraps a graph/workflow; GraphAsTask imports TaskGraph, which\n// imports this module — deferring construction avoids init-order issues)\n// ============================================================================\n\ntype GraphAsTaskConstructor = typeof GraphAsTask;\n\nlet _OwnGraphTask: GraphAsTaskConstructor;\nlet _OwnWorkflowTask: GraphAsTaskConstructor;\nlet _GraphTask: GraphAsTaskConstructor;\nlet _ConvWorkflowTask: GraphAsTaskConstructor;\n\nfunction getWrapperClasses() {\n if (!_OwnGraphTask) {\n class ListeningGraphAsTask extends GraphAsTask<any, any> {\n constructor(input: any, config: any) {\n super(input, config);\n this.subGraph.on(\"start\", () => {\n this.emit(\"start\");\n });\n this.subGraph.on(\"complete\", () => {\n this.emit(\"complete\");\n });\n this.subGraph.on(\"error\", (e) => {\n this.emit(\"error\", e);\n });\n }\n }\n\n class OwnGraphTask extends ListeningGraphAsTask {\n public static readonly type = \"Own[Graph]\";\n }\n\n class OwnWorkflowTask extends ListeningGraphAsTask {\n public static readonly type = \"Own[Workflow]\";\n }\n\n class GraphTask extends GraphAsTask {\n public static readonly type = \"Graph\";\n }\n\n class ConvWorkflowTask extends GraphAsTask {\n public static readonly type = \"Workflow\";\n }\n\n _OwnGraphTask = OwnGraphTask as unknown as GraphAsTaskConstructor;\n _OwnWorkflowTask = OwnWorkflowTask as unknown as GraphAsTaskConstructor;\n _GraphTask = GraphTask as unknown as GraphAsTaskConstructor;\n _ConvWorkflowTask = ConvWorkflowTask as unknown as GraphAsTaskConstructor;\n }\n}\n\n// ============================================================================\n// ensureTask — converts Taskish values into ITask instances\n// ============================================================================\n\nfunction convertPipeFunctionToTask<I extends DataPorts, O extends DataPorts>(\n fn: PipeFunction<I, O>,\n config?: any\n): ITask<I, O> {\n class QuickTask extends Task<I, O> {\n public static type = fn.name ? `𝑓 ${fn.name}` : \"𝑓\";\n public static inputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n };\n public static outputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: false,\n } as const satisfies DataPortSchema;\n };\n public static cacheable = false;\n public async execute(input: I, context: IExecuteContext) {\n return fn(input, context);\n }\n }\n return new QuickTask({}, config);\n}\n\n/**\n * Checks if a value implements the IWorkflow interface (has a `graph` property\n * that is a TaskGraph and a `run` method). Used instead of `instanceof Workflow`\n * to avoid a circular dependency with the Workflow module.\n */\nfunction isWorkflowLike(arg: unknown): arg is IWorkflow {\n return (\n arg != null &&\n typeof arg === \"object\" &&\n \"graph\" in arg &&\n arg.graph instanceof TaskGraph &&\n \"run\" in arg &&\n typeof arg.run === \"function\"\n );\n}\n\nexport function ensureTask<I extends DataPorts, O extends DataPorts>(\n arg: Taskish<I, O>,\n config: any = {}\n): ITask<any, any, any> {\n if (arg instanceof Task) {\n return arg;\n }\n if (arg instanceof TaskGraph) {\n getWrapperClasses();\n const { isOwned, ...cleanConfig } = config;\n if (isOwned) {\n return new _OwnGraphTask({}, { ...cleanConfig, subGraph: arg });\n } else {\n return new _GraphTask({}, { ...cleanConfig, subGraph: arg });\n }\n }\n if (isWorkflowLike(arg)) {\n getWrapperClasses();\n const { isOwned, ...cleanConfig } = config;\n if (isOwned) {\n return new _OwnWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });\n } else {\n return new _ConvWorkflowTask({}, { ...cleanConfig, subGraph: arg.graph });\n }\n }\n return convertPipeFunctionToTask(arg as PipeFunction<I, O>, config);\n}\n",
21
22
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { EventParameters } from \"@workglow/util\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport { TaskIdType } from \"../task/TaskTypes\";\nimport { DataflowIdType } from \"./Dataflow\";\n\n/**\n * Events that can be emitted by the TaskGraph\n */\n\nexport type TaskGraphStatusListeners = {\n graph_progress: (progress: number, message?: string, ...args: any[]) => void;\n start: () => void;\n complete: () => void;\n error: (error: Error) => void;\n abort: () => void;\n disabled: () => void;\n /** Fired when a task in the graph starts streaming */\n task_stream_start: (taskId: TaskIdType) => void;\n /** Fired for each stream chunk produced by a task in the graph */\n task_stream_chunk: (taskId: TaskIdType, event: StreamEvent) => void;\n /** Fired when a task in the graph finishes streaming */\n task_stream_end: (taskId: TaskIdType, output: Record<string, any>) => void;\n};\nexport type TaskGraphStatusEvents = keyof TaskGraphStatusListeners;\nexport type TaskGraphStatusListener<Event extends TaskGraphStatusEvents> =\n TaskGraphStatusListeners[Event];\nexport type TaskGraphEventStatusParameters<Event extends TaskGraphStatusEvents> = EventParameters<\n TaskGraphStatusListeners,\n Event\n>;\n\nexport type GraphEventDagListeners = {\n task_added: (taskId: TaskIdType) => void;\n task_removed: (taskId: TaskIdType) => void;\n task_replaced: (taskId: TaskIdType) => void;\n dataflow_added: (dataflowId: DataflowIdType) => void;\n dataflow_removed: (dataflowId: DataflowIdType) => void;\n dataflow_replaced: (dataflowId: DataflowIdType) => void;\n};\nexport type GraphEventDagEvents = keyof GraphEventDagListeners;\nexport type GraphEventDagListener<Event extends GraphEventDagEvents> =\n GraphEventDagListeners[Event];\nexport type GraphEventDagParameters<Event extends GraphEventDagEvents> = EventParameters<\n GraphEventDagListeners,\n Event\n>;\n\nexport type TaskGraphListeners = TaskGraphStatusListeners & GraphEventDagListeners;\nexport type TaskGraphEvents = keyof TaskGraphListeners;\nexport type TaskGraphEventListener<Event extends TaskGraphEvents> = TaskGraphListeners[Event];\nexport type TaskGraphEventParameters<Event extends TaskGraphEvents> = EventParameters<\n TaskGraphListeners,\n Event\n>;\n\nexport const EventDagToTaskGraphMapping = {\n \"node-added\": \"task_added\",\n \"node-removed\": \"task_removed\",\n \"node-replaced\": \"task_replaced\",\n \"edge-added\": \"dataflow_added\",\n \"edge-removed\": \"dataflow_removed\",\n \"edge-replaced\": \"dataflow_replaced\",\n} as const;\n\nexport const EventTaskGraphToDagMapping = {\n task_added: \"node-added\",\n task_removed: \"node-removed\",\n task_replaced: \"node-replaced\",\n dataflow_added: \"edge-added\",\n dataflow_removed: \"edge-removed\",\n dataflow_replaced: \"edge-replaced\",\n} as const;\n",
22
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DirectedAcyclicGraph } from \"@workglow/util/graph\";\nimport { EventEmitter, ServiceRegistry, uuid4 } from \"@workglow/util\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { ITask } from \"../task/ITask\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport type { TaskIdType, TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { ensureTask, type PipeFunction } from \"./Conversions\";\nimport { Dataflow, type DataflowIdType } from \"./Dataflow\";\nimport { addBoundaryNodesToDependencyJson, addBoundaryNodesToGraphJson } from \"./GraphSchemaUtils\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport {\n EventTaskGraphToDagMapping,\n GraphEventDagEvents,\n GraphEventDagParameters,\n TaskGraphEventListener,\n TaskGraphEvents,\n TaskGraphEventStatusParameters,\n TaskGraphStatusEvents,\n TaskGraphStatusListeners,\n} from \"./TaskGraphEvents\";\nimport {\n CompoundMergeStrategy,\n GraphResult,\n type GraphResultArray,\n TaskGraphRunner,\n} from \"./TaskGraphRunner\";\n\n/**\n * Configuration for running a task graph\n */\nexport interface TaskGraphRunConfig {\n /** Optional output cache to use for this task graph */\n outputCache?: TaskOutputRepository | boolean;\n /** Optional signal to abort the task graph */\n parentSignal?: AbortSignal;\n /** Optional service registry to use for this task graph (creates child from global if not provided) */\n registry?: ServiceRegistry;\n /**\n * When true, streaming leaf tasks (no outgoing edges) accumulate their full\n * output so the workflow return value is complete. Defaults to true.\n * Pass false for subgraph runs where the parent handles streaming via\n * subscriptions and does not rely on the return value for stream data.\n */\n accumulateLeafOutputs?: boolean;\n}\n\nexport interface TaskGraphRunReactiveConfig extends TaskGraphRunConfig {\n /** Optional service registry to use for this task graph */\n registry?: ServiceRegistry;\n}\n\nclass TaskGraphDAG extends DirectedAcyclicGraph<\n ITask<any, any, any>,\n Dataflow,\n TaskIdType,\n DataflowIdType\n> {\n constructor() {\n super(\n (task: ITask<any, any, any>) => task.id,\n (dataflow: Dataflow) => dataflow.id\n );\n }\n}\n\ninterface TaskGraphConstructorConfig {\n outputCache?: TaskOutputRepository;\n dag?: TaskGraphDAG;\n}\n\n/**\n * Represents a task graph, a directed acyclic graph of tasks and data flows\n */\nexport class TaskGraph implements ITaskGraph {\n /** Optional output cache to use for this task graph */\n public outputCache?: TaskOutputRepository;\n\n /**\n * Constructor for TaskGraph\n * @param config Configuration for the task graph\n */\n constructor({ outputCache, dag }: TaskGraphConstructorConfig = {}) {\n this.outputCache = outputCache;\n this._dag = dag || new TaskGraphDAG();\n }\n\n private _dag: TaskGraphDAG;\n\n private _runner: TaskGraphRunner | undefined;\n public get runner(): TaskGraphRunner {\n if (!this._runner) {\n this._runner = new TaskGraphRunner(this, this.outputCache);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Public methods\n // ========================================================================\n\n /**\n * Runs the task graph\n * @param config Configuration for the graph run\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskError if any tasks have failed\n */\n public run<ExecuteOutput extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config: TaskGraphRunConfig = {}\n ): Promise<GraphResultArray<ExecuteOutput>> {\n return this.runner.runGraph<ExecuteOutput>(input, {\n outputCache: config?.outputCache || this.outputCache,\n parentSignal: config?.parentSignal || undefined,\n accumulateLeafOutputs: config?.accumulateLeafOutputs,\n registry: config?.registry,\n });\n }\n\n /**\n * Runs the task graph reactively\n * @returns A promise that resolves when all tasks are complete\n * @throws TaskError if any tasks have failed\n */\n public runReactive<Output extends TaskOutput>(\n input: TaskInput = {} as TaskInput,\n config: TaskGraphRunConfig = {}\n ): Promise<GraphResultArray<Output>> {\n return this.runner.runGraphReactive<Output>(input, config);\n }\n\n /**\n * Merges the execute output to the run output\n * @param results The execute output\n * @param compoundMerge The compound merge strategy to use\n * @returns The run output\n */\n\n public mergeExecuteOutputsToRunOutput<\n ExecuteOutput extends TaskOutput,\n Merge extends CompoundMergeStrategy = CompoundMergeStrategy,\n >(\n results: GraphResultArray<ExecuteOutput>,\n compoundMerge: Merge\n ): GraphResult<ExecuteOutput, Merge> {\n return this.runner.mergeExecuteOutputsToRunOutput(results, compoundMerge);\n }\n\n /**\n * Aborts the task graph\n */\n public abort() {\n this.runner.abort();\n }\n\n /**\n * Disables the task graph\n */\n public async disable() {\n await this.runner.disable();\n }\n\n /**\n * Retrieves a task from the task graph by its id\n * @param id The id of the task to retrieve\n * @returns The task with the given id, or undefined if not found\n */\n public getTask(id: TaskIdType): ITask<any, any, any> | undefined {\n return this._dag.getNode(id);\n }\n\n /**\n * Retrieves all tasks in the task graph\n * @returns An array of tasks in the task graph\n */\n public getTasks(): ITask<any, any, any>[] {\n return this._dag.getNodes();\n }\n\n /**\n * Retrieves all tasks in the task graph topologically sorted\n * @returns An array of tasks in the task graph topologically sorted\n */\n public topologicallySortedNodes(): ITask<any, any, any>[] {\n return this._dag.topologicallySortedNodes();\n }\n\n /**\n * Adds a task to the task graph\n * @param task The task to add\n * @returns The current task graph\n */\n public addTask(fn: PipeFunction<any, any>, config?: any): unknown;\n public addTask(task: ITask<any, any, any>): unknown;\n public addTask(task: ITask<any, any, any> | PipeFunction<any, any>, config?: any): unknown {\n return this._dag.addNode(ensureTask(task, config));\n }\n\n /**\n * Adds multiple tasks to the task graph\n * @param tasks The tasks to add\n * @returns The current task graph\n */\n public addTasks(tasks: PipeFunction<any, any>[]): unknown[];\n public addTasks(tasks: ITask<any, any, any>[]): unknown[];\n public addTasks(tasks: ITask<any, any, any>[] | PipeFunction<any, any>[]): unknown[] {\n return this._dag.addNodes(tasks.map(ensureTask));\n }\n\n /**\n * Adds a data flow to the task graph\n * @param dataflow The data flow to add\n * @returns The current task graph\n */\n public addDataflow(dataflow: Dataflow) {\n return this._dag.addEdge(dataflow.sourceTaskId, dataflow.targetTaskId, dataflow);\n }\n\n /**\n * Adds multiple data flows to the task graph\n * @param dataflows The data flows to add\n * @returns The current task graph\n */\n public addDataflows(dataflows: Dataflow[]) {\n const addedEdges = dataflows.map<[s: unknown, t: unknown, e: Dataflow]>((edge) => {\n return [edge.sourceTaskId, edge.targetTaskId, edge];\n });\n return this._dag.addEdges(addedEdges);\n }\n\n /**\n * Retrieves a data flow from the task graph by its id\n * @param id The id of the data flow to retrieve\n * @returns The data flow with the given id, or undefined if not found\n */\n public getDataflow(id: DataflowIdType): Dataflow | undefined {\n // @ts-ignore\n for (const i in this._dag.adjacency) {\n // @ts-ignore\n for (const j in this._dag.adjacency[i]) {\n // @ts-ignore\n const maybeEdges = this._dag.adjacency[i][j];\n if (maybeEdges !== null) {\n for (const edge of maybeEdges) {\n // @ts-ignore\n if (this._dag.edgeIdentity(edge, \"\", \"\") == id) {\n return edge;\n }\n }\n }\n }\n }\n }\n\n /**\n * Retrieves all data flows in the task graph\n * @returns An array of data flows in the task graph\n */\n public getDataflows(): Dataflow[] {\n return this._dag.getEdges().map((edge) => edge[2]);\n }\n\n /**\n * Removes a data flow from the task graph\n * @param dataflow The data flow to remove\n * @returns The current task graph\n */\n public removeDataflow(dataflow: Dataflow) {\n return this._dag.removeEdge(dataflow.sourceTaskId, dataflow.targetTaskId, dataflow.id);\n }\n\n /**\n * Retrieves the data flows that are sources of a given task\n * @param taskId The id of the task to retrieve sources for\n * @returns An array of data flows that are sources of the given task\n */\n public getSourceDataflows(taskId: unknown): Dataflow[] {\n return this._dag.inEdges(taskId).map(([, , dataflow]) => dataflow);\n }\n\n /**\n * Retrieves the data flows that are targets of a given task\n * @param taskId The id of the task to retrieve targets for\n * @returns An array of data flows that are targets of the given task\n */\n public getTargetDataflows(taskId: unknown): Dataflow[] {\n return this._dag.outEdges(taskId).map(([, , dataflow]) => dataflow);\n }\n\n /**\n * Retrieves the tasks that are sources of a given task\n * @param taskId The id of the task to retrieve sources for\n * @returns An array of tasks that are sources of the given task\n */\n public getSourceTasks(taskId: unknown): ITask<any, any, any>[] {\n return this.getSourceDataflows(taskId).map((dataflow) => this.getTask(dataflow.sourceTaskId)!);\n }\n\n /**\n * Retrieves the tasks that are targets of a given task\n * @param taskId The id of the task to retrieve targets for\n * @returns An array of tasks that are targets of the given task\n */\n public getTargetTasks(taskId: unknown): ITask<any, any, any>[] {\n return this.getTargetDataflows(taskId).map((dataflow) => this.getTask(dataflow.targetTaskId)!);\n }\n\n /**\n * Removes a task from the task graph\n * @param taskId The id of the task to remove\n * @returns The current task graph\n */\n public removeTask(taskId: unknown) {\n return this._dag.removeNode(taskId);\n }\n\n public resetGraph() {\n this.runner.resetGraph(this, uuid4());\n }\n\n /**\n * Converts the task graph to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns A TaskGraphJson object representing the tasks and dataflows\n */\n public toJSON(options?: TaskGraphJsonOptions): TaskGraphJson {\n const tasks = this.getTasks().map((node) => node.toJSON(options));\n const dataflows = this.getDataflows().map((df) => df.toJSON());\n let json: TaskGraphJson = {\n tasks,\n dataflows,\n };\n if (options?.withBoundaryNodes) {\n json = addBoundaryNodesToGraphJson(json, this);\n }\n return json;\n }\n\n /**\n * Converts the task graph to a JSON format suitable for dependency tracking\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns An array of JsonTaskItem objects, each representing a task and its dependencies\n */\n public toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem[] {\n const tasks = this.getTasks().flatMap((node) => node.toDependencyJSON(options));\n this.getDataflows().forEach((df) => {\n const target = tasks.find((node) => node.id === df.targetTaskId)!;\n if (!target.dependencies) {\n target.dependencies = {};\n }\n const targetDeps = target.dependencies[df.targetTaskPortId];\n if (!targetDeps) {\n target.dependencies[df.targetTaskPortId] = {\n id: df.sourceTaskId,\n output: df.sourceTaskPortId,\n };\n } else {\n if (Array.isArray(targetDeps)) {\n targetDeps.push({\n id: df.sourceTaskId,\n output: df.sourceTaskPortId,\n });\n } else {\n target.dependencies[df.targetTaskPortId] = [\n targetDeps,\n { id: df.sourceTaskId, output: df.sourceTaskPortId },\n ];\n }\n }\n });\n if (options?.withBoundaryNodes) {\n return addBoundaryNodesToDependencyJson(tasks, this);\n }\n return tasks;\n }\n\n // ========================================================================\n // Event handling\n // ========================================================================\n\n /**\n * Event emitter for task lifecycle events\n */\n public get events(): EventEmitter<TaskGraphStatusListeners> {\n if (!this._events) {\n this._events = new EventEmitter<TaskGraphStatusListeners>();\n }\n return this._events;\n }\n protected _events: EventEmitter<TaskGraphStatusListeners> | undefined;\n\n /**\n * Subscribes to an event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n * @returns a function to unsubscribe from the event\n */\n public subscribe<Event extends TaskGraphEvents>(\n name: Event,\n fn: TaskGraphEventListener<Event>\n ): () => void {\n this.on(name, fn);\n return () => this.off(name, fn);\n }\n\n /**\n * Subscribes to status changes on all tasks (existing and future)\n * @param callback - Function called when any task's status changes\n * @param callback.taskId - The ID of the task whose status changed\n * @param callback.status - The new status of the task\n * @returns a function to unsubscribe from all task status events\n */\n public subscribeToTaskStatus(\n callback: (taskId: TaskIdType, status: TaskStatus) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to status events on all existing tasks\n const tasks = this.getTasks();\n tasks.forEach((task) => {\n const unsub = task.subscribe(\"status\", (status) => {\n callback(task.id, status);\n });\n unsubscribes.push(unsub);\n });\n\n const handleTaskAdded = (taskId: TaskIdType) => {\n const task = this.getTask(taskId);\n if (!task || typeof task.subscribe !== \"function\") return;\n\n const unsub = task.subscribe(\"status\", (status) => {\n callback(task.id, status);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"task_added\", handleTaskAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to progress updates on all tasks (existing and future)\n * @param callback - Function called when any task reports progress\n * @param callback.taskId - The ID of the task reporting progress\n * @param callback.progress - The progress value (0-100)\n * @param callback.message - Optional progress message\n * @param callback.args - Additional arguments passed with the progress update\n * @returns a function to unsubscribe from all task progress events\n */\n public subscribeToTaskProgress(\n callback: (taskId: TaskIdType, progress: number, message?: string, ...args: any[]) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to progress events on all existing tasks\n const tasks = this.getTasks();\n tasks.forEach((task) => {\n const unsub = task.subscribe(\"progress\", (progress, message, ...args) => {\n callback(task.id, progress, message, ...args);\n });\n unsubscribes.push(unsub);\n });\n\n const handleTaskAdded = (taskId: TaskIdType) => {\n const task = this.getTask(taskId);\n if (!task || typeof task.subscribe !== \"function\") return;\n\n const unsub = task.subscribe(\"progress\", (progress, message, ...args) => {\n callback(task.id, progress, message, ...args);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"task_added\", handleTaskAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to status changes on all dataflows (existing and future)\n * @param callback - Function called when any dataflow's status changes\n * @param callback.dataflowId - The ID of the dataflow whose status changed\n * @param callback.status - The new status of the dataflow\n * @returns a function to unsubscribe from all dataflow status events\n */\n public subscribeToDataflowStatus(\n callback: (dataflowId: DataflowIdType, status: TaskStatus) => void\n ): () => void {\n const unsubscribes: (() => void)[] = [];\n\n // Subscribe to status events on all existing dataflows\n const dataflows = this.getDataflows();\n dataflows.forEach((dataflow) => {\n const unsub = dataflow.subscribe(\"status\", (status) => {\n callback(dataflow.id, status);\n });\n unsubscribes.push(unsub);\n });\n\n const handleDataflowAdded = (dataflowId: DataflowIdType) => {\n const dataflow = this.getDataflow(dataflowId);\n if (!dataflow || typeof dataflow.subscribe !== \"function\") return;\n\n const unsub = dataflow.subscribe(\"status\", (status) => {\n callback(dataflow.id, status);\n });\n unsubscribes.push(unsub);\n };\n\n const graphUnsub = this.subscribe(\"dataflow_added\", handleDataflowAdded);\n unsubscribes.push(graphUnsub);\n\n // Return unsubscribe function\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribes to streaming events on the task graph.\n * Listens for task_stream_start, task_stream_chunk, and task_stream_end\n * events emitted by the TaskGraphRunner during streaming task execution.\n *\n * @param callbacks - Object with optional callbacks for each streaming event\n * @returns a function to unsubscribe from all streaming events\n */\n public subscribeToTaskStreaming(callbacks: {\n onStreamStart?: (taskId: TaskIdType) => void;\n onStreamChunk?: (taskId: TaskIdType, event: StreamEvent) => void;\n onStreamEnd?: (taskId: TaskIdType, output: Record<string, any>) => void;\n }): () => void {\n const unsubscribes: (() => void)[] = [];\n\n if (callbacks.onStreamStart) {\n const unsub = this.subscribe(\"task_stream_start\", callbacks.onStreamStart);\n unsubscribes.push(unsub);\n }\n\n if (callbacks.onStreamChunk) {\n const unsub = this.subscribe(\"task_stream_chunk\", callbacks.onStreamChunk);\n unsubscribes.push(unsub);\n }\n\n if (callbacks.onStreamEnd) {\n const unsub = this.subscribe(\"task_stream_end\", callbacks.onStreamEnd);\n unsubscribes.push(unsub);\n }\n\n return () => {\n unsubscribes.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Registers an event listener for the specified event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n */\n on<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // Safe cast: TaskGraph dag events (task_added, etc.) have the same signature as\n // the underlying DAG events (node-added, etc.) - both pass IDs, not full objects\n return this._dag.on(dagEvent, fn as Parameters<typeof this._dag.on>[1]);\n }\n return this.events.on(\n name as TaskGraphStatusEvents,\n fn as TaskGraphEventListener<TaskGraphStatusEvents>\n );\n }\n\n /**\n * Removes an event listener for the specified event\n * @param name - The event name to listen for\n * @param fn - The callback function to execute when the event occurs\n */\n off<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // Safe cast: TaskGraph dag events (task_added, etc.) have the same signature as\n // the underlying DAG events (node-added, etc.) - both pass IDs, not full objects\n return this._dag.off(dagEvent, fn as Parameters<typeof this._dag.off>[1]);\n }\n return this.events.off(\n name as TaskGraphStatusEvents,\n fn as TaskGraphEventListener<TaskGraphStatusEvents>\n );\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n emit<E extends GraphEventDagEvents>(name: E, ...args: GraphEventDagParameters<E>): void;\n emit<E extends TaskGraphStatusEvents>(name: E, ...args: TaskGraphEventStatusParameters<E>): void;\n emit(name: string, ...args: any[]): void {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // @ts-ignore\n return this.emit_dag(name, ...args);\n } else {\n // @ts-ignore\n return this.emit_local(name, ...args);\n }\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n protected emit_local<Event extends TaskGraphStatusEvents>(\n name: Event,\n ...args: TaskGraphEventStatusParameters<Event>\n ) {\n return this.events?.emit(name, ...args);\n }\n\n /**\n * Emits an event for the specified event\n * @param name - The event name to emit\n * @param args - The arguments to pass to the event listener\n */\n protected emit_dag<Event extends GraphEventDagEvents>(\n name: Event,\n ...args: GraphEventDagParameters<Event>\n ) {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n // Safe cast: GraphEventDagParameters matches the DAG's emit parameters (both are ID-based)\n return this._dag.emit(dagEvent, ...(args as unknown as [unknown]));\n }\n}\n\n/**\n * Super simple helper if you know the input and output handles, and there is only one each\n *\n * @param tasks\n * @param inputHandle\n * @param outputHandle\n * @returns\n */\nfunction serialGraphEdges(\n tasks: ITask<any, any, any>[],\n inputHandle: string,\n outputHandle: string\n): Dataflow[] {\n const edges: Dataflow[] = [];\n for (let i = 0; i < tasks.length - 1; i++) {\n edges.push(new Dataflow(tasks[i].id, inputHandle, tasks[i + 1].id, outputHandle));\n }\n return edges;\n}\n\n/**\n * Super simple helper if you know the input and output handles, and there is only one each\n *\n * @param tasks\n * @param inputHandle\n * @param outputHandle\n * @returns\n */\nexport function serialGraph(\n tasks: ITask<any, any, any>[],\n inputHandle: string,\n outputHandle: string\n): TaskGraph {\n const graph = new TaskGraph();\n graph.addTasks(tasks);\n graph.addDataflows(serialGraphEdges(tasks, inputHandle, outputHandle));\n return graph;\n}\n",
23
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport * from \"./task-graph/Dataflow\";\nexport * from \"./task-graph/DataflowEvents\";\n\nexport * from \"./task-graph/GraphSchemaUtils\";\nexport * from \"./task-graph/ITaskGraph\";\nexport * from \"./task-graph/TaskGraph\";\nexport * from \"./task-graph/TaskGraphEvents\";\nexport * from \"./task-graph/TaskGraphRunner\";\n\nexport * from \"./task-graph/Conversions\";\nexport * from \"./task-graph/GraphToWorkflowCode\";\nexport * from \"./task-graph/IWorkflow\";\nexport * from \"./task-graph/Workflow\";\n\nexport * from \"./task\";\n\nexport * from \"./storage/TaskGraphRepository\";\nexport * from \"./storage/TaskGraphTabularRepository\";\nexport * from \"./storage/TaskOutputRepository\";\nexport * from \"./storage/TaskOutputTabularRepository\";\n",
24
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ITask } from \"../task/ITask\";\nimport type { TaskIdType } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport type { TaskGraph } from \"./TaskGraph\";\nimport { Workflow } from \"./Workflow\";\n\n/**\n * Options controlling the generated workflow code.\n */\nexport interface GraphToWorkflowCodeOptions {\n /** Name of the workflow variable in the generated code. @default \"workflow\" */\n readonly variableName?: string;\n /** When true, include `new Workflow()` declaration. @default true */\n readonly includeDeclaration?: boolean;\n /** Indentation string per level. @default \" \" */\n readonly indent?: string;\n}\n\n/**\n * Map from task type name to the Workflow prototype method name.\n * Built lazily by scanning `Workflow.prototype` for methods with `workflowCreate = true`.\n */\nlet methodNameCache: Map<string, string> | undefined;\n\nfunction getMethodNameMap(): Map<string, string> {\n if (methodNameCache) return methodNameCache;\n methodNameCache = new Map<string, string>();\n for (const key of Object.getOwnPropertyNames(Workflow.prototype)) {\n try {\n const val = (Workflow.prototype as any)[key];\n if (val && val.workflowCreate && val.type) {\n methodNameCache.set(val.type, key);\n }\n } catch {\n // skip getters that throw\n }\n }\n return methodNameCache;\n}\n\n/**\n * Loop task types that use the builder pattern.\n */\nconst LOOP_TASK_TYPES: Record<string, { method: string; endMethod: string }> = {\n MapTask: { method: \"map\", endMethod: \"endMap\" },\n ReduceTask: { method: \"reduce\", endMethod: \"endReduce\" },\n WhileTask: { method: \"while\", endMethod: \"endWhile\" },\n GraphAsTask: { method: \"group\", endMethod: \"endGroup\" },\n};\n\n/**\n * Converts a TaskGraph into JavaScript/TypeScript code that builds an equivalent Workflow.\n *\n * This is the reverse of the Workflow builder: given a graph (with tasks, dataflows, and\n * potential subgraphs for loop/compound tasks), it produces code that re-creates the\n * same graph via the Workflow API.\n *\n * The generated code uses method chaining, which is critical for loop tasks where\n * `.map()` / `.while()` / `.reduce()` return a loop builder that inner tasks must\n * be called on before `.endMap()` / `.endWhile()` / `.endReduce()` returns to the\n * parent workflow.\n *\n * @param graph - The TaskGraph to convert\n * @param options - Options controlling output format\n * @returns Generated JavaScript code string\n */\nexport function graphToWorkflowCode(\n graph: TaskGraph,\n options: GraphToWorkflowCodeOptions = {}\n): string {\n const { variableName = \"workflow\", includeDeclaration = true, indent = \" \" } = options;\n\n const lines: string[] = [];\n\n if (includeDeclaration) {\n lines.push(`const ${variableName} = new Workflow();`);\n }\n\n const tasks = graph.topologicallySortedNodes();\n const dataflows = graph.getDataflows();\n\n // Build dataflow lookup: targetTaskId -> list of dataflows\n const incomingDataflows = new Map<TaskIdType, typeof dataflows>();\n for (const df of dataflows) {\n const list = incomingDataflows.get(df.targetTaskId) ?? [];\n list.push(df);\n incomingDataflows.set(df.targetTaskId, list);\n }\n\n // Track task order for determining which task is \"previous\"\n const taskOrder: TaskIdType[] = [];\n\n generateTaskChain(tasks, incomingDataflows, taskOrder, variableName, indent, 0, lines);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generates the workflow code for a sequence of tasks, using chained method calls.\n *\n * The variable name is always on its own line, with tasks chained below:\n * ```\n * workflow\n * .task1(args)\n * .task2(args)\n * .task3(args);\n * ```\n *\n * Single tasks that fit on one line are collapsed:\n * ```\n * workflow.task1(args);\n * ```\n *\n * For loop tasks, inner tasks are indented and chained on the loop builder.\n * The `.end*()` call returns to the parent workflow, so subsequent tasks\n * continue chaining on the parent variable.\n */\nfunction generateTaskChain(\n tasks: readonly ITask[],\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n variableName: string,\n indent: string,\n depth: number,\n lines: string[]\n): void {\n if (tasks.length === 0) return;\n\n const prefix = indent.repeat(depth);\n const chainIndent = indent.repeat(depth + 1);\n\n // Generate all chain lines into a temporary buffer\n const chainLines: string[] = [];\n\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n const loopInfo = LOOP_TASK_TYPES[task.type];\n\n // Check for rename() calls needed before this task\n const renames = computeRenames(task, incomingDataflows, taskOrder);\n for (const rename of renames) {\n chainLines.push(\n `${chainIndent}.rename(${formatValue(rename.source)}, ${formatValue(rename.target)})`\n );\n }\n\n if (loopInfo) {\n generateLoopTask(task, loopInfo, incomingDataflows, taskOrder, indent, depth, chainLines);\n } else {\n generateRegularTask(task, chainIndent, chainLines);\n }\n\n taskOrder.push(task.id);\n }\n\n // Try to collapse single-call chains onto one line\n if (chainLines.length === 1 && !chainLines[0].includes(\"\\n\")) {\n const call = chainLines[0].trimStart();\n const oneLine = `${prefix}${variableName}${call}`;\n if (oneLine.length < 80) {\n lines.push(`${oneLine};`);\n return;\n }\n }\n\n // Multi-line: variable on its own line, then chained calls\n lines.push(`${prefix}${variableName}`);\n for (const line of chainLines) {\n lines.push(line);\n }\n lines[lines.length - 1] += \";\";\n}\n\n/**\n * Generates code for a regular (non-loop) task as a chained `.method(args)` call.\n */\nfunction generateRegularTask(task: ITask, chainIndent: string, lines: string[]): void {\n const methodMap = getMethodNameMap();\n const methodName = methodMap.get(task.type);\n const defaults = task.defaults;\n const config = extractTaskConfig(task);\n\n if (methodName) {\n const colOffset = chainIndent.length + `.${methodName}(`.length;\n const args = buildMethodArgs(defaults, config, chainIndent, colOffset);\n lines.push(`${chainIndent}.${methodName}(${args})`);\n } else {\n const colOffset = chainIndent.length + \".addTask(\".length;\n const args = buildAddTaskArgs(task.type, defaults, config, chainIndent, colOffset);\n lines.push(`${chainIndent}.addTask(${args})`);\n }\n}\n\n/**\n * Generates code for a loop task (map/reduce/while) using builder pattern.\n *\n * Loop tasks use chained method calls:\n * ```\n * workflow\n * .map({ config })\n * .addTask(InnerTask)\n * .endMap()\n * ```\n *\n * The `.map()` call returns a loop builder, inner tasks chain on that,\n * and `.endMap()` returns to the parent workflow. All of this is a single\n * chained expression to preserve the correct `this` context.\n */\nfunction generateLoopTask(\n task: ITask,\n loopInfo: { method: string; endMethod: string },\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n indent: string,\n depth: number,\n lines: string[]\n): void {\n const chainIndent = indent.repeat(depth + 1);\n const config = extractLoopConfig(task);\n const loopColOffset = chainIndent.length + `.${loopInfo.method}(`.length;\n const configStr =\n Object.keys(config).length > 0 ? formatValue(config, chainIndent, loopColOffset) : \"\";\n\n lines.push(`${chainIndent}.${loopInfo.method}(${configStr})`);\n\n // Generate inner tasks from subgraph as chained calls\n if (task.hasChildren()) {\n const subGraph = task.subGraph!;\n const innerTasks = subGraph.topologicallySortedNodes();\n const innerDataflows = subGraph.getDataflows();\n\n const innerIncoming = new Map<TaskIdType, typeof innerDataflows>();\n for (const df of innerDataflows) {\n const list = innerIncoming.get(df.targetTaskId) ?? [];\n list.push(df);\n innerIncoming.set(df.targetTaskId, list);\n }\n\n const innerOrder: TaskIdType[] = [];\n generateChainedInnerTasks(innerTasks, innerIncoming, innerOrder, indent, depth + 1, lines);\n }\n\n // End the loop (no semicolon - caller adds it to the last line of the full chain)\n lines.push(`${chainIndent}.${loopInfo.endMethod}()`);\n}\n\n/**\n * Generates inner tasks as chained method calls (for loop builder bodies).\n * Each task becomes a `.methodName(args)` or `.addTask(Class, args)` continuation.\n * Nested loops generate recursive chained structures.\n */\nfunction generateChainedInnerTasks(\n tasks: readonly ITask[],\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n indent: string,\n depth: number,\n lines: string[]\n): void {\n const innerPrefix = indent.repeat(depth + 1);\n\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n const loopInfo = LOOP_TASK_TYPES[task.type];\n\n // Check for rename\n const renames = computeRenames(task, incomingDataflows, taskOrder);\n for (const rename of renames) {\n lines.push(\n `${innerPrefix}.rename(${formatValue(rename.source)}, ${formatValue(rename.target)})`\n );\n }\n\n if (loopInfo) {\n // Nested loop task - recurse\n const config = extractLoopConfig(task);\n const nestedColOffset = innerPrefix.length + `.${loopInfo.method}(`.length;\n const configStr =\n Object.keys(config).length > 0 ? formatValue(config, innerPrefix, nestedColOffset) : \"\";\n\n lines.push(`${innerPrefix}.${loopInfo.method}(${configStr})`);\n\n if (task.hasChildren()) {\n const subGraph = task.subGraph!;\n const innerTasks = subGraph.topologicallySortedNodes();\n const innerDataflows = subGraph.getDataflows();\n\n const innerIncoming = new Map<TaskIdType, typeof innerDataflows>();\n for (const df of innerDataflows) {\n const list = innerIncoming.get(df.targetTaskId) ?? [];\n list.push(df);\n innerIncoming.set(df.targetTaskId, list);\n }\n\n const innerOrder: TaskIdType[] = [];\n generateChainedInnerTasks(innerTasks, innerIncoming, innerOrder, indent, depth + 1, lines);\n }\n\n lines.push(`${innerPrefix}.${loopInfo.endMethod}()`);\n } else {\n // Regular inner task - chained call\n const methodMap = getMethodNameMap();\n const methodName = methodMap.get(task.type);\n const defaults = task.defaults;\n const config = extractTaskConfig(task);\n\n if (methodName) {\n const colOffset = innerPrefix.length + `.${methodName}(`.length;\n const args = buildMethodArgs(defaults, config, innerPrefix, colOffset);\n lines.push(`${innerPrefix}.${methodName}(${args})`);\n } else {\n const colOffset = innerPrefix.length + \".addTask(\".length;\n const args = buildAddTaskArgs(task.type, defaults, config, innerPrefix, colOffset);\n lines.push(`${innerPrefix}.addTask(${args})`);\n }\n }\n\n taskOrder.push(task.id);\n }\n}\n\n/**\n * Determines which dataflows need explicit `.rename()` calls.\n *\n * A rename is needed when a dataflow connects different port names between\n * the immediately previous task and the current task. Connections with matching\n * names are handled automatically by the Workflow's auto-connect system.\n */\nfunction computeRenames(\n task: ITask,\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[]\n): Array<{ source: string; target: string }> {\n const incoming = incomingDataflows.get(task.id) ?? [];\n const renames: Array<{ source: string; target: string }> = [];\n\n const prevTaskId = taskOrder.length > 0 ? taskOrder[taskOrder.length - 1] : undefined;\n\n for (const df of incoming) {\n // Skip all-ports connections (auto-connected by pipe/addTask)\n if (df.sourceTaskPortId === DATAFLOW_ALL_PORTS && df.targetTaskPortId === DATAFLOW_ALL_PORTS) {\n continue;\n }\n\n // Skip error port connections\n if (\n df.sourceTaskPortId === DATAFLOW_ERROR_PORT ||\n df.targetTaskPortId === DATAFLOW_ERROR_PORT\n ) {\n continue;\n }\n\n // Only the immediately previous task can produce a rename\n if (df.sourceTaskId !== prevTaskId) {\n continue;\n }\n\n // If port names match, auto-connect handles it\n if (df.sourceTaskPortId === df.targetTaskPortId) {\n continue;\n }\n\n renames.push({ source: df.sourceTaskPortId, target: df.targetTaskPortId });\n }\n\n return renames;\n}\n\n/**\n * Extracts non-default config properties from a task for regular tasks.\n * Skips title/description when they match the static class defaults.\n */\nfunction extractTaskConfig(task: ITask): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n const rawConfig = task.config;\n const staticTitle = (task.constructor as any).title || \"\";\n const staticDescription = (task.constructor as any).description || \"\";\n if (rawConfig.title && rawConfig.title !== staticTitle) config.title = rawConfig.title;\n if (rawConfig.description && rawConfig.description !== staticDescription)\n config.description = rawConfig.description;\n return config;\n}\n\n/**\n * Extracts config for loop tasks (map/reduce/while).\n */\nfunction extractLoopConfig(task: ITask): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n const rawConfig = task.config as Record<string, unknown>;\n\n switch (task.type) {\n case \"GraphAsTask\": {\n if (rawConfig.compoundMerge !== undefined) {\n config.compoundMerge = rawConfig.compoundMerge;\n }\n break;\n }\n case \"MapTask\": {\n if (rawConfig.preserveOrder !== undefined && rawConfig.preserveOrder !== true) {\n config.preserveOrder = rawConfig.preserveOrder;\n }\n if (rawConfig.flatten !== undefined && rawConfig.flatten !== false) {\n config.flatten = rawConfig.flatten;\n }\n if (rawConfig.concurrencyLimit !== undefined) {\n config.concurrencyLimit = rawConfig.concurrencyLimit;\n }\n if (rawConfig.batchSize !== undefined) {\n config.batchSize = rawConfig.batchSize;\n }\n break;\n }\n case \"ReduceTask\": {\n if (rawConfig.initialValue !== undefined) {\n config.initialValue = rawConfig.initialValue;\n }\n break;\n }\n case \"WhileTask\": {\n if (rawConfig.maxIterations !== undefined && rawConfig.maxIterations !== 100) {\n config.maxIterations = rawConfig.maxIterations;\n }\n if (rawConfig.chainIterations !== undefined && rawConfig.chainIterations !== true) {\n config.chainIterations = rawConfig.chainIterations;\n }\n // Emit serializable condition form\n if (rawConfig.conditionField !== undefined) {\n config.conditionField = rawConfig.conditionField;\n }\n if (rawConfig.conditionOperator !== undefined) {\n config.conditionOperator = rawConfig.conditionOperator;\n }\n if (rawConfig.conditionValue !== undefined) {\n config.conditionValue = rawConfig.conditionValue;\n }\n // If there's a function condition but no serializable form, use a null placeholder\n if (rawConfig.condition && !rawConfig.conditionOperator) {\n config.condition = null;\n }\n break;\n }\n }\n\n return config;\n}\n\n/**\n * Builds the argument string for a prototype method call.\n */\nfunction buildMethodArgs(\n defaults: Record<string, unknown> | undefined,\n config: Record<string, unknown>,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n const hasDefaults = defaults && Object.keys(defaults).length > 0;\n const hasConfig = Object.keys(config).length > 0;\n\n if (!hasDefaults && !hasConfig) return \"\";\n if (hasDefaults && !hasConfig) return formatValue(defaults, baseIndent, columnOffset);\n if (!hasDefaults && hasConfig) return `{}, ${formatValue(config, baseIndent, columnOffset + 4)}`;\n const defaultsStr = formatValue(defaults, baseIndent, columnOffset);\n return `${defaultsStr}, ${formatValue(config, baseIndent, columnOffset + defaultsStr.length + 2)}`;\n}\n\n/**\n * Builds the argument string for an addTask() call.\n */\nfunction buildAddTaskArgs(\n taskType: string,\n defaults: Record<string, unknown> | undefined,\n config: Record<string, unknown>,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n const hasDefaults = defaults && Object.keys(defaults).length > 0;\n const hasConfig = Object.keys(config).length > 0;\n const typeOffset = columnOffset + taskType.length + 2;\n\n if (!hasDefaults && !hasConfig) return taskType;\n if (hasDefaults && !hasConfig)\n return `${taskType}, ${formatValue(defaults, baseIndent, typeOffset)}`;\n if (!hasDefaults && hasConfig)\n return `${taskType}, {}, ${formatValue(config, baseIndent, typeOffset + 4)}`;\n const defaultsStr = formatValue(defaults, baseIndent, typeOffset);\n return `${taskType}, ${defaultsStr}, ${formatValue(config, baseIndent, typeOffset + defaultsStr.length + 2)}`;\n}\n\n/**\n * Formats a JavaScript value as a code string.\n * Handles objects, arrays, strings, numbers, booleans, undefined, null,\n * and special markers.\n */\nexport function formatValue(\n value: unknown,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (value instanceof Float32Array) {\n return `new Float32Array([${Array.from(value).join(\", \")}])`;\n }\n if (value instanceof Float64Array) {\n return `new Float64Array([${Array.from(value).join(\", \")}])`;\n }\n const entryIndent = baseIndent + \" \";\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n const items = value.map((v) => formatValue(v, entryIndent));\n const oneLine = `[${items.join(\", \")}]`;\n if (columnOffset + oneLine.length < 80) return oneLine;\n return `[\\n${items.map((item) => `${entryIndent}${item}`).join(\",\\n\")}\\n${baseIndent}]`;\n }\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n if (keys.length === 0) return \"{}\";\n const entries = keys.map((k) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) ? k : JSON.stringify(k);\n return `${formattedKey}: ${formatValue(obj[k], entryIndent)}`;\n });\n const oneLine = `{ ${entries.join(\", \")} }`;\n if (columnOffset + oneLine.length < 80) return oneLine;\n return `{\\n${entries.map((e) => `${entryIndent}${e}`).join(\",\\n\")}\\n${baseIndent}}`;\n }\n return String(value);\n}\n\n/**\n * Resets the method name cache. Useful for testing when prototype methods\n * are registered after initial import.\n */\nexport function resetMethodNameCache(): void {\n methodNameCache = undefined;\n}\n",
25
23
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { JsonSchema, type DataPortSchema } from \"@workglow/util/schema\";\nimport {\n EventEmitter,\n getLogger,\n ServiceRegistry,\n uuid4,\n type EventParameters,\n} from \"@workglow/util\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { GraphAsTask } from \"../task/GraphAsTask\";\nimport type { ITask, ITaskConstructor } from \"../task/ITask\";\nimport { getPortStreamMode, type StreamEvent } from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport { WorkflowError } from \"../task/TaskError\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport { DataPorts, TaskConfig, TaskIdType } from \"../task/TaskTypes\";\nimport { ensureTask, type PipeFunction, type Taskish } from \"./Conversions\";\nimport { Dataflow, DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport { IWorkflow, WorkflowRunConfig } from \"./IWorkflow\";\nimport { TaskGraph } from \"./TaskGraph\";\nimport {\n CompoundMergeStrategy,\n PROPERTY_ARRAY,\n type PropertyArrayGraphResult,\n} from \"./TaskGraphRunner\";\n\n// ============================================================================\n// Standalone utility functions (moved from Conversions.ts to break circular\n// dependency — these need both Workflow and GraphAsTask which live here)\n// ============================================================================\n\nexport function getLastTask(workflow: IWorkflow): ITask<any, any, any> | undefined {\n const tasks = workflow.graph.getTasks();\n return tasks.length > 0 ? tasks[tasks.length - 1] : undefined;\n}\n\nexport function connect(\n source: ITask<any, any, any>,\n target: ITask<any, any, any>,\n workflow: IWorkflow<any, any>\n): void {\n workflow.graph.addDataflow(new Dataflow(source.id, \"*\", target.id, \"*\"));\n}\n\nexport function pipe<A extends DataPorts, B extends DataPorts>(\n [fn1]: [Taskish<A, B>],\n workflow?: IWorkflow<A, B>\n): IWorkflow<A, B>;\n\nexport function pipe<A extends DataPorts, B extends DataPorts, C extends DataPorts>(\n [fn1, fn2]: [Taskish<A, B>, Taskish<B, C>],\n workflow?: IWorkflow<A, C>\n): IWorkflow<A, C>;\n\nexport function pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n>(\n [fn1, fn2, fn3]: [Taskish<A, B>, Taskish<B, C>, Taskish<C, D>],\n workflow?: IWorkflow<A, D>\n): IWorkflow<A, D>;\n\nexport function pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n>(\n [fn1, fn2, fn3, fn4]: [Taskish<A, B>, Taskish<B, C>, Taskish<C, D>, Taskish<D, E>],\n workflow?: IWorkflow<A, E>\n): IWorkflow<A, E>;\n\nexport function pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n F extends DataPorts,\n>(\n [fn1, fn2, fn3, fn4, fn5]: [\n Taskish<A, B>,\n Taskish<B, C>,\n Taskish<C, D>,\n Taskish<D, E>,\n Taskish<E, F>,\n ],\n workflow?: IWorkflow<A, F>\n): IWorkflow<A, F>;\n\nexport function pipe<I extends DataPorts, O extends DataPorts>(\n args: Taskish<I, O>[],\n workflow: IWorkflow<I, O> = new Workflow<I, O>()\n): IWorkflow<I, O> {\n let previousTask = getLastTask(workflow);\n const tasks = args.map((arg) => ensureTask(arg));\n tasks.forEach((task) => {\n workflow.graph.addTask(task);\n if (previousTask) {\n connect(previousTask, task, workflow);\n }\n previousTask = task;\n });\n return workflow;\n}\n\nexport function parallel<I extends DataPorts = DataPorts, O extends DataPorts = DataPorts>(\n args: (PipeFunction<I, O> | ITask<I, O> | IWorkflow<I, O> | ITaskGraph)[],\n mergeFn: CompoundMergeStrategy = PROPERTY_ARRAY,\n workflow: IWorkflow<I, O> = new Workflow<I, O>()\n): IWorkflow<I, O> {\n let previousTask = getLastTask(workflow);\n const tasks = args.map((arg) => ensureTask(arg));\n const input = {};\n const config = {\n compoundMerge: mergeFn,\n };\n const name = `‖${args.map((arg) => \"𝑓\").join(\"‖\")}‖`;\n class ParallelTask extends GraphAsTask<I, O> {\n public static type = name;\n }\n const mergeTask = new ParallelTask(input, config);\n mergeTask.subGraph!.addTasks(tasks);\n workflow.graph.addTask(mergeTask);\n if (previousTask) {\n connect(previousTask, mergeTask, workflow);\n }\n return workflow;\n}\n\n// Type definitions for the workflow\nexport type CreateWorkflow<I extends DataPorts, O extends DataPorts, C extends TaskConfig> = (\n input?: Partial<I>,\n config?: Partial<C>\n) => Workflow<I, O>;\n\nexport function CreateWorkflow<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig = TaskConfig,\n>(taskClass: ITaskConstructor<I, O, C>): CreateWorkflow<I, O, C> {\n return Workflow.createWorkflow<I, O, C>(taskClass);\n}\n\n/**\n * Type for loop workflow methods (map, while, reduce).\n * Represents the method signature with proper `this` context.\n * Loop methods take only a config parameter - input is not used for loop tasks.\n */\nexport type CreateLoopWorkflow<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig = TaskConfig,\n> = (this: Workflow<I, O>, config?: Partial<C>) => Workflow<I, O>;\n\n/**\n * Factory function that creates a loop workflow method for a given task class.\n * Returns a method that can be assigned to Workflow.prototype.\n *\n * @param taskClass - The iterator task class (MapTask, ReduceTask, etc.)\n * @returns A method that creates the task and returns a loop builder workflow\n */\nexport function CreateLoopWorkflow<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig = TaskConfig,\n>(taskClass: ITaskConstructor<I, O, C>): CreateLoopWorkflow<I, O, C> {\n return function (this: Workflow<I, O>, config: Partial<C> = {}): Workflow<I, O> {\n return this.addLoopTask(taskClass, config);\n };\n}\n\n/**\n * Type for end loop workflow methods (endMap, endBatch, etc.).\n */\nexport type EndLoopWorkflow = (this: Workflow) => Workflow;\n\n/**\n * Factory function that creates an end loop workflow method.\n *\n * @param methodName - The name of the method (for error messages)\n * @returns A method that finalizes the loop and returns to the parent workflow\n */\nexport function CreateEndLoopWorkflow(methodName: string): EndLoopWorkflow {\n return function (this: Workflow): Workflow {\n if (!this.isLoopBuilder) {\n throw new Error(`${methodName}() can only be called on loop workflows`);\n }\n return this.finalizeAndReturn();\n };\n}\n\nconst TYPED_ARRAY_FORMAT_PREFIX = \"TypedArray\";\n\n/**\n * Returns true if the given JSON schema (or any nested schema) has a format\n * string starting with \"TypedArray\" (e.g. \"TypedArray\" or \"TypedArray:Float32Array\").\n * Walks oneOf/anyOf wrappers and array items.\n */\nfunction schemaHasTypedArrayFormat(schema: JsonSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n if (!schema || typeof schema !== \"object\" || Array.isArray(schema)) return false;\n\n const s = schema as Record<string, unknown>;\n if (typeof s.format === \"string\" && s.format.startsWith(TYPED_ARRAY_FORMAT_PREFIX)) {\n return true;\n }\n\n const checkUnion = (schemas: unknown): boolean => {\n if (!Array.isArray(schemas)) return false;\n return schemas.some((sub) => schemaHasTypedArrayFormat(sub as JsonSchema));\n };\n if (checkUnion(s.oneOf) || checkUnion(s.anyOf)) return true;\n\n const items = s.items;\n if (items && typeof items === \"object\" && !Array.isArray(items)) {\n if (schemaHasTypedArrayFormat(items as JsonSchema)) return true;\n }\n\n return false;\n}\n\n/**\n * Returns true if the task's output schema has any port with TypedArray format.\n * Used by adaptive workflow methods to choose scalar vs vector task variant.\n */\nexport function hasVectorOutput(task: ITask): boolean {\n const outputSchema = task.outputSchema();\n if (typeof outputSchema === \"boolean\" || !outputSchema?.properties) return false;\n return Object.values(outputSchema.properties).some((prop) =>\n schemaHasTypedArrayFormat(prop as JsonSchema)\n );\n}\n\n/**\n * Returns true if the input object looks like vector task input: has a \"vectors\"\n * property that is an array with at least one TypedArray element. Used by\n * adaptive workflow methods so that e.g. sum({ vectors: [new Float32Array(...)] })\n * chooses the vector variant even with no previous task.\n */\nexport function hasVectorLikeInput(input: unknown): boolean {\n if (!input || typeof input !== \"object\") return false;\n const v = (input as Record<string, unknown>).vectors;\n return (\n Array.isArray(v) &&\n v.length > 0 &&\n typeof v[0] === \"object\" &&\n v[0] !== null &&\n ArrayBuffer.isView(v[0])\n );\n}\n\n/**\n * Type for adaptive workflow methods that dispatch to scalar or vector variant\n * based on the previous task's output schema.\n */\nexport type CreateAdaptiveWorkflow<\n IS extends DataPorts,\n OS extends DataPorts,\n IV extends DataPorts,\n OV extends DataPorts,\n CS extends TaskConfig = TaskConfig,\n CV extends TaskConfig = TaskConfig,\n> = (\n this: Workflow,\n input?: Partial<IS> & Partial<IV>,\n config?: Partial<CS> & Partial<CV>\n) => Workflow;\n\n/**\n * Factory that creates an adaptive workflow method: when called, inspects the\n * output schema of the last task in the chain and delegates to the vector\n * variant if it has TypedArray output, otherwise to the scalar variant.\n * If there is no previous task, defaults to the scalar variant.\n *\n * @param scalarClass - Task class for scalar path (e.g. ScalarAddTask)\n * @param vectorClass - Task class for vector path (e.g. VectorSumTask)\n * @returns A method suitable for Workflow.prototype\n */\nexport function CreateAdaptiveWorkflow<\n IS extends DataPorts,\n OS extends DataPorts,\n IV extends DataPorts,\n OV extends DataPorts,\n CS extends TaskConfig = TaskConfig,\n CV extends TaskConfig = TaskConfig,\n>(\n scalarClass: ITaskConstructor<IS, OS, CS>,\n vectorClass: ITaskConstructor<IV, OV, CV>\n): CreateAdaptiveWorkflow<IS, OS, IV, OV, CS, CV> {\n const scalarHelper = Workflow.createWorkflow<IS, OS, CS>(scalarClass);\n const vectorHelper = Workflow.createWorkflow<IV, OV, CV>(vectorClass);\n\n return function (\n this: Workflow<any, any>,\n input: (Partial<IS> & Partial<IV>) | undefined = {},\n config: (Partial<CS> & Partial<CV>) | undefined = {}\n ): Workflow {\n const parent = getLastTask(this);\n const useVector =\n (parent !== undefined && hasVectorOutput(parent)) || hasVectorLikeInput(input);\n if (useVector) {\n return vectorHelper.call(this, input, config) as Workflow;\n }\n return scalarHelper.call(this, input, config) as Workflow;\n };\n}\n\n// Event types\nexport type WorkflowEventListeners = {\n changed: (id: unknown) => void;\n reset: () => void;\n error: (error: string) => void;\n start: () => void;\n complete: () => void;\n abort: (error: string) => void;\n /** Fired when a task in the workflow starts streaming */\n stream_start: (taskId: TaskIdType) => void;\n /** Fired for each stream chunk produced by a task in the workflow */\n stream_chunk: (taskId: TaskIdType, event: StreamEvent) => void;\n /** Fired when a task in the workflow finishes streaming */\n stream_end: (taskId: TaskIdType, output: Record<string, any>) => void;\n};\n\nexport type WorkflowEvents = keyof WorkflowEventListeners;\nexport type WorkflowEventListener<Event extends WorkflowEvents> = WorkflowEventListeners[Event];\nexport type WorkflowEventParameters<Event extends WorkflowEvents> = EventParameters<\n WorkflowEventListeners,\n Event\n>;\n\nclass WorkflowTask<I extends DataPorts, O extends DataPorts> extends GraphAsTask<I, O> {\n public static readonly type = \"Workflow\";\n public static readonly compoundMerge = PROPERTY_ARRAY as CompoundMergeStrategy;\n}\n\n/**\n * Class for building and managing a task graph\n * Provides methods for adding tasks, connecting outputs to inputs, and running the task graph\n *\n * When used with a parent workflow (loop builder mode), this class redirects task additions\n * to the iterator task's template graph until an end method (endMap, endBatch, etc.) is called.\n */\nexport class Workflow<\n Input extends DataPorts = DataPorts,\n Output extends DataPorts = DataPorts,\n> implements IWorkflow<Input, Output> {\n /**\n * Creates a new Workflow\n *\n * @param cache - Optional repository for task outputs\n * @param parent - Optional parent workflow (for loop builder mode)\n * @param iteratorTask - Optional iterator task being configured (for loop builder mode)\n */\n constructor(cache?: TaskOutputRepository, parent?: Workflow, iteratorTask?: GraphAsTask) {\n this._outputCache = cache;\n this._parentWorkflow = parent;\n this._iteratorTask = iteratorTask;\n this._graph = new TaskGraph({ outputCache: this._outputCache });\n\n if (!parent) {\n this._onChanged = this._onChanged.bind(this);\n this.setupEvents();\n }\n }\n\n // Private properties\n private _graph: TaskGraph;\n private _dataFlows: Dataflow[] = [];\n private _error: string = \"\";\n private _outputCache?: TaskOutputRepository;\n\n // Abort controller for cancelling task execution\n private _abortController?: AbortController;\n\n // Loop builder properties\n private readonly _parentWorkflow?: Workflow;\n private readonly _iteratorTask?: GraphAsTask;\n private _pendingLoopConnect?: {\n parent: ITask;\n iteratorTask: ITask;\n };\n\n public outputCache(): TaskOutputRepository | undefined {\n return this._outputCache;\n }\n\n /**\n * Whether this workflow is in loop builder mode.\n * When true, tasks are added to the template graph for an iterator task.\n */\n public get isLoopBuilder(): boolean {\n return this._parentWorkflow !== undefined;\n }\n\n /**\n * Event emitter for task graph events\n */\n public readonly events = new EventEmitter<WorkflowEventListeners>();\n\n /**\n * Creates a helper function for adding specific task types to a Workflow\n *\n * @param taskClass - The task class to create a helper for\n * @returns A function that adds the specified task type to a Workflow\n */\n public static createWorkflow<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig = TaskConfig,\n >(taskClass: ITaskConstructor<I, O, C>): CreateWorkflow<I, O, C> {\n const helper = function (\n this: Workflow<any, any>,\n input: Partial<I> = {},\n config: Partial<C> = {}\n ) {\n this._error = \"\";\n\n const parent = getLastTask(this);\n\n const task = this.addTaskToGraph<I, O, C>(\n taskClass,\n input as I,\n { id: uuid4(), ...config } as C\n );\n\n // Process any pending data flows\n if (this._dataFlows.length > 0) {\n this._dataFlows.forEach((dataflow) => {\n const taskSchema = task.inputSchema();\n if (\n (typeof taskSchema !== \"boolean\" &&\n taskSchema.properties?.[dataflow.targetTaskPortId] === undefined &&\n taskSchema.additionalProperties !== true) ||\n (taskSchema === true && dataflow.targetTaskPortId !== DATAFLOW_ALL_PORTS)\n ) {\n this._error = `Input ${dataflow.targetTaskPortId} not found on task ${task.id}`;\n getLogger().error(this._error);\n return;\n }\n\n dataflow.targetTaskId = task.id;\n this.graph.addDataflow(dataflow);\n });\n\n this._dataFlows = [];\n }\n\n // Auto-connect to parent if needed\n if (parent) {\n // Build the list of earlier tasks (in reverse chronological order)\n const nodes = this._graph.getTasks();\n const parentIndex = nodes.findIndex((n) => n.id === parent.id);\n const earlierTasks: ITask[] = [];\n for (let i = parentIndex - 1; i >= 0; i--) {\n earlierTasks.push(nodes[i]);\n }\n\n const providedInputKeys = new Set(Object.keys(input || {}));\n\n // Ports already connected via pending dataflows (e.g., from .rename())\n // must not be re-matched by auto-connect Strategies 1/2/3.\n const connectedInputKeys = new Set(\n this.graph.getSourceDataflows(task.id).map((df) => df.targetTaskPortId)\n );\n\n const result = Workflow.autoConnect(this.graph, parent, task, {\n providedInputKeys,\n connectedInputKeys,\n earlierTasks,\n });\n\n if (result.error) {\n // In loop builder mode, don't remove the task - allow manual connection\n // In normal mode, remove the task since auto-connect is required\n if (this.isLoopBuilder) {\n this._error = result.error;\n getLogger().warn(this._error);\n } else {\n this._error = result.error + \" Task not added.\";\n getLogger().error(this._error);\n this.graph.removeTask(task.id);\n }\n }\n }\n\n // Update InputTask/OutputTask schemas based on connected dataflows\n if (!this._error) {\n Workflow.updateBoundaryTaskSchemas(this._graph);\n }\n\n // Preserve input type from the start of the chain\n // If this is the first task, set both input and output types\n // Otherwise, only update the output type (input type is preserved from 'this')\n return this as any;\n };\n\n // Copy metadata from the task class\n // @ts-expect-error - using internals\n helper.type = taskClass.runtype ?? taskClass.type;\n helper.category = taskClass.category;\n helper.inputSchema = taskClass.inputSchema;\n helper.outputSchema = taskClass.outputSchema;\n helper.cacheable = taskClass.cacheable;\n helper.workflowCreate = true;\n\n return helper as CreateWorkflow<I, O, C>;\n }\n\n /**\n * Gets the current task graph\n */\n public get graph(): TaskGraph {\n return this._graph;\n }\n\n /**\n * Sets a new task graph\n */\n public set graph(value: TaskGraph) {\n this._dataFlows = [];\n this._error = \"\";\n this.clearEvents();\n this._graph = value;\n this.setupEvents();\n this.events.emit(\"reset\");\n }\n\n /**\n * Gets the current error message\n */\n public get error(): string {\n return this._error;\n }\n\n /**\n * Event subscription methods\n */\n public on<Event extends WorkflowEvents>(name: Event, fn: WorkflowEventListener<Event>): void {\n this.events.on(name, fn);\n }\n\n public off<Event extends WorkflowEvents>(name: Event, fn: WorkflowEventListener<Event>): void {\n this.events.off(name, fn);\n }\n\n public once<Event extends WorkflowEvents>(name: Event, fn: WorkflowEventListener<Event>): void {\n this.events.once(name, fn);\n }\n\n public waitOn<Event extends WorkflowEvents>(\n name: Event\n ): Promise<WorkflowEventParameters<Event>> {\n return this.events.waitOn(name) as Promise<WorkflowEventParameters<Event>>;\n }\n\n /**\n * Runs the task graph\n *\n * @param input - The input to the task graph\n * @param config - Optional configuration for the workflow run\n * @returns The output of the task graph\n */\n public async run(\n input: Partial<Input> = {},\n config?: WorkflowRunConfig\n ): Promise<PropertyArrayGraphResult<Output>> {\n // In loop builder mode, finalize template and delegate to parent\n if (this.isLoopBuilder) {\n this.finalizeTemplate();\n // Run deferred auto-connect now that template graph is populated\n if (this._pendingLoopConnect) {\n this._parentWorkflow!.autoConnectLoopTask(this._pendingLoopConnect);\n this._pendingLoopConnect = undefined;\n }\n return this._parentWorkflow!.run(input as any, config) as Promise<\n PropertyArrayGraphResult<Output>\n >;\n }\n\n this.events.emit(\"start\");\n this._abortController = new AbortController();\n\n // Subscribe to graph-level streaming events and forward to workflow events\n const unsubStreaming = this.graph.subscribeToTaskStreaming({\n onStreamStart: (taskId) => this.events.emit(\"stream_start\", taskId),\n onStreamChunk: (taskId, event) => this.events.emit(\"stream_chunk\", taskId, event),\n onStreamEnd: (taskId, output) => this.events.emit(\"stream_end\", taskId, output),\n });\n\n try {\n const output = await this.graph.run<Output>(input, {\n parentSignal: this._abortController.signal,\n outputCache: this._outputCache,\n registry: config?.registry,\n });\n const results = this.graph.mergeExecuteOutputsToRunOutput<Output, typeof PROPERTY_ARRAY>(\n output,\n PROPERTY_ARRAY\n );\n this.events.emit(\"complete\");\n return results;\n } catch (error) {\n this.events.emit(\"error\", String(error));\n throw error;\n } finally {\n unsubStreaming();\n this._abortController = undefined;\n }\n }\n\n /**\n * Aborts the running task graph\n */\n public async abort(): Promise<void> {\n // In loop builder mode, delegate to parent\n if (this._parentWorkflow) {\n return this._parentWorkflow.abort();\n }\n this._abortController?.abort();\n }\n\n /**\n * Removes the last task from the task graph\n *\n * @returns The current task graph workflow\n */\n public pop(): Workflow {\n this._error = \"\";\n const nodes = this._graph.getTasks();\n\n if (nodes.length === 0) {\n this._error = \"No tasks to remove\";\n getLogger().error(this._error);\n return this;\n }\n\n const lastNode = nodes[nodes.length - 1];\n this._graph.removeTask(lastNode.id);\n return this;\n }\n\n /**\n * Converts the task graph to JSON\n *\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns The task graph as JSON\n */\n public toJSON(options: TaskGraphJsonOptions = { withBoundaryNodes: true }): TaskGraphJson {\n return this._graph.toJSON(options);\n }\n\n /**\n * Converts the task graph to dependency JSON\n *\n * @param options Options controlling serialization (e.g., boundary nodes)\n * @returns The task graph as dependency JSON\n */\n public toDependencyJSON(\n options: TaskGraphJsonOptions = { withBoundaryNodes: true }\n ): JsonTaskItem[] {\n return this._graph.toDependencyJSON(options);\n }\n\n // Replace both the instance and static pipe methods with properly typed versions\n // Pipe method overloads\n public pipe<A extends DataPorts, B extends DataPorts>(fn1: Taskish<A, B>): IWorkflow<A, B>;\n public pipe<A extends DataPorts, B extends DataPorts, C extends DataPorts>(\n fn1: Taskish<A, B>,\n fn2: Taskish<B, C>\n ): IWorkflow<A, C>;\n public pipe<A extends DataPorts, B extends DataPorts, C extends DataPorts, D extends DataPorts>(\n fn1: Taskish<A, B>,\n fn2: Taskish<B, C>,\n fn3: Taskish<C, D>\n ): IWorkflow<A, D>;\n public pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n >(\n fn1: Taskish<A, B>,\n fn2: Taskish<B, C>,\n fn3: Taskish<C, D>,\n fn4: Taskish<D, E>\n ): IWorkflow<A, E>;\n public pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n F extends DataPorts,\n >(\n fn1: Taskish<A, B>,\n fn2: Taskish<B, C>,\n fn3: Taskish<C, D>,\n fn4: Taskish<D, E>,\n fn5: Taskish<E, F>\n ): IWorkflow<A, F>;\n public pipe(...args: Taskish<DataPorts, DataPorts>[]): IWorkflow {\n return pipe(args as any, this);\n }\n\n // Static pipe method overloads\n public static pipe<A extends DataPorts, B extends DataPorts>(\n fn1: PipeFunction<A, B> | ITask<A, B>\n ): IWorkflow;\n public static pipe<A extends DataPorts, B extends DataPorts, C extends DataPorts>(\n fn1: PipeFunction<A, B> | ITask<A, B>,\n fn2: PipeFunction<B, C> | ITask<B, C>\n ): IWorkflow;\n public static pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n >(\n fn1: PipeFunction<A, B> | ITask<A, B>,\n fn2: PipeFunction<B, C> | ITask<B, C>,\n fn3: PipeFunction<C, D> | ITask<C, D>\n ): IWorkflow;\n public static pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n >(\n fn1: PipeFunction<A, B> | ITask<A, B>,\n fn2: PipeFunction<B, C> | ITask<B, C>,\n fn3: PipeFunction<C, D> | ITask<C, D>,\n fn4: PipeFunction<D, E> | ITask<D, E>\n ): IWorkflow;\n public static pipe<\n A extends DataPorts,\n B extends DataPorts,\n C extends DataPorts,\n D extends DataPorts,\n E extends DataPorts,\n F extends DataPorts,\n >(\n fn1: PipeFunction<A, B> | ITask<A, B>,\n fn2: PipeFunction<B, C> | ITask<B, C>,\n fn3: PipeFunction<C, D> | ITask<C, D>,\n fn4: PipeFunction<D, E> | ITask<D, E>,\n fn5: PipeFunction<E, F> | ITask<E, F>\n ): IWorkflow;\n public static pipe(...args: (PipeFunction | ITask)[]): IWorkflow {\n return pipe(args as any, new Workflow());\n }\n\n public parallel(\n args: (PipeFunction<any, any> | Task)[],\n mergeFn?: CompoundMergeStrategy\n ): IWorkflow {\n return parallel(args, mergeFn ?? PROPERTY_ARRAY, this);\n }\n\n public static parallel(\n args: (PipeFunction<any, any> | ITask)[],\n mergeFn?: CompoundMergeStrategy\n ): IWorkflow {\n return parallel(args, mergeFn ?? PROPERTY_ARRAY, new Workflow());\n }\n\n /**\n * Renames an output of a task to a new target input\n *\n * @param source - The id of the output to rename\n * @param target - The id of the input to rename to\n * @param index - The index of the task to rename the output of, defaults to the last task\n * @returns The current task graph workflow\n */\n public rename(source: string, target: string, index: number = -1): Workflow {\n this._error = \"\";\n\n const nodes = this._graph.getTasks();\n if (-index > nodes.length) {\n const errorMsg = `Back index greater than number of tasks`;\n this._error = errorMsg;\n getLogger().error(this._error);\n throw new WorkflowError(errorMsg);\n }\n\n const lastNode = nodes[nodes.length + index];\n const outputSchema = lastNode.outputSchema();\n\n // Handle boolean schemas\n if (typeof outputSchema === \"boolean\") {\n if (outputSchema === false && source !== DATAFLOW_ALL_PORTS) {\n const errorMsg = `Task ${lastNode.id} has schema 'false' and outputs nothing`;\n this._error = errorMsg;\n getLogger().error(this._error);\n throw new WorkflowError(errorMsg);\n }\n // If outputSchema is true, we skip validation as it outputs everything\n } else if (!(outputSchema.properties as any)?.[source] && source !== DATAFLOW_ALL_PORTS) {\n const errorMsg = `Output ${source} not found on task ${lastNode.id}`;\n this._error = errorMsg;\n getLogger().error(this._error);\n throw new WorkflowError(errorMsg);\n }\n\n this._dataFlows.push(new Dataflow(lastNode.id, source, undefined, target));\n return this;\n }\n\n /**\n * Adds an error handler task that receives errors from the previous task.\n *\n * When the previous task fails, instead of failing the entire workflow, the\n * error is routed to the handler task via the `[error]` output port. The\n * handler task receives `{ error, errorType }` as input and can produce\n * output that flows to subsequent tasks in the pipeline.\n *\n * @param handler - A task, task class, or pipe function to handle the error\n * @returns The current workflow for chaining\n */\n public onError(handler: Taskish): Workflow {\n this._error = \"\";\n\n const parent = getLastTask(this);\n if (!parent) {\n this._error = \"onError() requires a preceding task in the workflow\";\n getLogger().error(this._error);\n throw new WorkflowError(this._error);\n }\n\n const handlerTask = ensureTask(handler);\n this.graph.addTask(handlerTask);\n\n // Connect the previous task's error output port to the handler's all-ports input\n const dataflow = new Dataflow(\n parent.id,\n DATAFLOW_ERROR_PORT,\n handlerTask.id,\n DATAFLOW_ALL_PORTS\n );\n this.graph.addDataflow(dataflow);\n this.events.emit(\"changed\", handlerTask.id);\n\n return this;\n }\n\n toTaskGraph(): TaskGraph {\n return this._graph;\n }\n\n toTask(): GraphAsTask {\n const task = new WorkflowTask();\n task.subGraph = this.toTaskGraph();\n return task;\n }\n\n /**\n * Resets the task graph workflow to its initial state\n *\n * @returns The current task graph workflow\n */\n public reset(): Workflow {\n // In loop builder mode, reset is not supported\n if (this._parentWorkflow) {\n throw new WorkflowError(\"Cannot reset a loop workflow. Call reset() on the parent workflow.\");\n }\n\n this.clearEvents();\n this._graph = new TaskGraph({\n outputCache: this._outputCache,\n });\n this._dataFlows = [];\n this._error = \"\";\n this.setupEvents();\n this.events.emit(\"changed\", undefined);\n this.events.emit(\"reset\");\n return this;\n }\n\n /**\n * Sets up event listeners for the task graph\n */\n private setupEvents(): void {\n this._graph.on(\"task_added\", this._onChanged);\n this._graph.on(\"task_replaced\", this._onChanged);\n this._graph.on(\"task_removed\", this._onChanged);\n this._graph.on(\"dataflow_added\", this._onChanged);\n this._graph.on(\"dataflow_replaced\", this._onChanged);\n this._graph.on(\"dataflow_removed\", this._onChanged);\n }\n\n /**\n * Clears event listeners for the task graph\n */\n private clearEvents(): void {\n this._graph.off(\"task_added\", this._onChanged);\n this._graph.off(\"task_replaced\", this._onChanged);\n this._graph.off(\"task_removed\", this._onChanged);\n this._graph.off(\"dataflow_added\", this._onChanged);\n this._graph.off(\"dataflow_replaced\", this._onChanged);\n this._graph.off(\"dataflow_removed\", this._onChanged);\n }\n\n /**\n * Handles changes to the task graph\n */\n private _onChanged(id: unknown): void {\n this.events.emit(\"changed\", id);\n }\n\n /**\n * Connects outputs to inputs between tasks\n */\n public connect(\n sourceTaskId: unknown,\n sourceTaskPortId: string,\n targetTaskId: unknown,\n targetTaskPortId: string\n ): Workflow {\n const sourceTask = this.graph.getTask(sourceTaskId);\n const targetTask = this.graph.getTask(targetTaskId);\n\n if (!sourceTask || !targetTask) {\n throw new WorkflowError(\"Source or target task not found\");\n }\n\n const sourceSchema = sourceTask.outputSchema();\n const targetSchema = targetTask.inputSchema();\n\n // Handle boolean schemas\n if (typeof sourceSchema === \"boolean\") {\n if (sourceSchema === false) {\n throw new WorkflowError(`Source task has schema 'false' and outputs nothing`);\n }\n // If sourceSchema is true, we skip validation as it accepts everything\n } else if (!sourceSchema.properties?.[sourceTaskPortId]) {\n throw new WorkflowError(`Output ${sourceTaskPortId} not found on source task`);\n }\n\n if (typeof targetSchema === \"boolean\") {\n if (targetSchema === false) {\n throw new WorkflowError(`Target task has schema 'false' and accepts no inputs`);\n }\n if (targetSchema === true) {\n // do nothing, we allow additional properties\n }\n } else if (targetSchema.additionalProperties === true) {\n // do nothing, we allow additional properties\n } else if (!targetSchema.properties?.[targetTaskPortId]) {\n throw new WorkflowError(`Input ${targetTaskPortId} not found on target task`);\n }\n\n const dataflow = new Dataflow(sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId);\n this.graph.addDataflow(dataflow);\n return this;\n }\n\n public addTaskToGraph<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig = TaskConfig,\n >(taskClass: ITaskConstructor<I, O, C>, input: I, config: C): ITask<I, O, C> {\n const task = new taskClass(input, config);\n const id = this.graph.addTask(task);\n this.events.emit(\"changed\", id);\n return task;\n }\n\n /**\n * Adds a task to the workflow using the same logic as createWorkflow() helpers.\n * Auto-generates an ID, processes pending dataflows, and auto-connects to previous tasks.\n *\n * @param taskClass - The task class to instantiate and add\n * @param input - Optional input values for the task\n * @param config - Optional configuration (id will be auto-generated if not provided)\n * @returns The workflow for chaining\n */\n public addTask<I extends DataPorts, O extends DataPorts, C extends TaskConfig = TaskConfig>(\n taskClass: ITaskConstructor<I, O, C>,\n input?: Partial<I>,\n config?: Partial<C>\n ): Workflow<Input, Output> {\n const helper = Workflow.createWorkflow<I, O, C>(taskClass);\n return helper.call(this, input, config) as Workflow<Input, Output>;\n }\n\n // ========================================================================\n // Loop Builder Methods\n // ========================================================================\n\n /**\n * Adds an iterator/loop task to the workflow using the same auto-connect logic\n * as regular task addition (createWorkflow), then returns a new loop builder Workflow.\n *\n * @param taskClass - The iterator task class (MapTask, ReduceTask, etc.)\n * @param config - Optional configuration for the iterator task\n * @returns A new loop builder Workflow for adding tasks inside the loop\n */\n public addLoopTask<I extends DataPorts, O extends DataPorts, C extends TaskConfig = TaskConfig>(\n taskClass: ITaskConstructor<I, O, C>,\n config: Partial<C> = {}\n ): Workflow<I, O> {\n this._error = \"\";\n\n const parent = getLastTask(this);\n\n const task = this.addTaskToGraph<I, O, C>(taskClass, {} as I, { id: uuid4(), ...config } as C);\n\n // Process any pending data flows (same as createWorkflow)\n if (this._dataFlows.length > 0) {\n this._dataFlows.forEach((dataflow) => {\n const taskSchema = task.inputSchema();\n if (\n (typeof taskSchema !== \"boolean\" &&\n taskSchema.properties?.[dataflow.targetTaskPortId] === undefined &&\n taskSchema.additionalProperties !== true) ||\n (taskSchema === true && dataflow.targetTaskPortId !== DATAFLOW_ALL_PORTS)\n ) {\n this._error = `Input ${dataflow.targetTaskPortId} not found on task ${task.id}`;\n getLogger().error(this._error);\n return;\n }\n\n dataflow.targetTaskId = task.id;\n this.graph.addDataflow(dataflow);\n });\n\n this._dataFlows = [];\n }\n\n // Defer auto-connect until endMap/endReduce/endWhile, when the iterator task\n // has its template graph populated and its dynamic inputSchema is available.\n // Store the pending context on the loop builder workflow.\n const loopBuilder = new Workflow(\n this.outputCache(),\n this,\n task as unknown as GraphAsTask\n ) as unknown as Workflow<I, O>;\n if (parent) {\n loopBuilder._pendingLoopConnect = { parent, iteratorTask: task };\n }\n return loopBuilder;\n }\n\n /**\n * Runs deferred auto-connect for a loop task on this (parent) workflow's graph.\n * Called after finalizeTemplate() populates the iterator task's template graph,\n * so that the iterator task's dynamic inputSchema() is available for matching.\n */\n public autoConnectLoopTask(pending?: { parent: ITask; iteratorTask: ITask }): void {\n if (!pending) return;\n const { parent, iteratorTask } = pending;\n\n if (this.graph.getTargetDataflows(parent.id).length === 0) {\n const nodes = this._graph.getTasks();\n const parentIndex = nodes.findIndex((n) => n.id === parent.id);\n const earlierTasks: ITask[] = [];\n for (let i = parentIndex - 1; i >= 0; i--) {\n earlierTasks.push(nodes[i]);\n }\n\n const result = Workflow.autoConnect(this.graph, parent, iteratorTask, {\n earlierTasks,\n });\n\n if (result.error) {\n this._error = result.error + \" Task not added.\";\n getLogger().error(this._error);\n this.graph.removeTask(iteratorTask.id);\n }\n }\n }\n\n /**\n * Updates InputTask/OutputTask config schemas based on their connected dataflows.\n * InputTask schema reflects its outgoing dataflow targets' input schemas.\n * OutputTask schema reflects its incoming dataflow sources' output schemas.\n */\n private static updateBoundaryTaskSchemas(graph: TaskGraph): void {\n const tasks = graph.getTasks();\n\n for (const task of tasks) {\n if (task.type === \"InputTask\") {\n // If the schema is marked as fully manual (x-ui-manual at schema level),\n // skip edge-based regeneration — the user explicitly defined this schema.\n const existingConfig = (task as any).config;\n const existingSchema = existingConfig?.inputSchema ?? existingConfig?.outputSchema;\n if (\n existingSchema &&\n typeof existingSchema === \"object\" &&\n (existingSchema as Record<string, unknown>)[\"x-ui-manual\"] === true\n ) {\n continue;\n }\n\n const outgoing = graph.getTargetDataflows(task.id);\n if (outgoing.length === 0) continue;\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const df of outgoing) {\n const targetTask = graph.getTask(df.targetTaskId);\n if (!targetTask) continue;\n const targetSchema = targetTask.inputSchema();\n if (typeof targetSchema === \"boolean\") continue;\n const prop = (targetSchema.properties as any)?.[df.targetTaskPortId];\n if (prop && typeof prop !== \"boolean\") {\n properties[df.sourceTaskPortId] = prop;\n if (targetSchema.required?.includes(df.targetTaskPortId)) {\n if (!required.includes(df.sourceTaskPortId)) {\n required.push(df.sourceTaskPortId);\n }\n }\n }\n }\n\n const schema = {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties: false,\n } as DataPortSchema;\n\n (task as any).config = {\n ...(task as any).config,\n inputSchema: schema,\n outputSchema: schema,\n };\n }\n\n if (task.type === \"OutputTask\") {\n const incoming = graph.getSourceDataflows(task.id);\n if (incoming.length === 0) continue;\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const df of incoming) {\n const sourceTask = graph.getTask(df.sourceTaskId);\n if (!sourceTask) continue;\n const sourceSchema = sourceTask.outputSchema();\n if (typeof sourceSchema === \"boolean\") continue;\n const prop = (sourceSchema.properties as any)?.[df.sourceTaskPortId];\n if (prop && typeof prop !== \"boolean\") {\n properties[df.targetTaskPortId] = prop;\n if (\n sourceSchema.required?.includes(df.sourceTaskPortId) &&\n !required.includes(df.targetTaskPortId)\n ) {\n required.push(df.targetTaskPortId);\n }\n }\n }\n\n const schema = {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties: false,\n } as DataPortSchema;\n\n (task as any).config = {\n ...(task as any).config,\n inputSchema: schema,\n outputSchema: schema,\n };\n }\n }\n }\n\n /**\n * Options for auto-connect operation.\n */\n public static readonly AutoConnectOptions: unique symbol = Symbol(\"AutoConnectOptions\");\n\n /**\n * Auto-connects two tasks based on their schemas.\n * Uses multiple matching strategies:\n * 1. Match by type AND port name (highest priority)\n * 2. Match by specific type only (format, $id) for unmatched ports\n * 3. Look back through earlier tasks for unmatched required inputs\n *\n * @param graph - The task graph to add dataflows to\n * @param sourceTask - The source task to connect from\n * @param targetTask - The target task to connect to\n * @param options - Optional configuration for the auto-connect operation\n * @returns Result containing matches made, any errors, and unmatched required inputs\n */\n public static autoConnect(\n graph: TaskGraph,\n sourceTask: ITask,\n targetTask: ITask,\n options?: {\n /** Keys of inputs that are already provided and don't need connection */\n readonly providedInputKeys?: Set<string>;\n /** Keys of inputs that are already connected via dataflow (e.g., from rename) and must not be re-matched */\n readonly connectedInputKeys?: Set<string>;\n /** Earlier tasks to search for unmatched required inputs (in reverse chronological order) */\n readonly earlierTasks?: readonly ITask[];\n }\n ): {\n readonly matches: Map<string, string>;\n readonly error?: string;\n readonly unmatchedRequired: readonly string[];\n } {\n const matches = new Map<string, string>();\n const sourceSchema = sourceTask.outputSchema();\n const targetSchema = targetTask.inputSchema();\n const providedInputKeys = options?.providedInputKeys ?? new Set<string>();\n const connectedInputKeys = options?.connectedInputKeys ?? new Set<string>();\n const earlierTasks = options?.earlierTasks ?? [];\n\n /**\n * Extracts specific type identifiers (format, $id) from a schema,\n * looking inside oneOf/anyOf wrappers if needed.\n */\n const getSpecificTypeIdentifiers = (\n schema: JsonSchema\n ): { formats: Set<string>; ids: Set<string> } => {\n const formats = new Set<string>();\n const ids = new Set<string>();\n\n if (typeof schema === \"boolean\") {\n return { formats, ids };\n }\n\n // Helper to extract from a single schema object\n const extractFromSchema = (s: any): void => {\n if (!s || typeof s !== \"object\" || Array.isArray(s)) return;\n if (s.format) formats.add(s.format);\n if (s.$id) ids.add(s.$id);\n };\n\n // Check top-level format/$id\n extractFromSchema(schema);\n\n // Check inside oneOf/anyOf\n const checkUnion = (schemas: JsonSchema[] | undefined): void => {\n if (!schemas) return;\n for (const s of schemas) {\n if (typeof s === \"boolean\") continue;\n extractFromSchema(s);\n // Also check nested items for array types\n if (s.items && typeof s.items === \"object\" && !Array.isArray(s.items)) {\n extractFromSchema(s.items);\n }\n }\n };\n\n checkUnion(schema.oneOf as JsonSchema[] | undefined);\n checkUnion(schema.anyOf as JsonSchema[] | undefined);\n\n // Check items for array types (single schema, not tuple)\n if (schema.items && typeof schema.items === \"object\" && !Array.isArray(schema.items)) {\n extractFromSchema(schema.items);\n }\n\n return { formats, ids };\n };\n\n /**\n * Checks if output schema type is compatible with input schema type.\n * Handles $id matching, format matching, and oneOf/anyOf unions.\n */\n const isTypeCompatible = (\n fromPortOutputSchema: JsonSchema,\n toPortInputSchema: JsonSchema,\n requireSpecificType: boolean = false\n ): boolean => {\n if (typeof fromPortOutputSchema === \"boolean\" || typeof toPortInputSchema === \"boolean\") {\n return fromPortOutputSchema === true && toPortInputSchema === true;\n }\n\n // Extract specific type identifiers from both schemas\n const outputIds = getSpecificTypeIdentifiers(fromPortOutputSchema);\n const inputIds = getSpecificTypeIdentifiers(toPortInputSchema);\n\n // Check if any format matches\n for (const format of outputIds.formats) {\n if (inputIds.formats.has(format)) {\n return true;\n }\n }\n\n // Check if any $id matches\n for (const id of outputIds.ids) {\n if (inputIds.ids.has(id)) {\n return true;\n }\n }\n\n // For type-only fallback, we require specific types (not primitives)\n // to avoid over-matching strings, numbers, etc.\n if (requireSpecificType) {\n return false;\n }\n\n // $id both blank at top level - check type directly (only for name-matched ports)\n const idTypeBlank =\n fromPortOutputSchema.$id === undefined && toPortInputSchema.$id === undefined;\n if (!idTypeBlank) return false;\n\n // Direct type match (for primitives, only when names also match)\n if (fromPortOutputSchema.type === toPortInputSchema.type) return true;\n\n // Check if output type matches any option in oneOf/anyOf\n const matchesOneOf =\n toPortInputSchema.oneOf?.some((schema: any) => {\n if (typeof schema === \"boolean\") return schema;\n return schema.type === fromPortOutputSchema.type;\n }) ?? false;\n\n const matchesAnyOf =\n toPortInputSchema.anyOf?.some((schema: any) => {\n if (typeof schema === \"boolean\") return schema;\n return schema.type === fromPortOutputSchema.type;\n }) ?? false;\n\n return matchesOneOf || matchesAnyOf;\n };\n\n const makeMatch = (\n fromSchema: JsonSchema,\n toSchema: JsonSchema,\n fromTaskId: unknown,\n toTaskId: unknown,\n comparator: (\n [fromOutputPortId, fromPortOutputSchema]: [string, JsonSchema],\n [toInputPortId, toPortInputSchema]: [string, JsonSchema]\n ) => boolean\n ): void => {\n if (typeof fromSchema === \"object\") {\n if (\n toSchema === true ||\n (typeof toSchema === \"object\" && toSchema.additionalProperties === true)\n ) {\n for (const fromOutputPortId of Object.keys(fromSchema.properties || {})) {\n if (matches.has(fromOutputPortId)) continue;\n matches.set(fromOutputPortId, fromOutputPortId);\n graph.addDataflow(\n new Dataflow(fromTaskId, fromOutputPortId, toTaskId, fromOutputPortId)\n );\n }\n return;\n }\n }\n // When source is InputTask/OutputTask (pass-through with additionalProperties),\n // create same-name dataflows for all target input ports\n if (\n typeof fromSchema === \"object\" &&\n fromSchema.additionalProperties === true &&\n typeof toSchema === \"object\" &&\n (sourceTask.type === \"InputTask\" || sourceTask.type === \"OutputTask\")\n ) {\n for (const toInputPortId of Object.keys(toSchema.properties || {})) {\n if (matches.has(toInputPortId)) continue;\n if (connectedInputKeys.has(toInputPortId)) continue;\n matches.set(toInputPortId, toInputPortId);\n graph.addDataflow(new Dataflow(fromTaskId, toInputPortId, toTaskId, toInputPortId));\n }\n return;\n }\n // If either schema is true or false, skip auto-matching\n // as we cannot determine the appropriate connections\n if (typeof fromSchema === \"boolean\" || typeof toSchema === \"boolean\") {\n return;\n }\n\n // Iterate target-first to collect candidates per target port,\n // then apply x-stream tiebreaker when multiple source ports match.\n for (const [toInputPortId, toPortInputSchema] of Object.entries(toSchema.properties || {})) {\n if (matches.has(toInputPortId)) continue;\n // Skip ports already connected via dataflow (e.g., from rename)\n if (connectedInputKeys.has(toInputPortId)) continue;\n\n const candidates: string[] = [];\n for (const [fromOutputPortId, fromPortOutputSchema] of Object.entries(\n fromSchema.properties || {}\n )) {\n if (\n comparator([fromOutputPortId, fromPortOutputSchema], [toInputPortId, toPortInputSchema])\n ) {\n candidates.push(fromOutputPortId);\n }\n }\n\n if (candidates.length === 0) continue;\n\n // Tiebreaker: when multiple source ports match, prefer the one\n // whose x-stream setting matches the target port's x-stream.\n let winner = candidates[0];\n if (candidates.length > 1) {\n const targetStreamMode = getPortStreamMode(toSchema, toInputPortId);\n const streamMatch = candidates.find(\n (portId) => getPortStreamMode(fromSchema, portId) === targetStreamMode\n );\n if (streamMatch) winner = streamMatch;\n }\n\n matches.set(toInputPortId, winner);\n graph.addDataflow(new Dataflow(fromTaskId, winner, toTaskId, toInputPortId));\n }\n };\n\n // Strategy 1: Match by type AND port name (highest priority)\n makeMatch(\n sourceSchema,\n targetSchema,\n sourceTask.id,\n targetTask.id,\n ([fromOutputPortId, fromPortOutputSchema], [toInputPortId, toPortInputSchema]) => {\n const outputPortIdMatch = fromOutputPortId === toInputPortId;\n const outputPortIdOutputInput = fromOutputPortId === \"output\" && toInputPortId === \"input\";\n const portIdsCompatible = outputPortIdMatch || outputPortIdOutputInput;\n\n return (\n portIdsCompatible && isTypeCompatible(fromPortOutputSchema, toPortInputSchema, false)\n );\n }\n );\n\n // Strategy 2: Match by specific type only (fallback for unmatched ports)\n // Only matches specific types like TypedArray (with format), not primitives\n // This allows connecting ports with different names but compatible specific types\n makeMatch(\n sourceSchema,\n targetSchema,\n sourceTask.id,\n targetTask.id,\n ([_fromOutputPortId, fromPortOutputSchema], [_toInputPortId, toPortInputSchema]) => {\n return isTypeCompatible(fromPortOutputSchema, toPortInputSchema, true);\n }\n );\n\n // Strategy 3: Look back through earlier tasks for unmatched required inputs\n // Extract required inputs from target schema\n const requiredInputs = new Set<string>(\n typeof targetSchema === \"object\" ? (targetSchema.required as string[]) || [] : []\n );\n\n // Filter out required inputs that are already provided in the input parameter\n // or already connected via dataflow (e.g., from rename)\n const requiredInputsNeedingConnection = [...requiredInputs].filter(\n (r) => !providedInputKeys.has(r) && !connectedInputKeys.has(r)\n );\n\n // Compute unmatched required inputs (that aren't already provided)\n let unmatchedRequired = requiredInputsNeedingConnection.filter((r) => !matches.has(r));\n\n // If there are unmatched required inputs, iterate through earlier tasks\n if (unmatchedRequired.length > 0 && earlierTasks.length > 0) {\n for (let i = 0; i < earlierTasks.length && unmatchedRequired.length > 0; i++) {\n const earlierTask = earlierTasks[i];\n const earlierOutputSchema = earlierTask.outputSchema();\n\n // When earlier task is InputTask (pass-through), satisfy unmatched\n // required inputs. If the InputTask has an explicitly defined schema\n // (x-ui-manual), only connect ports that exist in its schema.\n // Otherwise, treat it as a universal provider.\n if (earlierTask.type === \"InputTask\") {\n const inputConfig = (earlierTask as any).config;\n const inputSchema = inputConfig?.inputSchema ?? inputConfig?.outputSchema;\n const isManualSchema =\n inputSchema &&\n typeof inputSchema === \"object\" &&\n (inputSchema as Record<string, unknown>)[\"x-ui-manual\"] === true;\n const inputProperties =\n isManualSchema &&\n inputSchema &&\n typeof inputSchema === \"object\" &&\n \"properties\" in inputSchema &&\n inputSchema.properties &&\n typeof inputSchema.properties === \"object\"\n ? new Set(Object.keys(inputSchema.properties as Record<string, unknown>))\n : undefined;\n\n for (const requiredInputId of [...unmatchedRequired]) {\n if (matches.has(requiredInputId)) continue;\n // If schema is manual, only connect ports that exist in the explicit schema\n if (inputProperties && !inputProperties.has(requiredInputId)) continue;\n matches.set(requiredInputId, requiredInputId);\n graph.addDataflow(\n new Dataflow(earlierTask.id, requiredInputId, targetTask.id, requiredInputId)\n );\n }\n unmatchedRequired = unmatchedRequired.filter((r) => !matches.has(r));\n continue;\n }\n\n // Helper function to match from an earlier task (only for unmatched required inputs)\n const makeMatchFromEarlier = (\n comparator: (\n [fromOutputPortId, fromPortOutputSchema]: [string, JsonSchema],\n [toInputPortId, toPortInputSchema]: [string, JsonSchema]\n ) => boolean\n ): void => {\n if (typeof earlierOutputSchema === \"boolean\" || typeof targetSchema === \"boolean\") {\n return;\n }\n\n for (const [fromOutputPortId, fromPortOutputSchema] of Object.entries(\n earlierOutputSchema.properties || {}\n )) {\n for (const requiredInputId of unmatchedRequired) {\n const toPortInputSchema = (targetSchema.properties as any)?.[requiredInputId];\n if (\n !matches.has(requiredInputId) &&\n toPortInputSchema &&\n comparator(\n [fromOutputPortId, fromPortOutputSchema],\n [requiredInputId, toPortInputSchema]\n )\n ) {\n matches.set(requiredInputId, fromOutputPortId);\n graph.addDataflow(\n new Dataflow(earlierTask.id, fromOutputPortId, targetTask.id, requiredInputId)\n );\n }\n }\n }\n };\n\n // Try both matching strategies for earlier tasks\n // Strategy 1: Match by type AND port name\n makeMatchFromEarlier(\n ([fromOutputPortId, fromPortOutputSchema], [toInputPortId, toPortInputSchema]) => {\n const outputPortIdMatch = fromOutputPortId === toInputPortId;\n const outputPortIdOutputInput =\n fromOutputPortId === \"output\" && toInputPortId === \"input\";\n const portIdsCompatible = outputPortIdMatch || outputPortIdOutputInput;\n\n return (\n portIdsCompatible && isTypeCompatible(fromPortOutputSchema, toPortInputSchema, false)\n );\n }\n );\n\n // Strategy 2: Match by specific type only\n makeMatchFromEarlier(\n ([_fromOutputPortId, fromPortOutputSchema], [_toInputPortId, toPortInputSchema]) => {\n return isTypeCompatible(fromPortOutputSchema, toPortInputSchema, true);\n }\n );\n\n // Update unmatched required inputs\n unmatchedRequired = unmatchedRequired.filter((r) => !matches.has(r));\n }\n }\n\n // Determine if there's an error\n const stillUnmatchedRequired = requiredInputsNeedingConnection.filter((r) => !matches.has(r));\n\n if (stillUnmatchedRequired.length > 0) {\n return {\n matches,\n error:\n `Could not find matches for required inputs [${stillUnmatchedRequired.join(\", \")}] of ${targetTask.type}. ` +\n `Attempted to match from ${sourceTask.type} and earlier tasks.`,\n unmatchedRequired: stillUnmatchedRequired,\n };\n }\n\n if (matches.size === 0 && requiredInputsNeedingConnection.length === 0) {\n // No matches were made AND no required inputs need connection\n // This happens in several cases:\n // 1. Task has required inputs, but they were all provided as parameters\n // 2. Task has no required inputs (all optional)\n // 3. Task is already connected via other means (rename, manual connect)\n\n // If the target already has incoming connections (from rename, etc.),\n // consider it already connected and allow the task\n const existingTargetConnections = graph.getSourceDataflows(targetTask.id);\n if (existingTargetConnections.length > 0) {\n return { matches, unmatchedRequired: [] };\n }\n\n // If task has required inputs that were all provided as parameters, allow the task\n const hasRequiredInputs = requiredInputs.size > 0;\n const allRequiredInputsProvided =\n hasRequiredInputs && [...requiredInputs].every((r) => providedInputKeys.has(r));\n\n // If no required inputs (all optional), check if there are defaults\n const hasInputsWithDefaults =\n typeof targetSchema === \"object\" &&\n targetSchema.properties &&\n Object.values(targetSchema.properties).some(\n (prop: any) => prop && typeof prop === \"object\" && \"default\" in prop\n );\n\n // Allow if:\n // - All required inputs were provided as parameters, OR\n // - No required inputs and task has defaults\n // Otherwise fail (no required inputs, no defaults, no matches)\n if (!allRequiredInputsProvided && !hasInputsWithDefaults) {\n return {\n matches,\n error:\n `Could not find a match between the outputs of ${sourceTask.type} and the inputs of ${targetTask.type}. ` +\n `You may need to connect the outputs to the inputs via connect() manually.`,\n unmatchedRequired: [],\n };\n }\n }\n\n return {\n matches,\n unmatchedRequired: [],\n };\n }\n\n /**\n * Finalizes the template graph and sets it on the iterator task.\n * Only applicable in loop builder mode.\n */\n public finalizeTemplate(): void {\n if (!this._iteratorTask || this.graph.getTasks().length === 0) {\n return;\n }\n\n this._iteratorTask.subGraph = this.graph;\n }\n\n /**\n * Finalizes the template graph and returns the parent workflow.\n * Only applicable in loop builder mode.\n *\n * @returns The parent workflow\n * @throws WorkflowError if not in loop builder mode\n */\n public finalizeAndReturn(): Workflow {\n if (!this._parentWorkflow) {\n throw new WorkflowError(\"finalizeAndReturn() can only be called on loop workflows\");\n }\n this.finalizeTemplate();\n // Now that the iterator task has its template graph, its dynamic inputSchema()\n // is available. Run deferred auto-connect on the parent workflow's graph.\n if (this._pendingLoopConnect) {\n this._parentWorkflow.autoConnectLoopTask(this._pendingLoopConnect);\n this._pendingLoopConnect = undefined;\n }\n return this._parentWorkflow;\n }\n}\n\n// Module augmentation prototype assignments — placed here (not in GraphAsTask.ts)\n// so that Workflow is fully defined before assignment. GraphAsTask is already\n// imported at the top of this file, so it's safe to reference here.\nWorkflow.prototype.group = CreateLoopWorkflow(GraphAsTask);\nWorkflow.prototype.endGroup = CreateEndLoopWorkflow(\"endGroup\");\n",
26
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport * from \"./ConditionalTask\";\nexport * from \"./ConditionUtils\";\nexport * from \"./FallbackTask\";\nexport * from \"./FallbackTaskRunner\";\nexport * from \"./GraphAsTask\";\nexport * from \"./GraphAsTaskRunner\";\nexport * from \"./InputResolver\";\nexport * from \"./ITask\";\nexport * from \"./iterationSchema\";\nexport * from \"./IteratorTask\";\nexport * from \"./IteratorTaskRunner\";\nexport * from \"./JobQueueFactory\";\nexport * from \"./JobQueueTask\";\nexport * from \"./MapTask\";\nexport * from \"./ReduceTask\";\nexport * from \"./StreamTypes\";\nexport * from \"./Task\";\nexport * from \"./TaskError\";\nexport * from \"./TaskEvents\";\nexport * from \"./TaskJSON\";\nexport * from \"./TaskQueueRegistry\";\nexport * from \"./TaskRegistry\";\nexport * from \"./TaskTypes\";\nexport * from \"./WhileTask\";\nexport * from \"./WhileTaskRunner\";\n\nimport { ConditionalTask } from \"./ConditionalTask\";\nimport { FallbackTask } from \"./FallbackTask\";\nimport { GraphAsTask } from \"./GraphAsTask\";\nimport { MapTask } from \"./MapTask\";\nimport { ReduceTask } from \"./ReduceTask\";\nimport { TaskRegistry } from \"./TaskRegistry\";\nimport { WhileTask } from \"./WhileTask\";\n\nexport const registerBaseTasks = () => {\n const tasks = [GraphAsTask, ConditionalTask, FallbackTask, MapTask, WhileTask, ReduceTask];\n tasks.map(TaskRegistry.registerTask);\n return tasks;\n};\n",
27
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport { FallbackTaskRunner } from \"./FallbackTaskRunner\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\n\n// ============================================================================\n// Types and Interfaces\n// ============================================================================\n\n/**\n * Execution mode for the fallback task.\n *\n * - `\"task\"`: Each task in the subgraph is an independent alternative.\n * They are tried sequentially until one succeeds.\n *\n * - `\"data\"`: The subgraph contains a template workflow that is executed\n * multiple times with different input overrides from the `alternatives` array.\n */\nexport type FallbackMode = \"task\" | \"data\";\n\nexport const fallbackTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n fallbackMode: { type: \"string\", enum: [\"task\", \"data\"] },\n alternatives: { type: \"array\", items: { type: \"object\", additionalProperties: true } },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration type for FallbackTask.\n * Extends GraphAsTaskConfig with fallback-specific options.\n */\nexport type FallbackTaskConfig = GraphAsTaskConfig & {\n /**\n * The fallback execution mode.\n * - `\"task\"`: Try each task in the subgraph as an alternative.\n * - `\"data\"`: Try the template workflow with each set of input overrides.\n * @default \"task\"\n */\n readonly fallbackMode?: FallbackMode;\n\n /**\n * Array of input overrides for data mode.\n * Each entry is merged with the task input before running the template.\n * Only used when `fallbackMode` is `\"data\"`.\n *\n * @example\n * ```typescript\n * alternatives: [\n * { model: \"openai:gpt-4\" },\n * { model: \"anthropic:claude-sonnet-4-20250514\" },\n * { model: \"onnx:Xenova/LaMini-Flan-T5-783M:q8\" },\n * ]\n * ```\n */\n readonly alternatives?: Record<string, unknown>[];\n};\n\n// ============================================================================\n// FallbackTask Class\n// ============================================================================\n\n/**\n * A task that tries multiple alternatives and returns the first successful result.\n *\n * FallbackTask provides resilient execution by automatically falling back to\n * alternative strategies when one fails. This is essential for production AI\n * workflows where provider availability is unpredictable.\n *\n * ## Execution Modes\n *\n * ### Task Mode (`fallbackMode: \"task\"`)\n * Each task added to the subgraph is an independent alternative. They are\n * tried sequentially in insertion order. The first successful result is\n * returned and remaining alternatives are skipped.\n *\n * ```typescript\n * // Via Workflow API:\n * workflow\n * .fallback()\n * .notifySlack({ channel: \"#alerts\", message: \"Hello\" })\n * .notifyEmail({ to: \"admin@example.com\", subject: \"Alert\" })\n * .notifySms({ phone: \"+1234567890\", message: \"Alert\" })\n * .endFallback();\n * ```\n *\n * ### Data Mode (`fallbackMode: \"data\"`)\n * The subgraph contains a template workflow that is executed multiple times,\n * each time with different input data merged from the `alternatives` array.\n *\n * ```typescript\n * // Via Workflow API:\n * workflow\n * .fallbackWith([\n * { model: \"openai:gpt-4\" },\n * { model: \"anthropic:claude-sonnet-4-20250514\" },\n * { model: \"onnx:Xenova/LaMini-Flan-T5-783M:q8\" },\n * ])\n * .textGeneration({ prompt: \"Hello\" })\n * .endFallbackWith();\n * ```\n *\n * ## Error Handling\n *\n * If all alternatives fail, a `TaskFailedError` is thrown with a message\n * that includes all individual error messages. Each attempt's error is\n * collected and reported for debugging.\n *\n * ## Output\n *\n * The output is the result from whichever alternative succeeded first.\n * The output schema matches the inner tasks' output schema.\n */\nexport class FallbackTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends FallbackTaskConfig = FallbackTaskConfig,\n> extends GraphAsTask<Input, Output, Config> {\n // ========================================================================\n // Static properties\n // ========================================================================\n\n public static type: TaskTypeName = \"FallbackTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Fallback\";\n public static description: string = \"Try alternatives until one succeeds\";\n\n /** FallbackTask has dynamic schemas based on the subgraph structure. */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return fallbackTaskConfigSchema;\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: FallbackTaskRunner<Input, Output, Config>;\n\n override get runner(): FallbackTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new FallbackTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Config accessors\n // ========================================================================\n\n public get fallbackMode(): FallbackMode {\n return this.config?.fallbackMode ?? \"task\";\n }\n\n public get alternatives(): Record<string, unknown>[] {\n return this.config?.alternatives ?? [];\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n /**\n * In task mode, input schema is the union of all alternative tasks' inputs.\n * In data mode, input schema comes from the template workflow's starting nodes.\n */\n public override inputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof FallbackTask).inputSchema();\n }\n\n if (this.fallbackMode === \"data\") {\n // Data mode: use the base GraphAsTask logic (union of starting node inputs)\n return super.inputSchema();\n }\n\n // Task mode: union of all tasks' input schemas (they are independent alternatives)\n const properties: Record<string, unknown> = {};\n const tasks = this.subGraph.getTasks();\n\n for (const task of tasks) {\n const taskInputSchema = task.inputSchema();\n if (typeof taskInputSchema === \"boolean\") continue;\n const taskProperties = taskInputSchema.properties || {};\n\n for (const [inputName, inputProp] of Object.entries(taskProperties)) {\n if (!properties[inputName]) {\n properties[inputName] = inputProp;\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: true,\n } as DataPortSchema;\n }\n\n /**\n * Output schema is derived from the first task in the subgraph.\n * All alternatives should produce compatible output.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof FallbackTask).outputSchema();\n }\n\n const tasks = this.subGraph.getTasks();\n if (tasks.length === 0) {\n return { type: \"object\", properties: {}, additionalProperties: false } as DataPortSchema;\n }\n\n if (this.fallbackMode === \"task\") {\n // Task mode: use the first task's output schema (all alternatives should be compatible)\n const firstTask = tasks[0];\n return firstTask.outputSchema();\n }\n\n // Data mode: use the ending nodes' output schema via base class logic\n return super.outputSchema();\n }\n\n // ========================================================================\n // Serialization\n // ========================================================================\n\n public override toJSON() {\n const json = super.toJSON();\n return {\n ...json,\n config: {\n ...(\"config\" in json ? json.config : {}),\n fallbackMode: this.fallbackMode,\n ...(this.alternatives.length > 0 ? { alternatives: this.alternatives } : {}),\n },\n };\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a task-mode fallback block. Each task added inside the block\n * is an independent alternative tried sequentially until one succeeds.\n * Use `.endFallback()` to close the block and return to the parent workflow.\n */\n fallback: CreateLoopWorkflow<TaskInput, TaskOutput, FallbackTaskConfig>;\n\n /**\n * Ends the task-mode fallback block and returns to the parent workflow.\n */\n endFallback(): Workflow;\n\n /**\n * Starts a data-mode fallback block. The tasks added inside the block\n * form a template workflow that is re-run with each set of input overrides\n * from `alternatives`. Use `.endFallbackWith()` to close the block.\n *\n * @param alternatives - Array of input override objects to try sequentially\n */\n fallbackWith(alternatives: Record<string, unknown>[]): Workflow;\n\n /**\n * Ends the data-mode fallback block and returns to the parent workflow.\n */\n endFallbackWith(): Workflow;\n }\n}\n\nqueueMicrotask(() => {\n Workflow.prototype.fallback = function (this: Workflow): Workflow {\n return this.addLoopTask(FallbackTask, { fallbackMode: \"task\" });\n };\n Workflow.prototype.endFallback = CreateEndLoopWorkflow(\"endFallback\");\n\n Workflow.prototype.fallbackWith = function (\n this: Workflow,\n alternatives: Record<string, unknown>[]\n ): Workflow {\n return this.addLoopTask(FallbackTask, {\n fallbackMode: \"data\",\n alternatives,\n });\n };\n Workflow.prototype.endFallbackWith = CreateEndLoopWorkflow(\"endFallbackWith\");\n});\n",
24
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ITask } from \"../task/ITask\";\nimport type { TaskIdType } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport type { TaskGraph } from \"./TaskGraph\";\nimport { Workflow } from \"./Workflow\";\n\n/**\n * Options controlling the generated workflow code.\n */\nexport interface GraphToWorkflowCodeOptions {\n /** Name of the workflow variable in the generated code. @default \"workflow\" */\n readonly variableName?: string;\n /** When true, include `new Workflow()` declaration. @default true */\n readonly includeDeclaration?: boolean;\n /** Indentation string per level. @default \" \" */\n readonly indent?: string;\n}\n\n/**\n * Map from task type name to the Workflow prototype method name.\n * Built lazily by scanning `Workflow.prototype` for methods with `workflowCreate = true`.\n */\nlet methodNameCache: Map<string, string> | undefined;\n\nfunction getMethodNameMap(): Map<string, string> {\n if (methodNameCache) return methodNameCache;\n methodNameCache = new Map<string, string>();\n for (const key of Object.getOwnPropertyNames(Workflow.prototype)) {\n try {\n const val = (Workflow.prototype as any)[key];\n if (val && val.workflowCreate && val.type) {\n methodNameCache.set(val.type, key);\n }\n } catch {\n // skip getters that throw\n }\n }\n return methodNameCache;\n}\n\n/**\n * Loop task types that use the builder pattern.\n */\nconst LOOP_TASK_TYPES: Record<string, { method: string; endMethod: string }> = {\n MapTask: { method: \"map\", endMethod: \"endMap\" },\n ReduceTask: { method: \"reduce\", endMethod: \"endReduce\" },\n WhileTask: { method: \"while\", endMethod: \"endWhile\" },\n GraphAsTask: { method: \"group\", endMethod: \"endGroup\" },\n};\n\n/**\n * Converts a TaskGraph into JavaScript/TypeScript code that builds an equivalent Workflow.\n *\n * This is the reverse of the Workflow builder: given a graph (with tasks, dataflows, and\n * potential subgraphs for loop/compound tasks), it produces code that re-creates the\n * same graph via the Workflow API.\n *\n * The generated code uses method chaining, which is critical for loop tasks where\n * `.map()` / `.while()` / `.reduce()` return a loop builder that inner tasks must\n * be called on before `.endMap()` / `.endWhile()` / `.endReduce()` returns to the\n * parent workflow.\n *\n * @param graph - The TaskGraph to convert\n * @param options - Options controlling output format\n * @returns Generated JavaScript code string\n */\nexport function graphToWorkflowCode(\n graph: TaskGraph,\n options: GraphToWorkflowCodeOptions = {}\n): string {\n const { variableName = \"workflow\", includeDeclaration = true, indent = \" \" } = options;\n\n const lines: string[] = [];\n\n if (includeDeclaration) {\n lines.push(`const ${variableName} = new Workflow();`);\n }\n\n const tasks = graph.topologicallySortedNodes();\n const dataflows = graph.getDataflows();\n\n // Build dataflow lookup: targetTaskId -> list of dataflows\n const incomingDataflows = new Map<TaskIdType, typeof dataflows>();\n for (const df of dataflows) {\n const list = incomingDataflows.get(df.targetTaskId) ?? [];\n list.push(df);\n incomingDataflows.set(df.targetTaskId, list);\n }\n\n // Track task order for determining which task is \"previous\"\n const taskOrder: TaskIdType[] = [];\n\n generateTaskChain(tasks, incomingDataflows, taskOrder, variableName, indent, 0, lines);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generates the workflow code for a sequence of tasks, using chained method calls.\n *\n * The variable name is always on its own line, with tasks chained below:\n * ```\n * workflow\n * .task1(args)\n * .task2(args)\n * .task3(args);\n * ```\n *\n * Single tasks that fit on one line are collapsed:\n * ```\n * workflow.task1(args);\n * ```\n *\n * For loop tasks, inner tasks are indented and chained on the loop builder.\n * The `.end*()` call returns to the parent workflow, so subsequent tasks\n * continue chaining on the parent variable.\n */\nfunction generateTaskChain(\n tasks: readonly ITask[],\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n variableName: string,\n indent: string,\n depth: number,\n lines: string[]\n): void {\n if (tasks.length === 0) return;\n\n const prefix = indent.repeat(depth);\n const chainIndent = indent.repeat(depth + 1);\n\n // Generate all chain lines into a temporary buffer\n const chainLines: string[] = [];\n\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n const loopInfo = LOOP_TASK_TYPES[task.type];\n\n // Check for rename() calls needed before this task\n const renames = computeRenames(task, incomingDataflows, taskOrder);\n for (const rename of renames) {\n chainLines.push(\n `${chainIndent}.rename(${formatValue(rename.source)}, ${formatValue(rename.target)})`\n );\n }\n\n if (loopInfo) {\n generateLoopTask(task, loopInfo, incomingDataflows, taskOrder, indent, depth, chainLines);\n } else {\n generateRegularTask(task, chainIndent, chainLines);\n }\n\n taskOrder.push(task.id);\n }\n\n // Try to collapse single-call chains onto one line\n if (chainLines.length === 1 && !chainLines[0].includes(\"\\n\")) {\n const call = chainLines[0].trimStart();\n const oneLine = `${prefix}${variableName}${call}`;\n if (oneLine.length < 80) {\n lines.push(`${oneLine};`);\n return;\n }\n }\n\n // Multi-line: variable on its own line, then chained calls\n lines.push(`${prefix}${variableName}`);\n for (const line of chainLines) {\n lines.push(line);\n }\n lines[lines.length - 1] += \";\";\n}\n\n/**\n * Generates code for a regular (non-loop) task as a chained `.method(args)` call.\n */\nfunction generateRegularTask(task: ITask, chainIndent: string, lines: string[]): void {\n const methodMap = getMethodNameMap();\n const methodName = methodMap.get(task.type);\n const defaults = task.defaults;\n const config = extractTaskConfig(task);\n\n if (methodName) {\n const colOffset = chainIndent.length + `.${methodName}(`.length;\n const args = buildMethodArgs(defaults, config, chainIndent, colOffset);\n lines.push(`${chainIndent}.${methodName}(${args})`);\n } else {\n const colOffset = chainIndent.length + \".addTask(\".length;\n const args = buildAddTaskArgs(task.type, defaults, config, chainIndent, colOffset);\n lines.push(`${chainIndent}.addTask(${args})`);\n }\n}\n\n/**\n * Generates code for a loop task (map/reduce/while) using builder pattern.\n *\n * Loop tasks use chained method calls:\n * ```\n * workflow\n * .map({ config })\n * .addTask(InnerTask)\n * .endMap()\n * ```\n *\n * The `.map()` call returns a loop builder, inner tasks chain on that,\n * and `.endMap()` returns to the parent workflow. All of this is a single\n * chained expression to preserve the correct `this` context.\n */\nfunction generateLoopTask(\n task: ITask,\n loopInfo: { method: string; endMethod: string },\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n indent: string,\n depth: number,\n lines: string[]\n): void {\n const chainIndent = indent.repeat(depth + 1);\n const config = extractLoopConfig(task);\n const loopColOffset = chainIndent.length + `.${loopInfo.method}(`.length;\n const configStr =\n Object.keys(config).length > 0 ? formatValue(config, chainIndent, loopColOffset) : \"\";\n\n lines.push(`${chainIndent}.${loopInfo.method}(${configStr})`);\n\n // Generate inner tasks from subgraph as chained calls\n if (task.hasChildren()) {\n const subGraph = task.subGraph!;\n const innerTasks = subGraph.topologicallySortedNodes();\n const innerDataflows = subGraph.getDataflows();\n\n const innerIncoming = new Map<TaskIdType, typeof innerDataflows>();\n for (const df of innerDataflows) {\n const list = innerIncoming.get(df.targetTaskId) ?? [];\n list.push(df);\n innerIncoming.set(df.targetTaskId, list);\n }\n\n const innerOrder: TaskIdType[] = [];\n generateChainedInnerTasks(innerTasks, innerIncoming, innerOrder, indent, depth + 1, lines);\n }\n\n // End the loop (no semicolon - caller adds it to the last line of the full chain)\n lines.push(`${chainIndent}.${loopInfo.endMethod}()`);\n}\n\n/**\n * Generates inner tasks as chained method calls (for loop builder bodies).\n * Each task becomes a `.methodName(args)` or `.addTask(Class, args)` continuation.\n * Nested loops generate recursive chained structures.\n */\nfunction generateChainedInnerTasks(\n tasks: readonly ITask[],\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[],\n indent: string,\n depth: number,\n lines: string[]\n): void {\n const innerPrefix = indent.repeat(depth + 1);\n\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n const loopInfo = LOOP_TASK_TYPES[task.type];\n\n // Check for rename\n const renames = computeRenames(task, incomingDataflows, taskOrder);\n for (const rename of renames) {\n lines.push(\n `${innerPrefix}.rename(${formatValue(rename.source)}, ${formatValue(rename.target)})`\n );\n }\n\n if (loopInfo) {\n // Nested loop task - recurse\n const config = extractLoopConfig(task);\n const nestedColOffset = innerPrefix.length + `.${loopInfo.method}(`.length;\n const configStr =\n Object.keys(config).length > 0 ? formatValue(config, innerPrefix, nestedColOffset) : \"\";\n\n lines.push(`${innerPrefix}.${loopInfo.method}(${configStr})`);\n\n if (task.hasChildren()) {\n const subGraph = task.subGraph!;\n const innerTasks = subGraph.topologicallySortedNodes();\n const innerDataflows = subGraph.getDataflows();\n\n const innerIncoming = new Map<TaskIdType, typeof innerDataflows>();\n for (const df of innerDataflows) {\n const list = innerIncoming.get(df.targetTaskId) ?? [];\n list.push(df);\n innerIncoming.set(df.targetTaskId, list);\n }\n\n const innerOrder: TaskIdType[] = [];\n generateChainedInnerTasks(innerTasks, innerIncoming, innerOrder, indent, depth + 1, lines);\n }\n\n lines.push(`${innerPrefix}.${loopInfo.endMethod}()`);\n } else {\n // Regular inner task - chained call\n const methodMap = getMethodNameMap();\n const methodName = methodMap.get(task.type);\n const defaults = task.defaults;\n const config = extractTaskConfig(task);\n\n if (methodName) {\n const colOffset = innerPrefix.length + `.${methodName}(`.length;\n const args = buildMethodArgs(defaults, config, innerPrefix, colOffset);\n lines.push(`${innerPrefix}.${methodName}(${args})`);\n } else {\n const colOffset = innerPrefix.length + \".addTask(\".length;\n const args = buildAddTaskArgs(task.type, defaults, config, innerPrefix, colOffset);\n lines.push(`${innerPrefix}.addTask(${args})`);\n }\n }\n\n taskOrder.push(task.id);\n }\n}\n\n/**\n * Determines which dataflows need explicit `.rename()` calls.\n *\n * A rename is needed when a dataflow connects different port names between\n * the immediately previous task and the current task. Connections with matching\n * names are handled automatically by the Workflow's auto-connect system.\n */\nfunction computeRenames(\n task: ITask,\n incomingDataflows: Map<TaskIdType, ReturnType<TaskGraph[\"getDataflows\"]>>,\n taskOrder: TaskIdType[]\n): Array<{ source: string; target: string }> {\n const incoming = incomingDataflows.get(task.id) ?? [];\n const renames: Array<{ source: string; target: string }> = [];\n\n const prevTaskId = taskOrder.length > 0 ? taskOrder[taskOrder.length - 1] : undefined;\n\n for (const df of incoming) {\n // Skip all-ports connections (auto-connected by pipe/addTask)\n if (df.sourceTaskPortId === DATAFLOW_ALL_PORTS && df.targetTaskPortId === DATAFLOW_ALL_PORTS) {\n continue;\n }\n\n // Skip error port connections\n if (\n df.sourceTaskPortId === DATAFLOW_ERROR_PORT ||\n df.targetTaskPortId === DATAFLOW_ERROR_PORT\n ) {\n continue;\n }\n\n // Only the immediately previous task can produce a rename\n if (df.sourceTaskId !== prevTaskId) {\n continue;\n }\n\n // If port names match, auto-connect handles it\n if (df.sourceTaskPortId === df.targetTaskPortId) {\n continue;\n }\n\n renames.push({ source: df.sourceTaskPortId, target: df.targetTaskPortId });\n }\n\n return renames;\n}\n\n/**\n * Extracts non-default config properties from a task for regular tasks.\n * Skips title/description when they match the static class defaults.\n */\nfunction extractTaskConfig(task: ITask): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n const rawConfig = task.config;\n const staticTitle = (task.constructor as any).title || \"\";\n const staticDescription = (task.constructor as any).description || \"\";\n if (rawConfig.title && rawConfig.title !== staticTitle) config.title = rawConfig.title;\n if (rawConfig.description && rawConfig.description !== staticDescription)\n config.description = rawConfig.description;\n return config;\n}\n\n/**\n * Extracts config for loop tasks (map/reduce/while).\n */\nfunction extractLoopConfig(task: ITask): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n const rawConfig = task.config as Record<string, unknown>;\n\n switch (task.type) {\n case \"GraphAsTask\": {\n if (rawConfig.compoundMerge !== undefined) {\n config.compoundMerge = rawConfig.compoundMerge;\n }\n break;\n }\n case \"MapTask\": {\n if (rawConfig.preserveOrder !== undefined && rawConfig.preserveOrder !== true) {\n config.preserveOrder = rawConfig.preserveOrder;\n }\n if (rawConfig.flatten !== undefined && rawConfig.flatten !== false) {\n config.flatten = rawConfig.flatten;\n }\n if (rawConfig.concurrencyLimit !== undefined) {\n config.concurrencyLimit = rawConfig.concurrencyLimit;\n }\n if (rawConfig.batchSize !== undefined) {\n config.batchSize = rawConfig.batchSize;\n }\n break;\n }\n case \"ReduceTask\": {\n if (rawConfig.initialValue !== undefined) {\n config.initialValue = rawConfig.initialValue;\n }\n break;\n }\n case \"WhileTask\": {\n if (rawConfig.maxIterations !== undefined && rawConfig.maxIterations !== 100) {\n config.maxIterations = rawConfig.maxIterations;\n }\n if (rawConfig.chainIterations !== undefined && rawConfig.chainIterations !== true) {\n config.chainIterations = rawConfig.chainIterations;\n }\n // Emit serializable condition form\n if (rawConfig.conditionField !== undefined) {\n config.conditionField = rawConfig.conditionField;\n }\n if (rawConfig.conditionOperator !== undefined) {\n config.conditionOperator = rawConfig.conditionOperator;\n }\n if (rawConfig.conditionValue !== undefined) {\n config.conditionValue = rawConfig.conditionValue;\n }\n // If there's a function condition but no serializable form, use a null placeholder\n if (rawConfig.condition && !rawConfig.conditionOperator) {\n config.condition = null;\n }\n break;\n }\n }\n\n return config;\n}\n\n/**\n * Builds the argument string for a prototype method call.\n */\nfunction buildMethodArgs(\n defaults: Record<string, unknown> | undefined,\n config: Record<string, unknown>,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n const hasDefaults = defaults && Object.keys(defaults).length > 0;\n const hasConfig = Object.keys(config).length > 0;\n\n if (!hasDefaults && !hasConfig) return \"\";\n if (hasDefaults && !hasConfig) return formatValue(defaults, baseIndent, columnOffset);\n if (!hasDefaults && hasConfig) return `{}, ${formatValue(config, baseIndent, columnOffset + 4)}`;\n const defaultsStr = formatValue(defaults, baseIndent, columnOffset);\n return `${defaultsStr}, ${formatValue(config, baseIndent, columnOffset + defaultsStr.length + 2)}`;\n}\n\n/**\n * Builds the argument string for an addTask() call.\n */\nfunction buildAddTaskArgs(\n taskType: string,\n defaults: Record<string, unknown> | undefined,\n config: Record<string, unknown>,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n const hasDefaults = defaults && Object.keys(defaults).length > 0;\n const hasConfig = Object.keys(config).length > 0;\n const typeOffset = columnOffset + taskType.length + 2;\n\n if (!hasDefaults && !hasConfig) return taskType;\n if (hasDefaults && !hasConfig)\n return `${taskType}, ${formatValue(defaults, baseIndent, typeOffset)}`;\n if (!hasDefaults && hasConfig)\n return `${taskType}, {}, ${formatValue(config, baseIndent, typeOffset + 4)}`;\n const defaultsStr = formatValue(defaults, baseIndent, typeOffset);\n return `${taskType}, ${defaultsStr}, ${formatValue(config, baseIndent, typeOffset + defaultsStr.length + 2)}`;\n}\n\n/**\n * Formats a JavaScript value as a code string.\n * Handles objects, arrays, strings, numbers, booleans, undefined, null,\n * and special markers.\n */\nexport function formatValue(\n value: unknown,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (value instanceof Float32Array) {\n return `new Float32Array([${Array.from(value).join(\", \")}])`;\n }\n if (value instanceof Float64Array) {\n return `new Float64Array([${Array.from(value).join(\", \")}])`;\n }\n const entryIndent = baseIndent + \" \";\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n const items = value.map((v) => formatValue(v, entryIndent));\n const oneLine = `[${items.join(\", \")}]`;\n if (columnOffset + oneLine.length < 80) return oneLine;\n return `[\\n${items.map((item) => `${entryIndent}${item}`).join(\",\\n\")}\\n${baseIndent}]`;\n }\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj);\n if (keys.length === 0) return \"{}\";\n const entries = keys.map((k) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) ? k : JSON.stringify(k);\n return `${formattedKey}: ${formatValue(obj[k], entryIndent)}`;\n });\n const oneLine = `{ ${entries.join(\", \")} }`;\n if (columnOffset + oneLine.length < 80) return oneLine;\n return `{\\n${entries.map((e) => `${entryIndent}${e}`).join(\",\\n\")}\\n${baseIndent}}`;\n }\n return String(value);\n}\n\n/**\n * Resets the method name cache. Useful for testing when prototype methods\n * are registered after initial import.\n */\nexport function resetMethodNameCache(): void {\n methodNameCache = undefined;\n}\n",
28
25
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { FallbackTask, FallbackTaskConfig } from \"./FallbackTask\";\nimport { GraphAsTaskRunner } from \"./GraphAsTaskRunner\";\nimport type { ITask } from \"./ITask\";\nimport { TaskAbortedError, TaskFailedError, TaskTimeoutError } from \"./TaskError\";\nimport { TaskStatus, type TaskInput, type TaskOutput } from \"./TaskTypes\";\n\n/**\n * Runner for FallbackTask that executes alternatives sequentially until one succeeds.\n *\n * In **task mode**, each task in the subgraph is tried independently.\n * In **data mode**, the entire subgraph is re-run with different input overrides.\n */\nexport class FallbackTaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends FallbackTaskConfig = FallbackTaskConfig,\n> extends GraphAsTaskRunner<Input, Output, Config> {\n declare task: FallbackTask<Input, Output, Config>;\n\n /**\n * Override executeTask to implement sequential fallback logic.\n */\n protected override async executeTask(input: Input): Promise<Output | undefined> {\n if (this.task.fallbackMode === \"data\") {\n return this.executeDataFallback(input);\n }\n return this.executeTaskFallback(input);\n }\n\n /**\n * For FallbackTask, reactive runs use the task's reactive hook only,\n * bypassing GraphAsTaskRunner's child-merging logic.\n */\n public override async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n const reactiveResult = await this.task.executeReactive(input, output, { own: this.own });\n return Object.assign({}, output, reactiveResult ?? {}) as Output;\n }\n\n // ========================================================================\n // Task Mode: Try each task in the subgraph as an independent alternative\n // ========================================================================\n\n /**\n * Tries each task in the subgraph sequentially. Returns the first\n * successful result. If all fail, throws with collected errors.\n */\n private async executeTaskFallback(input: Input): Promise<Output | undefined> {\n const tasks = this.task.subGraph.getTasks();\n if (tasks.length === 0) {\n throw new TaskFailedError(\"FallbackTask has no alternatives to try\");\n }\n\n const errors: { task: ITask; error: Error }[] = [];\n const totalAttempts = tasks.length;\n\n for (let i = 0; i < tasks.length; i++) {\n if (this.abortController?.signal.aborted) {\n throw new TaskAbortedError(\"Fallback aborted\");\n }\n\n const alternativeTask = tasks[i];\n const attemptNumber = i + 1;\n\n await this.handleProgress(\n Math.round(((i + 0.5) / totalAttempts) * 100),\n `Trying alternative ${attemptNumber}/${totalAttempts}: ${alternativeTask.type}`\n );\n\n try {\n // Reset the task to PENDING so it can be run\n this.resetTask(alternativeTask);\n\n // Run the individual task with the parent's input\n const result = await alternativeTask.run(input);\n\n await this.handleProgress(\n 100,\n `Alternative ${attemptNumber}/${totalAttempts} succeeded: ${alternativeTask.type}`\n );\n\n // Apply reactive post-processing\n return (await this.executeTaskReactive(input, result as Output)) as Output;\n } catch (error) {\n // Aborts (non-timeout) are not retryable — propagate immediately\n if (error instanceof TaskAbortedError && !(error instanceof TaskTimeoutError)) {\n throw error;\n }\n errors.push({ task: alternativeTask, error: error as Error });\n // Continue to next alternative\n }\n }\n\n // All alternatives failed\n throw this.buildAggregateError(errors, \"task\");\n }\n\n // ========================================================================\n // Data Mode: Run the template workflow with different input overrides\n // ========================================================================\n\n /**\n * Runs the subgraph workflow multiple times, each time with a different\n * set of input overrides merged from `config.alternatives`.\n */\n private async executeDataFallback(input: Input): Promise<Output | undefined> {\n const alternatives = this.task.alternatives;\n if (alternatives.length === 0) {\n throw new TaskFailedError(\"FallbackTask has no data alternatives to try\");\n }\n\n const errors: { alternative: Record<string, unknown>; error: Error }[] = [];\n const totalAttempts = alternatives.length;\n\n for (let i = 0; i < alternatives.length; i++) {\n if (this.abortController?.signal.aborted) {\n throw new TaskAbortedError(\"Fallback aborted\");\n }\n\n const alternative = alternatives[i];\n const attemptNumber = i + 1;\n\n await this.handleProgress(\n Math.round(((i + 0.5) / totalAttempts) * 100),\n `Trying data alternative ${attemptNumber}/${totalAttempts}`\n );\n\n try {\n // Reset all tasks in the subgraph to PENDING\n this.resetSubgraph();\n\n // Merge the alternative's data with the original input\n const mergedInput = { ...input, ...alternative } as Input;\n\n // Run the subgraph with merged input\n const results = await this.task.subGraph.run<Output>(mergedInput, {\n parentSignal: this.abortController?.signal,\n outputCache: this.outputCache,\n registry: this.registry,\n });\n\n const mergedOutput = this.task.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.task.compoundMerge\n ) as Output;\n\n await this.handleProgress(\n 100,\n `Data alternative ${attemptNumber}/${totalAttempts} succeeded`\n );\n\n // Apply reactive post-processing\n return (await this.executeTaskReactive(input, mergedOutput)) as Output;\n } catch (error) {\n // Aborts (non-timeout) are not retryable — propagate immediately\n if (error instanceof TaskAbortedError && !(error instanceof TaskTimeoutError)) {\n throw error;\n }\n errors.push({ alternative, error: error as Error });\n // Continue to next alternative\n }\n }\n\n // All alternatives failed\n throw this.buildAggregateError(errors, \"data\");\n }\n\n // ========================================================================\n // Helpers\n // ========================================================================\n\n /**\n * Resets a single task to PENDING status so it can be re-run.\n */\n private resetTask(task: ITask): void {\n task.status = TaskStatus.PENDING;\n task.progress = 0;\n task.error = undefined;\n task.completedAt = undefined;\n task.startedAt = undefined;\n task.resetInputData();\n }\n\n /**\n * Resets all tasks and dataflows in the subgraph for a fresh run.\n */\n private resetSubgraph(): void {\n for (const task of this.task.subGraph.getTasks()) {\n this.resetTask(task);\n }\n for (const dataflow of this.task.subGraph.getDataflows()) {\n dataflow.reset();\n }\n }\n\n /**\n * Builds a descriptive error from all collected failures.\n */\n private buildAggregateError(\n errors: { error: Error; [key: string]: unknown }[],\n mode: \"task\" | \"data\"\n ): TaskFailedError {\n const label = mode === \"task\" ? \"alternative\" : \"data alternative\";\n const details = errors\n .map((e, i) => {\n const prefix = e.error instanceof TaskTimeoutError ? \"[timeout] \" : \"\";\n return ` ${label} ${i + 1}: ${prefix}${e.error.message}`;\n })\n .join(\"\\n\");\n return new TaskFailedError(`All ${errors.length} ${label}s failed:\\n${details}`);\n }\n}\n",
29
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema, PropertySchema } from \"@workglow/util/schema\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { IExecuteContext } from \"./ITask\";\nimport { IteratorTaskRunner } from \"./IteratorTaskRunner\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError } from \"./TaskError\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\n\n/**\n * Standard iteration context schema for IteratorTask subclasses (Map, Reduce).\n * Properties are marked with \"x-ui-iteration\": true so the builder\n * knows to hide them from parent-level display.\n */\nexport const ITERATOR_CONTEXT_SCHEMA: DataPortSchema = {\n type: \"object\",\n properties: {\n _iterationIndex: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Index\",\n description: \"Current iteration index (0-based)\",\n \"x-ui-iteration\": true,\n },\n _iterationCount: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Count\",\n description: \"Total number of iterations\",\n \"x-ui-iteration\": true,\n },\n },\n};\n\n/**\n * Execution mode for iterator tasks.\n * - `parallel`: Execute all iterations concurrently (logical mode)\n * - `parallel-limited`: Execute with a concurrency limit\n */\nexport type ExecutionMode = \"parallel\" | \"parallel-limited\";\n\n/**\n * Input mode for a property in the iteration input schema.\n * - \"array\": Property must be an array (will be iterated)\n * - \"scalar\": Property must be a scalar (constant for all iterations)\n * - \"flexible\": Property accepts both array and scalar (T | T[])\n */\nexport type IterationInputMode = \"array\" | \"scalar\" | \"flexible\";\n\n/**\n * Configuration for a single property in the iteration input schema.\n */\nexport interface IterationPropertyConfig {\n /** The base schema for the property (without array wrapping) */\n readonly baseSchema: PropertySchema;\n /** The input mode for this property */\n readonly mode: IterationInputMode;\n}\n\nexport const iteratorTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n concurrencyLimit: { type: \"integer\", minimum: 1 },\n batchSize: { type: \"integer\", minimum: 1 },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration type for IteratorTask.\n * Extends GraphAsTaskConfig with iterator-specific options.\n */\nexport type IteratorTaskConfig = GraphAsTaskConfig & {\n /**\n * Maximum number of concurrent iteration workers\n * @default undefined (unlimited)\n */\n readonly concurrencyLimit?: number;\n\n /**\n * Number of items per batch. When set, iteration indices are grouped into batches.\n * @default undefined\n */\n readonly batchSize?: number;\n\n /**\n * User-defined iteration input schema configuration.\n */\n readonly iterationInputConfig?: Record<string, IterationPropertyConfig>;\n};\n\n/**\n * Result of detecting the iterator port from the input schema.\n */\ninterface IteratorPortInfo {\n readonly portName: string;\n readonly itemSchema: DataPortSchema;\n}\n\n/**\n * Result of analyzing input for iteration.\n */\nexport interface IterationAnalysisResult {\n /** The number of iterations to perform */\n readonly iterationCount: number;\n /** Names of properties that are arrays (to be iterated) */\n readonly arrayPorts: string[];\n /** Names of properties that are scalars (passed as constants) */\n readonly scalarPorts: string[];\n /** Gets the input for a specific iteration index */\n getIterationInput(index: number): Record<string, unknown>;\n}\n\nfunction isArrayVariant(schema: unknown): boolean {\n if (!schema || typeof schema !== \"object\") return false;\n const record = schema as Record<string, unknown>;\n return record.type === \"array\" || record.items !== undefined;\n}\n\nfunction getExplicitIterationFlag(schema: DataPortSchema | undefined): boolean | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const record = schema as Record<string, unknown>;\n const flag = record[\"x-ui-iteration\"];\n if (flag === true) return true;\n if (flag === false) return false;\n return undefined;\n}\n\nfunction inferIterationFromSchema(schema: DataPortSchema | undefined): boolean | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n\n const record = schema as Record<string, unknown>;\n\n if (record.type === \"array\" || record.items !== undefined) {\n return true;\n }\n\n const variants = (record.oneOf ?? record.anyOf) as unknown[] | undefined;\n if (!Array.isArray(variants) || variants.length === 0) {\n // Schema does not clearly indicate array/non-array - defer to runtime\n if (record.type !== undefined) {\n return false;\n }\n return undefined;\n }\n\n let hasArrayVariant = false;\n let hasNonArrayVariant = false;\n\n for (const variant of variants) {\n if (isArrayVariant(variant)) {\n hasArrayVariant = true;\n } else {\n hasNonArrayVariant = true;\n }\n }\n\n if (hasArrayVariant && hasNonArrayVariant) return undefined;\n if (hasArrayVariant) return true;\n return false;\n}\n\n/**\n * Creates a union type schema (T | T[]) for flexible iteration input.\n */\nexport function createFlexibleSchema(baseSchema: PropertySchema): PropertySchema {\n return {\n anyOf: [baseSchema, { type: \"array\", items: baseSchema }],\n } as PropertySchema;\n}\n\n/**\n * Creates an array schema from a base schema.\n */\nexport function createArraySchema(baseSchema: PropertySchema): PropertySchema {\n return {\n type: \"array\",\n items: baseSchema,\n } as PropertySchema;\n}\n\n/**\n * Extracts the base (scalar) schema from a potentially wrapped schema.\n */\nexport function extractBaseSchema(schema: PropertySchema): PropertySchema {\n const schemaType = (schema as Record<string, unknown>).type;\n if (schemaType === \"array\" && (schema as Record<string, unknown>).items) {\n return (schema as Record<string, unknown>).items as PropertySchema;\n }\n\n const variants =\n (schema as Record<string, unknown>).oneOf ?? (schema as Record<string, unknown>).anyOf;\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const variantType = (variant as Record<string, unknown>).type;\n if (variantType !== \"array\") {\n return variant as PropertySchema;\n }\n }\n }\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const variantType = (variant as Record<string, unknown>).type;\n if (variantType === \"array\" && (variant as Record<string, unknown>).items) {\n return (variant as Record<string, unknown>).items as PropertySchema;\n }\n }\n }\n }\n\n return schema;\n}\n\n/**\n * Determines if a schema accepts arrays (is array type or has array in union).\n */\nexport function schemaAcceptsArray(schema: DataPortSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n\n const schemaType = (schema as Record<string, unknown>).type;\n if (schemaType === \"array\") return true;\n\n const variants = (schema.oneOf ?? schema.anyOf) as DataPortSchema[] | undefined;\n if (Array.isArray(variants)) {\n return variants.some((variant) => isArrayVariant(variant));\n }\n\n return false;\n}\n\n/**\n * Base class for iterator tasks that process collections of items.\n */\nexport abstract class IteratorTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends IteratorTaskConfig = IteratorTaskConfig,\n> extends GraphAsTask<Input, Output, Config> {\n public static type: TaskTypeName = \"IteratorTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Iterator\";\n public static description: string = \"Base class for loop-type tasks\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return iteratorTaskConfigSchema;\n }\n\n /**\n * Returns the schema for iteration-context inputs that will be\n * injected into the subgraph at runtime.\n */\n public static getIterationContextSchema(): DataPortSchema {\n return ITERATOR_CONTEXT_SCHEMA;\n }\n\n /** Cached iterator port info from schema analysis. */\n protected _iteratorPortInfo: IteratorPortInfo | undefined;\n\n /** Cached computed iteration input schema. */\n protected _iterationInputSchema: DataPortSchema | undefined;\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n super(input, config as Config);\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: IteratorTaskRunner<Input, Output, Config>;\n\n override get runner(): IteratorTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new IteratorTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n /**\n * IteratorTask does not support streaming pass-through because its output\n * is an aggregation of multiple iterations (arrays for MapTask, accumulated\n * value for ReduceTask). The inherited GraphAsTask.executeStream is\n * overridden to just emit a finish event (no streaming).\n */\n async *executeStream(\n input: Input,\n _context: IExecuteContext\n ): AsyncIterable<StreamEvent<Output>> {\n yield { type: \"finish\", data: input as unknown as Output } as StreamFinish<Output>;\n }\n\n // ========================================================================\n // Graph hooks\n // ========================================================================\n\n override set subGraph(subGraph: TaskGraph) {\n super.subGraph = subGraph;\n this.invalidateIterationInputSchema();\n this.events.emit(\"regenerate\");\n }\n\n override get subGraph(): TaskGraph {\n return super.subGraph;\n }\n\n public override regenerateGraph(): void {\n this.invalidateIterationInputSchema();\n super.regenerateGraph();\n }\n\n // ========================================================================\n // Runner hooks\n // ========================================================================\n\n /**\n * Whether results should be ordered by iteration index.\n * MapTask overrides this to use its `preserveOrder` config.\n */\n public preserveIterationOrder(): boolean {\n return true;\n }\n\n /**\n * Whether this iterator runs in reduce mode.\n */\n public isReduceTask(): boolean {\n return false;\n }\n\n /**\n * Initial accumulator for reduce mode.\n */\n public getInitialAccumulator(): Output {\n return {} as Output;\n }\n\n /**\n * Builds the per-iteration subgraph input.\n */\n public buildIterationRunInput(\n analysis: IterationAnalysisResult,\n index: number,\n iterationCount: number,\n extraInput: Record<string, unknown> = {}\n ): Record<string, unknown> {\n return {\n ...analysis.getIterationInput(index),\n ...extraInput,\n _iterationIndex: index,\n _iterationCount: iterationCount,\n };\n }\n\n /**\n * Updates the accumulator with one iteration result in reduce mode.\n */\n public mergeIterationIntoAccumulator(\n accumulator: Output,\n iterationResult: TaskOutput | undefined,\n _index: number\n ): Output {\n return (iterationResult ?? accumulator) as Output;\n }\n\n /**\n * Returns the result when there are no items to iterate.\n */\n public getEmptyResult(): Output {\n return {} as Output;\n }\n\n /**\n * Collects and merges results from all iterations.\n */\n public collectResults(results: TaskOutput[]): Output {\n if (results.length === 0) {\n return {} as Output;\n }\n\n const merged: Record<string, unknown[]> = {};\n\n for (const result of results) {\n if (!result || typeof result !== \"object\") continue;\n\n for (const [key, value] of Object.entries(result as Record<string, unknown>)) {\n if (!merged[key]) {\n merged[key] = [];\n }\n merged[key].push(value);\n }\n }\n\n return merged as Output;\n }\n\n // ========================================================================\n // Execution Mode Configuration\n // ========================================================================\n\n public get concurrencyLimit(): number | undefined {\n return this.config.concurrencyLimit;\n }\n\n public get batchSize(): number | undefined {\n return this.config.batchSize;\n }\n\n // ========================================================================\n // Iteration Input Schema Management\n // ========================================================================\n\n public get iterationInputConfig(): Record<string, IterationPropertyConfig> | undefined {\n return this.config.iterationInputConfig;\n }\n\n protected buildDefaultIterationInputSchema(): DataPortSchema {\n const innerSchema = this.getInnerInputSchema();\n if (!innerSchema || typeof innerSchema === \"boolean\") {\n return { type: \"object\", properties: {}, additionalProperties: true };\n }\n\n const properties: Record<string, PropertySchema> = {};\n const innerProps = innerSchema.properties || {};\n\n for (const [key, propSchema] of Object.entries(innerProps)) {\n if (typeof propSchema === \"boolean\") continue;\n\n if ((propSchema as Record<string, unknown>)[\"x-ui-iteration\"]) {\n continue;\n }\n\n const baseSchema = propSchema as PropertySchema;\n properties[key] = createFlexibleSchema(baseSchema);\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: innerSchema.additionalProperties ?? true,\n } as DataPortSchema;\n }\n\n protected buildConfiguredIterationInputSchema(): DataPortSchema {\n const innerSchema = this.getInnerInputSchema();\n if (!innerSchema || typeof innerSchema === \"boolean\") {\n return { type: \"object\", properties: {}, additionalProperties: true };\n }\n\n const config = this.iterationInputConfig || {};\n const properties: Record<string, PropertySchema> = {};\n const innerProps = innerSchema.properties || {};\n\n for (const [key, propSchema] of Object.entries(innerProps)) {\n if (typeof propSchema === \"boolean\") continue;\n\n if ((propSchema as Record<string, unknown>)[\"x-ui-iteration\"]) {\n continue;\n }\n\n const baseSchema = propSchema as PropertySchema;\n const propConfig = config[key];\n\n if (!propConfig) {\n properties[key] = createFlexibleSchema(baseSchema);\n continue;\n }\n\n switch (propConfig.mode) {\n case \"array\":\n properties[key] = createArraySchema(propConfig.baseSchema);\n break;\n case \"scalar\":\n properties[key] = propConfig.baseSchema;\n break;\n case \"flexible\":\n default:\n properties[key] = createFlexibleSchema(propConfig.baseSchema);\n break;\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: innerSchema.additionalProperties ?? true,\n } as DataPortSchema;\n }\n\n /**\n * Derives the schema accepted by each iteration of the inner workflow.\n * For root tasks (no incoming edges) all input properties are collected.\n * For non-root tasks, only REQUIRED properties that are not satisfied by\n * any internal dataflow are added — this ensures that required inputs are\n * included in the iterator's input schema without pulling in every optional\n * downstream property.\n */\n protected getInnerInputSchema(): DataPortSchema | undefined {\n if (!this.hasChildren()) return undefined;\n\n const tasks = this.subGraph.getTasks();\n if (tasks.length === 0) return undefined;\n\n const startingNodes = tasks.filter(\n (task) => this.subGraph.getSourceDataflows(task.id).length === 0\n );\n const sources = startingNodes.length > 0 ? startingNodes : tasks;\n\n const properties: Record<string, DataPortSchema> = {};\n const required: string[] = [];\n let additionalProperties = false;\n\n // Collect all properties from root tasks (original behavior)\n for (const task of sources) {\n const inputSchema = task.inputSchema();\n if (typeof inputSchema === \"boolean\") {\n if (inputSchema === true) {\n additionalProperties = true;\n }\n continue;\n }\n\n additionalProperties = additionalProperties || inputSchema.additionalProperties === true;\n\n for (const [key, prop] of Object.entries(inputSchema.properties || {})) {\n if (typeof prop === \"boolean\") continue;\n if (!properties[key]) {\n properties[key] = prop as DataPortSchema;\n }\n }\n\n for (const key of inputSchema.required || []) {\n if (!required.includes(key)) {\n required.push(key);\n }\n }\n }\n\n // For non-root tasks, collect only REQUIRED properties not satisfied by dataflows.\n // This handles cases like: map().fetch().structuralParser() where structuralParser\n // requires \"title\" but fetch doesn't output it — title must come from the map input.\n const sourceIds = new Set(sources.map((t) => t.id));\n for (const task of tasks) {\n if (sourceIds.has(task.id)) continue;\n\n const inputSchema = task.inputSchema();\n if (typeof inputSchema === \"boolean\") continue;\n\n const requiredKeys = new Set<string>((inputSchema.required as string[] | undefined) || []);\n if (requiredKeys.size === 0) continue;\n\n const connectedPorts = new Set(\n this.subGraph.getSourceDataflows(task.id).map((df) => df.targetTaskPortId)\n );\n\n for (const key of requiredKeys) {\n // Skip if already connected via dataflow or already collected from a root task\n if (connectedPorts.has(key)) continue;\n if (properties[key]) continue;\n\n // Skip if the task already has a default value for this property\n // (e.g., .textEmbedding({ model }) stores model in task.defaults)\n if (task.defaults && task.defaults[key] !== undefined) continue;\n\n const prop = (inputSchema.properties || {})[key];\n if (!prop || typeof prop === \"boolean\") continue;\n\n properties[key] = prop as DataPortSchema;\n if (!required.includes(key)) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties,\n } as DataPortSchema;\n }\n\n public getIterationInputSchema(): DataPortSchema {\n if (this._iterationInputSchema) {\n return this._iterationInputSchema;\n }\n\n this._iterationInputSchema = this.iterationInputConfig\n ? this.buildConfiguredIterationInputSchema()\n : this.buildDefaultIterationInputSchema();\n\n return this._iterationInputSchema;\n }\n\n public setIterationInputSchema(schema: DataPortSchema): void {\n this._iterationInputSchema = schema;\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n public setPropertyInputMode(\n propertyName: string,\n mode: IterationInputMode,\n baseSchema?: PropertySchema\n ): void {\n const currentSchema = this.getIterationInputSchema();\n if (typeof currentSchema === \"boolean\") return;\n\n const currentProps = (currentSchema.properties || {}) as Record<string, PropertySchema>;\n const existingProp = currentProps[propertyName];\n const base: PropertySchema =\n baseSchema ?? (existingProp ? extractBaseSchema(existingProp) : { type: \"string\" });\n\n let newPropSchema: PropertySchema;\n switch (mode) {\n case \"array\":\n newPropSchema = createArraySchema(base);\n break;\n case \"scalar\":\n newPropSchema = base;\n break;\n case \"flexible\":\n default:\n newPropSchema = createFlexibleSchema(base);\n break;\n }\n\n this._iterationInputSchema = {\n ...currentSchema,\n properties: {\n ...currentProps,\n [propertyName]: newPropSchema,\n },\n } as DataPortSchema;\n\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n public invalidateIterationInputSchema(): void {\n this._iterationInputSchema = undefined;\n this._iteratorPortInfo = undefined;\n this._inputSchemaNode = undefined;\n }\n\n // ========================================================================\n // Iteration analysis\n // ========================================================================\n\n /**\n * Analyzes input to determine which ports are iterated vs scalar.\n * Precedence:\n * 1) explicit x-ui-iteration annotation\n * 2) schema inference where deterministic\n * 3) runtime value fallback (Array.isArray)\n */\n public analyzeIterationInput(input: Input): IterationAnalysisResult {\n const inputData = input as Record<string, unknown>;\n const schema = this.hasChildren() ? this.getIterationInputSchema() : this.inputSchema();\n const schemaProps: Record<string, DataPortSchema> =\n typeof schema === \"object\" && schema.properties\n ? (schema.properties as Record<string, DataPortSchema>)\n : {};\n\n const keys = new Set([...Object.keys(schemaProps), ...Object.keys(inputData)]);\n\n const arrayPorts: string[] = [];\n const scalarPorts: string[] = [];\n const iteratedValues: Record<string, unknown[]> = {};\n const arrayLengths: number[] = [];\n\n for (const key of keys) {\n if (key.startsWith(\"_iteration\")) continue;\n\n const value = inputData[key];\n const portSchema = schemaProps[key];\n\n let shouldIterate: boolean;\n\n const explicitFlag = getExplicitIterationFlag(portSchema);\n if (explicitFlag !== undefined) {\n shouldIterate = explicitFlag;\n } else {\n const schemaInference = inferIterationFromSchema(portSchema);\n shouldIterate = schemaInference ?? Array.isArray(value);\n }\n\n if (!shouldIterate) {\n scalarPorts.push(key);\n continue;\n }\n\n if (!Array.isArray(value)) {\n throw new TaskConfigurationError(\n `${this.type}: Input '${key}' is configured for iteration but value is not an array.`\n );\n }\n\n iteratedValues[key] = value;\n arrayPorts.push(key);\n arrayLengths.push(value.length);\n }\n\n if (arrayPorts.length === 0) {\n throw new TaskConfigurationError(\n `${this.type}: At least one array input is required for iteration. ` +\n `Mark a port with x-ui-iteration=true, provide array-typed schema, or pass array values at runtime.`\n );\n }\n\n const uniqueLengths = new Set(arrayLengths);\n if (uniqueLengths.size > 1) {\n const lengthInfo = arrayPorts\n .map((port, index) => `${port}=${arrayLengths[index]}`)\n .join(\", \");\n throw new TaskConfigurationError(\n `${this.type}: All iterated array inputs must have the same length (zip semantics). ` +\n `Found different lengths: ${lengthInfo}`\n );\n }\n\n const iterationCount = arrayLengths[0] ?? 0;\n\n const getIterationInput = (index: number): Record<string, unknown> => {\n const iterInput: Record<string, unknown> = {};\n\n for (const key of arrayPorts) {\n iterInput[key] = iteratedValues[key][index];\n }\n\n for (const key of scalarPorts) {\n if (key in inputData) {\n iterInput[key] = inputData[key];\n }\n }\n\n return iterInput;\n };\n\n return {\n iterationCount,\n arrayPorts,\n scalarPorts,\n getIterationInput,\n };\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n public getIterationContextSchema(): DataPortSchema {\n return (this.constructor as typeof IteratorTask).getIterationContextSchema();\n }\n\n public inputSchema(): DataPortSchema {\n if (this.hasChildren()) {\n return this.getIterationInputSchema();\n }\n return (this.constructor as typeof IteratorTask).inputSchema();\n }\n\n public outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof IteratorTask).outputSchema();\n }\n\n return this.getWrappedOutputSchema();\n }\n\n protected getWrappedOutputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return { type: \"object\", properties: {}, additionalProperties: false };\n }\n\n const endingNodes = this.subGraph\n .getTasks()\n .filter((task) => this.subGraph.getTargetDataflows(task.id).length === 0);\n\n if (endingNodes.length === 0) {\n return { type: \"object\", properties: {}, additionalProperties: false };\n }\n\n const properties: Record<string, unknown> = {};\n\n for (const task of endingNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") continue;\n\n for (const [key, schema] of Object.entries(taskOutputSchema.properties || {})) {\n properties[key] = {\n type: \"array\",\n items: schema,\n };\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n}\n",
26
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport { FallbackTaskRunner } from \"./FallbackTaskRunner\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\n\n// ============================================================================\n// Types and Interfaces\n// ============================================================================\n\n/**\n * Execution mode for the fallback task.\n *\n * - `\"task\"`: Each task in the subgraph is an independent alternative.\n * They are tried sequentially until one succeeds.\n *\n * - `\"data\"`: The subgraph contains a template workflow that is executed\n * multiple times with different input overrides from the `alternatives` array.\n */\nexport type FallbackMode = \"task\" | \"data\";\n\nexport const fallbackTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n fallbackMode: { type: \"string\", enum: [\"task\", \"data\"] },\n alternatives: { type: \"array\", items: { type: \"object\", additionalProperties: true } },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration type for FallbackTask.\n * Extends GraphAsTaskConfig with fallback-specific options.\n */\nexport type FallbackTaskConfig = GraphAsTaskConfig & {\n /**\n * The fallback execution mode.\n * - `\"task\"`: Try each task in the subgraph as an alternative.\n * - `\"data\"`: Try the template workflow with each set of input overrides.\n * @default \"task\"\n */\n readonly fallbackMode?: FallbackMode;\n\n /**\n * Array of input overrides for data mode.\n * Each entry is merged with the task input before running the template.\n * Only used when `fallbackMode` is `\"data\"`.\n *\n * @example\n * ```typescript\n * alternatives: [\n * { model: \"openai:gpt-4\" },\n * { model: \"anthropic:claude-sonnet-4-20250514\" },\n * { model: \"onnx:Xenova/LaMini-Flan-T5-783M:q8\" },\n * ]\n * ```\n */\n readonly alternatives?: Record<string, unknown>[];\n};\n\n// ============================================================================\n// FallbackTask Class\n// ============================================================================\n\n/**\n * A task that tries multiple alternatives and returns the first successful result.\n *\n * FallbackTask provides resilient execution by automatically falling back to\n * alternative strategies when one fails. This is essential for production AI\n * workflows where provider availability is unpredictable.\n *\n * ## Execution Modes\n *\n * ### Task Mode (`fallbackMode: \"task\"`)\n * Each task added to the subgraph is an independent alternative. They are\n * tried sequentially in insertion order. The first successful result is\n * returned and remaining alternatives are skipped.\n *\n * ```typescript\n * // Via Workflow API:\n * workflow\n * .fallback()\n * .notifySlack({ channel: \"#alerts\", message: \"Hello\" })\n * .notifyEmail({ to: \"admin@example.com\", subject: \"Alert\" })\n * .notifySms({ phone: \"+1234567890\", message: \"Alert\" })\n * .endFallback();\n * ```\n *\n * ### Data Mode (`fallbackMode: \"data\"`)\n * The subgraph contains a template workflow that is executed multiple times,\n * each time with different input data merged from the `alternatives` array.\n *\n * ```typescript\n * // Via Workflow API:\n * workflow\n * .fallbackWith([\n * { model: \"openai:gpt-4\" },\n * { model: \"anthropic:claude-sonnet-4-20250514\" },\n * { model: \"onnx:Xenova/LaMini-Flan-T5-783M:q8\" },\n * ])\n * .textGeneration({ prompt: \"Hello\" })\n * .endFallbackWith();\n * ```\n *\n * ## Error Handling\n *\n * If all alternatives fail, a `TaskFailedError` is thrown with a message\n * that includes all individual error messages. Each attempt's error is\n * collected and reported for debugging.\n *\n * ## Output\n *\n * The output is the result from whichever alternative succeeded first.\n * The output schema matches the inner tasks' output schema.\n */\nexport class FallbackTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends FallbackTaskConfig = FallbackTaskConfig,\n> extends GraphAsTask<Input, Output, Config> {\n // ========================================================================\n // Static properties\n // ========================================================================\n\n public static type: TaskTypeName = \"FallbackTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Fallback\";\n public static description: string = \"Try alternatives until one succeeds\";\n\n /** FallbackTask has dynamic schemas based on the subgraph structure. */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return fallbackTaskConfigSchema;\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: FallbackTaskRunner<Input, Output, Config>;\n\n override get runner(): FallbackTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new FallbackTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Config accessors\n // ========================================================================\n\n public get fallbackMode(): FallbackMode {\n return this.config?.fallbackMode ?? \"task\";\n }\n\n public get alternatives(): Record<string, unknown>[] {\n return this.config?.alternatives ?? [];\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n /**\n * In task mode, input schema is the union of all alternative tasks' inputs.\n * In data mode, input schema comes from the template workflow's starting nodes.\n */\n public override inputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof FallbackTask).inputSchema();\n }\n\n if (this.fallbackMode === \"data\") {\n // Data mode: use the base GraphAsTask logic (union of starting node inputs)\n return super.inputSchema();\n }\n\n // Task mode: union of all tasks' input schemas (they are independent alternatives)\n const properties: Record<string, unknown> = {};\n const tasks = this.subGraph.getTasks();\n\n for (const task of tasks) {\n const taskInputSchema = task.inputSchema();\n if (typeof taskInputSchema === \"boolean\") continue;\n const taskProperties = taskInputSchema.properties || {};\n\n for (const [inputName, inputProp] of Object.entries(taskProperties)) {\n if (!properties[inputName]) {\n properties[inputName] = inputProp;\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: true,\n } as DataPortSchema;\n }\n\n /**\n * Output schema is derived from the first task in the subgraph.\n * All alternatives should produce compatible output.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof FallbackTask).outputSchema();\n }\n\n const tasks = this.subGraph.getTasks();\n if (tasks.length === 0) {\n return { type: \"object\", properties: {}, additionalProperties: false } as DataPortSchema;\n }\n\n if (this.fallbackMode === \"task\") {\n // Task mode: use the first task's output schema (all alternatives should be compatible)\n const firstTask = tasks[0];\n return firstTask.outputSchema();\n }\n\n // Data mode: use the ending nodes' output schema via base class logic\n return super.outputSchema();\n }\n\n // ========================================================================\n // Serialization\n // ========================================================================\n\n public override toJSON() {\n const json = super.toJSON();\n return {\n ...json,\n config: {\n ...(\"config\" in json ? json.config : {}),\n fallbackMode: this.fallbackMode,\n ...(this.alternatives.length > 0 ? { alternatives: this.alternatives } : {}),\n },\n };\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a task-mode fallback block. Each task added inside the block\n * is an independent alternative tried sequentially until one succeeds.\n * Use `.endFallback()` to close the block and return to the parent workflow.\n */\n fallback: CreateLoopWorkflow<TaskInput, TaskOutput, FallbackTaskConfig>;\n\n /**\n * Ends the task-mode fallback block and returns to the parent workflow.\n */\n endFallback(): Workflow;\n\n /**\n * Starts a data-mode fallback block. The tasks added inside the block\n * form a template workflow that is re-run with each set of input overrides\n * from `alternatives`. Use `.endFallbackWith()` to close the block.\n *\n * @param alternatives - Array of input override objects to try sequentially\n */\n fallbackWith(alternatives: Record<string, unknown>[]): Workflow;\n\n /**\n * Ends the data-mode fallback block and returns to the parent workflow.\n */\n endFallbackWith(): Workflow;\n }\n}\n\nqueueMicrotask(() => {\n Workflow.prototype.fallback = function (this: Workflow): Workflow {\n return this.addLoopTask(FallbackTask, { fallbackMode: \"task\" });\n };\n Workflow.prototype.endFallback = CreateEndLoopWorkflow(\"endFallback\");\n\n Workflow.prototype.fallbackWith = function (\n this: Workflow,\n alternatives: Record<string, unknown>[]\n ): Workflow {\n return this.addLoopTask(FallbackTask, {\n fallbackMode: \"data\",\n alternatives,\n });\n };\n Workflow.prototype.endFallbackWith = CreateEndLoopWorkflow(\"endFallbackWith\");\n});\n",
30
27
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { uuid4 } from \"@workglow/util\";\nimport { Dataflow } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { GraphAsTaskRunner } from \"./GraphAsTaskRunner\";\nimport type { ITask, ITaskConstructor } from \"./ITask\";\nimport type { IterationAnalysisResult, IteratorTask, IteratorTaskConfig } from \"./IteratorTask\";\nimport type { TaskInput, TaskOutput } from \"./TaskTypes\";\n\n/**\n * Runner for IteratorTask that executes a single subgraph repeatedly with\n * per-iteration inputs. The task defines iteration analysis/collection hooks,\n * while this runner owns scheduling and execution orchestration.\n */\nexport class IteratorTaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends IteratorTaskConfig = IteratorTaskConfig,\n> extends GraphAsTaskRunner<Input, Output, Config> {\n declare task: IteratorTask<Input, Output, Config>;\n\n /** When true, {@link executeSubgraphIteration} folds inner progress into parent MapTask %. */\n private aggregatingParentMapProgress = false;\n private mapPartialProgress: number[] = [];\n private mapPartialIterationCount = 0;\n\n /**\n * For iterator tasks, reactive runs use full execution for correctness.\n */\n\n protected override async executeTask(input: Input): Promise<Output | undefined> {\n const analysis = this.task.analyzeIterationInput(input);\n\n if (analysis.iterationCount === 0) {\n const emptyResult = this.task.getEmptyResult();\n return this.executeTaskReactive(input, emptyResult as Output);\n }\n\n const result = this.task.isReduceTask()\n ? await this.executeReduceIterations(analysis)\n : await this.executeCollectIterations(analysis);\n\n return this.executeTaskReactive(input, result as Output);\n }\n\n /**\n * Iterator tasks should only run the task's reactive hook here.\n */\n public override async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n const reactiveResult = await this.task.executeReactive(input, output, { own: this.own });\n return Object.assign({}, output, reactiveResult ?? {}) as Output;\n }\n\n protected async executeCollectIterations(analysis: IterationAnalysisResult): Promise<Output> {\n const iterationCount = analysis.iterationCount;\n const preserveOrder = this.task.preserveIterationOrder();\n\n const batchSize =\n this.task.batchSize !== undefined && this.task.batchSize > 0\n ? this.task.batchSize\n : iterationCount;\n\n const requestedConcurrency = this.task.concurrencyLimit ?? iterationCount;\n const concurrency = Math.max(1, Math.min(requestedConcurrency, iterationCount));\n\n const orderedResults: Array<TaskOutput | undefined> = preserveOrder\n ? new Array(iterationCount)\n : [];\n const completionOrderResults: TaskOutput[] = [];\n\n this.aggregatingParentMapProgress = true;\n this.mapPartialIterationCount = iterationCount;\n this.mapPartialProgress = new Array(iterationCount).fill(0);\n\n try {\n for (let batchStart = 0; batchStart < iterationCount; batchStart += batchSize) {\n if (this.abortController?.signal.aborted) {\n break;\n }\n\n const batchEnd = Math.min(batchStart + batchSize, iterationCount);\n const batchIndices = Array.from(\n { length: batchEnd - batchStart },\n (_, i) => batchStart + i\n );\n\n const batchResults = await this.executeBatch(\n batchIndices,\n analysis,\n iterationCount,\n concurrency,\n undefined\n );\n\n for (const { index, result } of batchResults) {\n if (result === undefined) continue;\n\n if (preserveOrder) {\n orderedResults[index] = result;\n } else {\n completionOrderResults.push(result);\n }\n }\n }\n\n const collected = preserveOrder\n ? orderedResults.filter((result): result is TaskOutput => result !== undefined)\n : completionOrderResults;\n\n return this.task.collectResults(collected);\n } finally {\n this.aggregatingParentMapProgress = false;\n }\n }\n\n /**\n * Updates parent MapTask / workflow progress from per-iteration partial completion (0–100 each).\n */\n private emitMapParentProgressFromPartials(childMessage?: string): void {\n const n = this.mapPartialIterationCount;\n if (n <= 0) return;\n const sum = this.mapPartialProgress.reduce((a, b) => a + b, 0);\n const overall = Math.round(sum / n);\n const done = this.mapPartialProgress.filter((v) => v >= 100).length;\n const base = `Map ${done}/${n}`;\n const msg = childMessage ? `${base} — ${childMessage}` : `${base} iterations`;\n void this.handleProgress(overall, msg);\n }\n\n protected async executeReduceIterations(analysis: IterationAnalysisResult): Promise<Output> {\n const iterationCount = analysis.iterationCount;\n let accumulator = this.task.getInitialAccumulator();\n\n for (let index = 0; index < iterationCount; index++) {\n if (this.abortController?.signal.aborted) {\n break;\n }\n\n const iterationInput = this.task.buildIterationRunInput(analysis, index, iterationCount, {\n accumulator,\n });\n\n const iterationResult = await this.executeSubgraphIteration(\n iterationInput,\n index,\n iterationCount\n );\n accumulator = this.task.mergeIterationIntoAccumulator(accumulator, iterationResult, index);\n\n const progress = Math.round(((index + 1) / iterationCount) * 100);\n await this.handleProgress(progress, `Completed ${index + 1}/${iterationCount} iterations`);\n }\n\n return accumulator;\n }\n\n protected async executeBatch(\n indices: number[],\n analysis: IterationAnalysisResult,\n iterationCount: number,\n concurrency: number,\n onItemComplete?: () => Promise<void>\n ): Promise<Array<{ index: number; result: TaskOutput | undefined }>> {\n const results: Array<{ index: number; result: TaskOutput | undefined }> = [];\n let cursor = 0;\n\n const workerCount = Math.max(1, Math.min(concurrency, indices.length));\n\n const workers = Array.from({ length: workerCount }, async () => {\n while (true) {\n if (this.abortController?.signal.aborted) {\n return;\n }\n\n const position = cursor;\n cursor += 1;\n\n if (position >= indices.length) {\n return;\n }\n\n const index = indices[position];\n const iterationInput = this.task.buildIterationRunInput(analysis, index, iterationCount);\n const result = await this.executeSubgraphIteration(iterationInput, index, iterationCount);\n results.push({ index, result });\n await onItemComplete?.();\n }\n });\n\n await Promise.all(workers);\n return results;\n }\n\n /**\n * Clones a TaskGraph by reconstructing each task from its constructor,\n * defaults, and config. This preserves non-serializable config such as\n * function references (e.g. WhileTask condition functions).\n */\n private cloneGraph(graph: TaskGraph): TaskGraph {\n const clone = new TaskGraph();\n const idMap = new Map<unknown, string>();\n for (const task of graph.getTasks()) {\n const ctor = task.constructor as ITaskConstructor<any, any, any>;\n const newId = uuid4();\n idMap.set(task.config.id, newId);\n const clonedConfig = { ...task.config, id: newId };\n const newTask = new ctor(task.defaults, clonedConfig, task.runConfig);\n if (task.hasChildren()) {\n newTask.subGraph = this.cloneGraph(task.subGraph);\n }\n clone.addTask(newTask);\n }\n for (const df of graph.getDataflows()) {\n clone.addDataflow(\n new Dataflow(\n idMap.get(df.sourceTaskId) ?? df.sourceTaskId,\n df.sourceTaskPortId,\n idMap.get(df.targetTaskId) ?? df.targetTaskId,\n df.targetTaskPortId\n )\n );\n }\n return clone;\n }\n\n protected async executeSubgraphIteration(\n input: Record<string, unknown>,\n index: number,\n iterationCount: number\n ): Promise<TaskOutput | undefined> {\n if (this.abortController?.signal.aborted) {\n return undefined;\n }\n\n const graphClone = this.cloneGraph(this.task.subGraph);\n\n this.task.emit(\"iteration_start\", index, iterationCount);\n\n /**\n * Per-task `progress` (0–100), not {@link TaskGraph}'s `graph_progress`, which averages\n * `task.progress` across nodes when `getTasks().length > 1` (e.g. one task at 100% and\n * three at 0% becomes 25% — wrong for iteration sub-rows).\n */\n const taskProgressUnsubs: Array<{ task: ITask; fn: (p: number, m?: string) => void }> = [];\n for (const t of graphClone.getTasks()) {\n const fn = (p: number, message?: string): void => {\n this.task.emit(\"iteration_progress\", index, iterationCount, p, message);\n if (this.aggregatingParentMapProgress && this.mapPartialIterationCount > 0) {\n this.mapPartialProgress[index] = Math.max(this.mapPartialProgress[index] ?? 0, p);\n this.emitMapParentProgressFromPartials(message);\n }\n };\n t.events.on(\"progress\", fn);\n taskProgressUnsubs.push({ task: t, fn });\n }\n\n try {\n const results = await graphClone.run<TaskOutput>(input as TaskInput, {\n parentSignal: this.abortController?.signal,\n outputCache: this.outputCache,\n registry: this.registry,\n });\n\n if (results.length === 0) {\n return undefined;\n }\n\n return graphClone.mergeExecuteOutputsToRunOutput(\n results,\n this.task.compoundMerge\n ) as TaskOutput;\n } finally {\n for (const { task, fn } of taskProgressUnsubs) {\n task.events.off(\"progress\", fn);\n }\n if (this.aggregatingParentMapProgress && this.mapPartialIterationCount > 0) {\n this.mapPartialProgress[index] = 100;\n this.emitMapParentProgressFromPartials();\n }\n this.task.emit(\"iteration_complete\", index, iterationCount);\n }\n }\n}\n",
31
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport { evaluateCondition, getNestedValue } from \"./ConditionUtils\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { IExecuteContext } from \"./ITask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError } from \"./TaskError\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\nimport { WhileTaskRunner } from \"./WhileTaskRunner\";\n\n/**\n * WhileTask context schema - only has index since count is unknown ahead of time.\n * Properties are marked with \"x-ui-iteration\": true so the builder\n * knows to hide them from parent-level display.\n */\nexport const WHILE_CONTEXT_SCHEMA: DataPortSchema = {\n type: \"object\",\n properties: {\n _iterationIndex: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Number\",\n description: \"Current iteration number (0-based)\",\n \"x-ui-iteration\": true,\n },\n },\n};\n\n/**\n * Condition function type for WhileTask.\n * Receives the current output and iteration count, returns whether to continue looping.\n *\n * @param output - The output from the last iteration\n * @param iteration - The current iteration number (0-based)\n * @returns true to continue looping, false to stop\n */\nexport type WhileConditionFn<Output> = (output: Output, iteration: number) => boolean;\n\nexport const whileTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n condition: {},\n maxIterations: { type: \"integer\", minimum: 1 },\n chainIterations: { type: \"boolean\" },\n conditionField: { type: \"string\" },\n conditionOperator: { type: \"string\" },\n conditionValue: { type: \"string\" },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for WhileTask.\n */\nexport type WhileTaskConfig<Output extends TaskOutput = TaskOutput> = GraphAsTaskConfig & {\n /**\n * Condition function that determines whether to continue looping.\n * Called after each iteration with the current output and iteration count.\n * Returns true to continue, false to stop.\n */\n readonly condition?: WhileConditionFn<Output>;\n\n /**\n * Maximum number of iterations to prevent infinite loops.\n * @default 100\n */\n readonly maxIterations?: number;\n\n /**\n * Whether to pass the output of each iteration as input to the next.\n * When true, output from iteration N becomes input to iteration N+1.\n * @default true\n */\n readonly chainIterations?: boolean;\n\n /** Output field to evaluate for the loop condition. */\n readonly conditionField?: string;\n\n /** Comparison operator for the loop condition. */\n readonly conditionOperator?: string;\n\n /** Value to compare against for the loop condition. */\n readonly conditionValue?: string;\n\n /** Per-property iteration input configuration (scalar/array/flexible). */\n readonly iterationInputConfig?: Record<string, { mode: string; baseSchema?: unknown }>;\n};\n\n/**\n * WhileTask loops until a condition function returns false.\n *\n * This task is useful for:\n * - Iterative refinement processes\n * - Polling until a condition is met\n * - Convergence algorithms\n * - Retry logic with conditions\n *\n * ## Features\n *\n * - Loops until condition returns false\n * - Configurable maximum iterations (safety limit)\n * - Passes output from each iteration to the next\n * - Access to iteration count in condition function\n *\n * ## Usage\n *\n * ```typescript\n * // Refine until quality threshold\n * workflow\n * .while({\n * condition: (output, iteration) => output.quality < 0.9 && iteration < 10,\n * maxIterations: 20\n * })\n * .refineResult()\n * .evaluateQuality()\n * .endWhile()\n *\n * // Retry until success\n * workflow\n * .while({\n * condition: (output) => !output.success,\n * maxIterations: 5\n * })\n * .attemptOperation()\n * .endWhile()\n * ```\n *\n * @template Input - The input type for the while task\n * @template Output - The output type for the while task\n * @template Config - The configuration type\n */\nexport class WhileTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends WhileTaskConfig<Output> = WhileTaskConfig<Output>,\n> extends GraphAsTask<Input, Output, Config> {\n public static type: TaskTypeName = \"WhileTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"While Loop\";\n public static description: string = \"Loops until a condition function returns false\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return whileTaskConfigSchema;\n }\n\n /**\n * Returns the schema for iteration-context inputs that will be\n * injected into the subgraph InputTask at runtime.\n *\n * WhileTask only provides _iterationIndex since the total count\n * is unknown ahead of time.\n */\n public static getIterationContextSchema(): DataPortSchema {\n return WHILE_CONTEXT_SCHEMA;\n }\n\n /**\n * Current iteration count during execution.\n */\n protected _currentIteration: number = 0;\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n super(input, config as Config);\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: WhileTaskRunner<Input, Output, Config>;\n\n override get runner(): WhileTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new WhileTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Configuration Accessors\n // ========================================================================\n\n /**\n * Gets the condition function.\n */\n public get condition(): WhileConditionFn<Output> | undefined {\n return this.config.condition;\n }\n\n /**\n * Gets the maximum iterations limit.\n */\n public get maxIterations(): number {\n return this.config.maxIterations ?? 100;\n }\n\n /**\n * Whether to chain iteration outputs to inputs.\n */\n public get chainIterations(): boolean {\n return this.config.chainIterations ?? true;\n }\n\n /**\n * Gets the current iteration count.\n */\n public get currentIteration(): number {\n return this._currentIteration;\n }\n\n // ========================================================================\n // Execution\n // ========================================================================\n\n /**\n * Execute the while loop.\n */\n /**\n * Builds a condition function from the serialized condition fields in config.\n */\n private buildConditionFromConfig(): WhileConditionFn<Output> | undefined {\n const { conditionOperator, conditionField, conditionValue } = this.config;\n\n if (!conditionOperator) {\n return undefined;\n }\n\n return (output: Output) => {\n const fieldValue = conditionField\n ? getNestedValue(output as Record<string, unknown>, conditionField)\n : output;\n return evaluateCondition(fieldValue, conditionOperator as any, conditionValue ?? \"\");\n };\n }\n\n /**\n * Analyzes the iterationInputConfig from whileConfig to decompose\n * array inputs into per-iteration scalar values.\n *\n * Returns null if no iterationInputConfig is present (normal while behavior).\n */\n private analyzeArrayInputs(input: Input): {\n arrayPorts: string[];\n scalarPorts: string[];\n iteratedValues: Record<string, unknown[]>;\n iterationCount: number;\n } | null {\n if (!this.config.iterationInputConfig) {\n return null;\n }\n\n const inputData = input as Record<string, unknown>;\n const config = this.config.iterationInputConfig!;\n\n const arrayPorts: string[] = [];\n const scalarPorts: string[] = [];\n const iteratedValues: Record<string, unknown[]> = {};\n const arrayLengths: number[] = [];\n\n for (const [key, propConfig] of Object.entries(config)) {\n const value = inputData[key];\n\n if (propConfig.mode === \"array\") {\n if (!Array.isArray(value)) {\n // Skip non-array values for array-mode ports\n scalarPorts.push(key);\n continue;\n }\n iteratedValues[key] = value;\n arrayPorts.push(key);\n arrayLengths.push(value.length);\n } else {\n scalarPorts.push(key);\n }\n }\n\n // Also include any input keys not in the config as scalars\n for (const key of Object.keys(inputData)) {\n if (!config[key] && !key.startsWith(\"_iteration\")) {\n scalarPorts.push(key);\n }\n }\n\n if (arrayPorts.length === 0) {\n return null;\n }\n\n // All array ports must have the same length (zip semantics)\n const uniqueLengths = new Set(arrayLengths);\n if (uniqueLengths.size > 1) {\n const lengthInfo = arrayPorts\n .map((port, index) => `${port}=${arrayLengths[index]}`)\n .join(\", \");\n throw new TaskConfigurationError(\n `${this.type}: All iterated array inputs must have the same length. ` +\n `Found different lengths: ${lengthInfo}`\n );\n }\n\n return {\n arrayPorts,\n scalarPorts,\n iteratedValues,\n iterationCount: arrayLengths[0] ?? 0,\n };\n }\n\n /**\n * Builds per-iteration input by picking the i-th element from each array port\n * and passing scalar ports through unchanged.\n */\n private buildIterationInput(\n input: Input,\n analysis: {\n arrayPorts: string[];\n scalarPorts: string[];\n iteratedValues: Record<string, unknown[]>;\n },\n index: number\n ): Input {\n const inputData = input as Record<string, unknown>;\n const iterInput: Record<string, unknown> = {};\n\n for (const key of analysis.arrayPorts) {\n iterInput[key] = analysis.iteratedValues[key][index];\n }\n\n for (const key of analysis.scalarPorts) {\n if (key in inputData) {\n iterInput[key] = inputData[key];\n }\n }\n\n return iterInput as Input;\n }\n\n public async execute(input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (!this.hasChildren()) {\n throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);\n }\n\n // Use provided condition or auto-build from serialized whileConfig\n const condition = this.condition ?? this.buildConditionFromConfig();\n\n if (!condition) {\n throw new TaskConfigurationError(`${this.type}: No condition function provided`);\n }\n\n // Check for array decomposition via iterationInputConfig\n const arrayAnalysis = this.analyzeArrayInputs(input);\n\n this._currentIteration = 0;\n let currentInput: Input = { ...input };\n let currentOutput: Output = {} as Output;\n\n // Determine effective max iterations (respect array length if decomposing)\n const effectiveMax = arrayAnalysis\n ? Math.min(this.maxIterations, arrayAnalysis.iterationCount)\n : this.maxIterations;\n\n // Execute iterations until condition returns false or max iterations reached\n while (this._currentIteration < effectiveMax) {\n if (context.signal?.aborted) {\n break;\n }\n\n // Build the input for this iteration\n let iterationInput: Input;\n if (arrayAnalysis) {\n // Decompose array inputs into per-iteration scalars\n iterationInput = {\n ...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),\n _iterationIndex: this._currentIteration,\n } as Input;\n } else {\n iterationInput = {\n ...currentInput,\n _iterationIndex: this._currentIteration,\n } as Input;\n }\n\n // Run the subgraph (it resets itself on each run)\n const results = await this.subGraph.run<Output>(iterationInput, {\n parentSignal: context.signal,\n });\n\n // Merge results\n currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n\n // Check condition\n if (!condition(currentOutput, this._currentIteration)) {\n break;\n }\n\n // Chain output to input for next iteration if enabled\n if (this.chainIterations) {\n currentInput = { ...currentInput, ...currentOutput } as Input;\n }\n\n this._currentIteration++;\n\n // Update progress — cap at 99 since the loop may stop before effectiveMax\n const progress = Math.min(Math.round((this._currentIteration / effectiveMax) * 100), 99);\n await context.updateProgress(\n progress,\n `Completed ${this._currentIteration}/${effectiveMax} iterations`\n );\n }\n\n return currentOutput;\n }\n\n /**\n * Streaming execution for WhileTask: runs all iterations except the last\n * normally (materializing), then streams the final iteration's events.\n * This provides streaming output for the final result while still\n * supporting iteration chaining.\n */\n async *executeStream(input: Input, context: IExecuteContext): AsyncIterable<StreamEvent<Output>> {\n if (!this.hasChildren()) {\n throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);\n }\n\n const condition = this.condition ?? this.buildConditionFromConfig();\n if (!condition) {\n throw new TaskConfigurationError(`${this.type}: No condition function provided`);\n }\n\n const arrayAnalysis = this.analyzeArrayInputs(input);\n this._currentIteration = 0;\n let currentInput: Input = { ...input };\n let currentOutput: Output = {} as Output;\n\n const effectiveMax = arrayAnalysis\n ? Math.min(this.maxIterations, arrayAnalysis.iterationCount)\n : this.maxIterations;\n\n while (this._currentIteration < effectiveMax) {\n if (context.signal?.aborted) break;\n\n let iterationInput: Input;\n if (arrayAnalysis) {\n iterationInput = {\n ...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),\n _iterationIndex: this._currentIteration,\n } as Input;\n } else {\n iterationInput = {\n ...currentInput,\n _iterationIndex: this._currentIteration,\n } as Input;\n }\n\n // Check if the NEXT iteration would be the potential last: we always\n // run non-streaming first, then decide after the condition check.\n const results = await this.subGraph.run<Output>(iterationInput, {\n parentSignal: context.signal,\n });\n\n currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n\n if (!condition(currentOutput, this._currentIteration)) {\n // This was the final iteration -- but we already ran it non-streaming.\n // Emit the finish event with the collected output.\n break;\n }\n\n if (this.chainIterations) {\n currentInput = { ...currentInput, ...currentOutput } as Input;\n }\n\n this._currentIteration++;\n\n const progress = Math.min(Math.round((this._currentIteration / effectiveMax) * 100), 99);\n await context.updateProgress(\n progress,\n `Completed ${this._currentIteration}/${effectiveMax} iterations`\n );\n }\n\n yield { type: \"finish\", data: currentOutput } as StreamFinish<Output>;\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n /**\n * Instance method to get the iteration context schema.\n * Can be overridden by subclasses to customize iteration context.\n */\n public getIterationContextSchema(): DataPortSchema {\n return (this.constructor as typeof WhileTask).getIterationContextSchema();\n }\n\n /**\n * When chainIterations is true, the output schema from the previous\n * iteration becomes part of the input schema for the next iteration.\n * These chained properties should be marked with \"x-ui-iteration\": true.\n *\n * @returns Schema with chained output properties marked for iteration, or undefined if not chaining\n */\n public getChainedOutputSchema(): DataPortSchema | undefined {\n if (!this.chainIterations) return undefined;\n\n const outputSchema = this.outputSchema();\n if (typeof outputSchema === \"boolean\") return undefined;\n\n // Clone and mark all properties with x-ui-iteration\n const properties: Record<string, DataPortSchema> = {};\n if (outputSchema.properties && typeof outputSchema.properties === \"object\") {\n for (const [key, schema] of Object.entries(outputSchema.properties)) {\n // Skip the _iterations meta field\n if (key === \"_iterations\") continue;\n if (typeof schema === \"object\" && schema !== null) {\n properties[key] = { ...schema, \"x-ui-iteration\": true } as DataPortSchema;\n }\n }\n }\n\n if (Object.keys(properties).length === 0) return undefined;\n\n return { type: \"object\", properties } as DataPortSchema;\n }\n\n /**\n * Instance input schema override.\n * When iterationInputConfig is present, wraps array-mode ports in array schemas\n * so that the dataflow compatibility check accepts array values.\n */\n public override inputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof WhileTask).inputSchema();\n }\n\n // Get the base schema from the subgraph (GraphAsTask behavior)\n const baseSchema = super.inputSchema();\n if (typeof baseSchema === \"boolean\") return baseSchema;\n\n if (!this.config.iterationInputConfig) {\n return baseSchema;\n }\n\n // Wrap array-mode ports in anyOf (scalar | array) schemas.\n // Using anyOf instead of plain type:\"array\" to avoid addInput's array-merge behavior\n // which would prepend an undefined element when runInputData starts empty.\n const properties = { ...(baseSchema.properties || {}) } as Record<string, DataPortSchema>;\n for (const [key, propConfig] of Object.entries(this.config.iterationInputConfig)) {\n if (propConfig.mode === \"array\" && properties[key]) {\n const scalarSchema = properties[key] as DataPortSchema;\n properties[key] = {\n anyOf: [scalarSchema, { type: \"array\", items: scalarSchema }],\n } as unknown as DataPortSchema;\n }\n }\n\n return {\n ...baseSchema,\n properties,\n } as DataPortSchema;\n }\n\n /**\n * Static input schema for WhileTask.\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Static output schema for WhileTask.\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {\n _iterations: {\n type: \"number\",\n title: \"Iterations\",\n description: \"Number of iterations executed\",\n },\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance output schema - returns final iteration output schema.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof WhileTask).outputSchema();\n }\n\n // Get ending nodes from subgraph\n const tasks = this.subGraph.getTasks();\n const endingNodes = tasks.filter(\n (task) => this.subGraph.getTargetDataflows(task.id).length === 0\n );\n\n if (endingNodes.length === 0) {\n return (this.constructor as typeof WhileTask).outputSchema();\n }\n\n const properties: Record<string, unknown> = {\n _iterations: {\n type: \"number\",\n title: \"Iterations\",\n description: \"Number of iterations executed\",\n },\n };\n\n // Merge output schemas from ending nodes\n for (const task of endingNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") continue;\n\n const taskProperties = taskOutputSchema.properties || {};\n for (const [key, schema] of Object.entries(taskProperties)) {\n if (!properties[key]) {\n properties[key] = schema;\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a while loop that continues until a condition is false.\n * Use .endWhile() to close the loop and return to the parent workflow.\n *\n * @param config - Configuration for the while loop (must include condition)\n * @returns A Workflow in loop builder mode for defining the loop body\n *\n * @example\n * ```typescript\n * workflow\n * .while({\n * condition: (output, iteration) => output.quality < 0.9,\n * maxIterations: 10\n * })\n * .refineResult()\n * .endWhile()\n * ```\n */\n while: CreateLoopWorkflow<TaskInput, TaskOutput, WhileTaskConfig<any>>;\n\n /**\n * Ends the while loop and returns to the parent workflow.\n * Only callable on workflows in loop builder mode.\n *\n * @returns The parent workflow\n */\n endWhile(): Workflow;\n }\n}\n\nWorkflow.prototype.while = CreateLoopWorkflow(WhileTask);\n\nWorkflow.prototype.endWhile = CreateEndLoopWorkflow(\"endWhile\");\n",
28
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema, PropertySchema } from \"@workglow/util/schema\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { IExecuteContext } from \"./ITask\";\nimport { IteratorTaskRunner } from \"./IteratorTaskRunner\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError } from \"./TaskError\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\n\n/**\n * Standard iteration context schema for IteratorTask subclasses (Map, Reduce).\n * Properties are marked with \"x-ui-iteration\": true so the builder\n * knows to hide them from parent-level display.\n */\nexport const ITERATOR_CONTEXT_SCHEMA: DataPortSchema = {\n type: \"object\",\n properties: {\n _iterationIndex: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Index\",\n description: \"Current iteration index (0-based)\",\n \"x-ui-iteration\": true,\n },\n _iterationCount: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Count\",\n description: \"Total number of iterations\",\n \"x-ui-iteration\": true,\n },\n },\n};\n\n/**\n * Execution mode for iterator tasks.\n * - `parallel`: Execute all iterations concurrently (logical mode)\n * - `parallel-limited`: Execute with a concurrency limit\n */\nexport type ExecutionMode = \"parallel\" | \"parallel-limited\";\n\n/**\n * Input mode for a property in the iteration input schema.\n * - \"array\": Property must be an array (will be iterated)\n * - \"scalar\": Property must be a scalar (constant for all iterations)\n * - \"flexible\": Property accepts both array and scalar (T | T[])\n */\nexport type IterationInputMode = \"array\" | \"scalar\" | \"flexible\";\n\n/**\n * Configuration for a single property in the iteration input schema.\n */\nexport interface IterationPropertyConfig {\n /** The base schema for the property (without array wrapping) */\n readonly baseSchema: PropertySchema;\n /** The input mode for this property */\n readonly mode: IterationInputMode;\n}\n\nexport const iteratorTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n concurrencyLimit: { type: \"integer\", minimum: 1 },\n batchSize: { type: \"integer\", minimum: 1 },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration type for IteratorTask.\n * Extends GraphAsTaskConfig with iterator-specific options.\n */\nexport type IteratorTaskConfig = GraphAsTaskConfig & {\n /**\n * Maximum number of concurrent iteration workers\n * @default undefined (unlimited)\n */\n readonly concurrencyLimit?: number;\n\n /**\n * Number of items per batch. When set, iteration indices are grouped into batches.\n * @default undefined\n */\n readonly batchSize?: number;\n\n /**\n * User-defined iteration input schema configuration.\n */\n readonly iterationInputConfig?: Record<string, IterationPropertyConfig>;\n};\n\n/**\n * Result of detecting the iterator port from the input schema.\n */\ninterface IteratorPortInfo {\n readonly portName: string;\n readonly itemSchema: DataPortSchema;\n}\n\n/**\n * Result of analyzing input for iteration.\n */\nexport interface IterationAnalysisResult {\n /** The number of iterations to perform */\n readonly iterationCount: number;\n /** Names of properties that are arrays (to be iterated) */\n readonly arrayPorts: string[];\n /** Names of properties that are scalars (passed as constants) */\n readonly scalarPorts: string[];\n /** Gets the input for a specific iteration index */\n getIterationInput(index: number): Record<string, unknown>;\n}\n\nfunction isArrayVariant(schema: unknown): boolean {\n if (!schema || typeof schema !== \"object\") return false;\n const record = schema as Record<string, unknown>;\n return record.type === \"array\" || record.items !== undefined;\n}\n\nfunction getExplicitIterationFlag(schema: DataPortSchema | undefined): boolean | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n const record = schema as Record<string, unknown>;\n const flag = record[\"x-ui-iteration\"];\n if (flag === true) return true;\n if (flag === false) return false;\n return undefined;\n}\n\nfunction inferIterationFromSchema(schema: DataPortSchema | undefined): boolean | undefined {\n if (!schema || typeof schema !== \"object\") return undefined;\n\n const record = schema as Record<string, unknown>;\n\n if (record.type === \"array\" || record.items !== undefined) {\n return true;\n }\n\n const variants = (record.oneOf ?? record.anyOf) as unknown[] | undefined;\n if (!Array.isArray(variants) || variants.length === 0) {\n // Schema does not clearly indicate array/non-array - defer to runtime\n if (record.type !== undefined) {\n return false;\n }\n return undefined;\n }\n\n let hasArrayVariant = false;\n let hasNonArrayVariant = false;\n\n for (const variant of variants) {\n if (isArrayVariant(variant)) {\n hasArrayVariant = true;\n } else {\n hasNonArrayVariant = true;\n }\n }\n\n if (hasArrayVariant && hasNonArrayVariant) return undefined;\n if (hasArrayVariant) return true;\n return false;\n}\n\n/**\n * Creates a union type schema (T | T[]) for flexible iteration input.\n */\nexport function createFlexibleSchema(baseSchema: PropertySchema): PropertySchema {\n return {\n anyOf: [baseSchema, { type: \"array\", items: baseSchema }],\n } as PropertySchema;\n}\n\n/**\n * Creates an array schema from a base schema.\n */\nexport function createArraySchema(baseSchema: PropertySchema): PropertySchema {\n return {\n type: \"array\",\n items: baseSchema,\n } as PropertySchema;\n}\n\n/**\n * Extracts the base (scalar) schema from a potentially wrapped schema.\n */\nexport function extractBaseSchema(schema: PropertySchema): PropertySchema {\n const schemaType = (schema as Record<string, unknown>).type;\n if (schemaType === \"array\" && (schema as Record<string, unknown>).items) {\n return (schema as Record<string, unknown>).items as PropertySchema;\n }\n\n const variants =\n (schema as Record<string, unknown>).oneOf ?? (schema as Record<string, unknown>).anyOf;\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const variantType = (variant as Record<string, unknown>).type;\n if (variantType !== \"array\") {\n return variant as PropertySchema;\n }\n }\n }\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const variantType = (variant as Record<string, unknown>).type;\n if (variantType === \"array\" && (variant as Record<string, unknown>).items) {\n return (variant as Record<string, unknown>).items as PropertySchema;\n }\n }\n }\n }\n\n return schema;\n}\n\n/**\n * Determines if a schema accepts arrays (is array type or has array in union).\n */\nexport function schemaAcceptsArray(schema: DataPortSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n\n const schemaType = (schema as Record<string, unknown>).type;\n if (schemaType === \"array\") return true;\n\n const variants = (schema.oneOf ?? schema.anyOf) as DataPortSchema[] | undefined;\n if (Array.isArray(variants)) {\n return variants.some((variant) => isArrayVariant(variant));\n }\n\n return false;\n}\n\n/**\n * Base class for iterator tasks that process collections of items.\n */\nexport abstract class IteratorTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends IteratorTaskConfig = IteratorTaskConfig,\n> extends GraphAsTask<Input, Output, Config> {\n public static type: TaskTypeName = \"IteratorTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Iterator\";\n public static description: string = \"Base class for loop-type tasks\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return iteratorTaskConfigSchema;\n }\n\n /**\n * Returns the schema for iteration-context inputs that will be\n * injected into the subgraph at runtime.\n */\n public static getIterationContextSchema(): DataPortSchema {\n return ITERATOR_CONTEXT_SCHEMA;\n }\n\n /** Cached iterator port info from schema analysis. */\n protected _iteratorPortInfo: IteratorPortInfo | undefined;\n\n /** Cached computed iteration input schema. */\n protected _iterationInputSchema: DataPortSchema | undefined;\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n super(input, config as Config);\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: IteratorTaskRunner<Input, Output, Config>;\n\n override get runner(): IteratorTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new IteratorTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n /**\n * IteratorTask does not support streaming pass-through because its output\n * is an aggregation of multiple iterations (arrays for MapTask, accumulated\n * value for ReduceTask). The inherited GraphAsTask.executeStream is\n * overridden to just emit a finish event (no streaming).\n */\n async *executeStream(\n input: Input,\n _context: IExecuteContext\n ): AsyncIterable<StreamEvent<Output>> {\n yield { type: \"finish\", data: input as unknown as Output } as StreamFinish<Output>;\n }\n\n // ========================================================================\n // Graph hooks\n // ========================================================================\n\n override set subGraph(subGraph: TaskGraph) {\n super.subGraph = subGraph;\n this.invalidateIterationInputSchema();\n this.events.emit(\"regenerate\");\n }\n\n override get subGraph(): TaskGraph {\n return super.subGraph;\n }\n\n public override regenerateGraph(): void {\n this.invalidateIterationInputSchema();\n super.regenerateGraph();\n }\n\n // ========================================================================\n // Runner hooks\n // ========================================================================\n\n /**\n * Whether results should be ordered by iteration index.\n * MapTask overrides this to use its `preserveOrder` config.\n */\n public preserveIterationOrder(): boolean {\n return true;\n }\n\n /**\n * Whether this iterator runs in reduce mode.\n */\n public isReduceTask(): boolean {\n return false;\n }\n\n /**\n * Initial accumulator for reduce mode.\n */\n public getInitialAccumulator(): Output {\n return {} as Output;\n }\n\n /**\n * Builds the per-iteration subgraph input.\n */\n public buildIterationRunInput(\n analysis: IterationAnalysisResult,\n index: number,\n iterationCount: number,\n extraInput: Record<string, unknown> = {}\n ): Record<string, unknown> {\n return {\n ...analysis.getIterationInput(index),\n ...extraInput,\n _iterationIndex: index,\n _iterationCount: iterationCount,\n };\n }\n\n /**\n * Updates the accumulator with one iteration result in reduce mode.\n */\n public mergeIterationIntoAccumulator(\n accumulator: Output,\n iterationResult: TaskOutput | undefined,\n _index: number\n ): Output {\n return (iterationResult ?? accumulator) as Output;\n }\n\n /**\n * Returns the result when there are no items to iterate.\n */\n public getEmptyResult(): Output {\n return {} as Output;\n }\n\n /**\n * Collects and merges results from all iterations.\n */\n public collectResults(results: TaskOutput[]): Output {\n if (results.length === 0) {\n return {} as Output;\n }\n\n const merged: Record<string, unknown[]> = {};\n\n for (const result of results) {\n if (!result || typeof result !== \"object\") continue;\n\n for (const [key, value] of Object.entries(result as Record<string, unknown>)) {\n if (!merged[key]) {\n merged[key] = [];\n }\n merged[key].push(value);\n }\n }\n\n return merged as Output;\n }\n\n // ========================================================================\n // Execution Mode Configuration\n // ========================================================================\n\n public get concurrencyLimit(): number | undefined {\n return this.config.concurrencyLimit;\n }\n\n public get batchSize(): number | undefined {\n return this.config.batchSize;\n }\n\n // ========================================================================\n // Iteration Input Schema Management\n // ========================================================================\n\n public get iterationInputConfig(): Record<string, IterationPropertyConfig> | undefined {\n return this.config.iterationInputConfig;\n }\n\n protected buildDefaultIterationInputSchema(): DataPortSchema {\n const innerSchema = this.getInnerInputSchema();\n if (!innerSchema || typeof innerSchema === \"boolean\") {\n return { type: \"object\", properties: {}, additionalProperties: true };\n }\n\n const properties: Record<string, PropertySchema> = {};\n const innerProps = innerSchema.properties || {};\n\n for (const [key, propSchema] of Object.entries(innerProps)) {\n if (typeof propSchema === \"boolean\") continue;\n\n if ((propSchema as Record<string, unknown>)[\"x-ui-iteration\"]) {\n continue;\n }\n\n const baseSchema = propSchema as PropertySchema;\n properties[key] = createFlexibleSchema(baseSchema);\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: innerSchema.additionalProperties ?? true,\n } as DataPortSchema;\n }\n\n protected buildConfiguredIterationInputSchema(): DataPortSchema {\n const innerSchema = this.getInnerInputSchema();\n if (!innerSchema || typeof innerSchema === \"boolean\") {\n return { type: \"object\", properties: {}, additionalProperties: true };\n }\n\n const config = this.iterationInputConfig || {};\n const properties: Record<string, PropertySchema> = {};\n const innerProps = innerSchema.properties || {};\n\n for (const [key, propSchema] of Object.entries(innerProps)) {\n if (typeof propSchema === \"boolean\") continue;\n\n if ((propSchema as Record<string, unknown>)[\"x-ui-iteration\"]) {\n continue;\n }\n\n const baseSchema = propSchema as PropertySchema;\n const propConfig = config[key];\n\n if (!propConfig) {\n properties[key] = createFlexibleSchema(baseSchema);\n continue;\n }\n\n switch (propConfig.mode) {\n case \"array\":\n properties[key] = createArraySchema(propConfig.baseSchema);\n break;\n case \"scalar\":\n properties[key] = propConfig.baseSchema;\n break;\n case \"flexible\":\n default:\n properties[key] = createFlexibleSchema(propConfig.baseSchema);\n break;\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: innerSchema.additionalProperties ?? true,\n } as DataPortSchema;\n }\n\n /**\n * Derives the schema accepted by each iteration of the inner workflow.\n * For root tasks (no incoming edges) all input properties are collected.\n * For non-root tasks, only REQUIRED properties that are not satisfied by\n * any internal dataflow are added — this ensures that required inputs are\n * included in the iterator's input schema without pulling in every optional\n * downstream property.\n */\n protected getInnerInputSchema(): DataPortSchema | undefined {\n if (!this.hasChildren()) return undefined;\n\n const tasks = this.subGraph.getTasks();\n if (tasks.length === 0) return undefined;\n\n const startingNodes = tasks.filter(\n (task) => this.subGraph.getSourceDataflows(task.id).length === 0\n );\n const sources = startingNodes.length > 0 ? startingNodes : tasks;\n\n const properties: Record<string, DataPortSchema> = {};\n const required: string[] = [];\n let additionalProperties = false;\n\n // Collect all properties from root tasks (original behavior)\n for (const task of sources) {\n const inputSchema = task.inputSchema();\n if (typeof inputSchema === \"boolean\") {\n if (inputSchema === true) {\n additionalProperties = true;\n }\n continue;\n }\n\n additionalProperties = additionalProperties || inputSchema.additionalProperties === true;\n\n for (const [key, prop] of Object.entries(inputSchema.properties || {})) {\n if (typeof prop === \"boolean\") continue;\n if (!properties[key]) {\n properties[key] = prop as DataPortSchema;\n }\n }\n\n for (const key of inputSchema.required || []) {\n if (!required.includes(key)) {\n required.push(key);\n }\n }\n }\n\n // For non-root tasks, collect only REQUIRED properties not satisfied by dataflows.\n // This handles cases like: map().fetch().structuralParser() where structuralParser\n // requires \"title\" but fetch doesn't output it — title must come from the map input.\n const sourceIds = new Set(sources.map((t) => t.id));\n for (const task of tasks) {\n if (sourceIds.has(task.id)) continue;\n\n const inputSchema = task.inputSchema();\n if (typeof inputSchema === \"boolean\") continue;\n\n const requiredKeys = new Set<string>((inputSchema.required as string[] | undefined) || []);\n if (requiredKeys.size === 0) continue;\n\n const connectedPorts = new Set(\n this.subGraph.getSourceDataflows(task.id).map((df) => df.targetTaskPortId)\n );\n\n for (const key of requiredKeys) {\n // Skip if already connected via dataflow or already collected from a root task\n if (connectedPorts.has(key)) continue;\n if (properties[key]) continue;\n\n // Skip if the task already has a default value for this property\n // (e.g., .textEmbedding({ model }) stores model in task.defaults)\n if (task.defaults && task.defaults[key] !== undefined) continue;\n\n const prop = (inputSchema.properties || {})[key];\n if (!prop || typeof prop === \"boolean\") continue;\n\n properties[key] = prop as DataPortSchema;\n if (!required.includes(key)) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n additionalProperties,\n } as DataPortSchema;\n }\n\n public getIterationInputSchema(): DataPortSchema {\n if (this._iterationInputSchema) {\n return this._iterationInputSchema;\n }\n\n this._iterationInputSchema = this.iterationInputConfig\n ? this.buildConfiguredIterationInputSchema()\n : this.buildDefaultIterationInputSchema();\n\n return this._iterationInputSchema;\n }\n\n public setIterationInputSchema(schema: DataPortSchema): void {\n this._iterationInputSchema = schema;\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n public setPropertyInputMode(\n propertyName: string,\n mode: IterationInputMode,\n baseSchema?: PropertySchema\n ): void {\n const currentSchema = this.getIterationInputSchema();\n if (typeof currentSchema === \"boolean\") return;\n\n const currentProps = (currentSchema.properties || {}) as Record<string, PropertySchema>;\n const existingProp = currentProps[propertyName];\n const base: PropertySchema =\n baseSchema ?? (existingProp ? extractBaseSchema(existingProp) : { type: \"string\" });\n\n let newPropSchema: PropertySchema;\n switch (mode) {\n case \"array\":\n newPropSchema = createArraySchema(base);\n break;\n case \"scalar\":\n newPropSchema = base;\n break;\n case \"flexible\":\n default:\n newPropSchema = createFlexibleSchema(base);\n break;\n }\n\n this._iterationInputSchema = {\n ...currentSchema,\n properties: {\n ...currentProps,\n [propertyName]: newPropSchema,\n },\n } as DataPortSchema;\n\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n }\n\n public invalidateIterationInputSchema(): void {\n this._iterationInputSchema = undefined;\n this._iteratorPortInfo = undefined;\n this._inputSchemaNode = undefined;\n }\n\n // ========================================================================\n // Iteration analysis\n // ========================================================================\n\n /**\n * Analyzes input to determine which ports are iterated vs scalar.\n * Precedence:\n * 1) explicit x-ui-iteration annotation\n * 2) schema inference where deterministic\n * 3) runtime value fallback (Array.isArray)\n */\n public analyzeIterationInput(input: Input): IterationAnalysisResult {\n const inputData = input as Record<string, unknown>;\n const schema = this.hasChildren() ? this.getIterationInputSchema() : this.inputSchema();\n const schemaProps: Record<string, DataPortSchema> =\n typeof schema === \"object\" && schema.properties\n ? (schema.properties as Record<string, DataPortSchema>)\n : {};\n\n const keys = new Set([...Object.keys(schemaProps), ...Object.keys(inputData)]);\n\n const arrayPorts: string[] = [];\n const scalarPorts: string[] = [];\n const iteratedValues: Record<string, unknown[]> = {};\n const arrayLengths: number[] = [];\n\n for (const key of keys) {\n if (key.startsWith(\"_iteration\")) continue;\n\n const value = inputData[key];\n const portSchema = schemaProps[key];\n\n let shouldIterate: boolean;\n\n const explicitFlag = getExplicitIterationFlag(portSchema);\n if (explicitFlag !== undefined) {\n shouldIterate = explicitFlag;\n } else {\n const schemaInference = inferIterationFromSchema(portSchema);\n shouldIterate = schemaInference ?? Array.isArray(value);\n }\n\n if (!shouldIterate) {\n scalarPorts.push(key);\n continue;\n }\n\n if (!Array.isArray(value)) {\n throw new TaskConfigurationError(\n `${this.type}: Input '${key}' is configured for iteration but value is not an array.`\n );\n }\n\n iteratedValues[key] = value;\n arrayPorts.push(key);\n arrayLengths.push(value.length);\n }\n\n if (arrayPorts.length === 0) {\n throw new TaskConfigurationError(\n `${this.type}: At least one array input is required for iteration. ` +\n `Mark a port with x-ui-iteration=true, provide array-typed schema, or pass array values at runtime.`\n );\n }\n\n const uniqueLengths = new Set(arrayLengths);\n if (uniqueLengths.size > 1) {\n const lengthInfo = arrayPorts\n .map((port, index) => `${port}=${arrayLengths[index]}`)\n .join(\", \");\n throw new TaskConfigurationError(\n `${this.type}: All iterated array inputs must have the same length (zip semantics). ` +\n `Found different lengths: ${lengthInfo}`\n );\n }\n\n const iterationCount = arrayLengths[0] ?? 0;\n\n const getIterationInput = (index: number): Record<string, unknown> => {\n const iterInput: Record<string, unknown> = {};\n\n for (const key of arrayPorts) {\n iterInput[key] = iteratedValues[key][index];\n }\n\n for (const key of scalarPorts) {\n if (key in inputData) {\n iterInput[key] = inputData[key];\n }\n }\n\n return iterInput;\n };\n\n return {\n iterationCount,\n arrayPorts,\n scalarPorts,\n getIterationInput,\n };\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n public getIterationContextSchema(): DataPortSchema {\n return (this.constructor as typeof IteratorTask).getIterationContextSchema();\n }\n\n public inputSchema(): DataPortSchema {\n if (this.hasChildren()) {\n return this.getIterationInputSchema();\n }\n return (this.constructor as typeof IteratorTask).inputSchema();\n }\n\n public outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof IteratorTask).outputSchema();\n }\n\n return this.getWrappedOutputSchema();\n }\n\n protected getWrappedOutputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return { type: \"object\", properties: {}, additionalProperties: false };\n }\n\n const endingNodes = this.subGraph\n .getTasks()\n .filter((task) => this.subGraph.getTargetDataflows(task.id).length === 0);\n\n if (endingNodes.length === 0) {\n return { type: \"object\", properties: {}, additionalProperties: false };\n }\n\n const properties: Record<string, unknown> = {};\n\n for (const task of endingNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") continue;\n\n for (const [key, schema] of Object.entries(taskOutputSchema.properties || {})) {\n properties[key] = {\n type: \"array\",\n items: schema,\n };\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n}\n",
32
29
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { GraphAsTaskRunner } from \"./GraphAsTaskRunner\";\nimport type { TaskInput, TaskOutput } from \"./TaskTypes\";\nimport type { WhileTask, WhileTaskConfig } from \"./WhileTask\";\n\n/**\n * Runner for WhileTask that delegates to the task's execute() method\n * instead of directly running the subgraph once (which is what\n * GraphAsTaskRunner does by default).\n *\n * This follows the same pattern as IteratorTaskRunner.\n */\nexport class WhileTaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends WhileTaskConfig<Output> = WhileTaskConfig<Output>,\n> extends GraphAsTaskRunner<Input, Output, Config> {\n declare task: WhileTask<Input, Output, Config>;\n\n /**\n * Override executeTask to call the task's execute() method which\n * contains the while-loop logic, rather than the default\n * GraphAsTaskRunner behavior of running the subgraph once.\n */\n protected override async executeTask(input: Input): Promise<Output | undefined> {\n const result = await this.task.execute(input, {\n signal: this.abortController!.signal,\n updateProgress: this.handleProgress.bind(this),\n own: this.own,\n registry: this.registry,\n });\n\n return result;\n }\n\n /**\n * For WhileTask, reactive runs use the task's reactive hook only.\n */\n public override async executeTaskReactive(input: Input, output: Output): Promise<Output> {\n const reactiveResult = await this.task.executeReactive(input, output, { own: this.own });\n return Object.assign({}, output, reactiveResult ?? {}) as Output;\n }\n}\n",
30
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport { evaluateCondition, getNestedValue } from \"./ConditionUtils\";\nimport { GraphAsTask, GraphAsTaskConfig, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { IExecuteContext } from \"./ITask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError } from \"./TaskError\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\nimport { WhileTaskRunner } from \"./WhileTaskRunner\";\n\n/**\n * WhileTask context schema - only has index since count is unknown ahead of time.\n * Properties are marked with \"x-ui-iteration\": true so the builder\n * knows to hide them from parent-level display.\n */\nexport const WHILE_CONTEXT_SCHEMA: DataPortSchema = {\n type: \"object\",\n properties: {\n _iterationIndex: {\n type: \"integer\",\n minimum: 0,\n title: \"Iteration Number\",\n description: \"Current iteration number (0-based)\",\n \"x-ui-iteration\": true,\n },\n },\n};\n\n/**\n * Condition function type for WhileTask.\n * Receives the current output and iteration count, returns whether to continue looping.\n *\n * @param output - The output from the last iteration\n * @param iteration - The current iteration number (0-based)\n * @returns true to continue looping, false to stop\n */\nexport type WhileConditionFn<Output> = (output: Output, iteration: number) => boolean;\n\nexport const whileTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n condition: {},\n maxIterations: { type: \"integer\", minimum: 1 },\n chainIterations: { type: \"boolean\" },\n conditionField: { type: \"string\" },\n conditionOperator: { type: \"string\" },\n conditionValue: { type: \"string\" },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for WhileTask.\n */\nexport type WhileTaskConfig<Output extends TaskOutput = TaskOutput> = GraphAsTaskConfig & {\n /**\n * Condition function that determines whether to continue looping.\n * Called after each iteration with the current output and iteration count.\n * Returns true to continue, false to stop.\n */\n readonly condition?: WhileConditionFn<Output>;\n\n /**\n * Maximum number of iterations to prevent infinite loops.\n * @default 100\n */\n readonly maxIterations?: number;\n\n /**\n * Whether to pass the output of each iteration as input to the next.\n * When true, output from iteration N becomes input to iteration N+1.\n * @default true\n */\n readonly chainIterations?: boolean;\n\n /** Output field to evaluate for the loop condition. */\n readonly conditionField?: string;\n\n /** Comparison operator for the loop condition. */\n readonly conditionOperator?: string;\n\n /** Value to compare against for the loop condition. */\n readonly conditionValue?: string;\n\n /** Per-property iteration input configuration (scalar/array/flexible). */\n readonly iterationInputConfig?: Record<string, { mode: string; baseSchema?: unknown }>;\n};\n\n/**\n * WhileTask loops until a condition function returns false.\n *\n * This task is useful for:\n * - Iterative refinement processes\n * - Polling until a condition is met\n * - Convergence algorithms\n * - Retry logic with conditions\n *\n * ## Features\n *\n * - Loops until condition returns false\n * - Configurable maximum iterations (safety limit)\n * - Passes output from each iteration to the next\n * - Access to iteration count in condition function\n *\n * ## Usage\n *\n * ```typescript\n * // Refine until quality threshold\n * workflow\n * .while({\n * condition: (output, iteration) => output.quality < 0.9 && iteration < 10,\n * maxIterations: 20\n * })\n * .refineResult()\n * .evaluateQuality()\n * .endWhile()\n *\n * // Retry until success\n * workflow\n * .while({\n * condition: (output) => !output.success,\n * maxIterations: 5\n * })\n * .attemptOperation()\n * .endWhile()\n * ```\n *\n * @template Input - The input type for the while task\n * @template Output - The output type for the while task\n * @template Config - The configuration type\n */\nexport class WhileTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends WhileTaskConfig<Output> = WhileTaskConfig<Output>,\n> extends GraphAsTask<Input, Output, Config> {\n public static type: TaskTypeName = \"WhileTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"While Loop\";\n public static description: string = \"Loops until a condition function returns false\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static hasDynamicSchemas: boolean = true;\n\n public static configSchema(): DataPortSchema {\n return whileTaskConfigSchema;\n }\n\n /**\n * Returns the schema for iteration-context inputs that will be\n * injected into the subgraph InputTask at runtime.\n *\n * WhileTask only provides _iterationIndex since the total count\n * is unknown ahead of time.\n */\n public static getIterationContextSchema(): DataPortSchema {\n return WHILE_CONTEXT_SCHEMA;\n }\n\n /**\n * Current iteration count during execution.\n */\n protected _currentIteration: number = 0;\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n super(input, config as Config);\n }\n\n // ========================================================================\n // TaskRunner Override\n // ========================================================================\n\n declare _runner: WhileTaskRunner<Input, Output, Config>;\n\n override get runner(): WhileTaskRunner<Input, Output, Config> {\n if (!this._runner) {\n this._runner = new WhileTaskRunner<Input, Output, Config>(this);\n }\n return this._runner;\n }\n\n // ========================================================================\n // Configuration Accessors\n // ========================================================================\n\n /**\n * Gets the condition function.\n */\n public get condition(): WhileConditionFn<Output> | undefined {\n return this.config.condition;\n }\n\n /**\n * Gets the maximum iterations limit.\n */\n public get maxIterations(): number {\n return this.config.maxIterations ?? 100;\n }\n\n /**\n * Whether to chain iteration outputs to inputs.\n */\n public get chainIterations(): boolean {\n return this.config.chainIterations ?? true;\n }\n\n /**\n * Gets the current iteration count.\n */\n public get currentIteration(): number {\n return this._currentIteration;\n }\n\n // ========================================================================\n // Execution\n // ========================================================================\n\n /**\n * Execute the while loop.\n */\n /**\n * Builds a condition function from the serialized condition fields in config.\n */\n private buildConditionFromConfig(): WhileConditionFn<Output> | undefined {\n const { conditionOperator, conditionField, conditionValue } = this.config;\n\n if (!conditionOperator) {\n return undefined;\n }\n\n return (output: Output) => {\n const fieldValue = conditionField\n ? getNestedValue(output as Record<string, unknown>, conditionField)\n : output;\n return evaluateCondition(fieldValue, conditionOperator as any, conditionValue ?? \"\");\n };\n }\n\n /**\n * Analyzes the iterationInputConfig from whileConfig to decompose\n * array inputs into per-iteration scalar values.\n *\n * Returns null if no iterationInputConfig is present (normal while behavior).\n */\n private analyzeArrayInputs(input: Input): {\n arrayPorts: string[];\n scalarPorts: string[];\n iteratedValues: Record<string, unknown[]>;\n iterationCount: number;\n } | null {\n if (!this.config.iterationInputConfig) {\n return null;\n }\n\n const inputData = input as Record<string, unknown>;\n const config = this.config.iterationInputConfig!;\n\n const arrayPorts: string[] = [];\n const scalarPorts: string[] = [];\n const iteratedValues: Record<string, unknown[]> = {};\n const arrayLengths: number[] = [];\n\n for (const [key, propConfig] of Object.entries(config)) {\n const value = inputData[key];\n\n if (propConfig.mode === \"array\") {\n if (!Array.isArray(value)) {\n // Skip non-array values for array-mode ports\n scalarPorts.push(key);\n continue;\n }\n iteratedValues[key] = value;\n arrayPorts.push(key);\n arrayLengths.push(value.length);\n } else {\n scalarPorts.push(key);\n }\n }\n\n // Also include any input keys not in the config as scalars\n for (const key of Object.keys(inputData)) {\n if (!config[key] && !key.startsWith(\"_iteration\")) {\n scalarPorts.push(key);\n }\n }\n\n if (arrayPorts.length === 0) {\n return null;\n }\n\n // All array ports must have the same length (zip semantics)\n const uniqueLengths = new Set(arrayLengths);\n if (uniqueLengths.size > 1) {\n const lengthInfo = arrayPorts\n .map((port, index) => `${port}=${arrayLengths[index]}`)\n .join(\", \");\n throw new TaskConfigurationError(\n `${this.type}: All iterated array inputs must have the same length. ` +\n `Found different lengths: ${lengthInfo}`\n );\n }\n\n return {\n arrayPorts,\n scalarPorts,\n iteratedValues,\n iterationCount: arrayLengths[0] ?? 0,\n };\n }\n\n /**\n * Builds per-iteration input by picking the i-th element from each array port\n * and passing scalar ports through unchanged.\n */\n private buildIterationInput(\n input: Input,\n analysis: {\n arrayPorts: string[];\n scalarPorts: string[];\n iteratedValues: Record<string, unknown[]>;\n },\n index: number\n ): Input {\n const inputData = input as Record<string, unknown>;\n const iterInput: Record<string, unknown> = {};\n\n for (const key of analysis.arrayPorts) {\n iterInput[key] = analysis.iteratedValues[key][index];\n }\n\n for (const key of analysis.scalarPorts) {\n if (key in inputData) {\n iterInput[key] = inputData[key];\n }\n }\n\n return iterInput as Input;\n }\n\n public async execute(input: Input, context: IExecuteContext): Promise<Output | undefined> {\n if (!this.hasChildren()) {\n throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);\n }\n\n // Use provided condition or auto-build from serialized whileConfig\n const condition = this.condition ?? this.buildConditionFromConfig();\n\n if (!condition) {\n throw new TaskConfigurationError(`${this.type}: No condition function provided`);\n }\n\n // Check for array decomposition via iterationInputConfig\n const arrayAnalysis = this.analyzeArrayInputs(input);\n\n this._currentIteration = 0;\n let currentInput: Input = { ...input };\n let currentOutput: Output = {} as Output;\n\n // Determine effective max iterations (respect array length if decomposing)\n const effectiveMax = arrayAnalysis\n ? Math.min(this.maxIterations, arrayAnalysis.iterationCount)\n : this.maxIterations;\n\n // Execute iterations until condition returns false or max iterations reached\n while (this._currentIteration < effectiveMax) {\n if (context.signal?.aborted) {\n break;\n }\n\n // Build the input for this iteration\n let iterationInput: Input;\n if (arrayAnalysis) {\n // Decompose array inputs into per-iteration scalars\n iterationInput = {\n ...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),\n _iterationIndex: this._currentIteration,\n } as Input;\n } else {\n iterationInput = {\n ...currentInput,\n _iterationIndex: this._currentIteration,\n } as Input;\n }\n\n // Run the subgraph (it resets itself on each run)\n const results = await this.subGraph.run<Output>(iterationInput, {\n parentSignal: context.signal,\n });\n\n // Merge results\n currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n\n // Check condition\n if (!condition(currentOutput, this._currentIteration)) {\n break;\n }\n\n // Chain output to input for next iteration if enabled\n if (this.chainIterations) {\n currentInput = { ...currentInput, ...currentOutput } as Input;\n }\n\n this._currentIteration++;\n\n // Update progress — cap at 99 since the loop may stop before effectiveMax\n const progress = Math.min(Math.round((this._currentIteration / effectiveMax) * 100), 99);\n await context.updateProgress(\n progress,\n `Completed ${this._currentIteration}/${effectiveMax} iterations`\n );\n }\n\n return currentOutput;\n }\n\n /**\n * Streaming execution for WhileTask: runs all iterations except the last\n * normally (materializing), then streams the final iteration's events.\n * This provides streaming output for the final result while still\n * supporting iteration chaining.\n */\n async *executeStream(input: Input, context: IExecuteContext): AsyncIterable<StreamEvent<Output>> {\n if (!this.hasChildren()) {\n throw new TaskConfigurationError(`${this.type}: No subgraph set for while loop`);\n }\n\n const condition = this.condition ?? this.buildConditionFromConfig();\n if (!condition) {\n throw new TaskConfigurationError(`${this.type}: No condition function provided`);\n }\n\n const arrayAnalysis = this.analyzeArrayInputs(input);\n this._currentIteration = 0;\n let currentInput: Input = { ...input };\n let currentOutput: Output = {} as Output;\n\n const effectiveMax = arrayAnalysis\n ? Math.min(this.maxIterations, arrayAnalysis.iterationCount)\n : this.maxIterations;\n\n while (this._currentIteration < effectiveMax) {\n if (context.signal?.aborted) break;\n\n let iterationInput: Input;\n if (arrayAnalysis) {\n iterationInput = {\n ...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),\n _iterationIndex: this._currentIteration,\n } as Input;\n } else {\n iterationInput = {\n ...currentInput,\n _iterationIndex: this._currentIteration,\n } as Input;\n }\n\n // Check if the NEXT iteration would be the potential last: we always\n // run non-streaming first, then decide after the condition check.\n const results = await this.subGraph.run<Output>(iterationInput, {\n parentSignal: context.signal,\n });\n\n currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(\n results,\n this.compoundMerge\n ) as Output;\n\n if (!condition(currentOutput, this._currentIteration)) {\n // This was the final iteration -- but we already ran it non-streaming.\n // Emit the finish event with the collected output.\n break;\n }\n\n if (this.chainIterations) {\n currentInput = { ...currentInput, ...currentOutput } as Input;\n }\n\n this._currentIteration++;\n\n const progress = Math.min(Math.round((this._currentIteration / effectiveMax) * 100), 99);\n await context.updateProgress(\n progress,\n `Completed ${this._currentIteration}/${effectiveMax} iterations`\n );\n }\n\n yield { type: \"finish\", data: currentOutput } as StreamFinish<Output>;\n }\n\n // ========================================================================\n // Schema Methods\n // ========================================================================\n\n /**\n * Instance method to get the iteration context schema.\n * Can be overridden by subclasses to customize iteration context.\n */\n public getIterationContextSchema(): DataPortSchema {\n return (this.constructor as typeof WhileTask).getIterationContextSchema();\n }\n\n /**\n * When chainIterations is true, the output schema from the previous\n * iteration becomes part of the input schema for the next iteration.\n * These chained properties should be marked with \"x-ui-iteration\": true.\n *\n * @returns Schema with chained output properties marked for iteration, or undefined if not chaining\n */\n public getChainedOutputSchema(): DataPortSchema | undefined {\n if (!this.chainIterations) return undefined;\n\n const outputSchema = this.outputSchema();\n if (typeof outputSchema === \"boolean\") return undefined;\n\n // Clone and mark all properties with x-ui-iteration\n const properties: Record<string, DataPortSchema> = {};\n if (outputSchema.properties && typeof outputSchema.properties === \"object\") {\n for (const [key, schema] of Object.entries(outputSchema.properties)) {\n // Skip the _iterations meta field\n if (key === \"_iterations\") continue;\n if (typeof schema === \"object\" && schema !== null) {\n properties[key] = { ...schema, \"x-ui-iteration\": true } as DataPortSchema;\n }\n }\n }\n\n if (Object.keys(properties).length === 0) return undefined;\n\n return { type: \"object\", properties } as DataPortSchema;\n }\n\n /**\n * Instance input schema override.\n * When iterationInputConfig is present, wraps array-mode ports in array schemas\n * so that the dataflow compatibility check accepts array values.\n */\n public override inputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof WhileTask).inputSchema();\n }\n\n // Get the base schema from the subgraph (GraphAsTask behavior)\n const baseSchema = super.inputSchema();\n if (typeof baseSchema === \"boolean\") return baseSchema;\n\n if (!this.config.iterationInputConfig) {\n return baseSchema;\n }\n\n // Wrap array-mode ports in anyOf (scalar | array) schemas.\n // Using anyOf instead of plain type:\"array\" to avoid addInput's array-merge behavior\n // which would prepend an undefined element when runInputData starts empty.\n const properties = { ...(baseSchema.properties || {}) } as Record<string, DataPortSchema>;\n for (const [key, propConfig] of Object.entries(this.config.iterationInputConfig)) {\n if (propConfig.mode === \"array\" && properties[key]) {\n const scalarSchema = properties[key] as DataPortSchema;\n properties[key] = {\n anyOf: [scalarSchema, { type: \"array\", items: scalarSchema }],\n } as unknown as DataPortSchema;\n }\n }\n\n return {\n ...baseSchema,\n properties,\n } as DataPortSchema;\n }\n\n /**\n * Static input schema for WhileTask.\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Static output schema for WhileTask.\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {\n _iterations: {\n type: \"number\",\n title: \"Iterations\",\n description: \"Number of iterations executed\",\n },\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance output schema - returns final iteration output schema.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof WhileTask).outputSchema();\n }\n\n // Get ending nodes from subgraph\n const tasks = this.subGraph.getTasks();\n const endingNodes = tasks.filter(\n (task) => this.subGraph.getTargetDataflows(task.id).length === 0\n );\n\n if (endingNodes.length === 0) {\n return (this.constructor as typeof WhileTask).outputSchema();\n }\n\n const properties: Record<string, unknown> = {\n _iterations: {\n type: \"number\",\n title: \"Iterations\",\n description: \"Number of iterations executed\",\n },\n };\n\n // Merge output schemas from ending nodes\n for (const task of endingNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") continue;\n\n const taskProperties = taskOutputSchema.properties || {};\n for (const [key, schema] of Object.entries(taskProperties)) {\n if (!properties[key]) {\n properties[key] = schema;\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a while loop that continues until a condition is false.\n * Use .endWhile() to close the loop and return to the parent workflow.\n *\n * @param config - Configuration for the while loop (must include condition)\n * @returns A Workflow in loop builder mode for defining the loop body\n *\n * @example\n * ```typescript\n * workflow\n * .while({\n * condition: (output, iteration) => output.quality < 0.9,\n * maxIterations: 10\n * })\n * .refineResult()\n * .endWhile()\n * ```\n */\n while: CreateLoopWorkflow<TaskInput, TaskOutput, WhileTaskConfig<any>>;\n\n /**\n * Ends the while loop and returns to the parent workflow.\n * Only callable on workflows in loop builder mode.\n *\n * @returns The parent workflow\n */\n endWhile(): Workflow;\n }\n}\n\nWorkflow.prototype.while = CreateLoopWorkflow(WhileTask);\n\nWorkflow.prototype.endWhile = CreateEndLoopWorkflow(\"endWhile\");\n",
33
31
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n *\n * Shared iteration schema helpers used by IteratorTask/WhileTask and the builder.\n * Re-exports context schemas and adds pure schema functions that operate on DataPortSchema.\n */\n\nimport type { DataPortSchema, PropertySchema } from \"@workglow/util/schema\";\n\nimport {\n createArraySchema,\n createFlexibleSchema,\n extractBaseSchema,\n ITERATOR_CONTEXT_SCHEMA,\n type ExecutionMode,\n type IterationInputMode,\n type IterationPropertyConfig,\n} from \"./IteratorTask\";\nimport { WHILE_CONTEXT_SCHEMA } from \"./WhileTask\";\n\nexport {\n createArraySchema,\n createFlexibleSchema,\n extractBaseSchema,\n ITERATOR_CONTEXT_SCHEMA,\n WHILE_CONTEXT_SCHEMA,\n type ExecutionMode,\n type IterationInputMode,\n type IterationPropertyConfig,\n};\n\n/** Config for buildIterationInputSchema: mode and optional baseSchema (defaults to extracted from inner). */\nexport type IterationInputConfig = Record<\n string,\n { mode: IterationInputMode; baseSchema?: PropertySchema }\n>;\n\n/**\n * Determines if a schema is a flexible type (T | T[]).\n */\nexport function isFlexibleSchema(schema: DataPortSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n\n const variants =\n (schema as Record<string, unknown>).oneOf ?? (schema as Record<string, unknown>).anyOf;\n const arr = Array.isArray(variants) ? (variants as DataPortSchema[]) : undefined;\n if (!arr || arr.length !== 2) return false;\n\n let hasScalar = false;\n let hasArray = false;\n\n for (const variant of arr) {\n if (typeof variant !== \"object\") continue;\n const v = variant as Record<string, unknown>;\n if (v.type === \"array\" || \"items\" in v) {\n hasArray = true;\n } else {\n hasScalar = true;\n }\n }\n\n return hasScalar && hasArray;\n}\n\n/**\n * Determines if a schema is strictly an array type.\n */\nexport function isStrictArraySchema(schema: DataPortSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n const s = schema as Record<string, unknown>;\n return s.type === \"array\" && !isFlexibleSchema(schema);\n}\n\n/**\n * Gets the input mode for a schema property.\n */\nexport function getInputModeFromSchema(schema: DataPortSchema): IterationInputMode {\n if (isFlexibleSchema(schema)) return \"flexible\";\n if (isStrictArraySchema(schema)) return \"array\";\n return \"scalar\";\n}\n\n/**\n * Get the appropriate iteration context schema for a given task type.\n */\nexport function getIterationContextSchemaForType(taskType: string): DataPortSchema | undefined {\n if (taskType === \"MapTask\" || taskType === \"ReduceTask\") {\n return ITERATOR_CONTEXT_SCHEMA;\n }\n if (taskType === \"WhileTask\") {\n return WHILE_CONTEXT_SCHEMA;\n }\n return undefined;\n}\n\n/**\n * Merge iteration context schema into an existing InputNode schema.\n */\nexport function addIterationContextToSchema(\n existingSchema: DataPortSchema | undefined,\n parentTaskType: string\n): DataPortSchema {\n const contextSchema = getIterationContextSchemaForType(parentTaskType);\n if (!contextSchema) {\n return existingSchema ?? { type: \"object\", properties: {} };\n }\n\n const baseProperties =\n existingSchema &&\n typeof existingSchema !== \"boolean\" &&\n (existingSchema as Record<string, unknown>).properties &&\n typeof (existingSchema as Record<string, unknown>).properties !== \"boolean\"\n ? ((existingSchema as Record<string, unknown>).properties as Record<string, DataPortSchema>)\n : {};\n\n const contextProperties =\n typeof contextSchema !== \"boolean\" &&\n (contextSchema as Record<string, unknown>).properties &&\n typeof (contextSchema as Record<string, unknown>).properties !== \"boolean\"\n ? ((contextSchema as Record<string, unknown>).properties as Record<string, DataPortSchema>)\n : {};\n\n return {\n type: \"object\",\n properties: {\n ...baseProperties,\n ...contextProperties,\n },\n };\n}\n\n/**\n * Check if a schema property is an iteration-injected input.\n */\nexport function isIterationProperty(schema: PropertySchema): boolean {\n if (!schema || typeof schema === \"boolean\") return false;\n return (schema as Record<string, unknown>)[\"x-ui-iteration\"] === true;\n}\n\n/**\n * Filter out iteration properties from a schema (for parent display).\n */\nexport function filterIterationProperties(schema?: DataPortSchema): DataPortSchema | undefined {\n if (!schema || typeof schema === \"boolean\") return schema;\n const props = (schema as Record<string, unknown>).properties;\n if (!props || typeof props === \"boolean\") return schema;\n\n const filteredProps: Record<string, DataPortSchema> = {};\n for (const [key, propSchema] of Object.entries(props as Record<string, DataPortSchema>)) {\n if (!isIterationProperty(propSchema)) {\n filteredProps[key] = propSchema;\n }\n }\n\n if (Object.keys(filteredProps).length === 0) {\n return { type: \"object\", properties: {} };\n }\n\n return { ...schema, properties: filteredProps } as DataPortSchema;\n}\n\n/**\n * Extract only iteration properties from a schema.\n */\nexport function extractIterationProperties(schema?: DataPortSchema): DataPortSchema | undefined {\n if (!schema || typeof schema === \"boolean\") return undefined;\n const props = (schema as Record<string, unknown>).properties;\n if (!props || typeof props === \"boolean\") return undefined;\n\n const iterProps: Record<string, DataPortSchema> = {};\n for (const [key, propSchema] of Object.entries(props as Record<string, DataPortSchema>)) {\n if (isIterationProperty(propSchema)) {\n iterProps[key] = propSchema;\n }\n }\n\n if (Object.keys(iterProps).length === 0) return undefined;\n\n return { type: \"object\", properties: iterProps };\n}\n\n/**\n * Remove iteration properties from a schema (alias for filterIterationProperties).\n */\nexport function removeIterationProperties(schema?: DataPortSchema): DataPortSchema | undefined {\n return filterIterationProperties(schema);\n}\n\n/**\n * Merge chained output properties into input schema; marks output properties with \"x-ui-iteration\": true.\n */\nexport function mergeChainedOutputToInput(\n inputSchema: DataPortSchema | undefined,\n outputSchema: DataPortSchema | undefined\n): DataPortSchema {\n const baseSchema = filterIterationProperties(inputSchema) ?? {\n type: \"object\" as const,\n properties: {},\n };\n\n if (!outputSchema || typeof outputSchema === \"boolean\") {\n return baseSchema;\n }\n const outProps = (outputSchema as Record<string, unknown>).properties;\n if (!outProps || typeof outProps === \"boolean\") {\n return baseSchema;\n }\n\n const baseProps =\n typeof baseSchema !== \"boolean\" &&\n (baseSchema as Record<string, unknown>).properties &&\n typeof (baseSchema as Record<string, unknown>).properties !== \"boolean\"\n ? ((baseSchema as Record<string, unknown>).properties as Record<string, DataPortSchema>)\n : {};\n\n const mergedProperties: Record<string, DataPortSchema> = { ...baseProps };\n\n for (const [key, propSchema] of Object.entries(outProps as Record<string, DataPortSchema>)) {\n if (typeof propSchema === \"object\" && propSchema !== null) {\n mergedProperties[key] = { ...propSchema, \"x-ui-iteration\": true } as DataPortSchema;\n }\n }\n\n return {\n type: \"object\",\n properties: mergedProperties,\n };\n}\n\n/**\n * Builds the iteration input schema from the inner schema and optional iteration input configuration.\n */\nexport function buildIterationInputSchema(\n innerSchema: DataPortSchema | undefined,\n config?: IterationInputConfig\n): DataPortSchema {\n if (!innerSchema || typeof innerSchema === \"boolean\") {\n return { type: \"object\", properties: {} };\n }\n\n const innerProps = (innerSchema as Record<string, unknown>).properties;\n if (!innerProps || typeof innerProps === \"boolean\") {\n return { type: \"object\", properties: {} };\n }\n\n const properties: Record<string, PropertySchema> = {};\n const propsRecord = innerProps as Record<string, PropertySchema>;\n\n for (const [key, propSchema] of Object.entries(propsRecord)) {\n if (typeof propSchema === \"boolean\") continue;\n\n if ((propSchema as Record<string, unknown>)[\"x-ui-iteration\"]) {\n continue;\n }\n\n const originalProps = propSchema as Record<string, unknown>;\n const metadata: Record<string, unknown> = {};\n for (const metaKey of Object.keys(originalProps)) {\n if (metaKey === \"title\" || metaKey === \"description\" || metaKey.startsWith(\"x-\")) {\n metadata[metaKey] = originalProps[metaKey];\n }\n }\n\n const baseSchema = extractBaseSchema(propSchema);\n const propConfig = config?.[key];\n const mode = propConfig?.mode ?? \"flexible\";\n const base = propConfig?.baseSchema ?? baseSchema;\n\n let wrappedSchema: PropertySchema;\n switch (mode) {\n case \"array\":\n wrappedSchema = createArraySchema(base);\n break;\n case \"scalar\":\n wrappedSchema = base;\n break;\n case \"flexible\":\n default:\n wrappedSchema = createFlexibleSchema(base);\n break;\n }\n\n // Apply preserved metadata onto the wrapped schema\n if (Object.keys(metadata).length > 0 && typeof wrappedSchema === \"object\") {\n properties[key] = { ...metadata, ...wrappedSchema } as PropertySchema;\n } else {\n properties[key] = wrappedSchema;\n }\n }\n\n return {\n type: \"object\",\n properties,\n };\n}\n\n/**\n * Find array-typed ports from an input schema.\n */\nexport function findArrayPorts(schema: DataPortSchema | undefined): string[] {\n if (!schema || typeof schema === \"boolean\") return [];\n const props = (schema as Record<string, unknown>).properties;\n if (!props || typeof props === \"boolean\") return [];\n\n const arrayPorts: string[] = [];\n const propsRecord = props as Record<string, DataPortSchema>;\n\n for (const [key, propSchema] of Object.entries(propsRecord)) {\n if (typeof propSchema === \"boolean\") continue;\n if ((propSchema as Record<string, unknown>).type === \"array\") {\n arrayPorts.push(key);\n }\n }\n\n return arrayPorts;\n}\n\n/**\n * Wrap a schema's properties in arrays for iteration output.\n */\nexport function wrapSchemaInArray(schema: DataPortSchema | undefined): DataPortSchema | undefined {\n if (!schema || typeof schema === \"boolean\") return schema;\n const props = (schema as Record<string, unknown>).properties;\n if (!props || typeof props === \"boolean\") return schema;\n\n const propsRecord = props as Record<string, DataPortSchema>;\n const wrappedProperties: Record<string, DataPortSchema> = {};\n\n for (const [key, propSchema] of Object.entries(propsRecord)) {\n wrappedProperties[key] = {\n type: \"array\",\n items: propSchema,\n } as DataPortSchema;\n }\n\n return {\n type: \"object\",\n properties: wrappedProperties,\n };\n}\n",
34
32
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n Job,\n JobConstructorParam,\n JobQueueClient,\n JobQueueServer,\n JobQueueServerOptions,\n} from \"@workglow/job-queue\";\nimport { InMemoryQueueStorage, IQueueStorage } from \"@workglow/storage\";\nimport { createServiceToken, globalServiceRegistry } from \"@workglow/util\";\nimport type { JobQueueTask, JobQueueTaskConfig } from \"./JobQueueTask\";\nimport type { RegisteredQueue } from \"./TaskQueueRegistry\";\nimport type { TaskInput, TaskOutput } from \"./TaskTypes\";\n\nexport type JobClassConstructor<Input extends TaskInput, Output extends TaskOutput> = new (\n params: JobConstructorParam<Input, Output>\n) => Job<Input, Output>;\n\n/**\n * Options for creating a job queue via the factory\n */\nexport interface JobQueueFactoryOptions<Input, Output> {\n readonly storage?: IQueueStorage<Input, Output>;\n readonly limiter?: JobQueueServerOptions<Input, Output>[\"limiter\"];\n readonly workerCount?: number;\n readonly pollIntervalMs?: number;\n readonly deleteAfterCompletionMs?: number;\n readonly deleteAfterFailureMs?: number;\n readonly deleteAfterDisabledMs?: number;\n readonly cleanupIntervalMs?: number;\n}\n\nexport interface JobQueueFactoryParams<Input extends TaskInput, Output extends TaskOutput> {\n readonly queueName: string;\n readonly jobClass: JobClassConstructor<Input, Output>;\n readonly input?: Input;\n readonly config?: JobQueueTaskConfig;\n readonly task?: JobQueueTask<Input, Output>;\n readonly options?: JobQueueFactoryOptions<Input, Output>;\n}\n\nexport type JobQueueFactory = <Input extends TaskInput, Output extends TaskOutput>(\n params: JobQueueFactoryParams<Input, Output>\n) => Promise<RegisteredQueue<Input, Output>> | RegisteredQueue<Input, Output>;\n\nexport const JOB_QUEUE_FACTORY = createServiceToken<JobQueueFactory>(\"taskgraph.jobQueueFactory\");\n\nconst defaultJobQueueFactory: JobQueueFactory = async <\n Input extends TaskInput,\n Output extends TaskOutput,\n>({\n queueName,\n jobClass,\n options,\n}: JobQueueFactoryParams<Input, Output>): Promise<RegisteredQueue<Input, Output>> => {\n const storage =\n (options?.storage as IQueueStorage<Input, Output>) ??\n new InMemoryQueueStorage<Input, Output>(queueName);\n await storage.setupDatabase();\n\n const server = new JobQueueServer<Input, Output>(jobClass as JobClassConstructor<any, any>, {\n storage,\n queueName,\n limiter: options?.limiter,\n workerCount: options?.workerCount,\n pollIntervalMs: options?.pollIntervalMs,\n deleteAfterCompletionMs: options?.deleteAfterCompletionMs,\n deleteAfterFailureMs: options?.deleteAfterFailureMs,\n deleteAfterDisabledMs: options?.deleteAfterDisabledMs,\n cleanupIntervalMs: options?.cleanupIntervalMs,\n });\n\n const client = new JobQueueClient<Input, Output>({\n storage,\n queueName,\n });\n\n // Attach client to server for same-process optimization\n client.attach(server);\n\n return { server, client, storage };\n};\n\nexport function registerJobQueueFactory(factory: JobQueueFactory): void {\n globalServiceRegistry.registerInstance(JOB_QUEUE_FACTORY, factory);\n}\n\n/**\n * Creates a job queue factory from server options\n */\nexport function createJobQueueFactoryWithOptions(\n defaultOptions: Partial<JobQueueFactoryOptions<unknown, unknown>> = {}\n): JobQueueFactory {\n return async <Input extends TaskInput, Output extends TaskOutput>({\n queueName,\n jobClass,\n options,\n }: JobQueueFactoryParams<Input, Output>): Promise<RegisteredQueue<Input, Output>> => {\n const mergedOptions = {\n ...defaultOptions,\n ...(options ?? {}),\n } as JobQueueFactoryOptions<Input, Output>;\n\n const storage =\n (mergedOptions.storage as IQueueStorage<Input, Output>) ??\n new InMemoryQueueStorage<Input, Output>(queueName);\n await storage.setupDatabase();\n\n const server = new JobQueueServer<Input, Output>(jobClass as JobClassConstructor<any, any>, {\n storage,\n queueName,\n limiter: mergedOptions.limiter,\n workerCount: mergedOptions.workerCount,\n pollIntervalMs: mergedOptions.pollIntervalMs,\n deleteAfterCompletionMs: mergedOptions.deleteAfterCompletionMs,\n deleteAfterFailureMs: mergedOptions.deleteAfterFailureMs,\n deleteAfterDisabledMs: mergedOptions.deleteAfterDisabledMs,\n cleanupIntervalMs: mergedOptions.cleanupIntervalMs,\n });\n\n const client = new JobQueueClient<Input, Output>({\n storage,\n queueName,\n });\n\n // Attach client to server for same-process optimization\n client.attach(server);\n\n return { server, client, storage };\n };\n}\n\nexport function getJobQueueFactory(): JobQueueFactory {\n if (!globalServiceRegistry.has(JOB_QUEUE_FACTORY)) {\n registerJobQueueFactory(defaultJobQueueFactory);\n }\n return globalServiceRegistry.get(JOB_QUEUE_FACTORY);\n}\n\nif (!globalServiceRegistry.has(JOB_QUEUE_FACTORY)) {\n registerJobQueueFactory(defaultJobQueueFactory);\n}\n",
35
33
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Job, JobClass } from \"@workglow/job-queue\";\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { GraphAsTask, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport { IExecuteContext } from \"./ITask\";\nimport { getJobQueueFactory } from \"./JobQueueFactory\";\nimport { JobTaskFailedError, TaskConfigurationError } from \"./TaskError\";\nimport { TaskEventListeners } from \"./TaskEvents\";\nimport { getTaskQueueRegistry, RegisteredQueue } from \"./TaskQueueRegistry\";\nimport { TaskConfig, TaskInput, TaskOutput } from \"./TaskTypes\";\n\nexport const jobQueueTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...graphAsTaskConfigSchema[\"properties\"],\n queue: {\n oneOf: [{ type: \"boolean\" }, { type: \"string\" }],\n description: \"Queue handling: false=run inline, true=use default, string=explicit queue name\",\n \"x-ui-hidden\": true,\n },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration type for JobQueueTask.\n * Extends the base TaskConfig with job queue specific properties.\n */\nexport type JobQueueTaskConfig = TaskConfig & {\n /**\n * Queue selection for the task\n * - `true` (default): create/use the task's default queue\n * - `false`: run directly without queueing (requires `canRunDirectly`)\n * - `string`: use an explicitly registered queue name\n */\n queue?: boolean | string;\n};\n\n/**\n * Extended event listeners for JobQueueTask.\n * Adds progress event handling to base task event listeners.\n */\nexport type JobQueueTaskEventListeners = Omit<TaskEventListeners, \"progress\"> & {\n progress: (progress: number, message?: string, details?: Record<string, any> | null) => void;\n};\n\n/**\n * Abstract base class for tasks that operate within a job queue.\n * Provides functionality for managing job execution, progress tracking, and queue integration.\n *\n * @template Input - Type of input data for the task\n * @template Output - Type of output data produced by the task\n * @template Config - Type of configuration object for the task\n */\nexport abstract class JobQueueTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends JobQueueTaskConfig = JobQueueTaskConfig,\n> extends GraphAsTask<Input, Output, Config> {\n static readonly type: string = \"JobQueueTask\";\n static canRunDirectly = true;\n\n public static configSchema(): DataPortSchema {\n return jobQueueTaskConfigSchema;\n }\n\n /** Name of the queue currently processing the task */\n currentQueueName?: string;\n /** ID of the current job being processed */\n currentJobId?: string | unknown;\n /** ID of the current runner being used */\n currentRunnerId?: string;\n\n public jobClass: JobClass<any, any>;\n\n constructor(input: Partial<Input> = {} as Input, config: Config = {} as Config) {\n config.queue ??= true;\n super(input, config);\n this.jobClass = Job as JobClass<any, any>;\n }\n\n async execute(input: Input, executeContext: IExecuteContext): Promise<Output | undefined> {\n let cleanup: () => void = () => {};\n\n try {\n if (\n this.config.queue === false &&\n !(this.constructor as typeof JobQueueTask).canRunDirectly\n ) {\n throw new TaskConfigurationError(`${this.type} cannot run directly without a queue`);\n }\n\n const registeredQueue = await this.resolveQueue(input);\n\n if (!registeredQueue) {\n // Direct execution without a queue\n if (!(this.constructor as typeof JobQueueTask).canRunDirectly) {\n const queueLabel =\n typeof this.config.queue === \"string\"\n ? this.config.queue\n : (this.currentQueueName ?? this.type);\n throw new TaskConfigurationError(\n `Queue ${queueLabel} not found, and ${this.type} cannot run directly`\n );\n }\n this.currentJobId = undefined;\n\n // Create job for direct execution\n const job = await this.createJob(input, this.currentQueueName);\n cleanup = job.onJobProgress(\n (progress: number, message: string, details: Record<string, any> | null) => {\n executeContext.updateProgress(progress, message, details);\n }\n );\n const output = await job.execute(job.input, {\n signal: executeContext.signal,\n updateProgress: executeContext.updateProgress.bind(this),\n });\n return output;\n }\n\n // Execute via queue\n const { client } = registeredQueue;\n const jobInput = await this.getJobInput(input);\n const handle = await client.submit(jobInput as Input, {\n jobRunId: this.currentRunnerId,\n maxRetries: 10,\n });\n\n this.currentJobId = handle.id;\n this.currentQueueName = client.queueName;\n\n cleanup = handle.onProgress((progress, message, details) => {\n executeContext.updateProgress(progress, message, details);\n });\n\n const output = await handle.waitFor();\n if (output === undefined) {\n throw new TaskConfigurationError(\"Job disabled, should not happen\");\n }\n\n return output as Output;\n } catch (err: any) {\n throw new JobTaskFailedError(err);\n } finally {\n cleanup();\n }\n }\n\n /**\n * Get the input to submit to the job queue.\n * Override this method to transform task input to job input.\n * @param input - The task input\n * @returns The input to submit to the job queue\n */\n protected async getJobInput(input: Input): Promise<unknown> {\n return input;\n }\n\n /**\n * Override this method to create the right job class for direct execution (without a queue).\n * This is used when running the task directly without queueing.\n * @param input - The task input\n * @param queueName - The queue name (if any)\n * @returns Promise<Job> - The created job\n */\n async createJob(input: Input, queueName?: string): Promise<Job<any, Output>> {\n return new this.jobClass({\n queueName: queueName ?? this.currentQueueName,\n jobRunId: this.currentRunnerId, // could be undefined\n input: input,\n });\n }\n\n protected async resolveQueue(input: Input): Promise<RegisteredQueue<Input, Output> | undefined> {\n const preference = this.config.queue ?? true;\n\n if (preference === false) {\n this.currentQueueName = undefined;\n return undefined;\n }\n\n if (typeof preference === \"string\") {\n const registeredQueue = getTaskQueueRegistry().getQueue<Input, Output>(preference);\n if (registeredQueue) {\n this.currentQueueName = registeredQueue.server.queueName;\n return registeredQueue;\n }\n this.currentQueueName = preference;\n return undefined;\n }\n\n const queueName = await this.getDefaultQueueName(input);\n if (!queueName) {\n this.currentQueueName = undefined;\n return undefined;\n }\n\n this.currentQueueName = queueName;\n\n let registeredQueue = getTaskQueueRegistry().getQueue<Input, Output>(queueName);\n if (!registeredQueue) {\n registeredQueue = await this.createAndRegisterQueue(queueName, input);\n await registeredQueue.server.start();\n }\n\n return registeredQueue;\n }\n\n protected async getDefaultQueueName(_input: Input): Promise<string | undefined> {\n return this.type;\n }\n\n protected async createAndRegisterQueue(\n queueName: string,\n input: Input\n ): Promise<RegisteredQueue<Input, Output>> {\n const factory = getJobQueueFactory();\n let registeredQueue = await factory({\n queueName,\n jobClass: this.jobClass,\n input,\n config: this.config,\n task: this,\n });\n\n const registry = getTaskQueueRegistry();\n\n try {\n registry.registerQueue(registeredQueue);\n } catch (err) {\n if (err instanceof Error && err.message.includes(\"already exists\")) {\n const existing = registry.getQueue<Input, Output>(queueName);\n if (existing) {\n registeredQueue = existing;\n }\n } else {\n throw err;\n }\n }\n\n return registeredQueue;\n }\n\n /**\n * Aborts the task\n * @returns A promise that resolves when the task is aborted\n */\n abort() {\n if (this.currentQueueName && this.currentJobId) {\n const registeredQueue = getTaskQueueRegistry().getQueue(this.currentQueueName);\n if (registeredQueue) {\n registeredQueue.client.abort(this.currentJobId).catch((err) => {\n console.warn(`Failed to abort remote job ${this.currentJobId}`, err);\n });\n }\n }\n // Always call the parent abort to ensure the task is properly marked as aborted\n super.abort();\n }\n}\n",
36
34
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { JobQueueClient, JobQueueServer } from \"@workglow/job-queue\";\nimport { IQueueStorage } from \"@workglow/storage\";\n\n/**\n * Combined structure for a registered job queue containing server, client, and storage\n */\nexport interface RegisteredQueue<Input = unknown, Output = unknown> {\n readonly server: JobQueueServer<Input, Output>;\n readonly client: JobQueueClient<Input, Output>;\n readonly storage: IQueueStorage<Input, Output>;\n}\n\n/**\n * Global singleton instance of the TaskQueueRegistry.\n * This is used to manage all job queues across the application.\n */\nlet taskQueueRegistry: TaskQueueRegistry | null = null;\n\n/**\n * Registry for managing task queues in the application.\n * Provides functionality to register, manage, and control job queues.\n *\n * @template Input - The type of input data for tasks in the queues\n * @template Output - The type of output data for tasks in the queues\n */\nexport class TaskQueueRegistry {\n /**\n * Map of queue names to their corresponding registered queue instances\n */\n public readonly queues: Map<string, RegisteredQueue<unknown, unknown>> = new Map();\n\n /**\n * Registers a new job queue with the registry\n *\n * @param queue - The registered queue containing server, client, and storage\n * @throws Error if a queue with the same name already exists\n */\n registerQueue<Input, Output>(queue: RegisteredQueue<Input, Output>): void {\n const queueName = queue.server.queueName;\n if (this.queues.has(queueName)) {\n throw new Error(`Queue with name ${queueName} already exists`);\n }\n this.queues.set(queueName, queue as RegisteredQueue<unknown, unknown>);\n }\n\n /**\n * Retrieves a registered queue by its name\n *\n * @param queueName - The name of the queue to retrieve\n * @returns The registered queue or undefined if not found\n */\n getQueue<Input, Output>(queueName: string): RegisteredQueue<Input, Output> | undefined {\n return this.queues.get(queueName) as RegisteredQueue<Input, Output> | undefined;\n }\n\n /**\n * Starts all registered job queue servers\n * This allows queues to begin processing their jobs\n *\n * @returns The registry instance for chaining\n */\n async startQueues() {\n for (const queue of this.queues.values()) {\n await queue.server.start();\n }\n }\n\n /**\n * Stops all registered job queue servers\n * This pauses job processing but maintains the queued jobs\n *\n * @returns The registry instance for chaining\n */\n async stopQueues() {\n for (const queue of this.queues.values()) {\n await queue.server.stop();\n }\n }\n\n /**\n * Clears all registered job queues\n * This removes all queued jobs from the storage\n *\n * @returns The registry instance for chaining\n */\n async clearQueues() {\n for (const queue of this.queues.values()) {\n await queue.storage.deleteAll();\n }\n }\n}\n\n/**\n * Gets the global TaskQueueRegistry instance\n * Creates a new instance if one doesn't exist\n *\n * @returns The global TaskQueueRegistry instance\n */\nexport function getTaskQueueRegistry(): TaskQueueRegistry {\n if (!taskQueueRegistry) {\n taskQueueRegistry = new TaskQueueRegistry();\n }\n return taskQueueRegistry;\n}\n\n/**\n * Sets the global TaskQueueRegistry instance\n * Stops and clears any existing registry before replacing it\n *\n * @param registry - The new registry instance to use, or null to clear\n */\nexport async function setTaskQueueRegistry(registry: TaskQueueRegistry | null): Promise<void> {\n if (taskQueueRegistry) {\n await taskQueueRegistry.stopQueues();\n await taskQueueRegistry.clearQueues();\n }\n taskQueueRegistry = registry;\n}\n",
37
35
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { PROPERTY_ARRAY } from \"../task-graph/TaskGraphRunner\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport { IteratorTask, IteratorTaskConfig, iteratorTaskConfigSchema } from \"./IteratorTask\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\nexport const mapTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...iteratorTaskConfigSchema[\"properties\"],\n preserveOrder: { type: \"boolean\" },\n flatten: { type: \"boolean\" },\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for MapTask.\n */\nexport type MapTaskConfig = IteratorTaskConfig & {\n /**\n * Whether to preserve the order of results matching the input order.\n * When false, results may be in completion order.\n * @default true\n */\n readonly preserveOrder?: boolean;\n\n /**\n * Whether to flatten array results from each iteration.\n * When true, if each iteration returns an array, they are concatenated.\n * @default false\n */\n readonly flatten?: boolean;\n};\n\n/**\n * MapTask transforms one or more array inputs by running a workflow for each index.\n */\nexport class MapTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends MapTaskConfig = MapTaskConfig,\n> extends IteratorTask<Input, Output, Config> {\n public static type: TaskTypeName = \"MapTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Map\";\n public static description: string = \"Transforms array inputs by running a workflow per item\";\n\n public static configSchema(): DataPortSchema {\n return mapTaskConfigSchema;\n }\n\n /**\n * MapTask always uses PROPERTY_ARRAY merge strategy to collect results.\n */\n public static readonly compoundMerge = PROPERTY_ARRAY;\n\n /**\n * Static input schema for MapTask.\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Static output schema for MapTask.\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Whether to preserve order of results.\n */\n public get preserveOrder(): boolean {\n return this.config.preserveOrder ?? true;\n }\n\n /**\n * Whether to flatten nested array results.\n */\n public get flatten(): boolean {\n return this.config.flatten ?? false;\n }\n\n public override preserveIterationOrder(): boolean {\n return this.preserveOrder;\n }\n\n /**\n * Returns the empty result for MapTask.\n */\n public override getEmptyResult(): Output {\n const schema = this.outputSchema();\n if (typeof schema === \"boolean\") {\n return {} as Output;\n }\n\n const result: Record<string, unknown[]> = {};\n for (const key of Object.keys(schema.properties || {})) {\n result[key] = [];\n }\n\n return result as Output;\n }\n\n /**\n * Output schema for MapTask.\n * Wraps inner workflow output properties in arrays.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof MapTask).outputSchema();\n }\n\n return this.getWrappedOutputSchema();\n }\n\n /**\n * Collects and optionally flattens results from all iterations.\n */\n public override collectResults(results: TaskOutput[]): Output {\n const collected = super.collectResults(results);\n\n if (!this.flatten || typeof collected !== \"object\" || collected === null) {\n return collected;\n }\n\n const flattened: Record<string, unknown[]> = {};\n for (const [key, value] of Object.entries(collected)) {\n if (Array.isArray(value)) {\n flattened[key] = value.flat();\n } else {\n flattened[key] = value as unknown[];\n }\n }\n\n return flattened as Output;\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a map loop that transforms each element in array input ports.\n * Use .endMap() to close the loop and return to the parent workflow.\n */\n map: CreateLoopWorkflow<TaskInput, TaskOutput, MapTaskConfig>;\n\n /**\n * Ends the map loop and returns to the parent workflow.\n */\n endMap(): Workflow;\n }\n}\n\nWorkflow.prototype.map = CreateLoopWorkflow(MapTask);\nWorkflow.prototype.endMap = CreateEndLoopWorkflow(\"endMap\");\n",
38
36
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { CreateEndLoopWorkflow, CreateLoopWorkflow, Workflow } from \"../task-graph/Workflow\";\nimport {\n IterationAnalysisResult,\n IteratorTask,\n IteratorTaskConfig,\n iteratorTaskConfigSchema,\n} from \"./IteratorTask\";\nimport type { TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\n\nexport const reduceTaskConfigSchema = {\n type: \"object\",\n properties: {\n ...iteratorTaskConfigSchema[\"properties\"],\n initialValue: {},\n },\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for ReduceTask.\n */\nexport type ReduceTaskConfig<Accumulator = unknown> = IteratorTaskConfig & {\n /**\n * The initial value for the accumulator.\n */\n readonly initialValue?: Accumulator;\n};\n\n/**\n * ReduceTask processes iterated inputs sequentially with an accumulator.\n */\nexport class ReduceTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends ReduceTaskConfig<Output> = ReduceTaskConfig<Output>,\n> extends IteratorTask<Input, Output, Config> {\n public static type: TaskTypeName = \"ReduceTask\";\n public static category: string = \"Flow Control\";\n public static title: string = \"Reduce\";\n public static description: string =\n \"Processes iterated inputs sequentially with an accumulator (fold)\";\n\n public static configSchema(): DataPortSchema {\n return reduceTaskConfigSchema;\n }\n\n constructor(input: Partial<Input> = {}, config: Partial<Config> = {}) {\n // Reduce is always sequential\n const reduceConfig = {\n ...config,\n concurrencyLimit: 1,\n batchSize: 1,\n };\n super(input, reduceConfig as Config);\n }\n\n /**\n * Gets the initial accumulator value.\n */\n public get initialValue(): Output {\n return (this.config.initialValue ?? {}) as Output;\n }\n\n public override isReduceTask(): boolean {\n return true;\n }\n\n public override getInitialAccumulator(): Output {\n const value = this.initialValue;\n if (Array.isArray(value)) {\n return [...value] as unknown as Output;\n }\n if (value && typeof value === \"object\") {\n return { ...(value as Record<string, unknown>) } as Output;\n }\n return value;\n }\n\n public override buildIterationRunInput(\n analysis: IterationAnalysisResult,\n index: number,\n iterationCount: number,\n extraInput: Record<string, unknown> = {}\n ): Record<string, unknown> {\n return super.buildIterationRunInput(analysis, index, iterationCount, {\n accumulator: extraInput.accumulator,\n });\n }\n\n public override getEmptyResult(): Output {\n return this.getInitialAccumulator();\n }\n\n /**\n * Static input schema for ReduceTask.\n */\n public static inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Static output schema for ReduceTask.\n */\n public static outputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n\n /**\n * Instance output schema - returns the reduced output schema from ending nodes.\n */\n public override outputSchema(): DataPortSchema {\n if (!this.hasChildren()) {\n return (this.constructor as typeof ReduceTask).outputSchema();\n }\n\n const endingNodes = this.subGraph\n .getTasks()\n .filter((task) => this.subGraph.getTargetDataflows(task.id).length === 0);\n\n if (endingNodes.length === 0) {\n return (this.constructor as typeof ReduceTask).outputSchema();\n }\n\n const properties: Record<string, unknown> = {};\n\n for (const task of endingNodes) {\n const taskOutputSchema = task.outputSchema();\n if (typeof taskOutputSchema === \"boolean\") continue;\n\n for (const [key, schema] of Object.entries(taskOutputSchema.properties || {})) {\n if (!properties[key]) {\n properties[key] = schema;\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n additionalProperties: false,\n } as DataPortSchema;\n }\n}\n\n// ============================================================================\n// Workflow Prototype Extensions\n// ============================================================================\n\ndeclare module \"../task-graph/Workflow\" {\n interface Workflow {\n /**\n * Starts a reduce loop that processes iterated inputs with an accumulator.\n * Use .endReduce() to close the loop and return to the parent workflow.\n */\n reduce: CreateLoopWorkflow<TaskInput, TaskOutput, ReduceTaskConfig<any>>;\n\n /**\n * Ends the reduce loop and returns to the parent workflow.\n */\n endReduce(): Workflow;\n }\n}\n\nqueueMicrotask(() => {\n Workflow.prototype.reduce = CreateLoopWorkflow(ReduceTask);\n Workflow.prototype.endReduce = CreateEndLoopWorkflow(\"endReduce\");\n});\n",
39
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ServiceRegistry } from \"@workglow/util\";\nimport { Dataflow } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { CompoundMergeStrategy } from \"../task-graph/TaskGraphRunner\";\nimport { TaskConfigurationError, TaskJSONError } from \"../task/TaskError\";\nimport { getTaskConstructors } from \"../task/TaskRegistry\";\nimport { ConditionalTaskConfig } from \"./ConditionalTask\";\nimport { GraphAsTask, GraphAsTaskConfig } from \"./GraphAsTask\";\nimport { IteratorTaskConfig } from \"./IteratorTask\";\nimport { JobQueueTaskConfig } from \"./JobQueueTask\";\nimport { MapTaskConfig } from \"./MapTask\";\nimport { ReduceTaskConfig } from \"./ReduceTask\";\nimport { TaskConfig, TaskInput } from \"./TaskTypes\";\nimport { WhileTaskConfig } from \"./WhileTask\";\n\n// ========================================================================\n// JSON Serialization Types\n// ========================================================================\n/**\n * Represents a single task item in the JSON configuration.\n * This structure defines how tasks should be configured in JSON format.\n */\n\nexport type JsonTaskConfig = Omit<\n TaskConfig &\n GraphAsTaskConfig &\n WhileTaskConfig &\n IteratorTaskConfig &\n ReduceTaskConfig &\n MapTaskConfig &\n ConditionalTaskConfig &\n JobQueueTaskConfig,\n \"id\"\n>;\n\nexport type JsonTaskItem = {\n /** Unique identifier for the task */\n id: unknown;\n\n /** Type of task to create */\n type: string;\n\n /** Optional configuration for the task */\n config?: JsonTaskConfig;\n\n /** Default input values for the task */\n defaults?: TaskInput;\n\n /** Defines data flow between tasks */\n dependencies?: {\n /** Input parameter name mapped to source task output */\n [x: string]:\n | {\n /** ID of the source task */\n id: unknown;\n\n /** Output parameter name from source task */\n output: string;\n }\n | Array<{\n id: unknown;\n output: string;\n }>;\n };\n\n /** Nested tasks for compound operations */\n subtasks?: JsonTaskItem[];\n};\n\n/**\n * Represents a task graph item, which can be a task or a subgraph\n */\nexport type TaskGraphItemJson = {\n id: unknown;\n type: string;\n defaults?: TaskInput;\n config?: JsonTaskConfig;\n subgraph?: TaskGraphJson;\n merge?: CompoundMergeStrategy;\n};\n\nexport type TaskGraphJson = {\n tasks: TaskGraphItemJson[];\n dataflows: DataflowJson[];\n};\n\nexport type DataflowJson = {\n sourceTaskId: unknown;\n sourceTaskPortId: string;\n targetTaskId: unknown;\n targetTaskPortId: string;\n};\n\nexport interface TaskGraphJsonOptions {\n /** When true, synthetic InputTask/OutputTask boundary nodes are added at each graph level */\n readonly withBoundaryNodes?: boolean;\n}\n\nconst createSingleTaskFromJSON = (\n item: JsonTaskItem | TaskGraphItemJson,\n registry?: ServiceRegistry\n) => {\n if (!item.id) throw new TaskJSONError(\"Task id required\");\n if (!item.type) throw new TaskJSONError(\"Task type required\");\n if (item.defaults && Array.isArray(item.defaults))\n throw new TaskJSONError(\"Task defaults must be an object\");\n\n const constructors = getTaskConstructors(registry);\n const taskClass = constructors.get(item.type);\n if (!taskClass)\n throw new TaskJSONError(`Task type ${item.type} not found, perhaps not registered?`);\n\n const taskConfig: TaskConfig = {\n ...item.config,\n id: item.id,\n };\n const task = new taskClass(item.defaults ?? {}, taskConfig, registry ? { registry } : {});\n return task;\n};\n\n/**\n * Creates a task instance from a JSON task item configuration.\n * Validates required fields and resolves the task constructor by type name.\n *\n * @param item - The JSON task item containing the task `type`, `id`, optional `config`,\n * `defaults`, `dependencies`, and `subtasks`.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A fully constructed task instance, with its `subGraph` populated when\n * `subtasks` are present.\n * @throws {TaskJSONError} If `id` or `type` are missing, if `defaults` is an array,\n * or if the task type is not found in the resolved constructors map.\n * @throws {TaskConfigurationError} If `subtasks` are provided for a task that is not\n * a `GraphAsTask`.\n */\nexport const createTaskFromDependencyJSON = (item: JsonTaskItem, registry?: ServiceRegistry) => {\n const task = createSingleTaskFromJSON(item, registry);\n if (item.subtasks && item.subtasks.length > 0) {\n if (!(task instanceof GraphAsTask)) {\n throw new TaskConfigurationError(\"Subgraph is only supported for CompoundTasks\");\n }\n task.subGraph = createGraphFromDependencyJSON(item.subtasks, registry);\n }\n return task;\n};\n\n/**\n * Creates a `TaskGraph` from an array of JSON dependency-style task items.\n * Recursively processes `subtasks` for compound (`GraphAsTask`) tasks.\n *\n * @param jsonItems - Array of JSON task items to convert into a task graph.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new `TaskGraph` containing all tasks built from `jsonItems`.\n * @throws {TaskJSONError} If any task item has missing/invalid required fields or an\n * unregistered task type.\n * @throws {TaskConfigurationError} If `subtasks` are specified for a non-`GraphAsTask`.\n */\nexport const createGraphFromDependencyJSON = (\n jsonItems: JsonTaskItem[],\n registry?: ServiceRegistry\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of jsonItems) {\n subGraph.addTask(createTaskFromDependencyJSON(subitem, registry));\n }\n return subGraph;\n};\n\n/**\n * Creates a task instance from a task graph item JSON representation.\n *\n * @param item - The JSON representation of the task, including its `type`, `id`,\n * optional `config`, `defaults`, `subgraph`, and `merge` strategy.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new task instance, with its `subGraph` populated when `subgraph` is present.\n * @throws {TaskJSONError} If required fields are missing or the task type is not found\n * in the resolved constructors map.\n * @throws {TaskConfigurationError} If a `subgraph` is provided for a task that is not\n * a `GraphAsTask`.\n */\nexport const createTaskFromGraphJSON = (item: TaskGraphItemJson, registry?: ServiceRegistry) => {\n const task = createSingleTaskFromJSON(item, registry);\n if (item.subgraph) {\n if (!(task instanceof GraphAsTask)) {\n throw new TaskConfigurationError(\"Subgraph is only supported for GraphAsTask\");\n }\n task.subGraph = createGraphFromGraphJSON(item.subgraph, registry);\n }\n return task;\n};\n\n/**\n * Creates a `TaskGraph` instance from its JSON representation.\n * Reconstructs all tasks and the data flows between them.\n *\n * @param graphJsonObj - The JSON representation of the task graph, containing\n * `tasks` (array of `TaskGraphItemJson`) and `dataflows` (array of `DataflowJson`).\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new `TaskGraph` instance with all tasks and data flows restored.\n * @throws {TaskJSONError} If any task item has missing/invalid required fields or an\n * unregistered task type.\n * @throws {TaskConfigurationError} If a `subgraph` is specified for a non-`GraphAsTask`.\n */\nexport const createGraphFromGraphJSON = (\n graphJsonObj: TaskGraphJson,\n registry?: ServiceRegistry\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of graphJsonObj.tasks) {\n subGraph.addTask(createTaskFromGraphJSON(subitem, registry));\n }\n for (const subitem of graphJsonObj.dataflows) {\n subGraph.addDataflow(\n new Dataflow(\n subitem.sourceTaskId,\n subitem.sourceTaskPortId,\n subitem.targetTaskId,\n subitem.targetTaskPortId\n )\n );\n }\n return subGraph;\n};\n",
40
37
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n createServiceToken,\n globalServiceRegistry,\n registerInputResolver,\n ServiceRegistry,\n} from \"@workglow/util\";\nimport type { ITaskConstructor } from \"./ITask\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyTaskConstructor = ITaskConstructor<any, any, any>;\n\n/**\n * Map storing all registered task constructors.\n * Keys are task type identifiers and values are their corresponding constructor functions.\n */\nconst taskConstructors = new Map<string, AnyTaskConstructor>();\n\n/**\n * Registers a task constructor with the registry.\n * This allows the task type to be instantiated dynamically based on its type identifier.\n *\n * @param type - The unique identifier for the task type\n * @param constructor - The constructor function for the task\n * @throws Error if a task with the same type is already registered\n */\nfunction registerTask(baseClass: AnyTaskConstructor): void {\n if (taskConstructors.has(baseClass.type)) {\n // TODO: fix this\n // throw new Error(`Task type ${baseClass.type} is already registered`);\n }\n taskConstructors.set(baseClass.type, baseClass);\n}\n\n/**\n * TaskRegistry provides a centralized registry for task types.\n * It enables dynamic task instantiation and management across the application.\n */\nexport const TaskRegistry = {\n /**\n * Map containing all registered task constructors\n */\n all: taskConstructors,\n\n /**\n * Function to register new task types\n */\n registerTask,\n};\n\n// ========================================================================\n// DI-based access\n// ========================================================================\n\n/**\n * Service token for the task constructor registry.\n * Maps task type names to their constructor functions.\n */\nexport const TASK_CONSTRUCTORS =\n createServiceToken<Map<string, AnyTaskConstructor>>(\"task.constructors\");\n\n// Register default factory backed by the global TaskRegistry\nif (!globalServiceRegistry.has(TASK_CONSTRUCTORS)) {\n globalServiceRegistry.register(\n TASK_CONSTRUCTORS,\n (): Map<string, AnyTaskConstructor> => TaskRegistry.all,\n true\n );\n}\n\n/**\n * Gets the global task constructors map.\n * @returns The registered task constructors map\n */\nexport function getGlobalTaskConstructors(): Map<string, AnyTaskConstructor> {\n return globalServiceRegistry.get(TASK_CONSTRUCTORS);\n}\n\n/**\n * Sets the global task constructors map, replacing the default TaskRegistry-backed factory.\n * @param map The task constructors map to register\n */\nexport function setGlobalTaskConstructors(map: Map<string, AnyTaskConstructor>): void {\n globalServiceRegistry.registerInstance(TASK_CONSTRUCTORS, map);\n}\n\n/**\n * Gets the task constructors map from the given registry,\n * falling back to the global TaskRegistry.\n */\nexport function getTaskConstructors(registry?: ServiceRegistry): Map<string, AnyTaskConstructor> {\n if (!registry) return TaskRegistry.all;\n return registry.has(TASK_CONSTRUCTORS) ? registry.get(TASK_CONSTRUCTORS) : TaskRegistry.all;\n}\n\n// ========================================================================\n// Tasks resolver\n// ========================================================================\n\n/**\n * Resolves a task type name to a tool definition object via the task constructor registry.\n *\n * Used by the input resolver system for `format: \"tasks\"` properties.\n * Converts lightweight string IDs (stored by the property editor) into full\n * tool definition objects at runtime.\n *\n * @param id - Task type name registered in TaskRegistry\n * @param format - The format string (unused)\n * @param registry - Service registry for context-specific lookups\n * @returns Tool definition object, or undefined if the task type is not found\n */\nfunction resolveTaskFromRegistry(\n id: string,\n _format: string,\n registry: ServiceRegistry\n): {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema: unknown;\n configSchema?: unknown;\n} | undefined {\n const constructors = getTaskConstructors(registry);\n const ctor = constructors.get(id);\n if (!ctor) return undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ctorAny = ctor as any;\n const configSchema =\n typeof ctorAny.configSchema === \"function\" ? ctorAny.configSchema() : undefined;\n return {\n name: ctor.type,\n description: (ctor as { description?: string }).description ?? \"\",\n inputSchema: ctor.inputSchema(),\n outputSchema: ctor.outputSchema(),\n ...(configSchema ? { configSchema } : {}),\n };\n}\n\n// Register the tasks resolver for format: \"tasks\"\nregisterInputResolver(\"tasks\", resolveTaskFromRegistry);\n",
38
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ServiceRegistry } from \"@workglow/util\";\nimport { Dataflow } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { CompoundMergeStrategy } from \"../task-graph/TaskGraphRunner\";\nimport { TaskConfigurationError, TaskJSONError } from \"../task/TaskError\";\nimport { getTaskConstructors } from \"../task/TaskRegistry\";\nimport { ConditionalTaskConfig } from \"./ConditionalTask\";\nimport { GraphAsTask, GraphAsTaskConfig } from \"./GraphAsTask\";\nimport { IteratorTaskConfig } from \"./IteratorTask\";\nimport { JobQueueTaskConfig } from \"./JobQueueTask\";\nimport { MapTaskConfig } from \"./MapTask\";\nimport { ReduceTaskConfig } from \"./ReduceTask\";\nimport { TaskConfig, TaskInput } from \"./TaskTypes\";\nimport { WhileTaskConfig } from \"./WhileTask\";\n\n// ========================================================================\n// JSON Serialization Types\n// ========================================================================\n/**\n * Represents a single task item in the JSON configuration.\n * This structure defines how tasks should be configured in JSON format.\n */\n\nexport type JsonTaskConfig = Omit<\n TaskConfig &\n GraphAsTaskConfig &\n WhileTaskConfig &\n IteratorTaskConfig &\n ReduceTaskConfig &\n MapTaskConfig &\n ConditionalTaskConfig &\n JobQueueTaskConfig,\n \"id\"\n>;\n\nexport type JsonTaskItem = {\n /** Unique identifier for the task */\n id: unknown;\n\n /** Type of task to create */\n type: string;\n\n /** Optional configuration for the task */\n config?: JsonTaskConfig;\n\n /** Default input values for the task */\n defaults?: TaskInput;\n\n /** Defines data flow between tasks */\n dependencies?: {\n /** Input parameter name mapped to source task output */\n [x: string]:\n | {\n /** ID of the source task */\n id: unknown;\n\n /** Output parameter name from source task */\n output: string;\n }\n | Array<{\n id: unknown;\n output: string;\n }>;\n };\n\n /** Nested tasks for compound operations */\n subtasks?: JsonTaskItem[];\n};\n\n/**\n * Represents a task graph item, which can be a task or a subgraph\n */\nexport type TaskGraphItemJson = {\n id: unknown;\n type: string;\n defaults?: TaskInput;\n config?: JsonTaskConfig;\n subgraph?: TaskGraphJson;\n merge?: CompoundMergeStrategy;\n};\n\nexport type TaskGraphJson = {\n tasks: TaskGraphItemJson[];\n dataflows: DataflowJson[];\n};\n\nexport type DataflowJson = {\n sourceTaskId: unknown;\n sourceTaskPortId: string;\n targetTaskId: unknown;\n targetTaskPortId: string;\n};\n\nexport interface TaskGraphJsonOptions {\n /** When true, synthetic InputTask/OutputTask boundary nodes are added at each graph level */\n readonly withBoundaryNodes?: boolean;\n}\n\nconst createSingleTaskFromJSON = (\n item: JsonTaskItem | TaskGraphItemJson,\n registry?: ServiceRegistry\n) => {\n if (!item.id) throw new TaskJSONError(\"Task id required\");\n if (!item.type) throw new TaskJSONError(\"Task type required\");\n if (item.defaults && Array.isArray(item.defaults))\n throw new TaskJSONError(\"Task defaults must be an object\");\n\n const constructors = getTaskConstructors(registry);\n const taskClass = constructors.get(item.type);\n if (!taskClass)\n throw new TaskJSONError(`Task type ${item.type} not found, perhaps not registered?`);\n\n const taskConfig: TaskConfig = {\n ...item.config,\n id: item.id,\n };\n const task = new taskClass(item.defaults ?? {}, taskConfig, registry ? { registry } : {});\n return task;\n};\n\n/**\n * Creates a task instance from a JSON task item configuration.\n * Validates required fields and resolves the task constructor by type name.\n *\n * @param item - The JSON task item containing the task `type`, `id`, optional `config`,\n * `defaults`, `dependencies`, and `subtasks`.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A fully constructed task instance, with its `subGraph` populated when\n * `subtasks` are present.\n * @throws {TaskJSONError} If `id` or `type` are missing, if `defaults` is an array,\n * or if the task type is not found in the resolved constructors map.\n * @throws {TaskConfigurationError} If `subtasks` are provided for a task that is not\n * a `GraphAsTask`.\n */\nexport const createTaskFromDependencyJSON = (item: JsonTaskItem, registry?: ServiceRegistry) => {\n const task = createSingleTaskFromJSON(item, registry);\n if (item.subtasks && item.subtasks.length > 0) {\n if (!(task instanceof GraphAsTask)) {\n throw new TaskConfigurationError(\"Subgraph is only supported for CompoundTasks\");\n }\n task.subGraph = createGraphFromDependencyJSON(item.subtasks, registry);\n }\n return task;\n};\n\n/**\n * Creates a `TaskGraph` from an array of JSON dependency-style task items.\n * Recursively processes `subtasks` for compound (`GraphAsTask`) tasks.\n *\n * @param jsonItems - Array of JSON task items to convert into a task graph.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new `TaskGraph` containing all tasks built from `jsonItems`.\n * @throws {TaskJSONError} If any task item has missing/invalid required fields or an\n * unregistered task type.\n * @throws {TaskConfigurationError} If `subtasks` are specified for a non-`GraphAsTask`.\n */\nexport const createGraphFromDependencyJSON = (\n jsonItems: JsonTaskItem[],\n registry?: ServiceRegistry\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of jsonItems) {\n subGraph.addTask(createTaskFromDependencyJSON(subitem, registry));\n }\n return subGraph;\n};\n\n/**\n * Creates a task instance from a task graph item JSON representation.\n *\n * @param item - The JSON representation of the task, including its `type`, `id`,\n * optional `config`, `defaults`, `subgraph`, and `merge` strategy.\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new task instance, with its `subGraph` populated when `subgraph` is present.\n * @throws {TaskJSONError} If required fields are missing or the task type is not found\n * in the resolved constructors map.\n * @throws {TaskConfigurationError} If a `subgraph` is provided for a task that is not\n * a `GraphAsTask`.\n */\nexport const createTaskFromGraphJSON = (item: TaskGraphItemJson, registry?: ServiceRegistry) => {\n const task = createSingleTaskFromJSON(item, registry);\n if (item.subgraph) {\n if (!(task instanceof GraphAsTask)) {\n throw new TaskConfigurationError(\"Subgraph is only supported for GraphAsTask\");\n }\n task.subGraph = createGraphFromGraphJSON(item.subgraph, registry);\n }\n return task;\n};\n\n/**\n * Creates a `TaskGraph` instance from its JSON representation.\n * Reconstructs all tasks and the data flows between them.\n *\n * @param graphJsonObj - The JSON representation of the task graph, containing\n * `tasks` (array of `TaskGraphItemJson`) and `dataflows` (array of `DataflowJson`).\n * @param registry - Optional service registry for dependency-injection-based constructor\n * lookup. When provided, task constructors are resolved from the registry's\n * `TASK_CONSTRUCTORS` binding (if present); otherwise falls back to the global\n * `TaskRegistry`. Omit to use the global registry.\n * @returns A new `TaskGraph` instance with all tasks and data flows restored.\n * @throws {TaskJSONError} If any task item has missing/invalid required fields or an\n * unregistered task type.\n * @throws {TaskConfigurationError} If a `subgraph` is specified for a non-`GraphAsTask`.\n */\nexport const createGraphFromGraphJSON = (\n graphJsonObj: TaskGraphJson,\n registry?: ServiceRegistry\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of graphJsonObj.tasks) {\n subGraph.addTask(createTaskFromGraphJSON(subitem, registry));\n }\n for (const subitem of graphJsonObj.dataflows) {\n subGraph.addDataflow(\n new Dataflow(\n subitem.sourceTaskId,\n subitem.sourceTaskPortId,\n subitem.targetTaskId,\n subitem.targetTaskPortId\n )\n );\n }\n return subGraph;\n};\n",
39
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport * from \"./ConditionalTask\";\nexport * from \"./ConditionUtils\";\nexport * from \"./FallbackTask\";\nexport * from \"./FallbackTaskRunner\";\nexport * from \"./GraphAsTask\";\nexport * from \"./GraphAsTaskRunner\";\nexport * from \"./InputResolver\";\nexport * from \"./ITask\";\nexport * from \"./iterationSchema\";\nexport * from \"./IteratorTask\";\nexport * from \"./IteratorTaskRunner\";\nexport * from \"./JobQueueFactory\";\nexport * from \"./JobQueueTask\";\nexport * from \"./MapTask\";\nexport * from \"./ReduceTask\";\nexport * from \"./StreamTypes\";\nexport * from \"./Task\";\nexport * from \"./TaskError\";\nexport * from \"./TaskEvents\";\nexport * from \"./TaskJSON\";\nexport * from \"./TaskQueueRegistry\";\nexport * from \"./TaskRegistry\";\nexport * from \"./TaskTypes\";\nexport * from \"./WhileTask\";\nexport * from \"./WhileTaskRunner\";\n\nimport { ConditionalTask } from \"./ConditionalTask\";\nimport { FallbackTask } from \"./FallbackTask\";\nimport { GraphAsTask } from \"./GraphAsTask\";\nimport { MapTask } from \"./MapTask\";\nimport { ReduceTask } from \"./ReduceTask\";\nimport { TaskRegistry } from \"./TaskRegistry\";\nimport { WhileTask } from \"./WhileTask\";\n\nexport const registerBaseTasks = () => {\n const tasks = [GraphAsTask, ConditionalTask, FallbackTask, MapTask, WhileTask, ReduceTask];\n tasks.map(TaskRegistry.registerTask);\n return tasks;\n};\n",
41
40
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken, EventEmitter, EventParameters } from \"@workglow/util\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\n\n/**\n * Service token for TaskGraphRepository\n */\nexport const TASK_GRAPH_REPOSITORY = createServiceToken<TaskGraphRepository>(\n \"taskgraph.taskGraphRepository\"\n);\n\n/**\n * Events that can be emitted by the TaskGraphRepository\n */\nexport type TaskGraphRepositoryEvents = keyof TaskGraphRepositoryEventListeners;\n\nexport type TaskGraphRepositoryEventListeners = {\n graph_saved: (key: string) => void;\n graph_retrieved: (key: string) => void;\n graph_cleared: () => void;\n};\n\nexport type TaskGraphRepositoryEventListener<Event extends TaskGraphRepositoryEvents> =\n TaskGraphRepositoryEventListeners[Event];\n\nexport type TaskGraphRepositoryEventParameters<Event extends TaskGraphRepositoryEvents> =\n EventParameters<TaskGraphRepositoryEventListeners, Event>;\n\n/**\n * Repository class for managing task graphs persistence and retrieval.\n * Provides functionality to save, load, and manipulate task graphs with their associated tasks and data flows.\n */\nexport abstract class TaskGraphRepository {\n /**\n * The type of the repository\n */\n public type = \"TaskGraphRepository\";\n\n /**\n * The event emitter for the task graphs\n */\n private get events() {\n if (!this._events) {\n this._events = new EventEmitter<TaskGraphRepositoryEventListeners>();\n }\n return this._events;\n }\n private _events: EventEmitter<TaskGraphRepositoryEventListeners> | undefined;\n\n /**\n * Registers an event listener for the specified event\n * @param name The event name to listen for\n * @param fn The callback function to execute when the event occurs\n */\n on<Event extends TaskGraphRepositoryEvents>(\n name: Event,\n fn: TaskGraphRepositoryEventListener<Event>\n ) {\n this.events.on(name, fn);\n }\n\n /**\n * Removes an event listener for the specified event\n * @param name The event name to stop listening for\n * @param fn The callback function to remove\n */\n off<Event extends TaskGraphRepositoryEvents>(\n name: Event,\n fn: TaskGraphRepositoryEventListener<Event>\n ) {\n this.events.off(name, fn);\n }\n\n /**\n * Adds an event listener that will only be called once\n * @param name The event name to listen for\n * @param fn The callback function to execute when the event occurs\n */\n once<Event extends TaskGraphRepositoryEvents>(\n name: Event,\n fn: TaskGraphRepositoryEventListener<Event>\n ) {\n this.events.once(name, fn);\n }\n\n /**\n * Returns when the event was emitted (promise form of once)\n * @param name The event name to check\n * @returns true if the event has listeners, false otherwise\n */\n waitOn<Event extends TaskGraphRepositoryEvents>(name: Event) {\n return this.events.waitOn(name) as Promise<TaskGraphRepositoryEventParameters<Event>>;\n }\n\n /**\n * Emits an event (if there are listeners)\n * @param name The event name to emit\n * @param args The event parameters\n */\n emit<Event extends TaskGraphRepositoryEvents>(\n name: Event,\n ...args: TaskGraphRepositoryEventParameters<Event>\n ) {\n this._events?.emit(name, ...args);\n }\n\n /**\n * Saves a task graph to persistent storage\n * @param key The unique identifier for the task graph\n * @param output The task graph to save\n * @emits graph_saved when the operation completes\n */\n abstract saveTaskGraph(key: string, output: TaskGraph): Promise<void>;\n\n /**\n * Retrieves a task graph from persistent storage\n * @param key The unique identifier of the task graph to retrieve\n * @returns The retrieved task graph, or undefined if not found\n * @emits graph_retrieved when the operation completes successfully\n */\n abstract getTaskGraph(key: string): Promise<TaskGraph | undefined>;\n\n /**\n * Clears all task graphs from the repository\n * @emits graph_cleared when the operation completes\n */\n abstract clear(): Promise<void>;\n\n /**\n * Returns the number of task graphs stored in the repository\n * @returns The count of stored task graphs\n */\n abstract size(): Promise<number>;\n}\n",
42
41
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { BaseTabularStorage } from \"@workglow/storage\";\nimport { DataPortSchemaObject } from \"@workglow/util/schema\";\nimport type { ServiceRegistry } from \"@workglow/util\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport { createGraphFromGraphJSON } from \"../task/TaskJSON\";\nimport { TaskGraphRepository } from \"./TaskGraphRepository\";\n\nexport const TaskGraphSchema = {\n type: \"object\",\n properties: {\n key: { type: \"string\" },\n value: { type: \"string\" },\n },\n additionalProperties: false,\n} satisfies DataPortSchemaObject;\n\nexport const TaskGraphPrimaryKeyNames = [\"key\"] as const;\n\n/**\n * Options for the TaskGraphRepository\n */\nexport type TaskGraphRepositoryStorage = BaseTabularStorage<\n typeof TaskGraphSchema,\n typeof TaskGraphPrimaryKeyNames\n>;\ntype TaskGraphRepositoryOptions = {\n tabularRepository: TaskGraphRepositoryStorage;\n registry?: ServiceRegistry;\n};\n\n/**\n * Repository class for managing task graphs persistence and retrieval.\n * Provides functionality to save, load, and manipulate task graphs with their associated tasks and data flows.\n */\nexport class TaskGraphTabularRepository extends TaskGraphRepository {\n /**\n * The type of the repository\n */\n public type = \"TaskGraphTabularRepository\";\n\n /**\n * The tabular repository for the task graphs\n */\n tabularRepository: TaskGraphRepositoryStorage;\n\n /**\n * Optional service registry for DI-based task constructor lookups\n */\n readonly registry: ServiceRegistry | undefined;\n\n /**\n * Constructor for the TaskGraphRepository\n * @param options The options for the repository\n */\n constructor({ tabularRepository, registry }: TaskGraphRepositoryOptions) {\n super();\n this.tabularRepository = tabularRepository;\n this.registry = registry;\n }\n\n /**\n * Sets up the database for the repository.\n * Must be called before using any other methods.\n */\n async setupDatabase(): Promise<void> {\n await this.tabularRepository.setupDatabase?.();\n }\n\n /**\n * Saves a task graph to persistent storage\n * @param key The unique identifier for the task graph\n * @param output The task graph to save\n * @emits graph_saved when the operation completes\n */\n async saveTaskGraph(key: string, output: TaskGraph): Promise<void> {\n const value = JSON.stringify(output.toJSON());\n await this.tabularRepository.put({ key, value });\n this.emit(\"graph_saved\", key);\n }\n\n /**\n * Retrieves a task graph from persistent storage\n * @param key The unique identifier of the task graph to retrieve\n * @returns The retrieved task graph, or undefined if not found\n * @emits graph_retrieved when the operation completes successfully\n */\n async getTaskGraph(key: string): Promise<TaskGraph | undefined> {\n const result = await this.tabularRepository.get({ key });\n const value = result?.value;\n if (!value) {\n return undefined;\n }\n const jsonObj = JSON.parse(value);\n const graph = createGraphFromGraphJSON(jsonObj, this.registry);\n\n this.emit(\"graph_retrieved\", key);\n return graph;\n }\n\n /**\n * Clears all task graphs from the repository\n * @emits graph_cleared when the operation completes\n */\n async clear(): Promise<void> {\n await this.tabularRepository.deleteAll();\n this.emit(\"graph_cleared\");\n }\n\n /**\n * Returns the number of task graphs stored in the repository\n * @returns The count of stored task graphs\n */\n async size(): Promise<number> {\n return await this.tabularRepository.size();\n }\n}\n",
43
42
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { type BaseTabularStorage } from \"@workglow/storage\";\nimport { DataPortSchemaObject } from \"@workglow/util/schema\";\nimport { compress, decompress } from \"@workglow/util/compress\";\nimport { makeFingerprint } from \"@workglow/util\";\nimport { TaskInput, TaskOutput } from \"../task/TaskTypes\";\nimport { TaskOutputRepository } from \"./TaskOutputRepository\";\n\nexport type TaskOutputPrimaryKey = {\n key: string;\n taskType: string;\n};\n\nexport const TaskOutputSchema = {\n type: \"object\",\n properties: {\n key: { type: \"string\" },\n taskType: { type: \"string\" },\n value: { type: \"string\", contentEncoding: \"blob\" },\n createdAt: { type: \"string\", format: \"date-time\" },\n },\n additionalProperties: false,\n} satisfies DataPortSchemaObject;\n\nexport const TaskOutputPrimaryKeyNames = [\"key\", \"taskType\"] as const;\n\nexport type TaskOutputRepositoryStorage = BaseTabularStorage<\n typeof TaskOutputSchema,\n typeof TaskOutputPrimaryKeyNames\n>;\n\nexport type TaskOutputRepositoryOptions = {\n tabularRepository: TaskOutputRepositoryStorage;\n outputCompression?: boolean;\n};\n\n/**\n * Abstract class for managing task outputs in a repository\n * Provides methods for saving, retrieving, and clearing task outputs\n */\nexport class TaskOutputTabularRepository extends TaskOutputRepository {\n /**\n * The tabular repository for the task outputs\n */\n tabularRepository: TaskOutputRepositoryStorage;\n\n /**\n * Constructor for the TaskOutputTabularRepository\n * @param options The options for the repository\n */\n constructor({ tabularRepository, outputCompression = true }: TaskOutputRepositoryOptions) {\n super({ outputCompression });\n this.tabularRepository = tabularRepository;\n this.outputCompression = outputCompression;\n }\n\n /**\n * Sets up the database for the repository.\n * Must be called before using any other methods.\n */\n async setupDatabase(): Promise<void> {\n await this.tabularRepository.setupDatabase?.();\n }\n\n public async keyFromInputs(inputs: TaskInput): Promise<string> {\n return await makeFingerprint(inputs);\n }\n\n /**\n * Saves a task output to the repository\n * @param taskType The type of task to save the output for\n * @param inputs The input parameters for the task\n * @param output The task output to save\n */\n async saveOutput(\n taskType: string,\n inputs: TaskInput,\n output: TaskOutput,\n createdAt = new Date() // for testing purposes\n ): Promise<void> {\n const key = await this.keyFromInputs(inputs);\n const value = JSON.stringify(output);\n if (this.outputCompression) {\n const compressedValue = await compress(value);\n await this.tabularRepository.put({\n taskType,\n key,\n // contentEncoding: \"blob\" allows Uint8Array despite schema type being \"string\"\n value: compressedValue as unknown as string,\n createdAt: createdAt.toISOString(),\n });\n } else {\n const valueBuffer = Buffer.from(value);\n await this.tabularRepository.put({\n taskType,\n key,\n // contentEncoding: \"blob\" allows Buffer/Uint8Array despite schema type being \"string\"\n value: valueBuffer as unknown as string,\n createdAt: createdAt.toISOString(),\n });\n }\n this.emit(\"output_saved\", taskType);\n }\n\n /**\n * Retrieves a task output from the repository\n * @param taskType The type of task to retrieve the output for\n * @param inputs The input parameters for the task\n * @returns The retrieved task output, or undefined if not found\n */\n async getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined> {\n const key = await this.keyFromInputs(inputs);\n const output = await this.tabularRepository.get({ key, taskType });\n this.emit(\"output_retrieved\", taskType);\n if (output?.value) {\n if (this.outputCompression) {\n // Coerce JSON-serialized binary (from filesystem JSON store) back to Uint8Array\n const raw: unknown = output.value as unknown;\n const bytes: Uint8Array =\n raw instanceof Uint8Array\n ? raw\n : Array.isArray(raw)\n ? new Uint8Array(raw as number[])\n : raw && typeof raw === \"object\"\n ? new Uint8Array(\n Object.keys(raw as Record<string, number>)\n .filter((k) => /^\\d+$/.test(k))\n .sort((a, b) => Number(a) - Number(b))\n .map((k) => (raw as Record<string, number>)[k])\n )\n : new Uint8Array();\n const decompressedValue = await decompress(bytes);\n const value = JSON.parse(decompressedValue) as TaskOutput;\n return value as TaskOutput;\n } else {\n const stringValue = output.value.toString();\n const value = JSON.parse(stringValue) as TaskOutput;\n return value as TaskOutput;\n }\n } else {\n return undefined;\n }\n }\n\n /**\n * Clears all task outputs from the repository\n * @emits output_cleared when the operation completes\n */\n async clear(): Promise<void> {\n await this.tabularRepository.deleteAll();\n this.emit(\"output_cleared\");\n }\n\n /**\n * Returns the number of task outputs stored in the repository\n * @returns The count of stored task outputs\n */\n async size(): Promise<number> {\n return await this.tabularRepository.size();\n }\n\n /**\n * Clear all task outputs from the repository that are older than the given date\n * @param olderThanInMs The time in milliseconds to clear task outputs older than\n */\n async clearOlderThan(olderThanInMs: number): Promise<void> {\n const date = new Date(Date.now() - olderThanInMs).toISOString();\n await this.tabularRepository.deleteSearch({ createdAt: { value: date, operator: \"<\" } });\n this.emit(\"output_pruned\");\n }\n}\n"
44
43
  ],
45
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2Ba,YA6DA;AAAA;AAAA,EA7DA,aAAa;AAAA,IAExB,SAAS;AAAA,IAET,UAAU;AAAA,IAEV,YAAY;AAAA,IAEZ,WAAW;AAAA,IAEX,WAAW;AAAA,IAEX,UAAU;AAAA,IAEV,QAAQ;AAAA,EACV;AAAA,EA8Ca,mBAAmB;AAAA,IAC9B,MAAM;AAAA,IACN,YAAY;AAAA,MACV,IAAI;AAAA,QACF,eAAe;AAAA,MACjB;AAAA,MACA,OAAO,EAAE,MAAM,SAAS;AAAA,MACxB,aAAa,EAAE,MAAM,SAAS;AAAA,MAC9B,WAAW,EAAE,MAAM,UAAU;AAAA,MAC7B,SAAS,EAAE,MAAM,UAAU,aAAa,qCAAqC;AAAA,MAC7E,aAAa;AAAA,QACX,MAAM;AAAA,QACN,YAAY,CAAC;AAAA,QACb,sBAAsB;AAAA,QACtB,eAAe;AAAA,MACjB;A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