@workglow/tasks 0.0.84 → 0.0.86
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.
- package/README.md +73 -0
- package/dist/{index.js → browser.js} +742 -194
- package/dist/{index.js.map → browser.js.map} +17 -11
- package/dist/bun.js +5933 -0
- package/dist/bun.js.map +26 -0
- package/dist/common.d.ts +28 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/node.js +5933 -0
- package/dist/node.js.map +26 -0
- package/dist/task/ArrayTask.d.ts +109 -0
- package/dist/task/ArrayTask.d.ts.map +1 -0
- package/dist/task/DebugLogTask.d.ts.map +1 -1
- package/dist/task/DelayTask.d.ts.map +1 -1
- package/dist/task/FetchUrlTask.d.ts +37 -1
- package/dist/task/FetchUrlTask.d.ts.map +1 -1
- package/dist/task/FileLoaderTask.d.ts +162 -0
- package/dist/task/FileLoaderTask.d.ts.map +1 -0
- package/dist/task/FileLoaderTask.server.d.ts +38 -0
- package/dist/task/FileLoaderTask.server.d.ts.map +1 -0
- package/dist/task/InputTask.d.ts +32 -0
- package/dist/task/InputTask.d.ts.map +1 -0
- package/dist/task/JavaScriptTask.d.ts.map +1 -1
- package/dist/task/JsonTask.d.ts +2 -0
- package/dist/task/JsonTask.d.ts.map +1 -1
- package/dist/task/LambdaTask.d.ts +7 -26
- package/dist/task/LambdaTask.d.ts.map +1 -1
- package/dist/task/MergeTask.d.ts.map +1 -1
- package/dist/task/OutputTask.d.ts +35 -0
- package/dist/task/OutputTask.d.ts.map +1 -0
- package/dist/task/SplitTask.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +25 -15
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
|
@@ -6,132 +6,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
// src/
|
|
10
|
-
import {
|
|
11
|
-
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
12
|
-
var DEFAULT_LOG_LEVEL = "log";
|
|
13
|
-
var inputSchema = {
|
|
14
|
-
type: "object",
|
|
15
|
-
properties: {
|
|
16
|
-
console: {
|
|
17
|
-
title: "Message",
|
|
18
|
-
description: "The message to log"
|
|
19
|
-
},
|
|
20
|
-
log_level: {
|
|
21
|
-
type: "string",
|
|
22
|
-
enum: log_levels,
|
|
23
|
-
title: "Log Level",
|
|
24
|
-
description: "The log level to use",
|
|
25
|
-
default: DEFAULT_LOG_LEVEL
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
additionalProperties: false
|
|
29
|
-
};
|
|
30
|
-
var outputSchema = {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
console: {
|
|
34
|
-
title: "Messages",
|
|
35
|
-
description: "The messages logged by the task"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
additionalProperties: false
|
|
39
|
-
};
|
|
9
|
+
// src/browser.ts
|
|
10
|
+
import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
static type = "DebugLogTask";
|
|
43
|
-
static category = "Utility";
|
|
44
|
-
static title = "Debug Log";
|
|
45
|
-
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
46
|
-
static cacheable = false;
|
|
47
|
-
static inputSchema() {
|
|
48
|
-
return inputSchema;
|
|
49
|
-
}
|
|
50
|
-
static outputSchema() {
|
|
51
|
-
return outputSchema;
|
|
52
|
-
}
|
|
53
|
-
async executeReactive(input, output) {
|
|
54
|
-
const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
|
|
55
|
-
if (log_level == "dir") {
|
|
56
|
-
console.dir(messages, { depth: null });
|
|
57
|
-
} else {
|
|
58
|
-
console[log_level](messages);
|
|
59
|
-
}
|
|
60
|
-
output.console = input.console;
|
|
61
|
-
return output;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
TaskRegistry.registerTask(DebugLogTask);
|
|
65
|
-
var debugLog = (input, config = {}) => {
|
|
66
|
-
const task = new DebugLogTask(input, config);
|
|
67
|
-
return task.run();
|
|
68
|
-
};
|
|
69
|
-
Workflow.prototype.debugLog = CreateWorkflow(DebugLogTask);
|
|
70
|
-
// src/task/DelayTask.ts
|
|
12
|
+
// src/task/FileLoaderTask.ts
|
|
71
13
|
import {
|
|
72
14
|
CreateWorkflow as CreateWorkflow2,
|
|
73
|
-
Task
|
|
15
|
+
Task,
|
|
74
16
|
TaskAbortedError,
|
|
75
|
-
TaskRegistry as TaskRegistry2,
|
|
76
17
|
Workflow as Workflow2
|
|
77
18
|
} from "@workglow/task-graph";
|
|
78
|
-
import
|
|
79
|
-
var inputSchema2 = {
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
delay: {
|
|
83
|
-
type: "number",
|
|
84
|
-
title: "Delay (ms)",
|
|
85
|
-
default: 1
|
|
86
|
-
},
|
|
87
|
-
pass_through: {
|
|
88
|
-
title: "Pass Through",
|
|
89
|
-
description: "Pass through data to the output"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
additionalProperties: false
|
|
93
|
-
};
|
|
94
|
-
var outputSchema2 = {
|
|
95
|
-
type: "object",
|
|
96
|
-
properties: {},
|
|
97
|
-
additionalProperties: true
|
|
98
|
-
};
|
|
19
|
+
import Papa from "papaparse";
|
|
99
20
|
|
|
100
|
-
class DelayTask extends Task2 {
|
|
101
|
-
static type = "DelayTask";
|
|
102
|
-
static category = "Utility";
|
|
103
|
-
static title = "Delay";
|
|
104
|
-
static description = "Delays execution for a specified duration with progress tracking";
|
|
105
|
-
static inputSchema() {
|
|
106
|
-
return inputSchema2;
|
|
107
|
-
}
|
|
108
|
-
static outputSchema() {
|
|
109
|
-
return outputSchema2;
|
|
110
|
-
}
|
|
111
|
-
async execute(input, executeContext) {
|
|
112
|
-
const delay = input.delay ?? 0;
|
|
113
|
-
if (delay > 100) {
|
|
114
|
-
const iterations = Math.min(100, Math.floor(delay / 16));
|
|
115
|
-
const chunkSize = delay / iterations;
|
|
116
|
-
for (let i = 0;i < iterations; i++) {
|
|
117
|
-
if (executeContext.signal.aborted) {
|
|
118
|
-
throw new TaskAbortedError("Task aborted");
|
|
119
|
-
}
|
|
120
|
-
await sleep(chunkSize);
|
|
121
|
-
await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
await sleep(delay);
|
|
125
|
-
}
|
|
126
|
-
return input.pass_through;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
TaskRegistry2.registerTask(DelayTask);
|
|
130
|
-
var delay = (input, config = {}) => {
|
|
131
|
-
const task = new DelayTask(input, config);
|
|
132
|
-
return task.run();
|
|
133
|
-
};
|
|
134
|
-
Workflow2.prototype.delay = CreateWorkflow2(DelayTask);
|
|
135
21
|
// src/task/FetchUrlTask.ts
|
|
136
22
|
import {
|
|
137
23
|
AbortSignalJobError,
|
|
@@ -140,14 +26,13 @@ import {
|
|
|
140
26
|
RetryableJobError
|
|
141
27
|
} from "@workglow/job-queue";
|
|
142
28
|
import {
|
|
143
|
-
CreateWorkflow
|
|
29
|
+
CreateWorkflow,
|
|
144
30
|
JobQueueTask,
|
|
145
31
|
TaskConfigurationError,
|
|
146
32
|
TaskInvalidInputError,
|
|
147
|
-
|
|
148
|
-
Workflow as Workflow3
|
|
33
|
+
Workflow
|
|
149
34
|
} from "@workglow/task-graph";
|
|
150
|
-
var
|
|
35
|
+
var inputSchema = {
|
|
151
36
|
type: "object",
|
|
152
37
|
properties: {
|
|
153
38
|
url: {
|
|
@@ -178,6 +63,7 @@ var inputSchema3 = {
|
|
|
178
63
|
response_type: {
|
|
179
64
|
anyOf: [{ type: "null" }, { enum: ["json", "text", "blob", "arraybuffer"] }],
|
|
180
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.",
|
|
181
67
|
default: null
|
|
182
68
|
},
|
|
183
69
|
timeout: {
|
|
@@ -195,7 +81,7 @@ var inputSchema3 = {
|
|
|
195
81
|
required: ["url"],
|
|
196
82
|
additionalProperties: false
|
|
197
83
|
};
|
|
198
|
-
var
|
|
84
|
+
var outputSchema = {
|
|
199
85
|
type: "object",
|
|
200
86
|
properties: {
|
|
201
87
|
json: {
|
|
@@ -214,6 +100,16 @@ var outputSchema3 = {
|
|
|
214
100
|
arraybuffer: {
|
|
215
101
|
title: "ArrayBuffer",
|
|
216
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"
|
|
217
113
|
}
|
|
218
114
|
},
|
|
219
115
|
additionalProperties: false
|
|
@@ -281,9 +177,17 @@ class FetchUrlJob extends Job {
|
|
|
281
177
|
signal: context.signal
|
|
282
178
|
}, async (progress) => await context.updateProgress(progress));
|
|
283
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
|
+
};
|
|
284
189
|
let responseType = input.response_type;
|
|
285
190
|
if (!responseType) {
|
|
286
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
287
191
|
if (contentType.includes("application/json")) {
|
|
288
192
|
responseType = "json";
|
|
289
193
|
} else if (contentType.includes("text/")) {
|
|
@@ -298,13 +202,13 @@ class FetchUrlJob extends Job {
|
|
|
298
202
|
input.response_type = responseType;
|
|
299
203
|
}
|
|
300
204
|
if (responseType === "json") {
|
|
301
|
-
return { json: await response.json() };
|
|
205
|
+
return { json: await response.json(), metadata };
|
|
302
206
|
} else if (responseType === "text") {
|
|
303
|
-
return { text: await response.text() };
|
|
207
|
+
return { text: await response.text(), metadata };
|
|
304
208
|
} else if (responseType === "blob") {
|
|
305
|
-
return { blob: await response.blob() };
|
|
209
|
+
return { blob: await response.blob(), metadata };
|
|
306
210
|
} else if (responseType === "arraybuffer") {
|
|
307
|
-
return { arraybuffer: await response.arrayBuffer() };
|
|
211
|
+
return { arraybuffer: await response.arrayBuffer(), metadata };
|
|
308
212
|
}
|
|
309
213
|
throw new TaskInvalidInputError(`Invalid response type: ${responseType}`);
|
|
310
214
|
} else {
|
|
@@ -337,10 +241,10 @@ class FetchUrlTask extends JobQueueTask {
|
|
|
337
241
|
static description = "Fetches data from a URL with progress tracking and automatic retry handling";
|
|
338
242
|
static hasDynamicSchemas = true;
|
|
339
243
|
static inputSchema() {
|
|
340
|
-
return
|
|
244
|
+
return inputSchema;
|
|
341
245
|
}
|
|
342
246
|
static outputSchema() {
|
|
343
|
-
return
|
|
247
|
+
return outputSchema;
|
|
344
248
|
}
|
|
345
249
|
outputSchema() {
|
|
346
250
|
const responseType = this.runInputData?.response_type ?? this.defaults?.response_type ?? null;
|
|
@@ -364,6 +268,9 @@ class FetchUrlTask extends JobQueueTask {
|
|
|
364
268
|
} else if (responseType === "arraybuffer" && staticSchema.properties.arraybuffer) {
|
|
365
269
|
properties.arraybuffer = staticSchema.properties.arraybuffer;
|
|
366
270
|
}
|
|
271
|
+
if (staticSchema.properties.metadata) {
|
|
272
|
+
properties.metadata = staticSchema.properties.metadata;
|
|
273
|
+
}
|
|
367
274
|
if (Object.keys(properties).length === 0) {
|
|
368
275
|
return staticSchema;
|
|
369
276
|
}
|
|
@@ -413,14 +320,595 @@ class FetchUrlTask extends JobQueueTask {
|
|
|
413
320
|
}
|
|
414
321
|
}
|
|
415
322
|
}
|
|
416
|
-
TaskRegistry3.registerTask(FetchUrlTask);
|
|
417
323
|
var fetchUrl = async (input, config = {}) => {
|
|
418
|
-
const result = await new FetchUrlTask(
|
|
324
|
+
const result = await new FetchUrlTask({}, config).run(input);
|
|
419
325
|
return result;
|
|
420
326
|
};
|
|
421
|
-
|
|
327
|
+
Workflow.prototype.fetch = CreateWorkflow(FetchUrlTask);
|
|
328
|
+
|
|
329
|
+
// src/task/FileLoaderTask.ts
|
|
330
|
+
var inputSchema2 = {
|
|
331
|
+
type: "object",
|
|
332
|
+
properties: {
|
|
333
|
+
url: {
|
|
334
|
+
type: "string",
|
|
335
|
+
title: "URL",
|
|
336
|
+
description: "URL to load document from (http://, https://)",
|
|
337
|
+
format: "uri"
|
|
338
|
+
},
|
|
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"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
required: ["url"],
|
|
348
|
+
additionalProperties: false
|
|
349
|
+
};
|
|
350
|
+
var outputSchema2 = {
|
|
351
|
+
type: "object",
|
|
352
|
+
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"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
required: ["metadata"],
|
|
393
|
+
additionalProperties: false
|
|
394
|
+
};
|
|
395
|
+
|
|
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;
|
|
402
|
+
static inputSchema() {
|
|
403
|
+
return inputSchema2;
|
|
404
|
+
}
|
|
405
|
+
static outputSchema() {
|
|
406
|
+
return outputSchema2;
|
|
407
|
+
}
|
|
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");
|
|
428
|
+
}
|
|
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");
|
|
434
|
+
}
|
|
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
|
+
};
|
|
450
|
+
}
|
|
451
|
+
parseJsonContent(content) {
|
|
452
|
+
return JSON.parse(content);
|
|
453
|
+
}
|
|
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
|
+
}
|
|
465
|
+
}
|
|
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/ArrayTask.ts
|
|
626
|
+
import {
|
|
627
|
+
uuid4
|
|
628
|
+
} from "@workglow/util";
|
|
629
|
+
import {
|
|
630
|
+
GraphAsTask,
|
|
631
|
+
GraphAsTaskRunner,
|
|
632
|
+
PROPERTY_ARRAY,
|
|
633
|
+
TaskGraph
|
|
634
|
+
} from "@workglow/task-graph";
|
|
635
|
+
var TypeReplicateArray = (type, annotations = {}) => ({
|
|
636
|
+
oneOf: [type, { type: "array", items: type }],
|
|
637
|
+
title: type.title,
|
|
638
|
+
description: type.description,
|
|
639
|
+
...type.format ? { format: type.format } : {},
|
|
640
|
+
...annotations,
|
|
641
|
+
"x-replicate": true
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
class ArrayTask extends GraphAsTask {
|
|
645
|
+
static type = "ArrayTask";
|
|
646
|
+
static compoundMerge = PROPERTY_ARRAY;
|
|
647
|
+
inputSchema() {
|
|
648
|
+
return this.constructor.inputSchema();
|
|
649
|
+
}
|
|
650
|
+
outputSchema() {
|
|
651
|
+
return this.constructor.outputSchema();
|
|
652
|
+
}
|
|
653
|
+
executeMerge(_input, output) {
|
|
654
|
+
return output;
|
|
655
|
+
}
|
|
656
|
+
regenerateGraph() {
|
|
657
|
+
const arrayInputs = new Map;
|
|
658
|
+
let hasArrayInputs = false;
|
|
659
|
+
const inputSchema3 = this.inputSchema();
|
|
660
|
+
if (typeof inputSchema3 !== "boolean") {
|
|
661
|
+
const keys = Object.keys(inputSchema3.properties || {});
|
|
662
|
+
for (const inputId of keys) {
|
|
663
|
+
const inputValue = this.runInputData[inputId];
|
|
664
|
+
const inputDef = inputSchema3.properties?.[inputId];
|
|
665
|
+
if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
|
|
666
|
+
arrayInputs.set(inputId, inputValue);
|
|
667
|
+
hasArrayInputs = true;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
this.subGraph = new TaskGraph;
|
|
672
|
+
if (!hasArrayInputs) {
|
|
673
|
+
super.regenerateGraph();
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const inputIds = Array.from(arrayInputs.keys());
|
|
677
|
+
const inputObject = Object.fromEntries(arrayInputs);
|
|
678
|
+
const combinations = this.generateCombinations(inputObject, inputIds);
|
|
679
|
+
const tasks = combinations.map((combination) => {
|
|
680
|
+
const { id, name, ...rest } = this.config;
|
|
681
|
+
const task = new this.constructor({ ...this.defaults, ...this.runInputData, ...combination }, { ...rest, id: `${id}_${uuid4()}` });
|
|
682
|
+
return task;
|
|
683
|
+
});
|
|
684
|
+
this.subGraph.addTasks(tasks);
|
|
685
|
+
super.regenerateGraph();
|
|
686
|
+
}
|
|
687
|
+
generateCombinations(input, inputMakeArray) {
|
|
688
|
+
const arraysToCombine = inputMakeArray.map((key) => Array.isArray(input[key]) ? input[key] : []);
|
|
689
|
+
const indices = new Array(arraysToCombine.length).fill(0);
|
|
690
|
+
const combinations = [];
|
|
691
|
+
let done = false;
|
|
692
|
+
while (!done) {
|
|
693
|
+
combinations.push([...indices]);
|
|
694
|
+
for (let i = indices.length - 1;i >= 0; i--) {
|
|
695
|
+
if (++indices[i] < arraysToCombine[i].length)
|
|
696
|
+
break;
|
|
697
|
+
if (i === 0)
|
|
698
|
+
done = true;
|
|
699
|
+
else
|
|
700
|
+
indices[i] = 0;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const combos = combinations.map((combination) => {
|
|
704
|
+
const result = { ...input };
|
|
705
|
+
combination.forEach((valueIndex, arrayIndex) => {
|
|
706
|
+
const key = inputMakeArray[arrayIndex];
|
|
707
|
+
if (Array.isArray(input[key]))
|
|
708
|
+
result[key] = input[key][valueIndex];
|
|
709
|
+
});
|
|
710
|
+
return result;
|
|
711
|
+
});
|
|
712
|
+
return combos;
|
|
713
|
+
}
|
|
714
|
+
toJSON() {
|
|
715
|
+
const { subgraph, ...result } = super.toJSON();
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
toDependencyJSON() {
|
|
719
|
+
const { subtasks, ...result } = super.toDependencyJSON();
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
get runner() {
|
|
723
|
+
if (!this._runner) {
|
|
724
|
+
this._runner = new ArrayTaskRunner(this);
|
|
725
|
+
}
|
|
726
|
+
return this._runner;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
class ArrayTaskRunner extends GraphAsTaskRunner {
|
|
731
|
+
async executeTaskChildren(_input) {
|
|
732
|
+
return super.executeTaskChildren({});
|
|
733
|
+
}
|
|
734
|
+
async executeTaskReactive(input, output) {
|
|
735
|
+
await super.executeTaskReactive(input, output);
|
|
736
|
+
if (this.task.hasChildren()) {
|
|
737
|
+
this.task.runOutputData = this.task.executeMerge(input, this.task.runOutputData);
|
|
738
|
+
}
|
|
739
|
+
return this.task.runOutputData;
|
|
740
|
+
}
|
|
741
|
+
async executeTask(input) {
|
|
742
|
+
await super.executeTask(input);
|
|
743
|
+
if (this.task.hasChildren()) {
|
|
744
|
+
this.task.runOutputData = this.task.executeMerge(input, this.task.runOutputData);
|
|
745
|
+
}
|
|
746
|
+
return this.task.runOutputData;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
// src/task/DebugLogTask.ts
|
|
750
|
+
import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
751
|
+
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
752
|
+
var DEFAULT_LOG_LEVEL = "log";
|
|
753
|
+
var inputSchema3 = {
|
|
754
|
+
type: "object",
|
|
755
|
+
properties: {
|
|
756
|
+
console: {
|
|
757
|
+
title: "Message",
|
|
758
|
+
description: "The message to log"
|
|
759
|
+
},
|
|
760
|
+
log_level: {
|
|
761
|
+
type: "string",
|
|
762
|
+
enum: log_levels,
|
|
763
|
+
title: "Log Level",
|
|
764
|
+
description: "The log level to use",
|
|
765
|
+
default: DEFAULT_LOG_LEVEL
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
additionalProperties: false
|
|
769
|
+
};
|
|
770
|
+
var outputSchema3 = {
|
|
771
|
+
type: "object",
|
|
772
|
+
properties: {
|
|
773
|
+
console: {
|
|
774
|
+
title: "Messages",
|
|
775
|
+
description: "The messages logged by the task"
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
additionalProperties: false
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
class DebugLogTask extends Task2 {
|
|
782
|
+
static type = "DebugLogTask";
|
|
783
|
+
static category = "Utility";
|
|
784
|
+
static title = "Debug Log";
|
|
785
|
+
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
786
|
+
static cacheable = false;
|
|
787
|
+
static inputSchema() {
|
|
788
|
+
return inputSchema3;
|
|
789
|
+
}
|
|
790
|
+
static outputSchema() {
|
|
791
|
+
return outputSchema3;
|
|
792
|
+
}
|
|
793
|
+
async executeReactive(input, output) {
|
|
794
|
+
const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
|
|
795
|
+
if (log_level == "dir") {
|
|
796
|
+
console.dir(messages, { depth: null });
|
|
797
|
+
} else {
|
|
798
|
+
console[log_level](messages);
|
|
799
|
+
}
|
|
800
|
+
output.console = input.console;
|
|
801
|
+
return output;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
var debugLog = (input, config = {}) => {
|
|
805
|
+
const task = new DebugLogTask({}, config);
|
|
806
|
+
return task.run(input);
|
|
807
|
+
};
|
|
808
|
+
Workflow3.prototype.debugLog = CreateWorkflow3(DebugLogTask);
|
|
809
|
+
// src/task/DelayTask.ts
|
|
810
|
+
import {
|
|
811
|
+
CreateWorkflow as CreateWorkflow4,
|
|
812
|
+
Task as Task3,
|
|
813
|
+
TaskAbortedError as TaskAbortedError2,
|
|
814
|
+
Workflow as Workflow4
|
|
815
|
+
} from "@workglow/task-graph";
|
|
816
|
+
import { sleep } from "@workglow/util";
|
|
817
|
+
var inputSchema4 = {
|
|
818
|
+
type: "object",
|
|
819
|
+
properties: {
|
|
820
|
+
delay: {
|
|
821
|
+
type: "number",
|
|
822
|
+
title: "Delay (ms)",
|
|
823
|
+
default: 1
|
|
824
|
+
},
|
|
825
|
+
pass_through: {
|
|
826
|
+
title: "Pass Through",
|
|
827
|
+
description: "Pass through data to the output"
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
additionalProperties: false
|
|
831
|
+
};
|
|
832
|
+
var outputSchema4 = {
|
|
833
|
+
type: "object",
|
|
834
|
+
properties: {},
|
|
835
|
+
additionalProperties: true
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
class DelayTask extends Task3 {
|
|
839
|
+
static type = "DelayTask";
|
|
840
|
+
static category = "Utility";
|
|
841
|
+
static title = "Delay";
|
|
842
|
+
static description = "Delays execution for a specified duration with progress tracking";
|
|
843
|
+
static inputSchema() {
|
|
844
|
+
return inputSchema4;
|
|
845
|
+
}
|
|
846
|
+
static outputSchema() {
|
|
847
|
+
return outputSchema4;
|
|
848
|
+
}
|
|
849
|
+
async execute(input, executeContext) {
|
|
850
|
+
const delay = input.delay ?? 0;
|
|
851
|
+
if (delay > 100) {
|
|
852
|
+
const iterations = Math.min(100, Math.floor(delay / 16));
|
|
853
|
+
const chunkSize = delay / iterations;
|
|
854
|
+
for (let i = 0;i < iterations; i++) {
|
|
855
|
+
if (executeContext.signal.aborted) {
|
|
856
|
+
throw new TaskAbortedError2("Task aborted");
|
|
857
|
+
}
|
|
858
|
+
await sleep(chunkSize);
|
|
859
|
+
await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
|
|
860
|
+
}
|
|
861
|
+
} else {
|
|
862
|
+
await sleep(delay);
|
|
863
|
+
}
|
|
864
|
+
return input.pass_through;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
var delay = (input, config = {}) => {
|
|
868
|
+
const task = new DelayTask({}, config);
|
|
869
|
+
return task.run(input);
|
|
870
|
+
};
|
|
871
|
+
Workflow4.prototype.delay = CreateWorkflow4(DelayTask);
|
|
872
|
+
// src/task/InputTask.ts
|
|
873
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
874
|
+
|
|
875
|
+
class InputTask extends Task4 {
|
|
876
|
+
static type = "InputTask";
|
|
877
|
+
static category = "Flow Control";
|
|
878
|
+
static title = "Input";
|
|
879
|
+
static description = "Starts the workflow";
|
|
880
|
+
static hasDynamicSchemas = true;
|
|
881
|
+
static cacheable = false;
|
|
882
|
+
static inputSchema() {
|
|
883
|
+
return {
|
|
884
|
+
type: "object",
|
|
885
|
+
properties: {},
|
|
886
|
+
additionalProperties: true
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
static outputSchema() {
|
|
890
|
+
return {
|
|
891
|
+
type: "object",
|
|
892
|
+
properties: {},
|
|
893
|
+
additionalProperties: true
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
inputSchema() {
|
|
897
|
+
return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
|
|
898
|
+
}
|
|
899
|
+
outputSchema() {
|
|
900
|
+
return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
|
|
901
|
+
}
|
|
902
|
+
async execute(input) {
|
|
903
|
+
return input;
|
|
904
|
+
}
|
|
905
|
+
async executeReactive(input) {
|
|
906
|
+
return input;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
Workflow5.prototype.input = CreateWorkflow5(InputTask);
|
|
422
910
|
// src/task/JavaScriptTask.ts
|
|
423
|
-
import { CreateWorkflow as
|
|
911
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
424
912
|
|
|
425
913
|
// src/util/acorn.js
|
|
426
914
|
var options;
|
|
@@ -4883,7 +5371,7 @@ Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
|
4883
5371
|
Interpreter["Status"] = Interpreter.Status;
|
|
4884
5372
|
|
|
4885
5373
|
// src/task/JavaScriptTask.ts
|
|
4886
|
-
var
|
|
5374
|
+
var inputSchema5 = {
|
|
4887
5375
|
type: "object",
|
|
4888
5376
|
properties: {
|
|
4889
5377
|
javascript_code: {
|
|
@@ -4897,7 +5385,7 @@ var inputSchema4 = {
|
|
|
4897
5385
|
required: ["javascript_code"],
|
|
4898
5386
|
additionalProperties: true
|
|
4899
5387
|
};
|
|
4900
|
-
var
|
|
5388
|
+
var outputSchema5 = {
|
|
4901
5389
|
type: "object",
|
|
4902
5390
|
properties: {
|
|
4903
5391
|
output: {
|
|
@@ -4909,16 +5397,16 @@ var outputSchema4 = {
|
|
|
4909
5397
|
additionalProperties: false
|
|
4910
5398
|
};
|
|
4911
5399
|
|
|
4912
|
-
class JavaScriptTask extends
|
|
5400
|
+
class JavaScriptTask extends Task5 {
|
|
4913
5401
|
static type = "JavaScriptTask";
|
|
4914
5402
|
static category = "Utility";
|
|
4915
5403
|
static title = "JavaScript Interpreter";
|
|
4916
5404
|
static description = "Executes JavaScript code in a sandboxed interpreter environment";
|
|
4917
5405
|
static inputSchema() {
|
|
4918
|
-
return
|
|
5406
|
+
return inputSchema5;
|
|
4919
5407
|
}
|
|
4920
5408
|
static outputSchema() {
|
|
4921
|
-
return
|
|
5409
|
+
return outputSchema5;
|
|
4922
5410
|
}
|
|
4923
5411
|
async executeReactive(input2, output) {
|
|
4924
5412
|
if (input2.javascript_code) {
|
|
@@ -4937,22 +5425,20 @@ class JavaScriptTask extends Task3 {
|
|
|
4937
5425
|
return output;
|
|
4938
5426
|
}
|
|
4939
5427
|
}
|
|
4940
|
-
TaskRegistry4.registerTask(JavaScriptTask);
|
|
4941
5428
|
var javaScript = (input2, config = {}) => {
|
|
4942
|
-
return new JavaScriptTask(
|
|
5429
|
+
return new JavaScriptTask({}, config).run(input2);
|
|
4943
5430
|
};
|
|
4944
|
-
|
|
5431
|
+
Workflow6.prototype.javaScript = CreateWorkflow6(JavaScriptTask);
|
|
4945
5432
|
// src/task/JsonTask.ts
|
|
4946
5433
|
import {
|
|
4947
5434
|
createGraphFromDependencyJSON,
|
|
4948
|
-
CreateWorkflow as
|
|
5435
|
+
CreateWorkflow as CreateWorkflow7,
|
|
4949
5436
|
Dataflow,
|
|
4950
|
-
GraphAsTask,
|
|
5437
|
+
GraphAsTask as GraphAsTask2,
|
|
4951
5438
|
TaskConfigurationError as TaskConfigurationError2,
|
|
4952
|
-
|
|
4953
|
-
Workflow as Workflow5
|
|
5439
|
+
Workflow as Workflow7
|
|
4954
5440
|
} from "@workglow/task-graph";
|
|
4955
|
-
var
|
|
5441
|
+
var inputSchema6 = {
|
|
4956
5442
|
type: "object",
|
|
4957
5443
|
properties: {
|
|
4958
5444
|
json: {
|
|
@@ -4963,7 +5449,7 @@ var inputSchema5 = {
|
|
|
4963
5449
|
},
|
|
4964
5450
|
additionalProperties: false
|
|
4965
5451
|
};
|
|
4966
|
-
var
|
|
5452
|
+
var outputSchema6 = {
|
|
4967
5453
|
type: "object",
|
|
4968
5454
|
properties: {
|
|
4969
5455
|
output: {
|
|
@@ -4974,14 +5460,16 @@ var outputSchema5 = {
|
|
|
4974
5460
|
additionalProperties: false
|
|
4975
5461
|
};
|
|
4976
5462
|
|
|
4977
|
-
class JsonTask extends
|
|
5463
|
+
class JsonTask extends GraphAsTask2 {
|
|
4978
5464
|
static type = "JsonTask";
|
|
4979
5465
|
static category = "Hidden";
|
|
5466
|
+
static title = "JSON Task";
|
|
5467
|
+
static description = "A task that creates and manages task graphs from JSON configurations";
|
|
4980
5468
|
static inputSchema() {
|
|
4981
|
-
return
|
|
5469
|
+
return inputSchema6;
|
|
4982
5470
|
}
|
|
4983
5471
|
static outputSchema() {
|
|
4984
|
-
return
|
|
5472
|
+
return outputSchema6;
|
|
4985
5473
|
}
|
|
4986
5474
|
regenerateGraph() {
|
|
4987
5475
|
if (!this.runInputData.json)
|
|
@@ -5009,21 +5497,19 @@ class JsonTask extends GraphAsTask {
|
|
|
5009
5497
|
super.regenerateGraph();
|
|
5010
5498
|
}
|
|
5011
5499
|
}
|
|
5012
|
-
TaskRegistry5.registerTask(JsonTask);
|
|
5013
5500
|
var json = (input2, config = {}) => {
|
|
5014
|
-
return new JsonTask(
|
|
5501
|
+
return new JsonTask({}, config).run(input2);
|
|
5015
5502
|
};
|
|
5016
|
-
|
|
5503
|
+
Workflow7.prototype.json = CreateWorkflow7(JsonTask);
|
|
5017
5504
|
// src/task/LambdaTask.ts
|
|
5018
5505
|
import {
|
|
5019
|
-
CreateWorkflow as
|
|
5506
|
+
CreateWorkflow as CreateWorkflow8,
|
|
5020
5507
|
DATAFLOW_ALL_PORTS,
|
|
5021
|
-
Task as
|
|
5508
|
+
Task as Task6,
|
|
5022
5509
|
TaskConfigurationError as TaskConfigurationError3,
|
|
5023
|
-
|
|
5024
|
-
Workflow as Workflow6
|
|
5510
|
+
Workflow as Workflow8
|
|
5025
5511
|
} from "@workglow/task-graph";
|
|
5026
|
-
var
|
|
5512
|
+
var inputSchema7 = {
|
|
5027
5513
|
type: "object",
|
|
5028
5514
|
properties: {
|
|
5029
5515
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5033,7 +5519,7 @@ var inputSchema6 = {
|
|
|
5033
5519
|
},
|
|
5034
5520
|
additionalProperties: true
|
|
5035
5521
|
};
|
|
5036
|
-
var
|
|
5522
|
+
var outputSchema7 = {
|
|
5037
5523
|
type: "object",
|
|
5038
5524
|
properties: {
|
|
5039
5525
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5044,15 +5530,17 @@ var outputSchema6 = {
|
|
|
5044
5530
|
additionalProperties: true
|
|
5045
5531
|
};
|
|
5046
5532
|
|
|
5047
|
-
class LambdaTask extends
|
|
5533
|
+
class LambdaTask extends Task6 {
|
|
5048
5534
|
static type = "LambdaTask";
|
|
5535
|
+
static title = "Lambda Task";
|
|
5536
|
+
static description = "A task that wraps a provided function and its input";
|
|
5049
5537
|
static category = "Hidden";
|
|
5050
5538
|
static cacheable = true;
|
|
5051
5539
|
static inputSchema() {
|
|
5052
|
-
return
|
|
5540
|
+
return inputSchema7;
|
|
5053
5541
|
}
|
|
5054
5542
|
static outputSchema() {
|
|
5055
|
-
return
|
|
5543
|
+
return outputSchema7;
|
|
5056
5544
|
}
|
|
5057
5545
|
constructor(input2 = {}, config = {}) {
|
|
5058
5546
|
if (!config.execute && !config.executeReactive) {
|
|
@@ -5073,7 +5561,6 @@ class LambdaTask extends Task4 {
|
|
|
5073
5561
|
return output;
|
|
5074
5562
|
}
|
|
5075
5563
|
}
|
|
5076
|
-
TaskRegistry6.registerTask(LambdaTask);
|
|
5077
5564
|
function process(value) {
|
|
5078
5565
|
if (typeof value === "string")
|
|
5079
5566
|
return `Processed: ${value}`;
|
|
@@ -5091,20 +5578,15 @@ function lambda(input2, config) {
|
|
|
5091
5578
|
const task = new LambdaTask(input2, config);
|
|
5092
5579
|
return task.run();
|
|
5093
5580
|
}
|
|
5094
|
-
|
|
5581
|
+
Workflow8.prototype.lambda = CreateWorkflow8(LambdaTask);
|
|
5095
5582
|
// src/task/MergeTask.ts
|
|
5096
|
-
import {
|
|
5097
|
-
|
|
5098
|
-
Task as Task5,
|
|
5099
|
-
TaskRegistry as TaskRegistry7,
|
|
5100
|
-
Workflow as Workflow7
|
|
5101
|
-
} from "@workglow/task-graph";
|
|
5102
|
-
var inputSchema7 = {
|
|
5583
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
5584
|
+
var inputSchema8 = {
|
|
5103
5585
|
type: "object",
|
|
5104
5586
|
properties: {},
|
|
5105
5587
|
additionalProperties: true
|
|
5106
5588
|
};
|
|
5107
|
-
var
|
|
5589
|
+
var outputSchema8 = {
|
|
5108
5590
|
type: "object",
|
|
5109
5591
|
properties: {
|
|
5110
5592
|
output: {
|
|
@@ -5116,17 +5598,17 @@ var outputSchema7 = {
|
|
|
5116
5598
|
additionalProperties: false
|
|
5117
5599
|
};
|
|
5118
5600
|
|
|
5119
|
-
class MergeTask extends
|
|
5601
|
+
class MergeTask extends Task7 {
|
|
5120
5602
|
static type = "MergeTask";
|
|
5121
5603
|
static category = "Utility";
|
|
5122
5604
|
static title = "Merge";
|
|
5123
5605
|
static description = "Merges multiple inputs into a single array output";
|
|
5124
5606
|
static cacheable = true;
|
|
5125
5607
|
static inputSchema() {
|
|
5126
|
-
return
|
|
5608
|
+
return inputSchema8;
|
|
5127
5609
|
}
|
|
5128
5610
|
static outputSchema() {
|
|
5129
|
-
return
|
|
5611
|
+
return outputSchema8;
|
|
5130
5612
|
}
|
|
5131
5613
|
async execute(input2, context) {
|
|
5132
5614
|
const keys = Object.keys(input2).sort();
|
|
@@ -5136,15 +5618,52 @@ class MergeTask extends Task5 {
|
|
|
5136
5618
|
};
|
|
5137
5619
|
}
|
|
5138
5620
|
}
|
|
5139
|
-
TaskRegistry7.registerTask(MergeTask);
|
|
5140
5621
|
var merge = (input2, config = {}) => {
|
|
5141
|
-
const task = new MergeTask(
|
|
5142
|
-
return task.run();
|
|
5622
|
+
const task = new MergeTask({}, config);
|
|
5623
|
+
return task.run(input2);
|
|
5143
5624
|
};
|
|
5144
|
-
|
|
5625
|
+
Workflow9.prototype.merge = CreateWorkflow9(MergeTask);
|
|
5626
|
+
// src/task/OutputTask.ts
|
|
5627
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task8, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
5628
|
+
|
|
5629
|
+
class OutputTask extends Task8 {
|
|
5630
|
+
static type = "OutputTask";
|
|
5631
|
+
static category = "Flow Control";
|
|
5632
|
+
static title = "Output";
|
|
5633
|
+
static description = "Ends the workflow";
|
|
5634
|
+
static hasDynamicSchemas = true;
|
|
5635
|
+
static cacheable = false;
|
|
5636
|
+
static inputSchema() {
|
|
5637
|
+
return {
|
|
5638
|
+
type: "object",
|
|
5639
|
+
properties: {},
|
|
5640
|
+
additionalProperties: true
|
|
5641
|
+
};
|
|
5642
|
+
}
|
|
5643
|
+
static outputSchema() {
|
|
5644
|
+
return {
|
|
5645
|
+
type: "object",
|
|
5646
|
+
properties: {},
|
|
5647
|
+
additionalProperties: true
|
|
5648
|
+
};
|
|
5649
|
+
}
|
|
5650
|
+
inputSchema() {
|
|
5651
|
+
return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
|
|
5652
|
+
}
|
|
5653
|
+
outputSchema() {
|
|
5654
|
+
return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
|
|
5655
|
+
}
|
|
5656
|
+
async execute(input2) {
|
|
5657
|
+
return input2;
|
|
5658
|
+
}
|
|
5659
|
+
async executeReactive(input2) {
|
|
5660
|
+
return input2;
|
|
5661
|
+
}
|
|
5662
|
+
}
|
|
5663
|
+
Workflow10.prototype.output = CreateWorkflow10(OutputTask);
|
|
5145
5664
|
// src/task/SplitTask.ts
|
|
5146
|
-
import { CreateWorkflow as
|
|
5147
|
-
var
|
|
5665
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task9, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
5666
|
+
var inputSchema9 = {
|
|
5148
5667
|
type: "object",
|
|
5149
5668
|
properties: {
|
|
5150
5669
|
input: {
|
|
@@ -5154,13 +5673,13 @@ var inputSchema8 = {
|
|
|
5154
5673
|
},
|
|
5155
5674
|
additionalProperties: false
|
|
5156
5675
|
};
|
|
5157
|
-
var
|
|
5676
|
+
var outputSchema9 = {
|
|
5158
5677
|
type: "object",
|
|
5159
5678
|
properties: {},
|
|
5160
5679
|
additionalProperties: true
|
|
5161
5680
|
};
|
|
5162
5681
|
|
|
5163
|
-
class SplitTask extends
|
|
5682
|
+
class SplitTask extends Task9 {
|
|
5164
5683
|
static type = "SplitTask";
|
|
5165
5684
|
static category = "Utility";
|
|
5166
5685
|
static title = "Split";
|
|
@@ -5168,13 +5687,13 @@ class SplitTask extends Task6 {
|
|
|
5168
5687
|
static hasDynamicSchemas = true;
|
|
5169
5688
|
static cacheable = false;
|
|
5170
5689
|
static inputSchema() {
|
|
5171
|
-
return
|
|
5690
|
+
return inputSchema9;
|
|
5172
5691
|
}
|
|
5173
5692
|
static outputSchema() {
|
|
5174
|
-
return
|
|
5693
|
+
return outputSchema9;
|
|
5175
5694
|
}
|
|
5176
5695
|
outputSchema() {
|
|
5177
|
-
return
|
|
5696
|
+
return outputSchema9;
|
|
5178
5697
|
}
|
|
5179
5698
|
async executeReactive(input2) {
|
|
5180
5699
|
const inputValue = input2.input;
|
|
@@ -5189,31 +5708,60 @@ class SplitTask extends Task6 {
|
|
|
5189
5708
|
return output;
|
|
5190
5709
|
}
|
|
5191
5710
|
}
|
|
5192
|
-
TaskRegistry8.registerTask(SplitTask);
|
|
5193
5711
|
var split = (input2, config = {}) => {
|
|
5194
|
-
const task = new SplitTask(
|
|
5195
|
-
return task.run();
|
|
5712
|
+
const task = new SplitTask({}, config);
|
|
5713
|
+
return task.run(input2);
|
|
5714
|
+
};
|
|
5715
|
+
Workflow11.prototype.split = CreateWorkflow11(SplitTask);
|
|
5716
|
+
|
|
5717
|
+
// src/common.ts
|
|
5718
|
+
import { TaskRegistry } from "@workglow/task-graph";
|
|
5719
|
+
var registerCommonTasks = () => {
|
|
5720
|
+
const tasks = [
|
|
5721
|
+
ArrayTask,
|
|
5722
|
+
DebugLogTask,
|
|
5723
|
+
DelayTask,
|
|
5724
|
+
FetchUrlTask,
|
|
5725
|
+
InputTask,
|
|
5726
|
+
JavaScriptTask,
|
|
5727
|
+
JsonTask,
|
|
5728
|
+
LambdaTask,
|
|
5729
|
+
MergeTask,
|
|
5730
|
+
OutputTask,
|
|
5731
|
+
SplitTask
|
|
5732
|
+
];
|
|
5733
|
+
tasks.map(TaskRegistry.registerTask);
|
|
5734
|
+
return tasks;
|
|
5196
5735
|
};
|
|
5197
|
-
|
|
5736
|
+
|
|
5737
|
+
// src/browser.ts
|
|
5738
|
+
[FileLoaderTask].map(TaskRegistry2.registerTask);
|
|
5198
5739
|
export {
|
|
5199
5740
|
split,
|
|
5741
|
+
registerCommonTasks,
|
|
5200
5742
|
process,
|
|
5201
5743
|
merge,
|
|
5202
5744
|
lambda,
|
|
5203
5745
|
json,
|
|
5204
5746
|
javaScript,
|
|
5747
|
+
fileLoader,
|
|
5205
5748
|
fetchUrl,
|
|
5206
5749
|
delay,
|
|
5207
5750
|
debugLog,
|
|
5751
|
+
TypeReplicateArray,
|
|
5208
5752
|
SplitTask,
|
|
5753
|
+
OutputTask,
|
|
5209
5754
|
MergeTask,
|
|
5210
5755
|
LambdaTask,
|
|
5211
5756
|
JsonTask,
|
|
5212
5757
|
JavaScriptTask,
|
|
5758
|
+
InputTask,
|
|
5759
|
+
FileLoaderTask,
|
|
5213
5760
|
FetchUrlTask,
|
|
5214
5761
|
FetchUrlJob,
|
|
5215
5762
|
DelayTask,
|
|
5216
|
-
DebugLogTask
|
|
5763
|
+
DebugLogTask,
|
|
5764
|
+
ArrayTask
|
|
5217
5765
|
};
|
|
5218
5766
|
|
|
5219
|
-
//# debugId=
|
|
5767
|
+
//# debugId=B1BD272CB310F36564756E2164756E21
|