@workglow/tasks 0.0.102 → 0.0.104

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 (59) hide show
  1. package/dist/browser.js +5218 -4202
  2. package/dist/browser.js.map +24 -10
  3. package/dist/bun.js +2617 -1578
  4. package/dist/bun.js.map +25 -11
  5. package/dist/common.d.ts +29 -1
  6. package/dist/common.d.ts.map +1 -1
  7. package/dist/node.js +2617 -1578
  8. package/dist/node.js.map +25 -11
  9. package/dist/task/DateFormatTask.d.ts +107 -0
  10. package/dist/task/DateFormatTask.d.ts.map +1 -0
  11. package/dist/task/FetchUrlTask.d.ts +20 -1
  12. package/dist/task/FetchUrlTask.d.ts.map +1 -1
  13. package/dist/task/FileLoaderTask.d.ts +23 -0
  14. package/dist/task/FileLoaderTask.d.ts.map +1 -1
  15. package/dist/task/FileLoaderTask.server.d.ts +3 -0
  16. package/dist/task/FileLoaderTask.server.d.ts.map +1 -1
  17. package/dist/task/InputTask.d.ts.map +1 -1
  18. package/dist/task/JavaScriptTask.d.ts +4 -0
  19. package/dist/task/JavaScriptTask.d.ts.map +1 -1
  20. package/dist/task/JsonPathTask.d.ts +77 -0
  21. package/dist/task/JsonPathTask.d.ts.map +1 -0
  22. package/dist/task/LambdaTask.d.ts +4 -0
  23. package/dist/task/LambdaTask.d.ts.map +1 -1
  24. package/dist/task/OutputTask.d.ts.map +1 -1
  25. package/dist/task/RegexTask.d.ts +109 -0
  26. package/dist/task/RegexTask.d.ts.map +1 -0
  27. package/dist/task/TemplateTask.d.ts +89 -0
  28. package/dist/task/TemplateTask.d.ts.map +1 -0
  29. package/dist/task/mcp/McpPromptGetTask.d.ts +8 -0
  30. package/dist/task/mcp/McpPromptGetTask.d.ts.map +1 -1
  31. package/dist/task/mcp/McpResourceReadTask.d.ts +8 -0
  32. package/dist/task/mcp/McpResourceReadTask.d.ts.map +1 -1
  33. package/dist/task/mcp/McpToolCallTask.d.ts +8 -0
  34. package/dist/task/mcp/McpToolCallTask.d.ts.map +1 -1
  35. package/dist/task/string/StringConcatTask.d.ts +61 -0
  36. package/dist/task/string/StringConcatTask.d.ts.map +1 -0
  37. package/dist/task/string/StringIncludesTask.d.ts +81 -0
  38. package/dist/task/string/StringIncludesTask.d.ts.map +1 -0
  39. package/dist/task/string/StringJoinTask.d.ts +89 -0
  40. package/dist/task/string/StringJoinTask.d.ts.map +1 -0
  41. package/dist/task/string/StringLengthTask.d.ts +71 -0
  42. package/dist/task/string/StringLengthTask.d.ts.map +1 -0
  43. package/dist/task/string/StringLowerCaseTask.d.ts +71 -0
  44. package/dist/task/string/StringLowerCaseTask.d.ts.map +1 -0
  45. package/dist/task/string/StringReplaceTask.d.ts +91 -0
  46. package/dist/task/string/StringReplaceTask.d.ts.map +1 -0
  47. package/dist/task/string/StringSliceTask.d.ts +91 -0
  48. package/dist/task/string/StringSliceTask.d.ts.map +1 -0
  49. package/dist/task/string/StringTemplateTask.d.ts +83 -0
  50. package/dist/task/string/StringTemplateTask.d.ts.map +1 -0
  51. package/dist/task/string/StringTrimTask.d.ts +71 -0
  52. package/dist/task/string/StringTrimTask.d.ts.map +1 -0
  53. package/dist/task/string/StringUpperCaseTask.d.ts +71 -0
  54. package/dist/task/string/StringUpperCaseTask.d.ts.map +1 -0
  55. package/package.json +9 -9
  56. package/dist/task/scalar/scalar.test.d.ts +0 -7
  57. package/dist/task/scalar/scalar.test.d.ts.map +0 -1
  58. package/dist/task/vector/vector.test.d.ts +0 -7
  59. package/dist/task/vector/vector.test.d.ts.map +0 -1
package/dist/bun.js CHANGED
@@ -4,1090 +4,436 @@ var __require = import.meta.require;
4
4
  // src/bun.ts
5
5
  import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
6
6
 
7
- // src/task/FileLoaderTask.server.ts
8
- import {
9
- CreateWorkflow as CreateWorkflow3,
10
- TaskAbortedError as TaskAbortedError2,
11
- Workflow as Workflow3
12
- } from "@workglow/task-graph";
13
- import { readFile } from "fs/promises";
7
+ // src/task/adaptive.ts
8
+ import { CreateAdaptiveWorkflow, Workflow as Workflow10 } from "@workglow/task-graph";
14
9
 
15
- // src/task/FileLoaderTask.ts
16
- import {
17
- CreateWorkflow as CreateWorkflow2,
18
- Task,
19
- TaskAbortedError,
20
- Workflow as Workflow2
21
- } from "@workglow/task-graph";
22
- import Papa from "papaparse";
10
+ // src/task/scalar/ScalarAddTask.ts
11
+ import { CreateWorkflow, Task, Workflow } from "@workglow/task-graph";
23
12
 
