@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,116 @@
|
|
|
1
|
+
import { globalRivetNodeRegistry } from '../model/Nodes.js';
|
|
2
|
+
import { getProcessorEvents, getProcessorSSEStream, getSingleNodeStream } from './streaming.js';
|
|
3
|
+
// eslint-disable-next-line import/no-cycle -- GraphProcessor depends on CodeRunner, which exposes the package export surface.
|
|
4
|
+
import { GraphProcessor } from '../model/GraphProcessor.js';
|
|
5
|
+
import { deserializeProject } from '../utils/serialization/serialization.js';
|
|
6
|
+
import { GptTokenizerTokenizer } from '../integrations/GptTokenizerTokenizer.js';
|
|
7
|
+
import { looseDataValuesToDataValues } from './looseDataValue.js';
|
|
8
|
+
import { resolveProcessSettings } from './processSettings.js';
|
|
9
|
+
export function coreCreateProcessor(project, options) {
|
|
10
|
+
const { graph, inputs = {}, context = {} } = options;
|
|
11
|
+
const graphId = graph
|
|
12
|
+
? graph in project.graphs
|
|
13
|
+
? graph
|
|
14
|
+
: Object.values(project.graphs).find((g) => g.metadata?.name === graph)?.metadata?.id
|
|
15
|
+
: project.metadata.mainGraphId;
|
|
16
|
+
if (!graphId) {
|
|
17
|
+
throw new Error(`Graph not found, and no main graph specified.`);
|
|
18
|
+
}
|
|
19
|
+
// TODO: Consolidate options into one object
|
|
20
|
+
const processor = new GraphProcessor(project, graphId, options.registry ?? globalRivetNodeRegistry, options.includeTrace, { concurrency: options.concurrency });
|
|
21
|
+
if (options.onStart) {
|
|
22
|
+
processor.on('start', options.onStart);
|
|
23
|
+
}
|
|
24
|
+
if (options.onNodeStart) {
|
|
25
|
+
processor.on('nodeStart', options.onNodeStart);
|
|
26
|
+
}
|
|
27
|
+
if (options.onNodeFinish) {
|
|
28
|
+
processor.on('nodeFinish', options.onNodeFinish);
|
|
29
|
+
}
|
|
30
|
+
if (options.onNodeError) {
|
|
31
|
+
processor.on('nodeError', options.onNodeError);
|
|
32
|
+
}
|
|
33
|
+
if (options.onNodeExcluded) {
|
|
34
|
+
processor.on('nodeExcluded', options.onNodeExcluded);
|
|
35
|
+
}
|
|
36
|
+
if (options.onGraphStart) {
|
|
37
|
+
processor.on('graphStart', options.onGraphStart);
|
|
38
|
+
}
|
|
39
|
+
if (options.onGraphError) {
|
|
40
|
+
processor.on('graphError', options.onGraphError);
|
|
41
|
+
}
|
|
42
|
+
if (options.onGraphFinish) {
|
|
43
|
+
processor.on('graphFinish', options.onGraphFinish);
|
|
44
|
+
}
|
|
45
|
+
if (options.onPartialOutput) {
|
|
46
|
+
processor.on('partialOutput', options.onPartialOutput);
|
|
47
|
+
}
|
|
48
|
+
if (options.onUserInput) {
|
|
49
|
+
processor.on('userInput', options.onUserInput);
|
|
50
|
+
}
|
|
51
|
+
if (options.onDone) {
|
|
52
|
+
processor.on('done', options.onDone);
|
|
53
|
+
}
|
|
54
|
+
if (options.onAbort) {
|
|
55
|
+
processor.on('abort', options.onAbort);
|
|
56
|
+
}
|
|
57
|
+
if (options.onGraphAbort) {
|
|
58
|
+
processor.on('graphAbort', options.onGraphAbort);
|
|
59
|
+
}
|
|
60
|
+
if (options.onTrace) {
|
|
61
|
+
processor.on('trace', options.onTrace);
|
|
62
|
+
}
|
|
63
|
+
if (options.onNodeOutputsCleared) {
|
|
64
|
+
processor.on('nodeOutputsCleared', options.onNodeOutputsCleared);
|
|
65
|
+
}
|
|
66
|
+
if (options.externalFunctions) {
|
|
67
|
+
for (const [name, fn] of Object.entries(options.externalFunctions)) {
|
|
68
|
+
processor.setExternalFunction(name, fn);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (options.onUserEvent) {
|
|
72
|
+
for (const [name, fn] of Object.entries(options.onUserEvent)) {
|
|
73
|
+
processor.onUserEvent(name, fn);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
options.abortSignal?.addEventListener('abort', () => {
|
|
77
|
+
void processor.abort();
|
|
78
|
+
});
|
|
79
|
+
const resolvedInputs = looseDataValuesToDataValues(inputs);
|
|
80
|
+
const resolvedContextValues = looseDataValuesToDataValues(context);
|
|
81
|
+
return {
|
|
82
|
+
processor,
|
|
83
|
+
inputs: resolvedInputs,
|
|
84
|
+
contextValues: resolvedContextValues,
|
|
85
|
+
getEvents: (spec) => getProcessorEvents(processor, spec),
|
|
86
|
+
getSSEStream: (spec) => getProcessorSSEStream(processor, spec),
|
|
87
|
+
streamNode: (nodeIdOrTitle) => getSingleNodeStream(processor, nodeIdOrTitle),
|
|
88
|
+
async run() {
|
|
89
|
+
const outputs = await processor.processGraph({
|
|
90
|
+
nativeApi: options.nativeApi,
|
|
91
|
+
datasetProvider: options.datasetProvider,
|
|
92
|
+
audioProvider: options.audioProvider,
|
|
93
|
+
mcpProvider: options.mcpProvider,
|
|
94
|
+
codeRunner: options.codeRunner,
|
|
95
|
+
tokenizer: options.tokenizer ?? new GptTokenizerTokenizer(),
|
|
96
|
+
projectPath: options.projectPath,
|
|
97
|
+
projectReferenceLoader: options.projectReferenceLoader,
|
|
98
|
+
editorExecutionCache: options.editorExecutionCache,
|
|
99
|
+
settings: resolveProcessSettings(options),
|
|
100
|
+
getChatNodeEndpoint: options.getChatNodeEndpoint,
|
|
101
|
+
}, resolvedInputs, resolvedContextValues);
|
|
102
|
+
return outputs;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export async function coreRunGraph(project, options) {
|
|
107
|
+
const processorInfo = coreCreateProcessor(project, options);
|
|
108
|
+
return processorInfo.run();
|
|
109
|
+
}
|
|
110
|
+
export function loadProjectFromString(content) {
|
|
111
|
+
const [project] = deserializeProject(content);
|
|
112
|
+
return project;
|
|
113
|
+
}
|
|
114
|
+
export function loadProjectAndAttachedDataFromString(content) {
|
|
115
|
+
return deserializeProject(content);
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mapValues } from 'lodash-es';
|
|
2
|
+
export function looseDataValuesToDataValues(values) {
|
|
3
|
+
return mapValues(values, (val) => looseDataValueToDataValue(val));
|
|
4
|
+
}
|
|
5
|
+
export function looseDataValueToDataValue(value) {
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
return { type: 'string', value };
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === 'number') {
|
|
10
|
+
return { type: 'number', value };
|
|
11
|
+
}
|
|
12
|
+
if (typeof value === 'boolean') {
|
|
13
|
+
return { type: 'boolean', value };
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DEFAULT_CHAT_NODE_TIMEOUT } from '../utils/defaults.js';
|
|
2
|
+
export function resolveProcessSettings(settings = {}, fallbacks = {}) {
|
|
3
|
+
return {
|
|
4
|
+
openAiKey: settings.openAiKey ?? fallbacks.openAiKey ?? '',
|
|
5
|
+
openAiOrganization: settings.openAiOrganization ?? fallbacks.openAiOrganization ?? '',
|
|
6
|
+
openAiEndpoint: settings.openAiEndpoint ?? fallbacks.openAiEndpoint ?? '',
|
|
7
|
+
pluginEnv: settings.pluginEnv ?? fallbacks.pluginEnv ?? {},
|
|
8
|
+
pluginSettings: settings.pluginSettings ?? {},
|
|
9
|
+
recordingPlaybackLatency: settings.recordingPlaybackLatency ?? 1000,
|
|
10
|
+
defaultNodeColors: settings.defaultNodeColors ?? false,
|
|
11
|
+
openNodeSettingsOnCreate: settings.openNodeSettingsOnCreate ?? true,
|
|
12
|
+
chatNodeHeaders: settings.chatNodeHeaders ?? {},
|
|
13
|
+
chatNodeTimeout: settings.chatNodeTimeout ?? DEFAULT_CHAT_NODE_TIMEOUT,
|
|
14
|
+
throttleChatNode: settings.throttleChatNode ?? 100,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {} from '../index.js';
|
|
2
|
+
import { coerceType } from '../utils/coerceType.js';
|
|
3
|
+
/** A simplified way to listen and stream processor events, including filtering. */
|
|
4
|
+
export async function* getProcessorEvents(processor, spec) {
|
|
5
|
+
const previousIndexes = new Map();
|
|
6
|
+
for await (const event of processor.events()) {
|
|
7
|
+
if (event.type === 'partialOutput') {
|
|
8
|
+
if (spec.partialOutputs === true ||
|
|
9
|
+
spec.partialOutputs?.includes(event.node.id) ||
|
|
10
|
+
spec.partialOutputs?.includes(event.node.title)) {
|
|
11
|
+
const currentOutput = coerceType(event.outputs['response'], 'string');
|
|
12
|
+
const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
|
|
13
|
+
yield {
|
|
14
|
+
type: 'partialOutput',
|
|
15
|
+
nodeId: event.node.id,
|
|
16
|
+
nodeTitle: event.node.title,
|
|
17
|
+
delta,
|
|
18
|
+
};
|
|
19
|
+
previousIndexes.set(event.node.id, currentOutput.length);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (event.type === 'done') {
|
|
23
|
+
if (spec.done) {
|
|
24
|
+
yield {
|
|
25
|
+
type: 'done',
|
|
26
|
+
graphOutput: event.results,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (event.type === 'error') {
|
|
31
|
+
if (spec.error) {
|
|
32
|
+
yield {
|
|
33
|
+
type: 'error',
|
|
34
|
+
error: typeof event.error === 'string' ? event.error : event.error.toString(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (event.type === 'nodeStart') {
|
|
39
|
+
if (spec.nodeStart === true ||
|
|
40
|
+
spec.nodeStart?.includes(event.node.id) ||
|
|
41
|
+
spec.nodeStart?.includes(event.node.title)) {
|
|
42
|
+
yield {
|
|
43
|
+
type: 'nodeStart',
|
|
44
|
+
inputs: event.inputs,
|
|
45
|
+
nodeId: event.node.id,
|
|
46
|
+
nodeTitle: event.node.title,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (event.type === 'nodeFinish') {
|
|
51
|
+
if (spec.nodeFinish === true ||
|
|
52
|
+
spec.nodeFinish?.includes(event.node.id) ||
|
|
53
|
+
spec.nodeFinish?.includes(event.node.title)) {
|
|
54
|
+
yield {
|
|
55
|
+
type: 'nodeFinish',
|
|
56
|
+
outputs: event.outputs,
|
|
57
|
+
nodeId: event.node.id,
|
|
58
|
+
nodeTitle: event.node.title,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a ReadableStream for processor events, following the Server-Sent Events protocol.
|
|
66
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/EventSource
|
|
67
|
+
*
|
|
68
|
+
* Includes configuration for what events to send to the client, for example you can stream the partial output deltas
|
|
69
|
+
* for specific nodes, and/or the graph output when done.
|
|
70
|
+
*/
|
|
71
|
+
export function getProcessorSSEStream(processor,
|
|
72
|
+
/** The spec for what you're streaming to the client */
|
|
73
|
+
spec) {
|
|
74
|
+
const encoder = new TextEncoder();
|
|
75
|
+
function sendEvent(controller, type, data) {
|
|
76
|
+
const event = `event: ${type}\ndata: ${JSON.stringify(data)}\n\n`;
|
|
77
|
+
controller.enqueue(encoder.encode(event));
|
|
78
|
+
}
|
|
79
|
+
return new ReadableStream({
|
|
80
|
+
async start(controller) {
|
|
81
|
+
try {
|
|
82
|
+
for await (const event of getProcessorEvents(processor, spec)) {
|
|
83
|
+
sendEvent(controller, event.type, event);
|
|
84
|
+
}
|
|
85
|
+
controller.close();
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
controller.error(err);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function getSingleNodeStream(processor, nodeIdOrTitle) {
|
|
94
|
+
return new ReadableStream({
|
|
95
|
+
async start(controller) {
|
|
96
|
+
try {
|
|
97
|
+
for await (const event of getProcessorEvents(processor, {
|
|
98
|
+
partialOutputs: [nodeIdOrTitle],
|
|
99
|
+
nodeFinish: [nodeIdOrTitle],
|
|
100
|
+
})) {
|
|
101
|
+
if (event.type === 'partialOutput' && (event.nodeId === nodeIdOrTitle || event.nodeTitle === nodeIdOrTitle)) {
|
|
102
|
+
controller.enqueue(`data: ${JSON.stringify(event.delta)}\n\n`);
|
|
103
|
+
}
|
|
104
|
+
else if (event.type === 'nodeFinish' &&
|
|
105
|
+
(event.nodeId === nodeIdOrTitle || event.nodeTitle === nodeIdOrTitle)) {
|
|
106
|
+
controller.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
controller.close();
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
controller.error(err);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export * from './utils/index.js';
|
|
2
|
+
// eslint-disable-next-line import/no-cycle -- GraphProcessor depends on CodeRunner, which exposes the top-level Rivet export surface.
|
|
3
|
+
export * from './model/GraphProcessor.js';
|
|
4
|
+
export * from './model/DataValue.js';
|
|
5
|
+
export * from './model/NodeBase.js';
|
|
6
|
+
export * from './model/NodeGraph.js';
|
|
7
|
+
export * from './model/NodeImpl.js';
|
|
8
|
+
export * from './model/NodeDefinition.js';
|
|
9
|
+
export * from './model/Nodes.js';
|
|
10
|
+
export * from './model/Project.js';
|
|
11
|
+
export * from './native/BaseDir.js';
|
|
12
|
+
export * from './native/NativeApi.js';
|
|
13
|
+
export * from './native/BrowserNativeApi.js';
|
|
14
|
+
export * from './model/ProcessContext.js';
|
|
15
|
+
export * from './model/ProjectReferenceLoader.js';
|
|
16
|
+
export * from './model/RivetUIContext.js';
|
|
17
|
+
export * from './model/chat-v2/index.js';
|
|
18
|
+
export * from './integrations/integrations.js';
|
|
19
|
+
import './integrations/enableIntegrations.js';
|
|
20
|
+
export * from './integrations/VectorDatabase.js';
|
|
21
|
+
export * from './integrations/mcp/MCPProvider.js';
|
|
22
|
+
export * from './integrations/EmbeddingGenerator.js';
|
|
23
|
+
export * from './integrations/LLMProvider.js';
|
|
24
|
+
export * from './recording/ExecutionRecorder.js';
|
|
25
|
+
export * from './recording/RecordedEvents.js';
|
|
26
|
+
export * from './model/RivetPlugin.js';
|
|
27
|
+
export * from './model/PluginLoadSpec.js';
|
|
28
|
+
export * from './plugins.js';
|
|
29
|
+
export * from './model/NodeRegistration.js';
|
|
30
|
+
export * from './model/RegistryAssembly.js';
|
|
31
|
+
export * from './model/EditorDefinition.js';
|
|
32
|
+
export * from './model/NodeBodySpec.js';
|
|
33
|
+
export * from './model/interpolationInputDefinition.js';
|
|
34
|
+
export * from './integrations/DatasetProvider.js';
|
|
35
|
+
export * from './model/Dataset.js';
|
|
36
|
+
export * from './api/streaming.js';
|
|
37
|
+
export * from './api/createProcessor.js';
|
|
38
|
+
export * from './api/processSettings.js';
|
|
39
|
+
export * from './integrations/AudioProvider.js';
|
|
40
|
+
export * from './api/looseDataValue.js';
|
|
41
|
+
export * from './integrations/CodeRunner.js';
|
|
42
|
+
export * from './integrations/Tokenizer.js';
|
|
43
|
+
export * from './integrations/GptTokenizerTokenizer.js';
|
|
44
|
+
export { JS_LIST_CALLBACK_LOCAL_NAMES, interpolateJSListCallbackBody } from './model/nodes/jsListCallbackHelpers.js';
|
|
45
|
+
export { extractInterpolationVariables, findInterpolationTokenSpans, getInterpolationTokenName, interpolate, protectEscapedInterpolationTokens, restoreEscapedInterpolationTokens, } from './utils/interpolation.js';
|
|
46
|
+
export { WarningsPort } from './utils/symbols.js';
|
|
47
|
+
import * as openai from './utils/openai.js';
|
|
48
|
+
export { openai };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-cycle -- There has to be a cycle if we're to import the entirety of Rivet here.
|
|
2
|
+
import * as Rivet from '../exports.js';
|
|
3
|
+
export class IsomorphicCodeRunner {
|
|
4
|
+
async runCode(code, inputs, options, graphInputs, contextValues) {
|
|
5
|
+
const argNames = ['inputs'];
|
|
6
|
+
const args = [inputs];
|
|
7
|
+
if (options.includeRequire) {
|
|
8
|
+
throw new Error('require() requires the Node executor.');
|
|
9
|
+
}
|
|
10
|
+
if (options.includeProcess) {
|
|
11
|
+
throw new Error('process requires the Node executor.');
|
|
12
|
+
}
|
|
13
|
+
if (options.includeConsole) {
|
|
14
|
+
argNames.push('console');
|
|
15
|
+
args.push(console);
|
|
16
|
+
}
|
|
17
|
+
if (options.includeFetch) {
|
|
18
|
+
argNames.push('fetch');
|
|
19
|
+
args.push(fetch);
|
|
20
|
+
}
|
|
21
|
+
if (options.includeRivet) {
|
|
22
|
+
argNames.push('Rivet');
|
|
23
|
+
args.push(Rivet);
|
|
24
|
+
}
|
|
25
|
+
if (graphInputs) {
|
|
26
|
+
argNames.push('graphInputs');
|
|
27
|
+
args.push(graphInputs);
|
|
28
|
+
}
|
|
29
|
+
if (contextValues) {
|
|
30
|
+
argNames.push('context');
|
|
31
|
+
args.push(contextValues);
|
|
32
|
+
}
|
|
33
|
+
argNames.push(code);
|
|
34
|
+
const AsyncFunction = async function () { }.constructor;
|
|
35
|
+
const codeFunction = new AsyncFunction(...argNames);
|
|
36
|
+
const outputs = await codeFunction(...args);
|
|
37
|
+
return outputs;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class NotAllowedCodeRunner {
|
|
41
|
+
async runCode(_code, _inputs, _options, _graphInputs, _contextValues) {
|
|
42
|
+
throw new Error('Dynamic code execution is disabled.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {} from '../index.js';
|
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
|
3
|
+
export class InMemoryDatasetProvider {
|
|
4
|
+
#datasets;
|
|
5
|
+
constructor(datasets) {
|
|
6
|
+
this.#datasets = datasets;
|
|
7
|
+
}
|
|
8
|
+
async getDatasetMetadata(id) {
|
|
9
|
+
const dataset = this.#datasets.find((d) => d.meta.id === id);
|
|
10
|
+
return dataset?.meta;
|
|
11
|
+
}
|
|
12
|
+
async getDatasetsForProject() {
|
|
13
|
+
return this.#datasets.map((d) => d.meta);
|
|
14
|
+
}
|
|
15
|
+
async getDatasetData(id) {
|
|
16
|
+
const dataset = this.#datasets.find((d) => d.meta.id === id);
|
|
17
|
+
if (!dataset) {
|
|
18
|
+
return { id, rows: [] };
|
|
19
|
+
}
|
|
20
|
+
return dataset.data;
|
|
21
|
+
}
|
|
22
|
+
async putDatasetRow(id, row) {
|
|
23
|
+
const dataset = this.#datasets.find((d) => d.meta.id === id);
|
|
24
|
+
if (!dataset) {
|
|
25
|
+
throw new Error(`Dataset ${id} not found`);
|
|
26
|
+
}
|
|
27
|
+
const existingRow = dataset.data.rows.find((r) => r.id === row.id);
|
|
28
|
+
if (existingRow) {
|
|
29
|
+
existingRow.data = row.data;
|
|
30
|
+
existingRow.embedding = row.embedding;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
dataset.data.rows.push(row);
|
|
34
|
+
}
|
|
35
|
+
async putDatasetData(id, data) {
|
|
36
|
+
const dataset = this.#datasets.find((d) => d.meta.id === id);
|
|
37
|
+
if (!dataset) {
|
|
38
|
+
throw new Error(`Dataset ${id} not found`);
|
|
39
|
+
}
|
|
40
|
+
dataset.data = data;
|
|
41
|
+
}
|
|
42
|
+
async putDatasetMetadata(metadata) {
|
|
43
|
+
const matchingDataset = this.#datasets.find((d) => d.meta.id === metadata.id);
|
|
44
|
+
if (matchingDataset) {
|
|
45
|
+
matchingDataset.meta = metadata;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.#datasets.push({
|
|
49
|
+
meta: metadata,
|
|
50
|
+
data: {
|
|
51
|
+
id: metadata.id,
|
|
52
|
+
rows: [],
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async clearDatasetData(id) {
|
|
57
|
+
const dataset = this.#datasets.find((d) => d.meta.id === id);
|
|
58
|
+
if (!dataset) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
dataset.data = {
|
|
62
|
+
id,
|
|
63
|
+
rows: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async deleteDataset(id) {
|
|
67
|
+
const index = this.#datasets.findIndex((d) => d.meta.id === id);
|
|
68
|
+
if (index === -1) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.#datasets.splice(index, 1);
|
|
72
|
+
}
|
|
73
|
+
async knnDatasetRows(datasetId, k, vector) {
|
|
74
|
+
const allRows = await this.getDatasetData(datasetId);
|
|
75
|
+
const sorted = allRows.rows
|
|
76
|
+
.filter((row) => row.embedding != null)
|
|
77
|
+
.map((row) => ({
|
|
78
|
+
row,
|
|
79
|
+
similarity: dotProductSimilarity(vector, row.embedding),
|
|
80
|
+
}))
|
|
81
|
+
.sort((a, b) => b.similarity - a.similarity);
|
|
82
|
+
return sorted.slice(0, k).map((r) => ({ ...r.row, distance: r.similarity }));
|
|
83
|
+
}
|
|
84
|
+
async exportDatasetsForProject(_projectId) {
|
|
85
|
+
// Cloning is safest... but slow
|
|
86
|
+
return cloneDeep(this.#datasets);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** OpenAI embeddings are already normalized, so this is equivalent to cosine similarity */
|
|
90
|
+
const dotProductSimilarity = (a, b) => {
|
|
91
|
+
return a.reduce((acc, val, i) => acc + val * b[i], 0);
|
|
92
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {} from '../index.js';
|
|
2
|
+
import Emittery from 'emittery';
|
|
3
|
+
import { getError } from '../utils/errors.js';
|
|
4
|
+
import { chatMessageToOpenAIChatCompletionMessage } from '../utils/chatMessageToOpenAIChatCompletionMessage.js';
|
|
5
|
+
export class GptTokenizerTokenizer {
|
|
6
|
+
emitter = new Emittery();
|
|
7
|
+
on(event, listener) {
|
|
8
|
+
return this.emitter.on(event, listener);
|
|
9
|
+
}
|
|
10
|
+
async getTokenCountForString(input, _info) {
|
|
11
|
+
const { encode } = await import('gpt-tokenizer');
|
|
12
|
+
return encode(input).length;
|
|
13
|
+
}
|
|
14
|
+
async getTokenCountForMessages(messages, functions, _info) {
|
|
15
|
+
try {
|
|
16
|
+
const openaiMessages = await Promise.all(messages.map((message) => chatMessageToOpenAIChatCompletionMessage(message, { useDeveloperPrompts: false })));
|
|
17
|
+
const validMessages = openaiMessages.map((message) => {
|
|
18
|
+
// Tools not supported to calculate token count so we convert them to user messages
|
|
19
|
+
if (message.role === 'tool') {
|
|
20
|
+
return { role: 'user', content: message.content };
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(message.content)) {
|
|
23
|
+
const textContent = message.content
|
|
24
|
+
.filter((c) => c.type === 'text')
|
|
25
|
+
.map((c) => c.text)
|
|
26
|
+
.join('');
|
|
27
|
+
return { ...message, content: textContent };
|
|
28
|
+
}
|
|
29
|
+
return message;
|
|
30
|
+
});
|
|
31
|
+
const { encode, encodeChat } = await import('gpt-tokenizer');
|
|
32
|
+
const encodedChat = encodeChat(validMessages, 'gpt-3.5-turbo');
|
|
33
|
+
const encodedFunctions = functions && functions.length > 0 ? encode(this.convertGptFunctionsToPromptString(functions)) : [];
|
|
34
|
+
return encodedChat.length + encodedFunctions.length;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
void this.emitter.emit('error', getError(err));
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Converts GPT Functions to approximate TypeScript-style string.
|
|
43
|
+
* Per thread: https://community.openai.com/t/how-to-calculate-the-tokens-when-using-function-call/266573/24
|
|
44
|
+
* We should consider using a different library, eg. https://github.com/hmarr/openai-chat-tokens
|
|
45
|
+
* @param functions
|
|
46
|
+
*/
|
|
47
|
+
convertGptFunctionsToPromptString(functions) {
|
|
48
|
+
return `
|
|
49
|
+
# Tools
|
|
50
|
+
|
|
51
|
+
## functions
|
|
52
|
+
|
|
53
|
+
namespace functions {
|
|
54
|
+
${functions
|
|
55
|
+
.map((fn) => `
|
|
56
|
+
// ${fn.description}
|
|
57
|
+
type ${fn.name} = (_: {
|
|
58
|
+
${Object.entries(fn.parameters?.properties ?? {})
|
|
59
|
+
.map(([parameterName, value]) => `// ${value?.description}\n${parameterName}?: ${Array.isArray(value?.type) ? value.type.join(' | ') : value?.type}`)
|
|
60
|
+
.join('\n')}
|
|
61
|
+
})
|
|
62
|
+
`)
|
|
63
|
+
.join('')}
|
|
64
|
+
} // namespace functions
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from '../model/DataValue.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from '../model/DataValue.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {} from '../model/ProcessContext.js';
|
|
2
|
+
import {} from './EmbeddingGenerator.js';
|
|
3
|
+
import {} from './LLMProvider.js';
|
|
4
|
+
import {} from './VectorDatabase.js';
|
|
5
|
+
const registeredIntegrations = {
|
|
6
|
+
vectorDatabase: new Map(),
|
|
7
|
+
llmProvider: new Map(),
|
|
8
|
+
embeddingGenerator: new Map(),
|
|
9
|
+
};
|
|
10
|
+
export function registerIntegration(type, integrationKey, factory) {
|
|
11
|
+
registeredIntegrations[type].set(integrationKey, factory);
|
|
12
|
+
}
|
|
13
|
+
export function getIntegration(type, integrationKey, context) {
|
|
14
|
+
const factory = registeredIntegrations[type].get(integrationKey);
|
|
15
|
+
if (!factory) {
|
|
16
|
+
throw new Error(`Integration ${integrationKey} not found`);
|
|
17
|
+
}
|
|
18
|
+
return factory(context);
|
|
19
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { getServerHelperMessage, getServerOptions } from './MCPUtils.js';
|
|
2
|
+
export const getMCPBaseInputs = (data) => {
|
|
3
|
+
const inputs = [];
|
|
4
|
+
if (data.useNameInput) {
|
|
5
|
+
inputs.push({
|
|
6
|
+
dataType: 'string',
|
|
7
|
+
id: 'name',
|
|
8
|
+
title: 'Name',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (data.useVersionInput) {
|
|
12
|
+
inputs.push({
|
|
13
|
+
dataType: 'string',
|
|
14
|
+
id: 'version',
|
|
15
|
+
title: 'Version',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (data.transportType === 'http' && data.useServerUrlInput) {
|
|
19
|
+
inputs.push({
|
|
20
|
+
dataType: 'string',
|
|
21
|
+
id: 'serverUrl',
|
|
22
|
+
title: 'Server URL',
|
|
23
|
+
description: 'The endpoint URL for the MCP server',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return inputs;
|
|
27
|
+
};
|
|
28
|
+
export const getMCPBaseEditors = async (context, data) => {
|
|
29
|
+
const editors = [];
|
|
30
|
+
editors.push([
|
|
31
|
+
{
|
|
32
|
+
type: 'toggle',
|
|
33
|
+
label: 'Output Tools',
|
|
34
|
+
dataKey: 'useToolsOutput',
|
|
35
|
+
helperMessage: 'Toggle on if you want to get a Tools output',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'toggle',
|
|
39
|
+
label: 'Output Prompts',
|
|
40
|
+
dataKey: 'usePromptsOutput',
|
|
41
|
+
helperMessage: 'Toggle on if you want to get a Prompts output',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'string',
|
|
45
|
+
label: 'Name',
|
|
46
|
+
dataKey: 'name',
|
|
47
|
+
useInputToggleDataKey: 'useNameInput',
|
|
48
|
+
helperMessage: 'The name for the MCP Client',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'string',
|
|
52
|
+
label: 'Version',
|
|
53
|
+
dataKey: 'version',
|
|
54
|
+
useInputToggleDataKey: 'useVersionInput',
|
|
55
|
+
helperMessage: 'A version for the MCP Client',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'dropdown',
|
|
59
|
+
label: 'Transport Type',
|
|
60
|
+
dataKey: 'transportType',
|
|
61
|
+
options: [
|
|
62
|
+
{ label: 'HTTP', value: 'http' },
|
|
63
|
+
{ label: 'STDIO', value: 'stdio' },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
if (data.transportType === 'http') {
|
|
68
|
+
editors.push({
|
|
69
|
+
type: 'string',
|
|
70
|
+
label: 'Server URL',
|
|
71
|
+
dataKey: 'serverUrl',
|
|
72
|
+
useInputToggleDataKey: 'useServerUrlInput',
|
|
73
|
+
helperMessage: 'The endpoint URL for the MCP server to connect',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else if (data.transportType === 'stdio') {
|
|
77
|
+
const serverOptions = await getServerOptions(context);
|
|
78
|
+
editors.push({
|
|
79
|
+
type: 'dropdown',
|
|
80
|
+
label: 'Server ID',
|
|
81
|
+
dataKey: 'serverId',
|
|
82
|
+
helperMessage: getServerHelperMessage(context, serverOptions.length),
|
|
83
|
+
options: serverOptions,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return editors;
|
|
87
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from types here - https://github.com/modelcontextprotocol/typescript-sdk/blob/main/src/types.ts
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Errors
|
|
6
|
+
*/
|
|
7
|
+
export var MCPErrorType;
|
|
8
|
+
(function (MCPErrorType) {
|
|
9
|
+
MCPErrorType["CONFIG_NOT_FOUND"] = "CONFIG_NOT_FOUND";
|
|
10
|
+
MCPErrorType["SERVER_NOT_FOUND"] = "SERVER_NOT_FOUND";
|
|
11
|
+
MCPErrorType["SERVER_COMMUNICATION_FAILED"] = "SERVER_COMMUNICATION_FAILED";
|
|
12
|
+
MCPErrorType["INVALID_SCHEMA"] = "INVALID_SCHEMA";
|
|
13
|
+
})(MCPErrorType || (MCPErrorType = {}));
|
|
14
|
+
export class MCPError extends Error {
|
|
15
|
+
type;
|
|
16
|
+
details;
|
|
17
|
+
constructor(type, message, details) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.type = type;
|
|
20
|
+
this.details = details;
|
|
21
|
+
this.name = 'Error';
|
|
22
|
+
}
|
|
23
|
+
}
|