@workglow/tasks 0.0.77 → 0.0.79
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -1
- package/dist/index.js.map +6 -4
- package/dist/task/MergeTask.d.ts +74 -0
- package/dist/task/MergeTask.d.ts.map +1 -0
- package/dist/task/SplitTask.d.ts +72 -0
- package/dist/task/SplitTask.d.ts.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CreateWorkflow, IExecuteContext, Task, TaskConfig } from "@workglow/task-graph";
|
|
7
|
+
import { FromSchema } from "@workglow/util";
|
|
8
|
+
declare const inputSchema: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {};
|
|
11
|
+
readonly additionalProperties: true;
|
|
12
|
+
};
|
|
13
|
+
declare const outputSchema: {
|
|
14
|
+
readonly type: "object";
|
|
15
|
+
readonly properties: {
|
|
16
|
+
readonly output: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly title: "Merged Array";
|
|
19
|
+
readonly description: "Array containing all input values in order";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
readonly additionalProperties: false;
|
|
23
|
+
};
|
|
24
|
+
export type MergeTaskInput = FromSchema<typeof inputSchema>;
|
|
25
|
+
export type MergeTaskOutput = FromSchema<typeof outputSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* MergeTask takes multiple inputs and merges them into a single array output.
|
|
28
|
+
* Input properties are collected and sorted by key name to create a deterministic output order.
|
|
29
|
+
* Useful for collecting results from parallel branches into a single array.
|
|
30
|
+
*
|
|
31
|
+
* Features:
|
|
32
|
+
* - Accepts any number of input properties (additionalProperties: true)
|
|
33
|
+
* - Merges all input values into a single array output
|
|
34
|
+
* - Sorts inputs by property name for consistent ordering
|
|
35
|
+
* - Output is always an array
|
|
36
|
+
*
|
|
37
|
+
* Example:
|
|
38
|
+
* Input: { input_0: "a", input_1: "b", input_2: "c" }
|
|
39
|
+
* Output: { output: ["a", "b", "c"] }
|
|
40
|
+
*/
|
|
41
|
+
export declare class MergeTask<Input extends MergeTaskInput = MergeTaskInput, Output extends MergeTaskOutput = MergeTaskOutput, Config extends TaskConfig = TaskConfig> extends Task<Input, Output, Config> {
|
|
42
|
+
static type: string;
|
|
43
|
+
static category: string;
|
|
44
|
+
static title: string;
|
|
45
|
+
static description: string;
|
|
46
|
+
static readonly cacheable = true;
|
|
47
|
+
static inputSchema(): {
|
|
48
|
+
readonly type: "object";
|
|
49
|
+
readonly properties: {};
|
|
50
|
+
readonly additionalProperties: true;
|
|
51
|
+
};
|
|
52
|
+
static outputSchema(): {
|
|
53
|
+
readonly type: "object";
|
|
54
|
+
readonly properties: {
|
|
55
|
+
readonly output: {
|
|
56
|
+
readonly type: "array";
|
|
57
|
+
readonly title: "Merged Array";
|
|
58
|
+
readonly description: "Array containing all input values in order";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly additionalProperties: false;
|
|
62
|
+
};
|
|
63
|
+
execute(input: Input, context: IExecuteContext): Promise<Output>;
|
|
64
|
+
}
|
|
65
|
+
export declare const Merge: (input: MergeTaskInput, config?: TaskConfig) => Promise<{
|
|
66
|
+
output?: unknown[] | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
declare module "@workglow/task-graph" {
|
|
69
|
+
interface Workflow {
|
|
70
|
+
Merge: CreateWorkflow<MergeTaskInput, MergeTaskOutput, TaskConfig>;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=MergeTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MergeTask.d.ts","s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sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CreateWorkflow, IExecuteContext, Task, TaskConfig } from "@workglow/task-graph";
|
|
7
|
+
import { FromSchema } from "@workglow/util";
|
|
8
|
+
declare const inputSchema: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly input: {
|
|
12
|
+
readonly title: "Single Input";
|
|
13
|
+
readonly description: "A single value to output";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly additionalProperties: false;
|
|
17
|
+
};
|
|
18
|
+
declare const outputSchema: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
readonly properties: {};
|
|
21
|
+
readonly additionalProperties: true;
|
|
22
|
+
};
|
|
23
|
+
export type SplitTaskInput = FromSchema<typeof inputSchema>;
|
|
24
|
+
export type SplitTaskOutput = FromSchema<typeof outputSchema>;
|
|
25
|
+
/**
|
|
26
|
+
* SplitTask takes an array or single value as input and creates
|
|
27
|
+
* separate outputs for each element. Each output is named by its index (0, 1, 2, etc.).
|
|
28
|
+
* Useful for workflows that need to process array elements in parallel branches.
|
|
29
|
+
*
|
|
30
|
+
* Features:
|
|
31
|
+
* - Accepts both arrays and single values as input
|
|
32
|
+
* - Creates one output per array element (output_0, output_1, etc.)
|
|
33
|
+
* - Single values are treated as a single-element array
|
|
34
|
+
* - Output count matches array length
|
|
35
|
+
*
|
|
36
|
+
* Example:
|
|
37
|
+
* Input: { input: [1, 2, 3] }
|
|
38
|
+
* Output: { output_0: 1, output_1: 2, output_2: 3 }
|
|
39
|
+
*/
|
|
40
|
+
export declare class SplitTask<Input extends SplitTaskInput = SplitTaskInput, Output extends SplitTaskOutput = SplitTaskOutput, Config extends TaskConfig = TaskConfig> extends Task<Input, Output, Config> {
|
|
41
|
+
static type: string;
|
|
42
|
+
static category: string;
|
|
43
|
+
static title: string;
|
|
44
|
+
static description: string;
|
|
45
|
+
static readonly cacheable = true;
|
|
46
|
+
static inputSchema(): {
|
|
47
|
+
readonly type: "object";
|
|
48
|
+
readonly properties: {
|
|
49
|
+
readonly input: {
|
|
50
|
+
readonly title: "Single Input";
|
|
51
|
+
readonly description: "A single value to output";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
readonly additionalProperties: false;
|
|
55
|
+
};
|
|
56
|
+
static outputSchema(): {
|
|
57
|
+
readonly type: "object";
|
|
58
|
+
readonly properties: {};
|
|
59
|
+
readonly additionalProperties: true;
|
|
60
|
+
};
|
|
61
|
+
execute(input: Input, context: IExecuteContext): Promise<Output>;
|
|
62
|
+
}
|
|
63
|
+
export declare const Split: (input: SplitTaskInput, config?: TaskConfig) => Promise<{
|
|
64
|
+
[x: string]: unknown;
|
|
65
|
+
}>;
|
|
66
|
+
declare module "@workglow/task-graph" {
|
|
67
|
+
interface Workflow {
|
|
68
|
+
Split: CreateWorkflow<SplitTaskInput, SplitTaskOutput, TaskConfig>;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=SplitTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitTask.d.ts","sourceRoot":"","sources":["../../src/task/SplitTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,IAAI,EACJ,UAAU,EAGX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D,QAAA,MAAM,WAAW;;;;;;;;;CASkB,CAAC;AAEpC,QAAA,MAAM,YAAY;;;;CAIiB,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAS,CACpB,KAAK,SAAS,cAAc,GAAG,cAAc,EAC7C,MAAM,SAAS,eAAe,GAAG,eAAe,EAChD,MAAM,SAAS,UAAU,GAAG,UAAU,CACtC,SAAQ,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IACnC,OAAc,IAAI,SAAe;IACjC,OAAc,QAAQ,SAAa;IACnC,OAAc,KAAK,SAAW;IAC9B,OAAc,WAAW,SACoD;IAC7E,MAAM,CAAC,QAAQ,CAAC,SAAS,QAAQ;WAEnB,WAAW;;;;;;;;;;WAIX,YAAY;;;;;IAIpB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;CAgBvE;AAID,eAAO,MAAM,KAAK,GAAI,OAAO,cAAc,EAAE,SAAQ,UAAe;;EAGnE,CAAC;AAEF,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,QAAQ;QAChB,KAAK,EAAE,cAAc,CAAC,cAAc,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;KACpE;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workglow/tasks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.79",
|
|
5
5
|
"description": "Pre-built task implementations for Workglow, including common AI operations and utility functions.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"watch": "concurrently -c 'auto' 'bun:watch-*'",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@workglow/task-graph": "0.0.
|
|
34
|
-
"@workglow/util": "0.0.
|
|
35
|
-
"@workglow/job-queue": "0.0.
|
|
36
|
-
"@workglow/storage": "0.0.
|
|
33
|
+
"@workglow/task-graph": "0.0.79",
|
|
34
|
+
"@workglow/util": "0.0.79",
|
|
35
|
+
"@workglow/job-queue": "0.0.79",
|
|
36
|
+
"@workglow/storage": "0.0.79"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@workglow/task-graph": {
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@workglow/job-queue": "0.0.
|
|
54
|
-
"@workglow/storage": "0.0.
|
|
55
|
-
"@workglow/task-graph": "0.0.
|
|
56
|
-
"@workglow/util": "0.0.
|
|
53
|
+
"@workglow/job-queue": "0.0.79",
|
|
54
|
+
"@workglow/storage": "0.0.79",
|
|
55
|
+
"@workglow/task-graph": "0.0.79",
|
|
56
|
+
"@workglow/util": "0.0.79"
|
|
57
57
|
}
|
|
58
58
|
}
|