Skip to content

Combined#434

Merged
sroussey merged 11 commits intomainfrom
combined
Apr 25, 2026
Merged

Combined#434
sroussey merged 11 commits intomainfrom
combined

Conversation

@sroussey
Copy link
Copy Markdown
Collaborator

No description provided.

@sroussey sroussey self-assigned this Apr 25, 2026
@sroussey sroussey marked this pull request as ready for review April 25, 2026 04:26
@sroussey sroussey requested a review from Copilot April 25, 2026 04:26
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 25, 2026

Open in StackBlitz

@workglow/cli

npm i https://pkg.pr.new/@workglow/cli@434

@workglow/ai

npm i https://pkg.pr.new/@workglow/ai@434

@workglow/ai-provider

npm i https://pkg.pr.new/@workglow/ai-provider@434

@workglow/job-queue

npm i https://pkg.pr.new/@workglow/job-queue@434

@workglow/knowledge-base

npm i https://pkg.pr.new/@workglow/knowledge-base@434

@workglow/storage

npm i https://pkg.pr.new/@workglow/storage@434

@workglow/task-graph

npm i https://pkg.pr.new/@workglow/task-graph@434

@workglow/tasks

npm i https://pkg.pr.new/@workglow/tasks@434

@workglow/util

npm i https://pkg.pr.new/@workglow/util@434

workglow

npm i https://pkg.pr.new/workglow@434

commit: 0450216

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/media Image + 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.transforms support (registry, built-ins, runner integration, JSON round-trip) and refactor autoConnect.

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.

Comment thread packages/util/src/media/color.ts
Comment on lines +173 to +182
required: ["text", "color"],
additionalProperties: false,
if: {
not: {
required: ["image"],
},
},
then: {
required: ["width", "height"],
},
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"] }).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot we just ignore width and height if there is an image. if values are there it is not an error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +280 to +285
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;
}
}
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 58.46% 17505 / 29942
🔵 Statements 58.36% 18051 / 30929
🔵 Functions 61.4% 3215 / 5236
🔵 Branches 47% 8306 / 17671
File CoverageNo changed files found.
Generated in workflow #1825 for commit 0450216 by the Vitest Coverage Report Action

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.
@sroussey sroussey merged commit 6801a77 into main Apr 25, 2026
22 checks passed
@sroussey sroussey deleted the combined branch April 25, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants