@workglow/task-graph 0.2.14 → 0.2.16

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.
Files changed (69) hide show
  1. package/dist/__tests__/public-exports.test.d.ts +7 -0
  2. package/dist/__tests__/public-exports.test.d.ts.map +1 -0
  3. package/dist/browser.js +879 -374
  4. package/dist/browser.js.map +22 -13
  5. package/dist/bun.js +879 -374
  6. package/dist/bun.js.map +22 -13
  7. package/dist/common.d.ts +4 -0
  8. package/dist/common.d.ts.map +1 -1
  9. package/dist/node.js +879 -374
  10. package/dist/node.js.map +22 -13
  11. package/dist/task/EntitlementEnforcer.d.ts.map +1 -1
  12. package/dist/task/IteratorTask.d.ts +1 -1
  13. package/dist/task/IteratorTask.d.ts.map +1 -1
  14. package/dist/task/ReduceTask.d.ts +1 -0
  15. package/dist/task/ReduceTask.d.ts.map +1 -1
  16. package/dist/task/Task.d.ts +4 -1
  17. package/dist/task/Task.d.ts.map +1 -1
  18. package/dist/task/TaskJSON.d.ts +2 -0
  19. package/dist/task/TaskJSON.d.ts.map +1 -1
  20. package/dist/task/WhileTask.d.ts.map +1 -1
  21. package/dist/task/__tests__/DataflowJson.transforms.test.d.ts +7 -0
  22. package/dist/task/__tests__/DataflowJson.transforms.test.d.ts.map +1 -0
  23. package/dist/task-graph/ConditionalBuilder.d.ts.map +1 -1
  24. package/dist/task-graph/Dataflow.d.ts +41 -1
  25. package/dist/task-graph/Dataflow.d.ts.map +1 -1
  26. package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
  27. package/dist/task-graph/TransformRegistry.d.ts +14 -0
  28. package/dist/task-graph/TransformRegistry.d.ts.map +1 -0
  29. package/dist/task-graph/TransformTypes.d.ts +51 -0
  30. package/dist/task-graph/TransformTypes.d.ts.map +1 -0
  31. package/dist/task-graph/Workflow.d.ts +13 -2
  32. package/dist/task-graph/Workflow.d.ts.map +1 -1
  33. package/dist/task-graph/__tests__/Dataflow.streaming.test.d.ts +7 -0
  34. package/dist/task-graph/__tests__/Dataflow.streaming.test.d.ts.map +1 -0
  35. package/dist/task-graph/__tests__/Dataflow.transforms.test.d.ts +7 -0
  36. package/dist/task-graph/__tests__/Dataflow.transforms.test.d.ts.map +1 -0
  37. package/dist/task-graph/__tests__/TaskGraphRunner.transforms.test.d.ts +7 -0
  38. package/dist/task-graph/__tests__/TaskGraphRunner.transforms.test.d.ts.map +1 -0
  39. package/dist/task-graph/__tests__/TransformRegistry.test.d.ts +6 -0
  40. package/dist/task-graph/__tests__/TransformRegistry.test.d.ts.map +1 -0
  41. package/dist/task-graph/__tests__/transforms/coalesce.test.d.ts +6 -0
  42. package/dist/task-graph/__tests__/transforms/coalesce.test.d.ts.map +1 -0
  43. package/dist/task-graph/__tests__/transforms/date-conversions.test.d.ts +6 -0
  44. package/dist/task-graph/__tests__/transforms/date-conversions.test.d.ts.map +1 -0
  45. package/dist/task-graph/__tests__/transforms/index-access.test.d.ts +6 -0
  46. package/dist/task-graph/__tests__/transforms/index-access.test.d.ts.map +1 -0
  47. package/dist/task-graph/__tests__/transforms/pick.test.d.ts +6 -0
  48. package/dist/task-graph/__tests__/transforms/pick.test.d.ts.map +1 -0
  49. package/dist/task-graph/__tests__/transforms/scalar-conversions.test.d.ts +6 -0
  50. package/dist/task-graph/__tests__/transforms/scalar-conversions.test.d.ts.map +1 -0
  51. package/dist/task-graph/__tests__/transforms/string-casts.test.d.ts +6 -0
  52. package/dist/task-graph/__tests__/transforms/string-casts.test.d.ts.map +1 -0
  53. package/dist/task-graph/autoConnect.d.ts +39 -0
  54. package/dist/task-graph/autoConnect.d.ts.map +1 -0
  55. package/dist/task-graph/transforms/coalesce.d.ts +11 -0
  56. package/dist/task-graph/transforms/coalesce.d.ts.map +1 -0
  57. package/dist/task-graph/transforms/date-conversions.d.ts +12 -0
  58. package/dist/task-graph/transforms/date-conversions.d.ts.map +1 -0
  59. package/dist/task-graph/transforms/index-access.d.ts +11 -0
  60. package/dist/task-graph/transforms/index-access.d.ts.map +1 -0
  61. package/dist/task-graph/transforms/index.d.ts +18 -0
  62. package/dist/task-graph/transforms/index.d.ts.map +1 -0
  63. package/dist/task-graph/transforms/pick.d.ts +11 -0
  64. package/dist/task-graph/transforms/pick.d.ts.map +1 -0
  65. package/dist/task-graph/transforms/scalar-conversions.d.ts +10 -0
  66. package/dist/task-graph/transforms/scalar-conversions.d.ts.map +1 -0
  67. package/dist/task-graph/transforms/string-casts.d.ts +18 -0
  68. package/dist/task-graph/transforms/string-casts.d.ts.map +1 -0
  69. package/package.json +7 -7
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/task-graph/Dataflow.ts", "../src/task/TaskTypes.ts", "../src/task/TaskEntitlements.ts", "../src/task-graph/GraphEntitlementUtils.ts", "../src/task/InputResolver.ts", "../src/task-graph/GraphFormatScanner.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/StreamTypes.ts", "../src/task/EntitlementEnforcer.ts", "../src/task/EntitlementPolicy.ts", "../src/task/EntitlementResolver.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/ConditionalBuilder.ts", "../src/task-graph/GraphToWorkflowCode.ts", "../src/task/EntitlementProfiles.ts", "../src/task/FallbackTaskRunner.ts", "../src/task/FallbackTask.ts", "../src/task/InputCompactor.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/MapTask.ts", "../src/task/ReduceTask.ts", "../src/task/TaskRegistry.ts", "../src/task/TaskJSON.ts", "../src/task/TaskQueueRegistry.ts", "../src/task/index.ts", "../src/storage/TaskGraphRepository.ts", "../src/storage/TaskGraphTabularRepository.ts", "../src/storage/TaskOutputTabularRepository.ts", "../src/debug/console/ConsoleFormatters.ts"],
3
+ "sources": ["../src/task-graph/Dataflow.ts", "../src/task/TaskError.ts", "../src/task/TaskTypes.ts", "../src/task-graph/TransformRegistry.ts", "../src/task/TaskEntitlements.ts", "../src/task-graph/GraphEntitlementUtils.ts", "../src/task/InputResolver.ts", "../src/task-graph/GraphFormatScanner.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/TaskRunner.ts", "../src/task/StreamTypes.ts", "../src/task/EntitlementEnforcer.ts", "../src/task/EntitlementPolicy.ts", "../src/task/EntitlementResolver.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/autoConnect.ts", "../src/task-graph/ConditionalBuilder.ts", "../src/task-graph/GraphToWorkflowCode.ts", "../src/task-graph/transforms/pick.ts", "../src/task-graph/transforms/index-access.ts", "../src/task-graph/transforms/coalesce.ts", "../src/task-graph/transforms/string-casts.ts", "../src/task-graph/transforms/date-conversions.ts", "../src/task-graph/transforms/scalar-conversions.ts", "../src/task-graph/transforms/index.ts", "../src/task/EntitlementProfiles.ts", "../src/task/FallbackTaskRunner.ts", "../src/task/FallbackTask.ts", "../src/task/InputCompactor.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/MapTask.ts", "../src/task/ReduceTask.ts", "../src/task/TaskRegistry.ts", "../src/task/TaskJSON.ts", "../src/task/TaskQueueRegistry.ts", "../src/task/index.ts", "../src/storage/TaskGraphRepository.ts", "../src/storage/TaskGraphTabularRepository.ts", "../src/storage/TaskOutputTabularRepository.ts", "../src/debug/console/ConsoleFormatters.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 { 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 { Task } from \"../task/Task\";\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._compatibilityCache = 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 /**\n * Cached result of the last semantic compatibility check.\n * Invalidated by calling {@link invalidateCompatibilityCache}.\n */\n protected _compatibilityCache?: \"static\" | \"runtime\" | \"incompatible\";\n\n /**\n * Invalidates the cached semantic compatibility result so the next call\n * to {@link semanticallyCompatible} recomputes it. Call this when\n * either endpoint's schema changes (e.g., in response to a schemaChange event).\n */\n public invalidateCompatibilityCache(): void {\n this._compatibilityCache = undefined;\n }\n\n semanticallyCompatible(\n graph: TaskGraph,\n dataflow: Dataflow\n ): \"static\" | \"runtime\" | \"incompatible\" {\n const sourceTask = graph.getTask(dataflow.sourceTaskId)!;\n const targetTask = graph.getTask(dataflow.targetTaskId)!;\n\n // Only use the cache when both endpoint tasks have stable (non-dynamic) schemas.\n // Tasks with dynamic schemas may emit `schemaChange` events, which would make\n // a cached result stale. Checking the static `hasDynamicSchemas` flag (defined\n // on Task with a default of `false`) is sufficient because tasks with stable\n // schemas never emit `schemaChange`. Unknown constructors default to no caching.\n const shouldCache =\n !((sourceTask.constructor as typeof Task).hasDynamicSchemas ?? true) &&\n !((targetTask.constructor as typeof Task).hasDynamicSchemas ?? true);\n\n if (shouldCache && this._compatibilityCache !== undefined) {\n return this._compatibilityCache;\n }\n\n const targetSchema = targetTask.inputSchema();\n const sourceSchema = sourceTask.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 result = areSemanticallyCompatible(sourceSchemaProperty, targetSchemaProperty);\n if (shouldCache) {\n this._compatibilityCache = result;\n }\n return result;\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",
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 { Task } from \"../task/Task\";\nimport {\n DataflowEventListener,\n DataflowEventListeners,\n DataflowEventParameters,\n DataflowEvents,\n} from \"./DataflowEvents\";\nimport { TaskGraph } from \"./TaskGraph\";\nimport { TRANSFORM_DEFS, TransformRegistry } from \"./TransformRegistry\";\nimport type { ITransformStep } from \"./TransformTypes\";\nimport type { ServiceRegistry } from \"@workglow/util\";\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._compatibilityCache = 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 const base: DataflowJson = {\n sourceTaskId: this.sourceTaskId,\n sourceTaskPortId: this.sourceTaskPortId,\n targetTaskId: this.targetTaskId,\n targetTaskPortId: this.targetTaskPortId,\n };\n if (this._transforms.length > 0) {\n base.transforms = this._transforms.map((s) => ({ id: s.id, params: s.params }));\n }\n return base;\n }\n\n /**\n * Cached result of the last semantic compatibility check.\n * Invalidated by calling {@link invalidateCompatibilityCache}.\n */\n protected _compatibilityCache?: \"static\" | \"runtime\" | \"incompatible\";\n\n /**\n * Transform steps applied to data flowing through this dataflow.\n */\n private _transforms: Array<ITransformStep> = [];\n\n /**\n * Returns the list of transform steps applied to this dataflow.\n */\n getTransforms(): ReadonlyArray<ITransformStep> {\n return this._transforms;\n }\n\n /**\n * Replaces the transform chain with the given steps and invalidates the compatibility cache.\n * Accepts either strict {@link ITransformStep} or steps whose `params` is omitted;\n * omitted `params` is normalised to `undefined`.\n */\n setTransforms(\n steps: ReadonlyArray<{ readonly id: string; readonly params?: Record<string, unknown> }>\n ): void {\n this._transforms = steps.map((s) => ({ id: s.id, params: s.params }));\n this.invalidateCompatibilityCache();\n }\n\n /**\n * Appends a single transform step to the chain and invalidates the compatibility cache.\n * Accepts either strict {@link ITransformStep} or a step whose `params` is omitted;\n * omitted `params` is normalised to `undefined`.\n */\n addTransform(step: { readonly id: string; readonly params?: Record<string, unknown> }): void {\n this._transforms.push({ id: step.id, params: step.params });\n this.invalidateCompatibilityCache();\n }\n\n /**\n * Removes the transform step at the given index and invalidates the compatibility cache.\n */\n removeTransform(index: number): void {\n this._transforms.splice(index, 1);\n this.invalidateCompatibilityCache();\n }\n\n /**\n * Fold the transform chain over `this.value`. On any throw, sets\n * `this.error` and TaskStatus.FAILED, then re-throws so the caller\n * (typically TaskGraphRunner) fails the run. Without the re-throw the\n * runner's status-push step would overwrite the FAILED edge state with\n * the source task's COMPLETED status, silently delivering corrupt data.\n */\n async applyTransforms(registry: ServiceRegistry): Promise<void> {\n if (this._transforms.length === 0) return;\n const defs = registry.get(TRANSFORM_DEFS);\n let cur: unknown = this.value;\n try {\n for (const step of this._transforms) {\n const def = defs.get(step.id);\n if (!def) {\n throw new Error(`Unknown transform: ${step.id}`);\n }\n cur = await def.apply(cur, step.params ?? {});\n }\n this.value = cur;\n } catch (e) {\n const error =\n e instanceof TaskError ? e : new TaskError(e instanceof Error ? e.message : String(e));\n if (!(e instanceof TaskError) && e instanceof Error && e.stack) {\n error.stack = e.stack;\n }\n this.error = error;\n this.setStatus(TaskStatus.FAILED);\n throw e;\n }\n }\n\n /**\n * Invalidates the cached semantic compatibility result so the next call\n * to {@link semanticallyCompatible} recomputes it. Call this when\n * either endpoint's schema changes (e.g., in response to a schemaChange event).\n */\n public invalidateCompatibilityCache(): void {\n this._compatibilityCache = undefined;\n }\n\n semanticallyCompatible(\n graph: TaskGraph,\n dataflow: Dataflow,\n registry?: ServiceRegistry\n ): \"static\" | \"runtime\" | \"incompatible\" {\n const sourceTask = graph.getTask(dataflow.sourceTaskId)!;\n const targetTask = graph.getTask(dataflow.targetTaskId)!;\n\n // Only use the cache when both endpoint tasks have stable (non-dynamic) schemas.\n // Tasks with dynamic schemas may emit `schemaChange` events, which would make\n // a cached result stale. Checking the static `hasDynamicSchemas` flag (defined\n // on Task with a default of `false`) is sufficient because tasks with stable\n // schemas never emit `schemaChange`. Unknown constructors default to no caching.\n const shouldCache =\n !((sourceTask.constructor as typeof Task).hasDynamicSchemas ?? true) &&\n !((targetTask.constructor as typeof Task).hasDynamicSchemas ?? true);\n\n if (shouldCache && this._compatibilityCache !== undefined) {\n return this._compatibilityCache;\n }\n\n const targetSchema = targetTask.inputSchema();\n const sourceSchema = sourceTask.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 // Compose source schema through the transform chain before comparing.\n // Resolves transform defs from the same registry used by applyTransforms so\n // that custom TRANSFORM_DEFS overrides are reflected in both places.\n // When the source schema is `true` (accepts any — e.g. a boundary task\n // with `additionalProperties: true`), start the chain from `{}` so\n // transforms can still narrow the effective schema. Without this a chain\n // like `pick → unixToIsoDate` from an InputTask would short-circuit to\n // \"static\" against any target regardless of the transforms' output type.\n let effectiveSourceSchema = sourceSchemaProperty;\n if (this._transforms.length > 0) {\n const defs = registry ? registry.get(TRANSFORM_DEFS) : TransformRegistry.all;\n try {\n let cur: any = effectiveSourceSchema === true ? {} : effectiveSourceSchema;\n for (const step of this._transforms) {\n const def = defs.get(step.id);\n if (!def) {\n // Do not cache missing transform definitions because the registry\n // supports runtime registration and a later call may become compatible.\n return \"incompatible\";\n }\n cur = def.inferOutputSchema(cur, step.params ?? {});\n }\n effectiveSourceSchema = cur;\n } catch {\n if (shouldCache) this._compatibilityCache = \"incompatible\";\n return \"incompatible\";\n }\n }\n\n const result = areSemanticallyCompatible(effectiveSourceSchema, targetSchemaProperty);\n if (shouldCache) {\n this._compatibilityCache = result;\n }\n return result;\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 { JobError } from \"@workglow/job-queue\";\nimport { BaseError } from \"@workglow/util\";\n\nexport class TaskError extends BaseError {\n static override readonly type: string = \"TaskError\";\n /** The type of the task that produced this error, if available. */\n public taskType?: string;\n /** The ID of the task that produced this error, if available. */\n public taskId?: unknown;\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 override 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 override 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 override 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 override 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 * Thrown when graph-level execution exceeds the configured `timeout` in\n * {@link TaskGraphRunConfig}. Distinct from {@link TaskTimeoutError} (which is\n * thrown for individual-task timeouts) so callers can tell whether the timeout\n * was on a single task or on the entire graph run.\n */\nexport class TaskGraphTimeoutError extends TaskTimeoutError {\n static override readonly type: string = \"TaskGraphTimeoutError\";\n constructor(timeoutMs?: number) {\n super(timeoutMs);\n // Override the message set by TaskTimeoutError to make it graph-specific.\n this.message = timeoutMs\n ? `Graph execution timed out after ${timeoutMs}ms`\n : \"Graph execution 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 override readonly type: string = \"TaskFailedError\";\n constructor(message: string = \"Task failed\") {\n super(message);\n }\n}\n\nexport class JobTaskFailedError extends TaskFailedError {\n static override 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 override 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 override readonly type: string = \"TaskInvalidInputError\";\n constructor(message: string = \"Invalid input data\") {\n super(message);\n }\n}\n\n/**\n * Thrown when required entitlements are denied by the registered enforcer.\n */\nexport class TaskEntitlementError extends TaskError {\n static override readonly type: string = \"TaskEntitlementError\";\n constructor(message: string = \"Required entitlements denied\") {\n super(message);\n }\n}\n\n/**\n * Thrown when toJSON is called on a task whose config contains non-serializable\n * values (e.g. functions). Tasks should override canSerializeConfig() to declare\n * whether they support serialization.\n */\nexport class TaskSerializationError extends TaskError {\n static override readonly type: string = \"TaskSerializationError\";\n constructor(taskType: string) {\n super(\n `Task \"${taskType}\" cannot be serialized: config contains non-serializable values. ` +\n `Use a declarative config alternative or remove function-valued config properties.`\n );\n }\n}\n",
6
7
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { StripJSONSchema } from \"@workglow/util/schema\";\nimport type { DataPortSchema, FromSchema } 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 defaults: {\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<Input extends DataPorts = DataPorts> = Omit<\n BaseFromSchema,\n \"id\" | \"inputSchema\" | \"outputSchema\"\n> & {\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 /** Default input values provided at construction time */\n defaults?: NoInfer<Partial<Input>>;\n};\n\n/** Type for task ID */\nexport type TaskIdType = Task<TaskInput, TaskOutput, TaskConfig>[\"config\"][\"id\"];\n",
8
+ "/**\n * @license Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken, globalServiceRegistry } from \"@workglow/util\";\nimport type { ITransformDef } from \"./TransformTypes\";\n\nconst transformDefs = new Map<string, ITransformDef<any>>();\n\n/** Register / unregister / inspect global transforms. */\nexport const TransformRegistry = {\n all: transformDefs,\n registerTransform(def: ITransformDef<any>): void {\n transformDefs.set(def.id, def);\n },\n unregisterTransform(id: string): void {\n transformDefs.delete(id);\n },\n};\n\n/** DI token — mirrors TASK_CONSTRUCTORS pattern. */\nexport const TRANSFORM_DEFS = createServiceToken<Map<string, ITransformDef<any>>>(\"transform.defs\");\n\nglobalServiceRegistry.registerIfAbsent(\n TRANSFORM_DEFS,\n (): Map<string, ITransformDef<any>> => TransformRegistry.all,\n true\n);\n",
7
9
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { TaskIdType } from \"./TaskTypes\";\n\n// ========================================================================\n// Entitlement Types\n// ========================================================================\n\n/**\n * Hierarchical entitlement identifier.\n * Uses colon-separated namespacing: \"network\", \"network:http\", \"network:websocket\"\n * A grant of \"network\" implicitly covers \"network:http\" and \"network:websocket\".\n */\nexport type EntitlementId = string;\n\n/**\n * A single entitlement declaration.\n */\nexport interface TaskEntitlement {\n /** Hierarchical identifier, e.g. \"network:http\", \"credential:anthropic\", \"code-execution:javascript\" */\n readonly id: EntitlementId;\n /** Human-readable reason why this entitlement is needed */\n readonly reason?: string;\n /** Whether this entitlement is optional (task can degrade gracefully without it) */\n readonly optional?: boolean;\n /**\n * Specific resources this entitlement applies to.\n * E.g. URL patterns for network, model IDs for ai:model, server names for mcp.\n * When undefined, the entitlement applies broadly.\n */\n readonly resources?: readonly string[];\n}\n\n/**\n * Complete entitlement declaration for a task or graph.\n */\nexport interface TaskEntitlements {\n /** List of entitlements required */\n readonly entitlements: readonly TaskEntitlement[];\n}\n\n/**\n * An entitlement with origin tracking (which task(s) require it).\n */\nexport interface TrackedTaskEntitlement extends TaskEntitlement {\n /** Task IDs that require this entitlement */\n readonly sourceTaskIds: readonly TaskIdType[];\n}\n\n/**\n * Entitlements with optional origin tracking.\n */\nexport interface TrackedTaskEntitlements {\n readonly entitlements: readonly TrackedTaskEntitlement[];\n}\n\n// ========================================================================\n// Well-Known Entitlement Constants\n// ========================================================================\n\n/**\n * Well-known entitlement categories. Tasks may also use custom IDs beyond these.\n */\nexport const Entitlements = {\n // Network\n NETWORK: \"network\",\n NETWORK_HTTP: \"network:http\",\n NETWORK_WEBSOCKET: \"network:websocket\",\n NETWORK_PRIVATE: \"network:private\",\n\n // File system\n FILESYSTEM: \"filesystem\",\n FILESYSTEM_READ: \"filesystem:read\",\n FILESYSTEM_WRITE: \"filesystem:write\",\n\n // Code execution\n CODE_EXECUTION: \"code-execution\",\n CODE_EXECUTION_JS: \"code-execution:javascript\",\n\n // Credentials\n CREDENTIAL: \"credential\",\n\n // AI models\n AI: \"ai\",\n AI_MODEL: \"ai:model\",\n AI_INFERENCE: \"ai:inference\",\n\n // MCP\n MCP: \"mcp\",\n MCP_TOOL_CALL: \"mcp:tool-call\",\n MCP_RESOURCE_READ: \"mcp:resource-read\",\n MCP_PROMPT_GET: \"mcp:prompt-get\",\n MCP_STDIO: \"mcp:stdio\",\n\n // Storage / database\n STORAGE: \"storage\",\n STORAGE_READ: \"storage:read\",\n STORAGE_WRITE: \"storage:write\",\n\n // Browser automation\n BROWSER_CONTROL: \"browser\",\n BROWSER_CONTROL_LOCAL: \"browser:local\",\n BROWSER_CONTROL_CLOUD: \"browser:cloud\",\n BROWSER_CONTROL_NAVIGATE: \"browser:navigate\",\n BROWSER_CONTROL_EVALUATE: \"browser:evaluate\",\n BROWSER_CONTROL_CREDENTIAL: \"browser:credential\",\n} as const;\n\n// ========================================================================\n// Empty Entitlements Singleton\n// ========================================================================\n\n/** Shared empty entitlements object to avoid unnecessary allocations */\nexport const EMPTY_ENTITLEMENTS: TaskEntitlements = Object.freeze({\n entitlements: Object.freeze([]),\n});\n\n// ========================================================================\n// Utility Functions\n// ========================================================================\n\n/**\n * Check if a granted entitlement covers a required entitlement.\n * \"network\" covers \"network:http\" (parent covers child in hierarchy).\n */\nexport function entitlementCovers(granted: EntitlementId, required: EntitlementId): boolean {\n return required === granted || required.startsWith(granted + \":\");\n}\n\n/**\n * A grant declaration — what a consumer is willing to allow.\n * Unlike TaskEntitlement (which declares what a task *needs*), this declares what is *permitted*.\n */\nexport interface EntitlementGrant {\n /** Entitlement ID to grant. Hierarchy applies: granting \"network\" covers \"network:http\". */\n readonly id: EntitlementId;\n /**\n * Specific resources this grant covers.\n * - undefined → broad grant, covers all resources for this entitlement\n * - string[] → scoped grant, only covers requirements whose resources are a subset\n *\n * Supports glob-style patterns with any number of `*` wildcards.\n * Each `*` matches zero or more characters of any kind, including `/`.\n * - \"/tmp/*\" covers \"/tmp/data.json\" and \"/tmp/subdir/file.txt\"\n * - \"*.example.com\" covers \"api.example.com\"\n * - \"file-*-v*.json\" covers \"file-data-v2.json\"\n */\n readonly resources?: readonly string[];\n}\n\n/**\n * Check if a single grant resource pattern matches a single required resource.\n * Supports glob-style patterns with any number of `*` wildcards; each `*`\n * matches zero or more characters of any kind (including `/`).\n * - \"prefix*\" matches anything starting with \"prefix\"\n * - \"*.example.com\" matches anything ending with \".example.com\"\n * - \"pre*suf\" matches anything with the given prefix and suffix\n * - \"a*b*c\" matches anything containing \"a\", then \"b\", then \"c\" in order\n * Without `*`, requires exact match.\n */\nexport function resourcePatternMatches(grantPattern: string, requiredResource: string): boolean {\n if (grantPattern === requiredResource) return true;\n if (!grantPattern.includes(\"*\")) return false;\n\n const parts = grantPattern.split(\"*\");\n const first = parts[0];\n const last = parts[parts.length - 1];\n\n if (!requiredResource.startsWith(first)) return false;\n if (!requiredResource.endsWith(last)) return false;\n\n let fixedLength = 0;\n for (const p of parts) fixedLength += p.length;\n if (requiredResource.length < fixedLength) return false;\n\n let searchStart = first.length;\n const searchEnd = requiredResource.length - last.length;\n for (let i = 1; i < parts.length - 1; i++) {\n const part = parts[i];\n if (part.length === 0) continue; // consecutive wildcards collapse\n const idx = requiredResource.indexOf(part, searchStart);\n if (idx === -1 || idx + part.length > searchEnd) return false;\n searchStart = idx + part.length;\n }\n\n return true;\n}\n\n/**\n * Check if a grant covers the resource requirements of an entitlement.\n *\n * Matching rules:\n * - Grant has no resources (broad) → covers any resource requirement\n * - Requirement has no resources (broad need) → only a broad grant covers it\n * - Both have resources → every required resource must match at least one grant pattern\n */\nexport function grantCoversResources(grant: EntitlementGrant, required: TaskEntitlement): boolean {\n // Broad grant covers everything\n if (grant.resources === undefined) return true;\n // Scoped grant cannot cover a broad requirement\n if (required.resources === undefined) return false;\n // Every required resource must be covered by at least one grant pattern\n return required.resources.every((req) =>\n grant.resources!.some((pat) => resourcePatternMatches(pat, req))\n );\n}\n\n/**\n * Merge two TaskEntitlements into a union (deduplicating by ID).\n * If the same ID appears in both, optional is false if either is false (most restrictive wins).\n * Resources are merged (union of all resource arrays for the same ID).\n */\nexport function mergeEntitlements(a: TaskEntitlements, b: TaskEntitlements): TaskEntitlements {\n if (a.entitlements.length === 0) return b;\n if (b.entitlements.length === 0) return a;\n\n const merged = new Map<EntitlementId, TaskEntitlement>();\n\n for (const entitlement of a.entitlements) {\n merged.set(entitlement.id, entitlement);\n }\n\n for (const entitlement of b.entitlements) {\n const existing = merged.get(entitlement.id);\n if (existing) {\n merged.set(entitlement.id, mergeEntitlementPair(existing, entitlement));\n } else {\n merged.set(entitlement.id, entitlement);\n }\n }\n\n return { entitlements: Array.from(merged.values()) };\n}\n\n/**\n * Merge two entitlements with the same ID.\n * - optional: false wins (most restrictive)\n * - reason: first non-empty wins\n * - resources: union\n */\nexport function mergeEntitlementPair(a: TaskEntitlement, b: TaskEntitlement): TaskEntitlement {\n const optional = (a.optional ?? false) && (b.optional ?? false) ? true : undefined;\n const reason = a.reason ?? b.reason;\n const resources = mergeResources(a.resources, b.resources);\n\n const result: TaskEntitlement = {\n id: a.id,\n ...(reason !== undefined && { reason }),\n ...(optional === true && { optional: true }),\n ...(resources !== undefined && { resources }),\n };\n return result;\n}\n\nexport function mergeResources(\n a: readonly string[] | undefined,\n b: readonly string[] | undefined\n): readonly string[] | undefined {\n // undefined means \"all resources\" (broad), so if either side is broad the merged result stays broad\n if (a === undefined || b === undefined) return undefined;\n const set = new Set([...a, ...b]);\n return Array.from(set);\n}\n",
8
10
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type EntitlementId,\n type TaskEntitlement,\n type TaskEntitlements,\n type TrackedTaskEntitlement,\n type TrackedTaskEntitlements,\n EMPTY_ENTITLEMENTS,\n mergeEntitlementPair,\n} from \"../task/TaskEntitlements\";\nimport type { TaskIdType } from \"../task/TaskTypes\";\nimport { TaskStatus } from \"../task/TaskTypes\";\nimport type { TaskGraph } from \"./TaskGraph\";\n\n// ========================================================================\n// Options\n// ========================================================================\n\nexport interface GraphEntitlementOptions {\n /**\n * When true, annotate each entitlement with the source task IDs that require it.\n */\n readonly trackOrigins?: boolean;\n /**\n * Controls which ConditionalTask branches are included.\n * - \"all\" (default): Include entitlements from ALL branches (conservative, pre-execution analysis)\n * - \"active\": Only include entitlements from currently active branches (runtime, after conditions evaluated)\n */\n readonly conditionalBranches?: \"all\" | \"active\";\n}\n\n// ========================================================================\n// Graph Entitlement Computation\n// ========================================================================\n\n/**\n * Computes the aggregated entitlements for a TaskGraph.\n * Returns the union of all task entitlements in the graph.\n *\n * When `trackOrigins` is true, returns TrackedTaskEntitlements with source task IDs.\n */\nexport function computeGraphEntitlements(\n graph: TaskGraph,\n options?: GraphEntitlementOptions & { readonly trackOrigins: true }\n): TrackedTaskEntitlements;\nexport function computeGraphEntitlements(\n graph: TaskGraph,\n options?: GraphEntitlementOptions\n): TaskEntitlements;\nexport function computeGraphEntitlements(\n graph: TaskGraph,\n options?: GraphEntitlementOptions\n): TaskEntitlements | TrackedTaskEntitlements {\n const tasks = graph.getTasks();\n if (tasks.length === 0) return EMPTY_ENTITLEMENTS;\n\n const trackOrigins = options?.trackOrigins ?? false;\n const conditionalBranches = options?.conditionalBranches ?? \"all\";\n\n // Accumulate entitlements by ID\n const merged = new Map<\n EntitlementId,\n { entitlement: TaskEntitlement; sourceTaskIds: TaskIdType[] }\n >();\n\n for (const task of tasks) {\n // For ConditionalTask with \"active\" mode, skip disabled tasks\n if (conditionalBranches === \"active\" && task.status !== undefined) {\n if (task.status === TaskStatus.DISABLED) continue;\n }\n\n const taskEntitlements = task.entitlements();\n for (const entitlement of taskEntitlements.entitlements) {\n const existing = merged.get(entitlement.id);\n if (existing) {\n // Merge: optional=false wins, resources are unioned\n existing.entitlement = mergeEntitlementPair(existing.entitlement, entitlement);\n if (trackOrigins) {\n existing.sourceTaskIds.push(task.id);\n }\n } else {\n merged.set(entitlement.id, {\n entitlement,\n sourceTaskIds: trackOrigins ? [task.id] : [],\n });\n }\n }\n }\n\n if (merged.size === 0) return EMPTY_ENTITLEMENTS;\n\n if (trackOrigins) {\n const entitlements: TrackedTaskEntitlement[] = [];\n for (const { entitlement, sourceTaskIds } of merged.values()) {\n entitlements.push({ ...entitlement, sourceTaskIds });\n }\n return { entitlements };\n }\n\n return { entitlements: Array.from(merged.values()).map((e) => e.entitlement) };\n}\n",
9
11
  "/**\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 */\nexport function getSchemaFormat(\n schema: unknown,\n visited: WeakSet<object> = new WeakSet()\n): string | undefined {\n if (typeof schema !== \"object\" || schema === null) return undefined;\n if (visited.has(schema)) return undefined;\n visited.add(schema);\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/allOf 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 const allOf = s.allOf as unknown[] | undefined;\n if (Array.isArray(allOf)) {\n for (const sub of allOf) {\n const fmt = getSchemaFormat(sub, visited);\n if (fmt !== undefined) return fmt;\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 */\nexport function getObjectSchema(\n schema: unknown,\n visited: WeakSet<object> = new WeakSet()\n): (Record<string, unknown> & { properties: Record<string, unknown> }) | undefined {\n if (typeof schema !== \"object\" || schema === null) return undefined;\n if (visited.has(schema)) return undefined;\n visited.add(schema);\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 // Check allOf for object variant\n const allOf = s.allOf as unknown[] | undefined;\n if (Array.isArray(allOf)) {\n for (const sub of allOf) {\n const result = getObjectSchema(sub, visited);\n if (result !== undefined) return result;\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 */\nexport function getFormatPrefix(format: string): string {\n const colonIndex = format.indexOf(\":\");\n return colonIndex >= 0 ? format.substring(0, colonIndex) : format;\n}\n\n/**\n * Returns true if the schema has any properties with format annotations\n * (direct or in oneOf/anyOf variants). Used as a fast-path check to skip\n * resolution when no format-annotated properties exist.\n */\nexport function schemaHasFormatAnnotations(schema: DataPortSchema): boolean {\n if (typeof schema === \"boolean\") return false;\n\n const properties = schema.properties;\n if (!properties || typeof properties !== \"object\") return false;\n\n for (const propSchema of Object.values(properties)) {\n if (getSchemaFormat(propSchema) !== undefined) return true;\n }\n return false;\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 visited: Set<object> = new Set()\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 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 && !visited.has(objectSchema)) {\n visited.add(objectSchema);\n try {\n resolved[key] = await resolveSchemaInputs(\n value as Record<string, unknown>,\n objectSchema as DataPortSchema,\n config,\n visited\n );\n } finally {\n visited.delete(objectSchema);\n }\n }\n }\n }\n\n return resolved as T;\n}\n",
