Conversation
@workglow/cli
@workglow/ai
@workglow/ai-provider
@workglow/job-queue
@workglow/knowledge-base
@workglow/storage
@workglow/task-graph
@workglow/tasks
@workglow/util
workglow
commit: |
There was a problem hiding this comment.
Pull request overview
This PR combines several related improvements across the monorepo: it introduces a unified Image abstraction (with a shared raster codec registry), adds color parsing/normalization utilities and schemas, and adds first-class “transform chains” on Dataflow edges (with serialization + built-in transform registry). It also updates timeouts and aligns tests/docs with the new APIs.
Changes:
- Add
@workglow/util/mediaImage+ codec registry + browser augmentation; update tasks/AI code to use it. - Add
ColorValueSchema(hex or object) + color utilities; update image tasks to accept both wire forms. - Add
Dataflow.transformssupport (registry, built-ins, runner integration, JSON round-trip) and refactorautoConnect.
Reviewed changes
Copilot reviewed 83 out of 84 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Align hook timeout with test timeout. |
| scripts/test.ts | Align Bun test timeout with Vitest timeout. |
| packages/util/src/media/imageTypes.ts | Add RgbaImageBinary helper type. |
| packages/util/src/media/imageRasterCodecRegistry.ts | New shared raster codec registry in util. |
| packages/util/src/media/image.node.ts | Removed legacy node image conversion helper. |
| packages/util/src/media/image.browser.ts | Removed legacy browser image conversion helper. |
| packages/util/src/media/color.ts | New color parsing/normalization + guards. |
| packages/util/src/media/MediaRawImage.ts | Add HF RawImage-shape shim. |
| packages/util/src/media/Image.ts | New unified Image class with on-demand conversions + JSON support. |
| packages/util/src/media/Image.browser.ts | Browser-only augmentation for Image conversions. |
| packages/util/src/media-node.ts | Update node media barrel exports to new modules. |
| packages/util/src/media-browser.ts | Update browser media barrel exports to new modules (+ augmentation). |
| packages/test/src/test/util/color.test.ts | Tests for new color utilities. |
| packages/test/src/test/util/Image.test.ts | Tests for Image JSON + codec + support conversion behavior. |
| packages/test/src/test/task/StringTask.test.ts | Update string task tests for renamed ports. |
| packages/test/src/test/task/ImageTask.test.ts | Extend ImageTextTask tests (schema branches, background behavior). |
| packages/test/src/test/task/ImageColorInput.test.ts | Verify image tasks accept both color wire forms. |
| packages/test/src/test/task-graph/Workflow.transforms.test.ts | Test Workflow.rename({ transforms }) behavior. |
| packages/test/src/test/task-graph/Workflow.maxIterations.test.ts | Test fluent builder defaulting maxIterations to "unbounded". |
| packages/test/src/test/task-graph/Transforms.integration.test.ts | End-to-end transform chain tests across graph execution + JSON. |
| packages/test/src/test/task-graph/SubgraphCycleGuard.test.ts | Formatting-only test adjustment. |
| packages/test/src/test/task-graph/GraphToWorkflowCode.test.ts | Formatting-only test adjustment. |
| packages/test/src/test/schema/imageTextTaskInputSchema.test.ts | Validate ImageTextTask schema behavior via schema compiler. |
| packages/test/src/test/schema/colorValueSchema.test.ts | Validate ColorValueSchema/HexColorSchema. |
| packages/test/src/test/ai-provider/TextEmbeddingTask.integration.test.ts | Adjust map maxIterations in embedding integration test. |
| packages/test/src/test/ai-provider/HFTransformersBinding.test.ts | Tune hook timeouts + clear pipeline cache + import ordering. |
| packages/test/package.json | Formatting-only change. |
| packages/tasks/src/task/string/StringUpperCaseTask.ts | Rename value/result ports to text. |
| packages/tasks/src/task/string/StringTrimTask.ts | Rename value/result ports to text. |
| packages/tasks/src/task/string/StringTemplateTask.ts | Rename output port to text. |
| packages/tasks/src/task/string/StringSliceTask.ts | Rename value/result ports to text. |
| packages/tasks/src/task/string/StringReplaceTask.ts | Rename value/result ports to text. |
| packages/tasks/src/task/string/StringLowerCaseTask.ts | Rename value/result ports to text. |
| packages/tasks/src/task/string/StringLengthTask.ts | Rename output port to length and input to text. |
| packages/tasks/src/task/string/StringJoinTask.ts | Rename values/result ports to texts/text. |
| packages/tasks/src/task/string/StringIncludesTask.ts | Rename output port to included and input to text. |
| packages/tasks/src/task/string/StringConcatTask.ts | Rename output port to text. |
| packages/tasks/src/task/image/registerImageRasterCodec.node.ts | Register codec via util media registry. |
| packages/tasks/src/task/image/registerImageRasterCodec.browser.ts | Register codec via util media registry. |
| packages/tasks/src/task/image/imageTaskTransport.ts | Removed legacy image transport helper (moved to Image usage). |
| packages/tasks/src/task/image/imageTaskIo.ts | Use Image + util codec registry for decode/encode parity. |
| packages/tasks/src/task/image/imageRasterCodecRegistry.ts | Re-export registry/types from util media. |
| packages/tasks/src/task/image/imageRasterCodecNode.ts | Import ImageRasterCodec type from util media. |
| packages/tasks/src/task/image/imageRasterCodecBrowser.ts | Import ImageRasterCodec type from util media. |
| packages/tasks/src/task/image/ImageTintTask.ts | Accept ColorValueSchema + normalize via resolveColor. |
| packages/tasks/src/task/image/ImageTextTask.ts | Accept ColorValueSchema + schema changes for image vs width/height. |
| packages/tasks/src/task/image/ImageSchemas.ts | Add HexColorSchema + ColorValueSchema + FromSchema options. |
| packages/tasks/src/task/image/ImageBorderTask.ts | Accept ColorValueSchema + normalize via resolveColor. |
| packages/tasks/src/common.ts | Stop exporting removed imageTaskTransport. |
| packages/task-graph/src/task/tests/DataflowJson.transforms.test.ts | Add JSON typing test for DataflowJson.transforms. |
| packages/task-graph/src/task/WhileTask.ts | Formatting-only schema readability change. |
| packages/task-graph/src/task/TaskJSON.ts | Serialize/deserialize dataflow transforms. |
| packages/task-graph/src/task/ReduceTask.ts | Ensure config schema includes required fields from iterator schema. |
| packages/task-graph/src/task/IteratorTask.ts | Import ordering + formatting-only schema readability change. |
| packages/task-graph/src/task/EntitlementEnforcer.ts | Formatting-only readability change. |
| packages/task-graph/src/task-graph/transforms/string-casts.ts | Add built-in string transforms (uppercase/lowercase/etc.). |
| packages/task-graph/src/task-graph/transforms/scalar-conversions.ts | Add built-in scalar conversion transforms. |
| packages/task-graph/src/task-graph/transforms/pick.ts | Add structural pick transform + schema inference/suggestions. |
| packages/task-graph/src/task-graph/transforms/index.ts | Export/register built-in transforms. |
| packages/task-graph/src/task-graph/transforms/index-access.ts | Add structural index transform. |
| packages/task-graph/src/task-graph/transforms/date-conversions.ts | Add date conversion transforms. |
| packages/task-graph/src/task-graph/transforms/coalesce.ts | Add coalesce transform. |
| packages/task-graph/src/task-graph/autoConnect.ts | Extract autoConnect logic to standalone module (+ dryRun). |
| packages/task-graph/src/task-graph/tests/transforms/string-casts.test.ts | Unit tests for string transforms. |
| packages/task-graph/src/task-graph/tests/transforms/scalar-conversions.test.ts | Unit tests for scalar conversion transforms. |
| packages/task-graph/src/task-graph/tests/transforms/pick.test.ts | Unit tests for pick transform. |
| packages/task-graph/src/task-graph/tests/transforms/index-access.test.ts | Unit tests for index transform. |
| packages/task-graph/src/task-graph/tests/transforms/date-conversions.test.ts | Unit tests for date conversion transforms. |
| packages/task-graph/src/task-graph/tests/transforms/coalesce.test.ts | Unit tests for coalesce transform. |
| packages/task-graph/src/task-graph/tests/autoConnect.scenarios.test.ts | Scenario coverage for extracted autoConnect behavior. |
| packages/task-graph/src/task-graph/tests/TransformRegistry.test.ts | Unit tests for transform registry + built-in registration. |
| packages/task-graph/src/task-graph/tests/TaskGraphRunner.transforms.test.ts | Runner test ensuring transforms apply on edges. |
| packages/task-graph/src/task-graph/tests/Dataflow.transforms.test.ts | Dataflow API tests for transforms + compatibility. |
| packages/task-graph/src/task-graph/tests/Dataflow.streaming.test.ts | Streaming edge behavior + transform single-application tests. |
| packages/task-graph/src/task-graph/Workflow.ts | Add rename transforms option + default loop maxIterations + delegate autoConnect. |
| packages/task-graph/src/task-graph/TransformTypes.ts | Add transform step/def types. |
| packages/task-graph/src/task-graph/TransformRegistry.ts | Add global transform registry + DI token. |
| packages/task-graph/src/task-graph/TaskGraphRunner.ts | Apply transforms in runner + add runReactive telemetry/logging. |
| packages/task-graph/src/task-graph/Dataflow.ts | Add transform chain storage + JSON + compatibility composition + applyTransforms. |
| packages/task-graph/src/task-graph/ConditionalBuilder.ts | Formatting-only change. |
| packages/task-graph/src/common.ts | Export transforms + registry + autoConnect from public entry. |
| packages/task-graph/src/tests/public-exports.test.ts | Ensure new public exports are available. |
| packages/ai/src/task/base/AiVisionTask.ts | Switch to Image.from(...).toFirstSupported(...) conversion path. |
| docs/technical/03-control-flow-tasks.md | Document builder defaulting of maxIterations to "unbounded". |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| required: ["text", "color"], | ||
| additionalProperties: false, | ||
| if: { | ||
| not: { | ||
| required: ["image"], | ||
| }, | ||
| }, | ||
| then: { | ||
| required: ["width", "height"], | ||
| }, |
There was a problem hiding this comment.
The current JSON Schema only enforces width/height when image is absent, but it does not forbid supplying image together with width/height. That means the “mixing background image with explicit dimensions” case will validate, even though the tests in this PR expect it to be rejected. Consider encoding exclusivity (e.g. via an allOf with if: {required:["image"]} then: { not: { anyOf: [{required:["width"]},{required:["height"]}] } } else: { required:["width","height"] }).
There was a problem hiding this comment.
@copilot we just ignore width and height if there is an image. if values are there it is not an error
There was a problem hiding this comment.
Confirmed — the current code already does this. When a background image is provided, width and height are silently ignored; the task uses the background image's own dimensions instead. The schema only requires width/height when image is absent, but it does not forbid supplying them together with image. No changes needed.
| async getDataUri(mimeType: string = "image/png"): Promise<string> { | ||
| if (this.source.kind === "dataUri") { | ||
| if (mimeType === this.source.mimeType || mimeType === "image/png") { | ||
| return this.source.dataUri; | ||
| } | ||
| } |
There was a problem hiding this comment.
Image.getDataUri() returns the original data: URI whenever the requested mimeType is "image/png", even if the source data: URI is a different type (e.g. JPEG). Since mimeType defaults to "image/png", callers can unexpectedly receive a non-PNG data URI when they think they're requesting PNG. Consider only short-circuiting when mimeType === this.source.mimeType (or when the caller didn't request a different type), and otherwise re-encode via the raster codec.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Fixed in 93945c0. getDataUri() now only short-circuits when mimeType === this.source.mimeType; the spurious || mimeType === "image/png" condition that returned the wrong format has been removed.
Coverage Report
File CoverageNo changed files found. |
Adds a dataflow transforms system that runs ordered transform functions on edges between tasks, plus an autoConnect refactor extracting Workflow's auto-wiring logic into a dedicated module with broader scenario coverage. - New Transform/TransformRegistry abstraction with built-in transforms: coalesce, date-conversions, index-access, pick, scalar-conversions, string-casts. - Dataflow gains transform execution; TaskGraphRunner threads transforms through edge propagation with structured error handling. - Workflow.autoConnect extracted to autoConnect.ts; Workflow.ts shrunk by ~470 lines. - String tasks: standardize property names across schemas/outputs. - Integration + unit test coverage including streaming dataflows and per-transform tests. - examples/cli wires up registerBuiltInTransforms().
- Added hookTimeout to Vitest configuration to match the global testTimeout of 15 seconds. - Updated test cases in HFTransformersBinding to use a consistent timeout of 15 seconds for beforeEach and afterAll hooks. - Adjusted Bun test script to set a timeout of 15 seconds, aligning with Vitest's timeout settings for improved reliability.
Reworks ImageTextTask's input schema to better express the exclusive-branch semantics for text rendering options, with stronger validation and tighter type safety. - Branch exclusivity expressed via JSON Schema if/then so the validator can produce a single coherent error path instead of fanning out oneOf branch failures. - Schema-level test coverage in imageTextTaskInputSchema.test.ts. - Minor adjustments to autoConnect, ImageSchemas, and image task IO helpers to support the richer schema.
Introduces a structured color representation and helpers used to bridge hex strings, ColorObject values, and runtime resolution at task boundaries. - ColorObject type plus parseHexColor for parsing #rrggbb / #rrggbbaa. - toHexColor emitter for the inverse direction. - resolveColor + isColorObject / isHexColor type guards. - Unit tests covering edge cases (alpha, short forms, invalid input).
Introduces a JSON Schema oneOf union (HexColorSchema | ColorObjectSchema) that lets image tasks accept either wire form, and migrates existing color-consuming tasks to the new schema + resolveColor helper. - ColorValueSchema / HexColorSchema added to ImageSchemas with schema unit tests. - ImageTintTask, ImageBorderTask, ImageTextTask migrated to ColorValueSchema + resolveColor. - resolveColor input type relaxed to accept optional alpha so callers don't need to widen ColorObject before resolving. - Cross-form coverage in ImageColorInput.test.ts (verifies both wire forms produce equivalent rendering). - Formatting sweep across task-graph + tests after the migration.
Adds OTel span + per-task timing log around the reactive run loop, gated behind getTelemetryProvider().isEnabled so the UI preview hot path pays no overhead when telemetry is off. The body that runs without telemetry skips the four performance.now() calls per task and the timing array, matching prior behavior. With telemetry enabled the run carries a uuid run_id, per-task runReactiveMs and pushOutputMs samples, and a debug log at completion (or error).
Replaces the prior split image.browser.ts / image.node.ts files and the
ad-hoc imageTaskTransport helpers with a single platform-aware Image
class plus a small codec registry, both rooted in @workglow/util/media.
- new Image class (Image.ts + Image.browser.ts) with discriminated
ImageSource union covering dataUri, pixels, blob, bitmap, videoFrame
and offscreenCanvas.
- toFirstSupported(supports[]) replaces convertImageDataToUseableForm
with a typed pull-from-codec API.
- Image.toJSON returns a `{ unsynced: true, kind }` sentinel for
transient browser sources whose pixels haven't been materialized yet,
so JSON.stringify of a workflow holding such an image succeeds; the
caller must await getPixels() before serialization for a real
round-trip. Image.fromJSON rejects the sentinel with a clear message.
- Image.getDataUri only short-circuits when the requested mimeType
matches the source dataUri's mimeType.
- imageRasterCodecRegistry promoted to a public surface in
@workglow/util/media; tasks/image now thin-wraps it.
- The legacy image.ts type module is renamed to imageTypes.ts (its
former path is reused for the Image class).
- imageTaskTransport.ts deleted; functionality folded into imageTaskIo
and the new Image class.
- AiVisionTask, image-raster codec adapters, and ImageTask tests
updated to consume the new API.
…nges to tool use schema Enhances the StructuredGenerationTask by adding a check to ensure that outputSchema is a valid JSON Schema. Updates test cases to reflect changes in input handling for better type safety.
No description provided.