@orkestrel/workflow 0.0.6 → 0.0.7
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/src/browser/index.d.ts +6 -6
- package/dist/src/browser/index.js +40 -30
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +63 -68
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +7 -5
- package/dist/src/core/index.d.ts +7 -5
- package/dist/src/core/index.js +63 -68
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +10 -8
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +4 -4
- package/dist/src/server/index.d.ts +4 -4
- package/dist/src/server/index.js +10 -8
- package/dist/src/server/index.js.map +1 -1
- package/package.json +23 -20
|
@@ -1006,11 +1006,11 @@ export declare function parkSignal(signal: AbortSignal): Promise<void>;
|
|
|
1006
1006
|
*/
|
|
1007
1007
|
export declare class Phase implements PhaseInterface {
|
|
1008
1008
|
#private;
|
|
1009
|
+
readonly description?: string;
|
|
1009
1010
|
constructor(snapshot: PhaseSnapshot, workflow: WorkflowInterface, escalate: () => void, options?: PhaseOptions, bail?: boolean, functions?: WorkflowFunctions);
|
|
1010
1011
|
get emitter(): EmitterInterface<PhaseEventMap>;
|
|
1011
1012
|
get id(): string;
|
|
1012
1013
|
get name(): string;
|
|
1013
|
-
get description(): string | undefined;
|
|
1014
1014
|
get context(): PhaseContext;
|
|
1015
1015
|
get workflow(): WorkflowInterface;
|
|
1016
1016
|
get bail(): boolean;
|
|
@@ -1985,7 +1985,7 @@ export declare interface RunnerUnit<TInput> {
|
|
|
1985
1985
|
* }
|
|
1986
1986
|
* ```
|
|
1987
1987
|
*/
|
|
1988
|
-
|
|
1988
|
+
declare class Scheduler_2 implements SchedulerInterface {
|
|
1989
1989
|
#private;
|
|
1990
1990
|
/**
|
|
1991
1991
|
* Yield control back to the host so other tasks (I/O, timers, rendering) can
|
|
@@ -2004,6 +2004,7 @@ export declare class Scheduler implements SchedulerInterface {
|
|
|
2004
2004
|
*/
|
|
2005
2005
|
delay(ms: number, options?: SchedulerOptions): Promise<void>;
|
|
2006
2006
|
}
|
|
2007
|
+
export { Scheduler_2 as Scheduler }
|
|
2007
2008
|
|
|
2008
2009
|
/**
|
|
2009
2010
|
* A cooperative host-yield primitive: a loop decides WHAT to do; the scheduler
|
|
@@ -2085,11 +2086,11 @@ export declare function success<T>(value: T): Success<T>;
|
|
|
2085
2086
|
*/
|
|
2086
2087
|
export declare class Task implements TaskInterface {
|
|
2087
2088
|
#private;
|
|
2089
|
+
readonly description?: string;
|
|
2088
2090
|
constructor(context: TaskContext, phase: PhaseInterface, workflow: WorkflowInterface, recompute: () => void, options?: TaskOptions, status?: TaskStatus, result?: TaskResult, run?: string, retries?: number, timeout?: number, handler?: WorkflowFunction);
|
|
2089
2091
|
get emitter(): EmitterInterface<TaskEventMap>;
|
|
2090
2092
|
get id(): string;
|
|
2091
2093
|
get name(): string;
|
|
2092
|
-
get description(): string | undefined;
|
|
2093
2094
|
get context(): TaskContext;
|
|
2094
2095
|
get phase(): PhaseInterface;
|
|
2095
2096
|
get workflow(): WorkflowInterface;
|
|
@@ -2184,7 +2185,7 @@ export declare interface TaskContext extends WorkflowContext {
|
|
|
2184
2185
|
* - **Event-free.** Like the runner `Controller`, the per-task handle carries no Emitter;
|
|
2185
2186
|
* observe the W-b entities' own emitters (`task.emitter` / `phase.emitter`) instead.
|
|
2186
2187
|
*/
|
|
2187
|
-
|
|
2188
|
+
declare class TaskController_2 implements TaskControllerInterface {
|
|
2188
2189
|
#private;
|
|
2189
2190
|
readonly signal: AbortSignal;
|
|
2190
2191
|
readonly input: Readonly<Record<string, unknown>>;
|
|
@@ -2193,6 +2194,7 @@ export declare class TaskController implements TaskControllerInterface {
|
|
|
2193
2194
|
get aborted(): boolean;
|
|
2194
2195
|
results(): readonly TaskResult[];
|
|
2195
2196
|
}
|
|
2197
|
+
export { TaskController_2 as TaskController }
|
|
2196
2198
|
|
|
2197
2199
|
/**
|
|
2198
2200
|
* The per-task handle a {@link WorkflowFunction} receives — the running task's
|
|
@@ -2728,11 +2730,11 @@ export declare type UnitOutcome<TResult> = {
|
|
|
2728
2730
|
*/
|
|
2729
2731
|
export declare class Workflow implements WorkflowInterface {
|
|
2730
2732
|
#private;
|
|
2733
|
+
readonly description?: string;
|
|
2731
2734
|
constructor(snapshot: WorkflowSnapshot, options?: WorkflowOptions);
|
|
2732
2735
|
get emitter(): EmitterInterface<WorkflowEventMap>;
|
|
2733
2736
|
get id(): string;
|
|
2734
2737
|
get name(): string;
|
|
2735
|
-
get description(): string | undefined;
|
|
2736
2738
|
get context(): WorkflowContext;
|
|
2737
2739
|
get bail(): boolean;
|
|
2738
2740
|
get paused(): boolean;
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1006,11 +1006,11 @@ export declare function parkSignal(signal: AbortSignal): Promise<void>;
|
|
|
1006
1006
|
*/
|
|
1007
1007
|
export declare class Phase implements PhaseInterface {
|
|
1008
1008
|
#private;
|
|
1009
|
+
readonly description?: string;
|
|
1009
1010
|
constructor(snapshot: PhaseSnapshot, workflow: WorkflowInterface, escalate: () => void, options?: PhaseOptions, bail?: boolean, functions?: WorkflowFunctions);
|
|
1010
1011
|
get emitter(): EmitterInterface<PhaseEventMap>;
|
|
1011
1012
|
get id(): string;
|
|
1012
1013
|
get name(): string;
|
|
1013
|
-
get description(): string | undefined;
|
|
1014
1014
|
get context(): PhaseContext;
|
|
1015
1015
|
get workflow(): WorkflowInterface;
|
|
1016
1016
|
get bail(): boolean;
|
|
@@ -1985,7 +1985,7 @@ export declare interface RunnerUnit<TInput> {
|
|
|
1985
1985
|
* }
|
|
1986
1986
|
* ```
|
|
1987
1987
|
*/
|
|
1988
|
-
|
|
1988
|
+
declare class Scheduler_2 implements SchedulerInterface {
|
|
1989
1989
|
#private;
|
|
1990
1990
|
/**
|
|
1991
1991
|
* Yield control back to the host so other tasks (I/O, timers, rendering) can
|
|
@@ -2004,6 +2004,7 @@ export declare class Scheduler implements SchedulerInterface {
|
|
|
2004
2004
|
*/
|
|
2005
2005
|
delay(ms: number, options?: SchedulerOptions): Promise<void>;
|
|
2006
2006
|
}
|
|
2007
|
+
export { Scheduler_2 as Scheduler }
|
|
2007
2008
|
|
|
2008
2009
|
/**
|
|
2009
2010
|
* A cooperative host-yield primitive: a loop decides WHAT to do; the scheduler
|
|
@@ -2085,11 +2086,11 @@ export declare function success<T>(value: T): Success<T>;
|
|
|
2085
2086
|
*/
|
|
2086
2087
|
export declare class Task implements TaskInterface {
|
|
2087
2088
|
#private;
|
|
2089
|
+
readonly description?: string;
|
|
2088
2090
|
constructor(context: TaskContext, phase: PhaseInterface, workflow: WorkflowInterface, recompute: () => void, options?: TaskOptions, status?: TaskStatus, result?: TaskResult, run?: string, retries?: number, timeout?: number, handler?: WorkflowFunction);
|
|
2089
2091
|
get emitter(): EmitterInterface<TaskEventMap>;
|
|
2090
2092
|
get id(): string;
|
|
2091
2093
|
get name(): string;
|
|
2092
|
-
get description(): string | undefined;
|
|
2093
2094
|
get context(): TaskContext;
|
|
2094
2095
|
get phase(): PhaseInterface;
|
|
2095
2096
|
get workflow(): WorkflowInterface;
|
|
@@ -2184,7 +2185,7 @@ export declare interface TaskContext extends WorkflowContext {
|
|
|
2184
2185
|
* - **Event-free.** Like the runner `Controller`, the per-task handle carries no Emitter;
|
|
2185
2186
|
* observe the W-b entities' own emitters (`task.emitter` / `phase.emitter`) instead.
|
|
2186
2187
|
*/
|
|
2187
|
-
|
|
2188
|
+
declare class TaskController_2 implements TaskControllerInterface {
|
|
2188
2189
|
#private;
|
|
2189
2190
|
readonly signal: AbortSignal;
|
|
2190
2191
|
readonly input: Readonly<Record<string, unknown>>;
|
|
@@ -2193,6 +2194,7 @@ export declare class TaskController implements TaskControllerInterface {
|
|
|
2193
2194
|
get aborted(): boolean;
|
|
2194
2195
|
results(): readonly TaskResult[];
|
|
2195
2196
|
}
|
|
2197
|
+
export { TaskController_2 as TaskController }
|
|
2196
2198
|
|
|
2197
2199
|
/**
|
|
2198
2200
|
* The per-task handle a {@link WorkflowFunction} receives — the running task's
|
|
@@ -2728,11 +2730,11 @@ export declare type UnitOutcome<TResult> = {
|
|
|
2728
2730
|
*/
|
|
2729
2731
|
export declare class Workflow implements WorkflowInterface {
|
|
2730
2732
|
#private;
|
|
2733
|
+
readonly description?: string;
|
|
2731
2734
|
constructor(snapshot: WorkflowSnapshot, options?: WorkflowOptions);
|
|
2732
2735
|
get emitter(): EmitterInterface<WorkflowEventMap>;
|
|
2733
2736
|
get id(): string;
|
|
2734
2737
|
get name(): string;
|
|
2735
|
-
get description(): string | undefined;
|
|
2736
2738
|
get context(): WorkflowContext;
|
|
2737
2739
|
get bail(): boolean;
|
|
2738
2740
|
get paused(): boolean;
|
package/dist/src/core/index.js
CHANGED
|
@@ -64,17 +64,18 @@ var Scheduler = class {
|
|
|
64
64
|
#sleep(ms, signal) {
|
|
65
65
|
if (signal?.aborted === true) return Promise.reject(signal.reason);
|
|
66
66
|
return new Promise((resolve, reject) => {
|
|
67
|
-
const onAbort = () => {
|
|
68
|
-
clearTimeout(handle);
|
|
69
|
-
reject(signal?.reason);
|
|
70
|
-
};
|
|
71
67
|
const handle = setTimeout(() => {
|
|
72
68
|
signal?.removeEventListener("abort", onAbort);
|
|
73
69
|
resolve();
|
|
74
70
|
}, ms);
|
|
71
|
+
const onAbort = this.#abort.bind(this, handle, reject, signal);
|
|
75
72
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
76
73
|
});
|
|
77
74
|
}
|
|
75
|
+
#abort(handle, reject, signal) {
|
|
76
|
+
clearTimeout(handle);
|
|
77
|
+
reject(signal?.reason);
|
|
78
|
+
}
|
|
78
79
|
};
|
|
79
80
|
//#endregion
|
|
80
81
|
//#region src/core/constants.ts
|
|
@@ -200,7 +201,7 @@ var WorkflowError = class extends Error {
|
|
|
200
201
|
super(message);
|
|
201
202
|
this.name = "WorkflowError";
|
|
202
203
|
this.code = code;
|
|
203
|
-
this.context = context;
|
|
204
|
+
if (context !== void 0) this.context = context;
|
|
204
205
|
}
|
|
205
206
|
};
|
|
206
207
|
/**
|
|
@@ -660,16 +661,7 @@ function moveEntry(entries, key, index) {
|
|
|
660
661
|
* @returns A deferred `promise` plus its `resolve` / `reject`
|
|
661
662
|
*/
|
|
662
663
|
function createDeferred() {
|
|
663
|
-
|
|
664
|
-
let reject = () => {};
|
|
665
|
-
return {
|
|
666
|
-
promise: new Promise((res, rej) => {
|
|
667
|
-
resolve = res;
|
|
668
|
-
reject = rej;
|
|
669
|
-
}),
|
|
670
|
-
resolve,
|
|
671
|
-
reject
|
|
672
|
-
};
|
|
664
|
+
return Promise.withResolvers();
|
|
673
665
|
}
|
|
674
666
|
/**
|
|
675
667
|
* Park until `signal` aborts — a promise-parked wait (AGENTS §21), never a timer or
|
|
@@ -983,7 +975,6 @@ var Task = class {
|
|
|
983
975
|
#status;
|
|
984
976
|
#result;
|
|
985
977
|
#name;
|
|
986
|
-
#description;
|
|
987
978
|
#run;
|
|
988
979
|
#retries;
|
|
989
980
|
#timeout;
|
|
@@ -995,13 +986,16 @@ var Task = class {
|
|
|
995
986
|
this.#recompute = recompute;
|
|
996
987
|
this.#metadata = options?.metadata ?? {};
|
|
997
988
|
this.#emitter = new Emitter({
|
|
998
|
-
on: options
|
|
999
|
-
error: options
|
|
989
|
+
...options?.on === void 0 ? {} : { on: options.on },
|
|
990
|
+
...options?.error === void 0 ? {} : { error: options.error }
|
|
1000
991
|
});
|
|
1001
992
|
this.#status = status;
|
|
1002
993
|
this.#result = result;
|
|
1003
994
|
this.#name = context.name;
|
|
1004
|
-
|
|
995
|
+
if (context.description !== void 0) Object.defineProperty(this, "description", {
|
|
996
|
+
configurable: true,
|
|
997
|
+
value: context.description
|
|
998
|
+
});
|
|
1005
999
|
this.#run = run;
|
|
1006
1000
|
this.#retries = retries;
|
|
1007
1001
|
this.#timeout = timeout;
|
|
@@ -1016,9 +1010,6 @@ var Task = class {
|
|
|
1016
1010
|
get name() {
|
|
1017
1011
|
return this.#name;
|
|
1018
1012
|
}
|
|
1019
|
-
get description() {
|
|
1020
|
-
return this.#description;
|
|
1021
|
-
}
|
|
1022
1013
|
get context() {
|
|
1023
1014
|
return this.#context;
|
|
1024
1015
|
}
|
|
@@ -1101,7 +1092,10 @@ var Task = class {
|
|
|
1101
1092
|
status: this.#status
|
|
1102
1093
|
});
|
|
1103
1094
|
if (value.name !== void 0) this.#name = value.name;
|
|
1104
|
-
if (value.description !== void 0) this
|
|
1095
|
+
if (value.description !== void 0) Object.defineProperty(this, "description", {
|
|
1096
|
+
configurable: true,
|
|
1097
|
+
value: value.description
|
|
1098
|
+
});
|
|
1105
1099
|
}
|
|
1106
1100
|
snapshot() {
|
|
1107
1101
|
return {
|
|
@@ -1274,7 +1268,6 @@ var TaskManager = class {
|
|
|
1274
1268
|
var Phase = class {
|
|
1275
1269
|
#id;
|
|
1276
1270
|
#name;
|
|
1277
|
-
#description;
|
|
1278
1271
|
#workflow;
|
|
1279
1272
|
#escalateUp;
|
|
1280
1273
|
#tasks = new TaskManager();
|
|
@@ -1289,15 +1282,18 @@ var Phase = class {
|
|
|
1289
1282
|
constructor(snapshot, workflow, escalate, options, bail, functions) {
|
|
1290
1283
|
this.#id = snapshot.id;
|
|
1291
1284
|
this.#name = snapshot.name;
|
|
1292
|
-
|
|
1285
|
+
if (snapshot.description !== void 0) Object.defineProperty(this, "description", {
|
|
1286
|
+
configurable: true,
|
|
1287
|
+
value: snapshot.description
|
|
1288
|
+
});
|
|
1293
1289
|
this.#workflow = workflow;
|
|
1294
1290
|
this.#escalateUp = escalate;
|
|
1295
1291
|
this.#functions = functions;
|
|
1296
1292
|
this.#bail = bail ?? snapshot.bail;
|
|
1297
1293
|
this.#concurrency = snapshot.concurrency;
|
|
1298
1294
|
this.#emitter = new Emitter({
|
|
1299
|
-
on: options
|
|
1300
|
-
error: options
|
|
1295
|
+
...options?.on === void 0 ? {} : { on: options.on },
|
|
1296
|
+
...options?.error === void 0 ? {} : { error: options.error }
|
|
1301
1297
|
});
|
|
1302
1298
|
for (const task of snapshot.tasks) this.#append(task, options);
|
|
1303
1299
|
this.#override = snapshot.override;
|
|
@@ -1314,14 +1310,11 @@ var Phase = class {
|
|
|
1314
1310
|
get name() {
|
|
1315
1311
|
return this.#name;
|
|
1316
1312
|
}
|
|
1317
|
-
get description() {
|
|
1318
|
-
return this.#description;
|
|
1319
|
-
}
|
|
1320
1313
|
get context() {
|
|
1321
1314
|
return buildPhaseContext(this.#workflow.context, {
|
|
1322
1315
|
id: this.#id,
|
|
1323
1316
|
name: this.#name,
|
|
1324
|
-
...this
|
|
1317
|
+
...this.description === void 0 ? {} : { description: this.description }
|
|
1325
1318
|
});
|
|
1326
1319
|
}
|
|
1327
1320
|
get workflow() {
|
|
@@ -1423,7 +1416,10 @@ var Phase = class {
|
|
|
1423
1416
|
status: this.status
|
|
1424
1417
|
});
|
|
1425
1418
|
if (value.name !== void 0) this.#name = value.name;
|
|
1426
|
-
if (value.description !== void 0) this
|
|
1419
|
+
if (value.description !== void 0) Object.defineProperty(this, "description", {
|
|
1420
|
+
configurable: true,
|
|
1421
|
+
value: value.description
|
|
1422
|
+
});
|
|
1427
1423
|
if (value.concurrency !== void 0) this.#concurrency = value.concurrency;
|
|
1428
1424
|
if (value.bail !== void 0) this.#bail = value.bail;
|
|
1429
1425
|
}
|
|
@@ -1630,12 +1626,13 @@ var Workflow = class {
|
|
|
1630
1626
|
#destroyed;
|
|
1631
1627
|
constructor(snapshot, options) {
|
|
1632
1628
|
this.#context = buildWorkflowContext(snapshot);
|
|
1629
|
+
if (snapshot.description !== void 0) Object.defineProperty(this, "description", { value: snapshot.description });
|
|
1633
1630
|
this.#bail = options?.bail ?? snapshot.bail;
|
|
1634
1631
|
this.#bailOverride = options?.bail;
|
|
1635
1632
|
this.#functions = options?.functions;
|
|
1636
1633
|
this.#emitter = new Emitter({
|
|
1637
|
-
on: options
|
|
1638
|
-
error: options
|
|
1634
|
+
...options?.on === void 0 ? {} : { on: options.on },
|
|
1635
|
+
...options?.error === void 0 ? {} : { error: options.error }
|
|
1639
1636
|
});
|
|
1640
1637
|
this.#created = snapshot.created;
|
|
1641
1638
|
this.#updated = snapshot.updated;
|
|
@@ -1656,9 +1653,6 @@ var Workflow = class {
|
|
|
1656
1653
|
get name() {
|
|
1657
1654
|
return this.#context.name;
|
|
1658
1655
|
}
|
|
1659
|
-
get description() {
|
|
1660
|
-
return this.#context.description;
|
|
1661
|
-
}
|
|
1662
1656
|
get context() {
|
|
1663
1657
|
return this.#context;
|
|
1664
1658
|
}
|
|
@@ -1895,7 +1889,7 @@ var WorkflowManager = class {
|
|
|
1895
1889
|
return [...this.#workflows.values()];
|
|
1896
1890
|
}
|
|
1897
1891
|
add(definition) {
|
|
1898
|
-
const workflow = createWorkflow(definition, { functions: this.#functions });
|
|
1892
|
+
const workflow = createWorkflow(definition, { ...this.#functions === void 0 ? {} : { functions: this.#functions } });
|
|
1899
1893
|
this.#workflows.set(workflow.id, workflow);
|
|
1900
1894
|
return workflow;
|
|
1901
1895
|
}
|
|
@@ -1905,7 +1899,7 @@ var WorkflowManager = class {
|
|
|
1905
1899
|
if (this.#store === void 0) return void 0;
|
|
1906
1900
|
const snapshot = await this.#store.get(id);
|
|
1907
1901
|
if (snapshot === void 0) return void 0;
|
|
1908
|
-
const workflow = restoreWorkflow(snapshot, { functions: this.#functions });
|
|
1902
|
+
const workflow = restoreWorkflow(snapshot, { ...this.#functions === void 0 ? {} : { functions: this.#functions } });
|
|
1909
1903
|
this.#workflows.set(workflow.id, workflow);
|
|
1910
1904
|
return workflow;
|
|
1911
1905
|
}
|
|
@@ -2055,14 +2049,14 @@ var Runner = class {
|
|
|
2055
2049
|
this.#handler = options.handler;
|
|
2056
2050
|
this.#entries = options.entries;
|
|
2057
2051
|
this.#emitter = new Emitter({
|
|
2058
|
-
on: options
|
|
2059
|
-
error: options
|
|
2052
|
+
...options.on === void 0 ? {} : { on: options.on },
|
|
2053
|
+
...options.error === void 0 ? {} : { error: options.error }
|
|
2060
2054
|
});
|
|
2061
2055
|
this.#queue = createQueue({
|
|
2062
|
-
handler:
|
|
2063
|
-
concurrency: options.concurrency,
|
|
2064
|
-
retries: options.retries,
|
|
2065
|
-
timeout: options.timeout
|
|
2056
|
+
handler: this.#dispatch.bind(this),
|
|
2057
|
+
...options.concurrency === void 0 ? {} : { concurrency: options.concurrency },
|
|
2058
|
+
...options.retries === void 0 ? {} : { retries: options.retries },
|
|
2059
|
+
...options.timeout === void 0 ? {} : { timeout: options.timeout }
|
|
2066
2060
|
});
|
|
2067
2061
|
}
|
|
2068
2062
|
get emitter() {
|
|
@@ -2393,7 +2387,7 @@ var WorkflowRunner = class {
|
|
|
2393
2387
|
options?.budget?.start();
|
|
2394
2388
|
const runSignal = this.#fold(workflow, options, timeout);
|
|
2395
2389
|
const holder = { runner: void 0 };
|
|
2396
|
-
const onCancel = (
|
|
2390
|
+
const onCancel = this.#abortActive.bind(this, holder, runSignal);
|
|
2397
2391
|
if (runSignal.aborted) onCancel();
|
|
2398
2392
|
else runSignal.addEventListener("abort", onCancel, { once: true });
|
|
2399
2393
|
try {
|
|
@@ -2441,12 +2435,7 @@ var WorkflowRunner = class {
|
|
|
2441
2435
|
}
|
|
2442
2436
|
async #runPhase(workflow, phase, runSignal, holder) {
|
|
2443
2437
|
const launched = /* @__PURE__ */ new Set();
|
|
2444
|
-
|
|
2445
|
-
const onAdd = (task) => {
|
|
2446
|
-
if (launched.has(task.id)) return;
|
|
2447
|
-
launched.add(task.id);
|
|
2448
|
-
runner?.spawn(task);
|
|
2449
|
-
};
|
|
2438
|
+
const onAdd = this.#spawnAdded.bind(this, launched, holder);
|
|
2450
2439
|
phase.emitter.on("add", onAdd);
|
|
2451
2440
|
try {
|
|
2452
2441
|
const tasks = phase.tasks.tasks();
|
|
@@ -2457,13 +2446,9 @@ var WorkflowRunner = class {
|
|
|
2457
2446
|
const attempts = /* @__PURE__ */ new Map();
|
|
2458
2447
|
const created = new Runner({
|
|
2459
2448
|
concurrency,
|
|
2460
|
-
entries: (
|
|
2461
|
-
|
|
2462
|
-
timeout: task.timeout
|
|
2463
|
-
}),
|
|
2464
|
-
handler: (controller) => this.#runTask(workflow, controller.input, controller, runSignal, bail, attempts)
|
|
2449
|
+
entries: this.#entry.bind(this),
|
|
2450
|
+
handler: this.#runUnit.bind(this, workflow, runSignal, bail, attempts)
|
|
2465
2451
|
});
|
|
2466
|
-
runner = created;
|
|
2467
2452
|
holder.runner = created;
|
|
2468
2453
|
try {
|
|
2469
2454
|
await created.execute(tasks);
|
|
@@ -2480,6 +2465,23 @@ var WorkflowRunner = class {
|
|
|
2480
2465
|
for (const task of phase.tasks.tasks()) this.#skip(task);
|
|
2481
2466
|
}
|
|
2482
2467
|
}
|
|
2468
|
+
#abortActive(holder, runSignal) {
|
|
2469
|
+
holder.runner?.abort(runSignal.reason);
|
|
2470
|
+
}
|
|
2471
|
+
#spawnAdded(launched, holder, task) {
|
|
2472
|
+
if (launched.has(task.id)) return;
|
|
2473
|
+
launched.add(task.id);
|
|
2474
|
+
holder.runner?.spawn(task);
|
|
2475
|
+
}
|
|
2476
|
+
#entry(task) {
|
|
2477
|
+
return {
|
|
2478
|
+
...task.retries === void 0 ? {} : { retries: task.retries },
|
|
2479
|
+
...task.timeout === void 0 ? {} : { timeout: task.timeout }
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
#runUnit(workflow, runSignal, bail, attempts, controller) {
|
|
2483
|
+
return this.#runTask(workflow, controller.input, controller, runSignal, bail, attempts);
|
|
2484
|
+
}
|
|
2483
2485
|
async #runTask(workflow, task, controller, runSignal, bail, attempts) {
|
|
2484
2486
|
const signal = this.#taskSignal(controller.signal, runSignal);
|
|
2485
2487
|
const attempt = (attempts.get(task.id) ?? 0) + 1;
|
|
@@ -2530,7 +2532,7 @@ var WorkflowRunner = class {
|
|
|
2530
2532
|
if (runSignal.aborted) return;
|
|
2531
2533
|
let onAbort;
|
|
2532
2534
|
const cancelled = new Promise((resolve) => {
|
|
2533
|
-
onAbort = (
|
|
2535
|
+
onAbort = resolve.bind(void 0, void 0);
|
|
2534
2536
|
runSignal.addEventListener("abort", onAbort, { once: true });
|
|
2535
2537
|
});
|
|
2536
2538
|
try {
|
|
@@ -2547,7 +2549,7 @@ var WorkflowRunner = class {
|
|
|
2547
2549
|
if (options?.signal !== void 0) signals.push(options.signal);
|
|
2548
2550
|
if (timeout !== void 0) signals.push(timeout.signal);
|
|
2549
2551
|
if (options?.budget !== void 0) signals.push(options.budget.signal);
|
|
2550
|
-
return signals.length === 1 ?
|
|
2552
|
+
return signals.length === 1 ? workflow.signal : AbortSignal.any(signals);
|
|
2551
2553
|
}
|
|
2552
2554
|
#haltFrom(phases, index, workflow, runSignal) {
|
|
2553
2555
|
if (this.#cancelled(runSignal) && this.#stoppable(workflow)) workflow.stop();
|
|
@@ -2618,14 +2620,7 @@ var WorkflowRunner = class {
|
|
|
2618
2620
|
* ```
|
|
2619
2621
|
*/
|
|
2620
2622
|
function createWorkflowContract() {
|
|
2621
|
-
|
|
2622
|
-
return {
|
|
2623
|
-
schema: contract.schema,
|
|
2624
|
-
is: contract.is,
|
|
2625
|
-
generate: (random) => contract.generate(random),
|
|
2626
|
-
parse: (value) => contract.parse(value),
|
|
2627
|
-
explain: (value) => contract.explain(value)
|
|
2628
|
-
};
|
|
2623
|
+
return createContract(workflowShape);
|
|
2629
2624
|
}
|
|
2630
2625
|
/**
|
|
2631
2626
|
* Build the live W-b entity tree from a {@link WorkflowDefinition} — the whole
|