@@ -11,38 +13,45 @@
11
13
  "/**\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 type { DataPortSchema } from \"@workglow/util/schema\";\nimport type {\n DataflowJson,\n JsonTaskItem,\n TaskGraphItemJson,\n TaskGraphJson,\n} from \"../task/TaskJSON\";\nimport type { TaskIdType } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS } from \"./Dataflow\";\nimport type { TaskGraph } from \"./TaskGraph\";\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 for (const task of tasks) {\n depths.set(task.id, 0);\n }\n\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 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 const tasks = graph.getTasks();\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 // A root task's property is only truly \"required\" from the outside if\n // the task itself marks it required AND it is not pre-populated by a\n // `defaults` value baked into the task at construction. Tasks wrapped\n // into a parent graph after being built with `{ defaults: ... }` (a\n // common pattern inside `task.execute` when assembling a subgraph)\n // would otherwise cause the wrapping graph/workflow to reject empty\n // external input even though every child input is already satisfied.\n // The non-root branch below already honors `task.defaults`; this keeps\n // root handling consistent.\n const isRequired =\n taskInputSchema.required?.includes(inputName) === true &&\n !(task.defaults && task.defaults[inputName] !== undefined);\n if (isRequired) {\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",
12
14
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ResourceScope } from \"@workglow/util\";\nimport { EventEmitter, ServiceRegistry, uuid4 } from \"@workglow/util\";\nimport { DirectedAcyclicGraph } from \"@workglow/util/graph\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { ITask } from \"../task/ITask\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport type { TaskEntitlements } from \"../task/TaskEntitlements\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport type { TaskIdType, TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport type { PipeFunction } from \"./Conversions\";\nimport { ensureTask } from \"./Conversions\";\nimport type { DataflowIdType } from \"./Dataflow\";\nimport { Dataflow } from \"./Dataflow\";\nimport { computeGraphEntitlements } from \"./GraphEntitlementUtils\";\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 type { GraphResultArray } from \"./TaskGraphRunner\";\nimport { CompoundMergeStrategy, GraphResult, TaskGraphRunner } 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 if we should match all empty inputs with the graph input */\n matchAllEmptyInputs?: 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 * Maximum time in milliseconds for the entire graph execution.\n * When exceeded, all in-progress tasks are aborted and a TaskTimeoutError is thrown.\n */\n timeout?: number;\n /**\n * Maximum number of tasks allowed in the graph. Validated before execution starts.\n * Defaults to no limit. Set this to prevent runaway graph construction.\n */\n maxTasks?: number;\n /**\n * When true, check entitlements via the registered IEntitlementEnforcer before\n * graph execution begins. Throws TaskEntitlementError if any required (non-optional)\n * entitlements are denied. Default: false.\n */\n enforceEntitlements?: boolean;\n /**\n * Resource scope for collecting heavyweight resource disposers during graph execution.\n * Threaded to all tasks via IExecuteContext. The caller controls disposal.\n */\n resourceScope?: ResourceScope;\n}\n\nexport interface TaskGraphRunReactiveConfig extends Omit<\n TaskGraphRunConfig,\n \"enforceEntitlements\" | \"timeout\"\n> {\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 timeout: config?.timeout,\n maxTasks: config?.maxTasks,\n resourceScope: config?.resourceScope,\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 * Returns true if the underlying DAG is acyclic. Cycles are already rejected\n * synchronously by {@link addDataflow}, so this is a defensive check for\n * direct `_dag` manipulation or invariant re-assertion after cloning.\n */\n public isAcyclic(): boolean {\n return this._dag.isAcyclic();\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 for (const [, , edge] of this._dag.getEdges()) {\n if (edge.id === id) {\n return edge;\n }\n }\n return undefined;\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 () => {\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 () => {\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 () => {\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 * Subscribes to entitlement changes on all tasks (existing and future).\n * When any task's entitlements change, the graph recomputes and emits its own\n * `entitlementChange` event. Structural changes (task_added, task_removed) also trigger.\n *\n * @param callback - Function called with the aggregated entitlements whenever they change\n * @returns a function to unsubscribe from all entitlement events\n */\n public subscribeToTaskEntitlements(\n callback: (entitlements: TaskEntitlements) => void\n ): () => void {\n const globalUnsubs: (() => void)[] = [];\n const taskUnsubs = new Map<TaskIdType, () => void>();\n\n const emitChange = () => {\n const entitlements = computeGraphEntitlements(this);\n this.emit(\"entitlementChange\", entitlements);\n callback(entitlements);\n };\n\n const subscribeTask = (taskId: TaskIdType) => {\n const task = this.getTask(taskId);\n if (!task || typeof task.subscribe !== \"function\") return;\n const unsub = task.subscribe(\"entitlementChange\", () => emitChange());\n taskUnsubs.set(taskId, unsub);\n };\n\n // Subscribe to entitlementChange events on all existing tasks\n for (const task of this.getTasks()) {\n subscribeTask(task.id);\n }\n\n // Emit the initial state immediately so subscribers don't miss the current entitlements\n emitChange();\n\n // Subscribe to new tasks being added\n globalUnsubs.push(\n this.subscribe(\"task_added\", (taskId: TaskIdType) => {\n subscribeTask(taskId);\n emitChange();\n })\n );\n\n globalUnsubs.push(\n this.subscribe(\"task_removed\", (taskId: TaskIdType) => {\n const unsub = taskUnsubs.get(taskId);\n if (unsub) {\n unsub();\n taskUnsubs.delete(taskId);\n }\n emitChange();\n })\n );\n\n return () => {\n globalUnsubs.forEach((unsub) => unsub());\n taskUnsubs.forEach((unsub) => unsub());\n taskUnsubs.clear();\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n emit(name: string, ...args: any[]): void {\n const dagEvent = EventTaskGraphToDagMapping[name as keyof typeof EventTaskGraphToDagMapping];\n if (dagEvent) {\n // Safe: overload signatures guarantee correct arg types at call sites\n return (this.emit_dag as Function).call(this, name, ...args);\n } else {\n return (this.emit_local as Function).call(this, 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",
13
15
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { getLogger } from \"@workglow/util\";\nimport { CycleError } from \"@workglow/util/graph\";\nimport type { DataPortSchema, SchemaNode } from \"@workglow/util/schema\";\nimport { compileSchema } from \"@workglow/util/schema\";\nimport { computeGraphEntitlements } from \"../task-graph/GraphEntitlementUtils\";\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, IRunConfig } from \"./ITask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { Task } from \"./Task\";\nimport type { TaskEntitlements } from \"./TaskEntitlements\";\nimport type { TaskEventListener, TaskEvents } from \"./TaskEvents\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport type { TaskConfig, TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\nimport { TaskConfigSchema } 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<Input extends TaskInput = TaskInput> = TaskConfig<Input> & {\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<Input> = GraphAsTaskConfig<Input>,\n> extends Task<Input, Output, Config> {\n // ========================================================================\n // Static properties - should be overridden by subclasses\n // ========================================================================\n\n public static override type: TaskTypeName = \"GraphAsTask\";\n public static override title: string = \"Group\";\n public static override description: string = \"A group of tasks that are executed together\";\n public static override 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 override hasDynamicSchemas: boolean = true;\n\n /** Entitlements are always dynamic — they depend on child tasks in the subgraph */\n public static override hasDynamicEntitlements: boolean = true;\n\n // ========================================================================\n // Constructor\n // ========================================================================\n\n /**\n * @param config Task configuration; `subGraph` is applied to this instance and stripped before validating config.\n * @param runConfig Runtime configuration (forwarded to {@link Task}).\n */\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n const { subGraph, ...rest } = config;\n super(rest as Partial<Config>, runConfig);\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 override 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 override 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 override 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 getLogger().warn(\n `GraphAsTask \"${this.type}\" (${this.id}): Failed to compile input schema, ` +\n `falling back to permissive validation. Inputs will NOT be validated.`,\n { error, taskType: this.type, taskId: this.id }\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 * Override entitlements to aggregate from all tasks in the subgraph.\n */\n public override entitlements(): TaskEntitlements {\n if (!this.hasChildren()) {\n return (this.constructor as typeof Task).entitlements();\n }\n return computeGraphEntitlements(this.subGraph);\n }\n\n /**\n * Resets input data to defaults\n */\n public override 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 subgraphDone = false;\n\n // Eager promise/resolver — always available for producers to signal.\n // Prevents a race where producers call a stale or undefined resolver,\n // causing the generator to hang on a promise that never resolves.\n // `isWaiting` is true only while the generator is suspended at `await notifyPromise`.\n // `hasPending` records a notification that arrived while the generator was active,\n // so the generator skips the next wait without allocating a new promise.\n let { promise: notifyPromise, resolve: notifyResolve } = Promise.withResolvers<void>();\n let isWaiting = false;\n let hasPending = false;\n const notify = () => {\n if (isWaiting) {\n // Wake the generator and prepare a fresh deferred for the next wait.\n notifyResolve();\n ({ promise: notifyPromise, resolve: notifyResolve } = Promise.withResolvers<void>());\n isWaiting = false;\n } else {\n // Generator is still draining; skip the allocation.\n hasPending = true;\n }\n };\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 notify();\n }\n },\n });\n\n const runPromise = this.subGraph\n .run<Output>(input, { parentSignal: context.signal, accumulateLeafOutputs: false })\n .then(\n (results) => {\n subgraphDone = true;\n notify();\n return results;\n },\n (err) => {\n subgraphDone = true;\n notify();\n throw err;\n }\n );\n\n // Yield events as they arrive from ending nodes\n while (!subgraphDone) {\n if (eventQueue.length === 0) {\n if (hasPending) {\n // A notification arrived while we were active; consume it without blocking.\n hasPending = false;\n } else {\n isWaiting = true;\n await notifyPromise;\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 * Defensive re-assertion of the DAG invariant for the subgraph. `TaskGraph`\n * already rejects cycle-creating dataflows at `addDataflow` time, but this\n * runs a full topo sort so that any direct `_dag` manipulation or cycle\n * introduced via recursive subgraph composition surfaces here with a clear\n * error rather than deep inside the runner.\n */\n public validateAcyclic(): void {\n if (!this.hasChildren()) return;\n if (!this.subGraph.isAcyclic()) {\n throw new CycleError(\n `${this.type} (${this.id}): subgraph contains a cycle — loop tasks must wrap an acyclic subgraph.`\n );\n }\n for (const child of this.subGraph.getTasks()) {\n if (child instanceof GraphAsTask) {\n child.validateAcyclic();\n }\n }\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 override regenerateGraph(): void {\n this._inputSchemaNode = undefined;\n this.events.emit(\"regenerate\");\n this.emitEntitlementChange();\n }\n\n // ========================================================================\n // SubGraph entitlement forwarding\n // ========================================================================\n\n /** Unsubscribe handle for the current subGraph entitlement subscription */\n private _entitlementUnsub: (() => void) | undefined;\n\n /**\n * Guards against re-entry while the synchronous initial emit of\n * `subscribeToTaskEntitlements` is unwinding. Without this, the initial\n * emit's callback re-reads `this.subGraph`, which would re-trigger\n * `_syncSubGraphEntitlementSubscription` before `_entitlementUnsub` has\n * been assigned and loop forever.\n */\n private _subscribingEntitlements: boolean = false;\n\n // ========================================================================\n // SubGraph entitlement subscription\n // ========================================================================\n\n /**\n * Subscribe to the subGraph's aggregated entitlement changes and forward\n * them as an entitlementChange event on this task so that the parent\n * TaskGraph / Workflow sees the update.\n */\n private _subscribeToSubGraphEntitlements(graph: TaskGraph): void {\n this._entitlementUnsub?.();\n this._entitlementUnsub = undefined;\n this._subscribingEntitlements = true;\n try {\n this._entitlementUnsub = graph.subscribeToTaskEntitlements(() => {\n this.emitEntitlementChange();\n });\n } finally {\n this._subscribingEntitlements = false;\n }\n }\n\n private _syncSubGraphEntitlementSubscription(\n graph: TaskGraph | undefined = this._subGraph\n ): void {\n if (this._subscribingEntitlements) return;\n\n if ((this._events?.listenerCount(\"entitlementChange\") ?? 0) === 0) {\n this._entitlementUnsub?.();\n this._entitlementUnsub = undefined;\n return;\n }\n\n if (!graph || this._entitlementUnsub) {\n return;\n }\n\n this._subscribeToSubGraphEntitlements(graph);\n }\n\n public override subscribe<Event extends TaskEvents>(\n name: Event,\n fn: TaskEventListener<Event>\n ): () => void {\n const unsub = super.subscribe(name, fn);\n if (name !== \"entitlementChange\") {\n return unsub;\n }\n\n this._syncSubGraphEntitlementSubscription();\n\n return () => {\n unsub();\n this._syncSubGraphEntitlementSubscription();\n };\n }\n\n public override on<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n super.on(name, fn);\n if (name === \"entitlementChange\") {\n this._syncSubGraphEntitlementSubscription();\n }\n }\n\n public override off<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n super.off(name, fn);\n if (name === \"entitlementChange\") {\n this._syncSubGraphEntitlementSubscription();\n }\n }\n\n public override once<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void {\n super.once(name, fn);\n if (name === \"entitlementChange\") {\n this._syncSubGraphEntitlementSubscription();\n }\n }\n\n public override set subGraph(subGraph: TaskGraph) {\n this._entitlementUnsub?.();\n this._entitlementUnsub = undefined;\n super.subGraph = subGraph;\n this._syncSubGraphEntitlementSubscription(subGraph);\n }\n\n override get subGraph(): TaskGraph {\n const graph = super.subGraph;\n // The base getter may have lazily created a new graph — subscribe only when needed.\n this._syncSubGraphEntitlementSubscription(graph);\n return graph;\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<TaskInput>>;\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",
14
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ISpan } from \"@workglow/util\";\nimport {\n collectPropertyValues,\n ConvertAllToOptionalArray,\n getLogger,\n getTelemetryProvider,\n globalServiceRegistry,\n ResourceScope,\n ServiceRegistry,\n SpanStatusCode,\n uuid4,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport type { IEntitlementEnforcer } from \"../task/EntitlementEnforcer\";\nimport { ENTITLEMENT_ENFORCER, formatEntitlementDenial } from \"../task/EntitlementEnforcer\";\nimport { ITask } from \"../task/ITask\";\nimport type { StreamEvent, StreamMode } from \"../task/StreamTypes\";\nimport {\n edgeNeedsAccumulation,\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n} from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport {\n TaskAbortedError,\n TaskConfigurationError,\n TaskEntitlementError,\n TaskError,\n TaskGraphTimeoutError,\n} from \"../task/TaskError\";\nimport { TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport { computeGraphEntitlements } from \"./GraphEntitlementUtils\";\nimport { TaskGraph, TaskGraphRunConfig, TaskGraphRunReactiveConfig } from \"./TaskGraph\";\nimport { DependencyBasedScheduler, TopologicalScheduler } from \"./TaskGraphScheduler\";\n\n/**\n * Identifies tasks whose progress is meaningful to graph-level averaging. A task contributes when\n * it does real work — either because:\n *\n * - it declares its own `execute` on the subclass prototype (standard case), or\n * - it declares its own `executeStream` on the subclass prototype (streaming tasks keep their\n * `execute` on `Task.prototype` but still do real work), or\n * - it wraps a subgraph (`hasChildren()` — e.g. `GraphAsTask` / `WorkflowAsTask` /\n * `IteratorTask` / `WhileTask` / `FallbackTask`). Their runners route subgraph\n * `graph_progress` through {@link TaskRunner.handleProgress}, so `task.progress` tracks\n * the nested work and the averaging is accurate.\n *\n * Tasks flagged `isPassthrough` (e.g. `InputTask`, `OutputTask`) are always excluded: they only\n * forward data and would jump from 0% to 100%, diluting the bar.\n */\nexport function taskPrototypeHasOwnExecute(task: ITask): boolean {\n const Ctor = task.constructor as typeof Task;\n if (Ctor.isPassthrough) return false;\n return (\n Object.hasOwn(Ctor.prototype, \"execute\") ||\n Object.hasOwn(Ctor.prototype, \"executeStream\") ||\n task.hasChildren()\n );\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 * Resource scope for this graph run\n */\n protected resourceScope?: ResourceScope;\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<void>> = 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 * Timer handle for graph-level timeout. Cleared on completion, error, or abort.\n */\n protected graphTimeoutTimer?: ReturnType<typeof setTimeout>;\n\n /**\n * When a graph-level timeout fires, this stores the error so handleAbort()\n * can surface the correct error type.\n */\n protected pendingGraphTimeoutError?: TaskGraphTimeoutError;\n\n /**\n * The entitlement enforcer for the current run, if enforcement is enabled.\n * Set during handleStart and cleared after the run completes.\n */\n protected activeEnforcer?: IEntitlementEnforcer;\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 // Root tasks (no incoming dataflows) receive the graph run input so e.g.\n // InputTask can seed the graph. Downstream tasks rely only on dataflow\n // edges plus task defaults — unless matchAllEmptyInputs is true, in which case\n // we filter the input to only include properties that are not connected via dataflows.\n const taskInput = isRootTask\n ? input\n : config?.matchAllEmptyInputs\n ? this.filterInputForTask(task, input)\n : {};\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 // Check graph-level timeout first — it is the root cause when tasks fail due\n // to the graph abort signal, and should take precedence over any task-level\n // TaskAbortedError that was placed in failedTaskErrors as a consequence.\n if (this.pendingGraphTimeoutError) {\n await this.handleAbort();\n throw this.pendingGraphTimeoutError;\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 this.filterLeafResults(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 this.filterLeafResults(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\n /**\n * When leaf results include tasks with `isGraphOutput`, returns only those.\n * Otherwise returns all leaf results unchanged.\n */\n protected filterLeafResults<T>(results: GraphResultArray<T>): GraphResultArray<T> {\n if (results.length <= 1) return results;\n const graphOutputResults = results.filter((r) => {\n const task = this.graph.getTask(r.id);\n return task && (task.constructor as typeof Task).isGraphOutput;\n });\n return graphOutputResults.length > 0 ? graphOutputResults : results;\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 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 // Sort by dataflow id for deterministic input merging regardless of insertion order\n dataflows.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\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 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 // Runtime entitlement enforcement for tasks with dynamic entitlements\n if (this.activeEnforcer && (task.constructor as typeof Task).hasDynamicEntitlements) {\n const denied = await this.activeEnforcer.checkTask(task);\n if (denied.length > 0) {\n throw new TaskEntitlementError(\n `Task ${(task.constructor as typeof Task).type} denied entitlements: ${denied.map(formatEntitlementDenial).join(\", \")}`\n );\n }\n }\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 resourceScope: this.resourceScope,\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 resourceScope: this.resourceScope,\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: StreamMode): 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 if (config?.resourceScope !== undefined) {\n this.resourceScope = config.resourceScope;\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\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 // Set up graph-level timeout if configured\n if (config?.timeout !== undefined && config.timeout > 0) {\n this.pendingGraphTimeoutError = undefined;\n this.graphTimeoutTimer = setTimeout(() => {\n this.pendingGraphTimeoutError = new TaskGraphTimeoutError(config.timeout);\n this.abortController?.abort();\n }, config.timeout);\n }\n\n // Listen first, then check — addEventListener on an already-aborted signal\n // does not fire, so checking .aborted after ensures we never miss an abort.\n if (config?.parentSignal) {\n const onParentAbort = () => {\n this.abortController?.abort();\n };\n config.parentSignal.addEventListener(\"abort\", onParentAbort, { once: true });\n if (config.parentSignal.aborted) {\n config.parentSignal.removeEventListener(\"abort\", onParentAbort);\n this.abortController.abort();\n return;\n }\n }\n\n this.runId = uuid4();\n this.resetGraph(this.graph, this.runId); // Reset graph and regenerate sub-graphs, changes task count / entitlements\n this.processScheduler.reset();\n this.inProgressTasks.clear();\n this.inProgressFunctions.clear();\n this.failedTaskErrors.clear();\n\n // Validate and enforce after resetGraph (which regenerates sub-graphs and may\n // change task count / entitlements). On failure, clean up running state so the\n // runner remains reusable.\n try {\n // Validate graph size limits\n if (config?.maxTasks !== undefined && config.maxTasks > 0) {\n const taskCount = this.graph.getTasks().length;\n if (taskCount > config.maxTasks) {\n throw new TaskConfigurationError(\n `Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`\n );\n }\n }\n\n // Opt-in entitlement enforcement (preflight)\n if (config?.enforceEntitlements) {\n if (!this.registry.has(ENTITLEMENT_ENFORCER)) {\n throw new TaskConfigurationError(\n \"enforceEntitlements is enabled but no IEntitlementEnforcer is registered. \" +\n \"Register an enforcer via ENTITLEMENT_ENFORCER before running the graph.\"\n );\n }\n const enforcer = this.registry.get(ENTITLEMENT_ENFORCER);\n const denied = await enforcer.checkAll(computeGraphEntitlements(this.graph));\n if (denied.length > 0) {\n throw new TaskEntitlementError(\n `Denied entitlements: ${denied.map(formatEntitlementDenial).join(\", \")}`\n );\n }\n this.activeEnforcer = enforcer;\n } else {\n this.activeEnforcer = undefined;\n }\n } catch (err) {\n // Reset running state so the runner is reusable after validation failures\n if (this.graphTimeoutTimer !== undefined) {\n clearTimeout(this.graphTimeoutTimer);\n this.graphTimeoutTimer = undefined;\n }\n this.abortController = undefined;\n this.activeEnforcer = undefined;\n this.running = false;\n throw err;\n }\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 // Validate graph size limits (same as handleStart)\n if (config?.maxTasks !== undefined && config.maxTasks > 0) {\n const taskCount = this.graph.getTasks().length;\n if (taskCount > config.maxTasks) {\n throw new TaskConfigurationError(\n `Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`\n );\n }\n }\n\n // Note: `timeout` is not enforced for reactive runs. Reactive execution is\n // event-driven with no single completion point, so a graph-level timeout\n // does not apply. Use per-task timeouts for individual task time limits.\n\n this.reactiveScheduler.reset();\n this.reactiveRunning = true;\n }\n\n /**\n * Handles the completion of task graph execution\n */\n /**\n * Clears the graph-level timeout timer if active.\n */\n protected clearGraphTimeout(): void {\n if (this.graphTimeoutTimer !== undefined) {\n clearTimeout(this.graphTimeoutTimer);\n this.graphTimeoutTimer = undefined;\n }\n }\n\n protected async handleComplete(): Promise<void> {\n this.clearGraphTimeout();\n this.running = false;\n this.activeEnforcer = undefined;\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 this.clearGraphTimeout();\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 this.activeEnforcer = undefined;\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 this.clearGraphTimeout();\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 this.activeEnforcer = undefined;\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",
16
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ISpan } from \"@workglow/util\";\nimport {\n collectPropertyValues,\n ConvertAllToOptionalArray,\n getLogger,\n getTelemetryProvider,\n globalServiceRegistry,\n ResourceScope,\n ServiceRegistry,\n SpanStatusCode,\n uuid4,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport type { IEntitlementEnforcer } from \"../task/EntitlementEnforcer\";\nimport { ENTITLEMENT_ENFORCER, formatEntitlementDenial } from \"../task/EntitlementEnforcer\";\nimport { ITask } from \"../task/ITask\";\nimport type { StreamEvent, StreamMode } from \"../task/StreamTypes\";\nimport {\n edgeNeedsAccumulation,\n getOutputStreamMode,\n getStreamingPorts,\n isTaskStreamable,\n} from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport {\n TaskAbortedError,\n TaskConfigurationError,\n TaskEntitlementError,\n TaskError,\n TaskGraphTimeoutError,\n} from \"../task/TaskError\";\nimport { TaskInput, TaskOutput, TaskStatus } from \"../task/TaskTypes\";\nimport { DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport { computeGraphEntitlements } from \"./GraphEntitlementUtils\";\nimport { TaskGraph, TaskGraphRunConfig, TaskGraphRunReactiveConfig } from \"./TaskGraph\";\nimport { DependencyBasedScheduler, TopologicalScheduler } from \"./TaskGraphScheduler\";\n\n/**\n * Identifies tasks whose progress is meaningful to graph-level averaging. A task contributes when\n * it does real work — either because:\n *\n * - it declares its own `execute` on the subclass prototype (standard case), or\n * - it declares its own `executeStream` on the subclass prototype (streaming tasks keep their\n * `execute` on `Task.prototype` but still do real work), or\n * - it wraps a subgraph (`hasChildren()` — e.g. `GraphAsTask` / `WorkflowAsTask` /\n * `IteratorTask` / `WhileTask` / `FallbackTask`). Their runners route subgraph\n * `graph_progress` through {@link TaskRunner.handleProgress}, so `task.progress` tracks\n * the nested work and the averaging is accurate.\n *\n * Tasks flagged `isPassthrough` (e.g. `InputTask`, `OutputTask`) are always excluded: they only\n * forward data and would jump from 0% to 100%, diluting the bar.\n */\nexport function taskPrototypeHasOwnExecute(task: ITask): boolean {\n const Ctor = task.constructor as typeof Task;\n if (Ctor.isPassthrough) return false;\n return (\n Object.hasOwn(Ctor.prototype, \"execute\") ||\n Object.hasOwn(Ctor.prototype, \"executeStream\") ||\n task.hasChildren()\n );\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 * Resource scope for this graph run\n */\n protected resourceScope?: ResourceScope;\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<void>> = 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 * Timer handle for graph-level timeout. Cleared on completion, error, or abort.\n */\n protected graphTimeoutTimer?: ReturnType<typeof setTimeout>;\n\n /**\n * When a graph-level timeout fires, this stores the error so handleAbort()\n * can surface the correct error type.\n */\n protected pendingGraphTimeoutError?: TaskGraphTimeoutError;\n\n /**\n * The entitlement enforcer for the current run, if enforcement is enabled.\n * Set during handleStart and cleared after the run completes.\n */\n protected activeEnforcer?: IEntitlementEnforcer;\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 // Root tasks (no incoming dataflows) receive the graph run input so e.g.\n // InputTask can seed the graph. Downstream tasks rely only on dataflow\n // edges plus task defaults — unless matchAllEmptyInputs is true, in which case\n // we filter the input to only include properties that are not connected via dataflows.\n const taskInput = isRootTask\n ? input\n : config?.matchAllEmptyInputs\n ? this.filterInputForTask(task, input)\n : {};\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 // Check graph-level timeout first — it is the root cause when tasks fail due\n // to the graph abort signal, and should take precedence over any task-level\n // TaskAbortedError that was placed in failedTaskErrors as a consequence.\n if (this.pendingGraphTimeoutError) {\n await this.handleAbort();\n throw this.pendingGraphTimeoutError;\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 this.filterLeafResults(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 // runReactive is on the UI preview hot path (fires per keystroke), so\n // instrumentation only runs when telemetry is enabled. Without the gate,\n // the four performance.now() calls per task and the per-run debug log\n // payload would burn cycles on every preview update.\n const telemetry = getTelemetryProvider();\n const telemetryEnabled = telemetry.isEnabled;\n const reactiveRunId = telemetryEnabled ? uuid4() : \"\";\n let reactiveSpan: ISpan | undefined;\n if (telemetryEnabled) {\n reactiveSpan = telemetry.startSpan(\"workglow.graph.runReactive\", {\n attributes: {\n \"workglow.graph.reactive.run_id\": reactiveRunId,\n \"workglow.graph.task_count\": this.graph.getTasks().length,\n \"workglow.graph.dataflow_count\": this.graph.getDataflows().length,\n },\n });\n }\n\n const t0 = telemetryEnabled ? performance.now() : 0;\n const taskTimings: Array<{\n id: unknown;\n type: string;\n runReactiveMs: number;\n pushOutputMs: number;\n }> = [];\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 if (telemetryEnabled) {\n const taskType = String(\n (task.constructor as any).runtype || (task.constructor as typeof Task).type || \"?\"\n );\n const tReactive = performance.now();\n const taskResult = await task.runReactive(taskInput);\n const runReactiveMs = performance.now() - tReactive;\n const tPush = performance.now();\n await this.pushOutputFromNodeToEdges(task, taskResult);\n const pushOutputMs = performance.now() - tPush;\n taskTimings.push({ id: task.id, type: taskType, runReactiveMs, pushOutputMs });\n\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 } else {\n const taskResult = await task.runReactive(taskInput);\n await this.pushOutputFromNodeToEdges(task, taskResult);\n\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 }\n await this.handleCompleteReactive();\n\n if (reactiveSpan) {\n const totalMs = performance.now() - t0;\n reactiveSpan.setAttributes({\n \"workglow.graph.reactive.duration_ms\": Math.round(totalMs * 1000) / 1000,\n \"workglow.graph.reactive.tasks_executed\": taskTimings.length,\n });\n reactiveSpan.setStatus(SpanStatusCode.OK);\n reactiveSpan.end();\n getLogger().debug(\"task graph runReactive timings\", {\n reactiveRunId,\n totalMs: Math.round(totalMs * 1000) / 1000,\n taskTimings,\n });\n }\n\n return this.filterLeafResults(results);\n } catch (error) {\n await this.handleErrorReactive();\n\n if (reactiveSpan) {\n const totalMs = performance.now() - t0;\n const message = error instanceof Error ? error.message : String(error);\n reactiveSpan.setAttributes({\n \"workglow.graph.reactive.duration_ms\": Math.round(totalMs * 1000) / 1000,\n \"workglow.graph.reactive.tasks_executed\": taskTimings.length,\n });\n reactiveSpan.setStatus(SpanStatusCode.ERROR, message);\n reactiveSpan.end();\n getLogger().debug(\"task graph runReactive failed\", {\n reactiveRunId,\n totalMs: Math.round(totalMs * 1000) / 1000,\n taskTimings,\n error,\n });\n }\n\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\n /**\n * When leaf results include tasks with `isGraphOutput`, returns only those.\n * Otherwise returns all leaf results unchanged.\n */\n protected filterLeafResults<T>(results: GraphResultArray<T>): GraphResultArray<T> {\n if (results.length <= 1) return results;\n const graphOutputResults = results.filter((r) => {\n const task = this.graph.getTask(r.id);\n return task && (task.constructor as typeof Task).isGraphOutput;\n });\n return graphOutputResults.length > 0 ? graphOutputResults : results;\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 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 // Sort by dataflow id for deterministic input merging regardless of insertion order\n dataflows.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\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 // Edges with an active stream have their final value materialised by the\n // downstream task's awaitStreamInputs (which uses Dataflow.awaitStreamValue\n // to read the raw snapshot/finish data and then applies transforms).\n // Setting port data here would be overwritten by the finish event, and\n // applying transforms again on this path would double-apply\n // non-idempotent transforms, so skip the whole post-materialisation step.\n if (dataflow.stream !== undefined) continue;\n const compatibility = dataflow.semanticallyCompatible(this.graph, dataflow, this.registry);\n if (compatibility === \"static\") {\n dataflow.setPortData(results);\n await dataflow.applyTransforms(this.registry);\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 await dataflow.applyTransforms(this.registry);\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 // Preserve FAILED edges (e.g. transform chain failure) rather than\n // overwriting with the source task's completion status.\n if (dataflow.status === TaskStatus.FAILED) continue;\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 // Preserve FAILED edges (e.g. transform chain failure) rather than\n // overwriting with the source task's completion status.\n if (dataflow.status === TaskStatus.FAILED) return;\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 // Runtime entitlement enforcement for tasks with dynamic entitlements\n if (this.activeEnforcer && (task.constructor as typeof Task).hasDynamicEntitlements) {\n const denied = await this.activeEnforcer.checkTask(task);\n if (denied.length > 0) {\n throw new TaskEntitlementError(\n `Task ${(task.constructor as typeof Task).type} denied entitlements: ${denied.map(formatEntitlementDenial).join(\", \")}`\n );\n }\n }\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 resourceScope: this.resourceScope,\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 streamingDataflows = dataflows.filter((df) => df.stream !== undefined);\n if (streamingDataflows.length === 0) return;\n await Promise.all(\n streamingDataflows.map(async (df) => {\n await df.awaitStreamValue();\n // awaitStreamValue sets port data from the raw finish/snapshot event.\n // Apply the edge's transform chain over the materialised value so the\n // downstream task receives the transformed result. This is the sole\n // transform application for streaming edges (pushOutputFromNodeToEdges\n // deliberately skips them to avoid double-apply).\n await df.applyTransforms(this.registry);\n })\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 resourceScope: this.resourceScope,\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: StreamMode): 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 if (config?.resourceScope !== undefined) {\n this.resourceScope = config.resourceScope;\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\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 // Set up graph-level timeout if configured\n if (config?.timeout !== undefined && config.timeout > 0) {\n this.pendingGraphTimeoutError = undefined;\n this.graphTimeoutTimer = setTimeout(() => {\n this.pendingGraphTimeoutError = new TaskGraphTimeoutError(config.timeout);\n this.abortController?.abort();\n }, config.timeout);\n }\n\n // Listen first, then check — addEventListener on an already-aborted signal\n // does not fire, so checking .aborted after ensures we never miss an abort.\n if (config?.parentSignal) {\n const onParentAbort = () => {\n this.abortController?.abort();\n };\n config.parentSignal.addEventListener(\"abort\", onParentAbort, { once: true });\n if (config.parentSignal.aborted) {\n config.parentSignal.removeEventListener(\"abort\", onParentAbort);\n this.abortController.abort();\n return;\n }\n }\n\n this.runId = uuid4();\n this.resetGraph(this.graph, this.runId); // Reset graph and regenerate sub-graphs, changes task count / entitlements\n this.processScheduler.reset();\n this.inProgressTasks.clear();\n this.inProgressFunctions.clear();\n this.failedTaskErrors.clear();\n\n // Validate and enforce after resetGraph (which regenerates sub-graphs and may\n // change task count / entitlements). On failure, clean up running state so the\n // runner remains reusable.\n try {\n // Validate graph size limits\n if (config?.maxTasks !== undefined && config.maxTasks > 0) {\n const taskCount = this.graph.getTasks().length;\n if (taskCount > config.maxTasks) {\n throw new TaskConfigurationError(\n `Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`\n );\n }\n }\n\n // Opt-in entitlement enforcement (preflight)\n if (config?.enforceEntitlements) {\n if (!this.registry.has(ENTITLEMENT_ENFORCER)) {\n throw new TaskConfigurationError(\n \"enforceEntitlements is enabled but no IEntitlementEnforcer is registered. \" +\n \"Register an enforcer via ENTITLEMENT_ENFORCER before running the graph.\"\n );\n }\n const enforcer = this.registry.get(ENTITLEMENT_ENFORCER);\n const denied = await enforcer.checkAll(computeGraphEntitlements(this.graph));\n if (denied.length > 0) {\n throw new TaskEntitlementError(\n `Denied entitlements: ${denied.map(formatEntitlementDenial).join(\", \")}`\n );\n }\n this.activeEnforcer = enforcer;\n } else {\n this.activeEnforcer = undefined;\n }\n } catch (err) {\n // Reset running state so the runner is reusable after validation failures\n if (this.graphTimeoutTimer !== undefined) {\n clearTimeout(this.graphTimeoutTimer);\n this.graphTimeoutTimer = undefined;\n }\n this.abortController = undefined;\n this.activeEnforcer = undefined;\n this.running = false;\n throw err;\n }\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 // Validate graph size limits (same as handleStart)\n if (config?.maxTasks !== undefined && config.maxTasks > 0) {\n const taskCount = this.graph.getTasks().length;\n if (taskCount > config.maxTasks) {\n throw new TaskConfigurationError(\n `Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`\n );\n }\n }\n\n // Note: `timeout` is not enforced for reactive runs. Reactive execution is\n // event-driven with no single completion point, so a graph-level timeout\n // does not apply. Use per-task timeouts for individual task time limits.\n\n this.reactiveScheduler.reset();\n this.reactiveRunning = true;\n }\n\n /**\n * Handles the completion of task graph execution\n */\n /**\n * Clears the graph-level timeout timer if active.\n */\n protected clearGraphTimeout(): void {\n if (this.graphTimeoutTimer !== undefined) {\n clearTimeout(this.graphTimeoutTimer);\n this.graphTimeoutTimer = undefined;\n }\n }\n\n protected async handleComplete(): Promise<void> {\n this.clearGraphTimeout();\n this.running = false;\n this.activeEnforcer = undefined;\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 this.clearGraphTimeout();\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 this.activeEnforcer = undefined;\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 this.clearGraphTimeout();\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 this.activeEnforcer = undefined;\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",
15
17
  "/**\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",
