@workglow/task-graph 0.0.118 → 0.0.119

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/bun.js CHANGED
@@ -1719,18 +1719,24 @@ class Task {
1719
1719
  return obj;
1720
1720
  }
1721
1721
  toJSON(_options) {
1722
- const extras = this.config.extras;
1722
+ const ctor = this.constructor;
1723
+ const { id: _id, ...config } = this.config;
1724
+ if (config.title === ctor.title)
1725
+ delete config.title;
1726
+ if (config.description === ctor.description)
1727
+ delete config.description;
1728
+ const extras = config.extras;
1729
+ if (!extras || Object.keys(extras).length === 0)
1730
+ delete config.extras;
1731
+ for (const key of Object.keys(config)) {
1732
+ if (config[key] === undefined)
1733
+ delete config[key];
1734
+ }
1723
1735
  const json = this.stripSymbols({
1724
1736
  id: this.id,
1725
1737
  type: this.type,
1726
1738
  defaults: this.defaults,
1727
- config: {
1728
- ...this.config.title && this.config.title !== this.constructor.title ? { title: this.config.title } : {},
1729
- ...this.config.description && this.config.description !== this.constructor.description ? { description: this.config.description } : {},
1730
- ...this.config.inputSchema ? { inputSchema: this.config.inputSchema } : {},
1731
- ...this.config.outputSchema ? { outputSchema: this.config.outputSchema } : {},
1732
- ...extras && Object.keys(extras).length ? { extras } : {}
1733
- }
1739
+ config
1734
1740
  });
1735
1741
  return json;
1736
1742
  }
@@ -2395,11 +2401,14 @@ class TaskGraphRunner {
2395
2401
  const narrowed = await task.narrowInput({ ...results }, this.registry);
2396
2402
  dataflow.setPortData(narrowed);
2397
2403
  } else {
2398
- getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
2399
- dataflowId: dataflow.id,
2400
- compatibility,
2401
- resultsKeys: Object.keys(results)
2402
- });
2404
+ const resultsKeys = Object.keys(results);
2405
+ if (resultsKeys.length > 0) {
2406
+ getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
2407
+ dataflowId: dataflow.id,
2408
+ compatibility,
2409
+ resultsKeys
2410
+ });
2411
+ }
2403
2412
  }
2404
2413
  }
2405
2414
  }
@@ -2759,7 +2768,7 @@ class TaskGraphRunner {
2759
2768
  async handleError(error) {
2760
2769
  await Promise.allSettled(this.graph.getTasks().map(async (task) => {
2761
2770
  if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
2762
- task.abort();
2771
+ return task.abort();
2763
2772
  }
2764
2773
  }));
2765
2774
  this.running = false;
@@ -2775,11 +2784,11 @@ class TaskGraphRunner {
2775
2784
  this.reactiveRunning = false;
2776
2785
  }
2777
2786
  async handleAbort() {
2778
- this.graph.getTasks().map(async (task) => {
2787
+ await Promise.allSettled(this.graph.getTasks().map(async (task) => {
2779
2788
  if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
2780
- task.abort();
2789
+ return task.abort();
2781
2790
  }
2782
- });
2791
+ }));
2783
2792
  this.running = false;
2784
2793
  if (this.telemetrySpan) {
2785
2794
  this.telemetrySpan.setStatus(SpanStatusCode2.ERROR, "aborted");
@@ -2808,7 +2817,9 @@ class TaskGraphRunner {
2808
2817
  progress = Math.round(completed / total);
2809
2818
  }
2810
2819
  this.pushStatusFromNodeToEdges(this.graph, task);
2811
- await this.pushOutputFromNodeToEdges(task, task.runOutputData);
2820
+ if (task.runOutputData && Object.keys(task.runOutputData).length > 0) {
2821
+ await this.pushOutputFromNodeToEdges(task, task.runOutputData);
2822
+ }
2812
2823
  this.graph.emit("graph_progress", progress, message, args);
2813
2824
  }
2814
2825
  }
@@ -2834,13 +2845,16 @@ var init_GraphAsTaskRunner = __esm(() => {
2834
2845
  });
2835
2846
  const results = await this.task.subGraph.run(input, {
2836
2847
  parentSignal: this.abortController?.signal,
2837
- outputCache: this.outputCache
2848
+ outputCache: this.outputCache,
2849
+ registry: this.registry
2838
2850
  });
2839
2851
  unsubscribe();
2840
2852
  return results;
2841
2853
  }
