@workglow/tasks 0.0.102 → 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.
- package/dist/browser.js +1446 -1293
- package/dist/browser.js.map +10 -10
- package/dist/bun.js +1519 -1343
- package/dist/bun.js.map +11 -11
- package/dist/common.d.ts +1 -1
- package/dist/common.d.ts.map +1 -1
- package/dist/node.js +1519 -1343
- package/dist/node.js.map +11 -11
- package/dist/task/FileLoaderTask.d.ts +23 -0
- package/dist/task/FileLoaderTask.d.ts.map +1 -1
- package/dist/task/FileLoaderTask.server.d.ts +3 -0
- package/dist/task/FileLoaderTask.server.d.ts.map +1 -1
- package/dist/task/InputTask.d.ts.map +1 -1
- package/dist/task/JavaScriptTask.d.ts +4 -0
- package/dist/task/JavaScriptTask.d.ts.map +1 -1
- package/dist/task/LambdaTask.d.ts +4 -0
- package/dist/task/LambdaTask.d.ts.map +1 -1
- package/dist/task/OutputTask.d.ts.map +1 -1
- package/dist/task/mcp/McpPromptGetTask.d.ts +8 -0
- package/dist/task/mcp/McpPromptGetTask.d.ts.map +1 -1
- package/dist/task/mcp/McpResourceReadTask.d.ts +8 -0
- package/dist/task/mcp/McpResourceReadTask.d.ts.map +1 -1
- package/dist/task/mcp/McpToolCallTask.d.ts +8 -0
- package/dist/task/mcp/McpToolCallTask.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/task/scalar/scalar.test.d.ts +0 -7
- package/dist/task/scalar/scalar.test.d.ts.map +0 -1
- package/dist/task/vector/vector.test.d.ts +0 -7
- 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/
|
|
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/
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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: "
|
|
72
|
-
description: "
|
|
39
|
+
title: "A",
|
|
40
|
+
description: "First number"
|
|
73
41
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"x-ui-hidden": true
|
|
42
|
+
b: {
|
|
43
|
+
type: "number",
|
|
44
|
+
title: "B",
|
|
45
|
+
description: "Second number"
|
|
79
46
|
}
|
|
80
47
|
},
|
|
81
|
-
required: ["
|
|
48
|
+
required: ["a", "b"],
|
|
82
49
|
additionalProperties: false
|
|
83
50
|
};
|
|
84
51
|
var outputSchema = {
|
|
85
52
|
type: "object",
|
|
86
53
|
properties: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
238
|
-
static type = "
|
|
239
|
-
static category = "
|
|
240
|
-
static title = "
|
|
241
|
-
static description = "
|
|
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
|
-
|
|
250
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
334
|
-
type: "
|
|
335
|
-
title: "
|
|
336
|
-
description: "
|
|
337
|
-
format: "uri"
|
|
86
|
+
a: {
|
|
87
|
+
type: "number",
|
|
88
|
+
title: "A",
|
|
89
|
+
description: "Numerator"
|
|
338
90
|
},
|
|
339
|
-
|
|
340
|
-
type: "
|
|
341
|
-
|
|
342
|
-
|
|
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: ["
|
|
97
|
+
required: ["a", "b"],
|
|
348
98
|
additionalProperties: false
|
|
349
99
|
};
|
|
350
100
|
var outputSchema2 = {
|
|
351
101
|
type: "object",
|
|
352
102
|
properties: {
|
|
353
|
-
|
|
354
|
-
type: "
|
|
355
|
-
title: "
|
|
356
|
-
description: "
|
|
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: ["
|
|
109
|
+
required: ["result"],
|
|
393
110
|
additionalProperties: false
|
|
394
111
|
};
|
|
395
112
|
|
|
396
|
-
class
|
|
397
|
-
static type = "
|
|
398
|
-
static category = "
|
|
399
|
-
static title = "
|
|
400
|
-
static description = "
|
|
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,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
|
|
452
|
-
return
|
|
170
|
+
static outputSchema() {
|
|
171
|
+
return outputSchema3;
|
|
453
172
|
}
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
644
|
-
var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
|
|
177
|
+
Workflow3.prototype.scalarMultiply = CreateWorkflow3(ScalarMultiplyTask);
|
|
645
178
|
|
|
646
|
-
// src/task/scalar/
|
|
647
|
-
|
|
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
|
|
198
|
+
var outputSchema4 = {
|
|
665
199
|
type: "object",
|
|
666
200
|
properties: {
|
|
667
201
|
result: {
|
|
668
202
|
type: "number",
|
|
669
203
|
title: "Result",
|
|
670
|
-
description: "
|
|
204
|
+
description: "Difference (a - b)"
|
|
671
205
|
}
|
|
672
206
|
},
|
|
673
207
|
required: ["result"],
|
|
674
208
|
additionalProperties: false
|
|
675
209
|
};
|
|
676
210
|
|
|
677
|
-
class
|
|
678
|
-
static type = "
|
|
211
|
+
class ScalarSubtractTask extends Task4 {
|
|
212
|
+
static type = "ScalarSubtractTask";
|
|
679
213
|
static category = "Math";
|
|
680
|
-
static title = "
|
|
681
|
-
static description = "Returns the
|
|
214
|
+
static title = "Subtract";
|
|
215
|
+
static description = "Returns the difference of two numbers (a - b)";
|
|
682
216
|
static inputSchema() {
|
|
683
|
-
return
|
|
217
|
+
return inputSchema4;
|
|
684
218
|
}
|
|
685
219
|
static outputSchema() {
|
|
686
|
-
return
|
|
220
|
+
return outputSchema4;
|
|
687
221
|
}
|
|
688
222
|
async execute(input, _context) {
|
|
689
|
-
return { result:
|
|
223
|
+
return { result: input.a - input.b };
|
|
690
224
|
}
|
|
691
225
|
}
|
|
692
|
-
|
|
226
|
+
Workflow4.prototype.scalarSubtract = CreateWorkflow4(ScalarSubtractTask);
|
|
693
227
|
|
|
694
|
-
// src/task/scalar/
|
|
695
|
-
import { CreateWorkflow as
|
|
696
|
-
var
|
|
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
|
-
|
|
700
|
-
type: "
|
|
701
|
-
|
|
702
|
-
|
|
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: ["
|
|
240
|
+
required: ["values"],
|
|
711
241
|
additionalProperties: false
|
|
712
242
|
};
|
|
713
|
-
var
|
|
243
|
+
var outputSchema5 = {
|
|
714
244
|
type: "object",
|
|
715
245
|
properties: {
|
|
716
246
|
result: {
|
|
717
247
|
type: "number",
|
|
718
248
|
title: "Result",
|
|
719
|
-
description: "
|
|
249
|
+
description: "Sum of all values"
|
|
720
250
|
}
|
|
721
251
|
},
|
|
722
252
|
required: ["result"],
|
|
723
253
|
additionalProperties: false
|
|
724
254
|
};
|
|
725
255
|
|
|
726
|
-
class
|
|
727
|
-
static type = "
|
|
256
|
+
class ScalarSumTask extends Task5 {
|
|
257
|
+
static type = "ScalarSumTask";
|
|
728
258
|
static category = "Math";
|
|
729
|
-
static title = "
|
|
730
|
-
static description = "Returns the
|
|
259
|
+
static title = "Sum";
|
|
260
|
+
static description = "Returns the sum of an array of numbers";
|
|
731
261
|
static inputSchema() {
|
|
732
|
-
return
|
|
262
|
+
return inputSchema5;
|
|
733
263
|
}
|
|
734
264
|
static outputSchema() {
|
|
735
|
-
return
|
|
265
|
+
return outputSchema5;
|
|
736
266
|
}
|
|
737
267
|
async execute(input, _context) {
|
|
738
|
-
return { result: input.
|
|
268
|
+
return { result: sumPrecise(input.values) };
|
|
739
269
|
}
|
|
740
270
|
}
|
|
741
|
-
|
|
271
|
+
Workflow5.prototype.scalarSum = CreateWorkflow5(ScalarSumTask);
|
|
742
272
|
|
|
743
|
-
// src/task/
|
|
744
|
-
import { CreateWorkflow as
|
|
745
|
-
|
|
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
|
-
|
|
749
|
-
type: "
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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: ["
|
|
292
|
+
required: ["vectors"],
|
|
760
293
|
additionalProperties: false
|
|
761
294
|
};
|
|
762
|
-
var
|
|
295
|
+
var outputSchema6 = {
|
|
763
296
|
type: "object",
|
|
764
297
|
properties: {
|
|
765
|
-
result: {
|
|
766
|
-
type: "number",
|
|
298
|
+
result: TypedArraySchema({
|
|
767
299
|
title: "Result",
|
|
768
|
-
description: "
|
|
769
|
-
}
|
|
300
|
+
description: "Component-wise quotient"
|
|
301
|
+
})
|
|
770
302
|
},
|
|
771
303
|
required: ["result"],
|
|
772
304
|
additionalProperties: false
|
|
773
305
|
};
|
|
774
306
|
|
|
775
|
-
class
|
|
776
|
-
static type = "
|
|
777
|
-
static category = "
|
|
778
|
-
static title = "
|
|
779
|
-
static description = "Returns
|
|
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
|
|
313
|
+
return inputSchema6;
|
|
782
314
|
}
|
|
783
315
|
static outputSchema() {
|
|
784
|
-
return
|
|
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
|
-
|
|
339
|
+
Workflow6.prototype.vectorDivide = CreateWorkflow6(VectorDivideTask);
|
|
953
340
|
|
|
954
341
|
// src/task/vector/VectorMultiplyTask.ts
|
|
955
|
-
import { CreateWorkflow as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
381
|
+
return inputSchema7;
|
|
995
382
|
}
|
|
996
383
|
static outputSchema() {
|
|
997
|
-
return
|
|
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
|
-
|
|
401
|
+
Workflow7.prototype.vectorMultiply = CreateWorkflow7(VectorMultiplyTask);
|
|
1015
402
|
|
|
1016
403
|
// src/task/vector/VectorSubtractTask.ts
|
|
1017
|
-
import { CreateWorkflow as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
443
|
+
return inputSchema8;
|
|
1057
444
|
}
|
|
1058
445
|
static outputSchema() {
|
|
1059
|
-
return
|
|
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
|
-
|
|
469
|
+
Workflow8.prototype.vectorSubtract = CreateWorkflow8(VectorSubtractTask);
|
|
1083
470
|
|
|
1084
471
|
// src/task/vector/VectorSumTask.ts
|
|
1085
|
-
import { CreateWorkflow as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
511
|
+
return inputSchema9;
|
|
1125
512
|
}
|
|
1126
513
|
static outputSchema() {
|
|
1127
|
-
return
|
|
514
|
+
return outputSchema9;
|
|
1128
515
|
}
|
|
1129
516
|
async execute(input, _context) {
|
|
1130
517
|
const { vectors } = input;
|
|
@@ -1141,14 +528,14 @@ class VectorSumTask extends Task10 {
|
|
|
1141
528
|
return { result: createTypedArrayFrom4(vectors, values) };
|
|
1142
529
|
}
|
|
1143
530
|
}
|
|
1144
|
-
|
|
531
|
+
Workflow9.prototype.vectorSum = CreateWorkflow9(VectorSumTask);
|
|
1145
532
|
|
|
1146
533
|
// src/task/adaptive.ts
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
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);
|
|
1152
539
|
|
|
1153
540
|
// src/task/ArrayTask.ts
|
|
1154
541
|
import {
|
|
@@ -1184,12 +571,12 @@ class ArrayTask extends GraphAsTask {
|
|
|
1184
571
|
regenerateGraph() {
|
|
1185
572
|
const arrayInputs = new Map;
|
|
1186
573
|
let hasArrayInputs = false;
|
|
1187
|
-
const
|
|
1188
|
-
if (typeof
|
|
1189
|
-
const keys = Object.keys(
|
|
574
|
+
const inputSchema10 = this.inputSchema();
|
|
575
|
+
if (typeof inputSchema10 !== "boolean") {
|
|
576
|
+
const keys = Object.keys(inputSchema10.properties || {});
|
|
1190
577
|
for (const inputId of keys) {
|
|
1191
578
|
const inputValue = this.runInputData[inputId];
|
|
1192
|
-
const inputDef =
|
|
579
|
+
const inputDef = inputSchema10.properties?.[inputId];
|
|
1193
580
|
if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
|
|
1194
581
|
arrayInputs.set(inputId, inputValue);
|
|
1195
582
|
hasArrayInputs = true;
|
|
@@ -1278,7 +665,7 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
|
|
|
1278
665
|
}
|
|
1279
666
|
}
|
|
1280
667
|
// src/task/DebugLogTask.ts
|
|
1281
|
-
import { CreateWorkflow as
|
|
668
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task10, TaskConfigSchema, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
1282
669
|
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
1283
670
|
var DEFAULT_LOG_LEVEL = "log";
|
|
1284
671
|
var debugLogTaskConfigSchema = {
|
|
@@ -1295,18 +682,18 @@ var debugLogTaskConfigSchema = {
|
|
|
1295
682
|
},
|
|
1296
683
|
additionalProperties: false
|
|
1297
684
|
};
|
|
1298
|
-
var
|
|
685
|
+
var inputSchema10 = {
|
|
1299
686
|
type: "object",
|
|
1300
687
|
properties: {},
|
|
1301
688
|
additionalProperties: true
|
|
1302
689
|
};
|
|
1303
|
-
var
|
|
690
|
+
var outputSchema10 = {
|
|
1304
691
|
type: "object",
|
|
1305
692
|
properties: {},
|
|
1306
693
|
additionalProperties: true
|
|
1307
694
|
};
|
|
1308
695
|
|
|
1309
|
-
class DebugLogTask extends
|
|
696
|
+
class DebugLogTask extends Task10 {
|
|
1310
697
|
static type = "DebugLogTask";
|
|
1311
698
|
static category = "Utility";
|
|
1312
699
|
static title = "Debug Log";
|
|
@@ -1318,10 +705,10 @@ class DebugLogTask extends Task11 {
|
|
|
1318
705
|
return debugLogTaskConfigSchema;
|
|
1319
706
|
}
|
|
1320
707
|
static inputSchema() {
|
|
1321
|
-
return
|
|
708
|
+
return inputSchema10;
|
|
1322
709
|
}
|
|
1323
710
|
static outputSchema() {
|
|
1324
|
-
return
|
|
711
|
+
return outputSchema10;
|
|
1325
712
|
}
|
|
1326
713
|
async executeReactive(input, output) {
|
|
1327
714
|
const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
|
|
@@ -1339,14 +726,14 @@ var debugLog = (input, config = {}) => {
|
|
|
1339
726
|
const task = new DebugLogTask({}, config);
|
|
1340
727
|
return task.run(input);
|
|
1341
728
|
};
|
|
1342
|
-
|
|
729
|
+
Workflow11.prototype.debugLog = CreateWorkflow10(DebugLogTask);
|
|
1343
730
|
// src/task/DelayTask.ts
|
|
1344
731
|
import {
|
|
1345
|
-
CreateWorkflow as
|
|
1346
|
-
Task as
|
|
1347
|
-
TaskAbortedError
|
|
732
|
+
CreateWorkflow as CreateWorkflow11,
|
|
733
|
+
Task as Task11,
|
|
734
|
+
TaskAbortedError,
|
|
1348
735
|
TaskConfigSchema as TaskConfigSchema2,
|
|
1349
|
-
Workflow as
|
|
736
|
+
Workflow as Workflow12
|
|
1350
737
|
} from "@workglow/task-graph";
|
|
1351
738
|
import { sleep } from "@workglow/util";
|
|
1352
739
|
var delayTaskConfigSchema = {
|
|
@@ -1361,18 +748,18 @@ var delayTaskConfigSchema = {
|
|
|
1361
748
|
},
|
|
1362
749
|
additionalProperties: false
|
|
1363
750
|
};
|
|
1364
|
-
var
|
|
751
|
+
var inputSchema11 = {
|
|
1365
752
|
type: "object",
|
|
1366
753
|
properties: {},
|
|
1367
754
|
additionalProperties: true
|
|
1368
755
|
};
|
|
1369
|
-
var
|
|
756
|
+
var outputSchema11 = {
|
|
1370
757
|
type: "object",
|
|
1371
758
|
properties: {},
|
|
1372
759
|
additionalProperties: true
|
|
1373
760
|
};
|
|
1374
761
|
|
|
1375
|
-
class DelayTask extends
|
|
762
|
+
class DelayTask extends Task11 {
|
|
1376
763
|
static type = "DelayTask";
|
|
1377
764
|
static category = "Utility";
|
|
1378
765
|
static title = "Delay";
|
|
@@ -1384,10 +771,10 @@ class DelayTask extends Task12 {
|
|
|
1384
771
|
return delayTaskConfigSchema;
|
|
1385
772
|
}
|
|
1386
773
|
static inputSchema() {
|
|
1387
|
-
return
|
|
774
|
+
return inputSchema11;
|
|
1388
775
|
}
|
|
1389
776
|
static outputSchema() {
|
|
1390
|
-
return
|
|
777
|
+
return outputSchema11;
|
|
1391
778
|
}
|
|
1392
779
|
async execute(input, executeContext) {
|
|
1393
780
|
const delay = this.config.delay ?? 1;
|
|
@@ -1396,7 +783,7 @@ class DelayTask extends Task12 {
|
|
|
1396
783
|
const chunkSize = delay / iterations;
|
|
1397
784
|
for (let i = 0;i < iterations; i++) {
|
|
1398
785
|
if (executeContext.signal.aborted) {
|
|
1399
|
-
throw new
|
|
786
|
+
throw new TaskAbortedError("Task aborted");
|
|
1400
787
|
}
|
|
1401
788
|
await sleep(chunkSize);
|
|
1402
789
|
await executeContext.updateProgress(100 * i / iterations, `Delaying for ${delay}ms`);
|
|
@@ -1411,67 +798,378 @@ var delay = (input, config = { delay: 1 }) => {
|
|
|
1411
798
|
const task = new DelayTask({}, config);
|
|
1412
799
|
return task.run(input);
|
|
1413
800
|
};
|
|
1414
|
-
|
|
1415
|
-
// src/task/
|
|
1416
|
-
import {
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
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: {
|
|
1434
832
|
type: "object",
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
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.");
|
|
1470
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
|
+
});
|
|
1471
946
|
}
|
|
1472
|
-
|
|
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();
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
yield { type: "finish", data: input };
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
Workflow14.prototype.input = CreateWorkflow13(InputTask);
|
|
1473
1171
|
// src/task/JavaScriptTask.ts
|
|
1474
|
-
import { CreateWorkflow as
|
|
1172
|
+
import { CreateWorkflow as CreateWorkflow14, Task as Task13, TaskConfigSchema as TaskConfigSchema3, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
1475
1173
|
|
|
1476
1174
|
// src/util/acorn.js
|
|
1477
1175
|
var options;
|
|
@@ -5948,7 +5646,7 @@ var configSchema = {
|
|
|
5948
5646
|
},
|
|
5949
5647
|
additionalProperties: false
|
|
5950
5648
|
};
|
|
5951
|
-
var
|
|
5649
|
+
var inputSchema13 = {
|
|
5952
5650
|
type: "object",
|
|
5953
5651
|
properties: {
|
|
5954
5652
|
javascript_code: {
|
|
@@ -5962,7 +5660,7 @@ var inputSchema14 = {
|
|
|
5962
5660
|
required: ["javascript_code"],
|
|
5963
5661
|
additionalProperties: true
|
|
5964
5662
|
};
|
|
5965
|
-
var
|
|
5663
|
+
var outputSchema13 = {
|
|
5966
5664
|
type: "object",
|
|
5967
5665
|
properties: {
|
|
5968
5666
|
output: {
|
|
@@ -5974,7 +5672,7 @@ var outputSchema14 = {
|
|
|
5974
5672
|
additionalProperties: false
|
|
5975
5673
|
};
|
|
5976
5674
|
|
|
5977
|
-
class JavaScriptTask extends
|
|
5675
|
+
class JavaScriptTask extends Task13 {
|
|
5978
5676
|
static type = "JavaScriptTask";
|
|
5979
5677
|
static category = "Utility";
|
|
5980
5678
|
static title = "JavaScript Interpreter";
|
|
@@ -5984,10 +5682,10 @@ class JavaScriptTask extends Task14 {
|
|
|
5984
5682
|
return configSchema;
|
|
5985
5683
|
}
|
|
5986
5684
|
static inputSchema() {
|
|
5987
|
-
return
|
|
5685
|
+
return inputSchema13;
|
|
5988
5686
|
}
|
|
5989
5687
|
static outputSchema() {
|
|
5990
|
-
return
|
|
5688
|
+
return outputSchema13;
|
|
5991
5689
|
}
|
|
5992
5690
|
constructor(input2 = {}, config = {}) {
|
|
5993
5691
|
super(input2, config);
|
|
@@ -6003,7 +5701,7 @@ class JavaScriptTask extends Task14 {
|
|
|
6003
5701
|
additionalProperties: true
|
|
6004
5702
|
};
|
|
6005
5703
|
}
|
|
6006
|
-
return
|
|
5704
|
+
return inputSchema13;
|
|
6007
5705
|
}
|
|
6008
5706
|
async executeReactive(input2, output) {
|
|
6009
5707
|
if (this.config.javascript_code || input2.javascript_code) {
|
|
@@ -6022,18 +5720,18 @@ class JavaScriptTask extends Task14 {
|
|
|
6022
5720
|
var javaScript = (input2, config = {}) => {
|
|
6023
5721
|
return new JavaScriptTask({}, config).run(input2);
|
|
6024
5722
|
};
|
|
6025
|
-
|
|
5723
|
+
Workflow15.prototype.javaScript = CreateWorkflow14(JavaScriptTask);
|
|
6026
5724
|
// src/task/JsonTask.ts
|
|
6027
5725
|
import {
|
|
6028
5726
|
createGraphFromDependencyJSON,
|
|
6029
5727
|
createGraphFromGraphJSON,
|
|
6030
|
-
CreateWorkflow as
|
|
5728
|
+
CreateWorkflow as CreateWorkflow15,
|
|
6031
5729
|
Dataflow,
|
|
6032
5730
|
GraphAsTask as GraphAsTask2,
|
|
6033
5731
|
TaskConfigurationError as TaskConfigurationError2,
|
|
6034
|
-
Workflow as
|
|
5732
|
+
Workflow as Workflow16
|
|
6035
5733
|
} from "@workglow/task-graph";
|
|
6036
|
-
var
|
|
5734
|
+
var inputSchema14 = {
|
|
6037
5735
|
type: "object",
|
|
6038
5736
|
properties: {
|
|
6039
5737
|
json: {
|
|
@@ -6044,7 +5742,7 @@ var inputSchema15 = {
|
|
|
6044
5742
|
},
|
|
6045
5743
|
additionalProperties: false
|
|
6046
5744
|
};
|
|
6047
|
-
var
|
|
5745
|
+
var outputSchema14 = {
|
|
6048
5746
|
type: "object",
|
|
6049
5747
|
properties: {
|
|
6050
5748
|
output: {
|
|
@@ -6061,10 +5759,10 @@ class JsonTask extends GraphAsTask2 {
|
|
|
6061
5759
|
static title = "JSON Task";
|
|
6062
5760
|
static description = "A task that creates and manages task graphs from JSON configurations";
|
|
6063
5761
|
static inputSchema() {
|
|
6064
|
-
return
|
|
5762
|
+
return inputSchema14;
|
|
6065
5763
|
}
|
|
6066
5764
|
static outputSchema() {
|
|
6067
|
-
return
|
|
5765
|
+
return outputSchema14;
|
|
6068
5766
|
}
|
|
6069
5767
|
regenerateGraph() {
|
|
6070
5768
|
if (!this.runInputData.json)
|
|
@@ -6087,7 +5785,7 @@ class JsonTask extends GraphAsTask2 {
|
|
|
6087
5785
|
if (!sourceTask) {
|
|
6088
5786
|
throw new TaskConfigurationError2(`Dependency id ${dep.id} not found`);
|
|
6089
5787
|
}
|
|
6090
|
-
const df = new Dataflow(sourceTask.
|
|
5788
|
+
const df = new Dataflow(sourceTask.id, dep.output, item.id, input2);
|
|
6091
5789
|
this.subGraph.addDataflow(df);
|
|
6092
5790
|
}
|
|
6093
5791
|
}
|
|
@@ -6098,15 +5796,15 @@ class JsonTask extends GraphAsTask2 {
|
|
|
6098
5796
|
var json = (input2, config = {}) => {
|
|
6099
5797
|
return new JsonTask({}, config).run(input2);
|
|
6100
5798
|
};
|
|
6101
|
-
|
|
5799
|
+
Workflow16.prototype.json = CreateWorkflow15(JsonTask);
|
|
6102
5800
|
// src/task/LambdaTask.ts
|
|
6103
5801
|
import {
|
|
6104
|
-
CreateWorkflow as
|
|
5802
|
+
CreateWorkflow as CreateWorkflow16,
|
|
6105
5803
|
DATAFLOW_ALL_PORTS,
|
|
6106
|
-
Task as
|
|
5804
|
+
Task as Task14,
|
|
6107
5805
|
TaskConfigSchema as TaskConfigSchema4,
|
|
6108
5806
|
TaskConfigurationError as TaskConfigurationError3,
|
|
6109
|
-
Workflow as
|
|
5807
|
+
Workflow as Workflow17
|
|
6110
5808
|
} from "@workglow/task-graph";
|
|
6111
5809
|
var lambdaTaskConfigSchema = {
|
|
6112
5810
|
type: "object",
|
|
@@ -6117,7 +5815,7 @@ var lambdaTaskConfigSchema = {
|
|
|
6117
5815
|
},
|
|
6118
5816
|
additionalProperties: false
|
|
6119
5817
|
};
|
|
6120
|
-
var
|
|
5818
|
+
var inputSchema15 = {
|
|
6121
5819
|
type: "object",
|
|
6122
5820
|
properties: {
|
|
6123
5821
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -6127,7 +5825,7 @@ var inputSchema16 = {
|
|
|
6127
5825
|
},
|
|
6128
5826
|
additionalProperties: true
|
|
6129
5827
|
};
|
|
6130
|
-
var
|
|
5828
|
+
var outputSchema15 = {
|
|
6131
5829
|
type: "object",
|
|
6132
5830
|
properties: {
|
|
6133
5831
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -6138,7 +5836,7 @@ var outputSchema16 = {
|
|
|
6138
5836
|
additionalProperties: true
|
|
6139
5837
|
};
|
|
6140
5838
|
|
|
6141
|
-
class LambdaTask extends
|
|
5839
|
+
class LambdaTask extends Task14 {
|
|
6142
5840
|
static type = "LambdaTask";
|
|
6143
5841
|
static title = "Lambda Task";
|
|
6144
5842
|
static description = "A task that wraps a provided function and its input";
|
|
@@ -6148,10 +5846,10 @@ class LambdaTask extends Task15 {
|
|
|
6148
5846
|
return lambdaTaskConfigSchema;
|
|
6149
5847
|
}
|
|
6150
5848
|
static inputSchema() {
|
|
6151
|
-
return
|
|
5849
|
+
return inputSchema15;
|
|
6152
5850
|
}
|
|
6153
5851
|
static outputSchema() {
|
|
6154
|
-
return
|
|
5852
|
+
return outputSchema15;
|
|
6155
5853
|
}
|
|
6156
5854
|
constructor(input2 = {}, config = {}) {
|
|
6157
5855
|
if (!config.execute && !config.executeReactive) {
|
|
@@ -6189,15 +5887,15 @@ function lambda(input2, config) {
|
|
|
6189
5887
|
const task = new LambdaTask(input2, config);
|
|
6190
5888
|
return task.run();
|
|
6191
5889
|
}
|
|
6192
|
-
|
|
5890
|
+
Workflow17.prototype.lambda = CreateWorkflow16(LambdaTask);
|
|
6193
5891
|
// src/task/MergeTask.ts
|
|
6194
|
-
import { CreateWorkflow as
|
|
6195
|
-
var
|
|
5892
|
+
import { CreateWorkflow as CreateWorkflow17, Task as Task15, Workflow as Workflow18 } from "@workglow/task-graph";
|
|
5893
|
+
var inputSchema16 = {
|
|
6196
5894
|
type: "object",
|
|
6197
5895
|
properties: {},
|
|
6198
5896
|
additionalProperties: true
|
|
6199
5897
|
};
|
|
6200
|
-
var
|
|
5898
|
+
var outputSchema16 = {
|
|
6201
5899
|
type: "object",
|
|
6202
5900
|
properties: {
|
|
6203
5901
|
output: {
|
|
@@ -6209,17 +5907,17 @@ var outputSchema17 = {
|
|
|
6209
5907
|
additionalProperties: false
|
|
6210
5908
|
};
|
|
6211
5909
|
|
|
6212
|
-
class MergeTask extends
|
|
5910
|
+
class MergeTask extends Task15 {
|
|
6213
5911
|
static type = "MergeTask";
|
|
6214
5912
|
static category = "Utility";
|
|
6215
5913
|
static title = "Merge";
|
|
6216
5914
|
static description = "Merges multiple inputs into a single array output";
|
|
6217
5915
|
static cacheable = true;
|
|
6218
5916
|
static inputSchema() {
|
|
6219
|
-
return
|
|
5917
|
+
return inputSchema16;
|
|
6220
5918
|
}
|
|
6221
5919
|
static outputSchema() {
|
|
6222
|
-
return
|
|
5920
|
+
return outputSchema16;
|
|
6223
5921
|
}
|
|
6224
5922
|
async execute(input2, _context) {
|
|
6225
5923
|
const keys = Object.keys(input2).sort();
|
|
@@ -6233,11 +5931,15 @@ var merge = (input2, config = {}) => {
|
|
|
6233
5931
|
const task = new MergeTask({}, config);
|
|
6234
5932
|
return task.run(input2);
|
|
6235
5933
|
};
|
|
6236
|
-
|
|
5934
|
+
Workflow18.prototype.merge = CreateWorkflow17(MergeTask);
|
|
6237
5935
|
// src/task/OutputTask.ts
|
|
6238
|
-
import {
|
|
5936
|
+
import {
|
|
5937
|
+
CreateWorkflow as CreateWorkflow18,
|
|
5938
|
+
Task as Task16,
|
|
5939
|
+
Workflow as Workflow19
|
|
5940
|
+
} from "@workglow/task-graph";
|
|
6239
5941
|
|
|
6240
|
-
class OutputTask extends
|
|
5942
|
+
class OutputTask extends Task16 {
|
|
6241
5943
|
static type = "OutputTask";
|
|
6242
5944
|
static category = "Flow Control";
|
|
6243
5945
|
static title = "Output";
|
|
@@ -6291,10 +5993,10 @@ class OutputTask extends Task17 {
|
|
|
6291
5993
|
yield { type: "finish", data: input2 };
|
|
6292
5994
|
}
|
|
6293
5995
|
}
|
|
6294
|
-
|
|
5996
|
+
Workflow19.prototype.output = CreateWorkflow18(OutputTask);
|
|
6295
5997
|
// src/task/SplitTask.ts
|
|
6296
|
-
import { CreateWorkflow as
|
|
6297
|
-
var
|
|
5998
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task17, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
5999
|
+
var inputSchema17 = {
|
|
6298
6000
|
type: "object",
|
|
6299
6001
|
properties: {
|
|
6300
6002
|
input: {
|
|
@@ -6304,13 +6006,13 @@ var inputSchema18 = {
|
|
|
6304
6006
|
},
|
|
6305
6007
|
additionalProperties: false
|
|
6306
6008
|
};
|
|
6307
|
-
var
|
|
6009
|
+
var outputSchema17 = {
|
|
6308
6010
|
type: "object",
|
|
6309
6011
|
properties: {},
|
|
6310
6012
|
additionalProperties: true
|
|
6311
6013
|
};
|
|
6312
6014
|
|
|
6313
|
-
class SplitTask extends
|
|
6015
|
+
class SplitTask extends Task17 {
|
|
6314
6016
|
static type = "SplitTask";
|
|
6315
6017
|
static category = "Utility";
|
|
6316
6018
|
static title = "Split";
|
|
@@ -6318,13 +6020,13 @@ class SplitTask extends Task18 {
|
|
|
6318
6020
|
static hasDynamicSchemas = true;
|
|
6319
6021
|
static cacheable = false;
|
|
6320
6022
|
static inputSchema() {
|
|
6321
|
-
return
|
|
6023
|
+
return inputSchema17;
|
|
6322
6024
|
}
|
|
6323
6025
|
static outputSchema() {
|
|
6324
|
-
return
|
|
6026
|
+
return outputSchema17;
|
|
6325
6027
|
}
|
|
6326
6028
|
outputSchema() {
|
|
6327
|
-
return
|
|
6029
|
+
return outputSchema17;
|
|
6328
6030
|
}
|
|
6329
6031
|
async executeReactive(input2) {
|
|
6330
6032
|
const inputValue = input2.input;
|
|
@@ -6343,15 +6045,15 @@ var split = (input2, config = {}) => {
|
|
|
6343
6045
|
const task = new SplitTask({}, config);
|
|
6344
6046
|
return task.run(input2);
|
|
6345
6047
|
};
|
|
6346
|
-
|
|
6048
|
+
Workflow20.prototype.split = CreateWorkflow19(SplitTask);
|
|
6347
6049
|
// src/task/mcp/McpListTask.ts
|
|
6348
|
-
import { CreateWorkflow as
|
|
6050
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task18, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
6349
6051
|
import {
|
|
6350
6052
|
mcpClientFactory,
|
|
6351
6053
|
mcpServerConfigSchema
|
|
6352
6054
|
} from "@workglow/util";
|
|
6353
6055
|
var mcpListTypes = ["tools", "resources", "prompts"];
|
|
6354
|
-
var
|
|
6056
|
+
var inputSchema18 = {
|
|
6355
6057
|
type: "object",
|
|
6356
6058
|
properties: {
|
|
6357
6059
|
...mcpServerConfigSchema,
|
|
@@ -6520,7 +6222,7 @@ var outputSchemaAll = {
|
|
|
6520
6222
|
additionalProperties: false
|
|
6521
6223
|
};
|
|
6522
6224
|
|
|
6523
|
-
class McpListTask extends
|
|
6225
|
+
class McpListTask extends Task18 {
|
|
6524
6226
|
static type = "McpListTask";
|
|
6525
6227
|
static category = "MCP";
|
|
6526
6228
|
static title = "MCP List";
|
|
@@ -6528,7 +6230,7 @@ class McpListTask extends Task19 {
|
|
|
6528
6230
|
static cacheable = false;
|
|
6529
6231
|
static hasDynamicSchemas = true;
|
|
6530
6232
|
static inputSchema() {
|
|
6531
|
-
return
|
|
6233
|
+
return inputSchema18;
|
|
6532
6234
|
}
|
|
6533
6235
|
static outputSchema() {
|
|
6534
6236
|
return outputSchemaAll;
|
|
@@ -6588,13 +6290,13 @@ class McpListTask extends Task19 {
|
|
|
6588
6290
|
var mcpList = async (input2, config = {}) => {
|
|
6589
6291
|
return new McpListTask({}, config).run(input2);
|
|
6590
6292
|
};
|
|
6591
|
-
|
|
6293
|
+
Workflow21.prototype.mcpList = CreateWorkflow20(McpListTask);
|
|
6592
6294
|
// src/task/mcp/McpPromptGetTask.ts
|
|
6593
6295
|
import {
|
|
6594
|
-
CreateWorkflow as
|
|
6595
|
-
Task as
|
|
6296
|
+
CreateWorkflow as CreateWorkflow21,
|
|
6297
|
+
Task as Task19,
|
|
6596
6298
|
TaskConfigSchema as TaskConfigSchema5,
|
|
6597
|
-
Workflow as
|
|
6299
|
+
Workflow as Workflow22
|
|
6598
6300
|
} from "@workglow/task-graph";
|
|
6599
6301
|
import {
|
|
6600
6302
|
mcpClientFactory as mcpClientFactory2,
|
|
@@ -6751,7 +6453,7 @@ var fallbackInputSchema = {
|
|
|
6751
6453
|
additionalProperties: false
|
|
6752
6454
|
};
|
|
6753
6455
|
|
|
6754
|
-
class McpPromptGetTask extends
|
|
6456
|
+
class McpPromptGetTask extends Task19 {
|
|
6755
6457
|
static type = "McpPromptGetTask";
|
|
6756
6458
|
static category = "MCP";
|
|
6757
6459
|
static title = "MCP Get Prompt";
|
|
@@ -6835,13 +6537,13 @@ class McpPromptGetTask extends Task20 {
|
|
|
6835
6537
|
var mcpPromptGet = async (input2, config) => {
|
|
6836
6538
|
return new McpPromptGetTask({}, config).run(input2);
|
|
6837
6539
|
};
|
|
6838
|
-
|
|
6540
|
+
Workflow22.prototype.mcpPromptGet = CreateWorkflow21(McpPromptGetTask);
|
|
6839
6541
|
// src/task/mcp/McpResourceReadTask.ts
|
|
6840
6542
|
import {
|
|
6841
|
-
CreateWorkflow as
|
|
6842
|
-
Task as
|
|
6543
|
+
CreateWorkflow as CreateWorkflow22,
|
|
6544
|
+
Task as Task20,
|
|
6843
6545
|
TaskConfigSchema as TaskConfigSchema6,
|
|
6844
|
-
Workflow as
|
|
6546
|
+
Workflow as Workflow23
|
|
6845
6547
|
} from "@workglow/task-graph";
|
|
6846
6548
|
import {
|
|
6847
6549
|
mcpClientFactory as mcpClientFactory3,
|
|
@@ -6891,12 +6593,12 @@ var contentItemSchema = {
|
|
|
6891
6593
|
}
|
|
6892
6594
|
]
|
|
6893
6595
|
};
|
|
6894
|
-
var
|
|
6596
|
+
var inputSchema19 = {
|
|
6895
6597
|
type: "object",
|
|
6896
6598
|
properties: {},
|
|
6897
6599
|
additionalProperties: false
|
|
6898
6600
|
};
|
|
6899
|
-
var
|
|
6601
|
+
var outputSchema18 = {
|
|
6900
6602
|
type: "object",
|
|
6901
6603
|
properties: {
|
|
6902
6604
|
contents: {
|
|
@@ -6910,7 +6612,7 @@ var outputSchema19 = {
|
|
|
6910
6612
|
additionalProperties: false
|
|
6911
6613
|
};
|
|
6912
6614
|
|
|
6913
|
-
class McpResourceReadTask extends
|
|
6615
|
+
class McpResourceReadTask extends Task20 {
|
|
6914
6616
|
static type = "McpResourceReadTask";
|
|
6915
6617
|
static category = "MCP";
|
|
6916
6618
|
static title = "MCP Read Resource";
|
|
@@ -6918,10 +6620,10 @@ class McpResourceReadTask extends Task21 {
|
|
|
6918
6620
|
static cacheable = false;
|
|
6919
6621
|
static customizable = true;
|
|
6920
6622
|
static inputSchema() {
|
|
6921
|
-
return
|
|
6623
|
+
return inputSchema19;
|
|
6922
6624
|
}
|
|
6923
6625
|
static outputSchema() {
|
|
6924
|
-
return
|
|
6626
|
+
return outputSchema18;
|
|
6925
6627
|
}
|
|
6926
6628
|
static configSchema() {
|
|
6927
6629
|
return configSchema3;
|
|
@@ -6939,13 +6641,13 @@ class McpResourceReadTask extends Task21 {
|
|
|
6939
6641
|
var mcpResourceRead = async (config) => {
|
|
6940
6642
|
return new McpResourceReadTask({}, config).run({});
|
|
6941
6643
|
};
|
|
6942
|
-
|
|
6644
|
+
Workflow23.prototype.mcpResourceRead = CreateWorkflow22(McpResourceReadTask);
|
|
6943
6645
|
// src/task/mcp/McpToolCallTask.ts
|
|
6944
6646
|
import {
|
|
6945
|
-
CreateWorkflow as
|
|
6946
|
-
Task as
|
|
6647
|
+
CreateWorkflow as CreateWorkflow23,
|
|
6648
|
+
Task as Task21,
|
|
6947
6649
|
TaskConfigSchema as TaskConfigSchema7,
|
|
6948
|
-
Workflow as
|
|
6650
|
+
Workflow as Workflow24
|
|
6949
6651
|
} from "@workglow/task-graph";
|
|
6950
6652
|
import {
|
|
6951
6653
|
mcpClientFactory as mcpClientFactory4,
|
|
@@ -7094,7 +6796,7 @@ var fallbackInputSchema2 = {
|
|
|
7094
6796
|
additionalProperties: true
|
|
7095
6797
|
};
|
|
7096
6798
|
|
|
7097
|
-
class McpToolCallTask extends
|
|
6799
|
+
class McpToolCallTask extends Task21 {
|
|
7098
6800
|
static type = "McpToolCallTask";
|
|
7099
6801
|
static category = "MCP";
|
|
7100
6802
|
static title = "MCP Call Tool";
|
|
@@ -7193,10 +6895,10 @@ class McpToolCallTask extends Task22 {
|
|
|
7193
6895
|
var mcpToolCall = async (input2, config) => {
|
|
7194
6896
|
return new McpToolCallTask({}, config).run(input2);
|
|
7195
6897
|
};
|
|
7196
|
-
|
|
6898
|
+
Workflow24.prototype.mcpToolCall = CreateWorkflow23(McpToolCallTask);
|
|
7197
6899
|
// src/task/scalar/ScalarAbsTask.ts
|
|
7198
|
-
import { CreateWorkflow as
|
|
7199
|
-
var
|
|
6900
|
+
import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
6901
|
+
var inputSchema20 = {
|
|
7200
6902
|
type: "object",
|
|
7201
6903
|
properties: {
|
|
7202
6904
|
value: {
|
|
@@ -7208,7 +6910,7 @@ var inputSchema21 = {
|
|
|
7208
6910
|
required: ["value"],
|
|
7209
6911
|
additionalProperties: false
|
|
7210
6912
|
};
|
|
7211
|
-
var
|
|
6913
|
+
var outputSchema19 = {
|
|
7212
6914
|
type: "object",
|
|
7213
6915
|
properties: {
|
|
7214
6916
|
result: {
|
|
@@ -7221,25 +6923,25 @@ var outputSchema20 = {
|
|
|
7221
6923
|
additionalProperties: false
|
|
7222
6924
|
};
|
|
7223
6925
|
|
|
7224
|
-
class ScalarAbsTask extends
|
|
6926
|
+
class ScalarAbsTask extends Task22 {
|
|
7225
6927
|
static type = "ScalarAbsTask";
|
|
7226
6928
|
static category = "Math";
|
|
7227
6929
|
static title = "Abs";
|
|
7228
6930
|
static description = "Returns the absolute value of a number";
|
|
7229
6931
|
static inputSchema() {
|
|
7230
|
-
return
|
|
6932
|
+
return inputSchema20;
|
|
7231
6933
|
}
|
|
7232
6934
|
static outputSchema() {
|
|
7233
|
-
return
|
|
6935
|
+
return outputSchema19;
|
|
7234
6936
|
}
|
|
7235
6937
|
async execute(input2, _context) {
|
|
7236
6938
|
return { result: Math.abs(input2.value) };
|
|
7237
6939
|
}
|
|
7238
6940
|
}
|
|
7239
|
-
|
|
6941
|
+
Workflow25.prototype.scalarAbs = CreateWorkflow24(ScalarAbsTask);
|
|
7240
6942
|
// src/task/scalar/ScalarCeilTask.ts
|
|
7241
|
-
import { CreateWorkflow as
|
|
7242
|
-
var
|
|
6943
|
+
import { CreateWorkflow as CreateWorkflow25, Task as Task23, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
6944
|
+
var inputSchema21 = {
|
|
7243
6945
|
type: "object",
|
|
7244
6946
|
properties: {
|
|
7245
6947
|
value: {
|
|
@@ -7251,7 +6953,7 @@ var inputSchema22 = {
|
|
|
7251
6953
|
required: ["value"],
|
|
7252
6954
|
additionalProperties: false
|
|
7253
6955
|
};
|
|
7254
|
-
var
|
|
6956
|
+
var outputSchema20 = {
|
|
7255
6957
|
type: "object",
|
|
7256
6958
|
properties: {
|
|
7257
6959
|
result: {
|
|
@@ -7264,11 +6966,54 @@ var outputSchema21 = {
|
|
|
7264
6966
|
additionalProperties: false
|
|
7265
6967
|
};
|
|
7266
6968
|
|
|
7267
|
-
class ScalarCeilTask extends
|
|
6969
|
+
class ScalarCeilTask extends Task23 {
|
|
7268
6970
|
static type = "ScalarCeilTask";
|
|
7269
6971
|
static category = "Math";
|
|
7270
6972
|
static title = "Ceil";
|
|
7271
6973
|
static description = "Returns the smallest integer greater than or equal to a number";
|
|
6974
|
+
static inputSchema() {
|
|
6975
|
+
return inputSchema21;
|
|
6976
|
+
}
|
|
6977
|
+
static outputSchema() {
|
|
6978
|
+
return outputSchema20;
|
|
6979
|
+
}
|
|
6980
|
+
async execute(input2, _context) {
|
|
6981
|
+
return { result: Math.ceil(input2.value) };
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
Workflow26.prototype.scalarCeil = CreateWorkflow25(ScalarCeilTask);
|
|
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";
|
|
7272
7017
|
static inputSchema() {
|
|
7273
7018
|
return inputSchema22;
|
|
7274
7019
|
}
|
|
@@ -7276,13 +7021,144 @@ class ScalarCeilTask extends Task24 {
|
|
|
7276
7021
|
return outputSchema21;
|
|
7277
7022
|
}
|
|
7278
7023
|
async execute(input2, _context) {
|
|
7279
|
-
return { result: Math.
|
|
7024
|
+
return { result: Math.floor(input2.value) };
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
7027
|
+
Workflow27.prototype.scalarFloor = CreateWorkflow26(ScalarFloorTask);
|
|
7028
|
+
// src/task/scalar/ScalarMaxTask.ts
|
|
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";
|
|
7118
|
+
var inputSchema25 = {
|
|
7119
|
+
type: "object",
|
|
7120
|
+
properties: {
|
|
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) };
|
|
7280
7156
|
}
|
|
7281
7157
|
}
|
|
7282
|
-
|
|
7283
|
-
// src/task/scalar/
|
|
7284
|
-
import { CreateWorkflow as
|
|
7285
|
-
var
|
|
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 = {
|
|
7286
7162
|
type: "object",
|
|
7287
7163
|
properties: {
|
|
7288
7164
|
value: {
|
|
@@ -7294,476 +7170,753 @@ var inputSchema23 = {
|
|
|
7294
7170
|
required: ["value"],
|
|
7295
7171
|
additionalProperties: false
|
|
7296
7172
|
};
|
|
7297
|
-
var
|
|
7173
|
+
var outputSchema25 = {
|
|
7298
7174
|
type: "object",
|
|
7299
7175
|
properties: {
|
|
7300
7176
|
result: {
|
|
7301
7177
|
type: "number",
|
|
7302
7178
|
title: "Result",
|
|
7303
|
-
description: "
|
|
7179
|
+
description: "Truncated value"
|
|
7304
7180
|
}
|
|
7305
7181
|
},
|
|
7306
7182
|
required: ["result"],
|
|
7307
7183
|
additionalProperties: false
|
|
7308
7184
|
};
|
|
7309
7185
|
|
|
7310
|
-
class
|
|
7311
|
-
static type = "
|
|
7186
|
+
class ScalarTruncTask extends Task28 {
|
|
7187
|
+
static type = "ScalarTruncTask";
|
|
7312
7188
|
static category = "Math";
|
|
7313
|
-
static title = "
|
|
7314
|
-
static description = "Returns the
|
|
7189
|
+
static title = "Truncate";
|
|
7190
|
+
static description = "Returns the integer part of a number by removing fractional digits";
|
|
7315
7191
|
static inputSchema() {
|
|
7316
|
-
return
|
|
7192
|
+
return inputSchema26;
|
|
7317
7193
|
}
|
|
7318
7194
|
static outputSchema() {
|
|
7319
|
-
return
|
|
7195
|
+
return outputSchema25;
|
|
7320
7196
|
}
|
|
7321
7197
|
async execute(input2, _context) {
|
|
7322
|
-
return { result: Math.
|
|
7198
|
+
return { result: Math.trunc(input2.value) };
|
|
7323
7199
|
}
|
|
7324
7200
|
}
|
|
7325
|
-
|
|
7326
|
-
// src/task/
|
|
7327
|
-
import { CreateWorkflow as
|
|
7328
|
-
|
|
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 = {
|
|
7329
7208
|
type: "object",
|
|
7330
7209
|
properties: {
|
|
7331
|
-
|
|
7210
|
+
vectors: {
|
|
7332
7211
|
type: "array",
|
|
7333
|
-
items: {
|
|
7334
|
-
|
|
7335
|
-
|
|
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"
|
|
7336
7218
|
}
|
|
7337
7219
|
},
|
|
7338
|
-
required: ["
|
|
7220
|
+
required: ["vectors"],
|
|
7339
7221
|
additionalProperties: false
|
|
7340
7222
|
};
|
|
7341
|
-
var
|
|
7223
|
+
var outputSchema26 = {
|
|
7342
7224
|
type: "object",
|
|
7343
7225
|
properties: {
|
|
7344
7226
|
result: {
|
|
7345
7227
|
type: "number",
|
|
7346
7228
|
title: "Result",
|
|
7347
|
-
description: "
|
|
7229
|
+
description: "Euclidean distance between vectors"
|
|
7348
7230
|
}
|
|
7349
7231
|
},
|
|
7350
7232
|
required: ["result"],
|
|
7351
7233
|
additionalProperties: false
|
|
7352
7234
|
};
|
|
7353
7235
|
|
|
7354
|
-
class
|
|
7355
|
-
static type = "
|
|
7356
|
-
static category = "
|
|
7357
|
-
static title = "
|
|
7358
|
-
static description = "Returns the
|
|
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";
|
|
7359
7241
|
static inputSchema() {
|
|
7360
|
-
return
|
|
7242
|
+
return inputSchema27;
|
|
7361
7243
|
}
|
|
7362
7244
|
static outputSchema() {
|
|
7363
|
-
return
|
|
7245
|
+
return outputSchema26;
|
|
7364
7246
|
}
|
|
7365
7247
|
async execute(input2, _context) {
|
|
7366
|
-
|
|
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)) };
|
|
7367
7261
|
}
|
|
7368
7262
|
}
|
|
7369
|
-
|
|
7370
|
-
// src/task/
|
|
7371
|
-
import { CreateWorkflow as
|
|
7372
|
-
|
|
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 = {
|
|
7373
7270
|
type: "object",
|
|
7374
7271
|
properties: {
|
|
7375
|
-
|
|
7272
|
+
vectors: {
|
|
7376
7273
|
type: "array",
|
|
7377
|
-
items: {
|
|
7378
|
-
|
|
7379
|
-
|
|
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"
|
|
7380
7280
|
}
|
|
7381
7281
|
},
|
|
7382
|
-
required: ["
|
|
7282
|
+
required: ["vectors"],
|
|
7383
7283
|
additionalProperties: false
|
|
7384
7284
|
};
|
|
7385
|
-
var
|
|
7285
|
+
var outputSchema27 = {
|
|
7386
7286
|
type: "object",
|
|
7387
7287
|
properties: {
|
|
7388
7288
|
result: {
|
|
7389
7289
|
type: "number",
|
|
7390
7290
|
title: "Result",
|
|
7391
|
-
description: "
|
|
7291
|
+
description: "Dot product of the vectors"
|
|
7392
7292
|
}
|
|
7393
7293
|
},
|
|
7394
7294
|
required: ["result"],
|
|
7395
7295
|
additionalProperties: false
|
|
7396
7296
|
};
|
|
7397
7297
|
|
|
7398
|
-
class
|
|
7399
|
-
static type = "
|
|
7400
|
-
static category = "
|
|
7401
|
-
static title = "
|
|
7402
|
-
static description = "Returns the
|
|
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";
|
|
7403
7303
|
static inputSchema() {
|
|
7404
|
-
return
|
|
7304
|
+
return inputSchema28;
|
|
7405
7305
|
}
|
|
7406
7306
|
static outputSchema() {
|
|
7407
|
-
return
|
|
7307
|
+
return outputSchema27;
|
|
7408
7308
|
}
|
|
7409
7309
|
async execute(input2, _context) {
|
|
7410
|
-
|
|
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) };
|
|
7411
7320
|
}
|
|
7412
7321
|
}
|
|
7413
|
-
|
|
7414
|
-
// src/task/
|
|
7415
|
-
import { CreateWorkflow as
|
|
7416
|
-
|
|
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 = {
|
|
7417
7330
|
type: "object",
|
|
7418
7331
|
properties: {
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
}
|
|
7332
|
+
vector: TypedArraySchema7({
|
|
7333
|
+
title: "Vector",
|
|
7334
|
+
description: "Input vector to normalize"
|
|
7335
|
+
})
|
|
7424
7336
|
},
|
|
7425
|
-
required: ["
|
|
7337
|
+
required: ["vector"],
|
|
7426
7338
|
additionalProperties: false
|
|
7427
7339
|
};
|
|
7428
|
-
var
|
|
7340
|
+
var outputSchema28 = {
|
|
7429
7341
|
type: "object",
|
|
7430
7342
|
properties: {
|
|
7431
|
-
result: {
|
|
7432
|
-
type: "number",
|
|
7343
|
+
result: TypedArraySchema7({
|
|
7433
7344
|
title: "Result",
|
|
7434
|
-
description: "
|
|
7435
|
-
}
|
|
7345
|
+
description: "L2-normalized vector"
|
|
7346
|
+
})
|
|
7436
7347
|
},
|
|
7437
7348
|
required: ["result"],
|
|
7438
7349
|
additionalProperties: false
|
|
7439
7350
|
};
|
|
7440
7351
|
|
|
7441
|
-
class
|
|
7442
|
-
static type = "
|
|
7443
|
-
static category = "
|
|
7444
|
-
static title = "
|
|
7445
|
-
static description = "Returns the
|
|
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";
|
|
7446
7357
|
static inputSchema() {
|
|
7447
|
-
return
|
|
7358
|
+
return inputSchema29;
|
|
7448
7359
|
}
|
|
7449
7360
|
static outputSchema() {
|
|
7450
|
-
return
|
|
7361
|
+
return outputSchema28;
|
|
7451
7362
|
}
|
|
7452
7363
|
async execute(input2, _context) {
|
|
7453
|
-
return { result:
|
|
7364
|
+
return { result: normalize(input2.vector) };
|
|
7454
7365
|
}
|
|
7455
7366
|
}
|
|
7456
|
-
|
|
7457
|
-
// src/task/
|
|
7458
|
-
import { CreateWorkflow as
|
|
7459
|
-
|
|
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 = {
|
|
7460
7375
|
type: "object",
|
|
7461
7376
|
properties: {
|
|
7462
|
-
|
|
7377
|
+
vector: TypedArraySchema8({
|
|
7378
|
+
title: "Vector",
|
|
7379
|
+
description: "Input vector"
|
|
7380
|
+
}),
|
|
7381
|
+
scalar: {
|
|
7463
7382
|
type: "number",
|
|
7464
|
-
title: "
|
|
7465
|
-
description: "
|
|
7383
|
+
title: "Scalar",
|
|
7384
|
+
description: "Scalar multiplier"
|
|
7466
7385
|
}
|
|
7467
7386
|
},
|
|
7468
|
-
required: ["
|
|
7387
|
+
required: ["vector", "scalar"],
|
|
7469
7388
|
additionalProperties: false
|
|
7470
7389
|
};
|
|
7471
|
-
var
|
|
7390
|
+
var outputSchema29 = {
|
|
7472
7391
|
type: "object",
|
|
7473
7392
|
properties: {
|
|
7474
|
-
result: {
|
|
7475
|
-
type: "number",
|
|
7393
|
+
result: TypedArraySchema8({
|
|
7476
7394
|
title: "Result",
|
|
7477
|
-
description: "
|
|
7478
|
-
}
|
|
7395
|
+
description: "Scaled vector"
|
|
7396
|
+
})
|
|
7479
7397
|
},
|
|
7480
7398
|
required: ["result"],
|
|
7481
7399
|
additionalProperties: false
|
|
7482
7400
|
};
|
|
7483
7401
|
|
|
7484
|
-
class
|
|
7485
|
-
static type = "
|
|
7486
|
-
static category = "
|
|
7487
|
-
static title = "
|
|
7488
|
-
static description = "
|
|
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";
|
|
7489
7407
|
static inputSchema() {
|
|
7490
|
-
return
|
|
7408
|
+
return inputSchema30;
|
|
7491
7409
|
}
|
|
7492
7410
|
static outputSchema() {
|
|
7493
|
-
return
|
|
7411
|
+
return outputSchema29;
|
|
7494
7412
|
}
|
|
7495
7413
|
async execute(input2, _context) {
|
|
7496
|
-
|
|
7414
|
+
const { vector, scalar } = input2;
|
|
7415
|
+
const values = Array.from(vector, (v) => Number(v) * scalar);
|
|
7416
|
+
return { result: createTypedArrayFrom5([vector], values) };
|
|
7497
7417
|
}
|
|
7498
7418
|
}
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
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
|
|
7502
7465
|
import {
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
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 = {
|
|
7506
7473
|
type: "object",
|
|
7507
7474
|
properties: {
|
|
7508
|
-
|
|
7509
|
-
type: "
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
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"
|
|
7516
7487
|
}
|
|
7517
7488
|
},
|
|
7518
|
-
required: ["
|
|
7489
|
+
required: ["url"],
|
|
7519
7490
|
additionalProperties: false
|
|
7520
7491
|
};
|
|
7521
|
-
var
|
|
7492
|
+
var outputSchema30 = {
|
|
7522
7493
|
type: "object",
|
|
7523
7494
|
properties: {
|
|
7524
|
-
|
|
7525
|
-
type: "
|
|
7526
|
-
title: "
|
|
7527
|
-
description: "
|
|
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"
|
|
7528
7537
|
}
|
|
7529
7538
|
},
|
|
7530
|
-
required: ["
|
|
7539
|
+
required: ["metadata"],
|
|
7531
7540
|
additionalProperties: false
|
|
7532
7541
|
};
|
|
7533
7542
|
|
|
7534
|
-
class
|
|
7535
|
-
static type = "
|
|
7536
|
-
static category = "
|
|
7537
|
-
static title = "
|
|
7538
|
-
static description = "
|
|
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;
|
|
7539
7549
|
static inputSchema() {
|
|
7540
|
-
return
|
|
7550
|
+
return inputSchema31;
|
|
7541
7551
|
}
|
|
7542
7552
|
static outputSchema() {
|
|
7543
|
-
return
|
|
7553
|
+
return outputSchema30;
|
|
7544
7554
|
}
|
|
7545
|
-
async execute(input2,
|
|
7546
|
-
const {
|
|
7547
|
-
if (
|
|
7548
|
-
throw new
|
|
7555
|
+
async execute(input2, context) {
|
|
7556
|
+
const { url, format = "auto" } = input2;
|
|
7557
|
+
if (context.signal.aborted) {
|
|
7558
|
+
throw new TaskAbortedError2("Task aborted");
|
|
7549
7559
|
}
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
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");
|
|
7553
7565
|
}
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
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
|
+
};
|
|
7559
7598
|
}
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
title: "Vector",
|
|
7574
|
-
description: "Vector for dot product"
|
|
7575
|
-
}),
|
|
7576
|
-
title: "Vectors",
|
|
7577
|
-
description: "Array of two vectors to compute dot product"
|
|
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}`);
|
|
7578
7612
|
}
|
|
7579
|
-
}
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
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);
|
|
7646
|
+
}
|
|
7647
|
+
return result;
|
|
7648
|
+
}
|
|
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;
|
|
7716
|
+
}
|
|
7717
|
+
parseYamlValue(raw) {
|
|
7718
|
+
if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("'") && raw.endsWith("'")) {
|
|
7719
|
+
return raw.slice(1, -1);
|
|
7720
|
+
}
|
|
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()));
|
|
7731
|
+
}
|
|
7732
|
+
return raw;
|
|
7733
|
+
}
|
|
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
|
+
};
|
|
7752
|
+
}
|
|
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
|
+
};
|
|
7590
7787
|
}
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
}
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
const { vectors } = input2;
|
|
7609
|
-
if (vectors.length < 2) {
|
|
7610
|
-
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
|
+
};
|
|
7611
7805
|
}
|
|
7612
|
-
const
|
|
7613
|
-
if (
|
|
7614
|
-
throw new Error(
|
|
7806
|
+
const content = response.text || "";
|
|
7807
|
+
if (!content) {
|
|
7808
|
+
throw new Error(`Failed to load content from ${url}`);
|
|
7615
7809
|
}
|
|
7616
|
-
const
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
properties: {
|
|
7641
|
-
result: TypedArraySchema7({
|
|
7642
|
-
title: "Result",
|
|
7643
|
-
description: "L2-normalized vector"
|
|
7644
|
-
})
|
|
7645
|
-
},
|
|
7646
|
-
required: ["result"],
|
|
7647
|
-
additionalProperties: false
|
|
7648
|
-
};
|
|
7649
|
-
|
|
7650
|
-
class VectorNormalizeTask extends Task32 {
|
|
7651
|
-
static type = "VectorNormalizeTask";
|
|
7652
|
-
static category = "Vector";
|
|
7653
|
-
static title = "Normalize";
|
|
7654
|
-
static description = "Returns the L2-normalized (unit length) vector";
|
|
7655
|
-
static inputSchema() {
|
|
7656
|
-
return inputSchema30;
|
|
7657
|
-
}
|
|
7658
|
-
static outputSchema() {
|
|
7659
|
-
return outputSchema29;
|
|
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
|
+
};
|
|
7660
7834
|
}
|
|
7661
|
-
|
|
7662
|
-
|
|
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;
|
|
7663
7845
|
}
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
}
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
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
|
+
}
|
|
7683
7864
|
}
|
|
7684
|
-
|
|
7685
|
-
required: ["vector", "scalar"],
|
|
7686
|
-
additionalProperties: false
|
|
7687
|
-
};
|
|
7688
|
-
var outputSchema30 = {
|
|
7689
|
-
type: "object",
|
|
7690
|
-
properties: {
|
|
7691
|
-
result: TypedArraySchema8({
|
|
7692
|
-
title: "Result",
|
|
7693
|
-
description: "Scaled vector"
|
|
7694
|
-
})
|
|
7695
|
-
},
|
|
7696
|
-
required: ["result"],
|
|
7697
|
-
additionalProperties: false
|
|
7698
|
-
};
|
|
7699
|
-
|
|
7700
|
-
class VectorScaleTask extends Task33 {
|
|
7701
|
-
static type = "VectorScaleTask";
|
|
7702
|
-
static category = "Vector";
|
|
7703
|
-
static title = "Scale";
|
|
7704
|
-
static description = "Multiplies each element of a vector by a scalar";
|
|
7705
|
-
static inputSchema() {
|
|
7706
|
-
return inputSchema31;
|
|
7865
|
+
return format;
|
|
7707
7866
|
}
|
|
7708
|
-
|
|
7709
|
-
|
|
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";
|
|
7710
7884
|
}
|
|
7711
|
-
async
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
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
|
+
});
|
|
7715
7904
|
}
|
|
7716
7905
|
}
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
// src/common.ts
|
|
7720
|
-
import { TaskRegistry } from "@workglow/task-graph";
|
|
7721
|
-
var registerCommonTasks = () => {
|
|
7722
|
-
const tasks = [
|
|
7723
|
-
DebugLogTask,
|
|
7724
|
-
DelayTask,
|
|
7725
|
-
FetchUrlTask,
|
|
7726
|
-
InputTask,
|
|
7727
|
-
JavaScriptTask,
|
|
7728
|
-
JsonTask,
|
|
7729
|
-
LambdaTask,
|
|
7730
|
-
MergeTask,
|
|
7731
|
-
OutputTask,
|
|
7732
|
-
SplitTask,
|
|
7733
|
-
ScalarAbsTask,
|
|
7734
|
-
ScalarAddTask,
|
|
7735
|
-
ScalarCeilTask,
|
|
7736
|
-
ScalarDivideTask,
|
|
7737
|
-
ScalarFloorTask,
|
|
7738
|
-
ScalarMaxTask,
|
|
7739
|
-
ScalarMinTask,
|
|
7740
|
-
ScalarMultiplyTask,
|
|
7741
|
-
ScalarRoundTask,
|
|
7742
|
-
ScalarSubtractTask,
|
|
7743
|
-
ScalarSumTask,
|
|
7744
|
-
ScalarTruncTask,
|
|
7745
|
-
VectorSumTask,
|
|
7746
|
-
VectorDistanceTask,
|
|
7747
|
-
VectorDivideTask,
|
|
7748
|
-
VectorDotProductTask,
|
|
7749
|
-
VectorMultiplyTask,
|
|
7750
|
-
VectorNormalizeTask,
|
|
7751
|
-
VectorScaleTask,
|
|
7752
|
-
VectorSubtractTask,
|
|
7753
|
-
McpToolCallTask,
|
|
7754
|
-
McpResourceReadTask,
|
|
7755
|
-
McpPromptGetTask,
|
|
7756
|
-
McpListTask
|
|
7757
|
-
];
|
|
7758
|
-
tasks.map(TaskRegistry.registerTask);
|
|
7759
|
-
return tasks;
|
|
7906
|
+
var fileLoader = (input2, config) => {
|
|
7907
|
+
return new FileLoaderTask({}, config).run(input2);
|
|
7760
7908
|
};
|
|
7909
|
+
Workflow36.prototype.fileLoader = CreateWorkflow35(FileLoaderTask);
|
|
7761
7910
|
|
|
7762
7911
|
// src/browser.ts
|
|
7763
|
-
|
|
7912
|
+
var registerCommonTasks2 = () => {
|
|
7913
|
+
const tasks = registerCommonTasks();
|
|
7914
|
+
TaskRegistry2.registerTask(FileLoaderTask);
|
|
7915
|
+
return [...tasks, FileLoaderTask];
|
|
7916
|
+
};
|
|
7764
7917
|
export {
|
|
7765
7918
|
split,
|
|
7766
|
-
registerCommonTasks,
|
|
7919
|
+
registerCommonTasks2 as registerCommonTasks,
|
|
7767
7920
|
process,
|
|
7768
7921
|
merge,
|
|
7769
7922
|
mcpToolCall,
|
|
@@ -7818,4 +7971,4 @@ export {
|
|
|
7818
7971
|
ArrayTask
|
|
7819
7972
|
};
|
|
7820
7973
|
|
|
7821
|
-
//# debugId=
|
|
7974
|
+
//# debugId=5804C9302124181F64756E2164756E21
|