16
18
  "/**\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 } from \"./ConditionUtils\";\nimport type { UIConditionConfig } from \"./ConditionUtils\";\nimport type { IExecuteContext } from \"./ITask\";\nimport { Task } from \"./Task\";\nimport { TaskConfigSchema } from \"./TaskTypes\";\nimport type { TaskConfig, TaskInput, TaskOutput, TaskTypeName } 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 override type: TaskTypeName = \"ConditionalTask\";\n\n /** Category for UI organization and filtering */\n static override category = \"Flow Control\";\n\n /** Human-readable title for display in UIs */\n static override title = \"Condition\";\n static override description = \"Route data based on conditions\";\n\n /** This task has dynamic schemas that change based on branch configuration */\n static override hasDynamicSchemas: boolean = true;\n\n public static override configSchema(): DataPortSchema {\n return conditionalTaskConfigSchema;\n }\n\n public override canSerializeConfig(): boolean {\n if (!this.config.branches) return true;\n return !this.config.branches.some((b) => typeof b.condition === \"function\");\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 override async execute(\n input: Input,\n context: IExecuteContext\n ): 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().error(`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 override 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 override 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 override 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 override inputSchema(): DataPortSchema {\n return {\n type: \"object\",\n properties: {},\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n }\n}\n",
17
19
  "/**\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",
18
20
  "/**\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 { deepEqual, EventEmitter, uuid4 } from \"@workglow/util\";\nimport type { DataPortSchema, SchemaNode } from \"@workglow/util/schema\";\nimport { compileSchema } from \"@workglow/util/schema\";\nimport { DATAFLOW_ALL_PORTS } from \"../task-graph/Dataflow\";\nimport { TaskGraph } from \"../task-graph/TaskGraph\";\nimport type { IExecuteContext, IExecuteReactiveContext, IRunConfig, ITask } from \"./ITask\";\nimport { EMPTY_ENTITLEMENTS, type TaskEntitlements } from \"./TaskEntitlements\";\nimport {\n TaskAbortedError,\n TaskConfigurationError,\n TaskError,\n TaskInvalidInputError,\n TaskSerializationError,\n} from \"./TaskError\";\nimport type {\n TaskEventListener,\n TaskEventListeners,\n TaskEventParameters,\n TaskEvents,\n} from \"./TaskEvents\";\nimport type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from \"./TaskJSON\";\nimport { TaskRunner } from \"./TaskRunner\";\nimport type { TaskConfig, TaskIdType, TaskInput, TaskOutput, TaskTypeName } from \"./TaskTypes\";\nimport { TaskConfigSchema, TaskStatus } 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 * When true, this task defines the graph's output. The graph runner will\n * collect results only from tasks with this flag when they exist among the\n * leaf nodes; otherwise it falls back to collecting from all leaves.\n */\n public static isGraphOutput: boolean = false;\n\n /**\n * When true, this task does no real work — it only forwards inputs to outputs\n * (e.g. `InputTask`, `OutputTask`). Such tasks are excluded from graph-level\n * progress averaging because they jump from 0% to 100% and would dilute the bar.\n */\n public static isPassthrough: boolean = false;\n\n /**\n * Whether this task has dynamic entitlements that can change at runtime.\n * Tasks with dynamic entitlements should override the instance entitlements() method\n * and emit 'entitlementChange' events when their entitlements change.\n */\n public static hasDynamicEntitlements: boolean = false;\n\n /**\n * Entitlements required by this task class.\n * Subclasses override to declare their permission requirements.\n */\n public static entitlements(): TaskEntitlements {\n return EMPTY_ENTITLEMENTS;\n }\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 /**\n * Gets entitlements for this task instance.\n * For tasks with dynamic entitlements, override this to compute based on config/state.\n */\n public entitlements(): TaskEntitlements {\n return (this.constructor as typeof Task).entitlements();\n }\n\n /**\n * Emits an entitlementChange event when the task's required entitlements change.\n * Call this from tasks with dynamic entitlements when their configuration changes\n * in a way that affects their entitlements.\n */\n protected emitEntitlementChange(entitlements?: TaskEntitlements): void {\n const final = entitlements ?? this.entitlements();\n this.emit(\"entitlementChange\", final);\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 * Frozen snapshot of config at construction time, used by toJSON and\n * as the resolution source for re-runs (so fresh lookups use original IDs).\n */\n readonly originalConfig: Readonly<Record<string, unknown>> | undefined;\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 config Configuration for the task (includes defaults for input values)\n * @param runConfig Runtime configuration for the task\n */\n constructor(config: NoInfer<Partial<Config>> = {}, runConfig: NoInfer<Partial<IRunConfig>> = {}) {\n // Extract caller-provided defaults from config\n const { defaults: callerDefaultInputs, ...restConfig } = config as Partial<Config> & {\n defaults?: Partial<Input>;\n };\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 restConfig\n ) as Config;\n if (baseConfig.id === undefined) {\n (baseConfig as Record<string, unknown>).id = uuid4();\n }\n this.config = this.validateAndApplyConfigDefaults(baseConfig);\n try {\n this.originalConfig = Object.freeze(structuredClone(this.config) as Record<string, unknown>);\n } catch {\n // Config contains non-cloneable values (e.g. functions).\n // canSerializeConfig() should return false for such tasks.\n this.originalConfig = undefined;\n }\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 (\n this.runInputData[inputId] === undefined &&\n (prop as { default?: unknown }).default !== undefined\n ) {\n this.runInputData[inputId] = prop.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.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 const err = new TaskInvalidInputError(\n `Task \"${this.type}\" (${this.id}): Input ${JSON.stringify(Object.keys(input))} does not match schema: ${errorMessages.join(\", \")}`\n );\n err.taskType = this.type;\n err.taskId = this.id;\n throw err;\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 * Returns whether the task's config can be serialized to JSON.\n * Override in subclasses that store non-serializable values (functions) in config.\n * Called by toJSON — if false, toJSON throws TaskSerializationError.\n */\n public canSerializeConfig(): boolean {\n return true;\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 if (!this.canSerializeConfig() || !this.originalConfig) {\n throw new TaskSerializationError(this.type);\n }\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 task-specific configs).\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.originalConfig 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\n // Include entitlements if present\n const taskEntitlements = this.entitlements();\n if (taskEntitlements.entitlements.length > 0) {\n base.entitlements = taskEntitlements;\n }\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",
19
- "/**\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 override readonly type: string = \"TaskError\";\n /** The type of the task that produced this error, if available. */\n public taskType?: string;\n /** The ID of the task that produced this error, if available. */\n public taskId?: unknown;\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 override 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 override 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 override 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 override 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 * Thrown when graph-level execution exceeds the configured `timeout` in\n * {@link TaskGraphRunConfig}. Distinct from {@link TaskTimeoutError} (which is\n * thrown for individual-task timeouts) so callers can tell whether the timeout\n * was on a single task or on the entire graph run.\n */\nexport class TaskGraphTimeoutError extends TaskTimeoutError {\n static override readonly type: string = \"TaskGraphTimeoutError\";\n constructor(timeoutMs?: number) {\n super(timeoutMs);\n // Override the message set by TaskTimeoutError to make it graph-specific.\n this.message = timeoutMs\n ? `Graph execution timed out after ${timeoutMs}ms`\n : \"Graph execution 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 override readonly type: string = \"TaskFailedError\";\n constructor(message: string = \"Task failed\") {\n super(message);\n }\n}\n\nexport class JobTaskFailedError extends TaskFailedError {\n static override 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 override 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 override readonly type: string = \"TaskInvalidInputError\";\n constructor(message: string = \"Invalid input data\") {\n super(message);\n }\n}\n\n/**\n * Thrown when required entitlements are denied by the registered enforcer.\n */\nexport class TaskEntitlementError extends TaskError {\n static override readonly type: string = \"TaskEntitlementError\";\n constructor(message: string = \"Required entitlements denied\") {\n super(message);\n }\n}\n\n/**\n * Thrown when toJSON is called on a task whose config contains non-serializable\n * values (e.g. functions). Tasks should override canSerializeConfig() to declare\n * whether they support serialization.\n */\nexport class TaskSerializationError extends TaskError {\n static override readonly type: string = \"TaskSerializationError\";\n constructor(taskType: string) {\n super(\n `Task \"${taskType}\" cannot be serialized: config contains non-serializable values. ` +\n `Use a declarative config alternative or remove function-valued config properties.`\n );\n }\n}\n",
20
21
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ISpan } from \"@workglow/util\";\nimport {\n getLogger,\n getTelemetryProvider,\n globalServiceRegistry,\n ResourceScope,\n ServiceRegistry,\n SpanStatusCode,\n} from \"@workglow/util\";\nimport { TASK_OUTPUT_REPOSITORY, TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { Taskish } from \"../task-graph/Conversions\";\nimport { ensureTask } from \"../task-graph/Conversions\";\nimport { resolveSchemaInputs, schemaHasFormatAnnotations } from \"./InputResolver\";\nimport type { IRunConfig, ITask } from \"./ITask\";\nimport { ITaskRunner } from \"./ITaskRunner\";\nimport type { StreamEvent, StreamMode } from \"./StreamTypes\";\nimport { getOutputStreamMode, getStreamingPorts, isTaskStreamable } 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 * Resource scope for this task run\n */\n protected resourceScope?: ResourceScope;\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 config schema annotations (e.g. mcp-server references) by mutating task.config.\n // Always resolve from originalConfig so re-runs use the original string IDs, not\n // previously resolved objects. The original config is preserved for serialization.\n const configSchema = (this.task.constructor as typeof Task).configSchema();\n if (schemaHasFormatAnnotations(configSchema)) {\n const source = (this.task as unknown as Task).originalConfig ?? this.task.config;\n const resolved = await resolveSchemaInputs(\n { ...source } as Record<string, unknown>,\n configSchema,\n { registry: this.registry }\n );\n Object.assign(this.task.config, resolved);\n }\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 // Warn if schema declares streaming but executeStream is not implemented\n if (!isStreamable && typeof this.task.executeStream !== \"function\") {\n const streamMode = getOutputStreamMode(this.task.outputSchema());\n if (streamMode !== \"none\") {\n getLogger().warn(\n `Task \"${this.task.type}\" declares streaming output (x-stream: \"${streamMode}\") ` +\n `but does not implement executeStream(). Falling back to non-streaming execute().`\n );\n }\n }\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 config schema annotations by mutating task.config directly\n const configSchema = (this.task.constructor as typeof Task).configSchema();\n if (schemaHasFormatAnnotations(configSchema)) {\n const source = (this.task as unknown as Task).originalConfig ?? this.task.config;\n const resolved = await resolveSchemaInputs(\n { ...source } as Record<string, unknown>,\n configSchema,\n { registry: this.registry }\n );\n Object.assign(this.task.config, resolved);\n }\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 resourceScope: this.resourceScope,\n });\n }\n // Notify listeners that the entitlement landscape may have changed.\n // For GraphAsTask this is also handled by the subGraph subscription, but\n // non-GraphAsTask tasks with dynamic entitlements (e.g. AiTask) need it too.\n if ((this.task.constructor as typeof Task).hasDynamicEntitlements) {\n this.task.emit(\"entitlementChange\", this.task.entitlements());\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 resourceScope: this.resourceScope,\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 resourceScope: this.resourceScope,\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 const existing = accumulatedObjects.get(event.port);\n if (Array.isArray(event.objectDelta)) {\n // Array delta: upsert items by `id` into accumulated array\n const arr: unknown[] = Array.isArray(existing) ? [...existing] : [];\n for (const item of event.objectDelta) {\n const itemObj = item as Record<string, unknown>;\n if (itemObj && typeof itemObj === \"object\" && \"id\" in itemObj) {\n const idx = arr.findIndex(\n (e) => (e as Record<string, unknown>).id === itemObj.id\n );\n if (idx >= 0) arr[idx] = item;\n else arr.push(item);\n } else {\n arr.push(item);\n }\n }\n accumulatedObjects.set(event.port, arr);\n } else {\n // Non-array (e.g. structured generation): replace semantics\n accumulatedObjects.set(event.port, event.objectDelta);\n }\n }\n // Update runOutputData with accumulated state so listeners see growing state\n this.task.runOutputData = {\n ...this.task.runOutputData,\n [event.port]: accumulatedObjects?.get(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 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 if (config.updateProgress) {\n this.updateProgress = config.updateProgress;\n }\n\n if (config.registry) {\n this.registry = config.registry;\n }\n\n if (config.resourceScope) {\n this.resourceScope = config.resourceScope;\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 // Listen first, then check — addEventListener on an already-aborted signal\n // does not fire, so checking .aborted after ensures we never miss an abort.\n if (config.signal) {\n const onAbort = () => this.abortController!.abort();\n config.signal.addEventListener(\"abort\", onAbort, { once: true });\n if (config.signal.aborted) {\n config.signal.removeEventListener(\"abort\", onAbort);\n this.abortController.abort();\n return;\n }\n }\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 // 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 // Call optional cleanup method for resource release\n if (typeof this.task.cleanup === \"function\") {\n try {\n await this.task.cleanup();\n } catch {\n // Cleanup errors are swallowed — abort must not throw from cleanup\n }\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 if (err instanceof TaskError) {\n this.task.error = err;\n } else {\n this.task.error = new TaskFailedError(\n `Task \"${this.task.type}\" (${this.task.id}): ${err?.message || \"Task failed\"}`\n );\n }\n // Attach task context to all TaskError instances for programmatic access\n if (this.task.error instanceof TaskError) {\n this.task.error.taskType ??= this.task.type;\n this.task.error.taskId ??= this.task.id;\n }\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",
21
22
  "/**\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 *\n * - **Non-array** (e.g. structured generation): each `objectDelta` is a\n * progressively more complete partial object snapshot. Consumers should\n * replace (not merge) their state with the latest delta.\n * - **Array** (e.g. tool calls): each `objectDelta` is a single-element\n * array containing one item to upsert by `id` into the accumulated array.\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",
