@workglow/task-graph 0.3.0 → 0.3.2
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 +108 -80
- package/dist/browser.js.map +6 -6
- package/dist/bun.js +108 -80
- package/dist/bun.js.map +6 -6
- package/dist/node.js +108 -80
- package/dist/node.js.map +6 -6
- package/dist/task/ITask.d.ts +1 -4
- package/dist/task/ITask.d.ts.map +1 -1
- package/dist/task/JobQueueFactory.d.ts.map +1 -1
- package/dist/task/Task.d.ts +22 -10
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task/TaskRunContext.d.ts +7 -0
- package/dist/task/TaskRunContext.d.ts.map +1 -1
- package/dist/task/TaskRunner.d.ts +33 -14
- package/dist/task/TaskRunner.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/node.js
CHANGED
|
@@ -1277,14 +1277,14 @@ import { EventEmitter as EventEmitter4, uuid4 as uuid45 } from "@workglow/util";
|
|
|
1277
1277
|
import { DirectedAcyclicGraph } from "@workglow/util/graph";
|
|
1278
1278
|
|
|
1279
1279
|
// src/task/GraphAsTask.ts
|
|
1280
|
-
import { getLogger as
|
|
1280
|
+
import { getLogger as getLogger6 } from "@workglow/util";
|
|
1281
1281
|
import { CycleError } from "@workglow/util/graph";
|
|
1282
1282
|
import { compileSchema as compileSchema2 } from "@workglow/util/schema";
|
|
1283
1283
|
|
|
1284
1284
|
// src/task-graph/TaskGraphRunner.ts
|
|
1285
1285
|
import {
|
|
1286
1286
|
collectPropertyValues,
|
|
1287
|
-
getLogger as
|
|
1287
|
+
getLogger as getLogger5,
|
|
1288
1288
|
getTelemetryProvider as getTelemetryProvider2,
|
|
1289
1289
|
globalServiceRegistry as globalServiceRegistry3,
|
|
1290
1290
|
ResourceScope as ResourceScope2,
|
|
@@ -1629,7 +1629,7 @@ function hasStructuredOutput(schema) {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
|
|
1631
1631
|
// src/task/Task.ts
|
|
1632
|
-
import { deepEqual, EventEmitter as EventEmitter3,
|
|
1632
|
+
import { deepEqual, EventEmitter as EventEmitter3, uuid4 as uuid42 } from "@workglow/util";
|
|
1633
1633
|
import { compileSchema } from "@workglow/util/schema";
|
|
1634
1634
|
|
|
1635
1635
|
// src/task/TaskRunner.ts
|
|
@@ -1900,6 +1900,7 @@ class TaskRunContext {
|
|
|
1900
1900
|
telemetrySpan;
|
|
1901
1901
|
timeoutTimer;
|
|
1902
1902
|
pendingTimeoutError;
|
|
1903
|
+
terminated = false;
|
|
1903
1904
|
parentSignalCleanup;
|
|
1904
1905
|
constructor(parentSignal) {
|
|
1905
1906
|
this.abortController = new AbortController;
|
|
@@ -1954,9 +1955,9 @@ class TaskRunner {
|
|
|
1954
1955
|
const ownsScope = config.resourceScope === undefined;
|
|
1955
1956
|
const effectiveConfig = ownsScope ? { ...config, resourceScope: new ResourceScope({ strategy: config.disposeStrategy }) } : config;
|
|
1956
1957
|
this.ownsResourceScope = ownsScope;
|
|
1958
|
+
let ctx;
|
|
1957
1959
|
try {
|
|
1958
|
-
await this.handleStart(effectiveConfig);
|
|
1959
|
-
const ctx = this.currentCtx;
|
|
1960
|
+
ctx = await this.handleStart(effectiveConfig);
|
|
1960
1961
|
const proto = Object.getPrototypeOf(this.task);
|
|
1961
1962
|
if (proto.execute === Task.prototype.execute && typeof proto.executeStream !== "function" && proto.executePreview !== Task.prototype.executePreview) {
|
|
1962
1963
|
throw new TaskConfigurationError(`Task "${this.task.type}" implements only executePreview() and cannot be run via run(). ` + `After the run/runPreview split, run() requires execute() (or executeStream()). ` + `See docs/technical/02-dual-mode-execution.md.`);
|
|
@@ -1970,7 +1971,7 @@ class TaskRunner {
|
|
|
1970
1971
|
throw new TaskInvalidInputError("Invalid input data");
|
|
1971
1972
|
}
|
|
1972
1973
|
if (ctx.abortController.signal.aborted) {
|
|
1973
|
-
await this.handleAbort();
|
|
1974
|
+
await this.handleAbort(ctx);
|
|
1974
1975
|
throw new TaskAbortedError("Promise for task created and aborted before run");
|
|
1975
1976
|
}
|
|
1976
1977
|
const isStreamable = isTaskStreamable(this.task);
|
|
@@ -1989,7 +1990,7 @@ class TaskRunner {
|
|
|
1989
1990
|
}
|
|
1990
1991
|
policy = { kind: "none" };
|
|
1991
1992
|
}
|
|
1992
|
-
|
|
1993
|
+
ctx.telemetrySpan?.setAttributes({
|
|
1993
1994
|
"workglow.task.cache_policy": policy.kind
|
|
1994
1995
|
});
|
|
1995
1996
|
const keyInputs = await this.cacheCoordinator.buildKeyForPolicy(inputs, this.cacheRegistry, policy);
|
|
@@ -2005,12 +2006,30 @@ class TaskRunner {
|
|
|
2005
2006
|
await this.cacheCoordinator.saveByPolicy(keyInputs, outputs, this.cacheRegistry, policy);
|
|
2006
2007
|
this.task.runOutputData = outputs ?? {};
|
|
2007
2008
|
}
|
|
2008
|
-
await this.handleComplete();
|
|
2009
|
+
await this.handleComplete(ctx);
|
|
2009
2010
|
return this.task.runOutputData;
|
|
2010
2011
|
} catch (err) {
|
|
2011
|
-
await this.handleError(err);
|
|
2012
|
+
await this.handleError(err, ctx);
|
|
2012
2013
|
throw this.task.error instanceof TaskTimeoutError ? this.task.error : err;
|
|
2013
2014
|
}
|
|
2015
|
+
} catch (err) {
|
|
2016
|
+
if (ctx === undefined) {
|
|
2017
|
+
const partial = this.currentCtx;
|
|
2018
|
+
if (partial) {
|
|
2019
|
+
await this.handleError(err, partial);
|
|
2020
|
+
} else {
|
|
2021
|
+
this.task.status = TaskStatus.FAILED;
|
|
2022
|
+
this.task.error = err instanceof TaskError ? err : new TaskFailedError(`Task "${this.task.type}" (${this.task.id}): ${err?.message || "Task failed"}`);
|
|
2023
|
+
if (this.task.error instanceof TaskError) {
|
|
2024
|
+
this.task.error.taskType ??= this.task.type;
|
|
2025
|
+
this.task.error.taskId ??= this.task.id;
|
|
2026
|
+
}
|
|
2027
|
+
this.task.emit("error", this.task.error);
|
|
2028
|
+
this.task.emit("status", this.task.status);
|
|
2029
|
+
}
|
|
2030
|
+
this.running = false;
|
|
2031
|
+
}
|
|
2032
|
+
throw err;
|
|
2014
2033
|
} finally {
|
|
2015
2034
|
if (ownsScope) {
|
|
2016
2035
|
await effectiveConfig.resourceScope.runComplete();
|
|
@@ -2194,7 +2213,7 @@ class TaskRunner {
|
|
|
2194
2213
|
const ctx = new TaskRunContext(config.signal);
|
|
2195
2214
|
this.currentCtx = ctx;
|
|
2196
2215
|
ctx.abortController.signal.addEventListener("abort", () => {
|
|
2197
|
-
this.handleAbort();
|
|
2216
|
+
this.handleAbort(ctx);
|
|
2198
2217
|
});
|
|
2199
2218
|
if (config.registry) {
|
|
2200
2219
|
this.registry = config.registry;
|
|
@@ -2226,12 +2245,12 @@ class TaskRunner {
|
|
|
2226
2245
|
await this.resourceScope.runStart();
|
|
2227
2246
|
}
|
|
2228
2247
|
if (ctx.abortController.signal.aborted)
|
|
2229
|
-
return;
|
|
2248
|
+
return ctx;
|
|
2230
2249
|
const timeout = this.task.config.timeout;
|
|
2231
2250
|
if (timeout !== undefined && timeout > 0) {
|
|
2232
2251
|
ctx.pendingTimeoutError = new TaskTimeoutError(timeout);
|
|
2233
2252
|
ctx.timeoutTimer = setTimeout(() => {
|
|
2234
|
-
|
|
2253
|
+
ctx.abortController.abort();
|
|
2235
2254
|
}, timeout);
|
|
2236
2255
|
}
|
|
2237
2256
|
const telemetry = getTelemetryProvider();
|
|
@@ -2246,27 +2265,27 @@ class TaskRunner {
|
|
|
2246
2265
|
}
|
|
2247
2266
|
this.task.emit("start");
|
|
2248
2267
|
this.task.emit("status", this.task.status);
|
|
2268
|
+
return ctx;
|
|
2249
2269
|
}
|
|
2250
2270
|
updateProgress = async (_task, _progress, _message, ..._args) => {};
|
|
2251
2271
|
async handleStartPreview() {
|
|
2252
2272
|
this.previewRunning = true;
|
|
2253
2273
|
}
|
|
2254
|
-
clearTimeoutTimer() {
|
|
2255
|
-
|
|
2256
|
-
if (ctx?.timeoutTimer !== undefined) {
|
|
2274
|
+
clearTimeoutTimer(ctx) {
|
|
2275
|
+
if (ctx.timeoutTimer !== undefined) {
|
|
2257
2276
|
clearTimeout(ctx.timeoutTimer);
|
|
2258
2277
|
ctx.timeoutTimer = undefined;
|
|
2259
2278
|
}
|
|
2260
2279
|
}
|
|
2261
|
-
async handleAbort() {
|
|
2262
|
-
if (
|
|
2280
|
+
async handleAbort(ctx) {
|
|
2281
|
+
if (ctx.terminated)
|
|
2263
2282
|
return;
|
|
2264
|
-
|
|
2265
|
-
|
|
2283
|
+
ctx.terminated = true;
|
|
2284
|
+
this.clearTimeoutTimer(ctx);
|
|
2266
2285
|
this.task.status = TaskStatus.ABORTING;
|
|
2267
2286
|
await this.handleProgress(100);
|
|
2268
|
-
this.task.error = ctx
|
|
2269
|
-
if (ctx
|
|
2287
|
+
this.task.error = ctx.pendingTimeoutError ?? new TaskAbortedError;
|
|
2288
|
+
if (ctx.telemetrySpan) {
|
|
2270
2289
|
ctx.telemetrySpan.setStatus(SpanStatusCode.ERROR, "aborted");
|
|
2271
2290
|
ctx.telemetrySpan.addEvent("workglow.task.aborted", {
|
|
2272
2291
|
"workglow.task.error": this.task.error.message
|
|
@@ -2278,28 +2297,30 @@ class TaskRunner {
|
|
|
2278
2297
|
await this.task.cleanup();
|
|
2279
2298
|
} catch {}
|
|
2280
2299
|
}
|
|
2281
|
-
ctx
|
|
2282
|
-
this.currentCtx
|
|
2300
|
+
ctx.dispose();
|
|
2301
|
+
if (this.currentCtx === ctx)
|
|
2302
|
+
this.currentCtx = undefined;
|
|
2283
2303
|
this.task.emit("abort", this.task.error);
|
|
2284
2304
|
this.task.emit("status", this.task.status);
|
|
2285
2305
|
}
|
|
2286
2306
|
async handleAbortPreview() {
|
|
2287
2307
|
this.previewRunning = false;
|
|
2288
2308
|
}
|
|
2289
|
-
async handleComplete() {
|
|
2290
|
-
if (
|
|
2309
|
+
async handleComplete(ctx) {
|
|
2310
|
+
if (ctx.terminated)
|
|
2291
2311
|
return;
|
|
2292
|
-
|
|
2293
|
-
|
|
2312
|
+
ctx.terminated = true;
|
|
2313
|
+
this.clearTimeoutTimer(ctx);
|
|
2294
2314
|
this.task.completedAt = new Date;
|
|
2295
2315
|
this.task.status = TaskStatus.COMPLETED;
|
|
2296
2316
|
await this.handleProgress(100);
|
|
2297
|
-
if (ctx
|
|
2317
|
+
if (ctx.telemetrySpan) {
|
|
2298
2318
|
ctx.telemetrySpan.setStatus(SpanStatusCode.OK);
|
|
2299
2319
|
ctx.telemetrySpan.end();
|
|
2300
2320
|
}
|
|
2301
|
-
ctx
|
|
2302
|
-
this.currentCtx
|
|
2321
|
+
ctx.dispose();
|
|
2322
|
+
if (this.currentCtx === ctx)
|
|
2323
|
+
this.currentCtx = undefined;
|
|
2303
2324
|
this.task.emit("complete");
|
|
2304
2325
|
this.task.emit("status", this.task.status);
|
|
2305
2326
|
}
|
|
@@ -2307,8 +2328,10 @@ class TaskRunner {
|
|
|
2307
2328
|
this.previewRunning = false;
|
|
2308
2329
|
}
|
|
2309
2330
|
async handleDisable(ctx) {
|
|
2310
|
-
if (this.task.status === TaskStatus.DISABLED)
|
|
2331
|
+
if (ctx?.terminated || this.task.status === TaskStatus.DISABLED)
|
|
2311
2332
|
return;
|
|
2333
|
+
if (ctx)
|
|
2334
|
+
ctx.terminated = true;
|
|
2312
2335
|
this.task.status = TaskStatus.DISABLED;
|
|
2313
2336
|
await this.handleProgress(100);
|
|
2314
2337
|
this.task.completedAt = new Date;
|
|
@@ -2321,13 +2344,13 @@ class TaskRunner {
|
|
|
2321
2344
|
async disable() {
|
|
2322
2345
|
await this.handleDisable(this.currentCtx);
|
|
2323
2346
|
}
|
|
2324
|
-
async handleError(err) {
|
|
2347
|
+
async handleError(err, ctx) {
|
|
2325
2348
|
if (err instanceof TaskAbortedError)
|
|
2326
|
-
return this.handleAbort();
|
|
2327
|
-
if (
|
|
2349
|
+
return this.handleAbort(ctx);
|
|
2350
|
+
if (ctx.terminated)
|
|
2328
2351
|
return;
|
|
2329
|
-
|
|
2330
|
-
|
|
2352
|
+
ctx.terminated = true;
|
|
2353
|
+
this.clearTimeoutTimer(ctx);
|
|
2331
2354
|
if (this.task.hasChildren()) {
|
|
2332
2355
|
this.task.subGraph.abort();
|
|
2333
2356
|
}
|
|
@@ -2343,13 +2366,14 @@ class TaskRunner {
|
|
|
2343
2366
|
}
|
|
2344
2367
|
this.task.status = TaskStatus.FAILED;
|
|
2345
2368
|
await this.handleProgress(100);
|
|
2346
|
-
if (ctx
|
|
2369
|
+
if (ctx.telemetrySpan) {
|
|
2347
2370
|
ctx.telemetrySpan.setStatus(SpanStatusCode.ERROR, this.task.error.message);
|
|
2348
2371
|
ctx.telemetrySpan.setAttributes({ "workglow.task.error": this.task.error.message });
|
|
2349
2372
|
ctx.telemetrySpan.end();
|
|
2350
2373
|
}
|
|
2351
|
-
ctx
|
|
2352
|
-
this.currentCtx
|
|
2374
|
+
ctx.dispose();
|
|
2375
|
+
if (this.currentCtx === ctx)
|
|
2376
|
+
this.currentCtx = undefined;
|
|
2353
2377
|
this.task.emit("error", this.task.error);
|
|
2354
2378
|
this.task.emit("status", this.task.status);
|
|
2355
2379
|
}
|
|
@@ -2378,7 +2402,6 @@ class Task {
|
|
|
2378
2402
|
static isGraphOutput = false;
|
|
2379
2403
|
static isPassthrough = false;
|
|
2380
2404
|
static hasDynamicEntitlements = false;
|
|
2381
|
-
static __cacheableDeprecationWarned = new Set;
|
|
2382
2405
|
static entitlements() {
|
|
2383
2406
|
return EMPTY_ENTITLEMENTS;
|
|
2384
2407
|
}
|
|
@@ -2478,17 +2501,11 @@ class Task {
|
|
|
2478
2501
|
}
|
|
2479
2502
|
getCachePolicy(_inputs) {
|
|
2480
2503
|
const ctor = this.constructor;
|
|
2481
|
-
const hasLegacyOverride = Object.prototype.hasOwnProperty.call(ctor, "cacheable") && ctor.cacheable === false;
|
|
2482
|
-
const hasPolicyOverride = Object.prototype.hasOwnProperty.call(ctor, "cachePolicy");
|
|
2483
|
-
if (hasLegacyOverride && !hasPolicyOverride) {
|
|
2484
|
-
if (!Task.__cacheableDeprecationWarned.has(ctor.type)) {
|
|
2485
|
-
Task.__cacheableDeprecationWarned.add(ctor.type);
|
|
2486
|
-
getLogger2().warn(`Task "${ctor.type}": static \`cacheable = false\` is deprecated. ` + `Use \`static cachePolicy: CachePolicy = { kind: "none" }\` instead.`);
|
|
2487
|
-
}
|
|
2488
|
-
return { kind: "none" };
|
|
2489
|
-
}
|
|
2490
2504
|
if (this.runConfig?.cacheable === false || this.config?.cacheable === false)
|
|
2491
2505
|
return { kind: "none" };
|
|
2506
|
+
if (Object.prototype.hasOwnProperty.call(ctor, "cacheable") && ctor.cacheable === false && !Object.prototype.hasOwnProperty.call(ctor, "cachePolicy")) {
|
|
2507
|
+
return { kind: "none" };
|
|
2508
|
+
}
|
|
2492
2509
|
return ctor.cachePolicy ?? DEFAULT_CACHE_POLICY;
|
|
2493
2510
|
}
|
|
2494
2511
|
defaults;
|
|
@@ -2916,9 +2933,12 @@ class Task {
|
|
|
2916
2933
|
this.events.emit("regenerate");
|
|
2917
2934
|
}
|
|
2918
2935
|
}
|
|
2936
|
+
function __resetCacheableDeprecationWarnings() {
|
|
2937
|
+
Task.__cacheableDeprecationWarned.clear();
|
|
2938
|
+
}
|
|
2919
2939
|
|
|
2920
2940
|
// src/task-graph/EdgeMaterializer.ts
|
|
2921
|
-
import { getLogger as
|
|
2941
|
+
import { getLogger as getLogger2 } from "@workglow/util";
|
|
2922
2942
|
import { previewSource } from "@workglow/util/media";
|
|
2923
2943
|
class EdgeMaterializer {
|
|
2924
2944
|
graph;
|
|
@@ -2982,7 +3002,7 @@ class EdgeMaterializer {
|
|
|
2982
3002
|
} else {
|
|
2983
3003
|
const resultsKeys = Object.keys(results);
|
|
2984
3004
|
if (resultsKeys.length > 0) {
|
|
2985
|
-
|
|
3005
|
+
getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
|
|
2986
3006
|
dataflowId: dataflow.id,
|
|
2987
3007
|
compatibility,
|
|
2988
3008
|
resultsKeys
|
|
@@ -3078,10 +3098,10 @@ class RunContext {
|
|
|
3078
3098
|
}
|
|
3079
3099
|
|
|
3080
3100
|
// src/task-graph/RunScheduler.ts
|
|
3081
|
-
import { getLogger as
|
|
3101
|
+
import { getLogger as getLogger4 } from "@workglow/util";
|
|
3082
3102
|
|
|
3083
3103
|
// src/task/ConditionalTask.ts
|
|
3084
|
-
import { getLogger as
|
|
3104
|
+
import { getLogger as getLogger3 } from "@workglow/util";
|
|
3085
3105
|
|
|
3086
3106
|
// src/task/ConditionUtils.ts
|
|
3087
3107
|
function evaluateCondition(fieldValue, operator, compareValue) {
|
|
@@ -3239,7 +3259,7 @@ class ConditionalTask extends Task {
|
|
|
3239
3259
|
}
|
|
3240
3260
|
}
|
|
3241
3261
|
} catch (error) {
|
|
3242
|
-
|
|
3262
|
+
getLogger3().error(`Condition evaluation failed for branch "${branch.id}":`, { error });
|
|
3243
3263
|
}
|
|
3244
3264
|
}
|
|
3245
3265
|
if (this.activeBranches.size === 0 && defaultBranch) {
|
|
@@ -3511,7 +3531,7 @@ class RunScheduler {
|
|
|
3511
3531
|
ctx.inProgressFunctions.set(Symbol(task.id), runAsync());
|
|
3512
3532
|
}
|
|
3513
3533
|
} catch (err) {
|
|
3514
|
-
|
|
3534
|
+
getLogger4().error("Error running graph", { error: err });
|
|
3515
3535
|
}
|
|
3516
3536
|
await Promise.allSettled(Array.from(ctx.inProgressTasks.values()));
|
|
3517
3537
|
await Promise.allSettled(Array.from(ctx.inProgressFunctions.values()));
|
|
@@ -3914,7 +3934,7 @@ class TaskGraphRunner {
|
|
|
3914
3934
|
try {
|
|
3915
3935
|
await runPrivateToClean.clearRun();
|
|
3916
3936
|
} catch (e) {
|
|
3917
|
-
|
|
3937
|
+
getLogger5().warn("RunPrivateCacheRepo.clearRun failed", { error: e });
|
|
3918
3938
|
}
|
|
3919
3939
|
}
|
|
3920
3940
|
return this.filterLeafResults(results);
|
|
@@ -3988,7 +4008,7 @@ class TaskGraphRunner {
|
|
|
3988
4008
|
});
|
|
3989
4009
|
previewSpan.setStatus(SpanStatusCode2.OK);
|
|
3990
4010
|
previewSpan.end();
|
|
3991
|
-
|
|
4011
|
+
getLogger5().debug("task graph runPreview timings", {
|
|
3992
4012
|
previewRunId,
|
|
3993
4013
|
totalMs: Math.round(totalMs * 1000) / 1000,
|
|
3994
4014
|
taskTimings
|
|
@@ -4006,7 +4026,7 @@ class TaskGraphRunner {
|
|
|
4006
4026
|
});
|
|
4007
4027
|
previewSpan.setStatus(SpanStatusCode2.ERROR, message);
|
|
4008
4028
|
previewSpan.end();
|
|
4009
|
-
|
|
4029
|
+
getLogger5().debug("task graph runPreview failed", {
|
|
4010
4030
|
previewRunId,
|
|
4011
4031
|
totalMs: Math.round(totalMs * 1000) / 1000,
|
|
4012
4032
|
taskTimings,
|
|
@@ -4139,7 +4159,7 @@ class TaskGraphRunner {
|
|
|
4139
4159
|
const repo = checkRegistry.private;
|
|
4140
4160
|
if (!TaskGraphRunner.__durabilityWarnedRepos.has(repo)) {
|
|
4141
4161
|
TaskGraphRunner.__durabilityWarnedRepos.add(repo);
|
|
4142
|
-
|
|
4162
|
+
getLogger5().warn("TaskGraphRunner: private cache repo may be used but is non-durable — " + "restart-survival will not work. Ensure the CacheRegistry 'private' " + "slot is backed by a durable storage backend.");
|
|
4143
4163
|
}
|
|
4144
4164
|
}
|
|
4145
4165
|
}
|
|
@@ -4454,7 +4474,7 @@ class GraphAsTask extends Task {
|
|
|
4454
4474
|
const schemaNode = Task.generateInputSchemaNode(dataPortSchema);
|
|
4455
4475
|
this._inputSchemaNode = schemaNode;
|
|
4456
4476
|
} catch (error) {
|
|
4457
|
-
|
|
4477
|
+
getLogger6().warn(`GraphAsTask "${this.type}" (${this.id}): Failed to compile input schema, ` + `falling back to permissive validation. Inputs will NOT be validated.`, { error, taskType: this.type, taskId: this.id });
|
|
4458
4478
|
this._inputSchemaNode = compileSchema2({});
|
|
4459
4479
|
}
|
|
4460
4480
|
}
|
|
@@ -5371,7 +5391,7 @@ function autoConnect(graph, sourceTask, targetTask, options) {
|
|
|
5371
5391
|
}
|
|
5372
5392
|
|
|
5373
5393
|
// src/task-graph/LoopBuilderContext.ts
|
|
5374
|
-
import { getLogger as
|
|
5394
|
+
import { getLogger as getLogger7 } from "@workglow/util";
|
|
5375
5395
|
function runLoopAutoConnect(parentGraph, pending) {
|
|
5376
5396
|
const { parent, iteratorTask } = pending;
|
|
5377
5397
|
if (parentGraph.getTargetDataflows(parent.id).length !== 0)
|
|
@@ -5385,7 +5405,7 @@ function runLoopAutoConnect(parentGraph, pending) {
|
|
|
5385
5405
|
const result = autoConnect(parentGraph, parent, iteratorTask, { earlierTasks });
|
|
5386
5406
|
if (result.error) {
|
|
5387
5407
|
const message = result.error + " Task not added.";
|
|
5388
|
-
|
|
5408
|
+
getLogger7().error(message);
|
|
5389
5409
|
parentGraph.removeTask(iteratorTask.id);
|
|
5390
5410
|
return message;
|
|
5391
5411
|
}
|
|
@@ -5424,7 +5444,7 @@ class LoopBuilderContext {
|
|
|
5424
5444
|
}
|
|
5425
5445
|
|
|
5426
5446
|
// src/task-graph/WorkflowBuilder.ts
|
|
5427
|
-
import { getLogger as
|
|
5447
|
+
import { getLogger as getLogger8, uuid4 as uuid47 } from "@workglow/util";
|
|
5428
5448
|
|
|
5429
5449
|
// src/task-graph/ConditionalBuilder.ts
|
|
5430
5450
|
import { uuid4 as uuid46 } from "@workglow/util";
|
|
@@ -5583,7 +5603,7 @@ class WorkflowBuilder {
|
|
|
5583
5603
|
const taskSchema = task.inputSchema();
|
|
5584
5604
|
if (typeof taskSchema !== "boolean" && taskSchema.properties?.[dataflow.targetTaskPortId] === undefined && taskSchema.additionalProperties !== true || taskSchema === true && dataflow.targetTaskPortId !== DATAFLOW_ALL_PORTS) {
|
|
5585
5605
|
this._error = `Input ${dataflow.targetTaskPortId} not found on task ${task.id}`;
|
|
5586
|
-
|
|
5606
|
+
getLogger8().error(this._error);
|
|
5587
5607
|
return;
|
|
5588
5608
|
}
|
|
5589
5609
|
dataflow.targetTaskId = task.id;
|
|
@@ -5608,10 +5628,10 @@ class WorkflowBuilder {
|
|
|
5608
5628
|
if (result.error) {
|
|
5609
5629
|
if (this._loopContext !== undefined) {
|
|
5610
5630
|
this._error = result.error;
|
|
5611
|
-
|
|
5631
|
+
getLogger8().warn(this._error);
|
|
5612
5632
|
} else {
|
|
5613
5633
|
this._error = result.error + " Task not added.";
|
|
5614
|
-
|
|
5634
|
+
getLogger8().error(this._error);
|
|
5615
5635
|
this._facade.graph.removeTask(task.id);
|
|
5616
5636
|
}
|
|
5617
5637
|
}
|
|
@@ -5634,7 +5654,7 @@ class WorkflowBuilder {
|
|
|
5634
5654
|
const taskSchema = task.inputSchema();
|
|
5635
5655
|
if (typeof taskSchema !== "boolean" && taskSchema.properties?.[dataflow.targetTaskPortId] === undefined && taskSchema.additionalProperties !== true || taskSchema === true && dataflow.targetTaskPortId !== DATAFLOW_ALL_PORTS) {
|
|
5636
5656
|
this._error = `Input ${dataflow.targetTaskPortId} not found on task ${task.id}`;
|
|
5637
|
-
|
|
5657
|
+
getLogger8().error(this._error);
|
|
5638
5658
|
return;
|
|
5639
5659
|
}
|
|
5640
5660
|
dataflow.targetTaskId = task.id;
|
|
@@ -5686,7 +5706,7 @@ class WorkflowBuilder {
|
|
|
5686
5706
|
if (-index > nodes.length) {
|
|
5687
5707
|
const errorMsg = `Back index greater than number of tasks`;
|
|
5688
5708
|
this._error = errorMsg;
|
|
5689
|
-
|
|
5709
|
+
getLogger8().error(this._error);
|
|
5690
5710
|
throw new WorkflowError(errorMsg);
|
|
5691
5711
|
}
|
|
5692
5712
|
const lastNode = nodes[nodes.length + index];
|
|
@@ -5695,13 +5715,13 @@ class WorkflowBuilder {
|
|
|
5695
5715
|
if (outputSchema === false && source !== DATAFLOW_ALL_PORTS) {
|
|
5696
5716
|
const errorMsg = `Task ${lastNode.id} has schema 'false' and outputs nothing`;
|
|
5697
5717
|
this._error = errorMsg;
|
|
5698
|
-
|
|
5718
|
+
getLogger8().error(this._error);
|
|
5699
5719
|
throw new WorkflowError(errorMsg);
|
|
5700
5720
|
}
|
|
5701
5721
|
} else if (!outputSchema.properties?.[source] && source !== DATAFLOW_ALL_PORTS) {
|
|
5702
5722
|
const errorMsg = `Output ${source} not found on task ${lastNode.id}`;
|
|
5703
5723
|
this._error = errorMsg;
|
|
5704
|
-
|
|
5724
|
+
getLogger8().error(this._error);
|
|
5705
5725
|
throw new WorkflowError(errorMsg);
|
|
5706
5726
|
}
|
|
5707
5727
|
const df = new Dataflow(lastNode.id, source, undefined, target);
|
|
@@ -5714,7 +5734,7 @@ class WorkflowBuilder {
|
|
|
5714
5734
|
const parent = getLastTask(this._facade);
|
|
5715
5735
|
if (!parent) {
|
|
5716
5736
|
this._error = "onError() requires a preceding task in the workflow";
|
|
5717
|
-
|
|
5737
|
+
getLogger8().error(this._error);
|
|
5718
5738
|
throw new WorkflowError(this._error);
|
|
5719
5739
|
}
|
|
5720
5740
|
const handlerTask = ensureTask(handler);
|
|
@@ -5728,7 +5748,7 @@ class WorkflowBuilder {
|
|
|
5728
5748
|
const nodes = this._facade.graph.getTasks();
|
|
5729
5749
|
if (nodes.length === 0) {
|
|
5730
5750
|
this._error = "No tasks to remove";
|
|
5731
|
-
|
|
5751
|
+
getLogger8().error(this._error);
|
|
5732
5752
|
return;
|
|
5733
5753
|
}
|
|
5734
5754
|
const lastNode = nodes[nodes.length - 1];
|
|
@@ -8415,7 +8435,8 @@ function wrapSchemaInArray(schema) {
|
|
|
8415
8435
|
import {
|
|
8416
8436
|
InMemoryQueueStorage,
|
|
8417
8437
|
JobQueueClient,
|
|
8418
|
-
JobQueueServer
|
|
8438
|
+
JobQueueServer,
|
|
8439
|
+
wrapQueueStorage
|
|
8419
8440
|
} from "@workglow/job-queue";
|
|
8420
8441
|
import { createServiceToken as createServiceToken7, globalServiceRegistry as globalServiceRegistry4 } from "@workglow/util";
|
|
8421
8442
|
var JOB_QUEUE_FACTORY = createServiceToken7("taskgraph.jobQueueFactory");
|
|
@@ -8426,8 +8447,10 @@ var defaultJobQueueFactory = async ({
|
|
|
8426
8447
|
}) => {
|
|
8427
8448
|
const storage = options?.storage ?? new InMemoryQueueStorage(queueName);
|
|
8428
8449
|
await storage.migrate();
|
|
8450
|
+
const { messageQueue, jobStore } = wrapQueueStorage(storage);
|
|
8429
8451
|
const server = new JobQueueServer(jobClass, {
|
|
8430
|
-
|
|
8452
|
+
messageQueue,
|
|
8453
|
+
jobStore,
|
|
8431
8454
|
queueName,
|
|
8432
8455
|
limiter: options?.limiter,
|
|
8433
8456
|
workerCount: options?.workerCount,
|
|
@@ -8439,7 +8462,8 @@ var defaultJobQueueFactory = async ({
|
|
|
8439
8462
|
stopTimeoutMs: options?.stopTimeoutMs
|
|
8440
8463
|
});
|
|
8441
8464
|
const client = new JobQueueClient({
|
|
8442
|
-
|
|
8465
|
+
messageQueue,
|
|
8466
|
+
jobStore,
|
|
8443
8467
|
queueName
|
|
8444
8468
|
});
|
|
8445
8469
|
client.attach(server);
|
|
@@ -8460,8 +8484,10 @@ function createJobQueueFactoryWithOptions(defaultOptions = {}) {
|
|
|
8460
8484
|
};
|
|
8461
8485
|
const storage = mergedOptions.storage ?? new InMemoryQueueStorage(queueName);
|
|
8462
8486
|
await storage.migrate();
|
|
8487
|
+
const { messageQueue, jobStore } = wrapQueueStorage(storage);
|
|
8463
8488
|
const server = new JobQueueServer(jobClass, {
|
|
8464
|
-
|
|
8489
|
+
messageQueue,
|
|
8490
|
+
jobStore,
|
|
8465
8491
|
queueName,
|
|
8466
8492
|
limiter: mergedOptions.limiter,
|
|
8467
8493
|
workerCount: mergedOptions.workerCount,
|
|
@@ -8473,7 +8499,8 @@ function createJobQueueFactoryWithOptions(defaultOptions = {}) {
|
|
|
8473
8499
|
stopTimeoutMs: mergedOptions.stopTimeoutMs
|
|
8474
8500
|
});
|
|
8475
8501
|
const client = new JobQueueClient({
|
|
8476
|
-
|
|
8502
|
+
messageQueue,
|
|
8503
|
+
jobStore,
|
|
8477
8504
|
queueName
|
|
8478
8505
|
});
|
|
8479
8506
|
client.attach(server);
|
|
@@ -8684,7 +8711,7 @@ queueMicrotask(() => {
|
|
|
8684
8711
|
// src/task/TaskRegistry.ts
|
|
8685
8712
|
import {
|
|
8686
8713
|
createServiceToken as createServiceToken8,
|
|
8687
|
-
getLogger as
|
|
8714
|
+
getLogger as getLogger9,
|
|
8688
8715
|
globalServiceRegistry as globalServiceRegistry5,
|
|
8689
8716
|
registerInputCompactor,
|
|
8690
8717
|
registerInputResolver
|
|
@@ -8707,7 +8734,7 @@ function registerTask(baseClass) {
|
|
|
8707
8734
|
const result = validateSchema(schema);
|
|
8708
8735
|
if (!result.valid) {
|
|
8709
8736
|
const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join("; ");
|
|
8710
|
-
|
|
8737
|
+
getLogger9().warn(`Task "${baseClass.type}" has invalid ${name}: ${messages}`, {
|
|
8711
8738
|
taskType: baseClass.type,
|
|
8712
8739
|
schemaName: name,
|
|
8713
8740
|
errors: result.errors
|
|
@@ -9199,6 +9226,7 @@ export {
|
|
|
9199
9226
|
addBoundaryNodesToGraphJson,
|
|
9200
9227
|
addBoundaryNodesToDependencyJson,
|
|
9201
9228
|
_resetPortCodecsForTests,
|
|
9229
|
+
__resetCacheableDeprecationWarnings,
|
|
9202
9230
|
WorkflowRunContext,
|
|
9203
9231
|
WorkflowEventBridge,
|
|
9204
9232
|
WorkflowError,
|
|
@@ -9291,4 +9319,4 @@ export {
|
|
|
9291
9319
|
BROWSER_GRANTS
|
|
9292
9320
|
};
|
|
9293
9321
|
|
|
9294
|
-
//# debugId=
|
|
9322
|
+
//# debugId=E8891351CB2EEFF564756E2164756E21
|