@workglow/task-graph 0.3.11 → 0.3.13

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.
Files changed (65) hide show
  1. package/dist/browser.js +3368 -3321
  2. package/dist/browser.js.map +36 -34
  3. package/dist/bun.js +3368 -3321
  4. package/dist/bun.js.map +36 -34
  5. package/dist/cache/CacheJanitor.d.ts +2 -2
  6. package/dist/cache/RunPrivateCacheRepo.d.ts +6 -5
  7. package/dist/cache/RunPrivateCacheRepo.d.ts.map +1 -1
  8. package/dist/common.d.ts +9 -6
  9. package/dist/common.d.ts.map +1 -1
  10. package/dist/node.js +3368 -3321
  11. package/dist/node.js.map +36 -34
  12. package/dist/storage/ITaskOutputStorage.d.ts +35 -0
  13. package/dist/storage/ITaskOutputStorage.d.ts.map +1 -0
  14. package/dist/storage/TabularTaskOutputStorage.d.ts +29 -0
  15. package/dist/storage/TabularTaskOutputStorage.d.ts.map +1 -0
  16. package/dist/storage/TaskOutputRepository.d.ts +0 -48
  17. package/dist/storage/TaskOutputRepository.d.ts.map +1 -1
  18. package/dist/storage/TaskOutputStorageSchema.d.ts +31 -0
  19. package/dist/storage/TaskOutputStorageSchema.d.ts.map +1 -0
  20. package/dist/storage/TaskOutputTabularRepository.d.ts +10 -90
  21. package/dist/storage/TaskOutputTabularRepository.d.ts.map +1 -1
  22. package/dist/task/CacheCoordinator.d.ts +8 -2
  23. package/dist/task/CacheCoordinator.d.ts.map +1 -1
  24. package/dist/task/ConditionalTask.d.ts +10 -202
  25. package/dist/task/ConditionalTask.d.ts.map +1 -1
  26. package/dist/task/FallbackTask.d.ts +7 -59
  27. package/dist/task/FallbackTask.d.ts.map +1 -1
  28. package/dist/task/GraphAsTask.d.ts +8 -28
  29. package/dist/task/GraphAsTask.d.ts.map +1 -1
  30. package/dist/task/ITask.d.ts +2 -27
  31. package/dist/task/ITask.d.ts.map +1 -1
  32. package/dist/task/InputResolver.d.ts +0 -3
  33. package/dist/task/InputResolver.d.ts.map +1 -1
  34. package/dist/task/IteratorTask.d.ts +5 -43
  35. package/dist/task/IteratorTask.d.ts.map +1 -1
  36. package/dist/task/MapTask.d.ts +1 -25
  37. package/dist/task/MapTask.d.ts.map +1 -1
  38. package/dist/task/ReduceTask.d.ts +0 -18
  39. package/dist/task/ReduceTask.d.ts.map +1 -1
  40. package/dist/task/Task.d.ts +2 -106
  41. package/dist/task/Task.d.ts.map +1 -1
  42. package/dist/task/TaskError.d.ts +2 -29
  43. package/dist/task/TaskError.d.ts.map +1 -1
  44. package/dist/task/TaskJSON.d.ts +0 -10
  45. package/dist/task/TaskJSON.d.ts.map +1 -1
  46. package/dist/task/TaskRegistry.d.ts +0 -14
  47. package/dist/task/TaskRegistry.d.ts.map +1 -1
  48. package/dist/task/TaskRunner.d.ts +0 -41
  49. package/dist/task/TaskRunner.d.ts.map +1 -1
  50. package/dist/task/WhileTask.d.ts +3 -89
  51. package/dist/task/WhileTask.d.ts.map +1 -1
  52. package/dist/task/index.d.ts +6 -6
  53. package/dist/task/index.d.ts.map +1 -1
  54. package/dist/task-graph/Conversions.d.ts +10 -0
  55. package/dist/task-graph/Conversions.d.ts.map +1 -1
  56. package/dist/task-graph/Dataflow.d.ts +1 -29
  57. package/dist/task-graph/Dataflow.d.ts.map +1 -1
  58. package/dist/task-graph/TaskGraph.d.ts +0 -29
  59. package/dist/task-graph/TaskGraph.d.ts.map +1 -1
  60. package/dist/task-graph/TaskGraphRunner.d.ts +3 -65
  61. package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
  62. package/dist/task-graph/Workflow.d.ts +1 -60
  63. package/dist/task-graph/Workflow.d.ts.map +1 -1
  64. package/package.json +7 -7
  65. package/src/EXECUTION_MODEL.md +4 -4
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { SearchCondition } from "@workglow/storage";
7
+ /** One cached task output row. */
8
+ export interface TaskOutputRow {
9
+ readonly taskType: string;
10
+ readonly key: string;
11
+ /** Serialized (optionally compressed) output payload. */
12
+ readonly value: string;
13
+ readonly createdAt: string;
14
+ }
15
+ export type TaskOutputRowPrimaryKey = Pick<TaskOutputRow, "key" | "taskType">;
16
+ export type TaskOutputDeleteSearchCriteria = {
17
+ readonly createdAt?: SearchCondition<string>;
18
+ };
19
+ /**
20
+ * Minimal storage contract used by {@link TaskOutputTabularRepository}.
21
+ * Narrower than full tabular storage — only the methods the output cache calls.
22
+ */
23
+ export interface ITaskOutputStorage {
24
+ setupDatabase?(): Promise<void>;
25
+ put(row: TaskOutputRow): Promise<void>;
26
+ get(key: TaskOutputRowPrimaryKey): Promise<TaskOutputRow | undefined>;
27
+ delete(key: TaskOutputRowPrimaryKey): Promise<void>;
28
+ deleteAll(): Promise<void>;
29
+ size(): Promise<number>;
30
+ deleteSearch(criteria: TaskOutputDeleteSearchCriteria): Promise<void>;
31
+ records(pageSize?: number): AsyncGenerator<TaskOutputRow, void, undefined>;
32
+ /** When false, restart-survival for run-private cache is not guaranteed. */
33
+ isDurable?(): boolean;
34
+ }
35
+ //# sourceMappingURL=ITaskOutputStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITaskOutputStorage.d.ts","sourceRoot":"","sources":["../../src/storage/ITaskOutputStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;AAE9E,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,GAAG,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEtE,MAAM,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB,YAAY,CAAC,QAAQ,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAE3E,4EAA4E;IAC5E,SAAS,CAAC,IAAI,OAAO,CAAC;CACvB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ITabularStorage } from "@workglow/storage";
7
+ import type { ITaskOutputStorage, TaskOutputDeleteSearchCriteria, TaskOutputRow, TaskOutputRowPrimaryKey } from "./ITaskOutputStorage";
8
+ import { TaskOutputPrimaryKeyNames, TaskOutputSchema } from "./TaskOutputStorageSchema";
9
+ type TaskOutputTabularBacking = ITabularStorage<typeof TaskOutputSchema, typeof TaskOutputPrimaryKeyNames>;
10
+ export type { TaskOutputTabularBacking };
11
+ /**
12
+ * Adapts a full {@link ITabularStorage} table to {@link ITaskOutputStorage}.
13
+ */
14
+ export declare class TabularTaskOutputStorage implements ITaskOutputStorage {
15
+ private readonly tabular;
16
+ constructor(tabular: TaskOutputTabularBacking);
17
+ setupDatabase(): Promise<void>;
18
+ put(row: TaskOutputRow): Promise<void>;
19
+ get(key: TaskOutputRowPrimaryKey): Promise<TaskOutputRow | undefined>;
20
+ delete(key: TaskOutputRowPrimaryKey): Promise<void>;
21
+ deleteAll(): Promise<void>;
22
+ size(): Promise<number>;
23
+ deleteSearch(criteria: TaskOutputDeleteSearchCriteria): Promise<void>;
24
+ records(pageSize?: number): AsyncGenerator<TaskOutputRow, void, undefined>;
25
+ isDurable(): boolean;
26
+ }
27
+ /** Convenience factory for {@link TabularTaskOutputStorage}. */
28
+ export declare function tabularTaskOutputStorage(tabular: TaskOutputTabularBacking): ITaskOutputStorage;
29
+ //# sourceMappingURL=TabularTaskOutputStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabularTaskOutputStorage.d.ts","sourceRoot":"","sources":["../../src/storage/TabularTaskOutputStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,aAAa,EACb,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAExF,KAAK,wBAAwB,GAAG,eAAe,CAC7C,OAAO,gBAAgB,EACvB,OAAO,yBAAyB,CACjC,CAAC;AAEF,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC;;GAEG;AACH,qBAAa,wBAAyB,YAAW,kBAAkB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,wBAAwB,EAAI;IAE5D,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnC;IAEK,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3C;IAEK,GAAG,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAG1E;IAEK,MAAM,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExD;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/B;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAEK,YAAY,CAAC,QAAQ,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;IAED,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,CAEzE;IAED,SAAS,IAAI,OAAO,CAEnB;CACF;AAED,gEAAgE;AAChE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,wBAAwB,GAAG,kBAAkB,CAE9F"}
@@ -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.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AK,SAAS,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,yBAAyB,CAAC,KAAK,CAAC,QAE1F;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,CACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,CAAC,EAAE,IAAI,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAEzF,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjC,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC;IAE9B;;;;;;OAMG;IACG,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3D;IAED;;;;;;OAMG;IACG,gCAAgC,CAAC,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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export type TaskOutputPrimaryKey = {
7
+ key: string;
8
+ taskType: string;
9
+ };
10
+ export declare const TaskOutputSchema: {
11
+ type: "object";
12
+ properties: {
13
+ key: {
14
+ type: "string";
15
+ };
16
+ taskType: {
17
+ type: "string";
18
+ };
19
+ value: {
20
+ type: "string";
21
+ contentEncoding: string;
22
+ };
23
+ createdAt: {
24
+ type: "string";
25
+ format: string;
26
+ };
27
+ };
28
+ additionalProperties: false;
29
+ };
30
+ export declare const TaskOutputPrimaryKeyNames: readonly ["key", "taskType"];
31
+ //# sourceMappingURL=TaskOutputStorageSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskOutputStorageSchema.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputStorageSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CASG,CAAC;AAEjC,eAAO,MAAM,yBAAyB,YAAI,KAAK,EAAE,UAAU,CAAU,CAAC"}
@@ -3,114 +3,34 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { BaseTabularStorage } from "@workglow/storage";
7
6
  import { TaskInput, TaskOutput } from "../task/TaskTypes";