22
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken } from \"@workglow/util\";\nimport type { EntitlementPolicy, EntitlementRule } from \"./EntitlementPolicy\";\nimport { evaluatePolicy } from \"./EntitlementPolicy\";\nimport type { IEntitlementResolver } from \"./EntitlementResolver\";\nimport { PERMISSIVE_RESOLVER } from \"./EntitlementResolver\";\nimport type { ITask } from \"./ITask\";\nimport type { Task } from \"./Task\";\nimport type { EntitlementGrant, TaskEntitlement, TaskEntitlements } from \"./TaskEntitlements\";\n\n// ========================================================================\n// Denial Type\n// ========================================================================\n\n/**\n * Why an entitlement was denied.\n * - `policy-deny`: matched a deny rule\n * - `default-deny`: no rule covered the entitlement\n * - `user-deny`: matched an ask rule and the resolver returned \"deny\"\n */\nexport type EntitlementDenialReason = \"policy-deny\" | \"default-deny\" | \"user-deny\";\n\n/**\n * A single denied entitlement with the reason and the matching rule (if any).\n * Returned by `IEntitlementEnforcer` to give callers enough context to build\n * actionable error messages without re-running policy evaluation.\n *\n * Discriminated union on `reason`:\n * - `policy-deny`: `matchedRule` is always present (it is the deny rule that matched).\n * - `user-deny`: `matchedRule` is always present (it is the ask rule that matched).\n * - `default-deny`: no rule matched at all; `matchedRule` is absent.\n */\nexport type EntitlementDenial =\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"policy-deny\";\n /** The deny rule that explicitly blocked this entitlement. */\n readonly matchedRule: EntitlementRule;\n }\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"default-deny\";\n }\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"user-deny\";\n /** The ask rule that triggered the user prompt. */\n readonly matchedRule: EntitlementRule;\n };\n\n/** Format a denial for inclusion in an error message. */\nexport function formatEntitlementDenial(denial: EntitlementDenial): string {\n switch (denial.reason) {\n case \"policy-deny\":\n return `${denial.entitlement.id} (denied by rule ${denial.matchedRule.id})`;\n case \"user-deny\":\n return `${denial.entitlement.id} (denied by user)`;\n case \"default-deny\":\n return `${denial.entitlement.id} (no matching grant)`;\n }\n}\n\n// ========================================================================\n// Enforcer Interface\n// ========================================================================\n\n/**\n * Interface for checking whether required entitlements are granted.\n * Register a custom implementation via the ServiceRegistry to enforce entitlements.\n *\n * Methods are async because resolving \"ask\" verdicts may require user interaction.\n */\nexport interface IEntitlementEnforcer {\n /**\n * Preflight check: evaluate all required entitlements against the policy.\n * Resolves \"ask\" verdicts via the resolver (prompt + save).\n * Returns the list of denials (non-optional entitlements only) — empty array when all granted.\n */\n checkAll(required: TaskEntitlements): Promise<readonly EntitlementDenial[]>;\n\n /**\n * Runtime check: evaluate a single task's dynamic entitlements.\n * Called during execution for tasks with `hasDynamicEntitlements`.\n */\n checkTask(task: ITask): Promise<readonly EntitlementDenial[]>;\n}\n\n// ========================================================================\n// Default Enforcers\n// ========================================================================\n\n/** Default permissive enforcer — grants everything. */\nexport const PERMISSIVE_ENFORCER: IEntitlementEnforcer = {\n checkAll: async () => [],\n checkTask: async () => [],\n};\n\n/**\n * Creates an enforcer from a unified entitlement policy with deny/grant/ask rules.\n *\n * Evaluation order: Deny → Grant → Ask → Default(deny).\n *\n * @param policy - The policy defining deny, grant, and ask rules\n * @param resolver - Pluggable resolver for handling \"ask\" verdicts. Defaults to PERMISSIVE_RESOLVER.\n */\nexport function createPolicyEnforcer(\n policy: EntitlementPolicy,\n resolver: IEntitlementResolver = PERMISSIVE_RESOLVER\n): IEntitlementEnforcer {\n async function resolveAsks(\n required: TaskEntitlements,\n taskType?: string,\n taskId?: unknown\n ): Promise<readonly EntitlementDenial[]> {\n const results = evaluatePolicy(policy, required);\n const denied: EntitlementDenial[] = [];\n\n for (const result of results) {\n if (result.verdict === \"denied\") {\n if (result.matchedRule) {\n denied.push({ entitlement: result.entitlement, reason: \"policy-deny\", matchedRule: result.matchedRule });\n } else {\n denied.push({ entitlement: result.entitlement, reason: \"default-deny\" });\n }\n } else if (result.verdict === \"ask\") {\n const request = {\n entitlement: result.entitlement,\n taskType: taskType ?? \"unknown\",\n taskId: taskId ?? \"unknown\",\n };\n // Check saved answer first; otherwise prompt and save\n let answer = resolver.lookup(request);\n if (answer === undefined) {\n answer = await resolver.prompt(request);\n resolver.save(request, answer);\n }\n if (answer === \"deny\") {\n // ask verdicts always have a matchedRule (the ask rule that fired)\n if (!result.matchedRule) {\n throw new Error(\n `Invariant violation: ask verdict for \"${result.entitlement.id}\" is missing matchedRule`\n );\n }\n denied.push({ entitlement: result.entitlement, reason: \"user-deny\", matchedRule: result.matchedRule });\n }\n }\n // \"granted\" — nothing to do\n }\n\n return denied;\n }\n\n return {\n async checkAll(required: TaskEntitlements): Promise<readonly EntitlementDenial[]> {\n return resolveAsks(required);\n },\n\n async checkTask(task: ITask): Promise<readonly EntitlementDenial[]> {\n const entitlements = task.entitlements();\n return resolveAsks(entitlements, (task.constructor as typeof Task).type, task.id);\n },\n };\n}\n\n/**\n * Creates an enforcer from scoped grants that support resource-level matching.\n * This is a convenience wrapper around `createPolicyEnforcer` with no deny or ask rules.\n *\n * Optional entitlements are never denied.\n */\nexport function createScopedEnforcer(grants: readonly EntitlementGrant[]): IEntitlementEnforcer {\n return createPolicyEnforcer({ deny: [], grant: grants, ask: [] });\n}\n\n/**\n * Creates an enforcer from a list of entitlement ID strings (broad grants).\n * Entitlement hierarchy is respected: granting \"network\" covers \"network:http\".\n * All grants are broad (no resource scoping). Optional entitlements are never denied.\n */\nexport function createGrantListEnforcer(grants: readonly string[]): IEntitlementEnforcer {\n return createScopedEnforcer(grants.map((id) => ({ id })));\n}\n\n// ========================================================================\n// Service Token\n// ========================================================================\n\n/** Service token for registering an entitlement enforcer in the ServiceRegistry */\nexport const ENTITLEMENT_ENFORCER = createServiceToken<IEntitlementEnforcer>(\n \"workglow.entitlementEnforcer\"\n);\n",
23
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken } from \"@workglow/util\";\nimport type { EntitlementPolicy, EntitlementRule } from \"./EntitlementPolicy\";\nimport { evaluatePolicy } from \"./EntitlementPolicy\";\nimport type { IEntitlementResolver } from \"./EntitlementResolver\";\nimport { PERMISSIVE_RESOLVER } from \"./EntitlementResolver\";\nimport type { ITask } from \"./ITask\";\nimport type { Task } from \"./Task\";\nimport type { EntitlementGrant, TaskEntitlement, TaskEntitlements } from \"./TaskEntitlements\";\n\n// ========================================================================\n// Denial Type\n// ========================================================================\n\n/**\n * Why an entitlement was denied.\n * - `policy-deny`: matched a deny rule\n * - `default-deny`: no rule covered the entitlement\n * - `user-deny`: matched an ask rule and the resolver returned \"deny\"\n */\nexport type EntitlementDenialReason = \"policy-deny\" | \"default-deny\" | \"user-deny\";\n\n/**\n * A single denied entitlement with the reason and the matching rule (if any).\n * Returned by `IEntitlementEnforcer` to give callers enough context to build\n * actionable error messages without re-running policy evaluation.\n *\n * Discriminated union on `reason`:\n * - `policy-deny`: `matchedRule` is always present (it is the deny rule that matched).\n * - `user-deny`: `matchedRule` is always present (it is the ask rule that matched).\n * - `default-deny`: no rule matched at all; `matchedRule` is absent.\n */\nexport type EntitlementDenial =\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"policy-deny\";\n /** The deny rule that explicitly blocked this entitlement. */\n readonly matchedRule: EntitlementRule;\n }\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"default-deny\";\n }\n | {\n readonly entitlement: TaskEntitlement;\n readonly reason: \"user-deny\";\n /** The ask rule that triggered the user prompt. */\n readonly matchedRule: EntitlementRule;\n };\n\n/** Format a denial for inclusion in an error message. */\nexport function formatEntitlementDenial(denial: EntitlementDenial): string {\n switch (denial.reason) {\n case \"policy-deny\":\n return `${denial.entitlement.id} (denied by rule ${denial.matchedRule.id})`;\n case \"user-deny\":\n return `${denial.entitlement.id} (denied by user)`;\n case \"default-deny\":\n return `${denial.entitlement.id} (no matching grant)`;\n }\n}\n\n// ========================================================================\n// Enforcer Interface\n// ========================================================================\n\n/**\n * Interface for checking whether required entitlements are granted.\n * Register a custom implementation via the ServiceRegistry to enforce entitlements.\n *\n * Methods are async because resolving \"ask\" verdicts may require user interaction.\n */\nexport interface IEntitlementEnforcer {\n /**\n * Preflight check: evaluate all required entitlements against the policy.\n * Resolves \"ask\" verdicts via the resolver (prompt + save).\n * Returns the list of denials (non-optional entitlements only) — empty array when all granted.\n */\n checkAll(required: TaskEntitlements): Promise<readonly EntitlementDenial[]>;\n\n /**\n * Runtime check: evaluate a single task's dynamic entitlements.\n * Called during execution for tasks with `hasDynamicEntitlements`.\n */\n checkTask(task: ITask): Promise<readonly EntitlementDenial[]>;\n}\n\n// ========================================================================\n// Default Enforcers\n// ========================================================================\n\n/** Default permissive enforcer — grants everything. */\nexport const PERMISSIVE_ENFORCER: IEntitlementEnforcer = {\n checkAll: async () => [],\n checkTask: async () => [],\n};\n\n/**\n * Creates an enforcer from a unified entitlement policy with deny/grant/ask rules.\n *\n * Evaluation order: Deny → Grant → Ask → Default(deny).\n *\n * @param policy - The policy defining deny, grant, and ask rules\n * @param resolver - Pluggable resolver for handling \"ask\" verdicts. Defaults to PERMISSIVE_RESOLVER.\n */\nexport function createPolicyEnforcer(\n policy: EntitlementPolicy,\n resolver: IEntitlementResolver = PERMISSIVE_RESOLVER\n): IEntitlementEnforcer {\n async function resolveAsks(\n required: TaskEntitlements,\n taskType?: string,\n taskId?: unknown\n ): Promise<readonly EntitlementDenial[]> {\n const results = evaluatePolicy(policy, required);\n const denied: EntitlementDenial[] = [];\n\n for (const result of results) {\n if (result.verdict === \"denied\") {\n if (result.matchedRule) {\n denied.push({\n entitlement: result.entitlement,\n reason: \"policy-deny\",\n matchedRule: result.matchedRule,\n });\n } else {\n denied.push({ entitlement: result.entitlement, reason: \"default-deny\" });\n }\n } else if (result.verdict === \"ask\") {\n const request = {\n entitlement: result.entitlement,\n taskType: taskType ?? \"unknown\",\n taskId: taskId ?? \"unknown\",\n };\n // Check saved answer first; otherwise prompt and save\n let answer = resolver.lookup(request);\n if (answer === undefined) {\n answer = await resolver.prompt(request);\n resolver.save(request, answer);\n }\n if (answer === \"deny\") {\n // ask verdicts always have a matchedRule (the ask rule that fired)\n if (!result.matchedRule) {\n throw new Error(\n `Invariant violation: ask verdict for \"${result.entitlement.id}\" is missing matchedRule`\n );\n }\n denied.push({\n entitlement: result.entitlement,\n reason: \"user-deny\",\n matchedRule: result.matchedRule,\n });\n }\n }\n // \"granted\" — nothing to do\n }\n\n return denied;\n }\n\n return {\n async checkAll(required: TaskEntitlements): Promise<readonly EntitlementDenial[]> {\n return resolveAsks(required);\n },\n\n async checkTask(task: ITask): Promise<readonly EntitlementDenial[]> {\n const entitlements = task.entitlements();\n return resolveAsks(entitlements, (task.constructor as typeof Task).type, task.id);\n },\n };\n}\n\n/**\n * Creates an enforcer from scoped grants that support resource-level matching.\n * This is a convenience wrapper around `createPolicyEnforcer` with no deny or ask rules.\n *\n * Optional entitlements are never denied.\n */\nexport function createScopedEnforcer(grants: readonly EntitlementGrant[]): IEntitlementEnforcer {\n return createPolicyEnforcer({ deny: [], grant: grants, ask: [] });\n}\n\n/**\n * Creates an enforcer from a list of entitlement ID strings (broad grants).\n * Entitlement hierarchy is respected: granting \"network\" covers \"network:http\".\n * All grants are broad (no resource scoping). Optional entitlements are never denied.\n */\nexport function createGrantListEnforcer(grants: readonly string[]): IEntitlementEnforcer {\n return createScopedEnforcer(grants.map((id) => ({ id })));\n}\n\n// ========================================================================\n// Service Token\n// ========================================================================\n\n/** Service token for registering an entitlement enforcer in the ServiceRegistry */\nexport const ENTITLEMENT_ENFORCER = createServiceToken<IEntitlementEnforcer>(\n \"workglow.entitlementEnforcer\"\n);\n",
23
24
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n EntitlementGrant,\n EntitlementId,\n TaskEntitlement,\n TaskEntitlements,\n} from \"./TaskEntitlements\";\nimport { entitlementCovers, grantCoversResources } from \"./TaskEntitlements\";\n\n// ========================================================================\n// Policy Types\n// ========================================================================\n\n/**\n * A rule matching entitlements by ID and optional resource patterns.\n * Used for deny and ask rules. Same shape as EntitlementGrant.\n */\nexport interface EntitlementRule {\n readonly id: EntitlementId;\n /** Resource patterns (glob-style). When undefined, matches broadly. */\n readonly resources?: readonly string[];\n}\n\n/**\n * A unified entitlement policy combining deny, grant, and ask rules.\n *\n * Evaluation order: Deny → Grant → Ask → Default(deny).\n * - Deny rules override everything — if matched, the entitlement is denied.\n * - Grant rules auto-allow without prompting.\n * - Ask rules trigger a resolver to prompt the user.\n * - If no rule matches, the entitlement is denied.\n */\nexport interface EntitlementPolicy {\n /** Hard denials — checked first, override grants */\n readonly deny: readonly EntitlementRule[];\n /** Grants — auto-allowed without prompting */\n readonly grant: readonly EntitlementGrant[];\n /** Ask rules — require user approval via a resolver */\n readonly ask: readonly EntitlementRule[];\n}\n\n/**\n * The result of evaluating a single entitlement against a policy.\n */\nexport type EntitlementVerdict = \"granted\" | \"denied\" | \"ask\";\n\n/**\n * Per-entitlement result from policy evaluation.\n */\nexport interface EntitlementCheckResult {\n readonly verdict: EntitlementVerdict;\n readonly entitlement: TaskEntitlement;\n /** The rule that produced this verdict (for debugging/UI). Undefined when default-denied. */\n readonly matchedRule?: EntitlementRule;\n}\n\n/** An empty policy that denies everything (no grants, no denies, no asks). */\nexport const EMPTY_POLICY: EntitlementPolicy = Object.freeze({\n deny: Object.freeze([]),\n grant: Object.freeze([]),\n ask: Object.freeze([]),\n});\n\n// ========================================================================\n// Policy Evaluation\n// ========================================================================\n\n/**\n * Check if a rule covers a required entitlement.\n * Uses the same hierarchy and resource matching as grants:\n * - Rule ID must cover the entitlement ID (via `entitlementCovers`)\n * - Rule resources must cover the entitlement resources (via `grantCoversResources`)\n */\nfunction ruleCovers(rule: EntitlementRule, required: TaskEntitlement): boolean {\n if (!entitlementCovers(rule.id, required.id)) return false;\n return grantCoversResources(rule as EntitlementGrant, required);\n}\n\n/**\n * Evaluates a policy against a set of required entitlements.\n *\n * For each required entitlement (skipping optional ones):\n * 1. If any deny rule matches → `\"denied\"`\n * 2. If any grant rule matches → `\"granted\"`\n * 3. If any ask rule matches → `\"ask\"`\n * 4. Otherwise → `\"denied\"` (default deny)\n *\n * This is a pure function with no side effects.\n */\nexport function evaluatePolicy(\n policy: EntitlementPolicy,\n required: TaskEntitlements\n): readonly EntitlementCheckResult[] {\n const results: EntitlementCheckResult[] = [];\n\n for (const entitlement of required.entitlements) {\n if (entitlement.optional) continue;\n\n // 1. Check deny rules first\n const denyMatch = policy.deny.find((rule) => ruleCovers(rule, entitlement));\n if (denyMatch) {\n results.push({ verdict: \"denied\", entitlement, matchedRule: denyMatch });\n continue;\n }\n\n // 2. Check grant rules\n const grantMatch = policy.grant.find((rule) => ruleCovers(rule, entitlement));\n if (grantMatch) {\n results.push({ verdict: \"granted\", entitlement, matchedRule: grantMatch });\n continue;\n }\n\n // 3. Check ask rules\n const askMatch = policy.ask.find((rule) => ruleCovers(rule, entitlement));\n if (askMatch) {\n results.push({ verdict: \"ask\", entitlement, matchedRule: askMatch });\n continue;\n }\n\n // 4. Default deny\n results.push({ verdict: \"denied\", entitlement });\n }\n\n return results;\n}\n\n/**\n * Pure single-entitlement check. Convenience wrapper around `evaluatePolicy`\n * for callers that want the `can(action, resource)` style verdict in one call.\n *\n * Returns the per-entitlement check result with `verdict` (`\"granted\"`, `\"denied\"`,\n * or `\"ask\"`) and the `matchedRule` that produced it. No side effects — no\n * resolver is invoked even for `\"ask\"` verdicts; the caller decides how to\n * handle that.\n */\nexport function can(\n policy: EntitlementPolicy,\n id: EntitlementId,\n resources?: readonly string[]\n): EntitlementCheckResult {\n const required: TaskEntitlement = resources !== undefined ? { id, resources } : { id };\n // evaluatePolicy skips optional entitlements; we always pass a non-optional one.\n const [result] = evaluatePolicy(policy, { entitlements: [required] });\n return result;\n}\n",
24
25
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { createServiceToken } from \"@workglow/util\";\nimport type { TaskEntitlement } from \"./TaskEntitlements\";\nimport type { TaskIdType } from \"./TaskTypes\";\n\n// ========================================================================\n// Resolver Types\n// ========================================================================\n\n/**\n * A request to the resolver for a user decision on an entitlement.\n */\nexport interface EntitlementAskRequest {\n /** The entitlement that needs a decision */\n readonly entitlement: TaskEntitlement;\n /** The task type requesting the entitlement */\n readonly taskType: string;\n /** The task instance ID requesting the entitlement */\n readonly taskId: TaskIdType;\n}\n\n/**\n * A user's answer to an entitlement ask.\n */\nexport type EntitlementAnswer = \"grant\" | \"deny\";\n\n// ========================================================================\n// Resolver Interface\n// ========================================================================\n\n/**\n * Pluggable interface for handling \"ask\" entitlement verdicts.\n *\n * The resolver is responsible for:\n * - Checking if a saved answer exists (`lookup`)\n * - Prompting the user for a decision (`prompt`)\n * - Persisting the user's answer for future lookups (`save`)\n *\n * Implementations vary by environment:\n * - Builder app: shows a dialog, persists answers per-project\n * - CLI: prints to terminal, saves in config\n * - Tests: use PERMISSIVE_RESOLVER or DENY_ALL_RESOLVER\n */\nexport interface IEntitlementResolver {\n /** Check if there's a saved answer for this ask. Returns undefined if not saved. */\n lookup(request: EntitlementAskRequest): EntitlementAnswer | undefined;\n /** Prompt the user and return their answer. May block on UI. */\n prompt(request: EntitlementAskRequest): Promise<EntitlementAnswer>;\n /** Save a user's answer for future lookups. */\n save(request: EntitlementAskRequest, answer: EntitlementAnswer): void;\n}\n\n// ========================================================================\n// Built-in Resolvers\n// ========================================================================\n\n/** Grants all asks without prompting. Useful for tests and permissive environments. */\nexport const PERMISSIVE_RESOLVER: IEntitlementResolver = {\n lookup: () => \"grant\",\n prompt: async () => \"grant\",\n save: () => {},\n};\n\n/** Denies all asks without prompting. Useful for locked-down environments. */\nexport const DENY_ALL_RESOLVER: IEntitlementResolver = {\n lookup: () => \"deny\",\n prompt: async () => \"deny\",\n save: () => {},\n};\n\n// ========================================================================\n// Service Token\n// ========================================================================\n\n/** Service token for registering an entitlement resolver in the ServiceRegistry */\nexport const ENTITLEMENT_RESOLVER = createServiceToken<IEntitlementResolver>(\n \"workglow.entitlementResolver\"\n);\n",
25
26
  "/**\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",
26
27
  "/**\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 type { GraphAsTaskConfig } from \"./GraphAsTask\";\nimport { GraphAsTask } from \"./GraphAsTask\";\nimport { TaskRunner } from \"./TaskRunner\";\nimport type { TaskInput, TaskOutput } from \"./TaskTypes\";\n\nexport class GraphAsTaskRunner<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends GraphAsTaskConfig<Input> = GraphAsTaskConfig<Input>,\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 // Route inner graph_progress through handleProgress so the outer graph's\n // updateProgress callback fires (updating task.progress and re-emitting\n // graph_progress up the chain). A bare emit on the task was silently\n // dropped by the outer TaskGraphRunner, leaving parent progress stuck at\n // the value from whichever task ran before this one. Mirrors the pattern\n // used by FallbackTaskRunner, IteratorTaskRunner, and WhileTask.\n const unsubscribe = this.task.subGraph!.subscribe(\n \"graph_progress\",\n (progress: number, message?: string, ...args: any[]) => {\n void this.handleProgress(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 resourceScope: this.resourceScope,\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 resourceScope: this.resourceScope,\n });\n }\n\n protected override 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 override 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 override 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",
27
28
  "/**\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(config: any) {\n super(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 override readonly type = \"Own[Graph]\";\n }\n\n class OwnWorkflowTask extends ListeningGraphAsTask {\n public static override readonly type = \"Own[Workflow]\";\n }\n\n class GraphTask extends GraphAsTask {\n public static override readonly type = \"Graph\";\n }\n\n class ConvWorkflowTask extends GraphAsTask {\n public static override 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 // Plain JS functions used inside `pipe()` cannot declare port schemas, so\n // the wrapper must accept (and emit) any object shape. The previous\n // `additionalProperties: false` (alongside a single `[DATAFLOW_ALL_PORTS]`\n // (\"*\") property) caused the JSON-schema validator to treat \"*\" as a\n // literal key and reject every real upstream port — e.g. `{ json, metadata }`\n // from `FetchUrlTask` — breaking any `pipe(task, async fn, ...)` chain with\n // TaskInvalidInputError. The runtime already handles the \"*\" wildcard in\n // `Task.addInput`; the schema just needs to permit the data through.\n class QuickTask extends Task<I, O> {\n public static override type = fn.name ? `𝑓 ${fn.name}` : \"𝑓\";\n public static override inputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n };\n public static override outputSchema = () => {\n return {\n type: \"object\",\n properties: {\n [DATAFLOW_ALL_PORTS]: {},\n },\n additionalProperties: true,\n } as const satisfies DataPortSchema;\n };\n public static override cacheable = false;\n public override 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",
28
29
  "/**\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 type { TaskEntitlements } from \"../task/TaskEntitlements\";\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 /** Fired when the aggregated entitlements of the graph change */\n entitlementChange: (entitlements: TaskEntitlements) => 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",
