@valerypopoff/rivet2-core 2.1.7 → 2.1.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 +3412 -1844
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +45 -4
- package/dist/esm/exports.js +2 -0
- package/dist/esm/integrations/KnowledgeStoreFieldPolicy.js +216 -0
- package/dist/esm/integrations/KnowledgeStoreProvider.js +14 -90
- package/dist/esm/integrations/ManagedKnowledgeStore.js +0 -8
- package/dist/esm/model/DataBusPorts.js +26 -0
- package/dist/esm/model/DataBusTopology.js +207 -0
- package/dist/esm/model/DataValue.js +22 -7
- package/dist/esm/model/GraphPreprocessor.js +9 -3
- package/dist/esm/model/GraphProcessor.js +163 -366
- package/dist/esm/model/NodeIO.js +1 -0
- package/dist/esm/model/NodePrefabResolver.js +16 -0
- package/dist/esm/model/Nodes.js +7 -0
- package/dist/esm/model/ToolCallContinuationBranchPlanner.js +165 -0
- package/dist/esm/model/ToolCallContinuationCoordinator.js +201 -0
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +140 -0
- package/dist/esm/model/chat-v2/chatV2Errors.js +23 -6
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +47 -14
- package/dist/esm/model/chat-v2/chatV2ProviderTypes.js +1 -0
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +2 -2
- package/dist/esm/model/chat-v2/index.js +1 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +52 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +38 -13
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +42 -34
- package/dist/esm/model/chat-v2/llmProfile.js +191 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +73 -0
- package/dist/esm/model/chat-v2/llmProfileTypes.js +45 -0
- package/dist/esm/model/nodes/DataBusNode.js +81 -0
- package/dist/esm/model/nodes/GetGlobalNode.js +7 -11
- package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +1 -1
- package/dist/esm/model/nodes/LLMChatV2Node.js +44 -10
- package/dist/esm/model/nodes/LLMProfileNode.js +132 -0
- package/dist/esm/model/nodes/PassthroughNode.js +1 -11
- package/dist/esm/model/nodes/SearchKnowledgeNode.js +1 -1
- package/dist/esm/model/nodes/SetGlobalNode.js +6 -6
- package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +0 -1
- package/dist/esm/model/nodes/toolCallDelegation.js +13 -2
- package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +0 -4
- package/dist/esm/plugins/pinecone/plugin.js +1 -1
- package/dist/esm/utils/coerceType.js +84 -41
- package/dist/esm/utils/expectType.js +45 -8
- package/dist/esm/utils/fetchEventSource.js +18 -0
- package/dist/esm/utils/serialization/serialization.js +18 -7
- package/dist/esm/vendor/fnv1a.js +6 -3
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/integrations/KnowledgeStore.d.ts +0 -2
- package/dist/types/integrations/KnowledgeStoreFieldPolicy.d.ts +38 -0
- package/dist/types/integrations/KnowledgeStoreProvider.d.ts +6 -3
- package/dist/types/model/DataBusPorts.d.ts +6 -0
- package/dist/types/model/DataBusTopology.d.ts +16 -0
- package/dist/types/model/DataValue.d.ts +15 -5
- package/dist/types/model/GraphPreprocessor.d.ts +2 -1
- package/dist/types/model/GraphProcessor.d.ts +4 -3
- package/dist/types/model/NodeIO.d.ts +5 -0
- package/dist/types/model/NodePrefabResolver.d.ts +9 -0
- package/dist/types/model/Nodes.d.ts +5 -2
- package/dist/types/model/ProcessContext.d.ts +60 -0
- package/dist/types/model/ToolCallContinuationBranchPlanner.d.ts +43 -0
- package/dist/types/model/ToolCallContinuationCoordinator.d.ts +70 -0
- package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +10 -0
- package/dist/types/model/chat-v2/chatV2ProviderTypes.d.ts +1 -0
- package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +8 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +3 -3
- package/dist/types/model/chat-v2/index.d.ts +1 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +6 -0
- package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +5 -1
- package/dist/types/model/chat-v2/llmProfile.d.ts +3 -0
- package/dist/types/model/chat-v2/llmProfileNodeRuntime.d.ts +9 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +18 -0
- package/dist/types/model/nodes/DataBusNode.d.ts +19 -0
- package/dist/types/model/nodes/LLMProfileNode.d.ts +20 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +2 -15
- package/dist/types/model/nodes/SetGlobalNode.d.ts +2 -2
- package/dist/types/model/nodes/toolCallDelegation.d.ts +9 -0
- package/dist/types/vendor/fnv1a.d.ts +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { parseDataBusChannelIndex } from './DataBusPorts.js';
|
|
2
|
+
function isDedicatedDataBusNode(node) {
|
|
3
|
+
return node?.type === 'dataBus';
|
|
4
|
+
}
|
|
5
|
+
export function isDataBusTopologyNode(node) {
|
|
6
|
+
return isDedicatedDataBusNode(node);
|
|
7
|
+
}
|
|
8
|
+
export function canRenderDataBusNode(node) {
|
|
9
|
+
return (isDataBusTopologyNode(node) &&
|
|
10
|
+
!node.isConditional &&
|
|
11
|
+
!node.isSplitRun &&
|
|
12
|
+
!node.disabled &&
|
|
13
|
+
(node.variants?.length ?? 0) === 0);
|
|
14
|
+
}
|
|
15
|
+
export function getDataBusChannelKey(busNodeId, channelIndex) {
|
|
16
|
+
return `${busNodeId}:${channelIndex}`;
|
|
17
|
+
}
|
|
18
|
+
export function getDataBusInputChannelIndex(portId) {
|
|
19
|
+
return parseDataBusChannelIndex(portId, true);
|
|
20
|
+
}
|
|
21
|
+
export function getDataBusOutputChannelIndex(portId) {
|
|
22
|
+
return parseDataBusChannelIndex(portId, false);
|
|
23
|
+
}
|
|
24
|
+
export function compileDataBusTopology(options) {
|
|
25
|
+
const nodesById = Object.fromEntries(options.graphNodes.map((node) => [node.id, node]));
|
|
26
|
+
const dataBusNodeIds = new Set(options.graphNodes.filter(isDataBusTopologyNode).map((node) => node.id));
|
|
27
|
+
if (dataBusNodeIds.size === 0) {
|
|
28
|
+
return {
|
|
29
|
+
connections: [...options.connections],
|
|
30
|
+
executionNodes: [...options.graphNodes],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
for (const nodeId of dataBusNodeIds) {
|
|
34
|
+
const node = nodesById[nodeId];
|
|
35
|
+
if (isDedicatedDataBusNode(node) &&
|
|
36
|
+
(node.isConditional || node.isSplitRun || node.disabled || node.variants?.length)) {
|
|
37
|
+
throw new Error(`Data Bus "${node.title}" cannot be conditional, run per item, disabled, or variant-driven. Data Bus channels are always-active topology.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const channelsByBusAndIndex = new Map();
|
|
41
|
+
const rawConnections = [...options.connections];
|
|
42
|
+
const directConnections = [];
|
|
43
|
+
const getMutableChannel = (busNodeId, channelIndex) => {
|
|
44
|
+
const key = getDataBusChannelKey(busNodeId, channelIndex);
|
|
45
|
+
const existing = channelsByBusAndIndex.get(key);
|
|
46
|
+
if (existing) {
|
|
47
|
+
return existing;
|
|
48
|
+
}
|
|
49
|
+
const channel = { busNodeId, channelIndex, providerConnections: [], consumerConnections: [] };
|
|
50
|
+
channelsByBusAndIndex.set(key, channel);
|
|
51
|
+
return channel;
|
|
52
|
+
};
|
|
53
|
+
for (const connection of rawConnections) {
|
|
54
|
+
const inputNode = nodesById[connection.inputNodeId];
|
|
55
|
+
const outputNode = nodesById[connection.outputNodeId];
|
|
56
|
+
const inputBus = isDataBusTopologyNode(inputNode) ? inputNode : undefined;
|
|
57
|
+
const outputBus = isDataBusTopologyNode(outputNode) ? outputNode : undefined;
|
|
58
|
+
if (!inputBus && !outputBus) {
|
|
59
|
+
directConnections.push(connection);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (inputBus) {
|
|
63
|
+
const channelIndex = getDataBusInputChannelIndex(connection.inputId);
|
|
64
|
+
if (channelIndex == null) {
|
|
65
|
+
throw new Error(`Data Bus "${inputBus.title}" has an invalid input port "${connection.inputId}".`);
|
|
66
|
+
}
|
|
67
|
+
getMutableChannel(inputBus.id, channelIndex).providerConnections.push(connection);
|
|
68
|
+
}
|
|
69
|
+
if (outputBus) {
|
|
70
|
+
const channelIndex = getDataBusOutputChannelIndex(connection.outputId);
|
|
71
|
+
if (channelIndex == null) {
|
|
72
|
+
throw new Error(`Data Bus "${outputBus.title}" has an invalid output port "${connection.outputId}".`);
|
|
73
|
+
}
|
|
74
|
+
getMutableChannel(outputBus.id, channelIndex).consumerConnections.push(connection);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const [key, channel] of channelsByBusAndIndex) {
|
|
78
|
+
if (channel.providerConnections.length > 1) {
|
|
79
|
+
throw new Error(`Data Bus channel ${key} has ${channel.providerConnections.length} providers. Connect exactly one provider.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Validate the relay graph independently of ordinary consumers. Without
|
|
83
|
+
// this pass, a closed bus-to-bus loop with no receiver would never be
|
|
84
|
+
// resolved below and could be saved as invalid, dormant topology.
|
|
85
|
+
const relayProviderByChannelKey = new Map();
|
|
86
|
+
for (const [key, channel] of channelsByBusAndIndex) {
|
|
87
|
+
const providerConnection = channel.providerConnections[0];
|
|
88
|
+
if (!providerConnection) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const providerNode = nodesById[providerConnection.outputNodeId];
|
|
92
|
+
if (!isDataBusTopologyNode(providerNode)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const providerChannelIndex = getDataBusOutputChannelIndex(providerConnection.outputId);
|
|
96
|
+
if (providerChannelIndex == null) {
|
|
97
|
+
throw new Error(`Data Bus "${providerNode.title}" has an invalid output port "${providerConnection.outputId}".`);
|
|
98
|
+
}
|
|
99
|
+
relayProviderByChannelKey.set(key, getDataBusChannelKey(providerNode.id, providerChannelIndex));
|
|
100
|
+
}
|
|
101
|
+
const checkedRelayChannelKeys = new Set();
|
|
102
|
+
for (const startKey of relayProviderByChannelKey.keys()) {
|
|
103
|
+
if (checkedRelayChannelKeys.has(startKey)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const path = new Set();
|
|
107
|
+
let currentKey = startKey;
|
|
108
|
+
while (currentKey != null && !checkedRelayChannelKeys.has(currentKey)) {
|
|
109
|
+
if (path.has(currentKey)) {
|
|
110
|
+
throw new Error(`Data Bus relay cycle detected at channel ${currentKey}. Disconnect one relay connection to break the cycle.`);
|
|
111
|
+
}
|
|
112
|
+
path.add(currentKey);
|
|
113
|
+
currentKey = relayProviderByChannelKey.get(currentKey);
|
|
114
|
+
}
|
|
115
|
+
for (const key of path) {
|
|
116
|
+
checkedRelayChannelKeys.add(key);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const resolvedBusOutputs = new Map();
|
|
120
|
+
const resolveBusOutput = (busNodeId, channelIndex) => {
|
|
121
|
+
const startKey = getDataBusChannelKey(busNodeId, channelIndex);
|
|
122
|
+
if (resolvedBusOutputs.has(startKey)) {
|
|
123
|
+
return resolvedBusOutputs.get(startKey);
|
|
124
|
+
}
|
|
125
|
+
const traversedKeys = [];
|
|
126
|
+
const traversedKeySet = new Set();
|
|
127
|
+
let currentKey = startKey;
|
|
128
|
+
let resolved;
|
|
129
|
+
while (true) {
|
|
130
|
+
if (resolvedBusOutputs.has(currentKey)) {
|
|
131
|
+
resolved = resolvedBusOutputs.get(currentKey);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
// Relay cycles were validated above. Retain this guard so malformed
|
|
135
|
+
// future changes cannot turn resolution into an infinite loop.
|
|
136
|
+
if (traversedKeySet.has(currentKey)) {
|
|
137
|
+
throw new Error(`Data Bus relay cycle detected at channel ${currentKey}. Disconnect one relay connection to break the cycle.`);
|
|
138
|
+
}
|
|
139
|
+
traversedKeySet.add(currentKey);
|
|
140
|
+
traversedKeys.push(currentKey);
|
|
141
|
+
const channel = channelsByBusAndIndex.get(currentKey);
|
|
142
|
+
const providerConnection = channel?.providerConnections[0];
|
|
143
|
+
if (!providerConnection) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
const providerNode = nodesById[providerConnection.outputNodeId];
|
|
147
|
+
if (!isDataBusTopologyNode(providerNode)) {
|
|
148
|
+
resolved = {
|
|
149
|
+
nodeId: providerConnection.outputNodeId,
|
|
150
|
+
outputId: providerConnection.outputId,
|
|
151
|
+
};
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
const providerChannelIndex = getDataBusOutputChannelIndex(providerConnection.outputId);
|
|
155
|
+
if (providerChannelIndex == null) {
|
|
156
|
+
throw new Error(`Data Bus "${providerNode.title}" has an invalid output port "${providerConnection.outputId}".`);
|
|
157
|
+
}
|
|
158
|
+
currentKey = getDataBusChannelKey(providerNode.id, providerChannelIndex);
|
|
159
|
+
}
|
|
160
|
+
for (const key of traversedKeys) {
|
|
161
|
+
resolvedBusOutputs.set(key, resolved);
|
|
162
|
+
}
|
|
163
|
+
return resolved;
|
|
164
|
+
};
|
|
165
|
+
const effectiveConnections = [...directConnections];
|
|
166
|
+
const effectiveProviderByInput = new Map();
|
|
167
|
+
const addEffectiveConnection = (connection) => {
|
|
168
|
+
const consumerKey = `${connection.inputNodeId}\u0000${connection.inputId}`;
|
|
169
|
+
const existing = effectiveProviderByInput.get(consumerKey);
|
|
170
|
+
if (existing) {
|
|
171
|
+
if (existing.outputNodeId === connection.outputNodeId && existing.outputId === connection.outputId) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
throw new Error(`Data Bus routing gives "${nodesById[connection.inputNodeId]?.title ?? connection.inputNodeId}".${connection.inputId} more than one effective provider.`);
|
|
175
|
+
}
|
|
176
|
+
effectiveProviderByInput.set(consumerKey, connection);
|
|
177
|
+
effectiveConnections.push(connection);
|
|
178
|
+
};
|
|
179
|
+
for (const directConnection of directConnections) {
|
|
180
|
+
effectiveProviderByInput.set(`${directConnection.inputNodeId}\u0000${directConnection.inputId}`, directConnection);
|
|
181
|
+
}
|
|
182
|
+
for (const channel of channelsByBusAndIndex.values()) {
|
|
183
|
+
const busId = channel.busNodeId;
|
|
184
|
+
const channelIndex = channel.channelIndex;
|
|
185
|
+
for (const consumerConnection of channel.consumerConnections) {
|
|
186
|
+
const consumerNode = nodesById[consumerConnection.inputNodeId];
|
|
187
|
+
if (isDataBusTopologyNode(consumerNode)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const resolved = resolveBusOutput(busId, channelIndex);
|
|
191
|
+
if (!resolved) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const connection = {
|
|
195
|
+
inputNodeId: consumerConnection.inputNodeId,
|
|
196
|
+
inputId: consumerConnection.inputId,
|
|
197
|
+
outputNodeId: resolved.nodeId,
|
|
198
|
+
outputId: resolved.outputId,
|
|
199
|
+
};
|
|
200
|
+
addEffectiveConnection(connection);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
connections: effectiveConnections,
|
|
205
|
+
executionNodes: options.graphNodes.filter((node) => !dataBusNodeIds.has(node.id)),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { exhaustiveTuple } from '../utils/genericUtilFunctions.js';
|
|
2
|
-
|
|
3
|
-
export const
|
|
2
|
+
import { createDefaultLLMProfileValue } from './chat-v2/llmProfileTypes.js';
|
|
3
|
+
export const dataTypes = exhaustiveTuple()('any', 'any[]', 'boolean', 'boolean[]', 'string', 'string[]', 'number', 'number[]', 'date', 'date[]', 'time', 'time[]', 'datetime', 'datetime[]', 'chat-message', 'chat-message[]', 'control-flow-excluded', 'control-flow-excluded[]', 'object', 'object[]', 'fn<string>', 'fn<number>', 'fn<boolean>', 'fn<date>', 'fn<time>', 'fn<datetime>', 'fn<any>', 'fn<object>', 'fn<chat-message>', 'fn<control-flow-excluded>', 'fn<string[]>', 'fn<number[]>', 'fn<boolean[]>', 'fn<date[]>', 'fn<time[]>', 'fn<datetime[]>', 'fn<any[]>', 'fn<object[]>', 'fn<chat-message[]>', 'fn<control-flow-excluded[]>', 'gpt-function', 'gpt-function[]', 'fn<gpt-function[]>', 'fn<gpt-function>', 'vector', 'vector[]', 'fn<vector>', 'fn<vector[]>', 'image', 'image[]', 'fn<image>', 'fn<image[]>', 'binary', 'binary[]', 'fn<binary>', 'fn<binary[]>', 'audio', 'audio[]', 'fn<audio>', 'fn<audio[]>', 'graph-reference', 'graph-reference[]', 'fn<graph-reference>', 'fn<graph-reference[]>', 'knowledge-source', 'knowledge-source[]', 'fn<knowledge-source>', 'fn<knowledge-source[]>', 'knowledge-document', 'knowledge-document[]', 'fn<knowledge-document>', 'fn<knowledge-document[]>', 'knowledge-evidence', 'knowledge-evidence[]', 'fn<knowledge-evidence>', 'fn<knowledge-evidence[]>', 'llm-config', 'llm-config[]', 'fn<llm-config>', 'fn<llm-config[]>', 'document', 'document[]', 'fn<document>', 'fn<document[]>');
|
|
4
|
+
export const scalarTypes = exhaustiveTuple()('any', 'boolean', 'string', 'number', 'date', 'time', 'datetime', 'chat-message', 'control-flow-excluded', 'object', 'gpt-function', 'vector', 'image', 'binary', 'audio', 'graph-reference', 'knowledge-source', 'knowledge-document', 'knowledge-evidence', 'llm-config', 'document');
|
|
4
5
|
export const dataTypeDisplayNames = {
|
|
5
6
|
any: 'Any',
|
|
6
7
|
'any[]': 'Any Array',
|
|
@@ -78,6 +79,10 @@ export const dataTypeDisplayNames = {
|
|
|
78
79
|
'knowledge-evidence[]': 'Knowledge Evidence Array',
|
|
79
80
|
'fn<knowledge-evidence>': 'Function<Knowledge Evidence>',
|
|
80
81
|
'fn<knowledge-evidence[]>': 'Function<Knowledge Evidence Array>',
|
|
82
|
+
'llm-config': 'LLM Profile',
|
|
83
|
+
'llm-config[]': 'LLM Profile Array',
|
|
84
|
+
'fn<llm-config>': 'Function<LLM Profile>',
|
|
85
|
+
'fn<llm-config[]>': 'Function<LLM Profile Array>',
|
|
81
86
|
document: 'Document',
|
|
82
87
|
'document[]': 'Document Array',
|
|
83
88
|
'fn<document>': 'Function<Document>',
|
|
@@ -111,11 +116,15 @@ export function isFunctionDataValue(value) {
|
|
|
111
116
|
return isFunctionDataType(value.type) || (value.type === 'any' && typeof value.value === 'function');
|
|
112
117
|
}
|
|
113
118
|
export function isNotFunctionDataValue(value) {
|
|
114
|
-
return !isFunctionDataValue(value);
|
|
119
|
+
return value !== undefined && !isFunctionDataValue(value);
|
|
115
120
|
}
|
|
116
|
-
export function
|
|
121
|
+
export function functionTypeToReturnType(functionType) {
|
|
117
122
|
return functionType.slice(3, -1);
|
|
118
123
|
}
|
|
124
|
+
export function functionTypeToScalarType(functionType) {
|
|
125
|
+
const returnType = functionTypeToReturnType(functionType);
|
|
126
|
+
return isArrayDataType(returnType) ? arrayTypeToScalarType(returnType) : returnType;
|
|
127
|
+
}
|
|
119
128
|
export function arrayTypeToScalarType(arrayType) {
|
|
120
129
|
return arrayType.slice(0, -2);
|
|
121
130
|
}
|
|
@@ -133,7 +142,11 @@ export function unwrapDataValue(value) {
|
|
|
133
142
|
return undefined;
|
|
134
143
|
}
|
|
135
144
|
if (isFunctionDataValue(value)) {
|
|
136
|
-
|
|
145
|
+
const evaluated = value.value();
|
|
146
|
+
if (value.type === 'any') {
|
|
147
|
+
return { type: 'any', value: evaluated };
|
|
148
|
+
}
|
|
149
|
+
return { type: functionTypeToReturnType(value.type), value: evaluated };
|
|
137
150
|
}
|
|
138
151
|
return value;
|
|
139
152
|
}
|
|
@@ -189,6 +202,7 @@ export const scalarDefaults = {
|
|
|
189
202
|
source: { connectionId: '', sourceId: '' },
|
|
190
203
|
documentId: '',
|
|
191
204
|
},
|
|
205
|
+
'llm-config': createDefaultLLMProfileValue(),
|
|
192
206
|
document: {
|
|
193
207
|
mediaType: 'text/plain',
|
|
194
208
|
data: new Uint8Array(),
|
|
@@ -202,7 +216,8 @@ export function getDefaultValue(type) {
|
|
|
202
216
|
return [];
|
|
203
217
|
}
|
|
204
218
|
if (isFunctionDataType(type)) {
|
|
205
|
-
|
|
219
|
+
const returnType = functionTypeToReturnType(type);
|
|
220
|
+
return (() => getDefaultValue(returnType));
|
|
206
221
|
}
|
|
207
|
-
return scalarDefaults[getScalarTypeOf(type)];
|
|
222
|
+
return structuredClone(scalarDefaults[getScalarTypeOf(type)]);
|
|
208
223
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { values } from '../utils/typeSafety.js';
|
|
2
2
|
import { findStronglyConnectedComponents } from './CycleDetector.js';
|
|
3
3
|
import { resolveNodePrefabInstances } from './NodePrefabResolver.js';
|
|
4
|
+
import { compileDataBusTopology } from './DataBusTopology.js';
|
|
4
5
|
export function preprocessGraphState(options) {
|
|
5
6
|
const { buildExecutionPlan, definitionContext, graph, loadedProjects, project, registry, warnOnInvalidGraph } = options;
|
|
6
|
-
const
|
|
7
|
+
const authoredGraphNodes = resolveNodePrefabInstances(project, graph.nodes);
|
|
8
|
+
const compiledTopology = compileDataBusTopology({
|
|
9
|
+
connections: graph.connections,
|
|
10
|
+
graphNodes: authoredGraphNodes,
|
|
11
|
+
});
|
|
12
|
+
const graphNodes = compiledTopology.executionNodes;
|
|
7
13
|
const effectiveDefinitionContext = definitionContext && graphNodes.some(usesGraphBoundaryDefinitionContext) ? definitionContext : undefined;
|
|
8
14
|
const nodeInstances = {};
|
|
9
15
|
const nodesById = {};
|
|
@@ -12,7 +18,7 @@ export function preprocessGraphState(options) {
|
|
|
12
18
|
nodeInstances[node.id] = registry.createDynamicImpl(node);
|
|
13
19
|
nodesById[node.id] = node;
|
|
14
20
|
}
|
|
15
|
-
for (const connection of
|
|
21
|
+
for (const connection of compiledTopology.connections) {
|
|
16
22
|
if (!nodesById[connection.inputNodeId] || !nodesById[connection.outputNodeId]) {
|
|
17
23
|
if (warnOnInvalidGraph) {
|
|
18
24
|
if (!nodesById[connection.inputNodeId]) {
|
|
@@ -49,6 +55,7 @@ export function preprocessGraphState(options) {
|
|
|
49
55
|
const result = {
|
|
50
56
|
connections,
|
|
51
57
|
definitions,
|
|
58
|
+
graphNodes,
|
|
52
59
|
nodeInstances,
|
|
53
60
|
nodesById,
|
|
54
61
|
nodesNotInCycle,
|
|
@@ -266,7 +273,6 @@ function buildGraphExecutionPlan(options) {
|
|
|
266
273
|
}
|
|
267
274
|
return {
|
|
268
275
|
cycleIndexByNode,
|
|
269
|
-
graphNodes,
|
|
270
276
|
nodeIds: graphNodes.map((node) => node.id),
|
|
271
277
|
inputConnectionByNodeAndPort,
|
|
272
278
|
inputConnectionsByNode,
|