@workglow/tasks 0.0.99 → 0.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -40
- package/dist/browser.js +56 -32
- package/dist/browser.js.map +8 -8
- package/dist/bun.js +56 -32
- package/dist/bun.js.map +8 -8
- package/dist/node.js +56 -32
- package/dist/node.js.map +8 -8
- package/dist/task/DebugLogTask.d.ts +23 -49
- package/dist/task/DebugLogTask.d.ts.map +1 -1
- package/dist/task/DelayTask.d.ts +16 -29
- package/dist/task/DelayTask.d.ts.map +1 -1
- package/dist/task/InputTask.d.ts +1 -3
- package/dist/task/InputTask.d.ts.map +1 -1
- package/dist/task/LambdaTask.d.ts +36 -2
- package/dist/task/LambdaTask.d.ts.map +1 -1
- package/dist/task/OutputTask.d.ts +1 -3
- package/dist/task/OutputTask.d.ts.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -35,8 +35,8 @@ import { Workflow, fetch, debugLog, delay } from "@workglow/tasks";
|
|
|
35
35
|
// Simple workflow example (fluent API)
|
|
36
36
|
const workflow = new Workflow()
|
|
37
37
|
.fetch({ url: "https://api.example.com/data", response_type: "json" })
|
|
38
|
-
.debugLog({ log_level: "info" })
|
|
39
|
-
.delay({ delay: 1000 });
|
|
38
|
+
.debugLog(undefined, { log_level: "info" })
|
|
39
|
+
.delay(undefined, { delay: 1000 });
|
|
40
40
|
|
|
41
41
|
const results = await workflow.run();
|
|
42
42
|
```
|
|
@@ -50,12 +50,9 @@ const fetchResult = await new FetchUrlTask({
|
|
|
50
50
|
response_type: "json",
|
|
51
51
|
}).run();
|
|
52
52
|
|
|
53
|
-
await new DebugLogTask({
|
|
54
|
-
console: fetchResult.json,
|
|
55
|
-
log_level: "info",
|
|
56
|
-
}).run();
|
|
53
|
+
await new DebugLogTask({ console: fetchResult.json }, { log_level: "info" }).run();
|
|
57
54
|
|
|
58
|
-
await new DelayTask({ delay: 1000 }).run();
|
|
55
|
+
await new DelayTask({}, { delay: 1000 }).run();
|
|
59
56
|
```
|
|
60
57
|
|
|
61
58
|
```typescript
|
|
@@ -65,10 +62,7 @@ const data = await fetch({
|
|
|
65
62
|
url: "https://example.com/readme.txt",
|
|
66
63
|
response_type: "text",
|
|
67
64
|
});
|
|
68
|
-
await debugLog({
|
|
69
|
-
console: data.text,
|
|
70
|
-
log_level: "info",
|
|
71
|
-
});
|
|
65
|
+
await debugLog({ console: data.text }, { log_level: "info" });
|
|
72
66
|
```
|
|
73
67
|
|
|
74
68
|
## Available Tasks
|
|
@@ -138,33 +132,33 @@ Provides console logging functionality with multiple log levels for debugging ta
|
|
|
138
132
|
|
|
139
133
|
**Input Schema:**
|
|
140
134
|
|
|
141
|
-
-
|
|
135
|
+
- Any inputs are accepted and passed through to outputs unchanged.
|
|
136
|
+
|
|
137
|
+
**Config Schema:**
|
|
138
|
+
|
|
142
139
|
- `log_level` (string, optional): Log level ("dir", "log", "debug", "info", "warn", "error"). Default: "log"
|
|
143
140
|
|
|
144
141
|
**Output Schema:**
|
|
145
142
|
|
|
146
|
-
-
|
|
143
|
+
- All inputs passed through unchanged.
|
|
147
144
|
|
|
148
145
|
**Examples:**
|
|
149
146
|
|
|
150
147
|
```typescript
|
|
151
148
|
// Basic logging
|
|
152
|
-
await new DebugLogTask({
|
|
153
|
-
console: "Processing user data",
|
|
154
|
-
log_level: "info",
|
|
155
|
-
}).run();
|
|
149
|
+
await new DebugLogTask({ console: "Processing user data" }, { log_level: "info" }).run();
|
|
156
150
|
|
|
157
151
|
// Object inspection with dir
|
|
158
|
-
await new DebugLogTask(
|
|
159
|
-
console: { user: { id: 1, name: "John" }, status: "active" },
|
|
160
|
-
log_level: "dir"
|
|
161
|
-
|
|
152
|
+
await new DebugLogTask(
|
|
153
|
+
{ console: { user: { id: 1, name: "John" }, status: "active" } },
|
|
154
|
+
{ log_level: "dir" }
|
|
155
|
+
).run();
|
|
162
156
|
|
|
163
157
|
// In workflow with data flow
|
|
164
158
|
const workflow = new Workflow()
|
|
165
159
|
.fetch({ url: "https://api.example.com/data" })
|
|
166
|
-
.debugLog({ log_level: "dir" }) // Logs the fetched data
|
|
167
|
-
.delay({ delay: 1000 });
|
|
160
|
+
.debugLog(undefined, { log_level: "dir" }) // Logs the fetched data
|
|
161
|
+
.delay(undefined, { delay: 1000 });
|
|
168
162
|
```
|
|
169
163
|
|
|
170
164
|
**Features:**
|
|
@@ -180,31 +174,34 @@ Introduces timed delays in workflows with progress tracking and cancellation sup
|
|
|
180
174
|
|
|
181
175
|
**Input Schema:**
|
|
182
176
|
|
|
177
|
+
- Any inputs are accepted and passed through to outputs unchanged.
|
|
178
|
+
|
|
179
|
+
**Config Schema:**
|
|
180
|
+
|
|
183
181
|
- `delay` (number, optional): Delay duration in milliseconds. Default: 1
|
|
184
|
-
- `pass_through` (any, optional): Data to pass through to the output
|
|
185
182
|
|
|
186
183
|
**Output Schema:**
|
|
187
184
|
|
|
188
|
-
-
|
|
185
|
+
- All inputs passed through unchanged.
|
|
189
186
|
|
|
190
187
|
**Examples:**
|
|
191
188
|
|
|
192
189
|
```typescript
|
|
193
190
|
// Simple delay
|
|
194
|
-
await
|
|
191
|
+
await new DelayTask({}, { delay: 5000 }).run(); // 5 second delay
|
|
195
192
|
|
|
196
193
|
// Delay with data pass-through
|
|
197
|
-
const result = await new DelayTask(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
const result = await new DelayTask(
|
|
195
|
+
{ message: "Data preserved through delay" },
|
|
196
|
+
{ delay: 3000 }
|
|
197
|
+
).run();
|
|
201
198
|
console.log(result); // { message: "Data preserved through delay" }
|
|
202
199
|
|
|
203
200
|
// In workflow
|
|
204
201
|
const workflow = new Workflow()
|
|
205
202
|
.fetch({ url: "https://api.example.com/data" })
|
|
206
|
-
.delay({ delay: 2000 }) // 2 second delay
|
|
207
|
-
.debugLog({ log_level: "info" });
|
|
203
|
+
.delay(undefined, { delay: 2000 }) // 2 second delay
|
|
204
|
+
.debugLog(undefined, { log_level: "info" });
|
|
208
205
|
```
|
|
209
206
|
|
|
210
207
|
**Features:**
|
|
@@ -212,7 +209,7 @@ const workflow = new Workflow()
|
|
|
212
209
|
- Progress tracking for delays over 100ms
|
|
213
210
|
- Cancellation support via AbortSignal
|
|
214
211
|
- Chunked delay execution for responsiveness
|
|
215
|
-
-
|
|
212
|
+
- All inputs passed through to outputs
|
|
216
213
|
|
|
217
214
|
### JavaScriptTask
|
|
218
215
|
|
|
@@ -413,9 +410,7 @@ const linearWorkflow = await new JsonTask({
|
|
|
413
410
|
{
|
|
414
411
|
id: "log-data",
|
|
415
412
|
type: "DebugLogTask",
|
|
416
|
-
|
|
417
|
-
log_level: "info",
|
|
418
|
-
},
|
|
413
|
+
config: { log_level: "info" },
|
|
419
414
|
dependencies: {
|
|
420
415
|
console: { id: "fetch-data", output: "json" },
|
|
421
416
|
},
|
|
@@ -423,7 +418,7 @@ const linearWorkflow = await new JsonTask({
|
|
|
423
418
|
{
|
|
424
419
|
id: "delay",
|
|
425
420
|
type: "DelayTask",
|
|
426
|
-
|
|
421
|
+
config: { delay: 1000 },
|
|
427
422
|
},
|
|
428
423
|
]),
|
|
429
424
|
}).run();
|
|
@@ -470,7 +465,7 @@ const complexWorkflow = await new JsonTask({
|
|
|
470
465
|
{
|
|
471
466
|
id: "log-result",
|
|
472
467
|
type: "DebugLogTask",
|
|
473
|
-
|
|
468
|
+
config: { log_level: "dir" },
|
|
474
469
|
dependencies: {
|
|
475
470
|
console: { id: "combine-data", output: "output" },
|
|
476
471
|
},
|
|
@@ -583,8 +578,8 @@ const workflow = new Workflow()
|
|
|
583
578
|
.javaScript({
|
|
584
579
|
code: "return input.json.filter(item => item.status === 'active');",
|
|
585
580
|
})
|
|
586
|
-
.debugLog({ log_level: "info" })
|
|
587
|
-
.delay({ delay: 500 })
|
|
581
|
+
.debugLog(undefined, { log_level: "info" })
|
|
582
|
+
.delay(undefined, { delay: 500 })
|
|
588
583
|
.lambda(
|
|
589
584
|
{},
|
|
590
585
|
{
|
package/dist/browser.js
CHANGED
|
@@ -1213,7 +1213,7 @@ class ArrayTask extends GraphAsTask {
|
|
|
1213
1213
|
const inputObject = Object.fromEntries(arrayInputs);
|
|
1214
1214
|
const combinations = this.generateCombinations(inputObject, inputIds);
|
|
1215
1215
|
const tasks = combinations.map((combination) => {
|
|
1216
|
-
const { id,
|
|
1216
|
+
const { id, title, ...rest } = this.config;
|
|
1217
1217
|
const task = new this.constructor({ ...this.defaults, ...this.runInputData, ...combination }, { ...rest, id: `${id}_${uuid4()}` });
|
|
1218
1218
|
return task;
|
|
1219
1219
|
});
|
|
@@ -1286,16 +1286,13 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
}
|
|
1288
1288
|
// src/task/DebugLogTask.ts
|
|
1289
|
-
import { CreateWorkflow as CreateWorkflow12, Task as Task11, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
1289
|
+
import { CreateWorkflow as CreateWorkflow12, Task as Task11, TaskConfigSchema, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
1290
1290
|
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
1291
1291
|
var DEFAULT_LOG_LEVEL = "log";
|
|
1292
|
-
var
|
|
1292
|
+
var debugLogTaskConfigSchema = {
|
|
1293
1293
|
type: "object",
|
|
1294
1294
|
properties: {
|
|
1295
|
-
|
|
1296
|
-
title: "Message",
|
|
1297
|
-
description: "The message to log"
|
|
1298
|
-
},
|
|
1295
|
+
...TaskConfigSchema["properties"],
|
|
1299
1296
|
log_level: {
|
|
1300
1297
|
type: "string",
|
|
1301
1298
|
enum: log_levels,
|
|
@@ -1306,15 +1303,15 @@ var inputSchema12 = {
|
|
|
1306
1303
|
},
|
|
1307
1304
|
additionalProperties: false
|
|
1308
1305
|
};
|
|
1306
|
+
var inputSchema12 = {
|
|
1307
|
+
type: "object",
|
|
1308
|
+
properties: {},
|
|
1309
|
+
additionalProperties: true
|
|
1310
|
+
};
|
|
1309
1311
|
var outputSchema12 = {
|
|
1310
1312
|
type: "object",
|
|
1311
|
-
properties: {
|
|
1312
|
-
|
|
1313
|
-
title: "Messages",
|
|
1314
|
-
description: "The messages logged by the task"
|
|
1315
|
-
}
|
|
1316
|
-
},
|
|
1317
|
-
additionalProperties: false
|
|
1313
|
+
properties: {},
|
|
1314
|
+
additionalProperties: true
|
|
1318
1315
|
};
|
|
1319
1316
|
|
|
1320
1317
|
class DebugLogTask extends Task11 {
|
|
@@ -1323,6 +1320,10 @@ class DebugLogTask extends Task11 {
|
|
|
1323
1320
|
static title = "Debug Log";
|
|
1324
1321
|
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
1325
1322
|
static cacheable = false;
|
|
1323
|
+
static passthroughInputsToOutputs = true;
|
|
1324
|
+
static configSchema() {
|
|
1325
|
+
return debugLogTaskConfigSchema;
|
|
1326
|
+
}
|
|
1326
1327
|
static inputSchema() {
|
|
1327
1328
|
return inputSchema12;
|
|
1328
1329
|
}
|
|
@@ -1330,13 +1331,14 @@ class DebugLogTask extends Task11 {
|
|
|
1330
1331
|
return outputSchema12;
|
|
1331
1332
|
}
|
|
1332
1333
|
async executeReactive(input, output) {
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1334
|
+
const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
|
|
1335
|
+
const inputRecord = input;
|
|
1336
|
+
if (log_level === "dir") {
|
|
1337
|
+
console.dir(inputRecord, { depth: null });
|
|
1336
1338
|
} else {
|
|
1337
|
-
console[log_level](
|
|
1339
|
+
console[log_level](inputRecord);
|
|
1338
1340
|
}
|
|
1339
|
-
output
|
|
1341
|
+
Object.assign(output, inputRecord);
|
|
1340
1342
|
return output;
|
|
1341
1343
|
}
|
|
1342
1344
|
}
|
|
@@ -1350,24 +1352,27 @@ import {
|
|
|
1350
1352
|
CreateWorkflow as CreateWorkflow13,
|
|
1351
1353
|
Task as Task12,
|
|
1352
1354
|
TaskAbortedError as TaskAbortedError2,
|
|
1355
|
+
TaskConfigSchema as TaskConfigSchema2,
|
|
1353
1356
|
Workflow as Workflow14
|
|
1354
1357
|
} from "@workglow/task-graph";
|
|
1355
1358
|
import { sleep } from "@workglow/util";
|
|
1356
|
-
var
|
|
1359
|
+
var delayTaskConfigSchema = {
|
|
1357
1360
|
type: "object",
|
|
1358
1361
|
properties: {
|
|
1362
|
+
...TaskConfigSchema2["properties"],
|
|
1359
1363
|
delay: {
|
|
1360
1364
|
type: "number",
|
|
1361
1365
|
title: "Delay (ms)",
|
|
1362
1366
|
default: 1
|
|
1363
|
-
},
|
|
1364
|
-
pass_through: {
|
|
1365
|
-
title: "Pass Through",
|
|
1366
|
-
description: "Pass through data to the output"
|
|
1367
1367
|
}
|
|
1368
1368
|
},
|
|
1369
1369
|
additionalProperties: false
|
|
1370
1370
|
};
|
|
1371
|
+
var inputSchema13 = {
|
|
1372
|
+
type: "object",
|
|
1373
|
+
properties: {},
|
|
1374
|
+
additionalProperties: true
|
|
1375
|
+
};
|
|
1371
1376
|
var outputSchema13 = {
|
|
1372
1377
|
type: "object",
|
|
1373
1378
|
properties: {},
|
|
@@ -1379,6 +1384,11 @@ class DelayTask extends Task12 {
|
|
|
1379
1384
|
static category = "Utility";
|
|
1380
1385
|
static title = "Delay";
|
|
1381
1386
|
static description = "Delays execution for a specified duration with progress tracking";
|
|
1387
|
+
static cacheable = false;
|
|
1388
|
+
static passthroughInputsToOutputs = true;
|
|
1389
|
+
static configSchema() {
|
|
1390
|
+
return delayTaskConfigSchema;
|
|
1391
|
+
}
|
|
1382
1392
|
static inputSchema() {
|
|
1383
1393
|
return inputSchema13;
|
|
1384
1394
|
}
|
|
@@ -1386,7 +1396,7 @@ class DelayTask extends Task12 {
|
|
|
1386
1396
|
return outputSchema13;
|
|
1387
1397
|
}
|
|
1388
1398
|
async execute(input, executeContext) {
|
|
1389
|
-
const delay =
|
|
1399
|
+
const delay = this.config.delay ?? 1;
|
|
1390
1400
|
if (delay > 100) {
|
|
1391
1401
|
const iterations = Math.min(100, Math.floor(delay / 16));
|
|
1392
1402
|
const chunkSize = delay / iterations;
|
|
@@ -1400,10 +1410,10 @@ class DelayTask extends Task12 {
|
|
|
1400
1410
|
} else {
|
|
1401
1411
|
await sleep(delay);
|
|
1402
1412
|
}
|
|
1403
|
-
return input
|
|
1413
|
+
return input;
|
|
1404
1414
|
}
|
|
1405
1415
|
}
|
|
1406
|
-
var delay = (input, config = {}) => {
|
|
1416
|
+
var delay = (input, config = { delay: 1 }) => {
|
|
1407
1417
|
const task = new DelayTask({}, config);
|
|
1408
1418
|
return task.run(input);
|
|
1409
1419
|
};
|
|
@@ -1433,10 +1443,10 @@ class InputTask extends Task13 {
|
|
|
1433
1443
|
};
|
|
1434
1444
|
}
|
|
1435
1445
|
inputSchema() {
|
|
1436
|
-
return this.config?.
|
|
1446
|
+
return this.config?.inputSchema ?? this.constructor.inputSchema();
|
|
1437
1447
|
}
|
|
1438
1448
|
outputSchema() {
|
|
1439
|
-
return this.config?.
|
|
1449
|
+
return this.config?.outputSchema ?? this.constructor.outputSchema();
|
|
1440
1450
|
}
|
|
1441
1451
|
async execute(input) {
|
|
1442
1452
|
return input;
|
|
@@ -6066,9 +6076,19 @@ import {
|
|
|
6066
6076
|
CreateWorkflow as CreateWorkflow17,
|
|
6067
6077
|
DATAFLOW_ALL_PORTS,
|
|
6068
6078
|
Task as Task15,
|
|
6079
|
+
TaskConfigSchema as TaskConfigSchema3,
|
|
6069
6080
|
TaskConfigurationError as TaskConfigurationError3,
|
|
6070
6081
|
Workflow as Workflow18
|
|
6071
6082
|
} from "@workglow/task-graph";
|
|
6083
|
+
var lambdaTaskConfigSchema = {
|
|
6084
|
+
type: "object",
|
|
6085
|
+
properties: {
|
|
6086
|
+
...TaskConfigSchema3["properties"],
|
|
6087
|
+
execute: {},
|
|
6088
|
+
executeReactive: {}
|
|
6089
|
+
},
|
|
6090
|
+
additionalProperties: false
|
|
6091
|
+
};
|
|
6072
6092
|
var inputSchema16 = {
|
|
6073
6093
|
type: "object",
|
|
6074
6094
|
properties: {
|
|
@@ -6096,6 +6116,9 @@ class LambdaTask extends Task15 {
|
|
|
6096
6116
|
static description = "A task that wraps a provided function and its input";
|
|
6097
6117
|
static category = "Hidden";
|
|
6098
6118
|
static cacheable = true;
|
|
6119
|
+
static configSchema() {
|
|
6120
|
+
return lambdaTaskConfigSchema;
|
|
6121
|
+
}
|
|
6099
6122
|
static inputSchema() {
|
|
6100
6123
|
return inputSchema16;
|
|
6101
6124
|
}
|
|
@@ -6208,10 +6231,10 @@ class OutputTask extends Task17 {
|
|
|
6208
6231
|
};
|
|
6209
6232
|
}
|
|
6210
6233
|
inputSchema() {
|
|
6211
|
-
return this.config?.
|
|
6234
|
+
return this.config?.inputSchema ?? this.constructor.inputSchema();
|
|
6212
6235
|
}
|
|
6213
6236
|
outputSchema() {
|
|
6214
|
-
return this.config?.
|
|
6237
|
+
return this.config?.outputSchema ?? this.constructor.outputSchema();
|
|
6215
6238
|
}
|
|
6216
6239
|
async execute(input2) {
|
|
6217
6240
|
return input2;
|
|
@@ -7568,6 +7591,7 @@ export {
|
|
|
7568
7591
|
mcpPromptGet,
|
|
7569
7592
|
mcpList,
|
|
7570
7593
|
mcpClientFactory5 as mcpClientFactory,
|
|
7594
|
+
lambdaTaskConfigSchema,
|
|
7571
7595
|
lambda,
|
|
7572
7596
|
json,
|
|
7573
7597
|
javaScript,
|
|
@@ -7616,4 +7640,4 @@ export {
|
|
|
7616
7640
|
ArrayTask
|
|
7617
7641
|
};
|
|
7618
7642
|
|
|
7619
|
-
//# debugId=
|
|
7643
|
+
//# debugId=B9BF1F6C8E1711C764756E2164756E21
|