29
- "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { EventParameters } from \"@workglow/util\";\nimport { EventEmitter, getLogger, ServiceRegistry, uuid4 } from \"@workglow/util\";\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { JsonSchema } from \"@workglow/util/schema\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { ConditionFn } from \"../task/ConditionalTask\";\nimport { GraphAsTask } from \"../task/GraphAsTask\";\nimport type { ITask, ITaskConstructor } from \"../task/ITask\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport { getPortStreamMode } from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport type { TaskEntitlements } from \"../task/TaskEntitlements\";\nimport { WorkflowError } from \"../task/TaskError\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport type { DataPorts, TaskConfig, TaskIdType, TaskInput } from \"../task/TaskTypes\";\nimport { ConditionalBuilder } from \"./ConditionalBuilder\";\nimport type { PipeFunction, Taskish } from \"./Conversions\";\nimport { ensureTask } from \"./Conversions\";\nimport { Dataflow, DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport type { GraphEntitlementOptions } from \"./GraphEntitlementUtils\";\nimport { computeGraphEntitlements } from \"./GraphEntitlementUtils\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport type { IWorkflow, WorkflowRunConfig } from \"./IWorkflow\";\nimport { TaskGraph } from \"./TaskGraph\";\nimport type { PropertyArrayGraphResult } from \"./TaskGraphRunner\";\nimport { CompoundMergeStrategy, PROPERTY_ARRAY } 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 config = {\n compoundMerge: mergeFn,\n };\n const name = `‖${args.map((_arg) => \"𝑓\").join(\"‖\")}‖`;\n class ParallelTask extends GraphAsTask<I, O> {\n public static override type = name;\n }\n const mergeTask = new ParallelTask(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<I>> = (\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<I> = TaskConfig<I>,\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<I> = TaskConfig<I>,\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<I> = TaskConfig<I>,\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<IS> = TaskConfig<IS>,\n CV extends TaskConfig<IV> = TaskConfig<IV>,\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<IS> = TaskConfig<IS>,\n CV extends TaskConfig<IV> = TaskConfig<IV>,\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 /** Fired when the aggregated entitlements of the workflow change */\n entitlementChange: (entitlements: TaskEntitlements) => 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 override readonly type = \"Workflow\";\n public static override 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 * @param registry - Optional service registry to use for this workflow run\n * @returns A new Workflow instance\n */\n constructor(\n cache?: TaskOutputRepository,\n parent?: Workflow,\n iteratorTask?: GraphAsTask,\n registry?: ServiceRegistry\n ) {\n this._outputCache = cache;\n this._parentWorkflow = parent;\n this._iteratorTask = iteratorTask;\n this._registry = registry ?? parent?._registry;\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 private _registry?: ServiceRegistry;\n private _entitlementUnsub?: () => void;\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<I> = TaskConfig<I>,\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>(taskClass, {\n id: uuid4(),\n ...config,\n defaults: input,\n } as C);\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 helper.type = (taskClass as unknown as { runtype?: string }).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 ?? this._registry,\n resourceScope: config?.resourceScope,\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 /**\n * Returns the aggregated entitlements required by all tasks in this workflow.\n * @param options Options for controlling aggregation (e.g., conditional branch handling)\n */\n public entitlements(options?: GraphEntitlementOptions): TaskEntitlements {\n return computeGraphEntitlements(this._graph, 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 this._entitlementUnsub = this._graph.subscribeToTaskEntitlements((entitlements) =>\n this.events.emit(\"entitlementChange\", entitlements)\n );\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 this._entitlementUnsub?.();\n this._entitlementUnsub = undefined;\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<I> = TaskConfig<I>,\n >(taskClass: ITaskConstructor<I, O, C>, config: C): ITask<I, O, C> {\n const task = new taskClass(config, this._registry ? { registry: this._registry } : undefined);\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<I> = TaskConfig<I>>(\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<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig<I> = TaskConfig<I>,\n >(taskClass: ITaskConstructor<I, O, C>, config: Partial<C> = {}): Workflow<I, O> {\n this._error = \"\";\n\n const parent = getLastTask(this);\n\n const task = this.addTaskToGraph<I, O, C>(taskClass, { 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 this._registry\n ) as unknown as Workflow<I, O>;\n if (parent) {\n loopBuilder._pendingLoopConnect = { parent, iteratorTask: task };\n }\n return loopBuilder;\n }\n\n /**\n * Opens a conditional branch. Returns a {@link ConditionalBuilder} that\n * accepts `.then(taskClass)` and optional `.else(taskClass)` arms and is\n * closed via `.endIf()` to return to this workflow.\n *\n * @example\n * ```ts\n * workflow\n * .if((input) => input.kind === \"text\")\n * .then(TextTask)\n * .else(ImageTask)\n * .endIf();\n * ```\n */\n public if(condition: ConditionFn<TaskInput>): ConditionalBuilder {\n return new ConditionalBuilder(this, condition);\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 ITask).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 // @ts-expect-error - config is readonly\n task.config = {\n ...task.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 let prop = (sourceSchema.properties as any)?.[df.sourceTaskPortId];\n let propRequired = sourceSchema.required?.includes(df.sourceTaskPortId) ?? false;\n\n // For passthrough tasks with additionalProperties (e.g. DebugLogTask),\n // the port won't appear in the static output schema. Trace back through\n // the passthrough task's own incoming dataflows to find the actual schema.\n if (\n !prop &&\n sourceSchema.additionalProperties === true &&\n (sourceTask.constructor as typeof Task).passthroughInputsToOutputs === true\n ) {\n const upstreamDfs = graph.getSourceDataflows(sourceTask.id);\n for (const udf of upstreamDfs) {\n if (udf.targetTaskPortId !== df.sourceTaskPortId) continue;\n const upstreamTask = graph.getTask(udf.sourceTaskId);\n if (!upstreamTask) continue;\n const upstreamSchema = upstreamTask.outputSchema();\n if (typeof upstreamSchema === \"boolean\") continue;\n prop = (upstreamSchema.properties as any)?.[udf.sourceTaskPortId];\n if (prop) {\n propRequired = upstreamSchema.required?.includes(udf.sourceTaskPortId) ?? false;\n break;\n }\n }\n }\n\n if (prop && typeof prop !== \"boolean\") {\n properties[df.targetTaskPortId] = prop;\n if (propRequired && !required.includes(df.targetTaskPortId)) {\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 // @ts-expect-error - config is readonly\n task.config = {\n ...task.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 const outputKeys = Object.keys(fromSchema.properties || {});\n if (outputKeys.length > 0) {\n for (const fromOutputPortId of outputKeys) {\n if (matches.has(fromOutputPortId)) continue;\n matches.set(fromOutputPortId, fromOutputPortId);\n graph.addDataflow(\n new Dataflow(fromTaskId, fromOutputPortId, toTaskId, fromOutputPortId)\n );\n }\n } else if (fromSchema.additionalProperties === true) {\n // For passthrough tasks with no named output ports, infer output\n // port names from the task's incoming dataflows so the downstream\n // connection is established (e.g. DebugLogTask → OutputTask).\n const sourceGraphTask = graph.getTask(fromTaskId);\n if (\n sourceGraphTask &&\n (sourceGraphTask.constructor as typeof Task).passthroughInputsToOutputs === true\n ) {\n const incomingDfs = graph.getSourceDataflows(fromTaskId);\n for (const df of incomingDfs) {\n const portId = df.targetTaskPortId;\n if (portId === DATAFLOW_ALL_PORTS) continue;\n if (matches.has(portId)) continue;\n if (connectedInputKeys.has(portId)) continue;\n matches.set(portId, portId);\n graph.addDataflow(new Dataflow(fromTaskId, portId, toTaskId, portId));\n }\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.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 this._iteratorTask.validateAcyclic();\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",
30
- "/**\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 type { ConditionFn } from \"../task/ConditionalTask\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport type { ITask, ITaskConstructor } from \"../task/ITask\";\nimport { WorkflowError } from \"../task/TaskError\";\nimport type { DataPorts, TaskConfig, TaskInput } from \"../task/TaskTypes\";\nimport { Dataflow } from \"./Dataflow\";\nimport type { Workflow } from \"./Workflow\";\n\n/**\n * Fluent builder for constructing a {@link ConditionalTask} with a\n * canonical then/else shape. Created by {@link Workflow.if} and closed via\n * {@link ConditionalBuilder.endIf}. Each arm accepts a single task class\n * (with optional input/config), which the builder instantiates and wires\n * from the conditional's matching output port.\n *\n * Usage:\n *\n * ```ts\n * workflow\n * .if((input) => input.kind === \"text\")\n * .then(TextTask)\n * .else(ImageTask)\n * .endIf();\n * ```\n */\nexport class ConditionalBuilder {\n private thenSpec: BranchTaskSpec | undefined;\n private elseSpec: BranchTaskSpec | undefined;\n\n constructor(\n private readonly workflow: Workflow,\n private readonly condition: ConditionFn<TaskInput>\n ) {}\n\n /**\n * Register the task that runs when the condition matches. Accepts the\n * same (taskClass, input?, config?) triple as {@link Workflow.addTask}.\n */\n public then<I extends DataPorts, O extends DataPorts, C extends TaskConfig<I> = TaskConfig<I>>(\n taskClass: ITaskConstructor<I, O, C>,\n input?: Partial<I>,\n config?: Partial<C>\n ): this {\n this.thenSpec = { taskClass, input, config };\n return this;\n }\n\n /**\n * Register the task that runs when the condition does not match. Optional.\n */\n public else<I extends DataPorts, O extends DataPorts, C extends TaskConfig<I> = TaskConfig<I>>(\n taskClass: ITaskConstructor<I, O, C>,\n input?: Partial<I>,\n config?: Partial<C>\n ): this {\n this.elseSpec = { taskClass, input, config };\n return this;\n }\n\n /**\n * Finalize the if/else arms into a {@link ConditionalTask} plus the\n * downstream branch tasks, wired via dataflows from the conditional's\n * matching output ports. Returns the parent workflow for continued chaining.\n */\n public endIf(): Workflow {\n if (!this.thenSpec) {\n throw new WorkflowError(\".endIf() called without a prior .then(...) call\");\n }\n\n const thenPort = \"then\";\n const elsePort = \"else\";\n\n const branches = [\n {\n id: thenPort,\n condition: this.condition,\n outputPort: thenPort,\n },\n ];\n\n if (this.elseSpec) {\n // Inverse condition so the \"else\" branch is mutually exclusive with \"then\".\n // If the user's condition throws, ConditionalTask's own error handling\n // treats both branches as not-matched; `defaultBranch: elsePort` below\n // then routes to else — matching ConditionalTask's error-as-false semantics.\n branches.push({\n id: elsePort,\n condition: (input: TaskInput) => !this.condition(input),\n outputPort: elsePort,\n });\n }\n\n const conditionalTask = new ConditionalTask({\n id: uuid4(),\n branches,\n exclusive: true,\n defaultBranch: this.elseSpec ? elsePort : undefined,\n });\n this.workflow.graph.addTask(conditionalTask);\n\n const thenTask = instantiate(this.thenSpec);\n this.workflow.graph.addTask(thenTask);\n this.workflow.graph.addDataflow(\n new Dataflow(conditionalTask.id, thenPort, thenTask.id, \"*\")\n );\n\n if (this.elseSpec) {\n const elseTask = instantiate(this.elseSpec);\n this.workflow.graph.addTask(elseTask);\n this.workflow.graph.addDataflow(\n new Dataflow(conditionalTask.id, elsePort, elseTask.id, \"*\")\n );\n }\n\n return this.workflow;\n }\n}\n\ninterface BranchTaskSpec {\n readonly taskClass: ITaskConstructor<any, any, any>;\n readonly input?: unknown;\n readonly config?: unknown;\n}\n\nfunction instantiate(spec: BranchTaskSpec): ITask<any, any, any> {\n const config = {\n id: uuid4(),\n ...(spec.config as Record<string, unknown> | undefined),\n defaults: spec.input,\n };\n return new spec.taskClass(config as any);\n}\n",
30
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { EventParameters } from \"@workglow/util\";\nimport { EventEmitter, getLogger, ServiceRegistry, uuid4 } from \"@workglow/util\";\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { JsonSchema } from \"@workglow/util/schema\";\nimport { TaskOutputRepository } from \"../storage/TaskOutputRepository\";\nimport type { ConditionFn } from \"../task/ConditionalTask\";\nimport { GraphAsTask } from \"../task/GraphAsTask\";\nimport type { ITask, ITaskConstructor } from \"../task/ITask\";\nimport type { StreamEvent } from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport type { TaskEntitlements } from \"../task/TaskEntitlements\";\nimport { WorkflowError } from \"../task/TaskError\";\nimport type { JsonTaskItem, TaskGraphJson, TaskGraphJsonOptions } from \"../task/TaskJSON\";\nimport type { DataPorts, TaskConfig, TaskIdType, TaskInput } from \"../task/TaskTypes\";\nimport { autoConnect } from \"./autoConnect\";\nimport { ConditionalBuilder } from \"./ConditionalBuilder\";\nimport type { PipeFunction, Taskish } from \"./Conversions\";\nimport { ensureTask } from \"./Conversions\";\nimport { Dataflow, DATAFLOW_ALL_PORTS, DATAFLOW_ERROR_PORT } from \"./Dataflow\";\nimport type { GraphEntitlementOptions } from \"./GraphEntitlementUtils\";\nimport { computeGraphEntitlements } from \"./GraphEntitlementUtils\";\nimport type { ITaskGraph } from \"./ITaskGraph\";\nimport type { IWorkflow, WorkflowRunConfig } from \"./IWorkflow\";\nimport { TaskGraph } from \"./TaskGraph\";\nimport type { PropertyArrayGraphResult } from \"./TaskGraphRunner\";\nimport { CompoundMergeStrategy, PROPERTY_ARRAY } from \"./TaskGraphRunner\";\nimport type { ITransformStep } from \"./TransformTypes\";\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\n/** Options accepted by {@link Workflow.rename}. */\nexport interface RenameOptions {\n /** Index of the task whose output is renamed (defaults to the last task, `-1`). */\n readonly index?: number;\n /** Transform chain applied to the dataflow edge this rename creates. */\n readonly transforms?: ReadonlyArray<ITransformStep>;\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 config = {\n compoundMerge: mergeFn,\n };\n const name = `‖${args.map((_arg) => \"𝑓\").join(\"‖\")}‖`;\n class ParallelTask extends GraphAsTask<I, O> {\n public static override type = name;\n }\n const mergeTask = new ParallelTask(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<I>> = (\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<I> = TaskConfig<I>,\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<I> = TaskConfig<I>,\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<I> = TaskConfig<I>,\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<IS> = TaskConfig<IS>,\n CV extends TaskConfig<IV> = TaskConfig<IV>,\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<IS> = TaskConfig<IS>,\n CV extends TaskConfig<IV> = TaskConfig<IV>,\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 /** Fired when the aggregated entitlements of the workflow change */\n entitlementChange: (entitlements: TaskEntitlements) => 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 override readonly type = \"Workflow\";\n public static override 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 * @param registry - Optional service registry to use for this workflow run\n * @returns A new Workflow instance\n */\n constructor(\n cache?: TaskOutputRepository,\n parent?: Workflow,\n iteratorTask?: GraphAsTask,\n registry?: ServiceRegistry\n ) {\n this._outputCache = cache;\n this._parentWorkflow = parent;\n this._iteratorTask = iteratorTask;\n this._registry = registry ?? parent?._registry;\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 private _registry?: ServiceRegistry;\n private _entitlementUnsub?: () => void;\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<I> = TaskConfig<I>,\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>(taskClass, {\n id: uuid4(),\n ...config,\n defaults: input,\n } as C);\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 helper.type = (taskClass as unknown as { runtype?: string }).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 ?? this._registry,\n resourceScope: config?.resourceScope,\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 /**\n * Returns the aggregated entitlements required by all tasks in this workflow.\n * @param options Options for controlling aggregation (e.g., conditional branch handling)\n */\n public entitlements(options?: GraphEntitlementOptions): TaskEntitlements {\n return computeGraphEntitlements(this._graph, 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 indexOrOptions - Either the numeric task index (defaults to `-1`,\n * the last task) or a {@link RenameOptions} bag with `index` and/or\n * `transforms` to apply to the pending dataflow.\n * @returns The current task graph workflow\n */\n public rename(source: string, target: string, index?: number): Workflow;\n public rename(source: string, target: string, options: RenameOptions): Workflow;\n public rename(\n source: string,\n target: string,\n indexOrOptions: number | RenameOptions = -1\n ): Workflow {\n this._error = \"\";\n\n const index =\n typeof indexOrOptions === \"number\" ? indexOrOptions : (indexOrOptions.index ?? -1);\n const transforms = typeof indexOrOptions === \"number\" ? undefined : indexOrOptions.transforms;\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 const df = new Dataflow(lastNode.id, source, undefined, target);\n if (transforms && transforms.length > 0) df.setTransforms(transforms);\n this._dataFlows.push(df);\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 this._entitlementUnsub = this._graph.subscribeToTaskEntitlements((entitlements) =>\n this.events.emit(\"entitlementChange\", entitlements)\n );\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 this._entitlementUnsub?.();\n this._entitlementUnsub = undefined;\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<I> = TaskConfig<I>,\n >(taskClass: ITaskConstructor<I, O, C>, config: C): ITask<I, O, C> {\n const task = new taskClass(config, this._registry ? { registry: this._registry } : undefined);\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<I> = TaskConfig<I>>(\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<\n I extends DataPorts,\n O extends DataPorts,\n C extends TaskConfig<I> = TaskConfig<I>,\n >(taskClass: ITaskConstructor<I, O, C>, config: Partial<C> = {}): Workflow<I, O> {\n this._error = \"\";\n\n const parent = getLastTask(this);\n\n // Default maxIterations to \"unbounded\" for loop tasks whose config schema\n // marks it as required (MapTask, WhileTask, ReduceTask, ForEachTask). The\n // raw task constructors still require an explicit value; this default is a\n // convenience only for the fluent Workflow builder API.\n const schema = (\n taskClass as unknown as { configSchema?: () => DataPortSchema }\n ).configSchema?.();\n const required =\n typeof schema === \"object\" && schema !== null\n ? (schema as { required?: readonly string[] }).required\n : undefined;\n const needsMaxIterations = Array.isArray(required) && required.includes(\"maxIterations\");\n const resolvedConfig =\n needsMaxIterations && (config as { maxIterations?: unknown }).maxIterations === undefined\n ? ({ ...config, maxIterations: \"unbounded\" } as Partial<C>)\n : config;\n\n const task = this.addTaskToGraph<I, O, C>(taskClass, { id: uuid4(), ...resolvedConfig } 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 this._registry\n ) as unknown as Workflow<I, O>;\n if (parent) {\n loopBuilder._pendingLoopConnect = { parent, iteratorTask: task };\n }\n return loopBuilder;\n }\n\n /**\n * Opens a conditional branch. Returns a {@link ConditionalBuilder} that\n * accepts `.then(taskClass)` and optional `.else(taskClass)` arms and is\n * closed via `.endIf()` to return to this workflow.\n *\n * @example\n * ```ts\n * workflow\n * .if((input) => input.kind === \"text\")\n * .then(TextTask)\n * .else(ImageTask)\n * .endIf();\n * ```\n */\n public if(condition: ConditionFn<TaskInput>): ConditionalBuilder {\n return new ConditionalBuilder(this, condition);\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 ITask).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 // @ts-expect-error - config is readonly\n task.config = {\n ...task.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 let prop = (sourceSchema.properties as any)?.[df.sourceTaskPortId];\n let propRequired = sourceSchema.required?.includes(df.sourceTaskPortId) ?? false;\n\n // For passthrough tasks with additionalProperties (e.g. DebugLogTask),\n // the port won't appear in the static output schema. Trace back through\n // the passthrough task's own incoming dataflows to find the actual schema.\n if (\n !prop &&\n sourceSchema.additionalProperties === true &&\n (sourceTask.constructor as typeof Task).passthroughInputsToOutputs === true\n ) {\n const upstreamDfs = graph.getSourceDataflows(sourceTask.id);\n for (const udf of upstreamDfs) {\n if (udf.targetTaskPortId !== df.sourceTaskPortId) continue;\n const upstreamTask = graph.getTask(udf.sourceTaskId);\n if (!upstreamTask) continue;\n const upstreamSchema = upstreamTask.outputSchema();\n if (typeof upstreamSchema === \"boolean\") continue;\n prop = (upstreamSchema.properties as any)?.[udf.sourceTaskPortId];\n if (prop) {\n propRequired = upstreamSchema.required?.includes(udf.sourceTaskPortId) ?? false;\n break;\n }\n }\n }\n\n if (prop && typeof prop !== \"boolean\") {\n properties[df.targetTaskPortId] = prop;\n if (propRequired && !required.includes(df.targetTaskPortId)) {\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 // @ts-expect-error - config is readonly\n task.config = {\n ...task.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 return autoConnect(graph, sourceTask, targetTask, options);\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 this._iteratorTask.validateAcyclic();\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",
31
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { JsonSchema } from \"@workglow/util/schema\";\nimport type { ITask } from \"../task/ITask\";\nimport { getPortStreamMode } from \"../task/StreamTypes\";\nimport { Task } from \"../task/Task\";\nimport { Dataflow, DATAFLOW_ALL_PORTS } from \"./Dataflow\";\nimport type { TaskGraph } from \"./TaskGraph\";\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 */\nexport function 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 * When true, skip `graph.addDataflow(...)` side effects and return matches\n * only. Used by callers (e.g. the builder's proximity auto-connect) that\n * need to know what *would* be connected without mutating the graph.\n */\n readonly dryRun?: boolean;\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 const dryRun = options?.dryRun ?? false;\n const addDataflow = (df: Dataflow): void => {\n if (!dryRun) graph.addDataflow(df);\n };\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 const outputKeys = Object.keys(fromSchema.properties || {});\n if (outputKeys.length > 0) {\n for (const fromOutputPortId of outputKeys) {\n if (matches.has(fromOutputPortId)) continue;\n matches.set(fromOutputPortId, fromOutputPortId);\n addDataflow(new Dataflow(fromTaskId, fromOutputPortId, toTaskId, fromOutputPortId));\n }\n } else if (fromSchema.additionalProperties === true) {\n // For passthrough tasks with no named output ports, infer output\n // port names from the task's incoming dataflows so the downstream\n // connection is established (e.g. DebugLogTask → OutputTask).\n const sourceGraphTask = graph.getTask(fromTaskId);\n if (\n sourceGraphTask &&\n (sourceGraphTask.constructor as typeof Task).passthroughInputsToOutputs === true\n ) {\n const incomingDfs = graph.getSourceDataflows(fromTaskId);\n for (const df of incomingDfs) {\n const portId = df.targetTaskPortId;\n if (portId === DATAFLOW_ALL_PORTS) continue;\n if (matches.has(portId)) continue;\n if (connectedInputKeys.has(portId)) continue;\n matches.set(portId, portId);\n addDataflow(new Dataflow(fromTaskId, portId, toTaskId, portId));\n }\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 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 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 portIdsCompatible && isTypeCompatible(fromPortOutputSchema, toPortInputSchema, false);\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.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 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 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",
32
+ "/**\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 type { ConditionFn } from \"../task/ConditionalTask\";\nimport { ConditionalTask } from \"../task/ConditionalTask\";\nimport type { ITask, ITaskConstructor } from \"../task/ITask\";\nimport { WorkflowError } from \"../task/TaskError\";\nimport type { DataPorts, TaskConfig, TaskInput } from \"../task/TaskTypes\";\nimport { Dataflow } from \"./Dataflow\";\nimport type { Workflow } from \"./Workflow\";\n\n/**\n * Fluent builder for constructing a {@link ConditionalTask} with a\n * canonical then/else shape. Created by {@link Workflow.if} and closed via\n * {@link ConditionalBuilder.endIf}. Each arm accepts a single task class\n * (with optional input/config), which the builder instantiates and wires\n * from the conditional's matching output port.\n *\n * Usage:\n *\n * ```ts\n * workflow\n * .if((input) => input.kind === \"text\")\n * .then(TextTask)\n * .else(ImageTask)\n * .endIf();\n * ```\n */\nexport class ConditionalBuilder {\n private thenSpec: BranchTaskSpec | undefined;\n private elseSpec: BranchTaskSpec | undefined;\n\n constructor(\n private readonly workflow: Workflow,\n private readonly condition: ConditionFn<TaskInput>\n ) {}\n\n /**\n * Register the task that runs when the condition matches. Accepts the\n * same (taskClass, input?, config?) triple as {@link Workflow.addTask}.\n */\n public then<I extends DataPorts, O extends DataPorts, C extends TaskConfig<I> = TaskConfig<I>>(\n taskClass: ITaskConstructor<I, O, C>,\n input?: Partial<I>,\n config?: Partial<C>\n ): this {\n this.thenSpec = { taskClass, input, config };\n return this;\n }\n\n /**\n * Register the task that runs when the condition does not match. Optional.\n */\n public else<I extends DataPorts, O extends DataPorts, C extends TaskConfig<I> = TaskConfig<I>>(\n taskClass: ITaskConstructor<I, O, C>,\n input?: Partial<I>,\n config?: Partial<C>\n ): this {\n this.elseSpec = { taskClass, input, config };\n return this;\n }\n\n /**\n * Finalize the if/else arms into a {@link ConditionalTask} plus the\n * downstream branch tasks, wired via dataflows from the conditional's\n * matching output ports. Returns the parent workflow for continued chaining.\n */\n public endIf(): Workflow {\n if (!this.thenSpec) {\n throw new WorkflowError(\".endIf() called without a prior .then(...) call\");\n }\n\n const thenPort = \"then\";\n const elsePort = \"else\";\n\n const branches = [\n {\n id: thenPort,\n condition: this.condition,\n outputPort: thenPort,\n },\n ];\n\n if (this.elseSpec) {\n // Inverse condition so the \"else\" branch is mutually exclusive with \"then\".\n // If the user's condition throws, ConditionalTask's own error handling\n // treats both branches as not-matched; `defaultBranch: elsePort` below\n // then routes to else — matching ConditionalTask's error-as-false semantics.\n branches.push({\n id: elsePort,\n condition: (input: TaskInput) => !this.condition(input),\n outputPort: elsePort,\n });\n }\n\n const conditionalTask = new ConditionalTask({\n id: uuid4(),\n branches,\n exclusive: true,\n defaultBranch: this.elseSpec ? elsePort : undefined,\n });\n this.workflow.graph.addTask(conditionalTask);\n\n const thenTask = instantiate(this.thenSpec);\n this.workflow.graph.addTask(thenTask);\n this.workflow.graph.addDataflow(new Dataflow(conditionalTask.id, thenPort, thenTask.id, \"*\"));\n\n if (this.elseSpec) {\n const elseTask = instantiate(this.elseSpec);\n this.workflow.graph.addTask(elseTask);\n this.workflow.graph.addDataflow(new Dataflow(conditionalTask.id, elsePort, elseTask.id, \"*\"));\n }\n\n return this.workflow;\n }\n}\n\ninterface BranchTaskSpec {\n readonly taskClass: ITaskConstructor<any, any, any>;\n readonly input?: unknown;\n readonly config?: unknown;\n}\n\nfunction instantiate(spec: BranchTaskSpec): ITask<any, any, any> {\n const config = {\n id: uuid4(),\n ...(spec.config as Record<string, unknown> | undefined),\n defaults: spec.input,\n };\n return new spec.taskClass(config as any);\n}\n",
31
33
  "/**\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 { Task } from \"../task/Task\";\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 ForEachTask: { method: \"forEach\", endMethod: \"endForEach\" },\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 typeof Task).title || \"\";\n const staticDescription = (task.constructor as typeof Task).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 case \"ForEachTask\": {\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 if (rawConfig.maxIterations !== undefined) {\n config.maxIterations = rawConfig.maxIterations;\n }\n break;\n }\n case \"ReduceTask\": {\n if (rawConfig.initialValue !== undefined) {\n config.initialValue = rawConfig.initialValue;\n }\n if (rawConfig.maxIterations !== undefined) {\n config.maxIterations = rawConfig.maxIterations;\n }\n break;\n }\n case \"WhileTask\": {\n if (rawConfig.maxIterations !== undefined) {\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 */\n/**\n * Strips entries whose value is `undefined` — they carry no information\n * and would emit noisy `key: undefined` literals in the generated code.\n */\nfunction stripUndefined(\n obj: Record<string, unknown> | undefined\n): Record<string, unknown> | undefined {\n if (!obj) return obj;\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n if (v !== undefined) result[k] = v;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\nfunction buildMethodArgs(\n defaults: Record<string, unknown> | undefined,\n config: Record<string, unknown>,\n baseIndent: string = \"\",\n columnOffset: number = 0\n): string {\n defaults = stripUndefined(defaults);\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",
