@workglow/task-graph 0.0.118 → 0.0.120

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/node.js CHANGED
@@ -1718,18 +1718,35 @@ class Task {
1718
1718
  return obj;
1719
1719
  }
1720
1720
  toJSON(_options) {
1721
- const extras = this.config.extras;
1721
+ const ctor = this.constructor;
1722
+ const schema = ctor.configSchema();
1723
+ const schemaProperties = typeof schema !== "boolean" && schema?.properties ? schema.properties : {};
1724
+ const config = {};
1725
+ for (const [key, propSchema] of Object.entries(schemaProperties)) {
1726
+ if (key === "id")
1727
+ continue;
1728
+ if (propSchema?.["x-ui-hidden"] === true && key !== "inputSchema" && key !== "outputSchema" && key !== "extras") {
1729
+ continue;
1730
+ }
1731
+ const value = this.config[key];
1732
+ if (value === undefined)
1733
+ continue;
1734
+ if (typeof value === "function" || typeof value === "symbol")
1735
+ continue;
1736
+ config[key] = value;
1737
+ }
1738
+ if (config.title === ctor.title)
1739
+ delete config.title;
1740
+ if (config.description === ctor.description)
1741
+ delete config.description;
1742
+ const extras = config.extras;
1743
+ if (!extras || Object.keys(extras).length === 0)
1744
+ delete config.extras;
1722
1745
  const json = this.stripSymbols({
1723
1746
  id: this.id,
1724
1747
  type: this.type,
1725
1748
  defaults: this.defaults,
1726
- config: {
1727
- ...this.config.title && this.config.title !== this.constructor.title ? { title: this.config.title } : {},
1728
- ...this.config.description && this.config.description !== this.constructor.description ? { description: this.config.description } : {},
1729
- ...this.config.inputSchema ? { inputSchema: this.config.inputSchema } : {},
1730
- ...this.config.outputSchema ? { outputSchema: this.config.outputSchema } : {},
1731
- ...extras && Object.keys(extras).length ? { extras } : {}
1732
- }
1749
+ config
1733
1750
  });
1734
1751
  return json;
1735
1752
  }
@@ -2394,11 +2411,14 @@ class TaskGraphRunner {
2394
2411
  const narrowed = await task.narrowInput({ ...results }, this.registry);
2395
2412
  dataflow.setPortData(narrowed);
2396
2413
  } else {
2397
- getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
2398
- dataflowId: dataflow.id,
2399
- compatibility,
2400
- resultsKeys: Object.keys(results)
2401
- });
2414
+ const resultsKeys = Object.keys(results);
2415
+ if (resultsKeys.length > 0) {
2416
+ getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
2417
+ dataflowId: dataflow.id,
2418
+ compatibility,
2419
+ resultsKeys
2420
+ });
2421
+ }
2402
2422
  }
2403
2423
  }
2404
2424
  }
@@ -2758,7 +2778,7 @@ class TaskGraphRunner {
2758
2778
  async handleError(error) {
2759
2779
  await Promise.allSettled(this.graph.getTasks().map(async (task) => {
2760
2780
  if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
2761
- task.abort();
2781
+ return task.abort();
2762
2782
  }
2763
2783
  }));
2764
2784
  this.running = false;
@@ -2774,11 +2794,11 @@ class TaskGraphRunner {
2774
2794
  this.reactiveRunning = false;
2775
2795
  }
2776
2796
  async handleAbort() {
2777
- this.graph.getTasks().map(async (task) => {
2797
+ await Promise.allSettled(this.graph.getTasks().map(async (task) => {
2778
2798
  if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
2779
- task.abort();
2799
+ return task.abort();
2780
2800
  }
2781
- });
2801
+ }));
2782
2802
  this.running = false;
2783
2803
  if (this.telemetrySpan) {
2784
2804
  this.telemetrySpan.setStatus(SpanStatusCode2.ERROR, "aborted");
@@ -2807,7 +2827,9 @@ class TaskGraphRunner {
2807
2827
  progress = Math.round(completed / total);
2808
2828
  }
2809
2829
  this.pushStatusFromNodeToEdges(this.graph, task);
2810
- await this.pushOutputFromNodeToEdges(task, task.runOutputData);
2830
+ if (task.runOutputData && Object.keys(task.runOutputData).length > 0) {
2831
+ await this.pushOutputFromNodeToEdges(task, task.runOutputData);
2832
+ }
2811
2833
  this.graph.emit("graph_progress", progress, message, args);
2812
2834
  }
2813
2835
  }
@@ -2833,13 +2855,16 @@ var init_GraphAsTaskRunner = __esm(() => {
2833
2855
  });
