@workglow/tasks 0.2.8 → 0.2.10

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.d.ts CHANGED
@@ -14,5 +14,5 @@ export * from "./util/McpAuthTypes";
14
14
  export * from "./util/McpClientUtil";
15
15
  export * from "./util/McpTaskDeps";
16
16
  import { FileLoaderTask } from "./task/FileLoaderTask.server";
17
- export declare const registerCommonTasks: () => (typeof import("./common").ScalarAddTask | typeof import("./common").ScalarDivideTask | typeof import("./common").ScalarMultiplyTask | typeof import("./common").ScalarSubtractTask | typeof import("./common").ScalarSumTask | typeof import("./common").VectorDivideTask | typeof import("./common").VectorMultiplyTask | typeof import("./common").VectorSubtractTask | typeof import("./common").VectorSumTask | typeof import("./common").DateFormatTask | typeof import("./common").DebugLogTask | typeof import("./common").DelayTask | typeof import("./common").FetchUrlTask | typeof import("./common").HumanInputTask | typeof import("./common").HumanApprovalTask | typeof import("./common").ImageBlurTask | typeof import("./common").ImageBorderTask | typeof import("./common").ImageBrightnessTask | typeof import("./common").ImageContrastTask | typeof import("./common").ImageCropTask | typeof import("./common").ImageFlipTask | typeof import("./common").ImageGrayscaleTask | typeof import("./common").ImageInvertTask | typeof import("./common").ImagePixelateTask | typeof import("./common").ImagePosterizeTask | typeof import("./common").ImageResizeTask | typeof import("./common").ImageRotateTask | typeof import("./common").ImageSepiaTask | typeof import("./common").ImageTextTask | typeof import("./common").ImageThresholdTask | typeof import("./common").ImageTintTask | typeof import("./common").ImageTransparencyTask | typeof import("./common").ImageWatermarkTask | typeof import("./common").InputTask | typeof import("./common").JavaScriptTask | typeof import("./common").JsonPathTask | typeof import("./common").JsonTask | typeof import("./common").LambdaTask | typeof import("./common").McpListTask | typeof import("./common").McpPromptGetTask | typeof import("./common").McpResourceReadTask | typeof import("./common").McpSearchTask | typeof import("./common").McpToolCallTask | typeof import("./common").MergeTask | typeof import("./common").RegexTask | typeof import("./common").ScalarAbsTask | typeof import("./common").ScalarCeilTask | typeof import("./common").ScalarFloorTask | typeof import("./common").ScalarMaxTask | typeof import("./common").ScalarMinTask | typeof import("./common").ScalarRoundTask | typeof import("./common").ScalarTruncTask | typeof import("./common").SplitTask | typeof import("./common").StringConcatTask | typeof import("./common").StringIncludesTask | typeof import("./common").StringJoinTask | typeof import("./common").StringLengthTask | typeof import("./common").StringLowerCaseTask | typeof import("./common").StringReplaceTask | typeof import("./common").StringSliceTask | typeof import("./common").StringTemplateTask | typeof import("./common").StringTrimTask | typeof import("./common").StringUpperCaseTask | typeof import("./common").TemplateTask | typeof import("./common").VectorDistanceTask | typeof import("./common").VectorDotProductTask | typeof import("./common").VectorNormalizeTask | typeof import("./common").VectorScaleTask | typeof FileLoaderTask)[];
17
+ export declare const registerCommonTasks: () => (typeof import("./common").ScalarAddTask | typeof import("./common").ScalarDivideTask | typeof import("./common").ScalarMultiplyTask | typeof import("./common").ScalarSubtractTask | typeof import("./common").ScalarSumTask | typeof import("./common").VectorDivideTask | typeof import("./common").VectorMultiplyTask | typeof import("./common").VectorSubtractTask | typeof import("./common").VectorSumTask | typeof import("./common").DateFormatTask | typeof import("./common").DebugLogTask | typeof import("./common").DelayTask | typeof import("./common").FetchUrlTask | typeof import("./common").HumanApprovalTask | typeof import("./common").HumanInputTask | typeof import("./common").ImageBlurTask | typeof import("./common").ImageBorderTask | typeof import("./common").ImageBrightnessTask | typeof import("./common").ImageContrastTask | typeof import("./common").ImageCropTask | typeof import("./common").ImageFlipTask | typeof import("./common").ImageGrayscaleTask | typeof import("./common").ImageInvertTask | typeof import("./common").ImagePixelateTask | typeof import("./common").ImagePosterizeTask | typeof import("./common").ImageResizeTask | typeof import("./common").ImageRotateTask | typeof import("./common").ImageSepiaTask | typeof import("./common").ImageTextTask | typeof import("./common").ImageThresholdTask | typeof import("./common").ImageTintTask | typeof import("./common").ImageTransparencyTask | typeof import("./common").ImageWatermarkTask | typeof import("./common").InputTask | typeof import("./common").JavaScriptTask | typeof import("./common").JsonPathTask | typeof import("./common").JsonTask | typeof import("./common").LambdaTask | typeof import("./common").McpListTask | typeof import("./common").McpPromptGetTask | typeof import("./common").McpResourceReadTask | typeof import("./common").McpSearchTask | typeof import("./common").McpToolCallTask | typeof import("./common").MergeTask | typeof import("./common").RegexTask | typeof import("./common").ScalarAbsTask | typeof import("./common").ScalarCeilTask | typeof import("./common").ScalarFloorTask | typeof import("./common").ScalarMaxTask | typeof import("./common").ScalarMinTask | typeof import("./common").ScalarRoundTask | typeof import("./common").ScalarTruncTask | typeof import("./common").SplitTask | typeof import("./common").StringConcatTask | typeof import("./common").StringIncludesTask | typeof import("./common").StringJoinTask | typeof import("./common").StringLengthTask | typeof import("./common").StringLowerCaseTask | typeof import("./common").StringReplaceTask | typeof import("./common").StringSliceTask | typeof import("./common").StringTemplateTask | typeof import("./common").StringTrimTask | typeof import("./common").StringUpperCaseTask | typeof import("./common").TemplateTask | typeof import("./common").VectorDistanceTask | typeof import("./common").VectorDotProductTask | typeof import("./common").VectorNormalizeTask | typeof import("./common").VectorScaleTask | typeof FileLoaderTask)[];
18
18
  //# sourceMappingURL=bun.d.ts.map
