@workglow/tasks 0.0.101 → 0.0.103

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 (34) hide show
  1. package/dist/browser.js +1693 -1362
  2. package/dist/browser.js.map +17 -17
  3. package/dist/bun.js +1747 -1393
  4. package/dist/bun.js.map +18 -18
  5. package/dist/common.d.ts +1 -2
  6. package/dist/common.d.ts.map +1 -1
  7. package/dist/node.js +1747 -1393
  8. package/dist/node.js.map +18 -18
  9. package/dist/task/DebugLogTask.d.ts +1 -0
  10. package/dist/task/DebugLogTask.d.ts.map +1 -1
  11. package/dist/task/DelayTask.d.ts +2 -1
  12. package/dist/task/DelayTask.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 +66 -1
  19. package/dist/task/JavaScriptTask.d.ts.map +1 -1
  20. package/dist/task/LambdaTask.d.ts +10 -1
  21. package/dist/task/LambdaTask.d.ts.map +1 -1
  22. package/dist/task/OutputTask.d.ts.map +1 -1
  23. package/dist/task/mcp/McpListTask.d.ts +2 -2
  24. package/dist/task/mcp/McpPromptGetTask.d.ts +158 -66
  25. package/dist/task/mcp/McpPromptGetTask.d.ts.map +1 -1
  26. package/dist/task/mcp/McpResourceReadTask.d.ts +155 -47
  27. package/dist/task/mcp/McpResourceReadTask.d.ts.map +1 -1
  28. package/dist/task/mcp/McpToolCallTask.d.ts +156 -323
  29. package/dist/task/mcp/McpToolCallTask.d.ts.map +1 -1
  30. package/package.json +9 -9
  31. package/dist/task/scalar/scalar.test.d.ts +0 -7
  32. package/dist/task/scalar/scalar.test.d.ts.map +0 -1
  33. package/dist/task/vector/vector.test.d.ts +0 -7
  34. package/dist/task/vector/vector.test.d.ts.map +0 -1
package/dist/browser.js CHANGED
@@ -9,642 +9,176 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  // src/browser.ts
10
10
  import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
11
11
 
12
- // src/task/FileLoaderTask.ts
13
- import {
14
- CreateWorkflow as CreateWorkflow2,
15
- Task,
16
- TaskAbortedError,
17
- Workflow as Workflow2
18
- } from "@workglow/task-graph";
19
- import Papa from "papaparse";
12
+ // src/task/adaptive.ts
13
+ import { CreateAdaptiveWorkflow, Workflow as Workflow10 } from "@workglow/task-graph";
20
14
 