7
+ import type { ITaskOutputStorage } from "./ITaskOutputStorage";
8
+ import type { TaskOutputTabularBacking } from "./TabularTaskOutputStorage";
8
9
  import { TaskOutputRepository } from "./TaskOutputRepository";
9
- export type TaskOutputPrimaryKey = {
10
- key: string;
11
- taskType: string;
12
- };
13
- export declare const TaskOutputSchema: {
14
- type: "object";
15
- properties: {
16
- key: {
17
- type: "string";
18
- };
19
- taskType: {
20
- type: "string";
21
- };
22
- value: {
23
- type: "string";
24
- contentEncoding: string;
25
- };
26
- createdAt: {
27
- type: "string";
28
- format: string;
29
- };
30
- };
31
- additionalProperties: false;
32
- };
33
- export declare const TaskOutputPrimaryKeyNames: readonly ["key", "taskType"];
34
- export type TaskOutputRepositoryStorage = BaseTabularStorage<typeof TaskOutputSchema, typeof TaskOutputPrimaryKeyNames>;
10
+ export { TaskOutputPrimaryKeyNames, TaskOutputSchema } from "./TaskOutputStorageSchema";
11
+ export type { TaskOutputPrimaryKey } from "./TaskOutputStorageSchema";
35
12
  export type TaskOutputRepositoryOptions = {
36
- tabularRepository: TaskOutputRepositoryStorage;
13
+ storage: ITaskOutputStorage;
37
14
  outputCompression?: boolean;
38
15
  };