2842
2854
  async executeTaskChildrenReactive() {
2843
- return this.task.subGraph.runReactive(this.task.runInputData);
2855
+ return this.task.subGraph.runReactive(this.task.runInputData, {
2856
+ registry: this.registry
2857
+ });
2844
2858
  }
2845
2859
  async handleDisable() {
2846
2860
  if (this.task.hasChildren()) {
@@ -3957,6 +3971,11 @@ class Workflow {
3957
3971
  const tasks = graph.getTasks();
3958
3972
  for (const task of tasks) {
3959
3973
  if (task.type === "InputTask") {
3974
+ const existingConfig = task.config;
3975
+ const existingSchema = existingConfig?.inputSchema ?? existingConfig?.outputSchema;
3976
+ if (existingSchema && typeof existingSchema === "object" && existingSchema["x-ui-manual"] === true) {
3977
+ continue;
3978
+ }
3960
3979
  const outgoing = graph.getTargetDataflows(task.id);
3961
3980
  if (outgoing.length === 0)
3962
3981
  continue;
@@ -4171,9 +4190,15 @@ class Workflow {
4171
4190
  const earlierTask = earlierTasks[i];
4172
4191
  const earlierOutputSchema = earlierTask.outputSchema();
4173
4192
  if (earlierTask.type === "InputTask") {
4193
+ const inputConfig = earlierTask.config;
4194
+ const inputSchema = inputConfig?.inputSchema ?? inputConfig?.outputSchema;
4195
+ const isManualSchema = inputSchema && typeof inputSchema === "object" && inputSchema["x-ui-manual"] === true;
4196
+ const inputProperties = isManualSchema && inputSchema && typeof inputSchema === "object" && "properties" in inputSchema && inputSchema.properties && typeof inputSchema.properties === "object" ? new Set(Object.keys(inputSchema.properties)) : undefined;
4174
4197
  for (const requiredInputId of [...unmatchedRequired]) {
4175
4198
  if (matches.has(requiredInputId))
4176
4199
  continue;
4200
+ if (inputProperties && !inputProperties.has(requiredInputId))
4201
+ continue;
4177
4202
  matches.set(requiredInputId, requiredInputId);
4178
4203
  graph.addDataflow(new Dataflow(earlierTask.id, requiredInputId, targetTask.id, requiredInputId));
4179
4204
  }
@@ -4647,7 +4672,8 @@ class FallbackTaskRunner extends GraphAsTaskRunner {
4647
4672
  const mergedInput = { ...input, ...alternative };
4648
4673
  const results = await this.task.subGraph.run(mergedInput, {
4649
4674
  parentSignal: this.abortController?.signal,
4650
- outputCache: this.outputCache
4675
+ outputCache: this.outputCache,
4676
+ registry: this.registry
4651
4677
  });
4652
4678
  const mergedOutput = this.task.subGraph.mergeExecuteOutputsToRunOutput(results, this.task.compoundMerge);
4653
4679
  await this.handleProgress(100, `Data alternative ${attemptNumber}/${totalAttempts} succeeded`);
@@ -4915,7 +4941,8 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
4915
4941
  const graphClone = this.cloneGraph(this.task.subGraph);
4916
4942
  const results = await graphClone.run(input, {
4917
4943
  parentSignal: this.abortController?.signal,
4918
- outputCache: this.outputCache
4944
+ outputCache: this.outputCache,
4945
+ registry: this.registry
4919
4946
  });
4920
4947
  if (results.length === 0) {
4921
4948
  return;
@@ -6239,11 +6266,13 @@ class JobQueueTask extends GraphAsTask {
6239
6266
  }
6240
6267
  return registeredQueue;
6241
6268
  }
6242
- async abort() {
6269
+ abort() {
6243
6270
  if (this.currentQueueName && this.currentJobId) {
6244
6271
  const registeredQueue = getTaskQueueRegistry().getQueue(this.currentQueueName);
6245
6272
  if (registeredQueue) {
6246
- await registeredQueue.client.abort(this.currentJobId);
6273
+ registeredQueue.client.abort(this.currentJobId).catch((err) => {
6274
+ console.warn(`Failed to abort remote job ${this.currentJobId}`, err);
6275
+ });
6247
6276
  }
6248
6277
  }
6249
6278
  super.abort();
@@ -6834,4 +6863,4 @@ export {
6834
6863
  ConditionalTask
6835
6864
  };
6836
6865
 
6837
- //# debugId=CA4F1B6F3A390E6A64756E2164756E21
6866
+ //# debugId=EE13DDA7A2649B7064756E2164756E21