package/dist/bun.js CHANGED
@@ -5534,30 +5534,169 @@ var fetchUrl = async (input, config = {}) => {
5534
5534
  };
5535
5535
  Workflow14.prototype.fetch = CreateWorkflow13(FetchUrlTask);
5536
5536
  // src/task/HumanApprovalTask.ts
5537
- import {
5538
- CreateWorkflow as CreateWorkflow15,
5539
- Task as Task41,
5540
- TaskAbortedError as TaskAbortedError3,
5541
- TaskConfigSchema as TaskConfigSchema31,
5542
- Workflow as Workflow16
5543
- } from "@workglow/task-graph";
5544
- import { uuid4 as uuid44 } from "@workglow/util";
5545
-
5546
- // src/task/HumanInputTask.ts
5547
5537
  import {
5548
5538
  CreateWorkflow as CreateWorkflow14,
5549
5539
  Task as Task40,
5550
5540
  TaskAbortedError as TaskAbortedError2,
5551
5541
  TaskConfigSchema as TaskConfigSchema30,
5552
- TaskConfigurationError as TaskConfigurationError2,
5553
5542
  Workflow as Workflow15
5554
5543
  } from "@workglow/task-graph";
5555
- import { createServiceToken as createServiceToken5, uuid4 as uuid43 } from "@workglow/util";
5556
- var HUMAN_CONNECTOR = createServiceToken5("HUMAN_CONNECTOR");
5557
- var humanInputTaskConfigSchema = {
5544
+ import { uuid4 as uuid43, resolveHumanConnector } from "@workglow/util";
5545
+ var humanApprovalConfigSchema = {
5558
5546
  type: "object",
5559
5547
  properties: {
5560
5548
  ...TaskConfigSchema30["properties"],
5549
+ targetHumanId: {
5550
+ type: "string",
5551
+ title: "Target Human",
5552
+ description: "Identifier of the human to ask for approval",
5553
+ default: "default"
5554
+ },
5555
+ message: {
5556
+ type: "string",
5557
+ title: "Message",
5558
+ description: "Explanatory message shown to the approver",
5559
+ "x-ui-editor": "textarea"
5560
+ },
5561
+ metadata: {
5562
+ type: "object",
5563
+ additionalProperties: true,
5564
+ "x-ui-hidden": true
5565
+ }
5566
+ },
5567
+ additionalProperties: false
5568
+ };
5569
+ var inputSchema40 = {
5570
+ type: "object",
5571
+ properties: {
5572
+ prompt: {
5573
+ type: "string",
5574
+ title: "Prompt",
5575
+ description: "Dynamic prompt text merged into the approval message"
5576
+ },
5577
+ context: {
5578
+ type: "object",
5579
+ additionalProperties: true,
5580
+ title: "Context",
5581
+ description: "Dynamic context data merged into the request metadata",
5582
+ "x-ui-hidden": true
5583
+ }
5584
+ },
5585
+ additionalProperties: false
5586
+ };
5587
+ var approvalRequestedSchema = {
5588
+ type: "object",
5589
+ properties: {
5590
+ approved: {
5591
+ type: "boolean",
5592
+ title: "Approved",
5593
+ description: "Whether the request is approved"
5594
+ },
5595
+ reason: {
5596
+ type: "string",
5597
+ title: "Reason",
5598
+ description: "Optional explanation for the decision"
5599
+ }
5600
+ },
5601
+ required: ["approved"]
5602
+ };
5603
+ var approvalOutputSchema = {
5604
+ type: "object",
5605
+ properties: {
5606
+ action: {
5607
+ type: "string",
5608
+ title: "Action",
5609
+ description: "The human's action: accept, decline, or cancel",
5610
+ enum: ["accept", "decline", "cancel"]
5611
+ },
5612
+ approved: {
5613
+ type: "boolean",
5614
+ title: "Approved",
5615
+ description: "Whether the human approved the request"
5616
+ },
5617
+ reason: {
5618
+ type: "string",
5619
+ title: "Reason",
5620
+ description: "Optional explanation for the decision"
5621
+ }
5622
+ },
5623
+ required: ["action", "approved"],
5624
+ additionalProperties: false
5625
+ };
5626
+
5627
+ class HumanApprovalTask extends Task40 {
5628
+ static type = "HumanApprovalTask";
5629
+ static category = "Flow Control";
5630
+ static title = "Human Approval";
5631
+ static description = "Pauses execution to request approval from a human (approve/deny) via MCP elicitation";
5632
+ static cacheable = false;
5633
+ static configSchema() {
5634
+ return humanApprovalConfigSchema;
5635
+ }
5636
+ static inputSchema() {
5637
+ return inputSchema40;
5638
+ }
5639
+ static outputSchema() {
5640
+ return approvalOutputSchema;
5641
+ }
5642
+ async execute(input, context) {
5643
+ const connector = resolveHumanConnector(context);
5644
+ const requestId = uuid43();
5645
+ const message = input.prompt ? this.config.message ? `${this.config.message}
5646
+
5647
+ ${input.prompt}` : input.prompt : this.config.message ?? "";
5648
+ const request = {
5649
+ requestId,
5650
+ targetHumanId: this.config.targetHumanId ?? "default",
5651
+ kind: "elicit",
5652
+ message,
5653
+ contentSchema: approvalRequestedSchema,
5654
+ contentData: undefined,
5655
+ expectsResponse: true,
5656
+ mode: "single",
5657
+ metadata: input.context ? { ...this.config.metadata, ...input.context } : this.config.metadata
5658
+ };
5659
+ if (context.signal.aborted) {
5660
+ throw new TaskAbortedError2("Task aborted before requesting human approval");
5661
+ }
5662
+ let response;
5663
+ try {
5664
+ response = await connector.send(request, context.signal);
5665
+ } catch (err) {
5666
+ if (context.signal.aborted) {
5667
+ throw new TaskAbortedError2("Task aborted during human approval");
5668
+ }
5669
+ throw err;
5670
+ }
5671
+ if (response.action === "accept" && response.content) {
5672
+ return {
5673
+ action: response.action,
5674
+ approved: response.content.approved === true,
5675
+ reason: response.content.reason
5676
+ };
5677
+ }
5678
+ return {
5679
+ action: response.action,
5680
+ approved: false,
5681
+ ...response.content?.reason !== undefined ? { reason: response.content.reason } : {}
5682
+ };
5683
+ }
5684
+ }
5685
+ Workflow15.prototype.humanApproval = CreateWorkflow14(HumanApprovalTask);
5686
+ // src/task/HumanInputTask.ts
5687
+ import {
5688
+ CreateWorkflow as CreateWorkflow15,
5689
+ Task as Task41,
5690
+ TaskAbortedError as TaskAbortedError3,
5691
+ TaskConfigSchema as TaskConfigSchema31,
5692
+ TaskConfigurationError as TaskConfigurationError2,
5693
+ Workflow as Workflow16
5694
+ } from "@workglow/task-graph";
5695
+ import { resolveHumanConnector as resolveHumanConnector2, uuid4 as uuid44 } from "@workglow/util";
5696
+ var humanInputTaskConfigSchema = {
5697
+ type: "object",
5698
+ properties: {
5699
+ ...TaskConfigSchema31["properties"],
5561
5700
  targetHumanId: {
5562
5701
  type: "string",
5563
5702
  title: "Target Human",
@@ -5638,7 +5777,7 @@ var defaultOutputSchema = {
5638
5777
  additionalProperties: true
5639
5778
  };
5640
5779
 
5641
- class HumanInputTask extends Task40 {
5780
+ class HumanInputTask extends Task41 {
5642
5781
  static type = "HumanInputTask";
5643
5782
  static category = "Flow Control";
5644
5783
  static title = "Human Input";
@@ -5676,10 +5815,10 @@ class HumanInputTask extends Task40 {
5676
5815
  return this.constructor.outputSchema();
5677
5816
  }
5678
5817
  async execute(input, context) {
5679
- const connector = resolveHumanConnector(context);
5818
+ const connector = resolveHumanConnector2(context);
5680
5819
  const kind = this.config.kind ?? "elicit";
5681
5820
  const mode = this.config.mode ?? "single";
5682
- const requestId = uuid43();
5821
+ const requestId = uuid44();
5683
5822
  const message = input.prompt ? this.config.message ? `${this.config.message}
5684
5823
 
5685
5824
  ${input.prompt}` : input.prompt : this.config.message ?? "";
@@ -5700,14 +5839,14 @@ ${input.prompt}` : input.prompt : this.config.message ?? "";
5700
5839
  metadata: input.context ? { ...this.config.metadata, ...input.context } : this.config.metadata
5701
5840
  };
5702
5841
  if (context.signal.aborted) {
5703
- throw new TaskAbortedError2("Task aborted before sending human interaction");
5842
+ throw new TaskAbortedError3("Task aborted before sending human interaction");
5704
5843
  }
5705
5844
  let response;
5706
5845
  try {
5707
5846
  response = await connector.send(request, context.signal);
5708
5847
  } catch (err) {
5709
5848
  if (context.signal.aborted) {
5710
- throw new TaskAbortedError2("Task aborted during human interaction");
5849
+ throw new TaskAbortedError3("Task aborted during human interaction");
5711
5850
  }
5712
5851
  throw err;
5713
5852
  }
@@ -5717,13 +5856,13 @@ ${input.prompt}` : input.prompt : this.config.message ?? "";
5717
5856
  }
5718
5857
  while (!response.done) {
5719
5858
  if (context.signal.aborted) {
5720
- throw new TaskAbortedError2("Task aborted during multi-turn conversation");
5859
+ throw new TaskAbortedError3("Task aborted during multi-turn conversation");
5721
5860
  }
5722
5861
  try {
5723
5862
  response = await connector.followUp(request, response, context.signal);
5724
5863
  } catch (err) {
5725
5864
  if (context.signal.aborted) {
5726
- throw new TaskAbortedError2("Task aborted during multi-turn conversation");
5865
+ throw new TaskAbortedError3("Task aborted during multi-turn conversation");
5727
5866
  }
5728
5867
  throw err;
5729
5868
  }
@@ -5732,156 +5871,7 @@ ${input.prompt}` : input.prompt : this.config.message ?? "";
5732
5871
  return { ...response.content, action: response.action };
5733
5872
  }
5734
5873
  }
5735
- function resolveHumanConnector(context) {
5736
- if (!context.registry.has(HUMAN_CONNECTOR)) {
5737
- throw new TaskConfigurationError2("No IHumanConnector registered. Register one via " + "registry.registerInstance(HUMAN_CONNECTOR, connector) before running a human-in-the-loop task.");
5738
- }
5739
- return context.registry.get(HUMAN_CONNECTOR);
5740
- }
5741
- Workflow15.prototype.humanInput = CreateWorkflow14(HumanInputTask);
5742
-
5743
- // src/task/HumanApprovalTask.ts
5744
- var humanApprovalConfigSchema = {
5745
- type: "object",
5746
- properties: {
5747
- ...TaskConfigSchema31["properties"],
5748
- targetHumanId: {
5749
- type: "string",
5750
- title: "Target Human",
5751
- description: "Identifier of the human to ask for approval",
5752
- default: "default"
5753
- },
5754
- message: {
5755
- type: "string",
5756
- title: "Message",
5757
- description: "Explanatory message shown to the approver",
5758
- "x-ui-editor": "textarea"
5759
- },
5760
- metadata: {
5761
- type: "object",
5762
- additionalProperties: true,
5763
- "x-ui-hidden": true
5764
- }
5765
- },
5766
- additionalProperties: false
5767
- };
5768
- var inputSchema40 = {
5769
- type: "object",
5770
- properties: {
5771
- prompt: {
5772
- type: "string",
5773
- title: "Prompt",
5774
- description: "Dynamic prompt text merged into the approval message"
5775
- },
5776
- context: {
5777
- type: "object",
5778
- additionalProperties: true,
5779
- title: "Context",
5780
- description: "Dynamic context data merged into the request metadata",
5781
- "x-ui-hidden": true
5782
- }
5783
- },
5784
- additionalProperties: false
5785
- };
5786
- var approvalRequestedSchema = {
5787
- type: "object",
5788
- properties: {
5789
- approved: {
5790
- type: "boolean",
5791
- title: "Approved",
5792
- description: "Whether the request is approved"
5793
- },
5794
- reason: {
5795
- type: "string",
5796
- title: "Reason",
5797
- description: "Optional explanation for the decision"
5798
- }
5799
- },
5800
- required: ["approved"]
5801
- };
5802
- var approvalOutputSchema = {
5803
- type: "object",
5804
- properties: {
5805
- action: {
5806
- type: "string",
5807
- title: "Action",
5808
- description: "The human's action: accept, decline, or cancel",
5809
- enum: ["accept", "decline", "cancel"]
5810
- },
5811
- approved: {
5812
- type: "boolean",
5813
- title: "Approved",
5814
- description: "Whether the human approved the request"
5815
- },
5816
- reason: {
5817
- type: "string",
5818
- title: "Reason",
5819
- description: "Optional explanation for the decision"
5820
- }
5821
- },
5822
- required: ["action", "approved"],
5823
- additionalProperties: false
5824
- };
5825
-
5826
- class HumanApprovalTask extends Task41 {
5827
- static type = "HumanApprovalTask";
5828
- static category = "Flow Control";
5829
- static title = "Human Approval";
5830
- static description = "Pauses execution to request approval from a human (approve/deny) via MCP elicitation";
5831
- static cacheable = false;
5832
- static configSchema() {
5833
- return humanApprovalConfigSchema;
5834
- }
5835
- static inputSchema() {
5836
- return inputSchema40;
5837
- }
5838
- static outputSchema() {
5839
- return approvalOutputSchema;
5840
- }
5841
- async execute(input, context) {
5842
- const connector = resolveHumanConnector(context);
5843
- const requestId = uuid44();
5844
- const message = input.prompt ? this.config.message ? `${this.config.message}
5845
-
5846
- ${input.prompt}` : input.prompt : this.config.message ?? "";
5847
- const request = {
5848
- requestId,
5849
- targetHumanId: this.config.targetHumanId ?? "default",
5850
- kind: "elicit",
5851
- message,
5852
- contentSchema: approvalRequestedSchema,
5853
- contentData: undefined,
5854
- expectsResponse: true,
5855
- mode: "single",
5856
- metadata: input.context ? { ...this.config.metadata, ...input.context } : this.config.metadata
5857
- };
5858
- if (context.signal.aborted) {
5859
- throw new TaskAbortedError3("Task aborted before requesting human approval");
5860
- }
5861
- let response;
5862
- try {
5863
- response = await connector.send(request, context.signal);
5864
- } catch (err) {
5865
- if (context.signal.aborted) {
5866
- throw new TaskAbortedError3("Task aborted during human approval");
5867
- }
5868
- throw err;
5869
- }
5870
- if (response.action === "accept" && response.content) {
5871
- return {
5872
- action: response.action,
5873
- approved: response.content.approved === true,
5874
- reason: response.content.reason
5875
- };
5876
- }
5877
- return {
5878
- action: response.action,
5879
- approved: false,
5880
- ...response.content?.reason !== undefined ? { reason: response.content.reason } : {}
5881
- };
5882
- }
5883
- }
5884
- Workflow16.prototype.humanApproval = CreateWorkflow15(HumanApprovalTask);
5874
+ Workflow16.prototype.humanInput = CreateWorkflow15(HumanInputTask);
5885
5875
  // src/task/image/ImageBlurTask.ts
5886
5876
  import {
5887
5877
  CreateWorkflow as CreateWorkflow16,
@@ -16128,7 +16118,6 @@ export {
16128
16118
  searchMcpRegistry,
16129
16119
  safeFetch,
16130
16120
  resolveImageInput,
16131
- resolveHumanConnector,
16132
16121
  resolveAuthSecrets,
16133
16122
  resetSafeFetch,
16134
16123
  registerSafeFetch,
@@ -16262,7 +16251,6 @@ export {
16262
16251
  ImageBinaryOrDataUriSchema,
16263
16252
  HumanInputTask,
16264
16253
  HumanApprovalTask,
16265
- HUMAN_CONNECTOR,
16266
16254
  FileLoaderTask2 as FileLoaderTask,
16267
16255
  FetchUrlTask,
16268
16256
  FetchUrlJob,
@@ -16304,4 +16292,4 @@ export {
16304
16292
  ArrayTask
16305
16293
  };
16306
16294
 
16307
- //# debugId=BD5ACC142C4D180B64756E2164756E21
16295
+ //# debugId=1BFE50AE27869D8164756E2164756E21