16
+ /** Backing tabular table type for {@link tabularTaskOutputStorage}. */
17
+ export type TaskOutputRepositoryStorage = TaskOutputTabularBacking;
39
18
  /**
40
- * Abstract class for managing task outputs in a repository
41
- * Provides methods for saving, retrieving, and clearing task outputs
19
+ * Repository for task output caching backed by {@link ITaskOutputStorage}.
42
20
  */
43
21
  export declare class TaskOutputTabularRepository extends TaskOutputRepository {
44
- /**
45
- * The tabular repository for the task outputs
46
- */
47
- tabularRepository: TaskOutputRepositoryStorage;
48
- /**
49
- * Constructor for the TaskOutputTabularRepository
50
- * @param options The options for the repository
51
- */
52
- constructor({ tabularRepository, outputCompression }: TaskOutputRepositoryOptions);
22
+ readonly storage: ITaskOutputStorage;
23
+ constructor({ storage, outputCompression }: TaskOutputRepositoryOptions);
53
24
  isDurable(): boolean;
54
- /**
55
- * Sets up the database for the repository.
56
- * Must be called before using any other methods.
57
- */
58
25
  setupDatabase(): Promise<void>;
59
26
  keyFromInputs(inputs: TaskInput): Promise<string>;
60
- /**
61
- * Saves a task output to the repository
62
- * @param taskType The type of task to save the output for
63
- * @param inputs The input parameters for the task
64
- * @param output The task output to save
65
- */
66
27
  saveOutput(taskType: string, inputs: TaskInput, output: TaskOutput, createdAt?: Date): Promise<void>;
67
- /**
68
- * Retrieves a task output from the repository
69
- * @param taskType The type of task to retrieve the output for
70
- * @param inputs The input parameters for the task
71
- * @returns The retrieved task output, or undefined if not found
72
- */
73
28
  getOutput(taskType: string, inputs: TaskInput): Promise<TaskOutput | undefined>;
74
- /**
75
- * Clears all task outputs from the repository
76
- * @emits output_cleared when the operation completes
77
- */
78
29
  clear(): Promise<void>;
79
- /**
80
- * Returns the number of task outputs stored in the repository
81
- * @returns The count of stored task outputs
82
- */
83
30
  size(): Promise<number>;
84
- /**
85
- * Clear all task outputs from the repository that are older than the given date
86
- * @param olderThanInMs The time in milliseconds to clear task outputs older than
87
- */
88
31
  clearOlderThan(olderThanInMs: number): Promise<void>;
89
- /**
90
- * Deletes all entries whose `taskType` starts with the given prefix.
91
- * Used by {@link RunPrivateCacheRepo.clearRun} to remove all entries for a specific runId.
92
- *
93
- * @param prefix - The prefix to match against `taskType` (e.g. `__run:my-run::`)
94
- */
95
32
  deleteByTaskTypePrefix(prefix: string): Promise<void>;
96
- /**
97
- * Deletes entries whose `taskType` starts with the given prefix AND whose
98
- * `createdAt` is older than `olderThanInMs` milliseconds ago.
99
- *
100
- * Used by {@link CacheJanitor} to prune stale run-private entries left behind
101
- * by runs that crashed and were never restarted.
102
- *
103
- * @param prefix - The taskType prefix to match (e.g. `__run:`)
104
- * @param olderThanInMs - Age threshold in milliseconds; rows older than this are deleted
105
- */
106
33
  clearOlderThanWithTaskTypePrefix(prefix: string, olderThanInMs: number): Promise<void>;
107
- /**
108
- * Counts entries whose `taskType` starts with the given prefix.
109
- * Used by {@link RunPrivateCacheRepo.size} so the wrapper's count reflects
110
- * only its own namespaced view.
111
- *
112
- * @param prefix - The taskType prefix to match (e.g. `__run:my-run::`)
113
- */
114
34
  sizeByTaskTypePrefix(prefix: string): Promise<number>;
115
35
  }
