@valerypopoff/rivet2-core 2.1.3 → 2.1.4

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.
Files changed (77) hide show
  1. package/dist/cjs/bundle.cjs +2707 -1012
  2. package/dist/cjs/bundle.cjs.map +4 -4
  3. package/dist/cjs/webAppRuntime.cjs +625 -0
  4. package/dist/cjs/webAppRuntime.cjs.map +7 -0
  5. package/dist/esm/api/createProcessor.js +3 -0
  6. package/dist/esm/api/streaming.js +6 -0
  7. package/dist/esm/exports.js +5 -0
  8. package/dist/esm/integrations/mcp/MCPBase.js +92 -34
  9. package/dist/esm/model/GraphProcessor.js +11 -4
  10. package/dist/esm/model/GraphProgress.js +15 -0
  11. package/dist/esm/model/Nodes.js +3 -0
  12. package/dist/esm/model/ProcessContextBuilder.js +2 -1
  13. package/dist/esm/model/RecordingPlayer.js +10 -0
  14. package/dist/esm/model/SubprocessorBridge.js +1 -0
  15. package/dist/esm/model/UiGraph.js +127 -4
  16. package/dist/esm/model/UiGraphActionProtocol.js +122 -0
  17. package/dist/esm/model/UiGraphBindings.js +530 -0
  18. package/dist/esm/model/UiGraphBrowserRuntime.js +40 -0
  19. package/dist/esm/model/UiGraphNormalization.js +298 -0
  20. package/dist/esm/model/UiGraphRendererStyles.js +374 -6
  21. package/dist/esm/model/UiGraphRuntimeModel.js +300 -0
  22. package/dist/esm/model/UiGraphWebAppStatus.js +19 -0
  23. package/dist/esm/model/nodes/ArrayNode.js +2 -13
  24. package/dist/esm/model/nodes/AssembleMessageNode.js +2 -13
  25. package/dist/esm/model/nodes/AssemblePromptNode.js +2 -13
  26. package/dist/esm/model/nodes/CoalesceNode.js +2 -15
  27. package/dist/esm/model/nodes/DelayNode.js +3 -14
  28. package/dist/esm/model/nodes/DidRunNode.js +2 -13
  29. package/dist/esm/model/nodes/JoinNode.js +2 -13
  30. package/dist/esm/model/nodes/LoopControllerNode.js +3 -14
  31. package/dist/esm/model/nodes/MCPDiscoveryNode.js +19 -90
  32. package/dist/esm/model/nodes/MCPGetPromptNode.js +11 -97
  33. package/dist/esm/model/nodes/MCPToolCallNode.js +11 -97
  34. package/dist/esm/model/nodes/PassthroughNode.js +3 -14
  35. package/dist/esm/model/nodes/RaceInputsNode.js +2 -13
  36. package/dist/esm/model/nodes/ReportProgressNode.js +57 -0
  37. package/dist/esm/model/nodes/variadicPortIndex.js +32 -0
  38. package/dist/esm/plugins/anthropic/anthropic.js +1 -1
  39. package/dist/esm/recording/ExecutionRecorder.js +5 -0
  40. package/dist/esm/utils/fetchEventSource.js +16 -17
  41. package/dist/esm/utils/serialization/serialization.js +4 -0
  42. package/dist/esm/utils/serialization/serializationUtils.js +8 -27
  43. package/dist/esm/utils/serialization/serialization_v4.js +3 -3
  44. package/dist/esm/webAppRuntime.js +4 -2
  45. package/dist/types/api/streaming.d.ts +6 -0
  46. package/dist/types/exports.d.ts +5 -0
  47. package/dist/types/integrations/mcp/MCPBase.d.ts +26 -3
  48. package/dist/types/model/ExecutorProtocol.d.ts +7 -0
  49. package/dist/types/model/GraphProcessor.d.ts +7 -0
  50. package/dist/types/model/GraphProgress.d.ts +6 -0
  51. package/dist/types/model/Nodes.d.ts +3 -2
  52. package/dist/types/model/ProcessContext.d.ts +3 -0
  53. package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
  54. package/dist/types/model/UiGraph.d.ts +42 -9
  55. package/dist/types/model/UiGraphActionProtocol.d.ts +69 -0
  56. package/dist/types/model/UiGraphBindings.d.ts +45 -0
  57. package/dist/types/model/UiGraphBrowserRuntime.d.ts +4 -0
  58. package/dist/types/model/UiGraphNormalization.d.ts +24 -0
  59. package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
  60. package/dist/types/model/UiGraphRuntimeModel.d.ts +77 -5
  61. package/dist/types/model/UiGraphWebAppStatus.d.ts +5 -0
  62. package/dist/types/model/nodes/ArrayNode.d.ts +0 -1
  63. package/dist/types/model/nodes/AssembleMessageNode.d.ts +0 -1
  64. package/dist/types/model/nodes/AssemblePromptNode.d.ts +0 -1
  65. package/dist/types/model/nodes/DelayNode.d.ts +0 -1
  66. package/dist/types/model/nodes/DidRunNode.d.ts +0 -1
  67. package/dist/types/model/nodes/JoinNode.d.ts +0 -1
  68. package/dist/types/model/nodes/LoopControllerNode.d.ts +0 -1
  69. package/dist/types/model/nodes/PassthroughNode.d.ts +0 -1
  70. package/dist/types/model/nodes/RaceInputsNode.d.ts +0 -1
  71. package/dist/types/model/nodes/ReportProgressNode.d.ts +23 -0
  72. package/dist/types/model/nodes/variadicPortIndex.d.ts +4 -0
  73. package/dist/types/recording/RecordedEvents.d.ts +5 -0
  74. package/dist/types/webAppRuntime.d.ts +8 -3
  75. package/package.json +2 -2
  76. package/dist/esm/plugins/anthropic/fetchEventSource.js +0 -107
  77. package/dist/types/plugins/anthropic/fetchEventSource.d.ts +0 -11
