@workglow/tasks 0.2.16 → 0.2.18

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 (235) hide show
  1. package/README.md +10 -9
  2. package/dist/browser.d.ts +2 -2
  3. package/dist/browser.d.ts.map +1 -1
  4. package/dist/browser.js +1924 -1363
  5. package/dist/browser.js.map +79 -47
  6. package/dist/bun.d.ts +2 -2
  7. package/dist/bun.d.ts.map +1 -1
  8. package/dist/bun.js +1604 -1328
  9. package/dist/bun.js.map +77 -47
  10. package/dist/codec.browser.d.ts +39 -0
  11. package/dist/codec.browser.d.ts.map +1 -0
  12. package/dist/codec.node.d.ts +37 -0
  13. package/dist/codec.node.d.ts.map +1 -0
  14. package/dist/common.d.ts +39 -38
  15. package/dist/common.d.ts.map +1 -1
  16. package/dist/electron.d.ts +2 -2
  17. package/dist/electron.d.ts.map +1 -1
  18. package/dist/electron.js +1604 -1328
  19. package/dist/electron.js.map +77 -47
  20. package/dist/node.d.ts +2 -2
  21. package/dist/node.d.ts.map +1 -1
  22. package/dist/node.js +1604 -1328
  23. package/dist/node.js.map +77 -47
  24. package/dist/task/ArrayTask.d.ts +4 -5
  25. package/dist/task/ArrayTask.d.ts.map +1 -1
  26. package/dist/task/DateFormatTask.d.ts +3 -2
  27. package/dist/task/DateFormatTask.d.ts.map +1 -1
  28. package/dist/task/DebugLogTask.d.ts +2 -1
  29. package/dist/task/DebugLogTask.d.ts.map +1 -1
  30. package/dist/task/InputTask.d.ts +2 -1
  31. package/dist/task/InputTask.d.ts.map +1 -1
  32. package/dist/task/JavaScriptTask.d.ts +4 -1
  33. package/dist/task/JavaScriptTask.d.ts.map +1 -1
  34. package/dist/task/JsonPathTask.d.ts +3 -2
  35. package/dist/task/JsonPathTask.d.ts.map +1 -1
  36. package/dist/task/LambdaTask.d.ts +7 -6
  37. package/dist/task/LambdaTask.d.ts.map +1 -1
  38. package/dist/task/OutputTask.d.ts +2 -1
  39. package/dist/task/OutputTask.d.ts.map +1 -1
  40. package/dist/task/RegexTask.d.ts +3 -2
  41. package/dist/task/RegexTask.d.ts.map +1 -1
  42. package/dist/task/SplitTask.d.ts +3 -2
  43. package/dist/task/SplitTask.d.ts.map +1 -1
  44. package/dist/task/TemplateTask.d.ts +3 -2
  45. package/dist/task/TemplateTask.d.ts.map +1 -1
  46. package/dist/task/image/ImageFilterTask.d.ts +24 -0
  47. package/dist/task/image/ImageFilterTask.d.ts.map +1 -0
  48. package/dist/task/image/ImageSchemas.d.ts +15 -101
  49. package/dist/task/image/ImageSchemas.d.ts.map +1 -1
  50. package/dist/task/image/blur/ImageBlurTask.d.ts +29 -0
  51. package/dist/task/image/blur/ImageBlurTask.d.ts.map +1 -0
  52. package/dist/task/image/blur/blur.cpu.d.ts +4 -0
  53. package/dist/task/image/blur/blur.cpu.d.ts.map +1 -0
  54. package/dist/task/image/blur/blur.sharp.d.ts +2 -0
  55. package/dist/task/image/blur/blur.sharp.d.ts.map +1 -0
  56. package/dist/task/image/blur/blur.webgpu.d.ts +2 -0
  57. package/dist/task/image/blur/blur.webgpu.d.ts.map +1 -0
  58. package/dist/task/image/border/ImageBorderTask.d.ts +35 -0
  59. package/dist/task/image/border/ImageBorderTask.d.ts.map +1 -0
  60. package/dist/task/image/border/border.cpu.d.ts +10 -0
  61. package/dist/task/image/border/border.cpu.d.ts.map +1 -0
  62. package/dist/task/image/border/border.sharp.d.ts +2 -0
  63. package/dist/task/image/border/border.sharp.d.ts.map +1 -0
  64. package/dist/task/image/border/border.webgpu.d.ts +2 -0
  65. package/dist/task/image/border/border.webgpu.d.ts.map +1 -0
  66. package/dist/task/image/brightness/ImageBrightnessTask.d.ts +28 -0
  67. package/dist/task/image/brightness/ImageBrightnessTask.d.ts.map +1 -0
  68. package/dist/task/image/brightness/brightness.cpu.d.ts +4 -0
  69. package/dist/task/image/brightness/brightness.cpu.d.ts.map +1 -0
  70. package/dist/task/image/brightness/brightness.sharp.d.ts +2 -0
  71. package/dist/task/image/brightness/brightness.sharp.d.ts.map +1 -0
  72. package/dist/task/image/brightness/brightness.webgpu.d.ts +2 -0
  73. package/dist/task/image/brightness/brightness.webgpu.d.ts.map +1 -0
  74. package/dist/task/image/contrast/ImageContrastTask.d.ts +28 -0
  75. package/dist/task/image/contrast/ImageContrastTask.d.ts.map +1 -0
  76. package/dist/task/image/contrast/contrast.cpu.d.ts +4 -0
  77. package/dist/task/image/contrast/contrast.cpu.d.ts.map +1 -0
  78. package/dist/task/image/contrast/contrast.sharp.d.ts +2 -0
  79. package/dist/task/image/contrast/contrast.sharp.d.ts.map +1 -0
  80. package/dist/task/image/contrast/contrast.webgpu.d.ts +2 -0
  81. package/dist/task/image/contrast/contrast.webgpu.d.ts.map +1 -0
  82. package/dist/task/image/crop/ImageCropTask.d.ts +32 -0
  83. package/dist/task/image/crop/ImageCropTask.d.ts.map +1 -0
  84. package/dist/task/image/crop/crop.cpu.d.ts +7 -0
  85. package/dist/task/image/crop/crop.cpu.d.ts.map +1 -0
  86. package/dist/task/image/crop/crop.sharp.d.ts +2 -0
  87. package/dist/task/image/crop/crop.sharp.d.ts.map +1 -0
  88. package/dist/task/image/crop/crop.webgpu.d.ts +2 -0
  89. package/dist/task/image/crop/crop.webgpu.d.ts.map +1 -0
  90. package/dist/task/image/flip/ImageFlipTask.d.ts +28 -0
  91. package/dist/task/image/flip/ImageFlipTask.d.ts.map +1 -0
  92. package/dist/task/image/flip/flip.cpu.d.ts +4 -0
  93. package/dist/task/image/flip/flip.cpu.d.ts.map +1 -0
  94. package/dist/task/image/flip/flip.sharp.d.ts +2 -0
  95. package/dist/task/image/flip/flip.sharp.d.ts.map +1 -0
  96. package/dist/task/image/flip/flip.webgpu.d.ts +2 -0
  97. package/dist/task/image/flip/flip.webgpu.d.ts.map +1 -0
  98. package/dist/task/image/grayscale/ImageGrayscaleTask.d.ts +25 -0
  99. package/dist/task/image/grayscale/ImageGrayscaleTask.d.ts.map +1 -0
  100. package/dist/task/image/grayscale/grayscale.cpu.d.ts +2 -0
  101. package/dist/task/image/grayscale/grayscale.cpu.d.ts.map +1 -0
  102. package/dist/task/image/grayscale/grayscale.sharp.d.ts +2 -0
  103. package/dist/task/image/grayscale/grayscale.sharp.d.ts.map +1 -0
  104. package/dist/task/image/grayscale/grayscale.webgpu.d.ts +2 -0
  105. package/dist/task/image/grayscale/grayscale.webgpu.d.ts.map +1 -0
  106. package/dist/task/image/imageCodecLimits.d.ts +8 -4
  107. package/dist/task/image/imageCodecLimits.d.ts.map +1 -1
  108. package/dist/task/image/invert/ImageInvertTask.d.ts +25 -0
  109. package/dist/task/image/invert/ImageInvertTask.d.ts.map +1 -0
  110. package/dist/task/image/invert/invert.cpu.d.ts +2 -0
  111. package/dist/task/image/invert/invert.cpu.d.ts.map +1 -0
  112. package/dist/task/image/invert/invert.sharp.d.ts +2 -0
  113. package/dist/task/image/invert/invert.sharp.d.ts.map +1 -0
  114. package/dist/task/image/invert/invert.webgpu.d.ts +2 -0
  115. package/dist/task/image/invert/invert.webgpu.d.ts.map +1 -0
  116. package/dist/task/image/pixelate/ImagePixelateTask.d.ts +29 -0
  117. package/dist/task/image/pixelate/ImagePixelateTask.d.ts.map +1 -0
  118. package/dist/task/image/pixelate/pixelate.cpu.d.ts +4 -0
  119. package/dist/task/image/pixelate/pixelate.cpu.d.ts.map +1 -0
  120. package/dist/task/image/pixelate/pixelate.sharp.d.ts +2 -0
  121. package/dist/task/image/pixelate/pixelate.sharp.d.ts.map +1 -0
  122. package/dist/task/image/pixelate/pixelate.webgpu.d.ts +2 -0
  123. package/dist/task/image/pixelate/pixelate.webgpu.d.ts.map +1 -0
  124. package/dist/task/image/posterize/ImagePosterizeTask.d.ts +28 -0
  125. package/dist/task/image/posterize/ImagePosterizeTask.d.ts.map +1 -0
  126. package/dist/task/image/posterize/posterize.cpu.d.ts +4 -0
  127. package/dist/task/image/posterize/posterize.cpu.d.ts.map +1 -0
  128. package/dist/task/image/posterize/posterize.webgpu.d.ts +2 -0
  129. package/dist/task/image/posterize/posterize.webgpu.d.ts.map +1 -0
  130. package/dist/task/image/resize/ImageResizeTask.d.ts +32 -0
  131. package/dist/task/image/resize/ImageResizeTask.d.ts.map +1 -0
  132. package/dist/task/image/resize/resize.cpu.d.ts +7 -0
  133. package/dist/task/image/resize/resize.cpu.d.ts.map +1 -0
  134. package/dist/task/image/resize/resize.sharp.d.ts +2 -0
  135. package/dist/task/image/resize/resize.sharp.d.ts.map +1 -0
  136. package/dist/task/image/resize/resize.webgpu.d.ts +2 -0
  137. package/dist/task/image/resize/resize.webgpu.d.ts.map +1 -0
  138. package/dist/task/image/rotate/ImageRotateTask.d.ts +29 -0
  139. package/dist/task/image/rotate/ImageRotateTask.d.ts.map +1 -0
  140. package/dist/task/image/rotate/rotate.cpu.d.ts +5 -0
  141. package/dist/task/image/rotate/rotate.cpu.d.ts.map +1 -0
  142. package/dist/task/image/rotate/rotate.sharp.d.ts +2 -0
  143. package/dist/task/image/rotate/rotate.sharp.d.ts.map +1 -0
  144. package/dist/task/image/rotate/rotate.webgpu.d.ts +2 -0
  145. package/dist/task/image/rotate/rotate.webgpu.d.ts.map +1 -0
  146. package/dist/task/image/sepia/ImageSepiaTask.d.ts +25 -0
  147. package/dist/task/image/sepia/ImageSepiaTask.d.ts.map +1 -0
  148. package/dist/task/image/sepia/sepia.cpu.d.ts +2 -0
  149. package/dist/task/image/sepia/sepia.cpu.d.ts.map +1 -0
  150. package/dist/task/image/sepia/sepia.sharp.d.ts +2 -0
  151. package/dist/task/image/sepia/sepia.sharp.d.ts.map +1 -0
  152. package/dist/task/image/sepia/sepia.webgpu.d.ts +2 -0
  153. package/dist/task/image/sepia/sepia.webgpu.d.ts.map +1 -0
  154. package/dist/task/image/{ImageTextTask.d.ts → text/ImageTextTask.d.ts} +18 -104
  155. package/dist/task/image/text/ImageTextTask.d.ts.map +1 -0
  156. package/dist/task/image/threshold/ImageThresholdTask.d.ts +28 -0
  157. package/dist/task/image/threshold/ImageThresholdTask.d.ts.map +1 -0
  158. package/dist/task/image/threshold/threshold.cpu.d.ts +4 -0
  159. package/dist/task/image/threshold/threshold.cpu.d.ts.map +1 -0
  160. package/dist/task/image/threshold/threshold.sharp.d.ts +2 -0
  161. package/dist/task/image/threshold/threshold.sharp.d.ts.map +1 -0
  162. package/dist/task/image/threshold/threshold.webgpu.d.ts +2 -0
  163. package/dist/task/image/threshold/threshold.webgpu.d.ts.map +1 -0
  164. package/dist/task/image/tint/ImageTintTask.d.ts +30 -0
  165. package/dist/task/image/tint/ImageTintTask.d.ts.map +1 -0
  166. package/dist/task/image/tint/tint.cpu.d.ts +11 -0
  167. package/dist/task/image/tint/tint.cpu.d.ts.map +1 -0
  168. package/dist/task/image/tint/tint.sharp.d.ts +2 -0
  169. package/dist/task/image/tint/tint.sharp.d.ts.map +1 -0
  170. package/dist/task/image/tint/tint.webgpu.d.ts +2 -0
  171. package/dist/task/image/tint/tint.webgpu.d.ts.map +1 -0
  172. package/dist/task/image/transparency/ImageTransparencyTask.d.ts +28 -0
  173. package/dist/task/image/transparency/ImageTransparencyTask.d.ts.map +1 -0
  174. package/dist/task/image/transparency/transparency.cpu.d.ts +4 -0
  175. package/dist/task/image/transparency/transparency.cpu.d.ts.map +1 -0
  176. package/dist/task/image/transparency/transparency.webgpu.d.ts +2 -0
  177. package/dist/task/image/transparency/transparency.webgpu.d.ts.map +1 -0
  178. package/dist/task/string/StringConcatTask.d.ts +3 -2
  179. package/dist/task/string/StringConcatTask.d.ts.map +1 -1
  180. package/dist/task/string/StringIncludesTask.d.ts +3 -2
  181. package/dist/task/string/StringIncludesTask.d.ts.map +1 -1
  182. package/dist/task/string/StringJoinTask.d.ts +3 -2
  183. package/dist/task/string/StringJoinTask.d.ts.map +1 -1
  184. package/dist/task/string/StringLengthTask.d.ts +3 -2
  185. package/dist/task/string/StringLengthTask.d.ts.map +1 -1
  186. package/dist/task/string/StringLowerCaseTask.d.ts +3 -2
  187. package/dist/task/string/StringLowerCaseTask.d.ts.map +1 -1
  188. package/dist/task/string/StringReplaceTask.d.ts +3 -2
  189. package/dist/task/string/StringReplaceTask.d.ts.map +1 -1
  190. package/dist/task/string/StringSliceTask.d.ts +3 -2
  191. package/dist/task/string/StringSliceTask.d.ts.map +1 -1
  192. package/dist/task/string/StringTemplateTask.d.ts +3 -2
  193. package/dist/task/string/StringTemplateTask.d.ts.map +1 -1
  194. package/dist/task/string/StringTrimTask.d.ts +3 -2
  195. package/dist/task/string/StringTrimTask.d.ts.map +1 -1
  196. package/dist/task/string/StringUpperCaseTask.d.ts +3 -2
  197. package/dist/task/string/StringUpperCaseTask.d.ts.map +1 -1
  198. package/package.json +9 -9
  199. package/dist/task/image/ImageBlurTask.d.ts +0 -247
  200. package/dist/task/image/ImageBlurTask.d.ts.map +0 -1
  201. package/dist/task/image/ImageBorderTask.d.ts +0 -327
  202. package/dist/task/image/ImageBorderTask.d.ts.map +0 -1
  203. package/dist/task/image/ImageBrightnessTask.d.ts +0 -247
  204. package/dist/task/image/ImageBrightnessTask.d.ts.map +0 -1
  205. package/dist/task/image/ImageContrastTask.d.ts +0 -247
  206. package/dist/task/image/ImageContrastTask.d.ts.map +0 -1
  207. package/dist/task/image/ImageCropTask.d.ts +0 -279
  208. package/dist/task/image/ImageCropTask.d.ts.map +0 -1
  209. package/dist/task/image/ImageFlipTask.d.ts +0 -243
  210. package/dist/task/image/ImageFlipTask.d.ts.map +0 -1
  211. package/dist/task/image/ImageGrayscaleTask.d.ts +0 -231
  212. package/dist/task/image/ImageGrayscaleTask.d.ts.map +0 -1
  213. package/dist/task/image/ImageInvertTask.d.ts +0 -231
  214. package/dist/task/image/ImageInvertTask.d.ts.map +0 -1
  215. package/dist/task/image/ImagePixelateTask.d.ts +0 -245
  216. package/dist/task/image/ImagePixelateTask.d.ts.map +0 -1
  217. package/dist/task/image/ImagePosterizeTask.d.ts +0 -247
  218. package/dist/task/image/ImagePosterizeTask.d.ts.map +0 -1
  219. package/dist/task/image/ImageResizeTask.d.ts +0 -255
  220. package/dist/task/image/ImageResizeTask.d.ts.map +0 -1
  221. package/dist/task/image/ImageRotateTask.d.ts +0 -243
  222. package/dist/task/image/ImageRotateTask.d.ts.map +0 -1
  223. package/dist/task/image/ImageSepiaTask.d.ts +0 -231
  224. package/dist/task/image/ImageSepiaTask.d.ts.map +0 -1
  225. package/dist/task/image/ImageTextTask.d.ts.map +0 -1
  226. package/dist/task/image/ImageThresholdTask.d.ts +0 -247
  227. package/dist/task/image/ImageThresholdTask.d.ts.map +0 -1
  228. package/dist/task/image/ImageTintTask.d.ts +0 -329
  229. package/dist/task/image/ImageTintTask.d.ts.map +0 -1
  230. package/dist/task/image/ImageTransparencyTask.d.ts +0 -245
  231. package/dist/task/image/ImageTransparencyTask.d.ts.map +0 -1
  232. package/dist/task/image/ImageWatermarkTask.d.ts +0 -275
  233. package/dist/task/image/ImageWatermarkTask.d.ts.map +0 -1
  234. package/dist/task/image/imageTaskIo.d.ts +0 -20
  235. package/dist/task/image/imageTaskIo.d.ts.map +0 -1
package/dist/browser.js CHANGED
@@ -12,7 +12,7 @@ import { registerImageRasterCodec } from "@workglow/util/media";
12
12
  // src/task/image/imageCodecLimits.ts
13
13
  var MAX_DECODED_PIXELS = 1e8;
14
14
  var MAX_INPUT_BYTES_NODE = 64 * 1024 * 1024;