2834
2856
  const results = await this.task.subGraph.run(input, {
2835
2857
  parentSignal: this.abortController?.signal,
2836
- outputCache: this.outputCache
2858
+ outputCache: this.outputCache,
2859
+ registry: this.registry
2837
2860
  });
2838
2861
  unsubscribe();
2839
2862
  return results;
2840
2863
  }
2841
2864
  async executeTaskChildrenReactive() {
2842
- return this.task.subGraph.runReactive(this.task.runInputData);
2865
+ return this.task.subGraph.runReactive(this.task.runInputData, {
2866
+ registry: this.registry
2867
+ });
2843
2868
  }
2844
2869
  async handleDisable() {
2845
2870
  if (this.task.hasChildren()) {
@@ -3956,6 +3981,11 @@ class Workflow {
3956
3981
  const tasks = graph.getTasks();
3957
3982
  for (const task of tasks) {
3958
3983
  if (task.type === "InputTask") {
3984
+ const existingConfig = task.config;
3985
+ const existingSchema = existingConfig?.inputSchema ?? existingConfig?.outputSchema;
3986
+ if (existingSchema && typeof existingSchema === "object" && existingSchema["x-ui-manual"] === true) {
3987
+ continue;
3988
+ }
3959
3989
  const outgoing = graph.getTargetDataflows(task.id);
3960
3990
  if (outgoing.length === 0)
3961
3991
  continue;
@@ -4170,9 +4200,15 @@ class Workflow {
4170
4200
  const earlierTask = earlierTasks[i];
4171
4201
  const earlierOutputSchema = earlierTask.outputSchema();
4172
4202
  if (earlierTask.type === "InputTask") {
4203
+ const inputConfig = earlierTask.config;
4204
+ const inputSchema = inputConfig?.inputSchema ?? inputConfig?.outputSchema;
4205
+ const isManualSchema = inputSchema && typeof inputSchema === "object" && inputSchema["x-ui-manual"] === true;
4206
+ const inputProperties = isManualSchema && inputSchema && typeof inputSchema === "object" && "properties" in inputSchema && inputSchema.properties && typeof inputSchema.properties === "object" ? new Set(Object.keys(inputSchema.properties)) : undefined;
4173
4207
  for (const requiredInputId of [...unmatchedRequired]) {
4174
4208
  if (matches.has(requiredInputId))
4175
4209
  continue;
4210
+ if (inputProperties && !inputProperties.has(requiredInputId))
4211
+ continue;
4176
4212
  matches.set(requiredInputId, requiredInputId);
4177
4213
  graph.addDataflow(new Dataflow(earlierTask.id, requiredInputId, targetTask.id, requiredInputId));
4178
4214
  }
@@ -4646,7 +4682,8 @@ class FallbackTaskRunner extends GraphAsTaskRunner {
4646
4682
  const mergedInput = { ...input, ...alternative };
4647
4683
  const results = await this.task.subGraph.run(mergedInput, {
4648
4684
  parentSignal: this.abortController?.signal,
4649
- outputCache: this.outputCache
4685
+ outputCache: this.outputCache,
4686
+ registry: this.registry
4650
4687
  });
4651
4688
  const mergedOutput = this.task.subGraph.mergeExecuteOutputsToRunOutput(results, this.task.compoundMerge);
4652
4689
  await this.handleProgress(100, `Data alternative ${attemptNumber}/${totalAttempts} succeeded`);
@@ -4914,7 +4951,8 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
4914
4951
  const graphClone = this.cloneGraph(this.task.subGraph);
4915
4952
  const results = await graphClone.run(input, {
4916
4953
  parentSignal: this.abortController?.signal,
4917
- outputCache: this.outputCache
4954
+ outputCache: this.outputCache,
4955
+ registry: this.registry
4918
4956
  });
4919
4957
  if (results.length === 0) {
4920
4958
  return;
@@ -6238,11 +6276,13 @@ class JobQueueTask extends GraphAsTask {
6238
6276
  }
6239
6277
  return registeredQueue;
6240
6278
  }
6241
- async abort() {
6279
+ abort() {
6242
6280
  if (this.currentQueueName && this.currentJobId) {
6243
6281
  const registeredQueue = getTaskQueueRegistry().getQueue(this.currentQueueName);
6244
6282
  if (registeredQueue) {
6245
- await registeredQueue.client.abort(this.currentJobId);
6283
+ registeredQueue.client.abort(this.currentJobId).catch((err) => {
6284
+ console.warn(`Failed to abort remote job ${this.currentJobId}`, err);
6285
+ });
6246
6286
  }
6247
6287
  }
6248
6288
  super.abort();
@@ -6833,4 +6873,4 @@ export {
6833
6873
  ConditionalTask
6834
6874
  };
6835
6875
 
6836
- //# debugId=130AE55EFB9420D864756E2164756E21
6876
+ //# debugId=65F073C748987DA264756E2164756E21