34
+ "/**\n * @license Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { areSemanticallyCompatible } from \"@workglow/util/schema\";\nimport type { ITransformDef } from \"../TransformTypes\";\n\ninterface PickParams {\n readonly path: string;\n}\n\nfunction walk(value: unknown, path: string): unknown {\n if (value == null) return undefined;\n const parts = path.split(\".\");\n let cur: any = value;\n for (const p of parts) {\n if (cur == null) return undefined;\n cur = cur[p];\n }\n return cur;\n}\n\nfunction walkSchema(schema: DataPortSchema, path: string): DataPortSchema {\n const parts = path.split(\".\");\n let cur: any = schema;\n for (const p of parts) {\n if (!cur || typeof cur !== \"object\") return {} as DataPortSchema;\n if (cur.type !== \"object\" || !cur.properties || !cur.properties[p]) {\n return {} as DataPortSchema;\n }\n cur = cur.properties[p];\n }\n return cur as DataPortSchema;\n}\n\nexport const pickTransform: ITransformDef<PickParams> = {\n id: \"pick\",\n title: \"Pick field\",\n category: \"Structural\",\n paramsSchema: {\n type: \"object\",\n properties: {\n path: { type: \"string\", description: \"Dotted property path\" },\n },\n required: [\"path\"],\n } as DataPortSchema,\n\n inferOutputSchema(inputSchema, params) {\n return walkSchema(inputSchema, params.path);\n },\n\n apply(value, params) {\n return walk(value, params.path);\n },\n\n suggestFromSchemas(source, target) {\n if ((source as any).type !== \"object\" || !(source as any).properties) {\n return undefined;\n }\n const props = (source as any).properties as Record<string, DataPortSchema>;\n // Prefer exact leaf match; fall back to first compatible property.\n for (const [name, propSchema] of Object.entries(props)) {\n const compat = areSemanticallyCompatible(propSchema, target);\n if (compat === \"static\") return { score: 1.0, params: { path: name } };\n if (compat === \"runtime\") return { score: 0.6, params: { path: name } };\n }\n return undefined;\n },\n};\n",
35
+ "/**\n * @license Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { DataPortSchema } from \"@workglow/util/schema\";\nimport { areSemanticallyCompatible } from \"@workglow/util/schema\";\nimport type { ITransformDef } from \"../TransformTypes\";\n\ninterface IndexParams {\n readonly index: number;\n}\n\nfunction doIndex(value: unknown, idx: number): unknown {\n if (!Array.isArray(value)) return undefined;\n const i = idx < 0 ? value.length + idx : idx;\n return value[i];\n}\n\nexport const indexTransform: ITransformDef<IndexParams> = {\n id: \"index\",\n title: \"Array index\",\n category: \"Structural\",\n paramsSchema: {\n type: \"object\",\n properties: {\n index: { type: \"integer\", description: \"Array index (negative counts from end)\" },\n },\n required: [\"index\"],\n } as DataPortSchema,\n\n inferOutputSchema(inputSchema) {\n const s = inputSchema as any;\n if (s?.type === \"array\" && s.items) return s.items as DataPortSchema;\n return {} as DataPortSchema;\n },\n\n apply(value, params) {\n return doIndex(value, params.index);\n },\n\n suggestFromSchemas(source, target) {\n const s = source as any;\n if (s?.type !== \"array\" || !s.items) return undefined;\n const compat = areSemanticallyCompatible(s.items, target);\n if (compat === \"static\") return { score: 0.9, params: { index: 0 } };\n if (compat === \"runtime\") return { score: 0.5, params: { index: 0 } };\n return undefined;\n },\n};\n",
36
+ "/**\n * @license 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 { ITransformDef } from \"../TransformTypes\";\n\ninterface CoalesceParams {\n readonly defaultValue: unknown;\n}\n\nfunction stripNullable(schema: DataPortSchema): DataPortSchema {\n const s = schema as any;\n if (!s || typeof s !== \"object\") return schema;\n if (Array.isArray(s.type)) {\n const nonNull = s.type.filter((t: string) => t !== \"null\");\n if (nonNull.length === 1) return { ...s, type: nonNull[0] } as DataPortSchema;\n return { ...s, type: nonNull } as DataPortSchema;\n }\n return schema;\n}\n\nexport const coalesceTransform: ITransformDef<CoalesceParams> = {\n id: \"coalesce\",\n title: \"Coalesce null\",\n category: \"Conversion\",\n paramsSchema: {\n type: \"object\",\n properties: { defaultValue: {} },\n required: [\"defaultValue\"],\n } as DataPortSchema,\n inferOutputSchema: (input) => stripNullable(input),\n apply: (v, { defaultValue }) => (v == null ? defaultValue : v),\n};\n",
37
+ "/**\n * @license 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 { ITransformDef } from \"../TransformTypes\";\n\nconst stringSchema: DataPortSchema = { type: \"string\" } as DataPortSchema;\n\nexport const uppercaseTransform: ITransformDef<{}> = {\n id: \"uppercase\",\n title: \"Uppercase\",\n category: \"String\",\n paramsSchema: undefined,\n inferOutputSchema: () => stringSchema,\n apply: (v) => String(v ?? \"\").toUpperCase(),\n};\n\nexport const lowercaseTransform: ITransformDef<{}> = {\n id: \"lowercase\",\n title: \"Lowercase\",\n category: \"String\",\n paramsSchema: undefined,\n inferOutputSchema: () => stringSchema,\n apply: (v) => String(v ?? \"\").toLowerCase(),\n};\n\ninterface TruncateParams {\n readonly max: number;\n}\n\nexport const truncateTransform: ITransformDef<TruncateParams> = {\n id: \"truncate\",\n title: \"Truncate\",\n category: \"String\",\n paramsSchema: {\n type: \"object\",\n properties: { max: { type: \"integer\", minimum: 0 } },\n required: [\"max\"],\n } as DataPortSchema,\n inferOutputSchema: () => stringSchema,\n apply: (v, { max }) => String(v ?? \"\").slice(0, max),\n};\n\ninterface SubstringParams {\n readonly start: number;\n readonly end: number | undefined;\n}\n\nexport const substringTransform: ITransformDef<SubstringParams> = {\n id: \"substring\",\n title: \"Substring\",\n category: \"String\",\n paramsSchema: {\n type: \"object\",\n properties: {\n start: { type: \"integer\" },\n end: { type: \"integer\" },\n },\n required: [\"start\"],\n } as DataPortSchema,\n inferOutputSchema: () => stringSchema,\n apply: (v, { start, end }) => String(v ?? \"\").slice(start, end),\n};\n",
38
+ "/**\n * @license 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 { ITransformDef } from \"../TransformTypes\";\n\ninterface UnixUnit {\n readonly unit: \"s\" | \"ms\";\n}\n\nconst isoSchema: DataPortSchema = { type: \"string\", format: \"date-time\" } as DataPortSchema;\nconst numberSchema: DataPortSchema = { type: \"number\" } as DataPortSchema;\n\nfunction hasDateTimeFormat(schema: DataPortSchema): boolean {\n const s = schema as any;\n return s?.type === \"string\" && s.format === \"date-time\";\n}\n\nexport const unixToIsoDateTransform: ITransformDef<UnixUnit> = {\n id: \"unixToIsoDate\",\n title: \"Unix timestamp → ISO date\",\n category: \"Date\",\n paramsSchema: {\n type: \"object\",\n properties: {\n unit: { type: \"string\", enum: [\"s\", \"ms\"] },\n },\n required: [\"unit\"],\n } as DataPortSchema,\n inferOutputSchema: () => isoSchema,\n apply: (v, { unit }) => {\n const n = Number(v);\n return new Date(unit === \"s\" ? n * 1000 : n).toISOString();\n },\n suggestFromSchemas(source, target) {\n const s = source as any;\n if (s?.type !== \"number\" && s?.type !== \"integer\") return undefined;\n if (!hasDateTimeFormat(target)) return undefined;\n // Without semantic hints we don't know the unit; prefer \"s\" because\n // most unix timestamps in the wild are seconds.\n return { score: 0.85, params: { unit: \"s\" } };\n },\n};\n\nexport const isoDateToUnixTransform: ITransformDef<{}> = {\n id: \"isoDateToUnix\",\n title: \"ISO date → Unix ms\",\n category: \"Date\",\n paramsSchema: undefined,\n inferOutputSchema: () => numberSchema,\n apply: (v) => new Date(String(v)).getTime(),\n suggestFromSchemas(source, target) {\n if (!hasDateTimeFormat(source)) return undefined;\n const t = target as any;\n if (t?.type !== \"number\" && t?.type !== \"integer\") return undefined;\n return { score: 0.9, params: {} };\n },\n};\n",
39
+ "/**\n * @license 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 { ITransformDef } from \"../TransformTypes\";\n\nconst stringSchema: DataPortSchema = { type: \"string\" } as DataPortSchema;\nconst booleanSchema: DataPortSchema = { type: \"boolean\" } as DataPortSchema;\n\nexport const numberToStringTransform: ITransformDef<{}> = {\n id: \"numberToString\",\n title: \"Number → String\",\n category: \"Conversion\",\n paramsSchema: undefined,\n inferOutputSchema: () => stringSchema,\n apply: (v) => String(v),\n suggestFromSchemas(source, target) {\n const s = source as any;\n const t = target as any;\n if ((s?.type === \"number\" || s?.type === \"integer\") && t?.type === \"string\") {\n return { score: 0.8, params: {} };\n }\n return undefined;\n },\n};\n\nexport const toBooleanTransform: ITransformDef<{}> = {\n id: \"toBoolean\",\n title: \"To Boolean\",\n category: \"Conversion\",\n paramsSchema: undefined,\n inferOutputSchema: () => booleanSchema,\n apply: (v) => {\n if (typeof v === \"boolean\") return v;\n if (typeof v === \"number\") return v !== 0;\n if (typeof v === \"string\") return v.toLowerCase() === \"true\" || v === \"1\";\n return Boolean(v);\n },\n};\n\nexport const stringifyTransform: ITransformDef<{}> = {\n id: \"stringify\",\n title: \"JSON.stringify\",\n category: \"Conversion\",\n paramsSchema: undefined,\n inferOutputSchema: () => stringSchema,\n apply: (v) => JSON.stringify(v),\n suggestFromSchemas(source, target) {\n const t = target as any;\n return t?.type === \"string\" ? { score: 0.4, params: {} } : undefined;\n },\n};\n\nexport const parseJsonTransform: ITransformDef<{}> = {\n id: \"parseJson\",\n title: \"Parse JSON\",\n category: \"Conversion\",\n paramsSchema: undefined,\n inferOutputSchema: () => ({}) as DataPortSchema,\n apply: (v) => JSON.parse(String(v)),\n};\n",
40
+ "/**\n * @license Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { TransformRegistry } from \"../TransformRegistry\";\nimport { pickTransform } from \"./pick\";\nimport { indexTransform } from \"./index-access\";\nimport { coalesceTransform } from \"./coalesce\";\nimport {\n uppercaseTransform,\n lowercaseTransform,\n truncateTransform,\n substringTransform,\n} from \"./string-casts\";\nimport { unixToIsoDateTransform, isoDateToUnixTransform } from \"./date-conversions\";\nimport {\n numberToStringTransform,\n toBooleanTransform,\n stringifyTransform,\n parseJsonTransform,\n} from \"./scalar-conversions\";\n\nexport {\n pickTransform,\n indexTransform,\n coalesceTransform,\n uppercaseTransform,\n lowercaseTransform,\n truncateTransform,\n substringTransform,\n unixToIsoDateTransform,\n isoDateToUnixTransform,\n numberToStringTransform,\n toBooleanTransform,\n stringifyTransform,\n parseJsonTransform,\n};\n\n/**\n * Registers all MVP built-in transforms. Separate from registerBaseTasks so\n * consumers can opt in independently (tests may want transforms without\n * task registration and vice versa).\n */\nexport function registerBuiltInTransforms(): void {\n const all = [\n pickTransform,\n indexTransform,\n coalesceTransform,\n uppercaseTransform,\n lowercaseTransform,\n truncateTransform,\n substringTransform,\n unixToIsoDateTransform,\n isoDateToUnixTransform,\n numberToStringTransform,\n toBooleanTransform,\n stringifyTransform,\n parseJsonTransform,\n ];\n for (const t of all) TransformRegistry.registerTransform(t);\n}\n",
32
41
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n *\n * Pre-built entitlement grant profiles for common runtime environments.\n * The library has no concept of Electron, brands, or deployment targets —\n * only capability profiles expressed as entitlement policies.\n */\n\nimport { createPolicyEnforcer, type IEntitlementEnforcer } from \"./EntitlementEnforcer\";\nimport type { EntitlementPolicy } from \"./EntitlementPolicy\";\nimport type { IEntitlementResolver } from \"./EntitlementResolver\";\nimport type { EntitlementGrant } from \"./TaskEntitlements\";\nimport { Entitlements } from \"./TaskEntitlements\";\n\n// ========================================================================\n// Grant Profiles\n// ========================================================================\n\n/**\n * Browser environment grants.\n * No filesystem access, no code execution, no stdio MCP.\n *\n * Network grants are intentionally narrow: `network:http` + `network:websocket`.\n * The broader `network` grant is NOT issued because its hierarchical cover\n * would silently permit `network:private`, undermining SSRF protection.\n * Callers that legitimately need private/loopback access (e.g. a dev server\n * on localhost) must augment the enforcer with a scoped `network:private`\n * grant — see `workflow-builder/packages/app/src/lib/run-workflow.ts`.\n */\nexport const BROWSER_GRANTS: readonly EntitlementGrant[] = [\n { id: Entitlements.NETWORK_HTTP },\n { id: Entitlements.NETWORK_WEBSOCKET },\n { id: Entitlements.AI },\n { id: Entitlements.MCP_TOOL_CALL },\n { id: Entitlements.MCP_RESOURCE_READ },\n { id: Entitlements.MCP_PROMPT_GET },\n { id: Entitlements.STORAGE },\n { id: Entitlements.CREDENTIAL },\n];\n\n/**\n * Desktop environment grants (e.g., Electron with Node.js main process).\n * Adds filesystem, code execution, stdio MCP, and browser control on top of browser grants.\n */\nexport const DESKTOP_GRANTS: readonly EntitlementGrant[] = [\n ...BROWSER_GRANTS,\n { id: Entitlements.FILESYSTEM },\n { id: Entitlements.CODE_EXECUTION },\n { id: Entitlements.MCP_STDIO },\n { id: Entitlements.BROWSER_CONTROL },\n { id: Entitlements.BROWSER_CONTROL_LOCAL },\n { id: Entitlements.BROWSER_CONTROL_NAVIGATE },\n { id: Entitlements.BROWSER_CONTROL_EVALUATE },\n { id: Entitlements.BROWSER_CONTROL_CREDENTIAL },\n];\n\n/**\n * Server environment grants (e.g., cloud deployment).\n * Same as desktop plus BROWSER_CONTROL_CLOUD since server can proxy to cloud providers.\n */\nexport const SERVER_GRANTS: readonly EntitlementGrant[] = [\n ...DESKTOP_GRANTS,\n { id: Entitlements.BROWSER_CONTROL_CLOUD },\n];\n\n// ========================================================================\n// Policy Factory\n// ========================================================================\n\nexport type EntitlementProfile = \"browser\" | \"desktop\" | \"server\";\n\nconst PROFILE_GRANTS: Record<EntitlementProfile, readonly EntitlementGrant[]> = {\n browser: BROWSER_GRANTS,\n desktop: DESKTOP_GRANTS,\n server: SERVER_GRANTS,\n};\n\n/**\n * Creates an entitlement policy for the given runtime profile.\n * The profile's grants become the policy's grant rules.\n * Deny and ask arrays are empty by default — callers can extend the returned policy.\n */\nexport function createProfilePolicy(profile: EntitlementProfile): EntitlementPolicy {\n return { deny: [], grant: PROFILE_GRANTS[profile], ask: [] };\n}\n\n/**\n * Creates an entitlement enforcer for the given runtime profile.\n * Tasks requiring entitlements not in the profile will be denied.\n *\n * @param profile - The runtime profile to use\n * @param resolver - Optional resolver for handling \"ask\" verdicts\n */\nexport function createProfileEnforcer(\n profile: EntitlementProfile,\n resolver?: IEntitlementResolver\n): IEntitlementEnforcer {\n return createPolicyEnforcer(createProfilePolicy(profile), resolver);\n}\n\n/**\n * Returns the grant list for a given profile.\n * Useful for inspection or combining with additional grants.\n */\nexport function getProfileGrants(profile: EntitlementProfile): readonly EntitlementGrant[] {\n return PROFILE_GRANTS[profile];\n}\n",
33
42
  "/**\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 } from \"./TaskTypes\";\nimport type { TaskInput, 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<Input> = FallbackTaskConfig<Input>,\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 /**\n * Blend the subgraph's aggregate `graph_progress` with the outer attempt index so\n * nested streaming tasks visibly advance the bar between attempt boundaries. This\n * mirrors the pattern used by {@link IteratorTaskRunner.executeSubgraphIteration}\n * and {@link WhileTask.execute}. Because each attempt resets the subgraph and\n * `graph_progress` starts at 0, the blended value is monotonic across attempts\n * as `currentAttemptIndex` advances.\n */\n let currentAttemptIndex = 0;\n const onSubgraphProgress = (innerProgress: number, message?: string): void => {\n const blended = Math.round(\n ((currentAttemptIndex + innerProgress / 100) / totalAttempts) * 100\n );\n void this.handleProgress(\n blended,\n message ?? `Data alternative ${currentAttemptIndex + 1}/${totalAttempts}`\n );\n };\n const unsubscribeSubgraphProgress = this.task.subGraph.subscribe(\n \"graph_progress\",\n onSubgraphProgress\n );\n\n try {\n for (let i = 0; i < alternatives.length; i++) {\n if (this.abortController?.signal.aborted) {\n throw new TaskAbortedError(\"Fallback aborted\");\n }\n\n currentAttemptIndex = i;\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 } finally {\n unsubscribeSubgraphProgress();\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",
34
43
  "/**\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, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { GraphAsTaskConfig } 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<Input extends TaskInput = TaskInput> = GraphAsTaskConfig<Input> & {\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<Input> = FallbackTaskConfig<Input>,\n> extends GraphAsTask<Input, Output, Config> {\n // ========================================================================\n // Static properties\n // ========================================================================\n\n public static override type: TaskTypeName = \"FallbackTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Fallback\";\n public static override description: string = \"Try alternatives until one succeeds\";\n\n /** FallbackTask has dynamic schemas based on the subgraph structure. */\n public static override hasDynamicSchemas: boolean = true;\n\n public static override 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<TaskInput>>;\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",
35
44
  "/**\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 { getInputCompactors } from \"@workglow/util\";\nimport { getSchemaFormat, getFormatPrefix, getObjectSchema } from \"./InputResolver\";\n\n/**\n * Configuration for the input compactor\n */\nexport interface InputCompactorConfig {\n readonly registry: ServiceRegistry;\n}\n\n/**\n * Checks if a schema allows a string variant, recursively checking\n * through oneOf/anyOf nesting (e.g., TypeSingleOrArray(TypeModel(...))).\n */\nfunction schemaAllowsString(schema: unknown, visited: WeakSet<object> = new WeakSet()): boolean {\n if (typeof schema !== \"object\" || schema === null) return false;\n if (visited.has(schema)) return false;\n visited.add(schema);\n\n const s = schema as Record<string, unknown>;\n\n if (s.type === \"string\") return true;\n\n const variants = (s.oneOf ?? s.anyOf) as unknown[] | undefined;\n if (Array.isArray(variants)) {\n for (const variant of variants) {\n if (schemaAllowsString(variant, visited)) return true;\n }\n }\n\n const allOf = s.allOf as unknown[] | undefined;\n if (Array.isArray(allOf)) {\n for (const sub of allOf) {\n if (schemaAllowsString(sub, visited)) return true;\n }\n }\n\n return false;\n}\n\n/**\n * Compacts resolved inputs by converting instances back to their string IDs.\n * This is the reverse of `resolveSchemaInputs()` — objects with registered\n * compactors are replaced with their string identifier when the schema\n * allows a string variant (oneOf/anyOf with type: \"string\").\n *\n * @param input The task input object with resolved values\n * @param schema The task's input/config schema\n * @param config Configuration including the service registry\n * @returns The input with compacted values (objects replaced with string IDs)\n *\n * @example\n * ```typescript\n * // Compact a resolved model config back to its ID\n * const compacted = await compactSchemaInputs(\n * { model: { model_id: \"gpt-4\", provider: \"openai\", ... } },\n * taskSchema,\n * { registry: globalServiceRegistry }\n * );\n * // compacted.model === \"gpt-4\"\n * ```\n */\nexport async function compactSchemaInputs<T extends Record<string, unknown>>(\n input: T,\n schema: DataPortSchema,\n config: InputCompactorConfig,\n visited: Set<object> = new Set()\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 compactors = getInputCompactors();\n const compacted: Record<string, unknown> = { ...input };\n\n for (const [key, propSchema] of Object.entries(properties)) {\n let value = compacted[key];\n\n const format = getSchemaFormat(propSchema);\n if (format) {\n let compactor = compactors.get(format);\n if (!compactor) {\n const prefix = getFormatPrefix(format);\n compactor = compactors.get(prefix);\n }\n\n if (compactor) {\n // Handle object values: attempt to compact to string ID\n // Only compact if the schema allows a string variant (oneOf/anyOf with type: \"string\")\n if (\n value !== null &&\n value !== undefined &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n schemaAllowsString(propSchema)\n ) {\n const id = await compactor(value, format, config.registry);\n if (id !== undefined) {\n compacted[key] = id;\n continue; // Replaced with string — skip recursion\n }\n }\n // Handle arrays: compact object elements to strings where possible\n else if (Array.isArray(value)) {\n compacted[key] = await Promise.all(\n value.map(async (item) => {\n if (\n item !== null &&\n item !== undefined &&\n typeof item === \"object\" &&\n !Array.isArray(item)\n ) {\n const id = await compactor(item, format, config.registry);\n return id !== undefined ? id : item;\n }\n return item;\n })\n );\n continue;\n }\n // String values are already compact — pass through\n }\n }\n\n // Recurse into object values that have nested properties in schema\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 && !visited.has(objectSchema)) {\n visited.add(objectSchema);\n try {\n compacted[key] = await compactSchemaInputs(\n value as Record<string, unknown>,\n objectSchema as DataPortSchema,\n config,\n visited\n );\n } finally {\n visited.delete(objectSchema);\n }\n }\n }\n }\n\n return compacted as T;\n}\n",
36
45
  "/**\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 { ITaskConstructor } from \"./ITask\";\nimport {\n resolveIterationBound,\n type IterationAnalysisResult,\n type IteratorTask,\n type IteratorTaskConfig,\n} 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<Input> = IteratorTaskConfig<Input>,\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 let analysis = this.task.analyzeIterationInput(input);\n\n // Enforce maxIterations cap. Config is required (construction-time guard),\n // so the bound is always set; `\"unbounded\"` resolves to Infinity, which\n // leaves the natural array-length count untouched.\n const maxIterations = resolveIterationBound(this.task.config.maxIterations);\n if (analysis.iterationCount > maxIterations) {\n analysis = { ...analysis, iterationCount: maxIterations };\n }\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({ ...clonedConfig, defaults: task.defaults }, 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 * Subscribe to the iteration subgraph's aggregate `graph_progress` rather than individual\n * task `progress` events. {@link TaskGraphRunner.handleProgress} already averages across\n * only the tasks whose class declares its own `execute` (see `taskPrototypeHasOwnExecute`),\n * so passthrough nodes like `InputTask` — which hit `progress=100` immediately and would\n * otherwise saturate a max-across-tasks partial — are correctly excluded. This mirrors\n * the pattern in {@link GraphAsTaskRunner.executeTaskChildren}, and the `finally` block\n * below bumps the partial to 100 to guarantee completion for degenerate (all-passthrough)\n * subgraphs where `contributors.length === 0`.\n */\n const onGraphProgress = (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 const unsubscribeGraphProgress = graphClone.subscribe(\"graph_progress\", onGraphProgress);\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 resourceScope: this.resourceScope,\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 unsubscribeGraphProgress();\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",
37
- "/**\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, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { GraphAsTaskConfig } from \"./GraphAsTask\";\nimport type { IExecuteContext, IRunConfig } 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 * Upper bound for iteration. Either a positive integer or the string\n * sentinel `\"unbounded\"` — which the runner treats as `Number.POSITIVE_INFINITY`.\n * The string form forces every caller to explicitly acknowledge the opt-out\n * instead of silently dropping the safety ceiling.\n */\nexport type IterationBound = number | \"unbounded\";\n\n/**\n * Resolves an IterationBound to a numeric cap the runner can compare against.\n */\nexport function resolveIterationBound(bound: IterationBound): number {\n return bound === \"unbounded\" ? Number.POSITIVE_INFINITY : bound;\n}\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 maxIterations: {\n oneOf: [{ type: \"integer\", minimum: 1 }, { type: \"string\", const: \"unbounded\" }],\n },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n required: [\"maxIterations\"],\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<Input extends TaskInput = TaskInput> = GraphAsTaskConfig<Input> & {\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 * Upper bound on the number of iterations. Required — pass `\"unbounded\"` to\n * explicitly opt out of the safety ceiling, or a positive integer to cap.\n * Prevents runaway iteration on unexpectedly large input arrays.\n */\n readonly maxIterations: IterationBound;\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 * Only unwraps flexible schemas (T | T[]) and plain arrays.\n * Preserves discriminated unions (oneOf/anyOf) that aren't flexible wrappers.\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 // Only unwrap if this is a flexible schema (T | T[]) pattern.\n // Discriminated unions (e.g., oneOf: [string, object]) should be preserved as-is.\n let hasScalar = false;\n let hasArray = false;\n let scalarVariant: PropertySchema | undefined;\n let arrayVariant: PropertySchema | undefined;\n\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const v = variant as Record<string, unknown>;\n if (v.type === \"array\" || \"items\" in v) {\n hasArray = true;\n arrayVariant = variant as PropertySchema;\n } else {\n hasScalar = true;\n scalarVariant = variant as PropertySchema;\n }\n }\n }\n\n if (hasScalar && hasArray && variants.length === 2) {\n // This is a flexible (T | T[]) wrapper — extract the scalar base\n return scalarVariant!;\n }\n\n if (!hasScalar && hasArray && arrayVariant) {\n // All variants are arrays — extract items from the first array variant\n return (arrayVariant as Record<string, unknown>).items as PropertySchema;\n }\n\n // Not a flexible wrapper — preserve the union as-is\n return schema;\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<Input> = IteratorTaskConfig<Input>,\n> extends GraphAsTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"IteratorTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Iterator\";\n public static override description: string = \"Base class for loop-type tasks\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static override hasDynamicSchemas: boolean = true;\n\n public static override configSchema(): DataPortSchema {\n return iteratorTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n if ((config as Partial<IteratorTaskConfig<Input>>).maxIterations === undefined) {\n throw new TaskConfigurationError(\n `${(new.target as typeof IteratorTask).type ?? \"IteratorTask\"}: maxIterations is required. ` +\n `Pass a positive integer to cap iteration, or \"unbounded\" to opt out explicitly.`\n );\n }\n super(config, runConfig);\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 // ========================================================================\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 override 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 override inputSchema(): DataPortSchema {\n if (this.hasChildren()) {\n return this.getIterationInputSchema();\n }\n return (this.constructor as typeof IteratorTask).inputSchema();\n }\n\n public override 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",
46
+ "/**\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 type { GraphAsTaskConfig } from \"./GraphAsTask\";\nimport { GraphAsTask, graphAsTaskConfigSchema } from \"./GraphAsTask\";\nimport type { IExecuteContext, IRunConfig } 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 * Upper bound for iteration. Either a positive integer or the string\n * sentinel `\"unbounded\"` — which the runner treats as `Number.POSITIVE_INFINITY`.\n * The string form forces every caller to explicitly acknowledge the opt-out\n * instead of silently dropping the safety ceiling.\n */\nexport type IterationBound = number | \"unbounded\";\n\n/**\n * Resolves an IterationBound to a numeric cap the runner can compare against.\n */\nexport function resolveIterationBound(bound: IterationBound): number {\n return bound === \"unbounded\" ? Number.POSITIVE_INFINITY : bound;\n}\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 maxIterations: {\n oneOf: [\n { type: \"integer\", minimum: 1 },\n { type: \"string\", const: \"unbounded\" },\n ],\n },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n required: [\"maxIterations\"],\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<Input extends TaskInput = TaskInput> = GraphAsTaskConfig<Input> & {\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 * Upper bound on the number of iterations. Required — pass `\"unbounded\"` to\n * explicitly opt out of the safety ceiling, or a positive integer to cap.\n * Prevents runaway iteration on unexpectedly large input arrays.\n */\n readonly maxIterations: IterationBound;\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 * Only unwraps flexible schemas (T | T[]) and plain arrays.\n * Preserves discriminated unions (oneOf/anyOf) that aren't flexible wrappers.\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 // Only unwrap if this is a flexible schema (T | T[]) pattern.\n // Discriminated unions (e.g., oneOf: [string, object]) should be preserved as-is.\n let hasScalar = false;\n let hasArray = false;\n let scalarVariant: PropertySchema | undefined;\n let arrayVariant: PropertySchema | undefined;\n\n for (const variant of variants) {\n if (typeof variant === \"object\") {\n const v = variant as Record<string, unknown>;\n if (v.type === \"array\" || \"items\" in v) {\n hasArray = true;\n arrayVariant = variant as PropertySchema;\n } else {\n hasScalar = true;\n scalarVariant = variant as PropertySchema;\n }\n }\n }\n\n if (hasScalar && hasArray && variants.length === 2) {\n // This is a flexible (T | T[]) wrapper — extract the scalar base\n return scalarVariant!;\n }\n\n if (!hasScalar && hasArray && arrayVariant) {\n // All variants are arrays — extract items from the first array variant\n return (arrayVariant as Record<string, unknown>).items as PropertySchema;\n }\n\n // Not a flexible wrapper — preserve the union as-is\n return schema;\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<Input> = IteratorTaskConfig<Input>,\n> extends GraphAsTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"IteratorTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Iterator\";\n public static override description: string = \"Base class for loop-type tasks\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static override hasDynamicSchemas: boolean = true;\n\n public static override configSchema(): DataPortSchema {\n return iteratorTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n if ((config as Partial<IteratorTaskConfig<Input>>).maxIterations === undefined) {\n throw new TaskConfigurationError(\n `${(new.target as typeof IteratorTask).type ?? \"IteratorTask\"}: maxIterations is required. ` +\n `Pass a positive integer to cap iteration, or \"unbounded\" to opt out explicitly.`\n );\n }\n super(config, runConfig);\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 // ========================================================================\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 override 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 override inputSchema(): DataPortSchema {\n if (this.hasChildren()) {\n return this.getIterationInputSchema();\n }\n return (this.constructor as typeof IteratorTask).inputSchema();\n }\n\n public override 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",
38
47
  "/**\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<Input, Output> = WhileTaskConfig<Input, 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",