116
36
  //# sourceMappingURL=TaskOutputTabularRepository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskOutputTabularRepository.d.ts","sourceRoot":"","sources":["../../src/storage/TaskOutputTabularRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,oBA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EK,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEnC;IAEY,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7D;IAEK,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,OAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAqBf;IAEK,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA+BpF;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAG3B;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5B;IAEK,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzD;IAEc,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnE;IAEc,gCAAgC,CAC7C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAUf;IAEc,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQnE;CACF"}
@@ -42,12 +42,18 @@ export declare class CacheCoordinator<Input extends TaskInput, Output extends Ta
42
42
  *
43
43
  * Returns the deserialized output if found, undefined otherwise.
44
44
  */
45
- lookup(keyInputs: Input, outputCache: TaskOutputRepository | undefined, isStreamable: boolean, ctx: TaskRunContext): Promise<Output | undefined>;
45
+ /**
46
+ * Cache identity for the `taskType` axis of {@link TaskOutputRepository}.
47
+ * Deterministic entries key by task class; private (run-resume) entries key by
48
+ * task instance id so two nodes of the same type in one graph do not collide.
49
+ */
50
+ private cacheIdentityKey;
51
+ lookup(keyInputs: Input, outputCache: TaskOutputRepository | undefined, policy: CachePolicy, isStreamable: boolean, ctx: TaskRunContext): Promise<Output | undefined>;
46
52
  /**
47
53
  * Serializes and saves output. No-op when no cache is configured or task is
48
54
  * not cacheable.
49
55
  */
