@valerypopoff/rivet2-core 2.0.6 → 2.0.8
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 +1440 -769
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +8 -2
- package/dist/esm/model/GraphPreprocessor.js +129 -7
- package/dist/esm/model/GraphProcessor.js +204 -82
- package/dist/esm/model/NodeExclusionPolicy.js +67 -0
- package/dist/esm/model/NodeExecutionPlanner.js +66 -22
- package/dist/esm/model/Nodes.js +3 -0
- package/dist/esm/model/chat-v2/chatV2Outputs.js +183 -0
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +30 -212
- package/dist/esm/model/nodes/CodeNewNode.js +207 -0
- package/dist/esm/model/nodes/CodeNode.js +11 -10
- package/dist/esm/model/nodes/CommentNode.js +1 -1
- package/dist/esm/model/nodes/ExpressionNode.js +23 -39
- package/dist/esm/model/nodes/HttpCallNode.js +20 -18
- package/dist/esm/model/nodes/ObjectNode.js +1 -0
- package/dist/esm/model/nodes/ToolNode.js +1 -0
- package/dist/esm/model/nodes/codeNodeErrorDiagnostics.js +16 -11
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +26 -30
- package/dist/esm/model/nodes/jsValueInterpolation.js +56 -2
- package/dist/esm/utils/serialization/serialization.js +22 -1
- package/dist/types/api/createProcessor.d.ts +8 -2
- package/dist/types/model/EditorDefinition.d.ts +2 -0
- package/dist/types/model/GraphPreprocessor.d.ts +36 -2
- package/dist/types/model/GraphProcessor.d.ts +12 -1
- package/dist/types/model/NodeExclusionPolicy.d.ts +21 -0
- package/dist/types/model/NodeExecutionPlanner.d.ts +3 -8
- package/dist/types/model/Nodes.d.ts +3 -2
- package/dist/types/model/ProcessContext.d.ts +2 -2
- package/dist/types/model/chat-v2/chatV2Outputs.d.ts +29 -0
- package/dist/types/model/nodes/CodeNewNode.d.ts +27 -0
- package/dist/types/model/nodes/codeNodeErrorDiagnostics.d.ts +4 -2
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +20 -0
- package/package.json +1 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { dedent } from 'ts-dedent';
|
|
2
|
-
import {
|
|
3
|
-
import { createInterpolationInputDefinition } from '../interpolationInputDefinition.js';
|
|
4
|
-
import { buildClonedInputValueAssignments, buildCloneJsInputValueFunction, buildJsValueInterpolatedSource, getJsValueInterpolationInputNames, interpolateJsValuePreviewSource, sanitizeGeneratedJsValueText, } from './jsValueInterpolation.js';
|
|
2
|
+
import { buildClonedInputValueAssignments, buildJsValueInterpolatedSource, buildJsValueInputClonePreamble, buildJsValuePreview, getJsValueInterpolationInputDefinitions, getJsValueInterpolationRuntimeContext, interpolateJsValuePreviewSource, sanitizeGeneratedJsValueError, } from './jsValueInterpolation.js';
|
|
5
3
|
const MAX_CALLBACK_PREVIEW_BODY_LINES = 13;
|
|
6
4
|
const JS_LIST_CALLBACK_SIGNATURE = '(item, index, array)';
|
|
7
5
|
export const JS_LIST_CALLBACK_LOCAL_NAMES = new Set(['item', 'index', 'array']);
|
|
@@ -28,41 +26,38 @@ export function assertSynchronousCallbackResult(result, nodeName) {
|
|
|
28
26
|
throw new Error(`${nodeName} callbacks must be synchronous.`);
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
29
|
+
function getJSListInterpolationContext(callbackBody) {
|
|
30
|
+
return getJsValueInterpolationRuntimeContext(callbackBody, JS_LIST_INPUTS_IDENTIFIER, {
|
|
33
31
|
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES,
|
|
34
32
|
});
|
|
35
33
|
}
|
|
36
|
-
function buildJSListRuntimePreamble(
|
|
37
|
-
const inputNames = getJSListCallbackInterpolationInputNames(callbackBody);
|
|
34
|
+
function buildJSListRuntimePreamble(interpolationContext) {
|
|
38
35
|
return dedent `
|
|
39
36
|
const assertSynchronousCallbackResult = ${assertSynchronousCallbackResult.toString()};
|
|
40
|
-
${
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
${buildJsValueInputClonePreamble({
|
|
38
|
+
cacheIdentifier: JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER,
|
|
39
|
+
inputsIdentifier: interpolationContext.inputsIdentifier,
|
|
40
|
+
})}
|
|
43
41
|
const array = cloneJsInputValue(inputs.array?.value, ${JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER});
|
|
44
|
-
${buildClonedInputValueAssignments(inputNames,
|
|
42
|
+
${buildClonedInputValueAssignments(interpolationContext.inputNames, interpolationContext.inputsIdentifier, JS_LIST_INPUT_CLONE_CACHE_IDENTIFIER)}
|
|
45
43
|
`;
|
|
46
44
|
}
|
|
47
|
-
function buildJSListCallbackRuntimeSource(callbackBody) {
|
|
48
|
-
return buildJsValueInterpolatedSource(callbackBody,
|
|
45
|
+
function buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier) {
|
|
46
|
+
return buildJsValueInterpolatedSource(callbackBody, inputsIdentifier, {
|
|
49
47
|
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES,
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
function sanitizeJSListError(error, callbackBody, nodeName) {
|
|
53
|
-
const
|
|
54
|
-
const inputNames = getJSListCallbackInterpolationInputNames(callbackBody);
|
|
51
|
+
const { inputNames, inputsIdentifier } = getJSListInterpolationContext(callbackBody);
|
|
55
52
|
const fallbackLabel = `${nodeName} input`;
|
|
56
|
-
|
|
57
|
-
sanitizeGeneratedJsValueText(jsListError.message, inputNames, JS_LIST_INPUTS_IDENTIFIER, fallbackLabel) ??
|
|
58
|
-
jsListError.message;
|
|
59
|
-
jsListError.stack = sanitizeGeneratedJsValueText(jsListError.stack, inputNames, JS_LIST_INPUTS_IDENTIFIER, fallbackLabel);
|
|
60
|
-
return jsListError;
|
|
53
|
+
return sanitizeGeneratedJsValueError(error, inputNames, inputsIdentifier, fallbackLabel);
|
|
61
54
|
}
|
|
62
55
|
export function buildJSFilterWrapper(callbackBody) {
|
|
63
|
-
const
|
|
56
|
+
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
57
|
+
const { inputsIdentifier } = interpolationContext;
|
|
58
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
64
59
|
return dedent `
|
|
65
|
-
${buildJSListRuntimePreamble(
|
|
60
|
+
${buildJSListRuntimePreamble(interpolationContext)}
|
|
66
61
|
|
|
67
62
|
if (!Array.isArray(array)) {
|
|
68
63
|
throw new Error('JS Filter input "array" must be an array.');
|
|
@@ -95,9 +90,11 @@ export function buildJSFilterWrapper(callbackBody) {
|
|
|
95
90
|
`;
|
|
96
91
|
}
|
|
97
92
|
export function buildJSMapWrapper(callbackBody) {
|
|
98
|
-
const
|
|
93
|
+
const interpolationContext = getJSListInterpolationContext(callbackBody);
|
|
94
|
+
const { inputsIdentifier } = interpolationContext;
|
|
95
|
+
const callbackBodySource = buildJSListCallbackRuntimeSource(callbackBody, inputsIdentifier);
|
|
99
96
|
return dedent `
|
|
100
|
-
${buildJSListRuntimePreamble(
|
|
97
|
+
${buildJSListRuntimePreamble(interpolationContext)}
|
|
101
98
|
|
|
102
99
|
if (!Array.isArray(array)) {
|
|
103
100
|
throw new Error('JS Map input "array" must be an array.');
|
|
@@ -127,11 +124,9 @@ export function buildJSMapWrapper(callbackBody) {
|
|
|
127
124
|
`;
|
|
128
125
|
}
|
|
129
126
|
export function getJSListCallbackInterpolationInputDefinitions(callbackBody) {
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
required: false,
|
|
134
|
-
}));
|
|
127
|
+
return getJsValueInterpolationInputDefinitions(callbackBody, {
|
|
128
|
+
localIdentifiers: JS_LIST_CALLBACK_LOCAL_NAMES,
|
|
129
|
+
});
|
|
135
130
|
}
|
|
136
131
|
export function getJSListInputDefinitions(callbackBody) {
|
|
137
132
|
return [
|
|
@@ -153,6 +148,7 @@ export function getJSListEditors() {
|
|
|
153
148
|
postEditorHelperMessage: '};\n\n//Use {{var}} to create input ports that evaluate as connected values.',
|
|
154
149
|
dataKey: 'callbackBody',
|
|
155
150
|
language: 'javascript',
|
|
151
|
+
interpolationSyntax: 'js-value',
|
|
156
152
|
enableFolding: true,
|
|
157
153
|
},
|
|
158
154
|
];
|
|
@@ -163,7 +159,7 @@ export function interpolateJSListCallbackBody(callbackBody, inputs) {
|
|
|
163
159
|
});
|
|
164
160
|
}
|
|
165
161
|
export function getJSListNodeBody(callbackBody) {
|
|
166
|
-
const previewBody = callbackBody
|
|
162
|
+
const previewBody = buildJsValuePreview(callbackBody, MAX_CALLBACK_PREVIEW_BODY_LINES);
|
|
167
163
|
return {
|
|
168
164
|
type: 'colorized',
|
|
169
165
|
text: dedent `
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { dedent } from 'ts-dedent';
|
|
2
|
+
import { createInterpolationInputDefinition } from '../interpolationInputDefinition.js';
|
|
3
|
+
import { getError } from '../../utils/errors.js';
|
|
2
4
|
import { extractInterpolationVariables, replaceInterpolationTokens } from '../../utils/interpolation.js';
|
|
5
|
+
function escapeRegExp(value) {
|
|
6
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
|
+
}
|
|
8
|
+
function containsIdentifier(source, identifier) {
|
|
9
|
+
return new RegExp(`(^|[^A-Za-z0-9_$])${escapeRegExp(identifier)}($|[^A-Za-z0-9_$])`).test(source);
|
|
10
|
+
}
|
|
11
|
+
export function getSafeJsValueInterpolationIdentifier(source, baseIdentifier) {
|
|
12
|
+
let index = 0;
|
|
13
|
+
let candidate = baseIdentifier;
|
|
14
|
+
while (containsIdentifier(source, candidate)) {
|
|
15
|
+
index += 1;
|
|
16
|
+
candidate = `${baseIdentifier}_${index}`;
|
|
17
|
+
}
|
|
18
|
+
return candidate;
|
|
19
|
+
}
|
|
20
|
+
export function buildJsValuePreview(source, maxLines) {
|
|
21
|
+
return source.split('\n').slice(0, maxLines).join('\n').trim();
|
|
22
|
+
}
|
|
3
23
|
function isSpecialReference(inputName) {
|
|
4
24
|
return inputName.startsWith('@graphInputs.') || inputName.startsWith('@context.');
|
|
5
25
|
}
|
|
@@ -43,14 +63,27 @@ function formatJsValuePreviewValue(inputName, inputs, options) {
|
|
|
43
63
|
export function getJsValueInterpolationInputNames(template, options = {}) {
|
|
44
64
|
return extractInterpolationVariables(template).filter((inputName) => !options.localIdentifiers?.has(inputName));
|
|
45
65
|
}
|
|
66
|
+
export function getJsValueInterpolationInputDefinitions(template, options = {}) {
|
|
67
|
+
return getJsValueInterpolationInputNames(template, options).map((inputName) => createInterpolationInputDefinition({
|
|
68
|
+
interpolationName: inputName,
|
|
69
|
+
dataType: 'any',
|
|
70
|
+
required: false,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
export function getJsValueInterpolationRuntimeContext(template, baseInputsIdentifier, options = {}) {
|
|
74
|
+
return {
|
|
75
|
+
inputNames: getJsValueInterpolationInputNames(template, options),
|
|
76
|
+
inputsIdentifier: getSafeJsValueInterpolationIdentifier(template, baseInputsIdentifier),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
46
79
|
export function buildJsValueInterpolatedSource(template, targetIdentifier, options = {}) {
|
|
47
80
|
return replaceInterpolationTokens(template, (token) => buildJsValueReference(token.tokenName, targetIdentifier, options), {
|
|
48
|
-
trim: true,
|
|
81
|
+
trim: options.trim ?? true,
|
|
49
82
|
});
|
|
50
83
|
}
|
|
51
84
|
export function interpolateJsValuePreviewSource(template, inputs, options = {}) {
|
|
52
85
|
return replaceInterpolationTokens(template, (token) => formatJsValuePreviewValue(token.tokenName, inputs, options), {
|
|
53
|
-
trim: true,
|
|
86
|
+
trim: options.trim ?? true,
|
|
54
87
|
});
|
|
55
88
|
}
|
|
56
89
|
export function buildCloneJsInputValueFunction() {
|
|
@@ -148,6 +181,19 @@ export function buildClonedInputValueAssignments(inputNames, targetIdentifier, c
|
|
|
148
181
|
.map((inputName) => `${targetIdentifier}[${JSON.stringify(inputName)}] = cloneJsInputValue(inputs[${JSON.stringify(inputName)}]?.value, ${cacheIdentifier});`)
|
|
149
182
|
.join('\n');
|
|
150
183
|
}
|
|
184
|
+
export function buildJsValueInputClonePreamble({ cacheIdentifier, inputsIdentifier, }) {
|
|
185
|
+
return dedent `
|
|
186
|
+
${buildCloneJsInputValueFunction()}
|
|
187
|
+
const ${inputsIdentifier} = Object.create(null);
|
|
188
|
+
const ${cacheIdentifier} = new WeakMap();
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
export function buildJsValueInputsInitializer({ cacheIdentifier, inputNames, inputsIdentifier, }) {
|
|
192
|
+
return dedent `
|
|
193
|
+
${buildJsValueInputClonePreamble({ cacheIdentifier, inputsIdentifier })}
|
|
194
|
+
${buildClonedInputValueAssignments(inputNames, inputsIdentifier, cacheIdentifier)}
|
|
195
|
+
`;
|
|
196
|
+
}
|
|
151
197
|
export function sanitizeGeneratedJsValueText(text, inputNames, targetIdentifier, fallbackLabel) {
|
|
152
198
|
if (!text) {
|
|
153
199
|
return text;
|
|
@@ -161,3 +207,11 @@ export function sanitizeGeneratedJsValueText(text, inputNames, targetIdentifier,
|
|
|
161
207
|
}
|
|
162
208
|
return sanitized.replaceAll(targetIdentifier, fallbackLabel);
|
|
163
209
|
}
|
|
210
|
+
export function sanitizeGeneratedJsValueError(error, inputNames, targetIdentifier, fallbackLabel) {
|
|
211
|
+
const jsValueError = getError(error);
|
|
212
|
+
jsValueError.message =
|
|
213
|
+
sanitizeGeneratedJsValueText(jsValueError.message, inputNames, targetIdentifier, fallbackLabel) ??
|
|
214
|
+
jsValueError.message;
|
|
215
|
+
jsValueError.stack = sanitizeGeneratedJsValueText(jsValueError.stack, inputNames, targetIdentifier, fallbackLabel);
|
|
216
|
+
return jsValueError;
|
|
217
|
+
}
|
|
@@ -14,6 +14,7 @@ export function deserializeProject(serializedProject, path = null) {
|
|
|
14
14
|
const version = detectSerializationVersion(serializedProject);
|
|
15
15
|
try {
|
|
16
16
|
const result = deserializeProjectByVersion(serializedProject, version);
|
|
17
|
+
normalizeProjectDefaultNodeTitles(result[0]);
|
|
17
18
|
if (path !== null) {
|
|
18
19
|
result[0].metadata.path = path;
|
|
19
20
|
}
|
|
@@ -33,7 +34,9 @@ export function serializeGraph(graph) {
|
|
|
33
34
|
export function deserializeGraph(serializedGraph) {
|
|
34
35
|
const version = detectSerializationVersion(serializedGraph);
|
|
35
36
|
try {
|
|
36
|
-
|
|
37
|
+
const graph = deserializeGraphByVersion(serializedGraph, version);
|
|
38
|
+
normalizeGraphDefaultNodeTitles(graph);
|
|
39
|
+
return graph;
|
|
37
40
|
}
|
|
38
41
|
catch (err) {
|
|
39
42
|
if (err instanceof yaml.YAMLError) {
|
|
@@ -43,6 +46,24 @@ export function deserializeGraph(serializedGraph) {
|
|
|
43
46
|
throw new Error('Could not deserialize graph');
|
|
44
47
|
}
|
|
45
48
|
}
|
|
49
|
+
function normalizeProjectDefaultNodeTitles(project) {
|
|
50
|
+
for (const graph of Object.values(project.graphs)) {
|
|
51
|
+
normalizeGraphDefaultNodeTitles(graph);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function normalizeGraphDefaultNodeTitles(graph) {
|
|
55
|
+
for (const node of graph.nodes) {
|
|
56
|
+
normalizeDefaultCodeNodeTitle(node);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function normalizeDefaultCodeNodeTitle(node) {
|
|
60
|
+
if (node.type === 'code' && node.title === 'Code') {
|
|
61
|
+
node.title = 'Code (legacy)';
|
|
62
|
+
}
|
|
63
|
+
else if (node.type === 'codeNew' && node.title === 'Code new') {
|
|
64
|
+
node.title = 'Code';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
46
67
|
function deserializeProjectByVersion(serializedProject, version) {
|
|
47
68
|
switch (version) {
|
|
48
69
|
case 4:
|
|
@@ -3,7 +3,7 @@ import type { AttachedData } from '../utils/serialization/serializationUtils.js'
|
|
|
3
3
|
import type { AudioProvider } from '../integrations/AudioProvider.js';
|
|
4
4
|
import type { DataValue } from '../model/DataValue.js';
|
|
5
5
|
import type { DatasetProvider } from '../integrations/DatasetProvider.js';
|
|
6
|
-
import type { ExternalFunction, GraphProcessorConcurrency, ProcessEvents } from '../model/GraphProcessor.js';
|
|
6
|
+
import type { ExternalFunction, GraphProcessorConcurrency, GraphProcessorExecutionPlanCacheMode, GraphProcessorRuntimeCache, GraphProcessorScheduler, ProcessEvents } from '../model/GraphProcessor.js';
|
|
7
7
|
import type { Project } from '../model/Project.js';
|
|
8
8
|
import type { MCPProvider } from '../integrations/mcp/MCPProvider.js';
|
|
9
9
|
import type { NativeApi } from '../native/NativeApi.js';
|
|
@@ -42,7 +42,13 @@ export type RunGraphOptions = {
|
|
|
42
42
|
} & {
|
|
43
43
|
[P in keyof ProcessEvents as `on${PascalCase<P>}`]?: (params: ProcessEvents[P]) => void;
|
|
44
44
|
} & Settings;
|
|
45
|
-
export
|
|
45
|
+
export type CoreCreateProcessorInternalOptions = {
|
|
46
|
+
cacheLoadedProjects?: boolean;
|
|
47
|
+
executionPlanCacheMode?: GraphProcessorExecutionPlanCacheMode;
|
|
48
|
+
runtimeCache?: GraphProcessorRuntimeCache;
|
|
49
|
+
scheduler?: GraphProcessorScheduler;
|
|
50
|
+
};
|
|
51
|
+
export declare function coreCreateProcessor(project: Project, options: RunGraphOptions, internalOptions?: CoreCreateProcessorInternalOptions): {
|
|
46
52
|
processor: GraphProcessor;
|
|
47
53
|
inputs: Record<string, DataValue>;
|
|
48
54
|
contextValues: Record<string, DataValue>;
|
|
@@ -81,12 +81,14 @@ export type NumberEditorDefinition<T extends ChartNode> = SharedEditorDefinition
|
|
|
81
81
|
dataKey: DataOfType<T, number | undefined>;
|
|
82
82
|
allowEmpty: true;
|
|
83
83
|
});
|
|
84
|
+
export type CodeEditorInterpolationSyntax = 'js-value' | 'json-template';
|
|
84
85
|
export type CodeEditorDefinition<T extends ChartNode> = SharedEditorDefinitionProps<T> & {
|
|
85
86
|
type: 'code';
|
|
86
87
|
dataKey: DataOfType<T, string>;
|
|
87
88
|
useInputToggleDataKey?: DataOfType<T, boolean>;
|
|
88
89
|
postEditorHelperMessage?: string | ((data: T['data']) => string | undefined);
|
|
89
90
|
language: string;
|
|
91
|
+
interpolationSyntax?: CodeEditorInterpolationSyntax;
|
|
90
92
|
theme?: string;
|
|
91
93
|
height?: number;
|
|
92
94
|
enableFolding?: boolean;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type { NodeRegistration } from './NodeRegistration.js';
|
|
2
2
|
import type { NodeGraph } from './NodeGraph.js';
|
|
3
|
-
import type { NodeConnection, NodeId, ChartNode, NodeInputDefinition, NodeOutputDefinition } from './NodeBase.js';
|
|
3
|
+
import type { NodeConnection, NodeId, ChartNode, NodeInputDefinition, NodeOutputDefinition, PortId } from './NodeBase.js';
|
|
4
4
|
import type { NodeImpl } from './NodeImpl.js';
|
|
5
5
|
import type { Project, ProjectId } from './Project.js';
|
|
6
6
|
export type GraphNodeDefinitions = Record<NodeId, {
|
|
7
7
|
inputs: NodeInputDefinition[];
|
|
8
8
|
outputs: NodeOutputDefinition[];
|
|
9
9
|
}>;
|
|
10
|
+
export type GraphPortConnectionMap = Record<NodeId, Partial<Record<PortId, NodeConnection>>>;
|
|
11
|
+
export type GraphPortConnectionsMap = Record<NodeId, Partial<Record<PortId, NodeConnection[]>>>;
|
|
12
|
+
export type GraphOutputNodeResult = {
|
|
13
|
+
connections: NodeConnection[];
|
|
14
|
+
connectionsToNodes: {
|
|
15
|
+
connections: NodeConnection[];
|
|
16
|
+
node: ChartNode;
|
|
17
|
+
}[];
|
|
18
|
+
nodes: ChartNode[];
|
|
19
|
+
};
|
|
10
20
|
export type GraphPreprocessorResult = {
|
|
11
21
|
connections: Record<NodeId, NodeConnection[]>;
|
|
12
22
|
definitions: GraphNodeDefinitions;
|
|
@@ -15,10 +25,34 @@ export type GraphPreprocessorResult = {
|
|
|
15
25
|
nodesNotInCycle: ChartNode[];
|
|
16
26
|
stronglyConnectedComponents: ChartNode[][];
|
|
17
27
|
};
|
|
18
|
-
export
|
|
28
|
+
export type GraphExecutionPlan = Omit<GraphPreprocessorResult, 'nodeInstances'> & {
|
|
29
|
+
cycleIndexByNode: Record<NodeId, number>;
|
|
30
|
+
graphNodes: ChartNode[];
|
|
31
|
+
inputConnectionByNodeAndPort: GraphPortConnectionMap;
|
|
32
|
+
inputConnectionsByNode: Record<NodeId, NodeConnection[]>;
|
|
33
|
+
inputNodesByNode: Record<NodeId, ChartNode[]>;
|
|
34
|
+
missingRequiredInputsByNode: Record<NodeId, NodeInputDefinition[]>;
|
|
35
|
+
outputConnectionsByNodeAndPort: GraphPortConnectionsMap;
|
|
36
|
+
outputNodeResultsByNode: Record<NodeId, GraphOutputNodeResult>;
|
|
37
|
+
startNodes: ChartNode[];
|
|
38
|
+
};
|
|
39
|
+
export type GraphPreprocessorExecutionPlanResult = GraphPreprocessorResult & GraphExecutionPlan;
|
|
40
|
+
export type GraphPreprocessedState = GraphPreprocessorResult | GraphPreprocessorExecutionPlanResult;
|
|
41
|
+
type GraphPreprocessorOptions = {
|
|
42
|
+
buildExecutionPlan?: boolean;
|
|
19
43
|
graph: NodeGraph;
|
|
20
44
|
loadedProjects: Record<ProjectId, Project>;
|
|
21
45
|
project: Project;
|
|
22
46
|
registry: NodeRegistration<any, any>;
|
|
23
47
|
warnOnInvalidGraph: boolean;
|
|
48
|
+
};
|
|
49
|
+
export declare function preprocessGraphState(options: GraphPreprocessorOptions & {
|
|
50
|
+
buildExecutionPlan: true;
|
|
51
|
+
}): GraphPreprocessorExecutionPlanResult;
|
|
52
|
+
export declare function preprocessGraphState(options: GraphPreprocessorOptions & {
|
|
53
|
+
buildExecutionPlan?: false | undefined;
|
|
24
54
|
}): GraphPreprocessorResult;
|
|
55
|
+
export declare function preprocessGraphState(options: GraphPreprocessorOptions): GraphPreprocessedState;
|
|
56
|
+
export declare function isGraphExecutionPlan(preprocessedGraph: GraphPreprocessedState | GraphExecutionPlan): preprocessedGraph is GraphExecutionPlan;
|
|
57
|
+
export declare function toReusableGraphExecutionPlan(preprocessedGraph: GraphPreprocessorExecutionPlanResult): GraphExecutionPlan;
|
|
58
|
+
export {};
|
|
@@ -2,11 +2,12 @@ import { type DataValue, type StringArrayDataValue, type ScalarOrArrayDataValue
|
|
|
2
2
|
import { type ChartNode, type NodeConnection, type NodeId, type PortId } from './NodeBase.js';
|
|
3
3
|
import type { GraphId, NodeGraph } from './NodeGraph.js';
|
|
4
4
|
import Emittery from 'emittery';
|
|
5
|
-
import { type Project } from './Project.js';
|
|
5
|
+
import { type ProjectId, type Project } from './Project.js';
|
|
6
6
|
import type { GraphExecutionMetadata, InternalProcessContext, ProcessContext, ProcessId } from './ProcessContext.js';
|
|
7
7
|
import type { ExecutionRecorder } from '../recording/ExecutionRecorder.js';
|
|
8
8
|
import type { Tagged } from 'type-fest';
|
|
9
9
|
import type { NodeRegistration } from './NodeRegistration.js';
|
|
10
|
+
import { type GraphExecutionPlan } from './GraphPreprocessor.js';
|
|
10
11
|
type WithExecution<T extends object> = T & {
|
|
11
12
|
execution: GraphExecutionMetadata;
|
|
12
13
|
};
|
|
@@ -140,6 +141,12 @@ export type GraphProcessorConcurrency = {
|
|
|
140
141
|
nodeConcurrency?: number;
|
|
141
142
|
splitRunConcurrency?: number;
|
|
142
143
|
};
|
|
144
|
+
export type GraphProcessorRuntimeCache = {
|
|
145
|
+
executionPlans?: WeakMap<NodeGraph, GraphExecutionPlan>;
|
|
146
|
+
loadedProjects?: Record<ProjectId, Project>;
|
|
147
|
+
};
|
|
148
|
+
export type GraphProcessorExecutionPlanCacheMode = 'all' | 'subprocessors';
|
|
149
|
+
export type GraphProcessorScheduler = 'compatible' | 'fast-acyclic';
|
|
143
150
|
export declare const DEFAULT_SPLIT_RUN_CONCURRENCY = 4;
|
|
144
151
|
export type RaceId = Tagged<string, 'RaceId'>;
|
|
145
152
|
export type LoopInfo = AttachedNodeDataItem & {
|
|
@@ -175,7 +182,11 @@ export declare class GraphProcessor {
|
|
|
175
182
|
warnOnInvalidGraph: boolean;
|
|
176
183
|
get isRunning(): boolean;
|
|
177
184
|
constructor(project: Project, graphId: GraphId | undefined, registry: NodeRegistration<any, any>, includeTrace?: boolean, options?: {
|
|
185
|
+
cacheLoadedProjects?: boolean;
|
|
178
186
|
concurrency?: GraphProcessorConcurrency;
|
|
187
|
+
executionPlanCacheMode?: GraphProcessorExecutionPlanCacheMode;
|
|
188
|
+
runtimeCache?: GraphProcessorRuntimeCache;
|
|
189
|
+
scheduler?: GraphProcessorScheduler;
|
|
179
190
|
});
|
|
180
191
|
on: Emittery<ProcessEvents>["on"];
|
|
181
192
|
off: Emittery<ProcessEvents>["off"];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ControlFlowExcludedDataValue, type DataValue } from './DataValue.js';
|
|
2
|
+
import { type ChartNode, type NodeInputDefinition, type NodeOutputDefinition, type PortId } from './NodeBase.js';
|
|
3
|
+
type NodePortValues = Record<PortId, DataValue | undefined>;
|
|
4
|
+
export type NodeExclusionReason = 'disabled' | 'if port is false' | 'input is excluded value' | 'missing required input';
|
|
5
|
+
export type NodeExclusionDecision = {
|
|
6
|
+
action: 'continue' | 'defer';
|
|
7
|
+
} | {
|
|
8
|
+
action: 'exclude';
|
|
9
|
+
reason: NodeExclusionReason;
|
|
10
|
+
traceMessage: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function getControlFlowExclusionDecision({ inputValues, node, typeOfExclusion, }: {
|
|
13
|
+
inputValues: NodePortValues;
|
|
14
|
+
node: ChartNode;
|
|
15
|
+
typeOfExclusion?: ControlFlowExcludedDataValue['value'];
|
|
16
|
+
}): NodeExclusionDecision;
|
|
17
|
+
export declare function getMissingRequiredInputExclusion(node: ChartNode, missingRequiredInputs: NodeInputDefinition[]): Extract<NodeExclusionDecision, {
|
|
18
|
+
action: 'exclude';
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createExcludedNodeOutputs(node: ChartNode, outputDefinitions: NodeOutputDefinition[]): NodePortValues;
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChartNode, NodeConnection, NodeId, NodeInputDefinition, NodeOutputDefinition } from './NodeBase.js';
|
|
2
2
|
import type { Inputs } from './GraphProcessor.js';
|
|
3
|
+
import type { GraphExecutionPlan, GraphOutputNodeResult } from './GraphPreprocessor.js';
|
|
3
4
|
export type ExecutionState = {
|
|
4
5
|
connections: Record<NodeId, NodeConnection[]>;
|
|
5
6
|
definitions: Record<NodeId, {
|
|
@@ -7,19 +8,13 @@ export type ExecutionState = {
|
|
|
7
8
|
outputs: NodeOutputDefinition[];
|
|
8
9
|
}>;
|
|
9
10
|
erroredNodes: Map<NodeId, Error | string>;
|
|
11
|
+
executionPlan?: GraphExecutionPlan;
|
|
10
12
|
loopControllersSeen: Set<NodeId>;
|
|
11
13
|
nodesById: Record<NodeId, ChartNode>;
|
|
12
14
|
stronglyConnectedComponents: ChartNode[][];
|
|
13
15
|
visitedNodes: Set<NodeId>;
|
|
14
16
|
};
|
|
15
|
-
export type OutputNodeResult =
|
|
16
|
-
nodes: ChartNode[];
|
|
17
|
-
connections: NodeConnection[];
|
|
18
|
-
connectionsToNodes: {
|
|
19
|
-
connections: NodeConnection[];
|
|
20
|
-
node: ChartNode;
|
|
21
|
-
}[];
|
|
22
|
-
};
|
|
17
|
+
export type OutputNodeResult = GraphOutputNodeResult;
|
|
23
18
|
export declare function getStartNodes(state: ExecutionState, graphNodes: ChartNode[], runToNodeIds?: NodeId[]): ChartNode[];
|
|
24
19
|
export declare function getInputNodesTo(state: ExecutionState, node: ChartNode): ChartNode[];
|
|
25
20
|
export declare function getOutputNodesFrom(state: ExecutionState, node: ChartNode): OutputNodeResult;
|
|
@@ -7,6 +7,7 @@ export * from './nodes/LLMChatV2Node.js';
|
|
|
7
7
|
export * from './nodes/PromptNode.js';
|
|
8
8
|
export * from './nodes/ExtractRegexNode.js';
|
|
9
9
|
export * from './nodes/CodeNode.js';
|
|
10
|
+
export * from './nodes/CodeNewNode.js';
|
|
10
11
|
export * from './nodes/ExpressionNode.js';
|
|
11
12
|
export * from './nodes/MatchNode.js';
|
|
12
13
|
export * from './nodes/IfNode.js';
|
|
@@ -88,12 +89,12 @@ export * from './nodes/MCPDiscoveryNode.js';
|
|
|
88
89
|
export * from './nodes/MCPToolCallNode.js';
|
|
89
90
|
export * from './nodes/MCPGetPromptNode.js';
|
|
90
91
|
export * from './nodes/ReferencedGraphAliasNode.js';
|
|
91
|
-
export declare const registerBuiltInNodes: (registry: NodeRegistration) => NodeRegistration<"number" | "boolean" | "object" | "pop" | "join" | "slice" | "filter" | "match" | "split" | "image" | "audio" | "document" | "if" | "code" | "text" | "context" | "array" | "userInput" | "prompt" | "raiseEvent" | "getGlobal" | "setGlobal" | "abortGraph" | "chat" | "llmChatV2" | "extractRegex" | "expression" | "readDirectory" | "readFile" | "ifElse" | "chunk" | "graphInput" | "graphOutput" | "subGraph" | "extractJson" | "assemblePrompt" | "extractYaml" | "loopController" | "trimChatMessages" | "externalCall" | "extractObjectPath" | "coalesce" | "didRun" | "passthrough" | "waitForEvent" | "gptFunction" | "toYaml" | "getEmbedding" | "vectorStore" | "vectorNearestNeighbors" | "hash" | "raceInputs" | "toJson" | "jsFilter" | "jsMap" | "compare" | "evaluate" | "randomNumber" | "shuffle" | "comment" | "httpCall" | "delay" | "appendToDataset" | "createDataset" | "loadDataset" | "getAllDatasets" | "datasetNearestNeighbors" | "getDatasetRow" | "extractMarkdownCodeBlocks" | "assembleMessage" | "urlReference" | "destructure" | "replaceDataset" | "listGraphs" | "graphReference" | "callGraph" | "delegateFunctionCall" | "playAudio" | "chatLoop" | "readAllFiles" | "toMarkdownTable" | "cron" | "toTree" | "loopUntil" | "mcpDiscovery" | "mcpToolCall" | "mcpGetPrompt" | "referencedGraphAlias", import("./nodes/UserInputNode.js").UserInputNode | import("./nodes/TextNode.js").TextNode | import("./nodes/ChatNode.js").ChatNode | import("./chat-v2/llmChatV2NodeData.js").LLMChatV2Node | import("./nodes/PromptNode.js").PromptNode | import("./nodes/ExtractRegexNode.js").ExtractRegexNode | import("./nodes/CodeNode.js").CodeNode | import("./nodes/ExpressionNode.js").ExpressionNode | import("./nodes/MatchNode.js").MatchNode | import("./nodes/IfNode.js").IfNode | import("./nodes/ReadDirectoryNode.js").ReadDirectoryNode | import("./nodes/ReadFileNode.js").ReadFileNode | import("./nodes/IfElseNode.js").IfElseNode | import("./nodes/ChunkNode.js").ChunkNode | import("./nodes/GraphInputNode.js").GraphInputNode | import("./nodes/GraphOutputNode.js").GraphOutputNode | import("./nodes/SubGraphNode.js").SubGraphNode | import("./nodes/ArrayNode.js").ArrayNode | import("./nodes/ExtractJsonNode.js").ExtractJsonNode | import("./nodes/AssemblePromptNode.js").AssemblePromptNode | import("./nodes/ExtractYamlNode.js").ExtractYamlNode | import("./nodes/LoopControllerNode.js").LoopControllerNode | import("./nodes/TrimChatMessagesNode.js").TrimChatMessagesNode | import("./nodes/ExternalCallNode.js").ExternalCallNode | import("./nodes/ExtractObjectPathNode.js").ExtractObjectPathNode | import("./nodes/RaiseEventNode.js").RaiseEventNode | import("./nodes/ContextNode.js").ContextNode | import("./nodes/CoalesceNode.js").CoalesceNode | import("./nodes/DidRunNode.js").DidRunNode | import("./nodes/PassthroughNode.js").PassthroughNode | import("./nodes/PopNode.js").PopNode | import("./nodes/SetGlobalNode.js").SetGlobalNode | import("./nodes/GetGlobalNode.js").GetGlobalNode | import("./nodes/WaitForEventNode.js").WaitForEventNode | import("./nodes/ToolNode.js").GptFunctionNode | import("./nodes/ToYamlNode.js").ToYamlNode | import("./nodes/GetEmbeddingNode.js").GetEmbeddingNode | import("./nodes/VectorStoreNode.js").VectorStoreNode | import("./nodes/VectorNearestNeighborsNode.js").VectorNearestNeighborsNode | import("./nodes/HashNode.js").HashNode | import("./nodes/AbortGraphNode.js").AbortGraphNode | import("./nodes/RaceInputsNode.js").RaceInputsNode | import("./nodes/ToJsonNode.js").ToJsonNode | import("./nodes/JoinNode.js").JoinNode | import("./nodes/FilterNode.js").FilterNode | import("./nodes/JSFilterNode.js").JSFilterNode | import("./nodes/JSMapNode.js").JSMapNode | import("./nodes/ObjectNode.js").ObjectNode | import("./nodes/BooleanNode.js").BooleanNode | import("./nodes/CompareNode.js").CompareNode | import("./nodes/EvaluateNode.js").EvaluateNode | import("./nodes/NumberNode.js").NumberNode | import("./nodes/RandomNumberNode.js").RandomNumberNode | import("./nodes/ShuffleNode.js").ShuffleNode | import("./nodes/CommentNode.js").CommentNode | import("./nodes/ImageNode.js").ImageNode | import("./nodes/AudioNode.js").AudioNode | import("./nodes/HttpCallNode.js").HttpCallNode | import("./nodes/DelayNode.js").DelayNode | import("./nodes/AppendToDatasetNode.js").AppendToDatasetNode | import("./nodes/CreateDatasetNode.js").CreateDatasetNode | import("./nodes/LoadDatasetNode.js").LoadDatasetNode | import("./nodes/GetAllDatasetsNode.js").GetAllDatasetsNode | import("./nodes/SplitNode.js").SplitNode | import("./nodes/DatasetNearestNeigborsNode.js").DatasetNearestNeighborsNode | import("./nodes/GetDatasetRowNode.js").GetDatasetRowNode | import("./nodes/SliceNode.js").SliceNode | import("./nodes/ExtractMarkdownCodeBlocksNode.js").ExtractMarkdownCodeBlocksNode | import("./nodes/AssembleMessageNode.js").AssembleMessageNode | import("./nodes/URLReferenceNode.js").UrlReferenceNode | import("./nodes/DestructureNode.js").DestructureNode | import("./nodes/ReplaceDatasetNode.js").ReplaceDatasetNode | import("./nodes/ListGraphsNode.js").ListGraphsNode | import("./nodes/GraphReferenceNode.js").GraphReferenceNode | import("./nodes/CallGraphNode.js").CallGraphNode | import("./nodes/DelegateFunctionCallNode.js").DelegateFunctionCallNode | import("./nodes/PlayAudioNode.js").PlayAudioNode | import("./nodes/DocumentNode.js").DocumentNode | import("./nodes/ChatLoopNode.js").ChatLoopNode | import("./nodes/ReadAllFilesNode.js").ReadAllFilesNode | import("./nodes/ToMarkdownTableNode.js").ToMarkdownTableNode | import("./nodes/CronNode.js").CronNode | import("./nodes/ToTreeNode.js").ToTreeNode | import("./nodes/LoopUntilNode.js").LoopUntilNode | (import("./NodeBase.js").NodeBase & {
|
|
92
|
+
export declare const registerBuiltInNodes: (registry: NodeRegistration) => NodeRegistration<"number" | "boolean" | "object" | "pop" | "join" | "slice" | "filter" | "match" | "split" | "image" | "audio" | "document" | "if" | "code" | "text" | "context" | "array" | "codeNew" | "userInput" | "prompt" | "raiseEvent" | "getGlobal" | "setGlobal" | "abortGraph" | "chat" | "llmChatV2" | "extractRegex" | "expression" | "readDirectory" | "readFile" | "ifElse" | "chunk" | "graphInput" | "graphOutput" | "subGraph" | "extractJson" | "assemblePrompt" | "extractYaml" | "loopController" | "trimChatMessages" | "externalCall" | "extractObjectPath" | "coalesce" | "didRun" | "passthrough" | "waitForEvent" | "gptFunction" | "toYaml" | "getEmbedding" | "vectorStore" | "vectorNearestNeighbors" | "hash" | "raceInputs" | "toJson" | "jsFilter" | "jsMap" | "compare" | "evaluate" | "randomNumber" | "shuffle" | "comment" | "httpCall" | "delay" | "appendToDataset" | "createDataset" | "loadDataset" | "getAllDatasets" | "datasetNearestNeighbors" | "getDatasetRow" | "extractMarkdownCodeBlocks" | "assembleMessage" | "urlReference" | "destructure" | "replaceDataset" | "listGraphs" | "graphReference" | "callGraph" | "delegateFunctionCall" | "playAudio" | "chatLoop" | "readAllFiles" | "toMarkdownTable" | "cron" | "toTree" | "loopUntil" | "mcpDiscovery" | "mcpToolCall" | "mcpGetPrompt" | "referencedGraphAlias", import("./nodes/UserInputNode.js").UserInputNode | import("./nodes/TextNode.js").TextNode | import("./nodes/ChatNode.js").ChatNode | import("./chat-v2/llmChatV2NodeData.js").LLMChatV2Node | import("./nodes/PromptNode.js").PromptNode | import("./nodes/ExtractRegexNode.js").ExtractRegexNode | import("./nodes/CodeNode.js").CodeNode | import("./nodes/CodeNewNode.js").CodeNewNode | import("./nodes/ExpressionNode.js").ExpressionNode | import("./nodes/MatchNode.js").MatchNode | import("./nodes/IfNode.js").IfNode | import("./nodes/ReadDirectoryNode.js").ReadDirectoryNode | import("./nodes/ReadFileNode.js").ReadFileNode | import("./nodes/IfElseNode.js").IfElseNode | import("./nodes/ChunkNode.js").ChunkNode | import("./nodes/GraphInputNode.js").GraphInputNode | import("./nodes/GraphOutputNode.js").GraphOutputNode | import("./nodes/SubGraphNode.js").SubGraphNode | import("./nodes/ArrayNode.js").ArrayNode | import("./nodes/ExtractJsonNode.js").ExtractJsonNode | import("./nodes/AssemblePromptNode.js").AssemblePromptNode | import("./nodes/ExtractYamlNode.js").ExtractYamlNode | import("./nodes/LoopControllerNode.js").LoopControllerNode | import("./nodes/TrimChatMessagesNode.js").TrimChatMessagesNode | import("./nodes/ExternalCallNode.js").ExternalCallNode | import("./nodes/ExtractObjectPathNode.js").ExtractObjectPathNode | import("./nodes/RaiseEventNode.js").RaiseEventNode | import("./nodes/ContextNode.js").ContextNode | import("./nodes/CoalesceNode.js").CoalesceNode | import("./nodes/DidRunNode.js").DidRunNode | import("./nodes/PassthroughNode.js").PassthroughNode | import("./nodes/PopNode.js").PopNode | import("./nodes/SetGlobalNode.js").SetGlobalNode | import("./nodes/GetGlobalNode.js").GetGlobalNode | import("./nodes/WaitForEventNode.js").WaitForEventNode | import("./nodes/ToolNode.js").GptFunctionNode | import("./nodes/ToYamlNode.js").ToYamlNode | import("./nodes/GetEmbeddingNode.js").GetEmbeddingNode | import("./nodes/VectorStoreNode.js").VectorStoreNode | import("./nodes/VectorNearestNeighborsNode.js").VectorNearestNeighborsNode | import("./nodes/HashNode.js").HashNode | import("./nodes/AbortGraphNode.js").AbortGraphNode | import("./nodes/RaceInputsNode.js").RaceInputsNode | import("./nodes/ToJsonNode.js").ToJsonNode | import("./nodes/JoinNode.js").JoinNode | import("./nodes/FilterNode.js").FilterNode | import("./nodes/JSFilterNode.js").JSFilterNode | import("./nodes/JSMapNode.js").JSMapNode | import("./nodes/ObjectNode.js").ObjectNode | import("./nodes/BooleanNode.js").BooleanNode | import("./nodes/CompareNode.js").CompareNode | import("./nodes/EvaluateNode.js").EvaluateNode | import("./nodes/NumberNode.js").NumberNode | import("./nodes/RandomNumberNode.js").RandomNumberNode | import("./nodes/ShuffleNode.js").ShuffleNode | import("./nodes/CommentNode.js").CommentNode | import("./nodes/ImageNode.js").ImageNode | import("./nodes/AudioNode.js").AudioNode | import("./nodes/HttpCallNode.js").HttpCallNode | import("./nodes/DelayNode.js").DelayNode | import("./nodes/AppendToDatasetNode.js").AppendToDatasetNode | import("./nodes/CreateDatasetNode.js").CreateDatasetNode | import("./nodes/LoadDatasetNode.js").LoadDatasetNode | import("./nodes/GetAllDatasetsNode.js").GetAllDatasetsNode | import("./nodes/SplitNode.js").SplitNode | import("./nodes/DatasetNearestNeigborsNode.js").DatasetNearestNeighborsNode | import("./nodes/GetDatasetRowNode.js").GetDatasetRowNode | import("./nodes/SliceNode.js").SliceNode | import("./nodes/ExtractMarkdownCodeBlocksNode.js").ExtractMarkdownCodeBlocksNode | import("./nodes/AssembleMessageNode.js").AssembleMessageNode | import("./nodes/URLReferenceNode.js").UrlReferenceNode | import("./nodes/DestructureNode.js").DestructureNode | import("./nodes/ReplaceDatasetNode.js").ReplaceDatasetNode | import("./nodes/ListGraphsNode.js").ListGraphsNode | import("./nodes/GraphReferenceNode.js").GraphReferenceNode | import("./nodes/CallGraphNode.js").CallGraphNode | import("./nodes/DelegateFunctionCallNode.js").DelegateFunctionCallNode | import("./nodes/PlayAudioNode.js").PlayAudioNode | import("./nodes/DocumentNode.js").DocumentNode | import("./nodes/ChatLoopNode.js").ChatLoopNode | import("./nodes/ReadAllFilesNode.js").ReadAllFilesNode | import("./nodes/ToMarkdownTableNode.js").ToMarkdownTableNode | import("./nodes/CronNode.js").CronNode | import("./nodes/ToTreeNode.js").ToTreeNode | import("./nodes/LoopUntilNode.js").LoopUntilNode | (import("./NodeBase.js").NodeBase & {
|
|
92
93
|
type: "mcpDiscovery";
|
|
93
94
|
data: import("./nodes/MCPDiscoveryNode.js").MCPDiscoveryNodeData;
|
|
94
95
|
variants?: import("./NodeBase.js").ChartNodeVariant<import("./nodes/MCPDiscoveryNode.js").MCPDiscoveryNodeData>[] | undefined;
|
|
95
96
|
}) | import("./nodes/MCPToolCallNode.js").MCPToolCallNode | import("./nodes/MCPGetPromptNode.js").MCPGetPromptNode | import("./nodes/ReferencedGraphAliasNode.js").ReferencedGraphAliasNode>;
|
|
96
|
-
declare let globalRivetNodeRegistry: NodeRegistration<"number" | "boolean" | "object" | "pop" | "join" | "slice" | "filter" | "match" | "split" | "image" | "audio" | "document" | "if" | "code" | "text" | "context" | "array" | "userInput" | "prompt" | "raiseEvent" | "getGlobal" | "setGlobal" | "abortGraph" | "chat" | "llmChatV2" | "extractRegex" | "expression" | "readDirectory" | "readFile" | "ifElse" | "chunk" | "graphInput" | "graphOutput" | "subGraph" | "extractJson" | "assemblePrompt" | "extractYaml" | "loopController" | "trimChatMessages" | "externalCall" | "extractObjectPath" | "coalesce" | "didRun" | "passthrough" | "waitForEvent" | "gptFunction" | "toYaml" | "getEmbedding" | "vectorStore" | "vectorNearestNeighbors" | "hash" | "raceInputs" | "toJson" | "jsFilter" | "jsMap" | "compare" | "evaluate" | "randomNumber" | "shuffle" | "comment" | "httpCall" | "delay" | "appendToDataset" | "createDataset" | "loadDataset" | "getAllDatasets" | "datasetNearestNeighbors" | "getDatasetRow" | "extractMarkdownCodeBlocks" | "assembleMessage" | "urlReference" | "destructure" | "replaceDataset" | "listGraphs" | "graphReference" | "callGraph" | "delegateFunctionCall" | "playAudio" | "chatLoop" | "readAllFiles" | "toMarkdownTable" | "cron" | "toTree" | "loopUntil" | "mcpDiscovery" | "mcpToolCall" | "mcpGetPrompt" | "referencedGraphAlias", import("./nodes/UserInputNode.js").UserInputNode | import("./nodes/TextNode.js").TextNode | import("./nodes/ChatNode.js").ChatNode | import("./chat-v2/llmChatV2NodeData.js").LLMChatV2Node | import("./nodes/PromptNode.js").PromptNode | import("./nodes/ExtractRegexNode.js").ExtractRegexNode | import("./nodes/CodeNode.js").CodeNode | import("./nodes/ExpressionNode.js").ExpressionNode | import("./nodes/MatchNode.js").MatchNode | import("./nodes/IfNode.js").IfNode | import("./nodes/ReadDirectoryNode.js").ReadDirectoryNode | import("./nodes/ReadFileNode.js").ReadFileNode | import("./nodes/IfElseNode.js").IfElseNode | import("./nodes/ChunkNode.js").ChunkNode | import("./nodes/GraphInputNode.js").GraphInputNode | import("./nodes/GraphOutputNode.js").GraphOutputNode | import("./nodes/SubGraphNode.js").SubGraphNode | import("./nodes/ArrayNode.js").ArrayNode | import("./nodes/ExtractJsonNode.js").ExtractJsonNode | import("./nodes/AssemblePromptNode.js").AssemblePromptNode | import("./nodes/ExtractYamlNode.js").ExtractYamlNode | import("./nodes/LoopControllerNode.js").LoopControllerNode | import("./nodes/TrimChatMessagesNode.js").TrimChatMessagesNode | import("./nodes/ExternalCallNode.js").ExternalCallNode | import("./nodes/ExtractObjectPathNode.js").ExtractObjectPathNode | import("./nodes/RaiseEventNode.js").RaiseEventNode | import("./nodes/ContextNode.js").ContextNode | import("./nodes/CoalesceNode.js").CoalesceNode | import("./nodes/DidRunNode.js").DidRunNode | import("./nodes/PassthroughNode.js").PassthroughNode | import("./nodes/PopNode.js").PopNode | import("./nodes/SetGlobalNode.js").SetGlobalNode | import("./nodes/GetGlobalNode.js").GetGlobalNode | import("./nodes/WaitForEventNode.js").WaitForEventNode | import("./nodes/ToolNode.js").GptFunctionNode | import("./nodes/ToYamlNode.js").ToYamlNode | import("./nodes/GetEmbeddingNode.js").GetEmbeddingNode | import("./nodes/VectorStoreNode.js").VectorStoreNode | import("./nodes/VectorNearestNeighborsNode.js").VectorNearestNeighborsNode | import("./nodes/HashNode.js").HashNode | import("./nodes/AbortGraphNode.js").AbortGraphNode | import("./nodes/RaceInputsNode.js").RaceInputsNode | import("./nodes/ToJsonNode.js").ToJsonNode | import("./nodes/JoinNode.js").JoinNode | import("./nodes/FilterNode.js").FilterNode | import("./nodes/JSFilterNode.js").JSFilterNode | import("./nodes/JSMapNode.js").JSMapNode | import("./nodes/ObjectNode.js").ObjectNode | import("./nodes/BooleanNode.js").BooleanNode | import("./nodes/CompareNode.js").CompareNode | import("./nodes/EvaluateNode.js").EvaluateNode | import("./nodes/NumberNode.js").NumberNode | import("./nodes/RandomNumberNode.js").RandomNumberNode | import("./nodes/ShuffleNode.js").ShuffleNode | import("./nodes/CommentNode.js").CommentNode | import("./nodes/ImageNode.js").ImageNode | import("./nodes/AudioNode.js").AudioNode | import("./nodes/HttpCallNode.js").HttpCallNode | import("./nodes/DelayNode.js").DelayNode | import("./nodes/AppendToDatasetNode.js").AppendToDatasetNode | import("./nodes/CreateDatasetNode.js").CreateDatasetNode | import("./nodes/LoadDatasetNode.js").LoadDatasetNode | import("./nodes/GetAllDatasetsNode.js").GetAllDatasetsNode | import("./nodes/SplitNode.js").SplitNode | import("./nodes/DatasetNearestNeigborsNode.js").DatasetNearestNeighborsNode | import("./nodes/GetDatasetRowNode.js").GetDatasetRowNode | import("./nodes/SliceNode.js").SliceNode | import("./nodes/ExtractMarkdownCodeBlocksNode.js").ExtractMarkdownCodeBlocksNode | import("./nodes/AssembleMessageNode.js").AssembleMessageNode | import("./nodes/URLReferenceNode.js").UrlReferenceNode | import("./nodes/DestructureNode.js").DestructureNode | import("./nodes/ReplaceDatasetNode.js").ReplaceDatasetNode | import("./nodes/ListGraphsNode.js").ListGraphsNode | import("./nodes/GraphReferenceNode.js").GraphReferenceNode | import("./nodes/CallGraphNode.js").CallGraphNode | import("./nodes/DelegateFunctionCallNode.js").DelegateFunctionCallNode | import("./nodes/PlayAudioNode.js").PlayAudioNode | import("./nodes/DocumentNode.js").DocumentNode | import("./nodes/ChatLoopNode.js").ChatLoopNode | import("./nodes/ReadAllFilesNode.js").ReadAllFilesNode | import("./nodes/ToMarkdownTableNode.js").ToMarkdownTableNode | import("./nodes/CronNode.js").CronNode | import("./nodes/ToTreeNode.js").ToTreeNode | import("./nodes/LoopUntilNode.js").LoopUntilNode | (import("./NodeBase.js").NodeBase & {
|
|
97
|
+
declare let globalRivetNodeRegistry: NodeRegistration<"number" | "boolean" | "object" | "pop" | "join" | "slice" | "filter" | "match" | "split" | "image" | "audio" | "document" | "if" | "code" | "text" | "context" | "array" | "codeNew" | "userInput" | "prompt" | "raiseEvent" | "getGlobal" | "setGlobal" | "abortGraph" | "chat" | "llmChatV2" | "extractRegex" | "expression" | "readDirectory" | "readFile" | "ifElse" | "chunk" | "graphInput" | "graphOutput" | "subGraph" | "extractJson" | "assemblePrompt" | "extractYaml" | "loopController" | "trimChatMessages" | "externalCall" | "extractObjectPath" | "coalesce" | "didRun" | "passthrough" | "waitForEvent" | "gptFunction" | "toYaml" | "getEmbedding" | "vectorStore" | "vectorNearestNeighbors" | "hash" | "raceInputs" | "toJson" | "jsFilter" | "jsMap" | "compare" | "evaluate" | "randomNumber" | "shuffle" | "comment" | "httpCall" | "delay" | "appendToDataset" | "createDataset" | "loadDataset" | "getAllDatasets" | "datasetNearestNeighbors" | "getDatasetRow" | "extractMarkdownCodeBlocks" | "assembleMessage" | "urlReference" | "destructure" | "replaceDataset" | "listGraphs" | "graphReference" | "callGraph" | "delegateFunctionCall" | "playAudio" | "chatLoop" | "readAllFiles" | "toMarkdownTable" | "cron" | "toTree" | "loopUntil" | "mcpDiscovery" | "mcpToolCall" | "mcpGetPrompt" | "referencedGraphAlias", import("./nodes/UserInputNode.js").UserInputNode | import("./nodes/TextNode.js").TextNode | import("./nodes/ChatNode.js").ChatNode | import("./chat-v2/llmChatV2NodeData.js").LLMChatV2Node | import("./nodes/PromptNode.js").PromptNode | import("./nodes/ExtractRegexNode.js").ExtractRegexNode | import("./nodes/CodeNode.js").CodeNode | import("./nodes/CodeNewNode.js").CodeNewNode | import("./nodes/ExpressionNode.js").ExpressionNode | import("./nodes/MatchNode.js").MatchNode | import("./nodes/IfNode.js").IfNode | import("./nodes/ReadDirectoryNode.js").ReadDirectoryNode | import("./nodes/ReadFileNode.js").ReadFileNode | import("./nodes/IfElseNode.js").IfElseNode | import("./nodes/ChunkNode.js").ChunkNode | import("./nodes/GraphInputNode.js").GraphInputNode | import("./nodes/GraphOutputNode.js").GraphOutputNode | import("./nodes/SubGraphNode.js").SubGraphNode | import("./nodes/ArrayNode.js").ArrayNode | import("./nodes/ExtractJsonNode.js").ExtractJsonNode | import("./nodes/AssemblePromptNode.js").AssemblePromptNode | import("./nodes/ExtractYamlNode.js").ExtractYamlNode | import("./nodes/LoopControllerNode.js").LoopControllerNode | import("./nodes/TrimChatMessagesNode.js").TrimChatMessagesNode | import("./nodes/ExternalCallNode.js").ExternalCallNode | import("./nodes/ExtractObjectPathNode.js").ExtractObjectPathNode | import("./nodes/RaiseEventNode.js").RaiseEventNode | import("./nodes/ContextNode.js").ContextNode | import("./nodes/CoalesceNode.js").CoalesceNode | import("./nodes/DidRunNode.js").DidRunNode | import("./nodes/PassthroughNode.js").PassthroughNode | import("./nodes/PopNode.js").PopNode | import("./nodes/SetGlobalNode.js").SetGlobalNode | import("./nodes/GetGlobalNode.js").GetGlobalNode | import("./nodes/WaitForEventNode.js").WaitForEventNode | import("./nodes/ToolNode.js").GptFunctionNode | import("./nodes/ToYamlNode.js").ToYamlNode | import("./nodes/GetEmbeddingNode.js").GetEmbeddingNode | import("./nodes/VectorStoreNode.js").VectorStoreNode | import("./nodes/VectorNearestNeighborsNode.js").VectorNearestNeighborsNode | import("./nodes/HashNode.js").HashNode | import("./nodes/AbortGraphNode.js").AbortGraphNode | import("./nodes/RaceInputsNode.js").RaceInputsNode | import("./nodes/ToJsonNode.js").ToJsonNode | import("./nodes/JoinNode.js").JoinNode | import("./nodes/FilterNode.js").FilterNode | import("./nodes/JSFilterNode.js").JSFilterNode | import("./nodes/JSMapNode.js").JSMapNode | import("./nodes/ObjectNode.js").ObjectNode | import("./nodes/BooleanNode.js").BooleanNode | import("./nodes/CompareNode.js").CompareNode | import("./nodes/EvaluateNode.js").EvaluateNode | import("./nodes/NumberNode.js").NumberNode | import("./nodes/RandomNumberNode.js").RandomNumberNode | import("./nodes/ShuffleNode.js").ShuffleNode | import("./nodes/CommentNode.js").CommentNode | import("./nodes/ImageNode.js").ImageNode | import("./nodes/AudioNode.js").AudioNode | import("./nodes/HttpCallNode.js").HttpCallNode | import("./nodes/DelayNode.js").DelayNode | import("./nodes/AppendToDatasetNode.js").AppendToDatasetNode | import("./nodes/CreateDatasetNode.js").CreateDatasetNode | import("./nodes/LoadDatasetNode.js").LoadDatasetNode | import("./nodes/GetAllDatasetsNode.js").GetAllDatasetsNode | import("./nodes/SplitNode.js").SplitNode | import("./nodes/DatasetNearestNeigborsNode.js").DatasetNearestNeighborsNode | import("./nodes/GetDatasetRowNode.js").GetDatasetRowNode | import("./nodes/SliceNode.js").SliceNode | import("./nodes/ExtractMarkdownCodeBlocksNode.js").ExtractMarkdownCodeBlocksNode | import("./nodes/AssembleMessageNode.js").AssembleMessageNode | import("./nodes/URLReferenceNode.js").UrlReferenceNode | import("./nodes/DestructureNode.js").DestructureNode | import("./nodes/ReplaceDatasetNode.js").ReplaceDatasetNode | import("./nodes/ListGraphsNode.js").ListGraphsNode | import("./nodes/GraphReferenceNode.js").GraphReferenceNode | import("./nodes/CallGraphNode.js").CallGraphNode | import("./nodes/DelegateFunctionCallNode.js").DelegateFunctionCallNode | import("./nodes/PlayAudioNode.js").PlayAudioNode | import("./nodes/DocumentNode.js").DocumentNode | import("./nodes/ChatLoopNode.js").ChatLoopNode | import("./nodes/ReadAllFilesNode.js").ReadAllFilesNode | import("./nodes/ToMarkdownTableNode.js").ToMarkdownTableNode | import("./nodes/CronNode.js").CronNode | import("./nodes/ToTreeNode.js").ToTreeNode | import("./nodes/LoopUntilNode.js").LoopUntilNode | (import("./NodeBase.js").NodeBase & {
|
|
97
98
|
type: "mcpDiscovery";
|
|
98
99
|
data: import("./nodes/MCPDiscoveryNode.js").MCPDiscoveryNodeData;
|
|
99
100
|
variants?: import("./NodeBase.js").ChartNodeVariant<import("./nodes/MCPDiscoveryNode.js").MCPDiscoveryNodeData>[] | undefined;
|
|
@@ -14,7 +14,7 @@ export type ProcessContext = {
|
|
|
14
14
|
audioProvider?: AudioProvider;
|
|
15
15
|
/** The tokenizer that will be used for all nodes. */
|
|
16
16
|
tokenizer: Tokenizer;
|
|
17
|
-
/** The provider for running arbitrary code in
|
|
17
|
+
/** The provider for running arbitrary code in Code-family nodes. */
|
|
18
18
|
codeRunner?: CodeRunner;
|
|
19
19
|
/** The loader for loading project references. */
|
|
20
20
|
projectReferenceLoader?: ProjectReferenceLoader;
|
|
@@ -105,6 +105,6 @@ export type InternalProcessContext<T extends ChartNode = ChartNode> = ProcessCon
|
|
|
105
105
|
getPluginConfig(name: string): string | undefined;
|
|
106
106
|
/** Requests that the user input some text in response to the specified prompt. */
|
|
107
107
|
requestUserInput(inputs: string[], renderingType: 'text' | 'markdown'): Promise<StringArrayDataValue>;
|
|
108
|
-
/** The object used for running arbitrary code with
|
|
108
|
+
/** The object used for running arbitrary code with Code-family nodes. */
|
|
109
109
|
codeRunner: CodeRunner;
|
|
110
110
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LanguageModelUsage } from 'ai';
|
|
2
|
+
import type { ChatMessage } from '../DataValue.js';
|
|
3
|
+
import type { Outputs } from '../GraphProcessor.js';
|
|
4
|
+
import { type StreamedFunctionCall } from '../chat/streamChatResponse.js';
|
|
5
|
+
import type { ChatV2NormalizedUsage, ChatV2ReasoningOutput, RunChatV2PipelineOptions } from './chatV2Types.js';
|
|
6
|
+
type ChatV2CommonOutputOptions = Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | 'outputRequestStatus' | 'includeFunctionCalls' | 'functionCallMode' | 'retryOnNon200' | 'responseFormat'>;
|
|
7
|
+
type CreateChatV2CommonOutputsOptions = ChatV2CommonOutputOptions & {
|
|
8
|
+
requestMessages: ChatMessage[];
|
|
9
|
+
response: string;
|
|
10
|
+
structuredOutput: unknown | undefined;
|
|
11
|
+
functionCalls: StreamedFunctionCall[];
|
|
12
|
+
usage: ChatV2NormalizedUsage | undefined;
|
|
13
|
+
reasoning: ChatV2ReasoningOutput | undefined;
|
|
14
|
+
requestStatus: number | undefined;
|
|
15
|
+
responseError: string | undefined;
|
|
16
|
+
requestStatuses: number[];
|
|
17
|
+
requestErrors: string[];
|
|
18
|
+
};
|
|
19
|
+
type CreateChatV2ProviderFailureOutputsOptions = Pick<RunChatV2PipelineOptions, 'outputUsage' | 'outputReasoning' | 'includeFunctionCalls' | 'retryOnNon200'> & {
|
|
20
|
+
requestMessages: ChatMessage[];
|
|
21
|
+
responseStatus: number | undefined;
|
|
22
|
+
responseError: string;
|
|
23
|
+
requestStatuses: number[];
|
|
24
|
+
requestErrors: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare function normalizeChatV2Usage(usage: LanguageModelUsage | undefined, options: Pick<RunChatV2PipelineOptions, 'provider' | 'modelId'>): ChatV2NormalizedUsage | undefined;
|
|
27
|
+
export declare function createChatV2CommonOutputs({ requestMessages, response, structuredOutput, functionCalls, usage, reasoning, requestStatus, responseError, requestStatuses, requestErrors, outputUsage, outputReasoning, outputRequestStatus, includeFunctionCalls, functionCallMode, retryOnNon200, responseFormat, }: CreateChatV2CommonOutputsOptions): Outputs;
|
|
28
|
+
export declare function createChatV2ProviderFailureOutputs({ requestMessages, responseStatus, responseError, requestStatuses, requestErrors, outputUsage, outputReasoning, includeFunctionCalls, retryOnNon200, }: CreateChatV2ProviderFailureOutputsOptions): Outputs;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChartNode, NodeInputDefinition, NodeOutputDefinition, PortId } from '../NodeBase.js';
|
|
2
|
+
import { type EditorDefinition } from '../EditorDefinition.js';
|
|
3
|
+
import type { Inputs, Outputs } from '../GraphProcessor.js';
|
|
4
|
+
import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
|
|
5
|
+
import { type NodeBodySpec } from '../NodeBodySpec.js';
|
|
6
|
+
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
7
|
+
export type CodeNewNode = ChartNode<'codeNew', CodeNewNodeData>;
|
|
8
|
+
export type CodeNewNodeData = {
|
|
9
|
+
code: string;
|
|
10
|
+
allowFetch?: boolean;
|
|
11
|
+
allowRequire?: boolean;
|
|
12
|
+
allowRivet?: boolean;
|
|
13
|
+
allowProcess?: boolean;
|
|
14
|
+
allowConsole?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const CODE_NEW_OUTPUT_PORT_ID: PortId;
|
|
17
|
+
export declare function interpolateCodeNewSource(code: string, inputs: Inputs): string;
|
|
18
|
+
export declare class CodeNewNodeImpl extends NodeImpl<CodeNewNode> {
|
|
19
|
+
static create(): CodeNewNode;
|
|
20
|
+
getInputDefinitions(): NodeInputDefinition[];
|
|
21
|
+
getOutputDefinitions(): NodeOutputDefinition[];
|
|
22
|
+
getEditors(): EditorDefinition<CodeNewNode>[];
|
|
23
|
+
getBody(): NodeBodySpec;
|
|
24
|
+
static getUIData(): NodeUIData;
|
|
25
|
+
process(inputs: Inputs, context: InternalProcessContext): Promise<Outputs>;
|
|
26
|
+
}
|
|
27
|
+
export declare const codeNewNode: import("../NodeDefinition.js").NodeDefinition<CodeNewNode>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { NodeId } from '../NodeBase.js';
|
|
2
|
-
|
|
3
|
-
export declare function buildCodeNodeSourceUrl(nodeId: NodeId, processId?: ProcessId): string;
|
|
2
|
+
export declare function buildCodeNodeSourceUrl(nodeId: NodeId): string;
|
|
4
3
|
export declare function appendCodeNodeSourceUrl(code: string, sourceUrl: string): string;
|
|
5
4
|
export declare function enrichCodeNodeErrorWithLocation(params: {
|
|
6
5
|
code: string;
|
|
6
|
+
diagnosticCode?: string;
|
|
7
7
|
error: unknown;
|
|
8
|
+
locationLabel?: string;
|
|
8
9
|
sourceUrl: string;
|
|
10
|
+
userCodeLineOffset?: number;
|
|
9
11
|
}): Promise<Error>;
|