39
- "/**\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, IRunConfig } from \"./ITask\";\nimport { resolveIterationBound, type IterationBound } from \"./IteratorTask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError, TaskFailedError } 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: {\n oneOf: [{ type: \"integer\", minimum: 1 }, { type: \"string\", const: \"unbounded\" }],\n },\n chainIterations: { type: \"boolean\" },\n conditionField: { type: \"string\" },\n conditionOperator: { type: \"string\" },\n conditionValue: { type: \"string\" },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n required: [\"maxIterations\"],\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for WhileTask.\n */\nexport type WhileTaskConfig<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n> = GraphAsTaskConfig<Input> & {\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 * Upper bound on the number of iterations. Required — pass `\"unbounded\"` to\n * explicitly opt out of the safety ceiling, or a positive integer to cap.\n * Prevents infinite loops when the condition function can't disqualify\n * unbounded runaway input.\n */\n readonly maxIterations: IterationBound;\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<Input, Output> = WhileTaskConfig<Input, Output>,\n> extends GraphAsTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"WhileTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"While Loop\";\n public static override description: string = \"Loops until a condition function returns false\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static override hasDynamicSchemas: boolean = true;\n\n public static override configSchema(): DataPortSchema {\n return whileTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n if ((config as Partial<WhileTaskConfig<Input, Output>>).maxIterations === undefined) {\n throw new TaskConfigurationError(\n `${(new.target as typeof WhileTask).type ?? \"WhileTask\"}: maxIterations is required. ` +\n `Pass a positive integer to cap iteration, or \"unbounded\" to opt out explicitly.`\n );\n }\n super(config, runConfig);\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 public override canSerializeConfig(): boolean {\n return typeof this.config.condition !== \"function\";\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, resolved to a numeric cap. The raw\n * `config.maxIterations` accepts `\"unbounded\"` as an explicit opt-out — that\n * sentinel resolves to `Number.POSITIVE_INFINITY` here so the loop logic can\n * compare against it directly.\n */\n public get maxIterations(): number {\n return resolveIterationBound(this.config.maxIterations);\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 override async execute(\n input: Input,\n context: IExecuteContext\n ): 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 /**\n * Blend the inner subgraph's aggregate `graph_progress` with the outer iteration\n * count so nested streaming tasks visibly advance the progress bar between iteration\n * boundaries. See {@link IteratorTaskRunner.executeSubgraphIteration} for the\n * equivalent pattern in `MapTask`. Capped at 99 because the loop may exit early\n * (condition can return false before hitting `effectiveMax`), mirroring the\n * boundary emit below.\n */\n const onInnerGraphProgress = (innerProgress: number, innerMessage?: string): void => {\n const blended = Math.min(\n Math.round(((this._currentIteration + innerProgress / 100) / effectiveMax) * 100),\n 99\n );\n const message = innerMessage\n ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}`\n : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;\n void context.updateProgress(blended, message);\n };\n const unsubscribeInnerProgress = this.subGraph.subscribe(\n \"graph_progress\",\n onInnerGraphProgress\n );\n\n try {\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 — wrap in try/catch so a throwing condition doesn't\n // leave the task in an inconsistent state without progress cleanup.\n let shouldContinue: boolean;\n try {\n shouldContinue = condition(currentOutput, this._currentIteration);\n } catch (err) {\n // Rethrow TaskFailedError instances unchanged so their type, message,\n // and stack are preserved for the caller.\n if (err instanceof TaskFailedError) {\n throw err;\n }\n const message = `${this.type}: Condition function threw at iteration ${this._currentIteration}: ${\n err instanceof Error ? err.message : String(err)\n }`;\n const wrappedError = new TaskFailedError(message);\n if (err instanceof Error && err.stack) {\n if (wrappedError.stack) {\n wrappedError.stack += `\\nCaused by original error:\\n${err.stack}`;\n } else {\n wrappedError.stack = err.stack;\n }\n }\n throw wrappedError;\n }\n if (!shouldContinue) {\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 // Boundary emit — coarse signal that iteration N/effectiveMax completed. Capped\n // at 99 since the loop may exit early; the task runner will emit 100 on completion.\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 } finally {\n unsubscribeInnerProgress();\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 public override async *executeStream(\n input: Input,\n context: IExecuteContext\n ): 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 // Blend inner subgraph progress with outer iteration count; see execute() above.\n const onInnerGraphProgress = (innerProgress: number, innerMessage?: string): void => {\n const blended = Math.min(\n Math.round(((this._currentIteration + innerProgress / 100) / effectiveMax) * 100),\n 99\n );\n const message = innerMessage\n ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}`\n : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;\n void context.updateProgress(blended, message);\n };\n const unsubscribeInnerProgress = this.subGraph.subscribe(\n \"graph_progress\",\n onInnerGraphProgress\n );\n\n try {\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 let shouldContinue: boolean;\n try {\n shouldContinue = condition(currentOutput, this._currentIteration);\n } catch (err) {\n throw new TaskFailedError(\n `${this.type}: Condition function threw at iteration ${this._currentIteration}: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n if (!shouldContinue) {\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 } finally {\n unsubscribeInnerProgress();\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 override 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 override 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<TaskInput, 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);\nWorkflow.prototype.endWhile = CreateEndLoopWorkflow(\"endWhile\");\n",
48
+ "/**\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, IRunConfig } from \"./ITask\";\nimport { resolveIterationBound, type IterationBound } from \"./IteratorTask\";\nimport type { StreamEvent, StreamFinish } from \"./StreamTypes\";\nimport { TaskConfigurationError, TaskFailedError } 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: {\n oneOf: [\n { type: \"integer\", minimum: 1 },\n { type: \"string\", const: \"unbounded\" },\n ],\n },\n chainIterations: { type: \"boolean\" },\n conditionField: { type: \"string\" },\n conditionOperator: { type: \"string\" },\n conditionValue: { type: \"string\" },\n iterationInputConfig: { type: \"object\", additionalProperties: true },\n },\n required: [\"maxIterations\"],\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for WhileTask.\n */\nexport type WhileTaskConfig<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n> = GraphAsTaskConfig<Input> & {\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 * Upper bound on the number of iterations. Required — pass `\"unbounded\"` to\n * explicitly opt out of the safety ceiling, or a positive integer to cap.\n * Prevents infinite loops when the condition function can't disqualify\n * unbounded runaway input.\n */\n readonly maxIterations: IterationBound;\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<Input, Output> = WhileTaskConfig<Input, Output>,\n> extends GraphAsTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"WhileTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"While Loop\";\n public static override description: string = \"Loops until a condition function returns false\";\n\n /** This task has dynamic schemas based on the inner workflow */\n public static override hasDynamicSchemas: boolean = true;\n\n public static override configSchema(): DataPortSchema {\n return whileTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n if ((config as Partial<WhileTaskConfig<Input, Output>>).maxIterations === undefined) {\n throw new TaskConfigurationError(\n `${(new.target as typeof WhileTask).type ?? \"WhileTask\"}: maxIterations is required. ` +\n `Pass a positive integer to cap iteration, or \"unbounded\" to opt out explicitly.`\n );\n }\n super(config, runConfig);\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 public override canSerializeConfig(): boolean {\n return typeof this.config.condition !== \"function\";\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, resolved to a numeric cap. The raw\n * `config.maxIterations` accepts `\"unbounded\"` as an explicit opt-out — that\n * sentinel resolves to `Number.POSITIVE_INFINITY` here so the loop logic can\n * compare against it directly.\n */\n public get maxIterations(): number {\n return resolveIterationBound(this.config.maxIterations);\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 override async execute(\n input: Input,\n context: IExecuteContext\n ): 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 /**\n * Blend the inner subgraph's aggregate `graph_progress` with the outer iteration\n * count so nested streaming tasks visibly advance the progress bar between iteration\n * boundaries. See {@link IteratorTaskRunner.executeSubgraphIteration} for the\n * equivalent pattern in `MapTask`. Capped at 99 because the loop may exit early\n * (condition can return false before hitting `effectiveMax`), mirroring the\n * boundary emit below.\n */\n const onInnerGraphProgress = (innerProgress: number, innerMessage?: string): void => {\n const blended = Math.min(\n Math.round(((this._currentIteration + innerProgress / 100) / effectiveMax) * 100),\n 99\n );\n const message = innerMessage\n ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}`\n : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;\n void context.updateProgress(blended, message);\n };\n const unsubscribeInnerProgress = this.subGraph.subscribe(\n \"graph_progress\",\n onInnerGraphProgress\n );\n\n try {\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 — wrap in try/catch so a throwing condition doesn't\n // leave the task in an inconsistent state without progress cleanup.\n let shouldContinue: boolean;\n try {\n shouldContinue = condition(currentOutput, this._currentIteration);\n } catch (err) {\n // Rethrow TaskFailedError instances unchanged so their type, message,\n // and stack are preserved for the caller.\n if (err instanceof TaskFailedError) {\n throw err;\n }\n const message = `${this.type}: Condition function threw at iteration ${this._currentIteration}: ${\n err instanceof Error ? err.message : String(err)\n }`;\n const wrappedError = new TaskFailedError(message);\n if (err instanceof Error && err.stack) {\n if (wrappedError.stack) {\n wrappedError.stack += `\\nCaused by original error:\\n${err.stack}`;\n } else {\n wrappedError.stack = err.stack;\n }\n }\n throw wrappedError;\n }\n if (!shouldContinue) {\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 // Boundary emit — coarse signal that iteration N/effectiveMax completed. Capped\n // at 99 since the loop may exit early; the task runner will emit 100 on completion.\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 } finally {\n unsubscribeInnerProgress();\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 public override async *executeStream(\n input: Input,\n context: IExecuteContext\n ): 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 // Blend inner subgraph progress with outer iteration count; see execute() above.\n const onInnerGraphProgress = (innerProgress: number, innerMessage?: string): void => {\n const blended = Math.min(\n Math.round(((this._currentIteration + innerProgress / 100) / effectiveMax) * 100),\n 99\n );\n const message = innerMessage\n ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}`\n : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;\n void context.updateProgress(blended, message);\n };\n const unsubscribeInnerProgress = this.subGraph.subscribe(\n \"graph_progress\",\n onInnerGraphProgress\n );\n\n try {\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 let shouldContinue: boolean;\n try {\n shouldContinue = condition(currentOutput, this._currentIteration);\n } catch (err) {\n throw new TaskFailedError(\n `${this.type}: Condition function threw at iteration ${this._currentIteration}: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n if (!shouldContinue) {\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 } finally {\n unsubscribeInnerProgress();\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 override 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 override 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<TaskInput, 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);\nWorkflow.prototype.endWhile = CreateEndLoopWorkflow(\"endWhile\");\n",
40
49
  "/**\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} from \"./IteratorTask\";\nimport type { ExecutionMode, IterationInputMode, IterationPropertyConfig } 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",
41
50
  "/**\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 { RegisteredQueue } from \"./TaskQueueRegistry\";\nimport type { TaskConfig, 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?: TaskConfig;\n readonly task?: unknown;\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",
42
51
  "/**\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 type { IRunConfig } from \"./ITask\";\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 discardResults: { type: \"boolean\" },\n },\n required: iteratorTaskConfigSchema.required,\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for MapTask.\n */\nexport type MapTaskConfig<Input extends TaskInput = TaskInput> = IteratorTaskConfig<Input> & {\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 * When true, iteration results are discarded rather than collected into\n * per-property arrays. Used by the `.forEach()` workflow combinator for\n * side-effect-only loops where the caller does not need the return value.\n * @default false\n */\n readonly discardResults?: 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<Input> = MapTaskConfig<Input>,\n> extends IteratorTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"MapTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Map\";\n public static override description: string =\n \"Transforms array inputs by running a workflow per item\";\n\n public static override configSchema(): DataPortSchema {\n return mapTaskConfigSchema;\n }\n\n /**\n * MapTask always uses PROPERTY_ARRAY merge strategy to collect results.\n */\n public static override readonly compoundMerge = PROPERTY_ARRAY;\n\n /**\n * Static input schema for MapTask.\n */\n public static override 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 override 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 /**\n * Whether to drop iteration outputs rather than collect them. Used by\n * `.forEach()` for side-effect iteration.\n */\n public get discardResults(): boolean {\n return this.config.discardResults ?? 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. When\n * `discardResults` is set (via `.forEach()`), returns the empty result\n * without touching the per-iteration outputs.\n */\n public override collectResults(results: TaskOutput[]): Output {\n if (this.discardResults) {\n return this.getEmptyResult();\n }\n\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 * ForEachTask is a `MapTask` variant that discards iteration results by default.\n * Used via the `.forEach()` workflow combinator for side-effect-only loops.\n */\nexport class ForEachTask<\n Input extends TaskInput = TaskInput,\n Output extends TaskOutput = TaskOutput,\n Config extends MapTaskConfig<Input> = MapTaskConfig<Input>,\n> extends MapTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"ForEachTask\";\n public static override title: string = \"For Each\";\n public static override description: string =\n \"Runs a workflow per array item for side effects; discards collected results\";\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n super({ discardResults: true, ...config } as Partial<Config>, runConfig);\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<TaskInput>>;\n\n /**\n * Ends the map loop and returns to the parent workflow.\n */\n endMap(): Workflow;\n\n /**\n * Starts a forEach loop — iterates array input ports for side effects and\n * discards collected results. Use .endForEach() to close the loop and\n * return to the parent workflow. `maxIterations` is still required.\n */\n forEach: CreateLoopWorkflow<TaskInput, TaskOutput, MapTaskConfig<TaskInput>>;\n\n /**\n * Ends the forEach loop and returns to the parent workflow.\n */\n endForEach(): Workflow;\n }\n}\n\nWorkflow.prototype.map = CreateLoopWorkflow(MapTask);\nWorkflow.prototype.endMap = CreateEndLoopWorkflow(\"endMap\");\nWorkflow.prototype.forEach = CreateLoopWorkflow(ForEachTask);\nWorkflow.prototype.endForEach = CreateEndLoopWorkflow(\"endForEach\");\n",
43
- "/**\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 type { IRunConfig } from \"./ITask\";\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<\n Input extends TaskInput = TaskInput,\n Accumulator = unknown,\n> = IteratorTaskConfig<Input> & {\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<Input, Output> = ReduceTaskConfig<Input, Output>,\n> extends IteratorTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"ReduceTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Reduce\";\n public static override description: string =\n \"Processes iterated inputs sequentially with an accumulator (fold)\";\n\n public static override configSchema(): DataPortSchema {\n return reduceTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n // Reduce is always sequential\n const reduceConfig = {\n ...config,\n concurrencyLimit: 1,\n batchSize: 1,\n };\n super(reduceConfig as Partial<Config>, runConfig);\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 override 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 override 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<TaskInput, 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",
52
+ "/**\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 type { IRunConfig } from \"./ITask\";\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 required: iteratorTaskConfigSchema.required,\n additionalProperties: false,\n} as const satisfies DataPortSchema;\n\n/**\n * Configuration for ReduceTask.\n */\nexport type ReduceTaskConfig<\n Input extends TaskInput = TaskInput,\n Accumulator = unknown,\n> = IteratorTaskConfig<Input> & {\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<Input, Output> = ReduceTaskConfig<Input, Output>,\n> extends IteratorTask<Input, Output, Config> {\n public static override type: TaskTypeName = \"ReduceTask\";\n public static override category: string = \"Flow Control\";\n public static override title: string = \"Reduce\";\n public static override description: string =\n \"Processes iterated inputs sequentially with an accumulator (fold)\";\n\n public static override configSchema(): DataPortSchema {\n return reduceTaskConfigSchema;\n }\n\n constructor(config: Partial<Config> = {}, runConfig: Partial<IRunConfig> = {}) {\n // Reduce is always sequential\n const reduceConfig = {\n ...config,\n concurrencyLimit: 1,\n batchSize: 1,\n };\n super(reduceConfig as Partial<Config>, runConfig);\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 override 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 override 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<TaskInput, 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",
44
53
  "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n createServiceToken,\n getLogger,\n globalServiceRegistry,\n registerInputCompactor,\n registerInputResolver,\n ServiceRegistry,\n} from \"@workglow/util\";\nimport { validateSchema } from \"@workglow/util/schema\";\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 * Re-registering the exact same class is idempotent and does nothing.\n *\n * @param baseClass - The constructor function for the task to register\n * @throws Error if a different constructor is already registered for the same task type.\n * Call {@link unregisterTask} first to replace an existing registration.\n */\nfunction registerTask(baseClass: AnyTaskConstructor): void {\n const existing = taskConstructors.get(baseClass.type);\n if (existing) {\n if (existing === baseClass) return; // same class, idempotent\n throw new Error(\n `Task type \"${baseClass.type}\" is already registered. Unregister it first to replace.`\n );\n }\n taskConstructors.set(baseClass.type, baseClass);\n\n // Validate schemas at registration time (soft — warn only, don't throw)\n const schemas = [\n { name: \"inputSchema\", schema: baseClass.inputSchema() },\n { name: \"outputSchema\", schema: baseClass.outputSchema() },\n ] as const;\n\n for (const { name, schema } of schemas) {\n const result = validateSchema(schema);\n if (!result.valid) {\n const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join(\"; \");\n getLogger().warn(`Task \"${baseClass.type}\" has invalid ${name}: ${messages}`, {\n taskType: baseClass.type,\n schemaName: name,\n errors: result.errors,\n });\n }\n }\n}\n\n/**\n * Removes a task constructor from the registry.\n * Must be called before re-registering a task type with a different constructor.\n *\n * @param type - The task type identifier to remove\n * @returns true if the task type was found and removed, false otherwise\n */\nfunction unregisterTask(type: string): boolean {\n return taskConstructors.delete(type);\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 * Function to remove a registered task type\n */\n unregisterTask,\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\nglobalServiceRegistry.registerIfAbsent(\n TASK_CONSTRUCTORS,\n (): Map<string, AnyTaskConstructor> => TaskRegistry.all,\n true\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 | {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema: unknown;\n configSchema?: unknown;\n }\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\n// Register the tasks compactor — extracts name from a resolved task definition\nregisterInputCompactor(\"tasks\", (value, _format, registry) => {\n if (typeof value === \"object\" && value !== null && \"name\" in value) {\n const name = (value as Record<string, unknown>).name;\n if (typeof name !== \"string\") return undefined;\n const constructors = getTaskConstructors(registry);\n const ctor = constructors.get(name);\n return ctor ? name : undefined;\n }\n return undefined;\n});\n",
45
- "/**\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 type { TaskEntitlements } from \"../task/TaskEntitlements\";\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 { 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 \"id\" | \"defaults\" | \"maxIterations\"\n> & {\n /**\n * Optional in the JSON union because non-loop tasks don't carry it —\n * each loop task class still enforces required-at-construction via its\n * own config type.\n */\n readonly maxIterations?: WhileTaskConfig[\"maxIterations\"];\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 * Entitlements required by this task.\n * @output-only This field is populated during serialization (toJSON/toDependencyJSON)\n * and is ignored during deserialization. User-supplied entitlements in JSON input\n * are not applied to the reconstructed task.\n */\n entitlements?: TaskEntitlements;\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 * Entitlements required by this task.\n * @output-only This field is populated during serialization and is ignored during deserialization.\n */\n entitlements?: TaskEntitlements;\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\n/**\n * Options for deserializing tasks from JSON.\n */\nexport interface TaskDeserializationOptions {\n /**\n * Optional allowlist of task type names. When provided, only task types\n * in this set will be instantiated. Any other type throws TaskJSONError.\n * Use this to restrict which tasks can be created from untrusted JSON.\n */\n readonly allowedTypes?: ReadonlySet<string> | readonly string[];\n}\n\nconst createSingleTaskFromJSON = (\n item: JsonTaskItem | TaskGraphItemJson,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\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 // Check allowlist if provided\n if (options?.allowedTypes) {\n const allowed =\n options.allowedTypes instanceof Set ? options.allowedTypes : new Set(options.allowedTypes);\n if (!allowed.has(item.type)) {\n throw new TaskJSONError(`Task type \"${item.type}\" is not in the allowed types list`);\n }\n }\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 // Validate that the resolved value is actually a constructable task class\n if (typeof taskClass !== \"function\" || typeof taskClass.type !== \"string\") {\n throw new TaskJSONError(`Task type ${item.type} resolved to an invalid constructor`);\n }\n\n const taskConfig: TaskConfig = {\n ...item.config,\n id: item.id,\n defaults: item.defaults ?? {},\n };\n const task = new taskClass(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 = (\n item: JsonTaskItem,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\n) => {\n const task = createSingleTaskFromJSON(item, registry, options);\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, options);\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 options?: TaskDeserializationOptions\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of jsonItems) {\n subGraph.addTask(createTaskFromDependencyJSON(subitem, registry, options));\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 = (\n item: TaskGraphItemJson,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\n) => {\n const task = createSingleTaskFromJSON(item, registry, options);\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, options);\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 options?: TaskDeserializationOptions\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of graphJsonObj.tasks) {\n subGraph.addTask(createTaskFromGraphJSON(subitem, registry, options));\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",
54
+ "/**\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 type { ITransformStep } from \"../task-graph/TransformTypes\";\nimport type { TaskEntitlements } from \"../task/TaskEntitlements\";\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 { 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 \"id\" | \"defaults\" | \"maxIterations\"\n> & {\n /**\n * Optional in the JSON union because non-loop tasks don't carry it —\n * each loop task class still enforces required-at-construction via its\n * own config type.\n */\n readonly maxIterations?: WhileTaskConfig[\"maxIterations\"];\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 * Entitlements required by this task.\n * @output-only This field is populated during serialization (toJSON/toDependencyJSON)\n * and is ignored during deserialization. User-supplied entitlements in JSON input\n * are not applied to the reconstructed task.\n */\n entitlements?: TaskEntitlements;\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 * Entitlements required by this task.\n * @output-only This field is populated during serialization and is ignored during deserialization.\n */\n entitlements?: TaskEntitlements;\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 transforms?: ReadonlyArray<ITransformStep>;\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\n/**\n * Options for deserializing tasks from JSON.\n */\nexport interface TaskDeserializationOptions {\n /**\n * Optional allowlist of task type names. When provided, only task types\n * in this set will be instantiated. Any other type throws TaskJSONError.\n * Use this to restrict which tasks can be created from untrusted JSON.\n */\n readonly allowedTypes?: ReadonlySet<string> | readonly string[];\n}\n\nconst createSingleTaskFromJSON = (\n item: JsonTaskItem | TaskGraphItemJson,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\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 // Check allowlist if provided\n if (options?.allowedTypes) {\n const allowed =\n options.allowedTypes instanceof Set ? options.allowedTypes : new Set(options.allowedTypes);\n if (!allowed.has(item.type)) {\n throw new TaskJSONError(`Task type \"${item.type}\" is not in the allowed types list`);\n }\n }\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 // Validate that the resolved value is actually a constructable task class\n if (typeof taskClass !== \"function\" || typeof taskClass.type !== \"string\") {\n throw new TaskJSONError(`Task type ${item.type} resolved to an invalid constructor`);\n }\n\n const taskConfig: TaskConfig = {\n ...item.config,\n id: item.id,\n defaults: item.defaults ?? {},\n };\n const task = new taskClass(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 = (\n item: JsonTaskItem,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\n) => {\n const task = createSingleTaskFromJSON(item, registry, options);\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, options);\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 options?: TaskDeserializationOptions\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of jsonItems) {\n subGraph.addTask(createTaskFromDependencyJSON(subitem, registry, options));\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 = (\n item: TaskGraphItemJson,\n registry?: ServiceRegistry,\n options?: TaskDeserializationOptions\n) => {\n const task = createSingleTaskFromJSON(item, registry, options);\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, options);\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 options?: TaskDeserializationOptions\n) => {\n const subGraph = new TaskGraph();\n for (const subitem of graphJsonObj.tasks) {\n subGraph.addTask(createTaskFromGraphJSON(subitem, registry, options));\n }\n for (const subitem of graphJsonObj.dataflows) {\n const dataflow = new Dataflow(\n subitem.sourceTaskId,\n subitem.sourceTaskPortId,\n subitem.targetTaskId,\n subitem.targetTaskPortId\n );\n if (subitem.transforms && subitem.transforms.length > 0) {\n dataflow.setTransforms(subitem.transforms);\n }\n subGraph.addDataflow(dataflow);\n }\n return subGraph;\n};\n",
46
55
  "/**\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\";\nimport { EventEmitter } from \"@workglow/util\";\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 type TaskQueueRegistryEvents = {\n queue_registered: (queueName: string) => void;\n};\n\nexport class TaskQueueRegistry {\n /**\n * Emits when queues are registered ({@link TaskQueueRegistryEvents}).\n */\n public readonly emitter = new EventEmitter<TaskQueueRegistryEvents>();\n\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 this.emitter.emit(\"queue_registered\", queueName);\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",
47
56
  "/**\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 \"./EntitlementEnforcer\";\nexport * from \"./EntitlementPolicy\";\nexport * from \"./EntitlementProfiles\";\nexport * from \"./EntitlementResolver\";\nexport * from \"./FallbackTask\";\nexport * from \"./FallbackTaskRunner\";\nexport * from \"./GraphAsTask\";\nexport * from \"./GraphAsTaskRunner\";\nexport * from \"./InputCompactor\";\nexport * from \"./InputResolver\";\nexport * from \"./ITask\";\nexport * from \"./iterationSchema\";\nexport * from \"./IteratorTask\";\nexport * from \"./IteratorTaskRunner\";\nexport * from \"./JobQueueFactory\";\nexport * from \"./MapTask\";\nexport * from \"./ReduceTask\";\nexport * from \"./StreamTypes\";\nexport * from \"./Task\";\nexport * from \"./TaskEntitlements\";\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",
48
57
  "/**\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",
@@ -50,7 +59,7 @@
50
59
  "/**\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",