15
- var MAX_INPUT_BYTES_BROWSER = 8 * 1024 * 1024;
15
+ var MAX_INPUT_BYTES_BROWSER = 32 * 1024 * 1024;
16
16
  var REJECTED_DECODE_MIME_TYPES = new Set([
17
17
  "image/svg+xml",
18
18
  "image/svg",
@@ -176,6 +176,890 @@ function createBrowserImageRasterCodec() {
176
176
  // src/task/image/registerImageRasterCodec.browser.ts
177
177
  registerImageRasterCodec(createBrowserImageRasterCodec());
178
178
 
179
+ // src/task/image/blur/blur.cpu.ts
180
+ import { CpuImage, registerFilterOp } from "@workglow/util/media";
181
+ function cpuBoxBlur(bin, radius) {
182
+ const { data: src, width, height, channels } = bin;
183
+ const kernelSize = radius * 2 + 1;
184
+ const tmp = new Uint8ClampedArray(src.length);
185
+ for (let y = 0;y < height; y++) {
186
+ for (let c = 0;c < channels; c++) {
187
+ let sum = 0;
188
+ for (let k = -radius;k <= radius; k++) {
189
+ const x = Math.max(0, Math.min(k, width - 1));
190
+ sum += src[(y * width + x) * channels + c];
191
+ }
192
+ tmp[y * width * channels + c] = sum / kernelSize + 0.5 | 0;
193
+ for (let x = 1;x < width; x++) {
194
+ const addX = Math.min(x + radius, width - 1);
195
+ const removeX = Math.max(x - radius - 1, 0);
196
+ sum += src[(y * width + addX) * channels + c] - src[(y * width + removeX) * channels + c];
197
+ tmp[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
198
+ }
199
+ }
200
+ }
201
+ const dst = new Uint8ClampedArray(src.length);
202
+ for (let x = 0;x < width; x++) {
203
+ for (let c = 0;c < channels; c++) {
204
+ let sum = 0;
205
+ for (let k = -radius;k <= radius; k++) {
206
+ const y = Math.max(0, Math.min(k, height - 1));
207
+ sum += tmp[(y * width + x) * channels + c];
208
+ }
209
+ dst[x * channels + c] = sum / kernelSize + 0.5 | 0;
210
+ for (let y = 1;y < height; y++) {
211
+ const addY = Math.min(y + radius, height - 1);
212
+ const removeY = Math.max(y - radius - 1, 0);
213
+ sum += tmp[(addY * width + x) * channels + c] - tmp[(removeY * width + x) * channels + c];
214
+ dst[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
215
+ }
216
+ }
217
+ }
218
+ return { data: dst, width, height, channels };
219
+ }
220
+ registerFilterOp("cpu", "blur", (image, { radius }) => {
221
+ return CpuImage.fromImageBinary(cpuBoxBlur(image.getBinary(), Math.max(1, radius | 0)));
222
+ });
223
+
224
+ // src/task/image/border/border.cpu.ts
225
+ import { CpuImage as CpuImage2, registerFilterOp as registerFilterOp2, resolveColor } from "@workglow/util/media";
226
+ function cpuBorder(bin, borderWidth, color) {
227
+ const { data: src, width: srcW, height: srcH, channels: srcCh } = bin;
228
+ const bw = borderWidth;
229
+ const resolved = resolveColor(color);
230
+ const outCh = 4;
231
+ const dstW = srcW + bw * 2;
232
+ const dstH = srcH + bw * 2;
233
+ const dst = new Uint8ClampedArray(dstW * dstH * outCh);
234
+ const r = resolved.r;
235
+ const g = resolved.g;
236
+ const b = resolved.b;
237
+ const a = resolved.a;
238
+ for (let i = 0;i < dst.length; i += outCh) {
239
+ dst[i] = r;
240
+ dst[i + 1] = g;
241
+ dst[i + 2] = b;
242
+ dst[i + 3] = a;
243
+ }
244
+ for (let y = 0;y < srcH; y++) {
245
+ for (let x = 0;x < srcW; x++) {
246
+ const srcIdx = (y * srcW + x) * srcCh;
247
+ const dstIdx = ((y + bw) * dstW + (x + bw)) * outCh;
248
+ dst[dstIdx] = src[srcIdx];
249
+ dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
250
+ dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
251
+ dst[dstIdx + 3] = srcCh === 4 ? src[srcIdx + 3] : 255;
252
+ }
253
+ }
254
+ return { data: dst, width: dstW, height: dstH, channels: outCh };
255
+ }
256
+ registerFilterOp2("cpu", "border", (image, { borderWidth, color }) => {
257
+ return CpuImage2.fromImageBinary(cpuBorder(image.getBinary(), borderWidth, color));
258
+ });
259
+
260
+ // src/task/image/brightness/brightness.cpu.ts
261
+ import { CpuImage as CpuImage3, registerFilterOp as registerFilterOp3 } from "@workglow/util/media";
262
+ function cpuBrightness(bin, amount) {
263
+ const { data: src, width, height, channels } = bin;
264
+ const dst = new Uint8ClampedArray(src.length);
265
+ if (channels === 4) {
266
+ for (let i = 0;i < src.length; i += 4) {
267
+ dst[i] = src[i] + amount;
268
+ dst[i + 1] = src[i + 1] + amount;
269
+ dst[i + 2] = src[i + 2] + amount;
270
+ dst[i + 3] = src[i + 3];
271
+ }
272
+ } else {
273
+ for (let i = 0;i < src.length; i++) {
274
+ dst[i] = src[i] + amount;
275
+ }
276
+ }
277
+ return { data: dst, width, height, channels };
278
+ }
279
+ registerFilterOp3("cpu", "brightness", (image, { amount }) => {
280
+ return CpuImage3.fromImageBinary(cpuBrightness(image.getBinary(), amount));
281
+ });
282
+
283
+ // src/task/image/contrast/contrast.cpu.ts
284
+ import { CpuImage as CpuImage4, registerFilterOp as registerFilterOp4 } from "@workglow/util/media";
285
+ function cpuContrast(bin, amount) {
286
+ const { data: src, width, height, channels } = bin;
287
+ const factor = 259 * (amount + 255) / (255 * (259 - amount));
288
+ const lut = new Uint8ClampedArray(256);
289
+ for (let i = 0;i < 256; i++) {
290
+ lut[i] = factor * (i - 128) + 128;
291
+ }
292
+ const dst = new Uint8ClampedArray(src.length);
293
+ if (channels === 4) {
294
+ for (let i = 0;i < src.length; i += 4) {
295
+ dst[i] = lut[src[i]];
296
+ dst[i + 1] = lut[src[i + 1]];
297
+ dst[i + 2] = lut[src[i + 2]];
298
+ dst[i + 3] = src[i + 3];
299
+ }
300
+ } else {
301
+ for (let i = 0;i < src.length; i++) {
302
+ dst[i] = lut[src[i]];
303
+ }
304
+ }
305
+ return { data: dst, width, height, channels };
306
+ }
307
+ registerFilterOp4("cpu", "contrast", (image, { amount }) => {
308
+ return CpuImage4.fromImageBinary(cpuContrast(image.getBinary(), amount));
309
+ });
310
+
311
+ // src/task/image/crop/crop.cpu.ts
312
+ import { CpuImage as CpuImage5, registerFilterOp as registerFilterOp5 } from "@workglow/util/media";
313
+ function cpuCrop(bin, left, top, width, height) {
314
+ const { data: src, width: srcW, height: srcH, channels } = bin;
315
+ if (srcW < 1 || srcH < 1) {
316
+ throw new RangeError("Cannot crop an empty image");
317
+ }
318
+ if (left < 0 || left >= srcW || top < 0 || top >= srcH) {
319
+ throw new RangeError("Crop origin is outside the source image bounds");
320
+ }
321
+ const w = Math.min(width, srcW - left);
322
+ const h = Math.min(height, srcH - top);
323
+ const dst = new Uint8ClampedArray(w * h * channels);
324
+ const rowBytes = w * channels;
325
+ for (let row = 0;row < h; row++) {
326
+ const srcOffset = ((top + row) * srcW + left) * channels;
327
+ const dstOffset = row * rowBytes;
328
+ dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
329
+ }
330
+ return { data: dst, width: w, height: h, channels };
331
+ }
332
+ registerFilterOp5("cpu", "crop", (image, { left, top, width, height }) => {
333
+ return CpuImage5.fromImageBinary(cpuCrop(image.getBinary(), left, top, width, height));
334
+ });
335
+
336
+ // src/task/image/flip/flip.cpu.ts
337
+ import { CpuImage as CpuImage6, registerFilterOp as registerFilterOp6 } from "@workglow/util/media";
338
+ function cpuFlip(bin, direction) {
339
+ const { data: src, width, height, channels } = bin;
340
+ const dst = new Uint8ClampedArray(src.length);
341
+ const rowBytes = width * channels;
342
+ if (direction === "vertical") {
343
+ for (let y = 0;y < height; y++) {
344
+ const srcOffset = y * rowBytes;
345
+ const dstOffset = (height - 1 - y) * rowBytes;
346
+ dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
347
+ }
348
+ } else {
349
+ for (let y = 0;y < height; y++) {
350
+ for (let x = 0;x < width; x++) {
351
+ const srcIdx = (y * width + x) * channels;
352
+ const dstIdx = (y * width + (width - 1 - x)) * channels;
353
+ for (let c = 0;c < channels; c++) {
354
+ dst[dstIdx + c] = src[srcIdx + c];
355
+ }
356
+ }
357
+ }
358
+ }
359
+ return { data: dst, width, height, channels };
360
+ }
361
+ registerFilterOp6("cpu", "flip", (image, { direction }) => {
362
+ return CpuImage6.fromImageBinary(cpuFlip(image.getBinary(), direction));
363
+ });
364
+
365
+ // src/task/image/grayscale/grayscale.cpu.ts
366
+ import { CpuImage as CpuImage7, registerFilterOp as registerFilterOp7 } from "@workglow/util/media";
367
+ function cpuGrayscale(bin) {
368
+ const { data: src, width, height, channels } = bin;
369
+ const pixelCount = width * height;
370
+ const dst = new Uint8ClampedArray(pixelCount * 4);
371
+ for (let i = 0;i < pixelCount; i++) {
372
+ const idx = i * channels;
373
+ let g;
374
+ if (channels === 1) {
375
+ g = src[idx];
376
+ } else {
377
+ g = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
378
+ }
379
+ const a = channels === 4 ? src[idx + 3] : 255;
380
+ const dstIdx = i * 4;
381
+ dst[dstIdx] = g;
382
+ dst[dstIdx + 1] = g;
383
+ dst[dstIdx + 2] = g;
384
+ dst[dstIdx + 3] = a;
385
+ }
386
+ return { data: dst, width, height, channels: 4 };
387
+ }
388
+ registerFilterOp7("cpu", "grayscale", (image, _params) => {
389
+ return CpuImage7.fromImageBinary(cpuGrayscale(image.getBinary()));
390
+ });
391
+
392
+ // src/task/image/invert/invert.cpu.ts
393
+ import { CpuImage as CpuImage8, registerFilterOp as registerFilterOp8 } from "@workglow/util/media";
394
+ function cpuInvert(bin) {
395
+ const { data: src, width, height, channels } = bin;
396
+ const dst = new Uint8ClampedArray(src.length);
397
+ if (channels === 4) {
398
+ for (let i = 0;i < src.length; i += 4) {
399
+ dst[i] = 255 - src[i];
400
+ dst[i + 1] = 255 - src[i + 1];
401
+ dst[i + 2] = 255 - src[i + 2];
402
+ dst[i + 3] = src[i + 3];
403
+ }
404
+ } else {
405
+ for (let i = 0;i < src.length; i++) {
406
+ dst[i] = 255 - src[i];
407
+ }
408
+ }
409
+ return { data: dst, width, height, channels };
410
+ }
411
+ registerFilterOp8("cpu", "invert", (image, _params) => {
412
+ return CpuImage8.fromImageBinary(cpuInvert(image.getBinary()));
413
+ });
414
+
415
+ // src/task/image/pixelate/pixelate.cpu.ts
416
+ import { CpuImage as CpuImage9, registerFilterOp as registerFilterOp9 } from "@workglow/util/media";
417
+ function cpuPixelate(bin, blockSize) {
418
+ const { data: src, width, height, channels } = bin;
419
+ const dst = new Uint8ClampedArray(src.length);
420
+ for (let by = 0;by < height; by += blockSize) {
421
+ const blockH = Math.min(blockSize, height - by);
422
+ for (let bx = 0;bx < width; bx += blockSize) {
423
+ const blockW = Math.min(blockSize, width - bx);
424
+ const blockArea = blockW * blockH;
425
+ const sums = new Array(channels).fill(0);
426
+ for (let y = by;y < by + blockH; y++) {
427
+ for (let x = bx;x < bx + blockW; x++) {
428
+ const idx = (y * width + x) * channels;
429
+ for (let c = 0;c < channels; c++) {
430
+ sums[c] += src[idx + c];
431
+ }
432
+ }
433
+ }
434
+ const avg = sums.map((s) => s / blockArea + 0.5 | 0);
435
+ for (let y = by;y < by + blockH; y++) {
436
+ for (let x = bx;x < bx + blockW; x++) {
437
+ const idx = (y * width + x) * channels;
438
+ for (let c = 0;c < channels; c++) {
439
+ dst[idx + c] = avg[c];
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }
445
+ return { data: dst, width, height, channels };
446
+ }
447
+ registerFilterOp9("cpu", "pixelate", (image, { blockSize }) => {
448
+ return CpuImage9.fromImageBinary(cpuPixelate(image.getBinary(), blockSize));
449
+ });
450
+
451
+ // src/task/image/posterize/posterize.cpu.ts
452
+ import { CpuImage as CpuImage10, registerFilterOp as registerFilterOp10 } from "@workglow/util/media";
453
+ function cpuPosterize(bin, levels) {
454
+ const { data: src, width, height, channels } = bin;
455
+ const step = 255 / (levels - 1);
456
+ const lut = new Uint8ClampedArray(256);
457
+ for (let i = 0;i < 256; i++) {
458
+ lut[i] = Math.round(Math.round(i / step) * step);
459
+ }
460
+ const dst = new Uint8ClampedArray(src.length);
461
+ if (channels === 4) {
462
+ for (let i = 0;i < src.length; i += 4) {
463
+ dst[i] = lut[src[i]];
464
+ dst[i + 1] = lut[src[i + 1]];
465
+ dst[i + 2] = lut[src[i + 2]];
466
+ dst[i + 3] = src[i + 3];
467
+ }
468
+ } else {
469
+ for (let i = 0;i < src.length; i++) {
470
+ dst[i] = lut[src[i]];
471
+ }
472
+ }
473
+ return { data: dst, width, height, channels };
474
+ }
475
+ registerFilterOp10("cpu", "posterize", (image, { levels }) => {
476
+ return CpuImage10.fromImageBinary(cpuPosterize(image.getBinary(), levels));
477
+ });
478
+
479
+ // src/task/image/resize/resize.cpu.ts
480
+ import { CpuImage as CpuImage11, registerFilterOp as registerFilterOp11 } from "@workglow/util/media";
481
+ function cpuResize(bin, dstW, dstH) {
482
+ const { data: src, width: srcW, height: srcH, channels } = bin;
483
+ const dst = new Uint8ClampedArray(dstW * dstH * channels);
484
+ for (let dy = 0;dy < dstH; dy++) {
485
+ const srcY = Math.min(Math.floor(dy * srcH / dstH), srcH - 1);
486
+ for (let dx = 0;dx < dstW; dx++) {
487
+ const srcX = Math.min(Math.floor(dx * srcW / dstW), srcW - 1);
488
+ const srcIdx = (srcY * srcW + srcX) * channels;
489
+ const dstIdx = (dy * dstW + dx) * channels;
490
+ for (let c = 0;c < channels; c++) {
491
+ dst[dstIdx + c] = src[srcIdx + c];
492
+ }
493
+ }
494
+ }
495
+ return { data: dst, width: dstW, height: dstH, channels };
496
+ }
497
+ registerFilterOp11("cpu", "resize", (image, { width, height }) => {
498
+ return CpuImage11.fromImageBinary(cpuResize(image.getBinary(), width, height));
499
+ });
500
+
501
+ // src/task/image/rotate/rotate.cpu.ts
502
+ import { CpuImage as CpuImage12, registerFilterOp as registerFilterOp12 } from "@workglow/util/media";
503
+ function cpuRotate(bin, angle) {
504
+ const { data: src, width: srcW, height: srcH, channels } = bin;
505
+ const swap = angle === 90 || angle === 270;
506
+ const dstW = swap ? srcH : srcW;
507
+ const dstH = swap ? srcW : srcH;
508
+ const dst = new Uint8ClampedArray(dstW * dstH * channels);
509
+ for (let sy = 0;sy < srcH; sy++) {
510
+ for (let sx = 0;sx < srcW; sx++) {
511
+ let dx, dy;
512
+ if (angle === 90) {
513
+ dx = srcH - 1 - sy;
514
+ dy = sx;
515
+ } else if (angle === 180) {
516
+ dx = srcW - 1 - sx;
517
+ dy = srcH - 1 - sy;
518
+ } else {
519
+ dx = sy;
520
+ dy = srcW - 1 - sx;
521
+ }
522
+ const srcIdx = (sy * srcW + sx) * channels;
523
+ const dstIdx = (dy * dstW + dx) * channels;
524
+ for (let c = 0;c < channels; c++) {
525
+ dst[dstIdx + c] = src[srcIdx + c];
526
+ }
527
+ }
528
+ }
529
+ return { data: dst, width: dstW, height: dstH, channels };
530
+ }
531
+ registerFilterOp12("cpu", "rotate", (image, { angle }) => {
532
+ return CpuImage12.fromImageBinary(cpuRotate(image.getBinary(), angle));
533
+ });
534
+
535
+ // src/task/image/sepia/sepia.cpu.ts
536
+ import { CpuImage as CpuImage13, registerFilterOp as registerFilterOp13 } from "@workglow/util/media";
537
+ function cpuSepia(bin) {
538
+ const { data: src, width, height, channels } = bin;
539
+ const dst = new Uint8ClampedArray(src.length);
540
+ const pixelCount = width * height;
541
+ for (let i = 0;i < pixelCount; i++) {
542
+ const idx = i * channels;
543
+ const r = src[idx];
544
+ const g = channels === 1 ? r : src[idx + 1];
545
+ const b = channels === 1 ? r : src[idx + 2];
546
+ const outR = r * 402 + g * 787 + b * 194 >> 10;
547
+ const outG = r * 357 + g * 702 + b * 172 >> 10;
548
+ const outB = r * 279 + g * 547 + b * 134 >> 10;
549
+ dst[idx] = outR > 255 ? 255 : outR;
550
+ if (channels >= 3) {
551
+ dst[idx + 1] = outG > 255 ? 255 : outG;
552
+ dst[idx + 2] = outB > 255 ? 255 : outB;
553
+ }
554
+ if (channels === 4) {
555
+ dst[idx + 3] = src[idx + 3];
556
+ }
557
+ }
558
+ return { data: dst, width, height, channels };
559
+ }
560
+ registerFilterOp13("cpu", "sepia", (image, _params) => {
561
+ return CpuImage13.fromImageBinary(cpuSepia(image.getBinary()));
562
+ });
563
+
564
+ // src/task/image/threshold/threshold.cpu.ts
565
+ import { CpuImage as CpuImage14, registerFilterOp as registerFilterOp14 } from "@workglow/util/media";
566
+ function cpuThreshold(bin, value) {
567
+ const { data: src, width, height, channels } = bin;
568
+ const pixelCount = width * height;
569
+ const dst = new Uint8ClampedArray(pixelCount * channels);
570
+ for (let i = 0;i < pixelCount; i++) {
571
+ const idx = i * channels;
572
+ if (channels === 1) {
573
+ dst[idx] = src[idx] >= value ? 255 : 0;
574
+ } else {
575
+ dst[idx] = src[idx] >= value ? 255 : 0;
576
+ dst[idx + 1] = src[idx + 1] >= value ? 255 : 0;
577
+ dst[idx + 2] = src[idx + 2] >= value ? 255 : 0;
578
+ if (channels === 4) {
579
+ dst[idx + 3] = src[idx + 3];
580
+ }
581
+ }
582
+ }
583
+ return { data: dst, width, height, channels };
584
+ }
585
+ registerFilterOp14("cpu", "threshold", (image, { value }) => {
586
+ return CpuImage14.fromImageBinary(cpuThreshold(image.getBinary(), value));
587
+ });
588
+
589
+ // src/task/image/tint/tint.cpu.ts
590
+ import {
591
+ CpuImage as CpuImage15,
592
+ registerFilterOp as registerFilterOp15,
593
+ resolveColor as resolveColor2
594
+ } from "@workglow/util/media";
595
+ function cpuTint(bin, tr, tg, tb, amount) {
596
+ const { data: src, width, height, channels } = bin;
597
+ const invAmount = 1 - amount;
598
+ const tintR = tr * amount;
599
+ const tintG = tg * amount;
600
+ const tintB = tb * amount;
601
+ const pixelCount = width * height;
602
+ if (channels === 1) {
603
+ const dst2 = new Uint8ClampedArray(pixelCount * 3);
604
+ for (let i = 0;i < pixelCount; i++) {
605
+ const gray = src[i];
606
+ dst2[i * 3] = gray * invAmount + tintR;
607
+ dst2[i * 3 + 1] = gray * invAmount + tintG;
608
+ dst2[i * 3 + 2] = gray * invAmount + tintB;
609
+ }
610
+ return { data: dst2, width, height, channels: 3 };
611
+ }
612
+ const dst = new Uint8ClampedArray(src.length);
613
+ for (let i = 0;i < pixelCount; i++) {
614
+ const idx = i * channels;
615
+ dst[idx] = src[idx] * invAmount + tintR;
616
+ dst[idx + 1] = src[idx + 1] * invAmount + tintG;
617
+ dst[idx + 2] = src[idx + 2] * invAmount + tintB;
618
+ if (channels === 4) {
619
+ dst[idx + 3] = src[idx + 3];
620
+ }
621
+ }
622
+ return { data: dst, width, height, channels };
623
+ }
624
+ registerFilterOp15("cpu", "tint", (image, { color, amount }) => {
625
+ const { r: tr, g: tg, b: tb } = resolveColor2(color);
626
+ return CpuImage15.fromImageBinary(cpuTint(image.getBinary(), tr, tg, tb, amount));
627
+ });
628
+
629
+ // src/task/image/transparency/transparency.cpu.ts
630
+ import { CpuImage as CpuImage16, registerFilterOp as registerFilterOp16 } from "@workglow/util/media";
631
+ function cpuTransparency(bin, amount) {
632
+ const { data: src, width, height, channels: srcCh } = bin;
633
+ const pixelCount = width * height;
634
+ const dst = new Uint8ClampedArray(pixelCount * 4);
635
+ const alphaScale = Math.round(amount * 255);
636
+ for (let i = 0;i < pixelCount; i++) {
637
+ const srcIdx = i * srcCh;
638
+ const dstIdx = i * 4;
639
+ dst[dstIdx] = src[srcIdx];
640
+ dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
641
+ dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
642
+ const srcAlpha = srcCh === 4 ? src[srcIdx + 3] : 255;
643
+ dst[dstIdx + 3] = (srcAlpha * alphaScale + 127) / 255;
644
+ }
645
+ return { data: dst, width, height, channels: 4 };
646
+ }
647
+ registerFilterOp16("cpu", "transparency", (image, { amount }) => {
648
+ return CpuImage16.fromImageBinary(cpuTransparency(image.getBinary(), amount));
649
+ });
650
+
651
+ // src/task/image/blur/blur.webgpu.ts
652
+ import { registerFilterOp as registerFilterOp17, VERTEX_PRELUDE } from "@workglow/util/media";
653
+ var SHADER_SRC = `${VERTEX_PRELUDE}
654
+ struct U { radius: u32, direction: u32, width: f32, height: f32 };
655
+ @group(0) @binding(2) var<uniform> u: U;
656
+
657
+ @fragment
658
+ fn fs(in: VsOut) -> @location(0) vec4f {
659
+ let r = i32(u.radius);
660
+ var sum = vec4f(0.0);
661
+ let texel = vec2f(1.0 / u.width, 1.0 / u.height);
662
+ // direction: 0 = horizontal, 1 = vertical.
663
+ let dir = select(vec2f(0.0, texel.y), vec2f(texel.x, 0.0), u.direction == 0u);
664
+ for (var k: i32 = -r; k <= r; k = k + 1) {
665
+ let uv = clamp(in.uv + dir * f32(k), vec2f(0.0), vec2f(1.0));
666
+ sum = sum + textureSample(src, src_sampler, uv);
667
+ }
668
+ let n = f32(2 * r + 1);
669
+ return sum / n;
670
+ }
671
+ `;
672
+ function makeUniforms(radius, direction, width, height) {
673
+ const buf = new ArrayBuffer(16);
674
+ const u = new Uint32Array(buf, 0, 2);
675
+ u[0] = Math.max(1, radius | 0);
676
+ u[1] = direction;
677
+ const f = new Float32Array(buf, 8, 2);
678
+ f[0] = width;
679
+ f[1] = height;
680
+ return buf;
681
+ }
682
+ registerFilterOp17("webgpu", "blur", (image, { radius }) => {
683
+ const w = image.width;
684
+ const h = image.height;
685
+ const horiz = image.apply({
686
+ shader: SHADER_SRC,
687
+ uniforms: makeUniforms(radius, 0, w, h)
688
+ });
689
+ const vert = horiz.apply({ shader: SHADER_SRC, uniforms: makeUniforms(radius, 1, w, h) });
690
+ horiz.release();
691
+ return vert;
692
+ });
693
+
694
+ // src/task/image/border/border.webgpu.ts
695
+ import { VERTEX_PRELUDE as VERTEX_PRELUDE2, registerFilterOp as registerFilterOp18, resolveColor as resolveColor3 } from "@workglow/util/media";
696
+ var SHADER_SRC2 = `${VERTEX_PRELUDE2}
697
+ struct U { color: vec4f, borderWidth: f32, srcWidth: f32, srcHeight: f32, _pad: f32 };
698
+ @group(0) @binding(2) var<uniform> u: U;
699
+
700
+ @fragment
701
+ fn fs(in: VsOut) -> @location(0) vec4f {
702
+ let outW = u.srcWidth + 2.0 * u.borderWidth;
703
+ let outH = u.srcHeight + 2.0 * u.borderWidth;
704
+ let px = in.uv.x * outW;
705
+ let py = in.uv.y * outH;
706
+ let inside = px >= u.borderWidth && px < (u.borderWidth + u.srcWidth)
707
+ && py >= u.borderWidth && py < (u.borderWidth + u.srcHeight);
708
+ if (!inside) {
709
+ return u.color;
710
+ }
711
+ let sx = (px - u.borderWidth) / u.srcWidth;
712
+ let sy = (py - u.borderWidth) / u.srcHeight;
713
+ return textureSample(src, src_sampler, vec2f(sx, sy));
714
+ }
715
+ `;
716
+ registerFilterOp18("webgpu", "border", (image, { borderWidth, color }) => {
717
+ const w = image.width;
718
+ const h = image.height;
719
+ const c = resolveColor3(color);
720
+ const buf = new ArrayBuffer(32);
721
+ const f = new Float32Array(buf);
722
+ f[0] = c.r / 255;
723
+ f[1] = c.g / 255;
724
+ f[2] = c.b / 255;
725
+ f[3] = c.a / 255;
726
+ f[4] = borderWidth;
727
+ f[5] = w;
728
+ f[6] = h;
729
+ return image.apply({
730
+ shader: SHADER_SRC2,
731
+ uniforms: buf,
732
+ outSize: { width: w + 2 * borderWidth, height: h + 2 * borderWidth }
733
+ });
734
+ });
735
+
736
+ // src/task/image/brightness/brightness.webgpu.ts
737
+ import { registerFilterOp as registerFilterOp19, VERTEX_PRELUDE as VERTEX_PRELUDE3 } from "@workglow/util/media";
738
+ var SHADER_SRC3 = `${VERTEX_PRELUDE3}
739
+ struct U { amount: f32 };
740
+ @group(0) @binding(2) var<uniform> u: U;
741
+
742
+ @fragment
743
+ fn fs(in: VsOut) -> @location(0) vec4f {
744
+ let s = textureSample(src, src_sampler, in.uv);
745
+ let d = u.amount / 255.0;
746
+ return vec4f(clamp(s.rgb + vec3f(d), vec3f(0.0), vec3f(1.0)), s.a);
747
+ }
748
+ `;
749
+ registerFilterOp19("webgpu", "brightness", (image, { amount }) => {
750
+ const buf = new ArrayBuffer(16);
751
+ new Float32Array(buf, 0, 1)[0] = amount;
752
+ return image.apply({ shader: SHADER_SRC3, uniforms: buf });
753
+ });
754
+
755
+ // src/task/image/contrast/contrast.webgpu.ts
756
+ import { registerFilterOp as registerFilterOp20, VERTEX_PRELUDE as VERTEX_PRELUDE4 } from "@workglow/util/media";
757
+ var SHADER_SRC4 = `${VERTEX_PRELUDE4}
758
+ struct U { amount: f32 };
759
+ @group(0) @binding(2) var<uniform> u: U;
760
+
761
+ @fragment
762
+ fn fs(in: VsOut) -> @location(0) vec4f {
763
+ let s = textureSample(src, src_sampler, in.uv);
764
+ // Standard "GIMP" contrast curve, matching cpuContrast.
765
+ let factor = (259.0 * (u.amount + 255.0)) / (255.0 * (259.0 - u.amount));
766
+ let rgb = factor * (s.rgb - vec3f(0.5)) + vec3f(0.5);
767
+ return vec4f(clamp(rgb, vec3f(0.0), vec3f(1.0)), s.a);
768
+ }
769
+ `;
770
+ registerFilterOp20("webgpu", "contrast", (image, { amount }) => {
771
+ const buf = new ArrayBuffer(16);
772
+ new Float32Array(buf, 0, 1)[0] = amount;
773
+ return image.apply({ shader: SHADER_SRC4, uniforms: buf });
774
+ });
775
+
776
+ // src/task/image/crop/crop.webgpu.ts
777
+ import { registerFilterOp as registerFilterOp21, VERTEX_PRELUDE as VERTEX_PRELUDE5 } from "@workglow/util/media";
778
+ var SHADER_SRC5 = `${VERTEX_PRELUDE5}
779
+ struct U { left: f32, top: f32, srcWidth: f32, srcHeight: f32, outWidth: f32, outHeight: f32 };
780
+ @group(0) @binding(2) var<uniform> u: U;
781
+
782
+ @fragment
783
+ fn fs(in: VsOut) -> @location(0) vec4f {
784
+ let px = u.left + in.uv.x * u.outWidth;
785
+ let py = u.top + in.uv.y * u.outHeight;
786
+ let uv = vec2f(px / u.srcWidth, py / u.srcHeight);
787
+ return textureSample(src, src_sampler, uv);
788
+ }
789
+ `;
790
+ registerFilterOp21("webgpu", "crop", (image, { left, top, width, height }) => {
791
+ const w = image.width;
792
+ const h = image.height;
793
+ const buf = new ArrayBuffer(32);
794
+ const f = new Float32Array(buf);
795
+ f[0] = left;
796
+ f[1] = top;
797
+ f[2] = w;
798
+ f[3] = h;
799
+ f[4] = width;
800
+ f[5] = height;
801
+ return image.apply({
802
+ shader: SHADER_SRC5,
803
+ uniforms: buf,
804
+ outSize: { width, height }
805
+ });
806
+ });
807
+
808
+ // src/task/image/flip/flip.webgpu.ts
809
+ import { registerFilterOp as registerFilterOp22, VERTEX_PRELUDE as VERTEX_PRELUDE6 } from "@workglow/util/media";
810
+ var SHADER_SRC6 = `${VERTEX_PRELUDE6}
811
+ struct U { direction: u32 };
812
+ @group(0) @binding(2) var<uniform> u: U;
813
+
814
+ @fragment
815
+ fn fs(in: VsOut) -> @location(0) vec4f {
816
+ // direction: 0 = horizontal (flip x), 1 = vertical (flip y).
817
+ let flipX = u.direction == 0u;
818
+ let flipY = u.direction == 1u;
819
+ let uv = vec2f(
820
+ select(in.uv.x, 1.0 - in.uv.x, flipX),
821
+ select(in.uv.y, 1.0 - in.uv.y, flipY),
822
+ );
823
+ return textureSample(src, src_sampler, uv);
824
+ }
825
+ `;
826
+ var DIRECTION_TO_CODE = { horizontal: 0, vertical: 1 };
827
+ registerFilterOp22("webgpu", "flip", (image, { direction }) => {
828
+ const buf = new ArrayBuffer(16);
829
+ new Uint32Array(buf, 0, 1)[0] = DIRECTION_TO_CODE[direction];
830
+ return image.apply({ shader: SHADER_SRC6, uniforms: buf });
831
+ });
832
+
833
+ // src/task/image/grayscale/grayscale.webgpu.ts
834
+ import { registerFilterOp as registerFilterOp23, VERTEX_PRELUDE as VERTEX_PRELUDE7 } from "@workglow/util/media";
835
+ var SHADER_SRC7 = `${VERTEX_PRELUDE7}
836
+ @fragment
837
+ fn fs(in: VsOut) -> @location(0) vec4f {
838
+ let s = textureSample(src, src_sampler, in.uv);
839
+ // Match cpuGrayscale's BT.601-ish (77,150,29)/256 weights.
840
+ let g = (s.r * 77.0 + s.g * 150.0 + s.b * 29.0) / 256.0;
841
+ return vec4f(g, g, g, s.a);
842
+ }
843
+ `;
844
+ registerFilterOp23("webgpu", "grayscale", (image, _params) => {
845
+ return image.apply({ shader: SHADER_SRC7, uniforms: undefined });
846
+ });
847
+
848
+ // src/task/image/invert/invert.webgpu.ts
849
+ import { registerFilterOp as registerFilterOp24, VERTEX_PRELUDE as VERTEX_PRELUDE8 } from "@workglow/util/media";
850
+ var SHADER_SRC8 = `${VERTEX_PRELUDE8}
851
+ @fragment
852
+ fn fs(in: VsOut) -> @location(0) vec4f {
853
+ let s = textureSample(src, src_sampler, in.uv);
854
+ return vec4f(1.0 - s.rgb, s.a);
855
+ }
856
+ `;
857
+ registerFilterOp24("webgpu", "invert", (image, _params) => {
858
+ return image.apply({ shader: SHADER_SRC8, uniforms: undefined });
859
+ });
860
+
861
+ // src/task/image/pixelate/pixelate.webgpu.ts
862
+ import { registerFilterOp as registerFilterOp25, VERTEX_PRELUDE as VERTEX_PRELUDE9 } from "@workglow/util/media";
863
+ var SHADER_SRC9 = `${VERTEX_PRELUDE9}
864
+ struct U { blockSize: u32, width: u32, height: u32, _pad: u32 };
865
+ @group(0) @binding(2) var<uniform> u: U;
866
+
867
+ @fragment
868
+ fn fs(in: VsOut) -> @location(0) vec4f {
869
+ let px = u32(in.uv.x * f32(u.width));
870
+ let py = u32(in.uv.y * f32(u.height));
871
+ let bx = px / u.blockSize;
872
+ let by = py / u.blockSize;
873
+ let startX = bx * u.blockSize;
874
+ let startY = by * u.blockSize;
875
+ let endX = min(startX + u.blockSize, u.width);
876
+ let endY = min(startY + u.blockSize, u.height);
877
+
878
+ let invW = 1.0 / f32(u.width);
879
+ let invH = 1.0 / f32(u.height);
880
+
881
+ var sum = vec4f(0.0);
882
+ var count: f32 = 0.0;
883
+ for (var sy: u32 = startY; sy < endY; sy = sy + 1u) {
884
+ for (var sx: u32 = startX; sx < endX; sx = sx + 1u) {
885
+ // Sample at exact texel center. With a linear sampler, the bilinear
886
+ // weight collapses to 1.0 on this texel, giving a lossless read.
887
+ let suv = vec2f((f32(sx) + 0.5) * invW, (f32(sy) + 0.5) * invH);
888
+ sum = sum + textureSampleLevel(src, src_sampler, suv, 0.0);
889
+ count = count + 1.0;
890
+ }
891
+ }
892
+ return sum / count;
893
+ }
894
+ `;
895
+ registerFilterOp25("webgpu", "pixelate", (image, { blockSize }) => {
896
+ const w = image.width;
897
+ const h = image.height;
898
+ const buf = new ArrayBuffer(16);
899
+ const u = new Uint32Array(buf);
900
+ u[0] = Math.max(1, blockSize | 0);
901
+ u[1] = w;
902
+ u[2] = h;
903
+ return image.apply({ shader: SHADER_SRC9, uniforms: buf });
904
+ });
905
+
906
+ // src/task/image/posterize/posterize.webgpu.ts
907
+ import { registerFilterOp as registerFilterOp26, VERTEX_PRELUDE as VERTEX_PRELUDE10 } from "@workglow/util/media";
908
+ var SHADER_SRC10 = `${VERTEX_PRELUDE10}
909
+ struct U { levels: f32 };
910
+ @group(0) @binding(2) var<uniform> u: U;
911
+
912
+ @fragment
913
+ fn fs(in: VsOut) -> @location(0) vec4f {
914
+ let s = textureSample(src, src_sampler, in.uv);
915
+ let n = max(u.levels, 2.0);
916
+ // Round-to-nearest quantization, matching cpuPosterize's LUT semantics.
917
+ let q = round(s.rgb * (n - 1.0)) / (n - 1.0);
918
+ return vec4f(clamp(q, vec3f(0.0), vec3f(1.0)), s.a);
919
+ }
920
+ `;
921
+ registerFilterOp26("webgpu", "posterize", (image, { levels }) => {
922
+ const buf = new ArrayBuffer(16);
923
+ new Float32Array(buf, 0, 1)[0] = levels;
924
+ return image.apply({ shader: SHADER_SRC10, uniforms: buf });
925
+ });
926
+
927
+ // src/task/image/resize/resize.webgpu.ts
928
+ import { registerFilterOp as registerFilterOp27, VERTEX_PRELUDE as VERTEX_PRELUDE11 } from "@workglow/util/media";
929
+ var SHADER_SRC11 = `${VERTEX_PRELUDE11}
930
+ @fragment
931
+ fn fs(in: VsOut) -> @location(0) vec4f {
932
+ return textureSample(src, src_sampler, in.uv);
933
+ }
934
+ `;
935
+ registerFilterOp27("webgpu", "resize", (image, { width, height }) => {
936
+ return image.apply({
937
+ shader: SHADER_SRC11,
938
+ uniforms: undefined,
939
+ outSize: { width, height }
940
+ });
941
+ });
942
+
943
+ // src/task/image/rotate/rotate.webgpu.ts
944
+ import { registerFilterOp as registerFilterOp28, VERTEX_PRELUDE as VERTEX_PRELUDE12 } from "@workglow/util/media";
945
+ var SHADER_SRC12 = `${VERTEX_PRELUDE12}
946
+ struct U { angle: u32 };
947
+ @group(0) @binding(2) var<uniform> u: U;
948
+
949
+ @fragment
950
+ fn fs(in: VsOut) -> @location(0) vec4f {
951
+ // Map output uv back to source uv via inverse rotation.
952
+ var srcUv = in.uv;
953
+ if (u.angle == 90u) {
954
+ srcUv = vec2f(in.uv.y, 1.0 - in.uv.x);
955
+ } else if (u.angle == 180u) {
956
+ srcUv = vec2f(1.0 - in.uv.x, 1.0 - in.uv.y);
957
+ } else if (u.angle == 270u) {
958
+ srcUv = vec2f(1.0 - in.uv.y, in.uv.x);
959
+ }
960
+ return textureSample(src, src_sampler, srcUv);
961
+ }
962
+ `;
963
+ registerFilterOp28("webgpu", "rotate", (image, { angle }) => {
964
+ const w = image.width;
965
+ const h = image.height;
966
+ const swap = angle === 90 || angle === 270;
967
+ const buf = new ArrayBuffer(16);
968
+ new Uint32Array(buf, 0, 1)[0] = angle;
969
+ return image.apply({
970
+ shader: SHADER_SRC12,
971
+ uniforms: buf,
972
+ outSize: { width: swap ? h : w, height: swap ? w : h }
973
+ });
974
+ });
975
+
976
+ // src/task/image/sepia/sepia.webgpu.ts
977
+ import { registerFilterOp as registerFilterOp29, VERTEX_PRELUDE as VERTEX_PRELUDE13 } from "@workglow/util/media";
978
+ var SHADER_SRC13 = `${VERTEX_PRELUDE13}
979
+ @fragment
980
+ fn fs(in: VsOut) -> @location(0) vec4f {
981
+ let s = textureSample(src, src_sampler, in.uv);
982
+ let r = s.r * 0.393 + s.g * 0.769 + s.b * 0.189;
983
+ let g = s.r * 0.349 + s.g * 0.686 + s.b * 0.168;
984
+ let b = s.r * 0.272 + s.g * 0.534 + s.b * 0.131;
985
+ return vec4f(clamp(r, 0.0, 1.0), clamp(g, 0.0, 1.0), clamp(b, 0.0, 1.0), s.a);
986
+ }
987
+ `;
988
+ registerFilterOp29("webgpu", "sepia", (image, _params) => {
989
+ return image.apply({ shader: SHADER_SRC13, uniforms: undefined });
990
+ });
991
+
992
+ // src/task/image/threshold/threshold.webgpu.ts
993
+ import { registerFilterOp as registerFilterOp30, VERTEX_PRELUDE as VERTEX_PRELUDE14 } from "@workglow/util/media";
994
+ var SHADER_SRC14 = `${VERTEX_PRELUDE14}
995
+ struct U { value: f32 };
996
+ @group(0) @binding(2) var<uniform> u: U;
997
+
998
+ @fragment
999
+ fn fs(in: VsOut) -> @location(0) vec4f {
1000
+ let s = textureSample(src, src_sampler, in.uv);
1001
+ let v = u.value / 255.0;
1002
+ // Per-channel binary threshold to match cpuThreshold (each of R/G/B
1003
+ // compared independently); alpha preserved.
1004
+ let r = select(0.0, 1.0, s.r >= v);
1005
+ let g = select(0.0, 1.0, s.g >= v);
1006
+ let b = select(0.0, 1.0, s.b >= v);
1007
+ return vec4f(r, g, b, s.a);
1008
+ }
1009
+ `;
1010
+ registerFilterOp30("webgpu", "threshold", (image, { value }) => {
1011
+ const buf = new ArrayBuffer(16);
1012
+ new Float32Array(buf, 0, 1)[0] = value;
1013
+ return image.apply({ shader: SHADER_SRC14, uniforms: buf });
1014
+ });
1015
+
1016
+ // src/task/image/tint/tint.webgpu.ts
1017
+ import { VERTEX_PRELUDE as VERTEX_PRELUDE15, registerFilterOp as registerFilterOp31, resolveColor as resolveColor4 } from "@workglow/util/media";
1018
+ var SHADER_SRC15 = `${VERTEX_PRELUDE15}
1019
+ struct U { color: vec4f, amount: f32 };
1020
+ @group(0) @binding(2) var<uniform> u: U;
1021
+
1022
+ @fragment
1023
+ fn fs(in: VsOut) -> @location(0) vec4f {
1024
+ let s = textureSample(src, src_sampler, in.uv);
1025
+ let tinted = mix(s.rgb, u.color.rgb, u.amount);
1026
+ return vec4f(clamp(tinted, vec3f(0.0), vec3f(1.0)), s.a);
1027
+ }
1028
+ `;
1029
+ registerFilterOp31("webgpu", "tint", (image, { color, amount }) => {
1030
+ const c = resolveColor4(color);
1031
+ const buf = new ArrayBuffer(32);
1032
+ const f = new Float32Array(buf);
1033
+ f[0] = c.r / 255;
1034
+ f[1] = c.g / 255;
1035
+ f[2] = c.b / 255;
1036
+ f[3] = 1;
1037
+ f[4] = amount;
1038
+ return image.apply({ shader: SHADER_SRC15, uniforms: buf });
1039
+ });
1040
+
1041
+ // src/task/image/transparency/transparency.webgpu.ts
1042
+ import { registerFilterOp as registerFilterOp32, VERTEX_PRELUDE as VERTEX_PRELUDE16 } from "@workglow/util/media";
1043
+ var SHADER_SRC16 = `${VERTEX_PRELUDE16}
1044
+ struct U { amount: f32 };
1045
+ @group(0) @binding(2) var<uniform> u: U;
1046
+
1047
+ @fragment
1048
+ fn fs(in: VsOut) -> @location(0) vec4f {
1049
+ let s = textureSample(src, src_sampler, in.uv);
1050
+ return vec4f(s.rgb, s.a * u.amount);
1051
+ }
1052
+ `;
1053
+ registerFilterOp32("webgpu", "transparency", (image, { amount }) => {
1054
+ const buf = new ArrayBuffer(16);
1055
+ new Float32Array(buf, 0, 1)[0] = amount;
1056
+ return image.apply({ shader: SHADER_SRC16, uniforms: buf });
1057
+ });
1058
+
1059
+ // src/codec.browser.ts
1060
+ import { applyFilter, registerPreviewResizeFn } from "@workglow/util/media";
1061
+ registerPreviewResizeFn((image, width, height) => applyFilter(image, "resize", { width, height }));
1062
+
179
1063
  // src/task/image/imageTextRender.ts
180
1064
  import { createServiceToken, globalServiceRegistry } from "@workglow/util";
181
1065
  var IMAGE_TEXT_ANCHOR_POSITIONS = [
@@ -1746,11 +2630,11 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
1746
2630
  async executeTaskChildren(_input) {
1747
2631
  return super.executeTaskChildren({});
1748
2632
  }
1749
- async executeTaskChildrenReactive() {
1750
- return this.task.subGraph.runReactive({});
2633
+ async executeTaskChildrenPreview() {
2634
+ return this.task.subGraph.runPreview({});
1751
2635
  }
1752
- async executeTaskReactive(input, output) {
1753
- await super.executeTaskReactive(input, output);
2636
+ async executeTaskPreview(input) {
2637
+ await super.executeTaskPreview(input);
1754
2638
  if (this.task.hasChildren()) {
1755
2639
  this.task.runOutputData = this.task.executeMerge(input, this.task.runOutputData);
1756
2640
  }
@@ -4447,6 +5331,29 @@ import {
4447
5331
  Task as Task36,
4448
5332
  Workflow as Workflow11
4449
5333
  } from "@workglow/task-graph";
5334
+ function formatDate(input) {
5335
+ const dateInput = /^\d+$/.test(input.value) ? Number(input.value) : input.value;
5336
+ const date = new Date(dateInput);
5337
+ if (isNaN(date.getTime())) {
5338
+ throw new Error(`Invalid date: ${input.value}`);
5339
+ }
5340
+ const format = input.format ?? "iso";
5341
+ const locale = input.locale;
5342
+ const timeZone = input.timeZone;
5343
+ switch (format) {
5344
+ case "iso":
5345
+ return date.toISOString();
5346
+ case "date":
5347
+ return date.toLocaleDateString(locale, timeZone ? { timeZone } : undefined);
5348
+ case "time":
5349
+ return date.toLocaleTimeString(locale, timeZone ? { timeZone } : undefined);
5350
+ case "unix":
5351
+ return String(date.getTime());
5352
+ case "datetime":
5353
+ default:
5354
+ return date.toLocaleString(locale, timeZone ? { timeZone } : undefined);
5355
+ }
5356
+ }
4450
5357
  var inputSchema36 = {
4451
5358
  type: "object",
4452
5359
  properties: {
@@ -4501,35 +5408,11 @@ class DateFormatTask extends Task36 {
4501
5408
  static outputSchema() {
4502
5409
  return outputSchema36;
4503
5410
  }
4504
- async executeReactive(input, _output, _context) {
4505
- const dateInput = /^\d+$/.test(input.value) ? Number(input.value) : input.value;
4506
- const date = new Date(dateInput);
4507
- if (isNaN(date.getTime())) {
4508
- throw new Error(`Invalid date: ${input.value}`);
4509
- }
4510
- const format = input.format ?? "iso";
4511
- const locale = input.locale;
4512
- const timeZone = input.timeZone;
4513
- let result;
4514
- switch (format) {
4515
- case "iso":
4516
- result = date.toISOString();
4517
- break;
4518
- case "date":
4519
- result = date.toLocaleDateString(locale, timeZone ? { timeZone } : undefined);
4520
- break;
4521
- case "time":
4522
- result = date.toLocaleTimeString(locale, timeZone ? { timeZone } : undefined);
4523
- break;
4524
- case "unix":
4525
- result = String(date.getTime());
4526
- break;
4527
- case "datetime":
4528
- default:
4529
- result = date.toLocaleString(locale, timeZone ? { timeZone } : undefined);
4530
- break;
4531
- }
4532
- return { result };
5411
+ async execute(input, _context) {
5412
+ return { result: formatDate(input) };
5413
+ }
5414
+ async executePreview(input, _context) {
5415
+ return { result: formatDate(input) };
4533
5416
  }
4534
5417
  }
4535
5418
  Workflow11.prototype.dateFormat = CreateWorkflow10(DateFormatTask);
@@ -4561,6 +5444,17 @@ var outputSchema37 = {
4561
5444
  properties: {},
4562
5445
  additionalProperties: true
4563
5446
  };
5447
+ function logAndPassthrough(input, log_level) {
5448
+ const inputRecord = input;
5449
+ if (log_level === "dir") {
5450
+ console.dir(inputRecord, { depth: null });
5451
+ } else {
5452
+ console[log_level](inputRecord);
5453
+ }
5454
+ const output = {};
5455
+ Object.assign(output, inputRecord);
5456
+ return output;
5457
+ }
4564
5458
 
4565
5459
  class DebugLogTask extends Task37 {
4566
5460
  static type = "DebugLogTask";
@@ -4580,16 +5474,11 @@ class DebugLogTask extends Task37 {
4580
5474
  static outputSchema() {
4581
5475
  return outputSchema37;
4582
5476
  }
4583
- async executeReactive(input, output) {
4584
- const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
4585
- const inputRecord = input;
4586
- if (log_level === "dir") {
4587
- console.dir(inputRecord, { depth: null });
4588
- } else {
4589
- console[log_level](inputRecord);
4590
- }
4591
- Object.assign(output, inputRecord);
4592
- return output;
5477
+ async execute(input) {
5478
+ return logAndPassthrough(input, this.config.log_level ?? DEFAULT_LOG_LEVEL);
5479
+ }
5480
+ async executePreview(input) {
5481
+ return logAndPassthrough(input, this.config.log_level ?? DEFAULT_LOG_LEVEL);
4593
5482
  }
4594
5483
  }
4595
5484
  var debugLog = (input, config = {}) => {
@@ -5757,242 +6646,182 @@ ${input.prompt}` : input.prompt : this.config.message ?? "";
5757
6646
  }
5758
6647
  }
5759
6648
  Workflow16.prototype.humanInput = CreateWorkflow15(HumanInputTask);
5760
- // src/task/image/ImageBlurTask.ts
6649
+
6650
+ // src/common.ts
5761
6651
  import {
5762
- CreateWorkflow as CreateWorkflow16,
5763
- Task as Task42,
5764
- Workflow as Workflow17
5765
- } from "@workglow/task-graph";
6652
+ registerFilterOp as registerFilterOp33,
6653
+ applyFilter as applyFilter3,
6654
+ hasFilterOp as hasFilterOp2,
6655
+ _resetFilterRegistryForTests
6656
+ } from "@workglow/util/media";
5766
6657
 
5767
- // src/task/image/ImageSchemas.ts
5768
- import { FromSchemaDefaultOptions } from "@workglow/util/schema";
5769
- var ImageBinaryType = null;
5770
- var ImageBinarySchemaOptions = {
5771
- ...FromSchemaDefaultOptions,
5772
- deserialize: [
5773
- {
5774
- pattern: { type: "object", format: "image:ImageBinary" },
5775
- output: ImageBinaryType
6658
+ // src/task/image/ImageFilterTask.ts
6659
+ import {
6660
+ Task as Task42
6661
+ } from "@workglow/task-graph";
6662
+ import {
6663
+ applyFilter as applyFilter2,
6664
+ CpuImage as CpuImage17,
6665
+ GpuImageFactory,
6666
+ getGpuImageFactory,
6667
+ hasFilterOp,
6668
+ previewSource
6669
+ } from "@workglow/util/media";
6670
+
6671
+ class ImageFilterTask extends Task42 {
6672
+ scalePreviewParams(params, _scale) {
6673
+ return params;
6674
+ }
6675
+ async hydrateInput(image) {
6676
+ if (image !== null && typeof image === "object" && "backend" in image && "retain" in image && "release" in image && "materialize" in image) {
6677
+ return image;
6678
+ }
6679
+ if (typeof image === "string" && image.startsWith("data:")) {
6680
+ return GpuImageFactory.fromDataUri(image);
6681
+ }
6682
+ if (typeof Blob !== "undefined" && image instanceof Blob) {
6683
+ return GpuImageFactory.fromBlob(image);
6684
+ }
6685
+ if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
6686
+ const fromImageBitmap = getGpuImageFactory("fromImageBitmap");
6687
+ if (!fromImageBitmap) {
6688
+ throw new Error("ImageFilterTask: received ImageBitmap but GpuImage.fromImageBitmap is not registered " + "in this runtime. ImageBitmap inputs require the browser entry point.");
6689
+ }
6690
+ return fromImageBitmap(image);
6691
+ }
6692
+ if (image !== null && typeof image === "object" && "data" in image && "width" in image && "height" in image && "channels" in image) {
6693
+ const bin = image;
6694
+ const asyncFactory = getGpuImageFactory("fromImageBinaryAsync");
6695
+ if (asyncFactory)
6696
+ return asyncFactory(bin);
6697
+ return GpuImageFactory.fromImageBinary(bin);
6698
+ }
6699
+ const ctor = image && typeof image === "object" && image.constructor ? image.constructor.name : typeof image;
6700
+ const keys = image && typeof image === "object" ? Object.keys(image).slice(0, 10).join(", ") : "";
6701
+ throw new Error(`ImageFilterTask: input.image is not a recognized image shape (got ${ctor}` + (keys ? ` with keys [${keys}]` : "") + `). Expected one of: GpuImage instance, raw ImageBinary, Blob, ImageBitmap, ` + `or a data: URI string.`);
6702
+ }
6703
+ async execute(input, ctx) {
6704
+ let inputImage = await this.hydrateInput(input.image);
6705
+ if (!hasFilterOp(inputImage.backend, this.filterName)) {
6706
+ const bin = await inputImage.materialize();
6707
+ const cpu = CpuImage17.fromImageBinary(bin, inputImage.previewScale);
6708
+ inputImage.release();
6709
+ inputImage = cpu;
6710
+ }
6711
+ const params = this.scalePreviewParams(this.opParams(input), inputImage.previewScale);
6712
+ const out = applyFilter2(inputImage, this.filterName, params);
6713
+ inputImage.release();
6714
+ ctx.resourceScope?.register(`gpuimage:${String(this.id)}:image`, async () => out.release());
6715
+ return { image: out };
6716
+ }
6717
+ async executePreview(input, _ctx) {
6718
+ const inputImage = await this.hydrateInput(input.image);
6719
+ let sourced = previewSource(inputImage);
6720
+ if (!hasFilterOp(sourced.backend, this.filterName)) {
6721
+ const bin = await sourced.materialize();
6722
+ const cpu = CpuImage17.fromImageBinary(bin, sourced.previewScale);
6723
+ if (sourced !== inputImage)
6724
+ sourced.release();
6725
+ sourced = cpu;
6726
+ }
6727
+ const params = this.scalePreviewParams(this.opParams(input), sourced.previewScale);
6728
+ const out = applyFilter2(sourced, this.filterName, params);
6729
+ if (sourced !== inputImage)
6730
+ sourced.release();
6731
+ return { image: out };
6732
+ }
6733
+ }
6734
+ // src/task/image/blur/ImageBlurTask.ts
6735
+ import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow17 } from "@workglow/task-graph";
6736
+ import { GpuImageSchema } from "@workglow/util/media";
6737
+ var inputSchema41 = {
6738
+ type: "object",
6739
+ properties: {
6740
+ image: GpuImageSchema({ title: "Image", description: "Source image" }),
6741
+ radius: {
6742
+ type: "number",
6743
+ title: "Radius",
6744
+ description: "Blur radius (1-10)",
6745
+ minimum: 1,
6746
+ maximum: 10,
6747
+ default: 1
5776
6748
  }
5777
- ]
6749
+ },
6750
+ required: ["image"],
6751
+ additionalProperties: false
6752
+ };
6753
+ var outputSchema40 = {
6754
+ type: "object",
6755
+ properties: { image: GpuImageSchema({ title: "Image", description: "Blurred image" }) },
6756
+ required: ["image"],
6757
+ additionalProperties: false
5778
6758
  };
5779
- var ImageBinarySchema = (annotations = {}) => ({
6759
+
6760
+ class ImageBlurTask extends ImageFilterTask {
6761
+ static type = "ImageBlurTask";
6762
+ static category = "Image";
6763
+ static title = "Blur Image";
6764
+ static description = "Applies a box blur to an image";
6765
+ static inputSchema() {
6766
+ return inputSchema41;
6767
+ }
6768
+ static outputSchema() {
6769
+ return outputSchema40;
6770
+ }
6771
+ filterName = "blur";
6772
+ opParams(input) {
6773
+ return { radius: input.radius ?? 1 };
6774
+ }
6775
+ scalePreviewParams({ radius }, s) {
6776
+ return { radius: Math.max(1, Math.round(radius * s)) };
6777
+ }
6778
+ }
6779
+ Workflow17.prototype.imageBlur = CreateWorkflow16(ImageBlurTask);
6780
+ // src/task/image/border/ImageBorderTask.ts
6781
+ import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow18 } from "@workglow/task-graph";
6782
+ import { GpuImageSchema as GpuImageSchema2 } from "@workglow/util/media";
6783
+ var inputSchema42 = {
5780
6784
  type: "object",
5781
6785
  properties: {
5782
- data: {
5783
- type: "array",
5784
- items: { type: "number", format: "Uint8Clamped" },
5785
- format: "Uint8ClampedArray",
5786
- title: "Data",
5787
- description: "Pixel data of the image"
5788
- },
5789
- width: {
5790
- type: "integer",
5791
- minimum: 1,
5792
- title: "Width",
5793
- description: "Width in pixels"
5794
- },
5795
- height: {
6786
+ image: GpuImageSchema2({ title: "Image", description: "Source image" }),
6787
+ borderWidth: {
5796
6788
  type: "integer",
6789
+ title: "Border Width",
6790
+ description: "Border width in pixels",
5797
6791
  minimum: 1,
5798
- title: "Height",
5799
- description: "Height in pixels"
6792
+ default: 10
5800
6793
  },
5801
- channels: {
5802
- type: "integer",
5803
- enum: [1, 3, 4],
5804
- title: "Channels",
5805
- description: "1 (gray), 3 (RGB), or 4 (RGBA)"
5806
- }
5807
- },
5808
- additionalProperties: false,
5809
- required: ["data", "width", "height", "channels"],
5810
- format: "image:ImageBinary",
5811
- title: "Image",
5812
- description: "Raw pixel image data",
5813
- ...annotations
5814
- });
5815
- var ImageBinaryOrDataUriSchema = (annotations = {}) => ({
5816
- oneOf: [
5817
- ImageBinarySchema(annotations),
5818
- {
5819
- type: "string",
5820
- format: "image:data-uri",
5821
- title: annotations.title ?? "Image",
5822
- description: annotations.description ?? "Image as ImageBinary or data URI (data:image/png;base64,...)"
5823
- }
5824
- ]
5825
- });
5826
- var ColorSchema = (annotations = {}) => ({
5827
- type: "object",
5828
- properties: {
5829
- r: { type: "integer", minimum: 0, maximum: 255, title: "Red" },
5830
- g: { type: "integer", minimum: 0, maximum: 255, title: "Green" },
5831
- b: { type: "integer", minimum: 0, maximum: 255, title: "Blue" },
5832
- a: { type: "integer", minimum: 0, maximum: 255, title: "Alpha", default: 255 }
5833
- },
5834
- required: ["r", "g", "b"],
5835
- format: "color",
5836
- additionalProperties: false,
5837
- ...annotations
5838
- });
5839
- var HexColorSchema = (annotations = {}) => ({
5840
- type: "string",
5841
- format: "color",
5842
- pattern: "^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$",
5843
- title: "Color (hex)",
5844
- description: "Color as a `#RRGGBB[AA]` or `#RGB[A]` hex string",
5845
- ...annotations
5846
- });
5847
- var ColorValueSchema = (annotations = {}) => ({
5848
- oneOf: [
5849
- ColorSchema(),
5850
- HexColorSchema({
5851
- title: annotations.title ?? "Color",
5852
- description: annotations.description ?? "Color as {r,g,b,a} object or `#RRGGBB[AA]` / `#RGB[A]` hex string"
5853
- })
5854
- ],
5855
- ...annotations
5856
- });
5857
- var ColorObjectType = null;
5858
- var ColorFromSchemaOptions = {
5859
- ...FromSchemaDefaultOptions,
5860
- deserialize: [
5861
- {
5862
- pattern: { type: "object", format: "color" },
5863
- output: ColorObjectType
5864
- }
5865
- ]
5866
- };
5867
-
5868
- // src/task/image/imageTaskIo.ts
5869
- import { Image, getImageRasterCodec } from "@workglow/util/media";
5870
- async function produceImageOutput(inputImage, run) {
5871
- const image = Image.is(inputImage) ? inputImage : Image.from(inputImage);
5872
- const pixels = await image.getPixels();
5873
- const out = await run(pixels);
5874
- if (image.kind === "dataUri") {
5875
- const mime = image.mimeType ?? "image/png";
5876
- return getImageRasterCodec().encodeDataUri(out, mime);
5877
- }
5878
- return out;
5879
- }
5880
-
5881
- // src/task/image/ImageBlurTask.ts
5882
- var inputSchema41 = {
5883
- type: "object",
5884
- properties: {
5885
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
5886
- radius: {
5887
- type: "integer",
5888
- title: "Radius",
5889
- description: "Blur radius (1-10)",
5890
- minimum: 1,
5891
- maximum: 10,
5892
- default: 1
5893
- }
5894
- },
5895
- required: ["image"],
5896
- additionalProperties: false
5897
- };
5898
- var outputSchema40 = {
5899
- type: "object",
5900
- properties: {
5901
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Blurred image" })
5902
- },
5903
- required: ["image"],
5904
- additionalProperties: false
5905
- };
5906
-
5907
- class ImageBlurTask extends Task42 {
5908
- static type = "ImageBlurTask";
5909
- static category = "Image";
5910
- static title = "Blur Image";
5911
- static description = "Applies a box blur to an image";
5912
- static inputSchema() {
5913
- return inputSchema41;
5914
- }
5915
- static outputSchema() {
5916
- return outputSchema40;
5917
- }
5918
- async executeReactive(input, _output, _context) {
5919
- const { radius = 1 } = input;
5920
- const image = await produceImageOutput(input.image, (img) => {
5921
- const { data: src, width, height, channels } = img;
5922
- const kernelSize = radius * 2 + 1;
5923
- const tmp = new Uint8ClampedArray(src.length);
5924
- for (let y = 0;y < height; y++) {
5925
- for (let c = 0;c < channels; c++) {
5926
- let sum = 0;
5927
- for (let k = -radius;k <= radius; k++) {
5928
- const x = Math.max(0, Math.min(k, width - 1));
5929
- sum += src[(y * width + x) * channels + c];
5930
- }
5931
- tmp[y * width * channels + c] = sum / kernelSize + 0.5 | 0;
5932
- for (let x = 1;x < width; x++) {
5933
- const addX = Math.min(x + radius, width - 1);
5934
- const removeX = Math.max(x - radius - 1, 0);
5935
- sum += src[(y * width + addX) * channels + c] - src[(y * width + removeX) * channels + c];
5936
- tmp[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
5937
- }
5938
- }
5939
- }
5940
- const dst = new Uint8ClampedArray(src.length);
5941
- for (let x = 0;x < width; x++) {
5942
- for (let c = 0;c < channels; c++) {
5943
- let sum = 0;
5944
- for (let k = -radius;k <= radius; k++) {
5945
- const y = Math.max(0, Math.min(k, height - 1));
5946
- sum += tmp[(y * width + x) * channels + c];
5947
- }
5948
- dst[x * channels + c] = sum / kernelSize + 0.5 | 0;
5949
- for (let y = 1;y < height; y++) {
5950
- const addY = Math.min(y + radius, height - 1);
5951
- const removeY = Math.max(y - radius - 1, 0);
5952
- sum += tmp[(addY * width + x) * channels + c] - tmp[(removeY * width + x) * channels + c];
5953
- dst[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
5954
- }
6794
+ color: {
6795
+ oneOf: [
6796
+ { type: "string", pattern: "^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$" },
6797
+ {
6798
+ type: "object",
6799
+ properties: {
6800
+ r: { type: "integer", minimum: 0, maximum: 255 },
6801
+ g: { type: "integer", minimum: 0, maximum: 255 },
6802
+ b: { type: "integer", minimum: 0, maximum: 255 },
6803
+ a: { type: "integer", minimum: 0, maximum: 255 }
6804
+ },
6805
+ required: ["r", "g", "b"],
6806
+ additionalProperties: false
5955
6807
  }
5956
- }
5957
- return { data: dst, width, height, channels };
5958
- });
5959
- return { image };
5960
- }
5961
- }
5962
- Workflow17.prototype.imageBlur = CreateWorkflow16(ImageBlurTask);
5963
- // src/task/image/ImageBorderTask.ts
5964
- import {
5965
- CreateWorkflow as CreateWorkflow17,
5966
- Task as Task43,
5967
- Workflow as Workflow18
5968
- } from "@workglow/task-graph";
5969
- import { resolveColor } from "@workglow/util/media";
5970
- var inputSchema42 = {
5971
- type: "object",
5972
- properties: {
5973
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
5974
- borderWidth: {
5975
- type: "integer",
5976
- title: "Border Width",
5977
- description: "Border width in pixels",
5978
- minimum: 1,
5979
- default: 1
5980
- },
5981
- color: ColorValueSchema({ title: "Color", description: "Border color" })
6808
+ ],
6809
+ title: "Color",
6810
+ description: "Border color",
6811
+ default: "#000000"
6812
+ }
5982
6813
  },
5983
6814
  required: ["image", "color"],
5984
6815
  additionalProperties: false
5985
6816
  };
5986
6817
  var outputSchema41 = {
5987
6818
  type: "object",
5988
- properties: {
5989
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Image with border" })
5990
- },
6819
+ properties: { image: GpuImageSchema2({ title: "Image", description: "Image with border" }) },
5991
6820
  required: ["image"],
5992
6821
  additionalProperties: false
5993
6822
  };
5994
6823
 
5995
- class ImageBorderTask extends Task43 {
6824
+ class ImageBorderTask extends ImageFilterTask {
5996
6825
  static type = "ImageBorderTask";
5997
6826
  static category = "Image";
5998
6827
  static title = "Add Border";
@@ -6003,51 +6832,25 @@ class ImageBorderTask extends Task43 {
6003
6832
  static outputSchema() {
6004
6833
  return outputSchema41;
6005
6834
  }
6006
- async executeReactive(input, _output, _context) {
6007
- const { borderWidth: bw = 1 } = input;
6008
- const color = resolveColor(input.color);
6009
- const image = await produceImageOutput(input.image, (img) => {
6010
- const { data: src, width: srcW, height: srcH, channels: srcCh } = img;
6011
- const outCh = 4;
6012
- const dstW = srcW + bw * 2;
6013
- const dstH = srcH + bw * 2;
6014
- const dst = new Uint8ClampedArray(dstW * dstH * outCh);
6015
- const r = color.r;
6016
- const g = color.g;
6017
- const b = color.b;
6018
- const a = color.a;
6019
- for (let i = 0;i < dst.length; i += outCh) {
6020
- dst[i] = r;
6021
- dst[i + 1] = g;
6022
- dst[i + 2] = b;
6023
- dst[i + 3] = a;
6024
- }
6025
- for (let y = 0;y < srcH; y++) {
6026
- for (let x = 0;x < srcW; x++) {
6027
- const srcIdx = (y * srcW + x) * srcCh;
6028
- const dstIdx = ((y + bw) * dstW + (x + bw)) * outCh;
6029
- dst[dstIdx] = src[srcIdx];
6030
- dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
6031
- dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
6032
- dst[dstIdx + 3] = srcCh === 4 ? src[srcIdx + 3] : 255;
6033
- }
6034
- }
6035
- return { data: dst, width: dstW, height: dstH, channels: outCh };
6036
- });
6037
- return { image };
6835
+ filterName = "border";
6836
+ opParams(input) {
6837
+ return {
6838
+ borderWidth: input.borderWidth ?? 10,
6839
+ color: input.color
6840
+ };
6841
+ }
6842
+ scalePreviewParams({ borderWidth, color }, s) {
6843
+ return { borderWidth: Math.max(1, Math.round(borderWidth * s)), color };
6038
6844
  }
6039
6845
  }
6040
6846
  Workflow18.prototype.imageBorder = CreateWorkflow17(ImageBorderTask);
6041
- // src/task/image/ImageBrightnessTask.ts
6042
- import {
6043
- CreateWorkflow as CreateWorkflow18,
6044
- Task as Task44,
6045
- Workflow as Workflow19
6046
- } from "@workglow/task-graph";
6847
+ // src/task/image/brightness/ImageBrightnessTask.ts
6848
+ import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow19 } from "@workglow/task-graph";
6849
+ import { GpuImageSchema as GpuImageSchema3 } from "@workglow/util/media";
6047
6850
  var inputSchema43 = {
6048
6851
  type: "object",
6049
6852
  properties: {
6050
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
6853
+ image: GpuImageSchema3({ title: "Image", description: "Source image" }),
6051
6854
  amount: {
6052
6855
  type: "number",
6053
6856
  title: "Amount",
@@ -6062,14 +6865,12 @@ var inputSchema43 = {
6062
6865
  };
6063
6866
  var outputSchema42 = {
6064
6867
  type: "object",
6065
- properties: {
6066
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Brightness-adjusted image" })
6067
- },
6868
+ properties: { image: GpuImageSchema3({ title: "Image", description: "Brightness-adjusted image" }) },
6068
6869
  required: ["image"],
6069
6870
  additionalProperties: false
6070
6871
  };
6071
6872
 
6072
- class ImageBrightnessTask extends Task44 {
6873
+ class ImageBrightnessTask extends ImageFilterTask {
6073
6874
  static type = "ImageBrightnessTask";
6074
6875
  static category = "Image";
6075
6876
  static title = "Adjust Brightness";
@@ -6080,39 +6881,19 @@ class ImageBrightnessTask extends Task44 {
6080
6881
  static outputSchema() {
6081
6882
  return outputSchema42;
6082
6883
  }
6083
- async executeReactive(input, _output, _context) {
6084
- const amount = input.amount ?? 0;
6085
- const image = await produceImageOutput(input.image, (img) => {
6086
- const { data: src, width, height, channels } = img;
6087
- const dst = new Uint8ClampedArray(src.length);
6088
- if (channels === 4) {
6089
- for (let i = 0;i < src.length; i += 4) {
6090
- dst[i] = src[i] + amount;
6091
- dst[i + 1] = src[i + 1] + amount;
6092
- dst[i + 2] = src[i + 2] + amount;
6093
- dst[i + 3] = src[i + 3];
6094
- }
6095
- } else {
6096
- for (let i = 0;i < src.length; i++) {
6097
- dst[i] = src[i] + amount;
6098
- }
6099
- }
6100
- return { data: dst, width, height, channels };
6101
- });
6102
- return { image };
6884
+ filterName = "brightness";
6885
+ opParams(input) {
6886
+ return { amount: input.amount ?? 0 };
6103
6887
  }
6104
6888
  }
6105
6889
  Workflow19.prototype.imageBrightness = CreateWorkflow18(ImageBrightnessTask);
6106
- // src/task/image/ImageContrastTask.ts
6107
- import {
6108
- CreateWorkflow as CreateWorkflow19,
6109
- Task as Task45,
6110
- Workflow as Workflow20
6111
- } from "@workglow/task-graph";
6890
+ // src/task/image/contrast/ImageContrastTask.ts
6891
+ import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow20 } from "@workglow/task-graph";
6892
+ import { GpuImageSchema as GpuImageSchema4 } from "@workglow/util/media";
6112
6893
  var inputSchema44 = {
6113
6894
  type: "object",
6114
6895
  properties: {
6115
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
6896
+ image: GpuImageSchema4({ title: "Image", description: "Source image" }),
6116
6897
  amount: {
6117
6898
  type: "number",
6118
6899
  title: "Amount",
@@ -6127,14 +6908,12 @@ var inputSchema44 = {
6127
6908
  };
6128
6909
  var outputSchema43 = {
6129
6910
  type: "object",
6130
- properties: {
6131
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Contrast-adjusted image" })
6132
- },
6911
+ properties: { image: GpuImageSchema4({ title: "Image", description: "Contrast-adjusted image" }) },
6133
6912
  required: ["image"],
6134
6913
  additionalProperties: false
6135
6914
  };
6136
6915
 
6137
- class ImageContrastTask extends Task45 {
6916
+ class ImageContrastTask extends ImageFilterTask {
6138
6917
  static type = "ImageContrastTask";
6139
6918
  static category = "Image";
6140
6919
  static title = "Adjust Contrast";
@@ -6145,62 +6924,35 @@ class ImageContrastTask extends Task45 {
6145
6924
  static outputSchema() {
6146
6925
  return outputSchema43;
6147
6926
  }
6148
- async executeReactive(input, _output, _context) {
6149
- const amount = input.amount ?? 0;
6150
- const image = await produceImageOutput(input.image, (img) => {
6151
- const { data: src, width, height, channels } = img;
6152
- const factor = 259 * (amount + 255) / (255 * (259 - amount));
6153
- const lut = new Uint8ClampedArray(256);
6154
- for (let i = 0;i < 256; i++) {
6155
- lut[i] = factor * (i - 128) + 128;
6156
- }
6157
- const dst = new Uint8ClampedArray(src.length);
6158
- if (channels === 4) {
6159
- for (let i = 0;i < src.length; i += 4) {
6160
- dst[i] = lut[src[i]];
6161
- dst[i + 1] = lut[src[i + 1]];
6162
- dst[i + 2] = lut[src[i + 2]];
6163
- dst[i + 3] = src[i + 3];
6164
- }
6165
- } else {
6166
- for (let i = 0;i < src.length; i++) {
6167
- dst[i] = lut[src[i]];
6168
- }
6169
- }
6170
- return { data: dst, width, height, channels };
6171
- });
6172
- return { image };
6927
+ filterName = "contrast";
6928
+ opParams(input) {
6929
+ return { amount: input.amount ?? 0 };
6173
6930
  }
6174
6931
  }
6175
6932
  Workflow20.prototype.imageContrast = CreateWorkflow19(ImageContrastTask);
6176
- // src/task/image/ImageCropTask.ts
6177
- import {
6178
- CreateWorkflow as CreateWorkflow20,
6179
- Task as Task46,
6180
- Workflow as Workflow21
6181
- } from "@workglow/task-graph";
6933
+ // src/task/image/crop/ImageCropTask.ts
6934
+ import { CreateWorkflow as CreateWorkflow20, Workflow as Workflow21 } from "@workglow/task-graph";
6935
+ import { GpuImageSchema as GpuImageSchema5 } from "@workglow/util/media";
6182
6936
  var inputSchema45 = {
6183
6937
  type: "object",
6184
6938
  properties: {
6185
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
6186
- x: { type: "integer", title: "X", description: "Left offset", minimum: 0 },
6187
- y: { type: "integer", title: "Y", description: "Top offset", minimum: 0 },
6939
+ image: GpuImageSchema5({ title: "Image", description: "Source image" }),
6940
+ left: { type: "integer", title: "Left", description: "Left offset", minimum: 0, default: 0 },
6941
+ top: { type: "integer", title: "Top", description: "Top offset", minimum: 0, default: 0 },
6188
6942
  width: { type: "integer", title: "Width", description: "Crop width", minimum: 1 },
6189
6943
  height: { type: "integer", title: "Height", description: "Crop height", minimum: 1 }
6190
6944
  },
6191
- required: ["image", "x", "y", "width", "height"],
6945
+ required: ["image", "left", "top", "width", "height"],
6192
6946
  additionalProperties: false
6193
6947
  };
6194
6948
  var outputSchema44 = {
6195
6949
  type: "object",
6196
- properties: {
6197
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Cropped image" })
6198
- },
6950
+ properties: { image: GpuImageSchema5({ title: "Image", description: "Cropped image" }) },
6199
6951
  required: ["image"],
6200
6952
  additionalProperties: false
6201
6953
  };
6202
6954
 
6203
- class ImageCropTask extends Task46 {
6955
+ class ImageCropTask extends ImageFilterTask {
6204
6956
  static type = "ImageCropTask";
6205
6957
  static category = "Image";
6206
6958
  static title = "Crop Image";
@@ -6211,48 +6963,38 @@ class ImageCropTask extends Task46 {
6211
6963
  static outputSchema() {
6212
6964
  return outputSchema44;
6213
6965
  }
6214
- async executeReactive(input, _output, _context) {
6215
- const { x: rawX, y: rawY, width: rawW, height: rawH } = input;
6216
- const image = await produceImageOutput(input.image, (img) => {
6217
- const { data: src, width: srcW, height: srcH, channels } = img;
6218
- if (srcW < 1 || srcH < 1) {
6219
- throw new RangeError("Cannot crop an empty image");
6220
- }
6221
- if (rawX < 0 || rawX >= srcW || rawY < 0 || rawY >= srcH) {
6222
- throw new RangeError("Crop origin is outside the source image bounds");
6223
- }
6224
- const x = rawX;
6225
- const y = rawY;
6226
- const w = Math.min(rawW, srcW - x);
6227
- const h = Math.min(rawH, srcH - y);
6228
- const dst = new Uint8ClampedArray(w * h * channels);
6229
- const rowBytes = w * channels;
6230
- for (let row = 0;row < h; row++) {
6231
- const srcOffset = ((y + row) * srcW + x) * channels;
6232
- const dstOffset = row * rowBytes;
6233
- dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
6234
- }
6235
- return { data: dst, width: w, height: h, channels };
6236
- });
6237
- return { image };
6966
+ filterName = "crop";
6967
+ opParams(input) {
6968
+ return {
6969
+ left: input.left,
6970
+ top: input.top,
6971
+ width: input.width,
6972
+ height: input.height
6973
+ };
6974
+ }
6975
+ scalePreviewParams({ left, top, width, height }, s) {
6976
+ return {
6977
+ left: Math.round(left * s),
6978
+ top: Math.round(top * s),
6979
+ width: Math.max(1, Math.round(width * s)),
6980
+ height: Math.max(1, Math.round(height * s))
6981
+ };
6238
6982
  }
6239
6983
  }
6240
6984
  Workflow21.prototype.imageCrop = CreateWorkflow20(ImageCropTask);
6241
- // src/task/image/ImageFlipTask.ts
6242
- import {
6243
- CreateWorkflow as CreateWorkflow21,
6244
- Task as Task47,
6245
- Workflow as Workflow22
6246
- } from "@workglow/task-graph";
6985
+ // src/task/image/flip/ImageFlipTask.ts
6986
+ import { CreateWorkflow as CreateWorkflow21, Workflow as Workflow22 } from "@workglow/task-graph";
6987
+ import { GpuImageSchema as GpuImageSchema6 } from "@workglow/util/media";
6247
6988
  var inputSchema46 = {
6248
6989
  type: "object",
6249
6990
  properties: {
6250
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
6991
+ image: GpuImageSchema6({ title: "Image", description: "Source image" }),
6251
6992
  direction: {
6252
6993
  type: "string",
6253
6994
  enum: ["horizontal", "vertical"],
6254
6995
  title: "Direction",
6255
- description: "Flip direction"
6996
+ description: "Flip direction",
6997
+ default: "horizontal"
6256
6998
  }
6257
6999
  },
6258
7000
  required: ["image", "direction"],
@@ -6260,14 +7002,12 @@ var inputSchema46 = {
6260
7002
  };
6261
7003
  var outputSchema45 = {
6262
7004
  type: "object",
6263
- properties: {
6264
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Flipped image" })
6265
- },
7005
+ properties: { image: GpuImageSchema6({ title: "Image", description: "Flipped image" }) },
6266
7006
  required: ["image"],
6267
7007
  additionalProperties: false
6268
7008
  };
6269
7009
 
6270
- class ImageFlipTask extends Task47 {
7010
+ class ImageFlipTask extends ImageFilterTask {
6271
7011
  static type = "ImageFlipTask";
6272
7012
  static category = "Image";
6273
7013
  static title = "Flip Image";
@@ -6278,59 +7018,29 @@ class ImageFlipTask extends Task47 {
6278
7018
  static outputSchema() {
6279
7019
  return outputSchema45;
6280
7020
  }
6281
- async executeReactive(input, _output, _context) {
6282
- const { direction } = input;
6283
- const image = await produceImageOutput(input.image, (img) => {
6284
- const { data: src, width, height, channels } = img;
6285
- const dst = new Uint8ClampedArray(src.length);
6286
- const rowBytes = width * channels;
6287
- if (direction === "vertical") {
6288
- for (let y = 0;y < height; y++) {
6289
- const srcOffset = y * rowBytes;
6290
- const dstOffset = (height - 1 - y) * rowBytes;
6291
- dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
6292
- }
6293
- } else {
6294
- for (let y = 0;y < height; y++) {
6295
- for (let x = 0;x < width; x++) {
6296
- const srcIdx = (y * width + x) * channels;
6297
- const dstIdx = (y * width + (width - 1 - x)) * channels;
6298
- for (let c = 0;c < channels; c++) {
6299
- dst[dstIdx + c] = src[srcIdx + c];
6300
- }
6301
- }
6302
- }
6303
- }
6304
- return { data: dst, width, height, channels };
6305
- });
6306
- return { image };
7021
+ filterName = "flip";
7022
+ opParams(input) {
7023
+ return { direction: input.direction ?? "horizontal" };
6307
7024
  }
6308
7025
  }
6309
7026
  Workflow22.prototype.imageFlip = CreateWorkflow21(ImageFlipTask);
6310
- // src/task/image/ImageGrayscaleTask.ts
6311
- import {
6312
- CreateWorkflow as CreateWorkflow22,
6313
- Task as Task48,
6314
- Workflow as Workflow23
6315
- } from "@workglow/task-graph";
7027
+ // src/task/image/grayscale/ImageGrayscaleTask.ts
7028
+ import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow23 } from "@workglow/task-graph";
7029
+ import { GpuImageSchema as GpuImageSchema7 } from "@workglow/util/media";
6316
7030
  var inputSchema47 = {
6317
7031
  type: "object",
6318
- properties: {
6319
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" })
6320
- },
7032
+ properties: { image: GpuImageSchema7({ title: "Image", description: "Source image" }) },
6321
7033
  required: ["image"],
6322
7034
  additionalProperties: false
6323
7035
  };
6324
7036
  var outputSchema46 = {
6325
7037
  type: "object",
6326
- properties: {
6327
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Grayscale image" })
6328
- },
7038
+ properties: { image: GpuImageSchema7({ title: "Image", description: "Grayscale image" }) },
6329
7039
  required: ["image"],
6330
7040
  additionalProperties: false
6331
7041
  };
6332
7042
 
6333
- class ImageGrayscaleTask extends Task48 {
7043
+ class ImageGrayscaleTask extends ImageFilterTask {
6334
7044
  static type = "ImageGrayscaleTask";
6335
7045
  static category = "Image";
6336
7046
  static title = "Grayscale";
@@ -6341,48 +7051,29 @@ class ImageGrayscaleTask extends Task48 {
6341
7051
  static outputSchema() {
6342
7052
  return outputSchema46;
6343
7053
  }
6344
- async executeReactive(input, _output, _context) {
6345
- const image = await produceImageOutput(input.image, (img) => {
6346
- const { data: src, width, height, channels } = img;
6347
- if (channels === 1) {
6348
- return { data: new Uint8ClampedArray(src), width, height, channels: 1 };
6349
- }
6350
- const pixelCount = width * height;
6351
- const dst = new Uint8ClampedArray(pixelCount);
6352
- for (let i = 0;i < pixelCount; i++) {
6353
- const idx = i * channels;
6354
- dst[i] = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
6355
- }
6356
- return { data: dst, width, height, channels: 1 };
6357
- });
6358
- return { image };
7054
+ filterName = "grayscale";
7055
+ opParams(_input) {
7056
+ return;
6359
7057
  }
6360
7058
  }
6361
7059
  Workflow23.prototype.imageGrayscale = CreateWorkflow22(ImageGrayscaleTask);
6362
- // src/task/image/ImageInvertTask.ts
6363
- import {
6364
- CreateWorkflow as CreateWorkflow23,
6365
- Task as Task49,
6366
- Workflow as Workflow24
6367
- } from "@workglow/task-graph";
7060
+ // src/task/image/invert/ImageInvertTask.ts
7061
+ import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow24 } from "@workglow/task-graph";
7062
+ import { GpuImageSchema as GpuImageSchema8 } from "@workglow/util/media";
6368
7063
  var inputSchema48 = {
6369
7064
  type: "object",
6370
- properties: {
6371
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" })
6372
- },
7065
+ properties: { image: GpuImageSchema8({ title: "Image", description: "Source image" }) },
6373
7066
  required: ["image"],
6374
7067
  additionalProperties: false
6375
7068
  };
6376
7069
  var outputSchema47 = {
6377
7070
  type: "object",
6378
- properties: {
6379
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Inverted image" })
6380
- },
7071
+ properties: { image: GpuImageSchema8({ title: "Image", description: "Inverted image" }) },
6381
7072
  required: ["image"],
6382
7073
  additionalProperties: false
6383
7074
  };
6384
7075
 
6385
- class ImageInvertTask extends Task49 {
7076
+ class ImageInvertTask extends ImageFilterTask {
6386
7077
  static type = "ImageInvertTask";
6387
7078
  static category = "Image";
6388
7079
  static title = "Invert Colors";
@@ -6393,44 +7084,26 @@ class ImageInvertTask extends Task49 {
6393
7084
  static outputSchema() {
6394
7085
  return outputSchema47;
6395
7086
  }
6396
- async executeReactive(input, _output, _context) {
6397
- const image = await produceImageOutput(input.image, (img) => {
6398
- const { data: src, width, height, channels } = img;
6399
- const dst = new Uint8ClampedArray(src.length);
6400
- if (channels === 4) {
6401
- for (let i = 0;i < src.length; i += 4) {
6402
- dst[i] = 255 - src[i];
6403
- dst[i + 1] = 255 - src[i + 1];
6404
- dst[i + 2] = 255 - src[i + 2];
6405
- dst[i + 3] = src[i + 3];
6406
- }
6407
- } else {
6408
- for (let i = 0;i < src.length; i++) {
6409
- dst[i] = 255 - src[i];
6410
- }
6411
- }
6412
- return { data: dst, width, height, channels };
6413
- });
6414
- return { image };
7087
+ filterName = "invert";
7088
+ opParams(_input) {
7089
+ return;
6415
7090
  }
6416
7091
  }
6417
7092
  Workflow24.prototype.imageInvert = CreateWorkflow23(ImageInvertTask);
6418
- // src/task/image/ImagePixelateTask.ts
6419
- import {
6420
- CreateWorkflow as CreateWorkflow24,
6421
- Task as Task50,
6422
- Workflow as Workflow25
6423
- } from "@workglow/task-graph";
7093
+ // src/task/image/pixelate/ImagePixelateTask.ts
7094
+ import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow25 } from "@workglow/task-graph";
7095
+ import { GpuImageSchema as GpuImageSchema9 } from "@workglow/util/media";
6424
7096
  var inputSchema49 = {
6425
7097
  type: "object",
6426
7098
  properties: {
6427
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7099
+ image: GpuImageSchema9({ title: "Image", description: "Source image" }),
6428
7100
  blockSize: {
6429
7101
  type: "integer",
6430
7102
  title: "Block Size",
6431
7103
  description: "Size of each pixelation block",
6432
7104
  minimum: 2,
6433
- default: 8
7105
+ maximum: 64,
7106
+ default: 4
6434
7107
  }
6435
7108
  },
6436
7109
  required: ["image"],
@@ -6438,14 +7111,12 @@ var inputSchema49 = {
6438
7111
  };
6439
7112
  var outputSchema48 = {
6440
7113
  type: "object",
6441
- properties: {
6442
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Pixelated image" })
6443
- },
7114
+ properties: { image: GpuImageSchema9({ title: "Image", description: "Pixelated image" }) },
6444
7115
  required: ["image"],
6445
7116
  additionalProperties: false
6446
7117
  };
6447
7118
 
6448
- class ImagePixelateTask extends Task50 {
7119
+ class ImagePixelateTask extends ImageFilterTask {
6449
7120
  static type = "ImagePixelateTask";
6450
7121
  static category = "Image";
6451
7122
  static title = "Pixelate Image";
@@ -6456,58 +7127,28 @@ class ImagePixelateTask extends Task50 {
6456
7127
  static outputSchema() {
6457
7128
  return outputSchema48;
6458
7129
  }
6459
- async executeReactive(input, _output, _context) {
6460
- const { blockSize = 8 } = input;
6461
- const image = await produceImageOutput(input.image, (img) => {
6462
- const { data: src, width, height, channels } = img;
6463
- const dst = new Uint8ClampedArray(src.length);
6464
- for (let by = 0;by < height; by += blockSize) {
6465
- const blockH = Math.min(blockSize, height - by);
6466
- for (let bx = 0;bx < width; bx += blockSize) {
6467
- const blockW = Math.min(blockSize, width - bx);
6468
- const blockArea = blockW * blockH;
6469
- const sums = new Array(channels).fill(0);
6470
- for (let y = by;y < by + blockH; y++) {
6471
- for (let x = bx;x < bx + blockW; x++) {
6472
- const idx = (y * width + x) * channels;
6473
- for (let c = 0;c < channels; c++) {
6474
- sums[c] += src[idx + c];
6475
- }
6476
- }
6477
- }
6478
- const avg = sums.map((s) => s / blockArea + 0.5 | 0);
6479
- for (let y = by;y < by + blockH; y++) {
6480
- for (let x = bx;x < bx + blockW; x++) {
6481
- const idx = (y * width + x) * channels;
6482
- for (let c = 0;c < channels; c++) {
6483
- dst[idx + c] = avg[c];
6484
- }
6485
- }
6486
- }
6487
- }
6488
- }
6489
- return { data: dst, width, height, channels };
6490
- });
6491
- return { image };
7130
+ filterName = "pixelate";
7131
+ opParams(input) {
7132
+ return { blockSize: input.blockSize ?? 4 };
7133
+ }
7134
+ scalePreviewParams({ blockSize }, s) {
7135
+ return { blockSize: Math.max(1, Math.round(blockSize * s)) };
6492
7136
  }
6493
7137
  }
6494
7138
  Workflow25.prototype.imagePixelate = CreateWorkflow24(ImagePixelateTask);
6495
- // src/task/image/ImagePosterizeTask.ts
6496
- import {
6497
- CreateWorkflow as CreateWorkflow25,
6498
- Task as Task51,
6499
- Workflow as Workflow26
6500
- } from "@workglow/task-graph";
7139
+ // src/task/image/posterize/ImagePosterizeTask.ts
7140
+ import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow26 } from "@workglow/task-graph";
7141
+ import { GpuImageSchema as GpuImageSchema10 } from "@workglow/util/media";
6501
7142
  var inputSchema50 = {
6502
7143
  type: "object",
6503
7144
  properties: {
6504
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7145
+ image: GpuImageSchema10({ title: "Image", description: "Source image" }),
6505
7146
  levels: {
6506
7147
  type: "integer",
6507
7148
  title: "Levels",
6508
- description: "Number of color levels per channel (2-32)",
7149
+ description: "Number of color levels per channel (2-16)",
6509
7150
  minimum: 2,
6510
- maximum: 32,
7151
+ maximum: 16,
6511
7152
  default: 4
6512
7153
  }
6513
7154
  },
@@ -6516,14 +7157,12 @@ var inputSchema50 = {
6516
7157
  };
6517
7158
  var outputSchema49 = {
6518
7159
  type: "object",
6519
- properties: {
6520
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Posterized image" })
6521
- },
7160
+ properties: { image: GpuImageSchema10({ title: "Image", description: "Posterized image" }) },
6522
7161
  required: ["image"],
6523
7162
  additionalProperties: false
6524
7163
  };
6525
7164
 
6526
- class ImagePosterizeTask extends Task51 {
7165
+ class ImagePosterizeTask extends ImageFilterTask {
6527
7166
  static type = "ImagePosterizeTask";
6528
7167
  static category = "Image";
6529
7168
  static title = "Posterize";
@@ -6534,52 +7173,34 @@ class ImagePosterizeTask extends Task51 {
6534
7173
  static outputSchema() {
6535
7174
  return outputSchema49;
6536
7175
  }
6537
- async executeReactive(input, _output, _context) {
6538
- const levels = input.levels ?? 4;
6539
- const image = await produceImageOutput(input.image, (img) => {
6540
- const { data: src, width, height, channels } = img;
6541
- const step = 255 / (levels - 1);
6542
- const lut = new Uint8ClampedArray(256);
6543
- for (let i = 0;i < 256; i++) {
6544
- lut[i] = Math.round(Math.round(i / step) * step);
6545
- }
6546
- const dst = new Uint8ClampedArray(src.length);
6547
- if (channels === 4) {
6548
- for (let i = 0;i < src.length; i += 4) {
6549
- dst[i] = lut[src[i]];
6550
- dst[i + 1] = lut[src[i + 1]];
6551
- dst[i + 2] = lut[src[i + 2]];
6552
- dst[i + 3] = src[i + 3];
6553
- }
6554
- } else {
6555
- for (let i = 0;i < src.length; i++) {
6556
- dst[i] = lut[src[i]];
6557
- }
6558
- }
6559
- return { data: dst, width, height, channels };
6560
- });
6561
- return { image };
7176
+ filterName = "posterize";
7177
+ opParams(input) {
7178
+ return { levels: input.levels ?? 4 };
6562
7179
  }
6563
7180
  }
6564
7181
  Workflow26.prototype.imagePosterize = CreateWorkflow25(ImagePosterizeTask);
6565
7182
  // src/task/image/imageRasterCodecRegistry.ts
6566
- import { getImageRasterCodec as getImageRasterCodec2, registerImageRasterCodec as registerImageRasterCodec2 } from "@workglow/util/media";
6567
- // src/task/image/ImageResizeTask.ts
6568
- import {
6569
- CreateWorkflow as CreateWorkflow26,
6570
- Task as Task52,
6571
- Workflow as Workflow27
6572
- } from "@workglow/task-graph";
7183
+ import { getImageRasterCodec, registerImageRasterCodec as registerImageRasterCodec2 } from "@workglow/util/media";
7184
+ // src/task/image/resize/ImageResizeTask.ts
7185
+ import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow27 } from "@workglow/task-graph";
7186
+ import { GpuImageSchema as GpuImageSchema11 } from "@workglow/util/media";
6573
7187
  var inputSchema51 = {
6574
7188
  type: "object",
6575
7189
  properties: {
6576
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7190
+ image: GpuImageSchema11({ title: "Image", description: "Source image" }),
6577
7191
  width: { type: "integer", title: "Width", description: "Target width in pixels", minimum: 1 },
6578
- height: {
6579
- type: "integer",
6580
- title: "Height",
6581
- description: "Target height in pixels",
6582
- minimum: 1
7192
+ height: { type: "integer", title: "Height", description: "Target height in pixels", minimum: 1 },
7193
+ fit: {
7194
+ type: "string",
7195
+ enum: ["cover", "contain", "fill", "inside", "outside"],
7196
+ title: "Fit",
7197
+ description: "How the image should be resized to fit"
7198
+ },
7199
+ kernel: {
7200
+ type: "string",
7201
+ enum: ["nearest", "cubic", "mitchell", "lanczos2", "lanczos3"],
7202
+ title: "Kernel",
7203
+ description: "Resampling kernel"
6583
7204
  }
6584
7205
  },
6585
7206
  required: ["image", "width", "height"],
@@ -6587,14 +7208,12 @@ var inputSchema51 = {
6587
7208
  };
6588
7209
  var outputSchema50 = {
6589
7210
  type: "object",
6590
- properties: {
6591
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Resized image" })
6592
- },
7211
+ properties: { image: GpuImageSchema11({ title: "Image", description: "Resized image" }) },
6593
7212
  required: ["image"],
6594
7213
  additionalProperties: false
6595
7214
  };
6596
7215
 
6597
- class ImageResizeTask extends Task52 {
7216
+ class ImageResizeTask extends ImageFilterTask {
6598
7217
  static type = "ImageResizeTask";
6599
7218
  static category = "Image";
6600
7219
  static title = "Resize Image";
@@ -6605,43 +7224,42 @@ class ImageResizeTask extends Task52 {
6605
7224
  static outputSchema() {
6606
7225
  return outputSchema50;
6607
7226
  }
6608
- async executeReactive(input, _output, _context) {
6609
- const { width: dstW, height: dstH } = input;
6610
- const image = await produceImageOutput(input.image, (img) => {
6611
- const { data: src, width: srcW, height: srcH, channels } = img;
6612
- const dst = new Uint8ClampedArray(dstW * dstH * channels);
6613
- for (let dy = 0;dy < dstH; dy++) {
6614
- const srcY = Math.min(Math.floor(dy * srcH / dstH), srcH - 1);
6615
- for (let dx = 0;dx < dstW; dx++) {
6616
- const srcX = Math.min(Math.floor(dx * srcW / dstW), srcW - 1);
6617
- const srcIdx = (srcY * srcW + srcX) * channels;
6618
- const dstIdx = (dy * dstW + dx) * channels;
6619
- for (let c = 0;c < channels; c++) {
6620
- dst[dstIdx + c] = src[srcIdx + c];
6621
- }
6622
- }
6623
- }
6624
- return { data: dst, width: dstW, height: dstH, channels };
6625
- });
6626
- return { image };
7227
+ filterName = "resize";
7228
+ opParams(input) {
7229
+ return {
7230
+ width: input.width,
7231
+ height: input.height,
7232
+ fit: input.fit,
7233
+ kernel: input.kernel
7234
+ };
7235
+ }
7236
+ scalePreviewParams({ width, height, fit, kernel }, s) {
7237
+ return {
7238
+ width: Math.max(1, Math.round(width * s)),
7239
+ height: Math.max(1, Math.round(height * s)),
7240
+ fit,
7241
+ kernel
7242
+ };
6627
7243
  }
6628
7244
  }
6629
7245
  Workflow27.prototype.imageResize = CreateWorkflow26(ImageResizeTask);
6630
- // src/task/image/ImageRotateTask.ts
6631
- import {
6632
- CreateWorkflow as CreateWorkflow27,
6633
- Task as Task53,
6634
- Workflow as Workflow28
6635
- } from "@workglow/task-graph";
7246
+ // src/task/image/rotate/ImageRotateTask.ts
7247
+ import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow28 } from "@workglow/task-graph";
7248
+ import { GpuImageSchema as GpuImageSchema12 } from "@workglow/util/media";
6636
7249
  var inputSchema52 = {
6637
7250
  type: "object",
6638
7251
  properties: {
6639
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7252
+ image: GpuImageSchema12({ title: "Image", description: "Source image" }),
6640
7253
  angle: {
6641
7254
  type: "integer",
6642
7255
  enum: [90, 180, 270],
6643
7256
  title: "Angle",
6644
7257
  description: "Rotation angle in degrees (clockwise)"
7258
+ },
7259
+ background: {
7260
+ type: "string",
7261
+ title: "Background",
7262
+ description: "Background color for rotation (hex string)"
6645
7263
  }
6646
7264
  },
6647
7265
  required: ["image", "angle"],
@@ -6649,14 +7267,12 @@ var inputSchema52 = {
6649
7267
  };
6650
7268
  var outputSchema51 = {
6651
7269
  type: "object",
6652
- properties: {
6653
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Rotated image" })
6654
- },
7270
+ properties: { image: GpuImageSchema12({ title: "Image", description: "Rotated image" }) },
6655
7271
  required: ["image"],
6656
7272
  additionalProperties: false
6657
7273
  };
6658
7274
 
6659
- class ImageRotateTask extends Task53 {
7275
+ class ImageRotateTask extends ImageFilterTask {
6660
7276
  static type = "ImageRotateTask";
6661
7277
  static category = "Image";
6662
7278
  static title = "Rotate Image";
@@ -6667,64 +7283,87 @@ class ImageRotateTask extends Task53 {
6667
7283
  static outputSchema() {
6668
7284
  return outputSchema51;
6669
7285
  }
6670
- async executeReactive(input, _output, _context) {
6671
- const { angle } = input;
6672
- const image = await produceImageOutput(input.image, (img) => {
6673
- const { data: src, width: srcW, height: srcH, channels } = img;
6674
- const swap = angle === 90 || angle === 270;
6675
- const dstW = swap ? srcH : srcW;
6676
- const dstH = swap ? srcW : srcH;
6677
- const dst = new Uint8ClampedArray(dstW * dstH * channels);
6678
- for (let sy = 0;sy < srcH; sy++) {
6679
- for (let sx = 0;sx < srcW; sx++) {
6680
- let dx, dy;
6681
- if (angle === 90) {
6682
- dx = srcH - 1 - sy;
6683
- dy = sx;
6684
- } else if (angle === 180) {
6685
- dx = srcW - 1 - sx;
6686
- dy = srcH - 1 - sy;
6687
- } else {
6688
- dx = sy;
6689
- dy = srcW - 1 - sx;
6690
- }
6691
- const srcIdx = (sy * srcW + sx) * channels;
6692
- const dstIdx = (dy * dstW + dx) * channels;
6693
- for (let c = 0;c < channels; c++) {
6694
- dst[dstIdx + c] = src[srcIdx + c];
6695
- }
6696
- }
6697
- }
6698
- return { data: dst, width: dstW, height: dstH, channels };
6699
- });
6700
- return { image };
7286
+ filterName = "rotate";
7287
+ opParams(input) {
7288
+ return {
7289
+ angle: input.angle,
7290
+ background: input.background
7291
+ };
6701
7292
  }
6702
7293
  }
6703
7294
  Workflow28.prototype.imageRotate = CreateWorkflow27(ImageRotateTask);
6704
- // src/task/image/ImageSepiaTask.ts
6705
- import {
6706
- CreateWorkflow as CreateWorkflow28,
6707
- Task as Task54,
6708
- Workflow as Workflow29
6709
- } from "@workglow/task-graph";
6710
- var inputSchema53 = {
7295
+ // src/task/image/ImageSchemas.ts
7296
+ import { FromSchemaDefaultOptions } from "@workglow/util/schema";
7297
+ var cssRgbChannelPattern = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)";
7298
+ var cssRgbAlphaPattern = "(?:0(?:\\.\\d+)?|1(?:\\.0+)?)";
7299
+ var cssRgbColorPattern = `^rgba?\\(\\s*${cssRgbChannelPattern}\\s*,\\s*${cssRgbChannelPattern}\\s*,\\s*` + `${cssRgbChannelPattern}\\s*(?:,\\s*${cssRgbAlphaPattern})?\\s*\\)$`;
7300
+ var ColorSchema = (annotations = {}) => ({
6711
7301
  type: "object",
6712
7302
  properties: {
6713
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" })
7303
+ r: { type: "integer", minimum: 0, maximum: 255, title: "Red" },
7304
+ g: { type: "integer", minimum: 0, maximum: 255, title: "Green" },
7305
+ b: { type: "integer", minimum: 0, maximum: 255, title: "Blue" },
7306
+ a: { type: "integer", minimum: 0, maximum: 255, title: "Alpha", default: 255 }
6714
7307
  },
7308
+ required: ["r", "g", "b"],
7309
+ format: "color",
7310
+ additionalProperties: false,
7311
+ ...annotations
7312
+ });
7313
+ var HexColorSchema = (annotations = {}) => ({
7314
+ type: "string",
7315
+ format: "color",
7316
+ pattern: "^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$",
7317
+ title: "Color (hex)",
7318
+ description: "Color as a `#RRGGBB[AA]` or `#RGB[A]` hex string",
7319
+ ...annotations
7320
+ });
7321
+ var CssRgbColorSchema = (annotations = {}) => ({
7322
+ type: "string",
7323
+ format: "color",
7324
+ pattern: cssRgbColorPattern,
7325
+ title: "Color (RGB)",
7326
+ description: "Color as a CSS `rgb(r,g,b)` or `rgba(r,g,b,a)` string",
7327
+ ...annotations
7328
+ });
7329
+ var ColorValueSchema = (annotations = {}) => ({
7330
+ oneOf: [
7331
+ ColorSchema(),
7332
+ HexColorSchema({
7333
+ title: annotations.title ?? "Color",
7334
+ description: annotations.description ?? "Color as {r,g,b,a} object, `#RRGGBB[AA]` / `#RGB[A]` hex string, or CSS `rgb(...)` / `rgba(...)` string"
7335
+ }),
7336
+ CssRgbColorSchema()
7337
+ ],
7338
+ ...annotations
7339
+ });
7340
+ var ColorObjectType = null;
7341
+ var ColorFromSchemaOptions = {
7342
+ ...FromSchemaDefaultOptions,
7343
+ deserialize: [
7344
+ {
7345
+ pattern: { type: "object", format: "color" },
7346
+ output: ColorObjectType
7347
+ }
7348
+ ]
7349
+ };
7350
+ // src/task/image/sepia/ImageSepiaTask.ts
7351
+ import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow29 } from "@workglow/task-graph";
7352
+ import { GpuImageSchema as GpuImageSchema13 } from "@workglow/util/media";
7353
+ var inputSchema53 = {
7354
+ type: "object",
7355
+ properties: { image: GpuImageSchema13({ title: "Image", description: "Source image" }) },
6715
7356
  required: ["image"],
6716
7357
  additionalProperties: false
6717
7358
  };
6718
7359
  var outputSchema52 = {
6719
7360
  type: "object",
6720
- properties: {
6721
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Sepia-toned image" })
6722
- },
7361
+ properties: { image: GpuImageSchema13({ title: "Image", description: "Sepia-toned image" }) },
6723
7362
  required: ["image"],
6724
7363
  additionalProperties: false
6725
7364
  };
6726
7365
 
6727
- class ImageSepiaTask extends Task54 {
7366
+ class ImageSepiaTask extends ImageFilterTask {
6728
7367
  static type = "ImageSepiaTask";
6729
7368
  static category = "Image";
6730
7369
  static title = "Sepia Tone";
@@ -6735,41 +7374,24 @@ class ImageSepiaTask extends Task54 {
6735
7374
  static outputSchema() {
6736
7375
  return outputSchema52;
6737
7376
  }
6738
- async executeReactive(input, _output, _context) {
6739
- const image = await produceImageOutput(input.image, (img) => {
6740
- const { data: src, width, height, channels } = img;
6741
- const dst = new Uint8ClampedArray(src.length);
6742
- const pixelCount = width * height;
6743
- for (let i = 0;i < pixelCount; i++) {
6744
- const idx = i * channels;
6745
- const r = channels === 1 ? src[idx] : src[idx];
6746
- const g = channels === 1 ? src[idx] : src[idx + 1];
6747
- const b = channels === 1 ? src[idx] : src[idx + 2];
6748
- const outR = r * 402 + g * 787 + b * 194 >> 10;
6749
- const outG = r * 357 + g * 702 + b * 172 >> 10;
6750
- const outB = r * 279 + g * 547 + b * 134 >> 10;
6751
- dst[idx] = outR > 255 ? 255 : outR;
6752
- if (channels >= 3) {
6753
- dst[idx + 1] = outG > 255 ? 255 : outG;
6754
- dst[idx + 2] = outB > 255 ? 255 : outB;
6755
- }
6756
- if (channels === 4) {
6757
- dst[idx + 3] = src[idx + 3];
6758
- }
6759
- }
6760
- return { data: dst, width, height, channels };
6761
- });
6762
- return { image };
7377
+ filterName = "sepia";
7378
+ opParams(_input) {
7379
+ return;
6763
7380
  }
6764
7381
  }
6765
7382
  Workflow29.prototype.imageSepia = CreateWorkflow28(ImageSepiaTask);
6766
- // src/task/image/ImageTextTask.ts
7383
+ // src/task/image/text/ImageTextTask.ts
6767
7384
  import {
6768
7385
  CreateWorkflow as CreateWorkflow29,
6769
- Task as Task55,
7386
+ Task as Task43,
6770
7387
  Workflow as Workflow30
6771
7388
  } from "@workglow/task-graph";
6772
- import { resolveColor as resolveColor2 } from "@workglow/util/media";
7389
+ import {
7390
+ CpuImage as CpuImage18,
7391
+ getPreviewBudget,
7392
+ GpuImageSchema as GpuImageSchema14,
7393
+ resolveColor as resolveColor5
7394
+ } from "@workglow/util/media";
6773
7395
  function toRgbaImage(image) {
6774
7396
  const { data, width, height, channels } = image;
6775
7397
  const rgba = new Uint8ClampedArray(width * height * 4);
@@ -6844,7 +7466,7 @@ var IMAGE_TEXT_POSITION_LABELS = {
6844
7466
  "bottom-center": "Bottom center",
6845
7467
  "bottom-right": "Bottom right"
6846
7468
  };
6847
- var backgroundImageProperty = ImageBinaryOrDataUriSchema({
7469
+ var backgroundImageProperty = GpuImageSchema14({
6848
7470
  title: "Image",
6849
7471
  description: "Background image to render the text onto"
6850
7472
  });
@@ -6909,23 +7531,73 @@ var inputSchema54 = {
6909
7531
  var outputSchema53 = {
6910
7532
  type: "object",
6911
7533
  properties: {
6912
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Raster image with text" })
7534
+ image: GpuImageSchema14({ title: "Image", description: "Raster image with text" })
6913
7535
  },
6914
7536
  required: ["image"],
6915
7537
  additionalProperties: false
6916
7538
  };
6917
- function hasUsableBackgroundImage(value) {
6918
- if (typeof value === "string") {
6919
- return value.length > 0;
6920
- }
6921
- if (typeof value !== "object" || value === null) {
6922
- return false;
7539
+ function resolveTextParams(input) {
7540
+ return {
7541
+ text: input.text,
7542
+ font: input.font ?? "sans-serif",
7543
+ fontSize: input.fontSize ?? 24,
7544
+ bold: input.bold ?? false,
7545
+ italic: input.italic ?? false,
7546
+ color: resolveColor5(input.color),
7547
+ position: input.position ?? "middle-center"
7548
+ };
7549
+ }
7550
+ function requireStandaloneDims(input) {
7551
+ if (!("width" in input) || !("height" in input) || typeof input.width !== "number" || typeof input.height !== "number") {
7552
+ throw new Error("ImageTextTask: width and height are required when no background image is provided");
7553
+ }
7554
+ return { width: input.width, height: input.height };
7555
+ }
7556
+ async function renderTextOverBackground(params, backgroundImage, previewScale) {
7557
+ const background = await backgroundImage.materialize();
7558
+ const overlay = await renderImageTextToRgba({
7559
+ text: params.text,
7560
+ font: params.font,
7561
+ fontSize: Math.max(1, Math.round(params.fontSize * previewScale)),
7562
+ bold: params.bold,
7563
+ italic: params.italic,
7564
+ color: params.color,
7565
+ width: background.width,
7566
+ height: background.height,
7567
+ position: params.position
7568
+ });
7569
+ const composited = compositeTextOverBackground(background, overlay);
7570
+ return {
7571
+ image: CpuImage18.fromImageBinary(composited, previewScale)
7572
+ };
7573
+ }
7574
+ async function renderTextStandalone(params, width, height, previewScale) {
7575
+ const textBinary = await renderImageTextToRgba({
7576
+ text: params.text,
7577
+ font: params.font,
7578
+ fontSize: Math.max(1, Math.round(params.fontSize * previewScale)),
7579
+ bold: params.bold,
7580
+ italic: params.italic,
7581
+ color: params.color,
7582
+ width: Math.max(1, Math.round(width * previewScale)),
7583
+ height: Math.max(1, Math.round(height * previewScale)),
7584
+ position: params.position
7585
+ });
7586
+ return {
7587
+ image: CpuImage18.fromImageBinary(textBinary, previewScale)
7588
+ };
7589
+ }
7590
+ async function runText(input) {
7591
+ const params = resolveTextParams(input);
7592
+ const backgroundImage = "image" in input ? input.image : undefined;
7593
+ if (backgroundImage != null) {
7594
+ return renderTextOverBackground(params, backgroundImage, 1);
6923
7595
  }
6924
- const candidate = value;
6925
- return typeof candidate.width === "number" && typeof candidate.height === "number" && typeof candidate.channels === "number" && candidate.data !== undefined;
7596
+ const { width, height } = requireStandaloneDims(input);
7597
+ return renderTextStandalone(params, width, height, 1);
6926
7598
  }
6927
7599
 
6928
- class ImageTextTask extends Task55 {
7600
+ class ImageTextTask extends Task43 {
6929
7601
  static type = "ImageTextTask";
6930
7602
  static category = "Image";
6931
7603
  static title = "Render Text to Image";
@@ -6943,63 +7615,33 @@ class ImageTextTask extends Task55 {
6943
7615
  delete defaults.height;
6944
7616
  return defaults;
6945
7617
  }
6946
- async executeReactive(input, _output, _context) {
6947
- const color = resolveColor2(input.color);
6948
- const fontSize = input.fontSize ?? 24;
6949
- const font = input.font ?? "sans-serif";
6950
- const bold = input.bold ?? false;
6951
- const italic = input.italic ?? false;
6952
- const position = input.position ?? "middle-center";
7618
+ async execute(input, _context) {
7619
+ return await runText(input);
7620
+ }
7621
+ async executePreview(input, _context) {
7622
+ const params = resolveTextParams(input);
6953
7623
  const backgroundImage = "image" in input ? input.image : undefined;
6954
- let image;
6955
- if (hasUsableBackgroundImage(backgroundImage)) {
6956
- image = await produceImageOutput(backgroundImage, async (background) => {
6957
- const overlay = await renderImageTextToRgba({
6958
- text: input.text,
6959
- font,
6960
- fontSize,
6961
- bold,
6962
- italic,
6963
- color,
6964
- width: background.width,
6965
- height: background.height,
6966
- position
6967
- });
6968
- return compositeTextOverBackground(background, overlay);
6969
- });
6970
- } else {
6971
- if (!("width" in input) || !("height" in input) || typeof input.width !== "number" || typeof input.height !== "number") {
6972
- throw new Error("ImageTextTask: width and height are required when no background image is provided");
6973
- }
6974
- image = await renderImageTextToRgba({
6975
- text: input.text,
6976
- font,
6977
- fontSize,
6978
- bold,
6979
- italic,
6980
- color,
6981
- width: input.width,
6982
- height: input.height,
6983
- position
6984
- });
7624
+ if (backgroundImage != null) {
7625
+ return await renderTextOverBackground(params, backgroundImage, backgroundImage.previewScale);
6985
7626
  }
6986
- return { image };
7627
+ const { width, height } = requireStandaloneDims(input);
7628
+ const longEdge = Math.max(width, height);
7629
+ const budget = getPreviewBudget();
7630
+ const s = longEdge > budget ? budget / longEdge : 1;
7631
+ return await renderTextStandalone(params, width, height, s);
6987
7632
  }
6988
7633
  }
6989
7634
  Workflow30.prototype.imageText = CreateWorkflow29(ImageTextTask);
6990
- // src/task/image/ImageThresholdTask.ts
6991
- import {
6992
- CreateWorkflow as CreateWorkflow30,
6993
- Task as Task56,
6994
- Workflow as Workflow31
6995
- } from "@workglow/task-graph";
7635
+ // src/task/image/threshold/ImageThresholdTask.ts
7636
+ import { CreateWorkflow as CreateWorkflow30, Workflow as Workflow31 } from "@workglow/task-graph";
7637
+ import { GpuImageSchema as GpuImageSchema15 } from "@workglow/util/media";
6996
7638
  var inputSchema55 = {
6997
7639
  type: "object",
6998
7640
  properties: {
6999
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7000
- threshold: {
7001
- type: "integer",
7002
- title: "Threshold",
7641
+ image: GpuImageSchema15({ title: "Image", description: "Source image" }),
7642
+ value: {
7643
+ type: "number",
7644
+ title: "Value",
7003
7645
  description: "Threshold value (0-255)",
7004
7646
  minimum: 0,
7005
7647
  maximum: 255,
@@ -7011,57 +7653,35 @@ var inputSchema55 = {
7011
7653
  };
7012
7654
  var outputSchema54 = {
7013
7655
  type: "object",
7014
- properties: {
7015
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Thresholded binary image" })
7016
- },
7656
+ properties: { image: GpuImageSchema15({ title: "Image", description: "Thresholded image" }) },
7017
7657
  required: ["image"],
7018
7658
  additionalProperties: false
7019
7659
  };
7020
7660
 
7021
- class ImageThresholdTask extends Task56 {
7661
+ class ImageThresholdTask extends ImageFilterTask {
7022
7662
  static type = "ImageThresholdTask";
7023
7663
  static category = "Image";
7024
7664
  static title = "Threshold";
7025
- static description = "Converts an image to binary black and white";
7665
+ static description = "Applies a binary threshold per channel";
7026
7666
  static inputSchema() {
7027
7667
  return inputSchema55;
7028
7668
  }
7029
7669
  static outputSchema() {
7030
7670
  return outputSchema54;
7031
7671
  }
7032
- async executeReactive(input, _output, _context) {
7033
- const threshold = input.threshold ?? 128;
7034
- const image = await produceImageOutput(input.image, (img) => {
7035
- const { data: src, width, height, channels } = img;
7036
- const pixelCount = width * height;
7037
- const dst = new Uint8ClampedArray(pixelCount);
7038
- for (let i = 0;i < pixelCount; i++) {
7039
- const idx = i * channels;
7040
- let gray;
7041
- if (channels === 1) {
7042
- gray = src[idx];
7043
- } else {
7044
- gray = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
7045
- }
7046
- dst[i] = gray >= threshold ? 255 : 0;
7047
- }
7048
- return { data: dst, width, height, channels: 1 };
7049
- });
7050
- return { image };
7672
+ filterName = "threshold";
7673
+ opParams(input) {
7674
+ return { value: input.value ?? 128 };
7051
7675
  }
7052
7676
  }
7053
7677
  Workflow31.prototype.imageThreshold = CreateWorkflow30(ImageThresholdTask);
7054
- // src/task/image/ImageTintTask.ts
7055
- import {
7056
- CreateWorkflow as CreateWorkflow31,
7057
- Task as Task57,
7058
- Workflow as Workflow32
7059
- } from "@workglow/task-graph";
7060
- import { resolveColor as resolveColor3 } from "@workglow/util/media";
7678
+ // src/task/image/tint/ImageTintTask.ts
7679
+ import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow32 } from "@workglow/task-graph";
7680
+ import { GpuImageSchema as GpuImageSchema16 } from "@workglow/util/media";
7061
7681
  var inputSchema56 = {
7062
7682
  type: "object",
7063
7683
  properties: {
7064
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7684
+ image: GpuImageSchema16({ title: "Image", description: "Source image" }),
7065
7685
  color: ColorValueSchema({ title: "Color", description: "Tint color" }),
7066
7686
  amount: {
7067
7687
  type: "number",
@@ -7077,14 +7697,12 @@ var inputSchema56 = {
7077
7697
  };
7078
7698
  var outputSchema55 = {
7079
7699
  type: "object",
7080
- properties: {
7081
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Tinted image" })
7082
- },
7700
+ properties: { image: GpuImageSchema16({ title: "Image", description: "Tinted image" }) },
7083
7701
  required: ["image"],
7084
7702
  additionalProperties: false
7085
7703
  };
7086
7704
 
7087
- class ImageTintTask extends Task57 {
7705
+ class ImageTintTask extends ImageFilterTask {
7088
7706
  static type = "ImageTintTask";
7089
7707
  static category = "Image";
7090
7708
  static title = "Tint Image";
@@ -7095,76 +7713,42 @@ class ImageTintTask extends Task57 {
7095
7713
  static outputSchema() {
7096
7714
  return outputSchema55;
7097
7715
  }
7098
- async executeReactive(input, _output, _context) {
7099
- const { r: tr, g: tg, b: tb } = resolveColor3(input.color);
7100
- const amount = input.amount ?? 0.5;
7101
- const invAmount = 1 - amount;
7102
- const tintR = tr * amount;
7103
- const tintG = tg * amount;
7104
- const tintB = tb * amount;
7105
- const image = await produceImageOutput(input.image, (img) => {
7106
- const { data: src, width, height, channels } = img;
7107
- const pixelCount = width * height;
7108
- if (channels === 1) {
7109
- const dst2 = new Uint8ClampedArray(pixelCount * 3);
7110
- for (let i = 0;i < pixelCount; i++) {
7111
- const gray = src[i];
7112
- dst2[i * 3] = gray * invAmount + tintR;
7113
- dst2[i * 3 + 1] = gray * invAmount + tintG;
7114
- dst2[i * 3 + 2] = gray * invAmount + tintB;
7115
- }
7116
- return { data: dst2, width, height, channels: 3 };
7117
- }
7118
- const dst = new Uint8ClampedArray(src.length);
7119
- for (let i = 0;i < pixelCount; i++) {
7120
- const idx = i * channels;
7121
- dst[idx] = src[idx] * invAmount + tintR;
7122
- dst[idx + 1] = src[idx + 1] * invAmount + tintG;
7123
- dst[idx + 2] = src[idx + 2] * invAmount + tintB;
7124
- if (channels === 4) {
7125
- dst[idx + 3] = src[idx + 3];
7126
- }
7127
- }
7128
- return { data: dst, width, height, channels };
7129
- });
7130
- return { image };
7716
+ filterName = "tint";
7717
+ opParams(input) {
7718
+ return {
7719
+ color: input.color,
7720
+ amount: input.amount ?? 0.5
7721
+ };
7131
7722
  }
7132
7723
  }
7133
7724
  Workflow32.prototype.imageTint = CreateWorkflow31(ImageTintTask);
7134
- // src/task/image/ImageTransparencyTask.ts
7135
- import {
7136
- CreateWorkflow as CreateWorkflow32,
7137
- Task as Task58,
7138
- Workflow as Workflow33
7139
- } from "@workglow/task-graph";
7725
+ // src/task/image/transparency/ImageTransparencyTask.ts
7726
+ import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow33 } from "@workglow/task-graph";
7727
+ import { GpuImageSchema as GpuImageSchema17 } from "@workglow/util/media";
7140
7728
  var inputSchema57 = {
7141
7729
  type: "object",
7142
7730
  properties: {
7143
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7144
- opacity: {
7731
+ image: GpuImageSchema17({ title: "Image", description: "Source image" }),
7732
+ amount: {
7145
7733
  type: "number",
7146
- title: "Opacity",
7734
+ title: "Amount",
7147
7735
  description: "Opacity level (0.0 = fully transparent, 1.0 = fully opaque)",
7148
7736
  minimum: 0,
7149
- maximum: 1
7737
+ maximum: 1,
7738
+ default: 1
7150
7739
  }
7151
7740
  },
7152
- required: ["image", "opacity"],
7741
+ required: ["image"],
7153
7742
  additionalProperties: false
7154
7743
  };
7155
7744
  var outputSchema56 = {
7156
7745
  type: "object",
7157
- properties: {
7158
- image: ImageBinaryOrDataUriSchema({
7159
- title: "Image",
7160
- description: "Image with adjusted transparency"
7161
- })
7162
- },
7746
+ properties: { image: GpuImageSchema17({ title: "Image", description: "Image with adjusted transparency" }) },
7163
7747
  required: ["image"],
7164
7748
  additionalProperties: false
7165
7749
  };
7166
7750
 
7167
- class ImageTransparencyTask extends Task58 {
7751
+ class ImageTransparencyTask extends ImageFilterTask {
7168
7752
  static type = "ImageTransparencyTask";
7169
7753
  static category = "Image";
7170
7754
  static title = "Set Transparency";
@@ -7175,138 +7759,19 @@ class ImageTransparencyTask extends Task58 {
7175
7759
  static outputSchema() {
7176
7760
  return outputSchema56;
7177
7761
  }
7178
- async executeReactive(input, _output, _context) {
7179
- const { opacity } = input;
7180
- const image = await produceImageOutput(input.image, (img) => {
7181
- const { data: src, width, height, channels: srcCh } = img;
7182
- const pixelCount = width * height;
7183
- const dst = new Uint8ClampedArray(pixelCount * 4);
7184
- const alphaScale = Math.round(opacity * 255);
7185
- for (let i = 0;i < pixelCount; i++) {
7186
- const srcIdx = i * srcCh;
7187
- const dstIdx = i * 4;
7188
- dst[dstIdx] = src[srcIdx];
7189
- dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
7190
- dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
7191
- const srcAlpha = srcCh === 4 ? src[srcIdx + 3] : 255;
7192
- dst[dstIdx + 3] = (srcAlpha * alphaScale + 127) / 255;
7193
- }
7194
- return { data: dst, width, height, channels: 4 };
7195
- });
7196
- return { image };
7762
+ filterName = "transparency";
7763
+ opParams(input) {
7764
+ return { amount: input.amount ?? 1 };
7197
7765
  }
7198
7766
  }
7199
7767
  Workflow33.prototype.imageTransparency = CreateWorkflow32(ImageTransparencyTask);
7200
- // src/task/image/ImageWatermarkTask.ts
7201
- import {
7202
- CreateWorkflow as CreateWorkflow33,
7203
- Task as Task59,
7204
- Workflow as Workflow34
7205
- } from "@workglow/task-graph";
7206
- var inputSchema58 = {
7207
- type: "object",
7208
- properties: {
7209
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Source image" }),
7210
- spacing: {
7211
- type: "integer",
7212
- title: "Spacing",
7213
- description: "Pattern spacing in pixels",
7214
- minimum: 8,
7215
- default: 64
7216
- },
7217
- opacity: {
7218
- type: "number",
7219
- title: "Opacity",
7220
- description: "Watermark opacity (0.0-1.0)",
7221
- minimum: 0,
7222
- maximum: 1,
7223
- default: 0.3
7224
- },
7225
- pattern: {
7226
- type: "string",
7227
- enum: ["diagonal-lines", "grid", "dots"],
7228
- title: "Pattern",
7229
- description: "Watermark pattern type",
7230
- default: "diagonal-lines"
7231
- }
7232
- },
7233
- required: ["image"],
7234
- additionalProperties: false
7235
- };
7236
- var outputSchema57 = {
7237
- type: "object",
7238
- properties: {
7239
- image: ImageBinaryOrDataUriSchema({ title: "Image", description: "Watermarked image" })
7240
- },
7241
- required: ["image"],
7242
- additionalProperties: false
7243
- };
7244
-
7245
- class ImageWatermarkTask extends Task59 {
7246
- static type = "ImageWatermarkTask";
7247
- static category = "Image";
7248
- static title = "Add Watermark";
7249
- static description = "Adds a repeating pattern watermark to an image";
7250
- static inputSchema() {
7251
- return inputSchema58;
7252
- }
7253
- static outputSchema() {
7254
- return outputSchema57;
7255
- }
7256
- async executeReactive(input, _output, _context) {
7257
- const { spacing = 64, opacity = 0.3, pattern = "diagonal-lines" } = input;
7258
- const image = await produceImageOutput(input.image, (img) => {
7259
- const { data: src, width, height, channels: srcCh } = img;
7260
- const outCh = 4;
7261
- const dst = new Uint8ClampedArray(width * height * outCh);
7262
- const lineWidth = 2;
7263
- const dotRadius = Math.max(2, spacing >> 3);
7264
- const dotRadiusSq = dotRadius * dotRadius;
7265
- const half = spacing >> 1;
7266
- const alpha = Math.round(opacity * 255);
7267
- for (let y = 0;y < height; y++) {
7268
- for (let x = 0;x < width; x++) {
7269
- const srcIdx = (y * width + x) * srcCh;
7270
- const dstIdx = (y * width + x) * outCh;
7271
- const sr = src[srcIdx];
7272
- const sg = srcCh >= 3 ? src[srcIdx + 1] : sr;
7273
- const sb = srcCh >= 3 ? src[srcIdx + 2] : sr;
7274
- const sa = srcCh === 4 ? src[srcIdx + 3] : 255;
7275
- let isPattern = false;
7276
- if (pattern === "diagonal-lines") {
7277
- isPattern = (x + y) % spacing < lineWidth;
7278
- } else if (pattern === "grid") {
7279
- isPattern = x % spacing < lineWidth || y % spacing < lineWidth;
7280
- } else {
7281
- const dx = x % spacing - half;
7282
- const dy = y % spacing - half;
7283
- isPattern = dx * dx + dy * dy < dotRadiusSq;
7284
- }
7285
- if (isPattern) {
7286
- const blend = alpha;
7287
- const invBlend = 255 - blend;
7288
- dst[dstIdx] = (sr * invBlend + 255 * blend + 127) / 255;
7289
- dst[dstIdx + 1] = (sg * invBlend + 255 * blend + 127) / 255;
7290
- dst[dstIdx + 2] = (sb * invBlend + 255 * blend + 127) / 255;
7291
- dst[dstIdx + 3] = sa;
7292
- } else {
7293
- dst[dstIdx] = sr;
7294
- dst[dstIdx + 1] = sg;
7295
- dst[dstIdx + 2] = sb;
7296
- dst[dstIdx + 3] = sa;
7297
- }
7298
- }
7299
- }
7300
- return { data: dst, width, height, channels: outCh };
7301
- });
7302
- return { image };
7303
- }
7304
- }
7305
- Workflow34.prototype.imageWatermark = CreateWorkflow33(ImageWatermarkTask);
7306
7768
  // src/task/InputTask.ts
7307
- import { CreateWorkflow as CreateWorkflow34, Task as Task60, Workflow as Workflow35 } from "@workglow/task-graph";
7769
+ import { CreateWorkflow as CreateWorkflow33, Task as Task44, Workflow as Workflow34 } from "@workglow/task-graph";
7770
+ function passthroughInput(input) {
7771
+ return input;
7772
+ }
7308
7773
 
7309
- class InputTask extends Task60 {
7774
+ class InputTask extends Task44 {
7310
7775
  static type = "InputTask";
7311
7776
  static category = "Flow Control";
7312
7777
  static title = "Input";
@@ -7334,8 +7799,11 @@ class InputTask extends Task60 {
7334
7799
  outputSchema() {
7335
7800
  return this.config?.outputSchema ?? this.constructor.outputSchema();
7336
7801
  }
7337
- async executeReactive(input) {
7338
- return input;
7802
+ async execute(input, _context) {
7803
+ return passthroughInput(input);
7804
+ }
7805
+ async executePreview(input) {
7806
+ return passthroughInput(input);
7339
7807
  }
7340
7808
  async* executeStream(input, context) {
7341
7809
  if (context.inputStreams) {
@@ -7358,15 +7826,15 @@ class InputTask extends Task60 {
7358
7826
  yield { type: "finish", data: input };
7359
7827
  }
7360
7828
  }
7361
- Workflow35.prototype.input = CreateWorkflow34(InputTask);
7829
+ Workflow34.prototype.input = CreateWorkflow33(InputTask);
7362
7830
  // src/task/JavaScriptTask.ts
7363
7831
  import {
7364
- CreateWorkflow as CreateWorkflow35,
7832
+ CreateWorkflow as CreateWorkflow34,
7365
7833
  Entitlements as Entitlements7,
7366
- Task as Task61,
7834
+ Task as Task45,
7367
7835
  TaskConfigSchema as TaskConfigSchema32,
7368
7836
  TaskInvalidInputError as TaskInvalidInputError3,
7369
- Workflow as Workflow36
7837
+ Workflow as Workflow35
7370
7838
  } from "@workglow/task-graph";
7371
7839
 
7372
7840
  // src/util/acorn.js
@@ -11831,6 +12299,23 @@ Interpreter["Status"] = Interpreter.Status;
11831
12299
 
11832
12300
  // src/task/JavaScriptTask.ts
11833
12301
  var isValidIdentifier = (key) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
12302
+ function runJavaScript(input2, configuredCode) {
12303
+ const output = {};
12304
+ const code = input2.javascript_code || configuredCode;
12305
+ if (code) {
12306
+ try {
12307
+ const inputVariables = Object.keys(input2).filter((key) => key !== "javascript_code").filter(isValidIdentifier);
12308
+ const inputVariablesString = inputVariables.map((key) => `var ${key} = ${JSON.stringify(input2[key])};`).join(`
12309
+ `);
12310
+ const myInterpreter = new Interpreter(`${inputVariablesString} ${code}`);
12311
+ myInterpreter.run();
12312
+ output.output = myInterpreter.value;
12313
+ } catch (e) {
12314
+ throw new TaskInvalidInputError3(`JavaScript execution failed: ${e instanceof Error ? e.message : String(e)}`);
12315
+ }
12316
+ }
12317
+ return output;
12318
+ }
11834
12319
  var configSchema = {
11835
12320
  type: "object",
11836
12321
  properties: {
@@ -11845,7 +12330,7 @@ var configSchema = {
11845
12330
  },
11846
12331
  additionalProperties: false
11847
12332
  };
11848
- var inputSchema59 = {
12333
+ var inputSchema58 = {
11849
12334
  type: "object",
11850
12335
  properties: {
11851
12336
  javascript_code: {
@@ -11859,7 +12344,7 @@ var inputSchema59 = {
11859
12344
  required: ["javascript_code"],
11860
12345
  additionalProperties: true
11861
12346
  };
11862
- var outputSchema58 = {
12347
+ var outputSchema57 = {
11863
12348
  type: "object",
11864
12349
  properties: {
11865
12350
  output: {
@@ -11871,7 +12356,7 @@ var outputSchema58 = {
11871
12356
  additionalProperties: false
11872
12357
  };
11873
12358
 
11874
- class JavaScriptTask extends Task61 {
12359
+ class JavaScriptTask extends Task45 {
11875
12360
  static type = "JavaScriptTask";
11876
12361
  static category = "Utility";
11877
12362
  static title = "JavaScript Interpreter";
@@ -11892,10 +12377,10 @@ class JavaScriptTask extends Task61 {
11892
12377
  return configSchema;
11893
12378
  }
11894
12379
  static inputSchema() {
11895
- return inputSchema59;
12380
+ return inputSchema58;
11896
12381
  }
11897
12382
  static outputSchema() {
11898
- return outputSchema58;
12383
+ return outputSchema57;
11899
12384
  }
11900
12385
  inputSchema() {
11901
12386
  if (this.config?.javascript_code) {
@@ -11908,36 +12393,26 @@ class JavaScriptTask extends Task61 {
11908
12393
  additionalProperties: true
11909
12394
  };
11910
12395
  }
11911
- return inputSchema59;
12396
+ return inputSchema58;
11912
12397
  }
11913
- async executeReactive(input2, output) {
11914
- const code = input2.javascript_code || this.config.javascript_code;
11915
- if (code) {
11916
- try {
11917
- const inputVariables = Object.keys(input2).filter((key) => key !== "javascript_code").filter(isValidIdentifier);
11918
- const inputVariablesString = inputVariables.map((key) => `var ${key} = ${JSON.stringify(input2[key])};`).join(`
11919
- `);
11920
- const myInterpreter = new Interpreter(`${inputVariablesString} ${code}`);
11921
- myInterpreter.run();
11922
- output.output = myInterpreter.value;
11923
- } catch (e) {
11924
- throw new TaskInvalidInputError3(`JavaScript execution failed: ${e instanceof Error ? e.message : String(e)}`);
11925
- }
11926
- }
11927
- return output;
12398
+ async execute(input2) {
12399
+ return runJavaScript(input2, this.config.javascript_code);
12400
+ }
12401
+ async executePreview(input2) {
12402
+ return runJavaScript(input2, this.config.javascript_code);
11928
12403
  }
11929
12404
  }
11930
12405
  var javaScript = (input2, config = {}) => {
11931
12406
  return new JavaScriptTask(config).run(input2);
11932
12407
  };
11933
- Workflow36.prototype.javaScript = CreateWorkflow35(JavaScriptTask);
12408
+ Workflow35.prototype.javaScript = CreateWorkflow34(JavaScriptTask);
11934
12409
  // src/task/JsonPathTask.ts
11935
12410
  import {
11936
- CreateWorkflow as CreateWorkflow36,
11937
- Task as Task62,
11938
- Workflow as Workflow37
12411
+ CreateWorkflow as CreateWorkflow35,
12412
+ Task as Task46,
12413
+ Workflow as Workflow36
11939
12414
  } from "@workglow/task-graph";
11940
- var inputSchema60 = {
12415
+ var inputSchema59 = {
11941
12416
  type: "object",
11942
12417
  properties: {
11943
12418
  value: {
@@ -11953,7 +12428,7 @@ var inputSchema60 = {
11953
12428
  required: ["value", "path"],
11954
12429
  additionalProperties: false
11955
12430
  };
11956
- var outputSchema59 = {
12431
+ var outputSchema58 = {
11957
12432
  type: "object",
11958
12433
  properties: {
11959
12434
  result: {
@@ -11985,36 +12460,41 @@ function resolvePath(obj, segments) {
11985
12460
  const next2 = obj[head];
11986
12461
  return resolvePath(next2, tail);
11987
12462
  }
12463
+ function extractJsonPath(value, path) {
12464
+ const segments = path.split(".");
12465
+ return resolvePath(value, segments);
12466
+ }
11988
12467
 
11989
- class JsonPathTask extends Task62 {
12468
+ class JsonPathTask extends Task46 {
11990
12469
  static type = "JsonPathTask";
11991
12470
  static category = "Utility";
11992
12471
  static title = "JSON Path";
11993
12472
  static description = "Extracts a value from an object using a dot-notation path";
11994
12473
  static inputSchema() {
11995
- return inputSchema60;
12474
+ return inputSchema59;
11996
12475
  }
11997
12476
  static outputSchema() {
11998
- return outputSchema59;
12477
+ return outputSchema58;
12478
+ }
12479
+ async execute(input2, _context) {
12480
+ return { result: extractJsonPath(input2.value, input2.path) };
11999
12481
  }
12000
- async executeReactive(input2, _output, _context) {
12001
- const segments = input2.path.split(".");
12002
- const result = resolvePath(input2.value, segments);
12003
- return { result };
12482
+ async executePreview(input2, _context) {
12483
+ return { result: extractJsonPath(input2.value, input2.path) };
12004
12484
  }
12005
12485
  }
12006
- Workflow37.prototype.jsonPath = CreateWorkflow36(JsonPathTask);
12486
+ Workflow36.prototype.jsonPath = CreateWorkflow35(JsonPathTask);
12007
12487
  // src/task/JsonTask.ts
12008
12488
  import {
12009
12489
  createGraphFromDependencyJSON,
12010
12490
  createGraphFromGraphJSON,
12011
- CreateWorkflow as CreateWorkflow37,
12491
+ CreateWorkflow as CreateWorkflow36,
12012
12492
  Dataflow,
12013
12493
  GraphAsTask as GraphAsTask2,
12014
12494
  TaskConfigurationError as TaskConfigurationError3,
12015
- Workflow as Workflow38
12495
+ Workflow as Workflow37
12016
12496
  } from "@workglow/task-graph";
12017
- var inputSchema61 = {
12497
+ var inputSchema60 = {
12018
12498
  type: "object",
12019
12499
  properties: {
12020
12500
  json: {
@@ -12025,7 +12505,7 @@ var inputSchema61 = {
12025
12505
  },
12026
12506
  additionalProperties: false
12027
12507
  };
12028
- var outputSchema60 = {
12508
+ var outputSchema59 = {
12029
12509
  type: "object",
12030
12510
  properties: {
12031
12511
  output: {
@@ -12042,10 +12522,10 @@ class JsonTask extends GraphAsTask2 {
12042
12522
  static title = "JSON Task";
12043
12523
  static description = "A task that creates and manages task graphs from JSON configurations";
12044
12524
  static inputSchema() {
12045
- return inputSchema61;
12525
+ return inputSchema60;
12046
12526
  }
12047
12527
  static outputSchema() {
12048
- return outputSchema60;
12528
+ return outputSchema59;
12049
12529
  }
12050
12530
  regenerateGraph() {
12051
12531
  if (!this.runInputData.json)
@@ -12079,26 +12559,26 @@ class JsonTask extends GraphAsTask2 {
12079
12559
  var json = (input2, config = {}) => {
12080
12560
  return new JsonTask(config).run(input2);
12081
12561
  };
12082
- Workflow38.prototype.json = CreateWorkflow37(JsonTask);
12562
+ Workflow37.prototype.json = CreateWorkflow36(JsonTask);
12083
12563
  // src/task/LambdaTask.ts
12084
12564
  import {
12085
- CreateWorkflow as CreateWorkflow38,
12565
+ CreateWorkflow as CreateWorkflow37,
12086
12566
  DATAFLOW_ALL_PORTS,
12087
- Task as Task63,
12567
+ Task as Task47,
12088
12568
  TaskConfigSchema as TaskConfigSchema33,
12089
12569
  TaskConfigurationError as TaskConfigurationError4,
12090
- Workflow as Workflow39
12570
+ Workflow as Workflow38
12091
12571
  } from "@workglow/task-graph";
12092
12572
  var lambdaTaskConfigSchema = {
12093
12573
  type: "object",
12094
12574
  properties: {
12095
12575
  ...TaskConfigSchema33["properties"],
12096
12576
  execute: {},
12097
- executeReactive: {}
12577
+ executePreview: {}
12098
12578
  },
12099
12579
  additionalProperties: false
12100
12580
  };
12101
- var inputSchema62 = {
12581
+ var inputSchema61 = {
12102
12582
  type: "object",
12103
12583
  properties: {
12104
12584
  [DATAFLOW_ALL_PORTS]: {
@@ -12108,7 +12588,7 @@ var inputSchema62 = {
12108
12588
  },
12109
12589
  additionalProperties: true
12110
12590
  };
12111
- var outputSchema61 = {
12591
+ var outputSchema60 = {
12112
12592
  type: "object",
12113
12593
  properties: {
12114
12594
  [DATAFLOW_ALL_PORTS]: {
@@ -12119,7 +12599,7 @@ var outputSchema61 = {
12119
12599
  additionalProperties: true
12120
12600
  };
12121
12601
 
12122
- class LambdaTask extends Task63 {
12602
+ class LambdaTask extends Task47 {
12123
12603
  static type = "LambdaTask";
12124
12604
  static title = "Lambda Task";
12125
12605
  static description = "A task that wraps a provided function and its input";
@@ -12129,17 +12609,17 @@ class LambdaTask extends Task63 {
12129
12609
  return lambdaTaskConfigSchema;
12130
12610
  }
12131
12611
  static inputSchema() {
12132
- return inputSchema62;
12612
+ return inputSchema61;
12133
12613
  }
12134
12614
  static outputSchema() {
12135
- return outputSchema61;
12615
+ return outputSchema60;
12136
12616
  }
12137
12617
  canSerializeConfig() {
12138
12618
  return false;
12139
12619
  }
12140
12620
  constructor(config = {}) {
12141
- if (!config.execute && !config.executeReactive) {
12142
- throw new TaskConfigurationError4("LambdaTask must have either execute or executeReactive function in config");
12621
+ if (!config.execute && !config.executePreview) {
12622
+ throw new TaskConfigurationError4("LambdaTask must have either execute or executePreview function in config");
12143
12623
  }
12144
12624
  super(config);
12145
12625
  }
@@ -12149,11 +12629,11 @@ class LambdaTask extends Task63 {
12149
12629
  }
12150
12630
  return {};
12151
12631
  }
12152
- async executeReactive(input2, output, context) {
12153
- if (typeof this.config.executeReactive === "function") {
12154
- return await this.config.executeReactive(input2, output, context) ?? output;
12632
+ async executePreview(input2, context) {
12633
+ if (typeof this.config.executePreview === "function") {
12634
+ return await this.config.executePreview(input2, context);
12155
12635
  }
12156
- return output;
12636
+ return;
12157
12637
  }
12158
12638
  }
12159
12639
  function lambda(input2, config) {
@@ -12166,14 +12646,14 @@ function lambda(input2, config) {
12166
12646
  const task = new LambdaTask({ ...config, defaults: input2 });
12167
12647
  return task.run();
12168
12648
  }
12169
- Workflow39.prototype.lambda = CreateWorkflow38(LambdaTask);
12649
+ Workflow38.prototype.lambda = CreateWorkflow37(LambdaTask);
12170
12650
  // src/task/mcp/McpListTask.ts
12171
12651
  import {
12172
- CreateWorkflow as CreateWorkflow39,
12652
+ CreateWorkflow as CreateWorkflow38,
12173
12653
  Entitlements as Entitlements8,
12174
12654
  mergeEntitlements as mergeEntitlements4,
12175
- Task as Task64,
12176
- Workflow as Workflow40
12655
+ Task as Task48,
12656
+ Workflow as Workflow39
12177
12657
  } from "@workglow/task-graph";
12178
12658
 
12179
12659
  // src/util/getMcpServerTransport.ts
@@ -12347,7 +12827,7 @@ var outputSchemaAll = {
12347
12827
  additionalProperties: false
12348
12828
  };
12349
12829
 
12350
- class McpListTask extends Task64 {
12830
+ class McpListTask extends Task48 {
12351
12831
  static type = "McpListTask";
12352
12832
  static category = "MCP";
12353
12833
  static title = "MCP List";
@@ -12454,15 +12934,15 @@ class McpListTask extends Task64 {
12454
12934
  var mcpList = async (input2, config = {}) => {
12455
12935
  return new McpListTask(config).run(input2);
12456
12936
  };
12457
- Workflow40.prototype.mcpList = CreateWorkflow39(McpListTask);
12937
+ Workflow39.prototype.mcpList = CreateWorkflow38(McpListTask);
12458
12938
  // src/task/mcp/McpPromptGetTask.ts
12459
12939
  import {
12460
- CreateWorkflow as CreateWorkflow40,
12940
+ CreateWorkflow as CreateWorkflow39,
12461
12941
  Entitlements as Entitlements9,
12462
12942
  mergeEntitlements as mergeEntitlements5,
12463
- Task as Task65,
12943
+ Task as Task49,
12464
12944
  TaskConfigSchema as TaskConfigSchema34,
12465
- Workflow as Workflow41
12945
+ Workflow as Workflow40
12466
12946
  } from "@workglow/task-graph";
12467
12947
  var annotationsSchema = {
12468
12948
  type: "object",
@@ -12597,7 +13077,7 @@ var fallbackInputSchema = {
12597
13077
  additionalProperties: false
12598
13078
  };
12599
13079
 
12600
- class McpPromptGetTask extends Task65 {
13080
+ class McpPromptGetTask extends Task49 {
12601
13081
  static type = "McpPromptGetTask";
12602
13082
  static category = "MCP";
12603
13083
  static title = "MCP Get Prompt";
@@ -12720,15 +13200,15 @@ class McpPromptGetTask extends Task65 {
12720
13200
  var mcpPromptGet = async (input2, config) => {
12721
13201
  return new McpPromptGetTask(config).run(input2);
12722
13202
  };
12723
- Workflow41.prototype.mcpPromptGet = CreateWorkflow40(McpPromptGetTask);
13203
+ Workflow40.prototype.mcpPromptGet = CreateWorkflow39(McpPromptGetTask);
12724
13204
  // src/task/mcp/McpResourceReadTask.ts
12725
13205
  import {
12726
- CreateWorkflow as CreateWorkflow41,
13206
+ CreateWorkflow as CreateWorkflow40,
12727
13207
  Entitlements as Entitlements10,
12728
13208
  mergeEntitlements as mergeEntitlements6,
12729
- Task as Task66,
13209
+ Task as Task50,
12730
13210
  TaskConfigSchema as TaskConfigSchema35,
12731
- Workflow as Workflow42
13211
+ Workflow as Workflow41
12732
13212
  } from "@workglow/task-graph";
12733
13213
  var contentItemSchema = {
12734
13214
  anyOf: [
@@ -12756,12 +13236,12 @@ var contentItemSchema = {
12756
13236
  }
12757
13237
  ]
12758
13238
  };
12759
- var inputSchema63 = {
13239
+ var inputSchema62 = {
12760
13240
  type: "object",
12761
13241
  properties: {},
12762
13242
  additionalProperties: false
12763
13243
  };
12764
- var outputSchema62 = {
13244
+ var outputSchema61 = {
12765
13245
  type: "object",
12766
13246
  properties: {
12767
13247
  contents: {
@@ -12775,7 +13255,7 @@ var outputSchema62 = {
12775
13255
  additionalProperties: false
12776
13256
  };
12777
13257
 
12778
- class McpResourceReadTask extends Task66 {
13258
+ class McpResourceReadTask extends Task50 {
12779
13259
  static type = "McpResourceReadTask";
12780
13260
  static category = "MCP";
12781
13261
  static title = "MCP Read Resource";
@@ -12808,10 +13288,10 @@ class McpResourceReadTask extends Task66 {
12808
13288
  });
12809
13289
  }
12810
13290
  static inputSchema() {
12811
- return inputSchema63;
13291
+ return inputSchema62;
12812
13292
  }
12813
13293
  static outputSchema() {
12814
- return outputSchema62;
13294
+ return outputSchema61;
12815
13295
  }
12816
13296
  static configSchema() {
12817
13297
  const { mcpServerConfigSchema: mcpServerConfigSchema2 } = getMcpTaskDeps();
@@ -12848,13 +13328,13 @@ class McpResourceReadTask extends Task66 {
12848
13328
  var mcpResourceRead = async (config) => {
12849
13329
  return new McpResourceReadTask(config).run({});
12850
13330
  };
12851
- Workflow42.prototype.mcpResourceRead = CreateWorkflow41(McpResourceReadTask);
13331
+ Workflow41.prototype.mcpResourceRead = CreateWorkflow40(McpResourceReadTask);
12852
13332
  // src/task/mcp/McpSearchTask.ts
12853
13333
  import {
12854
- CreateWorkflow as CreateWorkflow42,
13334
+ CreateWorkflow as CreateWorkflow41,
12855
13335
  Entitlements as Entitlements11,
12856
- Task as Task67,
12857
- Workflow as Workflow43
13336
+ Task as Task51,
13337
+ Workflow as Workflow42
12858
13338
  } from "@workglow/task-graph";
12859
13339
  var MCP_REGISTRY_BASE = "https://registry.modelcontextprotocol.io/v0.1";
12860
13340
  var McpSearchInputSchema = {
@@ -12994,7 +13474,7 @@ async function searchMcpRegistry(query, signal) {
12994
13474
  return page.results;
12995
13475
  }
12996
13476
 
12997
- class McpSearchTask extends Task67 {
13477
+ class McpSearchTask extends Task51 {
12998
13478
  static type = "McpSearchTask";
12999
13479
  static category = "MCP";
13000
13480
  static title = "MCP Search";
@@ -13021,15 +13501,15 @@ class McpSearchTask extends Task67 {
13021
13501
  var mcpSearch = (input2, config) => {
13022
13502
  return new McpSearchTask(config).run(input2);
13023
13503
  };
13024
- Workflow43.prototype.mcpSearch = CreateWorkflow42(McpSearchTask);
13504
+ Workflow42.prototype.mcpSearch = CreateWorkflow41(McpSearchTask);
13025
13505
  // src/task/mcp/McpToolCallTask.ts
13026
13506
  import {
13027
- CreateWorkflow as CreateWorkflow43,
13507
+ CreateWorkflow as CreateWorkflow42,
13028
13508
  Entitlements as Entitlements12,
13029
13509
  mergeEntitlements as mergeEntitlements7,
13030
- Task as Task68,
13510
+ Task as Task52,
13031
13511
  TaskConfigSchema as TaskConfigSchema36,
13032
- Workflow as Workflow44
13512
+ Workflow as Workflow43
13033
13513
  } from "@workglow/task-graph";
13034
13514
  var annotationsSchema2 = {
13035
13515
  type: "object",
@@ -13156,7 +13636,7 @@ var fallbackInputSchema2 = {
13156
13636
  additionalProperties: true
13157
13637
  };
13158
13638
 
13159
- class McpToolCallTask extends Task68 {
13639
+ class McpToolCallTask extends Task52 {
13160
13640
  static type = "McpToolCallTask";
13161
13641
  static category = "MCP";
13162
13642
  static title = "MCP Call Tool";
@@ -13294,7 +13774,7 @@ class McpToolCallTask extends Task68 {
13294
13774
  var mcpToolCall = async (input2, config) => {
13295
13775
  return new McpToolCallTask(config).run(input2);
13296
13776
  };
13297
- Workflow44.prototype.mcpToolCall = CreateWorkflow43(McpToolCallTask);
13777
+ Workflow43.prototype.mcpToolCall = CreateWorkflow42(McpToolCallTask);
13298
13778
  // src/task/McpElicitationConnector.ts
13299
13779
  function defaultAbortError() {
13300
13780
  const err = new Error("The operation was aborted");
@@ -13388,13 +13868,13 @@ class McpElicitationConnector {
13388
13868
  }
13389
13869
  }
13390
13870
  // src/task/MergeTask.ts
13391
- import { CreateWorkflow as CreateWorkflow44, Task as Task69, Workflow as Workflow45 } from "@workglow/task-graph";
13392
- var inputSchema64 = {
13871
+ import { CreateWorkflow as CreateWorkflow43, Task as Task53, Workflow as Workflow44 } from "@workglow/task-graph";
13872
+ var inputSchema63 = {
13393
13873
  type: "object",
13394
13874
  properties: {},
13395
13875
  additionalProperties: true
13396
13876
  };
13397
- var outputSchema63 = {
13877
+ var outputSchema62 = {
13398
13878
  type: "object",
13399
13879
  properties: {
13400
13880
  output: {
@@ -13406,17 +13886,17 @@ var outputSchema63 = {
13406
13886
  additionalProperties: false
13407
13887
  };
13408
13888
 
13409
- class MergeTask extends Task69 {
13889
+ class MergeTask extends Task53 {
13410
13890
  static type = "MergeTask";
13411
13891
  static category = "Utility";
13412
13892
  static title = "Merge";
13413
13893
  static description = "Merges multiple inputs into a single array output";
13414
13894
  static cacheable = true;
13415
13895
  static inputSchema() {
13416
- return inputSchema64;
13896
+ return inputSchema63;
13417
13897
  }
13418
13898
  static outputSchema() {
13419
- return outputSchema63;
13899
+ return outputSchema62;
13420
13900
  }
13421
13901
  async execute(input2, _context) {
13422
13902
  const keys = Object.keys(input2).sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
@@ -13430,11 +13910,14 @@ var merge = (input2, config = {}) => {
13430
13910
  const task = new MergeTask(config);
13431
13911
  return task.run(input2);
13432
13912
  };
13433
- Workflow45.prototype.merge = CreateWorkflow44(MergeTask);
13913
+ Workflow44.prototype.merge = CreateWorkflow43(MergeTask);
13434
13914
  // src/task/OutputTask.ts
13435
- import { CreateWorkflow as CreateWorkflow45, Task as Task70, Workflow as Workflow46 } from "@workglow/task-graph";
13915
+ import { CreateWorkflow as CreateWorkflow44, Task as Task54, Workflow as Workflow45 } from "@workglow/task-graph";
13916
+ function passthroughInput2(input2) {
13917
+ return input2;
13918
+ }
13436
13919
 
13437
- class OutputTask extends Task70 {
13920
+ class OutputTask extends Task54 {
13438
13921
  static type = "OutputTask";
13439
13922
  static category = "Flow Control";
13440
13923
  static title = "Output";
@@ -13463,8 +13946,11 @@ class OutputTask extends Task70 {
13463
13946
  outputSchema() {
13464
13947
  return this.config?.outputSchema ?? this.constructor.outputSchema();
13465
13948
  }
13466
- async executeReactive(input2) {
13467
- return input2;
13949
+ async execute(input2, _context) {
13950
+ return passthroughInput2(input2);
13951
+ }
13952
+ async executePreview(input2) {
13953
+ return passthroughInput2(input2);
13468
13954
  }
13469
13955
  async* executeStream(input2, context) {
13470
13956
  if (context.inputStreams) {
@@ -13487,20 +13973,46 @@ class OutputTask extends Task70 {
13487
13973
  yield { type: "finish", data: input2 };
13488
13974
  }
13489
13975
  }
13490
- Workflow46.prototype.output = CreateWorkflow45(OutputTask);
13976
+ Workflow45.prototype.output = CreateWorkflow44(OutputTask);
13491
13977
  // src/task/RegexTask.ts
13492
13978
  import {
13493
- CreateWorkflow as CreateWorkflow46,
13494
- Task as Task71,
13979
+ CreateWorkflow as CreateWorkflow45,
13980
+ Task as Task55,
13495
13981
  TaskInvalidInputError as TaskInvalidInputError4,
13496
- Workflow as Workflow47
13982
+ Workflow as Workflow46
13497
13983
  } from "@workglow/task-graph";
13498
13984
  var MAX_BRACKET_COUNT = 100;
13499
13985
  function hasNestedQuantifiers(pattern) {
13500
13986
  const withoutClasses = pattern.replace(/\[(?:[^\]\\]|\\.)*\]/g, "X");
13501
13987
  return /\([^)]*[+*][^)]*\)[+*?]|\([^)]*[+*][^)]*\)\{/.test(withoutClasses);
13502
13988
  }
13503
- var inputSchema65 = {
13989
+ function executeRegex(input2) {
13990
+ const bracketCount = (input2.pattern.match(/\[/g) ?? []).length;
13991
+ if (bracketCount > MAX_BRACKET_COUNT) {
13992
+ throw new TaskInvalidInputError4("Regex pattern rejected: too many '[' characters (potential ReDoS). " + "Simplify the pattern to reduce complexity.");
13993
+ }
13994
+ if (hasNestedQuantifiers(input2.pattern)) {
13995
+ throw new TaskInvalidInputError4("Regex pattern rejected: nested quantifiers detected (potential ReDoS). " + "Simplify the pattern to avoid catastrophic backtracking.");
13996
+ }
13997
+ const flags = input2.flags ?? "";
13998
+ const regex = new RegExp(input2.pattern, flags);
13999
+ if (flags.includes("g")) {
14000
+ const allMatches = Array.from(input2.value.matchAll(new RegExp(input2.pattern, flags)));
14001
+ return {
14002
+ match: allMatches.length > 0,
14003
+ matches: allMatches.map((m) => m[0])
14004
+ };
14005
+ }
14006
+ const result = regex.exec(input2.value);
14007
+ if (!result) {
14008
+ return { match: false, matches: [] };
14009
+ }
14010
+ return {
14011
+ match: true,
14012
+ matches: result.slice(0)
14013
+ };
14014
+ }
14015
+ var inputSchema64 = {
13504
14016
  type: "object",
13505
14017
  properties: {
13506
14018
  value: {
@@ -13523,7 +14035,7 @@ var inputSchema65 = {
13523
14035
  required: ["value", "pattern"],
13524
14036
  additionalProperties: false
13525
14037
  };
13526
- var outputSchema64 = {
14038
+ var outputSchema63 = {
13527
14039
  type: "object",
13528
14040
  properties: {
13529
14041
  match: {
@@ -13542,48 +14054,28 @@ var outputSchema64 = {
13542
14054
  additionalProperties: false
13543
14055
  };
13544
14056
 
13545
- class RegexTask extends Task71 {
14057
+ class RegexTask extends Task55 {
13546
14058
  static type = "RegexTask";
13547
14059
  static category = "String";
13548
14060
  static title = "Regex";
13549
14061
  static description = "Matches a string against a regular expression pattern";
13550
14062
  static inputSchema() {
13551
- return inputSchema65;
14063
+ return inputSchema64;
13552
14064
  }
13553
14065
  static outputSchema() {
13554
- return outputSchema64;
14066
+ return outputSchema63;
13555
14067
  }
13556
- async executeReactive(input2, _output, _context) {
13557
- const bracketCount = (input2.pattern.match(/\[/g) ?? []).length;
13558
- if (bracketCount > MAX_BRACKET_COUNT) {
13559
- throw new TaskInvalidInputError4("Regex pattern rejected: too many '[' characters (potential ReDoS). " + "Simplify the pattern to reduce complexity.");
13560
- }
13561
- if (hasNestedQuantifiers(input2.pattern)) {
13562
- throw new TaskInvalidInputError4("Regex pattern rejected: nested quantifiers detected (potential ReDoS). " + "Simplify the pattern to avoid catastrophic backtracking.");
13563
- }
13564
- const flags = input2.flags ?? "";
13565
- const regex = new RegExp(input2.pattern, flags);
13566
- if (flags.includes("g")) {
13567
- const allMatches = Array.from(input2.value.matchAll(new RegExp(input2.pattern, flags)));
13568
- return {
13569
- match: allMatches.length > 0,
13570
- matches: allMatches.map((m) => m[0])
13571
- };
13572
- }
13573
- const result = regex.exec(input2.value);
13574
- if (!result) {
13575
- return { match: false, matches: [] };
13576
- }
13577
- return {
13578
- match: true,
13579
- matches: result.slice(0)
13580
- };
14068
+ async execute(input2, _context) {
14069
+ return executeRegex(input2);
14070
+ }
14071
+ async executePreview(input2, _context) {
14072
+ return executeRegex(input2);
13581
14073
  }
13582
14074
  }
13583
- Workflow47.prototype.regex = CreateWorkflow46(RegexTask);
14075
+ Workflow46.prototype.regex = CreateWorkflow45(RegexTask);
13584
14076
  // src/task/scalar/ScalarAbsTask.ts
13585
- import { CreateWorkflow as CreateWorkflow47, Task as Task72, Workflow as Workflow48 } from "@workglow/task-graph";
13586
- var inputSchema66 = {
14077
+ import { CreateWorkflow as CreateWorkflow46, Task as Task56, Workflow as Workflow47 } from "@workglow/task-graph";
14078
+ var inputSchema65 = {
13587
14079
  type: "object",
13588
14080
  properties: {
13589
14081
  value: {
@@ -13595,7 +14087,7 @@ var inputSchema66 = {
13595
14087
  required: ["value"],
13596
14088
  additionalProperties: false
13597
14089
  };
13598
- var outputSchema65 = {
14090
+ var outputSchema64 = {
13599
14091
  type: "object",
13600
14092
  properties: {
13601
14093
  result: {
@@ -13608,25 +14100,25 @@ var outputSchema65 = {
13608
14100
  additionalProperties: false
13609
14101
  };
13610
14102
 
13611
- class ScalarAbsTask extends Task72 {
14103
+ class ScalarAbsTask extends Task56 {
13612
14104
  static type = "ScalarAbsTask";
13613
14105
  static category = "Math";
13614
14106
  static title = "Abs";
13615
14107
  static description = "Returns the absolute value of a number";
13616
14108
  static inputSchema() {
13617
- return inputSchema66;
14109
+ return inputSchema65;
13618
14110
  }
13619
14111
  static outputSchema() {
13620
- return outputSchema65;
14112
+ return outputSchema64;
13621
14113
  }
13622
14114
  async execute(input2, _context) {
13623
14115
  return { result: Math.abs(input2.value) };
13624
14116
  }
13625
14117
  }
13626
- Workflow48.prototype.scalarAbs = CreateWorkflow47(ScalarAbsTask);
14118
+ Workflow47.prototype.scalarAbs = CreateWorkflow46(ScalarAbsTask);
13627
14119
  // src/task/scalar/ScalarCeilTask.ts
13628
- import { CreateWorkflow as CreateWorkflow48, Task as Task73, Workflow as Workflow49 } from "@workglow/task-graph";
13629
- var inputSchema67 = {
14120
+ import { CreateWorkflow as CreateWorkflow47, Task as Task57, Workflow as Workflow48 } from "@workglow/task-graph";
14121
+ var inputSchema66 = {
13630
14122
  type: "object",
13631
14123
  properties: {
13632
14124
  value: {
@@ -13638,7 +14130,7 @@ var inputSchema67 = {
13638
14130
  required: ["value"],
13639
14131
  additionalProperties: false
13640
14132
  };
13641
- var outputSchema66 = {
14133
+ var outputSchema65 = {
13642
14134
  type: "object",
13643
14135
  properties: {
13644
14136
  result: {
@@ -13651,25 +14143,25 @@ var outputSchema66 = {
13651
14143
  additionalProperties: false
13652
14144
  };
13653
14145
 
13654
- class ScalarCeilTask extends Task73 {
14146
+ class ScalarCeilTask extends Task57 {
13655
14147
  static type = "ScalarCeilTask";
13656
14148
  static category = "Math";
13657
14149
  static title = "Ceil";
13658
14150
  static description = "Returns the smallest integer greater than or equal to a number";
13659
14151
  static inputSchema() {
13660
- return inputSchema67;
14152
+ return inputSchema66;
13661
14153
  }
13662
14154
  static outputSchema() {
13663
- return outputSchema66;
14155
+ return outputSchema65;
13664
14156
  }
13665
14157
  async execute(input2, _context) {
13666
14158
  return { result: Math.ceil(input2.value) };
13667
14159
  }
13668
14160
  }
13669
- Workflow49.prototype.scalarCeil = CreateWorkflow48(ScalarCeilTask);
14161
+ Workflow48.prototype.scalarCeil = CreateWorkflow47(ScalarCeilTask);
13670
14162
  // src/task/scalar/ScalarFloorTask.ts
13671
- import { CreateWorkflow as CreateWorkflow49, Task as Task74, Workflow as Workflow50 } from "@workglow/task-graph";
13672
- var inputSchema68 = {
14163
+ import { CreateWorkflow as CreateWorkflow48, Task as Task58, Workflow as Workflow49 } from "@workglow/task-graph";
14164
+ var inputSchema67 = {
13673
14165
  type: "object",
13674
14166
  properties: {
13675
14167
  value: {
@@ -13681,7 +14173,7 @@ var inputSchema68 = {
13681
14173
  required: ["value"],
13682
14174
  additionalProperties: false
13683
14175
  };
13684
- var outputSchema67 = {
14176
+ var outputSchema66 = {
13685
14177
  type: "object",
13686
14178
  properties: {
13687
14179
  result: {
@@ -13694,25 +14186,25 @@ var outputSchema67 = {
13694
14186
  additionalProperties: false
13695
14187
  };
13696
14188
 
13697
- class ScalarFloorTask extends Task74 {
14189
+ class ScalarFloorTask extends Task58 {
13698
14190
  static type = "ScalarFloorTask";
13699
14191
  static category = "Math";
13700
14192
  static title = "Floor";
13701
14193
  static description = "Returns the largest integer less than or equal to a number";
13702
14194
  static inputSchema() {
13703
- return inputSchema68;
14195
+ return inputSchema67;
13704
14196
  }
13705
14197
  static outputSchema() {
13706
- return outputSchema67;
14198
+ return outputSchema66;
13707
14199
  }
13708
14200
  async execute(input2, _context) {
13709
14201
  return { result: Math.floor(input2.value) };
13710
14202
  }
13711
14203
  }
13712
- Workflow50.prototype.scalarFloor = CreateWorkflow49(ScalarFloorTask);
14204
+ Workflow49.prototype.scalarFloor = CreateWorkflow48(ScalarFloorTask);
13713
14205
  // src/task/scalar/ScalarMaxTask.ts
13714
- import { CreateWorkflow as CreateWorkflow50, Task as Task75, Workflow as Workflow51 } from "@workglow/task-graph";
13715
- var inputSchema69 = {
14206
+ import { CreateWorkflow as CreateWorkflow49, Task as Task59, Workflow as Workflow50 } from "@workglow/task-graph";
14207
+ var inputSchema68 = {
13716
14208
  type: "object",
13717
14209
  properties: {
13718
14210
  values: {
@@ -13725,7 +14217,7 @@ var inputSchema69 = {
13725
14217
  required: ["values"],
13726
14218
  additionalProperties: false
13727
14219
  };
13728
- var outputSchema68 = {
14220
+ var outputSchema67 = {
13729
14221
  type: "object",
13730
14222
  properties: {
13731
14223
  result: {
@@ -13738,25 +14230,25 @@ var outputSchema68 = {
13738
14230
  additionalProperties: false
13739
14231
  };
13740
14232
 
13741
- class ScalarMaxTask extends Task75 {
14233
+ class ScalarMaxTask extends Task59 {
13742
14234
  static type = "ScalarMaxTask";
13743
14235
  static category = "Math";
13744
14236
  static title = "Max";
13745
14237
  static description = "Returns the largest of the given numbers";
13746
14238
  static inputSchema() {
13747
- return inputSchema69;
14239
+ return inputSchema68;
13748
14240
  }
13749
14241
  static outputSchema() {
13750
- return outputSchema68;
14242
+ return outputSchema67;
13751
14243
  }
13752
14244
  async execute(input2, _context) {
13753
14245
  return { result: Math.max(...input2.values) };
13754
14246
  }
13755
14247
  }
13756
- Workflow51.prototype.scalarMax = CreateWorkflow50(ScalarMaxTask);
14248
+ Workflow50.prototype.scalarMax = CreateWorkflow49(ScalarMaxTask);
13757
14249
  // src/task/scalar/ScalarMinTask.ts
13758
- import { CreateWorkflow as CreateWorkflow51, Task as Task76, Workflow as Workflow52 } from "@workglow/task-graph";
13759
- var inputSchema70 = {
14250
+ import { CreateWorkflow as CreateWorkflow50, Task as Task60, Workflow as Workflow51 } from "@workglow/task-graph";
14251
+ var inputSchema69 = {
13760
14252
  type: "object",
13761
14253
  properties: {
13762
14254
  values: {
@@ -13769,7 +14261,7 @@ var inputSchema70 = {
13769
14261
  required: ["values"],
13770
14262
  additionalProperties: false
13771
14263
  };
13772
- var outputSchema69 = {
14264
+ var outputSchema68 = {
13773
14265
  type: "object",
13774
14266
  properties: {
13775
14267
  result: {
@@ -13782,25 +14274,25 @@ var outputSchema69 = {
13782
14274
  additionalProperties: false
13783
14275
  };
13784
14276
 
13785
- class ScalarMinTask extends Task76 {
14277
+ class ScalarMinTask extends Task60 {
13786
14278
  static type = "ScalarMinTask";
13787
14279
  static category = "Math";
13788
14280
  static title = "Min";
13789
14281
  static description = "Returns the smallest of the given numbers";
13790
14282
  static inputSchema() {
13791
- return inputSchema70;
14283
+ return inputSchema69;
13792
14284
  }
13793
14285
  static outputSchema() {
13794
- return outputSchema69;
14286
+ return outputSchema68;
13795
14287
  }
13796
14288
  async execute(input2, _context) {
13797
14289
  return { result: Math.min(...input2.values) };
13798
14290
  }
13799
14291
  }
13800
- Workflow52.prototype.scalarMin = CreateWorkflow51(ScalarMinTask);
14292
+ Workflow51.prototype.scalarMin = CreateWorkflow50(ScalarMinTask);
13801
14293
  // src/task/scalar/ScalarRoundTask.ts
13802
- import { CreateWorkflow as CreateWorkflow52, Task as Task77, Workflow as Workflow53 } from "@workglow/task-graph";
13803
- var inputSchema71 = {
14294
+ import { CreateWorkflow as CreateWorkflow51, Task as Task61, Workflow as Workflow52 } from "@workglow/task-graph";
14295
+ var inputSchema70 = {
13804
14296
  type: "object",
13805
14297
  properties: {
13806
14298
  value: {
@@ -13812,7 +14304,7 @@ var inputSchema71 = {
13812
14304
  required: ["value"],
13813
14305
  additionalProperties: false
13814
14306
  };
13815
- var outputSchema70 = {
14307
+ var outputSchema69 = {
13816
14308
  type: "object",
13817
14309
  properties: {
13818
14310
  result: {
@@ -13825,25 +14317,25 @@ var outputSchema70 = {
13825
14317
  additionalProperties: false
13826
14318
  };
13827
14319
 
13828
- class ScalarRoundTask extends Task77 {
14320
+ class ScalarRoundTask extends Task61 {
13829
14321
  static type = "ScalarRoundTask";
13830
14322
  static category = "Math";
13831
14323
  static title = "Round";
13832
14324
  static description = "Returns the value of a number rounded to the nearest integer";
13833
14325
  static inputSchema() {
13834
- return inputSchema71;
14326
+ return inputSchema70;
13835
14327
  }
13836
14328
  static outputSchema() {
13837
- return outputSchema70;
14329
+ return outputSchema69;
13838
14330
  }
13839
14331
  async execute(input2, _context) {
13840
14332
  return { result: Math.round(input2.value) };
13841
14333
  }
13842
14334
  }
13843
- Workflow53.prototype.scalarRound = CreateWorkflow52(ScalarRoundTask);
14335
+ Workflow52.prototype.scalarRound = CreateWorkflow51(ScalarRoundTask);
13844
14336
  // src/task/scalar/ScalarTruncTask.ts
13845
- import { CreateWorkflow as CreateWorkflow53, Task as Task78, Workflow as Workflow54 } from "@workglow/task-graph";
13846
- var inputSchema72 = {
14337
+ import { CreateWorkflow as CreateWorkflow52, Task as Task62, Workflow as Workflow53 } from "@workglow/task-graph";
14338
+ var inputSchema71 = {
13847
14339
  type: "object",
13848
14340
  properties: {
13849
14341
  value: {
@@ -13855,7 +14347,7 @@ var inputSchema72 = {
13855
14347
  required: ["value"],
13856
14348
  additionalProperties: false
13857
14349
  };
13858
- var outputSchema71 = {
14350
+ var outputSchema70 = {
13859
14351
  type: "object",
13860
14352
  properties: {
13861
14353
  result: {
@@ -13868,25 +14360,25 @@ var outputSchema71 = {
13868
14360
  additionalProperties: false
13869
14361
  };
13870
14362
 
13871
- class ScalarTruncTask extends Task78 {
14363
+ class ScalarTruncTask extends Task62 {
13872
14364
  static type = "ScalarTruncTask";
13873
14365
  static category = "Math";
13874
14366
  static title = "Truncate";
13875
14367
  static description = "Returns the integer part of a number by removing fractional digits";
13876
14368
  static inputSchema() {
13877
- return inputSchema72;
14369
+ return inputSchema71;
13878
14370
  }
13879
14371
  static outputSchema() {
13880
- return outputSchema71;
14372
+ return outputSchema70;
13881
14373
  }
13882
14374
  async execute(input2, _context) {
13883
14375
  return { result: Math.trunc(input2.value) };
13884
14376
  }
13885
14377
  }
13886
- Workflow54.prototype.scalarTrunc = CreateWorkflow53(ScalarTruncTask);
14378
+ Workflow53.prototype.scalarTrunc = CreateWorkflow52(ScalarTruncTask);
13887
14379
  // src/task/SplitTask.ts
13888
- import { CreateWorkflow as CreateWorkflow54, Task as Task79, Workflow as Workflow55 } from "@workglow/task-graph";
13889
- var inputSchema73 = {
14380
+ import { CreateWorkflow as CreateWorkflow53, Task as Task63, Workflow as Workflow54 } from "@workglow/task-graph";
14381
+ var inputSchema72 = {
13890
14382
  type: "object",
13891
14383
  properties: {
13892
14384
  input: {
@@ -13896,54 +14388,62 @@ var inputSchema73 = {
13896
14388
  },
13897
14389
  additionalProperties: false
13898
14390
  };
13899
- var outputSchema72 = {
14391
+ var outputSchema71 = {
13900
14392
  type: "object",
13901
14393
  properties: {},
13902
14394
  additionalProperties: true
13903
14395
  };
14396
+ function fanoutToIndexedOutputs(inputValue) {
14397
+ const output = {};
14398
+ if (Array.isArray(inputValue)) {
14399
+ inputValue.forEach((item, index) => {
14400
+ output[`output_${index}`] = item;
14401
+ });
14402
+ } else {
14403
+ output.output_0 = inputValue;
14404
+ }
14405
+ return output;
14406
+ }
13904
14407
 
13905
- class SplitTask extends Task79 {
14408
+ class SplitTask extends Task63 {
13906
14409
  static type = "SplitTask";
13907
14410
  static category = "Utility";
13908
14411
  static title = "Split";
13909
14412
  static description = "Splits an array into individual outputs, creating one output per element";
13910
14413
  static cacheable = false;
13911
14414
  static inputSchema() {
13912
- return inputSchema73;
14415
+ return inputSchema72;
13913
14416
  }
13914
14417
  static outputSchema() {
13915
- return outputSchema72;
14418
+ return outputSchema71;
13916
14419
  }
13917
- async executeReactive(input2) {
13918
- const inputValue = input2.input;
13919
- const output = {};
13920
- if (Array.isArray(inputValue)) {
13921
- inputValue.forEach((item, index) => {
13922
- output[`output_${index}`] = item;
13923
- });
13924
- } else {
13925
- output.output_0 = inputValue;
13926
- }
13927
- return output;
14420
+ async execute(input2, _context) {
14421
+ return fanoutToIndexedOutputs(input2.input);
14422
+ }
14423
+ async executePreview(input2) {
14424
+ return fanoutToIndexedOutputs(input2.input);
13928
14425
  }
13929
14426
  }
13930
14427
  var split = (input2, config = {}) => {
13931
14428
  const task = new SplitTask(config);
13932
14429
  return task.run(input2);
13933
14430
  };
13934
- Workflow55.prototype.split = CreateWorkflow54(SplitTask);
14431
+ Workflow54.prototype.split = CreateWorkflow53(SplitTask);
13935
14432
  // src/task/string/StringConcatTask.ts
13936
14433
  import {
13937
- CreateWorkflow as CreateWorkflow55,
13938
- Task as Task80,
13939
- Workflow as Workflow56
14434
+ CreateWorkflow as CreateWorkflow54,
14435
+ Task as Task64,
14436
+ Workflow as Workflow55
13940
14437
  } from "@workglow/task-graph";
13941
- var inputSchema74 = {
14438
+ function concatStrings(input2) {
14439
+ return Object.values(input2).join("");
14440
+ }
14441
+ var inputSchema73 = {
13942
14442
  type: "object",
13943
14443
  properties: {},
13944
14444
  additionalProperties: { type: "string" }
13945
14445
  };
13946
- var outputSchema73 = {
14446
+ var outputSchema72 = {
13947
14447
  type: "object",
13948
14448
  properties: {
13949
14449
  text: {
@@ -13956,29 +14456,35 @@ var outputSchema73 = {
13956
14456
  additionalProperties: false
13957
14457
  };
13958
14458
 
13959
- class StringConcatTask extends Task80 {
14459
+ class StringConcatTask extends Task64 {
13960
14460
  static type = "StringConcatTask";
13961
14461
  static category = "String";
13962
14462
  static title = "Concat";
13963
14463
  static description = "Concatenates all input strings";
13964
14464
  static inputSchema() {
13965
- return inputSchema74;
14465
+ return inputSchema73;
13966
14466
  }
13967
14467
  static outputSchema() {
13968
- return outputSchema73;
14468
+ return outputSchema72;
14469
+ }
14470
+ async execute(input2, _context) {
14471
+ return { text: concatStrings(input2) };
13969
14472
  }
13970
- async executeReactive(input2, _output, _context) {
13971
- return { text: Object.values(input2).join("") };
14473
+ async executePreview(input2, _context) {
14474
+ return { text: concatStrings(input2) };
13972
14475
  }
13973
14476
  }
13974
- Workflow56.prototype.stringConcat = CreateWorkflow55(StringConcatTask);
14477
+ Workflow55.prototype.stringConcat = CreateWorkflow54(StringConcatTask);
13975
14478
  // src/task/string/StringIncludesTask.ts
13976
14479
  import {
13977
- CreateWorkflow as CreateWorkflow56,
13978
- Task as Task81,
13979
- Workflow as Workflow57
14480
+ CreateWorkflow as CreateWorkflow55,
14481
+ Task as Task65,
14482
+ Workflow as Workflow56
13980
14483
  } from "@workglow/task-graph";
13981
- var inputSchema75 = {
14484
+ function stringIncludes(text, search) {
14485
+ return text.includes(search);
14486
+ }
14487
+ var inputSchema74 = {
13982
14488
  type: "object",
13983
14489
  properties: {
13984
14490
  text: {
@@ -13995,7 +14501,7 @@ var inputSchema75 = {
13995
14501
  required: ["text", "search"],
13996
14502
  additionalProperties: false
13997
14503
  };
13998
- var outputSchema74 = {
14504
+ var outputSchema73 = {
13999
14505
  type: "object",
14000
14506
  properties: {
14001
14507
  included: {
@@ -14008,29 +14514,35 @@ var outputSchema74 = {
14008
14514
  additionalProperties: false
14009
14515
  };
14010
14516
 
14011
- class StringIncludesTask extends Task81 {
14517
+ class StringIncludesTask extends Task65 {
14012
14518
  static type = "StringIncludesTask";
14013
14519
  static category = "String";
14014
14520
  static title = "Includes";
14015
14521
  static description = "Checks if a string contains a substring";
14016
14522
  static inputSchema() {
14017
- return inputSchema75;
14523
+ return inputSchema74;
14018
14524
  }
14019
14525
  static outputSchema() {
14020
- return outputSchema74;
14526
+ return outputSchema73;
14527
+ }
14528
+ async execute(input2, _context) {
14529
+ return { included: stringIncludes(input2.text, input2.search) };
14021
14530
  }
14022
- async executeReactive(input2, _output, _context) {
14023
- return { included: input2.text.includes(input2.search) };
14531
+ async executePreview(input2, _context) {
14532
+ return { included: stringIncludes(input2.text, input2.search) };
14024
14533
  }
14025
14534
  }
14026
- Workflow57.prototype.stringIncludes = CreateWorkflow56(StringIncludesTask);
14535
+ Workflow56.prototype.stringIncludes = CreateWorkflow55(StringIncludesTask);
14027
14536
  // src/task/string/StringJoinTask.ts
14028
14537
  import {
14029
- CreateWorkflow as CreateWorkflow57,
14030
- Task as Task82,
14031
- Workflow as Workflow58
14538
+ CreateWorkflow as CreateWorkflow56,
14539
+ Task as Task66,
14540
+ Workflow as Workflow57
14032
14541
  } from "@workglow/task-graph";
14033
- var inputSchema76 = {
14542
+ function joinStrings(texts, separator) {
14543
+ return texts.join(separator ?? "");
14544
+ }
14545
+ var inputSchema75 = {
14034
14546
  type: "object",
14035
14547
  properties: {
14036
14548
  texts: {
@@ -14049,7 +14561,7 @@ var inputSchema76 = {
14049
14561
  required: ["texts"],
14050
14562
  additionalProperties: false
14051
14563
  };
14052
- var outputSchema75 = {
14564
+ var outputSchema74 = {
14053
14565
  type: "object",
14054
14566
  properties: {
14055
14567
  text: {
@@ -14062,30 +14574,35 @@ var outputSchema75 = {
14062
14574
  additionalProperties: false
14063
14575
  };
14064
14576
 
14065
- class StringJoinTask extends Task82 {
14577
+ class StringJoinTask extends Task66 {
14066
14578
  static type = "StringJoinTask";
14067
14579
  static category = "String";
14068
14580
  static title = "Join";
14069
14581
  static description = "Joins an array of strings with a separator";
14070
14582
  static inputSchema() {
14071
- return inputSchema76;
14583
+ return inputSchema75;
14072
14584
  }
14073
14585
  static outputSchema() {
14074
- return outputSchema75;
14586
+ return outputSchema74;
14587
+ }
14588
+ async execute(input2, _context) {
14589
+ return { text: joinStrings(input2.texts, input2.separator) };
14075
14590
  }
14076
- async executeReactive(input2, _output, _context) {
14077
- const separator = input2.separator ?? "";
14078
- return { text: input2.texts.join(separator) };
14591
+ async executePreview(input2, _context) {
14592
+ return { text: joinStrings(input2.texts, input2.separator) };
14079
14593
  }
14080
14594
  }
14081
- Workflow58.prototype.stringJoin = CreateWorkflow57(StringJoinTask);
14595
+ Workflow57.prototype.stringJoin = CreateWorkflow56(StringJoinTask);
14082
14596
  // src/task/string/StringLengthTask.ts
14083
14597
  import {
14084
- CreateWorkflow as CreateWorkflow58,
14085
- Task as Task83,
14086
- Workflow as Workflow59
14598
+ CreateWorkflow as CreateWorkflow57,
14599
+ Task as Task67,
14600
+ Workflow as Workflow58
14087
14601
  } from "@workglow/task-graph";
14088
- var inputSchema77 = {
14602
+ function stringLength(text) {
14603
+ return text.length;
14604
+ }
14605
+ var inputSchema76 = {
14089
14606
  type: "object",
14090
14607
  properties: {
14091
14608
  text: {
@@ -14097,7 +14614,7 @@ var inputSchema77 = {
14097
14614
  required: ["text"],
14098
14615
  additionalProperties: false
14099
14616
  };
14100
- var outputSchema76 = {
14617
+ var outputSchema75 = {
14101
14618
  type: "object",
14102
14619
  properties: {
14103
14620
  length: {
@@ -14110,29 +14627,35 @@ var outputSchema76 = {
14110
14627
  additionalProperties: false
14111
14628
  };
14112
14629
 
14113
- class StringLengthTask extends Task83 {
14630
+ class StringLengthTask extends Task67 {
14114
14631
  static type = "StringLengthTask";
14115
14632
  static category = "String";
14116
14633
  static title = "Length";
14117
14634
  static description = "Returns the length of a string";
14118
14635
  static inputSchema() {
14119
- return inputSchema77;
14636
+ return inputSchema76;
14120
14637
  }
14121
14638
  static outputSchema() {
14122
- return outputSchema76;
14639
+ return outputSchema75;
14640
+ }
14641
+ async execute(input2, _context) {
14642
+ return { length: stringLength(input2.text) };
14123
14643
  }
14124
- async executeReactive(input2, _output, _context) {
14125
- return { length: input2.text.length };
14644
+ async executePreview(input2, _context) {
14645
+ return { length: stringLength(input2.text) };
14126
14646
  }
14127
14647
  }
14128
- Workflow59.prototype.stringLength = CreateWorkflow58(StringLengthTask);
14648
+ Workflow58.prototype.stringLength = CreateWorkflow57(StringLengthTask);
14129
14649
  // src/task/string/StringLowerCaseTask.ts
14130
14650
  import {
14131
- CreateWorkflow as CreateWorkflow59,
14132
- Task as Task84,
14133
- Workflow as Workflow60
14651
+ CreateWorkflow as CreateWorkflow58,
14652
+ Task as Task68,
14653
+ Workflow as Workflow59
14134
14654
  } from "@workglow/task-graph";
14135
- var inputSchema78 = {
14655
+ function toLowerCase(text) {
14656
+ return text.toLowerCase();
14657
+ }
14658
+ var inputSchema77 = {
14136
14659
  type: "object",
14137
14660
  properties: {
14138
14661
  text: {
@@ -14144,7 +14667,7 @@ var inputSchema78 = {
14144
14667
  required: ["text"],
14145
14668
  additionalProperties: false
14146
14669
  };
14147
- var outputSchema77 = {
14670
+ var outputSchema76 = {
14148
14671
  type: "object",
14149
14672
  properties: {
14150
14673
  text: {
@@ -14157,29 +14680,35 @@ var outputSchema77 = {
14157
14680
  additionalProperties: false
14158
14681
  };
14159
14682
 
14160
- class StringLowerCaseTask extends Task84 {
14683
+ class StringLowerCaseTask extends Task68 {
14161
14684
  static type = "StringLowerCaseTask";
14162
14685
  static category = "String";
14163
14686
  static title = "Lower Case";
14164
14687
  static description = "Converts a string to lower case";
14165
14688
  static inputSchema() {
14166
- return inputSchema78;
14689
+ return inputSchema77;
14167
14690
  }
14168
14691
  static outputSchema() {
14169
- return outputSchema77;
14692
+ return outputSchema76;
14693
+ }
14694
+ async execute(input2, _context) {
14695
+ return { text: toLowerCase(input2.text) };
14170
14696
  }
14171
- async executeReactive(input2, _output, _context) {
14172
- return { text: input2.text.toLowerCase() };
14697
+ async executePreview(input2, _context) {
14698
+ return { text: toLowerCase(input2.text) };
14173
14699
  }
14174
14700
  }
14175
- Workflow60.prototype.stringLowerCase = CreateWorkflow59(StringLowerCaseTask);
14701
+ Workflow59.prototype.stringLowerCase = CreateWorkflow58(StringLowerCaseTask);
14176
14702
  // src/task/string/StringReplaceTask.ts
14177
14703
  import {
14178
- CreateWorkflow as CreateWorkflow60,
14179
- Task as Task85,
14180
- Workflow as Workflow61
14704
+ CreateWorkflow as CreateWorkflow59,
14705
+ Task as Task69,
14706
+ Workflow as Workflow60
14181
14707
  } from "@workglow/task-graph";
14182
- var inputSchema79 = {
14708
+ function replaceString(text, search, replace) {
14709
+ return text.replaceAll(search, replace);
14710
+ }
14711
+ var inputSchema78 = {
14183
14712
  type: "object",
14184
14713
  properties: {
14185
14714
  text: {
@@ -14201,7 +14730,7 @@ var inputSchema79 = {
14201
14730
  required: ["text", "search", "replace"],
14202
14731
  additionalProperties: false
14203
14732
  };
14204
- var outputSchema78 = {
14733
+ var outputSchema77 = {
14205
14734
  type: "object",
14206
14735
  properties: {
14207
14736
  text: {
@@ -14214,29 +14743,35 @@ var outputSchema78 = {
14214
14743
  additionalProperties: false
14215
14744
  };
14216
14745
 
14217
- class StringReplaceTask extends Task85 {
14746
+ class StringReplaceTask extends Task69 {
14218
14747
  static type = "StringReplaceTask";
14219
14748
  static category = "String";
14220
14749
  static title = "Replace";
14221
14750
  static description = "Replaces all occurrences of a substring";
14222
14751
  static inputSchema() {
14223
- return inputSchema79;
14752
+ return inputSchema78;
14224
14753
  }
14225
14754
  static outputSchema() {
14226
- return outputSchema78;
14755
+ return outputSchema77;
14227
14756
  }
14228
- async executeReactive(input2, _output, _context) {
14229
- return { text: input2.text.replaceAll(input2.search, input2.replace) };
14757
+ async execute(input2, _context) {
14758
+ return { text: replaceString(input2.text, input2.search, input2.replace) };
14759
+ }
14760
+ async executePreview(input2, _context) {
14761
+ return { text: replaceString(input2.text, input2.search, input2.replace) };
14230
14762
  }
14231
14763
  }
14232
- Workflow61.prototype.stringReplace = CreateWorkflow60(StringReplaceTask);
14764
+ Workflow60.prototype.stringReplace = CreateWorkflow59(StringReplaceTask);
14233
14765
  // src/task/string/StringSliceTask.ts
14234
14766
  import {
14235
- CreateWorkflow as CreateWorkflow61,
14236
- Task as Task86,
14237
- Workflow as Workflow62
14767
+ CreateWorkflow as CreateWorkflow60,
14768
+ Task as Task70,
14769
+ Workflow as Workflow61
14238
14770
  } from "@workglow/task-graph";
14239
- var inputSchema80 = {
14771
+ function sliceString(text, start, end) {
14772
+ return text.slice(start, end);
14773
+ }
14774
+ var inputSchema79 = {
14240
14775
  type: "object",
14241
14776
  properties: {
14242
14777
  text: {
@@ -14258,7 +14793,7 @@ var inputSchema80 = {
14258
14793
  required: ["text", "start"],
14259
14794
  additionalProperties: false
14260
14795
  };
14261
- var outputSchema79 = {
14796
+ var outputSchema78 = {
14262
14797
  type: "object",
14263
14798
  properties: {
14264
14799
  text: {
@@ -14271,29 +14806,39 @@ var outputSchema79 = {
14271
14806
  additionalProperties: false
14272
14807
  };
14273
14808
 
14274
- class StringSliceTask extends Task86 {
14809
+ class StringSliceTask extends Task70 {
14275
14810
  static type = "StringSliceTask";
14276
14811
  static category = "String";
14277
14812
  static title = "Slice";
14278
14813
  static description = "Extracts a substring by start and optional end index";
14279
14814
  static inputSchema() {
14280
- return inputSchema80;
14815
+ return inputSchema79;
14281
14816
  }
14282
14817
  static outputSchema() {
14283
- return outputSchema79;
14818
+ return outputSchema78;
14819
+ }
14820
+ async execute(input2, _context) {
14821
+ return { text: sliceString(input2.text, input2.start, input2.end) };
14284
14822
  }
14285
- async executeReactive(input2, _output, _context) {
14286
- return { text: input2.text.slice(input2.start, input2.end) };
14823
+ async executePreview(input2, _context) {
14824
+ return { text: sliceString(input2.text, input2.start, input2.end) };
14287
14825
  }
14288
14826
  }
14289
- Workflow62.prototype.stringSlice = CreateWorkflow61(StringSliceTask);
14827
+ Workflow61.prototype.stringSlice = CreateWorkflow60(StringSliceTask);
14290
14828
  // src/task/string/StringTemplateTask.ts
14291
14829
  import {
14292
- CreateWorkflow as CreateWorkflow62,
14293
- Task as Task87,
14294
- Workflow as Workflow63
14830
+ CreateWorkflow as CreateWorkflow61,
14831
+ Task as Task71,
14832
+ Workflow as Workflow62
14295
14833
  } from "@workglow/task-graph";
14296
- var inputSchema81 = {
14834
+ function renderStringTemplate(template, values) {
14835
+ let text = template;
14836
+ for (const [key, value] of Object.entries(values)) {
14837
+ text = text.replaceAll(`{{${key}}}`, String(value));
14838
+ }
14839
+ return text;
14840
+ }
14841
+ var inputSchema80 = {
14297
14842
  type: "object",
14298
14843
  properties: {
14299
14844
  template: {
@@ -14311,7 +14856,7 @@ var inputSchema81 = {
14311
14856
  required: ["template", "values"],
14312
14857
  additionalProperties: false
14313
14858
  };
14314
- var outputSchema80 = {
14859
+ var outputSchema79 = {
14315
14860
  type: "object",
14316
14861
  properties: {
14317
14862
  text: {
@@ -14324,33 +14869,35 @@ var outputSchema80 = {
14324
14869
  additionalProperties: false
14325
14870
  };
14326
14871
 
14327
- class StringTemplateTask extends Task87 {
14872
+ class StringTemplateTask extends Task71 {
14328
14873
  static type = "StringTemplateTask";
14329
14874
  static category = "String";
14330
14875
  static title = "Template";
14331
14876
  static description = "Replaces {{key}} placeholders in a template string with values";
14332
14877
  static inputSchema() {
14333
- return inputSchema81;
14878
+ return inputSchema80;
14334
14879
  }
14335
14880
  static outputSchema() {
14336
- return outputSchema80;
14881
+ return outputSchema79;
14337
14882
  }
14338
- async executeReactive(input2, _output, _context) {
14339
- let text = input2.template;
14340
- for (const [key, value] of Object.entries(input2.values)) {
14341
- text = text.replaceAll(`{{${key}}}`, String(value));
14342
- }
14343
- return { text };
14883
+ async execute(input2, _context) {
14884
+ return { text: renderStringTemplate(input2.template, input2.values) };
14885
+ }
14886
+ async executePreview(input2, _context) {
14887
+ return { text: renderStringTemplate(input2.template, input2.values) };
14344
14888
  }
14345
14889
  }
14346
- Workflow63.prototype.stringTemplate = CreateWorkflow62(StringTemplateTask);
14890
+ Workflow62.prototype.stringTemplate = CreateWorkflow61(StringTemplateTask);
14347
14891
  // src/task/string/StringTrimTask.ts
14348
14892
  import {
14349
- CreateWorkflow as CreateWorkflow63,
14350
- Task as Task88,
14351
- Workflow as Workflow64
14893
+ CreateWorkflow as CreateWorkflow62,
14894
+ Task as Task72,
14895
+ Workflow as Workflow63
14352
14896
  } from "@workglow/task-graph";
14353
- var inputSchema82 = {
14897
+ function trimString(text) {
14898
+ return text.trim();
14899
+ }
14900
+ var inputSchema81 = {
14354
14901
  type: "object",
14355
14902
  properties: {
14356
14903
  text: {
@@ -14362,7 +14909,7 @@ var inputSchema82 = {
14362
14909
  required: ["text"],
14363
14910
  additionalProperties: false
14364
14911
  };
14365
- var outputSchema81 = {
14912
+ var outputSchema80 = {
14366
14913
  type: "object",
14367
14914
  properties: {
14368
14915
  text: {
@@ -14375,29 +14922,35 @@ var outputSchema81 = {
14375
14922
  additionalProperties: false
14376
14923
  };
14377
14924
 
14378
- class StringTrimTask extends Task88 {
14925
+ class StringTrimTask extends Task72 {
14379
14926
  static type = "StringTrimTask";
14380
14927
  static category = "String";
14381
14928
  static title = "Trim";
14382
14929
  static description = "Removes leading and trailing whitespace from a string";
14383
14930
  static inputSchema() {
14384
- return inputSchema82;
14931
+ return inputSchema81;
14385
14932
  }
14386
14933
  static outputSchema() {
14387
- return outputSchema81;
14934
+ return outputSchema80;
14388
14935
  }
14389
- async executeReactive(input2, _output, _context) {
14390
- return { text: input2.text.trim() };
14936
+ async execute(input2, _context) {
14937
+ return { text: trimString(input2.text) };
14938
+ }
14939
+ async executePreview(input2, _context) {
14940
+ return { text: trimString(input2.text) };
14391
14941
  }
14392
14942
  }
14393
- Workflow64.prototype.stringTrim = CreateWorkflow63(StringTrimTask);
14943
+ Workflow63.prototype.stringTrim = CreateWorkflow62(StringTrimTask);
14394
14944
  // src/task/string/StringUpperCaseTask.ts
14395
14945
  import {
14396
- CreateWorkflow as CreateWorkflow64,
14397
- Task as Task89,
14398
- Workflow as Workflow65
14946
+ CreateWorkflow as CreateWorkflow63,
14947
+ Task as Task73,
14948
+ Workflow as Workflow64
14399
14949
  } from "@workglow/task-graph";
14400
- var inputSchema83 = {
14950
+ function toUpperCase(text) {
14951
+ return text.toUpperCase();
14952
+ }
14953
+ var inputSchema82 = {
14401
14954
  type: "object",
14402
14955
  properties: {
14403
14956
  text: {
@@ -14409,7 +14962,7 @@ var inputSchema83 = {
14409
14962
  required: ["text"],
14410
14963
  additionalProperties: false
14411
14964
  };
14412
- var outputSchema82 = {
14965
+ var outputSchema81 = {
14413
14966
  type: "object",
14414
14967
  properties: {
14415
14968
  text: {
@@ -14422,29 +14975,50 @@ var outputSchema82 = {
14422
14975
  additionalProperties: false
14423
14976
  };
14424
14977
 
14425
- class StringUpperCaseTask extends Task89 {
14978
+ class StringUpperCaseTask extends Task73 {
14426
14979
  static type = "StringUpperCaseTask";
14427
14980
  static category = "String";
14428
14981
  static title = "Upper Case";
14429
14982
  static description = "Converts a string to upper case";
14430
14983
  static inputSchema() {
14431
- return inputSchema83;
14984
+ return inputSchema82;
14432
14985
  }
14433
14986
  static outputSchema() {
14434
- return outputSchema82;
14987
+ return outputSchema81;
14988
+ }
14989
+ async execute(input2, _context) {
14990
+ return { text: toUpperCase(input2.text) };
14435
14991
  }
14436
- async executeReactive(input2, _output, _context) {
14437
- return { text: input2.text.toUpperCase() };
14992
+ async executePreview(input2, _context) {
14993
+ return { text: toUpperCase(input2.text) };
14438
14994
  }
14439
14995
  }
14440
- Workflow65.prototype.stringUpperCase = CreateWorkflow64(StringUpperCaseTask);
14996
+ Workflow64.prototype.stringUpperCase = CreateWorkflow63(StringUpperCaseTask);
14441
14997
  // src/task/TemplateTask.ts
14442
14998
  import {
14443
- CreateWorkflow as CreateWorkflow65,
14444
- Task as Task90,
14445
- Workflow as Workflow66
14999
+ CreateWorkflow as CreateWorkflow64,
15000
+ Task as Task74,
15001
+ Workflow as Workflow65
14446
15002
  } from "@workglow/task-graph";
14447
- var inputSchema84 = {
15003
+ function renderTemplate(template, values) {
15004
+ return template.replace(/\{\{([^{}]+)\}\}/g, (_match, expr) => {
15005
+ const [path, defaultValue] = expr.split("|").map((s) => s.trim());
15006
+ const segments = path.split(".");
15007
+ let current = values;
15008
+ for (const segment of segments) {
15009
+ if (current === null || current === undefined || typeof current !== "object") {
15010
+ current = undefined;
15011
+ break;
15012
+ }
15013
+ current = current[segment];
15014
+ }
15015
+ if (current !== undefined && current !== null) {
15016
+ return String(current);
15017
+ }
15018
+ return defaultValue !== undefined ? defaultValue : "";
15019
+ });
15020
+ }
15021
+ var inputSchema83 = {
14448
15022
  type: "object",
14449
15023
  properties: {
14450
15024
  template: {
@@ -14462,7 +15036,7 @@ var inputSchema84 = {
14462
15036
  required: ["template", "values"],
14463
15037
  additionalProperties: false
14464
15038
  };
14465
- var outputSchema83 = {
15039
+ var outputSchema82 = {
14466
15040
  type: "object",
14467
15041
  properties: {
14468
15042
  result: {
@@ -14475,44 +15049,31 @@ var outputSchema83 = {
14475
15049
  additionalProperties: false
14476
15050
  };
14477
15051
 
14478
- class TemplateTask extends Task90 {
15052
+ class TemplateTask extends Task74 {
14479
15053
  static type = "TemplateTask";
14480
15054
  static category = "Utility";
14481
15055
  static title = "Template";
14482
15056
  static description = "Renders a template string with {{key}} placeholders and optional defaults";
14483
15057
  static inputSchema() {
14484
- return inputSchema84;
15058
+ return inputSchema83;
14485
15059
  }
14486
15060
  static outputSchema() {
14487
- return outputSchema83;
15061
+ return outputSchema82;
14488
15062
  }
14489
- async executeReactive(input2, _output, _context) {
14490
- const result = input2.template.replace(/\{\{([^}]+)\}\}/g, (_match, expr) => {
14491
- const [path, defaultValue] = expr.split("|").map((s) => s.trim());
14492
- const segments = path.split(".");
14493
- let current = input2.values;
14494
- for (const segment of segments) {
14495
- if (current === null || current === undefined || typeof current !== "object") {
14496
- current = undefined;
14497
- break;
14498
- }
14499
- current = current[segment];
14500
- }
14501
- if (current !== undefined && current !== null) {
14502
- return String(current);
14503
- }
14504
- return defaultValue !== undefined ? defaultValue : "";
14505
- });
14506
- return { result };
15063
+ async execute(input2, _context) {
15064
+ return { result: renderTemplate(input2.template, input2.values) };
15065
+ }
15066
+ async executePreview(input2, _context) {
15067
+ return { result: renderTemplate(input2.template, input2.values) };
14507
15068
  }
14508
15069
  }
14509
- Workflow66.prototype.template = CreateWorkflow65(TemplateTask);
15070
+ Workflow65.prototype.template = CreateWorkflow64(TemplateTask);
14510
15071
  // src/task/vector/VectorDistanceTask.ts
14511
- import { CreateWorkflow as CreateWorkflow66, Task as Task91, Workflow as Workflow67 } from "@workglow/task-graph";
15072
+ import { CreateWorkflow as CreateWorkflow65, Task as Task75, Workflow as Workflow66 } from "@workglow/task-graph";
14512
15073
  import {
14513
15074
  TypedArraySchema as TypedArraySchema5
14514
15075
  } from "@workglow/util/schema";
14515
- var inputSchema85 = {
15076
+ var inputSchema84 = {
14516
15077
  type: "object",
14517
15078
  properties: {
14518
15079
  vectors: {
@@ -14528,7 +15089,7 @@ var inputSchema85 = {
14528
15089
  required: ["vectors"],
14529
15090
  additionalProperties: false
14530
15091
  };
14531
- var outputSchema84 = {
15092
+ var outputSchema83 = {
14532
15093
  type: "object",
14533
15094
  properties: {
14534
15095
  result: {
@@ -14541,16 +15102,16 @@ var outputSchema84 = {
14541
15102
  additionalProperties: false
14542
15103
  };
14543
15104
 
14544
- class VectorDistanceTask extends Task91 {
15105
+ class VectorDistanceTask extends Task75 {
14545
15106
  static type = "VectorDistanceTask";
14546
15107
  static category = "Vector";
14547
15108
  static title = "Distance";
14548
15109
  static description = "Returns the Euclidean distance between the first two vectors";
14549
15110
  static inputSchema() {
14550
- return inputSchema85;
15111
+ return inputSchema84;
14551
15112
  }
14552
15113
  static outputSchema() {
14553
- return outputSchema84;
15114
+ return outputSchema83;
14554
15115
  }
14555
15116
  async execute(input2, _context) {
14556
15117
  const { vectors } = input2;
@@ -14568,13 +15129,13 @@ class VectorDistanceTask extends Task91 {
14568
15129
  return { result: Math.sqrt(sumPrecise(diffs)) };
14569
15130
  }
14570
15131
  }
14571
- Workflow67.prototype.vectorDistance = CreateWorkflow66(VectorDistanceTask);
15132
+ Workflow66.prototype.vectorDistance = CreateWorkflow65(VectorDistanceTask);
14572
15133
  // src/task/vector/VectorDotProductTask.ts
14573
- import { CreateWorkflow as CreateWorkflow67, Task as Task92, Workflow as Workflow68 } from "@workglow/task-graph";
15134
+ import { CreateWorkflow as CreateWorkflow66, Task as Task76, Workflow as Workflow67 } from "@workglow/task-graph";
14574
15135
  import {
14575
15136
  TypedArraySchema as TypedArraySchema6
14576
15137
  } from "@workglow/util/schema";
14577
- var inputSchema86 = {
15138
+ var inputSchema85 = {
14578
15139
  type: "object",
14579
15140
  properties: {
14580
15141
  vectors: {
@@ -14590,7 +15151,7 @@ var inputSchema86 = {
14590
15151
  required: ["vectors"],
14591
15152
  additionalProperties: false
14592
15153
  };
14593
- var outputSchema85 = {
15154
+ var outputSchema84 = {
14594
15155
  type: "object",
14595
15156
  properties: {
14596
15157
  result: {
@@ -14603,16 +15164,16 @@ var outputSchema85 = {
14603
15164
  additionalProperties: false
14604
15165
  };
14605
15166
 
14606
- class VectorDotProductTask extends Task92 {
15167
+ class VectorDotProductTask extends Task76 {
14607
15168
  static type = "VectorDotProductTask";
14608
15169
  static category = "Vector";
14609
15170
  static title = "Dot Product";
14610
15171
  static description = "Returns the dot (inner) product of the first two vectors";
14611
15172
  static inputSchema() {
14612
- return inputSchema86;
15173
+ return inputSchema85;
14613
15174
  }
14614
15175
  static outputSchema() {
14615
- return outputSchema85;
15176
+ return outputSchema84;
14616
15177
  }
14617
15178
  async execute(input2, _context) {
14618
15179
  const { vectors } = input2;
@@ -14627,14 +15188,14 @@ class VectorDotProductTask extends Task92 {
14627
15188
  return { result: sumPrecise(products) };
14628
15189
  }
14629
15190
  }
14630
- Workflow68.prototype.vectorDotProduct = CreateWorkflow67(VectorDotProductTask);
15191
+ Workflow67.prototype.vectorDotProduct = CreateWorkflow66(VectorDotProductTask);
14631
15192
  // src/task/vector/VectorNormalizeTask.ts
14632
- import { CreateWorkflow as CreateWorkflow68, Task as Task93, Workflow as Workflow69 } from "@workglow/task-graph";
15193
+ import { CreateWorkflow as CreateWorkflow67, Task as Task77, Workflow as Workflow68 } from "@workglow/task-graph";
14633
15194
  import {
14634
15195
  TypedArraySchema as TypedArraySchema7,
14635
15196
  normalize
14636
15197
  } from "@workglow/util/schema";
14637
- var inputSchema87 = {
15198
+ var inputSchema86 = {
14638
15199
  type: "object",
14639
15200
  properties: {
14640
15201
  vector: TypedArraySchema7({
@@ -14645,7 +15206,7 @@ var inputSchema87 = {
14645
15206
  required: ["vector"],
14646
15207
  additionalProperties: false
14647
15208
  };
14648
- var outputSchema86 = {
15209
+ var outputSchema85 = {
14649
15210
  type: "object",
14650
15211
  properties: {
14651
15212
  result: TypedArraySchema7({
@@ -14657,29 +15218,29 @@ var outputSchema86 = {
14657
15218
  additionalProperties: false
14658
15219
  };
14659
15220
 
14660
- class VectorNormalizeTask extends Task93 {
15221
+ class VectorNormalizeTask extends Task77 {
14661
15222
  static type = "VectorNormalizeTask";
14662
15223
  static category = "Vector";
14663
15224
  static title = "Normalize";
14664
15225
  static description = "Returns the L2-normalized (unit length) vector";
14665
15226
  static inputSchema() {
14666
- return inputSchema87;
15227
+ return inputSchema86;
14667
15228
  }
14668
15229
  static outputSchema() {
14669
- return outputSchema86;
15230
+ return outputSchema85;
14670
15231
  }
14671
15232
  async execute(input2, _context) {
14672
15233
  return { result: normalize(input2.vector) };
14673
15234
  }
14674
15235
  }
14675
- Workflow69.prototype.vectorNormalize = CreateWorkflow68(VectorNormalizeTask);
15236
+ Workflow68.prototype.vectorNormalize = CreateWorkflow67(VectorNormalizeTask);
14676
15237
  // src/task/vector/VectorScaleTask.ts
14677
- import { CreateWorkflow as CreateWorkflow69, Task as Task94, Workflow as Workflow70 } from "@workglow/task-graph";
15238
+ import { CreateWorkflow as CreateWorkflow68, Task as Task78, Workflow as Workflow69 } from "@workglow/task-graph";
14678
15239
  import {
14679
15240
  createTypedArrayFrom as createTypedArrayFrom5,
14680
15241
  TypedArraySchema as TypedArraySchema8
14681
15242
  } from "@workglow/util/schema";
14682
- var inputSchema88 = {
15243
+ var inputSchema87 = {
14683
15244
  type: "object",
14684
15245
  properties: {
14685
15246
  vector: TypedArraySchema8({
@@ -14695,7 +15256,7 @@ var inputSchema88 = {
14695
15256
  required: ["vector", "scalar"],
14696
15257
  additionalProperties: false
14697
15258
  };
14698
- var outputSchema87 = {
15259
+ var outputSchema86 = {
14699
15260
  type: "object",
14700
15261
  properties: {
14701
15262
  result: TypedArraySchema8({
@@ -14707,16 +15268,16 @@ var outputSchema87 = {
14707
15268
  additionalProperties: false
14708
15269
  };
14709
15270
 
14710
- class VectorScaleTask extends Task94 {
15271
+ class VectorScaleTask extends Task78 {
14711
15272
  static type = "VectorScaleTask";
14712
15273
  static category = "Vector";
14713
15274
  static title = "Scale";
14714
15275
  static description = "Multiplies each element of a vector by a scalar";
14715
15276
  static inputSchema() {
14716
- return inputSchema88;
15277
+ return inputSchema87;
14717
15278
  }
14718
15279
  static outputSchema() {
14719
- return outputSchema87;
15280
+ return outputSchema86;
14720
15281
  }
14721
15282
  async execute(input2, _context) {
14722
15283
  const { vector, scalar } = input2;
@@ -14724,7 +15285,7 @@ class VectorScaleTask extends Task94 {
14724
15285
  return { result: createTypedArrayFrom5([vector], values) };
14725
15286
  }
14726
15287
  }
14727
- Workflow70.prototype.vectorScale = CreateWorkflow69(VectorScaleTask);
15288
+ Workflow69.prototype.vectorScale = CreateWorkflow68(VectorScaleTask);
14728
15289
 
14729
15290
  // src/common.ts
14730
15291
  import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
@@ -14825,7 +15386,6 @@ var registerCommonTasks = () => {
14825
15386
  ImageBorderTask,
14826
15387
  ImageTransparencyTask,
14827
15388
  ImageBlurTask,
14828
- ImageWatermarkTask,
14829
15389
  ImagePixelateTask,
14830
15390
  ImageInvertTask,
14831
15391
  ImageBrightnessTask,
@@ -14842,10 +15402,10 @@ var registerCommonTasks = () => {
14842
15402
  };
14843
15403
  // src/task/FileLoaderTask.ts
14844
15404
  import {
14845
- CreateWorkflow as CreateWorkflow70,
14846
- Task as Task95,
15405
+ CreateWorkflow as CreateWorkflow69,
15406
+ Task as Task79,
14847
15407
  TaskAbortedError as TaskAbortedError4,
14848
- Workflow as Workflow71
15408
+ Workflow as Workflow70
14849
15409
  } from "@workglow/task-graph";
14850
15410
  var _papaParse;
14851
15411
  async function getPapaParse() {
@@ -14859,7 +15419,7 @@ async function getPapaParse() {
14859
15419
  }
14860
15420
  return _papaParse;
14861
15421
  }
14862
- var inputSchema89 = {
15422
+ var inputSchema88 = {
14863
15423
  type: "object",
14864
15424
  properties: {
14865
15425
  url: {
@@ -14879,7 +15439,7 @@ var inputSchema89 = {
14879
15439
  required: ["url"],
14880
15440
  additionalProperties: false
14881
15441
  };
14882
- var outputSchema88 = {
15442
+ var outputSchema87 = {
14883
15443
  type: "object",
14884
15444
  properties: {
14885
15445
  text: {
@@ -14930,17 +15490,17 @@ var outputSchema88 = {
14930
15490
  additionalProperties: false
14931
15491
  };
14932
15492
 
14933
- class FileLoaderTask extends Task95 {
15493
+ class FileLoaderTask extends Task79 {
14934
15494
  static type = "FileLoaderTask";
14935
15495
  static category = "Document";
14936
15496
  static title = "File Loader";
14937
15497
  static description = "Load documents from URLs (http://, https://)";
14938
15498
  static cacheable = true;
14939
15499
  static inputSchema() {
14940
- return inputSchema89;
15500
+ return inputSchema88;
14941
15501
  }
14942
15502
  static outputSchema() {
14943
- return outputSchema88;
15503
+ return outputSchema87;
14944
15504
  }
14945
15505
  async execute(input2, context) {
14946
15506
  const { url, format = "auto" } = input2;
@@ -15296,7 +15856,7 @@ class FileLoaderTask extends Task95 {
15296
15856
  var fileLoader = (input2, config) => {
15297
15857
  return new FileLoaderTask(config).run(input2);
15298
15858
  };
15299
- Workflow71.prototype.fileLoader = CreateWorkflow70(FileLoaderTask);
15859
+ Workflow70.prototype.fileLoader = CreateWorkflow69(FileLoaderTask);
15300
15860
  // src/browser.ts
15301
15861
  import { TaskRegistry as TaskRegistry3 } from "@workglow/task-graph";
15302
15862
  registerMcpTaskDeps({
@@ -15338,9 +15898,9 @@ export {
15338
15898
  registerMcpTaskDeps,
15339
15899
  registerMcpServer,
15340
15900
  registerImageRasterCodec2 as registerImageRasterCodec,
15901
+ registerFilterOp33 as registerFilterOp,
15341
15902
  registerCommonTasks2 as registerCommonTasks,
15342
15903
  registerBrowserDeps,
15343
- produceImageOutput,
15344
15904
  normalizeOutputMimeType,
15345
15905
  merge,
15346
15906
  mcpTransportTypes,
@@ -15358,11 +15918,12 @@ export {
15358
15918
  lambda,
15359
15919
  json,
15360
15920
  javaScript,
15921
+ hasFilterOp2 as hasFilterOp,
15361
15922
  getSafeFetchImpl,
15362
15923
  getMcpTaskDeps,
15363
15924
  getMcpServerConfig,
15364
15925
  getMcpServer,
15365
- getImageRasterCodec2 as getImageRasterCodec,
15926
+ getImageRasterCodec,
15366
15927
  getGlobalMcpServers,
15367
15928
  getGlobalMcpServerRepository,
15368
15929
  getBrowserDeps,
@@ -15379,6 +15940,8 @@ export {
15379
15940
  assertWithinPixelBudget,
15380
15941
  assertWithinByteBudget,
15381
15942
  assertIsDataUri,
15943
+ applyFilter3 as applyFilter,
15944
+ _resetFilterRegistryForTests,
15382
15945
  VectorSumTask,
15383
15946
  VectorSubtractTask,
15384
15947
  VectorScaleTask,
@@ -15439,7 +16002,6 @@ export {
15439
16002
  JavaScriptTask,
15440
16003
  InputTask,
15441
16004
  InMemoryMcpServerRepository,
15442
- ImageWatermarkTask,
15443
16005
  ImageTransparencyTask,
15444
16006
  ImageTintTask,
15445
16007
  ImageThresholdTask,
@@ -15452,14 +16014,12 @@ export {
15452
16014
  ImageInvertTask,
15453
16015
  ImageGrayscaleTask,
15454
16016
  ImageFlipTask,
16017
+ ImageFilterTask,
15455
16018
  ImageCropTask,
15456
16019
  ImageContrastTask,
15457
16020
  ImageBrightnessTask,
15458
16021
  ImageBorderTask,
15459
16022
  ImageBlurTask,
15460
- ImageBinarySchemaOptions,
15461
- ImageBinarySchema,
15462
- ImageBinaryOrDataUriSchema,
15463
16023
  HumanInputTask,
15464
16024
  HumanApprovalTask,
15465
16025
  HexColorSchema,
@@ -15469,6 +16029,7 @@ export {
15469
16029
  DelayTask,
15470
16030
  DebugLogTask,
15471
16031
  DateFormatTask,
16032
+ CssRgbColorSchema,
15472
16033
  CredentialStoreOAuthProvider,
15473
16034
  ColorValueSchema,
15474
16035
  ColorSchema,
@@ -15506,4 +16067,4 @@ export {
15506
16067
  ArrayTask
15507
16068
  };
15508
16069
 
15509
- //# debugId=C12051EC74980D7364756E2164756E21
16070
+ //# debugId=D3AD9302546FF7B664756E2164756E21