21
- // src/task/FetchUrlTask.ts
22
- import {
23
- AbortSignalJobError,
24
- Job,
25
- PermanentJobError,
26
- RetryableJobError
27
- } from "@workglow/job-queue";
28
- import {
29
- CreateWorkflow,
30
- JobQueueTask,
31
- TaskConfigurationError,
32
- TaskInvalidInputError,
33
- Workflow
34
- } from "@workglow/task-graph";
15
+ // src/task/scalar/ScalarAddTask.ts
16
+ import { CreateWorkflow, Task, Workflow } from "@workglow/task-graph";
17
+
18
+ // src/task/scalar/sumPrecise.ts
19
+ function kahanSum(values) {
20
+ let sum = 0;
21
+ let compensation = 0;
22
+ for (const value of values) {
23
+ const y = value - compensation;
24
+ const t = sum + y;
25
+ compensation = t - sum - y;
26
+ sum = t;
27
+ }
28
+ return sum;
29
+ }
30
+ var nativeSumPrecise = typeof Math.sumPrecise === "function" ? Math.sumPrecise : undefined;
31
+ var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
32
+
33
+ // src/task/scalar/ScalarAddTask.ts
35
34
  var inputSchema = {
36
35
  type: "object",
37
36
  properties: {
38
- url: {
39
- type: "string",
40
- title: "URL",
41
- description: "The URL to fetch from",
42
- format: "uri"
43
- },
44
- method: {
45
- enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
46
- title: "Method",
47
- description: "The HTTP method to use",
48
- default: "GET"
49
- },
50
- headers: {
51
- type: "object",
52
- additionalProperties: {
53
- type: "string"
54
- },
55
- title: "Headers",
56
- description: "The headers to send with the request"
57
- },
58
- body: {
59
- type: "string",
60
- title: "Body",
61
- description: "The body of the request"
62
- },
63
- response_type: {
64
- anyOf: [{ type: "null" }, { enum: ["json", "text", "blob", "arraybuffer"] }],
65
- title: "Response Type",
66
- description: "The forced type of response to return. If null, the response type is inferred from the Content-Type header.",
67
- default: null
68
- },
69
- timeout: {
37
+ a: {
70
38
  type: "number",
71
- title: "Timeout",
72
- description: "Request timeout in milliseconds"
39
+ title: "A",
40
+ description: "First number"
73
41
  },
74
- queue: {
75
- oneOf: [{ type: "boolean" }, { type: "string" }],
76
- description: "Queue handling: false=run inline, true=use default, string=explicit queue name",
77
- default: true,
78
- "x-ui-hidden": true
42
+ b: {
43
+ type: "number",
44
+ title: "B",
45
+ description: "Second number"
79
46
  }
80
47
  },
81
- required: ["url"],
48
+ required: ["a", "b"],
82
49
  additionalProperties: false
83
50
  };
84
51
  var outputSchema = {
85
52
  type: "object",
86
53
  properties: {
87
- json: {
88
- title: "JSON",
89
- description: "The JSON response"
90
- },
91
- text: {
92
- type: "string",
93
- title: "Text",
94
- description: "The text response"
95
- },
96
- blob: {
97
- title: "Blob",
98
- description: "The blob response"
99
- },
100
- arraybuffer: {
101
- title: "ArrayBuffer",
102
- description: "The arraybuffer response"
103
- },
104
- metadata: {
105
- type: "object",
106
- properties: {
107
- contentType: { type: "string" },
108
- headers: { type: "object", additionalProperties: { type: "string" } }
109
- },
110
- additionalProperties: false,
111
- title: "Response Metadata",
112
- description: "HTTP response metadata including content type and headers"
54
+ result: {
55
+ type: "number",
56
+ title: "Result",
57
+ description: "Sum of a and b"
113
58
  }
114
59
  },
60
+ required: ["result"],
115
61
  additionalProperties: false
116
62
  };
117
- async function fetchWithProgress(url, options = {}, onProgress) {
118
- if (!options.signal) {
119
- throw new TaskConfigurationError("An AbortSignal must be provided.");
120
- }
121
- const response = await globalThis.fetch(url, options);
122
- if (!response.body) {
123
- throw new Error("ReadableStream not supported in this environment.");
124
- }
125
- const contentLength = response.headers.get("Content-Length");
126
- const totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
127
- let receivedBytes = 0;
128
- const reader = response.body.getReader();
129
- const stream = new ReadableStream({
130
- start(controller) {
131
- async function push() {
132
- try {
133
- while (true) {
134
- if (options.signal?.aborted) {
135
- controller.error(new AbortSignalJobError("Fetch aborted"));
136
- reader.cancel();
137
- return;
138
- }
139
- const { done, value } = await reader.read();
140
- if (done) {
141
- controller.close();
142
- break;
143
- }
144
- controller.enqueue(value);
145
- receivedBytes += value.length;
146
- if (onProgress && totalBytes) {
147
- await onProgress(receivedBytes / totalBytes * 100);
148
- }
149
- }
150
- } catch (error) {
151
- controller.error(error);
152
- }
153
- }
154
- push();
155
- },
156
- cancel() {
157
- reader.cancel();
158
- }
159
- });
160
- return new Response(stream, {
161
- headers: response.headers,
162
- status: response.status,
163
- statusText: response.statusText
164
- });
165
- }
166
-
167
- class FetchUrlJob extends Job {
168
- constructor(config = { input: {} }) {
169
- super(config);
170
- }
171
- static type = "FetchUrlJob";
172
- async execute(input, context) {
173
- const response = await fetchWithProgress(input.url, {
174
- method: input.method,
175
- headers: input.headers,
176
- body: input.body,
177
- signal: context.signal
178
- }, async (progress) => await context.updateProgress(progress));
179
- if (response.ok) {
180
- const contentType = response.headers.get("content-type") ?? "";
181
- const headers = {};
182
- response.headers.forEach((value, key) => {
183
- headers[key] = value;
184
- });
185
- const metadata = {
186
- contentType,
187
- headers
188
- };
189
- let responseType = input.response_type;
190
- if (!responseType) {
191
- if (contentType.includes("application/json")) {
192
- responseType = "json";
193
- } else if (contentType.includes("text/")) {
194
- responseType = "text";
195
- } else if (contentType.includes("application/octet-stream")) {
196
- responseType = "arraybuffer";
197
- } else if (contentType.includes("application/pdf") || contentType.includes("image/") || contentType.includes("application/zip")) {
198
- responseType = "blob";
199
- } else {
200
- responseType = "json";
201
- }
202
- input.response_type = responseType;
203
- }
204
- if (responseType === "json") {
205
- return { json: await response.json(), metadata };
206
- } else if (responseType === "text") {
207
- return { text: await response.text(), metadata };
208
- } else if (responseType === "blob") {
209
- return { blob: await response.blob(), metadata };
210
- } else if (responseType === "arraybuffer") {
211
- return { arraybuffer: await response.arrayBuffer(), metadata };
212
- }
213
- throw new TaskInvalidInputError(`Invalid response type: ${responseType}`);
214
- } else {
215
- if (response.status === 429 || response.status === 503 || response.headers.get("Retry-After")) {
216
- let retryDate;
217
- const retryAfterStr = response.headers.get("Retry-After");
218
- if (retryAfterStr) {
219
- const parsedDate = new Date(retryAfterStr);
220
- if (!isNaN(parsedDate.getTime()) && parsedDate > new Date) {
221
- retryDate = parsedDate;
222
- } else {
223
- const retryAfterSeconds = parseInt(retryAfterStr) * 1000;
224
- if (!isNaN(retryAfterSeconds)) {
225
- retryDate = new Date(Date.now() + retryAfterSeconds);
226
- }
227
- }
228
- }
229
- throw new RetryableJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`, retryDate);
230
- } else {
231
- throw new PermanentJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`);
232
- }
233
- }
234
- }
235
- }
236
63
 
237
- class FetchUrlTask extends JobQueueTask {
238
- static type = "FetchUrlTask";
239
- static category = "Input";
240
- static title = "Fetch";
241
- static description = "Fetches data from a URL with progress tracking and automatic retry handling";
242
- static hasDynamicSchemas = true;
64
+ class ScalarAddTask extends Task {
65
+ static type = "ScalarAddTask";
66
+ static category = "Math";
67
+ static title = "Add";
68
+ static description = "Returns the sum of two numbers";
243
69
  static inputSchema() {
244
70
  return inputSchema;
245
71
  }
246
72
  static outputSchema() {
247
73
  return outputSchema;
248
74
  }
249
- outputSchema() {
250
- const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
251
- if (responseType === null || responseType === undefined) {
252
- return this.constructor.outputSchema();
253
- }
254
- const staticSchema = this.constructor.outputSchema();
255
- if (typeof staticSchema === "boolean") {
256
- return staticSchema;
257
- }
258
- if (!staticSchema.properties) {
259
- return staticSchema;
260
- }
261
- const properties = {};
262
- if (responseType === "json" && staticSchema.properties.json) {
263
- properties.json = staticSchema.properties.json;
264
- } else if (responseType === "text" && staticSchema.properties.text) {
265
- properties.text = staticSchema.properties.text;
266
- } else if (responseType === "blob" && staticSchema.properties.blob) {
267
- properties.blob = staticSchema.properties.blob;
268
- } else if (responseType === "arraybuffer" && staticSchema.properties.arraybuffer) {
269
- properties.arraybuffer = staticSchema.properties.arraybuffer;
270
- }
271
- if (staticSchema.properties.metadata) {
272
- properties.metadata = staticSchema.properties.metadata;
273
- }
274
- if (Object.keys(properties).length === 0) {
275
- return staticSchema;
276
- }
277
- return {
278
- type: "object",
279
- properties,
280
- additionalProperties: false
281
- };
282
- }
283
- constructor(input = {}, config = {}) {
284
- config.queue = input?.queue ?? config.queue;
285
- if (config.queue === undefined) {
286
- config.queue = false;
287
- }
288
- super(input, config);
289
- this.jobClass = FetchUrlJob;
290
- }
291
- setInput(input) {
292
- if (!("response_type" in input)) {
293
- super.setInput(input);
294
- return;
295
- }
296
- const getCurrentResponseType = () => {
297
- return this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
298
- };
299
- const previousResponseType = getCurrentResponseType();
300
- super.setInput(input);
301
- const newResponseType = getCurrentResponseType();
302
- if (previousResponseType !== newResponseType) {
303
- this.emitSchemaChange();
304
- }
305
- }
306
- async getDefaultQueueName(input) {
307
- if (!input.url) {
308
- return `fetch:${this.type}`;
309
- }
310
- try {
311
- const hostname = new URL(input.url).hostname.toLowerCase();
312
- const parts = hostname.split(".").filter(Boolean);
313
- if (parts.length === 0) {
314
- return `fetch:${this.type}`;
315
- }
316
- const domain = parts.length <= 2 ? parts.join(".") : parts.slice(-2).join(".");
317
- return `fetch:${domain}`;
318
- } catch {
319
- return `fetch:${this.type}`;
320
- }
75
+ async execute(input, _context) {
76
+ return { result: sumPrecise([input.a, input.b]) };
321
77
  }
322
78
  }
323
- var fetchUrl = async (input, config = {}) => {
324
- const result = await new FetchUrlTask({}, config).run(input);
325
- return result;
326
- };
327
- Workflow.prototype.fetch = CreateWorkflow(FetchUrlTask);
79
+ Workflow.prototype.scalarAdd = CreateWorkflow(ScalarAddTask);
328
80
 
329
- // src/task/FileLoaderTask.ts
81
+ // src/task/scalar/ScalarDivideTask.ts
82
+ import { CreateWorkflow as CreateWorkflow2, Task as Task2, Workflow as Workflow2 } from "@workglow/task-graph";
330
83
  var inputSchema2 = {
331
84
  type: "object",
332
85
  properties: {
333
- url: {
334
- type: "string",
335
- title: "URL",
336
- description: "URL to load document from (http://, https://)",
337
- format: "uri"
86
+ a: {
87
+ type: "number",
88
+ title: "A",
89
+ description: "Numerator"
338
90
  },
339
- format: {
340
- type: "string",
341
- enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
342
- title: "Format",
343
- description: "File format (auto-detected from URL if 'auto')",
344
- default: "auto"
91
+ b: {
92
+ type: "number",
93
+ title: "B",
94
+ description: "Denominator"
345
95
  }
346
96
  },
347
- required: ["url"],
97
+ required: ["a", "b"],
348
98
  additionalProperties: false
349
99
  };
350
100
  var outputSchema2 = {
351
101
  type: "object",
352
102
  properties: {
353
- text: {
354
- type: "string",
355
- title: "Text",
356
- description: "Text content (for text, markdown, html formats)"
357
- },
358
- json: {
359
- title: "JSON",
360
- description: "Parsed JSON object or array"
361
- },
362
- csv: {
363
- type: "array",
364
- title: "CSV",
365
- description: "Parsed CSV data as array of objects"
366
- },
367
- image: {
368
- type: "string",
369
- title: "Image",
370
- description: "Base64 data URL for image files",
371
- format: "image:data-uri"
372
- },
373
- pdf: {
374
- type: "string",
375
- title: "PDF",
376
- description: "Base64 data URL for PDF files"
377
- },
378
- metadata: {
379
- type: "object",
380
- properties: {
381
- url: { type: "string" },
382
- format: { type: "string" },
383
- size: { type: "number" },
384
- title: { type: "string" },
385
- mimeType: { type: "string" }
386
- },
387
- additionalProperties: false,
388
- title: "Metadata",
389
- description: "File metadata"
103
+ result: {
104
+ type: "number",
105
+ title: "Result",
106
+ description: "Quotient (a / b)"
390
107
  }
391
108
  },
392
- required: ["metadata"],
109
+ required: ["result"],
393
110
  additionalProperties: false
394
111
  };
395
112
 
396
- class FileLoaderTask extends Task {
397
- static type = "FileLoaderTask";
398
- static category = "Document";
399
- static title = "File Loader";
400
- static description = "Load documents from URLs (http://, https://)";
401
- static cacheable = true;
113
+ class ScalarDivideTask extends Task2 {
114
+ static type = "ScalarDivideTask";
115
+ static category = "Math";
116
+ static title = "Divide";
117
+ static description = "Returns the quotient of two numbers (a / b)";
402
118
  static inputSchema() {
403
119
  return inputSchema2;
404
120
  }
405
121
  static outputSchema() {
406
122
  return outputSchema2;
407
123
  }
408
- async execute(input, context) {
409
- const { url, format = "auto" } = input;
410
- if (context.signal.aborted) {
411
- throw new TaskAbortedError("Task aborted");
412
- }
413
- await context.updateProgress(0, "Detecting file format");
414
- const detectedFormat = this.detectFormat(url, format);
415
- const responseType = this.detectResponseType(detectedFormat);
416
- if (context.signal.aborted) {
417
- throw new TaskAbortedError("Task aborted");
418
- }
419
- await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
420
- const fetchTask = context.own(new FetchUrlTask({
421
- url,
422
- response_type: responseType,
423
- queue: false
424
- }));
425
- const response = await fetchTask.run();
426
- if (context.signal.aborted) {
427
- throw new TaskAbortedError("Task aborted");
124
+ async execute(input, _context) {
125
+ return { result: input.a / input.b };
126
+ }
127
+ }
128
+ Workflow2.prototype.scalarDivide = CreateWorkflow2(ScalarDivideTask);
129
+
130
+ // src/task/scalar/ScalarMultiplyTask.ts
131
+ import { CreateWorkflow as CreateWorkflow3, Task as Task3, Workflow as Workflow3 } from "@workglow/task-graph";
132
+ var inputSchema3 = {
133
+ type: "object",
134
+ properties: {
135
+ a: {
136
+ type: "number",
137
+ title: "A",
138
+ description: "First number"
139
+ },
140
+ b: {
141
+ type: "number",
142
+ title: "B",
143
+ description: "Second number"
428
144
  }
429
- await context.updateProgress(60, "Parsing file content");
430
- const title = url.split("/").pop() || url;
431
- const { text, json, csv, image, pdf, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
432
- if (context.signal.aborted) {
433
- throw new TaskAbortedError("Task aborted");
145
+ },
146
+ required: ["a", "b"],
147
+ additionalProperties: false
148
+ };
149
+ var outputSchema3 = {
150
+ type: "object",
151
+ properties: {
152
+ result: {
153
+ type: "number",
154
+ title: "Result",
155
+ description: "Product of a and b"
434
156
  }
435
- await context.updateProgress(100, "File loaded successfully");
436
- return {
437
- text,
438
- json,
439
- csv,
440
- image,
441
- pdf,
442
- metadata: {
443
- url,
444
- format: detectedFormat,
445
- size,
446
- title,
447
- mimeType
448
- }
449
- };
157
+ },
158
+ required: ["result"],
159
+ additionalProperties: false
160
+ };
161
+
162
+ class ScalarMultiplyTask extends Task3 {
163
+ static type = "ScalarMultiplyTask";
164
+ static category = "Math";
165
+ static title = "Multiply";
166
+ static description = "Returns the product of two numbers";
167
+ static inputSchema() {
168
+ return inputSchema3;
450
169
  }
451
- parseJsonContent(content) {
452
- return JSON.parse(content);
170
+ static outputSchema() {
171
+ return outputSchema3;
453
172
  }
454
- parseCsvContent(content) {
455
- try {
456
- const result = Papa.parse(content, {
457
- header: true,
458
- skipEmptyLines: true,
459
- transformHeader: (header) => header.trim()
460
- });
461
- return result.data;
462
- } catch (error) {
463
- throw new Error(`Failed to parse CSV: ${error}`);
464
- }
173
+ async execute(input, _context) {
174
+ return { result: input.a * input.b };
465
175
  }
466
- async parseResponse(response, url, detectedFormat) {
467
- const responseMimeType = response.metadata?.contentType || "";
468
- if (detectedFormat === "json") {
469
- if (!response.json) {
470
- throw new Error(`Failed to load JSON from ${url}`);
471
- }
472
- const jsonData = response.json;
473
- const content2 = JSON.stringify(jsonData, null, 2);
474
- return {
475
- text: undefined,
476
- json: jsonData,
477
- csv: undefined,
478
- image: undefined,
479
- pdf: undefined,
480
- size: content2.length,
481
- mimeType: responseMimeType || "application/json"
482
- };
483
- }
484
- if (detectedFormat === "csv") {
485
- const content2 = response.text || "";
486
- if (!content2) {
487
- throw new Error(`Failed to load CSV from ${url}`);
488
- }
489
- const csvData = this.parseCsvContent(content2);
490
- return {
491
- text: undefined,
492
- json: undefined,
493
- csv: csvData,
494
- image: undefined,
495
- pdf: undefined,
496
- size: content2.length,
497
- mimeType: responseMimeType || "text/csv"
498
- };
499
- }
500
- if (detectedFormat === "image") {
501
- if (!response.blob) {
502
- throw new Error(`Failed to load image from ${url}`);
503
- }
504
- const blob = response.blob;
505
- const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
506
- const imageData = await this.blobToBase64DataURL(blob, mimeType2);
507
- return {
508
- text: undefined,
509
- json: undefined,
510
- csv: undefined,
511
- image: imageData,
512
- pdf: undefined,
513
- size: blob.size,
514
- mimeType: mimeType2
515
- };
516
- }
517
- if (detectedFormat === "pdf") {
518
- if (!response.blob) {
519
- throw new Error(`Failed to load PDF from ${url}`);
520
- }
521
- const blob = response.blob;
522
- const mimeType2 = responseMimeType || "application/pdf";
523
- const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
524
- return {
525
- text: undefined,
526
- json: undefined,
527
- csv: undefined,
528
- image: undefined,
529
- pdf: pdfData,
530
- size: blob.size,
531
- mimeType: mimeType2
532
- };
533
- }
534
- const content = response.text || "";
535
- if (!content) {
536
- throw new Error(`Failed to load content from ${url}`);
537
- }
538
- const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
539
- return {
540
- text: content,
541
- json: undefined,
542
- csv: undefined,
543
- image: undefined,
544
- pdf: undefined,
545
- size: content.length,
546
- mimeType
547
- };
548
- }
549
- detectResponseType(detectedFormat) {
550
- let responseType = "text";
551
- if (detectedFormat === "json") {
552
- responseType = "json";
553
- } else if (detectedFormat === "image" || detectedFormat === "pdf") {
554
- responseType = "blob";
555
- } else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
556
- responseType = "text";
557
- }
558
- return responseType;
559
- }
560
- detectFormat(url, format) {
561
- if (format === "auto") {
562
- const urlLower = url.toLowerCase();
563
- if (urlLower.endsWith(".md") || urlLower.endsWith(".markdown")) {
564
- return "markdown";
565
- } else if (urlLower.endsWith(".json")) {
566
- return "json";
567
- } else if (urlLower.endsWith(".csv")) {
568
- return "csv";
569
- } else if (urlLower.endsWith(".pdf")) {
570
- return "pdf";
571
- } else if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/)) {
572
- return "image";
573
- } else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm")) {
574
- return "html";
575
- } else {
576
- return "text";
577
- }
578
- }
579
- return format;
580
- }
581
- getImageMimeType(url) {
582
- const urlLower = url.toLowerCase();
583
- if (urlLower.endsWith(".png"))
584
- return "image/png";
585
- if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
586
- return "image/jpeg";
587
- if (urlLower.endsWith(".gif"))
588
- return "image/gif";
589
- if (urlLower.endsWith(".webp"))
590
- return "image/webp";
591
- if (urlLower.endsWith(".bmp"))
592
- return "image/bmp";
593
- if (urlLower.endsWith(".svg"))
594
- return "image/svg+xml";
595
- if (urlLower.endsWith(".ico"))
596
- return "image/x-icon";
597
- return "image/jpeg";
598
- }
599
- async blobToBase64DataURL(blob, mimeType) {
600
- if (typeof Buffer !== "undefined") {
601
- const arrayBuffer = await blob.arrayBuffer();
602
- const buffer = Buffer.from(arrayBuffer);
603
- return `data:${mimeType};base64,${buffer.toString("base64")}`;
604
- }
605
- return new Promise((resolve, reject) => {
606
- const reader = new FileReader;
607
- reader.onloadend = () => {
608
- const result = reader.result;
609
- if (result.startsWith("data:;base64,")) {
610
- resolve(`data:${mimeType};base64,${result.substring(13)}`);
611
- } else {
612
- resolve(result);
613
- }
614
- };
615
- reader.onerror = reject;
616
- reader.readAsDataURL(blob);
617
- });
618
- }
619
- }
620
- var fileLoader = (input, config) => {
621
- return new FileLoaderTask({}, config).run(input);
622
- };
623
- Workflow2.prototype.fileLoader = CreateWorkflow2(FileLoaderTask);
624
-
625
- // src/task/adaptive.ts
626
- import { CreateAdaptiveWorkflow, Workflow as Workflow12 } from "@workglow/task-graph";
627
-
628
- // src/task/scalar/ScalarAddTask.ts
629
- import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
630
-
631
- // src/task/scalar/sumPrecise.ts
632
- function kahanSum(values) {
633
- let sum = 0;
634
- let compensation = 0;
635
- for (const value of values) {
636
- const y = value - compensation;
637
- const t = sum + y;
638
- compensation = t - sum - y;
639
- sum = t;
640
- }
641
- return sum;
642
176
  }
643
- var nativeSumPrecise = typeof Math.sumPrecise === "function" ? Math.sumPrecise : undefined;
644
- var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
177
+ Workflow3.prototype.scalarMultiply = CreateWorkflow3(ScalarMultiplyTask);
645
178
 
646
- // src/task/scalar/ScalarAddTask.ts
647
- var inputSchema3 = {
179
+ // src/task/scalar/ScalarSubtractTask.ts
180
+ import { CreateWorkflow as CreateWorkflow4, Task as Task4, Workflow as Workflow4 } from "@workglow/task-graph";
181
+ var inputSchema4 = {
648
182
  type: "object",
649
183
  properties: {
650
184
  a: {
@@ -661,272 +195,125 @@ var inputSchema3 = {
661
195
  required: ["a", "b"],
662
196
  additionalProperties: false
663
197
  };
664
- var outputSchema3 = {
198
+ var outputSchema4 = {
665
199
  type: "object",
666
200
  properties: {
667
201
  result: {
668
202
  type: "number",
669
203
  title: "Result",
670
- description: "Sum of a and b"
204
+ description: "Difference (a - b)"
671
205
  }
672
206
  },
673
207
  required: ["result"],
674
208
  additionalProperties: false
675
209
  };
676
210
 
677
- class ScalarAddTask extends Task2 {
678
- static type = "ScalarAddTask";
211
+ class ScalarSubtractTask extends Task4 {
212
+ static type = "ScalarSubtractTask";
679
213
  static category = "Math";
680
- static title = "Add";
681
- static description = "Returns the sum of two numbers";
214
+ static title = "Subtract";
215
+ static description = "Returns the difference of two numbers (a - b)";
682
216
  static inputSchema() {
683
- return inputSchema3;
217
+ return inputSchema4;
684
218
  }
685
219
  static outputSchema() {
686
- return outputSchema3;
220
+ return outputSchema4;
687
221
  }
688
222
  async execute(input, _context) {
689
- return { result: sumPrecise([input.a, input.b]) };
223
+ return { result: input.a - input.b };
690
224
  }
691
225
  }
692
- Workflow3.prototype.scalarAdd = CreateWorkflow3(ScalarAddTask);
226
+ Workflow4.prototype.scalarSubtract = CreateWorkflow4(ScalarSubtractTask);
693
227
 
694
- // src/task/scalar/ScalarDivideTask.ts
695
- import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
696
- var inputSchema4 = {
228
+ // src/task/scalar/ScalarSumTask.ts
229
+ import { CreateWorkflow as CreateWorkflow5, Task as Task5, Workflow as Workflow5 } from "@workglow/task-graph";
230
+ var inputSchema5 = {
697
231
  type: "object",
698
232
  properties: {
699
- a: {
700
- type: "number",
701
- title: "A",
702
- description: "Numerator"
703
- },
704
- b: {
705
- type: "number",
706
- title: "B",
707
- description: "Denominator"
233
+ values: {
234
+ type: "array",
235
+ items: { type: "number" },
236
+ title: "Values",
237
+ description: "Array of numbers to sum"
708
238
  }
709
239
  },
710
- required: ["a", "b"],
240
+ required: ["values"],
711
241
  additionalProperties: false
712
242
  };
713
- var outputSchema4 = {
243
+ var outputSchema5 = {
714
244
  type: "object",
715
245
  properties: {
716
246
  result: {
717
247
  type: "number",
718
248
  title: "Result",
719
- description: "Quotient (a / b)"
249
+ description: "Sum of all values"
720
250
  }
721
251
  },
722
252
  required: ["result"],
723
253
  additionalProperties: false
724
254
  };
725
255
 
726
- class ScalarDivideTask extends Task3 {
727
- static type = "ScalarDivideTask";
256
+ class ScalarSumTask extends Task5 {
257
+ static type = "ScalarSumTask";
728
258
  static category = "Math";
729
- static title = "Divide";
730
- static description = "Returns the quotient of two numbers (a / b)";
259
+ static title = "Sum";
260
+ static description = "Returns the sum of an array of numbers";
731
261
  static inputSchema() {
732
- return inputSchema4;
262
+ return inputSchema5;
733
263
  }
734
264
  static outputSchema() {
735
- return outputSchema4;
265
+ return outputSchema5;
736
266
  }
737
267
  async execute(input, _context) {
738
- return { result: input.a / input.b };
268
+ return { result: sumPrecise(input.values) };
739
269
  }
740
270
  }
741
- Workflow4.prototype.scalarDivide = CreateWorkflow4(ScalarDivideTask);
271
+ Workflow5.prototype.scalarSum = CreateWorkflow5(ScalarSumTask);
742
272
 
743
- // src/task/scalar/ScalarMultiplyTask.ts
744
- import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
745
- var inputSchema5 = {
273
+ // src/task/vector/VectorDivideTask.ts
274
+ import { CreateWorkflow as CreateWorkflow6, Task as Task6, Workflow as Workflow6 } from "@workglow/task-graph";
275
+ import {
276
+ createTypedArrayFrom,
277
+ TypedArraySchema
278
+ } from "@workglow/util";
279
+ var inputSchema6 = {
746
280
  type: "object",
747
281
  properties: {
748
- a: {
749
- type: "number",
750
- title: "A",
751
- description: "First number"
752
- },
753
- b: {
754
- type: "number",
755
- title: "B",
756
- description: "Second number"
282
+ vectors: {
283
+ type: "array",
284
+ items: TypedArraySchema({
285
+ title: "Vector",
286
+ description: "Vector (first is numerator, rest are denominators)"
287
+ }),
288
+ title: "Vectors",
289
+ description: "Array of vectors: vectors[0] / vectors[1] / vectors[2] / ..."
757
290
  }
758
291
  },
759
- required: ["a", "b"],
292
+ required: ["vectors"],
760
293
  additionalProperties: false
761
294
  };
762
- var outputSchema5 = {
295
+ var outputSchema6 = {
763
296
  type: "object",
764
297
  properties: {
765
- result: {
766
- type: "number",
298
+ result: TypedArraySchema({
767
299
  title: "Result",
768
- description: "Product of a and b"
769
- }
300
+ description: "Component-wise quotient"
301
+ })
770
302
  },
771
303
  required: ["result"],
772
304
  additionalProperties: false
773
305
  };
774
306
 
775
- class ScalarMultiplyTask extends Task4 {
776
- static type = "ScalarMultiplyTask";
777
- static category = "Math";
778
- static title = "Multiply";
779
- static description = "Returns the product of two numbers";
307
+ class VectorDivideTask extends Task6 {
308
+ static type = "VectorDivideTask";
309
+ static category = "Vector";
310
+ static title = "Divide";
311
+ static description = "Returns component-wise quotient: vectors[0] / vectors[1] / vectors[2] / ...";
780
312
  static inputSchema() {
781
- return inputSchema5;
313
+ return inputSchema6;
782
314
  }
783
315
  static outputSchema() {
784
- return outputSchema5;
785
- }
786
- async execute(input, _context) {
787
- return { result: input.a * input.b };
788
- }
789
- }
790
- Workflow5.prototype.scalarMultiply = CreateWorkflow5(ScalarMultiplyTask);
791
-
792
- // src/task/scalar/ScalarSubtractTask.ts
793
- import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
794
- var inputSchema6 = {
795
- type: "object",
796
- properties: {
797
- a: {
798
- type: "number",
799
- title: "A",
800
- description: "First number"
801
- },
802
- b: {
803
- type: "number",
804
- title: "B",
805
- description: "Second number"
806
- }
807
- },
808
- required: ["a", "b"],
809
- additionalProperties: false
810
- };
811
- var outputSchema6 = {
812
- type: "object",
813
- properties: {
814
- result: {
815
- type: "number",
816
- title: "Result",
817
- description: "Difference (a - b)"
818
- }
819
- },
820
- required: ["result"],
821
- additionalProperties: false
822
- };
823
-
824
- class ScalarSubtractTask extends Task5 {
825
- static type = "ScalarSubtractTask";
826
- static category = "Math";
827
- static title = "Subtract";
828
- static description = "Returns the difference of two numbers (a - b)";
829
- static inputSchema() {
830
- return inputSchema6;
831
- }
832
- static outputSchema() {
833
- return outputSchema6;
834
- }
835
- async execute(input, _context) {
836
- return { result: input.a - input.b };
837
- }
838
- }
839
- Workflow6.prototype.scalarSubtract = CreateWorkflow6(ScalarSubtractTask);
840
-
841
- // src/task/scalar/ScalarSumTask.ts
842
- import { CreateWorkflow as CreateWorkflow7, Task as Task6, Workflow as Workflow7 } from "@workglow/task-graph";
843
- var inputSchema7 = {
844
- type: "object",
845
- properties: {
846
- values: {
847
- type: "array",
848
- items: { type: "number" },
849
- title: "Values",
850
- description: "Array of numbers to sum"
851
- }
852
- },
853
- required: ["values"],
854
- additionalProperties: false
855
- };
856
- var outputSchema7 = {
857
- type: "object",
858
- properties: {
859
- result: {
860
- type: "number",
861
- title: "Result",
862
- description: "Sum of all values"
863
- }
864
- },
865
- required: ["result"],
866
- additionalProperties: false
867
- };
868
-
869
- class ScalarSumTask extends Task6 {
870
- static type = "ScalarSumTask";
871
- static category = "Math";
872
- static title = "Sum";
873
- static description = "Returns the sum of an array of numbers";
874
- static inputSchema() {
875
- return inputSchema7;
876
- }
877
- static outputSchema() {
878
- return outputSchema7;
879
- }
880
- async execute(input, _context) {
881
- return { result: sumPrecise(input.values) };
882
- }
883
- }
884
- Workflow7.prototype.scalarSum = CreateWorkflow7(ScalarSumTask);
885
-
886
- // src/task/vector/VectorDivideTask.ts
887
- import { CreateWorkflow as CreateWorkflow8, Task as Task7, Workflow as Workflow8 } from "@workglow/task-graph";
888
- import {
889
- createTypedArrayFrom,
890
- TypedArraySchema
891
- } from "@workglow/util";
892
- var inputSchema8 = {
893
- type: "object",
894
- properties: {
895
- vectors: {
896
- type: "array",
897
- items: TypedArraySchema({
898
- title: "Vector",
899
- description: "Vector (first is numerator, rest are denominators)"
900
- }),
901
- title: "Vectors",
902
- description: "Array of vectors: vectors[0] / vectors[1] / vectors[2] / ..."
903
- }
904
- },
905
- required: ["vectors"],
906
- additionalProperties: false
907
- };
908
- var outputSchema8 = {
909
- type: "object",
910
- properties: {
911
- result: TypedArraySchema({
912
- title: "Result",
913
- description: "Component-wise quotient"
914
- })
915
- },
916
- required: ["result"],
917
- additionalProperties: false
918
- };
919
-
920
- class VectorDivideTask extends Task7 {
921
- static type = "VectorDivideTask";
922
- static category = "Vector";
923
- static title = "Divide";
924
- static description = "Returns component-wise quotient: vectors[0] / vectors[1] / vectors[2] / ...";
925
- static inputSchema() {
926
- return inputSchema8;
927
- }
928
- static outputSchema() {
929
- return outputSchema8;
316
+ return outputSchema6;
930
317
  }
931
318
  async execute(input, _context) {
932
319
  const { vectors } = input;
@@ -949,15 +336,15 @@ class VectorDivideTask extends Task7 {
949
336
  return { result: createTypedArrayFrom(vectors, values) };
950
337
  }
951
338
  }
952
- Workflow8.prototype.vectorDivide = CreateWorkflow8(VectorDivideTask);
339
+ Workflow6.prototype.vectorDivide = CreateWorkflow6(VectorDivideTask);
953
340
 
954
341
  // src/task/vector/VectorMultiplyTask.ts
955
- import { CreateWorkflow as CreateWorkflow9, Task as Task8, Workflow as Workflow9 } from "@workglow/task-graph";
342
+ import { CreateWorkflow as CreateWorkflow7, Task as Task7, Workflow as Workflow7 } from "@workglow/task-graph";
956
343
  import {
957
344
  createTypedArrayFrom as createTypedArrayFrom2,
958
345
  TypedArraySchema as TypedArraySchema2
959
346
  } from "@workglow/util";
960
- var inputSchema9 = {
347
+ var inputSchema7 = {
961
348
  type: "object",
962
349
  properties: {
963
350
  vectors: {
@@ -973,7 +360,7 @@ var inputSchema9 = {
973
360
  required: ["vectors"],
974
361
  additionalProperties: false
975
362
  };
976
- var outputSchema9 = {
363
+ var outputSchema7 = {
977
364
  type: "object",
978
365
  properties: {
979
366
  result: TypedArraySchema2({
@@ -985,16 +372,16 @@ var outputSchema9 = {
985
372
  additionalProperties: false
986
373
  };
987
374
 
988
- class VectorMultiplyTask extends Task8 {
375
+ class VectorMultiplyTask extends Task7 {
989
376
  static type = "VectorMultiplyTask";
990
377
  static category = "Vector";
991
378
  static title = "Multiply";
992
379
  static description = "Returns the component-wise product (Hadamard product) of all vectors";
993
380
  static inputSchema() {
994
- return inputSchema9;
381
+ return inputSchema7;
995
382
  }
996
383
  static outputSchema() {
997
- return outputSchema9;
384
+ return outputSchema7;
998
385
  }
999
386
  async execute(input, _context) {
1000
387
  const { vectors } = input;
@@ -1011,15 +398,15 @@ class VectorMultiplyTask extends Task8 {
1011
398
  return { result: createTypedArrayFrom2(vectors, values) };
1012
399
  }
1013
400
  }
1014
- Workflow9.prototype.vectorMultiply = CreateWorkflow9(VectorMultiplyTask);
401
+ Workflow7.prototype.vectorMultiply = CreateWorkflow7(VectorMultiplyTask);
1015
402
 
1016
403
  // src/task/vector/VectorSubtractTask.ts
1017
- import { CreateWorkflow as CreateWorkflow10, Task as Task9, Workflow as Workflow10 } from "@workglow/task-graph";
404
+ import { CreateWorkflow as CreateWorkflow8, Task as Task8, Workflow as Workflow8 } from "@workglow/task-graph";
1018
405
  import {
1019
406
  createTypedArrayFrom as createTypedArrayFrom3,
1020
407
  TypedArraySchema as TypedArraySchema3
1021
408
  } from "@workglow/util";
1022
- var inputSchema10 = {
409
+ var inputSchema8 = {
1023
410
  type: "object",
1024
411
  properties: {
1025
412
  vectors: {
@@ -1035,7 +422,7 @@ var inputSchema10 = {
1035
422
  required: ["vectors"],
1036
423
  additionalProperties: false
1037
424
  };
1038
- var outputSchema10 = {
425
+ var outputSchema8 = {
1039
426
  type: "object",
1040
427
  properties: {
1041
428
  result: TypedArraySchema3({
@@ -1047,16 +434,16 @@ var outputSchema10 = {
1047
434
  additionalProperties: false
1048
435
  };
1049
436
 
1050
- class VectorSubtractTask extends Task9 {
437
+ class VectorSubtractTask extends Task8 {
1051
438
  static type = "VectorSubtractTask";
1052
439
  static category = "Vector";
1053
440
  static title = "Subtract";
1054
441
  static description = "Returns component-wise difference: vectors[0] - vectors[1] - vectors[2] - ...";
1055
442
  static inputSchema() {
1056
- return inputSchema10;
443
+ return inputSchema8;
1057
444
  }
1058
445
  static outputSchema() {
1059
- return outputSchema10;
446
+ return outputSchema8;
1060
447
  }
1061
448
  async execute(input, _context) {
1062
449
  const { vectors } = input;
@@ -1079,15 +466,15 @@ class VectorSubtractTask extends Task9 {
1079
466
  return { result: createTypedArrayFrom3(vectors, values) };
1080
467
  }
1081
468
  }
1082
- Workflow10.prototype.vectorSubtract = CreateWorkflow10(VectorSubtractTask);
469
+ Workflow8.prototype.vectorSubtract = CreateWorkflow8(VectorSubtractTask);
1083
470
 
1084
471
  // src/task/vector/VectorSumTask.ts
1085
- import { CreateWorkflow as CreateWorkflow11, Task as Task10, Workflow as Workflow11 } from "@workglow/task-graph";
472
+ import { CreateWorkflow as CreateWorkflow9, Task as Task9, Workflow as Workflow9 } from "@workglow/task-graph";
1086
473
  import {
1087
474
  createTypedArrayFrom as createTypedArrayFrom4,
1088
475
  TypedArraySchema as TypedArraySchema4
1089
476
  } from "@workglow/util";
1090
- var inputSchema11 = {
477
+ var inputSchema9 = {
1091
478
  type: "object",
1092
479
  properties: {
1093
480
  vectors: {
@@ -1103,7 +490,7 @@ var inputSchema11 = {
1103
490
  required: ["vectors"],
1104
491
  additionalProperties: false
1105
492
  };
1106
- var outputSchema11 = {
493
+ var outputSchema9 = {
1107
494
  type: "object",
1108
495
  properties: {
1109
496
  result: TypedArraySchema4({
@@ -1115,16 +502,16 @@ var outputSchema11 = {
1115
502
  additionalProperties: false
1116
503
  };
1117
504
 
1118
- class VectorSumTask extends Task10 {
505
+ class VectorSumTask extends Task9 {
1119
506
  static type = "VectorSumTask";
1120
507
  static category = "Vector";
1121
508
  static title = "Sum";
1122
509
  static description = "Returns the component-wise sum of an array of vectors";
1123
510
  static inputSchema() {
1124
- return inputSchema11;
511
+ return inputSchema9;
1125
512
  }
1126
513
  static outputSchema() {
1127
- return outputSchema11;
514
+ return outputSchema9;
1128
515
  }
1129
516
  async execute(input, _context) {
1130
517
  const { vectors } = input;
@@ -1141,22 +528,14 @@ class VectorSumTask extends Task10 {
1141
528
  return { result: createTypedArrayFrom4(vectors, values) };
1142
529
  }
1143
530
  }
1144
- Workflow11.prototype.vectorSum = CreateWorkflow11(VectorSumTask);
531
+ Workflow9.prototype.vectorSum = CreateWorkflow9(VectorSumTask);
1145
532
 
1146
533
  // src/task/adaptive.ts
1147
- Workflow12.prototype.add = CreateAdaptiveWorkflow(ScalarAddTask, VectorSumTask);
1148
- Workflow12.prototype.subtract = CreateAdaptiveWorkflow(ScalarSubtractTask, VectorSubtractTask);
1149
- Workflow12.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, VectorMultiplyTask);
1150
- Workflow12.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
1151
- Workflow12.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
1152
-
1153
- // src/common.ts
1154
- import {
1155
- createMcpClient,
1156
- mcpClientFactory as mcpClientFactory5,
1157
- mcpServerConfigSchema as mcpServerConfigSchema5,
1158
- mcpTransportTypes
1159
- } from "@workglow/util";
534
+ Workflow10.prototype.add = CreateAdaptiveWorkflow(ScalarAddTask, VectorSumTask);
535
+ Workflow10.prototype.subtract = CreateAdaptiveWorkflow(ScalarSubtractTask, VectorSubtractTask);
536
+ Workflow10.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, VectorMultiplyTask);
537
+ Workflow10.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
538
+ Workflow10.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
1160
539
 
1161
540
  // src/task/ArrayTask.ts
1162
541
  import {
@@ -1192,12 +571,12 @@ class ArrayTask extends GraphAsTask {
1192
571
  regenerateGraph() {
1193
572
  const arrayInputs = new Map;
1194
573
  let hasArrayInputs = false;
1195
- const inputSchema12 = this.inputSchema();
1196
- if (typeof inputSchema12 !== "boolean") {
1197
- const keys = Object.keys(inputSchema12.properties || {});
574
+ const inputSchema10 = this.inputSchema();
575
+ if (typeof inputSchema10 !== "boolean") {
576
+ const keys = Object.keys(inputSchema10.properties || {});
1198
577
  for (const inputId of keys) {
1199
578
  const inputValue = this.runInputData[inputId];
1200
- const inputDef = inputSchema12.properties?.[inputId];
579
+ const inputDef = inputSchema10.properties?.[inputId];
1201
580
  if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
1202
581
  arrayInputs.set(inputId, inputValue);
1203
582
  hasArrayInputs = true;
@@ -1286,7 +665,7 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
1286
665
  }
1287
666
  }
1288
667
  // src/task/DebugLogTask.ts
1289
- import { CreateWorkflow as CreateWorkflow12, Task as Task11, TaskConfigSchema, Workflow as Workflow13 } from "@workglow/task-graph";
668
+ import { CreateWorkflow as CreateWorkflow10, Task as Task10, TaskConfigSchema, Workflow as Workflow11 } from "@workglow/task-graph";
1290
669
  var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
1291
670
  var DEFAULT_LOG_LEVEL = "log";
1292
671
  var debugLogTaskConfigSchema = {
@@ -1303,32 +682,33 @@ var debugLogTaskConfigSchema = {
1303
682
  },
1304
683
  additionalProperties: false
1305
684
  };
1306
- var inputSchema12 = {
685
+ var inputSchema10 = {
1307
686
  type: "object",
1308
687
  properties: {},
1309
688
  additionalProperties: true
1310
689
  };
1311
- var outputSchema12 = {
690
+ var outputSchema10 = {
1312
691
  type: "object",
1313
692
  properties: {},
1314
693
  additionalProperties: true
1315
694
  };
1316
695
 
1317
- class DebugLogTask extends Task11 {
696
+ class DebugLogTask extends Task10 {
1318
697
  static type = "DebugLogTask";
1319
698
  static category = "Utility";
1320
699
  static title = "Debug Log";
1321
700
  static description = "Logs messages to the console with configurable log levels for debugging task graphs";
1322
701
  static cacheable = false;
1323
702
  static passthroughInputsToOutputs = true;
703
+ static customizable = true;
1324
704
  static configSchema() {
1325
705
  return debugLogTaskConfigSchema;
1326
706
  }
1327
707
  static inputSchema() {
1328
- return inputSchema12;
708
+ return inputSchema10;
1329
709
  }
1330
710
  static outputSchema() {
1331
- return outputSchema12;
711
+ return outputSchema10;
1332
712
  }
1333
713
  async executeReactive(input, output) {
1334
714
  const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
@@ -1346,14 +726,14 @@ var debugLog = (input, config = {}) => {
1346
726
  const task = new DebugLogTask({}, config);
1347
727
  return task.run(input);
1348
728
  };
1349
- Workflow13.prototype.debugLog = CreateWorkflow12(DebugLogTask);
729
+ Workflow11.prototype.debugLog = CreateWorkflow10(DebugLogTask);
1350
730
  // src/task/DelayTask.ts
1351
731
  import {
1352
- CreateWorkflow as CreateWorkflow13,
1353
- Task as Task12,
1354
- TaskAbortedError as TaskAbortedError2,
732
+ CreateWorkflow as CreateWorkflow11,
733
+ Task as Task11,
734
+ TaskAbortedError,
1355
735
  TaskConfigSchema as TaskConfigSchema2,
1356
- Workflow as Workflow14
736
+ Workflow as Workflow12
1357
737
  } from "@workglow/task-graph";
1358
738
  import { sleep } from "@workglow/util";
1359
739
  var delayTaskConfigSchema = {
@@ -1368,32 +748,33 @@ var delayTaskConfigSchema = {
1368
748
  },
1369
749
  additionalProperties: false
1370
750
  };
1371
- var inputSchema13 = {
751
+ var inputSchema11 = {
1372
752
  type: "object",
1373
753
  properties: {},
1374
754
  additionalProperties: true
1375
755
  };
1376
- var outputSchema13 = {
756
+ var outputSchema11 = {
1377
757
  type: "object",
1378
758
  properties: {},
1379
759
  additionalProperties: true
1380
760
  };
1381
761
 
1382
- class DelayTask extends Task12 {
762
+ class DelayTask extends Task11 {
1383
763
  static type = "DelayTask";
1384
764
  static category = "Utility";
1385
765
  static title = "Delay";
1386
766
  static description = "Delays execution for a specified duration with progress tracking";
1387
767
  static cacheable = false;
1388
768
  static passthroughInputsToOutputs = true;
769
+ static customizable = true;
1389
770
  static configSchema() {
1390
771
  return delayTaskConfigSchema;
1391
772
  }
1392
773
  static inputSchema() {
1393
- return inputSchema13;
774
+ return inputSchema11;
1394
775
  }
1395
776
  static outputSchema() {
1396
- return outputSchema13;
777
+ return outputSchema11;
1397
778
  }
1398
779
  async execute(input, executeContext) {
1399
780
  const delay = this.config.delay ?? 1;
@@ -1402,7 +783,7 @@ class DelayTask extends Task12 {
1402
783
  const chunkSize = delay / iterations;
1403
784
  for (let i = 0;i < iterations; i++) {
1404
785
  if (executeContext.signal.aborted) {
1405
- throw new TaskAbortedError2("Task aborted");
786
+ throw new TaskAbortedError("Task aborted");
1406
787
  }
1407
788
  await sleep(chunkSize);
1408
789
  await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
@@ -1417,67 +798,378 @@ var delay = (input, config = { delay: 1 }) => {
1417
798
  const task = new DelayTask({}, config);
1418
799
  return task.run(input);
1419
800
  };
1420
- Workflow14.prototype.delay = CreateWorkflow13(DelayTask);
1421
- // src/task/InputTask.ts
1422
- import { CreateWorkflow as CreateWorkflow14, Task as Task13, Workflow as Workflow15 } from "@workglow/task-graph";
1423
-
1424
- class InputTask extends Task13 {
1425
- static type = "InputTask";
1426
- static category = "Flow Control";
1427
- static title = "Input";
1428
- static description = "Starts the workflow";
1429
- static hasDynamicSchemas = true;
1430
- static cacheable = false;
1431
- static inputSchema() {
1432
- return {
1433
- type: "object",
1434
- properties: {},
1435
- additionalProperties: true
1436
- };
1437
- }
1438
- static outputSchema() {
1439
- return {
801
+ Workflow12.prototype.delay = CreateWorkflow11(DelayTask);
802
+ // src/task/FetchUrlTask.ts
803
+ import {
804
+ AbortSignalJobError,
805
+ Job,
806
+ PermanentJobError,
807
+ RetryableJobError
808
+ } from "@workglow/job-queue";
809
+ import {
810
+ CreateWorkflow as CreateWorkflow12,
811
+ JobQueueTask,
812
+ TaskConfigurationError,
813
+ TaskInvalidInputError,
814
+ Workflow as Workflow13
815
+ } from "@workglow/task-graph";
816
+ var inputSchema12 = {
817
+ type: "object",
818
+ properties: {
819
+ url: {
820
+ type: "string",
821
+ title: "URL",
822
+ description: "The URL to fetch from",
823
+ format: "uri"
824
+ },
825
+ method: {
826
+ enum: ["GET", "POST", "PUT", "DELETE", "PATCH"],
827
+ title: "Method",
828
+ description: "The HTTP method to use",
829
+ default: "GET"
830
+ },
831
+ headers: {
1440
832
  type: "object",
1441
- properties: {},
1442
- additionalProperties: true
1443
- };
1444
- }
1445
- inputSchema() {
1446
- return this.config?.inputSchema ?? this.constructor.inputSchema();
1447
- }
1448
- outputSchema() {
1449
- return this.config?.outputSchema ?? this.constructor.outputSchema();
1450
- }
1451
- async execute(input) {
1452
- return input;
1453
- }
1454
- async executeReactive(input) {
1455
- return input;
1456
- }
1457
- async* executeStream(input, context) {
1458
- if (context.inputStreams) {
1459
- for (const [, stream] of context.inputStreams) {
1460
- const reader = stream.getReader();
1461
- try {
1462
- while (true) {
1463
- const { done, value } = await reader.read();
1464
- if (done)
1465
- break;
1466
- if (value.type === "finish")
1467
- continue;
1468
- yield value;
1469
- }
1470
- } finally {
1471
- reader.releaseLock();
833
+ additionalProperties: {
834
+ type: "string"
835
+ },
836
+ title: "Headers",
837
+ description: "The headers to send with the request"
838
+ },
839
+ body: {
840
+ type: "string",
841
+ title: "Body",
842
+ description: "The body of the request"
843
+ },
844
+ response_type: {
845
+ anyOf: [{ type: "null" }, { enum: ["json", "text", "blob", "arraybuffer"] }],
846
+ title: "Response Type",
847
+ description: "The forced type of response to return. If null, the response type is inferred from the Content-Type header.",
848
+ default: null
849
+ },
850
+ timeout: {
851
+ type: "number",
852
+ title: "Timeout",
853
+ description: "Request timeout in milliseconds"
854
+ },
855
+ queue: {
856
+ oneOf: [{ type: "boolean" }, { type: "string" }],
857
+ description: "Queue handling: false=run inline, true=use default, string=explicit queue name",
858
+ default: true,
859
+ "x-ui-hidden": true
860
+ }
861
+ },
862
+ required: ["url"],
863
+ additionalProperties: false
864
+ };
865
+ var outputSchema12 = {
866
+ type: "object",
867
+ properties: {
868
+ json: {
869
+ title: "JSON",
870
+ description: "The JSON response"
871
+ },
872
+ text: {
873
+ type: "string",
874
+ title: "Text",
875
+ description: "The text response"
876
+ },
877
+ blob: {
878
+ title: "Blob",
879
+ description: "The blob response"
880
+ },
881
+ arraybuffer: {
882
+ title: "ArrayBuffer",
883
+ description: "The arraybuffer response"
884
+ },
885
+ metadata: {
886
+ type: "object",
887
+ properties: {
888
+ contentType: { type: "string" },
889
+ headers: { type: "object", additionalProperties: { type: "string" } }
890
+ },
891
+ additionalProperties: false,
892
+ title: "Response Metadata",
893
+ description: "HTTP response metadata including content type and headers"
894
+ }
895
+ },
896
+ additionalProperties: false
897
+ };
898
+ async function fetchWithProgress(url, options = {}, onProgress) {
899
+ if (!options.signal) {
900
+ throw new TaskConfigurationError("An AbortSignal must be provided.");
901
+ }
902
+ const response = await globalThis.fetch(url, options);
903
+ if (!response.body) {
904
+ throw new Error("ReadableStream not supported in this environment.");
905
+ }
906
+ const contentLength = response.headers.get("Content-Length");
907
+ const totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
908
+ let receivedBytes = 0;
909
+ const reader = response.body.getReader();
910
+ const stream = new ReadableStream({
911
+ start(controller) {
912
+ async function push() {
913
+ try {
914
+ while (true) {
915
+ if (options.signal?.aborted) {
916
+ controller.error(new AbortSignalJobError("Fetch aborted"));
917
+ reader.cancel();
918
+ return;
919
+ }
920
+ const { done, value } = await reader.read();
921
+ if (done) {
922
+ controller.close();
923
+ break;
924
+ }
925
+ controller.enqueue(value);
926
+ receivedBytes += value.length;
927
+ if (onProgress && totalBytes) {
928
+ await onProgress(receivedBytes / totalBytes * 100);
929
+ }
930
+ }
931
+ } catch (error) {
932
+ controller.error(error);
933
+ }
934
+ }
935
+ push();
936
+ },
937
+ cancel() {
938
+ reader.cancel();
939
+ }
940
+ });
941
+ return new Response(stream, {
942
+ headers: response.headers,
943
+ status: response.status,
944
+ statusText: response.statusText
945
+ });
946
+ }
947
+
948
+ class FetchUrlJob extends Job {
949
+ constructor(config = { input: {} }) {
950
+ super(config);
951
+ }
952
+ static type = "FetchUrlJob";
953
+ async execute(input, context) {
954
+ const response = await fetchWithProgress(input.url, {
955
+ method: input.method,
956
+ headers: input.headers,
957
+ body: input.body,
958
+ signal: context.signal
959
+ }, async (progress) => await context.updateProgress(progress));
960
+ if (response.ok) {
961
+ const contentType = response.headers.get("content-type") ?? "";
962
+ const headers = {};
963
+ response.headers.forEach((value, key) => {
964
+ headers[key] = value;
965
+ });
966
+ const metadata = {
967
+ contentType,
968
+ headers
969
+ };
970
+ let responseType = input.response_type;
971
+ if (!responseType) {
972
+ if (contentType.includes("application/json")) {
973
+ responseType = "json";
974
+ } else if (contentType.includes("text/")) {
975
+ responseType = "text";
976
+ } else if (contentType.includes("application/octet-stream")) {
977
+ responseType = "arraybuffer";
978
+ } else if (contentType.includes("application/pdf") || contentType.includes("image/") || contentType.includes("application/zip")) {
979
+ responseType = "blob";
980
+ } else {
981
+ responseType = "json";
982
+ }
983
+ input.response_type = responseType;
984
+ }
985
+ if (responseType === "json") {
986
+ return { json: await response.json(), metadata };
987
+ } else if (responseType === "text") {
988
+ return { text: await response.text(), metadata };
989
+ } else if (responseType === "blob") {
990
+ return { blob: await response.blob(), metadata };
991
+ } else if (responseType === "arraybuffer") {
992
+ return { arraybuffer: await response.arrayBuffer(), metadata };
993
+ }
994
+ throw new TaskInvalidInputError(`Invalid response type: ${responseType}`);
995
+ } else {
996
+ if (response.status === 429 || response.status === 503 || response.headers.get("Retry-After")) {
997
+ let retryDate;
998
+ const retryAfterStr = response.headers.get("Retry-After");
999
+ if (retryAfterStr) {
1000
+ const parsedDate = new Date(retryAfterStr);
1001
+ if (!isNaN(parsedDate.getTime()) && parsedDate > new Date) {
1002
+ retryDate = parsedDate;
1003
+ } else {
1004
+ const retryAfterSeconds = parseInt(retryAfterStr) * 1000;
1005
+ if (!isNaN(retryAfterSeconds)) {
1006
+ retryDate = new Date(Date.now() + retryAfterSeconds);
1007
+ }
1008
+ }
1009
+ }
1010
+ throw new RetryableJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`, retryDate);
1011
+ } else {
1012
+ throw new PermanentJobError(`Failed to fetch ${input.url}: ${response.status} ${response.statusText}`);
1013
+ }
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ class FetchUrlTask extends JobQueueTask {
1019
+ static type = "FetchUrlTask";
1020
+ static category = "Input";
1021
+ static title = "Fetch";
1022
+ static description = "Fetches data from a URL with progress tracking and automatic retry handling";
1023
+ static hasDynamicSchemas = true;
1024
+ static inputSchema() {
1025
+ return inputSchema12;
1026
+ }
1027
+ static outputSchema() {
1028
+ return outputSchema12;
1029
+ }
1030
+ outputSchema() {
1031
+ const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
1032
+ if (responseType === null || responseType === undefined) {
1033
+ return this.constructor.outputSchema();
1034
+ }
1035
+ const staticSchema = this.constructor.outputSchema();
1036
+ if (typeof staticSchema === "boolean") {
1037
+ return staticSchema;
1038
+ }
1039
+ if (!staticSchema.properties) {
1040
+ return staticSchema;
1041
+ }
1042
+ const properties = {};
1043
+ if (responseType === "json" && staticSchema.properties.json) {
1044
+ properties.json = staticSchema.properties.json;
1045
+ } else if (responseType === "text" && staticSchema.properties.text) {
1046
+ properties.text = staticSchema.properties.text;
1047
+ } else if (responseType === "blob" && staticSchema.properties.blob) {
1048
+ properties.blob = staticSchema.properties.blob;
1049
+ } else if (responseType === "arraybuffer" && staticSchema.properties.arraybuffer) {
1050
+ properties.arraybuffer = staticSchema.properties.arraybuffer;
1051
+ }
1052
+ if (staticSchema.properties.metadata) {
1053
+ properties.metadata = staticSchema.properties.metadata;
1054
+ }
1055
+ if (Object.keys(properties).length === 0) {
1056
+ return staticSchema;
1057
+ }
1058
+ return {
1059
+ type: "object",
1060
+ properties,
1061
+ additionalProperties: false
1062
+ };
1063
+ }
1064
+ constructor(input = {}, config = {}) {
1065
+ config.queue = input?.queue ?? config.queue;
1066
+ if (config.queue === undefined) {
1067
+ config.queue = false;
1068
+ }
1069
+ super(input, config);
1070
+ this.jobClass = FetchUrlJob;
1071
+ }
1072
+ setInput(input) {
1073
+ if (!("response_type" in input)) {
1074
+ super.setInput(input);
1075
+ return;
1076
+ }
1077
+ const getCurrentResponseType = () => {
1078
+ return this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
1079
+ };
1080
+ const previousResponseType = getCurrentResponseType();
1081
+ super.setInput(input);
1082
+ const newResponseType = getCurrentResponseType();
1083
+ if (previousResponseType !== newResponseType) {
1084
+ this.emitSchemaChange();
1085
+ }
1086
+ }
1087
+ async getDefaultQueueName(input) {
1088
+ if (!input.url) {
1089
+ return `fetch:${this.type}`;
1090
+ }
1091
+ try {
1092
+ const hostname = new URL(input.url).hostname.toLowerCase();
1093
+ const parts = hostname.split(".").filter(Boolean);
1094
+ if (parts.length === 0) {
1095
+ return `fetch:${this.type}`;
1096
+ }
1097
+ const domain = parts.length <= 2 ? parts.join(".") : parts.slice(-2).join(".");
1098
+ return `fetch:${domain}`;
1099
+ } catch {
1100
+ return `fetch:${this.type}`;
1101
+ }
1102
+ }
1103
+ }
1104
+ var fetchUrl = async (input, config = {}) => {
1105
+ const result = await new FetchUrlTask({}, config).run(input);
1106
+ return result;
1107
+ };
1108
+ Workflow13.prototype.fetch = CreateWorkflow12(FetchUrlTask);
1109
+ // src/task/InputTask.ts
1110
+ import {
1111
+ CreateWorkflow as CreateWorkflow13,
1112
+ Task as Task12,
1113
+ Workflow as Workflow14
1114
+ } from "@workglow/task-graph";
1115
+
1116
+ class InputTask extends Task12 {
1117
+ static type = "InputTask";
1118
+ static category = "Flow Control";
1119
+ static title = "Input";
1120
+ static description = "Starts the workflow";
1121
+ static hasDynamicSchemas = true;
1122
+ static cacheable = false;
1123
+ static inputSchema() {
1124
+ return {
1125
+ type: "object",
1126
+ properties: {},
1127
+ additionalProperties: true
1128
+ };
1129
+ }
1130
+ static outputSchema() {
1131
+ return {
1132
+ type: "object",
1133
+ properties: {},
1134
+ additionalProperties: true
1135
+ };
1136
+ }
1137
+ inputSchema() {
1138
+ return this.config?.inputSchema ?? this.constructor.inputSchema();
1139
+ }
1140
+ outputSchema() {
1141
+ return this.config?.outputSchema ?? this.constructor.outputSchema();
1142
+ }
1143
+ async execute(input) {
1144
+ return input;
1145
+ }
1146
+ async executeReactive(input) {
1147
+ return input;
1148
+ }
1149
+ async* executeStream(input, context) {
1150
+ if (context.inputStreams) {
1151
+ for (const [, stream] of context.inputStreams) {
1152
+ const reader = stream.getReader();
1153
+ try {
1154
+ while (true) {
1155
+ const { done, value } = await reader.read();
1156
+ if (done)
1157
+ break;
1158
+ if (value.type === "finish")
1159
+ continue;
1160
+ yield value;
1161
+ }
1162
+ } finally {
1163
+ reader.releaseLock();
1472
1164
  }
1473
1165
  }
1474
1166
  }
1475
1167
  yield { type: "finish", data: input };
1476
1168
  }
1477
1169
  }
1478
- Workflow15.prototype.input = CreateWorkflow14(InputTask);
1170
+ Workflow14.prototype.input = CreateWorkflow13(InputTask);
1479
1171
  // src/task/JavaScriptTask.ts
1480
- import { CreateWorkflow as CreateWorkflow15, Task as Task14, Workflow as Workflow16 } from "@workglow/task-graph";
1172
+ import { CreateWorkflow as CreateWorkflow14, Task as Task13, TaskConfigSchema as TaskConfigSchema3, Workflow as Workflow15 } from "@workglow/task-graph";
1481
1173
 
1482
1174
  // src/util/acorn.js
1483
1175
  var options;
@@ -5940,7 +5632,21 @@ Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
5940
5632
  Interpreter["Status"] = Interpreter.Status;
5941
5633
 
5942
5634
  // src/task/JavaScriptTask.ts
5943
- var inputSchema14 = {
5635
+ var configSchema = {
5636
+ type: "object",
5637
+ properties: {
5638
+ ...TaskConfigSchema3["properties"],
5639
+ javascript_code: {
5640
+ type: "string",
5641
+ title: "Code",
5642
+ minLength: 1,
5643
+ description: "JavaScript code to execute",
5644
+ format: "code:javascript"
5645
+ }
5646
+ },
5647
+ additionalProperties: false
5648
+ };
5649
+ var inputSchema13 = {
5944
5650
  type: "object",
5945
5651
  properties: {
5946
5652
  javascript_code: {
@@ -5954,7 +5660,7 @@ var inputSchema14 = {
5954
5660
  required: ["javascript_code"],
5955
5661
  additionalProperties: true
5956
5662
  };
5957
- var outputSchema14 = {
5663
+ var outputSchema13 = {
5958
5664
  type: "object",
5959
5665
  properties: {
5960
5666
  output: {
@@ -5966,19 +5672,39 @@ var outputSchema14 = {
5966
5672
  additionalProperties: false
5967
5673
  };
5968
5674
 
5969
- class JavaScriptTask extends Task14 {
5675
+ class JavaScriptTask extends Task13 {
5970
5676
  static type = "JavaScriptTask";
5971
5677
  static category = "Utility";
5972
5678
  static title = "JavaScript Interpreter";
5973
5679
  static description = "Executes JavaScript code in a sandboxed interpreter environment";
5680
+ static customizable = true;
5681
+ static configSchema() {
5682
+ return configSchema;
5683
+ }
5974
5684
  static inputSchema() {
5975
- return inputSchema14;
5685
+ return inputSchema13;
5976
5686
  }
5977
5687
  static outputSchema() {
5978
- return outputSchema14;
5688
+ return outputSchema13;
5689
+ }
5690
+ constructor(input2 = {}, config = {}) {
5691
+ super(input2, config);
5692
+ }
5693
+ inputSchema() {
5694
+ if (this.config?.javascript_code) {
5695
+ if (this.config.inputSchema) {
5696
+ return this.config.inputSchema;
5697
+ }
5698
+ return {
5699
+ type: "object",
5700
+ properties: {},
5701
+ additionalProperties: true
5702
+ };
5703
+ }
5704
+ return inputSchema13;
5979
5705
  }
5980
5706
  async executeReactive(input2, output) {
5981
- if (input2.javascript_code) {
5707
+ if (this.config.javascript_code || input2.javascript_code) {
5982
5708
  try {
5983
5709
  const inputVariables = Object.keys(input2).filter((key) => key !== "javascript_code");
5984
5710
  const inputVariablesString = inputVariables.map((key) => `var ${key} = ${JSON.stringify(input2[key])};`).join(`
@@ -5994,18 +5720,18 @@ class JavaScriptTask extends Task14 {
5994
5720
  var javaScript = (input2, config = {}) => {
5995
5721
  return new JavaScriptTask({}, config).run(input2);
5996
5722
  };
5997
- Workflow16.prototype.javaScript = CreateWorkflow15(JavaScriptTask);
5723
+ Workflow15.prototype.javaScript = CreateWorkflow14(JavaScriptTask);
5998
5724
  // src/task/JsonTask.ts
5999
5725
  import {
6000
5726
  createGraphFromDependencyJSON,
6001
5727
  createGraphFromGraphJSON,
6002
- CreateWorkflow as CreateWorkflow16,
5728
+ CreateWorkflow as CreateWorkflow15,
6003
5729
  Dataflow,
6004
5730
  GraphAsTask as GraphAsTask2,
6005
5731
  TaskConfigurationError as TaskConfigurationError2,
6006
- Workflow as Workflow17
5732
+ Workflow as Workflow16
6007
5733
  } from "@workglow/task-graph";
6008
- var inputSchema15 = {
5734
+ var inputSchema14 = {
6009
5735
  type: "object",
6010
5736
  properties: {
6011
5737
  json: {
@@ -6016,7 +5742,7 @@ var inputSchema15 = {
6016
5742
  },
6017
5743
  additionalProperties: false
6018
5744
  };
6019
- var outputSchema15 = {
5745
+ var outputSchema14 = {
6020
5746
  type: "object",
6021
5747
  properties: {
6022
5748
  output: {
@@ -6033,10 +5759,10 @@ class JsonTask extends GraphAsTask2 {
6033
5759
  static title = "JSON Task";
6034
5760
  static description = "A task that creates and manages task graphs from JSON configurations";
6035
5761
  static inputSchema() {
6036
- return inputSchema15;
5762
+ return inputSchema14;
6037
5763
  }
6038
5764
  static outputSchema() {
6039
- return outputSchema15;
5765
+ return outputSchema14;
6040
5766
  }
6041
5767
  regenerateGraph() {
6042
5768
  if (!this.runInputData.json)
@@ -6059,7 +5785,7 @@ class JsonTask extends GraphAsTask2 {
6059
5785
  if (!sourceTask) {
6060
5786
  throw new TaskConfigurationError2(`Dependency id ${dep.id} not found`);
6061
5787
  }
6062
- const df = new Dataflow(sourceTask.config.id, dep.output, item.id, input2);
5788
+ const df = new Dataflow(sourceTask.id, dep.output, item.id, input2);
6063
5789
  this.subGraph.addDataflow(df);
6064
5790
  }
6065
5791
  }
@@ -6070,26 +5796,26 @@ class JsonTask extends GraphAsTask2 {
6070
5796
  var json = (input2, config = {}) => {
6071
5797
  return new JsonTask({}, config).run(input2);
6072
5798
  };
6073
- Workflow17.prototype.json = CreateWorkflow16(JsonTask);
5799
+ Workflow16.prototype.json = CreateWorkflow15(JsonTask);
6074
5800
  // src/task/LambdaTask.ts
6075
5801
  import {
6076
- CreateWorkflow as CreateWorkflow17,
5802
+ CreateWorkflow as CreateWorkflow16,
6077
5803
  DATAFLOW_ALL_PORTS,
6078
- Task as Task15,
6079
- TaskConfigSchema as TaskConfigSchema3,
5804
+ Task as Task14,
5805
+ TaskConfigSchema as TaskConfigSchema4,
6080
5806
  TaskConfigurationError as TaskConfigurationError3,
6081
- Workflow as Workflow18
5807
+ Workflow as Workflow17
6082
5808
  } from "@workglow/task-graph";
6083
5809
  var lambdaTaskConfigSchema = {
6084
5810
  type: "object",
6085
5811
  properties: {
6086
- ...TaskConfigSchema3["properties"],
5812
+ ...TaskConfigSchema4["properties"],
6087
5813
  execute: {},
6088
5814
  executeReactive: {}
6089
5815
  },
6090
5816
  additionalProperties: false
6091
5817
  };
6092
- var inputSchema16 = {
5818
+ var inputSchema15 = {
6093
5819
  type: "object",
6094
5820
  properties: {
6095
5821
  [DATAFLOW_ALL_PORTS]: {
@@ -6099,7 +5825,7 @@ var inputSchema16 = {
6099
5825
  },
6100
5826
  additionalProperties: true
6101
5827
  };
6102
- var outputSchema16 = {
5828
+ var outputSchema15 = {
6103
5829
  type: "object",
6104
5830
  properties: {
6105
5831
  [DATAFLOW_ALL_PORTS]: {
@@ -6110,7 +5836,7 @@ var outputSchema16 = {
6110
5836
  additionalProperties: true
6111
5837
  };
6112
5838
 
6113
- class LambdaTask extends Task15 {
5839
+ class LambdaTask extends Task14 {
6114
5840
  static type = "LambdaTask";
6115
5841
  static title = "Lambda Task";
6116
5842
  static description = "A task that wraps a provided function and its input";
@@ -6120,10 +5846,10 @@ class LambdaTask extends Task15 {
6120
5846
  return lambdaTaskConfigSchema;
6121
5847
  }
6122
5848
  static inputSchema() {
6123
- return inputSchema16;
5849
+ return inputSchema15;
6124
5850
  }
6125
5851
  static outputSchema() {
6126
- return outputSchema16;
5852
+ return outputSchema15;
6127
5853
  }
6128
5854
  constructor(input2 = {}, config = {}) {
6129
5855
  if (!config.execute && !config.executeReactive) {
@@ -6161,15 +5887,15 @@ function lambda(input2, config) {
6161
5887
  const task = new LambdaTask(input2, config);
6162
5888
  return task.run();
6163
5889
  }
6164
- Workflow18.prototype.lambda = CreateWorkflow17(LambdaTask);
5890
+ Workflow17.prototype.lambda = CreateWorkflow16(LambdaTask);
6165
5891
  // src/task/MergeTask.ts
6166
- import { CreateWorkflow as CreateWorkflow18, Task as Task16, Workflow as Workflow19 } from "@workglow/task-graph";
6167
- var inputSchema17 = {
5892
+ import { CreateWorkflow as CreateWorkflow17, Task as Task15, Workflow as Workflow18 } from "@workglow/task-graph";
5893
+ var inputSchema16 = {
6168
5894
  type: "object",
6169
5895
  properties: {},
6170
5896
  additionalProperties: true
6171
5897
  };
6172
- var outputSchema17 = {
5898
+ var outputSchema16 = {
6173
5899
  type: "object",
6174
5900
  properties: {
6175
5901
  output: {
@@ -6181,17 +5907,17 @@ var outputSchema17 = {
6181
5907
  additionalProperties: false
6182
5908
  };
6183
5909
 
6184
- class MergeTask extends Task16 {
5910
+ class MergeTask extends Task15 {
6185
5911
  static type = "MergeTask";
6186
5912
  static category = "Utility";
6187
5913
  static title = "Merge";
6188
5914
  static description = "Merges multiple inputs into a single array output";
6189
5915
  static cacheable = true;
6190
5916
  static inputSchema() {
6191
- return inputSchema17;
5917
+ return inputSchema16;
6192
5918
  }
6193
5919
  static outputSchema() {
6194
- return outputSchema17;
5920
+ return outputSchema16;
6195
5921
  }
6196
5922
  async execute(input2, _context) {
6197
5923
  const keys = Object.keys(input2).sort();
@@ -6205,11 +5931,15 @@ var merge = (input2, config = {}) => {
6205
5931
  const task = new MergeTask({}, config);
6206
5932
  return task.run(input2);
6207
5933
  };
6208
- Workflow19.prototype.merge = CreateWorkflow18(MergeTask);
5934
+ Workflow18.prototype.merge = CreateWorkflow17(MergeTask);
6209
5935
  // src/task/OutputTask.ts
6210
- import { CreateWorkflow as CreateWorkflow19, Task as Task17, Workflow as Workflow20 } from "@workglow/task-graph";
5936
+ import {
5937
+ CreateWorkflow as CreateWorkflow18,
5938
+ Task as Task16,
5939
+ Workflow as Workflow19
5940
+ } from "@workglow/task-graph";
6211
5941
 
6212
- class OutputTask extends Task17 {
5942
+ class OutputTask extends Task16 {
6213
5943
  static type = "OutputTask";
6214
5944
  static category = "Flow Control";
6215
5945
  static title = "Output";
@@ -6263,10 +5993,10 @@ class OutputTask extends Task17 {
6263
5993
  yield { type: "finish", data: input2 };
6264
5994
  }
6265
5995
  }
6266
- Workflow20.prototype.output = CreateWorkflow19(OutputTask);
5996
+ Workflow19.prototype.output = CreateWorkflow18(OutputTask);
6267
5997
  // src/task/SplitTask.ts
6268
- import { CreateWorkflow as CreateWorkflow20, Task as Task18, Workflow as Workflow21 } from "@workglow/task-graph";
6269
- var inputSchema18 = {
5998
+ import { CreateWorkflow as CreateWorkflow19, Task as Task17, Workflow as Workflow20 } from "@workglow/task-graph";
5999
+ var inputSchema17 = {
6270
6000
  type: "object",
6271
6001
  properties: {
6272
6002
  input: {
@@ -6276,13 +6006,13 @@ var inputSchema18 = {
6276
6006
  },
6277
6007
  additionalProperties: false
6278
6008
  };
6279
- var outputSchema18 = {
6009
+ var outputSchema17 = {
6280
6010
  type: "object",
6281
6011
  properties: {},
6282
6012
  additionalProperties: true
6283
6013
  };
6284
6014
 
6285
- class SplitTask extends Task18 {
6015
+ class SplitTask extends Task17 {
6286
6016
  static type = "SplitTask";
6287
6017
  static category = "Utility";
6288
6018
  static title = "Split";
@@ -6290,13 +6020,13 @@ class SplitTask extends Task18 {
6290
6020
  static hasDynamicSchemas = true;
6291
6021
  static cacheable = false;
6292
6022
  static inputSchema() {
6293
- return inputSchema18;
6023
+ return inputSchema17;
6294
6024
  }
6295
6025
  static outputSchema() {
6296
- return outputSchema18;
6026
+ return outputSchema17;
6297
6027
  }
6298
6028
  outputSchema() {
6299
- return outputSchema18;
6029
+ return outputSchema17;
6300
6030
  }
6301
6031
  async executeReactive(input2) {
6302
6032
  const inputValue = input2.input;
@@ -6315,15 +6045,15 @@ var split = (input2, config = {}) => {
6315
6045
  const task = new SplitTask({}, config);
6316
6046
  return task.run(input2);
6317
6047
  };
6318
- Workflow21.prototype.split = CreateWorkflow20(SplitTask);
6048
+ Workflow20.prototype.split = CreateWorkflow19(SplitTask);
6319
6049
  // src/task/mcp/McpListTask.ts
6320
- import { CreateWorkflow as CreateWorkflow21, Task as Task19, Workflow as Workflow22 } from "@workglow/task-graph";
6050
+ import { CreateWorkflow as CreateWorkflow20, Task as Task18, Workflow as Workflow21 } from "@workglow/task-graph";
6321
6051
  import {
6322
6052
  mcpClientFactory,
6323
6053
  mcpServerConfigSchema
6324
6054
  } from "@workglow/util";
6325
6055
  var mcpListTypes = ["tools", "resources", "prompts"];
6326
- var inputSchema19 = {
6056
+ var inputSchema18 = {
6327
6057
  type: "object",
6328
6058
  properties: {
6329
6059
  ...mcpServerConfigSchema,
@@ -6492,7 +6222,7 @@ var outputSchemaAll = {
6492
6222
  additionalProperties: false
6493
6223
  };
6494
6224
 
6495
- class McpListTask extends Task19 {
6225
+ class McpListTask extends Task18 {
6496
6226
  static type = "McpListTask";
6497
6227
  static category = "MCP";
6498
6228
  static title = "MCP List";
@@ -6500,7 +6230,7 @@ class McpListTask extends Task19 {
6500
6230
  static cacheable = false;
6501
6231
  static hasDynamicSchemas = true;
6502
6232
  static inputSchema() {
6503
- return inputSchema19;
6233
+ return inputSchema18;
6504
6234
  }
6505
6235
  static outputSchema() {
6506
6236
  return outputSchemaAll;
@@ -6560,30 +6290,34 @@ class McpListTask extends Task19 {
6560
6290
  var mcpList = async (input2, config = {}) => {
6561
6291
  return new McpListTask({}, config).run(input2);
6562
6292
  };
6563
- Workflow22.prototype.mcpList = CreateWorkflow21(McpListTask);
6293
+ Workflow21.prototype.mcpList = CreateWorkflow20(McpListTask);
6564
6294
  // src/task/mcp/McpPromptGetTask.ts
6565
- import { CreateWorkflow as CreateWorkflow22, Task as Task20, Workflow as Workflow23 } from "@workglow/task-graph";
6295
+ import {
6296
+ CreateWorkflow as CreateWorkflow21,
6297
+ Task as Task19,
6298
+ TaskConfigSchema as TaskConfigSchema5,
6299
+ Workflow as Workflow22
6300
+ } from "@workglow/task-graph";
6566
6301
  import {
6567
6302
  mcpClientFactory as mcpClientFactory2,
6568
6303
  mcpServerConfigSchema as mcpServerConfigSchema2
6569
6304
  } from "@workglow/util";
6570
- var inputSchema20 = {
6305
+ var configSchema2 = {
6571
6306
  type: "object",
6572
6307
  properties: {
6308
+ ...TaskConfigSchema5["properties"],
6573
6309
  ...mcpServerConfigSchema2,
6574
6310
  prompt_name: {
6575
6311
  type: "string",
6576
6312
  title: "Prompt Name",
6577
- description: "The name of the prompt to get"
6578
- },
6579
- prompt_arguments: {
6580
- type: "object",
6581
- additionalProperties: { type: "string" },
6582
- title: "Prompt Arguments",
6583
- description: "Arguments to pass to the prompt"
6313
+ description: "The name of the prompt to get",
6314
+ format: "string:mcp-promptname"
6584
6315
  }
6585
6316
  },
6586
6317
  required: ["transport", "prompt_name"],
6318
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6319
+ then: { required: ["command"] },
6320
+ else: { required: ["server_url"] },
6587
6321
  additionalProperties: false
6588
6322
  };
6589
6323
  var annotationsSchema = {
@@ -6687,7 +6421,7 @@ var contentSchema = {
6687
6421
  }
6688
6422
  ]
6689
6423
  };
6690
- var outputSchema19 = {
6424
+ var fallbackOutputSchema = {
6691
6425
  type: "object",
6692
6426
  properties: {
6693
6427
  messages: {
@@ -6713,25 +6447,83 @@ var outputSchema19 = {
6713
6447
  required: ["messages"],
6714
6448
  additionalProperties: false
6715
6449
  };
6450
+ var fallbackInputSchema = {
6451
+ type: "object",
6452
+ properties: {},
6453
+ additionalProperties: false
6454
+ };
6716
6455
 
6717
- class McpPromptGetTask extends Task20 {
6456
+ class McpPromptGetTask extends Task19 {
6718
6457
  static type = "McpPromptGetTask";
6719
6458
  static category = "MCP";
6720
6459
  static title = "MCP Get Prompt";
6721
6460
  static description = "Gets a prompt from an MCP server";
6722
6461
  static cacheable = false;
6462
+ static customizable = true;
6463
+ static hasDynamicSchemas = true;
6723
6464
  static inputSchema() {
6724
- return inputSchema20;
6465
+ return fallbackInputSchema;
6725
6466
  }
6726
6467
  static outputSchema() {
6727
- return outputSchema19;
6468
+ return fallbackOutputSchema;
6469
+ }
6470
+ static configSchema() {
6471
+ return configSchema2;
6472
+ }
6473
+ inputSchema() {
6474
+ return this.config?.inputSchema ?? fallbackInputSchema;
6475
+ }
6476
+ outputSchema() {
6477
+ return this.config?.outputSchema ?? fallbackOutputSchema;
6478
+ }
6479
+ _schemasDiscovering = false;
6480
+ async discoverSchemas(signal) {
6481
+ if (this.config.inputSchema)
6482
+ return;
6483
+ if (this._schemasDiscovering)
6484
+ return;
6485
+ if (!this.config.transport || !this.config.prompt_name)
6486
+ return;
6487
+ this._schemasDiscovering = true;
6488
+ try {
6489
+ const result = await mcpList({
6490
+ transport: this.config.transport,
6491
+ server_url: this.config.server_url,
6492
+ command: this.config.command,
6493
+ args: this.config.args,
6494
+ env: this.config.env,
6495
+ list_type: "prompts"
6496
+ });
6497
+ const prompt = result.prompts?.find((p) => p.name === this.config.prompt_name);
6498
+ if (prompt) {
6499
+ const args = prompt.arguments ?? [];
6500
+ const required = args.filter((a) => a.required).map((a) => a.name);
6501
+ const properties = {};
6502
+ for (const arg of args) {
6503
+ properties[arg.name] = {
6504
+ type: "string",
6505
+ ...arg.description ? { description: arg.description } : {}
6506
+ };
6507
+ }
6508
+ this.config.inputSchema = {
6509
+ type: "object",
6510
+ properties,
6511
+ ...required.length > 0 ? { required } : {},
6512
+ additionalProperties: false
6513
+ };
6514
+ this.emitSchemaChange();
6515
+ }
6516
+ } finally {
6517
+ this._schemasDiscovering = false;
6518
+ }
6728
6519
  }
6729
6520
  async execute(input2, context) {
6730
- const { client } = await mcpClientFactory2.create(input2, context.signal);
6521
+ await this.discoverSchemas(context.signal);
6522
+ const { client } = await mcpClientFactory2.create(this.config, context.signal);
6731
6523
  try {
6732
6524
  const result = await client.getPrompt({
6733
- name: input2.prompt_name,
6734
- arguments: input2.prompt_arguments
6525
+ name: this.config.prompt_name,
6526
+ arguments: input2
6735
6527
  });
6736
6528
  return {
6737
6529
  messages: result.messages,
@@ -6742,28 +6534,37 @@ class McpPromptGetTask extends Task20 {
6742
6534
  }
6743
6535
  }
6744
6536
  }
6745
- var mcpPromptGet = async (input2, config = {}) => {
6746
- const result = await new McpPromptGetTask({}, config).run(input2);
6747
- return result;
6537
+ var mcpPromptGet = async (input2, config) => {
6538
+ return new McpPromptGetTask({}, config).run(input2);
6748
6539
  };
6749
- Workflow23.prototype.mcpPromptGet = CreateWorkflow22(McpPromptGetTask);
6540
+ Workflow22.prototype.mcpPromptGet = CreateWorkflow21(McpPromptGetTask);
6750
6541
  // src/task/mcp/McpResourceReadTask.ts
6751
- import { CreateWorkflow as CreateWorkflow23, Task as Task21, Workflow as Workflow24 } from "@workglow/task-graph";
6542
+ import {
6543
+ CreateWorkflow as CreateWorkflow22,
6544
+ Task as Task20,
6545
+ TaskConfigSchema as TaskConfigSchema6,
6546
+ Workflow as Workflow23
6547
+ } from "@workglow/task-graph";
6752
6548
  import {
6753
6549
  mcpClientFactory as mcpClientFactory3,
6754
6550
  mcpServerConfigSchema as mcpServerConfigSchema3
6755
6551
  } from "@workglow/util";
6756
- var inputSchema21 = {
6552
+ var configSchema3 = {
6757
6553
  type: "object",
6758
6554
  properties: {
6555
+ ...TaskConfigSchema6["properties"],
6759
6556
  ...mcpServerConfigSchema3,
6760
6557
  resource_uri: {
6761
6558
  type: "string",
6762
6559
  title: "Resource URI",
6763
- description: "The URI of the resource to read"
6560
+ description: "The URI of the resource to read",
6561
+ format: "string:uri:mcp-resourceuri"
6764
6562
  }
6765
6563
  },
6766
6564
  required: ["transport", "resource_uri"],
6565
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6566
+ then: { required: ["command"] },
6567
+ else: { required: ["server_url"] },
6767
6568
  additionalProperties: false
6768
6569
  };
6769
6570
  var contentItemSchema = {
@@ -6792,7 +6593,12 @@ var contentItemSchema = {
6792
6593
  }
6793
6594
  ]
6794
6595
  };
6795
- var outputSchema20 = {
6596
+ var inputSchema19 = {
6597
+ type: "object",
6598
+ properties: {},
6599
+ additionalProperties: false
6600
+ };
6601
+ var outputSchema18 = {
6796
6602
  type: "object",
6797
6603
  properties: {
6798
6604
  contents: {
@@ -6806,55 +6612,63 @@ var outputSchema20 = {
6806
6612
  additionalProperties: false
6807
6613
  };
6808
6614
 
6809
- class McpResourceReadTask extends Task21 {
6615
+ class McpResourceReadTask extends Task20 {
6810
6616
  static type = "McpResourceReadTask";
6811
6617
  static category = "MCP";
6812
6618
  static title = "MCP Read Resource";
6813
6619
  static description = "Reads a resource from an MCP server";
6814
6620
  static cacheable = false;
6621
+ static customizable = true;
6815
6622
  static inputSchema() {
6816
- return inputSchema21;
6623
+ return inputSchema19;
6817
6624
  }
6818
6625
  static outputSchema() {
6819
- return outputSchema20;
6626
+ return outputSchema18;
6820
6627
  }
6821
- async execute(input2, context) {
6822
- const { client } = await mcpClientFactory3.create(input2, context.signal);
6628
+ static configSchema() {
6629
+ return configSchema3;
6630
+ }
6631
+ async execute(_input, context) {
6632
+ const { client } = await mcpClientFactory3.create(this.config, context.signal);
6823
6633
  try {
6824
- const result = await client.readResource({ uri: input2.resource_uri });
6634
+ const result = await client.readResource({ uri: this.config.resource_uri });
6825
6635
  return { contents: result.contents };
6826
6636
  } finally {
6827
6637
  await client.close();
6828
6638
  }
6829
6639
  }
6830
6640
  }
6831
- var mcpResourceRead = async (input2, config = {}) => {
6832
- return new McpResourceReadTask({}, config).run(input2);
6641
+ var mcpResourceRead = async (config) => {
6642
+ return new McpResourceReadTask({}, config).run({});
6833
6643
  };
6834
- Workflow24.prototype.mcpResourceRead = CreateWorkflow23(McpResourceReadTask);
6644
+ Workflow23.prototype.mcpResourceRead = CreateWorkflow22(McpResourceReadTask);
6835
6645
  // src/task/mcp/McpToolCallTask.ts
6836
- import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
6646
+ import {
6647
+ CreateWorkflow as CreateWorkflow23,
6648
+ Task as Task21,
6649
+ TaskConfigSchema as TaskConfigSchema7,
6650
+ Workflow as Workflow24
6651
+ } from "@workglow/task-graph";
6837
6652
  import {
6838
6653
  mcpClientFactory as mcpClientFactory4,
6839
6654
  mcpServerConfigSchema as mcpServerConfigSchema4
6840
6655
  } from "@workglow/util";
6841
- var inputSchema22 = {
6656
+ var configSchema4 = {
6842
6657
  type: "object",
6843
6658
  properties: {
6659
+ ...TaskConfigSchema7["properties"],
6844
6660
  ...mcpServerConfigSchema4,
6845
6661
  tool_name: {
6846
6662
  type: "string",
6847
6663
  title: "Tool Name",
6848
- description: "The name of the tool to call"
6849
- },
6850
- tool_arguments: {
6851
- type: "object",
6852
- additionalProperties: true,
6853
- title: "Tool Arguments",
6854
- description: "Arguments to pass to the tool"
6664
+ description: "The name of the tool to call",
6665
+ format: "string:mcp-toolname"
6855
6666
  }
6856
6667
  },
6857
6668
  required: ["transport", "tool_name"],
6669
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6670
+ then: { required: ["command"] },
6671
+ else: { required: ["server_url"] },
6858
6672
  additionalProperties: false
6859
6673
  };
6860
6674
  var annotationsSchema2 = {
@@ -6958,7 +6772,7 @@ var toolContentSchema = {
6958
6772
  }
6959
6773
  ]
6960
6774
  };
6961
- var outputSchema21 = {
6775
+ var fallbackOutputSchema2 = {
6962
6776
  type: "object",
6963
6777
  properties: {
6964
6778
  content: {
@@ -6976,45 +6790,115 @@ var outputSchema21 = {
6976
6790
  required: ["content", "isError"],
6977
6791
  additionalProperties: false
6978
6792
  };
6793
+ var fallbackInputSchema2 = {
6794
+ type: "object",
6795
+ properties: {},
6796
+ additionalProperties: true
6797
+ };
6979
6798
 
6980
- class McpToolCallTask extends Task22 {
6799
+ class McpToolCallTask extends Task21 {
6981
6800
  static type = "McpToolCallTask";
6982
6801
  static category = "MCP";
6983
6802
  static title = "MCP Call Tool";
6984
6803
  static description = "Calls a tool on an MCP server and returns the result";
6985
6804
  static cacheable = false;
6805
+ static customizable = true;
6806
+ static hasDynamicSchemas = true;
6986
6807
  static inputSchema() {
6987
- return inputSchema22;
6808
+ return fallbackInputSchema2;
6988
6809
  }
6989
6810
  static outputSchema() {
6990
- return outputSchema21;
6811
+ return fallbackOutputSchema2;
6812
+ }
6813
+ static configSchema() {
6814
+ return configSchema4;
6815
+ }
6816
+ inputSchema() {
6817
+ return this.config?.inputSchema ?? fallbackInputSchema2;
6818
+ }
6819
+ outputSchema() {
6820
+ return this.config?.outputSchema ?? fallbackOutputSchema2;
6821
+ }
6822
+ _schemasDiscovering = false;
6823
+ async discoverSchemas(signal) {
6824
+ if (this.config.inputSchema && this.config.outputSchema)
6825
+ return;
6826
+ if (this._schemasDiscovering)
6827
+ return;
6828
+ if (!this.config.transport || !this.config.tool_name)
6829
+ return;
6830
+ this._schemasDiscovering = true;
6831
+ try {
6832
+ const result = await mcpList({
6833
+ transport: this.config.transport,
6834
+ server_url: this.config.server_url,
6835
+ command: this.config.command,
6836
+ args: this.config.args,
6837
+ env: this.config.env,
6838
+ list_type: "tools"
6839
+ });
6840
+ const tool = result.tools?.find((t) => t.name === this.config.tool_name);
6841
+ if (tool) {
6842
+ if (!this.config.inputSchema) {
6843
+ this.config.inputSchema = tool.inputSchema;
6844
+ }
6845
+ if (!this.config.outputSchema && tool.outputSchema) {
6846
+ this.config.outputSchema = tool.outputSchema;
6847
+ }
6848
+ this.emitSchemaChange();
6849
+ }
6850
+ } finally {
6851
+ this._schemasDiscovering = false;
6852
+ }
6991
6853
  }
6992
6854
  async execute(input2, context) {
6993
- const { client } = await mcpClientFactory4.create(input2, context.signal);
6855
+ await this.discoverSchemas(context.signal);
6856
+ const { client } = await mcpClientFactory4.create(this.config, context.signal);
6994
6857
  try {
6995
6858
  const result = await client.callTool({
6996
- name: input2.tool_name,
6997
- arguments: input2.tool_arguments
6859
+ name: this.config.tool_name,
6860
+ arguments: input2
6998
6861
  });
6999
6862
  if (!("content" in result) || !Array.isArray(result.content)) {
7000
6863
  throw new Error("Expected tool result with content array");
7001
6864
  }
6865
+ const content = result.content;
6866
+ const isError = result.isError === true;
6867
+ const structuredContent = "structuredContent" in result && result.structuredContent && typeof result.structuredContent === "object" && !Array.isArray(result.structuredContent) ? result.structuredContent : undefined;
6868
+ let parsedFromText;
6869
+ if (!structuredContent && content.length === 1) {
6870
+ const item = content[0];
6871
+ if (item && typeof item === "object" && "type" in item && item.type === "text" && "text" in item) {
6872
+ const text = String(item.text);
6873
+ const trimmed = text.trim();
6874
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
6875
+ try {
6876
+ const parsed = JSON.parse(text);
6877
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
6878
+ parsedFromText = parsed;
6879
+ }
6880
+ } catch {}
6881
+ }
6882
+ }
6883
+ }
7002
6884
  return {
7003
- content: result.content,
7004
- isError: result.isError === true
6885
+ content,
6886
+ isError,
6887
+ ...parsedFromText,
6888
+ ...structuredContent
7005
6889
  };
7006
6890
  } finally {
7007
6891
  await client.close();
7008
6892
  }
7009
6893
  }
7010
6894
  }
7011
- var mcpToolCall = async (input2, config = {}) => {
6895
+ var mcpToolCall = async (input2, config) => {
7012
6896
  return new McpToolCallTask({}, config).run(input2);
7013
6897
  };
7014
- Workflow25.prototype.mcpToolCall = CreateWorkflow24(McpToolCallTask);
6898
+ Workflow24.prototype.mcpToolCall = CreateWorkflow23(McpToolCallTask);
7015
6899
  // src/task/scalar/ScalarAbsTask.ts
7016
- import { CreateWorkflow as CreateWorkflow25, Task as Task23, Workflow as Workflow26 } from "@workglow/task-graph";
7017
- var inputSchema23 = {
6900
+ import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
6901
+ var inputSchema20 = {
7018
6902
  type: "object",
7019
6903
  properties: {
7020
6904
  value: {
@@ -7026,7 +6910,7 @@ var inputSchema23 = {
7026
6910
  required: ["value"],
7027
6911
  additionalProperties: false
7028
6912
  };
7029
- var outputSchema22 = {
6913
+ var outputSchema19 = {
7030
6914
  type: "object",
7031
6915
  properties: {
7032
6916
  result: {
@@ -7039,25 +6923,25 @@ var outputSchema22 = {
7039
6923
  additionalProperties: false
7040
6924
  };
7041
6925
 
7042
- class ScalarAbsTask extends Task23 {
6926
+ class ScalarAbsTask extends Task22 {
7043
6927
  static type = "ScalarAbsTask";
7044
6928
  static category = "Math";
7045
6929
  static title = "Abs";
7046
6930
  static description = "Returns the absolute value of a number";
7047
6931
  static inputSchema() {
7048
- return inputSchema23;
6932
+ return inputSchema20;
7049
6933
  }
7050
6934
  static outputSchema() {
7051
- return outputSchema22;
6935
+ return outputSchema19;
7052
6936
  }
7053
6937
  async execute(input2, _context) {
7054
6938
  return { result: Math.abs(input2.value) };
7055
6939
  }
7056
6940
  }
7057
- Workflow26.prototype.scalarAbs = CreateWorkflow25(ScalarAbsTask);
6941
+ Workflow25.prototype.scalarAbs = CreateWorkflow24(ScalarAbsTask);
7058
6942
  // src/task/scalar/ScalarCeilTask.ts
7059
- import { CreateWorkflow as CreateWorkflow26, Task as Task24, Workflow as Workflow27 } from "@workglow/task-graph";
7060
- var inputSchema24 = {
6943
+ import { CreateWorkflow as CreateWorkflow25, Task as Task23, Workflow as Workflow26 } from "@workglow/task-graph";
6944
+ var inputSchema21 = {
7061
6945
  type: "object",
7062
6946
  properties: {
7063
6947
  value: {
@@ -7069,7 +6953,7 @@ var inputSchema24 = {
7069
6953
  required: ["value"],
7070
6954
  additionalProperties: false
7071
6955
  };
7072
- var outputSchema23 = {
6956
+ var outputSchema20 = {
7073
6957
  type: "object",
7074
6958
  properties: {
7075
6959
  result: {
@@ -7082,515 +6966,963 @@ var outputSchema23 = {
7082
6966
  additionalProperties: false
7083
6967
  };
7084
6968
 
7085
- class ScalarCeilTask extends Task24 {
6969
+ class ScalarCeilTask extends Task23 {
7086
6970
  static type = "ScalarCeilTask";
7087
6971
  static category = "Math";
7088
6972
  static title = "Ceil";
7089
6973
  static description = "Returns the smallest integer greater than or equal to a number";
7090
6974
  static inputSchema() {
7091
- return inputSchema24;
6975
+ return inputSchema21;
7092
6976
  }
7093
6977
  static outputSchema() {
7094
- return outputSchema23;
6978
+ return outputSchema20;
7095
6979
  }
7096
6980
  async execute(input2, _context) {
7097
6981
  return { result: Math.ceil(input2.value) };
7098
6982
  }
7099
6983
  }
7100
- Workflow27.prototype.scalarCeil = CreateWorkflow26(ScalarCeilTask);
6984
+ Workflow26.prototype.scalarCeil = CreateWorkflow25(ScalarCeilTask);
7101
6985
  // src/task/scalar/ScalarFloorTask.ts
6986
+ import { CreateWorkflow as CreateWorkflow26, Task as Task24, Workflow as Workflow27 } from "@workglow/task-graph";
6987
+ var inputSchema22 = {
6988
+ type: "object",
6989
+ properties: {
6990
+ value: {
6991
+ type: "number",
6992
+ title: "Value",
6993
+ description: "Input number"
6994
+ }
6995
+ },
6996
+ required: ["value"],
6997
+ additionalProperties: false
6998
+ };
6999
+ var outputSchema21 = {
7000
+ type: "object",
7001
+ properties: {
7002
+ result: {
7003
+ type: "number",
7004
+ title: "Result",
7005
+ description: "Floored value"
7006
+ }
7007
+ },
7008
+ required: ["result"],
7009
+ additionalProperties: false
7010
+ };
7011
+
7012
+ class ScalarFloorTask extends Task24 {
7013
+ static type = "ScalarFloorTask";
7014
+ static category = "Math";
7015
+ static title = "Floor";
7016
+ static description = "Returns the largest integer less than or equal to a number";
7017
+ static inputSchema() {
7018
+ return inputSchema22;
7019
+ }
7020
+ static outputSchema() {
7021
+ return outputSchema21;
7022
+ }
7023
+ async execute(input2, _context) {
7024
+ return { result: Math.floor(input2.value) };
7025
+ }
7026
+ }
7027
+ Workflow27.prototype.scalarFloor = CreateWorkflow26(ScalarFloorTask);
7028
+ // src/task/scalar/ScalarMaxTask.ts
7102
7029
  import { CreateWorkflow as CreateWorkflow27, Task as Task25, Workflow as Workflow28 } from "@workglow/task-graph";
7030
+ var inputSchema23 = {
7031
+ type: "object",
7032
+ properties: {
7033
+ values: {
7034
+ type: "array",
7035
+ items: { type: "number" },
7036
+ title: "Values",
7037
+ description: "Array of numbers"
7038
+ }
7039
+ },
7040
+ required: ["values"],
7041
+ additionalProperties: false
7042
+ };
7043
+ var outputSchema22 = {
7044
+ type: "object",
7045
+ properties: {
7046
+ result: {
7047
+ type: "number",
7048
+ title: "Result",
7049
+ description: "Maximum value"
7050
+ }
7051
+ },
7052
+ required: ["result"],
7053
+ additionalProperties: false
7054
+ };
7055
+
7056
+ class ScalarMaxTask extends Task25 {
7057
+ static type = "ScalarMaxTask";
7058
+ static category = "Math";
7059
+ static title = "Max";
7060
+ static description = "Returns the largest of the given numbers";
7061
+ static inputSchema() {
7062
+ return inputSchema23;
7063
+ }
7064
+ static outputSchema() {
7065
+ return outputSchema22;
7066
+ }
7067
+ async execute(input2, _context) {
7068
+ return { result: Math.max(...input2.values) };
7069
+ }
7070
+ }
7071
+ Workflow28.prototype.scalarMax = CreateWorkflow27(ScalarMaxTask);
7072
+ // src/task/scalar/ScalarMinTask.ts
7073
+ import { CreateWorkflow as CreateWorkflow28, Task as Task26, Workflow as Workflow29 } from "@workglow/task-graph";
7074
+ var inputSchema24 = {
7075
+ type: "object",
7076
+ properties: {
7077
+ values: {
7078
+ type: "array",
7079
+ items: { type: "number" },
7080
+ title: "Values",
7081
+ description: "Array of numbers"
7082
+ }
7083
+ },
7084
+ required: ["values"],
7085
+ additionalProperties: false
7086
+ };
7087
+ var outputSchema23 = {
7088
+ type: "object",
7089
+ properties: {
7090
+ result: {
7091
+ type: "number",
7092
+ title: "Result",
7093
+ description: "Minimum value"
7094
+ }
7095
+ },
7096
+ required: ["result"],
7097
+ additionalProperties: false
7098
+ };
7099
+
7100
+ class ScalarMinTask extends Task26 {
7101
+ static type = "ScalarMinTask";
7102
+ static category = "Math";
7103
+ static title = "Min";
7104
+ static description = "Returns the smallest of the given numbers";
7105
+ static inputSchema() {
7106
+ return inputSchema24;
7107
+ }
7108
+ static outputSchema() {
7109
+ return outputSchema23;
7110
+ }
7111
+ async execute(input2, _context) {
7112
+ return { result: Math.min(...input2.values) };
7113
+ }
7114
+ }
7115
+ Workflow29.prototype.scalarMin = CreateWorkflow28(ScalarMinTask);
7116
+ // src/task/scalar/ScalarRoundTask.ts
7117
+ import { CreateWorkflow as CreateWorkflow29, Task as Task27, Workflow as Workflow30 } from "@workglow/task-graph";
7103
7118
  var inputSchema25 = {
7104
7119
  type: "object",
7105
7120
  properties: {
7106
- value: {
7107
- type: "number",
7108
- title: "Value",
7109
- description: "Input number"
7121
+ value: {
7122
+ type: "number",
7123
+ title: "Value",
7124
+ description: "Input number"
7125
+ }
7126
+ },
7127
+ required: ["value"],
7128
+ additionalProperties: false
7129
+ };
7130
+ var outputSchema24 = {
7131
+ type: "object",
7132
+ properties: {
7133
+ result: {
7134
+ type: "number",
7135
+ title: "Result",
7136
+ description: "Rounded value"
7137
+ }
7138
+ },
7139
+ required: ["result"],
7140
+ additionalProperties: false
7141
+ };
7142
+
7143
+ class ScalarRoundTask extends Task27 {
7144
+ static type = "ScalarRoundTask";
7145
+ static category = "Math";
7146
+ static title = "Round";
7147
+ static description = "Returns the value of a number rounded to the nearest integer";
7148
+ static inputSchema() {
7149
+ return inputSchema25;
7150
+ }
7151
+ static outputSchema() {
7152
+ return outputSchema24;
7153
+ }
7154
+ async execute(input2, _context) {
7155
+ return { result: Math.round(input2.value) };
7156
+ }
7157
+ }
7158
+ Workflow30.prototype.scalarRound = CreateWorkflow29(ScalarRoundTask);
7159
+ // src/task/scalar/ScalarTruncTask.ts
7160
+ import { CreateWorkflow as CreateWorkflow30, Task as Task28, Workflow as Workflow31 } from "@workglow/task-graph";
7161
+ var inputSchema26 = {
7162
+ type: "object",
7163
+ properties: {
7164
+ value: {
7165
+ type: "number",
7166
+ title: "Value",
7167
+ description: "Input number"
7168
+ }
7169
+ },
7170
+ required: ["value"],
7171
+ additionalProperties: false
7172
+ };
7173
+ var outputSchema25 = {
7174
+ type: "object",
7175
+ properties: {
7176
+ result: {
7177
+ type: "number",
7178
+ title: "Result",
7179
+ description: "Truncated value"
7180
+ }
7181
+ },
7182
+ required: ["result"],
7183
+ additionalProperties: false
7184
+ };
7185
+
7186
+ class ScalarTruncTask extends Task28 {
7187
+ static type = "ScalarTruncTask";
7188
+ static category = "Math";
7189
+ static title = "Truncate";
7190
+ static description = "Returns the integer part of a number by removing fractional digits";
7191
+ static inputSchema() {
7192
+ return inputSchema26;
7193
+ }
7194
+ static outputSchema() {
7195
+ return outputSchema25;
7196
+ }
7197
+ async execute(input2, _context) {
7198
+ return { result: Math.trunc(input2.value) };
7199
+ }
7200
+ }
7201
+ Workflow31.prototype.scalarTrunc = CreateWorkflow30(ScalarTruncTask);
7202
+ // src/task/vector/VectorDistanceTask.ts
7203
+ import { CreateWorkflow as CreateWorkflow31, Task as Task29, Workflow as Workflow32 } from "@workglow/task-graph";
7204
+ import {
7205
+ TypedArraySchema as TypedArraySchema5
7206
+ } from "@workglow/util";
7207
+ var inputSchema27 = {
7208
+ type: "object",
7209
+ properties: {
7210
+ vectors: {
7211
+ type: "array",
7212
+ items: TypedArraySchema5({
7213
+ title: "Vector",
7214
+ description: "Vector for distance computation"
7215
+ }),
7216
+ title: "Vectors",
7217
+ description: "Array of two vectors to compute Euclidean distance"
7110
7218
  }
7111
7219
  },
7112
- required: ["value"],
7220
+ required: ["vectors"],
7113
7221
  additionalProperties: false
7114
7222
  };
7115
- var outputSchema24 = {
7223
+ var outputSchema26 = {
7116
7224
  type: "object",
7117
7225
  properties: {
7118
7226
  result: {
7119
7227
  type: "number",
7120
7228
  title: "Result",
7121
- description: "Floored value"
7229
+ description: "Euclidean distance between vectors"
7122
7230
  }
7123
7231
  },
7124
7232
  required: ["result"],
7125
7233
  additionalProperties: false
7126
7234
  };
7127
7235
 
7128
- class ScalarFloorTask extends Task25 {
7129
- static type = "ScalarFloorTask";
7130
- static category = "Math";
7131
- static title = "Floor";
7132
- static description = "Returns the largest integer less than or equal to a number";
7236
+ class VectorDistanceTask extends Task29 {
7237
+ static type = "VectorDistanceTask";
7238
+ static category = "Vector";
7239
+ static title = "Distance";
7240
+ static description = "Returns the Euclidean distance between the first two vectors";
7133
7241
  static inputSchema() {
7134
- return inputSchema25;
7242
+ return inputSchema27;
7135
7243
  }
7136
7244
  static outputSchema() {
7137
- return outputSchema24;
7245
+ return outputSchema26;
7138
7246
  }
7139
7247
  async execute(input2, _context) {
7140
- return { result: Math.floor(input2.value) };
7248
+ const { vectors } = input2;
7249
+ if (vectors.length < 2) {
7250
+ throw new Error("Exactly two vectors are required for distance");
7251
+ }
7252
+ const [a, b] = vectors;
7253
+ if (a.length !== b.length) {
7254
+ throw new Error("Vectors must have the same length");
7255
+ }
7256
+ const diffs = Array.from({ length: a.length }, (_, i) => {
7257
+ const d = Number(a[i]) - Number(b[i]);
7258
+ return d * d;
7259
+ });
7260
+ return { result: Math.sqrt(sumPrecise(diffs)) };
7141
7261
  }
7142
7262
  }
7143
- Workflow28.prototype.scalarFloor = CreateWorkflow27(ScalarFloorTask);
7144
- // src/task/scalar/ScalarMaxTask.ts
7145
- import { CreateWorkflow as CreateWorkflow28, Task as Task26, Workflow as Workflow29 } from "@workglow/task-graph";
7146
- var inputSchema26 = {
7263
+ Workflow32.prototype.vectorDistance = CreateWorkflow31(VectorDistanceTask);
7264
+ // src/task/vector/VectorDotProductTask.ts
7265
+ import { CreateWorkflow as CreateWorkflow32, Task as Task30, Workflow as Workflow33 } from "@workglow/task-graph";
7266
+ import {
7267
+ TypedArraySchema as TypedArraySchema6
7268
+ } from "@workglow/util";
7269
+ var inputSchema28 = {
7147
7270
  type: "object",
7148
7271
  properties: {
7149
- values: {
7272
+ vectors: {
7150
7273
  type: "array",
7151
- items: { type: "number" },
7152
- title: "Values",
7153
- description: "Array of numbers"
7274
+ items: TypedArraySchema6({
7275
+ title: "Vector",
7276
+ description: "Vector for dot product"
7277
+ }),
7278
+ title: "Vectors",
7279
+ description: "Array of two vectors to compute dot product"
7154
7280
  }
7155
7281
  },
7156
- required: ["values"],
7282
+ required: ["vectors"],
7157
7283
  additionalProperties: false
7158
7284
  };
7159
- var outputSchema25 = {
7285
+ var outputSchema27 = {
7160
7286
  type: "object",
7161
7287
  properties: {
7162
7288
  result: {
7163
7289
  type: "number",
7164
7290
  title: "Result",
7165
- description: "Maximum value"
7291
+ description: "Dot product of the vectors"
7166
7292
  }
7167
7293
  },
7168
7294
  required: ["result"],
7169
7295
  additionalProperties: false
7170
7296
  };
7171
7297
 
7172
- class ScalarMaxTask extends Task26 {
7173
- static type = "ScalarMaxTask";
7174
- static category = "Math";
7175
- static title = "Max";
7176
- static description = "Returns the largest of the given numbers";
7298
+ class VectorDotProductTask extends Task30 {
7299
+ static type = "VectorDotProductTask";
7300
+ static category = "Vector";
7301
+ static title = "Dot Product";
7302
+ static description = "Returns the dot (inner) product of the first two vectors";
7177
7303
  static inputSchema() {
7178
- return inputSchema26;
7304
+ return inputSchema28;
7179
7305
  }
7180
7306
  static outputSchema() {
7181
- return outputSchema25;
7307
+ return outputSchema27;
7182
7308
  }
7183
7309
  async execute(input2, _context) {
7184
- return { result: Math.max(...input2.values) };
7310
+ const { vectors } = input2;
7311
+ if (vectors.length < 2) {
7312
+ throw new Error("Exactly two vectors are required for dot product");
7313
+ }
7314
+ const [a, b] = vectors;
7315
+ if (a.length !== b.length) {
7316
+ throw new Error("Vectors must have the same length");
7317
+ }
7318
+ const products = Array.from({ length: a.length }, (_, i) => Number(a[i]) * Number(b[i]));
7319
+ return { result: sumPrecise(products) };
7185
7320
  }
7186
7321
  }
7187
- Workflow29.prototype.scalarMax = CreateWorkflow28(ScalarMaxTask);
7188
- // src/task/scalar/ScalarMinTask.ts
7189
- import { CreateWorkflow as CreateWorkflow29, Task as Task27, Workflow as Workflow30 } from "@workglow/task-graph";
7190
- var inputSchema27 = {
7322
+ Workflow33.prototype.vectorDotProduct = CreateWorkflow32(VectorDotProductTask);
7323
+ // src/task/vector/VectorNormalizeTask.ts
7324
+ import { CreateWorkflow as CreateWorkflow33, Task as Task31, Workflow as Workflow34 } from "@workglow/task-graph";
7325
+ import {
7326
+ TypedArraySchema as TypedArraySchema7,
7327
+ normalize
7328
+ } from "@workglow/util";
7329
+ var inputSchema29 = {
7191
7330
  type: "object",
7192
7331
  properties: {
7193
- values: {
7194
- type: "array",
7195
- items: { type: "number" },
7196
- title: "Values",
7197
- description: "Array of numbers"
7198
- }
7332
+ vector: TypedArraySchema7({
7333
+ title: "Vector",
7334
+ description: "Input vector to normalize"
7335
+ })
7199
7336
  },
7200
- required: ["values"],
7337
+ required: ["vector"],
7201
7338
  additionalProperties: false
7202
7339
  };
7203
- var outputSchema26 = {
7340
+ var outputSchema28 = {
7204
7341
  type: "object",
7205
7342
  properties: {
7206
- result: {
7207
- type: "number",
7343
+ result: TypedArraySchema7({
7208
7344
  title: "Result",
7209
- description: "Minimum value"
7210
- }
7345
+ description: "L2-normalized vector"
7346
+ })
7211
7347
  },
7212
7348
  required: ["result"],
7213
7349
  additionalProperties: false
7214
7350
  };
7215
7351
 
7216
- class ScalarMinTask extends Task27 {
7217
- static type = "ScalarMinTask";
7218
- static category = "Math";
7219
- static title = "Min";
7220
- static description = "Returns the smallest of the given numbers";
7352
+ class VectorNormalizeTask extends Task31 {
7353
+ static type = "VectorNormalizeTask";
7354
+ static category = "Vector";
7355
+ static title = "Normalize";
7356
+ static description = "Returns the L2-normalized (unit length) vector";
7221
7357
  static inputSchema() {
7222
- return inputSchema27;
7358
+ return inputSchema29;
7223
7359
  }
7224
7360
  static outputSchema() {
7225
- return outputSchema26;
7361
+ return outputSchema28;
7226
7362
  }
7227
7363
  async execute(input2, _context) {
7228
- return { result: Math.min(...input2.values) };
7364
+ return { result: normalize(input2.vector) };
7229
7365
  }
7230
7366
  }
7231
- Workflow30.prototype.scalarMin = CreateWorkflow29(ScalarMinTask);
7232
- // src/task/scalar/ScalarRoundTask.ts
7233
- import { CreateWorkflow as CreateWorkflow30, Task as Task28, Workflow as Workflow31 } from "@workglow/task-graph";
7234
- var inputSchema28 = {
7367
+ Workflow34.prototype.vectorNormalize = CreateWorkflow33(VectorNormalizeTask);
7368
+ // src/task/vector/VectorScaleTask.ts
7369
+ import { CreateWorkflow as CreateWorkflow34, Task as Task32, Workflow as Workflow35 } from "@workglow/task-graph";
7370
+ import {
7371
+ createTypedArrayFrom as createTypedArrayFrom5,
7372
+ TypedArraySchema as TypedArraySchema8
7373
+ } from "@workglow/util";
7374
+ var inputSchema30 = {
7235
7375
  type: "object",
7236
7376
  properties: {
7237
- value: {
7377
+ vector: TypedArraySchema8({
7378
+ title: "Vector",
7379
+ description: "Input vector"
7380
+ }),
7381
+ scalar: {
7238
7382
  type: "number",
7239
- title: "Value",
7240
- description: "Input number"
7383
+ title: "Scalar",
7384
+ description: "Scalar multiplier"
7241
7385
  }
7242
7386
  },
7243
- required: ["value"],
7387
+ required: ["vector", "scalar"],
7244
7388
  additionalProperties: false
7245
7389
  };
7246
- var outputSchema27 = {
7390
+ var outputSchema29 = {
7247
7391
  type: "object",
7248
7392
  properties: {
7249
- result: {
7250
- type: "number",
7393
+ result: TypedArraySchema8({
7251
7394
  title: "Result",
7252
- description: "Rounded value"
7253
- }
7395
+ description: "Scaled vector"
7396
+ })
7254
7397
  },
7255
7398
  required: ["result"],
7256
7399
  additionalProperties: false
7257
7400
  };
7258
7401
 
7259
- class ScalarRoundTask extends Task28 {
7260
- static type = "ScalarRoundTask";
7261
- static category = "Math";
7262
- static title = "Round";
7263
- static description = "Returns the value of a number rounded to the nearest integer";
7402
+ class VectorScaleTask extends Task32 {
7403
+ static type = "VectorScaleTask";
7404
+ static category = "Vector";
7405
+ static title = "Scale";
7406
+ static description = "Multiplies each element of a vector by a scalar";
7264
7407
  static inputSchema() {
7265
- return inputSchema28;
7408
+ return inputSchema30;
7266
7409
  }
7267
7410
  static outputSchema() {
7268
- return outputSchema27;
7411
+ return outputSchema29;
7269
7412
  }
7270
7413
  async execute(input2, _context) {
7271
- return { result: Math.round(input2.value) };
7414
+ const { vector, scalar } = input2;
7415
+ const values = Array.from(vector, (v) => Number(v) * scalar);
7416
+ return { result: createTypedArrayFrom5([vector], values) };
7272
7417
  }
7273
7418
  }
7274
- Workflow31.prototype.scalarRound = CreateWorkflow30(ScalarRoundTask);
7275
- // src/task/scalar/ScalarTruncTask.ts
7276
- import { CreateWorkflow as CreateWorkflow31, Task as Task29, Workflow as Workflow32 } from "@workglow/task-graph";
7277
- var inputSchema29 = {
7419
+ Workflow35.prototype.vectorScale = CreateWorkflow34(VectorScaleTask);
7420
+
7421
+ // src/common.ts
7422
+ import { TaskRegistry } from "@workglow/task-graph";
7423
+ var registerCommonTasks = () => {
7424
+ const tasks = [
7425
+ DebugLogTask,
7426
+ DelayTask,
7427
+ FetchUrlTask,
7428
+ InputTask,
7429
+ JavaScriptTask,
7430
+ JsonTask,
7431
+ LambdaTask,
7432
+ MergeTask,
7433
+ OutputTask,
7434
+ SplitTask,
7435
+ ScalarAbsTask,
7436
+ ScalarAddTask,
7437
+ ScalarCeilTask,
7438
+ ScalarDivideTask,
7439
+ ScalarFloorTask,
7440
+ ScalarMaxTask,
7441
+ ScalarMinTask,
7442
+ ScalarMultiplyTask,
7443
+ ScalarRoundTask,
7444
+ ScalarSubtractTask,
7445
+ ScalarSumTask,
7446
+ ScalarTruncTask,
7447
+ VectorSumTask,
7448
+ VectorDistanceTask,
7449
+ VectorDivideTask,
7450
+ VectorDotProductTask,
7451
+ VectorMultiplyTask,
7452
+ VectorNormalizeTask,
7453
+ VectorScaleTask,
7454
+ VectorSubtractTask,
7455
+ McpToolCallTask,
7456
+ McpResourceReadTask,
7457
+ McpPromptGetTask,
7458
+ McpListTask
7459
+ ];
7460
+ tasks.map(TaskRegistry.registerTask);
7461
+ return tasks;
7462
+ };
7463
+
7464
+ // src/task/FileLoaderTask.ts
7465
+ import {
7466
+ CreateWorkflow as CreateWorkflow35,
7467
+ Task as Task33,
7468
+ TaskAbortedError as TaskAbortedError2,
7469
+ Workflow as Workflow36
7470
+ } from "@workglow/task-graph";
7471
+ import Papa from "papaparse";
7472
+ var inputSchema31 = {
7278
7473
  type: "object",
7279
7474
  properties: {
7280
- value: {
7281
- type: "number",
7282
- title: "Value",
7283
- description: "Input number"
7475
+ url: {
7476
+ type: "string",
7477
+ title: "URL",
7478
+ description: "URL to load document from (http://, https://)",
7479
+ format: "uri"
7480
+ },
7481
+ format: {
7482
+ type: "string",
7483
+ enum: ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"],
7484
+ title: "Format",
7485
+ description: "File format (auto-detected from URL if 'auto')",
7486
+ default: "auto"
7284
7487
  }
7285
7488
  },
7286
- required: ["value"],
7489
+ required: ["url"],
7287
7490
  additionalProperties: false
7288
7491
  };
7289
- var outputSchema28 = {
7492
+ var outputSchema30 = {
7290
7493
  type: "object",
7291
7494
  properties: {
7292
- result: {
7293
- type: "number",
7294
- title: "Result",
7295
- description: "Truncated value"
7495
+ text: {
7496
+ type: "string",
7497
+ title: "Text",
7498
+ description: "Text content (for text, markdown, html formats)"
7499
+ },
7500
+ json: {
7501
+ title: "JSON",
7502
+ description: "Parsed JSON object or array"
7503
+ },
7504
+ csv: {
7505
+ type: "array",
7506
+ title: "CSV",
7507
+ description: "Parsed CSV data as array of objects"
7508
+ },
7509
+ image: {
7510
+ type: "string",
7511
+ title: "Image",
7512
+ description: "Base64 data URL for image files",
7513
+ format: "image:data-uri"
7514
+ },
7515
+ pdf: {
7516
+ type: "string",
7517
+ title: "PDF",
7518
+ description: "Base64 data URL for PDF files"
7519
+ },
7520
+ frontmatter: {
7521
+ type: "object",
7522
+ title: "Frontmatter",
7523
+ description: "Parsed YAML frontmatter from markdown/MDX files"
7524
+ },
7525
+ metadata: {
7526
+ type: "object",
7527
+ properties: {
7528
+ url: { type: "string" },
7529
+ format: { type: "string" },
7530
+ size: { type: "number" },
7531
+ title: { type: "string" },
7532
+ mimeType: { type: "string" }
7533
+ },
7534
+ additionalProperties: false,
7535
+ title: "Metadata",
7536
+ description: "File metadata"
7296
7537
  }
7297
7538
  },
7298
- required: ["result"],
7539
+ required: ["metadata"],
7299
7540
  additionalProperties: false
7300
7541
  };
7301
7542
 
7302
- class ScalarTruncTask extends Task29 {
7303
- static type = "ScalarTruncTask";
7304
- static category = "Math";
7305
- static title = "Truncate";
7306
- static description = "Returns the integer part of a number by removing fractional digits";
7543
+ class FileLoaderTask extends Task33 {
7544
+ static type = "FileLoaderTask";
7545
+ static category = "Document";
7546
+ static title = "File Loader";
7547
+ static description = "Load documents from URLs (http://, https://)";
7548
+ static cacheable = true;
7307
7549
  static inputSchema() {
7308
- return inputSchema29;
7550
+ return inputSchema31;
7309
7551
  }
7310
7552
  static outputSchema() {
7311
- return outputSchema28;
7553
+ return outputSchema30;
7312
7554
  }
7313
- async execute(input2, _context) {
7314
- return { result: Math.trunc(input2.value) };
7555
+ async execute(input2, context) {
7556
+ const { url, format = "auto" } = input2;
7557
+ if (context.signal.aborted) {
7558
+ throw new TaskAbortedError2("Task aborted");
7559
+ }
7560
+ await context.updateProgress(0, "Detecting file format");
7561
+ const detectedFormat = this.detectFormat(url, format);
7562
+ const responseType = this.detectResponseType(detectedFormat);
7563
+ if (context.signal.aborted) {
7564
+ throw new TaskAbortedError2("Task aborted");
7565
+ }
7566
+ await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
7567
+ const fetchTask = context.own(new FetchUrlTask({
7568
+ url,
7569
+ response_type: responseType,
7570
+ queue: false
7571
+ }));
7572
+ const response = await fetchTask.run();
7573
+ if (context.signal.aborted) {
7574
+ throw new TaskAbortedError2("Task aborted");
7575
+ }
7576
+ await context.updateProgress(60, "Parsing file content");
7577
+ const title = url.split("/").pop() || url;
7578
+ const { text, json: json2, csv, image, pdf, frontmatter, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
7579
+ if (context.signal.aborted) {
7580
+ throw new TaskAbortedError2("Task aborted");
7581
+ }
7582
+ await context.updateProgress(100, "File loaded successfully");
7583
+ return {
7584
+ text,
7585
+ json: json2,
7586
+ csv,
7587
+ image,
7588
+ pdf,
7589
+ frontmatter,
7590
+ metadata: {
7591
+ url,
7592
+ format: detectedFormat,
7593
+ size,
7594
+ title,
7595
+ mimeType
7596
+ }
7597
+ };
7315
7598
  }
7316
- }
7317
- Workflow32.prototype.scalarTrunc = CreateWorkflow31(ScalarTruncTask);
7318
- // src/task/vector/VectorDistanceTask.ts
7319
- import { CreateWorkflow as CreateWorkflow32, Task as Task30, Workflow as Workflow33 } from "@workglow/task-graph";
7320
- import {
7321
- TypedArraySchema as TypedArraySchema5
7322
- } from "@workglow/util";
7323
- var inputSchema30 = {
7324
- type: "object",
7325
- properties: {
7326
- vectors: {
7327
- type: "array",
7328
- items: TypedArraySchema5({
7329
- title: "Vector",
7330
- description: "Vector for distance computation"
7331
- }),
7332
- title: "Vectors",
7333
- description: "Array of two vectors to compute Euclidean distance"
7599
+ parseJsonContent(content) {
7600
+ return JSON.parse(content);
7601
+ }
7602
+ parseCsvContent(content) {
7603
+ try {
7604
+ const result = Papa.parse(content, {
7605
+ header: true,
7606
+ skipEmptyLines: true,
7607
+ transformHeader: (header) => header.trim()
7608
+ });
7609
+ return result.data;
7610
+ } catch (error) {
7611
+ throw new Error(`Failed to parse CSV: ${error}`);
7334
7612
  }
7335
- },
7336
- required: ["vectors"],
7337
- additionalProperties: false
7338
- };
7339
- var outputSchema29 = {
7340
- type: "object",
7341
- properties: {
7342
- result: {
7343
- type: "number",
7344
- title: "Result",
7345
- description: "Euclidean distance between vectors"
7613
+ }
7614
+ parseFrontmatter(content) {
7615
+ const trimmed = content.replace(/^\uFEFF/, "");
7616
+ if (!trimmed.startsWith(`---
7617
+ `) && !trimmed.startsWith(`---\r
7618
+ `)) {
7619
+ return { frontmatter: undefined, body: content };
7620
+ }
7621
+ const firstDelimEnd = trimmed.indexOf(`
7622
+ `) + 1;
7623
+ const closingIdx = trimmed.indexOf(`
7624
+ ---`, firstDelimEnd);
7625
+ if (closingIdx === -1) {
7626
+ return { frontmatter: undefined, body: content };
7627
+ }
7628
+ const yamlBlock = trimmed.slice(firstDelimEnd, closingIdx);
7629
+ const afterClosing = closingIdx + 4;
7630
+ let bodyStart = afterClosing;
7631
+ if (trimmed[bodyStart] === "\r")
7632
+ bodyStart++;
7633
+ if (trimmed[bodyStart] === `
7634
+ `)
7635
+ bodyStart++;
7636
+ const body = trimmed.slice(bodyStart).replace(/^\r?\n/, "");
7637
+ const frontmatter = this.parseSimpleYaml(yamlBlock);
7638
+ return { frontmatter, body };
7639
+ }
7640
+ parseSimpleYaml(yaml) {
7641
+ const result = {};
7642
+ const lines = yaml.split(/\r?\n/);
7643
+ let i = 0;
7644
+ while (i < lines.length) {
7645
+ i = this.parseYamlLine(lines, i, result, 0);
7346
7646
  }
7347
- },
7348
- required: ["result"],
7349
- additionalProperties: false
7350
- };
7351
-
7352
- class VectorDistanceTask extends Task30 {
7353
- static type = "VectorDistanceTask";
7354
- static category = "Vector";
7355
- static title = "Distance";
7356
- static description = "Returns the Euclidean distance between the first two vectors";
7357
- static inputSchema() {
7358
- return inputSchema30;
7647
+ return result;
7359
7648
  }
7360
- static outputSchema() {
7361
- return outputSchema29;
7649
+ parseYamlLine(lines, index, target, indent) {
7650
+ if (index >= lines.length)
7651
+ return index + 1;
7652
+ const line = lines[index];
7653
+ if (line.trim() === "" || line.trim().startsWith("#")) {
7654
+ return index + 1;
7655
+ }
7656
+ const lineIndent = line.length - line.trimStart().length;
7657
+ if (lineIndent < indent)
7658
+ return index;
7659
+ const match = line.match(/^(\s*)([^:#]+?)\s*:\s*(.*)?$/);
7660
+ if (!match)
7661
+ return index + 1;
7662
+ const key = match[2].trim();
7663
+ const rawValue = (match[3] ?? "").trim();
7664
+ if (rawValue === "" || rawValue === "|" || rawValue === ">") {
7665
+ const nextIndex = index + 1;
7666
+ if (nextIndex < lines.length) {
7667
+ const nextLine = lines[nextIndex];
7668
+ const nextTrimmed = nextLine.trimStart();
7669
+ const nextIndent = nextLine.length - nextTrimmed.length;
7670
+ if (nextIndent > lineIndent && nextTrimmed.startsWith("- ")) {
7671
+ const arr = [];
7672
+ let j = nextIndex;
7673
+ while (j < lines.length) {
7674
+ const arrLine = lines[j];
7675
+ const arrTrimmed = arrLine.trimStart();
7676
+ const arrIndent = arrLine.length - arrTrimmed.length;
7677
+ if (arrTrimmed === "" || arrTrimmed.startsWith("#")) {
7678
+ j++;
7679
+ continue;
7680
+ }
7681
+ if (arrIndent < nextIndent)
7682
+ break;
7683
+ if (arrTrimmed.startsWith("- ")) {
7684
+ arr.push(this.parseYamlValue(arrTrimmed.slice(2).trim()));
7685
+ j++;
7686
+ } else {
7687
+ break;
7688
+ }
7689
+ }
7690
+ target[key] = arr;
7691
+ return j;
7692
+ } else if (nextIndent > lineIndent) {
7693
+ const nested = {};
7694
+ let j = nextIndex;
7695
+ while (j < lines.length) {
7696
+ const nestedLine = lines[j];
7697
+ const nestedTrimmed = nestedLine.trimStart();
7698
+ const nestedIndent = nestedLine.length - nestedTrimmed.length;
7699
+ if (nestedTrimmed === "" || nestedTrimmed.startsWith("#")) {
7700
+ j++;
7701
+ continue;
7702
+ }
7703
+ if (nestedIndent < nextIndent)
7704
+ break;
7705
+ j = this.parseYamlLine(lines, j, nested, nextIndent);
7706
+ }
7707
+ target[key] = nested;
7708
+ return j;
7709
+ }
7710
+ }
7711
+ target[key] = rawValue === "" ? null : rawValue;
7712
+ return index + 1;
7713
+ }
7714
+ target[key] = this.parseYamlValue(rawValue);
7715
+ return index + 1;
7362
7716
  }
7363
- async execute(input2, _context) {
7364
- const { vectors } = input2;
7365
- if (vectors.length < 2) {
7366
- throw new Error("Exactly two vectors are required for distance");
7717
+ parseYamlValue(raw) {
7718
+ if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("'") && raw.endsWith("'")) {
7719
+ return raw.slice(1, -1);
7367
7720
  }
7368
- const [a, b] = vectors;
7369
- if (a.length !== b.length) {
7370
- throw new Error("Vectors must have the same length");
7721
+ if (raw === "true" || raw === "True" || raw === "TRUE")
7722
+ return true;
7723
+ if (raw === "false" || raw === "False" || raw === "FALSE")
7724
+ return false;
7725
+ if (raw === "null" || raw === "~")
7726
+ return null;
7727
+ if (/^-?\d+(\.\d+)?$/.test(raw))
7728
+ return Number(raw);
7729
+ if (raw.startsWith("[") && raw.endsWith("]")) {
7730
+ return raw.slice(1, -1).split(",").map((item) => this.parseYamlValue(item.trim()));
7371
7731
  }
7372
- const diffs = Array.from({ length: a.length }, (_, i) => {
7373
- const d = Number(a[i]) - Number(b[i]);
7374
- return d * d;
7375
- });
7376
- return { result: Math.sqrt(sumPrecise(diffs)) };
7732
+ return raw;
7377
7733
  }
7378
- }
7379
- Workflow33.prototype.vectorDistance = CreateWorkflow32(VectorDistanceTask);
7380
- // src/task/vector/VectorDotProductTask.ts
7381
- import { CreateWorkflow as CreateWorkflow33, Task as Task31, Workflow as Workflow34 } from "@workglow/task-graph";
7382
- import {
7383
- TypedArraySchema as TypedArraySchema6
7384
- } from "@workglow/util";
7385
- var inputSchema31 = {
7386
- type: "object",
7387
- properties: {
7388
- vectors: {
7389
- type: "array",
7390
- items: TypedArraySchema6({
7391
- title: "Vector",
7392
- description: "Vector for dot product"
7393
- }),
7394
- title: "Vectors",
7395
- description: "Array of two vectors to compute dot product"
7734
+ async parseResponse(response, url, detectedFormat) {
7735
+ const responseMimeType = response.metadata?.contentType || "";
7736
+ if (detectedFormat === "json") {
7737
+ if (!response.json) {
7738
+ throw new Error(`Failed to load JSON from ${url}`);
7739
+ }
7740
+ const jsonData = response.json;
7741
+ const content2 = JSON.stringify(jsonData, null, 2);
7742
+ return {
7743
+ text: undefined,
7744
+ json: jsonData,
7745
+ csv: undefined,
7746
+ image: undefined,
7747
+ pdf: undefined,
7748
+ frontmatter: undefined,
7749
+ size: content2.length,
7750
+ mimeType: responseMimeType || "application/json"
7751
+ };
7396
7752
  }
7397
- },
7398
- required: ["vectors"],
7399
- additionalProperties: false
7400
- };
7401
- var outputSchema30 = {
7402
- type: "object",
7403
- properties: {
7404
- result: {
7405
- type: "number",
7406
- title: "Result",
7407
- description: "Dot product of the vectors"
7753
+ if (detectedFormat === "csv") {
7754
+ const content2 = response.text || "";
7755
+ if (!content2) {
7756
+ throw new Error(`Failed to load CSV from ${url}`);
7757
+ }
7758
+ const csvData = this.parseCsvContent(content2);
7759
+ return {
7760
+ text: undefined,
7761
+ json: undefined,
7762
+ csv: csvData,
7763
+ image: undefined,
7764
+ pdf: undefined,
7765
+ frontmatter: undefined,
7766
+ size: content2.length,
7767
+ mimeType: responseMimeType || "text/csv"
7768
+ };
7769
+ }
7770
+ if (detectedFormat === "image") {
7771
+ if (!response.blob) {
7772
+ throw new Error(`Failed to load image from ${url}`);
7773
+ }
7774
+ const blob = response.blob;
7775
+ const mimeType2 = responseMimeType || (blob.type && blob.type !== "" ? blob.type : this.getImageMimeType(url));
7776
+ const imageData = await this.blobToBase64DataURL(blob, mimeType2);
7777
+ return {
7778
+ text: undefined,
7779
+ json: undefined,
7780
+ csv: undefined,
7781
+ image: imageData,
7782
+ pdf: undefined,
7783
+ frontmatter: undefined,
7784
+ size: blob.size,
7785
+ mimeType: mimeType2
7786
+ };
7408
7787
  }
7409
- },
7410
- required: ["result"],
7411
- additionalProperties: false
7412
- };
7413
-
7414
- class VectorDotProductTask extends Task31 {
7415
- static type = "VectorDotProductTask";
7416
- static category = "Vector";
7417
- static title = "Dot Product";
7418
- static description = "Returns the dot (inner) product of the first two vectors";
7419
- static inputSchema() {
7420
- return inputSchema31;
7421
- }
7422
- static outputSchema() {
7423
- return outputSchema30;
7424
- }
7425
- async execute(input2, _context) {
7426
- const { vectors } = input2;
7427
- if (vectors.length < 2) {
7428
- throw new Error("Exactly two vectors are required for dot product");
7788
+ if (detectedFormat === "pdf") {
7789
+ if (!response.blob) {
7790
+ throw new Error(`Failed to load PDF from ${url}`);
7791
+ }
7792
+ const blob = response.blob;
7793
+ const mimeType2 = responseMimeType || "application/pdf";
7794
+ const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
7795
+ return {
7796
+ text: undefined,
7797
+ json: undefined,
7798
+ csv: undefined,
7799
+ image: undefined,
7800
+ pdf: pdfData,
7801
+ frontmatter: undefined,
7802
+ size: blob.size,
7803
+ mimeType: mimeType2
7804
+ };
7429
7805
  }
7430
- const [a, b] = vectors;
7431
- if (a.length !== b.length) {
7432
- throw new Error("Vectors must have the same length");
7806
+ const content = response.text || "";
7807
+ if (!content) {
7808
+ throw new Error(`Failed to load content from ${url}`);
7433
7809
  }
7434
- const products = Array.from({ length: a.length }, (_, i) => Number(a[i]) * Number(b[i]));
7435
- return { result: sumPrecise(products) };
7436
- }
7437
- }
7438
- Workflow34.prototype.vectorDotProduct = CreateWorkflow33(VectorDotProductTask);
7439
- // src/task/vector/VectorNormalizeTask.ts
7440
- import { CreateWorkflow as CreateWorkflow34, Task as Task32, Workflow as Workflow35 } from "@workglow/task-graph";
7441
- import {
7442
- TypedArraySchema as TypedArraySchema7,
7443
- normalize
7444
- } from "@workglow/util";
7445
- var inputSchema32 = {
7446
- type: "object",
7447
- properties: {
7448
- vector: TypedArraySchema7({
7449
- title: "Vector",
7450
- description: "Input vector to normalize"
7451
- })
7452
- },
7453
- required: ["vector"],
7454
- additionalProperties: false
7455
- };
7456
- var outputSchema31 = {
7457
- type: "object",
7458
- properties: {
7459
- result: TypedArraySchema7({
7460
- title: "Result",
7461
- description: "L2-normalized vector"
7462
- })
7463
- },
7464
- required: ["result"],
7465
- additionalProperties: false
7466
- };
7467
-
7468
- class VectorNormalizeTask extends Task32 {
7469
- static type = "VectorNormalizeTask";
7470
- static category = "Vector";
7471
- static title = "Normalize";
7472
- static description = "Returns the L2-normalized (unit length) vector";
7473
- static inputSchema() {
7474
- return inputSchema32;
7475
- }
7476
- static outputSchema() {
7477
- return outputSchema31;
7810
+ const mimeType = responseMimeType || (detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain");
7811
+ if (detectedFormat === "markdown") {
7812
+ const { frontmatter, body } = this.parseFrontmatter(content);
7813
+ return {
7814
+ text: body,
7815
+ json: undefined,
7816
+ csv: undefined,
7817
+ image: undefined,
7818
+ pdf: undefined,
7819
+ frontmatter,
7820
+ size: content.length,
7821
+ mimeType
7822
+ };
7823
+ }
7824
+ return {
7825
+ text: content,
7826
+ json: undefined,
7827
+ csv: undefined,
7828
+ image: undefined,
7829
+ pdf: undefined,
7830
+ frontmatter: undefined,
7831
+ size: content.length,
7832
+ mimeType
7833
+ };
7478
7834
  }
7479
- async execute(input2, _context) {
7480
- return { result: normalize(input2.vector) };
7835
+ detectResponseType(detectedFormat) {
7836
+ let responseType = "text";
7837
+ if (detectedFormat === "json") {
7838
+ responseType = "json";
7839
+ } else if (detectedFormat === "image" || detectedFormat === "pdf") {
7840
+ responseType = "blob";
7841
+ } else if (detectedFormat === "csv" || detectedFormat === "text" || detectedFormat === "markdown" || detectedFormat === "html") {
7842
+ responseType = "text";
7843
+ }
7844
+ return responseType;
7481
7845
  }
7482
- }
7483
- Workflow35.prototype.vectorNormalize = CreateWorkflow34(VectorNormalizeTask);
7484
- // src/task/vector/VectorScaleTask.ts
7485
- import { CreateWorkflow as CreateWorkflow35, Task as Task33, Workflow as Workflow36 } from "@workglow/task-graph";
7486
- import {
7487
- createTypedArrayFrom as createTypedArrayFrom5,
7488
- TypedArraySchema as TypedArraySchema8
7489
- } from "@workglow/util";
7490
- var inputSchema33 = {
7491
- type: "object",
7492
- properties: {
7493
- vector: TypedArraySchema8({
7494
- title: "Vector",
7495
- description: "Input vector"
7496
- }),
7497
- scalar: {
7498
- type: "number",
7499
- title: "Scalar",
7500
- description: "Scalar multiplier"
7846
+ detectFormat(url, format) {
7847
+ if (format === "auto") {
7848
+ const urlLower = url.toLowerCase();
7849
+ if (urlLower.endsWith(".md") || urlLower.endsWith(".mdx") || urlLower.endsWith(".markdown")) {
7850
+ return "markdown";
7851
+ } else if (urlLower.endsWith(".json")) {
7852
+ return "json";
7853
+ } else if (urlLower.endsWith(".csv")) {
7854
+ return "csv";
7855
+ } else if (urlLower.endsWith(".pdf")) {
7856
+ return "pdf";
7857
+ } else if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/)) {
7858
+ return "image";
7859
+ } else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm")) {
7860
+ return "html";
7861
+ } else {
7862
+ return "text";
7863
+ }
7501
7864
  }
7502
- },
7503
- required: ["vector", "scalar"],
7504
- additionalProperties: false
7505
- };
7506
- var outputSchema32 = {
7507
- type: "object",
7508
- properties: {
7509
- result: TypedArraySchema8({
7510
- title: "Result",
7511
- description: "Scaled vector"
7512
- })
7513
- },
7514
- required: ["result"],
7515
- additionalProperties: false
7516
- };
7517
-
7518
- class VectorScaleTask extends Task33 {
7519
- static type = "VectorScaleTask";
7520
- static category = "Vector";
7521
- static title = "Scale";
7522
- static description = "Multiplies each element of a vector by a scalar";
7523
- static inputSchema() {
7524
- return inputSchema33;
7865
+ return format;
7525
7866
  }
7526
- static outputSchema() {
7527
- return outputSchema32;
7867
+ getImageMimeType(url) {
7868
+ const urlLower = url.toLowerCase();
7869
+ if (urlLower.endsWith(".png"))
7870
+ return "image/png";
7871
+ if (urlLower.endsWith(".jpg") || urlLower.endsWith(".jpeg"))
7872
+ return "image/jpeg";
7873
+ if (urlLower.endsWith(".gif"))
7874
+ return "image/gif";
7875
+ if (urlLower.endsWith(".webp"))
7876
+ return "image/webp";
7877
+ if (urlLower.endsWith(".bmp"))
7878
+ return "image/bmp";
7879
+ if (urlLower.endsWith(".svg"))
7880
+ return "image/svg+xml";
7881
+ if (urlLower.endsWith(".ico"))
7882
+ return "image/x-icon";
7883
+ return "image/jpeg";
7528
7884
  }
7529
- async execute(input2, _context) {
7530
- const { vector, scalar } = input2;
7531
- const values = Array.from(vector, (v) => Number(v) * scalar);
7532
- return { result: createTypedArrayFrom5([vector], values) };
7885
+ async blobToBase64DataURL(blob, mimeType) {
7886
+ if (typeof Buffer !== "undefined") {
7887
+ const arrayBuffer = await blob.arrayBuffer();
7888
+ const buffer = Buffer.from(arrayBuffer);
7889
+ return `data:${mimeType};base64,${buffer.toString("base64")}`;
7890
+ }
7891
+ return new Promise((resolve, reject) => {
7892
+ const reader = new FileReader;
7893
+ reader.onloadend = () => {
7894
+ const result = reader.result;
7895
+ if (result.startsWith("data:;base64,")) {
7896
+ resolve(`data:${mimeType};base64,${result.substring(13)}`);
7897
+ } else {
7898
+ resolve(result);
7899
+ }
7900
+ };
7901
+ reader.onerror = reject;
7902
+ reader.readAsDataURL(blob);
7903
+ });
7533
7904
  }
7534
7905
  }
7535
- Workflow36.prototype.vectorScale = CreateWorkflow35(VectorScaleTask);
7536
-
7537
- // src/common.ts
7538
- import { TaskRegistry } from "@workglow/task-graph";
7539
- var registerCommonTasks = () => {
7540
- const tasks = [
7541
- DebugLogTask,
7542
- DelayTask,
7543
- FetchUrlTask,
7544
- InputTask,
7545
- JavaScriptTask,
7546
- JsonTask,
7547
- LambdaTask,
7548
- MergeTask,
7549
- OutputTask,
7550
- SplitTask,
7551
- ScalarAbsTask,
7552
- ScalarAddTask,
7553
- ScalarCeilTask,
7554
- ScalarDivideTask,
7555
- ScalarFloorTask,
7556
- ScalarMaxTask,
7557
- ScalarMinTask,
7558
- ScalarMultiplyTask,
7559
- ScalarRoundTask,
7560
- ScalarSubtractTask,
7561
- ScalarSumTask,
7562
- ScalarTruncTask,
7563
- VectorSumTask,
7564
- VectorDistanceTask,
7565
- VectorDivideTask,
7566
- VectorDotProductTask,
7567
- VectorMultiplyTask,
7568
- VectorNormalizeTask,
7569
- VectorScaleTask,
7570
- VectorSubtractTask,
7571
- McpToolCallTask,
7572
- McpResourceReadTask,
7573
- McpPromptGetTask,
7574
- McpListTask
7575
- ];
7576
- tasks.map(TaskRegistry.registerTask);
7577
- return tasks;
7906
+ var fileLoader = (input2, config) => {
7907
+ return new FileLoaderTask({}, config).run(input2);
7578
7908
  };
7909
+ Workflow36.prototype.fileLoader = CreateWorkflow35(FileLoaderTask);
7579
7910
 
7580
7911
  // src/browser.ts
7581
- [FileLoaderTask].map(TaskRegistry2.registerTask);
7912
+ var registerCommonTasks2 = () => {
7913
+ const tasks = registerCommonTasks();
7914
+ TaskRegistry2.registerTask(FileLoaderTask);
7915
+ return [...tasks, FileLoaderTask];
7916
+ };
7582
7917
  export {
7583
7918
  split,
7584
- registerCommonTasks,
7919
+ registerCommonTasks2 as registerCommonTasks,
7585
7920
  process,
7586
7921
  merge,
7587
- mcpTransportTypes,
7588
7922
  mcpToolCall,
7589
- mcpServerConfigSchema5 as mcpServerConfigSchema,
7590
7923
  mcpResourceRead,
7591
7924
  mcpPromptGet,
7592
7925
  mcpList,
7593
- mcpClientFactory5 as mcpClientFactory,
7594
7926
  lambdaTaskConfigSchema,
7595
7927
  lambda,
7596
7928
  json,
@@ -7599,7 +7931,6 @@ export {
7599
7931
  fetchUrl,
7600
7932
  delay,
7601
7933
  debugLog,
7602
- createMcpClient,
7603
7934
  VectorSumTask,
7604
7935
  VectorSubtractTask,
7605
7936
  VectorScaleTask,
@@ -7640,4 +7971,4 @@ export {
7640
7971
  ArrayTask
7641
7972
  };
7642
7973
 
7643
- //# debugId=B9BF1F6C8E1711C764756E2164756E21
7974
+ //# debugId=5804C9302124181F64756E2164756E21