@valerypopoff/rivet2-core 2.1.3 → 2.1.5
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/cjs/bundle.cjs +10138 -5679
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +1214 -0
- package/dist/cjs/webAppRuntime.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +8 -1
- package/dist/esm/api/streaming.js +6 -0
- package/dist/esm/exports.js +8 -0
- package/dist/esm/integrations/mcp/MCPBase.js +92 -34
- package/dist/esm/model/GraphBoundaryEffects.js +13 -0
- package/dist/esm/model/GraphProcessor.js +1138 -86
- package/dist/esm/model/GraphProgress.js +15 -0
- package/dist/esm/model/ManagedAsyncBranches.js +28 -0
- package/dist/esm/model/Nodes.js +12 -0
- package/dist/esm/model/ProcessContextBuilder.js +3 -1
- package/dist/esm/model/RecordingPlayer.js +19 -0
- package/dist/esm/model/StoredValueStore.js +226 -0
- package/dist/esm/model/SubprocessorBridge.js +50 -18
- package/dist/esm/model/ToolCallContinuation.js +1 -0
- package/dist/esm/model/UiGraph.js +177 -4
- package/dist/esm/model/UiGraphActionProtocol.js +131 -0
- package/dist/esm/model/UiGraphBindings.js +530 -0
- package/dist/esm/model/UiGraphBrowserRuntime.js +373 -0
- package/dist/esm/model/UiGraphNormalization.js +148 -0
- package/dist/esm/model/UiGraphRendererStyles.js +1108 -42
- package/dist/esm/model/UiGraphRuntimeModel.js +518 -2
- package/dist/esm/model/UiGraphSchema.js +91 -0
- package/dist/esm/model/UiGraphWebAppStatus.js +19 -0
- package/dist/esm/model/UiGraphWebAppStorage.js +1 -0
- package/dist/esm/model/chat/chatMessages.js +5 -9
- package/dist/esm/model/chat-v2/chatV2Errors.js +36 -3
- package/dist/esm/model/chat-v2/index.js +1 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +6 -8
- package/dist/esm/model/chat-v2/toolContinuationConnection.js +68 -0
- package/dist/esm/model/nodes/ArrayNode.js +2 -13
- package/dist/esm/model/nodes/AssembleMessageNode.js +2 -13
- package/dist/esm/model/nodes/AssemblePromptNode.js +2 -13
- package/dist/esm/model/nodes/CoalesceNode.js +2 -15
- package/dist/esm/model/nodes/DelayNode.js +3 -14
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +12 -40
- package/dist/esm/model/nodes/DidRunNode.js +2 -13
- package/dist/esm/model/nodes/GetStoredValueNode.js +109 -0
- package/dist/esm/model/nodes/JoinNode.js +2 -13
- package/dist/esm/model/nodes/LLMChatV2Node.js +17 -1
- package/dist/esm/model/nodes/LoopControllerNode.js +3 -14
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +19 -90
- package/dist/esm/model/nodes/MCPGetPromptNode.js +11 -97
- package/dist/esm/model/nodes/MCPToolCallNode.js +11 -97
- package/dist/esm/model/nodes/MatchNode.js +7 -7
- package/dist/esm/model/nodes/PassthroughNode.js +3 -14
- package/dist/esm/model/nodes/RaceInputsNode.js +2 -13
- package/dist/esm/model/nodes/ReportProgressNode.js +57 -0
- package/dist/esm/model/nodes/SetStoredValueNode.js +84 -0
- package/dist/esm/model/nodes/StartBackgroundBranchNode.js +59 -0
- package/dist/esm/model/nodes/StoredValueNodeUtils.js +47 -0
- package/dist/esm/model/nodes/toolCallDelegation.js +44 -1
- package/dist/esm/model/nodes/variadicPortIndex.js +32 -0
- package/dist/esm/plugins/anthropic/anthropic.js +1 -1
- package/dist/esm/recording/ExecutionRecorder.js +6 -0
- package/dist/esm/utils/coerceType.js +3 -0
- package/dist/esm/utils/fetchEventSource.js +16 -17
- package/dist/esm/utils/serialization/serialization.js +4 -0
- package/dist/esm/utils/serialization/serializationUtils.js +8 -27
- package/dist/esm/utils/serialization/serialization_v4.js +3 -3
- package/dist/esm/webAppRuntime.js +4 -2
- package/dist/types/api/createProcessor.d.ts +4 -0
- package/dist/types/api/streaming.d.ts +6 -0
- package/dist/types/exports.d.ts +8 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +26 -3
- package/dist/types/model/EditorDefinition.d.ts +2 -1
- package/dist/types/model/ExecutorProtocol.d.ts +19 -0
- package/dist/types/model/GraphBoundaryEffects.d.ts +9 -1
- package/dist/types/model/GraphProcessor.d.ts +26 -2
- package/dist/types/model/GraphProgress.d.ts +6 -0
- package/dist/types/model/ManagedAsyncBranches.d.ts +6 -0
- package/dist/types/model/Nodes.d.ts +6 -2
- package/dist/types/model/ProcessContext.d.ts +18 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
- package/dist/types/model/StoredValueStore.d.ts +55 -0
- package/dist/types/model/SubprocessorBridge.d.ts +4 -2
- package/dist/types/model/ToolCallContinuation.d.ts +13 -0
- package/dist/types/model/UiGraph.d.ts +63 -9
- package/dist/types/model/UiGraphActionProtocol.d.ts +71 -0
- package/dist/types/model/UiGraphBindings.d.ts +45 -0
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +55 -0
- package/dist/types/model/UiGraphNormalization.d.ts +24 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +2 -2
- package/dist/types/model/UiGraphRuntimeModel.d.ts +97 -6
- package/dist/types/model/UiGraphSchema.d.ts +113 -0
- package/dist/types/model/UiGraphWebAppStatus.d.ts +5 -0
- package/dist/types/model/UiGraphWebAppStorage.d.ts +3 -0
- package/dist/types/model/chat-v2/index.d.ts +1 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +1 -0
- package/dist/types/model/chat-v2/toolContinuationConnection.d.ts +28 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +0 -1
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +0 -1
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +0 -1
- package/dist/types/model/nodes/DelayNode.d.ts +0 -1
- package/dist/types/model/nodes/DidRunNode.d.ts +0 -1
- package/dist/types/model/nodes/GetStoredValueNode.d.ts +25 -0
- package/dist/types/model/nodes/JoinNode.d.ts +0 -1
- package/dist/types/model/nodes/LoopControllerNode.d.ts +0 -1
- package/dist/types/model/nodes/PassthroughNode.d.ts +0 -1
- package/dist/types/model/nodes/RaceInputsNode.d.ts +0 -1
- package/dist/types/model/nodes/ReportProgressNode.d.ts +23 -0
- package/dist/types/model/nodes/SetStoredValueNode.d.ts +23 -0
- package/dist/types/model/nodes/StartBackgroundBranchNode.d.ts +14 -0
- package/dist/types/model/nodes/StoredValueNodeUtils.d.ts +5 -0
- package/dist/types/model/nodes/toolCallDelegation.d.ts +4 -0
- package/dist/types/model/nodes/variadicPortIndex.d.ts +4 -0
- package/dist/types/recording/RecordedEvents.d.ts +10 -0
- package/dist/types/webAppRuntime.d.ts +8 -3
- package/package.json +2 -2
- package/dist/esm/plugins/anthropic/fetchEventSource.js +0 -107
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +0 -11
|
@@ -8,6 +8,7 @@ import {} from '../GraphProcessor.js';
|
|
|
8
8
|
import { dedent } from 'ts-dedent';
|
|
9
9
|
import {} from '../EditorDefinition.js';
|
|
10
10
|
import { handleEscapeCharacters } from '../../utils/index.js';
|
|
11
|
+
import { getNextVariadicPortIndex } from './variadicPortIndex.js';
|
|
11
12
|
export class JoinNodeImpl extends NodeImpl {
|
|
12
13
|
static create = () => {
|
|
13
14
|
const chartNode = {
|
|
@@ -28,7 +29,7 @@ export class JoinNodeImpl extends NodeImpl {
|
|
|
28
29
|
};
|
|
29
30
|
getInputDefinitions(connections) {
|
|
30
31
|
const inputs = [];
|
|
31
|
-
const inputCount =
|
|
32
|
+
const inputCount = getNextVariadicPortIndex(connections, this.chartNode.id, 'input', 'decimal');
|
|
32
33
|
if (this.data.useJoinStringInput) {
|
|
33
34
|
inputs.push({
|
|
34
35
|
dataType: 'string',
|
|
@@ -54,18 +55,6 @@ export class JoinNodeImpl extends NodeImpl {
|
|
|
54
55
|
},
|
|
55
56
|
];
|
|
56
57
|
}
|
|
57
|
-
#getInputPortCount(connections) {
|
|
58
|
-
const inputNodeId = this.chartNode.id;
|
|
59
|
-
const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
60
|
-
let maxInputNumber = 0;
|
|
61
|
-
for (const connection of inputConnections) {
|
|
62
|
-
const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
|
|
63
|
-
if (messageNumber > maxInputNumber) {
|
|
64
|
-
maxInputNumber = messageNumber;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return maxInputNumber + 1;
|
|
68
|
-
}
|
|
69
58
|
getEditors() {
|
|
70
59
|
return [
|
|
71
60
|
{
|
|
@@ -255,7 +255,9 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
255
255
|
getOptionalNumberBodyLine('Frequency penalty', this.data.frequencyPenalty, this.data.useFrequencyPenaltyInput),
|
|
256
256
|
getStopSequencesBodyLine(this.data),
|
|
257
257
|
getOptionalNumberBodyLine('Seed', this.data.seed, this.data.useSeedInput),
|
|
258
|
-
]
|
|
258
|
+
]
|
|
259
|
+
.filter((line) => line !== undefined)
|
|
260
|
+
.join('\n'),
|
|
259
261
|
};
|
|
260
262
|
}
|
|
261
263
|
async process(inputs, context) {
|
|
@@ -265,6 +267,7 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
265
267
|
inputs,
|
|
266
268
|
context,
|
|
267
269
|
});
|
|
270
|
+
const toolCallContinuation = context.toolCallContinuation;
|
|
268
271
|
if (runtime.cachedOutputs != null) {
|
|
269
272
|
return runtime.cachedOutputs;
|
|
270
273
|
}
|
|
@@ -274,6 +277,16 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
274
277
|
autoContinue: true,
|
|
275
278
|
maxToolRounds: runtime.maxToolRounds,
|
|
276
279
|
functions: runtime.functions,
|
|
280
|
+
delegateToolCallRound: toolCallContinuation
|
|
281
|
+
? async (toolCalls, preToolMessage) => {
|
|
282
|
+
const results = await toolCallContinuation.run(toolCalls, preToolMessage);
|
|
283
|
+
return results.map((result) => ({
|
|
284
|
+
type: 'chat-message',
|
|
285
|
+
value: result.message,
|
|
286
|
+
delegatedToolCall: result.record,
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
: undefined,
|
|
277
290
|
delegateToolCall: async (toolCall) => {
|
|
278
291
|
const delegated = await delegateToolCall(toolCall, context, {
|
|
279
292
|
handlers: [],
|
|
@@ -290,6 +303,9 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
290
303
|
},
|
|
291
304
|
})
|
|
292
305
|
: await runChatV2Pipeline(runtime.runOptions);
|
|
306
|
+
if (toolCallContinuation && result.functionCalls.length > 0) {
|
|
307
|
+
toolCallContinuation.release();
|
|
308
|
+
}
|
|
293
309
|
if (runtime.cacheKey != null && runtime.editorCache != null) {
|
|
294
310
|
runtime.editorCache.set(runtime.cacheKey, cloneLLMChatV2EditorCacheOutputs(result.commonOutputs));
|
|
295
311
|
}
|
|
@@ -8,6 +8,7 @@ import {} from '../ProcessContext.js';
|
|
|
8
8
|
import { dedent } from 'ts-dedent';
|
|
9
9
|
import {} from '../../index.js';
|
|
10
10
|
import { entries } from '../../utils/typeSafety.js';
|
|
11
|
+
import { getHighestVariadicPortIndex } from './variadicPortIndex.js';
|
|
11
12
|
export class LoopControllerNodeImpl extends NodeImpl {
|
|
12
13
|
static create() {
|
|
13
14
|
const chartNode = {
|
|
@@ -27,7 +28,7 @@ export class LoopControllerNodeImpl extends NodeImpl {
|
|
|
27
28
|
}
|
|
28
29
|
getInputDefinitions(connections, nodes) {
|
|
29
30
|
const inputs = [];
|
|
30
|
-
const messageCount =
|
|
31
|
+
const messageCount = getHighestVariadicPortIndex(connections, this.chartNode.id, 'input', 'legacy');
|
|
31
32
|
inputs.push({
|
|
32
33
|
dataType: 'any',
|
|
33
34
|
id: 'continue',
|
|
@@ -59,7 +60,7 @@ export class LoopControllerNodeImpl extends NodeImpl {
|
|
|
59
60
|
return inputs;
|
|
60
61
|
}
|
|
61
62
|
getOutputDefinitions(connections, nodes) {
|
|
62
|
-
const messageCount =
|
|
63
|
+
const messageCount = getHighestVariadicPortIndex(connections, this.chartNode.id, 'input', 'legacy');
|
|
63
64
|
const outputs = [];
|
|
64
65
|
outputs.push({
|
|
65
66
|
dataType: 'any',
|
|
@@ -123,18 +124,6 @@ export class LoopControllerNodeImpl extends NodeImpl {
|
|
|
123
124
|
group: ['Logic'],
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
|
-
#getInputPortCount(connections) {
|
|
127
|
-
const inputNodeId = this.chartNode.id;
|
|
128
|
-
const messageConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
129
|
-
let maxMessageNumber = 0;
|
|
130
|
-
for (const connection of messageConnections) {
|
|
131
|
-
const messageNumber = parseInt(connection.inputId.replace('input', ''));
|
|
132
|
-
if (messageNumber > maxMessageNumber) {
|
|
133
|
-
maxMessageNumber = messageNumber;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return maxMessageNumber;
|
|
137
|
-
}
|
|
138
127
|
async process(inputs, context) {
|
|
139
128
|
const output = {};
|
|
140
129
|
let inputCount = 0;
|
|
@@ -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 {
|
|
5
|
-
import { dedent
|
|
4
|
+
import {} from '../../integrations/mcp/MCPProvider.js';
|
|
5
|
+
import { dedent } from '../../utils/index.js';
|
|
6
6
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
7
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
|
99
|
+
? await mcpProvider.getHTTPPrompts(server.clientConfig, server.serverUrl)
|
|
164
100
|
: [];
|
|
165
101
|
}
|
|
166
|
-
else if (transportType === 'stdio') {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
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'] = {
|
|
@@ -11,7 +11,7 @@ export class MatchNodeImpl extends NodeImpl {
|
|
|
11
11
|
static create() {
|
|
12
12
|
const chartNode = {
|
|
13
13
|
type: 'match',
|
|
14
|
-
title: 'Match',
|
|
14
|
+
title: 'Regex Match',
|
|
15
15
|
id: nanoid(),
|
|
16
16
|
visualData: {
|
|
17
17
|
x: 0,
|
|
@@ -106,13 +106,14 @@ export class MatchNodeImpl extends NodeImpl {
|
|
|
106
106
|
infoBoxBody: dedent `
|
|
107
107
|
Any number of regular expressions can be configured, each corresponding to an output of the node. The output port of the first matching regex will be ran, and all other output ports will not be ran.
|
|
108
108
|
`,
|
|
109
|
-
infoBoxTitle: 'Match Node',
|
|
110
|
-
contextMenuTitle: 'Match',
|
|
109
|
+
infoBoxTitle: 'Regex Match Node',
|
|
110
|
+
contextMenuTitle: 'Regex Match',
|
|
111
111
|
group: ['Logic'],
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
async process(inputs) {
|
|
115
|
-
const
|
|
115
|
+
const inputValue = inputs['input'];
|
|
116
|
+
const inputString = inputValue?.value == null ? undefined : coerceType(inputValue, 'string');
|
|
116
117
|
const value = inputs['value'];
|
|
117
118
|
const portIds = resolveStoredOrderedPortIds(this.data.cases.length, this.data.casePortIds, {
|
|
118
119
|
kind: 'prefix',
|
|
@@ -125,8 +126,7 @@ export class MatchNodeImpl extends NodeImpl {
|
|
|
125
126
|
let matched = false;
|
|
126
127
|
const output = {};
|
|
127
128
|
for (let i = 0; i < cases.length; i++) {
|
|
128
|
-
const
|
|
129
|
-
const match = regExp.test(inputString);
|
|
129
|
+
const match = inputString !== undefined && new RegExp(cases[i]).test(inputString);
|
|
130
130
|
const canMatch = !this.data.exclusive || !matched;
|
|
131
131
|
if (match && canMatch) {
|
|
132
132
|
matched = true;
|
|
@@ -157,4 +157,4 @@ export class MatchNodeImpl extends NodeImpl {
|
|
|
157
157
|
return output;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
export const matchNode = nodeDefinition(MatchNodeImpl, 'Match');
|
|
160
|
+
export const matchNode = nodeDefinition(MatchNodeImpl, 'Regex Match');
|