@workglow/task-graph 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js.map +19 -19
- package/dist/bun.js.map +19 -19
- package/dist/node.js.map +19 -19
- package/dist/storage/TaskOutputRepository.d.ts +0 -48
- package/dist/storage/TaskOutputRepository.d.ts.map +1 -1
- package/dist/task/ConditionalTask.d.ts +10 -202
- package/dist/task/ConditionalTask.d.ts.map +1 -1
- package/dist/task/FallbackTask.d.ts +7 -59
- package/dist/task/FallbackTask.d.ts.map +1 -1
- package/dist/task/GraphAsTask.d.ts +8 -28
- package/dist/task/GraphAsTask.d.ts.map +1 -1
- package/dist/task/ITask.d.ts +2 -27
- package/dist/task/ITask.d.ts.map +1 -1
- package/dist/task/InputResolver.d.ts +0 -3
- package/dist/task/InputResolver.d.ts.map +1 -1
- package/dist/task/IteratorTask.d.ts +5 -43
- package/dist/task/IteratorTask.d.ts.map +1 -1
- package/dist/task/MapTask.d.ts +1 -25
- package/dist/task/MapTask.d.ts.map +1 -1
- package/dist/task/ReduceTask.d.ts +0 -18
- package/dist/task/ReduceTask.d.ts.map +1 -1
- package/dist/task/Task.d.ts +1 -105
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task/TaskError.d.ts +2 -29
- package/dist/task/TaskError.d.ts.map +1 -1
- package/dist/task/TaskJSON.d.ts +0 -10
- package/dist/task/TaskJSON.d.ts.map +1 -1
- package/dist/task/TaskRegistry.d.ts +0 -14
- package/dist/task/TaskRegistry.d.ts.map +1 -1
- package/dist/task/TaskRunner.d.ts +0 -41
- package/dist/task/TaskRunner.d.ts.map +1 -1
- package/dist/task/WhileTask.d.ts +3 -89
- package/dist/task/WhileTask.d.ts.map +1 -1
- package/dist/task-graph/Dataflow.d.ts +0 -28
- package/dist/task-graph/Dataflow.d.ts.map +1 -1
- package/dist/task-graph/TaskGraph.d.ts +0 -29
- package/dist/task-graph/TaskGraph.d.ts.map +1 -1
- package/dist/task-graph/TaskGraphRunner.d.ts +3 -65
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
- package/dist/task-graph/Workflow.d.ts +1 -60
- package/dist/task-graph/Workflow.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { EventParameters } from "@workglow/util";
|
|
7
7
|
import { TaskInput, TaskOutput } from "../task/TaskTypes";
|
|
8
|
-
/**
|
|
9
|
-
* Service token for TaskOutputRepository
|
|
10
|
-
*/
|
|
11
8
|
export declare const TASK_OUTPUT_REPOSITORY: import("@workglow/util").ServiceToken<TaskOutputRepository>;
|
|
12
9
|
export type TaskOutputEventListeners = {
|
|
13
10
|
output_saved: (taskType: string) => void;
|
|
@@ -23,42 +20,15 @@ export type TaskOutputEventParameters<Event extends TaskOutputEvents> = EventPar
|
|
|
23
20
|
* Provides methods for saving, retrieving, and clearing task outputs
|
|
24
21
|
*/
|
|
25
22
|
export declare abstract class TaskOutputRepository {
|
|
26
|
-
/**
|
|
27
|
-
* Whether to compress the output
|
|
28
|
-
*/
|
|
29
23
|
outputCompression: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Constructor for the TaskOutputRepository
|
|
32
|
-
* @param options The options for the repository
|
|
33
|
-
*/
|
|
34
24
|
constructor({ outputCompression }: {
|
|
35
25
|
outputCompression?: boolean | undefined;
|
|
36
26
|
});
|
|
37
27
|
private get events();
|
|
38
28
|
private _events;
|
|
39
|
-
/**
|
|
40
|
-
* Registers an event listener for a specific event
|
|
41
|
-
* @param name The event name to listen for
|
|
42
|
-
* @param fn The callback function to execute when the event occurs
|
|
43
|
-
*/
|
|
44
29
|
on<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>): void;
|
|
45
|
-
/**
|
|
46
|
-
* Removes an event listener for a specific event
|
|
47
|
-
* @param name The event name to stop listening for
|
|
48
|
-
* @param fn The callback function to remove
|
|
49
|
-
*/
|
|
50
30
|
off<Event extends TaskOutputEvents>(name: Event, fn: TaskOutputEventListener<Event>): void;
|
|
51
|
-
/**
|
|
52
|
-
* Returns a promise that resolves when the event is emitted
|
|
53
|
-
* @param name The event name to listen for
|
|
54
|
-
* @returns a promise that resolves to the event parameters
|
|
55
|
-
*/
|
|
56
31
|
waitOn<Event extends TaskOutputEvents>(name: Event): Promise<TaskOutputEventParameters<Event>>;
|
|
57
|
-
/**
|
|
58
|
-
* Emits an event (if there are listeners)
|
|
59
|
-
* @param name The event name to emit
|
|
60
|
-
* @param args The event parameters
|
|
61
|
-
*/
|
|
62
32
|
emit<Event extends TaskOutputEvents>(name: Event, ...args: TaskOutputEventParameters<Event>): void;
|
|
63
33
|
/**
|
|
64
34
|
* Persist a task output keyed by `(taskType, fingerprint(inputs))`.
|
|
@@ -70,27 +40,9 @@ export declare abstract class TaskOutputRepository {
|
|
|
70
40
|
* upsert behavior is also fine there.
|
|
71
41
|
*/
|
|
72
42
|
abstract saveOutput(taskType: string, inputs: TaskInput, output: TaskOutput, createdAt?: Date): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves a task output from the repository
|
|
75
|
-
* @param taskType The type of task to retrieve the output for
|
|
76
|
-
* @param inputs The input parameters for the task
|
|
77
|
-
* @returns The retrieved task output, or undefined if not found
|
|
78
|
-
*/
|
|
79
43
|
abstract getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined>;
|
|
80
|
-
/**
|
|
81
|
-
* Clears all task outputs from the repository
|
|
82
|
-
* @emits output_cleared when the operation completes
|
|
83
|
-
*/
|
|
84
44
|
abstract clear(): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Returns the number of task outputs stored in the repository
|
|
87
|
-
* @returns The count of stored task outputs
|
|
88
|
-
*/
|
|
89
45
|
abstract size(): Promise<number>;
|
|
90
|
-
/**
|
|
91
|
-
* Clear all task outputs from the repository that are older than the given date
|
|
92
|
-
* @param olderThanInMs The time in milliseconds to clear task outputs older than
|
|
93
|
-
*/
|
|
94
46
|
abstract clearOlderThan(olderThanInMs: number): Promise<void>;
|
|
95
47
|
/**
|
|
96
48
|
* Whether entries written to this repository will survive a process crash / restart.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskOutputRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"TaskOutputRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAoC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,sBAAsB,6DAElC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,wBAAwB,CAAC;AAE9D,MAAM,MAAM,uBAAuB,CAAC,KAAK,SAAS,gBAAgB,IAChE,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAElC,MAAM,MAAM,yBAAyB,CAAC,KAAK,SAAS,gBAAgB,IAAI,eAAe,CACrF,wBAAwB,EACxB,KAAK,CACN,CAAC;AAEF;;;GAGG;AACH,8BAAsB,oBAAoB;IACxC,iBAAiB,EAAE,OAAO,CAAC;IAE3B,YAAY,EAAE,iBAAwB,EAAE;;KAAA,EAE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AAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3F;IAED;;;;;;;OAOG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3D;CACF"}
|
|
@@ -10,71 +10,20 @@ import { Task } from "./Task";
|
|
|
10
10
|
import type { TaskConfig, TaskInput, TaskOutput, TaskTypeName } from "./TaskTypes";
|
|
11
11
|
/**
|
|
12
12
|
* A predicate function that evaluates whether a branch condition is met.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @template Input - The input type for the conditional task
|
|
16
|
-
* @param input - The input data to evaluate
|
|
17
|
-
* @returns true if the branch condition is met, false otherwise
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Simple numeric comparison
|
|
22
|
-
* const isHighValue: ConditionFn<{ value: number }> = (input) => input.value > 100;
|
|
23
|
-
*
|
|
24
|
-
* // String equality check
|
|
25
|
-
* const isAdmin: ConditionFn<{ role: string }> = (input) => input.role === "admin";
|
|
26
|
-
*
|
|
27
|
-
* // Complex boolean logic
|
|
28
|
-
* const isEligible: ConditionFn<{ age: number; verified: boolean }> = (input) =>
|
|
29
|
-
* input.age >= 18 && input.verified;
|
|
30
|
-
* ```
|
|
13
|
+
* Returns true if the branch should be active.
|
|
31
14
|
*/
|
|
32
15
|
export type ConditionFn<Input> = (input: Input) => boolean;
|
|
33
16
|
/**
|
|
34
|
-
* Configuration for a single branch in a ConditionalTask.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* When the condition evaluates to true, the branch becomes active and
|
|
38
|
-
* its output port will receive the task's input data.
|
|
39
|
-
*
|
|
40
|
-
* @template Input - The input type for the conditional task
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const highValueBranch: BranchConfig<{ amount: number }> = {
|
|
45
|
-
* id: "high",
|
|
46
|
-
* condition: (input) => input.amount > 1000,
|
|
47
|
-
* outputPort: "highValue"
|
|
48
|
-
* };
|
|
49
|
-
* ```
|
|
17
|
+
* Configuration for a single branch in a ConditionalTask. When `condition`
|
|
18
|
+
* returns true, the branch becomes active and its output port receives the
|
|
19
|
+
* task's input data.
|
|
50
20
|
*/
|
|
51
21
|
export interface BranchConfig<Input> {
|
|
52
|
-
/** Unique identifier for this branch within the task */
|
|
53
22
|
readonly id: string;
|
|
54
|
-
/** Predicate function that determines if this branch is active */
|
|
55
23
|
readonly condition: ConditionFn<Input>;
|
|
56
24
|
/** Name of the output port that will receive data when this branch is active */
|
|
57
25
|
readonly outputPort: string;
|
|
58
26
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Configuration interface for ConditionalTask.
|
|
61
|
-
*
|
|
62
|
-
* Extends the base TaskConfig with conditional-specific options including
|
|
63
|
-
* branch definitions, default branch handling, and execution mode.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const config: ConditionalTaskConfig = {
|
|
68
|
-
* id: "router",
|
|
69
|
-
* branches: [
|
|
70
|
-
* { id: "premium", condition: (i) => i.tier === "premium", outputPort: "premium" },
|
|
71
|
-
* { id: "standard", condition: (i) => i.tier === "standard", outputPort: "standard" },
|
|
72
|
-
* ],
|
|
73
|
-
* defaultBranch: "standard",
|
|
74
|
-
* exclusive: true, // Only first matching branch activates
|
|
75
|
-
* };
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
27
|
export declare const conditionalTaskConfigSchema: {
|
|
79
28
|
readonly type: "object";
|
|
80
29
|
readonly properties: {
|
|
@@ -144,92 +93,17 @@ export type ConditionalTaskConfig = TaskConfig & {
|
|
|
144
93
|
/**
|
|
145
94
|
* A task that evaluates conditions to determine which downstream paths are active.
|
|
146
95
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* dataflows to
|
|
151
|
-
*
|
|
152
|
-
* ## Key Features
|
|
153
|
-
*
|
|
154
|
-
* - **Condition-based routing**: Route data to different downstream tasks based on input values
|
|
155
|
-
* - **Exclusive mode**: Act as a switch/case where only the first matching branch activates
|
|
156
|
-
* - **Multi-path mode**: Enable multiple branches simultaneously when conditions match
|
|
157
|
-
* - **Default branch**: Specify a fallback branch when no conditions match
|
|
158
|
-
* - **Disabled propagation**: Inactive branches result in DISABLED status for downstream tasks
|
|
159
|
-
*
|
|
160
|
-
* ## Execution Modes
|
|
161
|
-
*
|
|
162
|
-
* ### Exclusive Mode (default)
|
|
163
|
-
* In exclusive mode (`exclusive: true`), the task behaves like a switch statement.
|
|
164
|
-
* Branches are evaluated in order, and only the first matching branch becomes active.
|
|
165
|
-
* This is useful for mutually exclusive paths.
|
|
166
|
-
*
|
|
167
|
-
* ### Multi-Path Mode
|
|
168
|
-
* In multi-path mode (`exclusive: false`), all branches whose conditions evaluate
|
|
169
|
-
* to true become active simultaneously. This enables fan-out patterns where the
|
|
170
|
-
* same input triggers multiple downstream processing paths.
|
|
171
|
-
*
|
|
172
|
-
* ## Output Behavior
|
|
173
|
-
*
|
|
174
|
-
* For each active branch, the task passes through its entire input to that branch's
|
|
175
|
-
* output port. Inactive branches receive no data, and their outgoing dataflows are
|
|
176
|
-
* set to DISABLED status, which cascades to downstream tasks that have no other
|
|
177
|
-
* active inputs.
|
|
178
|
-
*
|
|
179
|
-
* @template Input - The input type for the task
|
|
180
|
-
* @template Output - The output type for the task
|
|
181
|
-
* @template Config - The configuration type (must extend ConditionalTaskConfig)
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```typescript
|
|
185
|
-
* // Simple if/else routing based on a numeric threshold
|
|
186
|
-
* const thresholdRouter = new ConditionalTask(
|
|
187
|
-
* {},
|
|
188
|
-
* {
|
|
189
|
-
* branches: [
|
|
190
|
-
* { id: "high", condition: (i) => i.value > 100, outputPort: "highPath" },
|
|
191
|
-
* { id: "low", condition: (i) => i.value <= 100, outputPort: "lowPath" },
|
|
192
|
-
* ],
|
|
193
|
-
* }
|
|
194
|
-
* );
|
|
195
|
-
*
|
|
196
|
-
* // Switch/case style routing based on string enum
|
|
197
|
-
* const statusRouter = new ConditionalTask(
|
|
198
|
-
* {},
|
|
199
|
-
* {
|
|
200
|
-
* branches: [
|
|
201
|
-
* { id: "active", condition: (i) => i.status === "active", outputPort: "active" },
|
|
202
|
-
* { id: "pending", condition: (i) => i.status === "pending", outputPort: "pending" },
|
|
203
|
-
* { id: "inactive", condition: (i) => i.status === "inactive", outputPort: "inactive" },
|
|
204
|
-
* ],
|
|
205
|
-
* defaultBranch: "inactive",
|
|
206
|
-
* exclusive: true,
|
|
207
|
-
* }
|
|
208
|
-
* );
|
|
209
|
-
*
|
|
210
|
-
* // Multi-path fan-out for parallel processing
|
|
211
|
-
* const fanOut = new ConditionalTask(
|
|
212
|
-
* {},
|
|
213
|
-
* {
|
|
214
|
-
* branches: [
|
|
215
|
-
* { id: "log", condition: () => true, outputPort: "logger" },
|
|
216
|
-
* { id: "process", condition: () => true, outputPort: "processor" },
|
|
217
|
-
* { id: "archive", condition: (i) => i.shouldArchive, outputPort: "archiver" },
|
|
218
|
-
* ],
|
|
219
|
-
* exclusive: false, // All matching branches activate
|
|
220
|
-
* }
|
|
221
|
-
* );
|
|
222
|
-
* ```
|
|
96
|
+
* Implements conditional branching within a task graph (if/then/else or switch/case).
|
|
97
|
+
* In exclusive mode (default), branches are evaluated in order and only the first
|
|
98
|
+
* match activates. In multi-path mode, all matching branches activate simultaneously.
|
|
99
|
+
* Inactive branches DISABLE their outgoing dataflows, cascading to downstream tasks
|
|
100
|
+
* with no other active inputs.
|
|
223
101
|
*/
|
|
224
102
|
export declare class ConditionalTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends ConditionalTaskConfig = ConditionalTaskConfig> extends Task<Input, Output, Config> {
|
|
225
|
-
/** Task type identifier for serialization and registry lookup */
|
|
226
103
|
static type: TaskTypeName;
|
|
227
|
-
/** Category for UI organization and filtering */
|
|
228
104
|
static category: string;
|
|
229
|
-
/** Human-readable title for display in UIs */
|
|
230
105
|
static title: string;
|
|
231
106
|
static description: string;
|
|
232
|
-
/** This task has dynamic schemas that change based on branch configuration */
|
|
233
107
|
static hasDynamicSchemas: boolean;
|
|
234
108
|
static configSchema(): DataPortSchema;
|
|
235
109
|
canSerializeConfig(): boolean;
|
|
@@ -239,14 +113,6 @@ export declare class ConditionalTask<Input extends TaskInput = TaskInput, Output
|
|
|
239
113
|
* determine which dataflows should be enabled vs disabled.
|
|
240
114
|
*/
|
|
241
115
|
activeBranches: Set<string>;
|
|
242
|
-
/**
|
|
243
|
-
* Evaluates branch conditions and determines which branches are active.
|
|
244
|
-
* Only active branches will have their output ports populated.
|
|
245
|
-
*
|
|
246
|
-
* @param input - The input data to evaluate conditions against
|
|
247
|
-
* @param context - Execution context with signal and progress callback
|
|
248
|
-
* @returns Output with active branch data and metadata
|
|
249
|
-
*/
|
|
250
116
|
/**
|
|
251
117
|
* Builds runtime branch configs from serialized UI condition config.
|
|
252
118
|
*/
|
|
@@ -271,71 +137,13 @@ export declare class ConditionalTask<Input extends TaskInput = TaskInput, Output
|
|
|
271
137
|
* @returns Output object with active branch ports populated
|
|
272
138
|
*/
|
|
273
139
|
protected buildOutput(input: Input): Output;
|
|
274
|
-
/**
|
|
275
|
-
* Checks if a specific branch is currently active.
|
|
276
|
-
*
|
|
277
|
-
* @param branchId - The ID of the branch to check
|
|
278
|
-
* @returns true if the branch is active, false otherwise
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* ```typescript
|
|
282
|
-
* await conditionalTask.run({ value: 150 });
|
|
283
|
-
* if (conditionalTask.isBranchActive("high")) {
|
|
284
|
-
* console.log("High value path was taken");
|
|
285
|
-
* }
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
140
|
isBranchActive(branchId: string): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Gets the set of currently active branch IDs.
|
|
291
|
-
* Returns a new Set to prevent external modification.
|
|
292
|
-
*
|
|
293
|
-
* @returns Set of active branch IDs
|
|
294
|
-
*/
|
|
141
|
+
/** Returns a copy to prevent external modification. */
|
|
295
142
|
getActiveBranches(): Set<string>;
|
|
296
|
-
/**
|
|
297
|
-
* Gets a map of output port names to their active status.
|
|
298
|
-
* Useful for inspecting which output ports will have data.
|
|
299
|
-
*
|
|
300
|
-
* @returns Map of output port name to boolean active status
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```typescript
|
|
304
|
-
* const portStatus = conditionalTask.getPortActiveStatus();
|
|
305
|
-
* for (const [port, isActive] of portStatus) {
|
|
306
|
-
* console.log(`Port ${port}: ${isActive ? "active" : "inactive"}`);
|
|
307
|
-
* }
|
|
308
|
-
* ```
|
|
309
|
-
*/
|
|
310
143
|
getPortActiveStatus(): Map<string, boolean>;
|
|
311
|
-
/**
|
|
312
|
-
* Generates the output schema dynamically based on configured branches.
|
|
313
|
-
* Each branch's output port is defined as an object type that will
|
|
314
|
-
* receive the pass-through input data when active.
|
|
315
|
-
*
|
|
316
|
-
* @returns JSON Schema for the task's output
|
|
317
|
-
*/
|
|
318
144
|
static outputSchema(): DataPortSchema;
|
|
319
|
-
/**
|
|
320
|
-
* Instance method to get output schema with branch-specific ports.
|
|
321
|
-
* Dynamically generates properties based on the configured branches.
|
|
322
|
-
*
|
|
323
|
-
* @returns JSON Schema for the task's output including branch ports
|
|
324
|
-
*/
|
|
325
145
|
outputSchema(): DataPortSchema;
|
|
326
|
-
/**
|
|
327
|
-
* Returns schema indicating the task accepts any input.
|
|
328
|
-
* ConditionalTask passes through its input to active branches,
|
|
329
|
-
* so it doesn't constrain the input type.
|
|
330
|
-
*
|
|
331
|
-
* @returns Schema that accepts any input
|
|
332
|
-
*/
|
|
333
146
|
static inputSchema(): DataPortSchema;
|
|
334
|
-
/**
|
|
335
|
-
* Instance method returning schema that accepts any input.
|
|
336
|
-
*
|
|
337
|
-
* @returns Schema that accepts any input
|
|
338
|
-
*/
|
|
339
147
|
inputSchema(): DataPortSchema;
|
|
340
148
|
}
|
|
341
149
|
//# sourceMappingURL=ConditionalTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionalTask.d.ts","sourceRoot":"","sources":["../../src/task/ConditionalTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConditionalTask.d.ts","sourceRoot":"","sources":["../../src/task/ConditionalTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGnF;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACvC,gFAAgF;IAChF,Q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Z,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA2C7B;IAED;;;OAGG;IACH,SAAS,CAAC,0BAA0B,CAClC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,EAC/B,WAAW,EAAE,OAAO,GACnB,MAAM,CAsCR;IAED;;;;;;OAMG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAgB1C;IAMM,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/C;IAED,uDAAuD;IAChD,iBAAiB,IAAI,GAAG,CAAC,MAAM,CAAC,CAEtC;IAEM,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CASjD;IAMD,OAAgB,YAAY,IAAI,cAAc,CAa7C;IAEQ,YAAY,IAAI,cAAc,CAwBtC;IAED,OAAgB,WAAW,IAAI,cAAc,CAM5C;IAEQ,WAAW,IAAI,cAAc,CAMrC;CACF"}
|
|
@@ -11,12 +11,8 @@ import { GraphAsTask } from "./GraphAsTask";
|
|
|
11
11
|
import type { TaskInput, TaskOutput, TaskTypeName } from "./TaskTypes";
|
|
12
12
|
/**
|
|
13
13
|
* Execution mode for the fallback task.
|
|
14
|
-
*
|
|
15
|
-
* - `"
|
|
16
|
-
* They are tried sequentially until one succeeds.
|
|
17
|
-
*
|
|
18
|
-
* - `"data"`: The subgraph contains a template workflow that is executed
|
|
19
|
-
* multiple times with different input overrides from the `alternatives` array.
|
|
14
|
+
* - `"task"`: each task in the subgraph is an independent alternative tried sequentially.
|
|
15
|
+
* - `"data"`: the subgraph is a template workflow re-run with each entry in `alternatives`.
|
|
20
16
|
*/
|
|
21
17
|
export type FallbackMode = "task" | "data";
|
|
22
18
|
export declare const fallbackTaskConfigSchema: {
|
|
@@ -78,10 +74,6 @@ export declare const fallbackTaskConfigSchema: {
|
|
|
78
74
|
};
|
|
79
75
|
readonly additionalProperties: false;
|
|
80
76
|
};
|
|
81
|
-
/**
|
|
82
|
-
* Configuration type for FallbackTask.
|
|
83
|
-
* Extends GraphAsTaskConfig with fallback-specific options.
|
|
84
|
-
*/
|
|
85
77
|
export type FallbackTaskConfig<Input extends TaskInput = TaskInput> = GraphAsTaskConfig<Input> & {
|
|
86
78
|
/**
|
|
87
79
|
* The fallback execution mode.
|
|
@@ -107,62 +99,18 @@ export type FallbackTaskConfig<Input extends TaskInput = TaskInput> = GraphAsTas
|
|
|
107
99
|
readonly alternatives?: Record<string, unknown>[];
|
|
108
100
|
};
|
|
109
101
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* FallbackTask provides resilient execution by automatically falling back to
|
|
113
|
-
* alternative strategies when one fails. This is essential for production AI
|
|
114
|
-
* workflows where provider availability is unpredictable.
|
|
115
|
-
*
|
|
116
|
-
* ## Execution Modes
|
|
117
|
-
*
|
|
118
|
-
* ### Task Mode (`fallbackMode: "task"`)
|
|
119
|
-
* Each task added to the subgraph is an independent alternative. They are
|
|
120
|
-
* tried sequentially in insertion order. The first successful result is
|
|
121
|
-
* returned and remaining alternatives are skipped.
|
|
122
|
-
*
|
|
123
|
-
* ```typescript
|
|
124
|
-
* // Via Workflow API:
|
|
125
|
-
* workflow
|
|
126
|
-
* .fallback()
|
|
127
|
-
* .notifySlack({ channel: "#alerts", message: "Hello" })
|
|
128
|
-
* .notifyEmail({ to: "admin@example.com", subject: "Alert" })
|
|
129
|
-
* .notifySms({ phone: "+1234567890", message: "Alert" })
|
|
130
|
-
* .endFallback();
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* ### Data Mode (`fallbackMode: "data"`)
|
|
134
|
-
* The subgraph contains a template workflow that is executed multiple times,
|
|
135
|
-
* each time with different input data merged from the `alternatives` array.
|
|
136
|
-
*
|
|
137
|
-
* ```typescript
|
|
138
|
-
* // Via Workflow API:
|
|
139
|
-
* workflow
|
|
140
|
-
* .fallbackWith([
|
|
141
|
-
* { model: "openai:gpt-4" },
|
|
142
|
-
* { model: "anthropic:claude-sonnet-4-20250514" },
|
|
143
|
-
* { model: "onnx:Xenova/LaMini-Flan-T5-783M:q8" },
|
|
144
|
-
* ])
|
|
145
|
-
* .textGeneration({ prompt: "Hello" })
|
|
146
|
-
* .endFallbackWith();
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* ## Error Handling
|
|
150
|
-
*
|
|
151
|
-
* If all alternatives fail, a `TaskFailedError` is thrown with a message
|
|
152
|
-
* that includes all individual error messages. Each attempt's error is
|
|
153
|
-
* collected and reported for debugging.
|
|
154
|
-
*
|
|
155
|
-
* ## Output
|
|
102
|
+
* Tries multiple alternatives and returns the first successful result.
|
|
156
103
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
104
|
+
* In task mode each child is an independent alternative tried sequentially;
|
|
105
|
+
* in data mode the subgraph is a template re-run with each entry in
|
|
106
|
+
* `alternatives` merged into the input. If all alternatives fail a
|
|
107
|
+
* `TaskFailedError` aggregating each attempt's error is thrown.
|
|
159
108
|
*/
|
|
160
109
|
export declare class FallbackTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends FallbackTaskConfig<Input> = FallbackTaskConfig<Input>> extends GraphAsTask<Input, Output, Config> {
|
|
161
110
|
static type: TaskTypeName;
|
|
162
111
|
static category: string;
|
|
163
112
|
static title: string;
|
|
164
113
|
static description: string;
|
|
165
|
-
/** FallbackTask has dynamic schemas based on the subgraph structure. */
|
|
166
114
|
static hasDynamicSchemas: boolean;
|
|
167
115
|
static configSchema(): DataPortSchema;
|
|
168
116
|
_runner: FallbackTaskRunner<Input, Output, Config>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FallbackTask.d.ts","sourceRoot":"","sources":["../../src/task/FallbackTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAyB,k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AMG;QACH,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC;QAEhE;;WAEG;QACH,eAAe,IAAI,QAAQ,CAAC;KAC7B;CACF"}
|
|
@@ -82,14 +82,11 @@ export declare class GraphAsTask<Input extends TaskInput = TaskInput, Output ext
|
|
|
82
82
|
/** Entitlements are always dynamic — they depend on child tasks in the subgraph */
|
|
83
83
|
static hasDynamicEntitlements: boolean;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
85
|
+
* `subGraph` is extracted from `config` and applied to the instance before
|
|
86
|
+
* validating the remainder of the config.
|
|
87
87
|
*/
|
|
88
88
|
constructor(config?: Partial<Config>, runConfig?: Partial<IRunConfig>);
|
|
89
89
|
_runner: GraphAsTaskRunner<Input, Output, Config>;
|
|
90
|
-
/**
|
|
91
|
-
* Task runner for handling the task execution
|
|
92
|
-
*/
|
|
93
90
|
get runner(): GraphAsTaskRunner<Input, Output, Config>;
|
|
94
91
|
static configSchema(): DataPortSchema;
|
|
95
92
|
get compoundMerge(): CompoundMergeStrategy;
|
|
@@ -104,23 +101,16 @@ export declare class GraphAsTask<Input extends TaskInput = TaskInput, Output ext
|
|
|
104
101
|
*/
|
|
105
102
|
inputSchema(): DataPortSchema;
|
|
106
103
|
protected _inputSchemaNode: SchemaNode | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Gets the compiled input schema
|
|
109
|
-
*/
|
|
110
104
|
protected getInputSchemaNode(): SchemaNode;
|
|
111
105
|
/**
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
* The output schema depends on the compoundMerge strategy and the nodes at the last level
|
|
106
|
+
* Compute output schema dynamically from the subgraph. Depends on the
|
|
107
|
+
* compoundMerge strategy and the nodes at the last level.
|
|
115
108
|
*/
|
|
116
109
|
outputSchema(): DataPortSchema;
|
|
117
110
|
/**
|
|
118
|
-
*
|
|
111
|
+
* Aggregates entitlements from all tasks in the subgraph.
|
|
119
112
|
*/
|
|
120
113
|
entitlements(): TaskEntitlements;
|
|
121
|
-
/**
|
|
122
|
-
* Resets input data to defaults
|
|
123
|
-
*/
|
|
124
114
|
resetInputData(): void;
|
|
125
115
|
/**
|
|
126
116
|
* Stream pass-through for compound tasks: runs the subgraph and forwards
|
|
@@ -138,11 +128,9 @@ export declare class GraphAsTask<Input extends TaskInput = TaskInput, Output ext
|
|
|
138
128
|
*/
|
|
139
129
|
validateAcyclic(): void;
|
|
140
130
|
/**
|
|
141
|
-
* Regenerates the subtask graph and emits a "regenerate" event
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* regeneration logic, but all they need to do is call this method to
|
|
145
|
-
* emit the "regenerate" event.
|
|
131
|
+
* Regenerates the subtask graph and emits a "regenerate" event.
|
|
132
|
+
* Subclasses override to implement actual regeneration logic; they only
|
|
133
|
+
* need to call this method to emit the event.
|
|
146
134
|
*/
|
|
147
135
|
regenerateGraph(): void;
|
|
148
136
|
/** Unsubscribe handle for the current subGraph entitlement subscription */
|
|
@@ -168,15 +156,7 @@ export declare class GraphAsTask<Input extends TaskInput = TaskInput, Output ext
|
|
|
168
156
|
once<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void;
|
|
169
157
|
set subGraph(subGraph: TaskGraph);
|
|
170
158
|
get subGraph(): TaskGraph;
|
|
171
|
-
/**
|
|
172
|
-
* Serializes the task and its subtasks into a format that can be stored
|
|
173
|
-
* @returns The serialized task and subtasks
|
|
174
|
-
*/
|
|
175
159
|
toJSON(options?: TaskGraphJsonOptions): TaskGraphItemJson;
|
|
176
|
-
/**
|
|
177
|
-
* Converts the task to a JSON format suitable for dependency tracking
|
|
178
|
-
* @returns The task and subtasks in JSON thats easier for humans to read
|
|
179
|
-
*/
|
|
180
160
|
toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem;
|
|
181
161
|
}
|
|
182
162
|
declare module "../task-graph/Workflow" {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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S,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAK5F;IAEe,GAAG,CAAC,KAAK,SAAS,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAK7F;IAEe,IAAI,CAAC,KAAK,SAAS,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAK9F;IAED,IAAoB,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAK/C;IAED,IAAa,QAAQ,IAAI,SAAS,CAKjC;IAMe,MAAM,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,iBAAiB,CAWxE;IAEe,gBAAgB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,YAAY,CAS7E;CACF;AAED,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAU,QAAQ;QAChB;;;WAGG;QACH,KAAK,EAAE,kBAAkB,CAAC,SAAS,EAAE,UAAU,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;QAE/E;;WAEG;QACH,QAAQ,IAAI,QAAQ,CAAC;KACtB;CACF"}
|
package/dist/task/ITask.d.ts
CHANGED
|
@@ -18,9 +18,6 @@ import type { TaskEventListener, TaskEventListeners, TaskEventParameters, TaskEv
|
|
|
18
18
|
import type { JsonTaskItem, TaskGraphItemJson, TaskGraphJsonOptions } from "./TaskJSON";
|
|
19
19
|
import { TaskRunner } from "./TaskRunner";
|
|
20
20
|
import type { TaskConfig, TaskInput, TaskOutput, TaskStatus } from "./TaskTypes";
|
|
21
|
-
/**
|
|
22
|
-
* Context for task execution
|
|
23
|
-
*/
|
|
24
21
|
export interface IExecuteContext {
|
|
25
22
|
signal: AbortSignal;
|
|
26
23
|
/**
|
|
@@ -68,13 +65,11 @@ export type IExecutePreviewContext = Pick<IExecuteContext, "own">;
|
|
|
68
65
|
export interface IRunConfig {
|
|
69
66
|
/**
|
|
70
67
|
* Runner ID to use for job-queue-based tasks (e.g. AiTask).
|
|
71
|
-
* Previously lived in TaskConfig; moved here because it is a runtime concern.
|
|
72
68
|
* The graph runner sets this on task.runConfig before each run.
|
|
73
69
|
*/
|
|
74
70
|
runnerId?: string;
|
|
75
71
|
/**
|
|
76
72
|
* Output cache override for this run.
|
|
77
|
-
* Previously lived in TaskConfig; moved here because it is a runtime concern.
|
|
78
73
|
* - true → use the globally registered TaskOutputRepository
|
|
79
74
|
* - false → disable caching for this run
|
|
80
75
|
* - TaskOutputRepository instance → use this specific repository
|
|
@@ -165,8 +160,7 @@ export interface ITaskStaticProperties {
|
|
|
165
160
|
readonly entitlements: () => TaskEntitlements;
|
|
166
161
|
}
|
|
167
162
|
/**
|
|
168
|
-
* Interface for task execution logic
|
|
169
|
-
* These methods define how tasks are executed and should be implemented by Task subclasses
|
|
163
|
+
* Interface for task execution logic — implemented by Task subclasses.
|
|
170
164
|
*/
|
|
171
165
|
export interface ITaskExecution<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput> {
|
|
172
166
|
execute(input: Input, context: IExecuteContext): Promise<Output | undefined>;
|
|
@@ -185,8 +179,7 @@ export interface ITaskExecution<Input extends TaskInput = TaskInput, Output exte
|
|
|
185
179
|
cleanup?(): Promise<void> | void;
|
|
186
180
|
}
|
|
187
181
|
/**
|
|
188
|
-
* Interface for task lifecycle management
|
|
189
|
-
* These methods define how tasks are run and are usually delegated to a TaskRunner
|
|
182
|
+
* Interface for task lifecycle management — usually delegated to a TaskRunner.
|
|
190
183
|
*/
|
|
191
184
|
export interface ITaskLifecycle<Input extends TaskInput, Output extends TaskOutput, Config extends TaskConfig> {
|
|
192
185
|
run(overrides?: Partial<Input>, runConfig?: Partial<IRunConfig>): Promise<Output>;
|
|
@@ -195,9 +188,6 @@ export interface ITaskLifecycle<Input extends TaskInput, Output extends TaskOutp
|
|
|
195
188
|
abort(): void;
|
|
196
189
|
disable(): Promise<void>;
|
|
197
190
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Interface for task input/output operations
|
|
200
|
-
*/
|
|
201
191
|
export interface ITaskIO<Input extends TaskInput> {
|
|
202
192
|
defaults: Record<string, any>;
|
|
203
193
|
runInputData: Record<string, any>;
|
|
@@ -227,9 +217,6 @@ export interface ITaskInternalGraph {
|
|
|
227
217
|
hasChildren(): boolean;
|
|
228
218
|
regenerateGraph(): void;
|
|
229
219
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Interface for task event handling
|
|
232
|
-
*/
|
|
233
220
|
export interface ITaskEvents {
|
|
234
221
|
get events(): EventEmitter<TaskEventListeners>;
|
|
235
222
|
on<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): void;
|
|
@@ -239,17 +226,11 @@ export interface ITaskEvents {
|
|
|
239
226
|
emit<Event extends TaskEvents>(name: Event, ...args: TaskEventParameters<Event>): void;
|
|
240
227
|
subscribe<Event extends TaskEvents>(name: Event, fn: TaskEventListener<Event>): () => void;
|
|
241
228
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Interface for task serialization
|
|
244
|
-
*/
|
|
245
229
|
export interface ITaskSerialization {
|
|
246
230
|
toJSON(options?: TaskGraphJsonOptions): JsonTaskItem | TaskGraphItemJson;
|
|
247
231
|
toDependencyJSON(options?: TaskGraphJsonOptions): JsonTaskItem;
|
|
248
232
|
get id(): unknown;
|
|
249
233
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Interface for task configuration and state
|
|
252
|
-
*/
|
|
253
234
|
export interface ITaskState<Config extends TaskConfig = TaskConfig> {
|
|
254
235
|
readonly config: Config;
|
|
255
236
|
get id(): unknown;
|
|
@@ -269,13 +250,7 @@ export interface ITask<Input extends TaskInput = TaskInput, Output extends TaskO
|
|
|
269
250
|
export interface IGraphAsTask<Input extends TaskInput = TaskInput, Output extends TaskOutput = TaskOutput, Config extends TaskConfig = TaskConfig> extends ITask<Input, Output, Config> {
|
|
270
251
|
get compoundMerge(): CompoundMergeStrategy;
|
|
271
252
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Type for task constructor
|
|
274
|
-
*/
|
|
275
253
|
type ITaskConstructorType<Input extends TaskInput, Output extends TaskOutput, Config extends TaskConfig> = new (config: Config, runConfig?: Partial<IRunConfig>) => ITask<Input, Output, Config>;
|
|
276
|
-
/**
|
|
277
|
-
* Interface for task constructor with static properties
|
|
278
|
-
*/
|
|
279
254
|
export type ITaskConstructor<Input extends TaskInput, Output extends TaskOutput, Config extends TaskConfig> = ITaskConstructorType<Input, Output, Config> & ITaskStaticProperties;
|
|
280
255
|
export {};
|
|
281
256
|
//# sourceMappingURL=ITask.d.ts.map
|