@@ -1,11 +1,10 @@
1
1
  import { nanoid } from 'nanoid';
2
2
  import { NodeImpl } from '../NodeImpl.js';
3
3
  import {} from '../../index.js';
4
- import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
5
- import { dedent, getInputOrData } from '../../utils/index.js';
4
+ import {} from '../../integrations/mcp/MCPProvider.js';
5
+ import { dedent } from '../../utils/index.js';
6
6
  import { nodeDefinition } from '../NodeDefinition.js';
7
- import { getServerHelperMessage, getServerOptions, loadMCPConfiguration } from '../../integrations/mcp/MCPUtils.js';
8
- import { getMCPBaseInputs } from '../../integrations/mcp/MCPBase.js';
7
+ import { getMCPBaseBody, getMCPBaseInputs, getMCPClientEditors, getMCPServerEditors, requireMCPProvider, resolveMCPServer, } from '../../integrations/mcp/MCPBase.js';
9
8
  class MCPDiscoveryNodeImpl extends NodeImpl {
10
9
  static create() {
11
10
  const chartNode = {
@@ -32,8 +31,7 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
32
31
  return chartNode;
33
32
  }
34
33
  getInputDefinitions() {
35
- const inputs = getMCPBaseInputs(this.data);
36
- return inputs;
34
+ return getMCPBaseInputs(this.data);
37
35
  }
38
36
  getOutputDefinitions() {
39
37
  const outputDefinitions = [];
@@ -69,66 +67,15 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
69
67
  dataKey: 'usePromptsOutput',
70
68
  helperMessage: 'Toggle on if you want to get a Prompts output',
71
69
  },
72
- {
73
- type: 'string',
74
- label: 'Name',
75
- dataKey: 'name',
76
- useInputToggleDataKey: 'useNameInput',
77
- helperMessage: 'The name for the MCP Client',
78
- },
79
- {
80
- type: 'string',
81
- label: 'Version',
82
- dataKey: 'version',
83
- useInputToggleDataKey: 'useVersionInput',
84
- helperMessage: 'A version for the MCP Client',
85
- },
86
- {
87
- type: 'dropdown',
88
- label: 'Transport Type',
89
- dataKey: 'transportType',
90
- options: [
91
- { label: 'HTTP', value: 'http' },
92
- { label: 'STDIO', value: 'stdio' },
93
- ],
94
- },
70
+ ...getMCPClientEditors(),
95
71
  ];
96
- if (this.data.transportType === 'http') {
97
- editors.push({
98
- type: 'string',
99
- label: 'Server URL',
100
- dataKey: 'serverUrl',
101
- useInputToggleDataKey: 'useServerUrlInput',
102
- helperMessage: 'The base URL endpoint for the MCP server with `/mcp`',
103
- });
104
- }
105
- else if (this.data.transportType === 'stdio') {
106
- const serverOptions = await getServerOptions(context);
107
- editors.push({
108
- type: 'dropdown',
109
- label: 'Server ID',
110
- dataKey: 'serverId',
111
- helperMessage: getServerHelperMessage(context, serverOptions.length),
112
- options: serverOptions,
113
- });
114
- }
72
+ editors.push(...(await getMCPServerEditors(context, this.data, {
73
+ httpServerUrlHelperMessage: 'The base URL endpoint for the MCP server with `/mcp`',
74
+ })));
115
75
  return editors;
116
76
  }
