@valerypopoff/rivet2-core 2.0.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/LICENSE +7 -0
- package/README.md +15 -0
- package/dist/cjs/bundle.cjs +28772 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +116 -0
- package/dist/esm/api/looseDataValue.js +16 -0
- package/dist/esm/api/processSettings.js +16 -0
- package/dist/esm/api/streaming.js +116 -0
- package/dist/esm/exports.js +48 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/integrations/AudioProvider.js +1 -0
- package/dist/esm/integrations/CodeRunner.js +44 -0
- package/dist/esm/integrations/DatasetProvider.js +92 -0
- package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +67 -0
- package/dist/esm/integrations/LLMProvider.js +1 -0
- package/dist/esm/integrations/Tokenizer.js +1 -0
- package/dist/esm/integrations/VectorDatabase.js +1 -0
- package/dist/esm/integrations/enableIntegrations.js +3 -0
- package/dist/esm/integrations/integrations.js +19 -0
- package/dist/esm/integrations/mcp/MCPBase.js +87 -0
- package/dist/esm/integrations/mcp/MCPProvider.js +23 -0
- package/dist/esm/integrations/mcp/MCPUtils.js +33 -0
- package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +23 -0
- package/dist/esm/model/CycleDetector.js +43 -0
- package/dist/esm/model/DataValue.js +188 -0
- package/dist/esm/model/Dataset.js +1 -0
- package/dist/esm/model/EditorDefinition.js +1 -0
- package/dist/esm/model/ExecutorProtocol.js +1 -0
- package/dist/esm/model/GraphPreprocessor.js +97 -0
- package/dist/esm/model/GraphProcessor.js +1136 -0
- package/dist/esm/model/NodeBase.js +11 -0
- package/dist/esm/model/NodeBodySpec.js +1 -0
- package/dist/esm/model/NodeDefinition.js +12 -0
- package/dist/esm/model/NodeExecutionPlanner.js +82 -0
- package/dist/esm/model/NodeGraph.js +14 -0
- package/dist/esm/model/NodeImpl.js +57 -0
- package/dist/esm/model/NodeRegistration.js +146 -0
- package/dist/esm/model/Nodes.js +279 -0
- package/dist/esm/model/PluginLoadSpec.js +1 -0
- package/dist/esm/model/ProcessContext.js +1 -0
- package/dist/esm/model/ProcessContextBuilder.js +33 -0
- package/dist/esm/model/Project.js +2 -0
- package/dist/esm/model/ProjectReferenceLoader.js +1 -0
- package/dist/esm/model/RecordingPlayer.js +262 -0
- package/dist/esm/model/RegistryAssembly.js +53 -0
- package/dist/esm/model/RivetPlugin.js +1 -0
- package/dist/esm/model/RivetUIContext.js +1 -0
- package/dist/esm/model/Settings.js +1 -0
- package/dist/esm/model/SplitRunProcessor.js +98 -0
- package/dist/esm/model/SubprocessorBridge.js +82 -0
- package/dist/esm/model/chat/aiSdkMessages.js +105 -0
- package/dist/esm/model/chat/aiSdkStreaming.js +38 -0
- package/dist/esm/model/chat/aiSdkTools.js +10 -0
- package/dist/esm/model/chat/chatCost.js +33 -0
- package/dist/esm/model/chat/chatMessages.js +47 -0
- package/dist/esm/model/chat/openAIChatRequest.js +110 -0
- package/dist/esm/model/chat/openAIChatRuntime.js +220 -0
- package/dist/esm/model/chat/streamChatResponse.js +97 -0
- package/dist/esm/model/chat/tokenBudget.js +16 -0
- package/dist/esm/model/chat-v2/aiSdkBridge.js +88 -0
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +107 -0
- package/dist/esm/model/chat-v2/chatV2Errors.js +255 -0
- package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +16 -0
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +387 -0
- package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +57 -0
- package/dist/esm/model/chat-v2/chatV2Retry.js +41 -0
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +242 -0
- package/dist/esm/model/chat-v2/chatV2Shared.js +285 -0
- package/dist/esm/model/chat-v2/chatV2Types.js +1 -0
- package/dist/esm/model/chat-v2/index.js +10 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +56 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +475 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +90 -0
- package/dist/esm/model/chat-v2/messageConverter.js +173 -0
- package/dist/esm/model/chat-v2/modelRegistry.js +23 -0
- package/dist/esm/model/chat-v2/providerOptions.js +202 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +108 -0
- package/dist/esm/model/chat-v2/toolConverter.js +4 -0
- package/dist/esm/model/interpolationInputDefinition.js +36 -0
- package/dist/esm/model/loopControllerBreak.js +4 -0
- package/dist/esm/model/nodes/AbortGraphNode.js +100 -0
- package/dist/esm/model/nodes/AppendToDatasetNode.js +115 -0
- package/dist/esm/model/nodes/ArrayNode.js +144 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +209 -0
- package/dist/esm/model/nodes/AssemblePromptNode.js +151 -0
- package/dist/esm/model/nodes/AudioNode.js +101 -0
- package/dist/esm/model/nodes/BooleanNode.js +74 -0
- package/dist/esm/model/nodes/CallGraphNode.js +135 -0
- package/dist/esm/model/nodes/ChatLoopNode.js +150 -0
- package/dist/esm/model/nodes/ChatNode.js +56 -0
- package/dist/esm/model/nodes/ChatNodeBase.js +912 -0
- package/dist/esm/model/nodes/ChunkNode.js +166 -0
- package/dist/esm/model/nodes/CoalesceNode.js +104 -0
- package/dist/esm/model/nodes/CodeNode.js +197 -0
- package/dist/esm/model/nodes/CommentNode.js +71 -0
- package/dist/esm/model/nodes/CompareNode.js +144 -0
- package/dist/esm/model/nodes/ContextNode.js +99 -0
- package/dist/esm/model/nodes/CreateDatasetNode.js +71 -0
- package/dist/esm/model/nodes/CronNode.js +248 -0
- package/dist/esm/model/nodes/DatasetNearestNeigborsNode.js +97 -0
- package/dist/esm/model/nodes/DelayNode.js +105 -0
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +175 -0
- package/dist/esm/model/nodes/DestructureNode.js +110 -0
- package/dist/esm/model/nodes/DocumentNode.js +183 -0
- package/dist/esm/model/nodes/EvaluateNode.js +141 -0
- package/dist/esm/model/nodes/ExpressionNode.js +143 -0
- package/dist/esm/model/nodes/ExternalCallNode.js +162 -0
- package/dist/esm/model/nodes/ExtractJsonNode.js +122 -0
- package/dist/esm/model/nodes/ExtractMarkdownCodeBlocksNode.js +100 -0
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +159 -0
- package/dist/esm/model/nodes/ExtractRegexNode.js +200 -0
- package/dist/esm/model/nodes/ExtractYamlNode.js +214 -0
- package/dist/esm/model/nodes/FilterNode.js +73 -0
- package/dist/esm/model/nodes/GetAllDatasetsNode.js +53 -0
- package/dist/esm/model/nodes/GetDatasetRowNode.js +99 -0
- package/dist/esm/model/nodes/GetEmbeddingNode.js +130 -0
- package/dist/esm/model/nodes/GetGlobalNode.js +139 -0
- package/dist/esm/model/nodes/GraphInputNode.js +132 -0
- package/dist/esm/model/nodes/GraphOutputNode.js +104 -0
- package/dist/esm/model/nodes/GraphReferenceNode.js +128 -0
- package/dist/esm/model/nodes/HashNode.js +97 -0
- package/dist/esm/model/nodes/HttpCallNode.js +592 -0
- package/dist/esm/model/nodes/IfElseNode.js +138 -0
- package/dist/esm/model/nodes/IfNode.js +129 -0
- package/dist/esm/model/nodes/ImageNode.js +107 -0
- package/dist/esm/model/nodes/JSFilterNode.js +69 -0
- package/dist/esm/model/nodes/JSMapNode.js +69 -0
- package/dist/esm/model/nodes/JoinNode.js +135 -0
- package/dist/esm/model/nodes/LLMChatV2Node.js +234 -0
- package/dist/esm/model/nodes/ListGraphsNode.js +61 -0
- package/dist/esm/model/nodes/LoadDatasetNode.js +83 -0
- package/dist/esm/model/nodes/LoopControllerNode.js +206 -0
- package/dist/esm/model/nodes/LoopUntilNode.js +214 -0
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +214 -0
- package/dist/esm/model/nodes/MCPGetPromptNode.js +234 -0
- package/dist/esm/model/nodes/MCPToolCallNode.js +262 -0
- package/dist/esm/model/nodes/MatchNode.js +160 -0
- package/dist/esm/model/nodes/NumberNode.js +86 -0
- package/dist/esm/model/nodes/ObjectNode.js +152 -0
- package/dist/esm/model/nodes/PassthroughNode.js +78 -0
- package/dist/esm/model/nodes/PlayAudioNode.js +61 -0
- package/dist/esm/model/nodes/PopNode.js +89 -0
- package/dist/esm/model/nodes/PromptNode.js +248 -0
- package/dist/esm/model/nodes/RaceInputsNode.js +85 -0
- package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
- package/dist/esm/model/nodes/RandomNumberNode.js +117 -0
- package/dist/esm/model/nodes/ReadAllFilesNode.js +210 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +171 -0
- package/dist/esm/model/nodes/ReadFileNode.js +114 -0
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +199 -0
- package/dist/esm/model/nodes/ReplaceDatasetNode.js +118 -0
- package/dist/esm/model/nodes/SetGlobalNode.js +124 -0
- package/dist/esm/model/nodes/ShuffleNode.js +64 -0
- package/dist/esm/model/nodes/SliceNode.js +99 -0
- package/dist/esm/model/nodes/SplitNode.js +101 -0
- package/dist/esm/model/nodes/SubGraphNode.js +180 -0
- package/dist/esm/model/nodes/TextNode.js +125 -0
- package/dist/esm/model/nodes/ToJsonNode.js +78 -0
- package/dist/esm/model/nodes/ToMarkdownTableNode.js +119 -0
- package/dist/esm/model/nodes/ToTreeNode.js +133 -0
- package/dist/esm/model/nodes/ToYamlNode.js +68 -0
- package/dist/esm/model/nodes/ToolNode.js +172 -0
- package/dist/esm/model/nodes/TrimChatMessagesNode.js +120 -0
- package/dist/esm/model/nodes/URLReferenceNode.js +79 -0
- package/dist/esm/model/nodes/UserInputNode.js +109 -0
- package/dist/esm/model/nodes/VectorNearestNeighborsNode.js +127 -0
- package/dist/esm/model/nodes/VectorStoreNode.js +124 -0
- package/dist/esm/model/nodes/WaitForEventNode.js +88 -0
- package/dist/esm/model/nodes/codeNodeErrorDiagnostics.js +104 -0
- package/dist/esm/model/nodes/jsListCallbackHelpers.js +196 -0
- package/dist/esm/model/nodes/jsValueInterpolation.js +163 -0
- package/dist/esm/model/nodes/toolCallDelegation.js +159 -0
- package/dist/esm/native/BaseDir.js +32 -0
- package/dist/esm/native/BrowserNativeApi.js +19 -0
- package/dist/esm/native/NativeApi.js +1 -0
- package/dist/esm/plugins/anthropic/anthropic.js +208 -0
- package/dist/esm/plugins/anthropic/fetchEventSource.js +107 -0
- package/dist/esm/plugins/anthropic/index.js +2 -0
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +767 -0
- package/dist/esm/plugins/anthropic/plugin.js +26 -0
- package/dist/esm/plugins/assemblyAi/LemurActionItemsNode.js +75 -0
- package/dist/esm/plugins/assemblyAi/LemurQaNode.js +155 -0
- package/dist/esm/plugins/assemblyAi/LemurSummaryNode.js +79 -0
- package/dist/esm/plugins/assemblyAi/LemurTaskNode.js +82 -0
- package/dist/esm/plugins/assemblyAi/TranscribeAudioNode.js +126 -0
- package/dist/esm/plugins/assemblyAi/index.js +2 -0
- package/dist/esm/plugins/assemblyAi/lemurHelpers.js +114 -0
- package/dist/esm/plugins/assemblyAi/plugin.js +32 -0
- package/dist/esm/plugins/autoevals/AutoEvalsNode.js +223 -0
- package/dist/esm/plugins/autoevals/index.js +2 -0
- package/dist/esm/plugins/autoevals/plugin.js +8 -0
- package/dist/esm/plugins/gentrace/index.js +3 -0
- package/dist/esm/plugins/gentrace/plugin.js +195 -0
- package/dist/esm/plugins/google/google.js +165 -0
- package/dist/esm/plugins/google/index.js +2 -0
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +584 -0
- package/dist/esm/plugins/google/plugin.js +39 -0
- package/dist/esm/plugins/huggingface/index.js +2 -0
- package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +243 -0
- package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +189 -0
- package/dist/esm/plugins/huggingface/plugin.js +26 -0
- package/dist/esm/plugins/openai/handleOpenaiError.js +17 -0
- package/dist/esm/plugins/openai/index.js +2 -0
- package/dist/esm/plugins/openai/nodes/AttachAssistantFileNode.js +123 -0
- package/dist/esm/plugins/openai/nodes/CreateAssistantNode.js +289 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadMessageNode.js +176 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadNode.js +157 -0
- package/dist/esm/plugins/openai/nodes/DeleteAssistantNode.js +104 -0
- package/dist/esm/plugins/openai/nodes/DeleteThreadNode.js +97 -0
- package/dist/esm/plugins/openai/nodes/GetAssistantNode.js +118 -0
- package/dist/esm/plugins/openai/nodes/GetOpenAIFileNode.js +100 -0
- package/dist/esm/plugins/openai/nodes/GetThreadNode.js +108 -0
- package/dist/esm/plugins/openai/nodes/ListAssistantsNode.js +202 -0
- package/dist/esm/plugins/openai/nodes/ListOpenAIFilesNode.js +94 -0
- package/dist/esm/plugins/openai/nodes/ListThreadMessagesNode.js +224 -0
- package/dist/esm/plugins/openai/nodes/RunThreadNode.js +630 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +143 -0
- package/dist/esm/plugins/openai/nodes/UploadFileNode.js +121 -0
- package/dist/esm/plugins/openai/plugin.js +44 -0
- package/dist/esm/plugins/pinecone/PineconeVectorDatabase.js +88 -0
- package/dist/esm/plugins/pinecone/index.js +2 -0
- package/dist/esm/plugins/pinecone/plugin.js +19 -0
- package/dist/esm/plugins.js +29 -0
- package/dist/esm/recording/ExecutionRecorder.js +273 -0
- package/dist/esm/recording/RecordedEvents.js +1 -0
- package/dist/esm/utils/assertNever.js +3 -0
- package/dist/esm/utils/base64.js +38 -0
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +73 -0
- package/dist/esm/utils/coerceType.js +326 -0
- package/dist/esm/utils/compatibility.js +27 -0
- package/dist/esm/utils/copyToClipboard.js +10 -0
- package/dist/esm/utils/defaults.js +2 -0
- package/dist/esm/utils/emitDetached.js +12 -0
- package/dist/esm/utils/errors.js +7 -0
- package/dist/esm/utils/expectType.js +34 -0
- package/dist/esm/utils/fetchEventSource.js +120 -0
- package/dist/esm/utils/genericUtilFunctions.js +25 -0
- package/dist/esm/utils/getPluginConfig.js +23 -0
- package/dist/esm/utils/handleEscapeCharacters.js +11 -0
- package/dist/esm/utils/index.js +17 -0
- package/dist/esm/utils/inputs.js +16 -0
- package/dist/esm/utils/interpolation.js +286 -0
- package/dist/esm/utils/misc.js +1 -0
- package/dist/esm/utils/newId.js +4 -0
- package/dist/esm/utils/openai.js +206 -0
- package/dist/esm/utils/orderedStringPortIds.js +27 -0
- package/dist/esm/utils/outputs.js +14 -0
- package/dist/esm/utils/pQueueCompat.js +12 -0
- package/dist/esm/utils/paths.js +80 -0
- package/dist/esm/utils/providerStreamParsing.js +14 -0
- package/dist/esm/utils/runtimeLogging.js +121 -0
- package/dist/esm/utils/serialization/serialization.js +77 -0
- package/dist/esm/utils/serialization/serializationHelpers.js +63 -0
- package/dist/esm/utils/serialization/serializationUtils.js +112 -0
- package/dist/esm/utils/serialization/serialization_v1.js +19 -0
- package/dist/esm/utils/serialization/serialization_v2.js +24 -0
- package/dist/esm/utils/serialization/serialization_v3.js +100 -0
- package/dist/esm/utils/serialization/serialization_v4.js +156 -0
- package/dist/esm/utils/symbols.js +2 -0
- package/dist/esm/utils/time.js +14 -0
- package/dist/esm/utils/typeSafety.js +42 -0
- package/dist/esm/vendor/fnv1a.js +80 -0
- package/dist/types/api/createProcessor.d.ts +56 -0
- package/dist/types/api/looseDataValue.d.ts +4 -0
- package/dist/types/api/processSettings.d.ts +4 -0
- package/dist/types/api/streaming.d.ts +56 -0
- package/dist/types/exports.d.ts +49 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/integrations/AudioProvider.d.ts +4 -0
- package/dist/types/integrations/CodeRunner.d.ts +19 -0
- package/dist/types/integrations/DatasetProvider.d.ts +33 -0
- package/dist/types/integrations/EmbeddingGenerator.d.ts +3 -0
- package/dist/types/integrations/GptTokenizerTokenizer.d.ts +20 -0
- package/dist/types/integrations/LLMProvider.d.ts +7 -0
- package/dist/types/integrations/Tokenizer.d.ts +11 -0
- package/dist/types/integrations/VectorDatabase.d.ts +7 -0
- package/dist/types/integrations/enableIntegrations.d.ts +1 -0
- package/dist/types/integrations/integrations.d.ts +12 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +18 -0
- package/dist/types/integrations/mcp/MCPProvider.d.ts +153 -0
- package/dist/types/integrations/mcp/MCPUtils.d.ts +9 -0
- package/dist/types/integrations/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
- package/dist/types/model/CycleDetector.d.ts +2 -0
- package/dist/types/model/DataValue.d.ts +160 -0
- package/dist/types/model/Dataset.d.ts +19 -0
- package/dist/types/model/EditorDefinition.d.ts +176 -0
- package/dist/types/model/ExecutorProtocol.d.ts +216 -0
- package/dist/types/model/GraphPreprocessor.d.ts +24 -0
- package/dist/types/model/GraphProcessor.d.ts +210 -0
- package/dist/types/model/NodeBase.d.ts +116 -0
- package/dist/types/model/NodeBodySpec.d.ts +19 -0
- package/dist/types/model/NodeDefinition.d.ts +13 -0
- package/dist/types/model/NodeExecutionPlanner.d.ts +28 -0
- package/dist/types/model/NodeGraph.d.ts +15 -0
- package/dist/types/model/NodeImpl.d.ts +56 -0
- package/dist/types/model/NodeRegistration.d.ts +29 -0
- package/dist/types/model/Nodes.d.ts +112 -0
- package/dist/types/model/PluginLoadSpec.d.ts +17 -0
- package/dist/types/model/ProcessContext.d.ts +110 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +41 -0
- package/dist/types/model/Project.d.ts +31 -0
- package/dist/types/model/ProjectReferenceLoader.d.ts +5 -0
- package/dist/types/model/RecordingPlayer.d.ts +27 -0
- package/dist/types/model/RegistryAssembly.d.ts +42 -0
- package/dist/types/model/RivetPlugin.d.ts +51 -0
- package/dist/types/model/RivetUIContext.d.ts +27 -0
- package/dist/types/model/Settings.d.ts +20 -0
- package/dist/types/model/SplitRunProcessor.d.ts +31 -0
- package/dist/types/model/SubprocessorBridge.d.ts +13 -0
- package/dist/types/model/chat/aiSdkMessages.d.ts +3 -0
- package/dist/types/model/chat/aiSdkStreaming.d.ts +9 -0
- package/dist/types/model/chat/aiSdkTools.d.ts +3 -0
- package/dist/types/model/chat/chatCost.d.ts +30 -0
- package/dist/types/model/chat/chatMessages.d.ts +5 -0
- package/dist/types/model/chat/openAIChatRequest.d.ts +39 -0
- package/dist/types/model/chat/openAIChatRuntime.d.ts +61 -0
- package/dist/types/model/chat/streamChatResponse.d.ts +27 -0
- package/dist/types/model/chat/tokenBudget.d.ts +3 -0
- package/dist/types/model/chat-v2/aiSdkBridge.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +25 -0
- package/dist/types/model/chat-v2/chatV2Errors.d.ts +23 -0
- package/dist/types/model/chat-v2/chatV2FeatureCompatibility.d.ts +12 -0
- package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +24 -0
- package/dist/types/model/chat-v2/chatV2Retry.d.ts +5 -0
- package/dist/types/model/chat-v2/chatV2RuntimeOptions.d.ts +12 -0
- package/dist/types/model/chat-v2/chatV2Shared.d.ts +56 -0
- package/dist/types/model/chat-v2/chatV2Types.d.ts +110 -0
- package/dist/types/model/chat-v2/index.d.ts +10 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +73 -0
- package/dist/types/model/chat-v2/llmChatV2NodeEditors.d.ts +4 -0
- package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +23 -0
- package/dist/types/model/chat-v2/messageConverter.d.ts +8 -0
- package/dist/types/model/chat-v2/modelRegistry.d.ts +296 -0
- package/dist/types/model/chat-v2/providerOptions.d.ts +59 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +15 -0
- package/dist/types/model/chat-v2/toolConverter.d.ts +3 -0
- package/dist/types/model/interpolationInputDefinition.d.ts +16 -0
- package/dist/types/model/loopControllerBreak.d.ts +3 -0
- package/dist/types/model/nodes/AbortGraphNode.d.ts +22 -0
- package/dist/types/model/nodes/AppendToDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +20 -0
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +23 -0
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +23 -0
- package/dist/types/model/nodes/AudioNode.d.ts +20 -0
- package/dist/types/model/nodes/BooleanNode.d.ts +19 -0
- package/dist/types/model/nodes/CallGraphNode.d.ts +16 -0
- package/dist/types/model/nodes/ChatLoopNode.d.ts +21 -0
- package/dist/types/model/nodes/ChatNode.d.ts +17 -0
- package/dist/types/model/nodes/ChatNodeBase.d.ts +85 -0
- package/dist/types/model/nodes/ChunkNode.d.ts +22 -0
- package/dist/types/model/nodes/CoalesceNode.d.ts +14 -0
- package/dist/types/model/nodes/CodeNode.d.ts +27 -0
- package/dist/types/model/nodes/CommentNode.d.ts +20 -0
- package/dist/types/model/nodes/CompareNode.d.ts +19 -0
- package/dist/types/model/nodes/ContextNode.d.ts +24 -0
- package/dist/types/model/nodes/CreateDatasetNode.d.ts +13 -0
- package/dist/types/model/nodes/CronNode.d.ts +34 -0
- package/dist/types/model/nodes/DatasetNearestNeigborsNode.d.ts +19 -0
- package/dist/types/model/nodes/DelayNode.d.ts +20 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +28 -0
- package/dist/types/model/nodes/DestructureNode.d.ts +19 -0
- package/dist/types/model/nodes/DocumentNode.d.ts +28 -0
- package/dist/types/model/nodes/EvaluateNode.d.ts +19 -0
- package/dist/types/model/nodes/ExpressionNode.d.ts +21 -0
- package/dist/types/model/nodes/ExternalCallNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractJsonNode.d.ts +13 -0
- package/dist/types/model/nodes/ExtractMarkdownCodeBlocksNode.d.ts +12 -0
- package/dist/types/model/nodes/ExtractObjectPathNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractRegexNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractYamlNode.d.ts +21 -0
- package/dist/types/model/nodes/FilterNode.d.ts +13 -0
- package/dist/types/model/nodes/GetAllDatasetsNode.d.ts +14 -0
- package/dist/types/model/nodes/GetDatasetRowNode.d.ts +19 -0
- package/dist/types/model/nodes/GetEmbeddingNode.d.ts +24 -0
- package/dist/types/model/nodes/GetGlobalNode.d.ts +29 -0
- package/dist/types/model/nodes/GraphInputNode.d.ts +24 -0
- package/dist/types/model/nodes/GraphOutputNode.d.ts +22 -0
- package/dist/types/model/nodes/GraphReferenceNode.d.ts +22 -0
- package/dist/types/model/nodes/HashNode.d.ts +17 -0
- package/dist/types/model/nodes/HttpCallNode.d.ts +32 -0
- package/dist/types/model/nodes/IfElseNode.d.ts +18 -0
- package/dist/types/model/nodes/IfNode.d.ts +17 -0
- package/dist/types/model/nodes/ImageNode.d.ts +20 -0
- package/dist/types/model/nodes/JSFilterNode.d.ts +19 -0
- package/dist/types/model/nodes/JSMapNode.d.ts +19 -0
- package/dist/types/model/nodes/JoinNode.d.ts +21 -0
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +20 -0
- package/dist/types/model/nodes/ListGraphsNode.d.ts +14 -0
- package/dist/types/model/nodes/LoadDatasetNode.d.ts +17 -0
- package/dist/types/model/nodes/LoopControllerNode.d.ts +20 -0
- package/dist/types/model/nodes/LoopUntilNode.d.ts +32 -0
- package/dist/types/model/nodes/MCPDiscoveryNode.d.ts +9 -0
- package/dist/types/model/nodes/MCPGetPromptNode.d.ts +23 -0
- package/dist/types/model/nodes/MCPToolCallNode.d.ts +26 -0
- package/dist/types/model/nodes/MatchNode.d.ts +20 -0
- package/dist/types/model/nodes/NumberNode.d.ts +21 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +19 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +14 -0
- package/dist/types/model/nodes/PlayAudioNode.d.ts +15 -0
- package/dist/types/model/nodes/PopNode.d.ts +19 -0
- package/dist/types/model/nodes/PromptNode.d.ts +25 -0
- package/dist/types/model/nodes/RaceInputsNode.d.ts +16 -0
- package/dist/types/model/nodes/RaiseEventNode.d.ts +22 -0
- package/dist/types/model/nodes/RandomNumberNode.d.ts +23 -0
- package/dist/types/model/nodes/ReadAllFilesNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadDirectoryNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadFileNode.d.ts +23 -0
- package/dist/types/model/nodes/ReferencedGraphAliasNode.d.ts +31 -0
- package/dist/types/model/nodes/ReplaceDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/SetGlobalNode.d.ts +23 -0
- package/dist/types/model/nodes/ShuffleNode.d.ts +12 -0
- package/dist/types/model/nodes/SliceNode.d.ts +22 -0
- package/dist/types/model/nodes/SplitNode.d.ts +19 -0
- package/dist/types/model/nodes/SubGraphNode.d.ts +29 -0
- package/dist/types/model/nodes/TextNode.d.ts +19 -0
- package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
- package/dist/types/model/nodes/ToMarkdownTableNode.d.ts +19 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +21 -0
- package/dist/types/model/nodes/ToYamlNode.d.ts +13 -0
- package/dist/types/model/nodes/ToolNode.d.ts +25 -0
- package/dist/types/model/nodes/TrimChatMessagesNode.d.ts +20 -0
- package/dist/types/model/nodes/URLReferenceNode.d.ts +19 -0
- package/dist/types/model/nodes/UserInputNode.d.ts +20 -0
- package/dist/types/model/nodes/VectorNearestNeighborsNode.d.ts +24 -0
- package/dist/types/model/nodes/VectorStoreNode.d.ts +22 -0
- package/dist/types/model/nodes/WaitForEventNode.d.ts +21 -0
- package/dist/types/model/nodes/codeNodeErrorDiagnostics.d.ts +9 -0
- package/dist/types/model/nodes/jsListCallbackHelpers.d.ts +23 -0
- package/dist/types/model/nodes/jsValueInterpolation.d.ts +11 -0
- package/dist/types/model/nodes/toolCallDelegation.d.ts +29 -0
- package/dist/types/native/BaseDir.d.ts +29 -0
- package/dist/types/native/BrowserNativeApi.d.ts +9 -0
- package/dist/types/native/NativeApi.d.ts +17 -0
- package/dist/types/plugins/anthropic/anthropic.d.ts +315 -0
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +11 -0
- package/dist/types/plugins/anthropic/index.d.ts +2 -0
- package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +40 -0
- package/dist/types/plugins/anthropic/plugin.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/LemurActionItemsNode.d.ts +6 -0
- package/dist/types/plugins/assemblyAi/LemurQaNode.d.ts +22 -0
- package/dist/types/plugins/assemblyAi/LemurSummaryNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/LemurTaskNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/TranscribeAudioNode.d.ts +7 -0
- package/dist/types/plugins/assemblyAi/index.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/lemurHelpers.d.ts +67 -0
- package/dist/types/plugins/assemblyAi/plugin.d.ts +2 -0
- package/dist/types/plugins/autoevals/AutoEvalsNode.d.ts +8 -0
- package/dist/types/plugins/autoevals/index.d.ts +2 -0
- package/dist/types/plugins/autoevals/plugin.d.ts +2 -0
- package/dist/types/plugins/gentrace/index.d.ts +2 -0
- package/dist/types/plugins/gentrace/plugin.d.ts +10 -0
- package/dist/types/plugins/google/google.d.ts +129 -0
- package/dist/types/plugins/google/index.d.ts +2 -0
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +35 -0
- package/dist/types/plugins/google/plugin.d.ts +2 -0
- package/dist/types/plugins/huggingface/index.d.ts +2 -0
- package/dist/types/plugins/huggingface/nodes/ChatHuggingFace.d.ts +24 -0
- package/dist/types/plugins/huggingface/nodes/TextToImageHuggingFace.d.ts +20 -0
- package/dist/types/plugins/huggingface/plugin.d.ts +2 -0
- package/dist/types/plugins/openai/handleOpenaiError.d.ts +1 -0
- package/dist/types/plugins/openai/index.d.ts +2 -0
- package/dist/types/plugins/openai/nodes/AttachAssistantFileNode.d.ts +10 -0
- package/dist/types/plugins/openai/nodes/CreateAssistantNode.d.ts +26 -0
- package/dist/types/plugins/openai/nodes/CreateThreadMessageNode.d.ts +15 -0
- package/dist/types/plugins/openai/nodes/CreateThreadNode.d.ts +13 -0
- package/dist/types/plugins/openai/nodes/DeleteAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/DeleteThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetOpenAIFileNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListAssistantsNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/ListOpenAIFilesNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListThreadMessagesNode.d.ts +16 -0
- package/dist/types/plugins/openai/nodes/RunThreadNode.d.ts +28 -0
- package/dist/types/plugins/openai/nodes/ThreadMessageNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/UploadFileNode.d.ts +7 -0
- package/dist/types/plugins/openai/plugin.d.ts +2 -0
- package/dist/types/plugins/pinecone/PineconeVectorDatabase.d.ts +9 -0
- package/dist/types/plugins/pinecone/index.d.ts +2 -0
- package/dist/types/plugins/pinecone/plugin.d.ts +2 -0
- package/dist/types/plugins.d.ts +22 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +27 -0
- package/dist/types/recording/RecordedEvents.d.ts +114 -0
- package/dist/types/utils/assertNever.d.ts +1 -0
- package/dist/types/utils/base64.d.ts +3 -0
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +5 -0
- package/dist/types/utils/coerceType.d.ts +6 -0
- package/dist/types/utils/compatibility.d.ts +3 -0
- package/dist/types/utils/copyToClipboard.d.ts +1 -0
- package/dist/types/utils/defaults.d.ts +2 -0
- package/dist/types/utils/emitDetached.d.ts +11 -0
- package/dist/types/utils/errors.d.ts +2 -0
- package/dist/types/utils/expectType.d.ts +3 -0
- package/dist/types/utils/fetchEventSource.d.ts +12 -0
- package/dist/types/utils/genericUtilFunctions.d.ts +21 -0
- package/dist/types/utils/getPluginConfig.d.ts +2 -0
- package/dist/types/utils/handleEscapeCharacters.d.ts +2 -0
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/utils/inputs.d.ts +3 -0
- package/dist/types/utils/interpolation.d.ts +26 -0
- package/dist/types/utils/misc.d.ts +1 -0
- package/dist/types/utils/newId.d.ts +1 -0
- package/dist/types/utils/openai.d.ts +784 -0
- package/dist/types/utils/orderedStringPortIds.d.ts +10 -0
- package/dist/types/utils/outputs.d.ts +3 -0
- package/dist/types/utils/pQueueCompat.d.ts +10 -0
- package/dist/types/utils/paths.d.ts +8 -0
- package/dist/types/utils/providerStreamParsing.d.ts +1 -0
- package/dist/types/utils/runtimeLogging.d.ts +10 -0
- package/dist/types/utils/serialization/serialization.d.ts +12 -0
- package/dist/types/utils/serialization/serializationHelpers.d.ts +27 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +16 -0
- package/dist/types/utils/serialization/serialization_v1.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v2.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v3.d.ts +19 -0
- package/dist/types/utils/serialization/serialization_v4.d.ts +9 -0
- package/dist/types/utils/symbols.d.ts +3 -0
- package/dist/types/utils/time.d.ts +22 -0
- package/dist/types/utils/typeSafety.d.ts +37 -0
- package/dist/types/vendor/fnv1a.d.ts +9 -0
- package/package.json +77 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { getError } from '../utils/errors.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { emitDetached } from '../utils/emitDetached.js';
|
|
4
|
+
export async function replayExecutionRecording(options) {
|
|
5
|
+
const { emitter, erroredNodes, graphOutputs, project, recorder, recordingPlaybackChatLatency, setContextValues, setGraphInputs, setGraphOutputs, setRunning, visitedNodes, waitUntilUnpaused, nodeResults, isAborted, } = options;
|
|
6
|
+
const nodesByIdAllGraphs = {};
|
|
7
|
+
const graphIdByNodeId = {};
|
|
8
|
+
for (const graph of Object.values(project.graphs)) {
|
|
9
|
+
for (const node of graph.nodes) {
|
|
10
|
+
nodesByIdAllGraphs[node.id] = node;
|
|
11
|
+
graphIdByNodeId[node.id] = graph.metadata.id;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const rootGraphId = (project.metadata.mainGraphId ?? Object.keys(project.graphs)[0]);
|
|
15
|
+
const getGraph = (graphId) => {
|
|
16
|
+
const graph = project.graphs[graphId];
|
|
17
|
+
if (!graph) {
|
|
18
|
+
throw new Error(`Mismatch between project and recording: graph ${graphId} not found in project`);
|
|
19
|
+
}
|
|
20
|
+
return graph;
|
|
21
|
+
};
|
|
22
|
+
const getNode = (nodeId) => {
|
|
23
|
+
const node = nodesByIdAllGraphs[nodeId];
|
|
24
|
+
if (!node) {
|
|
25
|
+
throw new Error(`Mismatch between project and recording: node ${nodeId} not found in any graph in project`);
|
|
26
|
+
}
|
|
27
|
+
return node;
|
|
28
|
+
};
|
|
29
|
+
const getGraphIdForNode = (nodeId) => {
|
|
30
|
+
const graphId = graphIdByNodeId[nodeId];
|
|
31
|
+
if (!graphId) {
|
|
32
|
+
throw new Error(`Mismatch between project and recording: node ${nodeId} is not associated with a graph in project`);
|
|
33
|
+
}
|
|
34
|
+
return graphId;
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const legacyRootRunId = nanoid();
|
|
38
|
+
const legacyGraphRunsByGraphId = new Map();
|
|
39
|
+
const getExecution = (graphId, recordedExecution) => {
|
|
40
|
+
if (recordedExecution) {
|
|
41
|
+
return recordedExecution;
|
|
42
|
+
}
|
|
43
|
+
let graphRunId = legacyGraphRunsByGraphId.get(graphId);
|
|
44
|
+
if (!graphRunId) {
|
|
45
|
+
graphRunId = nanoid();
|
|
46
|
+
legacyGraphRunsByGraphId.set(graphId, graphRunId);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
graphId,
|
|
50
|
+
graphRunId,
|
|
51
|
+
rootRunId: legacyRootRunId,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
for (const event of recorder.events) {
|
|
55
|
+
if (isAborted()) {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
await waitUntilUnpaused();
|
|
59
|
+
switch (event.type) {
|
|
60
|
+
case 'start': {
|
|
61
|
+
const { data } = event;
|
|
62
|
+
emitDetached(emitter, 'start', {
|
|
63
|
+
project,
|
|
64
|
+
contextValues: data.contextValues,
|
|
65
|
+
inputs: data.inputs,
|
|
66
|
+
startGraph: getGraph(data.startGraph),
|
|
67
|
+
execution: getExecution(data.startGraph, data.execution),
|
|
68
|
+
});
|
|
69
|
+
setContextValues(data.contextValues);
|
|
70
|
+
setGraphInputs(data.inputs);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'abort': {
|
|
74
|
+
emitDetached(emitter, 'abort', event.data);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 'pause':
|
|
78
|
+
case 'resume': {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case 'done': {
|
|
82
|
+
emitDetached(emitter, 'done', event.data);
|
|
83
|
+
setGraphOutputs(event.data.results);
|
|
84
|
+
setRunning(false);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'error': {
|
|
88
|
+
emitDetached(emitter, 'error', event.data);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'globalSet': {
|
|
92
|
+
const { data } = event;
|
|
93
|
+
emitDetached(emitter, 'globalSet', {
|
|
94
|
+
...data,
|
|
95
|
+
execution: getExecution(data.execution?.graphId ?? rootGraphId, data.execution),
|
|
96
|
+
});
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 'trace': {
|
|
100
|
+
emitDetached(emitter, 'trace', event.data);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case 'graphStart': {
|
|
104
|
+
const { data } = event;
|
|
105
|
+
const execution = getExecution(data.graphId, data.execution);
|
|
106
|
+
legacyGraphRunsByGraphId.set(data.graphId, execution.graphRunId);
|
|
107
|
+
emitDetached(emitter, 'graphStart', {
|
|
108
|
+
graph: getGraph(data.graphId),
|
|
109
|
+
inputs: data.inputs,
|
|
110
|
+
execution,
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case 'graphFinish': {
|
|
115
|
+
const { data } = event;
|
|
116
|
+
emitDetached(emitter, 'graphFinish', {
|
|
117
|
+
graph: getGraph(data.graphId),
|
|
118
|
+
outputs: data.outputs,
|
|
119
|
+
execution: getExecution(data.graphId, data.execution),
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case 'graphError': {
|
|
124
|
+
const { data } = event;
|
|
125
|
+
emitDetached(emitter, 'graphError', {
|
|
126
|
+
graph: getGraph(data.graphId),
|
|
127
|
+
error: data.error,
|
|
128
|
+
execution: getExecution(data.graphId, data.execution),
|
|
129
|
+
});
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case 'graphAbort': {
|
|
133
|
+
const { data } = event;
|
|
134
|
+
emitDetached(emitter, 'graphAbort', {
|
|
135
|
+
graph: getGraph(data.graphId),
|
|
136
|
+
error: data.error,
|
|
137
|
+
successful: data.successful,
|
|
138
|
+
execution: getExecution(data.graphId, data.execution),
|
|
139
|
+
});
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case 'nodeStart': {
|
|
143
|
+
const { data } = event;
|
|
144
|
+
const node = getNode(data.nodeId);
|
|
145
|
+
emitDetached(emitter, 'nodeStart', {
|
|
146
|
+
node,
|
|
147
|
+
inputs: data.inputs,
|
|
148
|
+
processId: data.processId,
|
|
149
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
150
|
+
});
|
|
151
|
+
if (node.type === 'chat') {
|
|
152
|
+
await new Promise((resolve) => setTimeout(resolve, recordingPlaybackChatLatency));
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case 'nodeFinish': {
|
|
157
|
+
const { data } = event;
|
|
158
|
+
const node = getNode(data.nodeId);
|
|
159
|
+
emitDetached(emitter, 'nodeFinish', {
|
|
160
|
+
node,
|
|
161
|
+
outputs: data.outputs,
|
|
162
|
+
processId: data.processId,
|
|
163
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
164
|
+
});
|
|
165
|
+
nodeResults.set(data.nodeId, data.outputs);
|
|
166
|
+
visitedNodes.add(data.nodeId);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 'nodeError': {
|
|
170
|
+
const { data } = event;
|
|
171
|
+
const node = getNode(data.nodeId);
|
|
172
|
+
emitDetached(emitter, 'nodeError', {
|
|
173
|
+
node,
|
|
174
|
+
error: data.error,
|
|
175
|
+
processId: data.processId,
|
|
176
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
177
|
+
});
|
|
178
|
+
erroredNodes.set(data.nodeId, data.error);
|
|
179
|
+
visitedNodes.add(data.nodeId);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case 'nodeExcluded': {
|
|
183
|
+
const { data } = event;
|
|
184
|
+
const node = getNode(data.nodeId);
|
|
185
|
+
emitDetached(emitter, 'nodeExcluded', {
|
|
186
|
+
node,
|
|
187
|
+
processId: data.processId,
|
|
188
|
+
inputs: data.inputs,
|
|
189
|
+
outputs: data.outputs,
|
|
190
|
+
reason: data.reason,
|
|
191
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
192
|
+
});
|
|
193
|
+
visitedNodes.add(data.nodeId);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'nodeOutputsCleared': {
|
|
197
|
+
const { data } = event;
|
|
198
|
+
const node = getNode(data.nodeId);
|
|
199
|
+
if (data.processId == null) {
|
|
200
|
+
nodeResults.delete(data.nodeId);
|
|
201
|
+
}
|
|
202
|
+
emitDetached(emitter, 'nodeOutputsCleared', {
|
|
203
|
+
node,
|
|
204
|
+
processId: data.processId,
|
|
205
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
206
|
+
});
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case 'partialOutput': {
|
|
210
|
+
const { data } = event;
|
|
211
|
+
const node = getNode(data.nodeId);
|
|
212
|
+
emitDetached(emitter, 'partialOutput', {
|
|
213
|
+
node,
|
|
214
|
+
outputs: data.outputs,
|
|
215
|
+
index: data.index,
|
|
216
|
+
processId: data.processId,
|
|
217
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
218
|
+
});
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 'userInput': {
|
|
222
|
+
const { data } = event;
|
|
223
|
+
const node = getNode(data.nodeId);
|
|
224
|
+
emitDetached(emitter, 'userInput', {
|
|
225
|
+
callback: undefined,
|
|
226
|
+
inputStrings: data.inputStrings,
|
|
227
|
+
inputs: data.inputs,
|
|
228
|
+
node,
|
|
229
|
+
processId: data.processId,
|
|
230
|
+
renderingType: data.renderingType,
|
|
231
|
+
execution: getExecution(data.execution?.graphId ?? getGraphIdForNode(data.nodeId), data.execution),
|
|
232
|
+
});
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
case 'newAbortController': {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case 'finish': {
|
|
239
|
+
emitDetached(emitter, 'finish', undefined);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
default: {
|
|
243
|
+
const typedEvent = event;
|
|
244
|
+
if (typedEvent.type.startsWith('globalSet:')) {
|
|
245
|
+
emitDetached(emitter, typedEvent.type, typedEvent.data);
|
|
246
|
+
}
|
|
247
|
+
else if (typedEvent.type.startsWith('userEvent:')) {
|
|
248
|
+
emitDetached(emitter, typedEvent.type, typedEvent.data);
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
emitDetached(emitter, 'error', { error: getError(error) });
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
setRunning(false);
|
|
260
|
+
}
|
|
261
|
+
return graphOutputs;
|
|
262
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry assembly helpers.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the three explicit operations on a node registry:
|
|
5
|
+
* 1. createBuiltInRegistry - fresh registry with only built-in nodes
|
|
6
|
+
* 2. registerProjectPlugins - extend a registry with loaded plugins
|
|
7
|
+
* 3. assembleRegistry - 1 + 2 in one step
|
|
8
|
+
*
|
|
9
|
+
* Both the app (useProjectPlugins) and the sidecar (executor.mts) share
|
|
10
|
+
* this flow. Plugin *loading* is environment-specific, so callers supply
|
|
11
|
+
* a `loadPlugin` callback that resolves a PluginLoadSpec into a RivetPlugin.
|
|
12
|
+
*/
|
|
13
|
+
import { NodeRegistration } from './NodeRegistration.js';
|
|
14
|
+
import { registerBuiltInNodes } from './Nodes.js';
|
|
15
|
+
/** Create a fresh registry containing only built-in nodes (no plugins). */
|
|
16
|
+
export function createBuiltInRegistry() {
|
|
17
|
+
return registerBuiltInNodes(new NodeRegistration());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register an array of already-loaded plugins into a registry.
|
|
21
|
+
* Returns the count of successfully registered plugins.
|
|
22
|
+
*/
|
|
23
|
+
export function registerPluginsIntoRegistry(registry, plugins) {
|
|
24
|
+
for (const plugin of plugins) {
|
|
25
|
+
registry.registerPlugin(plugin);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Assemble a complete registry: built-in nodes + project plugins.
|
|
30
|
+
*
|
|
31
|
+
* `loadPlugin` is called for each spec and must return a `RivetPlugin`.
|
|
32
|
+
* If loading or registration throws, the spec is recorded as failed and
|
|
33
|
+
* assembly continues.
|
|
34
|
+
*
|
|
35
|
+
* Returns the assembled registry plus load results.
|
|
36
|
+
*/
|
|
37
|
+
export async function assembleRegistry(specs, loadPlugin) {
|
|
38
|
+
const registry = createBuiltInRegistry();
|
|
39
|
+
const loaded = [];
|
|
40
|
+
const failed = [];
|
|
41
|
+
for (const spec of specs) {
|
|
42
|
+
try {
|
|
43
|
+
const plugin = await loadPlugin(spec);
|
|
44
|
+
registerPluginsIntoRegistry(registry, [plugin]);
|
|
45
|
+
loaded.push(plugin);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
+
failed.push({ id: spec.id, error: message });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { registry, results: { loaded, failed } };
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from './NodeBase.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { max, range } from 'lodash-es';
|
|
2
|
+
import { isArrayDataValue, arrayizeDataValue, } from './DataValue.js';
|
|
3
|
+
import {} from './NodeBase.js';
|
|
4
|
+
import { getError } from '../utils/errors.js';
|
|
5
|
+
import PQueue from '../utils/pQueueCompat.js';
|
|
6
|
+
import { entries, fromEntries, values } from '../utils/typeSafety.js';
|
|
7
|
+
export async function processSplitRunNode(node, processId, deps) {
|
|
8
|
+
const inputValues = deps.getInputValues(node);
|
|
9
|
+
if (deps.isExcludedDueToControlFlow(node, inputValues, processId)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const splittingAmount = Math.min(max(values(inputValues).map((value) => (Array.isArray(value?.value) ? value?.value.length : 1))) ?? 1, node.splitRunMax ?? 10);
|
|
13
|
+
deps.emit('nodeStart', { node, inputs: inputValues, processId });
|
|
14
|
+
try {
|
|
15
|
+
let results;
|
|
16
|
+
if (node.isSplitSequential) {
|
|
17
|
+
results = await runSequential(node, inputValues, splittingAmount, processId, deps);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
results = await runParallel(node, inputValues, splittingAmount, processId, deps);
|
|
21
|
+
}
|
|
22
|
+
const errors = results.filter((r) => r.type === 'error').map((r) => r.error);
|
|
23
|
+
if (errors.length === 1) {
|
|
24
|
+
throw errors[0];
|
|
25
|
+
}
|
|
26
|
+
else if (errors.length > 0) {
|
|
27
|
+
throw new AggregateError(errors);
|
|
28
|
+
}
|
|
29
|
+
const aggregateResults = aggregateOutputs(results);
|
|
30
|
+
deps.setNodeResults(node.id, aggregateResults);
|
|
31
|
+
deps.markNodeVisited(node.id);
|
|
32
|
+
deps.emit('nodeFinish', { node, outputs: aggregateResults, processId });
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
deps.nodeErrored(node, error, processId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function runSequential(node, inputValues, splittingAmount, processId, deps) {
|
|
39
|
+
const results = [];
|
|
40
|
+
for (let i = 0; i < splittingAmount; i++) {
|
|
41
|
+
if (deps.isAborted()) {
|
|
42
|
+
throw new Error('Processing aborted');
|
|
43
|
+
}
|
|
44
|
+
const inputs = splitInputsAtIndex(inputValues, i);
|
|
45
|
+
try {
|
|
46
|
+
const output = await deps.processNodeWithInputData(node, inputs, i, processId, (n, partialOutputs, index) => {
|
|
47
|
+
deps.emit('partialOutput', { node: n, outputs: partialOutputs, index, processId });
|
|
48
|
+
});
|
|
49
|
+
deps.accumulateCost(output);
|
|
50
|
+
results.push({ type: 'output', output });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
results.push({ type: 'error', error: getError(error) });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return results;
|
|
57
|
+
}
|
|
58
|
+
async function runParallel(node, inputValues, splittingAmount, processId, deps) {
|
|
59
|
+
const queue = new PQueue({ concurrency: getParallelSplitRunConcurrency(node, deps.splitRunConcurrency) });
|
|
60
|
+
return Promise.all(range(0, splittingAmount).map(async (i) => {
|
|
61
|
+
const result = await queue.add(async () => {
|
|
62
|
+
const inputs = splitInputsAtIndex(inputValues, i);
|
|
63
|
+
try {
|
|
64
|
+
const output = await deps.processNodeWithInputData(node, inputs, i, processId, (n, partialOutputs, index) => {
|
|
65
|
+
deps.emit('partialOutput', { node: n, outputs: partialOutputs, index, processId });
|
|
66
|
+
});
|
|
67
|
+
deps.accumulateCost(output);
|
|
68
|
+
return { type: 'output', output };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return { type: 'error', error: getError(error) };
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!result) {
|
|
75
|
+
throw new Error('Parallel split-run task completed without a result.');
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
function getParallelSplitRunConcurrency(node, defaultConcurrency) {
|
|
81
|
+
const value = node.splitRunConcurrency;
|
|
82
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 2 ? Math.floor(value) : defaultConcurrency;
|
|
83
|
+
}
|
|
84
|
+
function splitInputsAtIndex(inputValues, index) {
|
|
85
|
+
return fromEntries(entries(inputValues).map(([port, value]) => [
|
|
86
|
+
port,
|
|
87
|
+
isArrayDataValue(value) ? arrayizeDataValue(value)[index] ?? undefined : value,
|
|
88
|
+
]));
|
|
89
|
+
}
|
|
90
|
+
function aggregateOutputs(results) {
|
|
91
|
+
return results.reduce((acc, result) => {
|
|
92
|
+
for (const [portId, value] of entries(result.output)) {
|
|
93
|
+
acc[portId] ??= { type: (value?.type + '[]'), value: [] };
|
|
94
|
+
acc[portId].value.push(value?.value);
|
|
95
|
+
}
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export function wireSubprocessorEvents(processor, parentEmitter, parentState) {
|
|
2
|
+
const unsubscribers = [
|
|
3
|
+
processor.on('nodeError', (event) => parentEmitter.emit('nodeError', event)),
|
|
4
|
+
processor.on('nodeFinish', (event) => parentEmitter.emit('nodeFinish', event)),
|
|
5
|
+
processor.on('partialOutput', (event) => parentEmitter.emit('partialOutput', event)),
|
|
6
|
+
processor.on('nodeExcluded', (event) => parentEmitter.emit('nodeExcluded', event)),
|
|
7
|
+
processor.on('nodeStart', (event) => parentEmitter.emit('nodeStart', event)),
|
|
8
|
+
processor.on('graphAbort', (event) => parentEmitter.emit('graphAbort', event)),
|
|
9
|
+
processor.on('graphError', (event) => parentEmitter.emit('graphError', event)),
|
|
10
|
+
processor.on('userInput', (event) => parentEmitter.emit('userInput', event)),
|
|
11
|
+
processor.on('graphStart', (event) => parentEmitter.emit('graphStart', event)),
|
|
12
|
+
processor.on('graphFinish', (event) => parentEmitter.emit('graphFinish', event)),
|
|
13
|
+
processor.on('nodeOutputsCleared', (event) => parentEmitter.emit('nodeOutputsCleared', event)),
|
|
14
|
+
processor.on('globalSet', (event) => parentEmitter.emit('globalSet', event)),
|
|
15
|
+
processor.on('newAbortController', (event) => parentEmitter.emit('newAbortController', event)),
|
|
16
|
+
processor.on('pause', () => {
|
|
17
|
+
if (!parentState.isPaused()) {
|
|
18
|
+
parentState.pause();
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
processor.on('resume', () => {
|
|
22
|
+
if (parentState.isPaused()) {
|
|
23
|
+
parentState.resume();
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
27
|
+
const unsubscribeAny = processor.onAny((event, data) => {
|
|
28
|
+
if (event.startsWith('globalSet:')) {
|
|
29
|
+
void parentEmitter.emit(event, data);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
let cleanedUp = false;
|
|
33
|
+
const cleanup = () => {
|
|
34
|
+
if (cleanedUp) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
cleanedUp = true;
|
|
38
|
+
unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
39
|
+
unsubscribeAny();
|
|
40
|
+
unsubscribeGraphFinish();
|
|
41
|
+
unsubscribeGraphAbort();
|
|
42
|
+
unsubscribeGraphError();
|
|
43
|
+
};
|
|
44
|
+
const unsubscribeGraphFinish = processor.on('graphFinish', cleanup);
|
|
45
|
+
const unsubscribeGraphAbort = processor.on('graphAbort', cleanup);
|
|
46
|
+
const unsubscribeGraphError = processor.on('graphError', cleanup);
|
|
47
|
+
}
|
|
48
|
+
export function wireSubprocessorLifecycle(processor, options) {
|
|
49
|
+
const abortFromSignal = () => {
|
|
50
|
+
void processor.abort();
|
|
51
|
+
};
|
|
52
|
+
const abortFromParent = () => {
|
|
53
|
+
void processor.abort();
|
|
54
|
+
};
|
|
55
|
+
const pauseProcessor = () => {
|
|
56
|
+
void processor.pause();
|
|
57
|
+
};
|
|
58
|
+
const resumeProcessor = () => {
|
|
59
|
+
void processor.resume();
|
|
60
|
+
};
|
|
61
|
+
options.signal?.addEventListener('abort', abortFromSignal, { once: true });
|
|
62
|
+
options.parentAbortSignal.addEventListener('abort', abortFromParent, { once: true });
|
|
63
|
+
const unsubscribeParentPause = options.onParentPause(pauseProcessor);
|
|
64
|
+
const unsubscribeParentResume = options.onParentResume(resumeProcessor);
|
|
65
|
+
let cleanedUp = false;
|
|
66
|
+
const cleanup = () => {
|
|
67
|
+
if (cleanedUp) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
cleanedUp = true;
|
|
71
|
+
options.signal?.removeEventListener('abort', abortFromSignal);
|
|
72
|
+
options.parentAbortSignal.removeEventListener('abort', abortFromParent);
|
|
73
|
+
unsubscribeParentPause();
|
|
74
|
+
unsubscribeParentResume();
|
|
75
|
+
unsubscribeGraphFinish();
|
|
76
|
+
unsubscribeGraphAbort();
|
|
77
|
+
unsubscribeGraphError();
|
|
78
|
+
};
|
|
79
|
+
const unsubscribeGraphFinish = processor.on('graphFinish', cleanup);
|
|
80
|
+
const unsubscribeGraphAbort = processor.on('graphAbort', cleanup);
|
|
81
|
+
const unsubscribeGraphError = processor.on('graphError', cleanup);
|
|
82
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
async function partToUserContent(part) {
|
|
2
|
+
if (typeof part === 'string') {
|
|
3
|
+
return { type: 'text', text: part };
|
|
4
|
+
}
|
|
5
|
+
switch (part.type) {
|
|
6
|
+
case 'image':
|
|
7
|
+
return {
|
|
8
|
+
type: 'image',
|
|
9
|
+
image: part.data,
|
|
10
|
+
mediaType: part.mediaType,
|
|
11
|
+
};
|
|
12
|
+
case 'url':
|
|
13
|
+
return {
|
|
14
|
+
type: 'image',
|
|
15
|
+
image: new URL(part.url),
|
|
16
|
+
};
|
|
17
|
+
case 'document':
|
|
18
|
+
return {
|
|
19
|
+
type: 'file',
|
|
20
|
+
data: part.data,
|
|
21
|
+
mediaType: part.mediaType,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function stringifyParts(parts) {
|
|
26
|
+
const arr = Array.isArray(parts) ? parts : [parts];
|
|
27
|
+
return arr
|
|
28
|
+
.map((p) => {
|
|
29
|
+
if (typeof p === 'string')
|
|
30
|
+
return p;
|
|
31
|
+
throw new Error(`Expected string content, got ${p.type}`);
|
|
32
|
+
})
|
|
33
|
+
.join('\n\n');
|
|
34
|
+
}
|
|
35
|
+
export async function rivetMessagesToAiSdk(messages) {
|
|
36
|
+
const result = [];
|
|
37
|
+
for (const msg of messages) {
|
|
38
|
+
switch (msg.type) {
|
|
39
|
+
case 'system': {
|
|
40
|
+
result.push({
|
|
41
|
+
role: 'system',
|
|
42
|
+
content: stringifyParts(msg.message),
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'user': {
|
|
47
|
+
const parts = Array.isArray(msg.message) ? msg.message : [msg.message];
|
|
48
|
+
if (parts.length === 1 && typeof parts[0] === 'string') {
|
|
49
|
+
result.push({ role: 'user', content: parts[0] });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const content = await Promise.all(parts.map(partToUserContent));
|
|
53
|
+
result.push({ role: 'user', content });
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'assistant': {
|
|
58
|
+
const textContent = stringifyParts(msg.message);
|
|
59
|
+
const toolCalls = msg.function_calls ?? (msg.function_call ? [msg.function_call] : []);
|
|
60
|
+
if (toolCalls.length === 0) {
|
|
61
|
+
result.push({ role: 'assistant', content: textContent });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const content = [];
|
|
65
|
+
if (textContent) {
|
|
66
|
+
content.push({ type: 'text', text: textContent });
|
|
67
|
+
}
|
|
68
|
+
for (const fc of toolCalls) {
|
|
69
|
+
let parsedArgs;
|
|
70
|
+
try {
|
|
71
|
+
parsedArgs = JSON.parse(fc.arguments);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
parsedArgs = {};
|
|
75
|
+
}
|
|
76
|
+
content.push({
|
|
77
|
+
type: 'tool-call',
|
|
78
|
+
toolCallId: fc.id ?? 'unknown_function_call',
|
|
79
|
+
toolName: fc.name,
|
|
80
|
+
input: parsedArgs,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
result.push({ role: 'assistant', content });
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'function': {
|
|
88
|
+
const textContent = stringifyParts(msg.message);
|
|
89
|
+
result.push({
|
|
90
|
+
role: 'tool',
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'tool-result',
|
|
94
|
+
toolCallId: msg.name,
|
|
95
|
+
toolName: msg.toolName ?? msg.name,
|
|
96
|
+
output: { type: 'text', value: textContent },
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export async function consumeAiSdkStream(fullStream, onPartialOutputs) {
|
|
2
|
+
let responseText = '';
|
|
3
|
+
let reasoning = '';
|
|
4
|
+
const functionCalls = [];
|
|
5
|
+
let usage;
|
|
6
|
+
for await (const part of fullStream) {
|
|
7
|
+
switch (part.type) {
|
|
8
|
+
case 'text-delta': {
|
|
9
|
+
responseText += part.text;
|
|
10
|
+
onPartialOutputs(responseText, functionCalls);
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
case 'reasoning-delta': {
|
|
14
|
+
reasoning += part.text;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
case 'tool-call': {
|
|
18
|
+
functionCalls.push({
|
|
19
|
+
type: 'function',
|
|
20
|
+
id: part.toolCallId,
|
|
21
|
+
name: part.toolName,
|
|
22
|
+
arguments: JSON.stringify(part.input),
|
|
23
|
+
lastParsedArguments: part.input,
|
|
24
|
+
});
|
|
25
|
+
onPartialOutputs(responseText, functionCalls);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'finish': {
|
|
29
|
+
usage = part.totalUsage;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case 'error': {
|
|
33
|
+
throw part.error instanceof Error ? part.error : new Error(String(part.error));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { responseText, functionCalls, usage, reasoning };
|
|
38
|
+
}
|