@workglow/tasks 0.0.100 → 0.0.102

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
@@ -1316,14 +1316,6 @@ Workflow13.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, Vecto
1316
1316
  Workflow13.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
1317
1317
  Workflow13.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
1318
1318
 
1319
- // src/common.ts
1320
- import {
1321
- createMcpClient,
1322
- mcpClientFactory as mcpClientFactory5,
1323
- mcpServerConfigSchema as mcpServerConfigSchema5,
1324
- mcpTransportTypes
1325
- } from "@workglow/util";
1326
-
1327
1319
  // src/task/ArrayTask.ts
1328
1320
  import {
1329
1321
  uuid4
@@ -1379,7 +1371,7 @@ class ArrayTask extends GraphAsTask {
1379
1371
  const inputObject = Object.fromEntries(arrayInputs);
1380
1372
  const combinations = this.generateCombinations(inputObject, inputIds);
1381
1373
  const tasks = combinations.map((combination) => {
1382
- const { id, name, ...rest } = this.config;
1374
+ const { id, title, ...rest } = this.config;
1383
1375
  const task = new this.constructor({ ...this.defaults, ...this.runInputData, ...combination }, { ...rest, id: `${id}_${uuid4()}` });
1384
1376
  return task;
1385
1377
  });
@@ -1452,16 +1444,13 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
1452
1444
  }
1453
1445
  }
1454
1446
  // src/task/DebugLogTask.ts
1455
- import { CreateWorkflow as CreateWorkflow13, Task as Task11, Workflow as Workflow14 } from "@workglow/task-graph";
1447
+ import { CreateWorkflow as CreateWorkflow13, Task as Task11, TaskConfigSchema, Workflow as Workflow14 } from "@workglow/task-graph";
1456
1448
  var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
1457
1449
  var DEFAULT_LOG_LEVEL = "log";