24
- // src/task/FetchUrlTask.ts
25
- import {
26
- AbortSignalJobError,
27
- Job,
28
- PermanentJobError,
29
- RetryableJobError
30
- } from "@workglow/job-queue";
31
- import {
32
- CreateWorkflow,
33
- JobQueueTask,
34
- TaskConfigurationError,
35
- TaskInvalidInputError,
36
- Workflow
37
- } from "@workglow/task-graph";
13
+ // src/task/scalar/sumPrecise.ts
14
+ function kahanSum(values) {
15
+ let sum = 0;
16
+ let compensation = 0;
17
+ for (const value of values) {
18
+ const y = value - compensation;
19
+ const t = sum + y;
20
+ compensation = t - sum - y;
21
+ sum = t;
22
+ }
23
+ return sum;
24
+ }
25
+ var nativeSumPrecise = typeof Math.sumPrecise === "function" ? Math.sumPrecise : undefined;
26
+ var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
27
+
28
+ // src/task/scalar/ScalarAddTask.ts
38
29
  var inputSchema = {
39
30
  type: "object",
40
31
  properties: {
41
- url: {
42
- type: "string",
43
- title: "URL",
44
- description: "The URL to fetch from",
45
- format: "uri"
46
- },
47
- method: {
48
- enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
49
- title: "Method",
50
- description: "The HTTP method to use",
51
- default: "GET"
52
- },
53
- headers: {
54
- type: "object",
55
- additionalProperties: {
56
- type: "string"
57
- },
58
- title: "Headers",
59
- description: "The headers to send with the request"
60
- },
61
- body: {
62
- type: "string",
63
- title: "Body",
64
- description: "The body of the request"
65
- },
66
- response_type: {
67
- anyOf: [{ type: "null" }, { enum: ["json", "text", "blob", "arraybuffer"] }],
68
- title: "Response Type",
69
- description: "The forced type of response to return. If null, the response type is inferred from the Content-Type header.",
70
- default: null
71
- },
72
- timeout: {
32
+ a: {
73
33
  type: "number",
74
- title: "Timeout",
75
- description: "Request timeout in milliseconds"
34
+ title: "A",
35
+ description: "First number"
76
36
  },
77
- queue: {
78
- oneOf: [{ type: "boolean" }, { type: "string" }],
79
- description: "Queue handling: false=run inline, true=use default, string=explicit queue name",
80
- default: true,
81
- "x-ui-hidden": true
37
+ b: {
38
+ type: "number",
39
+ title: "B",
40
+ description: "Second number"
82
41
  }
83
42
  },
84
- required: ["url"],
43
+ required: ["a", "b"],
85
44
  additionalProperties: false
86
45
  };
87
46
  var outputSchema = {
88
47
  type: "object",
89
48
  properties: {
90
- json: {
91
- title: "JSON",
92
- description: "The JSON response"
93
- },
94
- text: {
95
- type: "string",
96
- title: "Text",
97
- description: "The text response"
98
- },
99
- blob: {
100
- title: "Blob",
101
- description: "The blob response"
102
- },
103
- arraybuffer: {
104
- title: "ArrayBuffer",
105
- description: "The arraybuffer response"
106
- },
107
- metadata: {
108
- type: "object",
109
- properties: {
110
- contentType: { type: "string" },
111
- headers: { type: "object", additionalProperties: { type: "string" } }
112
- },
113
- additionalProperties: false,
114
- title: "Response Metadata",
115
- description: "HTTP response metadata including content type and headers"
49
+ result: {
50
+ type: "number",
51
+ title: "Result",
52
+ description: "Sum of a and b"
116
53
  }
117
54
  },
55
+ required: ["result"],
118
56
  additionalProperties: false
119
57
  };
120
- async function fetchWithProgress(url, options = {}, onProgress) {
121
- if (!options.signal) {
122
- throw new TaskConfigurationError("An AbortSignal must be provided.");
123
- }
124
- const response = await globalThis.fetch(url, options);
125
- if (!response.body) {
126
- throw new Error("ReadableStream not supported in this environment.");
127
- }
128
- const contentLength = response.headers.get("Content-Length");
129
- const totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
130
- let receivedBytes = 0;
131
- const reader = response.body.getReader();
132
- const stream = new ReadableStream({
133
- start(controller) {
134
- async function push() {
135
- try {
136
- while (true) {
137
- if (options.signal?.aborted) {
138
- controller.error(new AbortSignalJobError("Fetch aborted"));
139
- reader.cancel();
140
- return;
141
- }
142
- const { done, value } = await reader.read();
143
- if (done) {
144
- controller.close();
145
- break;
146
- }
147
- controller.enqueue(value);
148
- receivedBytes += value.length;
149
- if (onProgress && totalBytes) {
150
- await onProgress(receivedBytes / totalBytes * 100);
151
- }
152
- }
153
- } catch (error) {
154
- controller.error(error);
155
- }
156
- }
157
- push();
158
- },
159
- cancel() {
160
- reader.cancel();
161
- }
162
- });
163
- return new Response(stream, {
164
- headers: response.headers,
165
- status: response.status,
166
- statusText: response.statusText
167
- });
168
- }
169
-
170
- class FetchUrlJob extends Job {
171
- constructor(config = { input: {} }) {
172
- super(config);
173
- }
174
- static type = "FetchUrlJob";
175
- async execute(input, context) {
176
- const response = await fetchWithProgress(input.url, {
177
- method: input.method,
178
- headers: input.headers,
179
- body: input.body,
180
- signal: context.signal
181
- }, async (progress) => await context.updateProgress(progress));
182
- if (response.ok) {
183
- const contentType = response.headers.get("content-type") ?? "";
184
- const headers = {};
185
- response.headers.forEach((value, key) => {
186
- headers[key] = value;
187
- });
188
- const metadata = {
189
- contentType,
190
- headers
191
- };
192
- let responseType = input.response_type;
193
- if (!responseType) {
194
- if (contentType.includes("application/json")) {
195
- responseType = "json";
196
- } else if (contentType.includes("text/")) {
197
- responseType = "text";
198
- } else if (contentType.includes("application/octet-stream")) {
199
- responseType = "arraybuffer";
200
- } else if (contentType.includes("application/pdf") || contentType.includes("image/") || contentType.includes("application/zip")) {
201
- responseType = "blob";
202
- } else {
203
- responseType = "json";
204
- }
205
- input.response_type = responseType;
206
- }
207
- if (responseType === "json") {
208
- return { json: await response.json(), metadata };
209
- } else if (responseType === "text") {
210
- return { text: await response.text(), metadata };
211
- } else if (responseType === "blob") {
212
- return { blob: await response.blob(), metadata };
213
- } else if (responseType === "arraybuffer") {
214
- return { arraybuffer: await response.arrayBuffer(), metadata };
215
- }
216
- throw new TaskInvalidInputError(`Invalid response type: ${responseType}`);
217
- } else {
218
- if (response.status === 429 || response.status === 503 || response.headers.get("Retry-After")) {
219
- let retryDate;
220
- const retryAfterStr = response.headers.get("Retry-After");
221
- if (retryAfterStr) {
222
- const parsedDate = new Date(retryAfterStr);
223
- if (!isNaN(parsedDate.getTime()) && parsedDate > new Date) {
224
- retryDate = parsedDate;
225
- } else {
226
- const retryAfterSeconds = parseInt(retryAfterStr) * 1000;
227
- if (!isNaN(retryAfterSeconds)) {
228
- retryDate = new Date(Date.now() + retryAfterSeconds);
229
- }
230
- }
231
- }
232
- throw new RetryableJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`, retryDate);
233
- } else {
234
- throw new PermanentJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`);
235
- }
236
- }
237
- }
238
- }
239
58
 
240
- class FetchUrlTask extends JobQueueTask {
241
- static type = "FetchUrlTask";
242
- static category = "Input";
243
- static title = "Fetch";
244
- static description = "Fetches data from a URL with progress tracking and automatic retry handling";
245
- static hasDynamicSchemas = true;
59
+ class ScalarAddTask extends Task {
60
+ static type = "ScalarAddTask";
61
+ static category = "Math";
62
+ static title = "Add";
63
+ static description = "Returns the sum of two numbers";
246
64
  static inputSchema() {
247
65
  return inputSchema;
248
66
  }
249
67
  static outputSchema() {
250
68
  return outputSchema;
251
69
  }
252
- outputSchema() {
253
- const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
254
- if (responseType === null || responseType === undefined) {
255
- return this.constructor.outputSchema();
256
- }
257
- const staticSchema = this.constructor.outputSchema();
258
- if (typeof staticSchema === "boolean") {
259
- return staticSchema;
260
- }
261
- if (!staticSchema.properties) {
262
- return staticSchema;
263
- }
264
- const properties = {};
265
- if (responseType === "json" && staticSchema.properties.json) {
266
- properties.json = staticSchema.properties.json;
267
- } else if (responseType === "text" && staticSchema.properties.text) {
268
- properties.text = staticSchema.properties.text;
269
- } else if (responseType === "blob" && staticSchema.properties.blob) {
270
- properties.blob = staticSchema.properties.blob;
271
- } else if (responseType === "arraybuffer" && staticSchema.properties.arraybuffer) {
272
- properties.arraybuffer = staticSchema.properties.arraybuffer;
273
- }
274
- if (staticSchema.properties.metadata) {
275
- properties.metadata = staticSchema.properties.metadata;
276
- }
277
- if (Object.keys(properties).length === 0) {
278
- return staticSchema;
279
- }
280
- return {
281
- type: "object",
282
- properties,
283
- additionalProperties: false
284
- };
285
- }
286
- constructor(input = {}, config = {}) {
287
- config.queue = input?.queue ?? config.queue;
288
- if (config.queue === undefined) {
289
- config.queue = false;
290
- }
291
- super(input, config);
292
- this.jobClass = FetchUrlJob;
293
- }
294
- setInput(input) {
295
- if (!("response_type" in input)) {
296
- super.setInput(input);
297
- return;
298
- }
299
- const getCurrentResponseType = () => {
300
- return this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
301
- };
302
- const previousResponseType = getCurrentResponseType();
303
- super.setInput(input);
304
- const newResponseType = getCurrentResponseType();
305
- if (previousResponseType !== newResponseType) {
306
- this.emitSchemaChange();
307
- }
308
- }
309
- async getDefaultQueueName(input) {
310
- if (!input.url) {
311
- return `fetch:${this.type}`;
312
- }
313
- try {
314
- const hostname = new URL(input.url).hostname.toLowerCase();
315
- const parts = hostname.split(".").filter(Boolean);
316
- if (parts.length === 0) {
317
- return `fetch:${this.type}`;
318
- }
319
- const domain = parts.length <= 2 ? parts.join(".") : parts.slice(-2).join(".");
320
- return `fetch:${domain}`;
321
- } catch {
322
- return `fetch:${this.type}`;
323
- }
70
+ async execute(input, _context) {
71
+ return { result: sumPrecise([input.a, input.b]) };
324
72
  }
325
73
  }
326
- var fetchUrl = async (input, config = {}) => {
327
- const result = await new FetchUrlTask({}, config).run(input);
328
- return result;
329
- };
330
- Workflow.prototype.fetch = CreateWorkflow(FetchUrlTask);
74
+ Workflow.prototype.scalarAdd = CreateWorkflow(ScalarAddTask);
331
75
 
332
- // src/task/FileLoaderTask.ts
76
+ // src/task/scalar/ScalarDivideTask.ts
77
+ import { CreateWorkflow as CreateWorkflow2, Task as Task2, Workflow as Workflow2 } from "@workglow/task-graph";
333
78
  var inputSchema2 = {
334
79
  type: "object",
335
80
  properties: {
336
- url: {
337
- type: "string",
338
- title: "URL",
339
- description: "URL to load document from (http://, https://)",
340
- format: "uri"
81
+ a: {
82
+ type: "number",
83
+ title: "A",
84
+ description: "Numerator"
341
85
  },
342
- format: {
343
- type: "string",
344
- enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
345
- title: "Format",
346
- description: "File format (auto-detected from URL if 'auto')",
347
- default: "auto"
86
+ b: {
87
+ type: "number",
88
+ title: "B",
89
+ description: "Denominator"
348
90
  }
349
91
  },
350
- required: ["url"],
92
+ required: ["a", "b"],
351
93
  additionalProperties: false
352
94
  };
353
95
  var outputSchema2 = {
354
96
  type: "object",
355
97
  properties: {
356
- text: {
357
- type: "string",
358
- title: "Text",
359
- description: "Text content (for text, markdown, html formats)"
360
- },
361
- json: {
362
- title: "JSON",
363
- description: "Parsed JSON object or array"
364
- },
365
- csv: {
366
- type: "array",
367
- title: "CSV",
368
- description: "Parsed CSV data as array of objects"
369
- },
370
- image: {
371
- type: "string",
372
- title: "Image",
373
- description: "Base64 data URL for image files",
374
- format: "image:data-uri"
375
- },
376
- pdf: {
377
- type: "string",
378
- title: "PDF",
379
- description: "Base64 data URL for PDF files"
380
- },
381
- metadata: {
382
- type: "object",
383
- properties: {
384
- url: { type: "string" },
385
- format: { type: "string" },
386
- size: { type: "number" },
387
- title: { type: "string" },
388
- mimeType: { type: "string" }
389
- },
390
- additionalProperties: false,
391
- title: "Metadata",
392
- description: "File metadata"
98
+ result: {
99
+ type: "number",
100
+ title: "Result",
101
+ description: "Quotient (a / b)"
393
102
  }
394
103
  },
395
- required: ["metadata"],
104
+ required: ["result"],
396
105
  additionalProperties: false
397
106
  };
398
107
 
399
- class FileLoaderTask extends Task {
400
- static type = "FileLoaderTask";
401
- static category = "Document";
402
- static title = "File Loader";
403
- static description = "Load documents from URLs (http://, https://)";
404
- static cacheable = true;
108
+ class ScalarDivideTask extends Task2 {
109
+ static type = "ScalarDivideTask";
110
+ static category = "Math";
111
+ static title = "Divide";
112
+ static description = "Returns the quotient of two numbers (a / b)";
405
113
  static inputSchema() {
406
114
  return inputSchema2;
407
115
  }
408
116
  static outputSchema() {
409
117
  return outputSchema2;
410
118
  }
411
- async execute(input, context) {
412
- const { url, format = "auto" } = input;
413
- if (context.signal.aborted) {
414
- throw new TaskAbortedError("Task aborted");
415
- }
416
- await context.updateProgress(0, "Detecting file format");
417
- const detectedFormat = this.detectFormat(url, format);
418
- const responseType = this.detectResponseType(detectedFormat);
419
- if (context.signal.aborted) {
420
- throw new TaskAbortedError("Task aborted");
421
- }
422
- await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
423
- const fetchTask = context.own(new FetchUrlTask({
424
- url,
425
- response_type: responseType,
426
- queue: false
427
- }));
428
- const response = await fetchTask.run();
429
- if (context.signal.aborted) {
430
- throw new TaskAbortedError("Task aborted");
119
+ async execute(input, _context) {
120
+ return { result: input.a / input.b };
121
+ }
122
+ }
123
+ Workflow2.prototype.scalarDivide = CreateWorkflow2(ScalarDivideTask);
124
+
125
+ // src/task/scalar/ScalarMultiplyTask.ts
126
+ import { CreateWorkflow as CreateWorkflow3, Task as Task3, Workflow as Workflow3 } from "@workglow/task-graph";
127
+ var inputSchema3 = {
128
+ type: "object",
129
+ properties: {
130
+ a: {
131
+ type: "number",
132
+ title: "A",
133
+ description: "First number"
134
+ },
135
+ b: {
136
+ type: "number",
137
+ title: "B",
138
+ description: "Second number"
431
139
  }
432
- await context.updateProgress(60, "Parsing file content");
433
- const title = url.split("/").pop() || url;
434
- const { text, json, csv, image, pdf, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
435
- if (context.signal.aborted) {
436
- throw new TaskAbortedError("Task aborted");
140
+ },
141
+ required: ["a", "b"],
142
+ additionalProperties: false
143
+ };
144
+ var outputSchema3 = {
145
+ type: "object",
146
+ properties: {
147
+ result: {
148
+ type: "number",
149
+ title: "Result",
150
+ description: "Product of a and b"
437
151
  }
438
- await context.updateProgress(100, "File loaded successfully");
439
- return {
440
- text,
441
- json,
442
- csv,
443
- image,
444
- pdf,
445
- metadata: {
446
- url,
447
- format: detectedFormat,
448
- size,
449
- title,
450
- mimeType
451
- }
452
- };
152
+ },
153
+ required: ["result"],
154
+ additionalProperties: false
155
+ };
156
+
157
+ class ScalarMultiplyTask extends Task3 {
158
+ static type = "ScalarMultiplyTask";
159
+ static category = "Math";
160
+ static title = "Multiply";
161
+ static description = "Returns the product of two numbers";
162
+ static inputSchema() {
163
+ return inputSchema3;
453
164
  }
454
- parseJsonContent(content) {
455
- return JSON.parse(content);
165
+ static outputSchema() {
166
+ return outputSchema3;
456
167
  }
457
- parseCsvContent(content) {
458
- try {
459
- const result = Papa.parse(content, {
460
- header: true,
461
- skipEmptyLines: true,
462
- transformHeader: (header) => header.trim()
463
- });
464
- return result.data;
465
- } catch (error) {
466
- throw new Error(`Failed to parse CSV: ${error}`);
467
- }
168
+ async execute(input, _context) {
169
+ return { result: input.a * input.b };
468
170
  }
469
- async parseResponse(response, url, detectedFormat) {
470
- const responseMimeType = response.metadata?.contentType || "";
471
- if (detectedFormat === "json") {
472
- if (!response.json) {
473
- throw new Error(`Failed to load JSON from ${url}`);
474
- }
475
- const jsonData = response.json;
476
- const content2 = JSON.stringify(jsonData, null, 2);
477
- return {
478
- text: undefined,
479
- json: jsonData,
480
- csv: undefined,
481
- image: undefined,
482
- pdf: undefined,
483
- size: content2.length,
484
- mimeType: responseMimeType || "application/json"
485
- };
486
- }
487
- if (detectedFormat === "csv") {
488
- const content2 = response.text || "";
489
- if (!content2) {
490
- throw new Error(`Failed to load CSV from ${url}`);
491
- }
492
- const csvData = this.parseCsvContent(content2);
493
- return {
494
- text: undefined,
495
- json: undefined,
496
- csv: csvData,
497
- image: undefined,
498
- pdf: undefined,
499
- size: content2.length,
500
- mimeType: responseMimeType || "text/csv"
501
- };
502
- }
503
- if (detectedFormat === "image") {
504
- if (!response.blob) {
505
- throw new Error(`Failed to load image from ${url}`);
506
- }
507
- const blob = response.blob;
508
- const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
509
- const imageData = await this.blobToBase64DataURL(blob, mimeType2);
510
- return {
511
- text: undefined,
512
- json: undefined,
513
- csv: undefined,
514
- image: imageData,
515
- pdf: undefined,
516
- size: blob.size,
517
- mimeType: mimeType2
518
- };
519
- }
520
- if (detectedFormat === "pdf") {
521
- if (!response.blob) {
522
- throw new Error(`Failed to load PDF from ${url}`);
523
- }
524
- const blob = response.blob;
525
- const mimeType2 = responseMimeType || "application/pdf";
526
- const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
527
- return {
528
- text: undefined,
529
- json: undefined,
530
- csv: undefined,
531
- image: undefined,
532
- pdf: pdfData,
533
- size: blob.size,
534
- mimeType: mimeType2
535
- };
171
+ }
172
+ Workflow3.prototype.scalarMultiply = CreateWorkflow3(ScalarMultiplyTask);
173
+
174
+ // src/task/scalar/ScalarSubtractTask.ts
175
+ import { CreateWorkflow as CreateWorkflow4, Task as Task4, Workflow as Workflow4 } from "@workglow/task-graph";
176
+ var inputSchema4 = {
177
+ type: "object",
178
+ properties: {
179
+ a: {
180
+ type: "number",
181
+ title: "A",
182
+ description: "First number"
183
+ },
184
+ b: {
185
+ type: "number",
186
+ title: "B",
187
+ description: "Second number"
536
188
  }
537
- const content = response.text || "";
538
- if (!content) {
539
- throw new Error(`Failed to load content from ${url}`);
189
+ },
190
+ required: ["a", "b"],
191
+ additionalProperties: false
192
+ };
193
+ var outputSchema4 = {
194
+ type: "object",
195
+ properties: {
196
+ result: {
197
+ type: "number",
198
+ title: "Result",
199
+ description: "Difference (a - b)"
540
200
  }
541
- const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
542
- return {
543
- text: content,
544
- json: undefined,
545
- csv: undefined,
546
- image: undefined,
547
- pdf: undefined,
548
- size: content.length,
549
- mimeType
550
- };
201
+ },
202
+ required: ["result"],
203
+ additionalProperties: false
204
+ };
205
+
206
+ class ScalarSubtractTask extends Task4 {
207
+ static type = "ScalarSubtractTask";
208
+ static category = "Math";
209
+ static title = "Subtract";
210
+ static description = "Returns the difference of two numbers (a - b)";
211
+ static inputSchema() {
212
+ return inputSchema4;
551
213
  }
552
- detectResponseType(detectedFormat) {
553
- let responseType = "text";
554
- if (detectedFormat === "json") {
555
- responseType = "json";
556
- } else if (detectedFormat === "image" || detectedFormat === "pdf") {
557
- responseType = "blob";
558
- } else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
559
- responseType = "text";
560
- }
561
- return responseType;
214
+ static outputSchema() {
215
+ return outputSchema4;
562
216
  }
563
- detectFormat(url, format) {
564
- if (format === "auto") {
565
- const urlLower = url.toLowerCase();
566
- if (urlLower.endsWith(".md") || urlLower.endsWith(".markdown")) {
567
- return "markdown";
568
- } else if (urlLower.endsWith(".json")) {
569
- return "json";
570
- } else if (urlLower.endsWith(".csv")) {
571
- return "csv";
572
- } else if (urlLower.endsWith(".pdf")) {
573
- return "pdf";
574
- } else if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/)) {
575
- return "image";
576
- } else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm")) {
577
- return "html";
578
- } else {
579
- return "text";
580
- }
217
+ async execute(input, _context) {
218
+ return { result: input.a - input.b };
219
+ }
220
+ }
221
+ Workflow4.prototype.scalarSubtract = CreateWorkflow4(ScalarSubtractTask);
222
+
223
+ // src/task/scalar/ScalarSumTask.ts
224
+ import { CreateWorkflow as CreateWorkflow5, Task as Task5, Workflow as Workflow5 } from "@workglow/task-graph";
225
+ var inputSchema5 = {
226
+ type: "object",
227
+ properties: {
228
+ values: {
229
+ type: "array",
230
+ items: { type: "number" },
231
+ title: "Values",
232
+ description: "Array of numbers to sum"
581
233
  }
582
- return format;
234
+ },
235
+ required: ["values"],
236
+ additionalProperties: false
237
+ };
238
+ var outputSchema5 = {
239
+ type: "object",
240
+ properties: {
241
+ result: {
242
+ type: "number",
243
+ title: "Result",
244
+ description: "Sum of all values"
245
+ }
246
+ },
247
+ required: ["result"],
248
+ additionalProperties: false
249
+ };
250
+
251
+ class ScalarSumTask extends Task5 {
252
+ static type = "ScalarSumTask";
253
+ static category = "Math";
254
+ static title = "Sum";
255
+ static description = "Returns the sum of an array of numbers";
256
+ static inputSchema() {
257
+ return inputSchema5;
583
258
  }
584
- getImageMimeType(url) {
585
- const urlLower = url.toLowerCase();
586
- if (urlLower.endsWith(".png"))
587
- return "image/png";
588
- if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
589
- return "image/jpeg";
590
- if (urlLower.endsWith(".gif"))
591
- return "image/gif";
592
- if (urlLower.endsWith(".webp"))
593
- return "image/webp";
594
- if (urlLower.endsWith(".bmp"))
595
- return "image/bmp";
596
- if (urlLower.endsWith(".svg"))
597
- return "image/svg+xml";
598
- if (urlLower.endsWith(".ico"))
599
- return "image/x-icon";
600
- return "image/jpeg";
259
+ static outputSchema() {
260
+ return outputSchema5;
601
261
  }
602
- async blobToBase64DataURL(blob, mimeType) {
603
- if (typeof Buffer !== "undefined") {
604
- const arrayBuffer = await blob.arrayBuffer();
605
- const buffer = Buffer.from(arrayBuffer);
606
- return `data:${mimeType};base64,${buffer.toString("base64")}`;
607
- }
608
- return new Promise((resolve, reject) => {
609
- const reader = new FileReader;
610
- reader.onloadend = () => {
611
- const result = reader.result;
612
- if (result.startsWith("data:;base64,")) {
613
- resolve(`data:${mimeType};base64,${result.substring(13)}`);
614
- } else {
615
- resolve(result);
616
- }
617
- };
618
- reader.onerror = reject;
619
- reader.readAsDataURL(blob);
620
- });
262
+ async execute(input, _context) {
263
+ return { result: sumPrecise(input.values) };
621
264
  }
622
265
  }
623
- Workflow2.prototype.fileLoader = CreateWorkflow2(FileLoaderTask);
266
+ Workflow5.prototype.scalarSum = CreateWorkflow5(ScalarSumTask);
624
267
 
625
- // src/task/FileLoaderTask.server.ts
626
- class FileLoaderTask2 extends FileLoaderTask {
627
- async execute(input, context) {
628
- let { url, format = "auto" } = input;
629
- if (url.startsWith("http://") || url.startsWith("https://")) {
630
- return super.execute(input, context);
631
- }
632
- if (context.signal.aborted) {
633
- throw new TaskAbortedError2("Task aborted");
268
+ // src/task/vector/VectorDivideTask.ts
269
+ import { CreateWorkflow as CreateWorkflow6, Task as Task6, Workflow as Workflow6 } from "@workglow/task-graph";
270
+ import {
271
+ createTypedArrayFrom,
272
+ TypedArraySchema
273
+ } from "@workglow/util";
274
+ var inputSchema6 = {
275
+ type: "object",
276
+ properties: {
277
+ vectors: {
278
+ type: "array",
279
+ items: TypedArraySchema({
280
+ title: "Vector",
281
+ description: "Vector (first is numerator, rest are denominators)"
282
+ }),
283
+ title: "Vectors",
284
+ description: "Array of vectors: vectors[0] / vectors[1] / vectors[2] / ..."
634
285
  }
635
- await context.updateProgress(0, "Detecting file format");
636
- if (url.startsWith("file://")) {
637
- url = url.slice(7);
286
+ },
287
+ required: ["vectors"],
288
+ additionalProperties: false
289
+ };
290
+ var outputSchema6 = {
291
+ type: "object",
292
+ properties: {
293
+ result: TypedArraySchema({
294
+ title: "Result",
295
+ description: "Component-wise quotient"
296
+ })
297
+ },
298
+ required: ["result"],
299
+ additionalProperties: false
300
+ };
301
+
302
+ class VectorDivideTask extends Task6 {
303
+ static type = "VectorDivideTask";
304
+ static category = "Vector";
305
+ static title = "Divide";
306
+ static description = "Returns component-wise quotient: vectors[0] / vectors[1] / vectors[2] / ...";
307
+ static inputSchema() {
308
+ return inputSchema6;
309
+ }
310
+ static outputSchema() {
311
+ return outputSchema6;
312
+ }
313
+ async execute(input, _context) {
314
+ const { vectors } = input;
315
+ if (vectors.length < 2) {
316
+ throw new Error("At least two vectors are required");
638
317
  }
639
- const detectedFormat = this.detectFormat(url, format);
640
- const title = url.split("/").pop() || url;
641
- if (context.signal.aborted) {
642
- throw new TaskAbortedError2("Task aborted");
643
- }
644
- await context.updateProgress(10, `Reading ${detectedFormat} file from filesystem`);
645
- if (detectedFormat === "json") {
646
- const fileContent2 = await readFile(url, { encoding: "utf-8" });
647
- if (context.signal.aborted) {
648
- throw new TaskAbortedError2("Task aborted");
649
- }
650
- await context.updateProgress(50, "Parsing JSON content");
651
- const jsonData = this.parseJsonContent(fileContent2);
652
- const content = JSON.stringify(jsonData, null, 2);
653
- if (context.signal.aborted) {
654
- throw new TaskAbortedError2("Task aborted");
655
- }
656
- await context.updateProgress(100, "File loaded successfully");
657
- return {
658
- text: undefined,
659
- json: jsonData,
660
- csv: undefined,
661
- image: undefined,
662
- pdf: undefined,
663
- metadata: {
664
- url,
665
- format: detectedFormat,
666
- size: content.length,
667
- title,
668
- mimeType: "application/json"
669
- }
670
- };
671
- }
672
- if (detectedFormat === "csv") {
673
- const fileContent2 = await readFile(url, { encoding: "utf-8" });
674
- if (!fileContent2) {
675
- throw new Error(`Failed to load CSV from ${url}`);
676
- }
677
- if (context.signal.aborted) {
678
- throw new TaskAbortedError2("Task aborted");
679
- }
680
- await context.updateProgress(50, "Parsing CSV content");
681
- const csvData = this.parseCsvContent(fileContent2);
682
- if (context.signal.aborted) {
683
- throw new TaskAbortedError2("Task aborted");
684
- }
685
- await context.updateProgress(100, "File loaded successfully");
686
- return {
687
- text: undefined,
688
- json: undefined,
689
- csv: csvData,
690
- image: undefined,
691
- pdf: undefined,
692
- metadata: {
693
- url,
694
- format: detectedFormat,
695
- size: fileContent2.length,
696
- title,
697
- mimeType: "text/csv"
698
- }
699
- };
700
- }
701
- if (detectedFormat === "image") {
702
- const fileBuffer = await readFile(url);
703
- if (context.signal.aborted) {
704
- throw new TaskAbortedError2("Task aborted");
705
- }
706
- await context.updateProgress(50, "Converting image to base64");
707
- const mimeType2 = this.getImageMimeType(url);
708
- const blob = new Blob([fileBuffer], { type: mimeType2 });
709
- const imageData = await this.blobToBase64DataURL(blob, mimeType2);
710
- if (context.signal.aborted) {
711
- throw new TaskAbortedError2("Task aborted");
712
- }
713
- await context.updateProgress(100, "File loaded successfully");
714
- return {
715
- text: undefined,
716
- json: undefined,
717
- csv: undefined,
718
- image: imageData,
719
- pdf: undefined,
720
- metadata: {
721
- url,
722
- format: detectedFormat,
723
- size: fileBuffer.length,
724
- title,
725
- mimeType: mimeType2
726
- }
727
- };
728
- }
729
- if (detectedFormat === "pdf") {
730
- const fileBuffer = await readFile(url);
731
- if (context.signal.aborted) {
732
- throw new TaskAbortedError2("Task aborted");
733
- }
734
- await context.updateProgress(50, "Converting PDF to base64");
735
- const mimeType2 = "application/pdf";
736
- const blob = new Blob([fileBuffer], { type: mimeType2 });
737
- const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
738
- if (context.signal.aborted) {
739
- throw new TaskAbortedError2("Task aborted");
318
+ const len = vectors[0].length;
319
+ for (let i = 1;i < vectors.length; i++) {
320
+ if (vectors[i].length !== len) {
321
+ throw new Error("All vectors must have the same length");
740
322
  }
741
- await context.updateProgress(100, "File loaded successfully");
742
- return {
743
- text: undefined,
744
- json: undefined,
745
- csv: undefined,
746
- image: undefined,
747
- pdf: pdfData,
748
- metadata: {
749
- url,
750
- format: detectedFormat,
751
- size: fileBuffer.length,
752
- title,
753
- mimeType: mimeType2
754
- }
755
- };
756
323
  }
757
- const fileContent = await readFile(url, { encoding: "utf-8" });
758
- if (!fileContent) {
759
- throw new Error(`Failed to load content from ${url}`);
760
- }
761
- if (context.signal.aborted) {
762
- throw new TaskAbortedError2("Task aborted");
763
- }
764
- await context.updateProgress(50, `Parsing ${detectedFormat} content`);
765
- const mimeType = detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain";
766
- if (context.signal.aborted) {
767
- throw new TaskAbortedError2("Task aborted");
768
- }
769
- await context.updateProgress(100, "File loaded successfully");
770
- return {
771
- text: fileContent,
772
- json: undefined,
773
- csv: undefined,
774
- image: undefined,
775
- pdf: undefined,
776
- metadata: {
777
- url,
778
- format: detectedFormat,
779
- size: fileContent.length,
780
- title,
781
- mimeType
324
+ const values = Array.from({ length: len }, (_, i) => {
325
+ let acc = Number(vectors[0][i]);
326
+ for (let j = 1;j < vectors.length; j++) {
327
+ acc /= Number(vectors[j][i]);
782
328
  }
783
- };
784
- }
785
- }
786
- var fileLoader = (input, config) => {
787
- return new FileLoaderTask2({}, config).run(input);
788
- };
789
- Workflow3.prototype.fileLoader = CreateWorkflow3(FileLoaderTask2);
790
-
791
- // src/task/adaptive.ts
792
- import { CreateAdaptiveWorkflow, Workflow as Workflow13 } from "@workglow/task-graph";
793
-
794
- // src/task/scalar/ScalarAddTask.ts
795
- import { CreateWorkflow as CreateWorkflow4, Task as Task2, Workflow as Workflow4 } from "@workglow/task-graph";
796
-
797
- // src/task/scalar/sumPrecise.ts
798
- function kahanSum(values) {
799
- let sum = 0;
800
- let compensation = 0;
801
- for (const value of values) {
802
- const y = value - compensation;
803
- const t = sum + y;
804
- compensation = t - sum - y;
805
- sum = t;
329
+ return acc;
330
+ });
331
+ return { result: createTypedArrayFrom(vectors, values) };
806
332
  }
807
- return sum;
808
333
  }
809
- var nativeSumPrecise = typeof Math.sumPrecise === "function" ? Math.sumPrecise : undefined;
810
- var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
334
+ Workflow6.prototype.vectorDivide = CreateWorkflow6(VectorDivideTask);
811
335
 
812
- // src/task/scalar/ScalarAddTask.ts
813
- var inputSchema3 = {
336
+ // src/task/vector/VectorMultiplyTask.ts
337
+ import { CreateWorkflow as CreateWorkflow7, Task as Task7, Workflow as Workflow7 } from "@workglow/task-graph";
338
+ import {
339
+ createTypedArrayFrom as createTypedArrayFrom2,
340
+ TypedArraySchema as TypedArraySchema2
341
+ } from "@workglow/util";
342
+ var inputSchema7 = {
814
343
  type: "object",
815
344
  properties: {
816
- a: {
817
- type: "number",
818
- title: "A",
819
- description: "First number"
820
- },
821
- b: {
822
- type: "number",
823
- title: "B",
824
- description: "Second number"
345
+ vectors: {
346
+ type: "array",
347
+ items: TypedArraySchema2({
348
+ title: "Vector",
349
+ description: "Vector for component-wise product"
350
+ }),
351
+ title: "Vectors",
352
+ description: "Array of vectors to multiply component-wise"
825
353
  }
826
354
  },
827
- required: ["a", "b"],
355
+ required: ["vectors"],
828
356
  additionalProperties: false
829
357
  };
830
- var outputSchema3 = {
358
+ var outputSchema7 = {
831
359
  type: "object",
832
360
  properties: {
833
- result: {
834
- type: "number",
361
+ result: TypedArraySchema2({
835
362
  title: "Result",
836
- description: "Sum of a and b"
837
- }
363
+ description: "Component-wise product (Hadamard product)"
364
+ })
838
365
  },
839
366
  required: ["result"],
840
367
  additionalProperties: false
841
368
  };
842
369
 
843
- class ScalarAddTask extends Task2 {
844
- static type = "ScalarAddTask";
845
- static category = "Math";
846
- static title = "Add";
847
- static description = "Returns the sum of two numbers";
370
+ class VectorMultiplyTask extends Task7 {
371
+ static type = "VectorMultiplyTask";
372
+ static category = "Vector";
373
+ static title = "Multiply";
374
+ static description = "Returns the component-wise product (Hadamard product) of all vectors";
848
375
  static inputSchema() {
849
- return inputSchema3;
376
+ return inputSchema7;
850
377
  }
851
378
  static outputSchema() {
852
- return outputSchema3;
379
+ return outputSchema7;
853
380
  }
854
381
  async execute(input, _context) {
855
- return { result: sumPrecise([input.a, input.b]) };
382
+ const { vectors } = input;
383
+ if (vectors.length === 0) {
384
+ throw new Error("At least one vector is required");
385
+ }
386
+ const len = vectors[0].length;
387
+ for (let i = 1;i < vectors.length; i++) {
388
+ if (vectors[i].length !== len) {
389
+ throw new Error("All vectors must have the same length");
390
+ }
391
+ }
392
+ const values = Array.from({ length: len }, (_, i) => vectors.reduce((acc, v) => acc * Number(v[i]), 1));
393
+ return { result: createTypedArrayFrom2(vectors, values) };
856
394
  }
857
395
  }
858
- Workflow4.prototype.scalarAdd = CreateWorkflow4(ScalarAddTask);
396
+ Workflow7.prototype.vectorMultiply = CreateWorkflow7(VectorMultiplyTask);
859
397
 
860
- // src/task/scalar/ScalarDivideTask.ts
861
- import { CreateWorkflow as CreateWorkflow5, Task as Task3, Workflow as Workflow5 } from "@workglow/task-graph";
862
- var inputSchema4 = {
398
+ // src/task/vector/VectorSubtractTask.ts
399
+ import { CreateWorkflow as CreateWorkflow8, Task as Task8, Workflow as Workflow8 } from "@workglow/task-graph";
400
+ import {
401
+ createTypedArrayFrom as createTypedArrayFrom3,
402
+ TypedArraySchema as TypedArraySchema3
403
+ } from "@workglow/util";
404
+ var inputSchema8 = {
863
405
  type: "object",
864
406
  properties: {
865
- a: {
866
- type: "number",
867
- title: "A",
868
- description: "Numerator"
869
- },
870
- b: {
871
- type: "number",
872
- title: "B",
873
- description: "Denominator"
407
+ vectors: {
408
+ type: "array",
409
+ items: TypedArraySchema3({
410
+ title: "Vector",
411
+ description: "Vector (first is minuend, rest are subtrahends)"
412
+ }),
413
+ title: "Vectors",
414
+ description: "Array of vectors: vectors[0] - vectors[1] - vectors[2] - ..."
874
415
  }
875
416
  },
876
- required: ["a", "b"],
417
+ required: ["vectors"],
877
418
  additionalProperties: false
878
419
  };
879
- var outputSchema4 = {
420
+ var outputSchema8 = {
880
421
  type: "object",
881
422
  properties: {
882
- result: {
883
- type: "number",
884
- title: "Result",
885
- description: "Quotient (a / b)"
886
- }
887
- },
888
- required: ["result"],
889
- additionalProperties: false
890
- };
891
-
892
- class ScalarDivideTask extends Task3 {
893
- static type = "ScalarDivideTask";
894
- static category = "Math";
895
- static title = "Divide";
896
- static description = "Returns the quotient of two numbers (a / b)";
897
- static inputSchema() {
898
- return inputSchema4;
899
- }
900
- static outputSchema() {
901
- return outputSchema4;
902
- }
903
- async execute(input, _context) {
904
- return { result: input.a / input.b };
905
- }
906
- }
907
- Workflow5.prototype.scalarDivide = CreateWorkflow5(ScalarDivideTask);
908
-
909
- // src/task/scalar/ScalarMultiplyTask.ts
910
- import { CreateWorkflow as CreateWorkflow6, Task as Task4, Workflow as Workflow6 } from "@workglow/task-graph";
911
- var inputSchema5 = {
912
- type: "object",
913
- properties: {
914
- a: {
915
- type: "number",
916
- title: "A",
917
- description: "First number"
918
- },
919
- b: {
920
- type: "number",
921
- title: "B",
922
- description: "Second number"
923
- }
924
- },
925
- required: ["a", "b"],
926
- additionalProperties: false
927
- };
928
- var outputSchema5 = {
929
- type: "object",
930
- properties: {
931
- result: {
932
- type: "number",
933
- title: "Result",
934
- description: "Product of a and b"
935
- }
936
- },
937
- required: ["result"],
938
- additionalProperties: false
939
- };
940
-
941
- class ScalarMultiplyTask extends Task4 {
942
- static type = "ScalarMultiplyTask";
943
- static category = "Math";
944
- static title = "Multiply";
945
- static description = "Returns the product of two numbers";
946
- static inputSchema() {
947
- return inputSchema5;
948
- }
949
- static outputSchema() {
950
- return outputSchema5;
951
- }
952
- async execute(input, _context) {
953
- return { result: input.a * input.b };
954
- }
955
- }
956
- Workflow6.prototype.scalarMultiply = CreateWorkflow6(ScalarMultiplyTask);
957
-
958
- // src/task/scalar/ScalarSubtractTask.ts
959
- import { CreateWorkflow as CreateWorkflow7, Task as Task5, Workflow as Workflow7 } from "@workglow/task-graph";
960
- var inputSchema6 = {
961
- type: "object",
962
- properties: {
963
- a: {
964
- type: "number",
965
- title: "A",
966
- description: "First number"
967
- },
968
- b: {
969
- type: "number",
970
- title: "B",
971
- description: "Second number"
972
- }
973
- },
974
- required: ["a", "b"],
975
- additionalProperties: false
976
- };
977
- var outputSchema6 = {
978
- type: "object",
979
- properties: {
980
- result: {
981
- type: "number",
982
- title: "Result",
983
- description: "Difference (a - b)"
984
- }
985
- },
986
- required: ["result"],
987
- additionalProperties: false
988
- };
989
-
990
- class ScalarSubtractTask extends Task5 {
991
- static type = "ScalarSubtractTask";
992
- static category = "Math";
993
- static title = "Subtract";
994
- static description = "Returns the difference of two numbers (a - b)";
995
- static inputSchema() {
996
- return inputSchema6;
997
- }
998
- static outputSchema() {
999
- return outputSchema6;
1000
- }
1001
- async execute(input, _context) {
1002
- return { result: input.a - input.b };
1003
- }
1004
- }
1005
- Workflow7.prototype.scalarSubtract = CreateWorkflow7(ScalarSubtractTask);
1006
-
1007
- // src/task/scalar/ScalarSumTask.ts
1008
- import { CreateWorkflow as CreateWorkflow8, Task as Task6, Workflow as Workflow8 } from "@workglow/task-graph";
1009
- var inputSchema7 = {
1010
- type: "object",
1011
- properties: {
1012
- values: {
1013
- type: "array",
1014
- items: { type: "number" },
1015
- title: "Values",
1016
- description: "Array of numbers to sum"
1017
- }
1018
- },
1019
- required: ["values"],
1020
- additionalProperties: false
1021
- };
1022
- var outputSchema7 = {
1023
- type: "object",
1024
- properties: {
1025
- result: {
1026
- type: "number",
1027
- title: "Result",
1028
- description: "Sum of all values"
1029
- }
1030
- },
1031
- required: ["result"],
1032
- additionalProperties: false
1033
- };
1034
-
1035
- class ScalarSumTask extends Task6 {
1036
- static type = "ScalarSumTask";
1037
- static category = "Math";
1038
- static title = "Sum";
1039
- static description = "Returns the sum of an array of numbers";
1040
- static inputSchema() {
1041
- return inputSchema7;
1042
- }
1043
- static outputSchema() {
1044
- return outputSchema7;
1045
- }
1046
- async execute(input, _context) {
1047
- return { result: sumPrecise(input.values) };
1048
- }
1049
- }
1050
- Workflow8.prototype.scalarSum = CreateWorkflow8(ScalarSumTask);
1051
-
1052
- // src/task/vector/VectorDivideTask.ts
1053
- import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
1054
- import {
1055
- createTypedArrayFrom,
1056
- TypedArraySchema
1057
- } from "@workglow/util";
1058
- var inputSchema8 = {
1059
- type: "object",
1060
- properties: {
1061
- vectors: {
1062
- type: "array",
1063
- items: TypedArraySchema({
1064
- title: "Vector",
1065
- description: "Vector (first is numerator, rest are denominators)"
1066
- }),
1067
- title: "Vectors",
1068
- description: "Array of vectors: vectors[0] / vectors[1] / vectors[2] / ..."
1069
- }
1070
- },
1071
- required: ["vectors"],
1072
- additionalProperties: false
1073
- };
1074
- var outputSchema8 = {
1075
- type: "object",
1076
- properties: {
1077
- result: TypedArraySchema({
423
+ result: TypedArraySchema3({
1078
424
  title: "Result",
1079
- description: "Component-wise quotient"
425
+ description: "Difference of vectors"
1080
426
  })
1081
427
  },
1082
428
  required: ["result"],
1083
429
  additionalProperties: false
1084
430
  };
1085
431
 
1086
- class VectorDivideTask extends Task7 {
1087
- static type = "VectorDivideTask";
432
+ class VectorSubtractTask extends Task8 {
433
+ static type = "VectorSubtractTask";
1088
434
  static category = "Vector";
1089
- static title = "Divide";
1090
- static description = "Returns component-wise quotient: vectors[0] / vectors[1] / vectors[2] / ...";
435
+ static title = "Subtract";
436
+ static description = "Returns component-wise difference: vectors[0] - vectors[1] - vectors[2] - ...";
1091
437
  static inputSchema() {
1092
438
  return inputSchema8;
1093
439
  }
@@ -1108,32 +454,32 @@ class VectorDivideTask extends Task7 {
1108
454
  const values = Array.from({ length: len }, (_, i) => {
1109
455
  let acc = Number(vectors[0][i]);
1110
456
  for (let j = 1;j < vectors.length; j++) {
1111
- acc /= Number(vectors[j][i]);
457
+ acc -= Number(vectors[j][i]);
1112
458
  }
1113
459
  return acc;
1114
460
  });
1115
- return { result: createTypedArrayFrom(vectors, values) };
461
+ return { result: createTypedArrayFrom3(vectors, values) };
1116
462
  }
1117
463
  }
1118
- Workflow9.prototype.vectorDivide = CreateWorkflow9(VectorDivideTask);
464
+ Workflow8.prototype.vectorSubtract = CreateWorkflow8(VectorSubtractTask);
1119
465
 
1120
- // src/task/vector/VectorMultiplyTask.ts
1121
- import { CreateWorkflow as CreateWorkflow10, Task as Task8, Workflow as Workflow10 } from "@workglow/task-graph";
466
+ // src/task/vector/VectorSumTask.ts
467
+ import { CreateWorkflow as CreateWorkflow9, Task as Task9, Workflow as Workflow9 } from "@workglow/task-graph";
1122
468
  import {
1123
- createTypedArrayFrom as createTypedArrayFrom2,
1124
- TypedArraySchema as TypedArraySchema2
469
+ createTypedArrayFrom as createTypedArrayFrom4,
470
+ TypedArraySchema as TypedArraySchema4
1125
471
  } from "@workglow/util";
1126
472
  var inputSchema9 = {
1127
473
  type: "object",
1128
474
  properties: {
1129
475
  vectors: {
1130
476
  type: "array",
1131
- items: TypedArraySchema2({
477
+ items: TypedArraySchema4({
1132
478
  title: "Vector",
1133
- description: "Vector for component-wise product"
479
+ description: "Vector to sum"
1134
480
  }),
1135
481
  title: "Vectors",
1136
- description: "Array of vectors to multiply component-wise"
482
+ description: "Array of vectors to sum component-wise"
1137
483
  }
1138
484
  },
1139
485
  required: ["vectors"],
@@ -1142,20 +488,20 @@ var inputSchema9 = {
1142
488
  var outputSchema9 = {
1143
489
  type: "object",
1144
490
  properties: {
1145
- result: TypedArraySchema2({
491
+ result: TypedArraySchema4({
1146
492
  title: "Result",
1147
- description: "Component-wise product (Hadamard product)"
493
+ description: "Sum of vectors"
1148
494
  })
1149
495
  },
1150
496
  required: ["result"],
1151
497
  additionalProperties: false
1152
498
  };
1153
499
 
1154
- class VectorMultiplyTask extends Task8 {
1155
- static type = "VectorMultiplyTask";
500
+ class VectorSumTask extends Task9 {
501
+ static type = "VectorSumTask";
1156
502
  static category = "Vector";
1157
- static title = "Multiply";
1158
- static description = "Returns the component-wise product (Hadamard product) of all vectors";
503
+ static title = "Sum";
504
+ static description = "Returns the component-wise sum of an array of vectors";
1159
505
  static inputSchema() {
1160
506
  return inputSchema9;
1161
507
  }
@@ -1173,152 +519,22 @@ class VectorMultiplyTask extends Task8 {
1173
519
  throw new Error("All vectors must have the same length");
1174
520
  }
1175
521
  }
1176
- const values = Array.from({ length: len }, (_, i) => vectors.reduce((acc, v) => acc * Number(v[i]), 1));
1177
- return { result: createTypedArrayFrom2(vectors, values) };
522
+ const values = Array.from({ length: len }, (_, i) => sumPrecise(vectors.map((v) => Number(v[i]))));
523
+ return { result: createTypedArrayFrom4(vectors, values) };
1178
524
  }
1179
525
  }
1180
- Workflow10.prototype.vectorMultiply = CreateWorkflow10(VectorMultiplyTask);
526
+ Workflow9.prototype.vectorSum = CreateWorkflow9(VectorSumTask);
1181
527
 
1182
- // src/task/vector/VectorSubtractTask.ts
1183
- import { CreateWorkflow as CreateWorkflow11, Task as Task9, Workflow as Workflow11 } from "@workglow/task-graph";
528
+ // src/task/adaptive.ts
529
+ Workflow10.prototype.add = CreateAdaptiveWorkflow(ScalarAddTask, VectorSumTask);
530
+ Workflow10.prototype.subtract = CreateAdaptiveWorkflow(ScalarSubtractTask, VectorSubtractTask);
531
+ Workflow10.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, VectorMultiplyTask);
532
+ Workflow10.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
533
+ Workflow10.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
534
+
535
+ // src/task/ArrayTask.ts
1184
536
  import {
1185
- createTypedArrayFrom as createTypedArrayFrom3,
1186
- TypedArraySchema as TypedArraySchema3
1187
- } from "@workglow/util";
1188
- var inputSchema10 = {
1189
- type: "object",
1190
- properties: {
1191
- vectors: {
1192
- type: "array",
1193
- items: TypedArraySchema3({
1194
- title: "Vector",
1195
- description: "Vector (first is minuend, rest are subtrahends)"
1196
- }),
1197
- title: "Vectors",
1198
- description: "Array of vectors: vectors[0] - vectors[1] - vectors[2] - ..."
1199
- }
1200
- },
1201
- required: ["vectors"],
1202
- additionalProperties: false
1203
- };
1204
- var outputSchema10 = {
1205
- type: "object",
1206
- properties: {
1207
- result: TypedArraySchema3({
1208
- title: "Result",
1209
- description: "Difference of vectors"
1210
- })
1211
- },
1212
- required: ["result"],
1213
- additionalProperties: false
1214
- };
1215
-
1216
- class VectorSubtractTask extends Task9 {
1217
- static type = "VectorSubtractTask";
1218
- static category = "Vector";
1219
- static title = "Subtract";
1220
- static description = "Returns component-wise difference: vectors[0] - vectors[1] - vectors[2] - ...";
1221
- static inputSchema() {
1222
- return inputSchema10;
1223
- }
1224
- static outputSchema() {
1225
- return outputSchema10;
1226
- }
1227
- async execute(input, _context) {
1228
- const { vectors } = input;
1229
- if (vectors.length < 2) {
1230
- throw new Error("At least two vectors are required");
1231
- }
1232
- const len = vectors[0].length;
1233
- for (let i = 1;i < vectors.length; i++) {
1234
- if (vectors[i].length !== len) {
1235
- throw new Error("All vectors must have the same length");
1236
- }
1237
- }
1238
- const values = Array.from({ length: len }, (_, i) => {
1239
- let acc = Number(vectors[0][i]);
1240
- for (let j = 1;j < vectors.length; j++) {
1241
- acc -= Number(vectors[j][i]);
1242
- }
1243
- return acc;
1244
- });
1245
- return { result: createTypedArrayFrom3(vectors, values) };
1246
- }
1247
- }
1248
- Workflow11.prototype.vectorSubtract = CreateWorkflow11(VectorSubtractTask);
1249
-
1250
- // src/task/vector/VectorSumTask.ts
1251
- import { CreateWorkflow as CreateWorkflow12, Task as Task10, Workflow as Workflow12 } from "@workglow/task-graph";
1252
- import {
1253
- createTypedArrayFrom as createTypedArrayFrom4,
1254
- TypedArraySchema as TypedArraySchema4
1255
- } from "@workglow/util";
1256
- var inputSchema11 = {
1257
- type: "object",
1258
- properties: {
1259
- vectors: {
1260
- type: "array",
1261
- items: TypedArraySchema4({
1262
- title: "Vector",
1263
- description: "Vector to sum"
1264
- }),
1265
- title: "Vectors",
1266
- description: "Array of vectors to sum component-wise"
1267
- }
1268
- },
1269
- required: ["vectors"],
1270
- additionalProperties: false
1271
- };
1272
- var outputSchema11 = {
1273
- type: "object",
1274
- properties: {
1275
- result: TypedArraySchema4({
1276
- title: "Result",
1277
- description: "Sum of vectors"
1278
- })
1279
- },
1280
- required: ["result"],
1281
- additionalProperties: false
1282
- };
1283
-
1284
- class VectorSumTask extends Task10 {
1285
- static type = "VectorSumTask";
1286
- static category = "Vector";
1287
- static title = "Sum";
1288
- static description = "Returns the component-wise sum of an array of vectors";
1289
- static inputSchema() {
1290
- return inputSchema11;
1291
- }
1292
- static outputSchema() {
1293
- return outputSchema11;
1294
- }
1295
- async execute(input, _context) {
1296
- const { vectors } = input;
1297
- if (vectors.length === 0) {
1298
- throw new Error("At least one vector is required");
1299
- }
1300
- const len = vectors[0].length;
1301
- for (let i = 1;i < vectors.length; i++) {
1302
- if (vectors[i].length !== len) {
1303
- throw new Error("All vectors must have the same length");
1304
- }
1305
- }
1306
- const values = Array.from({ length: len }, (_, i) => sumPrecise(vectors.map((v) => Number(v[i]))));
1307
- return { result: createTypedArrayFrom4(vectors, values) };
1308
- }
1309
- }
1310
- Workflow12.prototype.vectorSum = CreateWorkflow12(VectorSumTask);
1311
-
1312
- // src/task/adaptive.ts
1313
- Workflow13.prototype.add = CreateAdaptiveWorkflow(ScalarAddTask, VectorSumTask);
1314
- Workflow13.prototype.subtract = CreateAdaptiveWorkflow(ScalarSubtractTask, VectorSubtractTask);
1315
- Workflow13.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, VectorMultiplyTask);
1316
- Workflow13.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
1317
- Workflow13.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
1318
-
1319
- // src/task/ArrayTask.ts
1320
- import {
1321
- uuid4
537
+ uuid4
1322
538
  } from "@workglow/util";
1323
539
  import {
1324
540
  GraphAsTask,
@@ -1350,12 +566,12 @@ class ArrayTask extends GraphAsTask {
1350
566
  regenerateGraph() {
1351
567
  const arrayInputs = new Map;
1352
568
  let hasArrayInputs = false;
1353
- const inputSchema12 = this.inputSchema();
1354
- if (typeof inputSchema12 !== "boolean") {
1355
- const keys = Object.keys(inputSchema12.properties || {});
569
+ const inputSchema10 = this.inputSchema();
570
+ if (typeof inputSchema10 !== "boolean") {
571
+ const keys = Object.keys(inputSchema10.properties || {});
1356
572
  for (const inputId of keys) {
1357
573
  const inputValue = this.runInputData[inputId];
1358
- const inputDef = inputSchema12.properties?.[inputId];
574
+ const inputDef = inputSchema10.properties?.[inputId];
1359
575
  if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
1360
576
  arrayInputs.set(inputId, inputValue);
1361
577
  hasArrayInputs = true;
@@ -1444,7 +660,7 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
1444
660
  }
1445
661
  }
1446
662
  // src/task/DebugLogTask.ts
1447
- import { CreateWorkflow as CreateWorkflow13, Task as Task11, TaskConfigSchema, Workflow as Workflow14 } from "@workglow/task-graph";
663
+ import { CreateWorkflow as CreateWorkflow10, Task as Task10, TaskConfigSchema, Workflow as Workflow11 } from "@workglow/task-graph";
1448
664
  var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
1449
665
  var DEFAULT_LOG_LEVEL = "log";
1450
666
  var debugLogTaskConfigSchema = {
@@ -1461,18 +677,18 @@ var debugLogTaskConfigSchema = {
1461
677
  },
1462
678
  additionalProperties: false
1463
679
  };
1464
- var inputSchema12 = {
680
+ var inputSchema10 = {
1465
681
  type: "object",
1466
682
  properties: {},
1467
683
  additionalProperties: true
1468
684
  };
1469
- var outputSchema12 = {
685
+ var outputSchema10 = {
1470
686
  type: "object",
1471
687
  properties: {},
1472
688
  additionalProperties: true
1473
689
  };
1474
690
 
1475
- class DebugLogTask extends Task11 {
691
+ class DebugLogTask extends Task10 {
1476
692
  static type = "DebugLogTask";
1477
693
  static category = "Utility";
1478
694
  static title = "Debug Log";
@@ -1484,10 +700,10 @@ class DebugLogTask extends Task11 {
1484
700
  return debugLogTaskConfigSchema;
1485
701
  }
1486
702
  static inputSchema() {
1487
- return inputSchema12;
703
+ return inputSchema10;
1488
704
  }
1489
705
  static outputSchema() {
1490
- return outputSchema12;
706
+ return outputSchema10;
1491
707
  }
1492
708
  async executeReactive(input, output) {
1493
709
  const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
@@ -1505,14 +721,14 @@ var debugLog = (input, config = {}) => {
1505
721
  const task = new DebugLogTask({}, config);
1506
722
  return task.run(input);
1507
723
  };
1508
- Workflow14.prototype.debugLog = CreateWorkflow13(DebugLogTask);
724
+ Workflow11.prototype.debugLog = CreateWorkflow10(DebugLogTask);
1509
725
  // src/task/DelayTask.ts
1510
726
  import {
1511
- CreateWorkflow as CreateWorkflow14,
1512
- Task as Task12,
1513
- TaskAbortedError as TaskAbortedError3,
727
+ CreateWorkflow as CreateWorkflow11,
728
+ Task as Task11,
729
+ TaskAbortedError,
1514
730
  TaskConfigSchema as TaskConfigSchema2,
1515
- Workflow as Workflow15
731
+ Workflow as Workflow12
1516
732
  } from "@workglow/task-graph";
1517
733
  import { sleep } from "@workglow/util";
1518
734
  var delayTaskConfigSchema = {
@@ -1527,18 +743,18 @@ var delayTaskConfigSchema = {
1527
743
  },
1528
744
  additionalProperties: false
1529
745
  };
1530
- var inputSchema13 = {
746
+ var inputSchema11 = {
1531
747
  type: "object",
1532
748
  properties: {},
1533
749
  additionalProperties: true
1534
750
  };
1535
- var outputSchema13 = {
751
+ var outputSchema11 = {
1536
752
  type: "object",
1537
753
  properties: {},
1538
754
  additionalProperties: true
1539
755
  };
1540
756
 
1541
- class DelayTask extends Task12 {
757
+ class DelayTask extends Task11 {
1542
758
  static type = "DelayTask";
1543
759
  static category = "Utility";
1544
760
  static title = "Delay";
@@ -1550,10 +766,10 @@ class DelayTask extends Task12 {
1550
766
  return delayTaskConfigSchema;
1551
767
  }
1552
768
  static inputSchema() {
1553
- return inputSchema13;
769
+ return inputSchema11;
1554
770
  }
1555
771
  static outputSchema() {
1556
- return outputSchema13;
772
+ return outputSchema11;
1557
773
  }
1558
774
  async execute(input, executeContext) {
1559
775
  const delay = this.config.delay ?? 1;
@@ -1562,7 +778,7 @@ class DelayTask extends Task12 {
1562
778
  const chunkSize = delay / iterations;
1563
779
  for (let i = 0;i < iterations; i++) {
1564
780
  if (executeContext.signal.aborted) {
1565
- throw new TaskAbortedError3("Task aborted");
781
+ throw new TaskAbortedError("Task aborted");
1566
782
  }
1567
783
  await sleep(chunkSize);
1568
784
  await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
@@ -1577,51 +793,379 @@ var delay = (input, config = { delay: 1 }) => {
1577
793
  const task = new DelayTask({}, config);
1578
794
  return task.run(input);
1579
795
  };
1580
- Workflow15.prototype.delay = CreateWorkflow14(DelayTask);
1581
- // src/task/InputTask.ts
1582
- import { CreateWorkflow as CreateWorkflow15, Task as Task13, Workflow as Workflow16 } from "@workglow/task-graph";
1583
-
1584
- class InputTask extends Task13 {
1585
- static type = "InputTask";
1586
- static category = "Flow Control";
1587
- static title = "Input";
1588
- static description = "Starts the workflow";
1589
- static hasDynamicSchemas = true;
1590
- static cacheable = false;
1591
- static inputSchema() {
1592
- return {
796
+ Workflow12.prototype.delay = CreateWorkflow11(DelayTask);
797
+ // src/task/FetchUrlTask.ts
798
+ import {
799
+ AbortSignalJobError,
800
+ Job,
801
+ PermanentJobError,
802
+ RetryableJobError
803
+ } from "@workglow/job-queue";
804
+ import {
805
+ CreateWorkflow as CreateWorkflow12,
806
+ JobQueueTask,
807
+ TaskConfigurationError,
808
+ TaskInvalidInputError,
809
+ Workflow as Workflow13
810
+ } from "@workglow/task-graph";
811
+ var inputSchema12 = {
812
+ type: "object",
813
+ properties: {
814
+ url: {
815
+ type: "string",
816
+ title: "URL",
817
+ description: "The URL to fetch from",
818
+ format: "uri"
819
+ },
820
+ method: {
821
+ enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
822
+ title: "Method",
823
+ description: "The HTTP method to use",
824
+ default: "GET"
825
+ },
826
+ headers: {
1593
827
  type: "object",
1594
- properties: {},
1595
- additionalProperties: true
1596
- };
1597
- }
1598
- static outputSchema() {
1599
- return {
828
+ additionalProperties: {
829
+ type: "string"
830
+ },
831
+ title: "Headers",
832
+ description: "The headers to send with the request"
833
+ },
834
+ body: {
835
+ type: "string",
836
+ title: "Body",
837
+ description: "The body of the request"
838
+ },
839
+ response_type: {
840
+ anyOf: [{ type: "null" }, { enum: ["json", "text", "blob", "arraybuffer"] }],
841
+ title: "Response Type",
842
+ description: "The forced type of response to return. If null, the response type is inferred from the Content-Type header.",
843
+ default: null
844
+ },
845
+ timeout: {
846
+ type: "number",
847
+ title: "Timeout",
848
+ description: "Request timeout in milliseconds"
849
+ },
850
+ credential_key: {
851
+ type: "string",
852
+ format: "credential",
853
+ title: "Credential Key",
854
+ description: "Key to look up in the credential store. The resolved value is sent as a Bearer token in the Authorization header.",
855
+ "x-ui-hidden": true
856
+ },
857
+ queue: {
858
+ oneOf: [{ type: "boolean" }, { type: "string" }],
859
+ description: "Queue handling: false=run inline, true=use default, string=explicit queue name",
860
+ default: true,
861
+ "x-ui-hidden": true
862
+ }
863
+ },
864
+ required: ["url"],
865
+ additionalProperties: false
866
+ };
867
+ var outputSchema12 = {
868
+ type: "object",
869
+ properties: {
870
+ json: {
871
+ title: "JSON",
872
+ description: "The JSON response"
873
+ },
874
+ text: {
875
+ type: "string",
876
+ title: "Text",
877
+ description: "The text response"
878
+ },
879
+ blob: {
880
+ title: "Blob",
881
+ description: "The blob response"
882
+ },
883
+ arraybuffer: {
884
+ title: "ArrayBuffer",
885
+ description: "The arraybuffer response"
886
+ },
887
+ metadata: {
1600
888
  type: "object",
1601
- properties: {},
1602
- additionalProperties: true
1603
- };
1604
- }
1605
- inputSchema() {
1606
- return this.config?.inputSchema ?? this.constructor.inputSchema();
1607
- }
1608
- outputSchema() {
1609
- return this.config?.outputSchema ?? this.constructor.outputSchema();
1610
- }
1611
- async execute(input) {
1612
- return input;
889
+ properties: {
890
+ contentType: { type: "string" },
891
+ headers: { type: "object", additionalProperties: { type: "string" } }
892
+ },
893
+ additionalProperties: false,
894
+ title: "Response Metadata",
895
+ description: "HTTP response metadata including content type and headers"
896
+ }
897
+ },
898
+ additionalProperties: false
899
+ };
900
+ async function fetchWithProgress(url, options = {}, onProgress) {
901
+ if (!options.signal) {
902
+ throw new TaskConfigurationError("An AbortSignal must be provided.");
1613
903
  }
1614
- async executeReactive(input) {
1615
- return input;
904
+ const response = await globalThis.fetch(url, options);
905
+ if (!response.body) {
906
+ throw new Error("ReadableStream not supported in this environment.");
1616
907
  }
1617
- async* executeStream(input, context) {
1618
- if (context.inputStreams) {
1619
- for (const [, stream] of context.inputStreams) {
1620
- const reader = stream.getReader();
1621
- try {
1622
- while (true) {
1623
- const { done, value } = await reader.read();
1624
- if (done)
908
+ const contentLength = response.headers.get("Content-Length");
909
+ const totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
910
+ let receivedBytes = 0;
911
+ const reader = response.body.getReader();
912
+ const stream = new ReadableStream({
913
+ start(controller) {
914
+ async function push() {
915
+ try {
916
+ while (true) {
917
+ if (options.signal?.aborted) {
918
+ controller.error(new AbortSignalJobError("Fetch aborted"));
919
+ reader.cancel();
920
+ return;
921
+ }
922
+ const { done, value } = await reader.read();
923
+ if (done) {
924
+ controller.close();
925
+ break;
926
+ }
927
+ controller.enqueue(value);
928
+ receivedBytes += value.length;
929
+ if (onProgress && totalBytes) {
930
+ await onProgress(receivedBytes / totalBytes * 100);
931
+ }
932
+ }
933
+ } catch (error) {
934
+ controller.error(error);
935
+ }
936
+ }
937
+ push();
938
+ },
939
+ cancel() {
940
+ reader.cancel();
941
+ }
942
+ });
943
+ return new Response(stream, {
944
+ headers: response.headers,
945
+ status: response.status,
946
+ statusText: response.statusText
947
+ });
948
+ }
949
+
950
+ class FetchUrlJob extends Job {
951
+ constructor(config = { input: {} }) {
952
+ super(config);
953
+ }
954
+ static type = "FetchUrlJob";
955
+ async execute(input, context) {
956
+ const response = await fetchWithProgress(input.url, {
957
+ method: input.method,
958
+ headers: input.headers,
959
+ body: input.body,
960
+ signal: context.signal
961
+ }, async (progress) => await context.updateProgress(progress));
962
+ if (response.ok) {
963
+ const contentType = response.headers.get("content-type") ?? "";
964
+ const responseHeaders = {};
965
+ response.headers.forEach((value, key) => {
966
+ responseHeaders[key] = value;
967
+ });
968
+ const metadata = {
969
+ contentType,
970
+ headers: responseHeaders
971
+ };
972
+ let responseType = input.response_type;
973
+ if (!responseType) {
974
+ if (contentType.includes("application/json")) {
975
+ responseType = "json";
976
+ } else if (contentType.includes("text/")) {
977
+ responseType = "text";
978
+ } else if (contentType.includes("application/octet-stream")) {
979
+ responseType = "arraybuffer";
980
+ } else if (contentType.includes("application/pdf") || contentType.includes("image/") || contentType.includes("application/zip")) {
981
+ responseType = "blob";
982
+ } else {
983
+ responseType = "json";
984
+ }
985
+ input.response_type = responseType;
986
+ }
987
+ if (responseType === "json") {
988
+ return { json: await response.json(), metadata };
989
+ } else if (responseType === "text") {
990
+ return { text: await response.text(), metadata };
991
+ } else if (responseType === "blob") {
992
+ return { blob: await response.blob(), metadata };
993
+ } else if (responseType === "arraybuffer") {
994
+ return { arraybuffer: await response.arrayBuffer(), metadata };
995
+ }
996
+ throw new TaskInvalidInputError(`Invalid response type: ${responseType}`);
997
+ } else {
998
+ if (response.status === 429 || response.status === 503 || response.headers.get("Retry-After")) {
999
+ let retryDate;
1000
+ const retryAfterStr = response.headers.get("Retry-After");
1001
+ if (retryAfterStr) {
1002
+ const parsedDate = new Date(retryAfterStr);
1003
+ if (!isNaN(parsedDate.getTime()) && parsedDate > new Date) {
1004
+ retryDate = parsedDate;
1005
+ } else {
1006
+ const retryAfterSeconds = parseInt(retryAfterStr) * 1000;
1007
+ if (!isNaN(retryAfterSeconds)) {
1008
+ retryDate = new Date(Date.now() + retryAfterSeconds);
1009
+ }
1010
+ }
1011
+ }
1012
+ throw new RetryableJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`, retryDate);
1013
+ } else {
1014
+ throw new PermanentJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`);
1015
+ }
1016
+ }
1017
+ }
1018
+ }
1019
+
1020
+ class FetchUrlTask extends JobQueueTask {
1021
+ static type = "FetchUrlTask";
1022
+ static category = "Input";
1023
+ static title = "Fetch";
1024
+ static description = "Fetches data from a URL with progress tracking and automatic retry handling";
1025
+ static hasDynamicSchemas = true;
1026
+ static inputSchema() {
1027
+ return inputSchema12;
1028
+ }
1029
+ static outputSchema() {
1030
+ return outputSchema12;
1031
+ }
1032
+ outputSchema() {
1033
+ const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
1034
+ if (responseType === null || responseType === undefined) {
1035
+ return this.constructor.outputSchema();
1036
+ }
1037
+ const staticSchema = this.constructor.outputSchema();
1038
+ if (typeof staticSchema === "boolean") {
1039
+ return staticSchema;
1040
+ }
1041
+ if (!staticSchema.properties) {
1042
+ return staticSchema;
1043
+ }
1044
+ const properties = {};
1045
+ if (responseType === "json" && staticSchema.properties.json) {
1046
+ properties.json = staticSchema.properties.json;
1047
+ } else if (responseType === "text" && staticSchema.properties.text) {
1048
+ properties.text = staticSchema.properties.text;
1049
+ } else if (responseType === "blob" && staticSchema.properties.blob) {
1050
+ properties.blob = staticSchema.properties.blob;
1051
+ } else if (responseType === "arraybuffer" && staticSchema.properties.arraybuffer) {
1052
+ properties.arraybuffer = staticSchema.properties.arraybuffer;
1053
+ }
1054
+ if (staticSchema.properties.metadata) {
1055
+ properties.metadata = staticSchema.properties.metadata;
1056
+ }
1057
+ if (Object.keys(properties).length === 0) {
1058
+ return staticSchema;
1059
+ }
1060
+ return {
1061
+ type: "object",
1062
+ properties,
1063
+ additionalProperties: false
1064
+ };
1065
+ }
1066
+ constructor(input = {}, config = {}) {
1067
+ config.queue = input?.queue ?? config.queue;
1068
+ if (config.queue === undefined) {
1069
+ config.queue = false;
1070
+ }
1071
+ super(input, config);
1072
+ this.jobClass = FetchUrlJob;
1073
+ }
1074
+ async execute(input, executeContext) {
1075
+ const credential = input.credential_key;
1076
+ if (credential) {
1077
+ input = {
1078
+ ...input,
1079
+ headers: { ...input.headers, Authorization: `Bearer ${credential}` }
1080
+ };
1081
+ }
1082
+ return super.execute(input, executeContext);
1083
+ }
1084
+ setInput(input) {
1085
+ if (!("response_type" in input)) {
1086
+ super.setInput(input);
1087
+ return;
1088
+ }
1089
+ const getCurrentResponseType = () => {
1090
+ return this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
1091
+ };
1092
+ const previousResponseType = getCurrentResponseType();
1093
+ super.setInput(input);
1094
+ const newResponseType = getCurrentResponseType();
1095
+ if (previousResponseType !== newResponseType) {
1096
+ this.emitSchemaChange();
1097
+ }
1098
+ }
1099
+ async getDefaultQueueName(input) {
1100
+ if (!input.url) {
1101
+ return `fetch:${this.type}`;
1102
+ }
1103
+ try {
1104
+ const hostname = new URL(input.url).hostname.toLowerCase();
1105
+ const parts = hostname.split(".").filter(Boolean);
1106
+ if (parts.length === 0) {
1107
+ return `fetch:${this.type}`;
1108
+ }
1109
+ const domain = parts.length <= 2 ? parts.join(".") : parts.slice(-2).join(".");
1110
+ return `fetch:${domain}`;
1111
+ } catch {
1112
+ return `fetch:${this.type}`;
1113
+ }
1114
+ }
1115
+ }
1116
+ var fetchUrl = async (input, config = {}) => {
1117
+ const result = await new FetchUrlTask({}, config).run(input);
1118
+ return result;
1119
+ };
1120
+ Workflow13.prototype.fetch = CreateWorkflow12(FetchUrlTask);
1121
+ // src/task/InputTask.ts
1122
+ import {
1123
+ CreateWorkflow as CreateWorkflow13,
1124
+ Task as Task12,
1125
+ Workflow as Workflow14
1126
+ } from "@workglow/task-graph";
1127
+
1128
+ class InputTask extends Task12 {
1129
+ static type = "InputTask";
1130
+ static category = "Flow Control";
1131
+ static title = "Input";
1132
+ static description = "Starts the workflow";
1133
+ static hasDynamicSchemas = true;
1134
+ static cacheable = false;
1135
+ static inputSchema() {
1136
+ return {
1137
+ type: "object",
1138
+ properties: {},
1139
+ additionalProperties: true
1140
+ };
1141
+ }
1142
+ static outputSchema() {
1143
+ return {
1144
+ type: "object",
1145
+ properties: {},
1146
+ additionalProperties: true
1147
+ };
1148
+ }
1149
+ inputSchema() {
1150
+ return this.config?.inputSchema ?? this.constructor.inputSchema();
1151
+ }
1152
+ outputSchema() {
1153
+ return this.config?.outputSchema ?? this.constructor.outputSchema();
1154
+ }
1155
+ async execute(input) {
1156
+ return input;
1157
+ }
1158
+ async executeReactive(input) {
1159
+ return input;
1160
+ }
1161
+ async* executeStream(input, context) {
1162
+ if (context.inputStreams) {
1163
+ for (const [, stream] of context.inputStreams) {
1164
+ const reader = stream.getReader();
1165
+ try {
1166
+ while (true) {
1167
+ const { done, value } = await reader.read();
1168
+ if (done)
1625
1169
  break;
1626
1170
  if (value.type === "finish")
1627
1171
  continue;
@@ -1635,9 +1179,9 @@ class InputTask extends Task13 {
1635
1179
  yield { type: "finish", data: input };
1636
1180
  }
1637
1181
  }
1638
- Workflow16.prototype.input = CreateWorkflow15(InputTask);
1182
+ Workflow14.prototype.input = CreateWorkflow13(InputTask);
1639
1183
  // src/task/JavaScriptTask.ts
1640
- import { CreateWorkflow as CreateWorkflow16, Task as Task14, TaskConfigSchema as TaskConfigSchema3, Workflow as Workflow17 } from "@workglow/task-graph";
1184
+ import { CreateWorkflow as CreateWorkflow14, Task as Task13, TaskConfigSchema as TaskConfigSchema3, Workflow as Workflow15 } from "@workglow/task-graph";
1641
1185
 
1642
1186
  // src/util/acorn.js
1643
1187
  var options;
@@ -6114,7 +5658,7 @@ var configSchema = {
6114
5658
  },
6115
5659
  additionalProperties: false
6116
5660
  };
6117
- var inputSchema14 = {
5661
+ var inputSchema13 = {
6118
5662
  type: "object",
6119
5663
  properties: {
6120
5664
  javascript_code: {
@@ -6128,7 +5672,7 @@ var inputSchema14 = {
6128
5672
  required: ["javascript_code"],
6129
5673
  additionalProperties: true
6130
5674
  };
6131
- var outputSchema14 = {
5675
+ var outputSchema13 = {
6132
5676
  type: "object",
6133
5677
  properties: {
6134
5678
  output: {
@@ -6140,7 +5684,7 @@ var outputSchema14 = {
6140
5684
  additionalProperties: false
6141
5685
  };
6142
5686
 
6143
- class JavaScriptTask extends Task14 {
5687
+ class JavaScriptTask extends Task13 {
6144
5688
  static type = "JavaScriptTask";
6145
5689
  static category = "Utility";
6146
5690
  static title = "JavaScript Interpreter";
@@ -6150,10 +5694,10 @@ class JavaScriptTask extends Task14 {
6150
5694
  return configSchema;
6151
5695
  }
6152
5696
  static inputSchema() {
6153
- return inputSchema14;
5697
+ return inputSchema13;
6154
5698
  }
6155
5699
  static outputSchema() {
6156
- return outputSchema14;
5700
+ return outputSchema13;
6157
5701
  }
6158
5702
  constructor(input2 = {}, config = {}) {
6159
5703
  super(input2, config);
@@ -6169,7 +5713,7 @@ class JavaScriptTask extends Task14 {
6169
5713
  additionalProperties: true
6170
5714
  };
6171
5715
  }
6172
- return inputSchema14;
5716
+ return inputSchema13;
6173
5717
  }
6174
5718
  async executeReactive(input2, output) {
6175
5719
  if (this.config.javascript_code || input2.javascript_code) {
@@ -6188,18 +5732,18 @@ class JavaScriptTask extends Task14 {
6188
5732
  var javaScript = (input2, config = {}) => {
6189
5733
  return new JavaScriptTask({}, config).run(input2);
6190
5734
  };
6191
- Workflow17.prototype.javaScript = CreateWorkflow16(JavaScriptTask);
5735
+ Workflow15.prototype.javaScript = CreateWorkflow14(JavaScriptTask);
6192
5736
  // src/task/JsonTask.ts
6193
5737
  import {
6194
5738
  createGraphFromDependencyJSON,
6195
5739
  createGraphFromGraphJSON,
6196
- CreateWorkflow as CreateWorkflow17,
5740
+ CreateWorkflow as CreateWorkflow15,
6197
5741
  Dataflow,
6198
5742
  GraphAsTask as GraphAsTask2,
6199
5743
  TaskConfigurationError as TaskConfigurationError2,
6200
- Workflow as Workflow18
5744
+ Workflow as Workflow16
6201
5745
  } from "@workglow/task-graph";
6202
- var inputSchema15 = {
5746
+ var inputSchema14 = {
6203
5747
  type: "object",
6204
5748
  properties: {
6205
5749
  json: {
@@ -6210,7 +5754,7 @@ var inputSchema15 = {
6210
5754
  },
6211
5755
  additionalProperties: false
6212
5756
  };
6213
- var outputSchema15 = {
5757
+ var outputSchema14 = {
6214
5758
  type: "object",
6215
5759
  properties: {
6216
5760
  output: {
@@ -6227,10 +5771,10 @@ class JsonTask extends GraphAsTask2 {
6227
5771
  static title = "JSON Task";
6228
5772
  static description = "A task that creates and manages task graphs from JSON configurations";
6229
5773
  static inputSchema() {
6230
- return inputSchema15;
5774
+ return inputSchema14;
6231
5775
  }
6232
5776
  static outputSchema() {
6233
- return outputSchema15;
5777
+ return outputSchema14;
6234
5778
  }
6235
5779
  regenerateGraph() {
6236
5780
  if (!this.runInputData.json)
@@ -6253,7 +5797,7 @@ class JsonTask extends GraphAsTask2 {
6253
5797
  if (!sourceTask) {
6254
5798
  throw new TaskConfigurationError2(`Dependency id ${dep.id} not found`);
6255
5799
  }
6256
- const df = new Dataflow(sourceTask.config.id, dep.output, item.id, input2);
5800
+ const df = new Dataflow(sourceTask.id, dep.output, item.id, input2);
6257
5801
  this.subGraph.addDataflow(df);
6258
5802
  }
6259
5803
  }
@@ -6264,15 +5808,15 @@ class JsonTask extends GraphAsTask2 {
6264
5808
  var json = (input2, config = {}) => {
6265
5809
  return new JsonTask({}, config).run(input2);
6266
5810
  };
6267
- Workflow18.prototype.json = CreateWorkflow17(JsonTask);
5811
+ Workflow16.prototype.json = CreateWorkflow15(JsonTask);
6268
5812
  // src/task/LambdaTask.ts
6269
5813
  import {
6270
- CreateWorkflow as CreateWorkflow18,
5814
+ CreateWorkflow as CreateWorkflow16,
6271
5815
  DATAFLOW_ALL_PORTS,
6272
- Task as Task15,
5816
+ Task as Task14,
6273
5817
  TaskConfigSchema as TaskConfigSchema4,
6274
5818
  TaskConfigurationError as TaskConfigurationError3,
6275
- Workflow as Workflow19
5819
+ Workflow as Workflow17
6276
5820
  } from "@workglow/task-graph";
6277
5821
  var lambdaTaskConfigSchema = {
6278
5822
  type: "object",
@@ -6283,7 +5827,7 @@ var lambdaTaskConfigSchema = {
6283
5827
  },
6284
5828
  additionalProperties: false
6285
5829
  };
6286
- var inputSchema16 = {
5830
+ var inputSchema15 = {
6287
5831
  type: "object",
6288
5832
  properties: {
6289
5833
  [DATAFLOW_ALL_PORTS]: {
@@ -6293,7 +5837,7 @@ var inputSchema16 = {
6293
5837
  },
6294
5838
  additionalProperties: true
6295
5839
  };
6296
- var outputSchema16 = {
5840
+ var outputSchema15 = {
6297
5841
  type: "object",
6298
5842
  properties: {
6299
5843
  [DATAFLOW_ALL_PORTS]: {
@@ -6304,7 +5848,7 @@ var outputSchema16 = {
6304
5848
  additionalProperties: true
6305
5849
  };
6306
5850
 
6307
- class LambdaTask extends Task15 {
5851
+ class LambdaTask extends Task14 {
6308
5852
  static type = "LambdaTask";
6309
5853
  static title = "Lambda Task";
6310
5854
  static description = "A task that wraps a provided function and its input";
@@ -6314,10 +5858,10 @@ class LambdaTask extends Task15 {
6314
5858
  return lambdaTaskConfigSchema;
6315
5859
  }
6316
5860
  static inputSchema() {
6317
- return inputSchema16;
5861
+ return inputSchema15;
6318
5862
  }
6319
5863
  static outputSchema() {
6320
- return outputSchema16;
5864
+ return outputSchema15;
6321
5865
  }
6322
5866
  constructor(input2 = {}, config = {}) {
6323
5867
  if (!config.execute && !config.executeReactive) {
@@ -6355,15 +5899,15 @@ function lambda(input2, config) {
6355
5899
  const task = new LambdaTask(input2, config);
6356
5900
  return task.run();
6357
5901
  }
6358
- Workflow19.prototype.lambda = CreateWorkflow18(LambdaTask);
5902
+ Workflow17.prototype.lambda = CreateWorkflow16(LambdaTask);
6359
5903
  // src/task/MergeTask.ts
6360
- import { CreateWorkflow as CreateWorkflow19, Task as Task16, Workflow as Workflow20 } from "@workglow/task-graph";
6361
- var inputSchema17 = {
5904
+ import { CreateWorkflow as CreateWorkflow17, Task as Task15, Workflow as Workflow18 } from "@workglow/task-graph";
5905
+ var inputSchema16 = {
6362
5906
  type: "object",
6363
5907
  properties: {},
6364
5908
  additionalProperties: true
6365
5909
  };
6366
- var outputSchema17 = {
5910
+ var outputSchema16 = {
6367
5911
  type: "object",
6368
5912
  properties: {
6369
5913
  output: {
@@ -6375,17 +5919,17 @@ var outputSchema17 = {
6375
5919
  additionalProperties: false
6376
5920
  };
6377
5921
 
6378
- class MergeTask extends Task16 {
5922
+ class MergeTask extends Task15 {
6379
5923
  static type = "MergeTask";
6380
5924
  static category = "Utility";
6381
5925
  static title = "Merge";
6382
5926
  static description = "Merges multiple inputs into a single array output";
6383
5927
  static cacheable = true;
6384
5928
  static inputSchema() {
6385
- return inputSchema17;
5929
+ return inputSchema16;
6386
5930
  }
6387
5931
  static outputSchema() {
6388
- return outputSchema17;
5932
+ return outputSchema16;
6389
5933
  }
6390
5934
  async execute(input2, _context) {
6391
5935
  const keys = Object.keys(input2).sort();
@@ -6399,11 +5943,15 @@ var merge = (input2, config = {}) => {
6399
5943
  const task = new MergeTask({}, config);
6400
5944
  return task.run(input2);
6401
5945
  };
6402
- Workflow20.prototype.merge = CreateWorkflow19(MergeTask);
5946
+ Workflow18.prototype.merge = CreateWorkflow17(MergeTask);
6403
5947
  // src/task/OutputTask.ts
6404
- import { CreateWorkflow as CreateWorkflow20, Task as Task17, Workflow as Workflow21 } from "@workglow/task-graph";
5948
+ import {
5949
+ CreateWorkflow as CreateWorkflow18,
5950
+ Task as Task16,
5951
+ Workflow as Workflow19
5952
+ } from "@workglow/task-graph";
6405
5953
 
6406
- class OutputTask extends Task17 {
5954
+ class OutputTask extends Task16 {
6407
5955
  static type = "OutputTask";
6408
5956
  static category = "Flow Control";
6409
5957
  static title = "Output";
@@ -6457,10 +6005,10 @@ class OutputTask extends Task17 {
6457
6005
  yield { type: "finish", data: input2 };
6458
6006
  }
6459
6007
  }
6460
- Workflow21.prototype.output = CreateWorkflow20(OutputTask);
6008
+ Workflow19.prototype.output = CreateWorkflow18(OutputTask);
6461
6009
  // src/task/SplitTask.ts
6462
- import { CreateWorkflow as CreateWorkflow21, Task as Task18, Workflow as Workflow22 } from "@workglow/task-graph";
6463
- var inputSchema18 = {
6010
+ import { CreateWorkflow as CreateWorkflow19, Task as Task17, Workflow as Workflow20 } from "@workglow/task-graph";
6011
+ var inputSchema17 = {
6464
6012
  type: "object",
6465
6013
  properties: {
6466
6014
  input: {
@@ -6470,13 +6018,13 @@ var inputSchema18 = {
6470
6018
  },
6471
6019
  additionalProperties: false
6472
6020
  };
6473
- var outputSchema18 = {
6021
+ var outputSchema17 = {
6474
6022
  type: "object",
6475
6023
  properties: {},
6476
6024
  additionalProperties: true
6477
6025
  };
6478
6026
 
6479
- class SplitTask extends Task18 {
6027
+ class SplitTask extends Task17 {
6480
6028
  static type = "SplitTask";
6481
6029
  static category = "Utility";
6482
6030
  static title = "Split";
@@ -6484,13 +6032,13 @@ class SplitTask extends Task18 {
6484
6032
  static hasDynamicSchemas = true;
6485
6033
  static cacheable = false;
6486
6034
  static inputSchema() {
6487
- return inputSchema18;
6035
+ return inputSchema17;
6488
6036
  }
6489
6037
  static outputSchema() {
6490
- return outputSchema18;
6038
+ return outputSchema17;
6491
6039
  }
6492
6040
  outputSchema() {
6493
- return outputSchema18;
6041
+ return outputSchema17;
6494
6042
  }
6495
6043
  async executeReactive(input2) {
6496
6044
  const inputValue = input2.input;
@@ -6509,15 +6057,327 @@ var split = (input2, config = {}) => {
6509
6057
  const task = new SplitTask({}, config);
6510
6058
  return task.run(input2);
6511
6059
  };
6512
- Workflow22.prototype.split = CreateWorkflow21(SplitTask);
6060
+ Workflow20.prototype.split = CreateWorkflow19(SplitTask);
6061
+ // src/task/DateFormatTask.ts
6062
+ import {
6063
+ CreateWorkflow as CreateWorkflow20,
6064
+ Task as Task18,
6065
+ Workflow as Workflow21
6066
+ } from "@workglow/task-graph";
6067
+ var inputSchema18 = {
6068
+ type: "object",
6069
+ properties: {
6070
+ value: {
6071
+ type: "string",
6072
+ title: "Value",
6073
+ description: "Date string, ISO 8601 timestamp, or Unix timestamp in milliseconds"
6074
+ },
6075
+ format: {
6076
+ type: "string",
6077
+ title: "Format",
6078
+ enum: ["iso", "date", "time", "datetime", "unix"],
6079
+ description: "Output format: 'iso', 'date', 'time', 'datetime', 'unix'",
6080
+ default: "iso"
6081
+ },
6082
+ locale: {
6083
+ type: "string",
6084
+ title: "Locale",
6085
+ description: "Locale string (e.g. 'en-US')",
6086
+ default: "en-US"
6087
+ },
6088
+ timeZone: {
6089
+ type: "string",
6090
+ title: "Time Zone",
6091
+ description: "IANA time zone (e.g. 'America/New_York', 'UTC')"
6092
+ }
6093
+ },
6094
+ required: ["value"],
6095
+ additionalProperties: false
6096
+ };
6097
+ var outputSchema18 = {
6098
+ type: "object",
6099
+ properties: {
6100
+ result: {
6101
+ type: "string",
6102
+ title: "Result",
6103
+ description: "Formatted date string"
6104
+ }
6105
+ },
6106
+ required: ["result"],
6107
+ additionalProperties: false
6108
+ };
6109
+
6110
+ class DateFormatTask extends Task18 {
6111
+ static type = "DateFormatTask";
6112
+ static category = "Utility";
6113
+ static title = "Date Format";
6114
+ static description = "Parses and formats a date string";
6115
+ static inputSchema() {
6116
+ return inputSchema18;
6117
+ }
6118
+ static outputSchema() {
6119
+ return outputSchema18;
6120
+ }
6121
+ async executeReactive(input2, _output, _context) {
6122
+ const dateInput = /^\d+$/.test(input2.value) ? Number(input2.value) : input2.value;
6123
+ const date = new Date(dateInput);
6124
+ if (isNaN(date.getTime())) {
6125
+ throw new Error(`Invalid date: ${input2.value}`);
6126
+ }
6127
+ const format = input2.format ?? "iso";
6128
+ const locale = input2.locale;
6129
+ const timeZone = input2.timeZone;
6130
+ let result;
6131
+ switch (format) {
6132
+ case "iso":
6133
+ result = date.toISOString();
6134
+ break;
6135
+ case "date":
6136
+ result = date.toLocaleDateString(locale, timeZone ? { timeZone } : undefined);
6137
+ break;
6138
+ case "time":
6139
+ result = date.toLocaleTimeString(locale, timeZone ? { timeZone } : undefined);
6140
+ break;
6141
+ case "unix":
6142
+ result = String(date.getTime());
6143
+ break;
6144
+ case "datetime":
6145
+ default:
6146
+ result = date.toLocaleString(locale, timeZone ? { timeZone } : undefined);
6147
+ break;
6148
+ }
6149
+ return { result };
6150
+ }
6151
+ }
6152
+ Workflow21.prototype.dateFormat = CreateWorkflow20(DateFormatTask);
6153
+ // src/task/JsonPathTask.ts
6154
+ import {
6155
+ CreateWorkflow as CreateWorkflow21,
6156
+ Task as Task19,
6157
+ Workflow as Workflow22
6158
+ } from "@workglow/task-graph";
6159
+ var inputSchema19 = {
6160
+ type: "object",
6161
+ properties: {
6162
+ value: {
6163
+ title: "Value",
6164
+ description: "Input object or array to query"
6165
+ },
6166
+ path: {
6167
+ type: "string",
6168
+ title: "Path",
6169
+ description: "Dot-notation path to extract (e.g. 'a.b.c', 'items.0.name', 'items.*.name')"
6170
+ }
6171
+ },
6172
+ required: ["value", "path"],
6173
+ additionalProperties: false
6174
+ };
6175
+ var outputSchema19 = {
6176
+ type: "object",
6177
+ properties: {
6178
+ result: {
6179
+ title: "Result",
6180
+ description: "Extracted value(s) from the path"
6181
+ }
6182
+ },
6183
+ required: ["result"],
6184
+ additionalProperties: false
6185
+ };
6186
+ function resolvePath(obj, segments) {
6187
+ if (segments.length === 0)
6188
+ return obj;
6189
+ const [head, ...tail] = segments;
6190
+ if (head === "*") {
6191
+ if (Array.isArray(obj)) {
6192
+ return obj.map((item) => resolvePath(item, tail));
6193
+ }
6194
+ if (obj !== null && typeof obj === "object") {
6195
+ return Object.values(obj).map((v) => resolvePath(v, tail));
6196
+ }
6197
+ return;
6198
+ }
6199
+ if (obj === null || obj === undefined || typeof obj !== "object") {
6200
+ return;
6201
+ }
6202
+ const next2 = obj[head];
6203
+ return resolvePath(next2, tail);
6204
+ }
6205
+
6206
+ class JsonPathTask extends Task19 {
6207
+ static type = "JsonPathTask";
6208
+ static category = "Utility";
6209
+ static title = "JSON Path";
6210
+ static description = "Extracts a value from an object using a dot-notation path";
6211
+ static inputSchema() {
6212
+ return inputSchema19;
6213
+ }
6214
+ static outputSchema() {
6215
+ return outputSchema19;
6216
+ }
6217
+ async executeReactive(input2, _output, _context) {
6218
+ const segments = input2.path.split(".");
6219
+ const result = resolvePath(input2.value, segments);
6220
+ return { result };
6221
+ }
6222
+ }
6223
+ Workflow22.prototype.jsonPath = CreateWorkflow21(JsonPathTask);
6224
+ // src/task/RegexTask.ts
6225
+ import {
6226
+ CreateWorkflow as CreateWorkflow22,
6227
+ Task as Task20,
6228
+ Workflow as Workflow23
6229
+ } from "@workglow/task-graph";
6230
+ var inputSchema20 = {
6231
+ type: "object",
6232
+ properties: {
6233
+ value: {
6234
+ type: "string",
6235
+ title: "Value",
6236
+ description: "Input string to match against"
6237
+ },
6238
+ pattern: {
6239
+ type: "string",
6240
+ title: "Pattern",
6241
+ description: "Regular expression pattern"
6242
+ },
6243
+ flags: {
6244
+ type: "string",
6245
+ title: "Flags",
6246
+ description: "Regex flags (e.g. 'g', 'i', 'gi')",
6247
+ default: ""
6248
+ }
6249
+ },
6250
+ required: ["value", "pattern"],
6251
+ additionalProperties: false
6252
+ };
6253
+ var outputSchema20 = {
6254
+ type: "object",
6255
+ properties: {
6256
+ match: {
6257
+ type: "boolean",
6258
+ title: "Match",
6259
+ description: "Whether the pattern matched"
6260
+ },
6261
+ matches: {
6262
+ type: "array",
6263
+ items: { type: "string" },
6264
+ title: "Matches",
6265
+ description: "Array of matched strings (full matches when global, groups when not)"
6266
+ }
6267
+ },
6268
+ required: ["match", "matches"],
6269
+ additionalProperties: false
6270
+ };
6271
+
6272
+ class RegexTask extends Task20 {
6273
+ static type = "RegexTask";
6274
+ static category = "String";
6275
+ static title = "Regex";
6276
+ static description = "Matches a string against a regular expression pattern";
6277
+ static inputSchema() {
6278
+ return inputSchema20;
6279
+ }
6280
+ static outputSchema() {
6281
+ return outputSchema20;
6282
+ }
6283
+ async executeReactive(input2, _output, _context) {
6284
+ const flags = input2.flags ?? "";
6285
+ const regex = new RegExp(input2.pattern, flags);
6286
+ if (flags.includes("g")) {
6287
+ const allMatches = Array.from(input2.value.matchAll(new RegExp(input2.pattern, flags)));
6288
+ return {
6289
+ match: allMatches.length > 0,
6290
+ matches: allMatches.map((m) => m[0])
6291
+ };
6292
+ }
6293
+ const result = regex.exec(input2.value);
6294
+ if (!result) {
6295
+ return { match: false, matches: [] };
6296
+ }
6297
+ return {
6298
+ match: true,
6299
+ matches: result.slice(0)
6300
+ };
6301
+ }
6302
+ }
6303
+ Workflow23.prototype.regex = CreateWorkflow22(RegexTask);
6304
+ // src/task/TemplateTask.ts
6305
+ import {
6306
+ CreateWorkflow as CreateWorkflow23,
6307
+ Task as Task21,
6308
+ Workflow as Workflow24
6309
+ } from "@workglow/task-graph";
6310
+ var inputSchema21 = {
6311
+ type: "object",
6312
+ properties: {
6313
+ template: {
6314
+ type: "string",
6315
+ title: "Template",
6316
+ description: "Template string with {{key}} placeholders; supports {{key|default}} for defaults"
6317
+ },
6318
+ values: {
6319
+ type: "object",
6320
+ title: "Values",
6321
+ description: "Key-value pairs to substitute into the template",
6322
+ additionalProperties: true
6323
+ }
6324
+ },
6325
+ required: ["template", "values"],
6326
+ additionalProperties: false
6327
+ };
6328
+ var outputSchema21 = {
6329
+ type: "object",
6330
+ properties: {
6331
+ result: {
6332
+ type: "string",
6333
+ title: "Result",
6334
+ description: "Rendered template string"
6335
+ }
6336
+ },
6337
+ required: ["result"],
6338
+ additionalProperties: false
6339
+ };
6340
+
6341
+ class TemplateTask extends Task21 {
6342
+ static type = "TemplateTask";
6343
+ static category = "Utility";
6344
+ static title = "Template";
6345
+ static description = "Renders a template string with {{key}} placeholders and optional defaults";
6346
+ static inputSchema() {
6347
+ return inputSchema21;
6348
+ }
6349
+ static outputSchema() {
6350
+ return outputSchema21;
6351
+ }
6352
+ async executeReactive(input2, _output, _context) {
6353
+ const result = input2.template.replace(/\{\{([^}]+)\}\}/g, (_match, expr) => {
6354
+ const [path, defaultValue] = expr.split("|").map((s) => s.trim());
6355
+ const segments = path.split(".");
6356
+ let current = input2.values;
6357
+ for (const segment of segments) {
6358
+ if (current === null || current === undefined || typeof current !== "object") {
6359
+ current = undefined;
6360
+ break;
6361
+ }
6362
+ current = current[segment];
6363
+ }
6364
+ if (current !== undefined && current !== null) {
6365
+ return String(current);
6366
+ }
6367
+ return defaultValue !== undefined ? defaultValue : "";
6368
+ });
6369
+ return { result };
6370
+ }
6371
+ }
6372
+ Workflow24.prototype.template = CreateWorkflow23(TemplateTask);
6513
6373
  // src/task/mcp/McpListTask.ts
6514
- import { CreateWorkflow as CreateWorkflow22, Task as Task19, Workflow as Workflow23 } from "@workglow/task-graph";
6374
+ import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
6515
6375
  import {
6516
6376
  mcpClientFactory,
6517
6377
  mcpServerConfigSchema
6518
6378
  } from "@workglow/util";
6519
6379
  var mcpListTypes = ["tools", "resources", "prompts"];
6520
- var inputSchema19 = {
6380
+ var inputSchema22 = {
6521
6381
  type: "object",
6522
6382
  properties: {
6523
6383
  ...mcpServerConfigSchema,
@@ -6686,7 +6546,7 @@ var outputSchemaAll = {
6686
6546
  additionalProperties: false
6687
6547
  };
6688
6548
 
6689
- class McpListTask extends Task19 {
6549
+ class McpListTask extends Task22 {
6690
6550
  static type = "McpListTask";
6691
6551
  static category = "MCP";
6692
6552
  static title = "MCP List";
@@ -6694,7 +6554,7 @@ class McpListTask extends Task19 {
6694
6554
  static cacheable = false;
6695
6555
  static hasDynamicSchemas = true;
6696
6556
  static inputSchema() {
6697
- return inputSchema19;
6557
+ return inputSchema22;
6698
6558
  }
6699
6559
  static outputSchema() {
6700
6560
  return outputSchemaAll;
@@ -6754,13 +6614,13 @@ class McpListTask extends Task19 {
6754
6614
  var mcpList = async (input2, config = {}) => {
6755
6615
  return new McpListTask({}, config).run(input2);
6756
6616
  };
6757
- Workflow23.prototype.mcpList = CreateWorkflow22(McpListTask);
6617
+ Workflow25.prototype.mcpList = CreateWorkflow24(McpListTask);
6758
6618
  // src/task/mcp/McpPromptGetTask.ts
6759
6619
  import {
6760
- CreateWorkflow as CreateWorkflow23,
6761
- Task as Task20,
6620
+ CreateWorkflow as CreateWorkflow25,
6621
+ Task as Task23,
6762
6622
  TaskConfigSchema as TaskConfigSchema5,
6763
- Workflow as Workflow24
6623
+ Workflow as Workflow26
6764
6624
  } from "@workglow/task-graph";
6765
6625
  import {
6766
6626
  mcpClientFactory as mcpClientFactory2,
@@ -6917,7 +6777,7 @@ var fallbackInputSchema = {
6917
6777
  additionalProperties: false
6918
6778
  };
6919
6779
 
6920
- class McpPromptGetTask extends Task20 {
6780
+ class McpPromptGetTask extends Task23 {
6921
6781
  static type = "McpPromptGetTask";
6922
6782
  static category = "MCP";
6923
6783
  static title = "MCP Get Prompt";
@@ -7001,13 +6861,13 @@ class McpPromptGetTask extends Task20 {
7001
6861
  var mcpPromptGet = async (input2, config) => {
7002
6862
  return new McpPromptGetTask({}, config).run(input2);
7003
6863
  };
7004
- Workflow24.prototype.mcpPromptGet = CreateWorkflow23(McpPromptGetTask);
6864
+ Workflow26.prototype.mcpPromptGet = CreateWorkflow25(McpPromptGetTask);
7005
6865
  // src/task/mcp/McpResourceReadTask.ts
7006
6866
  import {
7007
- CreateWorkflow as CreateWorkflow24,
7008
- Task as Task21,
6867
+ CreateWorkflow as CreateWorkflow26,
6868
+ Task as Task24,
7009
6869
  TaskConfigSchema as TaskConfigSchema6,
7010
- Workflow as Workflow25
6870
+ Workflow as Workflow27
7011
6871
  } from "@workglow/task-graph";
7012
6872
  import {
7013
6873
  mcpClientFactory as mcpClientFactory3,
@@ -7057,12 +6917,12 @@ var contentItemSchema = {
7057
6917
  }
7058
6918
  ]
7059
6919
  };
7060
- var inputSchema20 = {
6920
+ var inputSchema23 = {
7061
6921
  type: "object",
7062
6922
  properties: {},
7063
6923
  additionalProperties: false
7064
6924
  };
7065
- var outputSchema19 = {
6925
+ var outputSchema22 = {
7066
6926
  type: "object",
7067
6927
  properties: {
7068
6928
  contents: {
@@ -7076,7 +6936,7 @@ var outputSchema19 = {
7076
6936
  additionalProperties: false
7077
6937
  };
7078
6938
 
7079
- class McpResourceReadTask extends Task21 {
6939
+ class McpResourceReadTask extends Task24 {
7080
6940
  static type = "McpResourceReadTask";
7081
6941
  static category = "MCP";
7082
6942
  static title = "MCP Read Resource";
@@ -7084,10 +6944,10 @@ class McpResourceReadTask extends Task21 {
7084
6944
  static cacheable = false;
7085
6945
  static customizable = true;
7086
6946
  static inputSchema() {
7087
- return inputSchema20;
6947
+ return inputSchema23;
7088
6948
  }
7089
6949
  static outputSchema() {
7090
- return outputSchema19;
6950
+ return outputSchema22;
7091
6951
  }
7092
6952
  static configSchema() {
7093
6953
  return configSchema3;
@@ -7105,13 +6965,13 @@ class McpResourceReadTask extends Task21 {
7105
6965
  var mcpResourceRead = async (config) => {
7106
6966
  return new McpResourceReadTask({}, config).run({});
7107
6967
  };
7108
- Workflow25.prototype.mcpResourceRead = CreateWorkflow24(McpResourceReadTask);
6968
+ Workflow27.prototype.mcpResourceRead = CreateWorkflow26(McpResourceReadTask);
7109
6969
  // src/task/mcp/McpToolCallTask.ts
7110
6970
  import {
7111
- CreateWorkflow as CreateWorkflow25,
7112
- Task as Task22,
6971
+ CreateWorkflow as CreateWorkflow27,
6972
+ Task as Task25,
7113
6973
  TaskConfigSchema as TaskConfigSchema7,
7114
- Workflow as Workflow26
6974
+ Workflow as Workflow28
7115
6975
  } from "@workglow/task-graph";
7116
6976
  import {
7117
6977
  mcpClientFactory as mcpClientFactory4,
@@ -7260,7 +7120,7 @@ var fallbackInputSchema2 = {
7260
7120
  additionalProperties: true
7261
7121
  };
7262
7122
 
7263
- class McpToolCallTask extends Task22 {
7123
+ class McpToolCallTask extends Task25 {
7264
7124
  static type = "McpToolCallTask";
7265
7125
  static category = "MCP";
7266
7126
  static title = "MCP Call Tool";
@@ -7359,577 +7219,1742 @@ class McpToolCallTask extends Task22 {
7359
7219
  var mcpToolCall = async (input2, config) => {
7360
7220
  return new McpToolCallTask({}, config).run(input2);
7361
7221
  };
7362
- Workflow26.prototype.mcpToolCall = CreateWorkflow25(McpToolCallTask);
7363
- // src/task/scalar/ScalarAbsTask.ts
7364
- import { CreateWorkflow as CreateWorkflow26, Task as Task23, Workflow as Workflow27 } from "@workglow/task-graph";
7365
- var inputSchema21 = {
7222
+ Workflow28.prototype.mcpToolCall = CreateWorkflow27(McpToolCallTask);
7223
+ // src/task/string/StringConcatTask.ts
7224
+ import {
7225
+ CreateWorkflow as CreateWorkflow28,
7226
+ Task as Task26,
7227
+ Workflow as Workflow29
7228
+ } from "@workglow/task-graph";
7229
+ var inputSchema24 = {
7230
+ type: "object",
7231
+ properties: {},
7232
+ additionalProperties: { type: "string" }
7233
+ };
7234
+ var outputSchema23 = {
7366
7235
  type: "object",
7367
7236
  properties: {
7368
- value: {
7369
- type: "number",
7370
- title: "Value",
7371
- description: "Input number"
7237
+ result: {
7238
+ type: "string",
7239
+ title: "Result",
7240
+ description: "Concatenation of all input strings"
7372
7241
  }
7373
7242
  },
7374
- required: ["value"],
7243
+ required: ["result"],
7375
7244
  additionalProperties: false
7376
7245
  };
7377
- var outputSchema20 = {
7246
+
7247
+ class StringConcatTask extends Task26 {
7248
+ static type = "StringConcatTask";
7249
+ static category = "String";
7250
+ static title = "Concat";
7251
+ static description = "Concatenates all input strings";
7252
+ static inputSchema() {
7253
+ return inputSchema24;
7254
+ }
7255
+ static outputSchema() {
7256
+ return outputSchema23;
7257
+ }
7258
+ async executeReactive(input2, _output, _context) {
7259
+ return { result: Object.values(input2).join("") };
7260
+ }
7261
+ }
7262
+ Workflow29.prototype.stringConcat = CreateWorkflow28(StringConcatTask);
7263
+ // src/task/string/StringIncludesTask.ts
7264
+ import {
7265
+ CreateWorkflow as CreateWorkflow29,
7266
+ Task as Task27,
7267
+ Workflow as Workflow30
7268
+ } from "@workglow/task-graph";
7269
+ var inputSchema25 = {
7270
+ type: "object",
7271
+ properties: {
7272
+ value: {
7273
+ type: "string",
7274
+ title: "Value",
7275
+ description: "Input string to search in"
7276
+ },
7277
+ search: {
7278
+ type: "string",
7279
+ title: "Search",
7280
+ description: "Substring to search for"
7281
+ }
7282
+ },
7283
+ required: ["value", "search"],
7284
+ additionalProperties: false
7285
+ };
7286
+ var outputSchema24 = {
7378
7287
  type: "object",
7379
7288
  properties: {
7380
7289
  result: {
7381
- type: "number",
7290
+ type: "boolean",
7382
7291
  title: "Result",
7383
- description: "Absolute value"
7292
+ description: "Whether the string contains the search substring"
7384
7293
  }
7385
7294
  },
7386
7295
  required: ["result"],
7387
7296
  additionalProperties: false
7388
7297
  };
7389
7298
 
7390
- class ScalarAbsTask extends Task23 {
7391
- static type = "ScalarAbsTask";
7392
- static category = "Math";
7393
- static title = "Abs";
7394
- static description = "Returns the absolute value of a number";
7299
+ class StringIncludesTask extends Task27 {
7300
+ static type = "StringIncludesTask";
7301
+ static category = "String";
7302
+ static title = "Includes";
7303
+ static description = "Checks if a string contains a substring";
7395
7304
  static inputSchema() {
7396
- return inputSchema21;
7305
+ return inputSchema25;
7397
7306
  }
7398
7307
  static outputSchema() {
7399
- return outputSchema20;
7308
+ return outputSchema24;
7400
7309
  }
7401
- async execute(input2, _context) {
7402
- return { result: Math.abs(input2.value) };
7310
+ async executeReactive(input2, output, _context) {
7311
+ return { result: input2.value.includes(input2.search) };
7403
7312
  }
7404
7313
  }
7405
- Workflow27.prototype.scalarAbs = CreateWorkflow26(ScalarAbsTask);
7406
- // src/task/scalar/ScalarCeilTask.ts
7407
- import { CreateWorkflow as CreateWorkflow27, Task as Task24, Workflow as Workflow28 } from "@workglow/task-graph";
7408
- var inputSchema22 = {
7314
+ Workflow30.prototype.stringIncludes = CreateWorkflow29(StringIncludesTask);
7315
+ // src/task/string/StringJoinTask.ts
7316
+ import {
7317
+ CreateWorkflow as CreateWorkflow30,
7318
+ Task as Task28,
7319
+ Workflow as Workflow31
7320
+ } from "@workglow/task-graph";
7321
+ var inputSchema26 = {
7409
7322
  type: "object",
7410
7323
  properties: {
7411
- value: {
7412
- type: "number",
7413
- title: "Value",
7414
- description: "Input number"
7324
+ values: {
7325
+ type: "array",
7326
+ items: { type: "string" },
7327
+ title: "Values",
7328
+ description: "Array of strings to join"
7329
+ },
7330
+ separator: {
7331
+ type: "string",
7332
+ title: "Separator",
7333
+ description: "Separator between elements",
7334
+ default: ""
7415
7335
  }
7416
7336
  },
7417
- required: ["value"],
7337
+ required: ["values"],
7418
7338
  additionalProperties: false
7419
7339
  };
7420
- var outputSchema21 = {
7340
+ var outputSchema25 = {
7421
7341
  type: "object",
7422
7342
  properties: {
7423
7343
  result: {
7424
- type: "number",
7344
+ type: "string",
7425
7345
  title: "Result",
7426
- description: "Ceiling value"
7346
+ description: "Joined string"
7427
7347
  }
7428
7348
  },
7429
7349
  required: ["result"],
7430
7350
  additionalProperties: false
7431
7351
  };
7432
7352
 
7433
- class ScalarCeilTask extends Task24 {
7434
- static type = "ScalarCeilTask";
7435
- static category = "Math";
7436
- static title = "Ceil";
7437
- static description = "Returns the smallest integer greater than or equal to a number";
7353
+ class StringJoinTask extends Task28 {
7354
+ static type = "StringJoinTask";
7355
+ static category = "String";
7356
+ static title = "Join";
7357
+ static description = "Joins an array of strings with a separator";
7438
7358
  static inputSchema() {
7439
- return inputSchema22;
7359
+ return inputSchema26;
7440
7360
  }
7441
7361
  static outputSchema() {
7442
- return outputSchema21;
7362
+ return outputSchema25;
7443
7363
  }
7444
- async execute(input2, _context) {
7445
- return { result: Math.ceil(input2.value) };
7364
+ async executeReactive(input2, output, _context) {
7365
+ const separator = input2.separator ?? "";
7366
+ return { result: input2.values.join(separator) };
7446
7367
  }
7447
7368
  }
7448
- Workflow28.prototype.scalarCeil = CreateWorkflow27(ScalarCeilTask);
7449
- // src/task/scalar/ScalarFloorTask.ts
7450
- import { CreateWorkflow as CreateWorkflow28, Task as Task25, Workflow as Workflow29 } from "@workglow/task-graph";
7451
- var inputSchema23 = {
7369
+ Workflow31.prototype.stringJoin = CreateWorkflow30(StringJoinTask);
7370
+ // src/task/string/StringLengthTask.ts
7371
+ import {
7372
+ CreateWorkflow as CreateWorkflow31,
7373
+ Task as Task29,
7374
+ Workflow as Workflow32
7375
+ } from "@workglow/task-graph";
7376
+ var inputSchema27 = {
7452
7377
  type: "object",
7453
7378
  properties: {
7454
7379
  value: {
7455
- type: "number",
7380
+ type: "string",
7456
7381
  title: "Value",
7457
- description: "Input number"
7382
+ description: "Input string"
7458
7383
  }
7459
7384
  },
7460
7385
  required: ["value"],
7461
7386
  additionalProperties: false
7462
7387
  };
7463
- var outputSchema22 = {
7388
+ var outputSchema26 = {
7464
7389
  type: "object",
7465
7390
  properties: {
7466
7391
  result: {
7467
- type: "number",
7392
+ type: "integer",
7468
7393
  title: "Result",
7469
- description: "Floored value"
7394
+ description: "Length of the string"
7470
7395
  }
7471
7396
  },
7472
7397
  required: ["result"],
7473
7398
  additionalProperties: false
7474
7399
  };
7475
7400
 
7476
- class ScalarFloorTask extends Task25 {
7477
- static type = "ScalarFloorTask";
7478
- static category = "Math";
7479
- static title = "Floor";
7480
- static description = "Returns the largest integer less than or equal to a number";
7401
+ class StringLengthTask extends Task29 {
7402
+ static type = "StringLengthTask";
7403
+ static category = "String";
7404
+ static title = "Length";
7405
+ static description = "Returns the length of a string";
7481
7406
  static inputSchema() {
7482
- return inputSchema23;
7407
+ return inputSchema27;
7483
7408
  }
7484
7409
  static outputSchema() {
7485
- return outputSchema22;
7410
+ return outputSchema26;
7486
7411
  }
7487
- async execute(input2, _context) {
7488
- return { result: Math.floor(input2.value) };
7412
+ async executeReactive(input2, output, _context) {
7413
+ return { result: input2.value.length };
7489
7414
  }
7490
7415
  }
7491
- Workflow29.prototype.scalarFloor = CreateWorkflow28(ScalarFloorTask);
7492
- // src/task/scalar/ScalarMaxTask.ts
7493
- import { CreateWorkflow as CreateWorkflow29, Task as Task26, Workflow as Workflow30 } from "@workglow/task-graph";
7494
- var inputSchema24 = {
7416
+ Workflow32.prototype.stringLength = CreateWorkflow31(StringLengthTask);
7417
+ // src/task/string/StringLowerCaseTask.ts
7418
+ import {
7419
+ CreateWorkflow as CreateWorkflow32,
7420
+ Task as Task30,
7421
+ Workflow as Workflow33
7422
+ } from "@workglow/task-graph";
7423
+ var inputSchema28 = {
7495
7424
  type: "object",
7496
7425
  properties: {
7497
- values: {
7498
- type: "array",
7499
- items: { type: "number" },
7500
- title: "Values",
7501
- description: "Array of numbers"
7426
+ value: {
7427
+ type: "string",
7428
+ title: "Value",
7429
+ description: "Input string"
7502
7430
  }
7503
7431
  },
7504
- required: ["values"],
7432
+ required: ["value"],
7505
7433
  additionalProperties: false
7506
7434
  };
7507
- var outputSchema23 = {
7435
+ var outputSchema27 = {
7508
7436
  type: "object",
7509
7437
  properties: {
7510
7438
  result: {
7511
- type: "number",
7439
+ type: "string",
7512
7440
  title: "Result",
7513
- description: "Maximum value"
7441
+ description: "Lowercased string"
7514
7442
  }
7515
7443
  },
7516
7444
  required: ["result"],
7517
7445
  additionalProperties: false
7518
7446
  };
7519
7447
 
7520
- class ScalarMaxTask extends Task26 {
7521
- static type = "ScalarMaxTask";
7522
- static category = "Math";
7523
- static title = "Max";
7524
- static description = "Returns the largest of the given numbers";
7448
+ class StringLowerCaseTask extends Task30 {
7449
+ static type = "StringLowerCaseTask";
7450
+ static category = "String";
7451
+ static title = "Lower Case";
7452
+ static description = "Converts a string to lower case";
7525
7453
  static inputSchema() {
7526
- return inputSchema24;
7454
+ return inputSchema28;
7527
7455
  }
7528
7456
  static outputSchema() {
7529
- return outputSchema23;
7457
+ return outputSchema27;
7530
7458
  }
7531
- async execute(input2, _context) {
7532
- return { result: Math.max(...input2.values) };
7459
+ async executeReactive(input2, output, _context) {
7460
+ return { result: input2.value.toLowerCase() };
7533
7461
  }
7534
7462
  }
7535
- Workflow30.prototype.scalarMax = CreateWorkflow29(ScalarMaxTask);
7536
- // src/task/scalar/ScalarMinTask.ts
7537
- import { CreateWorkflow as CreateWorkflow30, Task as Task27, Workflow as Workflow31 } from "@workglow/task-graph";
7538
- var inputSchema25 = {
7463
+ Workflow33.prototype.stringLowerCase = CreateWorkflow32(StringLowerCaseTask);
7464
+ // src/task/string/StringReplaceTask.ts
7465
+ import {
7466
+ CreateWorkflow as CreateWorkflow33,
7467
+ Task as Task31,
7468
+ Workflow as Workflow34
7469
+ } from "@workglow/task-graph";
7470
+ var inputSchema29 = {
7539
7471
  type: "object",
7540
7472
  properties: {
7541
- values: {
7542
- type: "array",
7543
- items: { type: "number" },
7544
- title: "Values",
7545
- description: "Array of numbers"
7473
+ value: {
7474
+ type: "string",
7475
+ title: "Value",
7476
+ description: "Input string"
7477
+ },
7478
+ search: {
7479
+ type: "string",
7480
+ title: "Search",
7481
+ description: "Substring to search for"
7482
+ },
7483
+ replace: {
7484
+ type: "string",
7485
+ title: "Replace",
7486
+ description: "Replacement string"
7546
7487
  }
7547
7488
  },
7548
- required: ["values"],
7489
+ required: ["value", "search", "replace"],
7549
7490
  additionalProperties: false
7550
7491
  };
7551
- var outputSchema24 = {
7492
+ var outputSchema28 = {
7552
7493
  type: "object",
7553
7494
  properties: {
7554
7495
  result: {
7555
- type: "number",
7496
+ type: "string",
7556
7497
  title: "Result",
7557
- description: "Minimum value"
7498
+ description: "String with all occurrences replaced"
7558
7499
  }
7559
7500
  },
7560
7501
  required: ["result"],
7561
7502
  additionalProperties: false
7562
7503
  };
7563
7504
 
7564
- class ScalarMinTask extends Task27 {
7565
- static type = "ScalarMinTask";
7566
- static category = "Math";
7567
- static title = "Min";
7568
- static description = "Returns the smallest of the given numbers";
7505
+ class StringReplaceTask extends Task31 {
7506
+ static type = "StringReplaceTask";
7507
+ static category = "String";
7508
+ static title = "Replace";
7509
+ static description = "Replaces all occurrences of a substring";
7569
7510
  static inputSchema() {
7570
- return inputSchema25;
7511
+ return inputSchema29;
7571
7512
  }
7572
7513
  static outputSchema() {
7573
- return outputSchema24;
7514
+ return outputSchema28;
7574
7515
  }
7575
- async execute(input2, _context) {
7576
- return { result: Math.min(...input2.values) };
7516
+ async executeReactive(input2, output, _context) {
7517
+ return { result: input2.value.replaceAll(input2.search, input2.replace) };
7577
7518
  }
7578
7519
  }
7579
- Workflow31.prototype.scalarMin = CreateWorkflow30(ScalarMinTask);
7580
- // src/task/scalar/ScalarRoundTask.ts
7581
- import { CreateWorkflow as CreateWorkflow31, Task as Task28, Workflow as Workflow32 } from "@workglow/task-graph";
7582
- var inputSchema26 = {
7520
+ Workflow34.prototype.stringReplace = CreateWorkflow33(StringReplaceTask);
7521
+ // src/task/string/StringSliceTask.ts
7522
+ import {
7523
+ CreateWorkflow as CreateWorkflow34,
7524
+ Task as Task32,
7525
+ Workflow as Workflow35
7526
+ } from "@workglow/task-graph";
7527
+ var inputSchema30 = {
7583
7528
  type: "object",
7584
7529
  properties: {
7585
7530
  value: {
7586
- type: "number",
7531
+ type: "string",
7587
7532
  title: "Value",
7588
- description: "Input number"
7533
+ description: "Input string"
7534
+ },
7535
+ start: {
7536
+ type: "integer",
7537
+ title: "Start",
7538
+ description: "Start index (inclusive, supports negative indexing)"
7539
+ },
7540
+ end: {
7541
+ type: "integer",
7542
+ title: "End",
7543
+ description: "End index (exclusive, supports negative indexing)"
7589
7544
  }
7590
7545
  },
7591
- required: ["value"],
7546
+ required: ["value", "start"],
7592
7547
  additionalProperties: false
7593
7548
  };
7594
- var outputSchema25 = {
7549
+ var outputSchema29 = {
7595
7550
  type: "object",
7596
7551
  properties: {
7597
7552
  result: {
7598
- type: "number",
7553
+ type: "string",
7599
7554
  title: "Result",
7600
- description: "Rounded value"
7555
+ description: "Extracted substring"
7601
7556
  }
7602
7557
  },
7603
7558
  required: ["result"],
7604
7559
  additionalProperties: false
7605
7560
  };
7606
7561
 
7607
- class ScalarRoundTask extends Task28 {
7608
- static type = "ScalarRoundTask";
7609
- static category = "Math";
7610
- static title = "Round";
7611
- static description = "Returns the value of a number rounded to the nearest integer";
7562
+ class StringSliceTask extends Task32 {
7563
+ static type = "StringSliceTask";
7564
+ static category = "String";
7565
+ static title = "Slice";
7566
+ static description = "Extracts a substring by start and optional end index";
7612
7567
  static inputSchema() {
7613
- return inputSchema26;
7568
+ return inputSchema30;
7614
7569
  }
7615
7570
  static outputSchema() {
7616
- return outputSchema25;
7571
+ return outputSchema29;
7617
7572
  }
7618
- async execute(input2, _context) {
7619
- return { result: Math.round(input2.value) };
7573
+ async executeReactive(input2, output, _context) {
7574
+ return { result: input2.value.slice(input2.start, input2.end) };
7620
7575
  }
7621
7576
  }
7622
- Workflow32.prototype.scalarRound = CreateWorkflow31(ScalarRoundTask);
7623
- // src/task/scalar/ScalarTruncTask.ts
7624
- import { CreateWorkflow as CreateWorkflow32, Task as Task29, Workflow as Workflow33 } from "@workglow/task-graph";
7625
- var inputSchema27 = {
7577
+ Workflow35.prototype.stringSlice = CreateWorkflow34(StringSliceTask);
7578
+ // src/task/string/StringTemplateTask.ts
7579
+ import {
7580
+ CreateWorkflow as CreateWorkflow35,
7581
+ Task as Task33,
7582
+ Workflow as Workflow36
7583
+ } from "@workglow/task-graph";
7584
+ var inputSchema31 = {
7626
7585
  type: "object",
7627
7586
  properties: {
7628
- value: {
7629
- type: "number",
7630
- title: "Value",
7631
- description: "Input number"
7587
+ template: {
7588
+ type: "string",
7589
+ title: "Template",
7590
+ description: "Template string with {{key}} placeholders"
7591
+ },
7592
+ values: {
7593
+ type: "object",
7594
+ title: "Values",
7595
+ description: "Key-value pairs to substitute into the template",
7596
+ additionalProperties: true
7632
7597
  }
7633
7598
  },
7634
- required: ["value"],
7599
+ required: ["template", "values"],
7635
7600
  additionalProperties: false
7636
7601
  };
7637
- var outputSchema26 = {
7602
+ var outputSchema30 = {
7638
7603
  type: "object",
7639
7604
  properties: {
7640
7605
  result: {
7641
- type: "number",
7606
+ type: "string",
7642
7607
  title: "Result",
7643
- description: "Truncated value"
7608
+ description: "Template with placeholders replaced by values"
7644
7609
  }
7645
7610
  },
7646
7611
  required: ["result"],
7647
7612
  additionalProperties: false
7648
7613
  };
7649
7614
 
7650
- class ScalarTruncTask extends Task29 {
7651
- static type = "ScalarTruncTask";
7652
- static category = "Math";
7653
- static title = "Truncate";
7654
- static description = "Returns the integer part of a number by removing fractional digits";
7615
+ class StringTemplateTask extends Task33 {
7616
+ static type = "StringTemplateTask";
7617
+ static category = "String";
7618
+ static title = "Template";
7619
+ static description = "Replaces {{key}} placeholders in a template string with values";
7655
7620
  static inputSchema() {
7656
- return inputSchema27;
7621
+ return inputSchema31;
7657
7622
  }
7658
7623
  static outputSchema() {
7659
- return outputSchema26;
7624
+ return outputSchema30;
7660
7625
  }
7661
- async execute(input2, _context) {
7662
- return { result: Math.trunc(input2.value) };
7626
+ async executeReactive(input2, output, _context) {
7627
+ let result = input2.template;
7628
+ for (const [key, value] of Object.entries(input2.values)) {
7629
+ result = result.replaceAll(`{{${key}}}`, String(value));
7630
+ }
7631
+ return { result };
7663
7632
  }
7664
7633
  }
7665
- Workflow33.prototype.scalarTrunc = CreateWorkflow32(ScalarTruncTask);
7666
- // src/task/vector/VectorDistanceTask.ts
7667
- import { CreateWorkflow as CreateWorkflow33, Task as Task30, Workflow as Workflow34 } from "@workglow/task-graph";
7634
+ Workflow36.prototype.stringTemplate = CreateWorkflow35(StringTemplateTask);
7635
+ // src/task/string/StringTrimTask.ts
7668
7636
  import {
7669
- TypedArraySchema as TypedArraySchema5
7670
- } from "@workglow/util";
7671
- var inputSchema28 = {
7637
+ CreateWorkflow as CreateWorkflow36,
7638
+ Task as Task34,
7639
+ Workflow as Workflow37
7640
+ } from "@workglow/task-graph";
7641
+ var inputSchema32 = {
7672
7642
  type: "object",
7673
7643
  properties: {
7674
- vectors: {
7675
- type: "array",
7676
- items: TypedArraySchema5({
7677
- title: "Vector",
7678
- description: "Vector for distance computation"
7679
- }),
7680
- title: "Vectors",
7681
- description: "Array of two vectors to compute Euclidean distance"
7644
+ value: {
7645
+ type: "string",
7646
+ title: "Value",
7647
+ description: "Input string"
7682
7648
  }
7683
7649
  },
7684
- required: ["vectors"],
7650
+ required: ["value"],
7685
7651
  additionalProperties: false
7686
7652
  };
7687
- var outputSchema27 = {
7653
+ var outputSchema31 = {
7688
7654
  type: "object",
7689
7655
  properties: {
7690
7656
  result: {
7691
- type: "number",
7657
+ type: "string",
7692
7658
  title: "Result",
7693
- description: "Euclidean distance between vectors"
7659
+ description: "Trimmed string"
7694
7660
  }
7695
7661
  },
7696
7662
  required: ["result"],
7697
7663
  additionalProperties: false
7698
7664
  };
7699
7665
 
7700
- class VectorDistanceTask extends Task30 {
7701
- static type = "VectorDistanceTask";
7702
- static category = "Vector";
7703
- static title = "Distance";
7704
- static description = "Returns the Euclidean distance between the first two vectors";
7666
+ class StringTrimTask extends Task34 {
7667
+ static type = "StringTrimTask";
7668
+ static category = "String";
7669
+ static title = "Trim";
7670
+ static description = "Removes leading and trailing whitespace from a string";
7705
7671
  static inputSchema() {
7706
- return inputSchema28;
7672
+ return inputSchema32;
7707
7673
  }
7708
7674
  static outputSchema() {
7709
- return outputSchema27;
7675
+ return outputSchema31;
7710
7676
  }
7711
- async execute(input2, _context) {
7712
- const { vectors } = input2;
7713
- if (vectors.length < 2) {
7714
- throw new Error("Exactly two vectors are required for distance");
7715
- }
7716
- const [a, b] = vectors;
7717
- if (a.length !== b.length) {
7718
- throw new Error("Vectors must have the same length");
7719
- }
7720
- const diffs = Array.from({ length: a.length }, (_, i) => {
7721
- const d = Number(a[i]) - Number(b[i]);
7722
- return d * d;
7723
- });
7724
- return { result: Math.sqrt(sumPrecise(diffs)) };
7677
+ async executeReactive(input2, output, _context) {
7678
+ return { result: input2.value.trim() };
7725
7679
  }
7726
7680
  }
7727
- Workflow34.prototype.vectorDistance = CreateWorkflow33(VectorDistanceTask);
7728
- // src/task/vector/VectorDotProductTask.ts
7729
- import { CreateWorkflow as CreateWorkflow34, Task as Task31, Workflow as Workflow35 } from "@workglow/task-graph";
7681
+ Workflow37.prototype.stringTrim = CreateWorkflow36(StringTrimTask);
7682
+ // src/task/string/StringUpperCaseTask.ts
7730
7683
  import {
7731
- TypedArraySchema as TypedArraySchema6
7732
- } from "@workglow/util";
7733
- var inputSchema29 = {
7684
+ CreateWorkflow as CreateWorkflow37,
7685
+ Task as Task35,
7686
+ Workflow as Workflow38
7687
+ } from "@workglow/task-graph";
7688
+ var inputSchema33 = {
7734
7689
  type: "object",
7735
7690
  properties: {
7736
- vectors: {
7737
- type: "array",
7738
- items: TypedArraySchema6({
7739
- title: "Vector",
7740
- description: "Vector for dot product"
7741
- }),
7742
- title: "Vectors",
7743
- description: "Array of two vectors to compute dot product"
7691
+ value: {
7692
+ type: "string",
7693
+ title: "Value",
7694
+ description: "Input string"
7744
7695
  }
7745
7696
  },
7746
- required: ["vectors"],
7697
+ required: ["value"],
7747
7698
  additionalProperties: false
7748
7699
  };
7749
- var outputSchema28 = {
7700
+ var outputSchema32 = {
7750
7701
  type: "object",
7751
7702
  properties: {
7752
7703
  result: {
7753
- type: "number",
7704
+ type: "string",
7754
7705
  title: "Result",
7755
- description: "Dot product of the vectors"
7706
+ description: "Uppercased string"
7756
7707
  }
7757
7708
  },
7758
7709
  required: ["result"],
7759
7710
  additionalProperties: false
7760
7711
  };
7761
7712
 
7762
- class VectorDotProductTask extends Task31 {
7763
- static type = "VectorDotProductTask";
7764
- static category = "Vector";
7765
- static title = "Dot Product";
7766
- static description = "Returns the dot (inner) product of the first two vectors";
7713
+ class StringUpperCaseTask extends Task35 {
7714
+ static type = "StringUpperCaseTask";
7715
+ static category = "String";
7716
+ static title = "Upper Case";
7717
+ static description = "Converts a string to upper case";
7767
7718
  static inputSchema() {
7768
- return inputSchema29;
7719
+ return inputSchema33;
7769
7720
  }
7770
7721
  static outputSchema() {
7771
- return outputSchema28;
7722
+ return outputSchema32;
7772
7723
  }
7773
- async execute(input2, _context) {
7774
- const { vectors } = input2;
7775
- if (vectors.length < 2) {
7776
- throw new Error("Exactly two vectors are required for dot product");
7724
+ async executeReactive(input2, output, _context) {
7725
+ return { result: input2.value.toUpperCase() };
7726
+ }
7727
+ }
7728
+ Workflow38.prototype.stringUpperCase = CreateWorkflow37(StringUpperCaseTask);
7729
+ // src/task/scalar/ScalarAbsTask.ts
7730
+ import { CreateWorkflow as CreateWorkflow38, Task as Task36, Workflow as Workflow39 } from "@workglow/task-graph";
7731
+ var inputSchema34 = {
7732
+ type: "object",
7733
+ properties: {
7734
+ value: {
7735
+ type: "number",
7736
+ title: "Value",
7737
+ description: "Input number"
7777
7738
  }
7778
- const [a, b] = vectors;
7779
- if (a.length !== b.length) {
7780
- throw new Error("Vectors must have the same length");
7739
+ },
7740
+ required: ["value"],
7741
+ additionalProperties: false
7742
+ };
7743
+ var outputSchema33 = {
7744
+ type: "object",
7745
+ properties: {
7746
+ result: {
7747
+ type: "number",
7748
+ title: "Result",
7749
+ description: "Absolute value"
7781
7750
  }
7782
- const products = Array.from({ length: a.length }, (_, i) => Number(a[i]) * Number(b[i]));
7783
- return { result: sumPrecise(products) };
7751
+ },
7752
+ required: ["result"],
7753
+ additionalProperties: false
7754
+ };
7755
+
7756
+ class ScalarAbsTask extends Task36 {
7757
+ static type = "ScalarAbsTask";
7758
+ static category = "Math";
7759
+ static title = "Abs";
7760
+ static description = "Returns the absolute value of a number";
7761
+ static inputSchema() {
7762
+ return inputSchema34;
7763
+ }
7764
+ static outputSchema() {
7765
+ return outputSchema33;
7766
+ }
7767
+ async execute(input2, _context) {
7768
+ return { result: Math.abs(input2.value) };
7784
7769
  }
7785
7770
  }
7786
- Workflow35.prototype.vectorDotProduct = CreateWorkflow34(VectorDotProductTask);
7787
- // src/task/vector/VectorNormalizeTask.ts
7788
- import { CreateWorkflow as CreateWorkflow35, Task as Task32, Workflow as Workflow36 } from "@workglow/task-graph";
7789
- import {
7790
- TypedArraySchema as TypedArraySchema7,
7791
- normalize
7792
- } from "@workglow/util";
7793
- var inputSchema30 = {
7771
+ Workflow39.prototype.scalarAbs = CreateWorkflow38(ScalarAbsTask);
7772
+ // src/task/scalar/ScalarCeilTask.ts
7773
+ import { CreateWorkflow as CreateWorkflow39, Task as Task37, Workflow as Workflow40 } from "@workglow/task-graph";
7774
+ var inputSchema35 = {
7794
7775
  type: "object",
7795
7776
  properties: {
7796
- vector: TypedArraySchema7({
7797
- title: "Vector",
7798
- description: "Input vector to normalize"
7799
- })
7777
+ value: {
7778
+ type: "number",
7779
+ title: "Value",
7780
+ description: "Input number"
7781
+ }
7800
7782
  },
7801
- required: ["vector"],
7783
+ required: ["value"],
7802
7784
  additionalProperties: false
7803
7785
  };
7804
- var outputSchema29 = {
7786
+ var outputSchema34 = {
7805
7787
  type: "object",
7806
7788
  properties: {
7807
- result: TypedArraySchema7({
7789
+ result: {
7790
+ type: "number",
7808
7791
  title: "Result",
7809
- description: "L2-normalized vector"
7810
- })
7792
+ description: "Ceiling value"
7793
+ }
7811
7794
  },
7812
7795
  required: ["result"],
7813
7796
  additionalProperties: false
7814
7797
  };
7815
7798
 
7816
- class VectorNormalizeTask extends Task32 {
7817
- static type = "VectorNormalizeTask";
7818
- static category = "Vector";
7819
- static title = "Normalize";
7820
- static description = "Returns the L2-normalized (unit length) vector";
7799
+ class ScalarCeilTask extends Task37 {
7800
+ static type = "ScalarCeilTask";
7801
+ static category = "Math";
7802
+ static title = "Ceil";
7803
+ static description = "Returns the smallest integer greater than or equal to a number";
7821
7804
  static inputSchema() {
7822
- return inputSchema30;
7805
+ return inputSchema35;
7823
7806
  }
7824
7807
  static outputSchema() {
7825
- return outputSchema29;
7808
+ return outputSchema34;
7826
7809
  }
7827
7810
  async execute(input2, _context) {
7828
- return { result: normalize(input2.vector) };
7811
+ return { result: Math.ceil(input2.value) };
7829
7812
  }
7830
7813
  }
7831
- Workflow36.prototype.vectorNormalize = CreateWorkflow35(VectorNormalizeTask);
7832
- // src/task/vector/VectorScaleTask.ts
7833
- import { CreateWorkflow as CreateWorkflow36, Task as Task33, Workflow as Workflow37 } from "@workglow/task-graph";
7834
- import {
7835
- createTypedArrayFrom as createTypedArrayFrom5,
7836
- TypedArraySchema as TypedArraySchema8
7837
- } from "@workglow/util";
7838
- var inputSchema31 = {
7814
+ Workflow40.prototype.scalarCeil = CreateWorkflow39(ScalarCeilTask);
7815
+ // src/task/scalar/ScalarFloorTask.ts
7816
+ import { CreateWorkflow as CreateWorkflow40, Task as Task38, Workflow as Workflow41 } from "@workglow/task-graph";
7817
+ var inputSchema36 = {
7839
7818
  type: "object",
7840
7819
  properties: {
7841
- vector: TypedArraySchema8({
7842
- title: "Vector",
7843
- description: "Input vector"
7844
- }),
7845
- scalar: {
7820
+ value: {
7846
7821
  type: "number",
7847
- title: "Scalar",
7848
- description: "Scalar multiplier"
7822
+ title: "Value",
7823
+ description: "Input number"
7849
7824
  }
7850
7825
  },
7851
- required: ["vector", "scalar"],
7826
+ required: ["value"],
7852
7827
  additionalProperties: false
7853
7828
  };
7854
- var outputSchema30 = {
7829
+ var outputSchema35 = {
7855
7830
  type: "object",
7856
7831
  properties: {
7857
- result: TypedArraySchema8({
7832
+ result: {
7833
+ type: "number",
7858
7834
  title: "Result",
7859
- description: "Scaled vector"
7860
- })
7835
+ description: "Floored value"
7836
+ }
7861
7837
  },
7862
7838
  required: ["result"],
7863
7839
  additionalProperties: false
7864
7840
  };
7865
7841
 
7866
- class VectorScaleTask extends Task33 {
7867
- static type = "VectorScaleTask";
7868
- static category = "Vector";
7869
- static title = "Scale";
7870
- static description = "Multiplies each element of a vector by a scalar";
7842
+ class ScalarFloorTask extends Task38 {
7843
+ static type = "ScalarFloorTask";
7844
+ static category = "Math";
7845
+ static title = "Floor";
7846
+ static description = "Returns the largest integer less than or equal to a number";
7871
7847
  static inputSchema() {
7872
- return inputSchema31;
7848
+ return inputSchema36;
7873
7849
  }
7874
7850
  static outputSchema() {
7875
- return outputSchema30;
7851
+ return outputSchema35;
7876
7852
  }
7877
7853
  async execute(input2, _context) {
7878
- const { vector, scalar } = input2;
7879
- const values = Array.from(vector, (v) => Number(v) * scalar);
7880
- return { result: createTypedArrayFrom5([vector], values) };
7854
+ return { result: Math.floor(input2.value) };
7881
7855
  }
7882
7856
  }
7883
- Workflow37.prototype.vectorScale = CreateWorkflow36(VectorScaleTask);
7857
+ Workflow41.prototype.scalarFloor = CreateWorkflow40(ScalarFloorTask);
7858
+ // src/task/scalar/ScalarMaxTask.ts
7859
+ import { CreateWorkflow as CreateWorkflow41, Task as Task39, Workflow as Workflow42 } from "@workglow/task-graph";
7860
+ var inputSchema37 = {
7861
+ type: "object",
7862
+ properties: {
7863
+ values: {
7864
+ type: "array",
7865
+ items: { type: "number" },
7866
+ title: "Values",
7867
+ description: "Array of numbers"
7868
+ }
7869
+ },
7870
+ required: ["values"],
7871
+ additionalProperties: false
7872
+ };
7873
+ var outputSchema36 = {
7874
+ type: "object",
7875
+ properties: {
7876
+ result: {
7877
+ type: "number",
7878
+ title: "Result",
7879
+ description: "Maximum value"
7880
+ }
7881
+ },
7882
+ required: ["result"],
7883
+ additionalProperties: false
7884
+ };
7884
7885
 
7885
- // src/common.ts
7886
- import { TaskRegistry } from "@workglow/task-graph";
7887
- var registerCommonTasks = () => {
7888
- const tasks = [
7889
- DebugLogTask,
7890
- DelayTask,
7891
- FetchUrlTask,
7892
- InputTask,
7893
- JavaScriptTask,
7894
- JsonTask,
7895
- LambdaTask,
7896
- MergeTask,
7897
- OutputTask,
7898
- SplitTask,
7899
- ScalarAbsTask,
7900
- ScalarAddTask,
7901
- ScalarCeilTask,
7902
- ScalarDivideTask,
7903
- ScalarFloorTask,
7904
- ScalarMaxTask,
7905
- ScalarMinTask,
7906
- ScalarMultiplyTask,
7907
- ScalarRoundTask,
7908
- ScalarSubtractTask,
7909
- ScalarSumTask,
7910
- ScalarTruncTask,
7911
- VectorSumTask,
7912
- VectorDistanceTask,
7913
- VectorDivideTask,
7914
- VectorDotProductTask,
7915
- VectorMultiplyTask,
7916
- VectorNormalizeTask,
7917
- VectorScaleTask,
7918
- VectorSubtractTask,
7919
- McpToolCallTask,
7920
- McpResourceReadTask,
7921
- McpPromptGetTask,
7922
- McpListTask
7923
- ];
7924
- tasks.map(TaskRegistry.registerTask);
7925
- return tasks;
7886
+ class ScalarMaxTask extends Task39 {
7887
+ static type = "ScalarMaxTask";
7888
+ static category = "Math";
7889
+ static title = "Max";
7890
+ static description = "Returns the largest of the given numbers";
7891
+ static inputSchema() {
7892
+ return inputSchema37;
7893
+ }
7894
+ static outputSchema() {
7895
+ return outputSchema36;
7896
+ }
7897
+ async execute(input2, _context) {
7898
+ return { result: Math.max(...input2.values) };
7899
+ }
7900
+ }
7901
+ Workflow42.prototype.scalarMax = CreateWorkflow41(ScalarMaxTask);
7902
+ // src/task/scalar/ScalarMinTask.ts
7903
+ import { CreateWorkflow as CreateWorkflow42, Task as Task40, Workflow as Workflow43 } from "@workglow/task-graph";
7904
+ var inputSchema38 = {
7905
+ type: "object",
7906
+ properties: {
7907
+ values: {
7908
+ type: "array",
7909
+ items: { type: "number" },
7910
+ title: "Values",
7911
+ description: "Array of numbers"
7912
+ }
7913
+ },
7914
+ required: ["values"],
7915
+ additionalProperties: false
7916
+ };
7917
+ var outputSchema37 = {
7918
+ type: "object",
7919
+ properties: {
7920
+ result: {
7921
+ type: "number",
7922
+ title: "Result",
7923
+ description: "Minimum value"
7924
+ }
7925
+ },
7926
+ required: ["result"],
7927
+ additionalProperties: false
7926
7928
  };
7927
7929
 
7928
- // src/bun.ts
7929
- [FileLoaderTask2].map(TaskRegistry2.registerTask);
7930
+ class ScalarMinTask extends Task40 {
7931
+ static type = "ScalarMinTask";
7932
+ static category = "Math";
7933
+ static title = "Min";
7934
+ static description = "Returns the smallest of the given numbers";
7935
+ static inputSchema() {
7936
+ return inputSchema38;
7937
+ }
7938
+ static outputSchema() {
7939
+ return outputSchema37;
7940
+ }
7941
+ async execute(input2, _context) {
7942
+ return { result: Math.min(...input2.values) };
7943
+ }
7944
+ }
7945
+ Workflow43.prototype.scalarMin = CreateWorkflow42(ScalarMinTask);
7946
+ // src/task/scalar/ScalarRoundTask.ts
7947
+ import { CreateWorkflow as CreateWorkflow43, Task as Task41, Workflow as Workflow44 } from "@workglow/task-graph";
7948
+ var inputSchema39 = {
7949
+ type: "object",
7950
+ properties: {
7951
+ value: {
7952
+ type: "number",
7953
+ title: "Value",
7954
+ description: "Input number"
7955
+ }
7956
+ },
7957
+ required: ["value"],
7958
+ additionalProperties: false
7959
+ };
7960
+ var outputSchema38 = {
7961
+ type: "object",
7962
+ properties: {
7963
+ result: {
7964
+ type: "number",
7965
+ title: "Result",
7966
+ description: "Rounded value"
7967
+ }
7968
+ },
7969
+ required: ["result"],
7970
+ additionalProperties: false
7971
+ };
7972
+
7973
+ class ScalarRoundTask extends Task41 {
7974
+ static type = "ScalarRoundTask";
7975
+ static category = "Math";
7976
+ static title = "Round";
7977
+ static description = "Returns the value of a number rounded to the nearest integer";
7978
+ static inputSchema() {
7979
+ return inputSchema39;
7980
+ }
7981
+ static outputSchema() {
7982
+ return outputSchema38;
7983
+ }
7984
+ async execute(input2, _context) {
7985
+ return { result: Math.round(input2.value) };
7986
+ }
7987
+ }
7988
+ Workflow44.prototype.scalarRound = CreateWorkflow43(ScalarRoundTask);
7989
+ // src/task/scalar/ScalarTruncTask.ts
7990
+ import { CreateWorkflow as CreateWorkflow44, Task as Task42, Workflow as Workflow45 } from "@workglow/task-graph";
7991
+ var inputSchema40 = {
7992
+ type: "object",
7993
+ properties: {
7994
+ value: {
7995
+ type: "number",
7996
+ title: "Value",
7997
+ description: "Input number"
7998
+ }
7999
+ },
8000
+ required: ["value"],
8001
+ additionalProperties: false
8002
+ };
8003
+ var outputSchema39 = {
8004
+ type: "object",
8005
+ properties: {
8006
+ result: {
8007
+ type: "number",
8008
+ title: "Result",
8009
+ description: "Truncated value"
8010
+ }
8011
+ },
8012
+ required: ["result"],
8013
+ additionalProperties: false
8014
+ };
8015
+
8016
+ class ScalarTruncTask extends Task42 {
8017
+ static type = "ScalarTruncTask";
8018
+ static category = "Math";
8019
+ static title = "Truncate";
8020
+ static description = "Returns the integer part of a number by removing fractional digits";
8021
+ static inputSchema() {
8022
+ return inputSchema40;
8023
+ }
8024
+ static outputSchema() {
8025
+ return outputSchema39;
8026
+ }
8027
+ async execute(input2, _context) {
8028
+ return { result: Math.trunc(input2.value) };
8029
+ }
8030
+ }
8031
+ Workflow45.prototype.scalarTrunc = CreateWorkflow44(ScalarTruncTask);
8032
+ // src/task/vector/VectorDistanceTask.ts
8033
+ import { CreateWorkflow as CreateWorkflow45, Task as Task43, Workflow as Workflow46 } from "@workglow/task-graph";
8034
+ import {
8035
+ TypedArraySchema as TypedArraySchema5
8036
+ } from "@workglow/util";
8037
+ var inputSchema41 = {
8038
+ type: "object",
8039
+ properties: {
8040
+ vectors: {
8041
+ type: "array",
8042
+ items: TypedArraySchema5({
8043
+ title: "Vector",
8044
+ description: "Vector for distance computation"
8045
+ }),
8046
+ title: "Vectors",
8047
+ description: "Array of two vectors to compute Euclidean distance"
8048
+ }
8049
+ },
8050
+ required: ["vectors"],
8051
+ additionalProperties: false
8052
+ };
8053
+ var outputSchema40 = {
8054
+ type: "object",
8055
+ properties: {
8056
+ result: {
8057
+ type: "number",
8058
+ title: "Result",
8059
+ description: "Euclidean distance between vectors"
8060
+ }
8061
+ },
8062
+ required: ["result"],
8063
+ additionalProperties: false
8064
+ };
8065
+
8066
+ class VectorDistanceTask extends Task43 {
8067
+ static type = "VectorDistanceTask";
8068
+ static category = "Vector";
8069
+ static title = "Distance";
8070
+ static description = "Returns the Euclidean distance between the first two vectors";
8071
+ static inputSchema() {
8072
+ return inputSchema41;
8073
+ }
8074
+ static outputSchema() {
8075
+ return outputSchema40;
8076
+ }
8077
+ async execute(input2, _context) {
8078
+ const { vectors } = input2;
8079
+ if (vectors.length < 2) {
8080
+ throw new Error("Exactly two vectors are required for distance");
8081
+ }
8082
+ const [a, b] = vectors;
8083
+ if (a.length !== b.length) {
8084
+ throw new Error("Vectors must have the same length");
8085
+ }
8086
+ const diffs = Array.from({ length: a.length }, (_, i) => {
8087
+ const d = Number(a[i]) - Number(b[i]);
8088
+ return d * d;
8089
+ });
8090
+ return { result: Math.sqrt(sumPrecise(diffs)) };
8091
+ }
8092
+ }
8093
+ Workflow46.prototype.vectorDistance = CreateWorkflow45(VectorDistanceTask);
8094
+ // src/task/vector/VectorDotProductTask.ts
8095
+ import { CreateWorkflow as CreateWorkflow46, Task as Task44, Workflow as Workflow47 } from "@workglow/task-graph";
8096
+ import {
8097
+ TypedArraySchema as TypedArraySchema6
8098
+ } from "@workglow/util";
8099
+ var inputSchema42 = {
8100
+ type: "object",
8101
+ properties: {
8102
+ vectors: {
8103
+ type: "array",
8104
+ items: TypedArraySchema6({
8105
+ title: "Vector",
8106
+ description: "Vector for dot product"
8107
+ }),
8108
+ title: "Vectors",
8109
+ description: "Array of two vectors to compute dot product"
8110
+ }
8111
+ },
8112
+ required: ["vectors"],
8113
+ additionalProperties: false
8114
+ };
8115
+ var outputSchema41 = {
8116
+ type: "object",
8117
+ properties: {
8118
+ result: {
8119
+ type: "number",
8120
+ title: "Result",
8121
+ description: "Dot product of the vectors"
8122
+ }
8123
+ },
8124
+ required: ["result"],
8125
+ additionalProperties: false
8126
+ };
8127
+
8128
+ class VectorDotProductTask extends Task44 {
8129
+ static type = "VectorDotProductTask";
8130
+ static category = "Vector";
8131
+ static title = "Dot Product";
8132
+ static description = "Returns the dot (inner) product of the first two vectors";
8133
+ static inputSchema() {
8134
+ return inputSchema42;
8135
+ }
8136
+ static outputSchema() {
8137
+ return outputSchema41;
8138
+ }
8139
+ async execute(input2, _context) {
8140
+ const { vectors } = input2;
8141
+ if (vectors.length < 2) {
8142
+ throw new Error("Exactly two vectors are required for dot product");
8143
+ }
8144
+ const [a, b] = vectors;
8145
+ if (a.length !== b.length) {
8146
+ throw new Error("Vectors must have the same length");
8147
+ }
8148
+ const products = Array.from({ length: a.length }, (_, i) => Number(a[i]) * Number(b[i]));
8149
+ return { result: sumPrecise(products) };
8150
+ }
8151
+ }
8152
+ Workflow47.prototype.vectorDotProduct = CreateWorkflow46(VectorDotProductTask);
8153
+ // src/task/vector/VectorNormalizeTask.ts
8154
+ import { CreateWorkflow as CreateWorkflow47, Task as Task45, Workflow as Workflow48 } from "@workglow/task-graph";
8155
+ import {
8156
+ TypedArraySchema as TypedArraySchema7,
8157
+ normalize
8158
+ } from "@workglow/util";
8159
+ var inputSchema43 = {
8160
+ type: "object",
8161
+ properties: {
8162
+ vector: TypedArraySchema7({
8163
+ title: "Vector",
8164
+ description: "Input vector to normalize"
8165
+ })
8166
+ },
8167
+ required: ["vector"],
8168
+ additionalProperties: false
8169
+ };
8170
+ var outputSchema42 = {
8171
+ type: "object",
8172
+ properties: {
8173
+ result: TypedArraySchema7({
8174
+ title: "Result",
8175
+ description: "L2-normalized vector"
8176
+ })
8177
+ },
8178
+ required: ["result"],
8179
+ additionalProperties: false
8180
+ };
8181
+
8182
+ class VectorNormalizeTask extends Task45 {
8183
+ static type = "VectorNormalizeTask";
8184
+ static category = "Vector";
8185
+ static title = "Normalize";
8186
+ static description = "Returns the L2-normalized (unit length) vector";
8187
+ static inputSchema() {
8188
+ return inputSchema43;
8189
+ }
8190
+ static outputSchema() {
8191
+ return outputSchema42;
8192
+ }
8193
+ async execute(input2, _context) {
8194
+ return { result: normalize(input2.vector) };
8195
+ }
8196
+ }
8197
+ Workflow48.prototype.vectorNormalize = CreateWorkflow47(VectorNormalizeTask);
8198
+ // src/task/vector/VectorScaleTask.ts
8199
+ import { CreateWorkflow as CreateWorkflow48, Task as Task46, Workflow as Workflow49 } from "@workglow/task-graph";
8200
+ import {
8201
+ createTypedArrayFrom as createTypedArrayFrom5,
8202
+ TypedArraySchema as TypedArraySchema8
8203
+ } from "@workglow/util";
8204
+ var inputSchema44 = {
8205
+ type: "object",
8206
+ properties: {
8207
+ vector: TypedArraySchema8({
8208
+ title: "Vector",
8209
+ description: "Input vector"
8210
+ }),
8211
+ scalar: {
8212
+ type: "number",
8213
+ title: "Scalar",
8214
+ description: "Scalar multiplier"
8215
+ }
8216
+ },
8217
+ required: ["vector", "scalar"],
8218
+ additionalProperties: false
8219
+ };
8220
+ var outputSchema43 = {
8221
+ type: "object",
8222
+ properties: {
8223
+ result: TypedArraySchema8({
8224
+ title: "Result",
8225
+ description: "Scaled vector"
8226
+ })
8227
+ },
8228
+ required: ["result"],
8229
+ additionalProperties: false
8230
+ };
8231
+
8232
+ class VectorScaleTask extends Task46 {
8233
+ static type = "VectorScaleTask";
8234
+ static category = "Vector";
8235
+ static title = "Scale";
8236
+ static description = "Multiplies each element of a vector by a scalar";
8237
+ static inputSchema() {
8238
+ return inputSchema44;
8239
+ }
8240
+ static outputSchema() {
8241
+ return outputSchema43;
8242
+ }
8243
+ async execute(input2, _context) {
8244
+ const { vector, scalar } = input2;
8245
+ const values = Array.from(vector, (v) => Number(v) * scalar);
8246
+ return { result: createTypedArrayFrom5([vector], values) };
8247
+ }
8248
+ }
8249
+ Workflow49.prototype.vectorScale = CreateWorkflow48(VectorScaleTask);
8250
+
8251
+ // src/common.ts
8252
+ import { TaskRegistry } from "@workglow/task-graph";
8253
+ var registerCommonTasks = () => {
8254
+ const tasks = [
8255
+ DebugLogTask,
8256
+ DelayTask,
8257
+ FetchUrlTask,
8258
+ InputTask,
8259
+ JavaScriptTask,
8260
+ JsonTask,
8261
+ LambdaTask,
8262
+ MergeTask,
8263
+ OutputTask,
8264
+ SplitTask,
8265
+ ScalarAbsTask,
8266
+ ScalarAddTask,
8267
+ ScalarCeilTask,
8268
+ ScalarDivideTask,
8269
+ ScalarFloorTask,
8270
+ ScalarMaxTask,
8271
+ ScalarMinTask,
8272
+ ScalarMultiplyTask,
8273
+ ScalarRoundTask,
8274
+ ScalarSubtractTask,
8275
+ ScalarSumTask,
8276
+ ScalarTruncTask,
8277
+ VectorSumTask,
8278
+ VectorDistanceTask,
8279
+ VectorDivideTask,
8280
+ VectorDotProductTask,
8281
+ VectorMultiplyTask,
8282
+ VectorNormalizeTask,
8283
+ VectorScaleTask,
8284
+ VectorSubtractTask,
8285
+ McpToolCallTask,
8286
+ McpResourceReadTask,
8287
+ McpPromptGetTask,
8288
+ McpListTask,
8289
+ StringConcatTask,
8290
+ StringIncludesTask,
8291
+ StringJoinTask,
8292
+ StringLengthTask,
8293
+ StringLowerCaseTask,
8294
+ StringReplaceTask,
8295
+ StringSliceTask,
8296
+ StringTemplateTask,
8297
+ StringTrimTask,
8298
+ StringUpperCaseTask,
8299
+ JsonPathTask,
8300
+ TemplateTask,
8301
+ DateFormatTask,
8302
+ RegexTask
8303
+ ];
8304
+ tasks.map(TaskRegistry.registerTask);
8305
+ return tasks;
8306
+ };
8307
+
8308
+ // src/task/FileLoaderTask.server.ts
8309
+ import {
8310
+ CreateWorkflow as CreateWorkflow50,
8311
+ TaskAbortedError as TaskAbortedError3,
8312
+ Workflow as Workflow51
8313
+ } from "@workglow/task-graph";
8314
+ import { readFile } from "fs/promises";
8315
+
8316
+ // src/task/FileLoaderTask.ts
8317
+ import {
8318
+ CreateWorkflow as CreateWorkflow49,
8319
+ Task as Task47,
8320
+ TaskAbortedError as TaskAbortedError2,
8321
+ Workflow as Workflow50
8322
+ } from "@workglow/task-graph";
8323
+ import Papa from "papaparse";
8324
+ var inputSchema45 = {
8325
+ type: "object",
8326
+ properties: {
8327
+ url: {
8328
+ type: "string",
8329
+ title: "URL",
8330
+ description: "URL to load document from (http://, https://)",
8331
+ format: "uri"
8332
+ },
8333
+ format: {
8334
+ type: "string",
8335
+ enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
8336
+ title: "Format",
8337
+ description: "File format (auto-detected from URL if 'auto')",
8338
+ default: "auto"
8339
+ }
8340
+ },
8341
+ required: ["url"],
8342
+ additionalProperties: false
8343
+ };
8344
+ var outputSchema44 = {
8345
+ type: "object",
8346
+ properties: {
8347
+ text: {
8348
+ type: "string",
8349
+ title: "Text",
8350
+ description: "Text content (for text, markdown, html formats)"
8351
+ },
8352
+ json: {
8353
+ title: "JSON",
8354
+ description: "Parsed JSON object or array"
8355
+ },
8356
+ csv: {
8357
+ type: "array",
8358
+ title: "CSV",
8359
+ description: "Parsed CSV data as array of objects"
8360
+ },
8361
+ image: {
8362
+ type: "string",
8363
+ title: "Image",
8364
+ description: "Base64 data URL for image files",
8365
+ format: "image:data-uri"
8366
+ },
8367
+ pdf: {
8368
+ type: "string",
8369
+ title: "PDF",
8370
+ description: "Base64 data URL for PDF files"
8371
+ },
8372
+ frontmatter: {
8373
+ type: "object",
8374
+ title: "Frontmatter",
8375
+ description: "Parsed YAML frontmatter from markdown/MDX files"
8376
+ },
8377
+ metadata: {
8378
+ type: "object",
8379
+ properties: {
8380
+ url: { type: "string" },
8381
+ format: { type: "string" },
8382
+ size: { type: "number" },
8383
+ title: { type: "string" },
8384
+ mimeType: { type: "string" }
8385
+ },
8386
+ additionalProperties: false,
8387
+ title: "Metadata",
8388
+ description: "File metadata"
8389
+ }
8390
+ },
8391
+ required: ["metadata"],
8392
+ additionalProperties: false
8393
+ };
8394
+
8395
+ class FileLoaderTask extends Task47 {
8396
+ static type = "FileLoaderTask";
8397
+ static category = "Document";
8398
+ static title = "File Loader";
8399
+ static description = "Load documents from URLs (http://, https://)";
8400
+ static cacheable = true;
8401
+ static inputSchema() {
8402
+ return inputSchema45;
8403
+ }
8404
+ static outputSchema() {
8405
+ return outputSchema44;
8406
+ }
8407
+ async execute(input2, context) {
8408
+ const { url, format = "auto" } = input2;
8409
+ if (context.signal.aborted) {
8410
+ throw new TaskAbortedError2("Task aborted");
8411
+ }
8412
+ await context.updateProgress(0, "Detecting file format");
8413
+ const detectedFormat = this.detectFormat(url, format);
8414
+ const responseType = this.detectResponseType(detectedFormat);
8415
+ if (context.signal.aborted) {
8416
+ throw new TaskAbortedError2("Task aborted");
8417
+ }
8418
+ await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
8419
+ const fetchTask = context.own(new FetchUrlTask({
8420
+ url,
8421
+ response_type: responseType,
8422
+ queue: false
8423
+ }));
8424
+ const response = await fetchTask.run();
8425
+ if (context.signal.aborted) {
8426
+ throw new TaskAbortedError2("Task aborted");
8427
+ }
8428
+ await context.updateProgress(60, "Parsing file content");
8429
+ const title = url.split("/").pop() || url;
8430
+ const { text, json: json2, csv, image, pdf, frontmatter, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
8431
+ if (context.signal.aborted) {
8432
+ throw new TaskAbortedError2("Task aborted");
8433
+ }
8434
+ await context.updateProgress(100, "File loaded successfully");
8435
+ return {
8436
+ text,
8437
+ json: json2,
8438
+ csv,
8439
+ image,
8440
+ pdf,
8441
+ frontmatter,
8442
+ metadata: {
8443
+ url,
8444
+ format: detectedFormat,
8445
+ size,
8446
+ title,
8447
+ mimeType
8448
+ }
8449
+ };
8450
+ }
8451
+ parseJsonContent(content) {
8452
+ return JSON.parse(content);
8453
+ }
8454
+ parseCsvContent(content) {
8455
+ try {
8456
+ const result = Papa.parse(content, {
8457
+ header: true,
8458
+ skipEmptyLines: true,
8459
+ transformHeader: (header) => header.trim()
8460
+ });
8461
+ return result.data;
8462
+ } catch (error) {
8463
+ throw new Error(`Failed to parse CSV: ${error}`);
8464
+ }
8465
+ }
8466
+ parseFrontmatter(content) {
8467
+ const trimmed = content.replace(/^\uFEFF/, "");
8468
+ if (!trimmed.startsWith(`---
8469
+ `) && !trimmed.startsWith(`---\r
8470
+ `)) {
8471
+ return { frontmatter: undefined, body: content };
8472
+ }
8473
+ const firstDelimEnd = trimmed.indexOf(`
8474
+ `) + 1;
8475
+ const closingIdx = trimmed.indexOf(`
8476
+ ---`, firstDelimEnd);
8477
+ if (closingIdx === -1) {
8478
+ return { frontmatter: undefined, body: content };
8479
+ }
8480
+ const yamlBlock = trimmed.slice(firstDelimEnd, closingIdx);
8481
+ const afterClosing = closingIdx + 4;
8482
+ let bodyStart = afterClosing;
8483
+ if (trimmed[bodyStart] === "\r")
8484
+ bodyStart++;
8485
+ if (trimmed[bodyStart] === `
8486
+ `)
8487
+ bodyStart++;
8488
+ const body = trimmed.slice(bodyStart).replace(/^\r?\n/, "");
8489
+ const frontmatter = this.parseSimpleYaml(yamlBlock);
8490
+ return { frontmatter, body };
8491
+ }
8492
+ parseSimpleYaml(yaml) {
8493
+ const result = {};
8494
+ const lines = yaml.split(/\r?\n/);
8495
+ let i = 0;
8496
+ while (i < lines.length) {
8497
+ i = this.parseYamlLine(lines, i, result, 0);
8498
+ }
8499
+ return result;
8500
+ }
8501
+ parseYamlLine(lines, index, target, indent) {
8502
+ if (index >= lines.length)
8503
+ return index + 1;
8504
+ const line = lines[index];
8505
+ if (line.trim() === "" || line.trim().startsWith("#")) {
8506
+ return index + 1;
8507
+ }
8508
+ const lineIndent = line.length - line.trimStart().length;
8509
+ if (lineIndent < indent)
8510
+ return index;
8511
+ const match = line.match(/^(\s*)([^:#]+?)\s*:\s*(.*)?$/);
8512
+ if (!match)
8513
+ return index + 1;
8514
+ const key = match[2].trim();
8515
+ const rawValue = (match[3] ?? "").trim();
8516
+ if (rawValue === "" || rawValue === "|" || rawValue === ">") {
8517
+ const nextIndex = index + 1;
8518
+ if (nextIndex < lines.length) {
8519
+ const nextLine = lines[nextIndex];
8520
+ const nextTrimmed = nextLine.trimStart();
8521
+ const nextIndent = nextLine.length - nextTrimmed.length;
8522
+ if (nextIndent > lineIndent && nextTrimmed.startsWith("- ")) {
8523
+ const arr = [];
8524
+ let j = nextIndex;
8525
+ while (j < lines.length) {
8526
+ const arrLine = lines[j];
8527
+ const arrTrimmed = arrLine.trimStart();
8528
+ const arrIndent = arrLine.length - arrTrimmed.length;
8529
+ if (arrTrimmed === "" || arrTrimmed.startsWith("#")) {
8530
+ j++;
8531
+ continue;
8532
+ }
8533
+ if (arrIndent < nextIndent)
8534
+ break;
8535
+ if (arrTrimmed.startsWith("- ")) {
8536
+ arr.push(this.parseYamlValue(arrTrimmed.slice(2).trim()));
8537
+ j++;
8538
+ } else {
8539
+ break;
8540
+ }
8541
+ }
8542
+ target[key] = arr;
8543
+ return j;
8544
+ } else if (nextIndent > lineIndent) {
8545
+ const nested = {};
8546
+ let j = nextIndex;
8547
+ while (j < lines.length) {
8548
+ const nestedLine = lines[j];
8549
+ const nestedTrimmed = nestedLine.trimStart();
8550
+ const nestedIndent = nestedLine.length - nestedTrimmed.length;
8551
+ if (nestedTrimmed === "" || nestedTrimmed.startsWith("#")) {
8552
+ j++;
8553
+ continue;
8554
+ }
8555
+ if (nestedIndent < nextIndent)
8556
+ break;
8557
+ j = this.parseYamlLine(lines, j, nested, nextIndent);
8558
+ }
8559
+ target[key] = nested;
8560
+ return j;
8561
+ }
8562
+ }
8563
+ target[key] = rawValue === "" ? null : rawValue;
8564
+ return index + 1;
8565
+ }
8566
+ target[key] = this.parseYamlValue(rawValue);
8567
+ return index + 1;
8568
+ }
8569
+ parseYamlValue(raw) {
8570
+ if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("'") && raw.endsWith("'")) {
8571
+ return raw.slice(1, -1);
8572
+ }
8573
+ if (raw === "true" || raw === "True" || raw === "TRUE")
8574
+ return true;
8575
+ if (raw === "false" || raw === "False" || raw === "FALSE")
8576
+ return false;
8577
+ if (raw === "null" || raw === "~")
8578
+ return null;
8579
+ if (/^-?\d+(\.\d+)?$/.test(raw))
8580
+ return Number(raw);
8581
+ if (raw.startsWith("[") && raw.endsWith("]")) {
8582
+ return raw.slice(1, -1).split(",").map((item) => this.parseYamlValue(item.trim()));
8583
+ }
8584
+ return raw;
8585
+ }
8586
+ async parseResponse(response, url, detectedFormat) {
8587
+ const responseMimeType = response.metadata?.contentType || "";
8588
+ if (detectedFormat === "json") {
8589
+ if (!response.json) {
8590
+ throw new Error(`Failed to load JSON from ${url}`);
8591
+ }
8592
+ const jsonData = response.json;
8593
+ const content2 = JSON.stringify(jsonData, null, 2);
8594
+ return {
8595
+ text: undefined,
8596
+ json: jsonData,
8597
+ csv: undefined,
8598
+ image: undefined,
8599
+ pdf: undefined,
8600
+ frontmatter: undefined,
8601
+ size: content2.length,
8602
+ mimeType: responseMimeType || "application/json"
8603
+ };
8604
+ }
8605
+ if (detectedFormat === "csv") {
8606
+ const content2 = response.text || "";
8607
+ if (!content2) {
8608
+ throw new Error(`Failed to load CSV from ${url}`);
8609
+ }
8610
+ const csvData = this.parseCsvContent(content2);
8611
+ return {
8612
+ text: undefined,
8613
+ json: undefined,
8614
+ csv: csvData,
8615
+ image: undefined,
8616
+ pdf: undefined,
8617
+ frontmatter: undefined,
8618
+ size: content2.length,
8619
+ mimeType: responseMimeType || "text/csv"
8620
+ };
8621
+ }
8622
+ if (detectedFormat === "image") {
8623
+ if (!response.blob) {
8624
+ throw new Error(`Failed to load image from ${url}`);
8625
+ }
8626
+ const blob = response.blob;
8627
+ const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
8628
+ const imageData = await this.blobToBase64DataURL(blob, mimeType2);
8629
+ return {
8630
+ text: undefined,
8631
+ json: undefined,
8632
+ csv: undefined,
8633
+ image: imageData,
8634
+ pdf: undefined,
8635
+ frontmatter: undefined,
8636
+ size: blob.size,
8637
+ mimeType: mimeType2
8638
+ };
8639
+ }
8640
+ if (detectedFormat === "pdf") {
8641
+ if (!response.blob) {
8642
+ throw new Error(`Failed to load PDF from ${url}`);
8643
+ }
8644
+ const blob = response.blob;
8645
+ const mimeType2 = responseMimeType || "application/pdf";
8646
+ const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
8647
+ return {
8648
+ text: undefined,
8649
+ json: undefined,
8650
+ csv: undefined,
8651
+ image: undefined,
8652
+ pdf: pdfData,
8653
+ frontmatter: undefined,
8654
+ size: blob.size,
8655
+ mimeType: mimeType2
8656
+ };
8657
+ }
8658
+ const content = response.text || "";
8659
+ if (!content) {
8660
+ throw new Error(`Failed to load content from ${url}`);
8661
+ }
8662
+ const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
8663
+ if (detectedFormat === "markdown") {
8664
+ const { frontmatter, body } = this.parseFrontmatter(content);
8665
+ return {
8666
+ text: body,
8667
+ json: undefined,
8668
+ csv: undefined,
8669
+ image: undefined,
8670
+ pdf: undefined,
8671
+ frontmatter,
8672
+ size: content.length,
8673
+ mimeType
8674
+ };
8675
+ }
8676
+ return {
8677
+ text: content,
8678
+ json: undefined,
8679
+ csv: undefined,
8680
+ image: undefined,
8681
+ pdf: undefined,
8682
+ frontmatter: undefined,
8683
+ size: content.length,
8684
+ mimeType
8685
+ };
8686
+ }
8687
+ detectResponseType(detectedFormat) {
8688
+ let responseType = "text";
8689
+ if (detectedFormat === "json") {
8690
+ responseType = "json";
8691
+ } else if (detectedFormat === "image" || detectedFormat === "pdf") {
8692
+ responseType = "blob";
8693
+ } else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
8694
+ responseType = "text";
8695
+ }
8696
+ return responseType;
8697
+ }
8698
+ detectFormat(url, format) {
8699
+ if (format === "auto") {
8700
+ const urlLower = url.toLowerCase();
8701
+ if (urlLower.endsWith(".md") || urlLower.endsWith(".mdx") || urlLower.endsWith(".markdown")) {
8702
+ return "markdown";
8703
+ } else if (urlLower.endsWith(".json")) {
8704
+ return "json";
8705
+ } else if (urlLower.endsWith(".csv")) {
8706
+ return "csv";
8707
+ } else if (urlLower.endsWith(".pdf")) {
8708
+ return "pdf";
8709
+ } else if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/)) {
8710
+ return "image";
8711
+ } else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm")) {
8712
+ return "html";
8713
+ } else {
8714
+ return "text";
8715
+ }
8716
+ }
8717
+ return format;
8718
+ }
8719
+ getImageMimeType(url) {
8720
+ const urlLower = url.toLowerCase();
8721
+ if (urlLower.endsWith(".png"))
8722
+ return "image/png";
8723
+ if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
8724
+ return "image/jpeg";
8725
+ if (urlLower.endsWith(".gif"))
8726
+ return "image/gif";
8727
+ if (urlLower.endsWith(".webp"))
8728
+ return "image/webp";
8729
+ if (urlLower.endsWith(".bmp"))
8730
+ return "image/bmp";
8731
+ if (urlLower.endsWith(".svg"))
8732
+ return "image/svg+xml";
8733
+ if (urlLower.endsWith(".ico"))
8734
+ return "image/x-icon";
8735
+ return "image/jpeg";
8736
+ }
8737
+ async blobToBase64DataURL(blob, mimeType) {
8738
+ if (typeof Buffer !== "undefined") {
8739
+ const arrayBuffer = await blob.arrayBuffer();
8740
+ const buffer = Buffer.from(arrayBuffer);
8741
+ return `data:${mimeType};base64,${buffer.toString("base64")}`;
8742
+ }
8743
+ return new Promise((resolve, reject) => {
8744
+ const reader = new FileReader;
8745
+ reader.onloadend = () => {
8746
+ const result = reader.result;
8747
+ if (result.startsWith("data:;base64,")) {
8748
+ resolve(`data:${mimeType};base64,${result.substring(13)}`);
8749
+ } else {
8750
+ resolve(result);
8751
+ }
8752
+ };
8753
+ reader.onerror = reject;
8754
+ reader.readAsDataURL(blob);
8755
+ });
8756
+ }
8757
+ }
8758
+ Workflow50.prototype.fileLoader = CreateWorkflow49(FileLoaderTask);
8759
+
8760
+ // src/task/FileLoaderTask.server.ts
8761
+ class FileLoaderTask2 extends FileLoaderTask {
8762
+ async execute(input2, context) {
8763
+ let { url, format = "auto" } = input2;
8764
+ if (url.startsWith("http://") || url.startsWith("https://")) {
8765
+ return super.execute(input2, context);
8766
+ }
8767
+ if (context.signal.aborted) {
8768
+ throw new TaskAbortedError3("Task aborted");
8769
+ }
8770
+ await context.updateProgress(0, "Detecting file format");
8771
+ if (url.startsWith("file://")) {
8772
+ url = url.slice(7);
8773
+ }
8774
+ const detectedFormat = this.detectFormat(url, format);
8775
+ const title = url.split("/").pop() || url;
8776
+ if (context.signal.aborted) {
8777
+ throw new TaskAbortedError3("Task aborted");
8778
+ }
8779
+ await context.updateProgress(10, `Reading ${detectedFormat} file from filesystem`);
8780
+ if (detectedFormat === "json") {
8781
+ const fileContent2 = await readFile(url, { encoding: "utf-8" });
8782
+ if (context.signal.aborted) {
8783
+ throw new TaskAbortedError3("Task aborted");
8784
+ }
8785
+ await context.updateProgress(50, "Parsing JSON content");
8786
+ const jsonData = this.parseJsonContent(fileContent2);
8787
+ const content = JSON.stringify(jsonData, null, 2);
8788
+ if (context.signal.aborted) {
8789
+ throw new TaskAbortedError3("Task aborted");
8790
+ }
8791
+ await context.updateProgress(100, "File loaded successfully");
8792
+ return {
8793
+ text: undefined,
8794
+ json: jsonData,
8795
+ csv: undefined,
8796
+ image: undefined,
8797
+ pdf: undefined,
8798
+ frontmatter: undefined,
8799
+ metadata: {
8800
+ url,
8801
+ format: detectedFormat,
8802
+ size: content.length,
8803
+ title,
8804
+ mimeType: "application/json"
8805
+ }
8806
+ };
8807
+ }
8808
+ if (detectedFormat === "csv") {
8809
+ const fileContent2 = await readFile(url, { encoding: "utf-8" });
8810
+ if (!fileContent2) {
8811
+ throw new Error(`Failed to load CSV from ${url}`);
8812
+ }
8813
+ if (context.signal.aborted) {
8814
+ throw new TaskAbortedError3("Task aborted");
8815
+ }
8816
+ await context.updateProgress(50, "Parsing CSV content");
8817
+ const csvData = this.parseCsvContent(fileContent2);
8818
+ if (context.signal.aborted) {
8819
+ throw new TaskAbortedError3("Task aborted");
8820
+ }
8821
+ await context.updateProgress(100, "File loaded successfully");
8822
+ return {
8823
+ text: undefined,
8824
+ json: undefined,
8825
+ csv: csvData,
8826
+ image: undefined,
8827
+ pdf: undefined,
8828
+ frontmatter: undefined,
8829
+ metadata: {
8830
+ url,
8831
+ format: detectedFormat,
8832
+ size: fileContent2.length,
8833
+ title,
8834
+ mimeType: "text/csv"
8835
+ }
8836
+ };
8837
+ }
8838
+ if (detectedFormat === "image") {
8839
+ const fileBuffer = await readFile(url);
8840
+ if (context.signal.aborted) {
8841
+ throw new TaskAbortedError3("Task aborted");
8842
+ }
8843
+ await context.updateProgress(50, "Converting image to base64");
8844
+ const mimeType2 = this.getImageMimeType(url);
8845
+ const blob = new Blob([fileBuffer], { type: mimeType2 });
8846
+ const imageData = await this.blobToBase64DataURL(blob, mimeType2);
8847
+ if (context.signal.aborted) {
8848
+ throw new TaskAbortedError3("Task aborted");
8849
+ }
8850
+ await context.updateProgress(100, "File loaded successfully");
8851
+ return {
8852
+ text: undefined,
8853
+ json: undefined,
8854
+ csv: undefined,
8855
+ image: imageData,
8856
+ pdf: undefined,
8857
+ frontmatter: undefined,
8858
+ metadata: {
8859
+ url,
8860
+ format: detectedFormat,
8861
+ size: fileBuffer.length,
8862
+ title,
8863
+ mimeType: mimeType2
8864
+ }
8865
+ };
8866
+ }
8867
+ if (detectedFormat === "pdf") {
8868
+ const fileBuffer = await readFile(url);
8869
+ if (context.signal.aborted) {
8870
+ throw new TaskAbortedError3("Task aborted");
8871
+ }
8872
+ await context.updateProgress(50, "Converting PDF to base64");
8873
+ const mimeType2 = "application/pdf";
8874
+ const blob = new Blob([fileBuffer], { type: mimeType2 });
8875
+ const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
8876
+ if (context.signal.aborted) {
8877
+ throw new TaskAbortedError3("Task aborted");
8878
+ }
8879
+ await context.updateProgress(100, "File loaded successfully");
8880
+ return {
8881
+ text: undefined,
8882
+ json: undefined,
8883
+ csv: undefined,
8884
+ image: undefined,
8885
+ pdf: pdfData,
8886
+ frontmatter: undefined,
8887
+ metadata: {
8888
+ url,
8889
+ format: detectedFormat,
8890
+ size: fileBuffer.length,
8891
+ title,
8892
+ mimeType: mimeType2
8893
+ }
8894
+ };
8895
+ }
8896
+ const fileContent = await readFile(url, { encoding: "utf-8" });
8897
+ if (!fileContent) {
8898
+ throw new Error(`Failed to load content from ${url}`);
8899
+ }
8900
+ if (context.signal.aborted) {
8901
+ throw new TaskAbortedError3("Task aborted");
8902
+ }
8903
+ await context.updateProgress(50, `Parsing ${detectedFormat} content`);
8904
+ const mimeType = detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain";
8905
+ if (context.signal.aborted) {
8906
+ throw new TaskAbortedError3("Task aborted");
8907
+ }
8908
+ await context.updateProgress(100, "File loaded successfully");
8909
+ if (detectedFormat === "markdown") {
8910
+ const { frontmatter, body } = this.parseFrontmatter(fileContent);
8911
+ return {
8912
+ text: body,
8913
+ json: undefined,
8914
+ csv: undefined,
8915
+ image: undefined,
8916
+ pdf: undefined,
8917
+ frontmatter,
8918
+ metadata: {
8919
+ url,
8920
+ format: detectedFormat,
8921
+ size: fileContent.length,
8922
+ title,
8923
+ mimeType
8924
+ }
8925
+ };
8926
+ }
8927
+ return {
8928
+ text: fileContent,
8929
+ json: undefined,
8930
+ csv: undefined,
8931
+ image: undefined,
8932
+ pdf: undefined,
8933
+ frontmatter: undefined,
8934
+ metadata: {
8935
+ url,
8936
+ format: detectedFormat,
8937
+ size: fileContent.length,
8938
+ title,
8939
+ mimeType
8940
+ }
8941
+ };
8942
+ }
8943
+ }
8944
+ var fileLoader = (input2, config) => {
8945
+ return new FileLoaderTask2({}, config).run(input2);
8946
+ };
8947
+ Workflow51.prototype.fileLoader = CreateWorkflow50(FileLoaderTask2);
8948
+
8949
+ // src/bun.ts
8950
+ var registerCommonTasks2 = () => {
8951
+ const tasks = registerCommonTasks();
8952
+ TaskRegistry2.registerTask(FileLoaderTask2);
8953
+ return [...tasks, FileLoaderTask2];
8954
+ };
7930
8955
  export {
7931
8956
  split,
7932
- registerCommonTasks,
8957
+ registerCommonTasks2 as registerCommonTasks,
7933
8958
  process,
7934
8959
  merge,
7935
8960
  mcpToolCall,
@@ -7953,6 +8978,17 @@ export {
7953
8978
  VectorDivideTask,
7954
8979
  VectorDistanceTask,
7955
8980
  TypeReplicateArray,
8981
+ TemplateTask,
8982
+ StringUpperCaseTask,
8983
+ StringTrimTask,
8984
+ StringTemplateTask,
8985
+ StringSliceTask,
8986
+ StringReplaceTask,
8987
+ StringLowerCaseTask,
8988
+ StringLengthTask,
8989
+ StringJoinTask,
8990
+ StringIncludesTask,
8991
+ StringConcatTask,
7956
8992
  SplitTask,
7957
8993
  ScalarTruncTask,
7958
8994
  ScalarSumTask,
@@ -7966,6 +9002,7 @@ export {
7966
9002
  ScalarCeilTask,
7967
9003
  ScalarAddTask,
7968
9004
  ScalarAbsTask,
9005
+ RegexTask,
7969
9006
  OutputTask,
7970
9007
  MergeTask,
7971
9008
  McpToolCallTask,
@@ -7974,6 +9011,7 @@ export {
7974
9011
  McpListTask,
7975
9012
  LambdaTask,
7976
9013
  JsonTask,
9014
+ JsonPathTask,
7977
9015
  JavaScriptTask,
7978
9016
  InputTask,
7979
9017
  FileLoaderTask2 as FileLoaderTask,
@@ -7981,7 +9019,8 @@ export {
7981
9019
  FetchUrlJob,
7982
9020
  DelayTask,
7983
9021
  DebugLogTask,
9022
+ DateFormatTask,
7984
9023
  ArrayTask
7985
9024
  };
7986
9025
 
7987
- //# debugId=F7898CFF8161BF7464756E2164756E21
9026
+ //# debugId=3ABCF331B228FE6F64756E2164756E21