@alpic80/rivet-core 1.24.2-aidon.1 → 1.24.2-aidon.11
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 +189 -53
- package/dist/cjs/bundle.cjs.map +2 -2
- package/dist/esm/api/streaming.js +25 -6
- package/dist/esm/integrations/mcp/MCPBase.js +13 -0
- package/dist/esm/model/GraphProcessor.js +4 -1
- package/dist/esm/model/nodes/HttpCallNode.js +2 -2
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +33 -4
- package/dist/esm/model/nodes/MCPGetPromptNode.js +33 -4
- package/dist/esm/model/nodes/MCPToolCallNode.js +34 -5
- package/dist/esm/model/nodes/SubGraphNode.js +1 -0
- package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +7 -5
- package/dist/esm/plugins/aidon/plugin.js +15 -0
- package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +4 -2
- package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +5 -3
- package/dist/types/api/streaming.d.ts +2 -3
- package/dist/types/integrations/mcp/MCPBase.d.ts +2 -0
- package/dist/types/integrations/mcp/MCPProvider.d.ts +4 -4
- package/dist/types/model/GraphProcessor.d.ts +4 -0
- package/package.json +6 -6
|
@@ -9,12 +9,14 @@ function nodeMatches(spec, event) {
|
|
|
9
9
|
export async function* getProcessorEvents(processor, spec) {
|
|
10
10
|
const previousIndexes = new Map();
|
|
11
11
|
const usages = [];
|
|
12
|
+
let hasDelta = false;
|
|
12
13
|
for await (const event of processor.events()) {
|
|
13
14
|
if (event.type === 'partialOutput') {
|
|
14
15
|
if (spec.partialOutputs === true ||
|
|
15
16
|
nodeMatches(spec.partialOutputs, event)) {
|
|
16
17
|
const currentOutput = coerceType(event.outputs['response'], 'string');
|
|
17
18
|
const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
|
|
19
|
+
hasDelta = true;
|
|
18
20
|
yield {
|
|
19
21
|
type: 'partialOutput',
|
|
20
22
|
nodeId: event.node.id,
|
|
@@ -76,8 +78,8 @@ export async function* getProcessorEvents(processor, spec) {
|
|
|
76
78
|
usages.push(usage);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
if (spec.nodeFinish === true ||
|
|
80
|
-
|
|
81
|
+
if ((spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) &&
|
|
82
|
+
!(spec.removeFinalOutput && hasDelta)) {
|
|
81
83
|
yield {
|
|
82
84
|
type: 'nodeFinish',
|
|
83
85
|
outputs: event.outputs,
|
|
@@ -121,10 +123,14 @@ spec) {
|
|
|
121
123
|
return new ReadableStream({
|
|
122
124
|
async start(controller) {
|
|
123
125
|
const userEventHandler = async (eventName, data) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const graphEvent = {
|
|
127
|
+
type: 'event',
|
|
128
|
+
graphEvent: {
|
|
129
|
+
name: eventName,
|
|
130
|
+
message: coerceType(data, 'string')
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
sendEvent(controller, 'event', graphEvent);
|
|
128
134
|
};
|
|
129
135
|
const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
|
|
130
136
|
if (streamEvents) {
|
|
@@ -159,6 +165,19 @@ export function getSingleNodeStream(processor, arg) {
|
|
|
159
165
|
return new ReadableStream({
|
|
160
166
|
async start(controller) {
|
|
161
167
|
try {
|
|
168
|
+
const userEventHandler = async (eventName, data) => {
|
|
169
|
+
const payload = {
|
|
170
|
+
name: eventName,
|
|
171
|
+
message: coerceType(data, 'string')
|
|
172
|
+
};
|
|
173
|
+
controller.enqueue(`event: ${JSON.stringify(payload)}\n\n`);
|
|
174
|
+
};
|
|
175
|
+
const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
|
|
176
|
+
if (streamEvents) {
|
|
177
|
+
for (const [name, fn] of Object.entries(streamEvents)) {
|
|
178
|
+
processor.onUserEvent(name, fn);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
162
181
|
for await (const event of getProcessorEvents(processor, spec)) {
|
|
163
182
|
if (event.type === 'partialOutput') { //nodeIdOrTitle filter managed by spec
|
|
164
183
|
controller.enqueue(`data: ${JSON.stringify(event.delta)}\n\n`);
|
|
@@ -23,6 +23,13 @@ export const getMCPBaseInputs = (data) => {
|
|
|
23
23
|
description: 'The endpoint URL for the MCP server',
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
if (data.transportType === 'http' && data.useHeadersInput) {
|
|
27
|
+
inputs.push({
|
|
28
|
+
dataType: 'object',
|
|
29
|
+
id: 'headers',
|
|
30
|
+
title: 'Headers',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
26
33
|
return inputs;
|
|
27
34
|
};
|
|
28
35
|
export const getMCPBaseEditors = async (context, data) => {
|
|
@@ -71,6 +78,12 @@ export const getMCPBaseEditors = async (context, data) => {
|
|
|
71
78
|
dataKey: 'serverUrl',
|
|
72
79
|
useInputToggleDataKey: 'useServerUrlInput',
|
|
73
80
|
helperMessage: 'The endpoint URL for the MCP server to connect',
|
|
81
|
+
}, {
|
|
82
|
+
type: 'code',
|
|
83
|
+
label: 'Headers',
|
|
84
|
+
dataKey: 'headers',
|
|
85
|
+
useInputToggleDataKey: 'useHeadersInput',
|
|
86
|
+
language: 'json',
|
|
74
87
|
});
|
|
75
88
|
}
|
|
76
89
|
else if (data.transportType === 'stdio') {
|
|
@@ -13,7 +13,6 @@ import { coerceTypeOptional } from '../utils/coerceType.js';
|
|
|
13
13
|
import { globalRivetNodeRegistry } from './Nodes.js';
|
|
14
14
|
import { getPluginConfig } from '../utils/index.js';
|
|
15
15
|
import { GptTokenizerTokenizer } from '../integrations/GptTokenizerTokenizer.js';
|
|
16
|
-
// eslint-disable-next-line import/no-cycle -- There has to be a cycle because CodeRunner needs to import the entirety of Rivet
|
|
17
16
|
import { IsomorphicCodeRunner } from '../integrations/CodeRunner.js';
|
|
18
17
|
// CJS compatibility, gets default.default for whatever reason
|
|
19
18
|
let PQueue = PQueueImport;
|
|
@@ -514,6 +513,7 @@ export class GraphProcessor {
|
|
|
514
513
|
if (this.#running) {
|
|
515
514
|
throw new Error('Cannot process graph while already processing');
|
|
516
515
|
}
|
|
516
|
+
this.#emitTraceEvent(`Process graph called. Context:${JSON.stringify(context)}, Inputs: ${JSON.stringify(inputs)}, Context Values: ${JSON.stringify(contextValues)}`);
|
|
517
517
|
this.#initProcessState();
|
|
518
518
|
this.#context = context;
|
|
519
519
|
this.#graphInputs = inputs;
|
|
@@ -524,8 +524,11 @@ export class GraphProcessor {
|
|
|
524
524
|
this.#emitter.emit('error', { error });
|
|
525
525
|
});
|
|
526
526
|
}
|
|
527
|
+
this.#emitTraceEvent(`Process graph calling loadProjectReferences`);
|
|
527
528
|
await this.#loadProjectReferences();
|
|
529
|
+
this.#emitTraceEvent(`Process graph called loadProjectReferences`);
|
|
528
530
|
this.#preprocessGraph();
|
|
531
|
+
this.#emitTraceEvent(`Process graph called preprocessGraph`);
|
|
529
532
|
if (!this.#isSubProcessor) {
|
|
530
533
|
await this.#emitter.emit('start', {
|
|
531
534
|
contextValues: this.#contextValues,
|
|
@@ -141,7 +141,7 @@ export class HttpCallNodeImpl extends NodeImpl {
|
|
|
141
141
|
return dedent `
|
|
142
142
|
${this.data.useMethodInput ? '(Method Using Input)' : this.data.method} ${this.data.useUrlInput ? '(URL Using Input)' : this.data.url} ${this.data.useHeadersInput
|
|
143
143
|
? '\nHeaders: (Using Input)'
|
|
144
|
-
: this.data.headers
|
|
144
|
+
: this.data.headers?.trim()
|
|
145
145
|
? `\nHeaders: ${this.data.headers}`
|
|
146
146
|
: ''}${this.data.useBodyInput ? '\nBody: (Using Input)' : this.data.body.trim() ? `\nBody: ${this.data.body}` : ''}${this.data.errorOnNon200 ? '\nError on non-200' : ''}
|
|
147
147
|
`;
|
|
@@ -179,7 +179,7 @@ export class HttpCallNodeImpl extends NodeImpl {
|
|
|
179
179
|
headers = coerceType(headersInput, 'object');
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
else if (this.data.headers
|
|
182
|
+
else if (this.data.headers?.trim()) {
|
|
183
183
|
headers = JSON.parse(this.data.headers);
|
|
184
184
|
}
|
|
185
185
|
let body;
|
|
@@ -2,7 +2,7 @@ import { nanoid } from 'nanoid';
|
|
|
2
2
|
import { NodeImpl } from '../NodeImpl.js';
|
|
3
3
|
import {} from '../../index.js';
|
|
4
4
|
import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
|
|
5
|
-
import { dedent, getInputOrData } from '../../utils/index.js';
|
|
5
|
+
import { coerceType, dedent, getInputOrData } from '../../utils/index.js';
|
|
6
6
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
7
7
|
import { getServerHelperMessage, getServerOptions, loadMCPConfiguration } from '../../integrations/mcp/MCPUtils.js';
|
|
8
8
|
import { getMCPBaseInputs } from '../../integrations/mcp/MCPBase.js';
|
|
@@ -22,6 +22,7 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
|
|
|
22
22
|
version: '1.0.0',
|
|
23
23
|
transportType: 'stdio',
|
|
24
24
|
serverUrl: 'http://localhost:8080/mcp',
|
|
25
|
+
headers: '',
|
|
25
26
|
serverId: '',
|
|
26
27
|
useNameInput: false,
|
|
27
28
|
useVersionInput: false,
|
|
@@ -100,6 +101,12 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
|
|
|
100
101
|
dataKey: 'serverUrl',
|
|
101
102
|
useInputToggleDataKey: 'useServerUrlInput',
|
|
102
103
|
helperMessage: 'The base URL endpoint for the MCP server with `/mcp`',
|
|
104
|
+
}, {
|
|
105
|
+
type: 'code',
|
|
106
|
+
label: 'Headers',
|
|
107
|
+
dataKey: 'headers',
|
|
108
|
+
useInputToggleDataKey: 'useHeadersInput',
|
|
109
|
+
language: 'json',
|
|
103
110
|
});
|
|
104
111
|
}
|
|
105
112
|
else if (this.data.transportType === 'stdio') {
|
|
@@ -116,15 +123,21 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
|
|
|
116
123
|
}
|
|
117
124
|
getBody(context) {
|
|
118
125
|
let base;
|
|
126
|
+
let headers = '';
|
|
119
127
|
if (this.data.transportType === 'http') {
|
|
120
128
|
base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
|
|
129
|
+
headers = this.data.useHeadersInput
|
|
130
|
+
? '\nHeaders: (Using Input)'
|
|
131
|
+
: this.data.headers?.trim()
|
|
132
|
+
? `\nHeaders: ${this.data.headers}`
|
|
133
|
+
: '';
|
|
121
134
|
}
|
|
122
135
|
else {
|
|
123
136
|
base = `Server ID: ${this.data.serverId || '(None)'}`;
|
|
124
137
|
}
|
|
125
138
|
const namePart = `Name: ${this.data.name}`;
|
|
126
139
|
const versionPart = `Version: ${this.data.version}`;
|
|
127
|
-
const parts = [namePart, versionPart, base];
|
|
140
|
+
const parts = [namePart, versionPart, base, headers];
|
|
128
141
|
if (context.executor !== 'nodejs') {
|
|
129
142
|
parts.push('(Requires Node Executor)');
|
|
130
143
|
}
|
|
@@ -158,8 +171,24 @@ class MCPDiscoveryNodeImpl extends NodeImpl {
|
|
|
158
171
|
if (!serverUrl.includes('/mcp')) {
|
|
159
172
|
throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
|
|
160
173
|
}
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
let headers;
|
|
175
|
+
if (this.data.useHeadersInput) {
|
|
176
|
+
const headersInput = inputs['headers'];
|
|
177
|
+
if (headersInput?.type === 'string') {
|
|
178
|
+
headers = JSON.parse(headersInput.value);
|
|
179
|
+
}
|
|
180
|
+
else if (headersInput?.type === 'object') {
|
|
181
|
+
headers = headersInput.value;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
headers = coerceType(headersInput, 'object');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (this.data.headers?.trim()) {
|
|
188
|
+
headers = JSON.parse(this.data.headers);
|
|
189
|
+
}
|
|
190
|
+
tools = await context.mcpProvider.getHTTPTools({ name, version }, serverUrl, headers);
|
|
191
|
+
prompts = await context.mcpProvider.getHTTPrompts({ name, version }, serverUrl, headers);
|
|
163
192
|
}
|
|
164
193
|
else if (transportType === 'stdio') {
|
|
165
194
|
const serverId = this.data.serverId ?? '';
|
|
@@ -3,7 +3,7 @@ import { nanoid } from 'nanoid/non-secure';
|
|
|
3
3
|
import { NodeImpl } from '../NodeImpl.js';
|
|
4
4
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
5
|
import {} from '../GraphProcessor.js';
|
|
6
|
-
import {} from '../../index.js';
|
|
6
|
+
import { coerceType } from '../../index.js';
|
|
7
7
|
import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
|
|
8
8
|
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
9
9
|
import { dedent, getInputOrData } from '../../utils/index.js';
|
|
@@ -28,6 +28,7 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
|
|
|
28
28
|
version: '1.0.0',
|
|
29
29
|
transportType: 'stdio',
|
|
30
30
|
serverUrl: 'http://localhost:8080/mcp',
|
|
31
|
+
headers: '',
|
|
31
32
|
serverId: '',
|
|
32
33
|
promptName: '',
|
|
33
34
|
promptArguments: dedent `
|
|
@@ -117,7 +118,13 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
|
|
|
117
118
|
label: 'Server URL',
|
|
118
119
|
dataKey: 'serverUrl',
|
|
119
120
|
useInputToggleDataKey: 'useServerUrlInput',
|
|
120
|
-
helperMessage: 'The
|
|
121
|
+
helperMessage: 'The base URL endpoint for the MCP server with `/mcp`',
|
|
122
|
+
}, {
|
|
123
|
+
type: 'code',
|
|
124
|
+
label: 'Headers',
|
|
125
|
+
dataKey: 'headers',
|
|
126
|
+
useInputToggleDataKey: 'useHeadersInput',
|
|
127
|
+
language: 'json',
|
|
121
128
|
});
|
|
122
129
|
}
|
|
123
130
|
else if (this.data.transportType === 'stdio') {
|
|
@@ -134,15 +141,21 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
|
|
|
134
141
|
}
|
|
135
142
|
getBody(context) {
|
|
136
143
|
let base;
|
|
144
|
+
let headers = '';
|
|
137
145
|
if (this.data.transportType === 'http') {
|
|
138
146
|
base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
|
|
147
|
+
headers = this.data.useHeadersInput
|
|
148
|
+
? '\nHeaders: (Using Input)'
|
|
149
|
+
: this.data.headers?.trim()
|
|
150
|
+
? `\nHeaders: ${this.data.headers}`
|
|
151
|
+
: '';
|
|
139
152
|
}
|
|
140
153
|
else {
|
|
141
154
|
base = `Server ID: ${this.data.serverId || '(None)'}`;
|
|
142
155
|
}
|
|
143
156
|
const namePart = `Name: ${this.data.name}`;
|
|
144
157
|
const versionPart = `Version: ${this.data.version}`;
|
|
145
|
-
const parts = [namePart, versionPart, base];
|
|
158
|
+
const parts = [namePart, versionPart, base, headers];
|
|
146
159
|
if (context.executor !== 'nodejs') {
|
|
147
160
|
parts.push('(Requires Node Executor)');
|
|
148
161
|
}
|
|
@@ -199,7 +212,23 @@ export class MCPGetPromptNodeImpl extends NodeImpl {
|
|
|
199
212
|
if (!serverUrl.includes('/mcp')) {
|
|
200
213
|
throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
|
|
201
214
|
}
|
|
202
|
-
|
|
215
|
+
let headers;
|
|
216
|
+
if (this.data.useHeadersInput) {
|
|
217
|
+
const headersInput = inputs['headers'];
|
|
218
|
+
if (headersInput?.type === 'string') {
|
|
219
|
+
headers = JSON.parse(headersInput.value);
|
|
220
|
+
}
|
|
221
|
+
else if (headersInput?.type === 'object') {
|
|
222
|
+
headers = headersInput.value;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
headers = coerceType(headersInput, 'object');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else if (this.data.headers?.trim()) {
|
|
229
|
+
headers = JSON.parse(this.data.headers);
|
|
230
|
+
}
|
|
231
|
+
getPromptResponse = await context.mcpProvider.getHTTPrompt({ name, version }, serverUrl, headers, getPromptRequest);
|
|
203
232
|
}
|
|
204
233
|
else if (transportType === 'stdio') {
|
|
205
234
|
const serverId = this.data.serverId ?? '';
|
|
@@ -3,7 +3,7 @@ import { nanoid } from 'nanoid/non-secure';
|
|
|
3
3
|
import { NodeImpl } from '../NodeImpl.js';
|
|
4
4
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
5
|
import {} from '../GraphProcessor.js';
|
|
6
|
-
import {} from '../../index.js';
|
|
6
|
+
import { coerceType } from '../../index.js';
|
|
7
7
|
import { MCPError, MCPErrorType } from '../../integrations/mcp/MCPProvider.js';
|
|
8
8
|
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
9
9
|
import { getInputOrData } from '../../utils/index.js';
|
|
@@ -30,6 +30,7 @@ export class MCPToolCallNodeImpl extends NodeImpl {
|
|
|
30
30
|
version: '1.0.0',
|
|
31
31
|
transportType: 'stdio',
|
|
32
32
|
serverUrl: 'http://localhost:8080/mcp',
|
|
33
|
+
headers: '',
|
|
33
34
|
serverId: '',
|
|
34
35
|
toolName: '',
|
|
35
36
|
toolArguments: dedent `
|
|
@@ -131,7 +132,7 @@ export class MCPToolCallNodeImpl extends NodeImpl {
|
|
|
131
132
|
label: 'Tool ID',
|
|
132
133
|
dataKey: 'toolCallId',
|
|
133
134
|
useInputToggleDataKey: 'useToolCallIdInput',
|
|
134
|
-
helperMessage: 'The
|
|
135
|
+
helperMessage: 'The ID associated with the tool call',
|
|
135
136
|
},
|
|
136
137
|
];
|
|
137
138
|
if (this.data.transportType === 'http') {
|
|
@@ -140,7 +141,13 @@ export class MCPToolCallNodeImpl extends NodeImpl {
|
|
|
140
141
|
label: 'Server URL',
|
|
141
142
|
dataKey: 'serverUrl',
|
|
142
143
|
useInputToggleDataKey: 'useServerUrlInput',
|
|
143
|
-
helperMessage: 'The
|
|
144
|
+
helperMessage: 'The base URL endpoint for the MCP server with `/mcp`',
|
|
145
|
+
}, {
|
|
146
|
+
type: 'code',
|
|
147
|
+
label: 'Headers',
|
|
148
|
+
dataKey: 'headers',
|
|
149
|
+
useInputToggleDataKey: 'useHeadersInput',
|
|
150
|
+
language: 'json',
|
|
144
151
|
});
|
|
145
152
|
}
|
|
146
153
|
else if (this.data.transportType === 'stdio') {
|
|
@@ -157,15 +164,21 @@ export class MCPToolCallNodeImpl extends NodeImpl {
|
|
|
157
164
|
}
|
|
158
165
|
getBody(context) {
|
|
159
166
|
let base;
|
|
167
|
+
let headers = '';
|
|
160
168
|
if (this.data.transportType === 'http') {
|
|
161
169
|
base = this.data.useServerUrlInput ? '(Using Server URL Input)' : this.data.serverUrl;
|
|
170
|
+
headers = this.data.useHeadersInput
|
|
171
|
+
? '\nHeaders: (Using Input)'
|
|
172
|
+
: this.data.headers?.trim()
|
|
173
|
+
? `\nHeaders: ${this.data.headers}`
|
|
174
|
+
: '';
|
|
162
175
|
}
|
|
163
176
|
else {
|
|
164
177
|
base = `Server ID: ${this.data.serverId || '(None)'}`;
|
|
165
178
|
}
|
|
166
179
|
const namePart = `Name: ${this.data.name}`;
|
|
167
180
|
const versionPart = `Version: ${this.data.version}`;
|
|
168
|
-
const parts = [namePart, versionPart, base];
|
|
181
|
+
const parts = [namePart, versionPart, base, headers];
|
|
169
182
|
if (context.executor !== 'nodejs') {
|
|
170
183
|
parts.push('(Requires Node Executor)');
|
|
171
184
|
}
|
|
@@ -223,7 +236,23 @@ export class MCPToolCallNodeImpl extends NodeImpl {
|
|
|
223
236
|
if (!serverUrl.includes('/mcp')) {
|
|
224
237
|
throw new MCPError(MCPErrorType.SERVER_COMMUNICATION_FAILED, 'Include /mcp in your server URL. For example: http://localhost:8080/mcp');
|
|
225
238
|
}
|
|
226
|
-
|
|
239
|
+
let headers;
|
|
240
|
+
if (this.data.useHeadersInput) {
|
|
241
|
+
const headersInput = inputs['headers'];
|
|
242
|
+
if (headersInput?.type === 'string') {
|
|
243
|
+
headers = JSON.parse(headersInput.value);
|
|
244
|
+
}
|
|
245
|
+
else if (headersInput?.type === 'object') {
|
|
246
|
+
headers = headersInput.value;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
headers = coerceType(headersInput, 'object');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else if (this.data.headers?.trim()) {
|
|
253
|
+
headers = JSON.parse(this.data.headers);
|
|
254
|
+
}
|
|
255
|
+
toolResponse = await context.mcpProvider.httpToolCall({ name, version }, serverUrl, headers, toolCall);
|
|
227
256
|
}
|
|
228
257
|
else if (transportType === 'stdio') {
|
|
229
258
|
const serverId = this.data.serverId ?? '';
|
|
@@ -53,7 +53,7 @@ class ChatAidonNodeImpl extends ChatNodeImpl {
|
|
|
53
53
|
}
|
|
54
54
|
return path;
|
|
55
55
|
}
|
|
56
|
-
async callToolGet(
|
|
56
|
+
async callToolGet(schemaDetail, path, parsedArgs, data) {
|
|
57
57
|
const queryParams = new URLSearchParams(parsedArgs.parameters).toString();
|
|
58
58
|
const fullUrl = schemaDetail.url + path + (queryParams ? "?" + queryParams : "");
|
|
59
59
|
let headers = {};
|
|
@@ -112,8 +112,11 @@ class ChatAidonNodeImpl extends ChatNodeImpl {
|
|
|
112
112
|
async process(inputs, context) {
|
|
113
113
|
//make sure not to include functions if we have no way to run them after.
|
|
114
114
|
inputs = this.removeInvalidInputs(inputs);
|
|
115
|
+
// const configData = this.data
|
|
116
|
+
// configData.frequencyPenalty = 2;
|
|
115
117
|
// Call the parent class's process method to do its job
|
|
116
118
|
let outputs = await super.process(inputs, context);
|
|
119
|
+
//Now check if the LLM wants us to do some tool calling
|
|
117
120
|
const funcCallOutput = outputs['function-call'] ?? outputs['function-calls'];
|
|
118
121
|
const funcCalls = funcCallOutput?.type === 'object[]'
|
|
119
122
|
? funcCallOutput.value
|
|
@@ -135,14 +138,13 @@ class ChatAidonNodeImpl extends ChatNodeImpl {
|
|
|
135
138
|
}
|
|
136
139
|
const schemaDetail = this.convertToolSchemaToSchemaDetail(toolSchema);
|
|
137
140
|
const path = this.extractPath(schemaDetail, functionCall.name, functionCall.arguments);
|
|
138
|
-
// Determine if the request should be in the body or as a query
|
|
139
141
|
let data = {};
|
|
140
|
-
if
|
|
141
|
-
|
|
142
|
+
// Determine if the request should be in the body or as a query
|
|
143
|
+
if (schemaDetail.requestInBody) { // If the type is set to body
|
|
142
144
|
data = await this.callToolPost(schemaDetail, path, functionCall.arguments, data);
|
|
143
145
|
}
|
|
144
146
|
else { // If the type is set to query
|
|
145
|
-
data = await this.callToolGet(
|
|
147
|
+
data = await this.callToolGet(schemaDetail, path, functionCall.arguments, data);
|
|
146
148
|
}
|
|
147
149
|
messages['value'].push({
|
|
148
150
|
type: "function",
|
|
@@ -3,6 +3,21 @@ import { chatAidonNode } from './nodes/ChatAidonNode.js';
|
|
|
3
3
|
export const aidonPlugin = {
|
|
4
4
|
id: 'aidon',
|
|
5
5
|
name: 'Aidon',
|
|
6
|
+
configSpec: {
|
|
7
|
+
aidonURL: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
label: 'Aidon URL',
|
|
10
|
+
description: 'The URL for the Aidon application.',
|
|
11
|
+
helperText: 'Defaults to https://app.aidon.ai. URL for the Aidon application.',
|
|
12
|
+
default: 'https://app.aidon.ai',
|
|
13
|
+
},
|
|
14
|
+
aidonKey: {
|
|
15
|
+
type: 'secret',
|
|
16
|
+
label: 'Aidon API Key',
|
|
17
|
+
description: 'The API Key for the Aidon application.',
|
|
18
|
+
helperText: 'API Key for the Aidon application.',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
6
21
|
register: (register) => {
|
|
7
22
|
register(chatAidonNode());
|
|
8
23
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid/non-secure';
|
|
2
2
|
import {} from '../../../index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { InferenceClient } from '@huggingface/inference';
|
|
4
4
|
import { getInputOrData } from '../../../utils/inputs.js';
|
|
5
5
|
import { coerceType } from '../../../utils/coerceType.js';
|
|
6
6
|
import { dedent } from '../../../utils/misc.js';
|
|
@@ -206,7 +206,9 @@ export const ChatHuggingFaceNodeImpl = {
|
|
|
206
206
|
const repetitionPenalty = getInputOrData(data, inputData, 'repetitionPenalty', 'number');
|
|
207
207
|
const topP = getInputOrData(data, inputData, 'topP', 'number');
|
|
208
208
|
const topK = getInputOrData(data, inputData, 'topK', 'number');
|
|
209
|
-
const hf = endpoint
|
|
209
|
+
const hf = endpoint
|
|
210
|
+
? new InferenceClient(accessToken, { endpointUrl: endpoint })
|
|
211
|
+
: new InferenceClient(accessToken);
|
|
210
212
|
const generationStream = hf.textGenerationStream({
|
|
211
213
|
inputs: prompt,
|
|
212
214
|
model,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid/non-secure';
|
|
2
2
|
import {} from '../../../index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { InferenceClient } from '@huggingface/inference';
|
|
4
4
|
import { dedent } from 'ts-dedent';
|
|
5
5
|
import { pluginNodeDefinition } from '../../../model/NodeDefinition.js';
|
|
6
6
|
import { getInputOrData } from '../../../utils/inputs.js';
|
|
@@ -163,7 +163,9 @@ export const TextToImageHuggingFaceNodeImpl = {
|
|
|
163
163
|
const negativePrompt = getInputOrData(data, inputData, 'negativePrompt') || undefined;
|
|
164
164
|
const guidanceScale = getInputOrData(data, inputData, 'guidanceScale', 'number');
|
|
165
165
|
const numInferenceSteps = getInputOrData(data, inputData, 'numInferenceSteps', 'number');
|
|
166
|
-
const hf = endpoint
|
|
166
|
+
const hf = endpoint
|
|
167
|
+
? new InferenceClient(accessToken, { endpointUrl: endpoint })
|
|
168
|
+
: new InferenceClient(accessToken);
|
|
167
169
|
const image = await hf.textToImage({
|
|
168
170
|
inputs: prompt,
|
|
169
171
|
model,
|
|
@@ -174,7 +176,7 @@ export const TextToImageHuggingFaceNodeImpl = {
|
|
|
174
176
|
guidance_scale: guidanceScale,
|
|
175
177
|
num_inference_steps: numInferenceSteps,
|
|
176
178
|
},
|
|
177
|
-
});
|
|
179
|
+
}, { outputType: "blob" });
|
|
178
180
|
return {
|
|
179
181
|
['output']: {
|
|
180
182
|
type: 'image',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NodeId, type Inputs, type Outputs, type GraphOutputs, type GraphProcessor, type DataValue, type RunGraphOptions } from '../index.js';
|
|
1
|
+
import { type NodeId, type Inputs, type Outputs, type GraphOutputs, type GraphProcessor, type DataValue, type RunGraphOptions, type GraphEvents } from '../index.js';
|
|
2
2
|
export type RivetEventStreamFilterSpec = {
|
|
3
3
|
/** Stream partial output deltas for the specified node IDs or node titles. */
|
|
4
4
|
partialOutputs?: string[] | true;
|
|
@@ -41,8 +41,7 @@ export type RivetEventStreamEvent = {
|
|
|
41
41
|
graphOutput: GraphOutputs;
|
|
42
42
|
};
|
|
43
43
|
event: {
|
|
44
|
-
|
|
45
|
-
message: string;
|
|
44
|
+
graphEvent: GraphEvents;
|
|
46
45
|
};
|
|
47
46
|
error: {
|
|
48
47
|
error: string;
|
|
@@ -121,7 +121,7 @@ export interface MCPProvider {
|
|
|
121
121
|
getHTTPTools(clientConfig: {
|
|
122
122
|
name: string;
|
|
123
123
|
version: string;
|
|
124
|
-
}, serverUrl: string): Promise<MCP.Tool[]>;
|
|
124
|
+
}, serverUrl: string, headers: Record<string, string> | undefined): Promise<MCP.Tool[]>;
|
|
125
125
|
getStdioTools(clientConfig: {
|
|
126
126
|
name: string;
|
|
127
127
|
version: string;
|
|
@@ -129,7 +129,7 @@ export interface MCPProvider {
|
|
|
129
129
|
getHTTPrompts(clientConfig: {
|
|
130
130
|
name: string;
|
|
131
131
|
version: string;
|
|
132
|
-
}, serverUrl: string): Promise<MCP.Prompt[]>;
|
|
132
|
+
}, serverUrl: string, headers: Record<string, string> | undefined): Promise<MCP.Prompt[]>;
|
|
133
133
|
getStdioPrompts(clientConfig: {
|
|
134
134
|
name: string;
|
|
135
135
|
version: string;
|
|
@@ -137,7 +137,7 @@ export interface MCPProvider {
|
|
|
137
137
|
httpToolCall(clientConfig: {
|
|
138
138
|
name: string;
|
|
139
139
|
version: string;
|
|
140
|
-
}, serverUrl: string, toolCall: MCP.ToolCallRequest): Promise<MCP.ToolCallResponse>;
|
|
140
|
+
}, serverUrl: string, headers: Record<string, string> | undefined, toolCall: MCP.ToolCallRequest): Promise<MCP.ToolCallResponse>;
|
|
141
141
|
stdioToolCall(clientConfig: {
|
|
142
142
|
name: string;
|
|
143
143
|
version: string;
|
|
@@ -145,7 +145,7 @@ export interface MCPProvider {
|
|
|
145
145
|
getHTTPrompt(clientConfig: {
|
|
146
146
|
name: string;
|
|
147
147
|
version: string;
|
|
148
|
-
}, serverUrl: string, getPromptRequest: MCP.GetPromptRequest): Promise<MCP.GetPromptResponse>;
|
|
148
|
+
}, serverUrl: string, headers: Record<string, string> | undefined, getPromptRequest: MCP.GetPromptRequest): Promise<MCP.GetPromptResponse>;
|
|
149
149
|
getStdioPrompt(clientConfig: {
|
|
150
150
|
name: string;
|
|
151
151
|
version: string;
|
|
@@ -126,6 +126,10 @@ export type ProcessEvent = {
|
|
|
126
126
|
}[keyof ProcessEvents];
|
|
127
127
|
export type GraphOutputs = Record<string, DataValue>;
|
|
128
128
|
export type GraphInputs = Record<string, DataValue>;
|
|
129
|
+
export type GraphEvents = {
|
|
130
|
+
name: string;
|
|
131
|
+
message: string;
|
|
132
|
+
};
|
|
129
133
|
export type NodeResults = Map<NodeId, Outputs>;
|
|
130
134
|
export type Inputs = Record<PortId, DataValue | undefined>;
|
|
131
135
|
export type Outputs = Record<PortId, DataValue | undefined>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@alpic80/rivet-core",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"repository": "https://github.com/castortech/rivet",
|
|
5
|
-
"version": "1.24.2-aidon.
|
|
5
|
+
"version": "1.24.2-aidon.11",
|
|
6
6
|
"packageManager": "yarn@3.5.0",
|
|
7
7
|
"main": "dist/cjs/bundle.cjs",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@gentrace/core": "^2.2.5",
|
|
48
48
|
"@google-cloud/vertexai": "^0.1.3",
|
|
49
49
|
"@google/genai": "^0.12.0",
|
|
50
|
-
"@huggingface/inference": "^
|
|
51
|
-
"@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.2-aidon.
|
|
50
|
+
"@huggingface/inference": "^4.13.0",
|
|
51
|
+
"@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.2-aidon.11",
|
|
52
52
|
"assemblyai": "^4.6.0",
|
|
53
53
|
"autoevals": "^0.0.26",
|
|
54
54
|
"cron-parser": "^4.9.0",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"emittery": "^1.0.1",
|
|
57
57
|
"emittery-0-13": "npm:emittery@^0.13.1",
|
|
58
58
|
"gpt-tokenizer": "^2.1.2",
|
|
59
|
-
"jsonpath-plus": "^10.
|
|
59
|
+
"jsonpath-plus": "^10.3.0",
|
|
60
60
|
"lodash-es": "^4.17.21",
|
|
61
61
|
"mdast-util-gfm-table": "^2.0.0",
|
|
62
62
|
"mdast-util-to-markdown": "^2.1.2",
|
|
63
63
|
"minimatch": "^9.0.3",
|
|
64
|
-
"nanoid": "^3.3.
|
|
64
|
+
"nanoid": "^3.3.8",
|
|
65
65
|
"openai": "^4.28.4",
|
|
66
66
|
"p-queue": "^7.4.1",
|
|
67
67
|
"p-queue-6": "npm:p-queue@^6.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/yaml": "^1.9.7",
|
|
84
84
|
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
|
85
85
|
"@typescript-eslint/parser": "^8.24.0",
|
|
86
|
-
"esbuild": "^0.
|
|
86
|
+
"esbuild": "^0.25.12",
|
|
87
87
|
"eslint": "^9.20.1",
|
|
88
88
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
89
89
|
"eslint-plugin-import": "^2.31.0",
|