1458
- var inputSchema12 = {
1450
+ var debugLogTaskConfigSchema = {
1459
1451
  type: "object",
1460
1452
  properties: {
1461
- console: {
1462
- title: "Message",
1463
- description: "The message to log"
1464
- },
1453
+ ...TaskConfigSchema["properties"],
1465
1454
  log_level: {
1466
1455
  type: "string",
1467
1456
  enum: log_levels,
@@ -1472,15 +1461,15 @@ var inputSchema12 = {
1472
1461
  },
1473
1462
  additionalProperties: false
1474
1463
  };
1464
+ var inputSchema12 = {
1465
+ type: "object",
1466
+ properties: {},
1467
+ additionalProperties: true
1468
+ };
1475
1469
  var outputSchema12 = {
1476
1470
  type: "object",
1477
- properties: {
1478
- console: {
1479
- title: "Messages",
1480
- description: "The messages logged by the task"
1481
- }
1482
- },
1483
- additionalProperties: false
1471
+ properties: {},
1472
+ additionalProperties: true
1484
1473
  };
1485
1474
 
1486
1475
  class DebugLogTask extends Task11 {
@@ -1489,6 +1478,11 @@ class DebugLogTask extends Task11 {
1489
1478
  static title = "Debug Log";
1490
1479
  static description = "Logs messages to the console with configurable log levels for debugging task graphs";
1491
1480
  static cacheable = false;
1481
+ static passthroughInputsToOutputs = true;
1482
+ static customizable = true;
1483
+ static configSchema() {
1484
+ return debugLogTaskConfigSchema;
1485
+ }
1492
1486
  static inputSchema() {
1493
1487
  return inputSchema12;
1494
1488
  }
@@ -1496,13 +1490,14 @@ class DebugLogTask extends Task11 {
1496
1490
  return outputSchema12;
1497
1491
  }
1498
1492
  async executeReactive(input, output) {
1499
- const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
1500
- if (log_level == "dir") {
1501
- console.dir(messages, { depth: null });
1493
+ const log_level = this.config.log_level ?? DEFAULT_LOG_LEVEL;
1494
+ const inputRecord = input;
1495
+ if (log_level === "dir") {
1496
+ console.dir(inputRecord, { depth: null });
1502
1497
  } else {
1503
- console[log_level](messages);
1498
+ console[log_level](inputRecord);
1504
1499
  }
1505
- output.console = input.console;
1500
+ Object.assign(output, inputRecord);
1506
1501
  return output;
1507
1502
  }
1508
1503
  }
@@ -1516,24 +1511,27 @@ import {
1516
1511
  CreateWorkflow as CreateWorkflow14,
1517
1512
  Task as Task12,
1518
1513
  TaskAbortedError as TaskAbortedError3,
1514
+ TaskConfigSchema as TaskConfigSchema2,
1519
1515
  Workflow as Workflow15
1520
1516
  } from "@workglow/task-graph";
1521
1517
  import { sleep } from "@workglow/util";
1522
- var inputSchema13 = {
1518
+ var delayTaskConfigSchema = {
1523
1519
  type: "object",
1524
1520
  properties: {
1521
+ ...TaskConfigSchema2["properties"],
1525
1522
  delay: {
1526
1523
  type: "number",
1527
1524
  title: "Delay (ms)",
1528
1525
  default: 1
1529
- },
1530
- pass_through: {
1531
- title: "Pass Through",
1532
- description: "Pass through data to the output"
1533
1526
  }
1534
1527
  },
1535
1528
  additionalProperties: false
1536
1529
  };
1530
+ var inputSchema13 = {
1531
+ type: "object",
1532
+ properties: {},
1533
+ additionalProperties: true
1534
+ };
1537
1535
  var outputSchema13 = {
1538
1536
  type: "object",
1539
1537
  properties: {},
@@ -1545,6 +1543,12 @@ class DelayTask extends Task12 {
1545
1543
  static category = "Utility";
1546
1544
  static title = "Delay";
1547
1545
  static description = "Delays execution for a specified duration with progress tracking";
1546
+ static cacheable = false;
1547
+ static passthroughInputsToOutputs = true;
1548
+ static customizable = true;
1549
+ static configSchema() {
1550
+ return delayTaskConfigSchema;
1551
+ }
1548
1552
  static inputSchema() {
1549
1553
  return inputSchema13;
1550
1554
  }
@@ -1552,7 +1556,7 @@ class DelayTask extends Task12 {
1552
1556
  return outputSchema13;
1553
1557
  }
1554
1558
  async execute(input, executeContext) {
1555
- const delay = input.delay ?? 0;
1559
+ const delay = this.config.delay ?? 1;
1556
1560
  if (delay > 100) {
1557
1561
  const iterations = Math.min(100, Math.floor(delay / 16));
1558
1562
  const chunkSize = delay / iterations;
@@ -1566,10 +1570,10 @@ class DelayTask extends Task12 {
1566
1570
  } else {
1567
1571
  await sleep(delay);
1568
1572
  }
1569
- return input.pass_through;
1573
+ return input;
1570
1574
  }
1571
1575
  }
1572
- var delay = (input, config = {}) => {
1576
+ var delay = (input, config = { delay: 1 }) => {
1573
1577
  const task = new DelayTask({}, config);
1574
1578
  return task.run(input);
1575
1579
  };
@@ -1599,10 +1603,10 @@ class InputTask extends Task13 {
1599
1603
  };
1600
1604
  }
1601
1605
  inputSchema() {
1602
- return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
1606
+ return this.config?.inputSchema ?? this.constructor.inputSchema();
1603
1607
  }
1604
1608
  outputSchema() {
1605
- return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
1609
+ return this.config?.outputSchema ?? this.constructor.outputSchema();
1606
1610
  }
1607
1611
  async execute(input) {
1608
1612
  return input;
@@ -1633,7 +1637,7 @@ class InputTask extends Task13 {
1633
1637
  }
1634
1638
  Workflow16.prototype.input = CreateWorkflow15(InputTask);
1635
1639
  // src/task/JavaScriptTask.ts
1636
- import { CreateWorkflow as CreateWorkflow16, Task as Task14, Workflow as Workflow17 } from "@workglow/task-graph";
1640
+ import { CreateWorkflow as CreateWorkflow16, Task as Task14, TaskConfigSchema as TaskConfigSchema3, Workflow as Workflow17 } from "@workglow/task-graph";
1637
1641
 
1638
1642
  // src/util/acorn.js
1639
1643
  var options;
@@ -6096,6 +6100,20 @@ Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
6096
6100
  Interpreter["Status"] = Interpreter.Status;
6097
6101
 
6098
6102
  // src/task/JavaScriptTask.ts
6103
+ var configSchema = {
6104
+ type: "object",
6105
+ properties: {
6106
+ ...TaskConfigSchema3["properties"],
6107
+ javascript_code: {
6108
+ type: "string",
6109
+ title: "Code",
6110
+ minLength: 1,
6111
+ description: "JavaScript code to execute",
6112
+ format: "code:javascript"
6113
+ }
6114
+ },
6115
+ additionalProperties: false
6116
+ };
6099
6117
  var inputSchema14 = {
6100
6118
  type: "object",
6101
6119
  properties: {
@@ -6127,14 +6145,34 @@ class JavaScriptTask extends Task14 {
6127
6145
  static category = "Utility";
6128
6146
  static title = "JavaScript Interpreter";
6129
6147
  static description = "Executes JavaScript code in a sandboxed interpreter environment";
6148
+ static customizable = true;
6149
+ static configSchema() {
6150
+ return configSchema;
6151
+ }
6130
6152
  static inputSchema() {
6131
6153
  return inputSchema14;
6132
6154
  }
6133
6155
  static outputSchema() {
6134
6156
  return outputSchema14;
6135
6157
  }
6158
+ constructor(input2 = {}, config = {}) {
6159
+ super(input2, config);
6160
+ }
6161
+ inputSchema() {
6162
+ if (this.config?.javascript_code) {
6163
+ if (this.config.inputSchema) {
6164
+ return this.config.inputSchema;
6165
+ }
6166
+ return {
6167
+ type: "object",
6168
+ properties: {},
6169
+ additionalProperties: true
6170
+ };
6171
+ }
6172
+ return inputSchema14;
6173
+ }
6136
6174
  async executeReactive(input2, output) {
6137
- if (input2.javascript_code) {
6175
+ if (this.config.javascript_code || input2.javascript_code) {
6138
6176
  try {
6139
6177
  const inputVariables = Object.keys(input2).filter((key) => key !== "javascript_code");
6140
6178
  const inputVariablesString = inputVariables.map((key) => `var ${key} = ${JSON.stringify(input2[key])};`).join(`
@@ -6232,9 +6270,19 @@ import {
6232
6270
  CreateWorkflow as CreateWorkflow18,
6233
6271
  DATAFLOW_ALL_PORTS,
6234
6272
  Task as Task15,
6273
+ TaskConfigSchema as TaskConfigSchema4,
6235
6274
  TaskConfigurationError as TaskConfigurationError3,
6236
6275
  Workflow as Workflow19
6237
6276
  } from "@workglow/task-graph";
6277
+ var lambdaTaskConfigSchema = {
6278
+ type: "object",
6279
+ properties: {
6280
+ ...TaskConfigSchema4["properties"],
6281
+ execute: {},
6282
+ executeReactive: {}
6283
+ },
6284
+ additionalProperties: false
6285
+ };
6238
6286
  var inputSchema16 = {
6239
6287
  type: "object",
6240
6288
  properties: {
@@ -6262,6 +6310,9 @@ class LambdaTask extends Task15 {
6262
6310
  static description = "A task that wraps a provided function and its input";
6263
6311
  static category = "Hidden";
6264
6312
  static cacheable = true;
6313
+ static configSchema() {
6314
+ return lambdaTaskConfigSchema;
6315
+ }
6265
6316
  static inputSchema() {
6266
6317
  return inputSchema16;
6267
6318
  }
@@ -6374,10 +6425,10 @@ class OutputTask extends Task17 {
6374
6425
  };
6375
6426
  }
6376
6427
  inputSchema() {
6377
- return this.config?.extras?.inputSchema ?? this.constructor.inputSchema();
6428
+ return this.config?.inputSchema ?? this.constructor.inputSchema();
6378
6429
  }
6379
6430
  outputSchema() {
6380
- return this.config?.extras?.outputSchema ?? this.constructor.outputSchema();
6431
+ return this.config?.outputSchema ?? this.constructor.outputSchema();
6381
6432
  }
6382
6433
  async execute(input2) {
6383
6434
  return input2;
@@ -6705,28 +6756,32 @@ var mcpList = async (input2, config = {}) => {
6705
6756
  };
6706
6757
  Workflow23.prototype.mcpList = CreateWorkflow22(McpListTask);
6707
6758
  // src/task/mcp/McpPromptGetTask.ts
6708
- import { CreateWorkflow as CreateWorkflow23, Task as Task20, Workflow as Workflow24 } from "@workglow/task-graph";
6759
+ import {
6760
+ CreateWorkflow as CreateWorkflow23,
6761
+ Task as Task20,
6762
+ TaskConfigSchema as TaskConfigSchema5,
6763
+ Workflow as Workflow24
6764
+ } from "@workglow/task-graph";
6709
6765
  import {
6710
6766
  mcpClientFactory as mcpClientFactory2,
6711
6767
  mcpServerConfigSchema as mcpServerConfigSchema2
6712
6768
  } from "@workglow/util";
6713
- var inputSchema20 = {
6769
+ var configSchema2 = {
6714
6770
  type: "object",
6715
6771
  properties: {
6772
+ ...TaskConfigSchema5["properties"],
6716
6773
  ...mcpServerConfigSchema2,
6717
6774
  prompt_name: {
6718
6775
  type: "string",
6719
6776
  title: "Prompt Name",
6720
- description: "The name of the prompt to get"
6721
- },
6722
- prompt_arguments: {
6723
- type: "object",
6724
- additionalProperties: { type: "string" },
6725
- title: "Prompt Arguments",
6726
- description: "Arguments to pass to the prompt"
6777
+ description: "The name of the prompt to get",
6778
+ format: "string:mcp-promptname"
6727
6779
  }
6728
6780
  },
6729
6781
  required: ["transport", "prompt_name"],
6782
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
6783
+ then: { required: ["command"] },
6784
+ else: { required: ["server_url"] },
6730
6785
  additionalProperties: false
6731
6786
  };
6732
6787
  var annotationsSchema = {
@@ -6830,7 +6885,7 @@ var contentSchema = {
6830
6885
  }
6831
6886
  ]
6832
6887
  };
6833
- var outputSchema19 = {
6888
+ var fallbackOutputSchema = {
6834
6889
  type: "object",
6835
6890
  properties: {
6836
6891
  messages: {
@@ -6856,6 +6911,11 @@ var outputSchema19 = {
6856
6911
  required: ["messages"],
6857
6912
  additionalProperties: false
6858
6913
  };
6914
+ var fallbackInputSchema = {
6915
+ type: "object",
6916
+ properties: {},
6917
+ additionalProperties: false
6918
+ };
6859
6919
 
6860
6920
  class McpPromptGetTask extends Task20 {
6861
6921
  static type = "McpPromptGetTask";
@@ -6863,18 +6923,71 @@ class McpPromptGetTask extends Task20 {
6863
6923
  static title = "MCP Get Prompt";
6864
6924
  static description = "Gets a prompt from an MCP server";
6865
6925
  static cacheable = false;
6926
+ static customizable = true;
6927
+ static hasDynamicSchemas = true;
6866
6928
  static inputSchema() {
6867
- return inputSchema20;
6929
+ return fallbackInputSchema;
6868
6930
  }
6869
6931
  static outputSchema() {
6870
- return outputSchema19;
6932
+ return fallbackOutputSchema;
6933
+ }
6934
+ static configSchema() {
6935
+ return configSchema2;
6936
+ }
6937
+ inputSchema() {
6938
+ return this.config?.inputSchema ?? fallbackInputSchema;
6939
+ }
6940
+ outputSchema() {
6941
+ return this.config?.outputSchema ?? fallbackOutputSchema;
6942
+ }
6943
+ _schemasDiscovering = false;
6944
+ async discoverSchemas(signal) {
6945
+ if (this.config.inputSchema)
6946
+ return;
6947
+ if (this._schemasDiscovering)
6948
+ return;
6949
+ if (!this.config.transport || !this.config.prompt_name)
6950
+ return;
6951
+ this._schemasDiscovering = true;
6952
+ try {
6953
+ const result = await mcpList({
6954
+ transport: this.config.transport,
6955
+ server_url: this.config.server_url,
6956
+ command: this.config.command,
6957
+ args: this.config.args,
6958
+ env: this.config.env,
6959
+ list_type: "prompts"
6960
+ });
6961
+ const prompt = result.prompts?.find((p) => p.name === this.config.prompt_name);
6962
+ if (prompt) {
6963
+ const args = prompt.arguments ?? [];
6964
+ const required = args.filter((a) => a.required).map((a) => a.name);
6965
+ const properties = {};
6966
+ for (const arg of args) {
6967
+ properties[arg.name] = {
6968
+ type: "string",
6969
+ ...arg.description ? { description: arg.description } : {}
6970
+ };
6971
+ }
6972
+ this.config.inputSchema = {
6973
+ type: "object",
6974
+ properties,
6975
+ ...required.length > 0 ? { required } : {},
6976
+ additionalProperties: false
6977
+ };
6978
+ this.emitSchemaChange();
6979
+ }
6980
+ } finally {
6981
+ this._schemasDiscovering = false;
6982
+ }
6871
6983
  }
6872
6984
  async execute(input2, context) {
6873
- const { client } = await mcpClientFactory2.create(input2, context.signal);
6985
+ await this.discoverSchemas(context.signal);
6986
+ const { client } = await mcpClientFactory2.create(this.config, context.signal);
6874
6987
  try {
6875
6988
  const result = await client.getPrompt({
6876
- name: input2.prompt_name,
6877
- arguments: input2.prompt_arguments
6989
+ name: this.config.prompt_name,
6990
+ arguments: input2
6878
6991
  });
6879
6992
  return {
6880
6993
  messages: result.messages,
@@ -6885,28 +6998,37 @@ class McpPromptGetTask extends Task20 {
6885
6998
  }
6886
6999
  }
6887
7000
  }
6888
- var mcpPromptGet = async (input2, config = {}) => {
6889
- const result = await new McpPromptGetTask({}, config).run(input2);
6890
- return result;
7001
+ var mcpPromptGet = async (input2, config) => {
7002
+ return new McpPromptGetTask({}, config).run(input2);
6891
7003
  };
6892
7004
  Workflow24.prototype.mcpPromptGet = CreateWorkflow23(McpPromptGetTask);
6893
7005
  // src/task/mcp/McpResourceReadTask.ts
6894
- import { CreateWorkflow as CreateWorkflow24, Task as Task21, Workflow as Workflow25 } from "@workglow/task-graph";
7006
+ import {
7007
+ CreateWorkflow as CreateWorkflow24,
7008
+ Task as Task21,
7009
+ TaskConfigSchema as TaskConfigSchema6,
7010
+ Workflow as Workflow25
7011
+ } from "@workglow/task-graph";
6895
7012
  import {
6896
7013
  mcpClientFactory as mcpClientFactory3,
6897
7014
  mcpServerConfigSchema as mcpServerConfigSchema3
6898
7015
  } from "@workglow/util";
6899
- var inputSchema21 = {
7016
+ var configSchema3 = {
6900
7017
  type: "object",
6901
7018
  properties: {
7019
+ ...TaskConfigSchema6["properties"],
6902
7020
  ...mcpServerConfigSchema3,
6903
7021
  resource_uri: {
6904
7022
  type: "string",
6905
7023
  title: "Resource URI",
6906
- description: "The URI of the resource to read"
7024
+ description: "The URI of the resource to read",
7025
+ format: "string:uri:mcp-resourceuri"
6907
7026
  }
6908
7027
  },
6909
7028
  required: ["transport", "resource_uri"],
7029
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
7030
+ then: { required: ["command"] },
7031
+ else: { required: ["server_url"] },
6910
7032
  additionalProperties: false
6911
7033
  };
6912
7034
  var contentItemSchema = {
@@ -6935,7 +7057,12 @@ var contentItemSchema = {
6935
7057
  }
6936
7058
  ]
6937
7059
  };
6938
- var outputSchema20 = {
7060
+ var inputSchema20 = {
7061
+ type: "object",
7062
+ properties: {},
7063
+ additionalProperties: false
7064
+ };
7065
+ var outputSchema19 = {
6939
7066
  type: "object",
6940
7067
  properties: {
6941
7068
  contents: {
@@ -6955,49 +7082,57 @@ class McpResourceReadTask extends Task21 {
6955
7082
  static title = "MCP Read Resource";
6956
7083
  static description = "Reads a resource from an MCP server";
6957
7084
  static cacheable = false;
7085
+ static customizable = true;
6958
7086
  static inputSchema() {
6959
- return inputSchema21;
7087
+ return inputSchema20;
6960
7088
  }
6961
7089
  static outputSchema() {
6962
- return outputSchema20;
7090
+ return outputSchema19;
6963
7091
  }
6964
- async execute(input2, context) {
6965
- const { client } = await mcpClientFactory3.create(input2, context.signal);
7092
+ static configSchema() {
7093
+ return configSchema3;
7094
+ }
7095
+ async execute(_input, context) {
7096
+ const { client } = await mcpClientFactory3.create(this.config, context.signal);
6966
7097
  try {
6967
- const result = await client.readResource({ uri: input2.resource_uri });
7098
+ const result = await client.readResource({ uri: this.config.resource_uri });
6968
7099
  return { contents: result.contents };
6969
7100
  } finally {
6970
7101
  await client.close();
6971
7102
  }
6972
7103
  }
6973
7104
  }
6974
- var mcpResourceRead = async (input2, config = {}) => {
6975
- return new McpResourceReadTask({}, config).run(input2);
7105
+ var mcpResourceRead = async (config) => {
7106
+ return new McpResourceReadTask({}, config).run({});
6976
7107
  };
6977
7108
  Workflow25.prototype.mcpResourceRead = CreateWorkflow24(McpResourceReadTask);
6978
7109
  // src/task/mcp/McpToolCallTask.ts
6979
- import { CreateWorkflow as CreateWorkflow25, Task as Task22, Workflow as Workflow26 } from "@workglow/task-graph";
7110
+ import {
7111
+ CreateWorkflow as CreateWorkflow25,
7112
+ Task as Task22,
7113
+ TaskConfigSchema as TaskConfigSchema7,
7114
+ Workflow as Workflow26
7115
+ } from "@workglow/task-graph";
6980
7116
  import {
6981
7117
  mcpClientFactory as mcpClientFactory4,
6982
7118
  mcpServerConfigSchema as mcpServerConfigSchema4
6983
7119
  } from "@workglow/util";
6984
- var inputSchema22 = {
7120
+ var configSchema4 = {
6985
7121
  type: "object",
6986
7122
  properties: {
7123
+ ...TaskConfigSchema7["properties"],
6987
7124
  ...mcpServerConfigSchema4,
6988
7125
  tool_name: {
6989
7126
  type: "string",
6990
7127
  title: "Tool Name",
6991
- description: "The name of the tool to call"
6992
- },
6993
- tool_arguments: {
6994
- type: "object",
6995
- additionalProperties: true,
6996
- title: "Tool Arguments",
6997
- description: "Arguments to pass to the tool"
7128
+ description: "The name of the tool to call",
7129
+ format: "string:mcp-toolname"
6998
7130
  }
6999
7131
  },
7000
7132
  required: ["transport", "tool_name"],
7133
+ if: { properties: { transport: { const: "stdio" } }, required: ["transport"] },
7134
+ then: { required: ["command"] },
7135
+ else: { required: ["server_url"] },
7001
7136
  additionalProperties: false
7002
7137
  };
7003
7138
  var annotationsSchema2 = {
@@ -7101,7 +7236,7 @@ var toolContentSchema = {
7101
7236
  }
7102
7237
  ]
7103
7238
  };
7104
- var outputSchema21 = {
7239
+ var fallbackOutputSchema2 = {
7105
7240
  type: "object",
7106
7241
  properties: {
7107
7242
  content: {
@@ -7119,6 +7254,11 @@ var outputSchema21 = {
7119
7254
  required: ["content", "isError"],
7120
7255
  additionalProperties: false
7121
7256
  };
7257
+ var fallbackInputSchema2 = {
7258
+ type: "object",
7259
+ properties: {},
7260
+ additionalProperties: true
7261
+ };
7122
7262
 
7123
7263
  class McpToolCallTask extends Task22 {
7124
7264
  static type = "McpToolCallTask";
@@ -7126,38 +7266,103 @@ class McpToolCallTask extends Task22 {
7126
7266
  static title = "MCP Call Tool";
7127
7267
  static description = "Calls a tool on an MCP server and returns the result";
7128
7268
  static cacheable = false;
7269
+ static customizable = true;
7270
+ static hasDynamicSchemas = true;
7129
7271
  static inputSchema() {
7130
- return inputSchema22;
7272
+ return fallbackInputSchema2;
7131
7273
  }
7132
7274
  static outputSchema() {
7133
- return outputSchema21;
7275
+ return fallbackOutputSchema2;
7276
+ }
7277
+ static configSchema() {
7278
+ return configSchema4;
7279
+ }
7280
+ inputSchema() {
7281
+ return this.config?.inputSchema ?? fallbackInputSchema2;
7282
+ }
7283
+ outputSchema() {
7284
+ return this.config?.outputSchema ?? fallbackOutputSchema2;
7285
+ }
7286
+ _schemasDiscovering = false;
7287
+ async discoverSchemas(signal) {
7288
+ if (this.config.inputSchema && this.config.outputSchema)
7289
+ return;
7290
+ if (this._schemasDiscovering)
7291
+ return;
7292
+ if (!this.config.transport || !this.config.tool_name)
7293
+ return;
7294
+ this._schemasDiscovering = true;
7295
+ try {
7296
+ const result = await mcpList({
7297
+ transport: this.config.transport,
7298
+ server_url: this.config.server_url,
7299
+ command: this.config.command,
7300
+ args: this.config.args,
7301
+ env: this.config.env,
7302
+ list_type: "tools"
7303
+ });
7304
+ const tool = result.tools?.find((t) => t.name === this.config.tool_name);
7305
+ if (tool) {
7306
+ if (!this.config.inputSchema) {
7307
+ this.config.inputSchema = tool.inputSchema;
7308
+ }
7309
+ if (!this.config.outputSchema && tool.outputSchema) {
7310
+ this.config.outputSchema = tool.outputSchema;
7311
+ }
7312
+ this.emitSchemaChange();
7313
+ }
7314
+ } finally {
7315
+ this._schemasDiscovering = false;
7316
+ }
7134
7317
  }
7135
7318
  async execute(input2, context) {
7136
- const { client } = await mcpClientFactory4.create(input2, context.signal);
7319
+ await this.discoverSchemas(context.signal);
7320
+ const { client } = await mcpClientFactory4.create(this.config, context.signal);
7137
7321
  try {
7138
7322
  const result = await client.callTool({
7139
- name: input2.tool_name,
7140
- arguments: input2.tool_arguments
7323
+ name: this.config.tool_name,
7324
+ arguments: input2
7141
7325
  });
7142
7326
  if (!("content" in result) || !Array.isArray(result.content)) {
7143
7327
  throw new Error("Expected tool result with content array");
7144
7328
  }
7329
+ const content = result.content;
7330
+ const isError = result.isError === true;
7331
+ const structuredContent = "structuredContent" in result && result.structuredContent && typeof result.structuredContent === "object" && !Array.isArray(result.structuredContent) ? result.structuredContent : undefined;
7332
+ let parsedFromText;
7333
+ if (!structuredContent && content.length === 1) {
7334
+ const item = content[0];
7335
+ if (item && typeof item === "object" && "type" in item && item.type === "text" && "text" in item) {
7336
+ const text = String(item.text);
7337
+ const trimmed = text.trim();
7338
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
7339
+ try {
7340
+ const parsed = JSON.parse(text);
7341
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
7342
+ parsedFromText = parsed;
7343
+ }
7344
+ } catch {}
7345
+ }
7346
+ }
7347
+ }
7145
7348
  return {
7146
- content: result.content,
7147
- isError: result.isError === true
7349
+ content,
7350
+ isError,
7351
+ ...parsedFromText,
7352
+ ...structuredContent
7148
7353
  };
7149
7354
  } finally {
7150
7355
  await client.close();
7151
7356
  }
7152
7357
  }
7153
7358
  }
7154
- var mcpToolCall = async (input2, config = {}) => {
7359
+ var mcpToolCall = async (input2, config) => {
7155
7360
  return new McpToolCallTask({}, config).run(input2);
7156
7361
  };
7157
7362
  Workflow26.prototype.mcpToolCall = CreateWorkflow25(McpToolCallTask);
7158
7363
  // src/task/scalar/ScalarAbsTask.ts
7159
7364
  import { CreateWorkflow as CreateWorkflow26, Task as Task23, Workflow as Workflow27 } from "@workglow/task-graph";
7160
- var inputSchema23 = {
7365
+ var inputSchema21 = {
7161
7366
  type: "object",
7162
7367
  properties: {
7163
7368
  value: {
@@ -7169,7 +7374,7 @@ var inputSchema23 = {
7169
7374
  required: ["value"],
7170
7375
  additionalProperties: false
7171
7376
  };
7172
- var outputSchema22 = {
7377
+ var outputSchema20 = {
7173
7378
  type: "object",
7174
7379
  properties: {
7175
7380
  result: {
@@ -7188,10 +7393,10 @@ class ScalarAbsTask extends Task23 {
7188
7393
  static title = "Abs";
7189
7394
  static description = "Returns the absolute value of a number";
7190
7395
  static inputSchema() {
7191
- return inputSchema23;
7396
+ return inputSchema21;
7192
7397
  }
7193
7398
  static outputSchema() {
7194
- return outputSchema22;
7399
+ return outputSchema20;
7195
7400
  }
7196
7401
  async execute(input2, _context) {
7197
7402
  return { result: Math.abs(input2.value) };
@@ -7200,7 +7405,7 @@ class ScalarAbsTask extends Task23 {
7200
7405
  Workflow27.prototype.scalarAbs = CreateWorkflow26(ScalarAbsTask);
7201
7406
  // src/task/scalar/ScalarCeilTask.ts
7202
7407
  import { CreateWorkflow as CreateWorkflow27, Task as Task24, Workflow as Workflow28 } from "@workglow/task-graph";
7203
- var inputSchema24 = {
7408
+ var inputSchema22 = {
7204
7409
  type: "object",
7205
7410
  properties: {
7206
7411
  value: {
@@ -7212,7 +7417,7 @@ var inputSchema24 = {
7212
7417
  required: ["value"],
7213
7418
  additionalProperties: false
7214
7419
  };
7215
- var outputSchema23 = {
7420
+ var outputSchema21 = {
7216
7421
  type: "object",
7217
7422
  properties: {
7218
7423
  result: {
@@ -7231,10 +7436,10 @@ class ScalarCeilTask extends Task24 {
7231
7436
  static title = "Ceil";
7232
7437
  static description = "Returns the smallest integer greater than or equal to a number";
7233
7438
  static inputSchema() {
7234
- return inputSchema24;
7439
+ return inputSchema22;
7235
7440
  }
7236
7441
  static outputSchema() {
7237
- return outputSchema23;
7442
+ return outputSchema21;
7238
7443
  }
7239
7444
  async execute(input2, _context) {
7240
7445
  return { result: Math.ceil(input2.value) };
@@ -7243,7 +7448,7 @@ class ScalarCeilTask extends Task24 {
7243
7448
  Workflow28.prototype.scalarCeil = CreateWorkflow27(ScalarCeilTask);
7244
7449
  // src/task/scalar/ScalarFloorTask.ts
7245
7450
  import { CreateWorkflow as CreateWorkflow28, Task as Task25, Workflow as Workflow29 } from "@workglow/task-graph";
7246
- var inputSchema25 = {
7451
+ var inputSchema23 = {
7247
7452
  type: "object",
7248
7453
  properties: {
7249
7454
  value: {
@@ -7255,7 +7460,7 @@ var inputSchema25 = {
7255
7460
  required: ["value"],
7256
7461
  additionalProperties: false
7257
7462
  };
7258
- var outputSchema24 = {
7463
+ var outputSchema22 = {
7259
7464
  type: "object",
7260
7465
  properties: {
7261
7466
  result: {
@@ -7274,10 +7479,10 @@ class ScalarFloorTask extends Task25 {
7274
7479
  static title = "Floor";
7275
7480
  static description = "Returns the largest integer less than or equal to a number";
7276
7481
  static inputSchema() {
7277
- return inputSchema25;
7482
+ return inputSchema23;
7278
7483
  }
7279
7484
  static outputSchema() {
7280
- return outputSchema24;
7485
+ return outputSchema22;
7281
7486
  }
7282
7487
  async execute(input2, _context) {
7283
7488
  return { result: Math.floor(input2.value) };
@@ -7286,7 +7491,7 @@ class ScalarFloorTask extends Task25 {
7286
7491
  Workflow29.prototype.scalarFloor = CreateWorkflow28(ScalarFloorTask);
7287
7492
  // src/task/scalar/ScalarMaxTask.ts
7288
7493
  import { CreateWorkflow as CreateWorkflow29, Task as Task26, Workflow as Workflow30 } from "@workglow/task-graph";
7289
- var inputSchema26 = {
7494
+ var inputSchema24 = {
7290
7495
  type: "object",
7291
7496
  properties: {
7292
7497
  values: {
@@ -7299,7 +7504,7 @@ var inputSchema26 = {
7299
7504
  required: ["values"],
7300
7505
  additionalProperties: false
7301
7506
  };
7302
- var outputSchema25 = {
7507
+ var outputSchema23 = {
7303
7508
  type: "object",
7304
7509
  properties: {
7305
7510
  result: {
@@ -7318,10 +7523,10 @@ class ScalarMaxTask extends Task26 {
7318
7523
  static title = "Max";
7319
7524
  static description = "Returns the largest of the given numbers";
7320
7525
  static inputSchema() {
7321
- return inputSchema26;
7526
+ return inputSchema24;
7322
7527
  }
7323
7528
  static outputSchema() {
7324
- return outputSchema25;
7529
+ return outputSchema23;
7325
7530
  }
7326
7531
  async execute(input2, _context) {
7327
7532
  return { result: Math.max(...input2.values) };
@@ -7330,7 +7535,7 @@ class ScalarMaxTask extends Task26 {
7330
7535
  Workflow30.prototype.scalarMax = CreateWorkflow29(ScalarMaxTask);
7331
7536
  // src/task/scalar/ScalarMinTask.ts
7332
7537
  import { CreateWorkflow as CreateWorkflow30, Task as Task27, Workflow as Workflow31 } from "@workglow/task-graph";
7333
- var inputSchema27 = {
7538
+ var inputSchema25 = {
7334
7539
  type: "object",
7335
7540
  properties: {
7336
7541
  values: {
@@ -7343,7 +7548,7 @@ var inputSchema27 = {
7343
7548
  required: ["values"],
7344
7549
  additionalProperties: false
7345
7550
  };
7346
- var outputSchema26 = {
7551
+ var outputSchema24 = {
7347
7552
  type: "object",
7348
7553
  properties: {
7349
7554
  result: {
@@ -7362,10 +7567,10 @@ class ScalarMinTask extends Task27 {
7362
7567
  static title = "Min";
7363
7568
  static description = "Returns the smallest of the given numbers";
7364
7569
  static inputSchema() {
7365
- return inputSchema27;
7570
+ return inputSchema25;
7366
7571
  }
7367
7572
  static outputSchema() {
7368
- return outputSchema26;
7573
+ return outputSchema24;
7369
7574
  }
7370
7575
  async execute(input2, _context) {
7371
7576
  return { result: Math.min(...input2.values) };
@@ -7374,7 +7579,7 @@ class ScalarMinTask extends Task27 {
7374
7579
  Workflow31.prototype.scalarMin = CreateWorkflow30(ScalarMinTask);
7375
7580
  // src/task/scalar/ScalarRoundTask.ts
7376
7581
  import { CreateWorkflow as CreateWorkflow31, Task as Task28, Workflow as Workflow32 } from "@workglow/task-graph";
7377
- var inputSchema28 = {
7582
+ var inputSchema26 = {
7378
7583
  type: "object",
7379
7584
  properties: {
7380
7585
  value: {
@@ -7386,7 +7591,7 @@ var inputSchema28 = {
7386
7591
  required: ["value"],
7387
7592
  additionalProperties: false
7388
7593
  };
7389
- var outputSchema27 = {
7594
+ var outputSchema25 = {
7390
7595
  type: "object",
7391
7596
  properties: {
7392
7597
  result: {
@@ -7405,10 +7610,10 @@ class ScalarRoundTask extends Task28 {
7405
7610
  static title = "Round";
7406
7611
  static description = "Returns the value of a number rounded to the nearest integer";
7407
7612
  static inputSchema() {
7408
- return inputSchema28;
7613
+ return inputSchema26;
7409
7614
  }
7410
7615
  static outputSchema() {
7411
- return outputSchema27;
7616
+ return outputSchema25;
7412
7617
  }
7413
7618
  async execute(input2, _context) {
7414
7619
  return { result: Math.round(input2.value) };
@@ -7417,7 +7622,7 @@ class ScalarRoundTask extends Task28 {
7417
7622
  Workflow32.prototype.scalarRound = CreateWorkflow31(ScalarRoundTask);
7418
7623
  // src/task/scalar/ScalarTruncTask.ts
7419
7624
  import { CreateWorkflow as CreateWorkflow32, Task as Task29, Workflow as Workflow33 } from "@workglow/task-graph";
7420
- var inputSchema29 = {
7625
+ var inputSchema27 = {
7421
7626
  type: "object",
7422
7627
  properties: {
7423
7628
  value: {
@@ -7429,7 +7634,7 @@ var inputSchema29 = {
7429
7634
  required: ["value"],
7430
7635
  additionalProperties: false
7431
7636
  };
7432
- var outputSchema28 = {
7637
+ var outputSchema26 = {
7433
7638
  type: "object",
7434
7639
  properties: {
7435
7640
  result: {
@@ -7448,10 +7653,10 @@ class ScalarTruncTask extends Task29 {
7448
7653
  static title = "Truncate";
7449
7654
  static description = "Returns the integer part of a number by removing fractional digits";
7450
7655
  static inputSchema() {
7451
- return inputSchema29;
7656
+ return inputSchema27;
7452
7657
  }
7453
7658
  static outputSchema() {
7454
- return outputSchema28;
7659
+ return outputSchema26;
7455
7660
  }
7456
7661
  async execute(input2, _context) {
7457
7662
  return { result: Math.trunc(input2.value) };
@@ -7463,7 +7668,7 @@ import { CreateWorkflow as CreateWorkflow33, Task as Task30, Workflow as Workflo
7463
7668
  import {
7464
7669
  TypedArraySchema as TypedArraySchema5
7465
7670
  } from "@workglow/util";
7466
- var inputSchema30 = {
7671
+ var inputSchema28 = {
7467
7672
  type: "object",
7468
7673
  properties: {
7469
7674
  vectors: {
@@ -7479,7 +7684,7 @@ var inputSchema30 = {
7479
7684
  required: ["vectors"],
7480
7685
  additionalProperties: false
7481
7686
  };
7482
- var outputSchema29 = {
7687
+ var outputSchema27 = {
7483
7688
  type: "object",
7484
7689
  properties: {
7485
7690
  result: {
@@ -7498,10 +7703,10 @@ class VectorDistanceTask extends Task30 {
7498
7703
  static title = "Distance";
7499
7704
  static description = "Returns the Euclidean distance between the first two vectors";
7500
7705
  static inputSchema() {
7501
- return inputSchema30;
7706
+ return inputSchema28;
7502
7707
  }
7503
7708
  static outputSchema() {
7504
- return outputSchema29;
7709
+ return outputSchema27;
7505
7710
  }
7506
7711
  async execute(input2, _context) {
7507
7712
  const { vectors } = input2;
@@ -7525,7 +7730,7 @@ import { CreateWorkflow as CreateWorkflow34, Task as Task31, Workflow as Workflo
7525
7730
  import {
7526
7731
  TypedArraySchema as TypedArraySchema6
7527
7732
  } from "@workglow/util";
7528
- var inputSchema31 = {
7733
+ var inputSchema29 = {
7529
7734
  type: "object",
7530
7735
  properties: {
7531
7736
  vectors: {
@@ -7541,7 +7746,7 @@ var inputSchema31 = {
7541
7746
  required: ["vectors"],
7542
7747
  additionalProperties: false
7543
7748
  };
7544
- var outputSchema30 = {
7749
+ var outputSchema28 = {
7545
7750
  type: "object",
7546
7751
  properties: {
7547
7752
  result: {
@@ -7560,10 +7765,10 @@ class VectorDotProductTask extends Task31 {
7560
7765
  static title = "Dot Product";
7561
7766
  static description = "Returns the dot (inner) product of the first two vectors";
7562
7767
  static inputSchema() {
7563
- return inputSchema31;
7768
+ return inputSchema29;
7564
7769
  }
7565
7770
  static outputSchema() {
7566
- return outputSchema30;
7771
+ return outputSchema28;
7567
7772
  }
7568
7773
  async execute(input2, _context) {
7569
7774
  const { vectors } = input2;
@@ -7585,7 +7790,7 @@ import {
7585
7790
  TypedArraySchema as TypedArraySchema7,
7586
7791
  normalize
7587
7792
  } from "@workglow/util";
7588
- var inputSchema32 = {
7793
+ var inputSchema30 = {
7589
7794
  type: "object",
7590
7795
  properties: {
7591
7796
  vector: TypedArraySchema7({
@@ -7596,7 +7801,7 @@ var inputSchema32 = {
7596
7801
  required: ["vector"],
7597
7802
  additionalProperties: false
7598
7803
  };
7599
- var outputSchema31 = {
7804
+ var outputSchema29 = {
7600
7805
  type: "object",
7601
7806
  properties: {
7602
7807
  result: TypedArraySchema7({
@@ -7614,10 +7819,10 @@ class VectorNormalizeTask extends Task32 {
7614
7819
  static title = "Normalize";
7615
7820
  static description = "Returns the L2-normalized (unit length) vector";
7616
7821
  static inputSchema() {
7617
- return inputSchema32;
7822
+ return inputSchema30;
7618
7823
  }
7619
7824
  static outputSchema() {
7620
- return outputSchema31;
7825
+ return outputSchema29;
7621
7826
  }
7622
7827
  async execute(input2, _context) {
7623
7828
  return { result: normalize(input2.vector) };
@@ -7630,7 +7835,7 @@ import {
7630
7835
  createTypedArrayFrom as createTypedArrayFrom5,
7631
7836
  TypedArraySchema as TypedArraySchema8
7632
7837
  } from "@workglow/util";
7633
- var inputSchema33 = {
7838
+ var inputSchema31 = {
7634
7839
  type: "object",
7635
7840
  properties: {
7636
7841
  vector: TypedArraySchema8({
@@ -7646,7 +7851,7 @@ var inputSchema33 = {
7646
7851
  required: ["vector", "scalar"],
7647
7852
  additionalProperties: false
7648
7853
  };
7649
- var outputSchema32 = {
7854
+ var outputSchema30 = {
7650
7855
  type: "object",
7651
7856
  properties: {
7652
7857
  result: TypedArraySchema8({
@@ -7664,10 +7869,10 @@ class VectorScaleTask extends Task33 {
7664
7869
  static title = "Scale";
7665
7870
  static description = "Multiplies each element of a vector by a scalar";
7666
7871
  static inputSchema() {
7667
- return inputSchema33;
7872
+ return inputSchema31;
7668
7873
  }
7669
7874
  static outputSchema() {
7670
- return outputSchema32;
7875
+ return outputSchema30;
7671
7876
  }
7672
7877
  async execute(input2, _context) {
7673
7878
  const { vector, scalar } = input2;
@@ -7727,13 +7932,11 @@ export {
7727
7932
  registerCommonTasks,
7728
7933
  process,
7729
7934
  merge,
7730
- mcpTransportTypes,
7731
7935
  mcpToolCall,
7732
- mcpServerConfigSchema5 as mcpServerConfigSchema,
7733
7936
  mcpResourceRead,
7734
7937
  mcpPromptGet,
7735
7938
  mcpList,
7736
- mcpClientFactory5 as mcpClientFactory,
7939
+ lambdaTaskConfigSchema,
7737
7940
  lambda,
7738
7941
  json,
7739
7942
  javaScript,
@@ -7741,7 +7944,6 @@ export {
7741
7944
  fetchUrl,
7742
7945
  delay,
7743
7946
  debugLog,
7744
- createMcpClient,
7745
7947
  VectorSumTask,
7746
7948
  VectorSubtractTask,
7747
7949
  VectorScaleTask,
@@ -7782,4 +7984,4 @@ export {
7782
7984
  ArrayTask
7783
7985
  };
7784
7986
 
7785
- //# debugId=D4A2128BDA8D6B2F64756E2164756E21
7987
+ //# debugId=F7898CFF8161BF7464756E2164756E21