50
- save(keyInputs: Input, output: Output, outputCache: TaskOutputRepository | undefined): Promise<void>;
56
+ save(keyInputs: Input, output: Output, outputCache: TaskOutputRepository | undefined, policy: CachePolicy): Promise<void>;
51
57
  /**
52
58
  * Resolve the repository slot to use given a registry and policy. Returns
53
59
  * `undefined` if the registry is missing, the policy is `kind: "none"`, or
@@ -1 +1 @@
1
- {"version":3,"file":"CacheCoordinator.d.ts","sourceRoot":"","sources":["../../src/task/CacheCoordinator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAmC,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzD;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB,CAAC,KAAK,SAAS,SAAS,EAAE,MAAM,SAAS,UAAU;IAClE,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAI;IAEhE;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,oBAAoB,GAAG,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAS3F;IAED;;;;;;OAMG;IACG,MAAM,CACV,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,oBAAoB,GAAG,SAAS,EAC7C,YAAY,EAAE,OAAO,EACrB,GAAG,EAAE,cAAc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GAAG,SAAS,EACnC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf;mBAOoB,oBAAoB;mBAepB,sBAAsB;mBAetB,0BAA0B;CAchD"}
@@ -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
- * Receives the task's input data and returns true if the branch should be active.
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
- * Each branch represents a possible path through the conditional logic.
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
- * ConditionalTask implements conditional branching within a task graph, similar to
148
- * if/then/else or switch/case statements. It evaluates configured conditions against
149
- * its input and selectively enables output ports for active branches while disabling
150
- * dataflows to inactive branches.
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;AAOnF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK;IACjC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,kEAAkE;IAClE,Q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