@valerypopoff/rivet2-core 2.0.11 → 2.1.0
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 +1555 -172
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/exports.js +4 -0
- package/dist/esm/model/GraphBoundaryCache.js +36 -4
- package/dist/esm/model/GraphBoundaryEffects.js +32 -0
- package/dist/esm/model/GraphPreprocessor.js +6 -4
- package/dist/esm/model/GraphProcessor.js +129 -17
- package/dist/esm/model/NodeGraph.js +1 -1
- package/dist/esm/model/NodePrefabResolver.js +57 -0
- package/dist/esm/model/Nodes.js +4 -1
- package/dist/esm/model/ProcessContextBuilder.js +3 -1
- package/dist/esm/model/UiGraph.js +113 -0
- package/dist/esm/model/UiGraphRendererStyles.js +208 -0
- package/dist/esm/model/chat/openAIChatRuntime.js +0 -1
- package/dist/esm/model/chat-v2/aiSdkBridge.js +100 -2
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +35 -31
- package/dist/esm/model/chat-v2/chatV2Shared.js +1 -1
- package/dist/esm/model/chat-v2/providerOptions.js +5 -1
- package/dist/esm/model/nodes/CoalesceNode.js +1 -1
- package/dist/esm/model/nodes/CompareNode.js +15 -14
- package/dist/esm/model/nodes/GraphOutputNode.js +1 -0
- package/dist/esm/model/nodes/LLMChatV2Node.js +62 -17
- package/dist/esm/model/nodes/NodePrefabInstanceNode.js +39 -0
- package/dist/esm/model/nodes/PromptNode.js +2 -1
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +49 -7
- package/dist/esm/model/nodes/SubGraphNode.js +42 -5
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/jsonValueToDataValue.js +48 -0
- package/dist/esm/utils/projectComparison/connections.js +57 -0
- package/dist/esm/utils/projectComparison/graphs.js +60 -0
- package/dist/esm/utils/projectComparison/nodes.js +53 -0
- package/dist/esm/utils/projectComparison/summaries.js +60 -0
- package/dist/esm/utils/projectComparison/values.js +40 -0
- package/dist/esm/utils/projectComparison.js +73 -0
- package/dist/esm/utils/serialization/serializationHelpers.js +24 -3
- package/dist/esm/utils/serialization/serialization_v4.js +30 -0
- package/dist/types/exports.d.ts +5 -0
- package/dist/types/model/EditorDefinition.d.ts +1 -0
- package/dist/types/model/ExecutorProtocol.d.ts +13 -3
- package/dist/types/model/GraphBoundaryCache.d.ts +9 -3
- package/dist/types/model/GraphBoundaryEffects.d.ts +9 -0
- package/dist/types/model/GraphProcessor.d.ts +15 -0
- package/dist/types/model/NodeBase.d.ts +5 -0
- package/dist/types/model/NodeBodySpec.d.ts +1 -0
- package/dist/types/model/NodePrefabResolver.d.ts +13 -0
- package/dist/types/model/Nodes.d.ts +5 -4
- package/dist/types/model/ProcessContext.d.ts +5 -1
- package/dist/types/model/ProcessContextBuilder.d.ts +4 -2
- package/dist/types/model/Project.d.ts +9 -0
- package/dist/types/model/UiGraph.d.ts +84 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +2 -0
- package/dist/types/model/chat-v2/aiSdkBridge.d.ts +1 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +23 -1
- package/dist/types/model/nodes/CompareNode.d.ts +4 -0
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
- package/dist/types/model/nodes/NodePrefabInstanceNode.d.ts +13 -0
- package/dist/types/model/nodes/SubGraphNode.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/jsonValueToDataValue.d.ts +2 -0
- package/dist/types/utils/projectComparison/connections.d.ts +5 -0
- package/dist/types/utils/projectComparison/graphs.d.ts +3 -0
- package/dist/types/utils/projectComparison/nodes.d.ts +5 -0
- package/dist/types/utils/projectComparison/summaries.d.ts +4 -0
- package/dist/types/utils/projectComparison/values.d.ts +5 -0
- package/dist/types/utils/projectComparison.d.ts +77 -0
- package/package.json +1 -1
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -106,7 +106,9 @@ __export(src_exports, {
|
|
|
106
106
|
MCPGetPromptNodeImpl: () => MCPGetPromptNodeImpl,
|
|
107
107
|
MCPToolCallNodeImpl: () => MCPToolCallNodeImpl,
|
|
108
108
|
MatchNodeImpl: () => MatchNodeImpl,
|
|
109
|
+
NODE_PREFAB_INSTANCE_TYPE: () => NODE_PREFAB_INSTANCE_TYPE,
|
|
109
110
|
NodeImpl: () => NodeImpl,
|
|
111
|
+
NodePrefabInstanceNodeImpl: () => NodePrefabInstanceNodeImpl,
|
|
110
112
|
NodeRegistration: () => NodeRegistration,
|
|
111
113
|
NotAllowedCodeRunner: () => NotAllowedCodeRunner,
|
|
112
114
|
NumberNodeImpl: () => NumberNodeImpl,
|
|
@@ -116,6 +118,8 @@ __export(src_exports, {
|
|
|
116
118
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
117
119
|
PopNodeImpl: () => PopNodeImpl,
|
|
118
120
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
121
|
+
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
122
|
+
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
119
123
|
RaceInputsNodeImpl: () => RaceInputsNodeImpl,
|
|
120
124
|
RaiseEventNodeImpl: () => RaiseEventNodeImpl,
|
|
121
125
|
RandomNumberNodeImpl: () => RandomNumberNodeImpl,
|
|
@@ -168,6 +172,7 @@ __export(src_exports, {
|
|
|
168
172
|
callGraphNode: () => callGraphNode,
|
|
169
173
|
canBeCoerced: () => canBeCoerced,
|
|
170
174
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
175
|
+
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
171
176
|
chatLoopNode: () => chatLoopNode,
|
|
172
177
|
chatMessagesToModelMessages: () => chatMessagesToModelMessages,
|
|
173
178
|
chatNode: () => chatNode,
|
|
@@ -176,6 +181,8 @@ __export(src_exports, {
|
|
|
176
181
|
chunkNode: () => chunkNode,
|
|
177
182
|
chunkStringByTokenCount: () => chunkStringByTokenCount,
|
|
178
183
|
cleanHeaders: () => cleanHeaders,
|
|
184
|
+
cloneFrozenNodeOutputs: () => cloneFrozenNodeOutputs,
|
|
185
|
+
cloneFrozenNodeOutputsByGraph: () => cloneFrozenNodeOutputsByGraph,
|
|
179
186
|
coalesceNode: () => coalesceNode,
|
|
180
187
|
codeNewNode: () => codeNewNode,
|
|
181
188
|
codeNode: () => codeNode,
|
|
@@ -183,6 +190,8 @@ __export(src_exports, {
|
|
|
183
190
|
coerceTypeOptional: () => coerceTypeOptional,
|
|
184
191
|
commentNode: () => commentNode,
|
|
185
192
|
compareNode: () => compareNode,
|
|
193
|
+
compareNodeComparisonFunctionOptions: () => compareNodeComparisonFunctionOptions,
|
|
194
|
+
compareProjects: () => compareProjects,
|
|
186
195
|
contextNode: () => contextNode,
|
|
187
196
|
coreCreateProcessor: () => coreCreateProcessor,
|
|
188
197
|
coreRunGraph: () => coreRunGraph,
|
|
@@ -194,6 +203,8 @@ __export(src_exports, {
|
|
|
194
203
|
createDebuggerTransportEscapedSentinel: () => createDebuggerTransportEscapedSentinel,
|
|
195
204
|
createDebuggerTransportEscapedSentinelEnvelope: () => createDebuggerTransportEscapedSentinelEnvelope,
|
|
196
205
|
createDebuggerTransportUndefinedSentinel: () => createDebuggerTransportUndefinedSentinel,
|
|
206
|
+
createDefaultUiGraph: () => createDefaultUiGraph,
|
|
207
|
+
createFrozenNodeOutputResolver: () => createFrozenNodeOutputResolver,
|
|
197
208
|
createInterpolationInputDefinition: () => createInterpolationInputDefinition,
|
|
198
209
|
createsLLMChatV2ToolResponseFormatConflictForEdit: () => createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
199
210
|
cronNode: () => cronNode,
|
|
@@ -227,6 +238,7 @@ __export(src_exports, {
|
|
|
227
238
|
filterNode: () => filterNode,
|
|
228
239
|
findInterpolationTokenSpans: () => findInterpolationTokenSpans,
|
|
229
240
|
functionTypeToScalarType: () => functionTypeToScalarType,
|
|
241
|
+
generateChatV2: () => generateChatV2,
|
|
230
242
|
gentracePlugin: () => gentrace_default,
|
|
231
243
|
getAllDatasetsNode: () => getAllDatasetsNode,
|
|
232
244
|
getChatNodeMessages: () => getChatNodeMessages,
|
|
@@ -245,16 +257,25 @@ __export(src_exports, {
|
|
|
245
257
|
getExtractObjectPathInterpolationInputNames: () => getExtractObjectPathInterpolationInputNames,
|
|
246
258
|
getGentracePipelines: () => getGentracePipelines,
|
|
247
259
|
getGlobalNode: () => getGlobalNode,
|
|
260
|
+
getGraphBoundary: () => getGraphBoundary,
|
|
248
261
|
getHttpCallBodyPreviewSections: () => getHttpCallBodyPreviewSections,
|
|
249
262
|
getInputOrData: () => getInputOrData,
|
|
250
263
|
getIntegration: () => getIntegration,
|
|
251
264
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
252
265
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
266
|
+
getNodePrefabDisplayName: () => getNodePrefabDisplayName,
|
|
267
|
+
getNodePrefabInstancePrefabId: () => getNodePrefabInstancePrefabId,
|
|
253
268
|
getPluginConfig: () => getPluginConfig,
|
|
254
269
|
getProcessorEvents: () => getProcessorEvents,
|
|
255
270
|
getProcessorSSEStream: () => getProcessorSSEStream,
|
|
271
|
+
getProjectConnectionComparisonKey: () => getProjectConnectionComparisonKey,
|
|
272
|
+
getProjectNodeFieldComparisons: () => getProjectNodeFieldComparisons,
|
|
256
273
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
257
274
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
275
|
+
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
276
|
+
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
277
|
+
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
278
|
+
getUiGraphInitialState: () => getUiGraphInitialState,
|
|
258
279
|
getWarnings: () => getWarnings,
|
|
259
280
|
globalRivetNodeRegistry: () => globalRivetNodeRegistry,
|
|
260
281
|
googlePlugin: () => googlePlugin,
|
|
@@ -264,6 +285,7 @@ __export(src_exports, {
|
|
|
264
285
|
graphOutputNode: () => graphOutputNode,
|
|
265
286
|
graphReferenceNode: () => graphReferenceNode,
|
|
266
287
|
handleEscapeCharacters: () => handleEscapeCharacters,
|
|
288
|
+
hasFrozenNodeOutputs: () => hasFrozenNodeOutputs,
|
|
267
289
|
hasLLMChatV2ToolResponseFormatConflict: () => hasLLMChatV2ToolResponseFormatConflict,
|
|
268
290
|
hasValidStoredOrderedPortIds: () => hasValidStoredOrderedPortIds,
|
|
269
291
|
hashNode: () => hashNode,
|
|
@@ -289,6 +311,7 @@ __export(src_exports, {
|
|
|
289
311
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
290
312
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
291
313
|
isLLMChatV2StructuredResponseFormat: () => isLLMChatV2StructuredResponseFormat,
|
|
314
|
+
isNodePrefabInstanceNode: () => isNodePrefabInstanceNode,
|
|
292
315
|
isNotFunctionDataValue: () => isNotFunctionDataValue,
|
|
293
316
|
isRuntimeDebugLoggingEnabled: () => isRuntimeDebugLoggingEnabled,
|
|
294
317
|
isScalarDataType: () => isScalarDataType,
|
|
@@ -296,6 +319,7 @@ __export(src_exports, {
|
|
|
296
319
|
joinNode: () => joinNode,
|
|
297
320
|
jsFilterNode: () => jsFilterNode,
|
|
298
321
|
jsMapNode: () => jsMapNode,
|
|
322
|
+
jsonValueToDataValue: () => jsonValueToDataValue,
|
|
299
323
|
listGraphsNode: () => listGraphsNode,
|
|
300
324
|
llmChatV2Node: () => llmChatV2Node,
|
|
301
325
|
loadDatasetNode: () => loadDatasetNode,
|
|
@@ -316,6 +340,7 @@ __export(src_exports, {
|
|
|
316
340
|
mergeCustomProviderResponseFormatOptions: () => mergeCustomProviderResponseFormatOptions,
|
|
317
341
|
newId: () => newId,
|
|
318
342
|
nodeDefinition: () => nodeDefinition,
|
|
343
|
+
nodePrefabInstanceNode: () => nodePrefabInstanceNode,
|
|
319
344
|
numberNode: () => numberNode,
|
|
320
345
|
objectNode: () => objectNode,
|
|
321
346
|
openAICompatibleEndpointToBaseURL: () => openAICompatibleEndpointToBaseURL,
|
|
@@ -349,8 +374,13 @@ __export(src_exports, {
|
|
|
349
374
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
350
375
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
351
376
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
377
|
+
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
378
|
+
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
352
379
|
resolveProcessSettings: () => resolveProcessSettings,
|
|
353
380
|
resolveStoredOrderedPortIds: () => resolveStoredOrderedPortIds,
|
|
381
|
+
resolveUiGraphActionInputs: () => resolveUiGraphActionInputs,
|
|
382
|
+
resolveUiGraphActionOutputStatePatch: () => resolveUiGraphActionOutputStatePatch,
|
|
383
|
+
resolveUiGraphActionOutputStateValue: () => resolveUiGraphActionOutputStateValue,
|
|
354
384
|
resolveUniqueValueDerivedPortIds: () => resolveUniqueValueDerivedPortIds,
|
|
355
385
|
restoreEscapedInterpolationTokens: () => restoreEscapedInterpolationTokens,
|
|
356
386
|
runChatV2Pipeline: () => runChatV2Pipeline,
|
|
@@ -470,7 +500,9 @@ __export(exports_exports, {
|
|
|
470
500
|
MCPGetPromptNodeImpl: () => MCPGetPromptNodeImpl,
|
|
471
501
|
MCPToolCallNodeImpl: () => MCPToolCallNodeImpl,
|
|
472
502
|
MatchNodeImpl: () => MatchNodeImpl,
|
|
503
|
+
NODE_PREFAB_INSTANCE_TYPE: () => NODE_PREFAB_INSTANCE_TYPE,
|
|
473
504
|
NodeImpl: () => NodeImpl,
|
|
505
|
+
NodePrefabInstanceNodeImpl: () => NodePrefabInstanceNodeImpl,
|
|
474
506
|
NodeRegistration: () => NodeRegistration,
|
|
475
507
|
NotAllowedCodeRunner: () => NotAllowedCodeRunner,
|
|
476
508
|
NumberNodeImpl: () => NumberNodeImpl,
|
|
@@ -480,6 +512,8 @@ __export(exports_exports, {
|
|
|
480
512
|
PluginNodeImplClass: () => PluginNodeImplClass,
|
|
481
513
|
PopNodeImpl: () => PopNodeImpl,
|
|
482
514
|
PromptNodeImpl: () => PromptNodeImpl,
|
|
515
|
+
RIVET_WEB_APP_DOCUMENT_CSS: () => RIVET_WEB_APP_DOCUMENT_CSS,
|
|
516
|
+
RIVET_WEB_APP_RENDERER_CSS: () => RIVET_WEB_APP_RENDERER_CSS,
|
|
483
517
|
RaceInputsNodeImpl: () => RaceInputsNodeImpl,
|
|
484
518
|
RaiseEventNodeImpl: () => RaiseEventNodeImpl,
|
|
485
519
|
RandomNumberNodeImpl: () => RandomNumberNodeImpl,
|
|
@@ -531,6 +565,7 @@ __export(exports_exports, {
|
|
|
531
565
|
callGraphNode: () => callGraphNode,
|
|
532
566
|
canBeCoerced: () => canBeCoerced,
|
|
533
567
|
canBeCoercedAny: () => canBeCoercedAny,
|
|
568
|
+
canUseNodeAsPrefabSource: () => canUseNodeAsPrefabSource,
|
|
534
569
|
chatLoopNode: () => chatLoopNode,
|
|
535
570
|
chatMessagesToModelMessages: () => chatMessagesToModelMessages,
|
|
536
571
|
chatNode: () => chatNode,
|
|
@@ -539,6 +574,8 @@ __export(exports_exports, {
|
|
|
539
574
|
chunkNode: () => chunkNode,
|
|
540
575
|
chunkStringByTokenCount: () => chunkStringByTokenCount,
|
|
541
576
|
cleanHeaders: () => cleanHeaders,
|
|
577
|
+
cloneFrozenNodeOutputs: () => cloneFrozenNodeOutputs,
|
|
578
|
+
cloneFrozenNodeOutputsByGraph: () => cloneFrozenNodeOutputsByGraph,
|
|
542
579
|
coalesceNode: () => coalesceNode,
|
|
543
580
|
codeNewNode: () => codeNewNode,
|
|
544
581
|
codeNode: () => codeNode,
|
|
@@ -546,6 +583,8 @@ __export(exports_exports, {
|
|
|
546
583
|
coerceTypeOptional: () => coerceTypeOptional,
|
|
547
584
|
commentNode: () => commentNode,
|
|
548
585
|
compareNode: () => compareNode,
|
|
586
|
+
compareNodeComparisonFunctionOptions: () => compareNodeComparisonFunctionOptions,
|
|
587
|
+
compareProjects: () => compareProjects,
|
|
549
588
|
contextNode: () => contextNode,
|
|
550
589
|
coreCreateProcessor: () => coreCreateProcessor,
|
|
551
590
|
coreRunGraph: () => coreRunGraph,
|
|
@@ -557,6 +596,8 @@ __export(exports_exports, {
|
|
|
557
596
|
createDebuggerTransportEscapedSentinel: () => createDebuggerTransportEscapedSentinel,
|
|
558
597
|
createDebuggerTransportEscapedSentinelEnvelope: () => createDebuggerTransportEscapedSentinelEnvelope,
|
|
559
598
|
createDebuggerTransportUndefinedSentinel: () => createDebuggerTransportUndefinedSentinel,
|
|
599
|
+
createDefaultUiGraph: () => createDefaultUiGraph,
|
|
600
|
+
createFrozenNodeOutputResolver: () => createFrozenNodeOutputResolver,
|
|
560
601
|
createInterpolationInputDefinition: () => createInterpolationInputDefinition,
|
|
561
602
|
createsLLMChatV2ToolResponseFormatConflictForEdit: () => createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
562
603
|
cronNode: () => cronNode,
|
|
@@ -590,6 +631,7 @@ __export(exports_exports, {
|
|
|
590
631
|
filterNode: () => filterNode,
|
|
591
632
|
findInterpolationTokenSpans: () => findInterpolationTokenSpans,
|
|
592
633
|
functionTypeToScalarType: () => functionTypeToScalarType,
|
|
634
|
+
generateChatV2: () => generateChatV2,
|
|
593
635
|
gentracePlugin: () => gentrace_default,
|
|
594
636
|
getAllDatasetsNode: () => getAllDatasetsNode,
|
|
595
637
|
getChatNodeMessages: () => getChatNodeMessages,
|
|
@@ -608,16 +650,25 @@ __export(exports_exports, {
|
|
|
608
650
|
getExtractObjectPathInterpolationInputNames: () => getExtractObjectPathInterpolationInputNames,
|
|
609
651
|
getGentracePipelines: () => getGentracePipelines,
|
|
610
652
|
getGlobalNode: () => getGlobalNode,
|
|
653
|
+
getGraphBoundary: () => getGraphBoundary,
|
|
611
654
|
getHttpCallBodyPreviewSections: () => getHttpCallBodyPreviewSections,
|
|
612
655
|
getInputOrData: () => getInputOrData,
|
|
613
656
|
getIntegration: () => getIntegration,
|
|
614
657
|
getInterpolationInputDefinitionData: () => getInterpolationInputDefinitionData,
|
|
615
658
|
getInterpolationTokenName: () => getInterpolationTokenName,
|
|
659
|
+
getNodePrefabDisplayName: () => getNodePrefabDisplayName,
|
|
660
|
+
getNodePrefabInstancePrefabId: () => getNodePrefabInstancePrefabId,
|
|
616
661
|
getPluginConfig: () => getPluginConfig,
|
|
617
662
|
getProcessorEvents: () => getProcessorEvents,
|
|
618
663
|
getProcessorSSEStream: () => getProcessorSSEStream,
|
|
664
|
+
getProjectConnectionComparisonKey: () => getProjectConnectionComparisonKey,
|
|
665
|
+
getProjectNodeFieldComparisons: () => getProjectNodeFieldComparisons,
|
|
619
666
|
getScalarTypeOf: () => getScalarTypeOf,
|
|
620
667
|
getSingleNodeStream: () => getSingleNodeStream,
|
|
668
|
+
getUiGraphActionComponent: () => getUiGraphActionComponent,
|
|
669
|
+
getUiGraphActionInputBindings: () => getUiGraphActionInputBindings,
|
|
670
|
+
getUiGraphActionOutputBindings: () => getUiGraphActionOutputBindings,
|
|
671
|
+
getUiGraphInitialState: () => getUiGraphInitialState,
|
|
621
672
|
getWarnings: () => getWarnings,
|
|
622
673
|
globalRivetNodeRegistry: () => globalRivetNodeRegistry,
|
|
623
674
|
googlePlugin: () => googlePlugin,
|
|
@@ -627,6 +678,7 @@ __export(exports_exports, {
|
|
|
627
678
|
graphOutputNode: () => graphOutputNode,
|
|
628
679
|
graphReferenceNode: () => graphReferenceNode,
|
|
629
680
|
handleEscapeCharacters: () => handleEscapeCharacters,
|
|
681
|
+
hasFrozenNodeOutputs: () => hasFrozenNodeOutputs,
|
|
630
682
|
hasLLMChatV2ToolResponseFormatConflict: () => hasLLMChatV2ToolResponseFormatConflict,
|
|
631
683
|
hasValidStoredOrderedPortIds: () => hasValidStoredOrderedPortIds,
|
|
632
684
|
hashNode: () => hashNode,
|
|
@@ -652,6 +704,7 @@ __export(exports_exports, {
|
|
|
652
704
|
isFunctionDataValue: () => isFunctionDataValue,
|
|
653
705
|
isInterpolationInputDefinition: () => isInterpolationInputDefinition,
|
|
654
706
|
isLLMChatV2StructuredResponseFormat: () => isLLMChatV2StructuredResponseFormat,
|
|
707
|
+
isNodePrefabInstanceNode: () => isNodePrefabInstanceNode,
|
|
655
708
|
isNotFunctionDataValue: () => isNotFunctionDataValue,
|
|
656
709
|
isRuntimeDebugLoggingEnabled: () => isRuntimeDebugLoggingEnabled,
|
|
657
710
|
isScalarDataType: () => isScalarDataType,
|
|
@@ -659,6 +712,7 @@ __export(exports_exports, {
|
|
|
659
712
|
joinNode: () => joinNode,
|
|
660
713
|
jsFilterNode: () => jsFilterNode,
|
|
661
714
|
jsMapNode: () => jsMapNode,
|
|
715
|
+
jsonValueToDataValue: () => jsonValueToDataValue,
|
|
662
716
|
listGraphsNode: () => listGraphsNode,
|
|
663
717
|
llmChatV2Node: () => llmChatV2Node,
|
|
664
718
|
loadDatasetNode: () => loadDatasetNode,
|
|
@@ -679,6 +733,7 @@ __export(exports_exports, {
|
|
|
679
733
|
mergeCustomProviderResponseFormatOptions: () => mergeCustomProviderResponseFormatOptions,
|
|
680
734
|
newId: () => newId,
|
|
681
735
|
nodeDefinition: () => nodeDefinition,
|
|
736
|
+
nodePrefabInstanceNode: () => nodePrefabInstanceNode,
|
|
682
737
|
numberNode: () => numberNode,
|
|
683
738
|
objectNode: () => objectNode,
|
|
684
739
|
openAICompatibleEndpointToBaseURL: () => openAICompatibleEndpointToBaseURL,
|
|
@@ -712,8 +767,13 @@ __export(exports_exports, {
|
|
|
712
767
|
resolveChatV2ProviderConfig: () => resolveChatV2ProviderConfig,
|
|
713
768
|
resolveChatV2ResponseFormatParameters: () => resolveChatV2ResponseFormatParameters,
|
|
714
769
|
resolveLLMChatV2RuntimeProviderOptions: () => resolveLLMChatV2RuntimeProviderOptions,
|
|
770
|
+
resolveNodePrefabInstance: () => resolveNodePrefabInstance,
|
|
771
|
+
resolveNodePrefabInstances: () => resolveNodePrefabInstances,
|
|
715
772
|
resolveProcessSettings: () => resolveProcessSettings,
|
|
716
773
|
resolveStoredOrderedPortIds: () => resolveStoredOrderedPortIds,
|
|
774
|
+
resolveUiGraphActionInputs: () => resolveUiGraphActionInputs,
|
|
775
|
+
resolveUiGraphActionOutputStatePatch: () => resolveUiGraphActionOutputStatePatch,
|
|
776
|
+
resolveUiGraphActionOutputStateValue: () => resolveUiGraphActionOutputStateValue,
|
|
717
777
|
resolveUniqueValueDerivedPortIds: () => resolveUniqueValueDerivedPortIds,
|
|
718
778
|
restoreEscapedInterpolationTokens: () => restoreEscapedInterpolationTokens,
|
|
719
779
|
runChatV2Pipeline: () => runChatV2Pipeline,
|
|
@@ -1500,24 +1560,47 @@ function detectSerializationVersion(data) {
|
|
|
1500
1560
|
// src/utils/serialization/serializationHelpers.ts
|
|
1501
1561
|
var import_safe_stable_stringify = __toESM(require("safe-stable-stringify"), 1);
|
|
1502
1562
|
var yaml = __toESM(require("yaml"), 1);
|
|
1563
|
+
var CONNECTION_BEND_MARKER = " __rivet_bend:";
|
|
1564
|
+
var CONNECTION_BEND_MARKER_TITLE_FALLBACK = " __rivet bend:";
|
|
1565
|
+
var FINITE_NUMBER_PATTERN = String.raw`[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?`;
|
|
1566
|
+
var CONNECTION_BEND_PATTERN = new RegExp(
|
|
1567
|
+
`${CONNECTION_BEND_MARKER.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(${FINITE_NUMBER_PATTERN}),(${FINITE_NUMBER_PATTERN})$`
|
|
1568
|
+
);
|
|
1503
1569
|
function serializeConnection(connection, allNodes) {
|
|
1504
1570
|
var _a;
|
|
1505
|
-
const targetTitle = (
|
|
1506
|
-
|
|
1571
|
+
const targetTitle = serializeConnectionTargetTitle(
|
|
1572
|
+
((_a = allNodes.find((node) => node.id === connection.inputNodeId)) == null ? void 0 : _a.title) ?? ""
|
|
1573
|
+
);
|
|
1574
|
+
const bendPoint = connection.bendPoint && Number.isFinite(connection.bendPoint.x) && Number.isFinite(connection.bendPoint.y) ? `${CONNECTION_BEND_MARKER}${connection.bendPoint.x},${connection.bendPoint.y}` : "";
|
|
1575
|
+
return `${connection.outputId}->"${targetTitle}${bendPoint}" ${connection.inputNodeId}/${connection.inputId}`;
|
|
1507
1576
|
}
|
|
1508
1577
|
function deserializeConnection(connection, sourceNodeId) {
|
|
1509
1578
|
const match10 = connection.match(/(.+)->"(.*)"\s+(.+)\/(.+)/);
|
|
1510
1579
|
if (!match10) {
|
|
1511
1580
|
throw new Error(`Invalid connection: ${connection}`);
|
|
1512
1581
|
}
|
|
1513
|
-
const [, outputId, , inputNodeId, inputId] = match10;
|
|
1582
|
+
const [, outputId, targetTitle, inputNodeId, inputId] = match10;
|
|
1583
|
+
const bendPoint = deserializeConnectionBendPoint(targetTitle);
|
|
1514
1584
|
return {
|
|
1515
1585
|
outputId,
|
|
1516
1586
|
outputNodeId: sourceNodeId,
|
|
1517
1587
|
inputId,
|
|
1518
|
-
inputNodeId
|
|
1588
|
+
inputNodeId,
|
|
1589
|
+
...bendPoint ? { bendPoint } : {}
|
|
1519
1590
|
};
|
|
1520
1591
|
}
|
|
1592
|
+
function serializeConnectionTargetTitle(targetTitle) {
|
|
1593
|
+
return targetTitle.replaceAll(CONNECTION_BEND_MARKER, CONNECTION_BEND_MARKER_TITLE_FALLBACK);
|
|
1594
|
+
}
|
|
1595
|
+
function deserializeConnectionBendPoint(targetTitle) {
|
|
1596
|
+
const match10 = targetTitle == null ? void 0 : targetTitle.match(CONNECTION_BEND_PATTERN);
|
|
1597
|
+
if (!match10) {
|
|
1598
|
+
return void 0;
|
|
1599
|
+
}
|
|
1600
|
+
const x = Number.parseFloat(match10[1]);
|
|
1601
|
+
const y = Number.parseFloat(match10[2]);
|
|
1602
|
+
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : void 0;
|
|
1603
|
+
}
|
|
1521
1604
|
function parseOptionalFloat(val) {
|
|
1522
1605
|
return val === "null" || val === void 0 || val === "" ? void 0 : parseFloat(val);
|
|
1523
1606
|
}
|
|
@@ -1651,7 +1734,7 @@ function emptyNodeGraph() {
|
|
|
1651
1734
|
connections: [],
|
|
1652
1735
|
metadata: {
|
|
1653
1736
|
id: (0, import_non_secure.nanoid)(),
|
|
1654
|
-
name: "Untitled
|
|
1737
|
+
name: "Untitled graph",
|
|
1655
1738
|
description: ""
|
|
1656
1739
|
}
|
|
1657
1740
|
};
|
|
@@ -1682,25 +1765,56 @@ function graphV4Serializer(graph) {
|
|
|
1682
1765
|
return wrapInYamlEnvelope(4, toSerializedGraph(graph));
|
|
1683
1766
|
}
|
|
1684
1767
|
function toSerializedProject(project, attachedData) {
|
|
1768
|
+
const nodePrefabs = (0, import_lodash_es2.mapValues)(project.nodePrefabs ?? {}, (prefab) => ({
|
|
1769
|
+
id: prefab.id,
|
|
1770
|
+
sourceNode: toSerializedIsolatedNode(prefab.sourceNode)
|
|
1771
|
+
}));
|
|
1685
1772
|
return {
|
|
1686
1773
|
metadata: project.metadata,
|
|
1687
1774
|
graphs: (0, import_lodash_es2.mapValues)(project.graphs, (graph) => toSerializedGraph(graph)),
|
|
1775
|
+
nodePrefabs: Object.keys(nodePrefabs).length > 0 ? nodePrefabs : void 0,
|
|
1776
|
+
uiGraphs: project.uiGraphs && Object.keys(project.uiGraphs).length > 0 ? project.uiGraphs : void 0,
|
|
1688
1777
|
attachedData,
|
|
1689
1778
|
plugins: project.plugins ?? [],
|
|
1690
1779
|
references: project.references ?? []
|
|
1691
1780
|
};
|
|
1692
1781
|
}
|
|
1693
1782
|
function fromSerializedProject2(serializedProject) {
|
|
1783
|
+
const nodePrefabs = (0, import_lodash_es2.mapValues)(serializedProject.nodePrefabs ?? {}, (prefab) => ({
|
|
1784
|
+
id: prefab.id,
|
|
1785
|
+
sourceNode: fromSerializedIsolatedNode(prefab.sourceNode)
|
|
1786
|
+
}));
|
|
1694
1787
|
return [
|
|
1695
1788
|
{
|
|
1696
1789
|
metadata: serializedProject.metadata,
|
|
1697
1790
|
graphs: (0, import_lodash_es2.mapValues)(serializedProject.graphs, (graph) => fromSerializedGraph2(graph)),
|
|
1791
|
+
nodePrefabs: Object.keys(nodePrefabs).length > 0 ? nodePrefabs : void 0,
|
|
1792
|
+
uiGraphs: serializedProject.uiGraphs && Object.keys(serializedProject.uiGraphs).length > 0 ? serializedProject.uiGraphs : void 0,
|
|
1698
1793
|
plugins: serializedProject.plugins ?? [],
|
|
1699
1794
|
references: serializedProject.references ?? []
|
|
1700
1795
|
},
|
|
1701
1796
|
serializedProject.attachedData ?? {}
|
|
1702
1797
|
];
|
|
1703
1798
|
}
|
|
1799
|
+
function toSerializedIsolatedNode(node) {
|
|
1800
|
+
const { outgoingConnections: _outgoingConnections, ...serializedNode } = toSerializedNode(node, [node], []);
|
|
1801
|
+
return {
|
|
1802
|
+
...serializedNode,
|
|
1803
|
+
id: node.id,
|
|
1804
|
+
type: node.type,
|
|
1805
|
+
title: node.title
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
function fromSerializedIsolatedNode(serializedNode) {
|
|
1809
|
+
const [node] = fromSerializedNode2(
|
|
1810
|
+
{
|
|
1811
|
+
...serializedNode,
|
|
1812
|
+
outgoingConnections: void 0
|
|
1813
|
+
},
|
|
1814
|
+
`[${serializedNode.id}]:${serializedNode.type} "${serializedNode.title}"`
|
|
1815
|
+
);
|
|
1816
|
+
return node;
|
|
1817
|
+
}
|
|
1704
1818
|
function toSerializedGraph(graph) {
|
|
1705
1819
|
const graphMetadata = {
|
|
1706
1820
|
id: graph.metadata.id,
|
|
@@ -2242,6 +2356,412 @@ function parseProviderJsonChunk(provider, chunk) {
|
|
|
2242
2356
|
}
|
|
2243
2357
|
}
|
|
2244
2358
|
|
|
2359
|
+
// src/utils/projectComparison/connections.ts
|
|
2360
|
+
var import_safe_stable_stringify3 = __toESM(require("safe-stable-stringify"), 1);
|
|
2361
|
+
|
|
2362
|
+
// src/utils/projectComparison/values.ts
|
|
2363
|
+
var import_safe_stable_stringify2 = __toESM(require("safe-stable-stringify"), 1);
|
|
2364
|
+
function areComparisonValuesEqual(left, right) {
|
|
2365
|
+
return (0, import_safe_stable_stringify2.default)(left) === (0, import_safe_stable_stringify2.default)(right);
|
|
2366
|
+
}
|
|
2367
|
+
function getChangedValueComparisons(path, before, after) {
|
|
2368
|
+
if (areComparisonValuesEqual(before, after)) {
|
|
2369
|
+
return [];
|
|
2370
|
+
}
|
|
2371
|
+
if (Array.isArray(before) && Array.isArray(after)) {
|
|
2372
|
+
return Array.from({ length: Math.max(before.length, after.length) }).flatMap(
|
|
2373
|
+
(_value, index) => getChangedValueComparisons([...path, String(index)], before[index], after[index])
|
|
2374
|
+
);
|
|
2375
|
+
}
|
|
2376
|
+
if (isComparisonRecord(before) && isComparisonRecord(after)) {
|
|
2377
|
+
return unionKeys(before, after).flatMap(
|
|
2378
|
+
(key) => getChangedValueComparisons([...path, key], before[key], after[key])
|
|
2379
|
+
);
|
|
2380
|
+
}
|
|
2381
|
+
return [
|
|
2382
|
+
{
|
|
2383
|
+
after,
|
|
2384
|
+
before,
|
|
2385
|
+
field: formatComparisonPath(path),
|
|
2386
|
+
path
|
|
2387
|
+
}
|
|
2388
|
+
];
|
|
2389
|
+
}
|
|
2390
|
+
function isComparisonRecord(value) {
|
|
2391
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
2392
|
+
}
|
|
2393
|
+
function unionKeys(left, right) {
|
|
2394
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])].sort();
|
|
2395
|
+
}
|
|
2396
|
+
function formatComparisonPath(path) {
|
|
2397
|
+
return path.reduce((formatted, segment) => {
|
|
2398
|
+
if (/^\d+$/.test(segment)) {
|
|
2399
|
+
return `${formatted}[${segment}]`;
|
|
2400
|
+
}
|
|
2401
|
+
if (formatted.length === 0) {
|
|
2402
|
+
return segment;
|
|
2403
|
+
}
|
|
2404
|
+
return /^[A-Za-z_$][\w$]*$/.test(segment) ? `${formatted}.${segment}` : `${formatted}[${JSON.stringify(segment)}]`;
|
|
2405
|
+
}, "");
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
// src/utils/projectComparison/connections.ts
|
|
2409
|
+
function getProjectConnectionComparisonKey(connection) {
|
|
2410
|
+
return (0, import_safe_stable_stringify3.default)([
|
|
2411
|
+
connection.outputNodeId,
|
|
2412
|
+
connection.outputId,
|
|
2413
|
+
connection.inputNodeId,
|
|
2414
|
+
connection.inputId
|
|
2415
|
+
]);
|
|
2416
|
+
}
|
|
2417
|
+
function getComparableGraphConnections(connections, nodes) {
|
|
2418
|
+
const commentNodeIds = new Set(nodes.filter((node) => node.type === "comment").map((node) => node.id));
|
|
2419
|
+
return connections.filter(
|
|
2420
|
+
(connection) => !commentNodeIds.has(connection.outputNodeId) && !commentNodeIds.has(connection.inputNodeId)
|
|
2421
|
+
);
|
|
2422
|
+
}
|
|
2423
|
+
function compareConnections(beforeConnections, afterConnections) {
|
|
2424
|
+
const beforeByKey = new Map(beforeConnections.map((connection) => [getProjectConnectionComparisonKey(connection), connection]));
|
|
2425
|
+
const afterByKey = new Map(afterConnections.map((connection) => [getProjectConnectionComparisonKey(connection), connection]));
|
|
2426
|
+
const removedKeys = beforeConnections.map(getProjectConnectionComparisonKey).filter((key) => !afterByKey.has(key));
|
|
2427
|
+
const addedKeys = afterConnections.map(getProjectConnectionComparisonKey).filter((key) => !beforeByKey.has(key));
|
|
2428
|
+
const changedRemovedKeys = /* @__PURE__ */ new Set();
|
|
2429
|
+
const changedAddedKeys = /* @__PURE__ */ new Set();
|
|
2430
|
+
for (const addedKey of addedKeys) {
|
|
2431
|
+
const addedConnection = afterByKey.get(addedKey);
|
|
2432
|
+
const matchingRemovedKey = removedKeys.find((removedKey) => {
|
|
2433
|
+
if (changedRemovedKeys.has(removedKey)) {
|
|
2434
|
+
return false;
|
|
2435
|
+
}
|
|
2436
|
+
const removedConnection = beforeByKey.get(removedKey);
|
|
2437
|
+
return removedConnection.outputNodeId === addedConnection.outputNodeId && removedConnection.inputNodeId === addedConnection.inputNodeId;
|
|
2438
|
+
});
|
|
2439
|
+
if (matchingRemovedKey) {
|
|
2440
|
+
changedRemovedKeys.add(matchingRemovedKey);
|
|
2441
|
+
changedAddedKeys.add(addedKey);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
return Object.fromEntries(
|
|
2445
|
+
unionKeys(Object.fromEntries(beforeByKey), Object.fromEntries(afterByKey)).map((key) => {
|
|
2446
|
+
const before = beforeByKey.get(key);
|
|
2447
|
+
const after = afterByKey.get(key);
|
|
2448
|
+
const kind = changedAddedKeys.has(key) || changedRemovedKeys.has(key) ? "changed" : !before && after ? "added" : before && !after ? "removed" : "unchanged";
|
|
2449
|
+
return [
|
|
2450
|
+
key,
|
|
2451
|
+
{
|
|
2452
|
+
key,
|
|
2453
|
+
kind,
|
|
2454
|
+
before,
|
|
2455
|
+
after
|
|
2456
|
+
}
|
|
2457
|
+
];
|
|
2458
|
+
})
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
// src/utils/projectComparison/nodes.ts
|
|
2463
|
+
function getProjectNodeFieldComparisons(comparison) {
|
|
2464
|
+
const before = comparison.before;
|
|
2465
|
+
const after = comparison.after;
|
|
2466
|
+
if (!before || !after) {
|
|
2467
|
+
return [];
|
|
2468
|
+
}
|
|
2469
|
+
return getChangedValueComparisons([], getComparableNodeRecord(before), getComparableNodeRecord(after));
|
|
2470
|
+
}
|
|
2471
|
+
function getComparableGraphNodes(nodes) {
|
|
2472
|
+
return nodes.filter((node) => node.type !== "comment");
|
|
2473
|
+
}
|
|
2474
|
+
function compareNodes(beforeNodes, afterNodes) {
|
|
2475
|
+
const beforeById = new Map(beforeNodes.map((node) => [node.id, node]));
|
|
2476
|
+
const afterById = new Map(afterNodes.map((node) => [node.id, node]));
|
|
2477
|
+
const nodeIds = unionKeys(Object.fromEntries(beforeById), Object.fromEntries(afterById));
|
|
2478
|
+
return Object.fromEntries(
|
|
2479
|
+
nodeIds.map((nodeId) => {
|
|
2480
|
+
const before = beforeById.get(nodeId);
|
|
2481
|
+
const after = afterById.get(nodeId);
|
|
2482
|
+
if (!before && after) {
|
|
2483
|
+
return [nodeId, { id: nodeId, kind: "added", after }];
|
|
2484
|
+
}
|
|
2485
|
+
if (before && !after) {
|
|
2486
|
+
return [nodeId, { id: nodeId, kind: "removed", before }];
|
|
2487
|
+
}
|
|
2488
|
+
return [
|
|
2489
|
+
nodeId,
|
|
2490
|
+
{
|
|
2491
|
+
id: nodeId,
|
|
2492
|
+
kind: areComparisonNodesEqual(before, after) ? "unchanged" : "changed",
|
|
2493
|
+
before,
|
|
2494
|
+
after
|
|
2495
|
+
}
|
|
2496
|
+
];
|
|
2497
|
+
})
|
|
2498
|
+
);
|
|
2499
|
+
}
|
|
2500
|
+
function areComparisonNodesEqual(left, right) {
|
|
2501
|
+
return areComparisonValuesEqual(
|
|
2502
|
+
left ? getComparableNodeRecord(left) : left,
|
|
2503
|
+
right ? getComparableNodeRecord(right) : right
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
function getComparableNodeRecord(node) {
|
|
2507
|
+
const { data, visualData: _visualData, ...rest } = node;
|
|
2508
|
+
return {
|
|
2509
|
+
...rest,
|
|
2510
|
+
data: getComparableNodeData(node, data)
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
function getComparableNodeData(node, data) {
|
|
2514
|
+
if (node.type !== "subGraph" || !isComparisonRecord(data)) {
|
|
2515
|
+
return data;
|
|
2516
|
+
}
|
|
2517
|
+
const { inputPortOrder: _inputPortOrder, outputPortOrder: _outputPortOrder, ...semanticData } = data;
|
|
2518
|
+
return semanticData;
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
// src/utils/projectComparison/summaries.ts
|
|
2522
|
+
function summarizeProjectComparison(graphs, nodePrefabs = {}, uiGraphs = {}) {
|
|
2523
|
+
const summary = Object.values(graphs).reduce((acc, graph) => {
|
|
2524
|
+
if (graph.kind === "added")
|
|
2525
|
+
acc.addedGraphs += 1;
|
|
2526
|
+
if (graph.kind === "removed")
|
|
2527
|
+
acc.removedGraphs += 1;
|
|
2528
|
+
if (graph.kind === "changed")
|
|
2529
|
+
acc.changedGraphs += 1;
|
|
2530
|
+
acc.addedNodes += graph.summary.addedNodes;
|
|
2531
|
+
acc.removedNodes += graph.summary.removedNodes;
|
|
2532
|
+
acc.changedNodes += graph.summary.changedNodes;
|
|
2533
|
+
acc.addedConnections += graph.summary.addedConnections;
|
|
2534
|
+
acc.removedConnections += graph.summary.removedConnections;
|
|
2535
|
+
acc.changedConnections += graph.summary.changedConnections;
|
|
2536
|
+
return acc;
|
|
2537
|
+
}, createEmptyProjectSummary());
|
|
2538
|
+
for (const prefab of Object.values(nodePrefabs)) {
|
|
2539
|
+
if (prefab.kind === "added")
|
|
2540
|
+
summary.addedNodePrefabs = (summary.addedNodePrefabs ?? 0) + 1;
|
|
2541
|
+
if (prefab.kind === "removed")
|
|
2542
|
+
summary.removedNodePrefabs = (summary.removedNodePrefabs ?? 0) + 1;
|
|
2543
|
+
if (prefab.kind === "changed")
|
|
2544
|
+
summary.changedNodePrefabs = (summary.changedNodePrefabs ?? 0) + 1;
|
|
2545
|
+
}
|
|
2546
|
+
for (const uiGraph of Object.values(uiGraphs)) {
|
|
2547
|
+
if (uiGraph.kind === "added")
|
|
2548
|
+
summary.addedUiGraphs = (summary.addedUiGraphs ?? 0) + 1;
|
|
2549
|
+
if (uiGraph.kind === "removed")
|
|
2550
|
+
summary.removedUiGraphs = (summary.removedUiGraphs ?? 0) + 1;
|
|
2551
|
+
if (uiGraph.kind === "changed")
|
|
2552
|
+
summary.changedUiGraphs = (summary.changedUiGraphs ?? 0) + 1;
|
|
2553
|
+
}
|
|
2554
|
+
return summary;
|
|
2555
|
+
}
|
|
2556
|
+
function summarizeGraphComparison(nodes, connections) {
|
|
2557
|
+
const nodeComparisons = Object.values(nodes);
|
|
2558
|
+
const connectionComparisons = Object.values(connections);
|
|
2559
|
+
return {
|
|
2560
|
+
addedNodes: nodeComparisons.filter((node) => node.kind === "added").length,
|
|
2561
|
+
removedNodes: nodeComparisons.filter((node) => node.kind === "removed").length,
|
|
2562
|
+
changedNodes: nodeComparisons.filter((node) => node.kind === "changed").length,
|
|
2563
|
+
addedConnections: connectionComparisons.filter((connection) => connection.kind === "added").length,
|
|
2564
|
+
removedConnections: connectionComparisons.filter((connection) => connection.kind === "removed").length,
|
|
2565
|
+
changedConnections: connectionComparisons.filter((connection) => connection.kind === "changed" && connection.after).length
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
function createEmptyProjectSummary() {
|
|
2569
|
+
return {
|
|
2570
|
+
addedGraphs: 0,
|
|
2571
|
+
removedGraphs: 0,
|
|
2572
|
+
changedGraphs: 0,
|
|
2573
|
+
addedNodes: 0,
|
|
2574
|
+
removedNodes: 0,
|
|
2575
|
+
changedNodes: 0,
|
|
2576
|
+
addedConnections: 0,
|
|
2577
|
+
removedConnections: 0,
|
|
2578
|
+
changedConnections: 0
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
// src/utils/projectComparison/graphs.ts
|
|
2583
|
+
function compareGraphs(id, before, after) {
|
|
2584
|
+
if (!before && after) {
|
|
2585
|
+
return createOneSidedGraphComparison(id, after, "added");
|
|
2586
|
+
}
|
|
2587
|
+
if (before && !after) {
|
|
2588
|
+
return createOneSidedGraphComparison(id, before, "removed");
|
|
2589
|
+
}
|
|
2590
|
+
if (!before || !after) {
|
|
2591
|
+
throw new Error(`Cannot compare missing graph ${id}`);
|
|
2592
|
+
}
|
|
2593
|
+
const nodes = compareNodes(getComparableGraphNodes(before.nodes), getComparableGraphNodes(after.nodes));
|
|
2594
|
+
const connections = compareConnections(
|
|
2595
|
+
getComparableGraphConnections(before.connections, before.nodes),
|
|
2596
|
+
getComparableGraphConnections(after.connections, after.nodes)
|
|
2597
|
+
);
|
|
2598
|
+
const summary = summarizeGraphComparison(nodes, connections);
|
|
2599
|
+
const metadataChanged = !areComparisonValuesEqual(before.metadata, after.metadata);
|
|
2600
|
+
return {
|
|
2601
|
+
id,
|
|
2602
|
+
kind: metadataChanged || Object.values(summary).some((count) => count > 0) ? "changed" : "unchanged",
|
|
2603
|
+
before,
|
|
2604
|
+
after,
|
|
2605
|
+
metadataChanged,
|
|
2606
|
+
nodes,
|
|
2607
|
+
connections,
|
|
2608
|
+
summary
|
|
2609
|
+
};
|
|
2610
|
+
}
|
|
2611
|
+
function createOneSidedGraphComparison(id, graph, kind) {
|
|
2612
|
+
const graphNodes = getComparableGraphNodes(graph.nodes);
|
|
2613
|
+
const graphConnections = getComparableGraphConnections(graph.connections, graph.nodes);
|
|
2614
|
+
const nodes = Object.fromEntries(
|
|
2615
|
+
graphNodes.map((node) => [
|
|
2616
|
+
node.id,
|
|
2617
|
+
kind === "added" ? { id: node.id, kind, after: node } : { id: node.id, kind, before: node }
|
|
2618
|
+
])
|
|
2619
|
+
);
|
|
2620
|
+
const connections = createOneSidedConnectionComparisons(graphConnections, kind);
|
|
2621
|
+
return {
|
|
2622
|
+
id,
|
|
2623
|
+
kind,
|
|
2624
|
+
...kind === "added" ? { after: graph } : { before: graph },
|
|
2625
|
+
metadataChanged: true,
|
|
2626
|
+
nodes,
|
|
2627
|
+
connections,
|
|
2628
|
+
summary: summarizeGraphComparison(nodes, connections)
|
|
2629
|
+
};
|
|
2630
|
+
}
|
|
2631
|
+
function createOneSidedConnectionComparisons(connections, kind) {
|
|
2632
|
+
return Object.fromEntries(
|
|
2633
|
+
connections.map((connection) => {
|
|
2634
|
+
const key = getProjectConnectionComparisonKey(connection);
|
|
2635
|
+
return [
|
|
2636
|
+
key,
|
|
2637
|
+
kind === "added" ? { key, kind, after: connection } : { key, kind, before: connection }
|
|
2638
|
+
];
|
|
2639
|
+
})
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
// src/utils/projectComparison.ts
|
|
2644
|
+
function compareProjects(before, after) {
|
|
2645
|
+
const graphIds = unionKeys(before.graphs, after.graphs);
|
|
2646
|
+
const graphs = Object.fromEntries(
|
|
2647
|
+
graphIds.map((graphId) => [graphId, compareGraphs(graphId, before.graphs[graphId], after.graphs[graphId])])
|
|
2648
|
+
);
|
|
2649
|
+
const nodePrefabs = compareNodePrefabs(before.nodePrefabs ?? {}, after.nodePrefabs ?? {});
|
|
2650
|
+
const uiGraphs = compareUiGraphs(before.uiGraphs ?? {}, after.uiGraphs ?? {});
|
|
2651
|
+
return {
|
|
2652
|
+
beforeProjectId: before.metadata.id,
|
|
2653
|
+
afterProjectId: after.metadata.id,
|
|
2654
|
+
metadataChanged: !areComparisonValuesEqual(before.metadata, after.metadata),
|
|
2655
|
+
graphs,
|
|
2656
|
+
nodePrefabs,
|
|
2657
|
+
uiGraphs,
|
|
2658
|
+
summary: summarizeProjectComparison(graphs, nodePrefabs, uiGraphs)
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
function compareNodePrefabs(before, after) {
|
|
2662
|
+
const prefabIds = unionKeys(before, after);
|
|
2663
|
+
return Object.fromEntries(
|
|
2664
|
+
prefabIds.map((prefabId) => {
|
|
2665
|
+
const beforePrefab = before[prefabId];
|
|
2666
|
+
const afterPrefab = after[prefabId];
|
|
2667
|
+
if (!beforePrefab && afterPrefab) {
|
|
2668
|
+
return [prefabId, { id: prefabId, kind: "added", after: afterPrefab }];
|
|
2669
|
+
}
|
|
2670
|
+
if (beforePrefab && !afterPrefab) {
|
|
2671
|
+
return [prefabId, { id: prefabId, kind: "removed", before: beforePrefab }];
|
|
2672
|
+
}
|
|
2673
|
+
if (!beforePrefab || !afterPrefab) {
|
|
2674
|
+
throw new Error(`Cannot compare missing library node ${prefabId}`);
|
|
2675
|
+
}
|
|
2676
|
+
const sourceNodeComparison = Object.values(compareNodes([beforePrefab.sourceNode], [afterPrefab.sourceNode]))[0];
|
|
2677
|
+
return [
|
|
2678
|
+
prefabId,
|
|
2679
|
+
{
|
|
2680
|
+
id: prefabId,
|
|
2681
|
+
kind: sourceNodeComparison.kind === "unchanged" ? "unchanged" : "changed",
|
|
2682
|
+
before: beforePrefab,
|
|
2683
|
+
after: afterPrefab,
|
|
2684
|
+
sourceNode: sourceNodeComparison
|
|
2685
|
+
}
|
|
2686
|
+
];
|
|
2687
|
+
})
|
|
2688
|
+
);
|
|
2689
|
+
}
|
|
2690
|
+
function compareUiGraphs(before, after) {
|
|
2691
|
+
const uiGraphIds = unionKeys(before, after);
|
|
2692
|
+
return Object.fromEntries(
|
|
2693
|
+
uiGraphIds.map((uiGraphId) => {
|
|
2694
|
+
const beforeUiGraph = before[uiGraphId];
|
|
2695
|
+
const afterUiGraph = after[uiGraphId];
|
|
2696
|
+
if (!beforeUiGraph && afterUiGraph) {
|
|
2697
|
+
return [uiGraphId, { id: uiGraphId, kind: "added", after: afterUiGraph }];
|
|
2698
|
+
}
|
|
2699
|
+
if (beforeUiGraph && !afterUiGraph) {
|
|
2700
|
+
return [uiGraphId, { id: uiGraphId, kind: "removed", before: beforeUiGraph }];
|
|
2701
|
+
}
|
|
2702
|
+
if (!beforeUiGraph || !afterUiGraph) {
|
|
2703
|
+
throw new Error(`Cannot compare missing UI graph ${uiGraphId}`);
|
|
2704
|
+
}
|
|
2705
|
+
return [
|
|
2706
|
+
uiGraphId,
|
|
2707
|
+
{
|
|
2708
|
+
id: uiGraphId,
|
|
2709
|
+
kind: areComparisonValuesEqual(beforeUiGraph, afterUiGraph) ? "unchanged" : "changed",
|
|
2710
|
+
before: beforeUiGraph,
|
|
2711
|
+
after: afterUiGraph
|
|
2712
|
+
}
|
|
2713
|
+
];
|
|
2714
|
+
})
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
// src/utils/jsonValueToDataValue.ts
|
|
2719
|
+
function jsonValueToDataValue(value) {
|
|
2720
|
+
if (isDataValue(value)) {
|
|
2721
|
+
return value;
|
|
2722
|
+
}
|
|
2723
|
+
if (typeof value === "string") {
|
|
2724
|
+
return { type: "string", value };
|
|
2725
|
+
}
|
|
2726
|
+
if (typeof value === "number") {
|
|
2727
|
+
return { type: "number", value };
|
|
2728
|
+
}
|
|
2729
|
+
if (typeof value === "boolean") {
|
|
2730
|
+
return { type: "boolean", value };
|
|
2731
|
+
}
|
|
2732
|
+
if (Array.isArray(value)) {
|
|
2733
|
+
return jsonArrayToDataValue(value);
|
|
2734
|
+
}
|
|
2735
|
+
if (isRecord(value)) {
|
|
2736
|
+
return { type: "object", value };
|
|
2737
|
+
}
|
|
2738
|
+
return { type: "any", value };
|
|
2739
|
+
}
|
|
2740
|
+
function jsonArrayToDataValue(value) {
|
|
2741
|
+
if (value.length === 0) {
|
|
2742
|
+
return { type: "any[]", value: [] };
|
|
2743
|
+
}
|
|
2744
|
+
if (value.every((item) => typeof item === "string")) {
|
|
2745
|
+
return { type: "string[]", value };
|
|
2746
|
+
}
|
|
2747
|
+
if (value.every((item) => typeof item === "number")) {
|
|
2748
|
+
return { type: "number[]", value };
|
|
2749
|
+
}
|
|
2750
|
+
if (value.every((item) => typeof item === "boolean")) {
|
|
2751
|
+
return { type: "boolean[]", value };
|
|
2752
|
+
}
|
|
2753
|
+
if (value.every(isRecord)) {
|
|
2754
|
+
return { type: "object[]", value };
|
|
2755
|
+
}
|
|
2756
|
+
return { type: "any[]", value };
|
|
2757
|
+
}
|
|
2758
|
+
function isDataValue(value) {
|
|
2759
|
+
return value != null && typeof value === "object" && typeof value.type === "string" && "value" in value;
|
|
2760
|
+
}
|
|
2761
|
+
function isRecord(value) {
|
|
2762
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2245
2765
|
// src/utils/pQueueCompat.ts
|
|
2246
2766
|
var import_p_queue = __toESM(require("p-queue-6"), 1);
|
|
2247
2767
|
var PQueue = typeof import_p_queue.default === "function" ? import_p_queue.default : import_p_queue.default.default;
|
|
@@ -2295,15 +2815,76 @@ function findStronglyConnectedComponents(nodes, getAdjacentNodes) {
|
|
|
2295
2815
|
return stronglyConnectedComponents;
|
|
2296
2816
|
}
|
|
2297
2817
|
|
|
2818
|
+
// src/model/NodePrefabResolver.ts
|
|
2819
|
+
var NODE_PREFAB_INSTANCE_TYPE = "nodePrefabInstance";
|
|
2820
|
+
var BLOCKED_NODE_PREFAB_SOURCE_TYPES = /* @__PURE__ */ new Set([
|
|
2821
|
+
"comment",
|
|
2822
|
+
"graphInput",
|
|
2823
|
+
"graphOutput",
|
|
2824
|
+
"referencedGraphAlias",
|
|
2825
|
+
NODE_PREFAB_INSTANCE_TYPE
|
|
2826
|
+
]);
|
|
2827
|
+
function isNodePrefabInstanceNode(node) {
|
|
2828
|
+
return (node == null ? void 0 : node.type) === NODE_PREFAB_INSTANCE_TYPE;
|
|
2829
|
+
}
|
|
2830
|
+
function canUseNodeAsPrefabSource(node) {
|
|
2831
|
+
return !BLOCKED_NODE_PREFAB_SOURCE_TYPES.has(node.type);
|
|
2832
|
+
}
|
|
2833
|
+
function getNodePrefabInstancePrefabId(node) {
|
|
2834
|
+
var _a;
|
|
2835
|
+
if (!isNodePrefabInstanceNode(node)) {
|
|
2836
|
+
return void 0;
|
|
2837
|
+
}
|
|
2838
|
+
const prefabId = (_a = node.data) == null ? void 0 : _a.prefabId;
|
|
2839
|
+
return typeof prefabId === "string" && prefabId.length > 0 ? prefabId : void 0;
|
|
2840
|
+
}
|
|
2841
|
+
function resolveNodePrefabInstance(project, node) {
|
|
2842
|
+
var _a, _b;
|
|
2843
|
+
const prefabId = getNodePrefabInstancePrefabId(node);
|
|
2844
|
+
if (!prefabId) {
|
|
2845
|
+
return node;
|
|
2846
|
+
}
|
|
2847
|
+
const sourceNode = (_b = (_a = project.nodePrefabs) == null ? void 0 : _a[prefabId]) == null ? void 0 : _b.sourceNode;
|
|
2848
|
+
if (!sourceNode || !canUseNodeAsPrefabSource(sourceNode)) {
|
|
2849
|
+
return {
|
|
2850
|
+
...node,
|
|
2851
|
+
title: `Missing library node (${prefabId})`
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
return {
|
|
2855
|
+
...structuredClone(sourceNode),
|
|
2856
|
+
id: node.id,
|
|
2857
|
+
visualData: {
|
|
2858
|
+
...structuredClone(sourceNode.visualData),
|
|
2859
|
+
x: node.visualData.x,
|
|
2860
|
+
y: node.visualData.y,
|
|
2861
|
+
width: node.visualData.width ?? sourceNode.visualData.width,
|
|
2862
|
+
zIndex: node.visualData.zIndex
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
}
|
|
2866
|
+
function resolveNodePrefabInstances(project, nodes) {
|
|
2867
|
+
return nodes.map((node) => resolveNodePrefabInstance(project, node));
|
|
2868
|
+
}
|
|
2869
|
+
function getNodePrefabDisplayName(project, prefabId) {
|
|
2870
|
+
var _a, _b;
|
|
2871
|
+
if (!prefabId) {
|
|
2872
|
+
return "Missing library node";
|
|
2873
|
+
}
|
|
2874
|
+
const sourceNode = (_b = (_a = project.nodePrefabs) == null ? void 0 : _a[prefabId]) == null ? void 0 : _b.sourceNode;
|
|
2875
|
+
return sourceNode && canUseNodeAsPrefabSource(sourceNode) ? sourceNode.title || "Untitled library node" : "Missing library node";
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2298
2878
|
// src/model/GraphPreprocessor.ts
|
|
2299
2879
|
function preprocessGraphState(options2) {
|
|
2300
2880
|
var _a, _b;
|
|
2301
2881
|
const { buildExecutionPlan, definitionContext, graph, loadedProjects, project, registry, warnOnInvalidGraph } = options2;
|
|
2302
|
-
const
|
|
2882
|
+
const graphNodes = resolveNodePrefabInstances(project, graph.nodes);
|
|
2883
|
+
const effectiveDefinitionContext = definitionContext && graphNodes.some(usesGraphBoundaryDefinitionContext) ? definitionContext : void 0;
|
|
2303
2884
|
const nodeInstances = {};
|
|
2304
2885
|
const nodesById = {};
|
|
2305
2886
|
const connections = {};
|
|
2306
|
-
for (const node of
|
|
2887
|
+
for (const node of graphNodes) {
|
|
2307
2888
|
nodeInstances[node.id] = registry.createDynamicImpl(node);
|
|
2308
2889
|
nodesById[node.id] = node;
|
|
2309
2890
|
}
|
|
@@ -2336,7 +2917,7 @@ function preprocessGraphState(options2) {
|
|
|
2336
2917
|
definitionContext: effectiveDefinitionContext,
|
|
2337
2918
|
warnOnInvalidGraph
|
|
2338
2919
|
});
|
|
2339
|
-
const stronglyConnectedComponents = findStronglyConnectedComponents(
|
|
2920
|
+
const stronglyConnectedComponents = findStronglyConnectedComponents(graphNodes, (node) => {
|
|
2340
2921
|
const nodeConnections = connections[node.id] ?? [];
|
|
2341
2922
|
return nodeConnections.filter((connection) => connection.outputNodeId === node.id).map((connection) => nodesById[connection.inputNodeId]).filter(Boolean);
|
|
2342
2923
|
});
|
|
@@ -2357,7 +2938,7 @@ function preprocessGraphState(options2) {
|
|
|
2357
2938
|
...buildGraphExecutionPlan({
|
|
2358
2939
|
connections,
|
|
2359
2940
|
definitions,
|
|
2360
|
-
graphNodes
|
|
2941
|
+
graphNodes,
|
|
2361
2942
|
nodesById,
|
|
2362
2943
|
stronglyConnectedComponents
|
|
2363
2944
|
})
|
|
@@ -2621,6 +3202,7 @@ function buildGraphExecutionPlan(options2) {
|
|
|
2621
3202
|
}
|
|
2622
3203
|
|
|
2623
3204
|
// src/model/GraphBoundaryCache.ts
|
|
3205
|
+
var GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED = false;
|
|
2624
3206
|
function getGraphBoundary(project, graphId, cache4) {
|
|
2625
3207
|
if (!graphId) {
|
|
2626
3208
|
return void 0;
|
|
@@ -2640,8 +3222,33 @@ function getGraphBoundary(project, graphId, cache4) {
|
|
|
2640
3222
|
cache4.set(graph, boundary);
|
|
2641
3223
|
return boundary;
|
|
2642
3224
|
}
|
|
2643
|
-
function
|
|
2644
|
-
|
|
3225
|
+
function applyGraphBoundaryPortOrder(boundaryItems, portOrder) {
|
|
3226
|
+
if (!(portOrder == null ? void 0 : portOrder.length)) {
|
|
3227
|
+
return [...boundaryItems];
|
|
3228
|
+
}
|
|
3229
|
+
const itemsById = new Map(boundaryItems.map((item) => [item.id, item]));
|
|
3230
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
3231
|
+
const orderedItems = [];
|
|
3232
|
+
for (const id of portOrder) {
|
|
3233
|
+
if (usedIds.has(id)) {
|
|
3234
|
+
continue;
|
|
3235
|
+
}
|
|
3236
|
+
const item = itemsById.get(id);
|
|
3237
|
+
if (!item) {
|
|
3238
|
+
continue;
|
|
3239
|
+
}
|
|
3240
|
+
orderedItems.push(item);
|
|
3241
|
+
usedIds.add(id);
|
|
3242
|
+
}
|
|
3243
|
+
for (const item of boundaryItems) {
|
|
3244
|
+
if (!usedIds.has(item.id)) {
|
|
3245
|
+
orderedItems.push(item);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
return orderedItems;
|
|
3249
|
+
}
|
|
3250
|
+
function getGraphBoundaryInputDefinitions(boundary, inputPortOrder) {
|
|
3251
|
+
return applyGraphBoundaryPortOrder(boundary.inputs, inputPortOrder).map(
|
|
2645
3252
|
(input) => ({
|
|
2646
3253
|
id: input.portId,
|
|
2647
3254
|
title: input.id,
|
|
@@ -2649,8 +3256,8 @@ function getGraphBoundaryInputDefinitions(boundary) {
|
|
|
2649
3256
|
})
|
|
2650
3257
|
);
|
|
2651
3258
|
}
|
|
2652
|
-
function getGraphBoundaryOutputDefinitions(boundary) {
|
|
2653
|
-
return boundary.outputs.map(
|
|
3259
|
+
function getGraphBoundaryOutputDefinitions(boundary, outputPortOrder) {
|
|
3260
|
+
return applyGraphBoundaryPortOrder(boundary.outputs, outputPortOrder).map(
|
|
2654
3261
|
(output) => ({
|
|
2655
3262
|
id: output.portId,
|
|
2656
3263
|
title: output.id,
|
|
@@ -2683,6 +3290,9 @@ function buildExcludedGraphBoundaryOutputs(boundary) {
|
|
|
2683
3290
|
}
|
|
2684
3291
|
return outputs;
|
|
2685
3292
|
}
|
|
3293
|
+
function getRequestedGraphOutputNodeIds(boundary, requestedOutputPortIds) {
|
|
3294
|
+
return boundary.outputs.filter((output) => requestedOutputPortIds.has(output.portId)).map((output) => output.nodeId);
|
|
3295
|
+
}
|
|
2686
3296
|
function deriveGraphBoundary(graph) {
|
|
2687
3297
|
const inputsById = /* @__PURE__ */ new Map();
|
|
2688
3298
|
const outputsById = /* @__PURE__ */ new Map();
|
|
@@ -2700,6 +3310,7 @@ function deriveGraphBoundary(graph) {
|
|
|
2700
3310
|
outputsById.set(outputNode.data.id, {
|
|
2701
3311
|
dataType: outputNode.data.dataType,
|
|
2702
3312
|
id: outputNode.data.id,
|
|
3313
|
+
nodeId: outputNode.id,
|
|
2703
3314
|
portId: outputNode.data.id
|
|
2704
3315
|
});
|
|
2705
3316
|
}
|
|
@@ -2713,6 +3324,41 @@ function getBoundaryNodeId(node) {
|
|
|
2713
3324
|
return node.data.id;
|
|
2714
3325
|
}
|
|
2715
3326
|
|
|
3327
|
+
// src/model/GraphBoundaryEffects.ts
|
|
3328
|
+
function ensureGraphCostOutput(graphOutputs, totalCost) {
|
|
3329
|
+
const costPort = "cost";
|
|
3330
|
+
if (graphOutputs[costPort] == null) {
|
|
3331
|
+
graphOutputs[costPort] = {
|
|
3332
|
+
type: "number",
|
|
3333
|
+
value: totalCost
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
function applyFrozenGraphBoundaryEffects(graphOutputs, node, outputValues) {
|
|
3338
|
+
var _a;
|
|
3339
|
+
if (node.type === "graphOutput") {
|
|
3340
|
+
const outputId = (_a = node.data) == null ? void 0 : _a.id;
|
|
3341
|
+
const valueOutput = outputValues["valueOutput"];
|
|
3342
|
+
if (outputId && valueOutput) {
|
|
3343
|
+
graphOutputs[outputId] = valueOutput;
|
|
3344
|
+
}
|
|
3345
|
+
return void 0;
|
|
3346
|
+
}
|
|
3347
|
+
if (node.type !== "setGlobal") {
|
|
3348
|
+
return void 0;
|
|
3349
|
+
}
|
|
3350
|
+
const savedValue = outputValues["saved-value"];
|
|
3351
|
+
const variableId = outputValues["variable_id_out"];
|
|
3352
|
+
const variableIdValue = (variableId == null ? void 0 : variableId.type) === "string" ? variableId.value : void 0;
|
|
3353
|
+
if (!variableIdValue || !savedValue) {
|
|
3354
|
+
return void 0;
|
|
3355
|
+
}
|
|
3356
|
+
return {
|
|
3357
|
+
variableId: variableIdValue,
|
|
3358
|
+
value: savedValue
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
|
|
2716
3362
|
// src/model/RecordingPlayer.ts
|
|
2717
3363
|
var import_non_secure3 = require("nanoid/non-secure");
|
|
2718
3364
|
|
|
@@ -3049,11 +3695,13 @@ function didLoopControllerBreak(breakValue) {
|
|
|
3049
3695
|
function buildNodeProcessContext(options2) {
|
|
3050
3696
|
const {
|
|
3051
3697
|
attachedData,
|
|
3698
|
+
activeOutputPortIds,
|
|
3052
3699
|
base,
|
|
3053
3700
|
createSubProcessor,
|
|
3054
3701
|
execution,
|
|
3055
3702
|
externalFunctions,
|
|
3056
3703
|
getPluginConfig: getPluginConfig2,
|
|
3704
|
+
isDirectRunTarget,
|
|
3057
3705
|
node,
|
|
3058
3706
|
nodeAbortController,
|
|
3059
3707
|
onPartialOutputs,
|
|
@@ -3066,6 +3714,8 @@ function buildNodeProcessContext(options2) {
|
|
|
3066
3714
|
...base,
|
|
3067
3715
|
node,
|
|
3068
3716
|
attachedData,
|
|
3717
|
+
activeOutputPortIds,
|
|
3718
|
+
isDirectRunTarget,
|
|
3069
3719
|
waitEvent,
|
|
3070
3720
|
externalFunctions: { ...externalFunctions },
|
|
3071
3721
|
onPartialOutputs,
|
|
@@ -3638,6 +4288,50 @@ var NotAllowedCodeRunner = class {
|
|
|
3638
4288
|
};
|
|
3639
4289
|
|
|
3640
4290
|
// src/model/GraphProcessor.ts
|
|
4291
|
+
function cloneFrozenNodeOutputs(outputs) {
|
|
4292
|
+
if (typeof structuredClone !== "function") {
|
|
4293
|
+
throw new Error("Frozen node output cloning requires structuredClone support");
|
|
4294
|
+
}
|
|
4295
|
+
return structuredClone(outputs);
|
|
4296
|
+
}
|
|
4297
|
+
function cloneFrozenNodeOutputsByGraph(outputsByGraph) {
|
|
4298
|
+
return Object.fromEntries(
|
|
4299
|
+
Object.entries(outputsByGraph).map(([graphId, outputsByNode]) => [
|
|
4300
|
+
graphId,
|
|
4301
|
+
outputsByNode ? Object.fromEntries(
|
|
4302
|
+
Object.entries(outputsByNode).map(([nodeId, outputInstances]) => [
|
|
4303
|
+
nodeId,
|
|
4304
|
+
outputInstances == null ? void 0 : outputInstances.map((outputs) => cloneFrozenNodeOutputs(outputs))
|
|
4305
|
+
])
|
|
4306
|
+
) : void 0
|
|
4307
|
+
])
|
|
4308
|
+
);
|
|
4309
|
+
}
|
|
4310
|
+
function hasFrozenNodeOutputs(outputsByGraph) {
|
|
4311
|
+
if (!outputsByGraph) {
|
|
4312
|
+
return false;
|
|
4313
|
+
}
|
|
4314
|
+
return Object.values(outputsByGraph).some(
|
|
4315
|
+
(outputsByNode) => Object.values(outputsByNode ?? {}).some((outputInstances) => ((outputInstances == null ? void 0 : outputInstances.length) ?? 0) > 0)
|
|
4316
|
+
);
|
|
4317
|
+
}
|
|
4318
|
+
function createFrozenNodeOutputResolver(outputsByGraph) {
|
|
4319
|
+
if (!hasFrozenNodeOutputs(outputsByGraph)) {
|
|
4320
|
+
return void 0;
|
|
4321
|
+
}
|
|
4322
|
+
const countersByGraphRunAndNode = /* @__PURE__ */ new Map();
|
|
4323
|
+
return ({ execution, graphId, node }) => {
|
|
4324
|
+
var _a;
|
|
4325
|
+
const outputInstances = (_a = outputsByGraph == null ? void 0 : outputsByGraph[graphId]) == null ? void 0 : _a[node.id];
|
|
4326
|
+
if (!(outputInstances == null ? void 0 : outputInstances.length)) {
|
|
4327
|
+
return void 0;
|
|
4328
|
+
}
|
|
4329
|
+
const counterKey = `${execution.graphRunId}:${graphId}:${node.id}`;
|
|
4330
|
+
const currentIndex = countersByGraphRunAndNode.get(counterKey) ?? 0;
|
|
4331
|
+
countersByGraphRunAndNode.set(counterKey, currentIndex + 1);
|
|
4332
|
+
return cloneFrozenNodeOutputs(outputInstances[Math.min(currentIndex, outputInstances.length - 1)]);
|
|
4333
|
+
};
|
|
4334
|
+
}
|
|
3641
4335
|
var DEFAULT_NODE_CONCURRENCY = 8;
|
|
3642
4336
|
var DEFAULT_SPLIT_RUN_CONCURRENCY = 4;
|
|
3643
4337
|
var DEFAULT_ISOMORPHIC_CODE_RUNNER = new IsomorphicCodeRunner();
|
|
@@ -3705,6 +4399,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
3705
4399
|
#scheduler;
|
|
3706
4400
|
#runtimeProfiler;
|
|
3707
4401
|
#captureNodeTimings;
|
|
4402
|
+
#frozenNodeOutputResolver;
|
|
3708
4403
|
#useSeededExecutionPlanOnNextRun = false;
|
|
3709
4404
|
id = (0, import_non_secure4.nanoid)();
|
|
3710
4405
|
#includeTrace = true;
|
|
@@ -3752,6 +4447,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
3752
4447
|
#scc = void 0;
|
|
3753
4448
|
#graphExecutionPlan;
|
|
3754
4449
|
#nodeProcessContextBase = void 0;
|
|
4450
|
+
#runToRelevantNodeIds;
|
|
3755
4451
|
#nodesNotInCycle = void 0;
|
|
3756
4452
|
#nodeAbortControllers = /* @__PURE__ */ new Map();
|
|
3757
4453
|
#graphInputNodeValues = {};
|
|
@@ -3829,13 +4525,13 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
3829
4525
|
}
|
|
3830
4526
|
}
|
|
3831
4527
|
#preprocessGraph() {
|
|
3832
|
-
var _a;
|
|
4528
|
+
var _a, _b;
|
|
3833
4529
|
const profileStart = this.#startRuntimeProfile();
|
|
3834
4530
|
try {
|
|
3835
4531
|
const runtimeCache = this.#canUseRuntimeExecutionPlanCache() ? this.#runtimeCache : void 0;
|
|
3836
4532
|
const shouldUseRuntimeCache = runtimeCache != null;
|
|
3837
4533
|
const cachedPlan = (_a = runtimeCache == null ? void 0 : runtimeCache.executionPlans) == null ? void 0 : _a.get(this.#graph);
|
|
3838
|
-
if (cachedPlan) {
|
|
4534
|
+
if (cachedPlan && ((_b = runtimeCache == null ? void 0 : runtimeCache.executionPlanNodePrefabs) == null ? void 0 : _b.get(this.#graph)) === this.#project.nodePrefabs) {
|
|
3839
4535
|
this.#applyPreprocessedGraph(cachedPlan, { recreateNodeInstances: true });
|
|
3840
4536
|
return;
|
|
3841
4537
|
}
|
|
@@ -3852,7 +4548,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
3852
4548
|
});
|
|
3853
4549
|
if (shouldUseRuntimeCache && isGraphExecutionPlan(preprocessedGraph)) {
|
|
3854
4550
|
runtimeCache.executionPlans ??= /* @__PURE__ */ new WeakMap();
|
|
4551
|
+
runtimeCache.executionPlanNodePrefabs ??= /* @__PURE__ */ new WeakMap();
|
|
3855
4552
|
runtimeCache.executionPlans.set(this.#graph, toReusableGraphExecutionPlan(preprocessedGraph));
|
|
4553
|
+
runtimeCache.executionPlanNodePrefabs.set(this.#graph, this.#project.nodePrefabs);
|
|
3856
4554
|
}
|
|
3857
4555
|
this.#applyPreprocessedGraph(preprocessedGraph);
|
|
3858
4556
|
} finally {
|
|
@@ -3883,7 +4581,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
3883
4581
|
return getGraphBoundary(project, graphId, this.#runtimeCache.graphBoundaries);
|
|
3884
4582
|
}
|
|
3885
4583
|
#applyPreprocessedGraph(preprocessedGraph, options2 = {}) {
|
|
3886
|
-
const nodeInstances = options2.recreateNodeInstances || !("nodeInstances" in preprocessedGraph) ? this.#createNodeInstances(
|
|
4584
|
+
const nodeInstances = options2.recreateNodeInstances || !("nodeInstances" in preprocessedGraph) ? this.#createNodeInstances(
|
|
4585
|
+
isGraphExecutionPlan(preprocessedGraph) ? preprocessedGraph.graphNodes : Object.values(preprocessedGraph.nodesById)
|
|
4586
|
+
) : preprocessedGraph.nodeInstances;
|
|
3887
4587
|
replaceRecordContents(this.#nodeInstances, nodeInstances);
|
|
3888
4588
|
replaceRecordContents(this.#nodesById, preprocessedGraph.nodesById);
|
|
3889
4589
|
replaceRecordContents(this.#connections, preprocessedGraph.connections);
|
|
@@ -4046,6 +4746,9 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4046
4746
|
this.#visitedNodes.add(nodeId);
|
|
4047
4747
|
this.#hasPreloadedData = true;
|
|
4048
4748
|
}
|
|
4749
|
+
setFrozenNodeOutputResolver(resolver) {
|
|
4750
|
+
this.#frozenNodeOutputResolver = resolver;
|
|
4751
|
+
}
|
|
4049
4752
|
/** Gets all node IDs that a given node ID depends on being complete before the given node ID can start. */
|
|
4050
4753
|
getDependencyNodesDeep(nodeId) {
|
|
4051
4754
|
this.#ensureGraphPreprocessed();
|
|
@@ -4131,6 +4834,7 @@ var GraphProcessor = class _GraphProcessor {
|
|
|
4131
4834
|
this.#globals ??= /* @__PURE__ */ new Map();
|
|
4132
4835
|
this.#ignoreNodes = /* @__PURE__ */ new Set();
|
|
4133
4836
|
this.#nodeProcessContextBase = void 0;
|
|
4837
|
+
this.#runToRelevantNodeIds = void 0;
|
|
4134
4838
|
this.#abortController = this.#newAbortController();
|
|
4135
4839
|
this.#abortController.signal.addEventListener("abort", () => {
|
|
4136
4840
|
this.#aborted = true;
|
|
@@ -4438,12 +5142,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
4438
5142
|
throw error;
|
|
4439
5143
|
}
|
|
4440
5144
|
async #finalizeGraphRun() {
|
|
4441
|
-
|
|
4442
|
-
this.#graphOutputs["cost"] = {
|
|
4443
|
-
type: "number",
|
|
4444
|
-
value: this.#totalCost
|
|
4445
|
-
};
|
|
4446
|
-
}
|
|
5145
|
+
ensureGraphCostOutput(this.#graphOutputs, this.#totalCost);
|
|
4447
5146
|
const outputValues = this.#graphOutputs;
|
|
4448
5147
|
this.#running = false;
|
|
4449
5148
|
await this.#emitter.emit("graphFinish", this.#withExecution({ graph: this.#graph, outputs: outputValues }));
|
|
@@ -4601,7 +5300,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
4601
5300
|
const processProfileStart = this.#startRuntimeProfile();
|
|
4602
5301
|
let processResult;
|
|
4603
5302
|
try {
|
|
4604
|
-
processResult = await this.#processNode(node);
|
|
5303
|
+
processResult = await this.#processNode(node, inputValues);
|
|
4605
5304
|
} finally {
|
|
4606
5305
|
this.#finishRuntimeProfile("nodeDispatch", processProfileStart);
|
|
4607
5306
|
}
|
|
@@ -4789,17 +5488,20 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
4789
5488
|
}
|
|
4790
5489
|
return nodeData;
|
|
4791
5490
|
}
|
|
4792
|
-
async #processNode(node) {
|
|
5491
|
+
async #processNode(node, inputValues) {
|
|
4793
5492
|
const processId = (0, import_non_secure4.nanoid)();
|
|
4794
5493
|
if (this.#abortController.signal.aborted) {
|
|
4795
5494
|
await this.#nodeErrored(node, createGraphAbortErrorFromSignal(this.#abortController.signal), processId);
|
|
4796
5495
|
this.#successfulAbortTerminalProcessIds.delete(processId);
|
|
4797
5496
|
return { processId, shouldQueueOutputNodes: false };
|
|
4798
5497
|
}
|
|
4799
|
-
|
|
5498
|
+
const frozenOutputs = this.#resolveFrozenNodeOutputs(node, inputValues, processId);
|
|
5499
|
+
if (frozenOutputs) {
|
|
5500
|
+
await this.#processFrozenNode(node, processId, inputValues, frozenOutputs);
|
|
5501
|
+
} else if (node.isSplitRun) {
|
|
4800
5502
|
await this.#processSplitRunNode(node, processId);
|
|
4801
5503
|
} else {
|
|
4802
|
-
await this.#processNormalNode(node, processId);
|
|
5504
|
+
await this.#processNormalNode(node, processId, inputValues);
|
|
4803
5505
|
}
|
|
4804
5506
|
const successfulAbortTerminal = this.#successfulAbortTerminalProcessIds.delete(processId);
|
|
4805
5507
|
return { processId, shouldQueueOutputNodes: !successfulAbortTerminal };
|
|
@@ -4827,13 +5529,50 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
4827
5529
|
finishNodeTiming: this.#captureNodeTimings ? (start) => this.#finishNodeTiming(start) : void 0
|
|
4828
5530
|
});
|
|
4829
5531
|
}
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
5532
|
+
#resolveFrozenNodeOutputs(node, inputValues, processId) {
|
|
5533
|
+
var _a;
|
|
5534
|
+
return (_a = this.#frozenNodeOutputResolver) == null ? void 0 : _a.call(this, {
|
|
5535
|
+
execution: this.#buildExecutionMetadata(),
|
|
5536
|
+
graphId: this.#graph.metadata.id,
|
|
5537
|
+
inputs: inputValues,
|
|
5538
|
+
node,
|
|
5539
|
+
processId
|
|
5540
|
+
});
|
|
5541
|
+
}
|
|
5542
|
+
async #processFrozenNode(node, processId, inputValues, outputValues) {
|
|
5543
|
+
await this.#emitter.emit("nodeStart", this.#withExecution({ node, inputs: inputValues, processId }));
|
|
5544
|
+
const timingStart = this.#startNodeTiming();
|
|
5545
|
+
this.#nodeResults.set(node.id, outputValues);
|
|
5546
|
+
this.#visitedNodes.add(node.id);
|
|
5547
|
+
this.#accumulateCost(outputValues);
|
|
5548
|
+
this.#applyFrozenNodeDataflowEffects(node, outputValues, processId);
|
|
5549
|
+
await this.#emitter.emit(
|
|
5550
|
+
"nodeFinish",
|
|
5551
|
+
this.#withExecution(
|
|
5552
|
+
withOptionalDuration3(
|
|
5553
|
+
{
|
|
5554
|
+
node,
|
|
5555
|
+
outputs: outputValues,
|
|
5556
|
+
processId
|
|
5557
|
+
},
|
|
5558
|
+
this.#finishNodeTiming(timingStart)
|
|
5559
|
+
)
|
|
5560
|
+
)
|
|
5561
|
+
);
|
|
5562
|
+
}
|
|
5563
|
+
#applyFrozenNodeDataflowEffects(node, outputValues, processId) {
|
|
5564
|
+
const setGlobalEffect = applyFrozenGraphBoundaryEffects(this.#graphOutputs, node, outputValues);
|
|
5565
|
+
if (!setGlobalEffect) {
|
|
4835
5566
|
return;
|
|
4836
5567
|
}
|
|
5568
|
+
this.#globals.set(setGlobalEffect.variableId, setGlobalEffect.value);
|
|
5569
|
+
emitDetached(
|
|
5570
|
+
this.#emitter,
|
|
5571
|
+
"globalSet",
|
|
5572
|
+
this.#withExecution({ id: setGlobalEffect.variableId, value: setGlobalEffect.value, processId })
|
|
5573
|
+
);
|
|
5574
|
+
}
|
|
5575
|
+
async #processNormalNode(node, processId, inputValues) {
|
|
4837
5576
|
await this.#emitter.emit("nodeStart", this.#withExecution({ node, inputs: inputValues, processId }));
|
|
4838
5577
|
const timingStart = this.#startNodeTiming();
|
|
4839
5578
|
try {
|
|
@@ -5027,14 +5766,17 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5027
5766
|
return this.#context.tokenizer;
|
|
5028
5767
|
}
|
|
5029
5768
|
#createNodeProcessContext(node, inputValues, index, processId, nodeAbortController, partialOutput) {
|
|
5769
|
+
var _a;
|
|
5030
5770
|
const plugin = this.#registry.getPluginFor(node.type);
|
|
5031
5771
|
return buildNodeProcessContext({
|
|
5772
|
+
activeOutputPortIds: this.#getActiveOutputPortIds(node),
|
|
5032
5773
|
attachedData: this.#getAttachedDataTo(node),
|
|
5033
5774
|
base: this.#nodeProcessContextBase,
|
|
5034
5775
|
createSubProcessor: (subGraphId, options2 = {}) => this.#createSubProcessor(node, index, processId, subGraphId, options2),
|
|
5035
5776
|
execution: this.#buildExecutionMetadata(),
|
|
5036
5777
|
externalFunctions: this.#externalFunctions,
|
|
5037
5778
|
getPluginConfig: (name) => getPluginConfig(plugin, this.#context.settings, name),
|
|
5779
|
+
isDirectRunTarget: ((_a = this.runToNodeIds) == null ? void 0 : _a.includes(node.id)) ?? false,
|
|
5038
5780
|
node,
|
|
5039
5781
|
nodeAbortController,
|
|
5040
5782
|
onPartialOutputs: (partialOutputs) => {
|
|
@@ -5060,6 +5802,42 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5060
5802
|
}
|
|
5061
5803
|
});
|
|
5062
5804
|
}
|
|
5805
|
+
#getActiveOutputPortIds(node) {
|
|
5806
|
+
const outputConnections = getOutputNodesFrom(this.#executionState, node).connectionsToNodes;
|
|
5807
|
+
if (outputConnections.length === 0) {
|
|
5808
|
+
return /* @__PURE__ */ new Set();
|
|
5809
|
+
}
|
|
5810
|
+
const runToRelevantNodeIds = this.#getRunToRelevantNodeIds();
|
|
5811
|
+
const activeOutputPortIds = /* @__PURE__ */ new Set();
|
|
5812
|
+
for (const { node: outputNode, connections } of outputConnections) {
|
|
5813
|
+
if (outputNode.disabled) {
|
|
5814
|
+
continue;
|
|
5815
|
+
}
|
|
5816
|
+
if (runToRelevantNodeIds && !runToRelevantNodeIds.has(outputNode.id)) {
|
|
5817
|
+
continue;
|
|
5818
|
+
}
|
|
5819
|
+
for (const connection of connections) {
|
|
5820
|
+
activeOutputPortIds.add(connection.outputId);
|
|
5821
|
+
}
|
|
5822
|
+
}
|
|
5823
|
+
return activeOutputPortIds;
|
|
5824
|
+
}
|
|
5825
|
+
#getRunToRelevantNodeIds() {
|
|
5826
|
+
if (!this.runToNodeIds) {
|
|
5827
|
+
return void 0;
|
|
5828
|
+
}
|
|
5829
|
+
if (this.#runToRelevantNodeIds) {
|
|
5830
|
+
return this.#runToRelevantNodeIds;
|
|
5831
|
+
}
|
|
5832
|
+
const relevantNodeIds = /* @__PURE__ */ new Set();
|
|
5833
|
+
for (const runToNodeId of this.runToNodeIds) {
|
|
5834
|
+
for (const dependencyNodeId of this.getDependencyNodesDeep(runToNodeId)) {
|
|
5835
|
+
relevantNodeIds.add(dependencyNodeId);
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
this.#runToRelevantNodeIds = relevantNodeIds;
|
|
5839
|
+
return relevantNodeIds;
|
|
5840
|
+
}
|
|
5063
5841
|
#emitGraphPartialOutputIfNeeded(node, partialOutputs) {
|
|
5064
5842
|
const { useAsGraphPartialOutput } = node.data ?? {};
|
|
5065
5843
|
if (!(useAsGraphPartialOutput && this.#executor && this.#parent)) {
|
|
@@ -5106,6 +5884,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5106
5884
|
processor.#contextValues = this.#contextValues;
|
|
5107
5885
|
processor.#parent = this;
|
|
5108
5886
|
processor.#globals = this.#globals;
|
|
5887
|
+
processor.#frozenNodeOutputResolver = this.#frozenNodeOutputResolver;
|
|
5109
5888
|
processor.#executor = {
|
|
5110
5889
|
nodeId: node.id,
|
|
5111
5890
|
parentGraphId: this.#graph.metadata.id,
|
|
@@ -5222,36 +6001,364 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
|
|
|
5222
6001
|
reason
|
|
5223
6002
|
});
|
|
5224
6003
|
}
|
|
5225
|
-
#getInputValuesForNode(node) {
|
|
5226
|
-
const connections = this.#connections[node.id];
|
|
5227
|
-
return this.#definitions[node.id].inputs.reduce(
|
|
5228
|
-
(values2, input) => {
|
|
5229
|
-
var _a, _b;
|
|
5230
|
-
const connection = ((_b = (_a = this.#graphExecutionPlan) == null ? void 0 : _a.inputConnectionByNodeAndPort[node.id]) == null ? void 0 : _b[input.id]) ?? (connections == null ? void 0 : connections.find((conn) => conn.inputId === input.id && conn.inputNodeId === node.id));
|
|
5231
|
-
if (connection) {
|
|
5232
|
-
const outputNode = this.#nodeInstances[connection.outputNodeId].chartNode;
|
|
5233
|
-
const outputNodeOutputs = this.#nodeResults.get(outputNode.id);
|
|
5234
|
-
const outputResult = outputNodeOutputs == null ? void 0 : outputNodeOutputs[connection.outputId];
|
|
5235
|
-
values2[input.id] = outputResult;
|
|
5236
|
-
}
|
|
5237
|
-
return values2;
|
|
5238
|
-
},
|
|
5239
|
-
{}
|
|
5240
|
-
);
|
|
6004
|
+
#getInputValuesForNode(node) {
|
|
6005
|
+
const connections = this.#connections[node.id];
|
|
6006
|
+
return this.#definitions[node.id].inputs.reduce(
|
|
6007
|
+
(values2, input) => {
|
|
6008
|
+
var _a, _b;
|
|
6009
|
+
const connection = ((_b = (_a = this.#graphExecutionPlan) == null ? void 0 : _a.inputConnectionByNodeAndPort[node.id]) == null ? void 0 : _b[input.id]) ?? (connections == null ? void 0 : connections.find((conn) => conn.inputId === input.id && conn.inputNodeId === node.id));
|
|
6010
|
+
if (connection) {
|
|
6011
|
+
const outputNode = this.#nodeInstances[connection.outputNodeId].chartNode;
|
|
6012
|
+
const outputNodeOutputs = this.#nodeResults.get(outputNode.id);
|
|
6013
|
+
const outputResult = outputNodeOutputs == null ? void 0 : outputNodeOutputs[connection.outputId];
|
|
6014
|
+
values2[input.id] = outputResult;
|
|
6015
|
+
}
|
|
6016
|
+
return values2;
|
|
6017
|
+
},
|
|
6018
|
+
{}
|
|
6019
|
+
);
|
|
6020
|
+
}
|
|
6021
|
+
get #executionState() {
|
|
6022
|
+
return {
|
|
6023
|
+
connections: this.#connections,
|
|
6024
|
+
definitions: this.#definitions,
|
|
6025
|
+
erroredNodes: this.#erroredNodes,
|
|
6026
|
+
executionPlan: this.#graphExecutionPlan,
|
|
6027
|
+
loopControllersSeen: this.#loopControllersSeen,
|
|
6028
|
+
nodesById: this.#nodesById,
|
|
6029
|
+
stronglyConnectedComponents: this.#scc,
|
|
6030
|
+
visitedNodes: this.#visitedNodes
|
|
6031
|
+
};
|
|
6032
|
+
}
|
|
6033
|
+
};
|
|
6034
|
+
|
|
6035
|
+
// src/model/UiGraph.ts
|
|
6036
|
+
function createDefaultUiGraph(options2 = {}) {
|
|
6037
|
+
const promptStateKey = "input";
|
|
6038
|
+
const resultStateKey = "result";
|
|
6039
|
+
return {
|
|
6040
|
+
id: newId(),
|
|
6041
|
+
name: options2.name ?? "Untitled web app",
|
|
6042
|
+
components: [
|
|
6043
|
+
{
|
|
6044
|
+
id: newId(),
|
|
6045
|
+
type: "markdown",
|
|
6046
|
+
markdown: "## New Rivet web app\n\nEnter a value and run a graph."
|
|
6047
|
+
},
|
|
6048
|
+
{
|
|
6049
|
+
id: newId(),
|
|
6050
|
+
type: "textarea",
|
|
6051
|
+
label: "Input",
|
|
6052
|
+
stateKey: promptStateKey,
|
|
6053
|
+
placeholder: "Type something..."
|
|
6054
|
+
},
|
|
6055
|
+
{
|
|
6056
|
+
id: newId(),
|
|
6057
|
+
type: "button",
|
|
6058
|
+
label: "Run graph",
|
|
6059
|
+
action: {
|
|
6060
|
+
type: "runGraph",
|
|
6061
|
+
graphId: options2.graphId,
|
|
6062
|
+
inputMappings: [{ inputKey: "input", stateKey: promptStateKey }],
|
|
6063
|
+
outputs: [{ stateKey: resultStateKey }]
|
|
6064
|
+
}
|
|
6065
|
+
},
|
|
6066
|
+
{
|
|
6067
|
+
id: newId(),
|
|
6068
|
+
type: "output",
|
|
6069
|
+
label: "Result",
|
|
6070
|
+
stateKey: resultStateKey,
|
|
6071
|
+
renderAs: "json"
|
|
6072
|
+
}
|
|
6073
|
+
]
|
|
6074
|
+
};
|
|
6075
|
+
}
|
|
6076
|
+
function getUiGraphInitialState(uiGraph) {
|
|
6077
|
+
const state = {};
|
|
6078
|
+
for (const component of uiGraph.components) {
|
|
6079
|
+
if (component.type === "input" || component.type === "textarea") {
|
|
6080
|
+
state[component.stateKey] = component.defaultValue ?? "";
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
return state;
|
|
6084
|
+
}
|
|
6085
|
+
function getUiGraphActionComponent(uiGraph, componentId) {
|
|
6086
|
+
return uiGraph.components.find(
|
|
6087
|
+
(component) => component.id === componentId && component.type === "button"
|
|
6088
|
+
);
|
|
6089
|
+
}
|
|
6090
|
+
function resolveUiGraphActionInputs(action, state) {
|
|
6091
|
+
const inputs = {};
|
|
6092
|
+
if (action.inputMappings) {
|
|
6093
|
+
for (const binding of action.inputMappings) {
|
|
6094
|
+
if (binding.inputKey) {
|
|
6095
|
+
inputs[binding.inputKey] = state[binding.stateKey];
|
|
6096
|
+
}
|
|
6097
|
+
}
|
|
6098
|
+
return inputs;
|
|
6099
|
+
}
|
|
6100
|
+
for (const [inputId, binding] of Object.entries(action.inputs ?? {})) {
|
|
6101
|
+
inputs[inputId] = binding.type === "state" ? state[binding.key] : binding.value;
|
|
6102
|
+
}
|
|
6103
|
+
return inputs;
|
|
6104
|
+
}
|
|
6105
|
+
function resolveUiGraphActionOutputStateValue(action, outputs) {
|
|
6106
|
+
var _a;
|
|
6107
|
+
if (!action.outputKey) {
|
|
6108
|
+
return outputs;
|
|
6109
|
+
}
|
|
6110
|
+
if (!Object.prototype.hasOwnProperty.call(outputs, action.outputKey)) {
|
|
6111
|
+
throw new Error(`Graph output "${action.outputKey}" was not returned by the target graph.`);
|
|
6112
|
+
}
|
|
6113
|
+
return (_a = outputs[action.outputKey]) == null ? void 0 : _a.value;
|
|
6114
|
+
}
|
|
6115
|
+
function resolveUiGraphActionOutputStatePatch(action, outputs) {
|
|
6116
|
+
const bindings = getUiGraphActionOutputBindings(action);
|
|
6117
|
+
const statePatch = {};
|
|
6118
|
+
for (const binding of bindings) {
|
|
6119
|
+
const stateKey = binding.stateKey.trim();
|
|
6120
|
+
if (!stateKey) {
|
|
6121
|
+
continue;
|
|
6122
|
+
}
|
|
6123
|
+
statePatch[stateKey] = resolveUiGraphOutputBindingValue(binding, outputs);
|
|
6124
|
+
}
|
|
6125
|
+
return statePatch;
|
|
6126
|
+
}
|
|
6127
|
+
function getUiGraphActionOutputBindings(action) {
|
|
6128
|
+
if (action.outputs) {
|
|
6129
|
+
return action.outputs;
|
|
5241
6130
|
}
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
executionPlan: this.#graphExecutionPlan,
|
|
5248
|
-
loopControllersSeen: this.#loopControllersSeen,
|
|
5249
|
-
nodesById: this.#nodesById,
|
|
5250
|
-
stronglyConnectedComponents: this.#scc,
|
|
5251
|
-
visitedNodes: this.#visitedNodes
|
|
5252
|
-
};
|
|
6131
|
+
return action.outputStateKey ? [{ outputKey: action.outputKey, stateKey: action.outputStateKey }] : [];
|
|
6132
|
+
}
|
|
6133
|
+
function getUiGraphActionInputBindings(action) {
|
|
6134
|
+
if (action.inputMappings) {
|
|
6135
|
+
return action.inputMappings;
|
|
5253
6136
|
}
|
|
5254
|
-
}
|
|
6137
|
+
return Object.entries(action.inputs ?? {}).map(([inputKey, binding]) => ({
|
|
6138
|
+
inputKey,
|
|
6139
|
+
stateKey: binding.type === "state" ? binding.key : ""
|
|
6140
|
+
}));
|
|
6141
|
+
}
|
|
6142
|
+
function resolveUiGraphOutputBindingValue(binding, outputs) {
|
|
6143
|
+
var _a;
|
|
6144
|
+
if (!binding.outputKey) {
|
|
6145
|
+
return outputs;
|
|
6146
|
+
}
|
|
6147
|
+
if (!Object.prototype.hasOwnProperty.call(outputs, binding.outputKey)) {
|
|
6148
|
+
throw new Error(`Graph output "${binding.outputKey}" was not returned by the target graph.`);
|
|
6149
|
+
}
|
|
6150
|
+
return (_a = outputs[binding.outputKey]) == null ? void 0 : _a.value;
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6153
|
+
// src/model/UiGraphRendererStyles.ts
|
|
6154
|
+
var RIVET_WEB_APP_RENDERER_CSS = `
|
|
6155
|
+
.rivet-web-app-root {
|
|
6156
|
+
--rivet-web-app-background: var(--grey-dark-colorish, #1c222b);
|
|
6157
|
+
--rivet-web-app-foreground: var(--foreground, #ffffff);
|
|
6158
|
+
--rivet-web-app-card-background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 88%, var(--foreground, #ffffff) 4%);
|
|
6159
|
+
--rivet-web-app-card-border: var(--foldable-section-border, rgba(255, 255, 255, 0.04));
|
|
6160
|
+
--rivet-web-app-control-background: var(--form-control-bg, #20252d);
|
|
6161
|
+
--rivet-web-app-control-border: var(--form-control-border, rgba(255, 255, 255, 0.14));
|
|
6162
|
+
--rivet-web-app-button-radius: var(--rivet-web-app-host-button-radius, 6px);
|
|
6163
|
+
--rivet-web-app-button-background: var(--success, #3ba85b);
|
|
6164
|
+
--rivet-web-app-button-foreground: var(--grey-lightest, #ffffff);
|
|
6165
|
+
--rivet-web-app-output-title: var(--rivet-web-app-foreground, #ffffff);
|
|
6166
|
+
--rivet-web-app-error-color: var(--error, #ff6b5f);
|
|
6167
|
+
--rivet-web-app-font-size: var(--rivet-web-app-host-font-size, 15px);
|
|
6168
|
+
box-sizing: border-box;
|
|
6169
|
+
height: 100%;
|
|
6170
|
+
background: var(--rivet-web-app-background);
|
|
6171
|
+
color: var(--rivet-web-app-foreground);
|
|
6172
|
+
overflow: auto;
|
|
6173
|
+
font-family: Inter, system-ui, sans-serif;
|
|
6174
|
+
font-size: var(--rivet-web-app-font-size);
|
|
6175
|
+
line-height: 1.4;
|
|
6176
|
+
}
|
|
6177
|
+
|
|
6178
|
+
.rivet-web-app-root *,
|
|
6179
|
+
.rivet-web-app-root *::before,
|
|
6180
|
+
.rivet-web-app-root *::after {
|
|
6181
|
+
box-sizing: border-box;
|
|
6182
|
+
}
|
|
6183
|
+
|
|
6184
|
+
.rivet-web-app-surface {
|
|
6185
|
+
display: grid;
|
|
6186
|
+
gap: 16px;
|
|
6187
|
+
margin: 0 auto;
|
|
6188
|
+
max-width: 760px;
|
|
6189
|
+
padding: 48px 20px;
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6192
|
+
.rivet-web-app-card,
|
|
6193
|
+
.rivet-web-app-field {
|
|
6194
|
+
border: 1px solid var(--rivet-web-app-card-border);
|
|
6195
|
+
border-radius: 10px;
|
|
6196
|
+
background: var(--rivet-web-app-card-background);
|
|
6197
|
+
padding: 16px;
|
|
6198
|
+
}
|
|
6199
|
+
|
|
6200
|
+
.rivet-web-app-component-frame {
|
|
6201
|
+
border-radius: 12px;
|
|
6202
|
+
margin: -5px;
|
|
6203
|
+
padding: 4px;
|
|
6204
|
+
}
|
|
6205
|
+
|
|
6206
|
+
.rivet-web-app-component-frame.active {
|
|
6207
|
+
background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 75%, var(--primary, #ff9e2c) 16%);
|
|
6208
|
+
}
|
|
6209
|
+
|
|
6210
|
+
.rivet-web-app-field {
|
|
6211
|
+
display: grid;
|
|
6212
|
+
gap: 8px;
|
|
6213
|
+
color: var(--rivet-web-app-foreground);
|
|
6214
|
+
font-size: inherit;
|
|
6215
|
+
font-weight: 600;
|
|
6216
|
+
}
|
|
6217
|
+
|
|
6218
|
+
.rivet-web-app-field input,
|
|
6219
|
+
.rivet-web-app-field textarea {
|
|
6220
|
+
appearance: none;
|
|
6221
|
+
width: 100%;
|
|
6222
|
+
box-sizing: border-box;
|
|
6223
|
+
border: 1px solid var(--rivet-web-app-control-border);
|
|
6224
|
+
border-radius: 8px;
|
|
6225
|
+
background: var(--rivet-web-app-control-background);
|
|
6226
|
+
color: var(--rivet-web-app-foreground);
|
|
6227
|
+
font: inherit;
|
|
6228
|
+
font-weight: 400;
|
|
6229
|
+
padding: 10px 12px;
|
|
6230
|
+
}
|
|
6231
|
+
|
|
6232
|
+
.rivet-web-app-field textarea {
|
|
6233
|
+
min-height: 110px;
|
|
6234
|
+
resize: vertical;
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
.rivet-web-app-button {
|
|
6238
|
+
width: fit-content;
|
|
6239
|
+
border: 0;
|
|
6240
|
+
border-radius: var(--rivet-web-app-button-radius);
|
|
6241
|
+
background: var(--rivet-web-app-button-background);
|
|
6242
|
+
color: var(--rivet-web-app-button-foreground);
|
|
6243
|
+
cursor: pointer;
|
|
6244
|
+
font: inherit;
|
|
6245
|
+
font-weight: 700;
|
|
6246
|
+
padding: 10px 16px;
|
|
6247
|
+
}
|
|
6248
|
+
|
|
6249
|
+
.rivet-web-app-button:disabled {
|
|
6250
|
+
cursor: wait;
|
|
6251
|
+
opacity: 0.72;
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
.rivet-web-app-output {
|
|
6255
|
+
display: grid;
|
|
6256
|
+
gap: 8px;
|
|
6257
|
+
}
|
|
6258
|
+
|
|
6259
|
+
.rivet-web-app-output-title {
|
|
6260
|
+
color: var(--rivet-web-app-output-title);
|
|
6261
|
+
font-weight: 700;
|
|
6262
|
+
}
|
|
6263
|
+
|
|
6264
|
+
.rivet-web-app-output pre {
|
|
6265
|
+
margin: 0;
|
|
6266
|
+
background: transparent;
|
|
6267
|
+
border-radius: 0;
|
|
6268
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
6269
|
+
font-size: inherit;
|
|
6270
|
+
padding: 0;
|
|
6271
|
+
white-space: pre-wrap;
|
|
6272
|
+
word-break: break-word;
|
|
6273
|
+
}
|
|
6274
|
+
|
|
6275
|
+
.rivet-web-app-markdown,
|
|
6276
|
+
.rivet-web-app-output-markdown {
|
|
6277
|
+
word-break: break-word;
|
|
6278
|
+
}
|
|
6279
|
+
|
|
6280
|
+
.rivet-web-app-markdown.markdown-body {
|
|
6281
|
+
background: var(--rivet-web-app-card-background);
|
|
6282
|
+
font-family: inherit;
|
|
6283
|
+
min-width: 0;
|
|
6284
|
+
}
|
|
6285
|
+
|
|
6286
|
+
.rivet-web-app-output-markdown.markdown-body {
|
|
6287
|
+
background: transparent;
|
|
6288
|
+
font-family: inherit;
|
|
6289
|
+
min-width: 0;
|
|
6290
|
+
}
|
|
6291
|
+
|
|
6292
|
+
.rivet-web-app-markdown h1,
|
|
6293
|
+
.rivet-web-app-output-markdown h1 {
|
|
6294
|
+
margin: 0 0 12px;
|
|
6295
|
+
padding-bottom: 8px;
|
|
6296
|
+
border-bottom: 1px solid var(--rivet-web-app-card-border);
|
|
6297
|
+
font-size: 24px;
|
|
6298
|
+
line-height: 1.22;
|
|
6299
|
+
}
|
|
6300
|
+
|
|
6301
|
+
.rivet-web-app-markdown h2,
|
|
6302
|
+
.rivet-web-app-output-markdown h2 {
|
|
6303
|
+
margin: 0 0 10px;
|
|
6304
|
+
font-size: 20px;
|
|
6305
|
+
line-height: 1.25;
|
|
6306
|
+
}
|
|
6307
|
+
|
|
6308
|
+
.rivet-web-app-markdown p,
|
|
6309
|
+
.rivet-web-app-output-markdown p,
|
|
6310
|
+
.rivet-web-app-markdown ul,
|
|
6311
|
+
.rivet-web-app-output-markdown ul {
|
|
6312
|
+
margin: 0 0 12px;
|
|
6313
|
+
}
|
|
6314
|
+
|
|
6315
|
+
.rivet-web-app-markdown.markdown-body code,
|
|
6316
|
+
.rivet-web-app-output-markdown.markdown-body code {
|
|
6317
|
+
border-radius: 4px;
|
|
6318
|
+
background: color-mix(in srgb, var(--rivet-web-app-control-background) 70%, var(--rivet-web-app-foreground) 6%);
|
|
6319
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
6320
|
+
padding: 1px 4px;
|
|
6321
|
+
}
|
|
6322
|
+
|
|
6323
|
+
.rivet-web-app-markdown.markdown-body pre,
|
|
6324
|
+
.rivet-web-app-output-markdown.markdown-body pre {
|
|
6325
|
+
background: transparent;
|
|
6326
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
6327
|
+
padding: 0;
|
|
6328
|
+
white-space: pre-wrap;
|
|
6329
|
+
}
|
|
6330
|
+
|
|
6331
|
+
.rivet-web-app-markdown > :first-child,
|
|
6332
|
+
.rivet-web-app-output-markdown > :first-child {
|
|
6333
|
+
margin-top: 0;
|
|
6334
|
+
}
|
|
6335
|
+
|
|
6336
|
+
.rivet-web-app-markdown > :last-child,
|
|
6337
|
+
.rivet-web-app-output-markdown > :last-child {
|
|
6338
|
+
margin-bottom: 0;
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
.rivet-web-app-error {
|
|
6342
|
+
color: var(--rivet-web-app-error-color);
|
|
6343
|
+
font-weight: 700;
|
|
6344
|
+
}
|
|
6345
|
+
`;
|
|
6346
|
+
var RIVET_WEB_APP_DOCUMENT_CSS = `
|
|
6347
|
+
html,
|
|
6348
|
+
body {
|
|
6349
|
+
height: 100%;
|
|
6350
|
+
margin: 0;
|
|
6351
|
+
}
|
|
6352
|
+
|
|
6353
|
+
body {
|
|
6354
|
+
min-height: 100vh;
|
|
6355
|
+
background: #1c222b;
|
|
6356
|
+
}
|
|
6357
|
+
|
|
6358
|
+
#app {
|
|
6359
|
+
min-height: 100vh;
|
|
6360
|
+
}
|
|
6361
|
+
`;
|
|
5255
6362
|
|
|
5256
6363
|
// src/model/NodeImpl.ts
|
|
5257
6364
|
var NodeImpl = class {
|
|
@@ -6933,7 +8040,6 @@ async function applyOpenAIStreamingResponse(params) {
|
|
|
6933
8040
|
};
|
|
6934
8041
|
}
|
|
6935
8042
|
output["cost"] = { type: "number", value: totalCost };
|
|
6936
|
-
output["__hidden_token_count"] = { type: "number", value: inputTokenCount + outputTokenCount };
|
|
6937
8043
|
}
|
|
6938
8044
|
function handleOpenAIRetryableFailure(params) {
|
|
6939
8045
|
var _a, _b;
|
|
@@ -8098,7 +9204,7 @@ function getCommonChatV2Outputs(data, options2 = {}) {
|
|
|
8098
9204
|
if (includeFunctionCalls) {
|
|
8099
9205
|
outputs.push({
|
|
8100
9206
|
id: functionCallsPortId,
|
|
8101
|
-
title: "
|
|
9207
|
+
title: "Tool Calls",
|
|
8102
9208
|
dataType: "object[]"
|
|
8103
9209
|
});
|
|
8104
9210
|
}
|
|
@@ -8983,7 +10089,9 @@ function createChatV2Model(provider, modelId, context, options2 = {}) {
|
|
|
8983
10089
|
headers: options2.headers,
|
|
8984
10090
|
includeUsage: true
|
|
8985
10091
|
});
|
|
8986
|
-
|
|
10092
|
+
const model = providerInstance.chatModel(modelId);
|
|
10093
|
+
model.supportsStructuredOutputs = true;
|
|
10094
|
+
return model;
|
|
8987
10095
|
}
|
|
8988
10096
|
}
|
|
8989
10097
|
}
|
|
@@ -9676,9 +10784,9 @@ function createsLLMChatV2ToolResponseFormatConflictForEdit(previousData, nextDat
|
|
|
9676
10784
|
}
|
|
9677
10785
|
|
|
9678
10786
|
// src/model/chat-v2/chatV2EditorCache.ts
|
|
9679
|
-
var
|
|
10787
|
+
var import_safe_stable_stringify4 = __toESM(require("safe-stable-stringify"), 1);
|
|
9680
10788
|
function buildLLMChatV2EditorCacheKey(parts) {
|
|
9681
|
-
return (0,
|
|
10789
|
+
return (0, import_safe_stable_stringify4.default)(parts) ?? "";
|
|
9682
10790
|
}
|
|
9683
10791
|
function cloneEditorCacheValue(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
9684
10792
|
if (value == null || typeof value !== "object") {
|
|
@@ -9754,7 +10862,7 @@ function fingerprintProviderOptionsForCache(providerOptions) {
|
|
|
9754
10862
|
if (providerOptions == null) {
|
|
9755
10863
|
return void 0;
|
|
9756
10864
|
}
|
|
9757
|
-
return fingerprintSecret((0,
|
|
10865
|
+
return fingerprintSecret((0, import_safe_stable_stringify4.default)(providerOptions) ?? "");
|
|
9758
10866
|
}
|
|
9759
10867
|
function resolveLLMChatV2EditorCache(params) {
|
|
9760
10868
|
const { editorCache } = params;
|
|
@@ -10187,6 +11295,9 @@ function defaultStreamExecutor(args) {
|
|
|
10187
11295
|
usage: "usage" in result ? keepPromiseHandled(Promise.resolve(result.usage)) : void 0
|
|
10188
11296
|
};
|
|
10189
11297
|
}
|
|
11298
|
+
async function defaultGenerateExecutor(args) {
|
|
11299
|
+
return await (0, import_ai2.generateText)(args);
|
|
11300
|
+
}
|
|
10190
11301
|
async function resolveOptionalValue(value) {
|
|
10191
11302
|
return value == null ? void 0 : await value;
|
|
10192
11303
|
}
|
|
@@ -10200,6 +11311,51 @@ async function resolveOptionalStructuredOutput(value) {
|
|
|
10200
11311
|
return void 0;
|
|
10201
11312
|
}
|
|
10202
11313
|
}
|
|
11314
|
+
async function resolveGenerateStructuredOutput(result, responseOutput, finishReason) {
|
|
11315
|
+
if (responseOutput == null || finishReason != null && finishReason !== "stop") {
|
|
11316
|
+
return void 0;
|
|
11317
|
+
}
|
|
11318
|
+
try {
|
|
11319
|
+
return await resolveOptionalStructuredOutput(result.output);
|
|
11320
|
+
} catch {
|
|
11321
|
+
return void 0;
|
|
11322
|
+
}
|
|
11323
|
+
}
|
|
11324
|
+
function recoverGenerateStructuredOutputError(error, options2, toolCalls) {
|
|
11325
|
+
if (options2.responseOutput == null || !isChatV2StructuredResponseFormat(options2.responseFormat)) {
|
|
11326
|
+
return void 0;
|
|
11327
|
+
}
|
|
11328
|
+
if (!import_ai2.NoObjectGeneratedError.isInstance(error)) {
|
|
11329
|
+
return void 0;
|
|
11330
|
+
}
|
|
11331
|
+
if (typeof error.text !== "string") {
|
|
11332
|
+
return void 0;
|
|
11333
|
+
}
|
|
11334
|
+
const rawText = error.text;
|
|
11335
|
+
const responseText = collapseRepeatedStructuredJsonText(rawText);
|
|
11336
|
+
return {
|
|
11337
|
+
responseText,
|
|
11338
|
+
structuredOutput: void 0,
|
|
11339
|
+
functionCalls: toStreamedFunctionCalls(toolCalls),
|
|
11340
|
+
usage: error.usage,
|
|
11341
|
+
reasoning: "",
|
|
11342
|
+
finishReason: error.finishReason == null ? void 0 : String(error.finishReason),
|
|
11343
|
+
providerMetadata: void 0,
|
|
11344
|
+
requestStatus: void 0
|
|
11345
|
+
};
|
|
11346
|
+
}
|
|
11347
|
+
function attachGenerateStepToolCallCollector(args) {
|
|
11348
|
+
const toolCalls = [];
|
|
11349
|
+
const previousOnStepFinish = args.onStepFinish;
|
|
11350
|
+
args.onStepFinish = async (event) => {
|
|
11351
|
+
const stepToolCalls = event.toolCalls;
|
|
11352
|
+
if (stepToolCalls != null) {
|
|
11353
|
+
toolCalls.push(...stepToolCalls);
|
|
11354
|
+
}
|
|
11355
|
+
await (previousOnStepFinish == null ? void 0 : previousOnStepFinish(event));
|
|
11356
|
+
};
|
|
11357
|
+
return toolCalls;
|
|
11358
|
+
}
|
|
10203
11359
|
function collapseRepeatedStructuredJsonText(responseText) {
|
|
10204
11360
|
if (responseText.length === 0 || responseText.length % 2 !== 0) {
|
|
10205
11361
|
return responseText;
|
|
@@ -10220,10 +11376,11 @@ function collapseRepeatedStructuredJsonText(responseText) {
|
|
|
10220
11376
|
return responseText;
|
|
10221
11377
|
}
|
|
10222
11378
|
}
|
|
10223
|
-
|
|
11379
|
+
function buildTextArgs(options2) {
|
|
10224
11380
|
const args = {
|
|
10225
11381
|
model: options2.model,
|
|
10226
|
-
messages: options2.messages
|
|
11382
|
+
messages: options2.messages,
|
|
11383
|
+
maxRetries: 0
|
|
10227
11384
|
};
|
|
10228
11385
|
if (options2.tools !== void 0)
|
|
10229
11386
|
args.tools = options2.tools;
|
|
@@ -10251,6 +11408,27 @@ async function executeStream(options2, executor) {
|
|
|
10251
11408
|
args.toolChoice = options2.toolChoice;
|
|
10252
11409
|
if (options2.abortSignal !== void 0)
|
|
10253
11410
|
args.abortSignal = options2.abortSignal;
|
|
11411
|
+
return args;
|
|
11412
|
+
}
|
|
11413
|
+
function toStreamedFunctionCalls(toolCalls) {
|
|
11414
|
+
return (toolCalls ?? []).map((toolCall) => ({
|
|
11415
|
+
type: "function",
|
|
11416
|
+
id: toolCall.toolCallId,
|
|
11417
|
+
name: toolCall.toolName,
|
|
11418
|
+
arguments: JSON.stringify(toolCall.input),
|
|
11419
|
+
lastParsedArguments: toolCall.input
|
|
11420
|
+
}));
|
|
11421
|
+
}
|
|
11422
|
+
async function resolveGenerateReasoning(result) {
|
|
11423
|
+
var _a;
|
|
11424
|
+
const reasoningText = await resolveOptionalValue(result.reasoningText);
|
|
11425
|
+
if (reasoningText != null && reasoningText.trim().length > 0) {
|
|
11426
|
+
return reasoningText;
|
|
11427
|
+
}
|
|
11428
|
+
return ((_a = await resolveOptionalValue(result.reasoning)) == null ? void 0 : _a.map((part) => part.text).join("")) ?? "";
|
|
11429
|
+
}
|
|
11430
|
+
async function executeStream(options2, executor) {
|
|
11431
|
+
const args = buildTextArgs(options2);
|
|
10254
11432
|
const handle = await executor(args);
|
|
10255
11433
|
markOptionalPromiseHandled(handle.finishReason);
|
|
10256
11434
|
markOptionalPromiseHandled(handle.output);
|
|
@@ -10286,6 +11464,35 @@ async function executeStream(options2, executor) {
|
|
|
10286
11464
|
async function streamChatV2(options2) {
|
|
10287
11465
|
return executeStream(options2, options2.executeStream ?? defaultStreamExecutor);
|
|
10288
11466
|
}
|
|
11467
|
+
async function generateChatV2(options2) {
|
|
11468
|
+
const args = buildTextArgs(options2);
|
|
11469
|
+
const stepToolCalls = attachGenerateStepToolCallCollector(args);
|
|
11470
|
+
let result;
|
|
11471
|
+
try {
|
|
11472
|
+
result = await (options2.executeGenerate ?? defaultGenerateExecutor)(args);
|
|
11473
|
+
} catch (error) {
|
|
11474
|
+
const recovered = recoverGenerateStructuredOutputError(error, options2, stepToolCalls);
|
|
11475
|
+
if (recovered != null) {
|
|
11476
|
+
return recovered;
|
|
11477
|
+
}
|
|
11478
|
+
throw error;
|
|
11479
|
+
}
|
|
11480
|
+
const isStructuredOutput = isChatV2StructuredResponseFormat(options2.responseFormat);
|
|
11481
|
+
const responseText = isStructuredOutput ? collapseRepeatedStructuredJsonText(result.text) : result.text;
|
|
11482
|
+
const finishReason = await resolveOptionalValue(result.finishReason);
|
|
11483
|
+
return {
|
|
11484
|
+
responseText,
|
|
11485
|
+
structuredOutput: await resolveGenerateStructuredOutput(result, options2.responseOutput, finishReason),
|
|
11486
|
+
functionCalls: toStreamedFunctionCalls(
|
|
11487
|
+
result.toolCalls != null && result.toolCalls.length > 0 ? result.toolCalls : stepToolCalls
|
|
11488
|
+
),
|
|
11489
|
+
usage: await resolveOptionalValue(result.totalUsage) ?? await resolveOptionalValue(result.usage),
|
|
11490
|
+
reasoning: await resolveGenerateReasoning(result),
|
|
11491
|
+
finishReason,
|
|
11492
|
+
providerMetadata: await resolveOptionalValue(result.providerMetadata),
|
|
11493
|
+
requestStatus: await resolveOptionalValue(result.requestStatus)
|
|
11494
|
+
};
|
|
11495
|
+
}
|
|
10289
11496
|
|
|
10290
11497
|
// src/model/chat-v2/messageConverter.ts
|
|
10291
11498
|
function mergeProviderMetadata(base, extra) {
|
|
@@ -10503,7 +11710,7 @@ function compact(value, maxLength = 500) {
|
|
|
10503
11710
|
const normalized = value.replace(/\s+/g, " ").trim();
|
|
10504
11711
|
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 3)}...` : normalized;
|
|
10505
11712
|
}
|
|
10506
|
-
function
|
|
11713
|
+
function isRecord2(value) {
|
|
10507
11714
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
10508
11715
|
}
|
|
10509
11716
|
function stringifyProviderValue(value) {
|
|
@@ -10523,7 +11730,7 @@ function stringifyProviderValue(value) {
|
|
|
10523
11730
|
}
|
|
10524
11731
|
}
|
|
10525
11732
|
function findProviderMessage(value) {
|
|
10526
|
-
if (!
|
|
11733
|
+
if (!isRecord2(value)) {
|
|
10527
11734
|
return stringifyProviderValue(value);
|
|
10528
11735
|
}
|
|
10529
11736
|
const direct = value.message ?? value.error_description ?? value.detail;
|
|
@@ -10611,7 +11818,7 @@ function getRecordStatusCode(record) {
|
|
|
10611
11818
|
return coerceHttpStatusCode(record.statusCode) ?? coerceHttpStatusCode(record.status);
|
|
10612
11819
|
}
|
|
10613
11820
|
function getChatV2ProviderErrorStatusCode(error, seen = /* @__PURE__ */ new Set()) {
|
|
10614
|
-
if (!
|
|
11821
|
+
if (!isRecord2(error)) {
|
|
10615
11822
|
return void 0;
|
|
10616
11823
|
}
|
|
10617
11824
|
if (seen.has(error)) {
|
|
@@ -10623,20 +11830,20 @@ function getChatV2ProviderErrorStatusCode(error, seen = /* @__PURE__ */ new Set(
|
|
|
10623
11830
|
return directStatusCode;
|
|
10624
11831
|
}
|
|
10625
11832
|
const response = error.response;
|
|
10626
|
-
if (
|
|
11833
|
+
if (isRecord2(response)) {
|
|
10627
11834
|
const responseStatusCode = getRecordStatusCode(response);
|
|
10628
11835
|
if (responseStatusCode != null) {
|
|
10629
11836
|
return responseStatusCode;
|
|
10630
11837
|
}
|
|
10631
11838
|
}
|
|
10632
11839
|
const data = error.data;
|
|
10633
|
-
if (
|
|
11840
|
+
if (isRecord2(data)) {
|
|
10634
11841
|
const dataStatusCode = getRecordStatusCode(data);
|
|
10635
11842
|
if (dataStatusCode != null) {
|
|
10636
11843
|
return dataStatusCode;
|
|
10637
11844
|
}
|
|
10638
11845
|
const dataError = data.error;
|
|
10639
|
-
if (
|
|
11846
|
+
if (isRecord2(dataError)) {
|
|
10640
11847
|
const dataErrorStatusCode = getRecordStatusCode(dataError);
|
|
10641
11848
|
if (dataErrorStatusCode != null) {
|
|
10642
11849
|
return dataErrorStatusCode;
|
|
@@ -10923,17 +12130,17 @@ function createChatV2ProviderFailureOutputs({
|
|
|
10923
12130
|
}
|
|
10924
12131
|
|
|
10925
12132
|
// src/model/chat-v2/chatV2Pipeline.ts
|
|
10926
|
-
var
|
|
12133
|
+
var ChatV2RetryFailure = class extends Error {
|
|
10927
12134
|
constructor(error, requestStatuses, requestErrors) {
|
|
10928
12135
|
super("Chat v2 retry attempts failed");
|
|
10929
12136
|
this.error = error;
|
|
10930
12137
|
this.requestStatuses = requestStatuses;
|
|
10931
12138
|
this.requestErrors = requestErrors;
|
|
10932
|
-
this.name = "
|
|
12139
|
+
this.name = "ChatV2RetryFailure";
|
|
10933
12140
|
}
|
|
10934
12141
|
};
|
|
10935
|
-
function
|
|
10936
|
-
return error instanceof
|
|
12142
|
+
function isChatV2RetryFailure(error) {
|
|
12143
|
+
return error instanceof ChatV2RetryFailure;
|
|
10937
12144
|
}
|
|
10938
12145
|
function getProviderFailureMessage(error) {
|
|
10939
12146
|
if (error instanceof Error) {
|
|
@@ -10958,14 +12165,14 @@ function normalizeProviderFailureMessage(error, options2) {
|
|
|
10958
12165
|
function normalizeProviderFailureMessages(errors, options2) {
|
|
10959
12166
|
return errors.map((error) => normalizeProviderFailureMessage(error, options2));
|
|
10960
12167
|
}
|
|
10961
|
-
async function
|
|
12168
|
+
async function runChatV2WithRetry(chatOptions, retryOptions, transportMode) {
|
|
10962
12169
|
const repeatTimes = retryOptions.retryOnNon200 ? normalizeLLMChatV2RetryCount(retryOptions.retryOnNon200RepeatTimes) : 0;
|
|
10963
12170
|
const cooldownMs = normalizeLLMChatV2RetryCooldownMs(retryOptions.retryOnNon200CooldownMs);
|
|
10964
12171
|
const requestStatuses = [];
|
|
10965
12172
|
const requestErrors = [];
|
|
10966
12173
|
for (let attempt = 0; ; attempt++) {
|
|
10967
12174
|
try {
|
|
10968
|
-
const result = await streamChatV2(
|
|
12175
|
+
const result = transportMode === "generate" ? await generateChatV2(chatOptions) : await streamChatV2(chatOptions);
|
|
10969
12176
|
const statusCode = result.requestStatus ?? 200;
|
|
10970
12177
|
if (retryOptions.retryOnNon200) {
|
|
10971
12178
|
requestStatuses.push(statusCode);
|
|
@@ -10987,7 +12194,7 @@ async function streamChatV2WithRetry(streamOptions, retryOptions) {
|
|
|
10987
12194
|
requestStatuses.push(statusCode);
|
|
10988
12195
|
requestErrors.push(error);
|
|
10989
12196
|
if (attempt >= repeatTimes) {
|
|
10990
|
-
throw new
|
|
12197
|
+
throw new ChatV2RetryFailure(error, requestStatuses, requestErrors);
|
|
10991
12198
|
}
|
|
10992
12199
|
await waitForLLMChatV2RetryCooldown(cooldownMs, retryOptions.context.signal);
|
|
10993
12200
|
}
|
|
@@ -11044,7 +12251,9 @@ async function runChatV2Pipeline(options2) {
|
|
|
11044
12251
|
});
|
|
11045
12252
|
const functionTools = options2.functions != null && options2.functions.length > 0 ? chatV2ToolsToAiSdk(options2.functions) : void 0;
|
|
11046
12253
|
const tools = functionTools == null ? options2.additionalTools : options2.additionalTools == null ? functionTools : { ...functionTools, ...options2.additionalTools };
|
|
11047
|
-
const
|
|
12254
|
+
const shouldStreamResponse = options2.emitPartialOutputs !== false;
|
|
12255
|
+
const transportMode = shouldStreamResponse ? "stream" : "generate";
|
|
12256
|
+
const chatResponse = await runChatV2WithRetry(
|
|
11048
12257
|
{
|
|
11049
12258
|
model: options2.model,
|
|
11050
12259
|
messages: modelMessages,
|
|
@@ -11063,7 +12272,8 @@ async function runChatV2Pipeline(options2) {
|
|
|
11063
12272
|
toolChoice: options2.toolChoice,
|
|
11064
12273
|
abortSignal: options2.context.signal,
|
|
11065
12274
|
executeStream: options2.executeStream,
|
|
11066
|
-
|
|
12275
|
+
executeGenerate: options2.executeGenerate,
|
|
12276
|
+
onPartialOutput: !shouldStreamResponse ? void 0 : ({ text, functionCalls }) => {
|
|
11067
12277
|
var _a, _b;
|
|
11068
12278
|
(_b = (_a = options2.context).onPartialOutputs) == null ? void 0 : _b.call(
|
|
11069
12279
|
_a,
|
|
@@ -11089,9 +12299,10 @@ async function runChatV2Pipeline(options2) {
|
|
|
11089
12299
|
);
|
|
11090
12300
|
}
|
|
11091
12301
|
},
|
|
11092
|
-
options2
|
|
12302
|
+
options2,
|
|
12303
|
+
transportMode
|
|
11093
12304
|
).catch((caughtError) => {
|
|
11094
|
-
const retryFailure =
|
|
12305
|
+
const retryFailure = isChatV2RetryFailure(caughtError) ? caughtError : void 0;
|
|
11095
12306
|
const rawError = (retryFailure == null ? void 0 : retryFailure.error) ?? caughtError;
|
|
11096
12307
|
const normalizedError = normalizeChatV2ProviderError(rawError, {
|
|
11097
12308
|
provider: options2.provider,
|
|
@@ -11112,21 +12323,22 @@ async function runChatV2Pipeline(options2) {
|
|
|
11112
12323
|
}
|
|
11113
12324
|
throw normalizedError;
|
|
11114
12325
|
});
|
|
11115
|
-
if ("commonOutputs" in
|
|
11116
|
-
return
|
|
11117
|
-
}
|
|
11118
|
-
const usage = normalizeChatV2Usage(
|
|
11119
|
-
const requestStatuses =
|
|
11120
|
-
const
|
|
11121
|
-
const
|
|
12326
|
+
if ("commonOutputs" in chatResponse) {
|
|
12327
|
+
return chatResponse;
|
|
12328
|
+
}
|
|
12329
|
+
const usage = normalizeChatV2Usage(chatResponse.result.usage, options2);
|
|
12330
|
+
const requestStatuses = chatResponse.requestStatuses;
|
|
12331
|
+
const requestStatus = chatResponse.result.requestStatus ?? 200;
|
|
12332
|
+
const requestErrors = normalizeProviderFailureMessages(chatResponse.requestErrors, options2);
|
|
12333
|
+
const responseError = chatResponse.responseError ? normalizeProviderFailureMessage(chatResponse.responseError, options2) : void 0;
|
|
11122
12334
|
const commonOutputs = createChatV2CommonOutputs({
|
|
11123
12335
|
requestMessages,
|
|
11124
|
-
response:
|
|
11125
|
-
structuredOutput:
|
|
11126
|
-
functionCalls:
|
|
12336
|
+
response: chatResponse.result.responseText,
|
|
12337
|
+
structuredOutput: chatResponse.result.structuredOutput,
|
|
12338
|
+
functionCalls: chatResponse.result.functionCalls,
|
|
11127
12339
|
usage,
|
|
11128
|
-
reasoning:
|
|
11129
|
-
requestStatus
|
|
12340
|
+
reasoning: chatResponse.result.reasoning,
|
|
12341
|
+
requestStatus,
|
|
11130
12342
|
responseError,
|
|
11131
12343
|
requestStatuses,
|
|
11132
12344
|
requestErrors,
|
|
@@ -11146,14 +12358,14 @@ async function runChatV2Pipeline(options2) {
|
|
|
11146
12358
|
commonOutputs,
|
|
11147
12359
|
requestMessages,
|
|
11148
12360
|
allMessages: allMessagesOutput.value,
|
|
11149
|
-
response:
|
|
11150
|
-
functionCalls:
|
|
11151
|
-
reasoning:
|
|
12361
|
+
response: chatResponse.result.responseText,
|
|
12362
|
+
functionCalls: chatResponse.result.functionCalls,
|
|
12363
|
+
reasoning: chatResponse.result.reasoning,
|
|
11152
12364
|
usage,
|
|
11153
|
-
rawUsage:
|
|
11154
|
-
finishReason:
|
|
11155
|
-
providerMetadata:
|
|
11156
|
-
requestStatus
|
|
12365
|
+
rawUsage: chatResponse.result.usage,
|
|
12366
|
+
finishReason: chatResponse.result.finishReason,
|
|
12367
|
+
providerMetadata: chatResponse.result.providerMetadata,
|
|
12368
|
+
requestStatus
|
|
11157
12369
|
};
|
|
11158
12370
|
}
|
|
11159
12371
|
|
|
@@ -11418,32 +12630,54 @@ async function delegateToolCall(rawFunctionCall, context, config) {
|
|
|
11418
12630
|
function usesBaseURLInput(data) {
|
|
11419
12631
|
return data.provider === "custom" ? data.useCustomProviderBaseURLInput : data.useBaseURLInput;
|
|
11420
12632
|
}
|
|
11421
|
-
function
|
|
12633
|
+
function getCustomProviderBaseURLBodyValue(data) {
|
|
11422
12634
|
if (data.provider !== "custom") {
|
|
11423
12635
|
return void 0;
|
|
11424
12636
|
}
|
|
11425
12637
|
if (data.useCustomProviderBaseURLInput) {
|
|
11426
|
-
return "
|
|
12638
|
+
return "(Using Input)";
|
|
11427
12639
|
}
|
|
11428
12640
|
const baseURL = data.customProviderBaseURL.trim();
|
|
11429
|
-
return baseURL
|
|
12641
|
+
return baseURL || void 0;
|
|
11430
12642
|
}
|
|
11431
12643
|
function getOptionLabel(options2, value) {
|
|
11432
12644
|
var _a;
|
|
11433
12645
|
return ((_a = options2.find((option) => option.value === (value ?? ""))) == null ? void 0 : _a.label) ?? value ?? "Default";
|
|
11434
12646
|
}
|
|
11435
|
-
function
|
|
12647
|
+
function getProviderBodyLabel(data) {
|
|
12648
|
+
return data.provider === "custom" ? "Custom" : getChatV2ProviderLabel(data.provider);
|
|
12649
|
+
}
|
|
12650
|
+
function getReasoningEffortBodyValue(data) {
|
|
11436
12651
|
switch (data.provider) {
|
|
11437
12652
|
case "openai":
|
|
11438
|
-
return
|
|
12653
|
+
return getOptionLabel(openAIReasoningEffortOptions, data.openAIReasoningEffort);
|
|
11439
12654
|
case "anthropic":
|
|
11440
|
-
return
|
|
12655
|
+
return getOptionLabel(anthropicEffortOptions, data.anthropicEffort);
|
|
11441
12656
|
case "google":
|
|
11442
|
-
return
|
|
12657
|
+
return getOptionLabel(googleThinkingLevelOptions, data.googleThinkingLevel);
|
|
11443
12658
|
case "custom":
|
|
11444
12659
|
return void 0;
|
|
11445
12660
|
}
|
|
11446
12661
|
}
|
|
12662
|
+
function escapeMarkdownInline(value) {
|
|
12663
|
+
return value.replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/([\\`*_[\]{}()#+\-.!|])/g, "\\$1");
|
|
12664
|
+
}
|
|
12665
|
+
function getBodyLine(label, value) {
|
|
12666
|
+
return `<span style="opacity: 0.55">${label}:</span> ${escapeMarkdownInline(value)}`;
|
|
12667
|
+
}
|
|
12668
|
+
function getOptionalNumberBodyLine(label, value, usesInput) {
|
|
12669
|
+
if (usesInput) {
|
|
12670
|
+
return getBodyLine(label, "(Using Input)");
|
|
12671
|
+
}
|
|
12672
|
+
return value === void 0 ? void 0 : getBodyLine(label, `${value}`);
|
|
12673
|
+
}
|
|
12674
|
+
function getStopSequencesBodyLine(data) {
|
|
12675
|
+
if (data.useStopSequencesInput) {
|
|
12676
|
+
return getBodyLine("Stop sequences", "(Using Input)");
|
|
12677
|
+
}
|
|
12678
|
+
const stopSequences = (data.stopSequences ?? []).filter((sequence) => sequence.length > 0);
|
|
12679
|
+
return stopSequences.length === 0 ? void 0 : getBodyLine("Stop sequences", stopSequences.map((sequence) => JSON.stringify(sequence)).join(", "));
|
|
12680
|
+
}
|
|
11447
12681
|
var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
11448
12682
|
static create() {
|
|
11449
12683
|
return {
|
|
@@ -11601,17 +12835,31 @@ var LLMChatV2NodeImpl = class extends NodeImpl {
|
|
|
11601
12835
|
}
|
|
11602
12836
|
getBody() {
|
|
11603
12837
|
const modelInfo = getChatV2ModelInfo(this.data.provider, this.data.model);
|
|
11604
|
-
const providerLabel =
|
|
11605
|
-
const
|
|
12838
|
+
const providerLabel = getProviderBodyLabel(this.data);
|
|
12839
|
+
const baseURLValue = getCustomProviderBaseURLBodyValue(this.data);
|
|
11606
12840
|
const modelLine = (modelInfo == null ? void 0 : modelInfo.displayName) ?? this.data.model;
|
|
11607
|
-
const providerDetails =
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
12841
|
+
const providerDetails = [
|
|
12842
|
+
getBodyLine("Provider", providerLabel),
|
|
12843
|
+
...baseURLValue ? [getBodyLine("Base URL", baseURLValue)] : [],
|
|
12844
|
+
getBodyLine("Model", modelLine)
|
|
12845
|
+
];
|
|
12846
|
+
const reasoningEffortValue = getReasoningEffortBodyValue(this.data);
|
|
12847
|
+
return {
|
|
12848
|
+
type: "markdown",
|
|
12849
|
+
disableLinks: true,
|
|
12850
|
+
text: [
|
|
12851
|
+
...providerDetails,
|
|
12852
|
+
...reasoningEffortValue ? [getBodyLine("Reasoning effort", reasoningEffortValue)] : [],
|
|
12853
|
+
getBodyLine("Temperature", this.data.useTemperatureInput ? "(Using Input)" : `${this.data.temperature}`),
|
|
12854
|
+
getBodyLine("Max output tokens", this.data.useMaxTokensInput ? "(Using Input)" : `${this.data.maxTokens}`),
|
|
12855
|
+
getOptionalNumberBodyLine("Top P", this.data.topP, this.data.useTopPInput),
|
|
12856
|
+
getOptionalNumberBodyLine("Top K", this.data.topK, this.data.useTopKInput),
|
|
12857
|
+
getOptionalNumberBodyLine("Presence penalty", this.data.presencePenalty, this.data.usePresencePenaltyInput),
|
|
12858
|
+
getOptionalNumberBodyLine("Frequency penalty", this.data.frequencyPenalty, this.data.useFrequencyPenaltyInput),
|
|
12859
|
+
getStopSequencesBodyLine(this.data),
|
|
12860
|
+
getOptionalNumberBodyLine("Seed", this.data.seed, this.data.useSeedInput)
|
|
12861
|
+
].filter((line) => line !== void 0).join("\n")
|
|
12862
|
+
};
|
|
11615
12863
|
}
|
|
11616
12864
|
async process(inputs, context) {
|
|
11617
12865
|
const runtime = await resolveLLMChatV2RuntimeConfig({
|
|
@@ -11826,12 +13074,13 @@ var PromptNodeImpl = class extends NodeImpl {
|
|
|
11826
13074
|
},
|
|
11827
13075
|
{}
|
|
11828
13076
|
);
|
|
11829
|
-
|
|
13077
|
+
let outputValue = interpolate(
|
|
11830
13078
|
this.chartNode.data.promptText,
|
|
11831
13079
|
inputMap,
|
|
11832
13080
|
context.graphInputNodeValues,
|
|
11833
13081
|
context.contextValues
|
|
11834
13082
|
);
|
|
13083
|
+
outputValue = outputValue.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
11835
13084
|
const type = getInputOrData(this.data, inputs, "type", "string");
|
|
11836
13085
|
const isCacheBreakpoint = getInputOrData(this.data, inputs, "isCacheBreakpoint", "boolean");
|
|
11837
13086
|
if (["assistant", "system", "user", "function"].includes(type) === false) {
|
|
@@ -14095,7 +15344,8 @@ var GraphOutputNodeImpl = class extends NodeImpl {
|
|
|
14095
15344
|
{
|
|
14096
15345
|
type: "string",
|
|
14097
15346
|
label: "ID",
|
|
14098
|
-
dataKey: "id"
|
|
15347
|
+
dataKey: "id",
|
|
15348
|
+
commitDebounceMs: 300
|
|
14099
15349
|
},
|
|
14100
15350
|
{
|
|
14101
15351
|
type: "dataTypeSelector",
|
|
@@ -14172,11 +15422,11 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
14172
15422
|
}
|
|
14173
15423
|
getInputDefinitions(_connections, _nodes, project, _referencedProjects, definitionContext) {
|
|
14174
15424
|
const boundary = this.getBoundary(project, definitionContext);
|
|
14175
|
-
return boundary ? getGraphBoundaryInputDefinitions(boundary) : [];
|
|
15425
|
+
return boundary ? getGraphBoundaryInputDefinitions(boundary, this.data.inputPortOrder) : [];
|
|
14176
15426
|
}
|
|
14177
15427
|
getGraphOutputs(project, definitionContext) {
|
|
14178
15428
|
const boundary = this.getBoundary(project, definitionContext);
|
|
14179
|
-
return boundary ? getGraphBoundaryOutputDefinitions(boundary) : [];
|
|
15429
|
+
return boundary ? getGraphBoundaryOutputDefinitions(boundary, this.data.outputPortOrder) : [];
|
|
14180
15430
|
}
|
|
14181
15431
|
getOutputDefinitions(_connections, _nodes, project, _referencedProjects, definitionContext) {
|
|
14182
15432
|
const outputs = [];
|
|
@@ -14209,7 +15459,7 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
14209
15459
|
if (this.data.graphId) {
|
|
14210
15460
|
const boundary = getGraphBoundary(context.project, this.data.graphId);
|
|
14211
15461
|
if (boundary) {
|
|
14212
|
-
for (const input of boundary.inputs) {
|
|
15462
|
+
for (const input of applyGraphBoundaryPortOrder(boundary.inputs, this.data.inputPortOrder)) {
|
|
14213
15463
|
definitions.push({
|
|
14214
15464
|
type: "dynamic",
|
|
14215
15465
|
dataKey: "inputData",
|
|
@@ -14245,14 +15495,26 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
14245
15495
|
}
|
|
14246
15496
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, project, this.data.graphId)) ?? getGraphBoundary(project, this.data.graphId);
|
|
14247
15497
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
15498
|
+
const shouldRunWholeGraph = !GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED || context.isDirectRunTarget || this.data.useAsGraphPartialOutput === true || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
15499
|
+
const requestedGraphOutputNodeIds = shouldRunWholeGraph ? [] : getRequestedGraphOutputNodeIds(boundary, context.activeOutputPortIds);
|
|
15500
|
+
if (!shouldRunWholeGraph && requestedGraphOutputNodeIds.length === 0) {
|
|
15501
|
+
return buildSkippedSubgraphOutputs(boundary, this.data.useErrorOutput);
|
|
15502
|
+
}
|
|
14248
15503
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, { signal: context.signal });
|
|
15504
|
+
if (!shouldRunWholeGraph) {
|
|
15505
|
+
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
15506
|
+
}
|
|
14249
15507
|
try {
|
|
14250
15508
|
const startTime = Date.now();
|
|
14251
|
-
const
|
|
15509
|
+
const graphOutputs = await subGraphProcessor.processGraph(
|
|
14252
15510
|
context,
|
|
14253
15511
|
inputData,
|
|
14254
15512
|
context.contextValues
|
|
14255
15513
|
);
|
|
15514
|
+
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
15515
|
+
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
15516
|
+
...graphOutputs
|
|
15517
|
+
};
|
|
14256
15518
|
const duration = Date.now() - startTime;
|
|
14257
15519
|
if (this.data.useErrorOutput) {
|
|
14258
15520
|
outputs["error"] = {
|
|
@@ -14281,6 +15543,24 @@ var SubGraphNodeImpl = class extends NodeImpl {
|
|
|
14281
15543
|
}
|
|
14282
15544
|
};
|
|
14283
15545
|
var subGraphNode = nodeDefinition(SubGraphNodeImpl, "Subgraph");
|
|
15546
|
+
function buildSkippedSubgraphOutputs(boundary, useErrorOutput) {
|
|
15547
|
+
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
15548
|
+
if (useErrorOutput) {
|
|
15549
|
+
outputs["error"] = {
|
|
15550
|
+
type: "control-flow-excluded",
|
|
15551
|
+
value: void 0
|
|
15552
|
+
};
|
|
15553
|
+
}
|
|
15554
|
+
outputs["cost"] = {
|
|
15555
|
+
type: "number",
|
|
15556
|
+
value: 0
|
|
15557
|
+
};
|
|
15558
|
+
outputs["duration"] = {
|
|
15559
|
+
type: "number",
|
|
15560
|
+
value: 0
|
|
15561
|
+
};
|
|
15562
|
+
return outputs;
|
|
15563
|
+
}
|
|
14284
15564
|
|
|
14285
15565
|
// src/model/nodes/ArrayNode.ts
|
|
14286
15566
|
var import_non_secure23 = require("nanoid/non-secure");
|
|
@@ -15705,7 +16985,7 @@ var CoalesceNodeImpl = class extends NodeImpl {
|
|
|
15705
16985
|
visualData: {
|
|
15706
16986
|
x: 0,
|
|
15707
16987
|
y: 0,
|
|
15708
|
-
width:
|
|
16988
|
+
width: 190
|
|
15709
16989
|
}
|
|
15710
16990
|
};
|
|
15711
16991
|
return chartNode;
|
|
@@ -18169,6 +19449,20 @@ var import_non_secure55 = require("nanoid/non-secure");
|
|
|
18169
19449
|
var import_lodash_es12 = require("lodash");
|
|
18170
19450
|
var import_ts_pattern5 = require("ts-pattern");
|
|
18171
19451
|
var import_ts_dedent53 = require("ts-dedent");
|
|
19452
|
+
var compareNodeComparisonFunctionOptions = [
|
|
19453
|
+
{ label: "==", value: "==" },
|
|
19454
|
+
{ label: "!=", value: "!=" },
|
|
19455
|
+
{ label: "<", value: "<" },
|
|
19456
|
+
{ label: "<=", value: "<=" },
|
|
19457
|
+
{ label: ">", value: ">" },
|
|
19458
|
+
{ label: ">=", value: ">=" },
|
|
19459
|
+
{ label: "and", value: "and" },
|
|
19460
|
+
{ label: "or", value: "or" },
|
|
19461
|
+
{ label: "xor", value: "xor" },
|
|
19462
|
+
{ label: "nand", value: "nand" },
|
|
19463
|
+
{ label: "nor", value: "nor" },
|
|
19464
|
+
{ label: "xnor", value: "xnor" }
|
|
19465
|
+
];
|
|
18172
19466
|
var CompareNodeImpl = class extends NodeImpl {
|
|
18173
19467
|
static create() {
|
|
18174
19468
|
const chartNode = {
|
|
@@ -18223,20 +19517,7 @@ var CompareNodeImpl = class extends NodeImpl {
|
|
|
18223
19517
|
type: "dropdown",
|
|
18224
19518
|
label: "Comparison Function",
|
|
18225
19519
|
dataKey: "comparisonFunction",
|
|
18226
|
-
options:
|
|
18227
|
-
{ label: "==", value: "==" },
|
|
18228
|
-
{ label: "!=", value: "!=" },
|
|
18229
|
-
{ label: "<", value: "<" },
|
|
18230
|
-
{ label: "<=", value: "<=" },
|
|
18231
|
-
{ label: ">", value: ">" },
|
|
18232
|
-
{ label: ">=", value: ">=" },
|
|
18233
|
-
{ label: "and", value: "and" },
|
|
18234
|
-
{ label: "or", value: "or" },
|
|
18235
|
-
{ label: "xor", value: "xor" },
|
|
18236
|
-
{ label: "nand", value: "nand" },
|
|
18237
|
-
{ label: "nor", value: "nor" },
|
|
18238
|
-
{ label: "xnor", value: "xnor" }
|
|
18239
|
-
],
|
|
19520
|
+
options: compareNodeComparisonFunctionOptions,
|
|
18240
19521
|
useInputToggleDataKey: "useComparisonFunctionInput"
|
|
18241
19522
|
}
|
|
18242
19523
|
];
|
|
@@ -23510,17 +24791,29 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
23510
24791
|
}
|
|
23511
24792
|
const boundary = ((_a = context.getGraphBoundary) == null ? void 0 : _a.call(context, referencedProject, this.data.graphId)) ?? getGraphBoundary(referencedProject, this.data.graphId);
|
|
23512
24793
|
const inputData = buildGraphBoundaryInputData(boundary, inputs, this.data.inputData);
|
|
24794
|
+
const shouldRunWholeGraph = !GRAPH_BOUNDARY_OUTPUT_DEMAND_OPTIMIZATION_ENABLED || context.isDirectRunTarget || this.data.useErrorOutput === true && context.activeOutputPortIds.has("error");
|
|
24795
|
+
const requestedGraphOutputNodeIds = shouldRunWholeGraph ? [] : getRequestedGraphOutputNodeIds(boundary, context.activeOutputPortIds);
|
|
24796
|
+
if (!shouldRunWholeGraph && requestedGraphOutputNodeIds.length === 0) {
|
|
24797
|
+
return buildSkippedReferencedGraphOutputs(boundary, this.data.useErrorOutput, this.data.outputCostDuration);
|
|
24798
|
+
}
|
|
23513
24799
|
const subGraphProcessor = context.createSubProcessor(this.data.graphId, {
|
|
23514
24800
|
signal: context.signal,
|
|
23515
24801
|
project: referencedProject
|
|
23516
24802
|
});
|
|
24803
|
+
if (!shouldRunWholeGraph) {
|
|
24804
|
+
subGraphProcessor.runToNodeIds = requestedGraphOutputNodeIds;
|
|
24805
|
+
}
|
|
23517
24806
|
try {
|
|
23518
24807
|
const startTime = Date.now();
|
|
23519
|
-
const
|
|
24808
|
+
const graphOutputs = await subGraphProcessor.processGraph(
|
|
23520
24809
|
context,
|
|
23521
24810
|
inputData,
|
|
23522
24811
|
context.contextValues
|
|
23523
24812
|
);
|
|
24813
|
+
const outputs = shouldRunWholeGraph ? graphOutputs : {
|
|
24814
|
+
...buildExcludedGraphBoundaryOutputs(boundary),
|
|
24815
|
+
...graphOutputs
|
|
24816
|
+
};
|
|
23524
24817
|
const duration = Date.now() - startTime;
|
|
23525
24818
|
if (this.data.useErrorOutput) {
|
|
23526
24819
|
outputs["error"] = {
|
|
@@ -23534,11 +24827,7 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
23534
24827
|
value: duration
|
|
23535
24828
|
};
|
|
23536
24829
|
}
|
|
23537
|
-
|
|
23538
|
-
delete outputs["cost"];
|
|
23539
|
-
delete outputs["duration"];
|
|
23540
|
-
}
|
|
23541
|
-
return outputs;
|
|
24830
|
+
return applyMetricOutputSetting(outputs, this.data.outputCostDuration);
|
|
23542
24831
|
} catch (err) {
|
|
23543
24832
|
if (!this.data.useErrorOutput) {
|
|
23544
24833
|
throw err;
|
|
@@ -23553,10 +24842,74 @@ var ReferencedGraphAliasNodeImpl = class extends NodeImpl {
|
|
|
23553
24842
|
}
|
|
23554
24843
|
};
|
|
23555
24844
|
var referencedGraphAliasNode = nodeDefinition(ReferencedGraphAliasNodeImpl, "Referenced Graph Alias");
|
|
24845
|
+
function buildSkippedReferencedGraphOutputs(boundary, useErrorOutput, outputCostDuration) {
|
|
24846
|
+
const outputs = buildExcludedGraphBoundaryOutputs(boundary);
|
|
24847
|
+
if (useErrorOutput) {
|
|
24848
|
+
outputs["error"] = {
|
|
24849
|
+
type: "control-flow-excluded",
|
|
24850
|
+
value: void 0
|
|
24851
|
+
};
|
|
24852
|
+
}
|
|
24853
|
+
if (outputCostDuration) {
|
|
24854
|
+
outputs["cost"] = {
|
|
24855
|
+
type: "number",
|
|
24856
|
+
value: 0
|
|
24857
|
+
};
|
|
24858
|
+
outputs["duration"] = {
|
|
24859
|
+
type: "number",
|
|
24860
|
+
value: 0
|
|
24861
|
+
};
|
|
24862
|
+
}
|
|
24863
|
+
return applyMetricOutputSetting(outputs, outputCostDuration);
|
|
24864
|
+
}
|
|
24865
|
+
function applyMetricOutputSetting(outputs, outputCostDuration) {
|
|
24866
|
+
if (outputCostDuration) {
|
|
24867
|
+
return outputs;
|
|
24868
|
+
}
|
|
24869
|
+
delete outputs["cost"];
|
|
24870
|
+
delete outputs["duration"];
|
|
24871
|
+
return outputs;
|
|
24872
|
+
}
|
|
24873
|
+
|
|
24874
|
+
// src/model/nodes/NodePrefabInstanceNode.ts
|
|
24875
|
+
var import_non_secure84 = require("nanoid/non-secure");
|
|
24876
|
+
var NodePrefabInstanceNodeImpl = class extends NodeImpl {
|
|
24877
|
+
static create() {
|
|
24878
|
+
return {
|
|
24879
|
+
type: NODE_PREFAB_INSTANCE_TYPE,
|
|
24880
|
+
title: "Linked node",
|
|
24881
|
+
id: (0, import_non_secure84.nanoid)(),
|
|
24882
|
+
visualData: {
|
|
24883
|
+
x: 0,
|
|
24884
|
+
y: 0,
|
|
24885
|
+
width: 240
|
|
24886
|
+
},
|
|
24887
|
+
data: {}
|
|
24888
|
+
};
|
|
24889
|
+
}
|
|
24890
|
+
getInputDefinitions() {
|
|
24891
|
+
return [];
|
|
24892
|
+
}
|
|
24893
|
+
getOutputDefinitions() {
|
|
24894
|
+
return [];
|
|
24895
|
+
}
|
|
24896
|
+
async process(_inputData) {
|
|
24897
|
+
throw new Error("Library node is missing. Open the Node Library and reconnect this linked node.");
|
|
24898
|
+
}
|
|
24899
|
+
static getUIData() {
|
|
24900
|
+
return {
|
|
24901
|
+
contextMenuTitle: "Linked node",
|
|
24902
|
+
infoBoxTitle: "Linked node",
|
|
24903
|
+
infoBoxBody: "Runs a node from the project Node Library.",
|
|
24904
|
+
group: "Advanced"
|
|
24905
|
+
};
|
|
24906
|
+
}
|
|
24907
|
+
};
|
|
24908
|
+
var nodePrefabInstanceNode = nodeDefinition(NodePrefabInstanceNodeImpl, "Linked node");
|
|
23556
24909
|
|
|
23557
24910
|
// src/model/Nodes.ts
|
|
23558
24911
|
var registerBuiltInNodes = (registry) => {
|
|
23559
|
-
return registry.register(toYamlNode).register(userInputNode).register(textNode).register(llmChatV2Node).register(chatNode).register(promptNode).register(extractRegexNode).register(codeNode).register(codeNewNode).register(expressionNode).register(matchNode).register(ifNode).register(readDirectoryNode).register(readFileNode).register(ifElseNode).register(chunkNode).register(graphInputNode).register(graphOutputNode).register(subGraphNode).register(arrayNode).register(extractJsonNode).register(assemblePromptNode).register(loopControllerNode).register(trimChatMessagesNode).register(extractYamlNode).register(externalCallNode).register(extractObjectPathNode).register(raiseEventNode).register(contextNode).register(coalesceNode).register(didRunNode).register(passthroughNode).register(popNode).register(setGlobalNode).register(getGlobalNode).register(waitForEventNode).register(gptFunctionNode).register(getEmbeddingNode).register(vectorStoreNode).register(vectorNearestNeighborsNode).register(hashNode).register(abortGraphNode).register(raceInputsNode).register(toJsonNode).register(joinNode).register(filterNode).register(jsFilterNode).register(jsMapNode).register(objectNode).register(booleanNode).register(compareNode).register(evaluateNode).register(numberNode).register(randomNumberNode).register(shuffleNode).register(commentNode).register(imageNode).register(audioNode).register(httpCallNode).register(delayNode).register(appendToDatasetNode).register(createDatasetNode).register(loadDatasetNode).register(getAllDatasetsNode).register(splitNode).register(datasetNearestNeighborsNode).register(getDatasetRowNode).register(sliceNode).register(extractMarkdownCodeBlocksNode).register(assembleMessageNode).register(urlReferenceNode).register(destructureNode).register(replaceDatasetNode).register(listGraphsNode).register(graphReferenceNode).register(callGraphNode).register(delegateFunctionCallNode).register(playAudioNode).register(documentNode).register(chatLoopNode).register(readAllFilesNode).register(toMarkdownTableNode).register(cronNode).register(toTreeNode).register(loopUntilNode).register(mcpDiscoveryNode).register(mcpToolCallNode).register(mcpGetPromptNode).register(referencedGraphAliasNode);
|
|
24912
|
+
return registry.register(toYamlNode).register(userInputNode).register(textNode).register(llmChatV2Node).register(chatNode).register(promptNode).register(extractRegexNode).register(codeNode).register(codeNewNode).register(expressionNode).register(matchNode).register(ifNode).register(readDirectoryNode).register(readFileNode).register(ifElseNode).register(chunkNode).register(graphInputNode).register(graphOutputNode).register(subGraphNode).register(arrayNode).register(extractJsonNode).register(assemblePromptNode).register(loopControllerNode).register(trimChatMessagesNode).register(extractYamlNode).register(externalCallNode).register(extractObjectPathNode).register(raiseEventNode).register(contextNode).register(coalesceNode).register(didRunNode).register(passthroughNode).register(popNode).register(setGlobalNode).register(getGlobalNode).register(waitForEventNode).register(gptFunctionNode).register(getEmbeddingNode).register(vectorStoreNode).register(vectorNearestNeighborsNode).register(hashNode).register(abortGraphNode).register(raceInputsNode).register(toJsonNode).register(joinNode).register(filterNode).register(jsFilterNode).register(jsMapNode).register(objectNode).register(booleanNode).register(compareNode).register(evaluateNode).register(numberNode).register(randomNumberNode).register(shuffleNode).register(commentNode).register(imageNode).register(audioNode).register(httpCallNode).register(delayNode).register(appendToDatasetNode).register(createDatasetNode).register(loadDatasetNode).register(getAllDatasetsNode).register(splitNode).register(datasetNearestNeighborsNode).register(getDatasetRowNode).register(sliceNode).register(extractMarkdownCodeBlocksNode).register(assembleMessageNode).register(urlReferenceNode).register(destructureNode).register(replaceDatasetNode).register(listGraphsNode).register(graphReferenceNode).register(callGraphNode).register(delegateFunctionCallNode).register(playAudioNode).register(documentNode).register(chatLoopNode).register(readAllFilesNode).register(toMarkdownTableNode).register(cronNode).register(toTreeNode).register(loopUntilNode).register(mcpDiscoveryNode).register(mcpToolCallNode).register(mcpGetPromptNode).register(referencedGraphAliasNode).register(nodePrefabInstanceNode);
|
|
23560
24913
|
};
|
|
23561
24914
|
var globalRivetNodeRegistry = registerBuiltInNodes(new NodeRegistration());
|
|
23562
24915
|
function resetGlobalRivetNodeRegistry() {
|
|
@@ -23723,7 +25076,7 @@ var OpenAIEmbeddingGenerator = class {
|
|
|
23723
25076
|
registerIntegration("embeddingGenerator", "openai", (context) => new OpenAIEmbeddingGenerator(context.settings));
|
|
23724
25077
|
|
|
23725
25078
|
// src/recording/ExecutionRecorder.ts
|
|
23726
|
-
var
|
|
25079
|
+
var import_non_secure85 = require("nanoid/non-secure");
|
|
23727
25080
|
var import_emittery2 = __toESM(require("emittery-0-13"), 1);
|
|
23728
25081
|
var import_lodash_es17 = require("lodash");
|
|
23729
25082
|
var import_json_stream_es = require("json-stream-es");
|
|
@@ -23923,7 +25276,7 @@ function serializeToObject(recording) {
|
|
|
23923
25276
|
const asString = uint8ArrayToBase64Sync(val);
|
|
23924
25277
|
const existingAsset = Object.entries(serialized.assets).find(([, asset]) => asset === asString);
|
|
23925
25278
|
if (!existingAsset) {
|
|
23926
|
-
const id = (0,
|
|
25279
|
+
const id = (0, import_non_secure85.nanoid)();
|
|
23927
25280
|
serialized.assets[id] = asString;
|
|
23928
25281
|
return `$ASSET:${id}`;
|
|
23929
25282
|
} else {
|
|
@@ -23982,7 +25335,7 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
23982
25335
|
once = void 0;
|
|
23983
25336
|
recordSocket(channel) {
|
|
23984
25337
|
return new Promise((resolve) => {
|
|
23985
|
-
this.recordingId = (0,
|
|
25338
|
+
this.recordingId = (0, import_non_secure85.nanoid)();
|
|
23986
25339
|
const listener = (event) => {
|
|
23987
25340
|
const { message, data } = JSON.parse(event.data);
|
|
23988
25341
|
if (this.#includePartialOutputs === false && message === "partialOutput") {
|
|
@@ -24007,7 +25360,7 @@ var ExecutionRecorder = class _ExecutionRecorder {
|
|
|
24007
25360
|
});
|
|
24008
25361
|
}
|
|
24009
25362
|
record(processor) {
|
|
24010
|
-
this.recordingId = (0,
|
|
25363
|
+
this.recordingId = (0, import_non_secure85.nanoid)();
|
|
24011
25364
|
processor.onAny((event, data) => {
|
|
24012
25365
|
if (this.#includePartialOutputs === false && event === "partialOutput") {
|
|
24013
25366
|
return;
|
|
@@ -24069,7 +25422,7 @@ function isRecordingTerminalEvent(event, data) {
|
|
|
24069
25422
|
}
|
|
24070
25423
|
|
|
24071
25424
|
// src/plugins/anthropic/nodes/ChatAnthropicNode.ts
|
|
24072
|
-
var
|
|
25425
|
+
var import_non_secure86 = require("nanoid/non-secure");
|
|
24073
25426
|
var import_ts_dedent76 = require("ts-dedent");
|
|
24074
25427
|
var import_p_retry2 = __toESM(require("p-retry-4"), 1);
|
|
24075
25428
|
|
|
@@ -24085,7 +25438,7 @@ var ChatAnthropicNodeImpl = {
|
|
|
24085
25438
|
const chartNode = {
|
|
24086
25439
|
type: "chatAnthropic",
|
|
24087
25440
|
title: "Chat (Anthropic, Legacy)",
|
|
24088
|
-
id: (0,
|
|
25441
|
+
id: (0, import_non_secure86.nanoid)(),
|
|
24089
25442
|
visualData: {
|
|
24090
25443
|
x: 0,
|
|
24091
25444
|
y: 0,
|
|
@@ -24827,7 +26180,7 @@ var anthropicPlugin = {
|
|
|
24827
26180
|
var anthropic_default = anthropicPlugin;
|
|
24828
26181
|
|
|
24829
26182
|
// src/plugins/autoevals/AutoEvalsNode.ts
|
|
24830
|
-
var
|
|
26183
|
+
var import_non_secure87 = require("nanoid/non-secure");
|
|
24831
26184
|
var import_ts_dedent77 = require("ts-dedent");
|
|
24832
26185
|
var import_autoevals = require("autoevals");
|
|
24833
26186
|
var import_ts_pattern8 = require("ts-pattern");
|
|
@@ -24847,7 +26200,7 @@ var AutoEvalsNodeImpl = {
|
|
|
24847
26200
|
const chartNode = {
|
|
24848
26201
|
type: "autoevals",
|
|
24849
26202
|
title: "Autoevals",
|
|
24850
|
-
id: (0,
|
|
26203
|
+
id: (0, import_non_secure87.nanoid)(),
|
|
24851
26204
|
visualData: {
|
|
24852
26205
|
x: 0,
|
|
24853
26206
|
y: 0,
|
|
@@ -25042,7 +26395,7 @@ var autoevalsPlugin = {
|
|
|
25042
26395
|
var autoevals_default = autoevalsPlugin;
|
|
25043
26396
|
|
|
25044
26397
|
// src/plugins/assemblyAi/LemurQaNode.ts
|
|
25045
|
-
var
|
|
26398
|
+
var import_non_secure88 = require("nanoid/non-secure");
|
|
25046
26399
|
var import_ts_dedent78 = require("ts-dedent");
|
|
25047
26400
|
|
|
25048
26401
|
// src/plugins/assemblyAi/lemurHelpers.ts
|
|
@@ -25163,7 +26516,7 @@ var LemurQaNodeImpl = {
|
|
|
25163
26516
|
const chartNode = {
|
|
25164
26517
|
type: "assemblyAiLemurQa",
|
|
25165
26518
|
title: "LeMUR Question & Answers",
|
|
25166
|
-
id: (0,
|
|
26519
|
+
id: (0, import_non_secure88.nanoid)(),
|
|
25167
26520
|
visualData: {
|
|
25168
26521
|
x: 0,
|
|
25169
26522
|
y: 0,
|
|
@@ -25301,14 +26654,14 @@ function applyQuestionEditors(data, question) {
|
|
|
25301
26654
|
var lemurQaNode = pluginNodeDefinition(LemurQaNodeImpl, "LeMUR Q&A");
|
|
25302
26655
|
|
|
25303
26656
|
// src/plugins/assemblyAi/TranscribeAudioNode.ts
|
|
25304
|
-
var
|
|
26657
|
+
var import_non_secure89 = require("nanoid/non-secure");
|
|
25305
26658
|
var import_ts_dedent79 = require("ts-dedent");
|
|
25306
26659
|
var TranscribeAudioNodeImpl = {
|
|
25307
26660
|
create() {
|
|
25308
26661
|
const chartNode = {
|
|
25309
26662
|
type: "assemblyAiTranscribeAudio",
|
|
25310
26663
|
title: "Transcribe Audio",
|
|
25311
|
-
id: (0,
|
|
26664
|
+
id: (0, import_non_secure89.nanoid)(),
|
|
25312
26665
|
visualData: {
|
|
25313
26666
|
x: 0,
|
|
25314
26667
|
y: 0,
|
|
@@ -25423,7 +26776,7 @@ function getAdditionalParameters(data) {
|
|
|
25423
26776
|
}
|
|
25424
26777
|
|
|
25425
26778
|
// src/plugins/assemblyAi/LemurSummaryNode.ts
|
|
25426
|
-
var
|
|
26779
|
+
var import_non_secure90 = require("nanoid/non-secure");
|
|
25427
26780
|
var import_ts_dedent80 = require("ts-dedent");
|
|
25428
26781
|
var import_assemblyai3 = require("assemblyai");
|
|
25429
26782
|
var LemurSummaryNodeImpl = {
|
|
@@ -25431,7 +26784,7 @@ var LemurSummaryNodeImpl = {
|
|
|
25431
26784
|
const chartNode = {
|
|
25432
26785
|
type: "assemblyAiLemurSummary",
|
|
25433
26786
|
title: "LeMUR Summary",
|
|
25434
|
-
id: (0,
|
|
26787
|
+
id: (0, import_non_secure90.nanoid)(),
|
|
25435
26788
|
visualData: {
|
|
25436
26789
|
x: 0,
|
|
25437
26790
|
y: 0,
|
|
@@ -25501,7 +26854,7 @@ var LemurSummaryNodeImpl = {
|
|
|
25501
26854
|
var lemurSummaryNode = pluginNodeDefinition(LemurSummaryNodeImpl, "LeMUR Summary");
|
|
25502
26855
|
|
|
25503
26856
|
// src/plugins/assemblyAi/LemurTaskNode.ts
|
|
25504
|
-
var
|
|
26857
|
+
var import_non_secure91 = require("nanoid/non-secure");
|
|
25505
26858
|
var import_ts_dedent81 = require("ts-dedent");
|
|
25506
26859
|
var import_assemblyai4 = require("assemblyai");
|
|
25507
26860
|
var LemurTaskNodeImpl = {
|
|
@@ -25509,7 +26862,7 @@ var LemurTaskNodeImpl = {
|
|
|
25509
26862
|
const chartNode = {
|
|
25510
26863
|
type: "assemblyAiLemurTask",
|
|
25511
26864
|
title: "LeMUR Task",
|
|
25512
|
-
id: (0,
|
|
26865
|
+
id: (0, import_non_secure91.nanoid)(),
|
|
25513
26866
|
visualData: {
|
|
25514
26867
|
x: 0,
|
|
25515
26868
|
y: 0,
|
|
@@ -25581,14 +26934,14 @@ var LemurTaskNodeImpl = {
|
|
|
25581
26934
|
var lemurTaskNode = pluginNodeDefinition(LemurTaskNodeImpl, "LeMUR Task");
|
|
25582
26935
|
|
|
25583
26936
|
// src/plugins/assemblyAi/LemurActionItemsNode.ts
|
|
25584
|
-
var
|
|
26937
|
+
var import_non_secure92 = require("nanoid/non-secure");
|
|
25585
26938
|
var import_ts_dedent82 = require("ts-dedent");
|
|
25586
26939
|
var LemurActionItemsNodeImpl = {
|
|
25587
26940
|
create() {
|
|
25588
26941
|
const chartNode = {
|
|
25589
26942
|
type: "assemblyAiLemurActionItems",
|
|
25590
26943
|
title: "LeMUR Action Items",
|
|
25591
|
-
id: (0,
|
|
26944
|
+
id: (0, import_non_secure92.nanoid)(),
|
|
25592
26945
|
visualData: {
|
|
25593
26946
|
x: 0,
|
|
25594
26947
|
y: 0,
|
|
@@ -25686,12 +27039,12 @@ var assemblyAiPlugin = {
|
|
|
25686
27039
|
var assemblyAi_default = assemblyAiPlugin;
|
|
25687
27040
|
|
|
25688
27041
|
// src/plugins/huggingface/nodes/ChatHuggingFace.ts
|
|
25689
|
-
var
|
|
27042
|
+
var import_non_secure93 = require("nanoid/non-secure");
|
|
25690
27043
|
var import_inference = require("@huggingface/inference");
|
|
25691
27044
|
var ChatHuggingFaceNodeImpl = {
|
|
25692
27045
|
create() {
|
|
25693
27046
|
return {
|
|
25694
|
-
id: (0,
|
|
27047
|
+
id: (0, import_non_secure93.nanoid)(),
|
|
25695
27048
|
type: "chatHuggingFace",
|
|
25696
27049
|
data: {
|
|
25697
27050
|
model: "",
|
|
@@ -25921,13 +27274,13 @@ var ChatHuggingFaceNodeImpl = {
|
|
|
25921
27274
|
var chatHuggingFaceNode = pluginNodeDefinition(ChatHuggingFaceNodeImpl, "Chat (Hugging Face, Legacy)");
|
|
25922
27275
|
|
|
25923
27276
|
// src/plugins/huggingface/nodes/TextToImageHuggingFace.ts
|
|
25924
|
-
var
|
|
27277
|
+
var import_non_secure94 = require("nanoid/non-secure");
|
|
25925
27278
|
var import_inference2 = require("@huggingface/inference");
|
|
25926
27279
|
var import_ts_dedent83 = require("ts-dedent");
|
|
25927
27280
|
var TextToImageHuggingFaceNodeImpl = {
|
|
25928
27281
|
create() {
|
|
25929
27282
|
return {
|
|
25930
|
-
id: (0,
|
|
27283
|
+
id: (0, import_non_secure94.nanoid)(),
|
|
25931
27284
|
type: "textToImageHuggingFace",
|
|
25932
27285
|
data: {
|
|
25933
27286
|
model: "",
|
|
@@ -29243,7 +30596,7 @@ var openAIPlugin = {
|
|
|
29243
30596
|
};
|
|
29244
30597
|
|
|
29245
30598
|
// src/plugins/google/nodes/ChatGoogleNode.ts
|
|
29246
|
-
var
|
|
30599
|
+
var import_non_secure95 = require("nanoid/non-secure");
|
|
29247
30600
|
var import_ts_dedent84 = require("ts-dedent");
|
|
29248
30601
|
var import_p_retry3 = __toESM(require("p-retry-4"), 1);
|
|
29249
30602
|
var import_ts_pattern9 = require("ts-pattern");
|
|
@@ -29272,7 +30625,7 @@ var ChatGoogleNodeImpl = {
|
|
|
29272
30625
|
const chartNode = {
|
|
29273
30626
|
type: "chatGoogle",
|
|
29274
30627
|
title: "Chat (Google, Legacy)",
|
|
29275
|
-
id: (0,
|
|
30628
|
+
id: (0, import_non_secure95.nanoid)(),
|
|
29276
30629
|
visualData: {
|
|
29277
30630
|
x: 0,
|
|
29278
30631
|
y: 0,
|
|
@@ -30313,7 +31666,9 @@ var Rivet = void 0;
|
|
|
30313
31666
|
MCPGetPromptNodeImpl,
|
|
30314
31667
|
MCPToolCallNodeImpl,
|
|
30315
31668
|
MatchNodeImpl,
|
|
31669
|
+
NODE_PREFAB_INSTANCE_TYPE,
|
|
30316
31670
|
NodeImpl,
|
|
31671
|
+
NodePrefabInstanceNodeImpl,
|
|
30317
31672
|
NodeRegistration,
|
|
30318
31673
|
NotAllowedCodeRunner,
|
|
30319
31674
|
NumberNodeImpl,
|
|
@@ -30323,6 +31678,8 @@ var Rivet = void 0;
|
|
|
30323
31678
|
PluginNodeImplClass,
|
|
30324
31679
|
PopNodeImpl,
|
|
30325
31680
|
PromptNodeImpl,
|
|
31681
|
+
RIVET_WEB_APP_DOCUMENT_CSS,
|
|
31682
|
+
RIVET_WEB_APP_RENDERER_CSS,
|
|
30326
31683
|
RaceInputsNodeImpl,
|
|
30327
31684
|
RaiseEventNodeImpl,
|
|
30328
31685
|
RandomNumberNodeImpl,
|
|
@@ -30375,6 +31732,7 @@ var Rivet = void 0;
|
|
|
30375
31732
|
callGraphNode,
|
|
30376
31733
|
canBeCoerced,
|
|
30377
31734
|
canBeCoercedAny,
|
|
31735
|
+
canUseNodeAsPrefabSource,
|
|
30378
31736
|
chatLoopNode,
|
|
30379
31737
|
chatMessagesToModelMessages,
|
|
30380
31738
|
chatNode,
|
|
@@ -30383,6 +31741,8 @@ var Rivet = void 0;
|
|
|
30383
31741
|
chunkNode,
|
|
30384
31742
|
chunkStringByTokenCount,
|
|
30385
31743
|
cleanHeaders,
|
|
31744
|
+
cloneFrozenNodeOutputs,
|
|
31745
|
+
cloneFrozenNodeOutputsByGraph,
|
|
30386
31746
|
coalesceNode,
|
|
30387
31747
|
codeNewNode,
|
|
30388
31748
|
codeNode,
|
|
@@ -30390,6 +31750,8 @@ var Rivet = void 0;
|
|
|
30390
31750
|
coerceTypeOptional,
|
|
30391
31751
|
commentNode,
|
|
30392
31752
|
compareNode,
|
|
31753
|
+
compareNodeComparisonFunctionOptions,
|
|
31754
|
+
compareProjects,
|
|
30393
31755
|
contextNode,
|
|
30394
31756
|
coreCreateProcessor,
|
|
30395
31757
|
coreRunGraph,
|
|
@@ -30401,6 +31763,8 @@ var Rivet = void 0;
|
|
|
30401
31763
|
createDebuggerTransportEscapedSentinel,
|
|
30402
31764
|
createDebuggerTransportEscapedSentinelEnvelope,
|
|
30403
31765
|
createDebuggerTransportUndefinedSentinel,
|
|
31766
|
+
createDefaultUiGraph,
|
|
31767
|
+
createFrozenNodeOutputResolver,
|
|
30404
31768
|
createInterpolationInputDefinition,
|
|
30405
31769
|
createsLLMChatV2ToolResponseFormatConflictForEdit,
|
|
30406
31770
|
cronNode,
|
|
@@ -30434,6 +31798,7 @@ var Rivet = void 0;
|
|
|
30434
31798
|
filterNode,
|
|
30435
31799
|
findInterpolationTokenSpans,
|
|
30436
31800
|
functionTypeToScalarType,
|
|
31801
|
+
generateChatV2,
|
|
30437
31802
|
gentracePlugin,
|
|
30438
31803
|
getAllDatasetsNode,
|
|
30439
31804
|
getChatNodeMessages,
|
|
@@ -30452,16 +31817,25 @@ var Rivet = void 0;
|
|
|
30452
31817
|
getExtractObjectPathInterpolationInputNames,
|
|
30453
31818
|
getGentracePipelines,
|
|
30454
31819
|
getGlobalNode,
|
|
31820
|
+
getGraphBoundary,
|
|
30455
31821
|
getHttpCallBodyPreviewSections,
|
|
30456
31822
|
getInputOrData,
|
|
30457
31823
|
getIntegration,
|
|
30458
31824
|
getInterpolationInputDefinitionData,
|
|
30459
31825
|
getInterpolationTokenName,
|
|
31826
|
+
getNodePrefabDisplayName,
|
|
31827
|
+
getNodePrefabInstancePrefabId,
|
|
30460
31828
|
getPluginConfig,
|
|
30461
31829
|
getProcessorEvents,
|
|
30462
31830
|
getProcessorSSEStream,
|
|
31831
|
+
getProjectConnectionComparisonKey,
|
|
31832
|
+
getProjectNodeFieldComparisons,
|
|
30463
31833
|
getScalarTypeOf,
|
|
30464
31834
|
getSingleNodeStream,
|
|
31835
|
+
getUiGraphActionComponent,
|
|
31836
|
+
getUiGraphActionInputBindings,
|
|
31837
|
+
getUiGraphActionOutputBindings,
|
|
31838
|
+
getUiGraphInitialState,
|
|
30465
31839
|
getWarnings,
|
|
30466
31840
|
globalRivetNodeRegistry,
|
|
30467
31841
|
googlePlugin,
|
|
@@ -30471,6 +31845,7 @@ var Rivet = void 0;
|
|
|
30471
31845
|
graphOutputNode,
|
|
30472
31846
|
graphReferenceNode,
|
|
30473
31847
|
handleEscapeCharacters,
|
|
31848
|
+
hasFrozenNodeOutputs,
|
|
30474
31849
|
hasLLMChatV2ToolResponseFormatConflict,
|
|
30475
31850
|
hasValidStoredOrderedPortIds,
|
|
30476
31851
|
hashNode,
|
|
@@ -30496,6 +31871,7 @@ var Rivet = void 0;
|
|
|
30496
31871
|
isFunctionDataValue,
|
|
30497
31872
|
isInterpolationInputDefinition,
|
|
30498
31873
|
isLLMChatV2StructuredResponseFormat,
|
|
31874
|
+
isNodePrefabInstanceNode,
|
|
30499
31875
|
isNotFunctionDataValue,
|
|
30500
31876
|
isRuntimeDebugLoggingEnabled,
|
|
30501
31877
|
isScalarDataType,
|
|
@@ -30503,6 +31879,7 @@ var Rivet = void 0;
|
|
|
30503
31879
|
joinNode,
|
|
30504
31880
|
jsFilterNode,
|
|
30505
31881
|
jsMapNode,
|
|
31882
|
+
jsonValueToDataValue,
|
|
30506
31883
|
listGraphsNode,
|
|
30507
31884
|
llmChatV2Node,
|
|
30508
31885
|
loadDatasetNode,
|
|
@@ -30523,6 +31900,7 @@ var Rivet = void 0;
|
|
|
30523
31900
|
mergeCustomProviderResponseFormatOptions,
|
|
30524
31901
|
newId,
|
|
30525
31902
|
nodeDefinition,
|
|
31903
|
+
nodePrefabInstanceNode,
|
|
30526
31904
|
numberNode,
|
|
30527
31905
|
objectNode,
|
|
30528
31906
|
openAICompatibleEndpointToBaseURL,
|
|
@@ -30556,8 +31934,13 @@ var Rivet = void 0;
|
|
|
30556
31934
|
resolveChatV2ProviderConfig,
|
|
30557
31935
|
resolveChatV2ResponseFormatParameters,
|
|
30558
31936
|
resolveLLMChatV2RuntimeProviderOptions,
|
|
31937
|
+
resolveNodePrefabInstance,
|
|
31938
|
+
resolveNodePrefabInstances,
|
|
30559
31939
|
resolveProcessSettings,
|
|
30560
31940
|
resolveStoredOrderedPortIds,
|
|
31941
|
+
resolveUiGraphActionInputs,
|
|
31942
|
+
resolveUiGraphActionOutputStatePatch,
|
|
31943
|
+
resolveUiGraphActionOutputStateValue,
|
|
30561
31944
|
resolveUniqueValueDerivedPortIds,
|
|
30562
31945
|
restoreEscapedInterpolationTokens,
|
|
30563
31946
|
runChatV2Pipeline,
|