117
77
  getBody(context) {
118
- let base;
119
- if (this.data.transportType === 'http') {
120
- base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
121
- }
122
- else {
123
- base = `Server ID: ${this.data.serverId || '(None)'}`;
124
- }
125
- const namePart = `Name: ${this.data.name}`;
126
- const versionPart = `Version: ${this.data.version}`;
127
- const parts = [namePart, versionPart, base];
128
- if (context.executor !== 'nodejs') {
129
- parts.push('(Requires Node Executor)');
130
- }
131
- return parts.join('\n');
78
+ return getMCPBaseBody(this.data, context);
132
79
  }
133
80
  static getUIData() {
134
81
  return {
@@ -141,41 +88,23 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
141
88
  };
142
89
  }
143
90
  async process(inputs, context) {
144
- const name = getInputOrData(this.data, inputs, 'name', 'string');
145
- const version = getInputOrData(this.data, inputs, 'version', 'string');
146
- const transportType = getInputOrData(this.data, inputs, 'transportType', 'string');
147
91
  let tools = [];
148
92
  let prompts = [];
149
93
  try {
150
- if (!context.mcpProvider) {
151
- throw new Error('MCP Provider not found');
152
- }
153
- if (transportType === 'http') {
154
- const serverUrl = getInputOrData(this.data, inputs, 'serverUrl', 'string');
155
- if (!serverUrl || serverUrl === '') {
156
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, 'No server URL was provided');
157
- }
158
- if (!serverUrl.includes('/mcp')) {
159
- throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
160
- }
161
- tools = this.data.useToolsOutput ? await context.mcpProvider.getHTTPTools({ name, version }, serverUrl) : [];
94
+ const mcpProvider = requireMCPProvider(context);
95
+ const server = await resolveMCPServer(this.data, inputs, context);
96
+ if (server?.transportType === 'http') {
97
+ tools = this.data.useToolsOutput ? await mcpProvider.getHTTPTools(server.clientConfig, server.serverUrl) : [];
162
98
  prompts = this.data.usePromptsOutput
163
- ? await context.mcpProvider.getHTTPPrompts({ name, version }, serverUrl)
99
+ ? await mcpProvider.getHTTPPrompts(server.clientConfig, server.serverUrl)
164
100
  : [];
165
101
  }
166
- else if (transportType === 'stdio') {
167
- const serverId = this.data.serverId ?? '';
168
- const mcpConfig = await loadMCPConfiguration(context);
169
- if (!mcpConfig.mcpServers[serverId]) {
170
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, `Server ${serverId} not found in MCP config`);
171
- }
172
- const serverConfig = {
173
- config: mcpConfig.mcpServers[serverId],
174
- serverId,
175
- };
176
- tools = this.data.useToolsOutput ? await context.mcpProvider.getStdioTools({ name, version }, serverConfig) : [];
102
+ else if (server?.transportType === 'stdio') {
103
+ tools = this.data.useToolsOutput
104
+ ? await mcpProvider.getStdioTools(server.clientConfig, server.serverConfig)
105
+ : [];
177
106
  prompts = this.data.usePromptsOutput
178
- ? await context.mcpProvider.getStdioPrompts({ name, version }, serverConfig)
107
+ ? await mcpProvider.getStdioPrompts(server.clientConfig, server.serverConfig)
179
108
  : [];
180
109
  }
181
110
  const output = {};
@@ -5,13 +5,9 @@ import { nodeDefinition } from '../NodeDefinition.js';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import {} from '../../index.js';
7
7
  import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
8
- import { coerceTypeOptional } from '../../utils/coerceType.js';
9
8
  import { dedent, getInputOrData } from '../../utils/index.js';
10
9
  import { getError } from '../../utils/errors.js';
11
- import { getMCPBaseInputs } from '../../integrations/mcp/MCPBase.js';
12
- import { getServerHelperMessage, getServerOptions, loadMCPConfiguration } from '../../integrations/mcp/MCPUtils.js';
13
- import { keys } from '../../utils/typeSafety.js';
14
- import { interpolate } from '../../utils/interpolation.js';
10
+ import { getMCPBaseBody, getMCPBaseInputs, getMCPClientEditors, getMCPServerEditors, interpolateMCPArgumentTemplate, requireMCPProvider, resolveMCPServer, } from '../../integrations/mcp/MCPBase.js';
15
11
  export class MCPGetPromptNodeImpl extends NodeImpl {
16
12
  static create() {
17
13
  const chartNode = {
@@ -72,29 +68,7 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
72
68
  }
73
69
  async getEditors(context) {
74
70
  const editors = [
75
- {
76
- type: 'string',
77
- label: 'Name',
78
- dataKey: 'name',
79
- useInputToggleDataKey: 'useNameInput',
80
- helperMessage: 'The name for the MCP Client',
81
- },
82
- {
83
- type: 'string',
84
- label: 'Version',
85
- dataKey: 'version',
86
- useInputToggleDataKey: 'useVersionInput',
87
- helperMessage: 'A version for the MCP Client',
88
- },
89
- {
90
- type: 'dropdown',
91
- label: 'Transport Type',
92
- dataKey: 'transportType',
93
- options: [
94
- { label: 'HTTP', value: 'http' },
95
- { label: 'STDIO', value: 'stdio' },
96
- ],
97
- },
71
+ ...getMCPClientEditors(),
98
72
  {
99
73
  type: 'string',
100
74
  label: 'Prompt Name',
@@ -112,42 +86,11 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
112
86
  enableFolding: true,
113
87
  },
114
88
  ];
115
- if (this.data.transportType === 'http') {
116
- editors.push({
117
- type: 'string',
118
- label: 'Server URL',
119
- dataKey: 'serverUrl',
120
- useInputToggleDataKey: 'useServerUrlInput',
121
- helperMessage: 'The endpoint URL for the MCP server to connect',
122
- });
123
- }
124
- else if (this.data.transportType === 'stdio') {
125
- const serverOptions = await getServerOptions(context);
126
- editors.push({
127
- type: 'dropdown',
128
- label: 'Server ID',
129
- dataKey: 'serverId',
130
- helperMessage: getServerHelperMessage(context, serverOptions.length),
131
- options: serverOptions,
132
- });
133
- }
89
+ editors.push(...(await getMCPServerEditors(context, this.data)));
134
90
  return editors;
135
91
  }
136
92
  getBody(context) {
137
- let base;
138
- if (this.data.transportType === 'http') {
139
- base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
140
- }
141
- else {
142
- base = `Server ID: ${this.data.serverId || '(None)'}`;
143
- }
144
- const namePart = `Name: ${this.data.name}`;
145
- const versionPart = `Version: ${this.data.version}`;
146
- const parts = [namePart, versionPart, base];
147
- if (context.executor !== 'nodejs') {
148
- parts.push('(Requires Node Executor)');
149
- }
150
- return parts.join('\n');
93
+ return getMCPBaseBody(this.data, context);
151
94
  }
152
95
  static getUIData() {
153
96
  return {
@@ -160,8 +103,6 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
160
103
  };
161
104
  }
162
105
  async process(inputs, context) {
163
- const name = getInputOrData(this.data, inputs, 'name', 'string');
164
- const version = getInputOrData(this.data, inputs, 'version', 'string');
165
106
  const promptName = getInputOrData(this.data, inputs, 'promptName', 'string');
166
107
  let promptArguments;
167
108
  if (this.data.usePromptArgumentsInput) {
@@ -171,48 +112,21 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
171
112
  }
172
113
  }
173
114
  else {
174
- const inputMap = keys(inputs)
175
- .filter((key) => key.startsWith('input'))
176
- .reduce((acc, key) => {
177
- const stringValue = coerceTypeOptional(inputs[key], 'string') ?? '';
178
- const interpolationKey = key.slice('input-'.length);
179
- acc[interpolationKey] = stringValue;
180
- return acc;
181
- }, {});
182
- const interpolated = interpolate(this.data.promptArguments ?? '', inputMap);
183
- promptArguments = JSON.parse(interpolated);
115
+ promptArguments = JSON.parse(interpolateMCPArgumentTemplate(this.data.promptArguments ?? '', inputs));
184
116
  }
185
117
  const getPromptRequest = {
186
118
  name: promptName,
187
119
  arguments: promptArguments,
188
120
  };
189
- const transportType = getInputOrData(this.data, inputs, 'transportType', 'string');
190
121
  let getPromptResponse = undefined;
191
122
  try {
192
- if (!context.mcpProvider) {
193
- throw new Error('MCP Provider not found');
194
- }
195
- if (transportType === 'http') {
196
- const serverUrl = getInputOrData(this.data, inputs, 'serverUrl', 'string');
197
- if (!serverUrl || serverUrl === '') {
198
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, 'No server URL was provided');
199
- }
200
- if (!serverUrl.includes('/mcp')) {
201
- throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
202
- }
203
- getPromptResponse = await context.mcpProvider.getHTTPrompt({ name, version }, serverUrl, getPromptRequest);
123
+ const mcpProvider = requireMCPProvider(context);
124
+ const server = await resolveMCPServer(this.data, inputs, context);
125
+ if (server?.transportType === 'http') {
126
+ getPromptResponse = await mcpProvider.getHTTPrompt(server.clientConfig, server.serverUrl, getPromptRequest);
204
127
  }
205
- else if (transportType === 'stdio') {
206
- const serverId = this.data.serverId ?? '';
207
- const mcpConfig = await loadMCPConfiguration(context);
208
- if (!mcpConfig.mcpServers[serverId]) {
209
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, `Server ${serverId} not found in MCP config`);
210
- }
211
- const serverConfig = {
212
- config: mcpConfig.mcpServers[serverId],
213
- serverId,
214
- };
215
- getPromptResponse = await context.mcpProvider.getStdioPrompt({ name, version }, serverConfig, getPromptRequest);
128
+ else if (server?.transportType === 'stdio') {
129
+ getPromptResponse = await mcpProvider.getStdioPrompt(server.clientConfig, server.serverConfig, getPromptRequest);
216
130
  }
217
131
  const output = {};
218
132
  output['prompt'] = {
@@ -5,15 +5,11 @@ import { nodeDefinition } from '../NodeDefinition.js';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import {} from '../../index.js';
7
7
  import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
8
- import { coerceTypeOptional } from '../../utils/coerceType.js';
9
8
  import { getInputOrData } from '../../utils/index.js';
10
9
  import { getError } from '../../utils/errors.js';
11
- import { getMCPBaseInputs } from '../../integrations/mcp/MCPBase.js';
12
- import { getServerHelperMessage, getServerOptions, loadMCPConfiguration } from '../../integrations/mcp/MCPUtils.js';
10
+ import { getMCPBaseBody, getMCPBaseInputs, getMCPClientEditors, getMCPServerEditors, interpolateMCPArgumentTemplate, requireMCPProvider, resolveMCPServer, } from '../../integrations/mcp/MCPBase.js';
13
11
  import { dedent } from 'ts-dedent';
14
12
  import {} from '../EditorDefinition.js';
15
- import { interpolate } from '../../utils/interpolation.js';
16
- import { keys } from '../../utils/typeSafety.js';
17
13
  export class MCPToolCallNodeImpl extends NodeImpl {
18
14
  static create() {
19
15
  const chartNode = {
@@ -89,29 +85,7 @@ export class MCPToolCallNodeImpl extends NodeImpl {
89
85
  }
90
86
  async getEditors(context) {
91
87
  const editors = [
92
- {
93
- type: 'string',
94
- label: 'Name',
95
- dataKey: 'name',
96
- useInputToggleDataKey: 'useNameInput',
97
- helperMessage: 'The name for the MCP Client',
98
- },
99
- {
100
- type: 'string',
101
- label: 'Version',
102
- dataKey: 'version',
103
- useInputToggleDataKey: 'useVersionInput',
104
- helperMessage: 'A version for the MCP Client',
105
- },
106
- {
107
- type: 'dropdown',
108
- label: 'Transport Type',
109
- dataKey: 'transportType',
110
- options: [
111
- { label: 'HTTP', value: 'http' },
112
- { label: 'STDIO', value: 'stdio' },
113
- ],
114
- },
88
+ ...getMCPClientEditors(),
115
89
  {
116
90
  type: 'string',
117
91
  label: 'Tool Name',
@@ -135,42 +109,11 @@ export class MCPToolCallNodeImpl extends NodeImpl {
135
109
  helperMessage: 'The name for the MCP Tool Call',
136
110
  },
137
111
  ];
138
- if (this.data.transportType === 'http') {
139
- editors.push({
140
- type: 'string',
141
- label: 'Server URL',
142
- dataKey: 'serverUrl',
143
- useInputToggleDataKey: 'useServerUrlInput',
144
- helperMessage: 'The endpoint URL for the MCP server to connect',
145
- });
146
- }
147
- else if (this.data.transportType === 'stdio') {
148
- const serverOptions = await getServerOptions(context);
149
- editors.push({
150
- type: 'dropdown',
151
- label: 'Server ID',
152
- dataKey: 'serverId',
153
- helperMessage: getServerHelperMessage(context, serverOptions.length),
154
- options: serverOptions,
155
- });
156
- }
112
+ editors.push(...(await getMCPServerEditors(context, this.data)));
157
113
  return editors;
158
114
  }
159
115
  getBody(context) {
160
- let base;
161
- if (this.data.transportType === 'http') {
162
- base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
163
- }
164
- else {
165
- base = `Server ID: ${this.data.serverId || '(None)'}`;
166
- }
167
- const namePart = `Name: ${this.data.name}`;
168
- const versionPart = `Version: ${this.data.version}`;
169
- const parts = [namePart, versionPart, base];
170
- if (context.executor !== 'nodejs') {
171
- parts.push('(Requires Node Executor)');
172
- }
173
- return parts.join('\n');
116
+ return getMCPBaseBody(this.data, context);
174
117
  }
175
118
  static getUIData() {
176
119
  return {
@@ -183,8 +126,6 @@ export class MCPToolCallNodeImpl extends NodeImpl {
183
126
  };
184
127
  }
185
128
  async process(inputs, context) {
186
- const name = getInputOrData(this.data, inputs, 'name', 'string');
187
- const version = getInputOrData(this.data, inputs, 'version', 'string');
188
129
  const toolName = getInputOrData(this.data, inputs, 'toolName', 'string');
189
130
  const toolCallId = getInputOrData(this.data, inputs, 'toolCallId', 'string');
190
131
  let toolArguments;
@@ -195,48 +136,21 @@ export class MCPToolCallNodeImpl extends NodeImpl {
195
136
  }
196
137
  }
197
138
  else {
198
- const inputMap = keys(inputs)
199
- .filter((key) => key.startsWith('input'))
200
- .reduce((acc, key) => {
201
- const stringValue = coerceTypeOptional(inputs[key], 'string') ?? '';
202
- const interpolationKey = key.slice('input-'.length);
203
- acc[interpolationKey] = stringValue;
204
- return acc;
205
- }, {});
206
- const interpolated = interpolate(this.data.toolArguments ?? '', inputMap);
207
- toolArguments = JSON.parse(interpolated);
139
+ toolArguments = JSON.parse(interpolateMCPArgumentTemplate(this.data.toolArguments ?? '', inputs));
208
140
  }
209
141
  const toolCall = {
210
142
  name: toolName,
211
143
  arguments: toolArguments,
212
144
  };
213
- const transportType = getInputOrData(this.data, inputs, 'transportType', 'string');
214
145
  let toolResponse = undefined;
215
146
  try {
216
- if (!context.mcpProvider) {
217
- throw new Error('MCP Provider not found');
218
- }
219
- if (transportType === 'http') {
220
- const serverUrl = getInputOrData(this.data, inputs, 'serverUrl', 'string');
221
- if (!serverUrl || serverUrl === '') {
222
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, 'No server URL was provided');
223
- }
224
- if (!serverUrl.includes('/mcp')) {
225
- throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
226
- }
227
- toolResponse = await context.mcpProvider.httpToolCall({ name, version }, serverUrl, toolCall);
147
+ const mcpProvider = requireMCPProvider(context);
148
+ const server = await resolveMCPServer(this.data, inputs, context);
149
+ if (server?.transportType === 'http') {
150
+ toolResponse = await mcpProvider.httpToolCall(server.clientConfig, server.serverUrl, toolCall);
228
151
  }
229
- else if (transportType === 'stdio') {
230
- const serverId = this.data.serverId ?? '';
231
- const mcpConfig = await loadMCPConfiguration(context);
232
- if (!mcpConfig.mcpServers[serverId]) {
233
- throw new MCPError(MCPErrorType.SERVER_NOT_FOUND, `Server ${serverId} not found in MCP config`);
234
- }
235
- const serverConfig = {
236
- config: mcpConfig.mcpServers[serverId],
237
- serverId,
238
- };
239
- toolResponse = await context.mcpProvider.stdioToolCall({ name, version }, serverConfig, toolCall);
152
+ else if (server?.transportType === 'stdio') {
153
+ toolResponse = await mcpProvider.stdioToolCall(server.clientConfig, server.serverConfig, toolCall);
240
154
  }
241
155
  const output = {};
242
156
  output['response'] = {
@@ -4,6 +4,7 @@ import {} from '../NodeBase.js';
4
4
  import { nanoid } from 'nanoid/non-secure';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import { dedent } from 'ts-dedent';
7
+ import { getNextVariadicPortIndex } from './variadicPortIndex.js';
7
8
  export class PassthroughNodeImpl extends NodeImpl {
8
9
  static create = () => {
9
10
  const chartNode = {
@@ -21,7 +22,7 @@ export class PassthroughNodeImpl extends NodeImpl {
21
22
  };
22
23
  getInputDefinitions(connections) {
23
24
  const inputs = [];
24
- const inputCount = this.#getInputPortCount(connections);
25
+ const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
25
26
  for (let i = 1; i <= inputCount; i++) {
26
27
  inputs.push({
27
28
  dataType: 'any',
@@ -33,7 +34,7 @@ export class PassthroughNodeImpl extends NodeImpl {
33
34
  }
34
35
  getOutputDefinitions(connections) {
35
36
  const outputs = [];
36
- const inputCount = this.#getInputPortCount(connections);
37
+ const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
37
38
  for (let i = 1; i <= inputCount - 1; i++) {
38
39
  outputs.push({
39
40
  dataType: 'any',
@@ -53,18 +54,6 @@ export class PassthroughNodeImpl extends NodeImpl {
53
54
  group: ['Logic'],
54
55
  };
55
56
  }
56
- #getInputPortCount(connections) {
57
- const inputNodeId = this.chartNode.id;
58
- const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
59
- let maxInputNumber = 0;
60
- for (const connection of inputConnections) {
61
- const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
62
- if (messageNumber > maxInputNumber) {
63
- maxInputNumber = messageNumber;
64
- }
65
- }
66
- return maxInputNumber + 1;
67
- }
68
57
  async process(inputData) {
69
58
  const inputCount = Object.keys(inputData).filter((key) => key.startsWith('input')).length;
70
59
  const outputs = {};
@@ -5,6 +5,7 @@ import { nodeDefinition } from '../NodeDefinition.js';
5
5
  import {} from '../GraphProcessor.js';
6
6
  import { dedent } from 'ts-dedent';
7
7
  import {} from '../../index.js';
8
+ import { getNextVariadicPortIndex } from './variadicPortIndex.js';
8
9
  export class RaceInputsNodeImpl extends NodeImpl {
9
10
  static create() {
10
11
  const chartNode = {
@@ -20,21 +21,9 @@ export class RaceInputsNodeImpl extends NodeImpl {
20
21
  };
21
22
  return chartNode;
22
23
  }
23
- #getInputPortCount(connections) {
24
- const inputNodeId = this.chartNode.id;
25
- const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
26
- let maxInputNumber = 0;
27
- for (const connection of inputConnections) {
28
- const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
29
- if (messageNumber > maxInputNumber) {
30
- maxInputNumber = messageNumber;
31
- }
32
- }
33
- return maxInputNumber + 1;
34
- }
35
24
  getInputDefinitions(connections) {
36
25
  const inputs = [];
37
- const inputCount = this.#getInputPortCount(connections);
26
+ const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
38
27
  for (let i = 1; i <= inputCount; i++) {
39
28
  inputs.push({
40
29
  dataType: 'any',
@@ -0,0 +1,57 @@
1
+ import { nanoid } from 'nanoid/non-secure';
2
+ import { coerceTypeOptional } from '../../utils/coerceType.js';
3
+ import { nodeDefinition } from '../NodeDefinition.js';
4
+ import { NodeImpl } from '../NodeImpl.js';
5
+ export class ReportProgressNodeImpl extends NodeImpl {
6
+ static create() {
7
+ return {
8
+ id: nanoid(),
9
+ type: 'reportProgress',
10
+ title: 'Report Progress',
11
+ visualData: { x: 0, y: 0, width: 200 },
12
+ data: { message: '', useMessageInput: true, usePercentInput: true },
13
+ };
14
+ }
15
+ getInputDefinitions() {
16
+ return [
17
+ { dataType: 'any', id: 'value', required: true, title: 'Value' },
18
+ ...(this.data.useMessageInput
19
+ ? [{ dataType: 'string', id: 'message', title: 'Message' }]
20
+ : []),
21
+ ...(this.data.usePercentInput
22
+ ? [{ dataType: 'number', id: 'percent', title: 'Percent' }]
23
+ : []),
24
+ ];
25
+ }
26
+ getOutputDefinitions() {
27
+ return [{ dataType: 'any', id: 'value', title: 'Value' }];
28
+ }
29
+ getEditors() {
30
+ return [
31
+ { type: 'string', label: 'Message', dataKey: 'message', useInputToggleDataKey: 'useMessageInput' },
32
+ { type: 'number', label: 'Percent', dataKey: 'percent', useInputToggleDataKey: 'usePercentInput' },
33
+ ];
34
+ }
35
+ getBody() {
36
+ return this.data.message || 'Reports progress to the host';
37
+ }
38
+ static getUIData() {
39
+ return {
40
+ contextMenuTitle: 'Report Progress',
41
+ group: ['Advanced'],
42
+ infoBoxTitle: 'Report Progress',
43
+ infoBoxBody: 'Reports a public status message and/or percentage to progress-aware hosts such as Rivet web apps.',
44
+ };
45
+ }
46
+ async process(inputs, context) {
47
+ const message = this.data.useMessageInput
48
+ ? coerceTypeOptional(inputs['message'], 'string')
49
+ : this.data.message;
50
+ const percent = this.data.usePercentInput
51
+ ? coerceTypeOptional(inputs['percent'], 'number')
52
+ : this.data.percent;
53
+ context.reportProgress({ message, percent });
54
+ return { value: inputs['value'] };
55
+ }
56
+ }
57
+ export const reportProgressNode = nodeDefinition(ReportProgressNodeImpl, 'Report Progress');
@@ -0,0 +1,32 @@
1
+ export function getHighestVariadicPortIndex(connections, inputNodeId, prefix, policy) {
2
+ let highestIndex = 0;
3
+ for (const connection of connections) {
4
+ if (connection.inputNodeId !== inputNodeId || !connection.inputId.startsWith(prefix)) {
5
+ continue;
6
+ }
7
+ const index = parseVariadicPortIndex(connection.inputId, prefix, policy);
8
+ if (index != null && index > highestIndex) {
9
+ highestIndex = index;
10
+ }
11
+ }
12
+ return highestIndex;
13
+ }
14
+ export function getNextVariadicPortIndex(connections, inputNodeId, prefix, policy) {
15
+ return getHighestVariadicPortIndex(connections, inputNodeId, prefix, policy) + 1;
16
+ }
17
+ function parseVariadicPortIndex(portId, prefix, policy) {
18
+ if (policy === 'legacy') {
19
+ const index = parseInt(portId.replace(prefix, ''));
20
+ return Number.isNaN(index) ? undefined : index;
21
+ }
22
+ if (policy === 'decimal') {
23
+ const index = parseInt(portId.replace(prefix, ''), 10);
24
+ return Number.isNaN(index) ? undefined : index;
25
+ }
26
+ const indexText = portId.slice(prefix.length);
27
+ if (!/^\d+$/.test(indexText)) {
28
+ return undefined;
29
+ }
30
+ const index = Number(indexText);
31
+ return Number.isSafeInteger(index) && index > 0 ? index : undefined;
32
+ }
@@ -1,4 +1,4 @@
1
- import fetchEventSource from './fetchEventSource.js';
1
+ import fetchEventSource from '../../utils/fetchEventSource.js';
2
2
  import { parseProviderJsonChunk } from '../../utils/providerStreamParsing.js';
3
3
  export const anthropicModels = {
4
4
  'claude-instant-1': {
@@ -65,6 +65,11 @@ const toRecordedEventMap = {
65
65
  index,
66
66
  processId,
67
67
  }, execution),
68
+ progress: ({ node, processId, progress, execution }) => withExecution({
69
+ nodeId: node.id,
70
+ processId,
71
+ progress,
72
+ }, execution),
68
73
  nodeOutputsCleared: ({ node, processId, execution }) => withExecution({
69
74
  nodeId: node.id,
70
75
  processId,