51
60
  "/**\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 type { DataPortSchema } from \"@workglow/util/schema\";\nimport { Dataflow } from \"../../task-graph/Dataflow\";\nimport { TaskGraph } from \"../../task-graph/TaskGraph\";\nimport { Workflow } from \"../../task-graph/Workflow\";\nimport { Task } from \"../../task/Task\";\nimport { TaskStatus } from \"../../task/TaskTypes\";\n\ntype Config = Record<string, unknown>;\n\n/**\n * Formats a duration in milliseconds as a human-readable string.\n */\nfunction formatDuration(ms: number): string {\n if (ms < 1) return `${(ms * 1000).toFixed(0)}\\u00B5s`;\n if (ms < 1000) return `${ms.toFixed(1)}ms`;\n return `${(ms / 1000).toFixed(2)}s`;\n}\n\n/**\n * Extracts property keys from a JSON schema, handling boolean schemas.\n * Boolean schemas: true = accepts any, false = rejects all\n */\nfunction getSchemaProperties(schema: DataPortSchema): Record<string, DataPortSchema> | null {\n if (typeof schema === \"boolean\") {\n // Boolean schemas don't have properties\n // true = accepts any value, false = rejects all values\n return null;\n }\n return schema.properties as Record<string, DataPortSchema> | null;\n}\n\ntype JsonMLTagName = string;\n\ninterface JsonMLAttributes {\n readonly [key: string]: unknown;\n}\n\ntype JsonMLNode = JsonMLText | JsonMLElementDef;\n\ntype JsonMLText = string;\n\ntype JsonMLElementDef = [JsonMLTagName, JsonMLAttributes?, ...JsonMLNode[]];\n\nabstract class ConsoleFormatter {\n abstract header(value: unknown, config?: Config): JsonMLElementDef | null;\n abstract hasBody(value: unknown, config?: Config): boolean;\n abstract body(value: unknown, config?: Config): JsonMLElementDef | null;\n}\n\n/**\n * Returns whether the browser is in dark mode\n */\nexport function isDarkMode(): boolean {\n return window.matchMedia && window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n}\n\nclass WorkflowConsoleFormatter extends ConsoleFormatter {\n header(workflow: Workflow | TaskGraph, config?: Config): JsonMLElementDef | null {\n // @ts-ignore\n if (workflow instanceof Workflow || workflow instanceof TaskGraph) {\n const graph: TaskGraph = workflow instanceof TaskGraph ? workflow : workflow.graph;\n const error = workflow instanceof Workflow ? workflow.error : \"\";\n const title = workflow instanceof Workflow ? \"Workflow\" : \"TaskGraph\";\n const header = new JsonMLElement(\"div\");\n header.sectionHeader(title);\n header.styledText(`(${graph.getTasks().length} tasks)`, \"color: green; margin-left: 10px;\");\n if (error) {\n header.styledText(error, \"color: red; margin-left: 10px;\");\n }\n\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return true;\n }\n\n body(obj: unknown, config?: Config): JsonMLElementDef {\n const body = new JsonMLElement(\"div\");\n const graph: TaskGraph = obj instanceof TaskGraph ? obj : (obj as Workflow).graph;\n const nodes = body.createStyledList();\n const tasks = graph.getTasks();\n if (tasks.length) {\n nodes.createTextChild(\"Tasks:\");\n for (const node of tasks) {\n const nodeTag = nodes.createListItem(\"\", \"list-style-type: none;\");\n if (obj instanceof Workflow) {\n for (const df of graph.getSourceDataflows(node.config.id)) {\n const edgeTag = nodeTag.createChild(\"li\").setStyle(\"padding-left: 20px;\");\n if (df.sourceTaskPortId === df.targetTaskPortId) continue;\n const num =\n tasks.findIndex((t) => t.config.id === df.sourceTaskId) -\n tasks.findIndex((t) => t.config.id === node.config.id);\n\n edgeTag.highlightText(\"rename\");\n edgeTag.functionCall((el) => {\n el.greyText('\"');\n el.outputText(`${df.sourceTaskPortId}`);\n el.greyText('\", \"');\n el.inputText(`${df.targetTaskPortId}`);\n el.greyText('\"');\n if (num !== -1) el.greyText(`, ${num}`);\n });\n }\n }\n nodeTag.createObjectTag(node, { graph, workflow: obj });\n }\n }\n if (obj instanceof TaskGraph) {\n const dfList = nodes.createTextChild(\"Dataflows:\");\n for (const df of obj.getDataflows()) {\n const dfTag = dfList.createListItem(\"\", \"list-style-type: none;\");\n dfTag.createObjectTag(df);\n }\n }\n\n // Show total duration computed from earliest startedAt to latest completedAt\n let earliestStart: Date | undefined;\n let latestEnd: Date | undefined;\n for (const t of tasks) {\n if (t.startedAt && (!earliestStart || t.startedAt < earliestStart)) {\n earliestStart = t.startedAt;\n }\n if (t.completedAt && (!latestEnd || t.completedAt > latestEnd)) {\n latestEnd = t.completedAt;\n }\n }\n if (earliestStart && latestEnd) {\n const durationMs = latestEnd.getTime() - earliestStart.getTime();\n const timing = nodes.createListItem(\"\", \"list-style-type: none;\");\n timing.highlightText(\"Total duration: \");\n timing.createTextChild(formatDuration(durationMs));\n }\n\n // @ts-ignore\n const dag = obj._dag ?? obj.graph._dag;\n\n if (dag && dag.getNodes().length > 0) body.createObjectTag(dag);\n\n return body.toJsonML();\n }\n}\n\nclass WorkflowAPIConsoleFormatter extends ConsoleFormatter {\n header(obj: unknown, config?: Config): JsonMLElementDef | null {\n if (obj === Workflow.prototype || obj === Workflow) {\n const header = new JsonMLElement(\"div\");\n header.sectionHeader(\"Workflow API\");\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return true;\n }\n\n body(): JsonMLElementDef {\n const body = new JsonMLElement(\"div\");\n const apiSection = body.createChild(\"div\");\n const apiList = apiSection.createStyledList();\n const apiTag = apiList.createListItem(\"\", \"list-style-type: none;\");\n apiTag.createHighlightedListItem(\".reset()\");\n apiTag.createHighlightedListItem(\".rename(outputName, inputName)\");\n apiTag.createHighlightedListItem(\".run()\");\n apiTag.createHighlightedListItem(\".abort()\");\n apiTag.createHighlightedListItem(\".toJSON()\");\n apiTag.createHighlightedListItem(\".toDependencyJSON()\");\n\n for (const [key, value] of Object.entries(Workflow.prototype)) {\n if (typeof value === \"function\" && key !== \"constructor\") {\n const item = apiTag.createListItem(\"\");\n item.createChild(\"span\").createObjectTag(value);\n }\n }\n\n return body.toJsonML();\n }\n}\n\ninterface WorkflowCreateObject {\n readonly workflowCreate: boolean;\n readonly constructor: { readonly runtype?: string; readonly type?: string };\n readonly type: string;\n inputSchema(): DataPortSchema;\n outputSchema(): DataPortSchema;\n}\n\nclass CreateWorkflowConsoleFormatter extends ConsoleFormatter {\n header(obj: unknown, config?: Config): JsonMLElementDef | null {\n const workflowObj = obj as WorkflowCreateObject;\n if (workflowObj.workflowCreate) {\n const header = new JsonMLElement(\"div\");\n const name =\n workflowObj.constructor.runtype ??\n workflowObj.constructor.type ??\n workflowObj.type.replace(/Task$/, \"\");\n const inputSchema = workflowObj.inputSchema();\n const outputSchema = workflowObj.outputSchema();\n const inputProperties = getSchemaProperties(inputSchema);\n const outputProperties = getSchemaProperties(outputSchema);\n\n const inputs = inputProperties\n ? Object.keys(inputProperties).map((key) => `${key}: …`)\n : typeof inputSchema === \"boolean\"\n ? inputSchema\n ? [\"…\"] // true = accepts any\n : [\"never\"] // false = rejects all\n : [];\n\n const outputs = outputProperties\n ? Object.keys(outputProperties).map((key) => `${key}: …`)\n : typeof outputSchema === \"boolean\"\n ? outputSchema\n ? [\"…\"] // true = accepts any\n : [\"never\"] // false = rejects all\n : [];\n\n header.methodSignature(name);\n header.functionCall((el) => {\n el.objectBraces((innerObj) => {\n innerObj.inputText(`${inputs.join(\", \")}`);\n });\n });\n header.greyText(\"): \");\n header.objectBraces((el) => {\n el.outputText(`${outputs.join(\", \")}`);\n });\n\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return false;\n }\n\n body(obj: unknown, config?: Config): JsonMLElementDef | null {\n return null;\n }\n}\n\nclass TaskConsoleFormatter extends ConsoleFormatter {\n header(task: Task, config?: Config): JsonMLElementDef | null {\n if (!task) return null;\n\n if (\n task instanceof Task &&\n task.inputSchema &&\n task.outputSchema &&\n task.runInputData &&\n task.runOutputData\n ) {\n const header = new JsonMLElement(\"div\");\n let name = task.type ?? task.constructor.name;\n if ((config as { workflow?: unknown })?.workflow) name = name.replace(/Task$/, \"\");\n const inputSchema = task.inputSchema();\n const outputSchema = task.outputSchema();\n const inputProperties = getSchemaProperties(inputSchema);\n const outputProperties = getSchemaProperties(outputSchema);\n\n const inputs = inputProperties\n ? Object.keys(inputProperties)\n .filter((key) => task.runInputData[key] !== undefined)\n .map((key) => {\n const value = task.runInputData[key];\n return { name: key, value };\n })\n : typeof inputSchema === \"boolean\" && inputSchema\n ? Object.keys(task.runInputData || {})\n .filter((key) => task.runInputData[key] !== undefined)\n .map((key) => {\n const value = task.runInputData[key];\n return { name: key, value };\n })\n : [];\n\n const outputs = outputProperties\n ? Object.keys(outputProperties)\n .filter(\n (key) => task.runOutputData[key] !== undefined && task.runOutputData[key] !== \"\"\n )\n .filter(\n (key) =>\n !(Array.isArray(task.runOutputData[key]) && task.runOutputData[key].length === 0)\n )\n .map((key) => {\n return { name: key, value: task.runOutputData[key] };\n })\n : typeof outputSchema === \"boolean\" && outputSchema\n ? Object.keys(task.runOutputData || {})\n .filter(\n (key) => task.runOutputData[key] !== undefined && task.runOutputData[key] !== \"\"\n )\n .filter(\n (key) =>\n !(Array.isArray(task.runOutputData[key]) && task.runOutputData[key].length === 0)\n )\n .map((key) => {\n return { name: key, value: task.runOutputData[key] };\n })\n : [];\n\n header.highlightText(name);\n header.functionCall((el) => {\n el.objectBraces((innerObj) => {\n innerObj.parameterList(inputs);\n });\n el.greyText(\", \");\n el.objectBraces((innerObj) => {\n innerObj.parameterList([{ name: \"id\", value: task.config.id }]);\n });\n });\n\n if (task.status === TaskStatus.COMPLETED) {\n header.greyText(\": \");\n header.objectBraces((el) => {\n el.parameterList(outputs, true);\n });\n }\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(task: unknown, config?: Config): boolean {\n return task instanceof Task;\n }\n\n body(task: Task, config?: Config): JsonMLElementDef | null {\n if (!task) return null;\n if (!(task instanceof Task)) return null;\n\n const body = new JsonMLElement(\"div\").setStyle(\"padding-left: 10px;\");\n\n const inputs = body.createStyledList(\"Inputs:\");\n const allInboundDataflows = (config as { graph?: TaskGraph })?.graph?.getSourceDataflows(\n task.config.id\n );\n\n const inputSchema = task.inputSchema();\n const inputProperties = getSchemaProperties(inputSchema);\n const schemaKeys =\n inputProperties !== null\n ? Object.keys(inputProperties)\n : inputSchema === true\n ? Object.keys(task.runInputData || {})\n : [];\n\n for (const key of schemaKeys) {\n const value = task.runInputData[key];\n const li = inputs.createListItem(\"\", \"padding-left: 20px;\");\n li.inputText(`${key}: `);\n const inputInboundDataflows = allInboundDataflows?.filter((e) => e.targetTaskPortId === key);\n if (inputInboundDataflows) {\n const sources: string[] = [];\n const sourceValues: unknown[] = [];\n inputInboundDataflows.forEach((df) => {\n const sourceTask = (config as { graph?: TaskGraph })?.graph?.getTask(df.sourceTaskId);\n sources.push(`${sourceTask?.type}->Output{${df.sourceTaskPortId}}`);\n if (df.status === TaskStatus.COMPLETED) {\n sourceValues.push(df.value);\n }\n });\n if (sources.length > 1) {\n if (sourceValues.length > 0) {\n li.createValueObject(sourceValues);\n li.createTextChild(\" \");\n }\n li.createTextChild(`from [${sources.join(\", \")}]`);\n } else if (sources.length === 1) {\n if (sourceValues.length > 0) {\n li.createValueObject(sourceValues[0]);\n li.createTextChild(\" \");\n }\n li.createTextChild(\"from \" + sources[0]);\n } else {\n li.createValueObject(value);\n }\n } else {\n li.createValueObject(value);\n }\n }\n\n const outputsList = body.createStyledList(\"Outputs:\");\n const outputSchema = task.outputSchema();\n const outputProperties = getSchemaProperties(outputSchema);\n const outputKeys =\n outputProperties !== null\n ? Object.keys(outputProperties)\n : outputSchema === true\n ? Object.keys(task.runOutputData || {})\n : [];\n\n for (const key of outputKeys) {\n const value = task.runOutputData[key];\n const li = outputsList.createListItem(\"\", \"padding-left: 20px;\");\n li.outputText(`${key}: `);\n li.createValueObject(value);\n }\n\n const taskConfig = body.createStyledList(\"Config:\");\n for (const [key, value] of Object.entries(task.config)) {\n if (value === undefined) continue;\n const li = taskConfig.createListItem(\"\", \"padding-left: 20px;\");\n li.inputText(`${key}: `);\n li.createValueObject(value);\n }\n\n body.createStatusListItem(task.status);\n\n if (task.startedAt || task.completedAt) {\n const timing = body.createStyledList(\"Timing:\");\n if (task.startedAt) {\n const li = timing.createListItem(\"\", \"padding-left: 20px;\");\n li.inputText(\"startedAt: \");\n li.createTextChild(task.startedAt.toISOString());\n }\n if (task.completedAt) {\n const li = timing.createListItem(\"\", \"padding-left: 20px;\");\n li.inputText(\"completedAt: \");\n li.createTextChild(task.completedAt.toISOString());\n }\n if (task.startedAt && task.completedAt) {\n const durationMs = task.completedAt.getTime() - task.startedAt.getTime();\n const li = timing.createListItem(\"\", \"padding-left: 20px;\");\n li.highlightText(\"duration: \");\n li.createTextChild(formatDuration(durationMs));\n }\n }\n\n // @ts-ignore\n const dag = task.subGraph?._dag;\n\n if (dag && dag.getNodes().length > 0) body.createObjectTag(dag);\n\n return body.toJsonML();\n }\n}\n\nclass DAGConsoleFormatter extends ConsoleFormatter {\n header(obj: unknown, config?: Config): JsonMLElementDef | null {\n if (obj instanceof DirectedAcyclicGraph) {\n const header = new JsonMLElement(\"div\");\n header.createTextChild(\"DAG\");\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return true;\n }\n\n body(obj: unknown, config?: Config): JsonMLElementDef {\n const body = new JsonMLElement(\"div\");\n body.createStyledList();\n const dag = obj as DirectedAcyclicGraph<NodeWithConfig, unknown, string, unknown>;\n if (dag.getNodes().length > 0) {\n const { dataURL, height } = generateGraphImage(dag);\n if (dataURL) {\n const imageTag = body.createChild(\"div\");\n imageTag.addAttribute(\n \"style\",\n `background-image: url(${dataURL}); background-size: cover; background-position: center; width: 800px; height: ${height}px;`\n );\n }\n }\n return body.toJsonML();\n }\n}\n\nclass DataflowConsoleFormatter extends ConsoleFormatter {\n header(obj: unknown, config?: Config): JsonMLElementDef | null {\n if (obj instanceof Dataflow) {\n const header = new JsonMLElement(\"div\");\n header.highlightText(\"Dataflow \");\n header.inputText(`${obj.sourceTaskId}.${obj.sourceTaskPortId}`);\n header.createTextChild(\" -> \");\n header.outputText(`${obj.targetTaskId}.${obj.targetTaskPortId}`);\n if (obj.status === TaskStatus.COMPLETED) {\n header.greyText(\" = \");\n header.createValueObject(obj.value);\n }\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return true;\n }\n\n body(obj: unknown, config?: Config): JsonMLElementDef | null {\n return null;\n }\n}\n\ninterface ReactElement {\n readonly $$typeof?: { toString(): string };\n readonly displayName?: string;\n readonly type?: {\n readonly $$typeof?: { toString(): string };\n readonly displayName?: string;\n readonly name?: string;\n readonly type?: {\n readonly displayName?: string;\n readonly name?: string;\n };\n };\n readonly key?: string;\n readonly props?: Record<string, unknown>;\n}\n\nclass ReactElementConsoleFormatter extends ConsoleFormatter {\n header(obj: unknown, config?: Config): JsonMLElementDef | null {\n const reactEl = obj as ReactElement;\n if (\n reactEl?.$$typeof?.toString() === \"Symbol(react.transitional.element)\" &&\n !(config as { parent?: unknown })?.parent\n ) {\n const header = new JsonMLElement(\"div\");\n const isMemo = reactEl.type?.$$typeof?.toString() === \"Symbol(react.memo)\";\n const name = !isMemo\n ? reactEl.displayName || reactEl.type?.displayName || reactEl.type?.name\n : reactEl.type?.type?.displayName || reactEl.type?.type?.name;\n header.greyText(`<`);\n header.sectionHeader(`${name}`);\n header.greyText(`/>`);\n if (reactEl.key) {\n header.createTextChild(\" \");\n header.inputText(`key={${reactEl.key}}`);\n }\n if (isMemo) {\n header.createTextChild(\" \");\n header.pill(`Memo`);\n }\n // header.createObjectTag(obj, { parent: obj });\n return header.toJsonML();\n }\n return null;\n }\n\n hasBody(value: unknown, config?: Config): boolean {\n return true;\n }\n\n body(obj: unknown, config?: Config): JsonMLElementDef {\n const body = new JsonMLElement(\"div\");\n const props = body.createStyledList(\"Props:\");\n const reactEl = obj as ReactElement;\n props.propertyBlock(reactEl.props ?? {});\n return body.toJsonML();\n }\n}\n\nclass JsonMLElement {\n _attributes: Record<string, unknown>;\n _jsonML: JsonMLElementDef;\n\n // Color constants\n static getColors(): {\n readonly grey: string;\n readonly inputColor: string;\n readonly outputColor: string;\n readonly yellow: string;\n readonly undefined: string;\n } {\n const dark = isDarkMode();\n return {\n grey: dark ? \"#aaa\" : \"#333\",\n inputColor: dark ? \"#ada\" : \"#363\",\n outputColor: dark ? \"#caa\" : \"#633\",\n yellow: dark ? \"#f3ce49\" : \"#a68307\",\n undefined: \"#888\",\n };\n }\n\n constructor(tagName: JsonMLTagName) {\n this._attributes = {};\n this._jsonML = [tagName, this._attributes];\n }\n\n // Add a helper method for creating colored text in one call\n coloredText(text: string, color: string): JsonMLElement {\n this.createChild(\"span\").setStyle(`color:${color};`).createTextChild(text);\n return this;\n }\n\n // Helper for creating styled text with any style\n styledText(text: string, style: string): JsonMLElement {\n this.createChild(\"span\").setStyle(style).createTextChild(text);\n return this;\n }\n\n // Helper specifically for input-colored text\n inputText(text: string): JsonMLElement {\n const colors = JsonMLElement.getColors();\n return this.coloredText(text, colors.inputColor);\n }\n\n // Helper specifically for output-colored text\n outputText(text: string): JsonMLElement {\n const colors = JsonMLElement.getColors();\n return this.coloredText(text, colors.outputColor);\n }\n\n // Helper for grey text which is commonly used\n greyText(text: string): JsonMLElement {\n const colors = JsonMLElement.getColors();\n return this.coloredText(text, colors.grey);\n }\n\n // Helper for yellow/highlight text\n highlightText(text: string): JsonMLElement {\n const colors = JsonMLElement.getColors();\n return this.coloredText(text, colors.yellow);\n }\n\n // Helper for creating a section header\n sectionHeader(text: string): JsonMLElement {\n return this.styledText(text, \"font-weight: bold;\");\n }\n\n pill(text: string): JsonMLElement {\n return this.styledText(\n text,\n \"color: #009; background-color: #ccf; padding: 2px 4px; border-radius: 4px; font-size: 0.7em;\"\n );\n }\n\n // Helper for creating a method signature\n methodSignature(name: string, params: string = \"\"): JsonMLElement {\n const colors = JsonMLElement.getColors();\n this.styledText(\".\" + name, `font-weight: bold;color:${colors.yellow}`);\n if (params) this.greyText(`(${params})`);\n return this;\n }\n\n // Helper for creating a parameter list with input/output coloring\n parameterList(\n params: ReadonlyArray<{ readonly name: string; readonly value: unknown }>,\n isOutput: boolean = false\n ): JsonMLElement {\n params.forEach((param, i) => {\n if (i > 0) this.greyText(`, `);\n if (isOutput) {\n this.outputText(param.name);\n } else {\n this.inputText(param.name);\n }\n this.greyText(`: `);\n this.createValueObject(param.value);\n });\n return this;\n }\n\n // Helper for creating a parameter list with coloring\n propertyBlock(params: Record<string, unknown>): JsonMLElement {\n for (const [key, value] of Object.entries(params)) {\n const item = this.createListItem(\"\");\n item.inputText(key);\n item.greyText(`: `);\n item.createValueObject(value);\n }\n return this;\n }\n\n // Helper for creating list items with padding\n createListItem(text: string, style?: string): JsonMLElement {\n const li = this.createChild(\"li\").setStyle(`padding-left: 10px;${style ? \" \" + style : \"\"}`);\n if (text) li.createTextChild(text);\n return li;\n }\n\n // Helper for creating highlighted list items (commonly used in API sections)\n createHighlightedListItem(text: string): JsonMLElement {\n const colors = JsonMLElement.getColors();\n this.createChild(\"li\")\n .setStyle(`color:${colors.yellow}; padding-left: 10px;`)\n .createTextChild(text);\n return this;\n }\n\n createStatusListItem(text: string): JsonMLElement {\n this.createStyledList(\"Status: \");\n let color = \"grey\";\n switch (text) {\n case TaskStatus.COMPLETED:\n color = \"green\";\n break;\n case TaskStatus.ABORTING:\n case TaskStatus.FAILED:\n color = \"red\";\n break;\n default:\n color = \"grey\";\n }\n return this.createListItem(text, `padding-left: 30px;color: ${color};`);\n }\n\n // Helper for creating a styled list\n createStyledList(title?: string): JsonMLElement {\n const list = this.createChild(\"ol\").setStyle(\"list-style-type: none; padding-left: 10px;\");\n if (title) list.createTextChild(title);\n return list;\n }\n\n // Helper for creating an object-like structure with braces\n objectBraces(content: (element: JsonMLElement) => void): JsonMLElement {\n this.greyText(\"{ \");\n content(this);\n this.greyText(\" }\");\n return this;\n }\n\n // Helper for creating a function call-like structure with parentheses\n functionCall(content: (element: JsonMLElement) => void): JsonMLElement {\n this.greyText(\"(\");\n content(this);\n this.greyText(\")\");\n return this;\n }\n\n createChild(tagName: JsonMLTagName): JsonMLElement {\n const c = new JsonMLElement(tagName);\n this._jsonML.push(c.toJsonML());\n return c;\n }\n\n createObjectTag(object: unknown, config?: Config): JsonMLElement {\n const tag = this.createChild(\"object\");\n tag.addAttribute(\"object\", object);\n if (config) {\n tag.addAttribute(\"config\", config);\n }\n return tag;\n }\n\n createValueObject(value: unknown, config?: Config): JsonMLElement {\n if (Array.isArray(value)) return this.createArrayChild(value, config);\n if (typeof value === \"undefined\") {\n const colors = JsonMLElement.getColors();\n return this.createChild(\"span\")\n .setStyle(`color:${colors.undefined};`)\n .createTextChild(\"undefined\");\n }\n\n return this.createObjectTag(value, config);\n }\n\n setStyle(style: string): JsonMLElement {\n this._attributes[\"style\"] = style;\n return this;\n }\n\n addAttribute(key: string, value: unknown): JsonMLElement {\n this._attributes[key] = value;\n return this;\n }\n\n createTextChild(text: string): JsonMLElement {\n this._jsonML.push(text + \"\");\n return this;\n }\n\n createArrayChild(array: readonly unknown[], config?: Config): JsonMLElement {\n const j = new JsonMLElement(\"span\");\n j.createTextChild(\"[\");\n for (let i = 0; i < array.length; ++i) {\n if (i != 0) j.createTextChild(\", \");\n j.createValueObject(array[i], config);\n }\n j.createTextChild(\"]\");\n this._jsonML.push(j.toJsonML());\n return j;\n }\n\n toJsonML(): JsonMLElementDef {\n return this._jsonML;\n }\n}\n\ninterface NodeWithConfig {\n readonly config: { readonly id: string };\n readonly type?: string;\n}\n\nfunction computeLayout(\n graph: DirectedAcyclicGraph<NodeWithConfig, unknown, string, unknown>,\n canvasWidth: number\n): {\n readonly positions: { readonly [id: string]: { readonly x: number; readonly y: number } };\n readonly requiredHeight: number;\n} {\n const positions: { [id: string]: { x: number; y: number } } = {};\n const layers: Map<number, string[]> = new Map();\n const depths: { [id: string]: number } = {};\n\n // Compute depth (longest path from any root)\n for (const node of graph.topologicallySortedNodes()) {\n const incomingEdges = graph.inEdges(node.config.id).map(([from]) => from);\n const depth =\n incomingEdges.length > 0 ? Math.max(...incomingEdges.map((from) => depths[from])) + 1 : 0;\n depths[node.config.id] = depth;\n\n if (!layers.has(depth)) layers.set(depth, []);\n layers.get(depth)!.push(node.config.id);\n }\n\n // Compute spacing based on available canvas size\n const totalLayers = layers.size;\n const layerSpacing = totalLayers > 1 ? Math.max(canvasWidth / totalLayers, 150) : 150;\n\n // Determine the required height dynamically\n const maxNodesInLayer = Math.max(...Array.from(layers.values()).map((layer) => layer.length));\n const nodeSpacing = 100;\n const requiredHeight = maxNodesInLayer * nodeSpacing + 100; // Extra padding\n\n layers.forEach((layerNodes, layerIndex) => {\n const yStart = (requiredHeight - layerNodes.length * nodeSpacing) / 2;\n layerNodes.forEach((nodeId, index) => {\n positions[nodeId] = {\n x: layerIndex * layerSpacing + layerSpacing / 2,\n y: yStart + index * nodeSpacing,\n };\n });\n });\n\n return { positions, requiredHeight };\n}\n\nfunction generateGraphImage(\n graph: DirectedAcyclicGraph<NodeWithConfig, unknown, string, unknown>,\n width = 800\n): { readonly dataURL: string; readonly height: number } {\n const ratio = window.devicePixelRatio || 1;\n const { positions, requiredHeight } = computeLayout(graph, width);\n const canvas = document.createElement(\"canvas\");\n canvas.width = width * ratio;\n canvas.height = requiredHeight * ratio;\n const ctx = canvas.getContext(\"2d\");\n\n if (!ctx) {\n console.error(\"Canvas context is not available.\");\n return { dataURL: \"\", height: requiredHeight };\n }\n ctx.scale(ratio, ratio);\n\n // Draw edges first\n ctx.clearRect(0, 0, width, requiredHeight);\n ctx.strokeStyle = \"#aaa\";\n ctx.lineWidth = 2;\n for (const [source, target] of graph.getEdges()) {\n const fromNode = positions[source];\n const toNode = positions[target];\n if (fromNode && toNode) {\n ctx.beginPath();\n ctx.moveTo(fromNode.x, fromNode.y);\n ctx.lineTo(toNode.x, toNode.y);\n ctx.stroke();\n }\n }\n\n // Draw nodes over the edges\n ctx.fillStyle = \"#3498db\";\n for (const node of graph.getNodes()) {\n const pos = positions[node.config.id];\n ctx.beginPath();\n ctx.arc(pos.x, pos.y, 10, 0, Math.PI * 2);\n ctx.fill();\n\n ctx.fillStyle = \"black\";\n ctx.font = `12px Arial`;\n ctx.textAlign = \"center\";\n ctx.fillText(node.type ?? \"\", pos.x, pos.y - 15);\n ctx.fillStyle = \"#3498db\";\n }\n\n const dataURL = canvas.toDataURL(\"image/png\");\n\n return { dataURL, height: requiredHeight };\n}\n\ndeclare global {\n interface Window {\n devtoolsFormatters?: ConsoleFormatter[];\n }\n}\n\n/**\n * Installs custom DevTools formatters for Workglow task graphs, workflows, and related objects.\n * Call this function once in your application to enable rich console output for debugging.\n *\n * @example\n * ```ts\n * import { installDevToolsFormatters } from \"@workglow/task-graph\";\n *\n * // Call early in your app initialization\n * installDevToolsFormatters();\n *\n * // Now console.log will show rich output for Workflow, Task, TaskGraph, etc.\n * console.log(myWorkflow);\n * ```\n */\nexport function installDevToolsFormatters(): void {\n window.devtoolsFormatters = window.devtoolsFormatters || [];\n window.devtoolsFormatters.push(\n new WorkflowAPIConsoleFormatter(),\n new CreateWorkflowConsoleFormatter(),\n new WorkflowConsoleFormatter(),\n new TaskConsoleFormatter(),\n new ReactElementConsoleFormatter(),\n new DataflowConsoleFormatter(),\n new DAGConsoleFormatter()\n );\n}\n"
52
61
  ],
53
- "mappings": ";AAMA;AACA;;;ACqBO,IAAM,aAAa;AAAA,EAExB,SAAS;AAAA,EAET,UAAU;AAAA,EAEV,YAAY;AAAA,EAEZ,WAAW;AAAA,EAEX,WAAW;AAAA,EAEX,UAAU;AAAA,EAEV,QAAQ;AACV;AA8CO,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,YAAY;AAAA,IACV,IAAI;AAAA,MACF,eAAe;AAAA,IACjB;AAAA,IACA,OAAO,EAAE,MAAM,SAA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