@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,143 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import {} from '../../index.js';
|
|
5
|
+
import { dedent } from 'ts-dedent';
|
|
6
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
7
|
+
import { getError } from '../../utils/errors.js';
|
|
8
|
+
import { buildClonedInputValueAssignments, buildCloneJsInputValueFunction, buildJsValueInterpolatedSource, getJsValueInterpolationInputNames, interpolateJsValuePreviewSource, sanitizeGeneratedJsValueText, } from './jsValueInterpolation.js';
|
|
9
|
+
import { createInterpolationInputDefinition } from '../interpolationInputDefinition.js';
|
|
10
|
+
const DEFAULT_EXPRESSION = '{{a}} == "123" ? {{b}} : {{c}}';
|
|
11
|
+
const MAX_BODY_PREVIEW_LINES = 15;
|
|
12
|
+
const EXPRESSION_INPUTS_IDENTIFIER = '__expressionInputs';
|
|
13
|
+
const EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER = 'expressionInputCloneCache';
|
|
14
|
+
export const EXPRESSION_OUTPUT_PORT_ID = 'output';
|
|
15
|
+
function buildExpressionPreview(expression) {
|
|
16
|
+
return expression.split('\n').slice(0, MAX_BODY_PREVIEW_LINES).join('\n').trim();
|
|
17
|
+
}
|
|
18
|
+
function getExpressionInputNames(expression) {
|
|
19
|
+
return getJsValueInterpolationInputNames(expression);
|
|
20
|
+
}
|
|
21
|
+
function buildExpressionRuntimeSource(expression) {
|
|
22
|
+
return buildJsValueInterpolatedSource(expression, EXPRESSION_INPUTS_IDENTIFIER);
|
|
23
|
+
}
|
|
24
|
+
function buildExpressionInputsInitializer(inputNames) {
|
|
25
|
+
return dedent `
|
|
26
|
+
${buildCloneJsInputValueFunction()}
|
|
27
|
+
const ${EXPRESSION_INPUTS_IDENTIFIER} = Object.create(null);
|
|
28
|
+
const ${EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER} = new WeakMap();
|
|
29
|
+
${buildClonedInputValueAssignments(inputNames, EXPRESSION_INPUTS_IDENTIFIER, EXPRESSION_INPUT_CLONE_CACHE_IDENTIFIER)}
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
export function interpolateExpressionSource(expression, inputs) {
|
|
33
|
+
return interpolateJsValuePreviewSource(expression, inputs);
|
|
34
|
+
}
|
|
35
|
+
function sanitizeGeneratedExpressionText(text, inputNames) {
|
|
36
|
+
return sanitizeGeneratedJsValueText(text, inputNames, EXPRESSION_INPUTS_IDENTIFIER, 'expression input');
|
|
37
|
+
}
|
|
38
|
+
function sanitizeExpressionError(error, inputNames) {
|
|
39
|
+
const expressionError = getError(error);
|
|
40
|
+
expressionError.message =
|
|
41
|
+
sanitizeGeneratedExpressionText(expressionError.message, inputNames) ?? expressionError.message;
|
|
42
|
+
expressionError.stack = sanitizeGeneratedExpressionText(expressionError.stack, inputNames);
|
|
43
|
+
return expressionError;
|
|
44
|
+
}
|
|
45
|
+
function buildExpressionWrapper(expression) {
|
|
46
|
+
const inputNames = getExpressionInputNames(expression);
|
|
47
|
+
const expressionSource = buildExpressionRuntimeSource(expression);
|
|
48
|
+
return dedent `
|
|
49
|
+
${buildExpressionInputsInitializer(inputNames)}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
output: {
|
|
53
|
+
type: 'any',
|
|
54
|
+
value: (${expressionSource}),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
export class ExpressionNodeImpl extends NodeImpl {
|
|
60
|
+
static create() {
|
|
61
|
+
const chartNode = {
|
|
62
|
+
type: 'expression',
|
|
63
|
+
title: 'Expression',
|
|
64
|
+
id: nanoid(),
|
|
65
|
+
visualData: {
|
|
66
|
+
x: 0,
|
|
67
|
+
y: 0,
|
|
68
|
+
width: 260,
|
|
69
|
+
},
|
|
70
|
+
data: {
|
|
71
|
+
expression: DEFAULT_EXPRESSION,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
return chartNode;
|
|
75
|
+
}
|
|
76
|
+
getInputDefinitions() {
|
|
77
|
+
return getExpressionInputNames(this.data.expression).map((inputName) => {
|
|
78
|
+
return createInterpolationInputDefinition({
|
|
79
|
+
interpolationName: inputName,
|
|
80
|
+
dataType: 'any',
|
|
81
|
+
required: false,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
getOutputDefinitions() {
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
id: EXPRESSION_OUTPUT_PORT_ID,
|
|
89
|
+
title: 'Output',
|
|
90
|
+
dataType: 'any',
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
getEditors() {
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
type: 'code',
|
|
98
|
+
label: 'Expression',
|
|
99
|
+
helperMessage: 'Use {{var}} to create input ports. Interpolated variables evaluate as the connected values.',
|
|
100
|
+
dataKey: 'expression',
|
|
101
|
+
language: 'javascript',
|
|
102
|
+
enableFolding: true,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
getBody() {
|
|
107
|
+
return {
|
|
108
|
+
type: 'colorized',
|
|
109
|
+
text: buildExpressionPreview(this.data.expression),
|
|
110
|
+
language: 'javascript',
|
|
111
|
+
fontSize: 12,
|
|
112
|
+
fontFamily: 'monospace',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static getUIData() {
|
|
116
|
+
return {
|
|
117
|
+
infoBoxBody: dedent `
|
|
118
|
+
Evaluates a single JavaScript expression and returns the resulting value.
|
|
119
|
+
|
|
120
|
+
<code>{{interpolation}}</code> creates dynamic input ports. Interpolated variables evaluate as connected values, so arrays, objects, strings, numbers, and booleans can be used directly.
|
|
121
|
+
`,
|
|
122
|
+
infoBoxTitle: 'Expression Node',
|
|
123
|
+
contextMenuTitle: 'Expression',
|
|
124
|
+
group: ['Advanced'],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async process(inputs, context) {
|
|
128
|
+
const inputNames = getExpressionInputNames(this.data.expression);
|
|
129
|
+
try {
|
|
130
|
+
return await context.codeRunner.runCode(buildExpressionWrapper(this.data.expression), inputs, {
|
|
131
|
+
includeFetch: false,
|
|
132
|
+
includeRequire: false,
|
|
133
|
+
includeRivet: false,
|
|
134
|
+
includeProcess: false,
|
|
135
|
+
includeConsole: false,
|
|
136
|
+
}, context.graphInputNodeValues, context.contextValues);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw sanitizeExpressionError(error, inputNames);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export const expressionNode = nodeDefinition(ExpressionNodeImpl, 'Expression');
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
3
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
|
+
import {} from '../DataValue.js';
|
|
5
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
6
|
+
import {} from '../GraphProcessor.js';
|
|
7
|
+
import { coerceType } from '../../utils/coerceType.js';
|
|
8
|
+
import { getError } from '../../utils/errors.js';
|
|
9
|
+
import {} from '../ProcessContext.js';
|
|
10
|
+
import { omit } from 'lodash-es';
|
|
11
|
+
import { dedent } from 'ts-dedent';
|
|
12
|
+
import {} from '../EditorDefinition.js';
|
|
13
|
+
import {} from '../NodeBodySpec.js';
|
|
14
|
+
export class ExternalCallNodeImpl extends NodeImpl {
|
|
15
|
+
static create() {
|
|
16
|
+
return {
|
|
17
|
+
id: nanoid(),
|
|
18
|
+
type: 'externalCall',
|
|
19
|
+
title: 'External Call',
|
|
20
|
+
visualData: { x: 0, y: 0, width: 150 },
|
|
21
|
+
data: {
|
|
22
|
+
functionName: '',
|
|
23
|
+
useFunctionNameInput: false,
|
|
24
|
+
useErrorOutput: false,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
getInputDefinitions() {
|
|
29
|
+
const inputDefinitions = [];
|
|
30
|
+
if (this.chartNode.data.useFunctionNameInput) {
|
|
31
|
+
inputDefinitions.push({
|
|
32
|
+
id: 'functionName',
|
|
33
|
+
title: 'Function Name',
|
|
34
|
+
dataType: 'string',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
inputDefinitions.push({
|
|
38
|
+
id: 'arguments',
|
|
39
|
+
title: 'Arguments',
|
|
40
|
+
dataType: 'any[]',
|
|
41
|
+
});
|
|
42
|
+
return inputDefinitions;
|
|
43
|
+
}
|
|
44
|
+
getOutputDefinitions() {
|
|
45
|
+
const outputs = [
|
|
46
|
+
{
|
|
47
|
+
id: 'result',
|
|
48
|
+
title: 'Result',
|
|
49
|
+
dataType: 'any',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
if (this.chartNode.data.useErrorOutput) {
|
|
53
|
+
outputs.push({
|
|
54
|
+
id: 'error',
|
|
55
|
+
title: 'Error',
|
|
56
|
+
dataType: 'string',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return outputs;
|
|
60
|
+
}
|
|
61
|
+
getEditors() {
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
type: 'string',
|
|
65
|
+
label: 'Function Name',
|
|
66
|
+
dataKey: 'functionName',
|
|
67
|
+
useInputToggleDataKey: 'useFunctionNameInput',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'toggle',
|
|
71
|
+
label: 'Use Error Output',
|
|
72
|
+
dataKey: 'useErrorOutput',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
getBody() {
|
|
77
|
+
return this.data.useFunctionNameInput ? '(Using Input)' : this.data.functionName;
|
|
78
|
+
}
|
|
79
|
+
static getUIData() {
|
|
80
|
+
return {
|
|
81
|
+
infoBoxBody: dedent `
|
|
82
|
+
Provides a way to call into the host project from inside a Rivet graph when Rivet graphs are integrated into another project.
|
|
83
|
+
`,
|
|
84
|
+
infoBoxTitle: 'External Call Node',
|
|
85
|
+
contextMenuTitle: 'External Call',
|
|
86
|
+
group: ['Advanced'],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async process(inputs, context) {
|
|
90
|
+
const functionName = this.chartNode.data.useFunctionNameInput
|
|
91
|
+
? coerceType(inputs['functionName'], 'string')
|
|
92
|
+
: this.chartNode.data.functionName;
|
|
93
|
+
const args = inputs['arguments'];
|
|
94
|
+
let arrayArgs = {
|
|
95
|
+
type: 'any[]',
|
|
96
|
+
value: [],
|
|
97
|
+
};
|
|
98
|
+
if (args) {
|
|
99
|
+
if (args.type.endsWith('[]') === false) {
|
|
100
|
+
arrayArgs = {
|
|
101
|
+
type: 'any[]',
|
|
102
|
+
value: [args.value],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
arrayArgs = args;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const fn = context.externalFunctions[functionName];
|
|
110
|
+
const externalContext = omit(context, ['setGlobal']);
|
|
111
|
+
if (!fn) {
|
|
112
|
+
if (this.data.useErrorOutput) {
|
|
113
|
+
return {
|
|
114
|
+
['result']: {
|
|
115
|
+
type: 'control-flow-excluded',
|
|
116
|
+
value: undefined,
|
|
117
|
+
},
|
|
118
|
+
['error']: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
value: `Function ${functionName} not was not defined using setExternalCall`,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new Error(`Function ${functionName} not was not defined using setExternalCall`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (this.data.useErrorOutput) {
|
|
129
|
+
try {
|
|
130
|
+
const result = await fn(externalContext, ...arrayArgs.value);
|
|
131
|
+
return {
|
|
132
|
+
['result']: result,
|
|
133
|
+
['cost']: {
|
|
134
|
+
type: 'number',
|
|
135
|
+
value: result.cost ?? 0,
|
|
136
|
+
},
|
|
137
|
+
['error']: {
|
|
138
|
+
type: 'control-flow-excluded',
|
|
139
|
+
value: undefined,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
return {
|
|
145
|
+
['result']: {
|
|
146
|
+
type: 'control-flow-excluded',
|
|
147
|
+
value: undefined,
|
|
148
|
+
},
|
|
149
|
+
['error']: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
value: getError(error).message,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const result = await fn(externalContext, ...arrayArgs.value);
|
|
157
|
+
return {
|
|
158
|
+
['result']: result,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export const externalCallNode = nodeDefinition(ExternalCallNodeImpl, 'External Call');
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../DataValue.js';
|
|
6
|
+
import { expectType } from '../../utils/index.js';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
export class ExtractJsonNodeImpl extends NodeImpl {
|
|
9
|
+
static create() {
|
|
10
|
+
const chartNode = {
|
|
11
|
+
type: 'extractJson',
|
|
12
|
+
title: 'Extract JSON',
|
|
13
|
+
id: nanoid(),
|
|
14
|
+
visualData: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
width: 250,
|
|
18
|
+
},
|
|
19
|
+
data: {},
|
|
20
|
+
};
|
|
21
|
+
return chartNode;
|
|
22
|
+
}
|
|
23
|
+
getInputDefinitions() {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
id: 'input',
|
|
27
|
+
title: 'Input',
|
|
28
|
+
dataType: 'string',
|
|
29
|
+
required: true,
|
|
30
|
+
coerced: false,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
getOutputDefinitions() {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
id: 'output',
|
|
38
|
+
title: 'Output',
|
|
39
|
+
dataType: 'object',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'noMatch',
|
|
43
|
+
title: 'No Match',
|
|
44
|
+
dataType: 'string',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
static getUIData() {
|
|
49
|
+
return {
|
|
50
|
+
infoBoxBody: dedent `
|
|
51
|
+
Finds and parses the first JSON object in the input text.
|
|
52
|
+
|
|
53
|
+
Outputs the parsed object.
|
|
54
|
+
`,
|
|
55
|
+
infoBoxTitle: 'Extract JSON Node',
|
|
56
|
+
contextMenuTitle: 'Extract JSON',
|
|
57
|
+
group: ['Objects'],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async process(inputs) {
|
|
61
|
+
const inputString = expectType(inputs['input'], 'string');
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(inputString);
|
|
64
|
+
return {
|
|
65
|
+
['output']: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
value: parsed,
|
|
68
|
+
},
|
|
69
|
+
['noMatch']: {
|
|
70
|
+
type: 'control-flow-excluded',
|
|
71
|
+
value: undefined,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (_err) {
|
|
76
|
+
// Fall back to more manual parsing
|
|
77
|
+
}
|
|
78
|
+
// Find the first { or [ and the last } or ], and try parsing everything in between including them.
|
|
79
|
+
const firstBracket = inputString.indexOf('{');
|
|
80
|
+
const lastBracket = inputString.lastIndexOf('}');
|
|
81
|
+
const firstSquareBracket = inputString.indexOf('[');
|
|
82
|
+
const lastSquareBracket = inputString.lastIndexOf(']');
|
|
83
|
+
const firstIndex = firstBracket >= 0 && firstSquareBracket >= 0
|
|
84
|
+
? Math.min(firstBracket, firstSquareBracket)
|
|
85
|
+
: firstBracket >= 0
|
|
86
|
+
? firstBracket
|
|
87
|
+
: firstSquareBracket;
|
|
88
|
+
const lastIndex = lastBracket >= 0 && lastSquareBracket >= 0
|
|
89
|
+
? Math.max(lastBracket, lastSquareBracket)
|
|
90
|
+
: lastBracket >= 0
|
|
91
|
+
? lastBracket
|
|
92
|
+
: lastSquareBracket;
|
|
93
|
+
const substring = inputString.substring(firstIndex, lastIndex + 1);
|
|
94
|
+
let jsonObject = undefined;
|
|
95
|
+
try {
|
|
96
|
+
jsonObject = JSON.parse(substring);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return {
|
|
100
|
+
['noMatch']: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
value: inputString,
|
|
103
|
+
},
|
|
104
|
+
['output']: {
|
|
105
|
+
type: 'control-flow-excluded',
|
|
106
|
+
value: undefined,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
['output']: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
value: jsonObject,
|
|
114
|
+
},
|
|
115
|
+
['noMatch']: {
|
|
116
|
+
type: 'control-flow-excluded',
|
|
117
|
+
value: undefined,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export const extractJsonNode = nodeDefinition(ExtractJsonNodeImpl, 'Extract JSON');
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import { expectType } from '../../utils/expectType.js';
|
|
6
|
+
import { dedent } from 'ts-dedent';
|
|
7
|
+
export class ExtractMarkdownCodeBlocksNodeImpl extends NodeImpl {
|
|
8
|
+
static create() {
|
|
9
|
+
const chartNode = {
|
|
10
|
+
type: 'extractMarkdownCodeBlocks',
|
|
11
|
+
title: 'Extract Markdown Code Blocks',
|
|
12
|
+
id: nanoid(),
|
|
13
|
+
visualData: {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0,
|
|
16
|
+
width: 250,
|
|
17
|
+
},
|
|
18
|
+
data: {},
|
|
19
|
+
};
|
|
20
|
+
return chartNode;
|
|
21
|
+
}
|
|
22
|
+
getInputDefinitions() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
id: 'input',
|
|
26
|
+
title: 'Input',
|
|
27
|
+
dataType: 'string',
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
getOutputDefinitions() {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
id: 'firstBlock',
|
|
36
|
+
title: 'First Block',
|
|
37
|
+
dataType: 'string',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'allBlocks',
|
|
41
|
+
title: 'All Blocks',
|
|
42
|
+
dataType: 'string[]',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'languages',
|
|
46
|
+
title: 'Languages',
|
|
47
|
+
dataType: 'string[]',
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
static getUIData() {
|
|
52
|
+
return {
|
|
53
|
+
infoBoxBody: dedent `
|
|
54
|
+
Extracts the code blocks in the input Markdown text.
|
|
55
|
+
|
|
56
|
+
Outputs the first matched block, all matched blocks, and the languages specified for the blocks.
|
|
57
|
+
`,
|
|
58
|
+
infoBoxTitle: 'Extract Markdown Code Blocks Node',
|
|
59
|
+
contextMenuTitle: 'Extract Markdown Code Blocks',
|
|
60
|
+
group: ['Text'],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async process(inputs) {
|
|
64
|
+
const inputString = expectType(inputs['input'], 'string');
|
|
65
|
+
const regex = /```(\w*)\n([\s\S]*?)```/g;
|
|
66
|
+
let match;
|
|
67
|
+
let firstBlock;
|
|
68
|
+
const allBlocks = [];
|
|
69
|
+
const languages = [];
|
|
70
|
+
while ((match = regex.exec(inputString)) !== null) {
|
|
71
|
+
const language = match[1];
|
|
72
|
+
const block = match[2];
|
|
73
|
+
if (!firstBlock) {
|
|
74
|
+
firstBlock = block;
|
|
75
|
+
}
|
|
76
|
+
allBlocks.push(block);
|
|
77
|
+
languages.push(language);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
['firstBlock']: firstBlock == null
|
|
81
|
+
? {
|
|
82
|
+
type: 'control-flow-excluded',
|
|
83
|
+
value: undefined,
|
|
84
|
+
}
|
|
85
|
+
: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
value: firstBlock,
|
|
88
|
+
},
|
|
89
|
+
['allBlocks']: {
|
|
90
|
+
type: 'string[]',
|
|
91
|
+
value: allBlocks,
|
|
92
|
+
},
|
|
93
|
+
['languages']: {
|
|
94
|
+
type: 'string[]',
|
|
95
|
+
value: languages,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const extractMarkdownCodeBlocksNode = nodeDefinition(ExtractMarkdownCodeBlocksNodeImpl, 'Extract Markdown Code Blocks');
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../DataValue.js';
|
|
6
|
+
import { JSONPath } from 'jsonpath-plus';
|
|
7
|
+
import { expectType } from '../../utils/expectType.js';
|
|
8
|
+
import {} from '../../index.js';
|
|
9
|
+
import { dedent } from 'ts-dedent';
|
|
10
|
+
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
11
|
+
import { extractInterpolationVariables, interpolate } from '../../utils/interpolation.js';
|
|
12
|
+
import { createInterpolationInputDefinition } from '../interpolationInputDefinition.js';
|
|
13
|
+
// Keep built-in ports from becoming implicit interpolation variables.
|
|
14
|
+
const RESERVED_INPUT_IDS = new Set(['object']);
|
|
15
|
+
export function getExtractObjectPathInterpolationInputNames(path) {
|
|
16
|
+
return extractInterpolationVariables(path).filter((inputName) => !RESERVED_INPUT_IDS.has(inputName));
|
|
17
|
+
}
|
|
18
|
+
function buildExtractObjectPathInterpolationInputs(path, inputs) {
|
|
19
|
+
return Object.fromEntries(extractInterpolationVariables(path).map((inputName) => [
|
|
20
|
+
inputName,
|
|
21
|
+
RESERVED_INPUT_IDS.has(inputName) ? '' : inputs[inputName],
|
|
22
|
+
]));
|
|
23
|
+
}
|
|
24
|
+
export function interpolateExtractObjectPathSource(path, inputs, graphInputValues, contextValues) {
|
|
25
|
+
return interpolate(path, buildExtractObjectPathInterpolationInputs(path, inputs), graphInputValues, contextValues).trim();
|
|
26
|
+
}
|
|
27
|
+
export class ExtractObjectPathNodeImpl extends NodeImpl {
|
|
28
|
+
static create() {
|
|
29
|
+
const chartNode = {
|
|
30
|
+
type: 'extractObjectPath',
|
|
31
|
+
title: 'Extract Object Path',
|
|
32
|
+
id: nanoid(),
|
|
33
|
+
visualData: {
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
width: 250,
|
|
37
|
+
},
|
|
38
|
+
data: {
|
|
39
|
+
path: '$',
|
|
40
|
+
usePathInput: false,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return chartNode;
|
|
44
|
+
}
|
|
45
|
+
getInterpolationInputNames() {
|
|
46
|
+
return getExtractObjectPathInterpolationInputNames(this.chartNode.data.path ?? '');
|
|
47
|
+
}
|
|
48
|
+
getInputDefinitions() {
|
|
49
|
+
const { usePathInput } = this.chartNode.data;
|
|
50
|
+
const inputDefinitions = [
|
|
51
|
+
{
|
|
52
|
+
id: 'object',
|
|
53
|
+
title: 'Object',
|
|
54
|
+
dataType: 'object',
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
if (usePathInput) {
|
|
59
|
+
inputDefinitions.push({
|
|
60
|
+
id: 'path',
|
|
61
|
+
title: 'Path',
|
|
62
|
+
dataType: 'string',
|
|
63
|
+
required: true,
|
|
64
|
+
coerced: false,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
for (const inputName of this.getInterpolationInputNames()) {
|
|
69
|
+
inputDefinitions.push(createInterpolationInputDefinition({
|
|
70
|
+
interpolationName: inputName,
|
|
71
|
+
dataType: 'any',
|
|
72
|
+
required: false,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return inputDefinitions;
|
|
77
|
+
}
|
|
78
|
+
getOutputDefinitions() {
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
id: 'match',
|
|
82
|
+
title: 'Match',
|
|
83
|
+
dataType: 'any',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'all_matches',
|
|
87
|
+
title: 'All Matches',
|
|
88
|
+
dataType: 'any[]',
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
getEditors() {
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
type: 'code',
|
|
96
|
+
label: 'Path',
|
|
97
|
+
dataKey: 'path',
|
|
98
|
+
language: 'jsonpath',
|
|
99
|
+
useInputToggleDataKey: 'usePathInput',
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
getBody() {
|
|
104
|
+
return this.data.usePathInput ? '(Using Input)' : this.data.path;
|
|
105
|
+
}
|
|
106
|
+
static getUIData() {
|
|
107
|
+
return {
|
|
108
|
+
infoBoxBody: dedent `
|
|
109
|
+
Extracts the value at the specified path from the input value. The path uses JSONPath notation to navigate through the value.
|
|
110
|
+
`,
|
|
111
|
+
infoBoxTitle: 'Extract Object Path Node',
|
|
112
|
+
contextMenuTitle: 'Extract Object Path',
|
|
113
|
+
group: ['Objects'],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async process(inputs, context) {
|
|
117
|
+
const { usePathInput, path } = this.chartNode.data;
|
|
118
|
+
const inputObject = coerceTypeOptional(inputs['object'], 'object');
|
|
119
|
+
const rawPath = usePathInput ? expectType(inputs['path'], 'string') : path;
|
|
120
|
+
if (!rawPath) {
|
|
121
|
+
throw new Error('Path input is not provided');
|
|
122
|
+
}
|
|
123
|
+
const inputPath = usePathInput
|
|
124
|
+
? rawPath.trim()
|
|
125
|
+
: interpolateExtractObjectPathSource(rawPath, inputs, context.graphInputNodeValues, context.contextValues);
|
|
126
|
+
let matches;
|
|
127
|
+
try {
|
|
128
|
+
// Wrap doesn't seem to wrap when the input is undefined or null...
|
|
129
|
+
const match = JSONPath({ json: inputObject ?? null, path: inputPath, wrap: true });
|
|
130
|
+
matches = match == null ? [] : match;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
matches = [];
|
|
134
|
+
}
|
|
135
|
+
if (matches.length === 0) {
|
|
136
|
+
return {
|
|
137
|
+
['match']: {
|
|
138
|
+
type: 'control-flow-excluded',
|
|
139
|
+
value: undefined,
|
|
140
|
+
},
|
|
141
|
+
['all_matches']: {
|
|
142
|
+
type: 'any[]',
|
|
143
|
+
value: [],
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
['match']: {
|
|
149
|
+
type: 'any',
|
|
150
|
+
value: matches[0],
|
|
151
|
+
},
|
|
152
|
+
['all_matches']: {
|
|
153
|
+
type: 'any[]',
|
|
154
|
+
value: matches,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export const extractObjectPathNode = nodeDefinition(ExtractObjectPathNodeImpl, 'Extract Object Path');
|