@workglow/tasks 0.1.2 → 0.2.1
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.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2185 -337
- package/dist/browser.js.map +52 -30
- package/dist/bun.d.ts +1 -1
- package/dist/bun.d.ts.map +1 -1
- package/dist/bun.js +2201 -353
- package/dist/bun.js.map +53 -31
- package/dist/common.d.ts +41 -1
- package/dist/common.d.ts.map +1 -1
- package/dist/mcp-server/McpServerRegistry.d.ts.map +1 -1
- package/dist/mcp-server/McpServerRepository.d.ts +5 -3
- package/dist/mcp-server/McpServerRepository.d.ts.map +1 -1
- package/dist/mcp-server/getMcpServerConfig.d.ts.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +2201 -353
- package/dist/node.js.map +53 -31
- package/dist/task/ArrayTask.d.ts +5 -4
- package/dist/task/ArrayTask.d.ts.map +1 -1
- package/dist/task/DelayTask.d.ts.map +1 -1
- package/dist/task/FetchUrlTask.d.ts +3 -1
- package/dist/task/FetchUrlTask.d.ts.map +1 -1
- package/dist/task/FileLoaderTask.d.ts.map +1 -1
- package/dist/task/HumanApprovalTask.d.ts +68 -0
- package/dist/task/HumanApprovalTask.d.ts.map +1 -0
- package/dist/task/HumanInputTask.d.ts +164 -0
- package/dist/task/HumanInputTask.d.ts.map +1 -0
- package/dist/task/InputTask.d.ts +2 -1
- package/dist/task/InputTask.d.ts.map +1 -1
- package/dist/task/JavaScriptTask.d.ts +8 -1
- package/dist/task/JavaScriptTask.d.ts.map +1 -1
- package/dist/task/JsonTask.d.ts +2 -2
- package/dist/task/JsonTask.d.ts.map +1 -1
- package/dist/task/LambdaTask.d.ts +6 -1
- package/dist/task/LambdaTask.d.ts.map +1 -1
- package/dist/task/McpElicitationConnector.d.ts +39 -0
- package/dist/task/McpElicitationConnector.d.ts.map +1 -0
- package/dist/task/MergeTask.d.ts.map +1 -1
- package/dist/task/OutputTask.d.ts +3 -1
- package/dist/task/OutputTask.d.ts.map +1 -1
- package/dist/task/SplitTask.d.ts +1 -3
- package/dist/task/SplitTask.d.ts.map +1 -1
- package/dist/task/image/ImageBlurTask.d.ts +219 -0
- package/dist/task/image/ImageBlurTask.d.ts.map +1 -0
- package/dist/task/image/ImageBorderTask.d.ts +281 -0
- package/dist/task/image/ImageBorderTask.d.ts.map +1 -0
- package/dist/task/image/ImageBrightnessTask.d.ts +219 -0
- package/dist/task/image/ImageBrightnessTask.d.ts.map +1 -0
- package/dist/task/image/ImageContrastTask.d.ts +219 -0
- package/dist/task/image/ImageContrastTask.d.ts.map +1 -0
- package/dist/task/image/ImageCropTask.d.ts +251 -0
- package/dist/task/image/ImageCropTask.d.ts.map +1 -0
- package/dist/task/image/ImageFlipTask.d.ts +215 -0
- package/dist/task/image/ImageFlipTask.d.ts.map +1 -0
- package/dist/task/image/ImageGrayscaleTask.d.ts +203 -0
- package/dist/task/image/ImageGrayscaleTask.d.ts.map +1 -0
- package/dist/task/image/ImageInvertTask.d.ts +203 -0
- package/dist/task/image/ImageInvertTask.d.ts.map +1 -0
- package/dist/task/image/ImagePixelateTask.d.ts +217 -0
- package/dist/task/image/ImagePixelateTask.d.ts.map +1 -0
- package/dist/task/image/ImagePosterizeTask.d.ts +219 -0
- package/dist/task/image/ImagePosterizeTask.d.ts.map +1 -0
- package/dist/task/image/ImageResizeTask.d.ts +227 -0
- package/dist/task/image/ImageResizeTask.d.ts.map +1 -0
- package/dist/task/image/ImageRotateTask.d.ts +215 -0
- package/dist/task/image/ImageRotateTask.d.ts.map +1 -0
- package/dist/task/image/ImageSchemas.d.ts +94 -0
- package/dist/task/image/ImageSchemas.d.ts.map +1 -0
- package/dist/task/image/ImageSepiaTask.d.ts +203 -0
- package/dist/task/image/ImageSepiaTask.d.ts.map +1 -0
- package/dist/task/image/ImageThresholdTask.d.ts +219 -0
- package/dist/task/image/ImageThresholdTask.d.ts.map +1 -0
- package/dist/task/image/ImageTintTask.d.ts +283 -0
- package/dist/task/image/ImageTintTask.d.ts.map +1 -0
- package/dist/task/image/ImageTransparencyTask.d.ts +217 -0
- package/dist/task/image/ImageTransparencyTask.d.ts.map +1 -0
- package/dist/task/image/ImageWatermarkTask.d.ts +247 -0
- package/dist/task/image/ImageWatermarkTask.d.ts.map +1 -0
- package/dist/task/mcp/McpListTask.d.ts +4 -0
- package/dist/task/mcp/McpListTask.d.ts.map +1 -1
- package/dist/task/mcp/McpPromptGetTask.d.ts +6 -2
- package/dist/task/mcp/McpPromptGetTask.d.ts.map +1 -1
- package/dist/task/mcp/McpResourceReadTask.d.ts +4 -0
- package/dist/task/mcp/McpResourceReadTask.d.ts.map +1 -1
- package/dist/task/mcp/McpSearchTask.d.ts +2 -0
- package/dist/task/mcp/McpSearchTask.d.ts.map +1 -1
- package/dist/task/mcp/McpToolCallTask.d.ts +6 -2
- package/dist/task/mcp/McpToolCallTask.d.ts.map +1 -1
- package/dist/task/scalar/ScalarCeilTask.d.ts.map +1 -1
- package/dist/task/scalar/ScalarRoundTask.d.ts.map +1 -1
- package/dist/task/scalar/ScalarTruncTask.d.ts.map +1 -1
- package/dist/task/string/StringTemplateTask.d.ts.map +1 -1
- package/dist/task/vector/VectorDistanceTask.d.ts.map +1 -1
- package/dist/util/McpAuthProvider.d.ts +1 -1
- package/dist/util/McpAuthProvider.d.ts.map +1 -1
- package/dist/util/getMcpServerTransport.d.ts +13 -0
- package/dist/util/getMcpServerTransport.d.ts.map +1 -0
- package/package.json +14 -9
package/dist/bun.js
CHANGED
|
@@ -593,7 +593,11 @@ class ArrayTask extends GraphAsTask {
|
|
|
593
593
|
const combinations = this.generateCombinations(inputObject, inputIds);
|
|
594
594
|
const tasks = combinations.map((combination) => {
|
|
595
595
|
const { id, title, ...rest } = this.config;
|
|
596
|
-
const task = new this.constructor({
|
|
596
|
+
const task = new this.constructor({
|
|
597
|
+
...rest,
|
|
598
|
+
id: `${id}_${uuid4()}`,
|
|
599
|
+
defaults: { ...this.defaults, ...this.runInputData, ...combination }
|
|
600
|
+
}, this.runConfig);
|
|
597
601
|
return task;
|
|
598
602
|
});
|
|
599
603
|
this.subGraph.addTasks(tasks);
|
|
@@ -723,7 +727,7 @@ class DebugLogTask extends Task10 {
|
|
|
723
727
|
}
|
|
724
728
|
}
|
|
725
729
|
var debugLog = (input, config = {}) => {
|
|
726
|
-
const task = new DebugLogTask(
|
|
730
|
+
const task = new DebugLogTask(config);
|
|
727
731
|
return task.run(input);
|
|
728
732
|
};
|
|
729
733
|
Workflow11.prototype.debugLog = CreateWorkflow10(DebugLogTask);
|
|
@@ -795,7 +799,7 @@ class DelayTask extends Task11 {
|
|
|
795
799
|
}
|
|
796
800
|
}
|
|
797
801
|
var delay = (input, config = { delay: 1 }) => {
|
|
798
|
-
const task = new DelayTask(
|
|
802
|
+
const task = new DelayTask(config);
|
|
799
803
|
return task.run(input);
|
|
800
804
|
};
|
|
801
805
|
Workflow12.prototype.delay = CreateWorkflow11(DelayTask);
|
|
@@ -808,6 +812,7 @@ import {
|
|
|
808
812
|
} from "@workglow/job-queue";
|
|
809
813
|
import {
|
|
810
814
|
CreateWorkflow as CreateWorkflow12,
|
|
815
|
+
Entitlements,
|
|
811
816
|
getJobQueueFactory,
|
|
812
817
|
getTaskQueueRegistry,
|
|
813
818
|
JobTaskFailedError,
|
|
@@ -1070,6 +1075,18 @@ class FetchUrlTask extends Task12 {
|
|
|
1070
1075
|
static title = "Fetch";
|
|
1071
1076
|
static description = "Fetches data from a URL with progress tracking and automatic retry handling";
|
|
1072
1077
|
static hasDynamicSchemas = true;
|
|
1078
|
+
static entitlements() {
|
|
1079
|
+
return {
|
|
1080
|
+
entitlements: [
|
|
1081
|
+
{ id: Entitlements.NETWORK_HTTP, reason: "Fetches data from URLs via HTTP/HTTPS" },
|
|
1082
|
+
{
|
|
1083
|
+
id: Entitlements.CREDENTIAL,
|
|
1084
|
+
reason: "May use Bearer token authentication",
|
|
1085
|
+
optional: true
|
|
1086
|
+
}
|
|
1087
|
+
]
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1073
1090
|
static configSchema() {
|
|
1074
1091
|
return fetchUrlTaskConfigSchema;
|
|
1075
1092
|
}
|
|
@@ -1142,7 +1159,7 @@ class FetchUrlTask extends Task12 {
|
|
|
1142
1159
|
}
|
|
1143
1160
|
const registeredQueue = await this.resolveOrCreateQueue(queueName);
|
|
1144
1161
|
if (executeContext.signal.aborted) {
|
|
1145
|
-
throw executeContext.signal.reason ?? new
|
|
1162
|
+
throw executeContext.signal.reason ?? new AbortSignalJobError("The operation was aborted");
|
|
1146
1163
|
}
|
|
1147
1164
|
const handle = await registeredQueue.client.submit(jobInput, {
|
|
1148
1165
|
jobRunId: this.runConfig.runnerId,
|
|
@@ -1159,7 +1176,7 @@ class FetchUrlTask extends Task12 {
|
|
|
1159
1176
|
});
|
|
1160
1177
|
try {
|
|
1161
1178
|
if (executeContext.signal.aborted) {
|
|
1162
|
-
throw executeContext.signal.reason ?? new
|
|
1179
|
+
throw executeContext.signal.reason ?? new AbortSignalJobError("The operation was aborted");
|
|
1163
1180
|
}
|
|
1164
1181
|
const output = await handle.waitFor();
|
|
1165
1182
|
return output;
|
|
@@ -1237,18 +1254,455 @@ class FetchUrlTask extends Task12 {
|
|
|
1237
1254
|
}
|
|
1238
1255
|
}
|
|
1239
1256
|
var fetchUrl = async (input, config = {}) => {
|
|
1240
|
-
const result = await new FetchUrlTask(
|
|
1257
|
+
const result = await new FetchUrlTask(config).run(input);
|
|
1241
1258
|
return result;
|
|
1242
1259
|
};
|
|
1243
1260
|
Workflow13.prototype.fetch = CreateWorkflow12(FetchUrlTask);
|
|
1244
|
-
// src/task/
|
|
1261
|
+
// src/task/HumanApprovalTask.ts
|
|
1262
|
+
import {
|
|
1263
|
+
CreateWorkflow as CreateWorkflow14,
|
|
1264
|
+
Task as Task14,
|
|
1265
|
+
TaskAbortedError as TaskAbortedError3,
|
|
1266
|
+
TaskConfigSchema as TaskConfigSchema5,
|
|
1267
|
+
Workflow as Workflow15
|
|
1268
|
+
} from "@workglow/task-graph";
|
|
1269
|
+
import { uuid4 as uuid43 } from "@workglow/util";
|
|
1270
|
+
|
|
1271
|
+
// src/task/HumanInputTask.ts
|
|
1245
1272
|
import {
|
|
1246
1273
|
CreateWorkflow as CreateWorkflow13,
|
|
1247
1274
|
Task as Task13,
|
|
1275
|
+
TaskAbortedError as TaskAbortedError2,
|
|
1276
|
+
TaskConfigSchema as TaskConfigSchema4,
|
|
1277
|
+
TaskConfigurationError as TaskConfigurationError2,
|
|
1248
1278
|
Workflow as Workflow14
|
|
1249
1279
|
} from "@workglow/task-graph";
|
|
1280
|
+
import { createServiceToken, uuid4 as uuid42 } from "@workglow/util";
|
|
1281
|
+
var HUMAN_CONNECTOR = createServiceToken("HUMAN_CONNECTOR");
|
|
1282
|
+
var humanInputTaskConfigSchema = {
|
|
1283
|
+
type: "object",
|
|
1284
|
+
properties: {
|
|
1285
|
+
...TaskConfigSchema4["properties"],
|
|
1286
|
+
targetHumanId: {
|
|
1287
|
+
type: "string",
|
|
1288
|
+
title: "Target Human",
|
|
1289
|
+
description: "Identifier of the human to ask (e.g. 'default', 'admin', 'user:alice')",
|
|
1290
|
+
default: "default"
|
|
1291
|
+
},
|
|
1292
|
+
kind: {
|
|
1293
|
+
type: "string",
|
|
1294
|
+
title: "Kind",
|
|
1295
|
+
description: "Interaction kind: notify (one-way), display (show content), elicit (request input)",
|
|
1296
|
+
enum: ["notify", "display", "elicit"],
|
|
1297
|
+
default: "elicit"
|
|
1298
|
+
},
|
|
1299
|
+
contentSchema: {
|
|
1300
|
+
type: "object",
|
|
1301
|
+
properties: {},
|
|
1302
|
+
additionalProperties: true,
|
|
1303
|
+
title: "Content Schema",
|
|
1304
|
+
description: "JSON schema describing the content/form to present",
|
|
1305
|
+
"x-ui-hidden": true
|
|
1306
|
+
},
|
|
1307
|
+
message: {
|
|
1308
|
+
type: "string",
|
|
1309
|
+
title: "Message",
|
|
1310
|
+
description: "Explanatory message shown to the human",
|
|
1311
|
+
"x-ui-editor": "textarea"
|
|
1312
|
+
},
|
|
1313
|
+
mode: {
|
|
1314
|
+
type: "string",
|
|
1315
|
+
title: "Mode",
|
|
1316
|
+
description: "Interaction mode",
|
|
1317
|
+
enum: ["single", "multi-turn"],
|
|
1318
|
+
default: "single"
|
|
1319
|
+
},
|
|
1320
|
+
metadata: {
|
|
1321
|
+
type: "object",
|
|
1322
|
+
additionalProperties: true,
|
|
1323
|
+
"x-ui-hidden": true
|
|
1324
|
+
}
|
|
1325
|
+
},
|
|
1326
|
+
additionalProperties: false
|
|
1327
|
+
};
|
|
1328
|
+
var defaultInputSchema = {
|
|
1329
|
+
type: "object",
|
|
1330
|
+
properties: {
|
|
1331
|
+
prompt: {
|
|
1332
|
+
type: "string",
|
|
1333
|
+
title: "Prompt",
|
|
1334
|
+
description: "Dynamic prompt text merged into the request message"
|
|
1335
|
+
},
|
|
1336
|
+
contentData: {
|
|
1337
|
+
type: "object",
|
|
1338
|
+
additionalProperties: true,
|
|
1339
|
+
title: "Content Data",
|
|
1340
|
+
description: "Data to display (for notify/display kinds)",
|
|
1341
|
+
"x-ui-hidden": true
|
|
1342
|
+
},
|
|
1343
|
+
context: {
|
|
1344
|
+
type: "object",
|
|
1345
|
+
additionalProperties: true,
|
|
1346
|
+
title: "Context",
|
|
1347
|
+
description: "Dynamic context data merged into the request metadata",
|
|
1348
|
+
"x-ui-hidden": true
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
additionalProperties: false
|
|
1352
|
+
};
|
|
1353
|
+
var defaultOutputSchema = {
|
|
1354
|
+
type: "object",
|
|
1355
|
+
properties: {
|
|
1356
|
+
action: {
|
|
1357
|
+
type: "string",
|
|
1358
|
+
title: "Action",
|
|
1359
|
+
description: "The human's action: accept, decline, or cancel",
|
|
1360
|
+
enum: ["accept", "decline", "cancel"]
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
additionalProperties: true
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
class HumanInputTask extends Task13 {
|
|
1367
|
+
static type = "HumanInputTask";
|
|
1368
|
+
static category = "Flow Control";
|
|
1369
|
+
static title = "Human Input";
|
|
1370
|
+
static description = "Sends an interaction (notification, display, or input request) to a human";
|
|
1371
|
+
static cacheable = false;
|
|
1372
|
+
static hasDynamicSchemas = true;
|
|
1373
|
+
static configSchema() {
|
|
1374
|
+
return humanInputTaskConfigSchema;
|
|
1375
|
+
}
|
|
1376
|
+
static inputSchema() {
|
|
1377
|
+
return defaultInputSchema;
|
|
1378
|
+
}
|
|
1379
|
+
static outputSchema() {
|
|
1380
|
+
return defaultOutputSchema;
|
|
1381
|
+
}
|
|
1382
|
+
outputSchema() {
|
|
1383
|
+
if (this.config?.contentSchema && (this.config.kind ?? "elicit") === "elicit") {
|
|
1384
|
+
const configSchema = this.config.contentSchema;
|
|
1385
|
+
const existingProps = configSchema.properties ?? {};
|
|
1386
|
+
const additionalProperties = configSchema.additionalProperties ?? false;
|
|
1387
|
+
const actionProp = {
|
|
1388
|
+
type: "string",
|
|
1389
|
+
title: "Action",
|
|
1390
|
+
description: "The human's action: accept, decline, or cancel",
|
|
1391
|
+
enum: ["accept", "decline", "cancel"]
|
|
1392
|
+
};
|
|
1393
|
+
const result = {
|
|
1394
|
+
type: "object",
|
|
1395
|
+
properties: { ...existingProps, action: actionProp },
|
|
1396
|
+
required: ["action"],
|
|
1397
|
+
additionalProperties
|
|
1398
|
+
};
|
|
1399
|
+
return result;
|
|
1400
|
+
}
|
|
1401
|
+
return this.constructor.outputSchema();
|
|
1402
|
+
}
|
|
1403
|
+
async execute(input, context) {
|
|
1404
|
+
const connector = resolveHumanConnector(context);
|
|
1405
|
+
const kind = this.config.kind ?? "elicit";
|
|
1406
|
+
const mode = this.config.mode ?? "single";
|
|
1407
|
+
const requestId = uuid42();
|
|
1408
|
+
const message = input.prompt ? this.config.message ? `${this.config.message}
|
|
1409
|
+
|
|
1410
|
+
${input.prompt}` : input.prompt : this.config.message ?? "";
|
|
1411
|
+
const emptySchema = {
|
|
1412
|
+
type: "object",
|
|
1413
|
+
properties: {},
|
|
1414
|
+
additionalProperties: true
|
|
1415
|
+
};
|
|
1416
|
+
const request = {
|
|
1417
|
+
requestId,
|
|
1418
|
+
targetHumanId: this.config.targetHumanId ?? "default",
|
|
1419
|
+
kind,
|
|
1420
|
+
message,
|
|
1421
|
+
contentSchema: this.config.contentSchema ?? emptySchema,
|
|
1422
|
+
contentData: input.contentData,
|
|
1423
|
+
expectsResponse: kind === "elicit",
|
|
1424
|
+
mode: kind === "elicit" ? mode : "single",
|
|
1425
|
+
metadata: input.context ? { ...this.config.metadata, ...input.context } : this.config.metadata
|
|
1426
|
+
};
|
|
1427
|
+
if (context.signal.aborted) {
|
|
1428
|
+
throw new TaskAbortedError2("Task aborted before sending human interaction");
|
|
1429
|
+
}
|
|
1430
|
+
let response;
|
|
1431
|
+
try {
|
|
1432
|
+
response = await connector.send(request, context.signal);
|
|
1433
|
+
} catch (err) {
|
|
1434
|
+
if (context.signal.aborted) {
|
|
1435
|
+
throw new TaskAbortedError2("Task aborted during human interaction");
|
|
1436
|
+
}
|
|
1437
|
+
throw err;
|
|
1438
|
+
}
|
|
1439
|
+
if (kind === "elicit" && mode === "multi-turn" && !response.done) {
|
|
1440
|
+
if (typeof connector.followUp !== "function") {
|
|
1441
|
+
throw new TaskConfigurationError2('HumanInputTask is configured for "multi-turn" mode but the registered ' + "IHumanConnector does not implement followUp()");
|
|
1442
|
+
}
|
|
1443
|
+
while (!response.done) {
|
|
1444
|
+
if (context.signal.aborted) {
|
|
1445
|
+
throw new TaskAbortedError2("Task aborted during multi-turn conversation");
|
|
1446
|
+
}
|
|
1447
|
+
try {
|
|
1448
|
+
response = await connector.followUp(request, response, context.signal);
|
|
1449
|
+
} catch (err) {
|
|
1450
|
+
if (context.signal.aborted) {
|
|
1451
|
+
throw new TaskAbortedError2("Task aborted during multi-turn conversation");
|
|
1452
|
+
}
|
|
1453
|
+
throw err;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
return { ...response.content, action: response.action };
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
function resolveHumanConnector(context) {
|
|
1461
|
+
if (!context.registry.has(HUMAN_CONNECTOR)) {
|
|
1462
|
+
throw new TaskConfigurationError2("No IHumanConnector registered. Register one via " + "registry.registerInstance(HUMAN_CONNECTOR, connector) before running a human-in-the-loop task.");
|
|
1463
|
+
}
|
|
1464
|
+
return context.registry.get(HUMAN_CONNECTOR);
|
|
1465
|
+
}
|
|
1466
|
+
Workflow14.prototype.humanInput = CreateWorkflow13(HumanInputTask);
|
|
1467
|
+
|
|
1468
|
+
// src/task/HumanApprovalTask.ts
|
|
1469
|
+
var humanApprovalConfigSchema = {
|
|
1470
|
+
type: "object",
|
|
1471
|
+
properties: {
|
|
1472
|
+
...TaskConfigSchema5["properties"],
|
|
1473
|
+
targetHumanId: {
|
|
1474
|
+
type: "string",
|
|
1475
|
+
title: "Target Human",
|
|
1476
|
+
description: "Identifier of the human to ask for approval",
|
|
1477
|
+
default: "default"
|
|
1478
|
+
},
|
|
1479
|
+
message: {
|
|
1480
|
+
type: "string",
|
|
1481
|
+
title: "Message",
|
|
1482
|
+
description: "Explanatory message shown to the approver",
|
|
1483
|
+
"x-ui-editor": "textarea"
|
|
1484
|
+
},
|
|
1485
|
+
metadata: {
|
|
1486
|
+
type: "object",
|
|
1487
|
+
additionalProperties: true,
|
|
1488
|
+
"x-ui-hidden": true
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
additionalProperties: false
|
|
1492
|
+
};
|
|
1493
|
+
var inputSchema13 = {
|
|
1494
|
+
type: "object",
|
|
1495
|
+
properties: {
|
|
1496
|
+
prompt: {
|
|
1497
|
+
type: "string",
|
|
1498
|
+
title: "Prompt",
|
|
1499
|
+
description: "Dynamic prompt text merged into the approval message"
|
|
1500
|
+
},
|
|
1501
|
+
context: {
|
|
1502
|
+
type: "object",
|
|
1503
|
+
additionalProperties: true,
|
|
1504
|
+
title: "Context",
|
|
1505
|
+
description: "Dynamic context data merged into the request metadata",
|
|
1506
|
+
"x-ui-hidden": true
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
additionalProperties: false
|
|
1510
|
+
};
|
|
1511
|
+
var approvalRequestedSchema = {
|
|
1512
|
+
type: "object",
|
|
1513
|
+
properties: {
|
|
1514
|
+
approved: {
|
|
1515
|
+
type: "boolean",
|
|
1516
|
+
title: "Approved",
|
|
1517
|
+
description: "Whether the request is approved"
|
|
1518
|
+
},
|
|
1519
|
+
reason: {
|
|
1520
|
+
type: "string",
|
|
1521
|
+
title: "Reason",
|
|
1522
|
+
description: "Optional explanation for the decision"
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1525
|
+
required: ["approved"]
|
|
1526
|
+
};
|
|
1527
|
+
var approvalOutputSchema = {
|
|
1528
|
+
type: "object",
|
|
1529
|
+
properties: {
|
|
1530
|
+
action: {
|
|
1531
|
+
type: "string",
|
|
1532
|
+
title: "Action",
|
|
1533
|
+
description: "The human's action: accept, decline, or cancel",
|
|
1534
|
+
enum: ["accept", "decline", "cancel"]
|
|
1535
|
+
},
|
|
1536
|
+
approved: {
|
|
1537
|
+
type: "boolean",
|
|
1538
|
+
title: "Approved",
|
|
1539
|
+
description: "Whether the human approved the request"
|
|
1540
|
+
},
|
|
1541
|
+
reason: {
|
|
1542
|
+
type: "string",
|
|
1543
|
+
title: "Reason",
|
|
1544
|
+
description: "Optional explanation for the decision"
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
required: ["action", "approved"],
|
|
1548
|
+
additionalProperties: false
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
class HumanApprovalTask extends Task14 {
|
|
1552
|
+
static type = "HumanApprovalTask";
|
|
1553
|
+
static category = "Flow Control";
|
|
1554
|
+
static title = "Human Approval";
|
|
1555
|
+
static description = "Pauses execution to request approval from a human (approve/deny) via MCP elicitation";
|
|
1556
|
+
static cacheable = false;
|
|
1557
|
+
static configSchema() {
|
|
1558
|
+
return humanApprovalConfigSchema;
|
|
1559
|
+
}
|
|
1560
|
+
static inputSchema() {
|
|
1561
|
+
return inputSchema13;
|
|
1562
|
+
}
|
|
1563
|
+
static outputSchema() {
|
|
1564
|
+
return approvalOutputSchema;
|
|
1565
|
+
}
|
|
1566
|
+
async execute(input, context) {
|
|
1567
|
+
const connector = resolveHumanConnector(context);
|
|
1568
|
+
const requestId = uuid43();
|
|
1569
|
+
const message = input.prompt ? this.config.message ? `${this.config.message}
|
|
1570
|
+
|
|
1571
|
+
${input.prompt}` : input.prompt : this.config.message ?? "";
|
|
1572
|
+
const request = {
|
|
1573
|
+
requestId,
|
|
1574
|
+
targetHumanId: this.config.targetHumanId ?? "default",
|
|
1575
|
+
kind: "elicit",
|
|
1576
|
+
message,
|
|
1577
|
+
contentSchema: approvalRequestedSchema,
|
|
1578
|
+
contentData: undefined,
|
|
1579
|
+
expectsResponse: true,
|
|
1580
|
+
mode: "single",
|
|
1581
|
+
metadata: input.context ? { ...this.config.metadata, ...input.context } : this.config.metadata
|
|
1582
|
+
};
|
|
1583
|
+
if (context.signal.aborted) {
|
|
1584
|
+
throw new TaskAbortedError3("Task aborted before requesting human approval");
|
|
1585
|
+
}
|
|
1586
|
+
let response;
|
|
1587
|
+
try {
|
|
1588
|
+
response = await connector.send(request, context.signal);
|
|
1589
|
+
} catch (err) {
|
|
1590
|
+
if (context.signal.aborted) {
|
|
1591
|
+
throw new TaskAbortedError3("Task aborted during human approval");
|
|
1592
|
+
}
|
|
1593
|
+
throw err;
|
|
1594
|
+
}
|
|
1595
|
+
if (response.action === "accept" && response.content) {
|
|
1596
|
+
return {
|
|
1597
|
+
action: response.action,
|
|
1598
|
+
approved: response.content.approved === true,
|
|
1599
|
+
reason: response.content.reason
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
action: response.action,
|
|
1604
|
+
approved: false,
|
|
1605
|
+
...response.content?.reason !== undefined ? { reason: response.content.reason } : {}
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
Workflow15.prototype.humanApproval = CreateWorkflow14(HumanApprovalTask);
|
|
1610
|
+
// src/task/McpElicitationConnector.ts
|
|
1611
|
+
function defaultAbortError() {
|
|
1612
|
+
const err = new Error("The operation was aborted");
|
|
1613
|
+
err.name = "AbortError";
|
|
1614
|
+
return err;
|
|
1615
|
+
}
|
|
1616
|
+
function toMcpRequestedSchema(schema) {
|
|
1617
|
+
const props = schema.properties ?? {};
|
|
1618
|
+
const required = schema.required;
|
|
1619
|
+
return {
|
|
1620
|
+
type: "object",
|
|
1621
|
+
properties: props,
|
|
1622
|
+
...required ? { required } : {}
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
class McpElicitationConnector {
|
|
1627
|
+
server;
|
|
1628
|
+
constructor(server) {
|
|
1629
|
+
this.server = server;
|
|
1630
|
+
}
|
|
1631
|
+
async send(request, signal) {
|
|
1632
|
+
switch (request.kind) {
|
|
1633
|
+
case "notify":
|
|
1634
|
+
return this.handleNotify(request, signal);
|
|
1635
|
+
case "display":
|
|
1636
|
+
return this.handleDisplay(request, signal);
|
|
1637
|
+
case "elicit":
|
|
1638
|
+
return this.handleElicit(request, signal);
|
|
1639
|
+
default:
|
|
1640
|
+
return this.handleElicit(request, signal);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
async followUp(request, _previousResponse, signal) {
|
|
1644
|
+
return this.send(request, signal);
|
|
1645
|
+
}
|
|
1646
|
+
async handleNotify(request, signal) {
|
|
1647
|
+
if (signal.aborted) {
|
|
1648
|
+
throw signal.reason ?? defaultAbortError();
|
|
1649
|
+
}
|
|
1650
|
+
await this.server.sendLoggingMessage({
|
|
1651
|
+
level: "info",
|
|
1652
|
+
data: request.contentData ?? request.message,
|
|
1653
|
+
logger: request.targetHumanId
|
|
1654
|
+
});
|
|
1655
|
+
if (signal.aborted) {
|
|
1656
|
+
throw signal.reason ?? defaultAbortError();
|
|
1657
|
+
}
|
|
1658
|
+
return {
|
|
1659
|
+
requestId: request.requestId,
|
|
1660
|
+
action: "accept",
|
|
1661
|
+
content: undefined,
|
|
1662
|
+
done: true
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
async handleDisplay(request, signal) {
|
|
1666
|
+
if (signal.aborted) {
|
|
1667
|
+
throw signal.reason ?? defaultAbortError();
|
|
1668
|
+
}
|
|
1669
|
+
await this.server.sendLoggingMessage({
|
|
1670
|
+
level: "info",
|
|
1671
|
+
data: {
|
|
1672
|
+
message: request.message,
|
|
1673
|
+
content: request.contentData,
|
|
1674
|
+
schema: request.contentSchema
|
|
1675
|
+
},
|
|
1676
|
+
logger: request.targetHumanId
|
|
1677
|
+
});
|
|
1678
|
+
if (signal.aborted) {
|
|
1679
|
+
throw signal.reason ?? defaultAbortError();
|
|
1680
|
+
}
|
|
1681
|
+
return {
|
|
1682
|
+
requestId: request.requestId,
|
|
1683
|
+
action: "accept",
|
|
1684
|
+
content: undefined,
|
|
1685
|
+
done: true
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
async handleElicit(request, signal) {
|
|
1689
|
+
const mcpResult = await this.server.elicitInput({
|
|
1690
|
+
mode: "form",
|
|
1691
|
+
message: request.message,
|
|
1692
|
+
requestedSchema: toMcpRequestedSchema(request.contentSchema)
|
|
1693
|
+
}, { signal });
|
|
1694
|
+
return {
|
|
1695
|
+
requestId: request.requestId,
|
|
1696
|
+
action: mcpResult.action,
|
|
1697
|
+
content: mcpResult.action === "accept" ? mcpResult.content : undefined,
|
|
1698
|
+
done: true
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
// src/task/InputTask.ts
|
|
1703
|
+
import { CreateWorkflow as CreateWorkflow15, Task as Task15, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
1250
1704
|
|
|
1251
|
-
class InputTask extends
|
|
1705
|
+
class InputTask extends Task15 {
|
|
1252
1706
|
static type = "InputTask";
|
|
1253
1707
|
static category = "Flow Control";
|
|
1254
1708
|
static title = "Input";
|
|
@@ -1299,14 +1753,15 @@ class InputTask extends Task13 {
|
|
|
1299
1753
|
yield { type: "finish", data: input };
|
|
1300
1754
|
}
|
|
1301
1755
|
}
|
|
1302
|
-
|
|
1756
|
+
Workflow16.prototype.input = CreateWorkflow15(InputTask);
|
|
1303
1757
|
// src/task/JavaScriptTask.ts
|
|
1304
1758
|
import {
|
|
1305
|
-
CreateWorkflow as
|
|
1306
|
-
|
|
1307
|
-
|
|
1759
|
+
CreateWorkflow as CreateWorkflow16,
|
|
1760
|
+
Entitlements as Entitlements2,
|
|
1761
|
+
Task as Task16,
|
|
1762
|
+
TaskConfigSchema as TaskConfigSchema6,
|
|
1308
1763
|
TaskInvalidInputError as TaskInvalidInputError3,
|
|
1309
|
-
Workflow as
|
|
1764
|
+
Workflow as Workflow17
|
|
1310
1765
|
} from "@workglow/task-graph";
|
|
1311
1766
|
|
|
1312
1767
|
// src/util/acorn.js
|
|
@@ -5774,7 +6229,7 @@ var isValidIdentifier = (key) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
|
5774
6229
|
var configSchema = {
|
|
5775
6230
|
type: "object",
|
|
5776
6231
|
properties: {
|
|
5777
|
-
...
|
|
6232
|
+
...TaskConfigSchema6["properties"],
|
|
5778
6233
|
javascript_code: {
|
|
5779
6234
|
type: "string",
|
|
5780
6235
|
title: "Code",
|
|
@@ -5785,7 +6240,7 @@ var configSchema = {
|
|
|
5785
6240
|
},
|
|
5786
6241
|
additionalProperties: false
|
|
5787
6242
|
};
|
|
5788
|
-
var
|
|
6243
|
+
var inputSchema14 = {
|
|
5789
6244
|
type: "object",
|
|
5790
6245
|
properties: {
|
|
5791
6246
|
javascript_code: {
|
|
@@ -5811,24 +6266,32 @@ var outputSchema13 = {
|
|
|
5811
6266
|
additionalProperties: false
|
|
5812
6267
|
};
|
|
5813
6268
|
|
|
5814
|
-
class JavaScriptTask extends
|
|
6269
|
+
class JavaScriptTask extends Task16 {
|
|
5815
6270
|
static type = "JavaScriptTask";
|
|
5816
6271
|
static category = "Utility";
|
|
5817
6272
|
static title = "JavaScript Interpreter";
|
|
5818
6273
|
static description = "Executes JavaScript code in a sandboxed interpreter environment";
|
|
5819
6274
|
static customizable = true;
|
|
6275
|
+
static hasDynamicSchemas = true;
|
|
6276
|
+
static entitlements() {
|
|
6277
|
+
return {
|
|
6278
|
+
entitlements: [
|
|
6279
|
+
{
|
|
6280
|
+
id: Entitlements2.CODE_EXECUTION_JS,
|
|
6281
|
+
reason: "Executes user-provided JavaScript code in a sandboxed interpreter"
|
|
6282
|
+
}
|
|
6283
|
+
]
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
5820
6286
|
static configSchema() {
|
|
5821
6287
|
return configSchema;
|
|
5822
6288
|
}
|
|
5823
6289
|
static inputSchema() {
|
|
5824
|
-
return
|
|
6290
|
+
return inputSchema14;
|
|
5825
6291
|
}
|
|
5826
6292
|
static outputSchema() {
|
|
5827
6293
|
return outputSchema13;
|
|
5828
6294
|
}
|
|
5829
|
-
constructor(input2 = {}, config = {}) {
|
|
5830
|
-
super(input2, config);
|
|
5831
|
-
}
|
|
5832
6295
|
inputSchema() {
|
|
5833
6296
|
if (this.config?.javascript_code) {
|
|
5834
6297
|
if (this.config.inputSchema) {
|
|
@@ -5840,7 +6303,7 @@ class JavaScriptTask extends Task14 {
|
|
|
5840
6303
|
additionalProperties: true
|
|
5841
6304
|
};
|
|
5842
6305
|
}
|
|
5843
|
-
return
|
|
6306
|
+
return inputSchema14;
|
|
5844
6307
|
}
|
|
5845
6308
|
async executeReactive(input2, output) {
|
|
5846
6309
|
const code = input2.javascript_code || this.config.javascript_code;
|
|
@@ -5860,20 +6323,20 @@ class JavaScriptTask extends Task14 {
|
|
|
5860
6323
|
}
|
|
5861
6324
|
}
|
|
5862
6325
|
var javaScript = (input2, config = {}) => {
|
|
5863
|
-
return new JavaScriptTask(
|
|
6326
|
+
return new JavaScriptTask(config).run(input2);
|
|
5864
6327
|
};
|
|
5865
|
-
|
|
6328
|
+
Workflow17.prototype.javaScript = CreateWorkflow16(JavaScriptTask);
|
|
5866
6329
|
// src/task/JsonTask.ts
|
|
5867
6330
|
import {
|
|
5868
6331
|
createGraphFromDependencyJSON,
|
|
5869
6332
|
createGraphFromGraphJSON,
|
|
5870
|
-
CreateWorkflow as
|
|
6333
|
+
CreateWorkflow as CreateWorkflow17,
|
|
5871
6334
|
Dataflow,
|
|
5872
6335
|
GraphAsTask as GraphAsTask2,
|
|
5873
|
-
TaskConfigurationError as
|
|
5874
|
-
Workflow as
|
|
6336
|
+
TaskConfigurationError as TaskConfigurationError3,
|
|
6337
|
+
Workflow as Workflow18
|
|
5875
6338
|
} from "@workglow/task-graph";
|
|
5876
|
-
var
|
|
6339
|
+
var inputSchema15 = {
|
|
5877
6340
|
type: "object",
|
|
5878
6341
|
properties: {
|
|
5879
6342
|
json: {
|
|
@@ -5901,7 +6364,7 @@ class JsonTask extends GraphAsTask2 {
|
|
|
5901
6364
|
static title = "JSON Task";
|
|
5902
6365
|
static description = "A task that creates and manages task graphs from JSON configurations";
|
|
5903
6366
|
static inputSchema() {
|
|
5904
|
-
return
|
|
6367
|
+
return inputSchema15;
|
|
5905
6368
|
}
|
|
5906
6369
|
static outputSchema() {
|
|
5907
6370
|
return outputSchema14;
|
|
@@ -5925,7 +6388,7 @@ class JsonTask extends GraphAsTask2 {
|
|
|
5925
6388
|
for (const dep of dependencies) {
|
|
5926
6389
|
const sourceTask = this.subGraph.getTask(dep.id);
|
|
5927
6390
|
if (!sourceTask) {
|
|
5928
|
-
throw new
|
|
6391
|
+
throw new TaskConfigurationError3(`Dependency id ${dep.id} not found`);
|
|
5929
6392
|
}
|
|
5930
6393
|
const df = new Dataflow(sourceTask.id, dep.output, item.id, input2);
|
|
5931
6394
|
this.subGraph.addDataflow(df);
|
|
@@ -5936,28 +6399,28 @@ class JsonTask extends GraphAsTask2 {
|
|
|
5936
6399
|
}
|
|
5937
6400
|
}
|
|
5938
6401
|
var json = (input2, config = {}) => {
|
|
5939
|
-
return new JsonTask(
|
|
6402
|
+
return new JsonTask(config).run(input2);
|
|
5940
6403
|
};
|
|
5941
|
-
|
|
6404
|
+
Workflow18.prototype.json = CreateWorkflow17(JsonTask);
|
|
5942
6405
|
// src/task/LambdaTask.ts
|
|
5943
6406
|
import {
|
|
5944
|
-
CreateWorkflow as
|
|
6407
|
+
CreateWorkflow as CreateWorkflow18,
|
|
5945
6408
|
DATAFLOW_ALL_PORTS,
|
|
5946
|
-
Task as
|
|
5947
|
-
TaskConfigSchema as
|
|
5948
|
-
TaskConfigurationError as
|
|
5949
|
-
Workflow as
|
|
6409
|
+
Task as Task17,
|
|
6410
|
+
TaskConfigSchema as TaskConfigSchema7,
|
|
6411
|
+
TaskConfigurationError as TaskConfigurationError4,
|
|
6412
|
+
Workflow as Workflow19
|
|
5950
6413
|
} from "@workglow/task-graph";
|
|
5951
6414
|
var lambdaTaskConfigSchema = {
|
|
5952
6415
|
type: "object",
|
|
5953
6416
|
properties: {
|
|
5954
|
-
...
|
|
6417
|
+
...TaskConfigSchema7["properties"],
|
|
5955
6418
|
execute: {},
|
|
5956
6419
|
executeReactive: {}
|
|
5957
6420
|
},
|
|
5958
6421
|
additionalProperties: false
|
|
5959
6422
|
};
|
|
5960
|
-
var
|
|
6423
|
+
var inputSchema16 = {
|
|
5961
6424
|
type: "object",
|
|
5962
6425
|
properties: {
|
|
5963
6426
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5978,7 +6441,7 @@ var outputSchema15 = {
|
|
|
5978
6441
|
additionalProperties: true
|
|
5979
6442
|
};
|
|
5980
6443
|
|
|
5981
|
-
class LambdaTask extends
|
|
6444
|
+
class LambdaTask extends Task17 {
|
|
5982
6445
|
static type = "LambdaTask";
|
|
5983
6446
|
static title = "Lambda Task";
|
|
5984
6447
|
static description = "A task that wraps a provided function and its input";
|
|
@@ -5988,7 +6451,7 @@ class LambdaTask extends Task15 {
|
|
|
5988
6451
|
return lambdaTaskConfigSchema;
|
|
5989
6452
|
}
|
|
5990
6453
|
static inputSchema() {
|
|
5991
|
-
return
|
|
6454
|
+
return inputSchema16;
|
|
5992
6455
|
}
|
|
5993
6456
|
static outputSchema() {
|
|
5994
6457
|
return outputSchema15;
|
|
@@ -5996,11 +6459,11 @@ class LambdaTask extends Task15 {
|
|
|
5996
6459
|
canSerializeConfig() {
|
|
5997
6460
|
return false;
|
|
5998
6461
|
}
|
|
5999
|
-
constructor(
|
|
6462
|
+
constructor(config = {}) {
|
|
6000
6463
|
if (!config.execute && !config.executeReactive) {
|
|
6001
|
-
throw new
|
|
6464
|
+
throw new TaskConfigurationError4("LambdaTask must have either execute or executeReactive function in config");
|
|
6002
6465
|
}
|
|
6003
|
-
super(
|
|
6466
|
+
super(config);
|
|
6004
6467
|
}
|
|
6005
6468
|
async execute(input2, context) {
|
|
6006
6469
|
if (typeof this.config.execute === "function") {
|
|
@@ -6017,18 +6480,18 @@ class LambdaTask extends Task15 {
|
|
|
6017
6480
|
}
|
|
6018
6481
|
function lambda(input2, config) {
|
|
6019
6482
|
if (typeof input2 === "function") {
|
|
6020
|
-
const task2 = new LambdaTask({
|
|
6483
|
+
const task2 = new LambdaTask({
|
|
6021
6484
|
execute: input2
|
|
6022
6485
|
});
|
|
6023
6486
|
return task2.run();
|
|
6024
6487
|
}
|
|
6025
|
-
const task = new LambdaTask(
|
|
6488
|
+
const task = new LambdaTask({ ...config, defaults: input2 });
|
|
6026
6489
|
return task.run();
|
|
6027
6490
|
}
|
|
6028
|
-
|
|
6491
|
+
Workflow19.prototype.lambda = CreateWorkflow18(LambdaTask);
|
|
6029
6492
|
// src/task/MergeTask.ts
|
|
6030
|
-
import { CreateWorkflow as
|
|
6031
|
-
var
|
|
6493
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task18, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
6494
|
+
var inputSchema17 = {
|
|
6032
6495
|
type: "object",
|
|
6033
6496
|
properties: {},
|
|
6034
6497
|
additionalProperties: true
|
|
@@ -6045,14 +6508,14 @@ var outputSchema16 = {
|
|
|
6045
6508
|
additionalProperties: false
|
|
6046
6509
|
};
|
|
6047
6510
|
|
|
6048
|
-
class MergeTask extends
|
|
6511
|
+
class MergeTask extends Task18 {
|
|
6049
6512
|
static type = "MergeTask";
|
|
6050
6513
|
static category = "Utility";
|
|
6051
6514
|
static title = "Merge";
|
|
6052
6515
|
static description = "Merges multiple inputs into a single array output";
|
|
6053
6516
|
static cacheable = true;
|
|
6054
6517
|
static inputSchema() {
|
|
6055
|
-
return
|
|
6518
|
+
return inputSchema17;
|
|
6056
6519
|
}
|
|
6057
6520
|
static outputSchema() {
|
|
6058
6521
|
return outputSchema16;
|
|
@@ -6066,24 +6529,21 @@ class MergeTask extends Task16 {
|
|
|
6066
6529
|
}
|
|
6067
6530
|
}
|
|
6068
6531
|
var merge = (input2, config = {}) => {
|
|
6069
|
-
const task = new MergeTask(
|
|
6532
|
+
const task = new MergeTask(config);
|
|
6070
6533
|
return task.run(input2);
|
|
6071
6534
|
};
|
|
6072
|
-
|
|
6535
|
+
Workflow20.prototype.merge = CreateWorkflow19(MergeTask);
|
|
6073
6536
|
// src/task/OutputTask.ts
|
|
6074
|
-
import {
|
|
6075
|
-
CreateWorkflow as CreateWorkflow18,
|
|
6076
|
-
Task as Task17,
|
|
6077
|
-
Workflow as Workflow19
|
|
6078
|
-
} from "@workglow/task-graph";
|
|
6537
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task19, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
6079
6538
|
|
|
6080
|
-
class OutputTask extends
|
|
6539
|
+
class OutputTask extends Task19 {
|
|
6081
6540
|
static type = "OutputTask";
|
|
6082
6541
|
static category = "Flow Control";
|
|
6083
6542
|
static title = "Output";
|
|
6084
6543
|
static description = "Ends the workflow";
|
|
6085
6544
|
static hasDynamicSchemas = true;
|
|
6086
6545
|
static cacheable = false;
|
|
6546
|
+
static isGraphOutput = true;
|
|
6087
6547
|
static inputSchema() {
|
|
6088
6548
|
return {
|
|
6089
6549
|
type: "object",
|
|
@@ -6128,10 +6588,10 @@ class OutputTask extends Task17 {
|
|
|
6128
6588
|
yield { type: "finish", data: input2 };
|
|
6129
6589
|
}
|
|
6130
6590
|
}
|
|
6131
|
-
|
|
6591
|
+
Workflow21.prototype.output = CreateWorkflow20(OutputTask);
|
|
6132
6592
|
// src/task/SplitTask.ts
|
|
6133
|
-
import { CreateWorkflow as
|
|
6134
|
-
var
|
|
6593
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task20, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
6594
|
+
var inputSchema18 = {
|
|
6135
6595
|
type: "object",
|
|
6136
6596
|
properties: {
|
|
6137
6597
|
input: {
|
|
@@ -6147,22 +6607,18 @@ var outputSchema17 = {
|
|
|
6147
6607
|
additionalProperties: true
|
|
6148
6608
|
};
|
|
6149
6609
|
|
|
6150
|
-
class SplitTask extends
|
|
6610
|
+
class SplitTask extends Task20 {
|
|
6151
6611
|
static type = "SplitTask";
|
|
6152
6612
|
static category = "Utility";
|
|
6153
6613
|
static title = "Split";
|
|
6154
6614
|
static description = "Splits an array into individual outputs, creating one output per element";
|
|
6155
|
-
static hasDynamicSchemas = true;
|
|
6156
6615
|
static cacheable = false;
|
|
6157
6616
|
static inputSchema() {
|
|
6158
|
-
return
|
|
6617
|
+
return inputSchema18;
|
|
6159
6618
|
}
|
|
6160
6619
|
static outputSchema() {
|
|
6161
6620
|
return outputSchema17;
|
|
6162
6621
|
}
|
|
6163
|
-
outputSchema() {
|
|
6164
|
-
return outputSchema17;
|
|
6165
|
-
}
|
|
6166
6622
|
async executeReactive(input2) {
|
|
6167
6623
|
const inputValue = input2.input;
|
|
6168
6624
|
const output = {};
|
|
@@ -6177,17 +6633,17 @@ class SplitTask extends Task18 {
|
|
|
6177
6633
|
}
|
|
6178
6634
|
}
|
|
6179
6635
|
var split = (input2, config = {}) => {
|
|
6180
|
-
const task = new SplitTask(
|
|
6636
|
+
const task = new SplitTask(config);
|
|
6181
6637
|
return task.run(input2);
|
|
6182
6638
|
};
|
|
6183
|
-
|
|
6639
|
+
Workflow22.prototype.split = CreateWorkflow21(SplitTask);
|
|
6184
6640
|
// src/task/DateFormatTask.ts
|
|
6185
6641
|
import {
|
|
6186
|
-
CreateWorkflow as
|
|
6187
|
-
Task as
|
|
6188
|
-
Workflow as
|
|
6642
|
+
CreateWorkflow as CreateWorkflow22,
|
|
6643
|
+
Task as Task21,
|
|
6644
|
+
Workflow as Workflow23
|
|
6189
6645
|
} from "@workglow/task-graph";
|
|
6190
|
-
var
|
|
6646
|
+
var inputSchema19 = {
|
|
6191
6647
|
type: "object",
|
|
6192
6648
|
properties: {
|
|
6193
6649
|
value: {
|
|
@@ -6230,13 +6686,13 @@ var outputSchema18 = {
|
|
|
6230
6686
|
additionalProperties: false
|
|
6231
6687
|
};
|
|
6232
6688
|
|
|
6233
|
-
class DateFormatTask extends
|
|
6689
|
+
class DateFormatTask extends Task21 {
|
|
6234
6690
|
static type = "DateFormatTask";
|
|
6235
6691
|
static category = "Utility";
|
|
6236
6692
|
static title = "Date Format";
|
|
6237
6693
|
static description = "Parses and formats a date string";
|
|
6238
6694
|
static inputSchema() {
|
|
6239
|
-
return
|
|
6695
|
+
return inputSchema19;
|
|
6240
6696
|
}
|
|
6241
6697
|
static outputSchema() {
|
|
6242
6698
|
return outputSchema18;
|
|
@@ -6272,14 +6728,14 @@ class DateFormatTask extends Task19 {
|
|
|
6272
6728
|
return { result };
|
|
6273
6729
|
}
|
|
6274
6730
|
}
|
|
6275
|
-
|
|
6731
|
+
Workflow23.prototype.dateFormat = CreateWorkflow22(DateFormatTask);
|
|
6276
6732
|
// src/task/JsonPathTask.ts
|
|
6277
6733
|
import {
|
|
6278
|
-
CreateWorkflow as
|
|
6279
|
-
Task as
|
|
6280
|
-
Workflow as
|
|
6734
|
+
CreateWorkflow as CreateWorkflow23,
|
|
6735
|
+
Task as Task22,
|
|
6736
|
+
Workflow as Workflow24
|
|
6281
6737
|
} from "@workglow/task-graph";
|
|
6282
|
-
var
|
|
6738
|
+
var inputSchema20 = {
|
|
6283
6739
|
type: "object",
|
|
6284
6740
|
properties: {
|
|
6285
6741
|
value: {
|
|
@@ -6328,13 +6784,13 @@ function resolvePath(obj, segments) {
|
|
|
6328
6784
|
return resolvePath(next2, tail);
|
|
6329
6785
|
}
|
|
6330
6786
|
|
|
6331
|
-
class JsonPathTask extends
|
|
6787
|
+
class JsonPathTask extends Task22 {
|
|
6332
6788
|
static type = "JsonPathTask";
|
|
6333
6789
|
static category = "Utility";
|
|
6334
6790
|
static title = "JSON Path";
|
|
6335
6791
|
static description = "Extracts a value from an object using a dot-notation path";
|
|
6336
6792
|
static inputSchema() {
|
|
6337
|
-
return
|
|
6793
|
+
return inputSchema20;
|
|
6338
6794
|
}
|
|
6339
6795
|
static outputSchema() {
|
|
6340
6796
|
return outputSchema19;
|
|
@@ -6345,20 +6801,20 @@ class JsonPathTask extends Task20 {
|
|
|
6345
6801
|
return { result };
|
|
6346
6802
|
}
|
|
6347
6803
|
}
|
|
6348
|
-
|
|
6804
|
+
Workflow24.prototype.jsonPath = CreateWorkflow23(JsonPathTask);
|
|
6349
6805
|
// src/task/RegexTask.ts
|
|
6350
6806
|
import {
|
|
6351
|
-
CreateWorkflow as
|
|
6352
|
-
Task as
|
|
6807
|
+
CreateWorkflow as CreateWorkflow24,
|
|
6808
|
+
Task as Task23,
|
|
6353
6809
|
TaskInvalidInputError as TaskInvalidInputError4,
|
|
6354
|
-
Workflow as
|
|
6810
|
+
Workflow as Workflow25
|
|
6355
6811
|
} from "@workglow/task-graph";
|
|
6356
6812
|
var MAX_BRACKET_COUNT = 100;
|
|
6357
6813
|
function hasNestedQuantifiers(pattern) {
|
|
6358
6814
|
const withoutClasses = pattern.replace(/\[(?:[^\]\\]|\\.)*\]/g, "X");
|
|
6359
6815
|
return /\([^)]*[+*][^)]*\)[+*?]|\([^)]*[+*][^)]*\)\{/.test(withoutClasses);
|
|
6360
6816
|
}
|
|
6361
|
-
var
|
|
6817
|
+
var inputSchema21 = {
|
|
6362
6818
|
type: "object",
|
|
6363
6819
|
properties: {
|
|
6364
6820
|
value: {
|
|
@@ -6400,13 +6856,13 @@ var outputSchema20 = {
|
|
|
6400
6856
|
additionalProperties: false
|
|
6401
6857
|
};
|
|
6402
6858
|
|
|
6403
|
-
class RegexTask extends
|
|
6859
|
+
class RegexTask extends Task23 {
|
|
6404
6860
|
static type = "RegexTask";
|
|
6405
6861
|
static category = "String";
|
|
6406
6862
|
static title = "Regex";
|
|
6407
6863
|
static description = "Matches a string against a regular expression pattern";
|
|
6408
6864
|
static inputSchema() {
|
|
6409
|
-
return
|
|
6865
|
+
return inputSchema21;
|
|
6410
6866
|
}
|
|
6411
6867
|
static outputSchema() {
|
|
6412
6868
|
return outputSchema20;
|
|
@@ -6438,14 +6894,14 @@ class RegexTask extends Task21 {
|
|
|
6438
6894
|
};
|
|
6439
6895
|
}
|
|
6440
6896
|
}
|
|
6441
|
-
|
|
6897
|
+
Workflow25.prototype.regex = CreateWorkflow24(RegexTask);
|
|
6442
6898
|
// src/task/TemplateTask.ts
|
|
6443
6899
|
import {
|
|
6444
|
-
CreateWorkflow as
|
|
6445
|
-
Task as
|
|
6446
|
-
Workflow as
|
|
6900
|
+
CreateWorkflow as CreateWorkflow25,
|
|
6901
|
+
Task as Task24,
|
|
6902
|
+
Workflow as Workflow26
|
|
6447
6903
|
} from "@workglow/task-graph";
|
|
6448
|
-
var
|
|
6904
|
+
var inputSchema22 = {
|
|
6449
6905
|
type: "object",
|
|
6450
6906
|
properties: {
|
|
6451
6907
|
template: {
|
|
@@ -6476,13 +6932,13 @@ var outputSchema21 = {
|
|
|
6476
6932
|
additionalProperties: false
|
|
6477
6933
|
};
|
|
6478
6934
|
|
|
6479
|
-
class TemplateTask extends
|
|
6935
|
+
class TemplateTask extends Task24 {
|
|
6480
6936
|
static type = "TemplateTask";
|
|
6481
6937
|
static category = "Utility";
|
|
6482
6938
|
static title = "Template";
|
|
6483
6939
|
static description = "Renders a template string with {{key}} placeholders and optional defaults";
|
|
6484
6940
|
static inputSchema() {
|
|
6485
|
-
return
|
|
6941
|
+
return inputSchema22;
|
|
6486
6942
|
}
|
|
6487
6943
|
static outputSchema() {
|
|
6488
6944
|
return outputSchema21;
|
|
@@ -6507,7 +6963,7 @@ class TemplateTask extends Task22 {
|
|
|
6507
6963
|
return { result };
|
|
6508
6964
|
}
|
|
6509
6965
|
}
|
|
6510
|
-
|
|
6966
|
+
Workflow26.prototype.template = CreateWorkflow25(TemplateTask);
|
|
6511
6967
|
// src/util/McpClientUtil.ts
|
|
6512
6968
|
import { Client } from "@modelcontextprotocol/sdk/client";
|
|
6513
6969
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
@@ -7029,8 +7485,8 @@ function buildAuthConfig(flat) {
|
|
|
7029
7485
|
}
|
|
7030
7486
|
|
|
7031
7487
|
// src/util/McpTaskDeps.ts
|
|
7032
|
-
import { createServiceToken, globalServiceRegistry } from "@workglow/util";
|
|
7033
|
-
var MCP_TASK_DEPS =
|
|
7488
|
+
import { createServiceToken as createServiceToken2, globalServiceRegistry } from "@workglow/util";
|
|
7489
|
+
var MCP_TASK_DEPS = createServiceToken2("@workglow/tasks/mcp");
|
|
7034
7490
|
function registerMcpTaskDeps(deps) {
|
|
7035
7491
|
globalServiceRegistry.registerInstance(MCP_TASK_DEPS, deps);
|
|
7036
7492
|
}
|
|
@@ -7257,19 +7713,15 @@ class InMemoryMcpServerRepository extends McpServerRepository {
|
|
|
7257
7713
|
}
|
|
7258
7714
|
// src/mcp-server/McpServerRegistry.ts
|
|
7259
7715
|
import {
|
|
7260
|
-
createServiceToken as
|
|
7716
|
+
createServiceToken as createServiceToken3,
|
|
7261
7717
|
globalServiceRegistry as globalServiceRegistry2,
|
|
7262
7718
|
registerInputCompactor,
|
|
7263
7719
|
registerInputResolver
|
|
7264
7720
|
} from "@workglow/util";
|
|
7265
|
-
var MCP_SERVERS =
|
|
7266
|
-
var MCP_SERVER_REPOSITORY =
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
}
|
|
7270
|
-
if (!globalServiceRegistry2.has(MCP_SERVER_REPOSITORY)) {
|
|
7271
|
-
globalServiceRegistry2.register(MCP_SERVER_REPOSITORY, () => new InMemoryMcpServerRepository, true);
|
|
7272
|
-
}
|
|
7721
|
+
var MCP_SERVERS = createServiceToken3("mcp-server.registry");
|
|
7722
|
+
var MCP_SERVER_REPOSITORY = createServiceToken3("mcp-server.repository");
|
|
7723
|
+
globalServiceRegistry2.registerIfAbsent(MCP_SERVERS, () => new Map, true);
|
|
7724
|
+
globalServiceRegistry2.registerIfAbsent(MCP_SERVER_REPOSITORY, () => new InMemoryMcpServerRepository, true);
|
|
7273
7725
|
function getGlobalMcpServers() {
|
|
7274
7726
|
return globalServiceRegistry2.get(MCP_SERVERS);
|
|
7275
7727
|
}
|
|
@@ -7334,7 +7786,29 @@ function getMcpServerConfig(configOrInput) {
|
|
|
7334
7786
|
return base;
|
|
7335
7787
|
}
|
|
7336
7788
|
// src/task/mcp/McpListTask.ts
|
|
7337
|
-
import {
|
|
7789
|
+
import {
|
|
7790
|
+
CreateWorkflow as CreateWorkflow26,
|
|
7791
|
+
Entitlements as Entitlements3,
|
|
7792
|
+
mergeEntitlements,
|
|
7793
|
+
Task as Task25,
|
|
7794
|
+
Workflow as Workflow27
|
|
7795
|
+
} from "@workglow/task-graph";
|
|
7796
|
+
|
|
7797
|
+
// src/util/getMcpServerTransport.ts
|
|
7798
|
+
function getMcpServerTransport(task) {
|
|
7799
|
+
const runInputData = task.runInputData;
|
|
7800
|
+
const inputServer = runInputData?.server;
|
|
7801
|
+
if (typeof inputServer?.transport === "string") {
|
|
7802
|
+
return inputServer.transport;
|
|
7803
|
+
}
|
|
7804
|
+
const configServer = task.config?.server;
|
|
7805
|
+
if (typeof configServer?.transport === "string") {
|
|
7806
|
+
return configServer.transport;
|
|
7807
|
+
}
|
|
7808
|
+
return;
|
|
7809
|
+
}
|
|
7810
|
+
|
|
7811
|
+
// src/task/mcp/McpListTask.ts
|
|
7338
7812
|
var mcpListTypes = ["tools", "resources", "prompts"];
|
|
7339
7813
|
var iconSchema = {
|
|
7340
7814
|
type: "object",
|
|
@@ -7491,13 +7965,35 @@ var outputSchemaAll = {
|
|
|
7491
7965
|
additionalProperties: false
|
|
7492
7966
|
};
|
|
7493
7967
|
|
|
7494
|
-
class McpListTask extends
|
|
7968
|
+
class McpListTask extends Task25 {
|
|
7495
7969
|
static type = "McpListTask";
|
|
7496
7970
|
static category = "MCP";
|
|
7497
7971
|
static title = "MCP List";
|
|
7498
7972
|
static description = "Lists tools, resources, or prompts available on an MCP server";
|
|
7499
7973
|
static cacheable = false;
|
|
7500
7974
|
static hasDynamicSchemas = true;
|
|
7975
|
+
static hasDynamicEntitlements = true;
|
|
7976
|
+
static entitlements() {
|
|
7977
|
+
return {
|
|
7978
|
+
entitlements: [
|
|
7979
|
+
{ id: Entitlements3.MCP, reason: "Lists tools, resources, or prompts on MCP servers" }
|
|
7980
|
+
]
|
|
7981
|
+
};
|
|
7982
|
+
}
|
|
7983
|
+
entitlements() {
|
|
7984
|
+
const base = McpListTask.entitlements();
|
|
7985
|
+
const transport = getMcpServerTransport(this);
|
|
7986
|
+
if (transport === "stdio") {
|
|
7987
|
+
return mergeEntitlements(base, {
|
|
7988
|
+
entitlements: [
|
|
7989
|
+
{ id: Entitlements3.MCP_STDIO, reason: "Uses stdio transport to spawn local process" }
|
|
7990
|
+
]
|
|
7991
|
+
});
|
|
7992
|
+
}
|
|
7993
|
+
return mergeEntitlements(base, {
|
|
7994
|
+
entitlements: [{ id: Entitlements3.NETWORK_HTTP, reason: "Connects to MCP server over HTTP" }]
|
|
7995
|
+
});
|
|
7996
|
+
}
|
|
7501
7997
|
static inputSchema() {
|
|
7502
7998
|
const { mcpServerConfigSchema: mcpServerConfigSchema2 } = getMcpTaskDeps();
|
|
7503
7999
|
return {
|
|
@@ -7574,15 +8070,17 @@ class McpListTask extends Task23 {
|
|
|
7574
8070
|
}
|
|
7575
8071
|
}
|
|
7576
8072
|
var mcpList = async (input2, config = {}) => {
|
|
7577
|
-
return new McpListTask(
|
|
8073
|
+
return new McpListTask(config).run(input2);
|
|
7578
8074
|
};
|
|
7579
|
-
|
|
8075
|
+
Workflow27.prototype.mcpList = CreateWorkflow26(McpListTask);
|
|
7580
8076
|
// src/task/mcp/McpPromptGetTask.ts
|
|
7581
8077
|
import {
|
|
7582
|
-
CreateWorkflow as
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
8078
|
+
CreateWorkflow as CreateWorkflow27,
|
|
8079
|
+
Entitlements as Entitlements4,
|
|
8080
|
+
mergeEntitlements as mergeEntitlements2,
|
|
8081
|
+
Task as Task26,
|
|
8082
|
+
TaskConfigSchema as TaskConfigSchema8,
|
|
8083
|
+
Workflow as Workflow28
|
|
7586
8084
|
} from "@workglow/task-graph";
|
|
7587
8085
|
var annotationsSchema = {
|
|
7588
8086
|
type: "object",
|
|
@@ -7717,7 +8215,7 @@ var fallbackInputSchema = {
|
|
|
7717
8215
|
additionalProperties: false
|
|
7718
8216
|
};
|
|
7719
8217
|
|
|
7720
|
-
class McpPromptGetTask extends
|
|
8218
|
+
class McpPromptGetTask extends Task26 {
|
|
7721
8219
|
static type = "McpPromptGetTask";
|
|
7722
8220
|
static category = "MCP";
|
|
7723
8221
|
static title = "MCP Get Prompt";
|
|
@@ -7725,6 +8223,29 @@ class McpPromptGetTask extends Task24 {
|
|
|
7725
8223
|
static cacheable = false;
|
|
7726
8224
|
static customizable = true;
|
|
7727
8225
|
static hasDynamicSchemas = true;
|
|
8226
|
+
static hasDynamicEntitlements = true;
|
|
8227
|
+
static entitlements() {
|
|
8228
|
+
return {
|
|
8229
|
+
entitlements: [{ id: Entitlements4.MCP_PROMPT_GET, reason: "Gets prompts from MCP servers" }]
|
|
8230
|
+
};
|
|
8231
|
+
}
|
|
8232
|
+
entitlements() {
|
|
8233
|
+
const base = McpPromptGetTask.entitlements();
|
|
8234
|
+
const transport = getMcpServerTransport(this);
|
|
8235
|
+
if (transport === "stdio") {
|
|
8236
|
+
return mergeEntitlements2(base, {
|
|
8237
|
+
entitlements: [
|
|
8238
|
+
{ id: Entitlements4.MCP_STDIO, reason: "Uses stdio transport to spawn local process" }
|
|
8239
|
+
]
|
|
8240
|
+
});
|
|
8241
|
+
}
|
|
8242
|
+
return mergeEntitlements2(base, {
|
|
8243
|
+
entitlements: [
|
|
8244
|
+
{ id: Entitlements4.NETWORK_HTTP, reason: "Connects to MCP server over HTTP" },
|
|
8245
|
+
{ id: Entitlements4.CREDENTIAL, reason: "May require authentication", optional: true }
|
|
8246
|
+
]
|
|
8247
|
+
});
|
|
8248
|
+
}
|
|
7728
8249
|
static inputSchema() {
|
|
7729
8250
|
return fallbackInputSchema;
|
|
7730
8251
|
}
|
|
@@ -7736,7 +8257,7 @@ class McpPromptGetTask extends Task24 {
|
|
|
7736
8257
|
return {
|
|
7737
8258
|
type: "object",
|
|
7738
8259
|
properties: {
|
|
7739
|
-
...
|
|
8260
|
+
...TaskConfigSchema8["properties"],
|
|
7740
8261
|
server: TypeMcpServer(mcpServerConfigSchema2),
|
|
7741
8262
|
prompt_name: {
|
|
7742
8263
|
type: "string",
|
|
@@ -7755,43 +8276,45 @@ class McpPromptGetTask extends Task24 {
|
|
|
7755
8276
|
outputSchema() {
|
|
7756
8277
|
return this.config?.outputSchema ?? fallbackOutputSchema;
|
|
7757
8278
|
}
|
|
7758
|
-
|
|
8279
|
+
_schemasDiscoveringPromise;
|
|
7759
8280
|
async discoverSchemas(_signal, serverConfig) {
|
|
7760
8281
|
if (this.config.inputSchema)
|
|
7761
8282
|
return;
|
|
7762
|
-
if (this.
|
|
7763
|
-
return;
|
|
8283
|
+
if (this._schemasDiscoveringPromise)
|
|
8284
|
+
return this._schemasDiscoveringPromise;
|
|
7764
8285
|
const resolved = serverConfig ?? getMcpServerConfig(this.config);
|
|
7765
8286
|
if (!resolved.transport || !this.config.prompt_name)
|
|
7766
8287
|
return;
|
|
7767
|
-
this.
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
8288
|
+
this._schemasDiscoveringPromise = (async () => {
|
|
8289
|
+
try {
|
|
8290
|
+
const result = await mcpList({
|
|
8291
|
+
server: resolved,
|
|
8292
|
+
list_type: "prompts"
|
|
8293
|
+
});
|
|
8294
|
+
const prompt = result.prompts?.find((p) => p.name === this.config.prompt_name);
|
|
8295
|
+
if (prompt) {
|
|
8296
|
+
const args = prompt.arguments ?? [];
|
|
8297
|
+
const required = args.filter((a) => a.required).map((a) => a.name);
|
|
8298
|
+
const properties = {};
|
|
8299
|
+
for (const arg of args) {
|
|
8300
|
+
properties[arg.name] = {
|
|
8301
|
+
type: "string",
|
|
8302
|
+
...arg.description ? { description: arg.description } : {}
|
|
8303
|
+
};
|
|
8304
|
+
}
|
|
8305
|
+
this.config.inputSchema = {
|
|
8306
|
+
type: "object",
|
|
8307
|
+
properties,
|
|
8308
|
+
...required.length > 0 ? { required } : {},
|
|
8309
|
+
additionalProperties: false
|
|
7782
8310
|
};
|
|
8311
|
+
this.emitSchemaChange();
|
|
7783
8312
|
}
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
properties,
|
|
7787
|
-
...required.length > 0 ? { required } : {},
|
|
7788
|
-
additionalProperties: false
|
|
7789
|
-
};
|
|
7790
|
-
this.emitSchemaChange();
|
|
8313
|
+
} finally {
|
|
8314
|
+
this._schemasDiscoveringPromise = undefined;
|
|
7791
8315
|
}
|
|
7792
|
-
}
|
|
7793
|
-
|
|
7794
|
-
}
|
|
8316
|
+
})();
|
|
8317
|
+
return this._schemasDiscoveringPromise;
|
|
7795
8318
|
}
|
|
7796
8319
|
async execute(input2, context) {
|
|
7797
8320
|
const serverConfig = getMcpServerConfig(this.config);
|
|
@@ -7813,15 +8336,17 @@ class McpPromptGetTask extends Task24 {
|
|
|
7813
8336
|
}
|
|
7814
8337
|
}
|
|
7815
8338
|
var mcpPromptGet = async (input2, config) => {
|
|
7816
|
-
return new McpPromptGetTask(
|
|
8339
|
+
return new McpPromptGetTask(config).run(input2);
|
|
7817
8340
|
};
|
|
7818
|
-
|
|
8341
|
+
Workflow28.prototype.mcpPromptGet = CreateWorkflow27(McpPromptGetTask);
|
|
7819
8342
|
// src/task/mcp/McpResourceReadTask.ts
|
|
7820
8343
|
import {
|
|
7821
|
-
CreateWorkflow as
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
8344
|
+
CreateWorkflow as CreateWorkflow28,
|
|
8345
|
+
Entitlements as Entitlements5,
|
|
8346
|
+
mergeEntitlements as mergeEntitlements3,
|
|
8347
|
+
Task as Task27,
|
|
8348
|
+
TaskConfigSchema as TaskConfigSchema9,
|
|
8349
|
+
Workflow as Workflow29
|
|
7825
8350
|
} from "@workglow/task-graph";
|
|
7826
8351
|
var contentItemSchema = {
|
|
7827
8352
|
anyOf: [
|
|
@@ -7849,7 +8374,7 @@ var contentItemSchema = {
|
|
|
7849
8374
|
}
|
|
7850
8375
|
]
|
|
7851
8376
|
};
|
|
7852
|
-
var
|
|
8377
|
+
var inputSchema23 = {
|
|
7853
8378
|
type: "object",
|
|
7854
8379
|
properties: {},
|
|
7855
8380
|
additionalProperties: false
|
|
@@ -7868,15 +8393,40 @@ var outputSchema22 = {
|
|
|
7868
8393
|
additionalProperties: false
|
|
7869
8394
|
};
|
|
7870
8395
|
|
|
7871
|
-
class McpResourceReadTask extends
|
|
8396
|
+
class McpResourceReadTask extends Task27 {
|
|
7872
8397
|
static type = "McpResourceReadTask";
|
|
7873
8398
|
static category = "MCP";
|
|
7874
8399
|
static title = "MCP Read Resource";
|
|
7875
8400
|
static description = "Reads a resource from an MCP server";
|
|
7876
8401
|
static cacheable = false;
|
|
7877
8402
|
static customizable = true;
|
|
8403
|
+
static hasDynamicEntitlements = true;
|
|
8404
|
+
static entitlements() {
|
|
8405
|
+
return {
|
|
8406
|
+
entitlements: [
|
|
8407
|
+
{ id: Entitlements5.MCP_RESOURCE_READ, reason: "Reads resources from MCP servers" }
|
|
8408
|
+
]
|
|
8409
|
+
};
|
|
8410
|
+
}
|
|
8411
|
+
entitlements() {
|
|
8412
|
+
const base = McpResourceReadTask.entitlements();
|
|
8413
|
+
const transport = getMcpServerTransport(this);
|
|
8414
|
+
if (transport === "stdio") {
|
|
8415
|
+
return mergeEntitlements3(base, {
|
|
8416
|
+
entitlements: [
|
|
8417
|
+
{ id: Entitlements5.MCP_STDIO, reason: "Uses stdio transport to spawn local process" }
|
|
8418
|
+
]
|
|
8419
|
+
});
|
|
8420
|
+
}
|
|
8421
|
+
return mergeEntitlements3(base, {
|
|
8422
|
+
entitlements: [
|
|
8423
|
+
{ id: Entitlements5.NETWORK_HTTP, reason: "Connects to MCP server over HTTP" },
|
|
8424
|
+
{ id: Entitlements5.CREDENTIAL, reason: "May require authentication", optional: true }
|
|
8425
|
+
]
|
|
8426
|
+
});
|
|
8427
|
+
}
|
|
7878
8428
|
static inputSchema() {
|
|
7879
|
-
return
|
|
8429
|
+
return inputSchema23;
|
|
7880
8430
|
}
|
|
7881
8431
|
static outputSchema() {
|
|
7882
8432
|
return outputSchema22;
|
|
@@ -7886,7 +8436,7 @@ class McpResourceReadTask extends Task25 {
|
|
|
7886
8436
|
return {
|
|
7887
8437
|
type: "object",
|
|
7888
8438
|
properties: {
|
|
7889
|
-
...
|
|
8439
|
+
...TaskConfigSchema9["properties"],
|
|
7890
8440
|
server: TypeMcpServer(mcpServerConfigSchema2),
|
|
7891
8441
|
resource_uri: {
|
|
7892
8442
|
type: "string",
|
|
@@ -7914,11 +8464,16 @@ class McpResourceReadTask extends Task25 {
|
|
|
7914
8464
|
}
|
|
7915
8465
|
}
|
|
7916
8466
|
var mcpResourceRead = async (config) => {
|
|
7917
|
-
return new McpResourceReadTask(
|
|
8467
|
+
return new McpResourceReadTask(config).run({});
|
|
7918
8468
|
};
|
|
7919
|
-
|
|
8469
|
+
Workflow29.prototype.mcpResourceRead = CreateWorkflow28(McpResourceReadTask);
|
|
7920
8470
|
// src/task/mcp/McpSearchTask.ts
|
|
7921
|
-
import {
|
|
8471
|
+
import {
|
|
8472
|
+
CreateWorkflow as CreateWorkflow29,
|
|
8473
|
+
Entitlements as Entitlements6,
|
|
8474
|
+
Task as Task28,
|
|
8475
|
+
Workflow as Workflow30
|
|
8476
|
+
} from "@workglow/task-graph";
|
|
7922
8477
|
var MCP_REGISTRY_BASE = "https://registry.modelcontextprotocol.io/v0.1";
|
|
7923
8478
|
var McpSearchInputSchema = {
|
|
7924
8479
|
type: "object",
|
|
@@ -8057,12 +8612,19 @@ async function searchMcpRegistry(query, signal) {
|
|
|
8057
8612
|
return page.results;
|
|
8058
8613
|
}
|
|
8059
8614
|
|
|
8060
|
-
class McpSearchTask extends
|
|
8615
|
+
class McpSearchTask extends Task28 {
|
|
8061
8616
|
static type = "McpSearchTask";
|
|
8062
8617
|
static category = "MCP";
|
|
8063
8618
|
static title = "MCP Search";
|
|
8064
8619
|
static description = "Search the MCP server registry for servers matching a query";
|
|
8065
8620
|
static cacheable = false;
|
|
8621
|
+
static entitlements() {
|
|
8622
|
+
return {
|
|
8623
|
+
entitlements: [
|
|
8624
|
+
{ id: Entitlements6.NETWORK_HTTP, reason: "Searches the MCP server registry via HTTPS" }
|
|
8625
|
+
]
|
|
8626
|
+
};
|
|
8627
|
+
}
|
|
8066
8628
|
static inputSchema() {
|
|
8067
8629
|
return McpSearchInputSchema;
|
|
8068
8630
|
}
|
|
@@ -8075,15 +8637,17 @@ class McpSearchTask extends Task26 {
|
|
|
8075
8637
|
}
|
|
8076
8638
|
}
|
|
8077
8639
|
var mcpSearch = (input2, config) => {
|
|
8078
|
-
return new McpSearchTask(
|
|
8640
|
+
return new McpSearchTask(config).run(input2);
|
|
8079
8641
|
};
|
|
8080
|
-
|
|
8642
|
+
Workflow30.prototype.mcpSearch = CreateWorkflow29(McpSearchTask);
|
|
8081
8643
|
// src/task/mcp/McpToolCallTask.ts
|
|
8082
8644
|
import {
|
|
8083
|
-
CreateWorkflow as
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8645
|
+
CreateWorkflow as CreateWorkflow30,
|
|
8646
|
+
Entitlements as Entitlements7,
|
|
8647
|
+
mergeEntitlements as mergeEntitlements4,
|
|
8648
|
+
Task as Task29,
|
|
8649
|
+
TaskConfigSchema as TaskConfigSchema10,
|
|
8650
|
+
Workflow as Workflow31
|
|
8087
8651
|
} from "@workglow/task-graph";
|
|
8088
8652
|
var annotationsSchema2 = {
|
|
8089
8653
|
type: "object",
|
|
@@ -8210,7 +8774,7 @@ var fallbackInputSchema2 = {
|
|
|
8210
8774
|
additionalProperties: true
|
|
8211
8775
|
};
|
|
8212
8776
|
|
|
8213
|
-
class McpToolCallTask extends
|
|
8777
|
+
class McpToolCallTask extends Task29 {
|
|
8214
8778
|
static type = "McpToolCallTask";
|
|
8215
8779
|
static category = "MCP";
|
|
8216
8780
|
static title = "MCP Call Tool";
|
|
@@ -8218,6 +8782,29 @@ class McpToolCallTask extends Task27 {
|
|
|
8218
8782
|
static cacheable = false;
|
|
8219
8783
|
static customizable = true;
|
|
8220
8784
|
static hasDynamicSchemas = true;
|
|
8785
|
+
static hasDynamicEntitlements = true;
|
|
8786
|
+
static entitlements() {
|
|
8787
|
+
return {
|
|
8788
|
+
entitlements: [{ id: Entitlements7.MCP_TOOL_CALL, reason: "Calls tools on MCP servers" }]
|
|
8789
|
+
};
|
|
8790
|
+
}
|
|
8791
|
+
entitlements() {
|
|
8792
|
+
const base = McpToolCallTask.entitlements();
|
|
8793
|
+
const transport = getMcpServerTransport(this);
|
|
8794
|
+
if (transport === "stdio") {
|
|
8795
|
+
return mergeEntitlements4(base, {
|
|
8796
|
+
entitlements: [
|
|
8797
|
+
{ id: Entitlements7.MCP_STDIO, reason: "Uses stdio transport to spawn local process" }
|
|
8798
|
+
]
|
|
8799
|
+
});
|
|
8800
|
+
}
|
|
8801
|
+
return mergeEntitlements4(base, {
|
|
8802
|
+
entitlements: [
|
|
8803
|
+
{ id: Entitlements7.NETWORK_HTTP, reason: "Connects to MCP server over HTTP" },
|
|
8804
|
+
{ id: Entitlements7.CREDENTIAL, reason: "May require authentication", optional: true }
|
|
8805
|
+
]
|
|
8806
|
+
});
|
|
8807
|
+
}
|
|
8221
8808
|
static inputSchema() {
|
|
8222
8809
|
return fallbackInputSchema2;
|
|
8223
8810
|
}
|
|
@@ -8229,7 +8816,7 @@ class McpToolCallTask extends Task27 {
|
|
|
8229
8816
|
return {
|
|
8230
8817
|
type: "object",
|
|
8231
8818
|
properties: {
|
|
8232
|
-
...
|
|
8819
|
+
...TaskConfigSchema10["properties"],
|
|
8233
8820
|
server: TypeMcpServer(mcpServerConfigSchema2),
|
|
8234
8821
|
tool_name: {
|
|
8235
8822
|
type: "string",
|
|
@@ -8248,34 +8835,36 @@ class McpToolCallTask extends Task27 {
|
|
|
8248
8835
|
outputSchema() {
|
|
8249
8836
|
return this.config?.outputSchema ?? fallbackOutputSchema2;
|
|
8250
8837
|
}
|
|
8251
|
-
|
|
8838
|
+
_schemasDiscoveringPromise;
|
|
8252
8839
|
async discoverSchemas(_signal, serverConfig) {
|
|
8253
8840
|
if (this.config.inputSchema && this.config.outputSchema)
|
|
8254
8841
|
return;
|
|
8255
|
-
if (this.
|
|
8256
|
-
return;
|
|
8842
|
+
if (this._schemasDiscoveringPromise)
|
|
8843
|
+
return this._schemasDiscoveringPromise;
|
|
8257
8844
|
const resolved = serverConfig ?? getMcpServerConfig(this.config);
|
|
8258
8845
|
if (!resolved.transport || !this.config.tool_name)
|
|
8259
8846
|
return;
|
|
8260
|
-
this.
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8847
|
+
this._schemasDiscoveringPromise = (async () => {
|
|
8848
|
+
try {
|
|
8849
|
+
const result = await mcpList({
|
|
8850
|
+
server: resolved,
|
|
8851
|
+
list_type: "tools"
|
|
8852
|
+
});
|
|
8853
|
+
const tool = result.tools?.find((t) => t.name === this.config.tool_name);
|
|
8854
|
+
if (tool) {
|
|
8855
|
+
if (!this.config.inputSchema) {
|
|
8856
|
+
this.config.inputSchema = tool.inputSchema;
|
|
8857
|
+
}
|
|
8858
|
+
if (!this.config.outputSchema && tool.outputSchema) {
|
|
8859
|
+
this.config.outputSchema = tool.outputSchema;
|
|
8860
|
+
}
|
|
8861
|
+
this.emitSchemaChange();
|
|
8273
8862
|
}
|
|
8274
|
-
|
|
8863
|
+
} finally {
|
|
8864
|
+
this._schemasDiscoveringPromise = undefined;
|
|
8275
8865
|
}
|
|
8276
|
-
}
|
|
8277
|
-
|
|
8278
|
-
}
|
|
8866
|
+
})();
|
|
8867
|
+
return this._schemasDiscoveringPromise;
|
|
8279
8868
|
}
|
|
8280
8869
|
async execute(input2, context) {
|
|
8281
8870
|
const serverConfig = getMcpServerConfig(this.config);
|
|
@@ -8321,16 +8910,16 @@ class McpToolCallTask extends Task27 {
|
|
|
8321
8910
|
}
|
|
8322
8911
|
}
|
|
8323
8912
|
var mcpToolCall = async (input2, config) => {
|
|
8324
|
-
return new McpToolCallTask(
|
|
8913
|
+
return new McpToolCallTask(config).run(input2);
|
|
8325
8914
|
};
|
|
8326
|
-
|
|
8915
|
+
Workflow31.prototype.mcpToolCall = CreateWorkflow30(McpToolCallTask);
|
|
8327
8916
|
// src/task/string/StringConcatTask.ts
|
|
8328
8917
|
import {
|
|
8329
|
-
CreateWorkflow as
|
|
8330
|
-
Task as
|
|
8331
|
-
Workflow as
|
|
8918
|
+
CreateWorkflow as CreateWorkflow31,
|
|
8919
|
+
Task as Task30,
|
|
8920
|
+
Workflow as Workflow32
|
|
8332
8921
|
} from "@workglow/task-graph";
|
|
8333
|
-
var
|
|
8922
|
+
var inputSchema24 = {
|
|
8334
8923
|
type: "object",
|
|
8335
8924
|
properties: {},
|
|
8336
8925
|
additionalProperties: { type: "string" }
|
|
@@ -8348,13 +8937,13 @@ var outputSchema23 = {
|
|
|
8348
8937
|
additionalProperties: false
|
|
8349
8938
|
};
|
|
8350
8939
|
|
|
8351
|
-
class StringConcatTask extends
|
|
8940
|
+
class StringConcatTask extends Task30 {
|
|
8352
8941
|
static type = "StringConcatTask";
|
|
8353
8942
|
static category = "String";
|
|
8354
8943
|
static title = "Concat";
|
|
8355
8944
|
static description = "Concatenates all input strings";
|
|
8356
8945
|
static inputSchema() {
|
|
8357
|
-
return
|
|
8946
|
+
return inputSchema24;
|
|
8358
8947
|
}
|
|
8359
8948
|
static outputSchema() {
|
|
8360
8949
|
return outputSchema23;
|
|
@@ -8363,14 +8952,14 @@ class StringConcatTask extends Task28 {
|
|
|
8363
8952
|
return { result: Object.values(input2).join("") };
|
|
8364
8953
|
}
|
|
8365
8954
|
}
|
|
8366
|
-
|
|
8955
|
+
Workflow32.prototype.stringConcat = CreateWorkflow31(StringConcatTask);
|
|
8367
8956
|
// src/task/string/StringIncludesTask.ts
|
|
8368
8957
|
import {
|
|
8369
|
-
CreateWorkflow as
|
|
8370
|
-
Task as
|
|
8371
|
-
Workflow as
|
|
8958
|
+
CreateWorkflow as CreateWorkflow32,
|
|
8959
|
+
Task as Task31,
|
|
8960
|
+
Workflow as Workflow33
|
|
8372
8961
|
} from "@workglow/task-graph";
|
|
8373
|
-
var
|
|
8962
|
+
var inputSchema25 = {
|
|
8374
8963
|
type: "object",
|
|
8375
8964
|
properties: {
|
|
8376
8965
|
value: {
|
|
@@ -8400,13 +8989,13 @@ var outputSchema24 = {
|
|
|
8400
8989
|
additionalProperties: false
|
|
8401
8990
|
};
|
|
8402
8991
|
|
|
8403
|
-
class StringIncludesTask extends
|
|
8992
|
+
class StringIncludesTask extends Task31 {
|
|
8404
8993
|
static type = "StringIncludesTask";
|
|
8405
8994
|
static category = "String";
|
|
8406
8995
|
static title = "Includes";
|
|
8407
8996
|
static description = "Checks if a string contains a substring";
|
|
8408
8997
|
static inputSchema() {
|
|
8409
|
-
return
|
|
8998
|
+
return inputSchema25;
|
|
8410
8999
|
}
|
|
8411
9000
|
static outputSchema() {
|
|
8412
9001
|
return outputSchema24;
|
|
@@ -8415,14 +9004,14 @@ class StringIncludesTask extends Task29 {
|
|
|
8415
9004
|
return { result: input2.value.includes(input2.search) };
|
|
8416
9005
|
}
|
|
8417
9006
|
}
|
|
8418
|
-
|
|
9007
|
+
Workflow33.prototype.stringIncludes = CreateWorkflow32(StringIncludesTask);
|
|
8419
9008
|
// src/task/string/StringJoinTask.ts
|
|
8420
9009
|
import {
|
|
8421
|
-
CreateWorkflow as
|
|
8422
|
-
Task as
|
|
8423
|
-
Workflow as
|
|
9010
|
+
CreateWorkflow as CreateWorkflow33,
|
|
9011
|
+
Task as Task32,
|
|
9012
|
+
Workflow as Workflow34
|
|
8424
9013
|
} from "@workglow/task-graph";
|
|
8425
|
-
var
|
|
9014
|
+
var inputSchema26 = {
|
|
8426
9015
|
type: "object",
|
|
8427
9016
|
properties: {
|
|
8428
9017
|
values: {
|
|
@@ -8454,13 +9043,13 @@ var outputSchema25 = {
|
|
|
8454
9043
|
additionalProperties: false
|
|
8455
9044
|
};
|
|
8456
9045
|
|
|
8457
|
-
class StringJoinTask extends
|
|
9046
|
+
class StringJoinTask extends Task32 {
|
|
8458
9047
|
static type = "StringJoinTask";
|
|
8459
9048
|
static category = "String";
|
|
8460
9049
|
static title = "Join";
|
|
8461
9050
|
static description = "Joins an array of strings with a separator";
|
|
8462
9051
|
static inputSchema() {
|
|
8463
|
-
return
|
|
9052
|
+
return inputSchema26;
|
|
8464
9053
|
}
|
|
8465
9054
|
static outputSchema() {
|
|
8466
9055
|
return outputSchema25;
|
|
@@ -8470,14 +9059,14 @@ class StringJoinTask extends Task30 {
|
|
|
8470
9059
|
return { result: input2.values.join(separator) };
|
|
8471
9060
|
}
|
|
8472
9061
|
}
|
|
8473
|
-
|
|
9062
|
+
Workflow34.prototype.stringJoin = CreateWorkflow33(StringJoinTask);
|
|
8474
9063
|
// src/task/string/StringLengthTask.ts
|
|
8475
9064
|
import {
|
|
8476
|
-
CreateWorkflow as
|
|
8477
|
-
Task as
|
|
8478
|
-
Workflow as
|
|
9065
|
+
CreateWorkflow as CreateWorkflow34,
|
|
9066
|
+
Task as Task33,
|
|
9067
|
+
Workflow as Workflow35
|
|
8479
9068
|
} from "@workglow/task-graph";
|
|
8480
|
-
var
|
|
9069
|
+
var inputSchema27 = {
|
|
8481
9070
|
type: "object",
|
|
8482
9071
|
properties: {
|
|
8483
9072
|
value: {
|
|
@@ -8502,13 +9091,13 @@ var outputSchema26 = {
|
|
|
8502
9091
|
additionalProperties: false
|
|
8503
9092
|
};
|
|
8504
9093
|
|
|
8505
|
-
class StringLengthTask extends
|
|
9094
|
+
class StringLengthTask extends Task33 {
|
|
8506
9095
|
static type = "StringLengthTask";
|
|
8507
9096
|
static category = "String";
|
|
8508
9097
|
static title = "Length";
|
|
8509
9098
|
static description = "Returns the length of a string";
|
|
8510
9099
|
static inputSchema() {
|
|
8511
|
-
return
|
|
9100
|
+
return inputSchema27;
|
|
8512
9101
|
}
|
|
8513
9102
|
static outputSchema() {
|
|
8514
9103
|
return outputSchema26;
|
|
@@ -8517,14 +9106,14 @@ class StringLengthTask extends Task31 {
|
|
|
8517
9106
|
return { result: input2.value.length };
|
|
8518
9107
|
}
|
|
8519
9108
|
}
|
|
8520
|
-
|
|
9109
|
+
Workflow35.prototype.stringLength = CreateWorkflow34(StringLengthTask);
|
|
8521
9110
|
// src/task/string/StringLowerCaseTask.ts
|
|
8522
9111
|
import {
|
|
8523
|
-
CreateWorkflow as
|
|
8524
|
-
Task as
|
|
8525
|
-
Workflow as
|
|
9112
|
+
CreateWorkflow as CreateWorkflow35,
|
|
9113
|
+
Task as Task34,
|
|
9114
|
+
Workflow as Workflow36
|
|
8526
9115
|
} from "@workglow/task-graph";
|
|
8527
|
-
var
|
|
9116
|
+
var inputSchema28 = {
|
|
8528
9117
|
type: "object",
|
|
8529
9118
|
properties: {
|
|
8530
9119
|
value: {
|
|
@@ -8549,13 +9138,13 @@ var outputSchema27 = {
|
|
|
8549
9138
|
additionalProperties: false
|
|
8550
9139
|
};
|
|
8551
9140
|
|
|
8552
|
-
class StringLowerCaseTask extends
|
|
9141
|
+
class StringLowerCaseTask extends Task34 {
|
|
8553
9142
|
static type = "StringLowerCaseTask";
|
|
8554
9143
|
static category = "String";
|
|
8555
9144
|
static title = "Lower Case";
|
|
8556
9145
|
static description = "Converts a string to lower case";
|
|
8557
9146
|
static inputSchema() {
|
|
8558
|
-
return
|
|
9147
|
+
return inputSchema28;
|
|
8559
9148
|
}
|
|
8560
9149
|
static outputSchema() {
|
|
8561
9150
|
return outputSchema27;
|
|
@@ -8564,14 +9153,14 @@ class StringLowerCaseTask extends Task32 {
|
|
|
8564
9153
|
return { result: input2.value.toLowerCase() };
|
|
8565
9154
|
}
|
|
8566
9155
|
}
|
|
8567
|
-
|
|
9156
|
+
Workflow36.prototype.stringLowerCase = CreateWorkflow35(StringLowerCaseTask);
|
|
8568
9157
|
// src/task/string/StringReplaceTask.ts
|
|
8569
9158
|
import {
|
|
8570
|
-
CreateWorkflow as
|
|
8571
|
-
Task as
|
|
8572
|
-
Workflow as
|
|
9159
|
+
CreateWorkflow as CreateWorkflow36,
|
|
9160
|
+
Task as Task35,
|
|
9161
|
+
Workflow as Workflow37
|
|
8573
9162
|
} from "@workglow/task-graph";
|
|
8574
|
-
var
|
|
9163
|
+
var inputSchema29 = {
|
|
8575
9164
|
type: "object",
|
|
8576
9165
|
properties: {
|
|
8577
9166
|
value: {
|
|
@@ -8606,13 +9195,13 @@ var outputSchema28 = {
|
|
|
8606
9195
|
additionalProperties: false
|
|
8607
9196
|
};
|
|
8608
9197
|
|
|
8609
|
-
class StringReplaceTask extends
|
|
9198
|
+
class StringReplaceTask extends Task35 {
|
|
8610
9199
|
static type = "StringReplaceTask";
|
|
8611
9200
|
static category = "String";
|
|
8612
9201
|
static title = "Replace";
|
|
8613
9202
|
static description = "Replaces all occurrences of a substring";
|
|
8614
9203
|
static inputSchema() {
|
|
8615
|
-
return
|
|
9204
|
+
return inputSchema29;
|
|
8616
9205
|
}
|
|
8617
9206
|
static outputSchema() {
|
|
8618
9207
|
return outputSchema28;
|
|
@@ -8621,14 +9210,14 @@ class StringReplaceTask extends Task33 {
|
|
|
8621
9210
|
return { result: input2.value.replaceAll(input2.search, input2.replace) };
|
|
8622
9211
|
}
|
|
8623
9212
|
}
|
|
8624
|
-
|
|
9213
|
+
Workflow37.prototype.stringReplace = CreateWorkflow36(StringReplaceTask);
|
|
8625
9214
|
// src/task/string/StringSliceTask.ts
|
|
8626
9215
|
import {
|
|
8627
|
-
CreateWorkflow as
|
|
8628
|
-
Task as
|
|
8629
|
-
Workflow as
|
|
9216
|
+
CreateWorkflow as CreateWorkflow37,
|
|
9217
|
+
Task as Task36,
|
|
9218
|
+
Workflow as Workflow38
|
|
8630
9219
|
} from "@workglow/task-graph";
|
|
8631
|
-
var
|
|
9220
|
+
var inputSchema30 = {
|
|
8632
9221
|
type: "object",
|
|
8633
9222
|
properties: {
|
|
8634
9223
|
value: {
|
|
@@ -8663,13 +9252,13 @@ var outputSchema29 = {
|
|
|
8663
9252
|
additionalProperties: false
|
|
8664
9253
|
};
|
|
8665
9254
|
|
|
8666
|
-
class StringSliceTask extends
|
|
9255
|
+
class StringSliceTask extends Task36 {
|
|
8667
9256
|
static type = "StringSliceTask";
|
|
8668
9257
|
static category = "String";
|
|
8669
9258
|
static title = "Slice";
|
|
8670
9259
|
static description = "Extracts a substring by start and optional end index";
|
|
8671
9260
|
static inputSchema() {
|
|
8672
|
-
return
|
|
9261
|
+
return inputSchema30;
|
|
8673
9262
|
}
|
|
8674
9263
|
static outputSchema() {
|
|
8675
9264
|
return outputSchema29;
|
|
@@ -8678,14 +9267,14 @@ class StringSliceTask extends Task34 {
|
|
|
8678
9267
|
return { result: input2.value.slice(input2.start, input2.end) };
|
|
8679
9268
|
}
|
|
8680
9269
|
}
|
|
8681
|
-
|
|
9270
|
+
Workflow38.prototype.stringSlice = CreateWorkflow37(StringSliceTask);
|
|
8682
9271
|
// src/task/string/StringTemplateTask.ts
|
|
8683
9272
|
import {
|
|
8684
|
-
CreateWorkflow as
|
|
8685
|
-
Task as
|
|
8686
|
-
Workflow as
|
|
9273
|
+
CreateWorkflow as CreateWorkflow38,
|
|
9274
|
+
Task as Task37,
|
|
9275
|
+
Workflow as Workflow39
|
|
8687
9276
|
} from "@workglow/task-graph";
|
|
8688
|
-
var
|
|
9277
|
+
var inputSchema31 = {
|
|
8689
9278
|
type: "object",
|
|
8690
9279
|
properties: {
|
|
8691
9280
|
template: {
|
|
@@ -8716,13 +9305,13 @@ var outputSchema30 = {
|
|
|
8716
9305
|
additionalProperties: false
|
|
8717
9306
|
};
|
|
8718
9307
|
|
|
8719
|
-
class StringTemplateTask extends
|
|
9308
|
+
class StringTemplateTask extends Task37 {
|
|
8720
9309
|
static type = "StringTemplateTask";
|
|
8721
9310
|
static category = "String";
|
|
8722
9311
|
static title = "Template";
|
|
8723
9312
|
static description = "Replaces {{key}} placeholders in a template string with values";
|
|
8724
9313
|
static inputSchema() {
|
|
8725
|
-
return
|
|
9314
|
+
return inputSchema31;
|
|
8726
9315
|
}
|
|
8727
9316
|
static outputSchema() {
|
|
8728
9317
|
return outputSchema30;
|
|
@@ -8735,14 +9324,14 @@ class StringTemplateTask extends Task35 {
|
|
|
8735
9324
|
return { result };
|
|
8736
9325
|
}
|
|
8737
9326
|
}
|
|
8738
|
-
|
|
9327
|
+
Workflow39.prototype.stringTemplate = CreateWorkflow38(StringTemplateTask);
|
|
8739
9328
|
// src/task/string/StringTrimTask.ts
|
|
8740
9329
|
import {
|
|
8741
|
-
CreateWorkflow as
|
|
8742
|
-
Task as
|
|
8743
|
-
Workflow as
|
|
9330
|
+
CreateWorkflow as CreateWorkflow39,
|
|
9331
|
+
Task as Task38,
|
|
9332
|
+
Workflow as Workflow40
|
|
8744
9333
|
} from "@workglow/task-graph";
|
|
8745
|
-
var
|
|
9334
|
+
var inputSchema32 = {
|
|
8746
9335
|
type: "object",
|
|
8747
9336
|
properties: {
|
|
8748
9337
|
value: {
|
|
@@ -8767,13 +9356,13 @@ var outputSchema31 = {
|
|
|
8767
9356
|
additionalProperties: false
|
|
8768
9357
|
};
|
|
8769
9358
|
|
|
8770
|
-
class StringTrimTask extends
|
|
9359
|
+
class StringTrimTask extends Task38 {
|
|
8771
9360
|
static type = "StringTrimTask";
|
|
8772
9361
|
static category = "String";
|
|
8773
9362
|
static title = "Trim";
|
|
8774
9363
|
static description = "Removes leading and trailing whitespace from a string";
|
|
8775
9364
|
static inputSchema() {
|
|
8776
|
-
return
|
|
9365
|
+
return inputSchema32;
|
|
8777
9366
|
}
|
|
8778
9367
|
static outputSchema() {
|
|
8779
9368
|
return outputSchema31;
|
|
@@ -8782,14 +9371,14 @@ class StringTrimTask extends Task36 {
|
|
|
8782
9371
|
return { result: input2.value.trim() };
|
|
8783
9372
|
}
|
|
8784
9373
|
}
|
|
8785
|
-
|
|
9374
|
+
Workflow40.prototype.stringTrim = CreateWorkflow39(StringTrimTask);
|
|
8786
9375
|
// src/task/string/StringUpperCaseTask.ts
|
|
8787
9376
|
import {
|
|
8788
|
-
CreateWorkflow as
|
|
8789
|
-
Task as
|
|
8790
|
-
Workflow as
|
|
9377
|
+
CreateWorkflow as CreateWorkflow40,
|
|
9378
|
+
Task as Task39,
|
|
9379
|
+
Workflow as Workflow41
|
|
8791
9380
|
} from "@workglow/task-graph";
|
|
8792
|
-
var
|
|
9381
|
+
var inputSchema33 = {
|
|
8793
9382
|
type: "object",
|
|
8794
9383
|
properties: {
|
|
8795
9384
|
value: {
|
|
@@ -8814,13 +9403,13 @@ var outputSchema32 = {
|
|
|
8814
9403
|
additionalProperties: false
|
|
8815
9404
|
};
|
|
8816
9405
|
|
|
8817
|
-
class StringUpperCaseTask extends
|
|
9406
|
+
class StringUpperCaseTask extends Task39 {
|
|
8818
9407
|
static type = "StringUpperCaseTask";
|
|
8819
9408
|
static category = "String";
|
|
8820
9409
|
static title = "Upper Case";
|
|
8821
9410
|
static description = "Converts a string to upper case";
|
|
8822
9411
|
static inputSchema() {
|
|
8823
|
-
return
|
|
9412
|
+
return inputSchema33;
|
|
8824
9413
|
}
|
|
8825
9414
|
static outputSchema() {
|
|
8826
9415
|
return outputSchema32;
|
|
@@ -8829,10 +9418,10 @@ class StringUpperCaseTask extends Task37 {
|
|
|
8829
9418
|
return { result: input2.value.toUpperCase() };
|
|
8830
9419
|
}
|
|
8831
9420
|
}
|
|
8832
|
-
|
|
9421
|
+
Workflow41.prototype.stringUpperCase = CreateWorkflow40(StringUpperCaseTask);
|
|
8833
9422
|
// src/task/scalar/ScalarAbsTask.ts
|
|
8834
|
-
import { CreateWorkflow as
|
|
8835
|
-
var
|
|
9423
|
+
import { CreateWorkflow as CreateWorkflow41, Task as Task40, Workflow as Workflow42 } from "@workglow/task-graph";
|
|
9424
|
+
var inputSchema34 = {
|
|
8836
9425
|
type: "object",
|
|
8837
9426
|
properties: {
|
|
8838
9427
|
value: {
|
|
@@ -8857,13 +9446,13 @@ var outputSchema33 = {
|
|
|
8857
9446
|
additionalProperties: false
|
|
8858
9447
|
};
|
|
8859
9448
|
|
|
8860
|
-
class ScalarAbsTask extends
|
|
9449
|
+
class ScalarAbsTask extends Task40 {
|
|
8861
9450
|
static type = "ScalarAbsTask";
|
|
8862
9451
|
static category = "Math";
|
|
8863
9452
|
static title = "Abs";
|
|
8864
9453
|
static description = "Returns the absolute value of a number";
|
|
8865
9454
|
static inputSchema() {
|
|
8866
|
-
return
|
|
9455
|
+
return inputSchema34;
|
|
8867
9456
|
}
|
|
8868
9457
|
static outputSchema() {
|
|
8869
9458
|
return outputSchema33;
|
|
@@ -8872,10 +9461,10 @@ class ScalarAbsTask extends Task38 {
|
|
|
8872
9461
|
return { result: Math.abs(input2.value) };
|
|
8873
9462
|
}
|
|
8874
9463
|
}
|
|
8875
|
-
|
|
9464
|
+
Workflow42.prototype.scalarAbs = CreateWorkflow41(ScalarAbsTask);
|
|
8876
9465
|
// src/task/scalar/ScalarCeilTask.ts
|
|
8877
|
-
import { CreateWorkflow as
|
|
8878
|
-
var
|
|
9466
|
+
import { CreateWorkflow as CreateWorkflow42, Task as Task41, Workflow as Workflow43 } from "@workglow/task-graph";
|
|
9467
|
+
var inputSchema35 = {
|
|
8879
9468
|
type: "object",
|
|
8880
9469
|
properties: {
|
|
8881
9470
|
value: {
|
|
@@ -8900,13 +9489,13 @@ var outputSchema34 = {
|
|
|
8900
9489
|
additionalProperties: false
|
|
8901
9490
|
};
|
|
8902
9491
|
|
|
8903
|
-
class ScalarCeilTask extends
|
|
9492
|
+
class ScalarCeilTask extends Task41 {
|
|
8904
9493
|
static type = "ScalarCeilTask";
|
|
8905
9494
|
static category = "Math";
|
|
8906
9495
|
static title = "Ceil";
|
|
8907
9496
|
static description = "Returns the smallest integer greater than or equal to a number";
|
|
8908
9497
|
static inputSchema() {
|
|
8909
|
-
return
|
|
9498
|
+
return inputSchema35;
|
|
8910
9499
|
}
|
|
8911
9500
|
static outputSchema() {
|
|
8912
9501
|
return outputSchema34;
|
|
@@ -8915,10 +9504,10 @@ class ScalarCeilTask extends Task39 {
|
|
|
8915
9504
|
return { result: Math.ceil(input2.value) };
|
|
8916
9505
|
}
|
|
8917
9506
|
}
|
|
8918
|
-
|
|
9507
|
+
Workflow43.prototype.scalarCeil = CreateWorkflow42(ScalarCeilTask);
|
|
8919
9508
|
// src/task/scalar/ScalarFloorTask.ts
|
|
8920
|
-
import { CreateWorkflow as
|
|
8921
|
-
var
|
|
9509
|
+
import { CreateWorkflow as CreateWorkflow43, Task as Task42, Workflow as Workflow44 } from "@workglow/task-graph";
|
|
9510
|
+
var inputSchema36 = {
|
|
8922
9511
|
type: "object",
|
|
8923
9512
|
properties: {
|
|
8924
9513
|
value: {
|
|
@@ -8943,13 +9532,13 @@ var outputSchema35 = {
|
|
|
8943
9532
|
additionalProperties: false
|
|
8944
9533
|
};
|
|
8945
9534
|
|
|
8946
|
-
class ScalarFloorTask extends
|
|
9535
|
+
class ScalarFloorTask extends Task42 {
|
|
8947
9536
|
static type = "ScalarFloorTask";
|
|
8948
9537
|
static category = "Math";
|
|
8949
9538
|
static title = "Floor";
|
|
8950
9539
|
static description = "Returns the largest integer less than or equal to a number";
|
|
8951
9540
|
static inputSchema() {
|
|
8952
|
-
return
|
|
9541
|
+
return inputSchema36;
|
|
8953
9542
|
}
|
|
8954
9543
|
static outputSchema() {
|
|
8955
9544
|
return outputSchema35;
|
|
@@ -8958,10 +9547,10 @@ class ScalarFloorTask extends Task40 {
|
|
|
8958
9547
|
return { result: Math.floor(input2.value) };
|
|
8959
9548
|
}
|
|
8960
9549
|
}
|
|
8961
|
-
|
|
9550
|
+
Workflow44.prototype.scalarFloor = CreateWorkflow43(ScalarFloorTask);
|
|
8962
9551
|
// src/task/scalar/ScalarMaxTask.ts
|
|
8963
|
-
import { CreateWorkflow as
|
|
8964
|
-
var
|
|
9552
|
+
import { CreateWorkflow as CreateWorkflow44, Task as Task43, Workflow as Workflow45 } from "@workglow/task-graph";
|
|
9553
|
+
var inputSchema37 = {
|
|
8965
9554
|
type: "object",
|
|
8966
9555
|
properties: {
|
|
8967
9556
|
values: {
|
|
@@ -8987,13 +9576,13 @@ var outputSchema36 = {
|
|
|
8987
9576
|
additionalProperties: false
|
|
8988
9577
|
};
|
|
8989
9578
|
|
|
8990
|
-
class ScalarMaxTask extends
|
|
9579
|
+
class ScalarMaxTask extends Task43 {
|
|
8991
9580
|
static type = "ScalarMaxTask";
|
|
8992
9581
|
static category = "Math";
|
|
8993
9582
|
static title = "Max";
|
|
8994
9583
|
static description = "Returns the largest of the given numbers";
|
|
8995
9584
|
static inputSchema() {
|
|
8996
|
-
return
|
|
9585
|
+
return inputSchema37;
|
|
8997
9586
|
}
|
|
8998
9587
|
static outputSchema() {
|
|
8999
9588
|
return outputSchema36;
|
|
@@ -9002,10 +9591,10 @@ class ScalarMaxTask extends Task41 {
|
|
|
9002
9591
|
return { result: Math.max(...input2.values) };
|
|
9003
9592
|
}
|
|
9004
9593
|
}
|
|
9005
|
-
|
|
9594
|
+
Workflow45.prototype.scalarMax = CreateWorkflow44(ScalarMaxTask);
|
|
9006
9595
|
// src/task/scalar/ScalarMinTask.ts
|
|
9007
|
-
import { CreateWorkflow as
|
|
9008
|
-
var
|
|
9596
|
+
import { CreateWorkflow as CreateWorkflow45, Task as Task44, Workflow as Workflow46 } from "@workglow/task-graph";
|
|
9597
|
+
var inputSchema38 = {
|
|
9009
9598
|
type: "object",
|
|
9010
9599
|
properties: {
|
|
9011
9600
|
values: {
|
|
@@ -9031,13 +9620,13 @@ var outputSchema37 = {
|
|
|
9031
9620
|
additionalProperties: false
|
|
9032
9621
|
};
|
|
9033
9622
|
|
|
9034
|
-
class ScalarMinTask extends
|
|
9623
|
+
class ScalarMinTask extends Task44 {
|
|
9035
9624
|
static type = "ScalarMinTask";
|
|
9036
9625
|
static category = "Math";
|
|
9037
9626
|
static title = "Min";
|
|
9038
9627
|
static description = "Returns the smallest of the given numbers";
|
|
9039
9628
|
static inputSchema() {
|
|
9040
|
-
return
|
|
9629
|
+
return inputSchema38;
|
|
9041
9630
|
}
|
|
9042
9631
|
static outputSchema() {
|
|
9043
9632
|
return outputSchema37;
|
|
@@ -9046,10 +9635,10 @@ class ScalarMinTask extends Task42 {
|
|
|
9046
9635
|
return { result: Math.min(...input2.values) };
|
|
9047
9636
|
}
|
|
9048
9637
|
}
|
|
9049
|
-
|
|
9638
|
+
Workflow46.prototype.scalarMin = CreateWorkflow45(ScalarMinTask);
|
|
9050
9639
|
// src/task/scalar/ScalarRoundTask.ts
|
|
9051
|
-
import { CreateWorkflow as
|
|
9052
|
-
var
|
|
9640
|
+
import { CreateWorkflow as CreateWorkflow46, Task as Task45, Workflow as Workflow47 } from "@workglow/task-graph";
|
|
9641
|
+
var inputSchema39 = {
|
|
9053
9642
|
type: "object",
|
|
9054
9643
|
properties: {
|
|
9055
9644
|
value: {
|
|
@@ -9074,13 +9663,13 @@ var outputSchema38 = {
|
|
|
9074
9663
|
additionalProperties: false
|
|
9075
9664
|
};
|
|
9076
9665
|
|
|
9077
|
-
class ScalarRoundTask extends
|
|
9666
|
+
class ScalarRoundTask extends Task45 {
|
|
9078
9667
|
static type = "ScalarRoundTask";
|
|
9079
9668
|
static category = "Math";
|
|
9080
9669
|
static title = "Round";
|
|
9081
9670
|
static description = "Returns the value of a number rounded to the nearest integer";
|
|
9082
9671
|
static inputSchema() {
|
|
9083
|
-
return
|
|
9672
|
+
return inputSchema39;
|
|
9084
9673
|
}
|
|
9085
9674
|
static outputSchema() {
|
|
9086
9675
|
return outputSchema38;
|
|
@@ -9089,10 +9678,10 @@ class ScalarRoundTask extends Task43 {
|
|
|
9089
9678
|
return { result: Math.round(input2.value) };
|
|
9090
9679
|
}
|
|
9091
9680
|
}
|
|
9092
|
-
|
|
9681
|
+
Workflow47.prototype.scalarRound = CreateWorkflow46(ScalarRoundTask);
|
|
9093
9682
|
// src/task/scalar/ScalarTruncTask.ts
|
|
9094
|
-
import { CreateWorkflow as
|
|
9095
|
-
var
|
|
9683
|
+
import { CreateWorkflow as CreateWorkflow47, Task as Task46, Workflow as Workflow48 } from "@workglow/task-graph";
|
|
9684
|
+
var inputSchema40 = {
|
|
9096
9685
|
type: "object",
|
|
9097
9686
|
properties: {
|
|
9098
9687
|
value: {
|
|
@@ -9117,13 +9706,13 @@ var outputSchema39 = {
|
|
|
9117
9706
|
additionalProperties: false
|
|
9118
9707
|
};
|
|
9119
9708
|
|
|
9120
|
-
class ScalarTruncTask extends
|
|
9709
|
+
class ScalarTruncTask extends Task46 {
|
|
9121
9710
|
static type = "ScalarTruncTask";
|
|
9122
9711
|
static category = "Math";
|
|
9123
9712
|
static title = "Truncate";
|
|
9124
9713
|
static description = "Returns the integer part of a number by removing fractional digits";
|
|
9125
9714
|
static inputSchema() {
|
|
9126
|
-
return
|
|
9715
|
+
return inputSchema40;
|
|
9127
9716
|
}
|
|
9128
9717
|
static outputSchema() {
|
|
9129
9718
|
return outputSchema39;
|
|
@@ -9132,13 +9721,13 @@ class ScalarTruncTask extends Task44 {
|
|
|
9132
9721
|
return { result: Math.trunc(input2.value) };
|
|
9133
9722
|
}
|
|
9134
9723
|
}
|
|
9135
|
-
|
|
9724
|
+
Workflow48.prototype.scalarTrunc = CreateWorkflow47(ScalarTruncTask);
|
|
9136
9725
|
// src/task/vector/VectorDistanceTask.ts
|
|
9137
|
-
import { CreateWorkflow as
|
|
9726
|
+
import { CreateWorkflow as CreateWorkflow48, Task as Task47, Workflow as Workflow49 } from "@workglow/task-graph";
|
|
9138
9727
|
import {
|
|
9139
9728
|
TypedArraySchema as TypedArraySchema5
|
|
9140
9729
|
} from "@workglow/util/schema";
|
|
9141
|
-
var
|
|
9730
|
+
var inputSchema41 = {
|
|
9142
9731
|
type: "object",
|
|
9143
9732
|
properties: {
|
|
9144
9733
|
vectors: {
|
|
@@ -9167,13 +9756,13 @@ var outputSchema40 = {
|
|
|
9167
9756
|
additionalProperties: false
|
|
9168
9757
|
};
|
|
9169
9758
|
|
|
9170
|
-
class VectorDistanceTask extends
|
|
9759
|
+
class VectorDistanceTask extends Task47 {
|
|
9171
9760
|
static type = "VectorDistanceTask";
|
|
9172
9761
|
static category = "Vector";
|
|
9173
9762
|
static title = "Distance";
|
|
9174
9763
|
static description = "Returns the Euclidean distance between the first two vectors";
|
|
9175
9764
|
static inputSchema() {
|
|
9176
|
-
return
|
|
9765
|
+
return inputSchema41;
|
|
9177
9766
|
}
|
|
9178
9767
|
static outputSchema() {
|
|
9179
9768
|
return outputSchema40;
|
|
@@ -9194,13 +9783,13 @@ class VectorDistanceTask extends Task45 {
|
|
|
9194
9783
|
return { result: Math.sqrt(sumPrecise(diffs)) };
|
|
9195
9784
|
}
|
|
9196
9785
|
}
|
|
9197
|
-
|
|
9786
|
+
Workflow49.prototype.vectorDistance = CreateWorkflow48(VectorDistanceTask);
|
|
9198
9787
|
// src/task/vector/VectorDotProductTask.ts
|
|
9199
|
-
import { CreateWorkflow as
|
|
9788
|
+
import { CreateWorkflow as CreateWorkflow49, Task as Task48, Workflow as Workflow50 } from "@workglow/task-graph";
|
|
9200
9789
|
import {
|
|
9201
9790
|
TypedArraySchema as TypedArraySchema6
|
|
9202
9791
|
} from "@workglow/util/schema";
|
|
9203
|
-
var
|
|
9792
|
+
var inputSchema42 = {
|
|
9204
9793
|
type: "object",
|
|
9205
9794
|
properties: {
|
|
9206
9795
|
vectors: {
|
|
@@ -9229,13 +9818,13 @@ var outputSchema41 = {
|
|
|
9229
9818
|
additionalProperties: false
|
|
9230
9819
|
};
|
|
9231
9820
|
|
|
9232
|
-
class VectorDotProductTask extends
|
|
9821
|
+
class VectorDotProductTask extends Task48 {
|
|
9233
9822
|
static type = "VectorDotProductTask";
|
|
9234
9823
|
static category = "Vector";
|
|
9235
9824
|
static title = "Dot Product";
|
|
9236
9825
|
static description = "Returns the dot (inner) product of the first two vectors";
|
|
9237
9826
|
static inputSchema() {
|
|
9238
|
-
return
|
|
9827
|
+
return inputSchema42;
|
|
9239
9828
|
}
|
|
9240
9829
|
static outputSchema() {
|
|
9241
9830
|
return outputSchema41;
|
|
@@ -9253,14 +9842,14 @@ class VectorDotProductTask extends Task46 {
|
|
|
9253
9842
|
return { result: sumPrecise(products) };
|
|
9254
9843
|
}
|
|
9255
9844
|
}
|
|
9256
|
-
|
|
9845
|
+
Workflow50.prototype.vectorDotProduct = CreateWorkflow49(VectorDotProductTask);
|
|
9257
9846
|
// src/task/vector/VectorNormalizeTask.ts
|
|
9258
|
-
import { CreateWorkflow as
|
|
9847
|
+
import { CreateWorkflow as CreateWorkflow50, Task as Task49, Workflow as Workflow51 } from "@workglow/task-graph";
|
|
9259
9848
|
import {
|
|
9260
9849
|
TypedArraySchema as TypedArraySchema7,
|
|
9261
9850
|
normalize
|
|
9262
9851
|
} from "@workglow/util/schema";
|
|
9263
|
-
var
|
|
9852
|
+
var inputSchema43 = {
|
|
9264
9853
|
type: "object",
|
|
9265
9854
|
properties: {
|
|
9266
9855
|
vector: TypedArraySchema7({
|
|
@@ -9283,13 +9872,13 @@ var outputSchema42 = {
|
|
|
9283
9872
|
additionalProperties: false
|
|
9284
9873
|
};
|
|
9285
9874
|
|
|
9286
|
-
class VectorNormalizeTask extends
|
|
9875
|
+
class VectorNormalizeTask extends Task49 {
|
|
9287
9876
|
static type = "VectorNormalizeTask";
|
|
9288
9877
|
static category = "Vector";
|
|
9289
9878
|
static title = "Normalize";
|
|
9290
9879
|
static description = "Returns the L2-normalized (unit length) vector";
|
|
9291
9880
|
static inputSchema() {
|
|
9292
|
-
return
|
|
9881
|
+
return inputSchema43;
|
|
9293
9882
|
}
|
|
9294
9883
|
static outputSchema() {
|
|
9295
9884
|
return outputSchema42;
|
|
@@ -9298,14 +9887,14 @@ class VectorNormalizeTask extends Task47 {
|
|
|
9298
9887
|
return { result: normalize(input2.vector) };
|
|
9299
9888
|
}
|
|
9300
9889
|
}
|
|
9301
|
-
|
|
9890
|
+
Workflow51.prototype.vectorNormalize = CreateWorkflow50(VectorNormalizeTask);
|
|
9302
9891
|
// src/task/vector/VectorScaleTask.ts
|
|
9303
|
-
import { CreateWorkflow as
|
|
9892
|
+
import { CreateWorkflow as CreateWorkflow51, Task as Task50, Workflow as Workflow52 } from "@workglow/task-graph";
|
|
9304
9893
|
import {
|
|
9305
9894
|
createTypedArrayFrom as createTypedArrayFrom5,
|
|
9306
9895
|
TypedArraySchema as TypedArraySchema8
|
|
9307
9896
|
} from "@workglow/util/schema";
|
|
9308
|
-
var
|
|
9897
|
+
var inputSchema44 = {
|
|
9309
9898
|
type: "object",
|
|
9310
9899
|
properties: {
|
|
9311
9900
|
vector: TypedArraySchema8({
|
|
@@ -9333,13 +9922,13 @@ var outputSchema43 = {
|
|
|
9333
9922
|
additionalProperties: false
|
|
9334
9923
|
};
|
|
9335
9924
|
|
|
9336
|
-
class VectorScaleTask extends
|
|
9925
|
+
class VectorScaleTask extends Task50 {
|
|
9337
9926
|
static type = "VectorScaleTask";
|
|
9338
9927
|
static category = "Vector";
|
|
9339
9928
|
static title = "Scale";
|
|
9340
9929
|
static description = "Multiplies each element of a vector by a scalar";
|
|
9341
9930
|
static inputSchema() {
|
|
9342
|
-
return
|
|
9931
|
+
return inputSchema44;
|
|
9343
9932
|
}
|
|
9344
9933
|
static outputSchema() {
|
|
9345
9934
|
return outputSchema43;
|
|
@@ -9350,7 +9939,1224 @@ class VectorScaleTask extends Task48 {
|
|
|
9350
9939
|
return { result: createTypedArrayFrom5([vector], values) };
|
|
9351
9940
|
}
|
|
9352
9941
|
}
|
|
9353
|
-
|
|
9942
|
+
Workflow52.prototype.vectorScale = CreateWorkflow51(VectorScaleTask);
|
|
9943
|
+
// src/task/image/ImageSchemas.ts
|
|
9944
|
+
import { FromSchemaDefaultOptions } from "@workglow/util/schema";
|
|
9945
|
+
var ImageBinaryType = null;
|
|
9946
|
+
var ImageBinarySchemaOptions = {
|
|
9947
|
+
...FromSchemaDefaultOptions,
|
|
9948
|
+
deserialize: [
|
|
9949
|
+
{
|
|
9950
|
+
pattern: { type: "object", format: "image:ImageBinary" },
|
|
9951
|
+
output: ImageBinaryType
|
|
9952
|
+
}
|
|
9953
|
+
]
|
|
9954
|
+
};
|
|
9955
|
+
var ImageBinarySchema = (annotations = {}) => ({
|
|
9956
|
+
type: "object",
|
|
9957
|
+
properties: {
|
|
9958
|
+
data: {
|
|
9959
|
+
type: "array",
|
|
9960
|
+
items: { type: "number", format: "Uint8Clamped" },
|
|
9961
|
+
format: "Uint8ClampedArray",
|
|
9962
|
+
title: "Data",
|
|
9963
|
+
description: "Pixel data of the image"
|
|
9964
|
+
},
|
|
9965
|
+
width: {
|
|
9966
|
+
type: "integer",
|
|
9967
|
+
minimum: 1,
|
|
9968
|
+
title: "Width",
|
|
9969
|
+
description: "Width in pixels"
|
|
9970
|
+
},
|
|
9971
|
+
height: {
|
|
9972
|
+
type: "integer",
|
|
9973
|
+
minimum: 1,
|
|
9974
|
+
title: "Height",
|
|
9975
|
+
description: "Height in pixels"
|
|
9976
|
+
},
|
|
9977
|
+
channels: {
|
|
9978
|
+
type: "integer",
|
|
9979
|
+
enum: [1, 3, 4],
|
|
9980
|
+
title: "Channels",
|
|
9981
|
+
description: "1 (gray), 3 (RGB), or 4 (RGBA)"
|
|
9982
|
+
}
|
|
9983
|
+
},
|
|
9984
|
+
additionalProperties: false,
|
|
9985
|
+
required: ["data", "width", "height", "channels"],
|
|
9986
|
+
format: "image:ImageBinary",
|
|
9987
|
+
title: "Image",
|
|
9988
|
+
description: "Raw pixel image data",
|
|
9989
|
+
...annotations
|
|
9990
|
+
});
|
|
9991
|
+
var ColorSchema = (annotations = {}) => ({
|
|
9992
|
+
type: "object",
|
|
9993
|
+
properties: {
|
|
9994
|
+
r: { type: "integer", minimum: 0, maximum: 255, title: "Red" },
|
|
9995
|
+
g: { type: "integer", minimum: 0, maximum: 255, title: "Green" },
|
|
9996
|
+
b: { type: "integer", minimum: 0, maximum: 255, title: "Blue" },
|
|
9997
|
+
a: { type: "integer", minimum: 0, maximum: 255, title: "Alpha", default: 255 }
|
|
9998
|
+
},
|
|
9999
|
+
required: ["r", "g", "b"],
|
|
10000
|
+
additionalProperties: false,
|
|
10001
|
+
...annotations
|
|
10002
|
+
});
|
|
10003
|
+
// src/task/image/ImageResizeTask.ts
|
|
10004
|
+
import {
|
|
10005
|
+
CreateWorkflow as CreateWorkflow52,
|
|
10006
|
+
Task as Task51,
|
|
10007
|
+
Workflow as Workflow53
|
|
10008
|
+
} from "@workglow/task-graph";
|
|
10009
|
+
var inputSchema45 = {
|
|
10010
|
+
type: "object",
|
|
10011
|
+
properties: {
|
|
10012
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10013
|
+
width: { type: "integer", title: "Width", description: "Target width in pixels", minimum: 1 },
|
|
10014
|
+
height: {
|
|
10015
|
+
type: "integer",
|
|
10016
|
+
title: "Height",
|
|
10017
|
+
description: "Target height in pixels",
|
|
10018
|
+
minimum: 1
|
|
10019
|
+
}
|
|
10020
|
+
},
|
|
10021
|
+
required: ["image", "width", "height"],
|
|
10022
|
+
additionalProperties: false
|
|
10023
|
+
};
|
|
10024
|
+
var outputSchema44 = {
|
|
10025
|
+
type: "object",
|
|
10026
|
+
properties: {
|
|
10027
|
+
image: ImageBinarySchema({ title: "Image", description: "Resized image" })
|
|
10028
|
+
},
|
|
10029
|
+
required: ["image"],
|
|
10030
|
+
additionalProperties: false
|
|
10031
|
+
};
|
|
10032
|
+
|
|
10033
|
+
class ImageResizeTask extends Task51 {
|
|
10034
|
+
static type = "ImageResizeTask";
|
|
10035
|
+
static category = "Image";
|
|
10036
|
+
static title = "Resize Image";
|
|
10037
|
+
static description = "Resizes an image using nearest-neighbor sampling";
|
|
10038
|
+
static inputSchema() {
|
|
10039
|
+
return inputSchema45;
|
|
10040
|
+
}
|
|
10041
|
+
static outputSchema() {
|
|
10042
|
+
return outputSchema44;
|
|
10043
|
+
}
|
|
10044
|
+
async executeReactive(input2, _output, _context) {
|
|
10045
|
+
const { image, width: dstW, height: dstH } = input2;
|
|
10046
|
+
const { data: src, width: srcW, height: srcH, channels } = image;
|
|
10047
|
+
const dst = new Uint8ClampedArray(dstW * dstH * channels);
|
|
10048
|
+
for (let dy = 0;dy < dstH; dy++) {
|
|
10049
|
+
const srcY = Math.min(Math.floor(dy * srcH / dstH), srcH - 1);
|
|
10050
|
+
for (let dx = 0;dx < dstW; dx++) {
|
|
10051
|
+
const srcX = Math.min(Math.floor(dx * srcW / dstW), srcW - 1);
|
|
10052
|
+
const srcIdx = (srcY * srcW + srcX) * channels;
|
|
10053
|
+
const dstIdx = (dy * dstW + dx) * channels;
|
|
10054
|
+
for (let c = 0;c < channels; c++) {
|
|
10055
|
+
dst[dstIdx + c] = src[srcIdx + c];
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10058
|
+
}
|
|
10059
|
+
return {
|
|
10060
|
+
image: { data: dst, width: dstW, height: dstH, channels }
|
|
10061
|
+
};
|
|
10062
|
+
}
|
|
10063
|
+
}
|
|
10064
|
+
Workflow53.prototype.imageResize = CreateWorkflow52(ImageResizeTask);
|
|
10065
|
+
// src/task/image/ImageCropTask.ts
|
|
10066
|
+
import {
|
|
10067
|
+
CreateWorkflow as CreateWorkflow53,
|
|
10068
|
+
Task as Task52,
|
|
10069
|
+
Workflow as Workflow54
|
|
10070
|
+
} from "@workglow/task-graph";
|
|
10071
|
+
var inputSchema46 = {
|
|
10072
|
+
type: "object",
|
|
10073
|
+
properties: {
|
|
10074
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10075
|
+
x: { type: "integer", title: "X", description: "Left offset", minimum: 0 },
|
|
10076
|
+
y: { type: "integer", title: "Y", description: "Top offset", minimum: 0 },
|
|
10077
|
+
width: { type: "integer", title: "Width", description: "Crop width", minimum: 1 },
|
|
10078
|
+
height: { type: "integer", title: "Height", description: "Crop height", minimum: 1 }
|
|
10079
|
+
},
|
|
10080
|
+
required: ["image", "x", "y", "width", "height"],
|
|
10081
|
+
additionalProperties: false
|
|
10082
|
+
};
|
|
10083
|
+
var outputSchema45 = {
|
|
10084
|
+
type: "object",
|
|
10085
|
+
properties: {
|
|
10086
|
+
image: ImageBinarySchema({ title: "Image", description: "Cropped image" })
|
|
10087
|
+
},
|
|
10088
|
+
required: ["image"],
|
|
10089
|
+
additionalProperties: false
|
|
10090
|
+
};
|
|
10091
|
+
|
|
10092
|
+
class ImageCropTask extends Task52 {
|
|
10093
|
+
static type = "ImageCropTask";
|
|
10094
|
+
static category = "Image";
|
|
10095
|
+
static title = "Crop Image";
|
|
10096
|
+
static description = "Crops an image to a rectangular region";
|
|
10097
|
+
static inputSchema() {
|
|
10098
|
+
return inputSchema46;
|
|
10099
|
+
}
|
|
10100
|
+
static outputSchema() {
|
|
10101
|
+
return outputSchema45;
|
|
10102
|
+
}
|
|
10103
|
+
async executeReactive(input2, _output, _context) {
|
|
10104
|
+
const { image, x: rawX, y: rawY, width: rawW, height: rawH } = input2;
|
|
10105
|
+
const { data: src, width: srcW, height: srcH, channels } = image;
|
|
10106
|
+
if (srcW < 1 || srcH < 1) {
|
|
10107
|
+
throw new RangeError("Cannot crop an empty image");
|
|
10108
|
+
}
|
|
10109
|
+
if (rawX < 0 || rawX >= srcW || rawY < 0 || rawY >= srcH) {
|
|
10110
|
+
throw new RangeError("Crop origin is outside the source image bounds");
|
|
10111
|
+
}
|
|
10112
|
+
const x = rawX;
|
|
10113
|
+
const y = rawY;
|
|
10114
|
+
const w = Math.min(rawW, srcW - x);
|
|
10115
|
+
const h = Math.min(rawH, srcH - y);
|
|
10116
|
+
const dst = new Uint8ClampedArray(w * h * channels);
|
|
10117
|
+
const rowBytes = w * channels;
|
|
10118
|
+
for (let row = 0;row < h; row++) {
|
|
10119
|
+
const srcOffset = ((y + row) * srcW + x) * channels;
|
|
10120
|
+
const dstOffset = row * rowBytes;
|
|
10121
|
+
dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
|
|
10122
|
+
}
|
|
10123
|
+
return { image: { data: dst, width: w, height: h, channels } };
|
|
10124
|
+
}
|
|
10125
|
+
}
|
|
10126
|
+
Workflow54.prototype.imageCrop = CreateWorkflow53(ImageCropTask);
|
|
10127
|
+
// src/task/image/ImageRotateTask.ts
|
|
10128
|
+
import {
|
|
10129
|
+
CreateWorkflow as CreateWorkflow54,
|
|
10130
|
+
Task as Task53,
|
|
10131
|
+
Workflow as Workflow55
|
|
10132
|
+
} from "@workglow/task-graph";
|
|
10133
|
+
var inputSchema47 = {
|
|
10134
|
+
type: "object",
|
|
10135
|
+
properties: {
|
|
10136
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10137
|
+
angle: {
|
|
10138
|
+
type: "integer",
|
|
10139
|
+
enum: [90, 180, 270],
|
|
10140
|
+
title: "Angle",
|
|
10141
|
+
description: "Rotation angle in degrees (clockwise)"
|
|
10142
|
+
}
|
|
10143
|
+
},
|
|
10144
|
+
required: ["image", "angle"],
|
|
10145
|
+
additionalProperties: false
|
|
10146
|
+
};
|
|
10147
|
+
var outputSchema46 = {
|
|
10148
|
+
type: "object",
|
|
10149
|
+
properties: {
|
|
10150
|
+
image: ImageBinarySchema({ title: "Image", description: "Rotated image" })
|
|
10151
|
+
},
|
|
10152
|
+
required: ["image"],
|
|
10153
|
+
additionalProperties: false
|
|
10154
|
+
};
|
|
10155
|
+
|
|
10156
|
+
class ImageRotateTask extends Task53 {
|
|
10157
|
+
static type = "ImageRotateTask";
|
|
10158
|
+
static category = "Image";
|
|
10159
|
+
static title = "Rotate Image";
|
|
10160
|
+
static description = "Rotates an image by 90, 180, or 270 degrees clockwise";
|
|
10161
|
+
static inputSchema() {
|
|
10162
|
+
return inputSchema47;
|
|
10163
|
+
}
|
|
10164
|
+
static outputSchema() {
|
|
10165
|
+
return outputSchema46;
|
|
10166
|
+
}
|
|
10167
|
+
async executeReactive(input2, _output, _context) {
|
|
10168
|
+
const { image, angle } = input2;
|
|
10169
|
+
const { data: src, width: srcW, height: srcH, channels } = image;
|
|
10170
|
+
const swap = angle === 90 || angle === 270;
|
|
10171
|
+
const dstW = swap ? srcH : srcW;
|
|
10172
|
+
const dstH = swap ? srcW : srcH;
|
|
10173
|
+
const dst = new Uint8ClampedArray(dstW * dstH * channels);
|
|
10174
|
+
for (let sy = 0;sy < srcH; sy++) {
|
|
10175
|
+
for (let sx = 0;sx < srcW; sx++) {
|
|
10176
|
+
let dx, dy;
|
|
10177
|
+
if (angle === 90) {
|
|
10178
|
+
dx = srcH - 1 - sy;
|
|
10179
|
+
dy = sx;
|
|
10180
|
+
} else if (angle === 180) {
|
|
10181
|
+
dx = srcW - 1 - sx;
|
|
10182
|
+
dy = srcH - 1 - sy;
|
|
10183
|
+
} else {
|
|
10184
|
+
dx = sy;
|
|
10185
|
+
dy = srcW - 1 - sx;
|
|
10186
|
+
}
|
|
10187
|
+
const srcIdx = (sy * srcW + sx) * channels;
|
|
10188
|
+
const dstIdx = (dy * dstW + dx) * channels;
|
|
10189
|
+
for (let c = 0;c < channels; c++) {
|
|
10190
|
+
dst[dstIdx + c] = src[srcIdx + c];
|
|
10191
|
+
}
|
|
10192
|
+
}
|
|
10193
|
+
}
|
|
10194
|
+
return {
|
|
10195
|
+
image: { data: dst, width: dstW, height: dstH, channels }
|
|
10196
|
+
};
|
|
10197
|
+
}
|
|
10198
|
+
}
|
|
10199
|
+
Workflow55.prototype.imageRotate = CreateWorkflow54(ImageRotateTask);
|
|
10200
|
+
// src/task/image/ImageFlipTask.ts
|
|
10201
|
+
import {
|
|
10202
|
+
CreateWorkflow as CreateWorkflow55,
|
|
10203
|
+
Task as Task54,
|
|
10204
|
+
Workflow as Workflow56
|
|
10205
|
+
} from "@workglow/task-graph";
|
|
10206
|
+
var inputSchema48 = {
|
|
10207
|
+
type: "object",
|
|
10208
|
+
properties: {
|
|
10209
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10210
|
+
direction: {
|
|
10211
|
+
type: "string",
|
|
10212
|
+
enum: ["horizontal", "vertical"],
|
|
10213
|
+
title: "Direction",
|
|
10214
|
+
description: "Flip direction"
|
|
10215
|
+
}
|
|
10216
|
+
},
|
|
10217
|
+
required: ["image", "direction"],
|
|
10218
|
+
additionalProperties: false
|
|
10219
|
+
};
|
|
10220
|
+
var outputSchema47 = {
|
|
10221
|
+
type: "object",
|
|
10222
|
+
properties: {
|
|
10223
|
+
image: ImageBinarySchema({ title: "Image", description: "Flipped image" })
|
|
10224
|
+
},
|
|
10225
|
+
required: ["image"],
|
|
10226
|
+
additionalProperties: false
|
|
10227
|
+
};
|
|
10228
|
+
|
|
10229
|
+
class ImageFlipTask extends Task54 {
|
|
10230
|
+
static type = "ImageFlipTask";
|
|
10231
|
+
static category = "Image";
|
|
10232
|
+
static title = "Flip Image";
|
|
10233
|
+
static description = "Flips an image horizontally or vertically";
|
|
10234
|
+
static inputSchema() {
|
|
10235
|
+
return inputSchema48;
|
|
10236
|
+
}
|
|
10237
|
+
static outputSchema() {
|
|
10238
|
+
return outputSchema47;
|
|
10239
|
+
}
|
|
10240
|
+
async executeReactive(input2, _output, _context) {
|
|
10241
|
+
const { image, direction } = input2;
|
|
10242
|
+
const { data: src, width, height, channels } = image;
|
|
10243
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10244
|
+
const rowBytes = width * channels;
|
|
10245
|
+
if (direction === "vertical") {
|
|
10246
|
+
for (let y = 0;y < height; y++) {
|
|
10247
|
+
const srcOffset = y * rowBytes;
|
|
10248
|
+
const dstOffset = (height - 1 - y) * rowBytes;
|
|
10249
|
+
dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
|
|
10250
|
+
}
|
|
10251
|
+
} else {
|
|
10252
|
+
for (let y = 0;y < height; y++) {
|
|
10253
|
+
for (let x = 0;x < width; x++) {
|
|
10254
|
+
const srcIdx = (y * width + x) * channels;
|
|
10255
|
+
const dstIdx = (y * width + (width - 1 - x)) * channels;
|
|
10256
|
+
for (let c = 0;c < channels; c++) {
|
|
10257
|
+
dst[dstIdx + c] = src[srcIdx + c];
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
10260
|
+
}
|
|
10261
|
+
}
|
|
10262
|
+
return { image: { data: dst, width, height, channels } };
|
|
10263
|
+
}
|
|
10264
|
+
}
|
|
10265
|
+
Workflow56.prototype.imageFlip = CreateWorkflow55(ImageFlipTask);
|
|
10266
|
+
// src/task/image/ImageGrayscaleTask.ts
|
|
10267
|
+
import {
|
|
10268
|
+
CreateWorkflow as CreateWorkflow56,
|
|
10269
|
+
Task as Task55,
|
|
10270
|
+
Workflow as Workflow57
|
|
10271
|
+
} from "@workglow/task-graph";
|
|
10272
|
+
var inputSchema49 = {
|
|
10273
|
+
type: "object",
|
|
10274
|
+
properties: {
|
|
10275
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" })
|
|
10276
|
+
},
|
|
10277
|
+
required: ["image"],
|
|
10278
|
+
additionalProperties: false
|
|
10279
|
+
};
|
|
10280
|
+
var outputSchema48 = {
|
|
10281
|
+
type: "object",
|
|
10282
|
+
properties: {
|
|
10283
|
+
image: ImageBinarySchema({ title: "Image", description: "Grayscale image" })
|
|
10284
|
+
},
|
|
10285
|
+
required: ["image"],
|
|
10286
|
+
additionalProperties: false
|
|
10287
|
+
};
|
|
10288
|
+
|
|
10289
|
+
class ImageGrayscaleTask extends Task55 {
|
|
10290
|
+
static type = "ImageGrayscaleTask";
|
|
10291
|
+
static category = "Image";
|
|
10292
|
+
static title = "Grayscale";
|
|
10293
|
+
static description = "Converts an image to grayscale using luminance";
|
|
10294
|
+
static inputSchema() {
|
|
10295
|
+
return inputSchema49;
|
|
10296
|
+
}
|
|
10297
|
+
static outputSchema() {
|
|
10298
|
+
return outputSchema48;
|
|
10299
|
+
}
|
|
10300
|
+
async executeReactive(input2, _output, _context) {
|
|
10301
|
+
const { data: src, width, height, channels } = input2.image;
|
|
10302
|
+
if (channels === 1) {
|
|
10303
|
+
return { image: { data: new Uint8ClampedArray(src), width, height, channels: 1 } };
|
|
10304
|
+
}
|
|
10305
|
+
const pixelCount = width * height;
|
|
10306
|
+
const dst = new Uint8ClampedArray(pixelCount);
|
|
10307
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
10308
|
+
const idx = i * channels;
|
|
10309
|
+
dst[i] = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
|
|
10310
|
+
}
|
|
10311
|
+
return { image: { data: dst, width, height, channels: 1 } };
|
|
10312
|
+
}
|
|
10313
|
+
}
|
|
10314
|
+
Workflow57.prototype.imageGrayscale = CreateWorkflow56(ImageGrayscaleTask);
|
|
10315
|
+
// src/task/image/ImageBorderTask.ts
|
|
10316
|
+
import {
|
|
10317
|
+
CreateWorkflow as CreateWorkflow57,
|
|
10318
|
+
Task as Task56,
|
|
10319
|
+
Workflow as Workflow58
|
|
10320
|
+
} from "@workglow/task-graph";
|
|
10321
|
+
var inputSchema50 = {
|
|
10322
|
+
type: "object",
|
|
10323
|
+
properties: {
|
|
10324
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10325
|
+
borderWidth: {
|
|
10326
|
+
type: "integer",
|
|
10327
|
+
title: "Border Width",
|
|
10328
|
+
description: "Border width in pixels",
|
|
10329
|
+
minimum: 1,
|
|
10330
|
+
default: 1
|
|
10331
|
+
},
|
|
10332
|
+
color: ColorSchema({ title: "Color", description: "Border color" })
|
|
10333
|
+
},
|
|
10334
|
+
required: ["image", "color"],
|
|
10335
|
+
additionalProperties: false
|
|
10336
|
+
};
|
|
10337
|
+
var outputSchema49 = {
|
|
10338
|
+
type: "object",
|
|
10339
|
+
properties: {
|
|
10340
|
+
image: ImageBinarySchema({ title: "Image", description: "Image with border" })
|
|
10341
|
+
},
|
|
10342
|
+
required: ["image"],
|
|
10343
|
+
additionalProperties: false
|
|
10344
|
+
};
|
|
10345
|
+
|
|
10346
|
+
class ImageBorderTask extends Task56 {
|
|
10347
|
+
static type = "ImageBorderTask";
|
|
10348
|
+
static category = "Image";
|
|
10349
|
+
static title = "Add Border";
|
|
10350
|
+
static description = "Adds a colored border around an image";
|
|
10351
|
+
static inputSchema() {
|
|
10352
|
+
return inputSchema50;
|
|
10353
|
+
}
|
|
10354
|
+
static outputSchema() {
|
|
10355
|
+
return outputSchema49;
|
|
10356
|
+
}
|
|
10357
|
+
async executeReactive(input2, _output, _context) {
|
|
10358
|
+
const { image, borderWidth: bw = 1, color } = input2;
|
|
10359
|
+
const { data: src, width: srcW, height: srcH, channels: srcCh } = image;
|
|
10360
|
+
const outCh = 4;
|
|
10361
|
+
const dstW = srcW + bw * 2;
|
|
10362
|
+
const dstH = srcH + bw * 2;
|
|
10363
|
+
const dst = new Uint8ClampedArray(dstW * dstH * outCh);
|
|
10364
|
+
const r = color.r;
|
|
10365
|
+
const g = color.g;
|
|
10366
|
+
const b = color.b;
|
|
10367
|
+
const a = color.a ?? 255;
|
|
10368
|
+
for (let i = 0;i < dst.length; i += outCh) {
|
|
10369
|
+
dst[i] = r;
|
|
10370
|
+
dst[i + 1] = g;
|
|
10371
|
+
dst[i + 2] = b;
|
|
10372
|
+
dst[i + 3] = a;
|
|
10373
|
+
}
|
|
10374
|
+
for (let y = 0;y < srcH; y++) {
|
|
10375
|
+
for (let x = 0;x < srcW; x++) {
|
|
10376
|
+
const srcIdx = (y * srcW + x) * srcCh;
|
|
10377
|
+
const dstIdx = ((y + bw) * dstW + (x + bw)) * outCh;
|
|
10378
|
+
dst[dstIdx] = src[srcIdx];
|
|
10379
|
+
dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
|
|
10380
|
+
dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
|
|
10381
|
+
dst[dstIdx + 3] = srcCh === 4 ? src[srcIdx + 3] : 255;
|
|
10382
|
+
}
|
|
10383
|
+
}
|
|
10384
|
+
return {
|
|
10385
|
+
image: { data: dst, width: dstW, height: dstH, channels: outCh }
|
|
10386
|
+
};
|
|
10387
|
+
}
|
|
10388
|
+
}
|
|
10389
|
+
Workflow58.prototype.imageBorder = CreateWorkflow57(ImageBorderTask);
|
|
10390
|
+
// src/task/image/ImageTransparencyTask.ts
|
|
10391
|
+
import {
|
|
10392
|
+
CreateWorkflow as CreateWorkflow58,
|
|
10393
|
+
Task as Task57,
|
|
10394
|
+
Workflow as Workflow59
|
|
10395
|
+
} from "@workglow/task-graph";
|
|
10396
|
+
var inputSchema51 = {
|
|
10397
|
+
type: "object",
|
|
10398
|
+
properties: {
|
|
10399
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10400
|
+
opacity: {
|
|
10401
|
+
type: "number",
|
|
10402
|
+
title: "Opacity",
|
|
10403
|
+
description: "Opacity level (0.0 = fully transparent, 1.0 = fully opaque)",
|
|
10404
|
+
minimum: 0,
|
|
10405
|
+
maximum: 1
|
|
10406
|
+
}
|
|
10407
|
+
},
|
|
10408
|
+
required: ["image", "opacity"],
|
|
10409
|
+
additionalProperties: false
|
|
10410
|
+
};
|
|
10411
|
+
var outputSchema50 = {
|
|
10412
|
+
type: "object",
|
|
10413
|
+
properties: {
|
|
10414
|
+
image: ImageBinarySchema({ title: "Image", description: "Image with adjusted transparency" })
|
|
10415
|
+
},
|
|
10416
|
+
required: ["image"],
|
|
10417
|
+
additionalProperties: false
|
|
10418
|
+
};
|
|
10419
|
+
|
|
10420
|
+
class ImageTransparencyTask extends Task57 {
|
|
10421
|
+
static type = "ImageTransparencyTask";
|
|
10422
|
+
static category = "Image";
|
|
10423
|
+
static title = "Set Transparency";
|
|
10424
|
+
static description = "Adjusts the opacity of an image";
|
|
10425
|
+
static inputSchema() {
|
|
10426
|
+
return inputSchema51;
|
|
10427
|
+
}
|
|
10428
|
+
static outputSchema() {
|
|
10429
|
+
return outputSchema50;
|
|
10430
|
+
}
|
|
10431
|
+
async executeReactive(input2, _output, _context) {
|
|
10432
|
+
const { image, opacity } = input2;
|
|
10433
|
+
const { data: src, width, height, channels: srcCh } = image;
|
|
10434
|
+
const pixelCount = width * height;
|
|
10435
|
+
const dst = new Uint8ClampedArray(pixelCount * 4);
|
|
10436
|
+
const alphaScale = Math.round(opacity * 255);
|
|
10437
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
10438
|
+
const srcIdx = i * srcCh;
|
|
10439
|
+
const dstIdx = i * 4;
|
|
10440
|
+
dst[dstIdx] = src[srcIdx];
|
|
10441
|
+
dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
|
|
10442
|
+
dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
|
|
10443
|
+
const srcAlpha = srcCh === 4 ? src[srcIdx + 3] : 255;
|
|
10444
|
+
dst[dstIdx + 3] = (srcAlpha * alphaScale + 127) / 255;
|
|
10445
|
+
}
|
|
10446
|
+
return {
|
|
10447
|
+
image: { data: dst, width, height, channels: 4 }
|
|
10448
|
+
};
|
|
10449
|
+
}
|
|
10450
|
+
}
|
|
10451
|
+
Workflow59.prototype.imageTransparency = CreateWorkflow58(ImageTransparencyTask);
|
|
10452
|
+
// src/task/image/ImageBlurTask.ts
|
|
10453
|
+
import {
|
|
10454
|
+
CreateWorkflow as CreateWorkflow59,
|
|
10455
|
+
Task as Task58,
|
|
10456
|
+
Workflow as Workflow60
|
|
10457
|
+
} from "@workglow/task-graph";
|
|
10458
|
+
var inputSchema52 = {
|
|
10459
|
+
type: "object",
|
|
10460
|
+
properties: {
|
|
10461
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10462
|
+
radius: {
|
|
10463
|
+
type: "integer",
|
|
10464
|
+
title: "Radius",
|
|
10465
|
+
description: "Blur radius (1-10)",
|
|
10466
|
+
minimum: 1,
|
|
10467
|
+
maximum: 10,
|
|
10468
|
+
default: 1
|
|
10469
|
+
}
|
|
10470
|
+
},
|
|
10471
|
+
required: ["image"],
|
|
10472
|
+
additionalProperties: false
|
|
10473
|
+
};
|
|
10474
|
+
var outputSchema51 = {
|
|
10475
|
+
type: "object",
|
|
10476
|
+
properties: {
|
|
10477
|
+
image: ImageBinarySchema({ title: "Image", description: "Blurred image" })
|
|
10478
|
+
},
|
|
10479
|
+
required: ["image"],
|
|
10480
|
+
additionalProperties: false
|
|
10481
|
+
};
|
|
10482
|
+
|
|
10483
|
+
class ImageBlurTask extends Task58 {
|
|
10484
|
+
static type = "ImageBlurTask";
|
|
10485
|
+
static category = "Image";
|
|
10486
|
+
static title = "Blur Image";
|
|
10487
|
+
static description = "Applies a box blur to an image";
|
|
10488
|
+
static inputSchema() {
|
|
10489
|
+
return inputSchema52;
|
|
10490
|
+
}
|
|
10491
|
+
static outputSchema() {
|
|
10492
|
+
return outputSchema51;
|
|
10493
|
+
}
|
|
10494
|
+
async executeReactive(input2, _output, _context) {
|
|
10495
|
+
const { image, radius = 1 } = input2;
|
|
10496
|
+
const { data: src, width, height, channels } = image;
|
|
10497
|
+
const kernelSize = radius * 2 + 1;
|
|
10498
|
+
const tmp = new Uint8ClampedArray(src.length);
|
|
10499
|
+
for (let y = 0;y < height; y++) {
|
|
10500
|
+
for (let c = 0;c < channels; c++) {
|
|
10501
|
+
let sum = 0;
|
|
10502
|
+
for (let k = -radius;k <= radius; k++) {
|
|
10503
|
+
const x = Math.max(0, Math.min(k, width - 1));
|
|
10504
|
+
sum += src[(y * width + x) * channels + c];
|
|
10505
|
+
}
|
|
10506
|
+
tmp[y * width * channels + c] = sum / kernelSize + 0.5 | 0;
|
|
10507
|
+
for (let x = 1;x < width; x++) {
|
|
10508
|
+
const addX = Math.min(x + radius, width - 1);
|
|
10509
|
+
const removeX = Math.max(x - radius - 1, 0);
|
|
10510
|
+
sum += src[(y * width + addX) * channels + c] - src[(y * width + removeX) * channels + c];
|
|
10511
|
+
tmp[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
|
|
10512
|
+
}
|
|
10513
|
+
}
|
|
10514
|
+
}
|
|
10515
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10516
|
+
for (let x = 0;x < width; x++) {
|
|
10517
|
+
for (let c = 0;c < channels; c++) {
|
|
10518
|
+
let sum = 0;
|
|
10519
|
+
for (let k = -radius;k <= radius; k++) {
|
|
10520
|
+
const y = Math.max(0, Math.min(k, height - 1));
|
|
10521
|
+
sum += tmp[(y * width + x) * channels + c];
|
|
10522
|
+
}
|
|
10523
|
+
dst[x * channels + c] = sum / kernelSize + 0.5 | 0;
|
|
10524
|
+
for (let y = 1;y < height; y++) {
|
|
10525
|
+
const addY = Math.min(y + radius, height - 1);
|
|
10526
|
+
const removeY = Math.max(y - radius - 1, 0);
|
|
10527
|
+
sum += tmp[(addY * width + x) * channels + c] - tmp[(removeY * width + x) * channels + c];
|
|
10528
|
+
dst[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
|
|
10529
|
+
}
|
|
10530
|
+
}
|
|
10531
|
+
}
|
|
10532
|
+
return { image: { data: dst, width, height, channels } };
|
|
10533
|
+
}
|
|
10534
|
+
}
|
|
10535
|
+
Workflow60.prototype.imageBlur = CreateWorkflow59(ImageBlurTask);
|
|
10536
|
+
// src/task/image/ImageWatermarkTask.ts
|
|
10537
|
+
import {
|
|
10538
|
+
CreateWorkflow as CreateWorkflow60,
|
|
10539
|
+
Task as Task59,
|
|
10540
|
+
Workflow as Workflow61
|
|
10541
|
+
} from "@workglow/task-graph";
|
|
10542
|
+
var inputSchema53 = {
|
|
10543
|
+
type: "object",
|
|
10544
|
+
properties: {
|
|
10545
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10546
|
+
spacing: {
|
|
10547
|
+
type: "integer",
|
|
10548
|
+
title: "Spacing",
|
|
10549
|
+
description: "Pattern spacing in pixels",
|
|
10550
|
+
minimum: 8,
|
|
10551
|
+
default: 64
|
|
10552
|
+
},
|
|
10553
|
+
opacity: {
|
|
10554
|
+
type: "number",
|
|
10555
|
+
title: "Opacity",
|
|
10556
|
+
description: "Watermark opacity (0.0-1.0)",
|
|
10557
|
+
minimum: 0,
|
|
10558
|
+
maximum: 1,
|
|
10559
|
+
default: 0.3
|
|
10560
|
+
},
|
|
10561
|
+
pattern: {
|
|
10562
|
+
type: "string",
|
|
10563
|
+
enum: ["diagonal-lines", "grid", "dots"],
|
|
10564
|
+
title: "Pattern",
|
|
10565
|
+
description: "Watermark pattern type",
|
|
10566
|
+
default: "diagonal-lines"
|
|
10567
|
+
}
|
|
10568
|
+
},
|
|
10569
|
+
required: ["image"],
|
|
10570
|
+
additionalProperties: false
|
|
10571
|
+
};
|
|
10572
|
+
var outputSchema52 = {
|
|
10573
|
+
type: "object",
|
|
10574
|
+
properties: {
|
|
10575
|
+
image: ImageBinarySchema({ title: "Image", description: "Watermarked image" })
|
|
10576
|
+
},
|
|
10577
|
+
required: ["image"],
|
|
10578
|
+
additionalProperties: false
|
|
10579
|
+
};
|
|
10580
|
+
|
|
10581
|
+
class ImageWatermarkTask extends Task59 {
|
|
10582
|
+
static type = "ImageWatermarkTask";
|
|
10583
|
+
static category = "Image";
|
|
10584
|
+
static title = "Add Watermark";
|
|
10585
|
+
static description = "Adds a repeating pattern watermark to an image";
|
|
10586
|
+
static inputSchema() {
|
|
10587
|
+
return inputSchema53;
|
|
10588
|
+
}
|
|
10589
|
+
static outputSchema() {
|
|
10590
|
+
return outputSchema52;
|
|
10591
|
+
}
|
|
10592
|
+
async executeReactive(input2, _output, _context) {
|
|
10593
|
+
const { image, spacing = 64, opacity = 0.3, pattern = "diagonal-lines" } = input2;
|
|
10594
|
+
const { data: src, width, height, channels: srcCh } = image;
|
|
10595
|
+
const outCh = 4;
|
|
10596
|
+
const dst = new Uint8ClampedArray(width * height * outCh);
|
|
10597
|
+
const lineWidth = 2;
|
|
10598
|
+
const dotRadius = Math.max(2, spacing >> 3);
|
|
10599
|
+
const dotRadiusSq = dotRadius * dotRadius;
|
|
10600
|
+
const half = spacing >> 1;
|
|
10601
|
+
const alpha = Math.round(opacity * 255);
|
|
10602
|
+
for (let y = 0;y < height; y++) {
|
|
10603
|
+
for (let x = 0;x < width; x++) {
|
|
10604
|
+
const srcIdx = (y * width + x) * srcCh;
|
|
10605
|
+
const dstIdx = (y * width + x) * outCh;
|
|
10606
|
+
const sr = src[srcIdx];
|
|
10607
|
+
const sg = srcCh >= 3 ? src[srcIdx + 1] : sr;
|
|
10608
|
+
const sb = srcCh >= 3 ? src[srcIdx + 2] : sr;
|
|
10609
|
+
const sa = srcCh === 4 ? src[srcIdx + 3] : 255;
|
|
10610
|
+
let isPattern = false;
|
|
10611
|
+
if (pattern === "diagonal-lines") {
|
|
10612
|
+
isPattern = (x + y) % spacing < lineWidth;
|
|
10613
|
+
} else if (pattern === "grid") {
|
|
10614
|
+
isPattern = x % spacing < lineWidth || y % spacing < lineWidth;
|
|
10615
|
+
} else {
|
|
10616
|
+
const dx = x % spacing - half;
|
|
10617
|
+
const dy = y % spacing - half;
|
|
10618
|
+
isPattern = dx * dx + dy * dy < dotRadiusSq;
|
|
10619
|
+
}
|
|
10620
|
+
if (isPattern) {
|
|
10621
|
+
const blend = alpha;
|
|
10622
|
+
const invBlend = 255 - blend;
|
|
10623
|
+
dst[dstIdx] = (sr * invBlend + 255 * blend + 127) / 255;
|
|
10624
|
+
dst[dstIdx + 1] = (sg * invBlend + 255 * blend + 127) / 255;
|
|
10625
|
+
dst[dstIdx + 2] = (sb * invBlend + 255 * blend + 127) / 255;
|
|
10626
|
+
dst[dstIdx + 3] = sa;
|
|
10627
|
+
} else {
|
|
10628
|
+
dst[dstIdx] = sr;
|
|
10629
|
+
dst[dstIdx + 1] = sg;
|
|
10630
|
+
dst[dstIdx + 2] = sb;
|
|
10631
|
+
dst[dstIdx + 3] = sa;
|
|
10632
|
+
}
|
|
10633
|
+
}
|
|
10634
|
+
}
|
|
10635
|
+
return {
|
|
10636
|
+
image: { data: dst, width, height, channels: outCh }
|
|
10637
|
+
};
|
|
10638
|
+
}
|
|
10639
|
+
}
|
|
10640
|
+
Workflow61.prototype.imageWatermark = CreateWorkflow60(ImageWatermarkTask);
|
|
10641
|
+
// src/task/image/ImagePixelateTask.ts
|
|
10642
|
+
import {
|
|
10643
|
+
CreateWorkflow as CreateWorkflow61,
|
|
10644
|
+
Task as Task60,
|
|
10645
|
+
Workflow as Workflow62
|
|
10646
|
+
} from "@workglow/task-graph";
|
|
10647
|
+
var inputSchema54 = {
|
|
10648
|
+
type: "object",
|
|
10649
|
+
properties: {
|
|
10650
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10651
|
+
blockSize: {
|
|
10652
|
+
type: "integer",
|
|
10653
|
+
title: "Block Size",
|
|
10654
|
+
description: "Size of each pixelation block",
|
|
10655
|
+
minimum: 2,
|
|
10656
|
+
default: 8
|
|
10657
|
+
}
|
|
10658
|
+
},
|
|
10659
|
+
required: ["image"],
|
|
10660
|
+
additionalProperties: false
|
|
10661
|
+
};
|
|
10662
|
+
var outputSchema53 = {
|
|
10663
|
+
type: "object",
|
|
10664
|
+
properties: {
|
|
10665
|
+
image: ImageBinarySchema({ title: "Image", description: "Pixelated image" })
|
|
10666
|
+
},
|
|
10667
|
+
required: ["image"],
|
|
10668
|
+
additionalProperties: false
|
|
10669
|
+
};
|
|
10670
|
+
|
|
10671
|
+
class ImagePixelateTask extends Task60 {
|
|
10672
|
+
static type = "ImagePixelateTask";
|
|
10673
|
+
static category = "Image";
|
|
10674
|
+
static title = "Pixelate Image";
|
|
10675
|
+
static description = "Pixelates an image by averaging blocks of pixels";
|
|
10676
|
+
static inputSchema() {
|
|
10677
|
+
return inputSchema54;
|
|
10678
|
+
}
|
|
10679
|
+
static outputSchema() {
|
|
10680
|
+
return outputSchema53;
|
|
10681
|
+
}
|
|
10682
|
+
async executeReactive(input2, _output, _context) {
|
|
10683
|
+
const { image, blockSize = 8 } = input2;
|
|
10684
|
+
const { data: src, width, height, channels } = image;
|
|
10685
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10686
|
+
for (let by = 0;by < height; by += blockSize) {
|
|
10687
|
+
const blockH = Math.min(blockSize, height - by);
|
|
10688
|
+
for (let bx = 0;bx < width; bx += blockSize) {
|
|
10689
|
+
const blockW = Math.min(blockSize, width - bx);
|
|
10690
|
+
const blockArea = blockW * blockH;
|
|
10691
|
+
const sums = new Array(channels).fill(0);
|
|
10692
|
+
for (let y = by;y < by + blockH; y++) {
|
|
10693
|
+
for (let x = bx;x < bx + blockW; x++) {
|
|
10694
|
+
const idx = (y * width + x) * channels;
|
|
10695
|
+
for (let c = 0;c < channels; c++) {
|
|
10696
|
+
sums[c] += src[idx + c];
|
|
10697
|
+
}
|
|
10698
|
+
}
|
|
10699
|
+
}
|
|
10700
|
+
const avg = sums.map((s) => s / blockArea + 0.5 | 0);
|
|
10701
|
+
for (let y = by;y < by + blockH; y++) {
|
|
10702
|
+
for (let x = bx;x < bx + blockW; x++) {
|
|
10703
|
+
const idx = (y * width + x) * channels;
|
|
10704
|
+
for (let c = 0;c < channels; c++) {
|
|
10705
|
+
dst[idx + c] = avg[c];
|
|
10706
|
+
}
|
|
10707
|
+
}
|
|
10708
|
+
}
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
return { image: { data: dst, width, height, channels } };
|
|
10712
|
+
}
|
|
10713
|
+
}
|
|
10714
|
+
Workflow62.prototype.imagePixelate = CreateWorkflow61(ImagePixelateTask);
|
|
10715
|
+
// src/task/image/ImageInvertTask.ts
|
|
10716
|
+
import {
|
|
10717
|
+
CreateWorkflow as CreateWorkflow62,
|
|
10718
|
+
Task as Task61,
|
|
10719
|
+
Workflow as Workflow63
|
|
10720
|
+
} from "@workglow/task-graph";
|
|
10721
|
+
var inputSchema55 = {
|
|
10722
|
+
type: "object",
|
|
10723
|
+
properties: {
|
|
10724
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" })
|
|
10725
|
+
},
|
|
10726
|
+
required: ["image"],
|
|
10727
|
+
additionalProperties: false
|
|
10728
|
+
};
|
|
10729
|
+
var outputSchema54 = {
|
|
10730
|
+
type: "object",
|
|
10731
|
+
properties: {
|
|
10732
|
+
image: ImageBinarySchema({ title: "Image", description: "Inverted image" })
|
|
10733
|
+
},
|
|
10734
|
+
required: ["image"],
|
|
10735
|
+
additionalProperties: false
|
|
10736
|
+
};
|
|
10737
|
+
|
|
10738
|
+
class ImageInvertTask extends Task61 {
|
|
10739
|
+
static type = "ImageInvertTask";
|
|
10740
|
+
static category = "Image";
|
|
10741
|
+
static title = "Invert Colors";
|
|
10742
|
+
static description = "Inverts the colors of an image";
|
|
10743
|
+
static inputSchema() {
|
|
10744
|
+
return inputSchema55;
|
|
10745
|
+
}
|
|
10746
|
+
static outputSchema() {
|
|
10747
|
+
return outputSchema54;
|
|
10748
|
+
}
|
|
10749
|
+
async executeReactive(input2, _output, _context) {
|
|
10750
|
+
const { data: src, width, height, channels } = input2.image;
|
|
10751
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10752
|
+
if (channels === 4) {
|
|
10753
|
+
for (let i = 0;i < src.length; i += 4) {
|
|
10754
|
+
dst[i] = 255 - src[i];
|
|
10755
|
+
dst[i + 1] = 255 - src[i + 1];
|
|
10756
|
+
dst[i + 2] = 255 - src[i + 2];
|
|
10757
|
+
dst[i + 3] = src[i + 3];
|
|
10758
|
+
}
|
|
10759
|
+
} else {
|
|
10760
|
+
for (let i = 0;i < src.length; i++) {
|
|
10761
|
+
dst[i] = 255 - src[i];
|
|
10762
|
+
}
|
|
10763
|
+
}
|
|
10764
|
+
return { image: { data: dst, width, height, channels } };
|
|
10765
|
+
}
|
|
10766
|
+
}
|
|
10767
|
+
Workflow63.prototype.imageInvert = CreateWorkflow62(ImageInvertTask);
|
|
10768
|
+
// src/task/image/ImageBrightnessTask.ts
|
|
10769
|
+
import {
|
|
10770
|
+
CreateWorkflow as CreateWorkflow63,
|
|
10771
|
+
Task as Task62,
|
|
10772
|
+
Workflow as Workflow64
|
|
10773
|
+
} from "@workglow/task-graph";
|
|
10774
|
+
var inputSchema56 = {
|
|
10775
|
+
type: "object",
|
|
10776
|
+
properties: {
|
|
10777
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10778
|
+
amount: {
|
|
10779
|
+
type: "number",
|
|
10780
|
+
title: "Amount",
|
|
10781
|
+
description: "Brightness adjustment (-255 to 255)",
|
|
10782
|
+
minimum: -255,
|
|
10783
|
+
maximum: 255,
|
|
10784
|
+
default: 0
|
|
10785
|
+
}
|
|
10786
|
+
},
|
|
10787
|
+
required: ["image"],
|
|
10788
|
+
additionalProperties: false
|
|
10789
|
+
};
|
|
10790
|
+
var outputSchema55 = {
|
|
10791
|
+
type: "object",
|
|
10792
|
+
properties: {
|
|
10793
|
+
image: ImageBinarySchema({ title: "Image", description: "Brightness-adjusted image" })
|
|
10794
|
+
},
|
|
10795
|
+
required: ["image"],
|
|
10796
|
+
additionalProperties: false
|
|
10797
|
+
};
|
|
10798
|
+
|
|
10799
|
+
class ImageBrightnessTask extends Task62 {
|
|
10800
|
+
static type = "ImageBrightnessTask";
|
|
10801
|
+
static category = "Image";
|
|
10802
|
+
static title = "Adjust Brightness";
|
|
10803
|
+
static description = "Adjusts the brightness of an image";
|
|
10804
|
+
static inputSchema() {
|
|
10805
|
+
return inputSchema56;
|
|
10806
|
+
}
|
|
10807
|
+
static outputSchema() {
|
|
10808
|
+
return outputSchema55;
|
|
10809
|
+
}
|
|
10810
|
+
async executeReactive(input2, _output, _context) {
|
|
10811
|
+
const { data: src, width, height, channels } = input2.image;
|
|
10812
|
+
const amount = input2.amount ?? 0;
|
|
10813
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10814
|
+
if (channels === 4) {
|
|
10815
|
+
for (let i = 0;i < src.length; i += 4) {
|
|
10816
|
+
dst[i] = src[i] + amount;
|
|
10817
|
+
dst[i + 1] = src[i + 1] + amount;
|
|
10818
|
+
dst[i + 2] = src[i + 2] + amount;
|
|
10819
|
+
dst[i + 3] = src[i + 3];
|
|
10820
|
+
}
|
|
10821
|
+
} else {
|
|
10822
|
+
for (let i = 0;i < src.length; i++) {
|
|
10823
|
+
dst[i] = src[i] + amount;
|
|
10824
|
+
}
|
|
10825
|
+
}
|
|
10826
|
+
return { image: { data: dst, width, height, channels } };
|
|
10827
|
+
}
|
|
10828
|
+
}
|
|
10829
|
+
Workflow64.prototype.imageBrightness = CreateWorkflow63(ImageBrightnessTask);
|
|
10830
|
+
// src/task/image/ImageContrastTask.ts
|
|
10831
|
+
import {
|
|
10832
|
+
CreateWorkflow as CreateWorkflow64,
|
|
10833
|
+
Task as Task63,
|
|
10834
|
+
Workflow as Workflow65
|
|
10835
|
+
} from "@workglow/task-graph";
|
|
10836
|
+
var inputSchema57 = {
|
|
10837
|
+
type: "object",
|
|
10838
|
+
properties: {
|
|
10839
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10840
|
+
amount: {
|
|
10841
|
+
type: "number",
|
|
10842
|
+
title: "Amount",
|
|
10843
|
+
description: "Contrast adjustment (-100 to 100)",
|
|
10844
|
+
minimum: -100,
|
|
10845
|
+
maximum: 100,
|
|
10846
|
+
default: 0
|
|
10847
|
+
}
|
|
10848
|
+
},
|
|
10849
|
+
required: ["image"],
|
|
10850
|
+
additionalProperties: false
|
|
10851
|
+
};
|
|
10852
|
+
var outputSchema56 = {
|
|
10853
|
+
type: "object",
|
|
10854
|
+
properties: {
|
|
10855
|
+
image: ImageBinarySchema({ title: "Image", description: "Contrast-adjusted image" })
|
|
10856
|
+
},
|
|
10857
|
+
required: ["image"],
|
|
10858
|
+
additionalProperties: false
|
|
10859
|
+
};
|
|
10860
|
+
|
|
10861
|
+
class ImageContrastTask extends Task63 {
|
|
10862
|
+
static type = "ImageContrastTask";
|
|
10863
|
+
static category = "Image";
|
|
10864
|
+
static title = "Adjust Contrast";
|
|
10865
|
+
static description = "Adjusts the contrast of an image";
|
|
10866
|
+
static inputSchema() {
|
|
10867
|
+
return inputSchema57;
|
|
10868
|
+
}
|
|
10869
|
+
static outputSchema() {
|
|
10870
|
+
return outputSchema56;
|
|
10871
|
+
}
|
|
10872
|
+
async executeReactive(input2, _output, _context) {
|
|
10873
|
+
const { data: src, width, height, channels } = input2.image;
|
|
10874
|
+
const amount = input2.amount ?? 0;
|
|
10875
|
+
const factor = 259 * (amount + 255) / (255 * (259 - amount));
|
|
10876
|
+
const lut = new Uint8ClampedArray(256);
|
|
10877
|
+
for (let i = 0;i < 256; i++) {
|
|
10878
|
+
lut[i] = factor * (i - 128) + 128;
|
|
10879
|
+
}
|
|
10880
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10881
|
+
if (channels === 4) {
|
|
10882
|
+
for (let i = 0;i < src.length; i += 4) {
|
|
10883
|
+
dst[i] = lut[src[i]];
|
|
10884
|
+
dst[i + 1] = lut[src[i + 1]];
|
|
10885
|
+
dst[i + 2] = lut[src[i + 2]];
|
|
10886
|
+
dst[i + 3] = src[i + 3];
|
|
10887
|
+
}
|
|
10888
|
+
} else {
|
|
10889
|
+
for (let i = 0;i < src.length; i++) {
|
|
10890
|
+
dst[i] = lut[src[i]];
|
|
10891
|
+
}
|
|
10892
|
+
}
|
|
10893
|
+
return { image: { data: dst, width, height, channels } };
|
|
10894
|
+
}
|
|
10895
|
+
}
|
|
10896
|
+
Workflow65.prototype.imageContrast = CreateWorkflow64(ImageContrastTask);
|
|
10897
|
+
// src/task/image/ImageSepiaTask.ts
|
|
10898
|
+
import {
|
|
10899
|
+
CreateWorkflow as CreateWorkflow65,
|
|
10900
|
+
Task as Task64,
|
|
10901
|
+
Workflow as Workflow66
|
|
10902
|
+
} from "@workglow/task-graph";
|
|
10903
|
+
var inputSchema58 = {
|
|
10904
|
+
type: "object",
|
|
10905
|
+
properties: {
|
|
10906
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" })
|
|
10907
|
+
},
|
|
10908
|
+
required: ["image"],
|
|
10909
|
+
additionalProperties: false
|
|
10910
|
+
};
|
|
10911
|
+
var outputSchema57 = {
|
|
10912
|
+
type: "object",
|
|
10913
|
+
properties: {
|
|
10914
|
+
image: ImageBinarySchema({ title: "Image", description: "Sepia-toned image" })
|
|
10915
|
+
},
|
|
10916
|
+
required: ["image"],
|
|
10917
|
+
additionalProperties: false
|
|
10918
|
+
};
|
|
10919
|
+
|
|
10920
|
+
class ImageSepiaTask extends Task64 {
|
|
10921
|
+
static type = "ImageSepiaTask";
|
|
10922
|
+
static category = "Image";
|
|
10923
|
+
static title = "Sepia Tone";
|
|
10924
|
+
static description = "Applies a sepia tone filter to an image";
|
|
10925
|
+
static inputSchema() {
|
|
10926
|
+
return inputSchema58;
|
|
10927
|
+
}
|
|
10928
|
+
static outputSchema() {
|
|
10929
|
+
return outputSchema57;
|
|
10930
|
+
}
|
|
10931
|
+
async executeReactive(input2, _output, _context) {
|
|
10932
|
+
const { data: src, width, height, channels } = input2.image;
|
|
10933
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
10934
|
+
const pixelCount = width * height;
|
|
10935
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
10936
|
+
const idx = i * channels;
|
|
10937
|
+
const r = channels === 1 ? src[idx] : src[idx];
|
|
10938
|
+
const g = channels === 1 ? src[idx] : src[idx + 1];
|
|
10939
|
+
const b = channels === 1 ? src[idx] : src[idx + 2];
|
|
10940
|
+
const outR = r * 402 + g * 787 + b * 194 >> 10;
|
|
10941
|
+
const outG = r * 357 + g * 702 + b * 172 >> 10;
|
|
10942
|
+
const outB = r * 279 + g * 547 + b * 134 >> 10;
|
|
10943
|
+
dst[idx] = outR > 255 ? 255 : outR;
|
|
10944
|
+
if (channels >= 3) {
|
|
10945
|
+
dst[idx + 1] = outG > 255 ? 255 : outG;
|
|
10946
|
+
dst[idx + 2] = outB > 255 ? 255 : outB;
|
|
10947
|
+
}
|
|
10948
|
+
if (channels === 4) {
|
|
10949
|
+
dst[idx + 3] = src[idx + 3];
|
|
10950
|
+
}
|
|
10951
|
+
}
|
|
10952
|
+
return { image: { data: dst, width, height, channels } };
|
|
10953
|
+
}
|
|
10954
|
+
}
|
|
10955
|
+
Workflow66.prototype.imageSepia = CreateWorkflow65(ImageSepiaTask);
|
|
10956
|
+
// src/task/image/ImageThresholdTask.ts
|
|
10957
|
+
import {
|
|
10958
|
+
CreateWorkflow as CreateWorkflow66,
|
|
10959
|
+
Task as Task65,
|
|
10960
|
+
Workflow as Workflow67
|
|
10961
|
+
} from "@workglow/task-graph";
|
|
10962
|
+
var inputSchema59 = {
|
|
10963
|
+
type: "object",
|
|
10964
|
+
properties: {
|
|
10965
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
10966
|
+
threshold: {
|
|
10967
|
+
type: "integer",
|
|
10968
|
+
title: "Threshold",
|
|
10969
|
+
description: "Threshold value (0-255)",
|
|
10970
|
+
minimum: 0,
|
|
10971
|
+
maximum: 255,
|
|
10972
|
+
default: 128
|
|
10973
|
+
}
|
|
10974
|
+
},
|
|
10975
|
+
required: ["image"],
|
|
10976
|
+
additionalProperties: false
|
|
10977
|
+
};
|
|
10978
|
+
var outputSchema58 = {
|
|
10979
|
+
type: "object",
|
|
10980
|
+
properties: {
|
|
10981
|
+
image: ImageBinarySchema({ title: "Image", description: "Thresholded binary image" })
|
|
10982
|
+
},
|
|
10983
|
+
required: ["image"],
|
|
10984
|
+
additionalProperties: false
|
|
10985
|
+
};
|
|
10986
|
+
|
|
10987
|
+
class ImageThresholdTask extends Task65 {
|
|
10988
|
+
static type = "ImageThresholdTask";
|
|
10989
|
+
static category = "Image";
|
|
10990
|
+
static title = "Threshold";
|
|
10991
|
+
static description = "Converts an image to binary black and white";
|
|
10992
|
+
static inputSchema() {
|
|
10993
|
+
return inputSchema59;
|
|
10994
|
+
}
|
|
10995
|
+
static outputSchema() {
|
|
10996
|
+
return outputSchema58;
|
|
10997
|
+
}
|
|
10998
|
+
async executeReactive(input2, _output, _context) {
|
|
10999
|
+
const { data: src, width, height, channels } = input2.image;
|
|
11000
|
+
const threshold = input2.threshold ?? 128;
|
|
11001
|
+
const pixelCount = width * height;
|
|
11002
|
+
const dst = new Uint8ClampedArray(pixelCount);
|
|
11003
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
11004
|
+
const idx = i * channels;
|
|
11005
|
+
let gray;
|
|
11006
|
+
if (channels === 1) {
|
|
11007
|
+
gray = src[idx];
|
|
11008
|
+
} else {
|
|
11009
|
+
gray = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
|
|
11010
|
+
}
|
|
11011
|
+
dst[i] = gray >= threshold ? 255 : 0;
|
|
11012
|
+
}
|
|
11013
|
+
return { image: { data: dst, width, height, channels: 1 } };
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
Workflow67.prototype.imageThreshold = CreateWorkflow66(ImageThresholdTask);
|
|
11017
|
+
// src/task/image/ImagePosterizeTask.ts
|
|
11018
|
+
import {
|
|
11019
|
+
CreateWorkflow as CreateWorkflow67,
|
|
11020
|
+
Task as Task66,
|
|
11021
|
+
Workflow as Workflow68
|
|
11022
|
+
} from "@workglow/task-graph";
|
|
11023
|
+
var inputSchema60 = {
|
|
11024
|
+
type: "object",
|
|
11025
|
+
properties: {
|
|
11026
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
11027
|
+
levels: {
|
|
11028
|
+
type: "integer",
|
|
11029
|
+
title: "Levels",
|
|
11030
|
+
description: "Number of color levels per channel (2-32)",
|
|
11031
|
+
minimum: 2,
|
|
11032
|
+
maximum: 32,
|
|
11033
|
+
default: 4
|
|
11034
|
+
}
|
|
11035
|
+
},
|
|
11036
|
+
required: ["image"],
|
|
11037
|
+
additionalProperties: false
|
|
11038
|
+
};
|
|
11039
|
+
var outputSchema59 = {
|
|
11040
|
+
type: "object",
|
|
11041
|
+
properties: {
|
|
11042
|
+
image: ImageBinarySchema({ title: "Image", description: "Posterized image" })
|
|
11043
|
+
},
|
|
11044
|
+
required: ["image"],
|
|
11045
|
+
additionalProperties: false
|
|
11046
|
+
};
|
|
11047
|
+
|
|
11048
|
+
class ImagePosterizeTask extends Task66 {
|
|
11049
|
+
static type = "ImagePosterizeTask";
|
|
11050
|
+
static category = "Image";
|
|
11051
|
+
static title = "Posterize";
|
|
11052
|
+
static description = "Reduces the number of color levels in an image";
|
|
11053
|
+
static inputSchema() {
|
|
11054
|
+
return inputSchema60;
|
|
11055
|
+
}
|
|
11056
|
+
static outputSchema() {
|
|
11057
|
+
return outputSchema59;
|
|
11058
|
+
}
|
|
11059
|
+
async executeReactive(input2, _output, _context) {
|
|
11060
|
+
const { data: src, width, height, channels } = input2.image;
|
|
11061
|
+
const levels = input2.levels ?? 4;
|
|
11062
|
+
const step = 255 / (levels - 1);
|
|
11063
|
+
const lut = new Uint8ClampedArray(256);
|
|
11064
|
+
for (let i = 0;i < 256; i++) {
|
|
11065
|
+
lut[i] = Math.round(Math.round(i / step) * step);
|
|
11066
|
+
}
|
|
11067
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
11068
|
+
if (channels === 4) {
|
|
11069
|
+
for (let i = 0;i < src.length; i += 4) {
|
|
11070
|
+
dst[i] = lut[src[i]];
|
|
11071
|
+
dst[i + 1] = lut[src[i + 1]];
|
|
11072
|
+
dst[i + 2] = lut[src[i + 2]];
|
|
11073
|
+
dst[i + 3] = src[i + 3];
|
|
11074
|
+
}
|
|
11075
|
+
} else {
|
|
11076
|
+
for (let i = 0;i < src.length; i++) {
|
|
11077
|
+
dst[i] = lut[src[i]];
|
|
11078
|
+
}
|
|
11079
|
+
}
|
|
11080
|
+
return { image: { data: dst, width, height, channels } };
|
|
11081
|
+
}
|
|
11082
|
+
}
|
|
11083
|
+
Workflow68.prototype.imagePosterize = CreateWorkflow67(ImagePosterizeTask);
|
|
11084
|
+
// src/task/image/ImageTintTask.ts
|
|
11085
|
+
import {
|
|
11086
|
+
CreateWorkflow as CreateWorkflow68,
|
|
11087
|
+
Task as Task67,
|
|
11088
|
+
Workflow as Workflow69
|
|
11089
|
+
} from "@workglow/task-graph";
|
|
11090
|
+
var inputSchema61 = {
|
|
11091
|
+
type: "object",
|
|
11092
|
+
properties: {
|
|
11093
|
+
image: ImageBinarySchema({ title: "Image", description: "Source image" }),
|
|
11094
|
+
color: ColorSchema({ title: "Color", description: "Tint color" }),
|
|
11095
|
+
amount: {
|
|
11096
|
+
type: "number",
|
|
11097
|
+
title: "Amount",
|
|
11098
|
+
description: "Tint strength (0.0 = no tint, 1.0 = full tint color)",
|
|
11099
|
+
minimum: 0,
|
|
11100
|
+
maximum: 1,
|
|
11101
|
+
default: 0.5
|
|
11102
|
+
}
|
|
11103
|
+
},
|
|
11104
|
+
required: ["image", "color"],
|
|
11105
|
+
additionalProperties: false
|
|
11106
|
+
};
|
|
11107
|
+
var outputSchema60 = {
|
|
11108
|
+
type: "object",
|
|
11109
|
+
properties: {
|
|
11110
|
+
image: ImageBinarySchema({ title: "Image", description: "Tinted image" })
|
|
11111
|
+
},
|
|
11112
|
+
required: ["image"],
|
|
11113
|
+
additionalProperties: false
|
|
11114
|
+
};
|
|
11115
|
+
|
|
11116
|
+
class ImageTintTask extends Task67 {
|
|
11117
|
+
static type = "ImageTintTask";
|
|
11118
|
+
static category = "Image";
|
|
11119
|
+
static title = "Tint Image";
|
|
11120
|
+
static description = "Applies a color tint to an image";
|
|
11121
|
+
static inputSchema() {
|
|
11122
|
+
return inputSchema61;
|
|
11123
|
+
}
|
|
11124
|
+
static outputSchema() {
|
|
11125
|
+
return outputSchema60;
|
|
11126
|
+
}
|
|
11127
|
+
async executeReactive(input2, _output, _context) {
|
|
11128
|
+
const { data: src, width, height, channels } = input2.image;
|
|
11129
|
+
const { r: tr, g: tg, b: tb } = input2.color;
|
|
11130
|
+
const amount = input2.amount ?? 0.5;
|
|
11131
|
+
const invAmount = 1 - amount;
|
|
11132
|
+
const tintR = tr * amount;
|
|
11133
|
+
const tintG = tg * amount;
|
|
11134
|
+
const tintB = tb * amount;
|
|
11135
|
+
const pixelCount = width * height;
|
|
11136
|
+
if (channels === 1) {
|
|
11137
|
+
const dst2 = new Uint8ClampedArray(pixelCount * 3);
|
|
11138
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
11139
|
+
const gray = src[i];
|
|
11140
|
+
dst2[i * 3] = gray * invAmount + tintR;
|
|
11141
|
+
dst2[i * 3 + 1] = gray * invAmount + tintG;
|
|
11142
|
+
dst2[i * 3 + 2] = gray * invAmount + tintB;
|
|
11143
|
+
}
|
|
11144
|
+
return { image: { data: dst2, width, height, channels: 3 } };
|
|
11145
|
+
}
|
|
11146
|
+
const dst = new Uint8ClampedArray(src.length);
|
|
11147
|
+
for (let i = 0;i < pixelCount; i++) {
|
|
11148
|
+
const idx = i * channels;
|
|
11149
|
+
dst[idx] = src[idx] * invAmount + tintR;
|
|
11150
|
+
dst[idx + 1] = src[idx + 1] * invAmount + tintG;
|
|
11151
|
+
dst[idx + 2] = src[idx + 2] * invAmount + tintB;
|
|
11152
|
+
if (channels === 4) {
|
|
11153
|
+
dst[idx + 3] = src[idx + 3];
|
|
11154
|
+
}
|
|
11155
|
+
}
|
|
11156
|
+
return { image: { data: dst, width, height, channels } };
|
|
11157
|
+
}
|
|
11158
|
+
}
|
|
11159
|
+
Workflow69.prototype.imageTint = CreateWorkflow68(ImageTintTask);
|
|
9354
11160
|
|
|
9355
11161
|
// src/common.ts
|
|
9356
11162
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
@@ -9359,6 +11165,8 @@ var registerCommonTasks = () => {
|
|
|
9359
11165
|
DebugLogTask,
|
|
9360
11166
|
DelayTask,
|
|
9361
11167
|
FetchUrlTask,
|
|
11168
|
+
HumanApprovalTask,
|
|
11169
|
+
HumanInputTask,
|
|
9362
11170
|
InputTask,
|
|
9363
11171
|
JavaScriptTask,
|
|
9364
11172
|
JsonTask,
|
|
@@ -9404,28 +11212,45 @@ var registerCommonTasks = () => {
|
|
|
9404
11212
|
JsonPathTask,
|
|
9405
11213
|
TemplateTask,
|
|
9406
11214
|
DateFormatTask,
|
|
9407
|
-
RegexTask
|
|
11215
|
+
RegexTask,
|
|
11216
|
+
ImageResizeTask,
|
|
11217
|
+
ImageCropTask,
|
|
11218
|
+
ImageRotateTask,
|
|
11219
|
+
ImageFlipTask,
|
|
11220
|
+
ImageGrayscaleTask,
|
|
11221
|
+
ImageBorderTask,
|
|
11222
|
+
ImageTransparencyTask,
|
|
11223
|
+
ImageBlurTask,
|
|
11224
|
+
ImageWatermarkTask,
|
|
11225
|
+
ImagePixelateTask,
|
|
11226
|
+
ImageInvertTask,
|
|
11227
|
+
ImageBrightnessTask,
|
|
11228
|
+
ImageContrastTask,
|
|
11229
|
+
ImageSepiaTask,
|
|
11230
|
+
ImageThresholdTask,
|
|
11231
|
+
ImagePosterizeTask,
|
|
11232
|
+
ImageTintTask
|
|
9408
11233
|
];
|
|
9409
11234
|
tasks.map(TaskRegistry.registerTask);
|
|
9410
11235
|
return tasks;
|
|
9411
11236
|
};
|
|
9412
11237
|
// src/task/FileLoaderTask.server.ts
|
|
9413
11238
|
import {
|
|
9414
|
-
CreateWorkflow as
|
|
9415
|
-
TaskAbortedError as
|
|
9416
|
-
Workflow as
|
|
11239
|
+
CreateWorkflow as CreateWorkflow70,
|
|
11240
|
+
TaskAbortedError as TaskAbortedError5,
|
|
11241
|
+
Workflow as Workflow71
|
|
9417
11242
|
} from "@workglow/task-graph";
|
|
9418
11243
|
import { readFile } from "fs/promises";
|
|
9419
11244
|
|
|
9420
11245
|
// src/task/FileLoaderTask.ts
|
|
9421
11246
|
import {
|
|
9422
|
-
CreateWorkflow as
|
|
9423
|
-
Task as
|
|
9424
|
-
TaskAbortedError as
|
|
9425
|
-
Workflow as
|
|
11247
|
+
CreateWorkflow as CreateWorkflow69,
|
|
11248
|
+
Task as Task68,
|
|
11249
|
+
TaskAbortedError as TaskAbortedError4,
|
|
11250
|
+
Workflow as Workflow70
|
|
9426
11251
|
} from "@workglow/task-graph";
|
|
9427
11252
|
import Papa from "papaparse";
|
|
9428
|
-
var
|
|
11253
|
+
var inputSchema62 = {
|
|
9429
11254
|
type: "object",
|
|
9430
11255
|
properties: {
|
|
9431
11256
|
url: {
|
|
@@ -9445,7 +11270,7 @@ var inputSchema44 = {
|
|
|
9445
11270
|
required: ["url"],
|
|
9446
11271
|
additionalProperties: false
|
|
9447
11272
|
};
|
|
9448
|
-
var
|
|
11273
|
+
var outputSchema61 = {
|
|
9449
11274
|
type: "object",
|
|
9450
11275
|
properties: {
|
|
9451
11276
|
text: {
|
|
@@ -9496,45 +11321,43 @@ var outputSchema44 = {
|
|
|
9496
11321
|
additionalProperties: false
|
|
9497
11322
|
};
|
|
9498
11323
|
|
|
9499
|
-
class FileLoaderTask extends
|
|
11324
|
+
class FileLoaderTask extends Task68 {
|
|
9500
11325
|
static type = "FileLoaderTask";
|
|
9501
11326
|
static category = "Document";
|
|
9502
11327
|
static title = "File Loader";
|
|
9503
11328
|
static description = "Load documents from URLs (http://, https://)";
|
|
9504
11329
|
static cacheable = true;
|
|
9505
11330
|
static inputSchema() {
|
|
9506
|
-
return
|
|
11331
|
+
return inputSchema62;
|
|
9507
11332
|
}
|
|
9508
11333
|
static outputSchema() {
|
|
9509
|
-
return
|
|
11334
|
+
return outputSchema61;
|
|
9510
11335
|
}
|
|
9511
11336
|
async execute(input2, context) {
|
|
9512
11337
|
const { url, format = "auto" } = input2;
|
|
9513
11338
|
if (context.signal.aborted) {
|
|
9514
|
-
throw new
|
|
11339
|
+
throw new TaskAbortedError4("Task aborted");
|
|
9515
11340
|
}
|
|
9516
11341
|
await context.updateProgress(0, "Detecting file format");
|
|
9517
11342
|
const detectedFormat = this.detectFormat(url, format);
|
|
9518
11343
|
const responseType = this.detectResponseType(detectedFormat);
|
|
9519
11344
|
if (context.signal.aborted) {
|
|
9520
|
-
throw new
|
|
11345
|
+
throw new TaskAbortedError4("Task aborted");
|
|
9521
11346
|
}
|
|
9522
11347
|
await context.updateProgress(10, `Fetching ${detectedFormat} file from ${url}`);
|
|
9523
|
-
const fetchTask = context.own(new FetchUrlTask({
|
|
11348
|
+
const fetchTask = context.own(new FetchUrlTask({ queue: false }));
|
|
11349
|
+
const response = await fetchTask.run({
|
|
9524
11350
|
url,
|
|
9525
11351
|
response_type: responseType
|
|
9526
|
-
}
|
|
9527
|
-
queue: false
|
|
9528
|
-
}));
|
|
9529
|
-
const response = await fetchTask.run();
|
|
11352
|
+
});
|
|
9530
11353
|
if (context.signal.aborted) {
|
|
9531
|
-
throw new
|
|
11354
|
+
throw new TaskAbortedError4("Task aborted");
|
|
9532
11355
|
}
|
|
9533
11356
|
await context.updateProgress(60, "Parsing file content");
|
|
9534
11357
|
const title = url.split("/").pop() || url;
|
|
9535
11358
|
const { text, json: json2, csv, image, pdf, frontmatter, size, mimeType } = await this.parseResponse(response, url, detectedFormat);
|
|
9536
11359
|
if (context.signal.aborted) {
|
|
9537
|
-
throw new
|
|
11360
|
+
throw new TaskAbortedError4("Task aborted");
|
|
9538
11361
|
}
|
|
9539
11362
|
await context.updateProgress(100, "File loaded successfully");
|
|
9540
11363
|
return {
|
|
@@ -9857,7 +11680,7 @@ class FileLoaderTask extends Task49 {
|
|
|
9857
11680
|
});
|
|
9858
11681
|
}
|
|
9859
11682
|
}
|
|
9860
|
-
|
|
11683
|
+
Workflow70.prototype.fileLoader = CreateWorkflow69(FileLoaderTask);
|
|
9861
11684
|
|
|
9862
11685
|
// src/task/FileLoaderTask.server.ts
|
|
9863
11686
|
class FileLoaderTask2 extends FileLoaderTask {
|
|
@@ -9867,7 +11690,7 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
9867
11690
|
return super.execute(input2, context);
|
|
9868
11691
|
}
|
|
9869
11692
|
if (context.signal.aborted) {
|
|
9870
|
-
throw new
|
|
11693
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9871
11694
|
}
|
|
9872
11695
|
await context.updateProgress(0, "Detecting file format");
|
|
9873
11696
|
if (url.startsWith("file://")) {
|
|
@@ -9876,19 +11699,19 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
9876
11699
|
const detectedFormat = this.detectFormat(url, format);
|
|
9877
11700
|
const title = url.split("/").pop() || url;
|
|
9878
11701
|
if (context.signal.aborted) {
|
|
9879
|
-
throw new
|
|
11702
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9880
11703
|
}
|
|
9881
11704
|
await context.updateProgress(10, `Reading ${detectedFormat} file from filesystem`);
|
|
9882
11705
|
if (detectedFormat === "json") {
|
|
9883
11706
|
const fileContent2 = await readFile(url, { encoding: "utf-8" });
|
|
9884
11707
|
if (context.signal.aborted) {
|
|
9885
|
-
throw new
|
|
11708
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9886
11709
|
}
|
|
9887
11710
|
await context.updateProgress(50, "Parsing JSON content");
|
|
9888
11711
|
const jsonData = this.parseJsonContent(fileContent2);
|
|
9889
11712
|
const content = JSON.stringify(jsonData, null, 2);
|
|
9890
11713
|
if (context.signal.aborted) {
|
|
9891
|
-
throw new
|
|
11714
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9892
11715
|
}
|
|
9893
11716
|
await context.updateProgress(100, "File loaded successfully");
|
|
9894
11717
|
return {
|
|
@@ -9913,12 +11736,12 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
9913
11736
|
throw new Error(`Failed to load CSV from ${url}`);
|
|
9914
11737
|
}
|
|
9915
11738
|
if (context.signal.aborted) {
|
|
9916
|
-
throw new
|
|
11739
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9917
11740
|
}
|
|
9918
11741
|
await context.updateProgress(50, "Parsing CSV content");
|
|
9919
11742
|
const csvData = this.parseCsvContent(fileContent2);
|
|
9920
11743
|
if (context.signal.aborted) {
|
|
9921
|
-
throw new
|
|
11744
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9922
11745
|
}
|
|
9923
11746
|
await context.updateProgress(100, "File loaded successfully");
|
|
9924
11747
|
return {
|
|
@@ -9940,14 +11763,14 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
9940
11763
|
if (detectedFormat === "image") {
|
|
9941
11764
|
const fileBuffer = await readFile(url);
|
|
9942
11765
|
if (context.signal.aborted) {
|
|
9943
|
-
throw new
|
|
11766
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9944
11767
|
}
|
|
9945
11768
|
await context.updateProgress(50, "Converting image to base64");
|
|
9946
11769
|
const mimeType2 = this.getImageMimeType(url);
|
|
9947
11770
|
const blob = new Blob([fileBuffer], { type: mimeType2 });
|
|
9948
11771
|
const imageData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
9949
11772
|
if (context.signal.aborted) {
|
|
9950
|
-
throw new
|
|
11773
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9951
11774
|
}
|
|
9952
11775
|
await context.updateProgress(100, "File loaded successfully");
|
|
9953
11776
|
return {
|
|
@@ -9969,14 +11792,14 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
9969
11792
|
if (detectedFormat === "pdf") {
|
|
9970
11793
|
const fileBuffer = await readFile(url);
|
|
9971
11794
|
if (context.signal.aborted) {
|
|
9972
|
-
throw new
|
|
11795
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9973
11796
|
}
|
|
9974
11797
|
await context.updateProgress(50, "Converting PDF to base64");
|
|
9975
11798
|
const mimeType2 = "application/pdf";
|
|
9976
11799
|
const blob = new Blob([fileBuffer], { type: mimeType2 });
|
|
9977
11800
|
const pdfData = await this.blobToBase64DataURL(blob, mimeType2);
|
|
9978
11801
|
if (context.signal.aborted) {
|
|
9979
|
-
throw new
|
|
11802
|
+
throw new TaskAbortedError5("Task aborted");
|
|
9980
11803
|
}
|
|
9981
11804
|
await context.updateProgress(100, "File loaded successfully");
|
|
9982
11805
|
return {
|
|
@@ -10000,12 +11823,12 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
10000
11823
|
throw new Error(`Failed to load content from ${url}`);
|
|
10001
11824
|
}
|
|
10002
11825
|
if (context.signal.aborted) {
|
|
10003
|
-
throw new
|
|
11826
|
+
throw new TaskAbortedError5("Task aborted");
|
|
10004
11827
|
}
|
|
10005
11828
|
await context.updateProgress(50, `Parsing ${detectedFormat} content`);
|
|
10006
11829
|
const mimeType = detectedFormat === "markdown" ? "text/markdown" : detectedFormat === "html" ? "text/html" : "text/plain";
|
|
10007
11830
|
if (context.signal.aborted) {
|
|
10008
|
-
throw new
|
|
11831
|
+
throw new TaskAbortedError5("Task aborted");
|
|
10009
11832
|
}
|
|
10010
11833
|
await context.updateProgress(100, "File loaded successfully");
|
|
10011
11834
|
if (detectedFormat === "markdown") {
|
|
@@ -10044,9 +11867,9 @@ class FileLoaderTask2 extends FileLoaderTask {
|
|
|
10044
11867
|
}
|
|
10045
11868
|
}
|
|
10046
11869
|
var fileLoader = (input2, config) => {
|
|
10047
|
-
return new FileLoaderTask2(
|
|
11870
|
+
return new FileLoaderTask2(config).run(input2);
|
|
10048
11871
|
};
|
|
10049
|
-
|
|
11872
|
+
Workflow71.prototype.fileLoader = CreateWorkflow70(FileLoaderTask2);
|
|
10050
11873
|
|
|
10051
11874
|
// src/bun.ts
|
|
10052
11875
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
@@ -10070,6 +11893,7 @@ export {
|
|
|
10070
11893
|
setGlobalMcpServerRepository,
|
|
10071
11894
|
searchMcpRegistryPage,
|
|
10072
11895
|
searchMcpRegistry,
|
|
11896
|
+
resolveHumanConnector,
|
|
10073
11897
|
resolveAuthSecrets,
|
|
10074
11898
|
registerMcpTaskDeps,
|
|
10075
11899
|
registerMcpServer,
|
|
@@ -10147,6 +11971,7 @@ export {
|
|
|
10147
11971
|
McpResourceReadTask,
|
|
10148
11972
|
McpPromptGetTask,
|
|
10149
11973
|
McpListTask,
|
|
11974
|
+
McpElicitationConnector,
|
|
10150
11975
|
MCP_TASK_DEPS,
|
|
10151
11976
|
MCP_SERVER_REPOSITORY,
|
|
10152
11977
|
MCP_SERVERS,
|
|
@@ -10156,6 +11981,28 @@ export {
|
|
|
10156
11981
|
JavaScriptTask,
|
|
10157
11982
|
InputTask,
|
|
10158
11983
|
InMemoryMcpServerRepository,
|
|
11984
|
+
ImageWatermarkTask,
|
|
11985
|
+
ImageTransparencyTask,
|
|
11986
|
+
ImageTintTask,
|
|
11987
|
+
ImageThresholdTask,
|
|
11988
|
+
ImageSepiaTask,
|
|
11989
|
+
ImageRotateTask,
|
|
11990
|
+
ImageResizeTask,
|
|
11991
|
+
ImagePosterizeTask,
|
|
11992
|
+
ImagePixelateTask,
|
|
11993
|
+
ImageInvertTask,
|
|
11994
|
+
ImageGrayscaleTask,
|
|
11995
|
+
ImageFlipTask,
|
|
11996
|
+
ImageCropTask,
|
|
11997
|
+
ImageContrastTask,
|
|
11998
|
+
ImageBrightnessTask,
|
|
11999
|
+
ImageBorderTask,
|
|
12000
|
+
ImageBlurTask,
|
|
12001
|
+
ImageBinarySchemaOptions,
|
|
12002
|
+
ImageBinarySchema,
|
|
12003
|
+
HumanInputTask,
|
|
12004
|
+
HumanApprovalTask,
|
|
12005
|
+
HUMAN_CONNECTOR,
|
|
10159
12006
|
FileLoaderTask2 as FileLoaderTask,
|
|
10160
12007
|
FetchUrlTask,
|
|
10161
12008
|
FetchUrlJob,
|
|
@@ -10163,7 +12010,8 @@ export {
|
|
|
10163
12010
|
DebugLogTask,
|
|
10164
12011
|
DateFormatTask,
|
|
10165
12012
|
CredentialStoreOAuthProvider,
|
|
12013
|
+
ColorSchema,
|
|
10166
12014
|
ArrayTask
|
|
10167
12015
|
};
|
|
10168
12016
|
|
|
10169
|
-
//# debugId=
|
|
12017
|
+
//# debugId=BA94302B77638A1964756E2164756E21
|