@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,173 @@
|
|
|
1
|
+
function mergeProviderMetadata(base, extra) {
|
|
2
|
+
if (base == null) {
|
|
3
|
+
return extra;
|
|
4
|
+
}
|
|
5
|
+
if (extra == null) {
|
|
6
|
+
return base;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...base,
|
|
10
|
+
...extra,
|
|
11
|
+
anthropic: {
|
|
12
|
+
...(base.anthropic ?? {}),
|
|
13
|
+
...(extra.anthropic ?? {}),
|
|
14
|
+
},
|
|
15
|
+
google: {
|
|
16
|
+
...(base.google ?? {}),
|
|
17
|
+
...(extra.google ?? {}),
|
|
18
|
+
},
|
|
19
|
+
openai: {
|
|
20
|
+
...(base.openai ?? {}),
|
|
21
|
+
...(extra.openai ?? {}),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getAnthropicCacheMetadata(enabled, ttl) {
|
|
26
|
+
if (!enabled) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
anthropic: {
|
|
31
|
+
cacheControl: {
|
|
32
|
+
type: 'ephemeral',
|
|
33
|
+
...(ttl ? { ttl } : {}),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function partToUserContent(part, options) {
|
|
39
|
+
if (typeof part === 'string') {
|
|
40
|
+
return { type: 'text', text: part };
|
|
41
|
+
}
|
|
42
|
+
switch (part.type) {
|
|
43
|
+
case 'image':
|
|
44
|
+
return {
|
|
45
|
+
type: 'image',
|
|
46
|
+
image: part.data,
|
|
47
|
+
mediaType: part.mediaType,
|
|
48
|
+
};
|
|
49
|
+
case 'url':
|
|
50
|
+
return {
|
|
51
|
+
type: 'image',
|
|
52
|
+
image: new URL(part.url),
|
|
53
|
+
};
|
|
54
|
+
case 'document':
|
|
55
|
+
return {
|
|
56
|
+
type: 'file',
|
|
57
|
+
data: part.data,
|
|
58
|
+
mediaType: part.mediaType,
|
|
59
|
+
filename: part.title?.trim() || undefined,
|
|
60
|
+
providerOptions: options.provider === 'anthropic'
|
|
61
|
+
? {
|
|
62
|
+
anthropic: {
|
|
63
|
+
...(part.enableCitations ? { citations: { enabled: true } } : {}),
|
|
64
|
+
...(part.title?.trim() ? { title: part.title.trim() } : {}),
|
|
65
|
+
...(part.context?.trim() ? { context: part.context.trim() } : {}),
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
: undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function stringifyParts(parts) {
|
|
73
|
+
const arr = Array.isArray(parts) ? parts : [parts];
|
|
74
|
+
return arr
|
|
75
|
+
.map((p) => {
|
|
76
|
+
if (typeof p === 'string')
|
|
77
|
+
return p;
|
|
78
|
+
throw new Error(`Expected string content, got ${p.type}`);
|
|
79
|
+
})
|
|
80
|
+
.join('\n\n');
|
|
81
|
+
}
|
|
82
|
+
function applyAnthropicCacheBreakpoint(parts, enabled, ttl) {
|
|
83
|
+
if (!enabled || parts.length === 0) {
|
|
84
|
+
return parts;
|
|
85
|
+
}
|
|
86
|
+
const lastPart = parts[parts.length - 1];
|
|
87
|
+
if (lastPart == null) {
|
|
88
|
+
return parts;
|
|
89
|
+
}
|
|
90
|
+
lastPart.providerOptions = mergeProviderMetadata(lastPart.providerOptions, getAnthropicCacheMetadata(true, ttl));
|
|
91
|
+
return parts;
|
|
92
|
+
}
|
|
93
|
+
export async function chatMessagesToModelMessages(messages, options) {
|
|
94
|
+
const result = [];
|
|
95
|
+
for (const msg of messages) {
|
|
96
|
+
switch (msg.type) {
|
|
97
|
+
case 'system': {
|
|
98
|
+
result.push({
|
|
99
|
+
role: 'system',
|
|
100
|
+
content: stringifyParts(msg.message),
|
|
101
|
+
providerOptions: options.provider === 'anthropic'
|
|
102
|
+
? getAnthropicCacheMetadata(!!msg.isCacheBreakpoint, options.anthropicCacheControlTtl)
|
|
103
|
+
: undefined,
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'user': {
|
|
108
|
+
const parts = Array.isArray(msg.message) ? msg.message : [msg.message];
|
|
109
|
+
if (parts.length === 1 && typeof parts[0] === 'string' && !msg.isCacheBreakpoint) {
|
|
110
|
+
result.push({ role: 'user', content: parts[0] });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const content = await Promise.all(parts.map((part) => partToUserContent(part, options)));
|
|
114
|
+
result.push({
|
|
115
|
+
role: 'user',
|
|
116
|
+
content: applyAnthropicCacheBreakpoint(content, options.provider === 'anthropic' && !!msg.isCacheBreakpoint, options.anthropicCacheControlTtl),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'assistant': {
|
|
122
|
+
const textContent = stringifyParts(msg.message);
|
|
123
|
+
const toolCalls = msg.function_calls ?? (msg.function_call ? [msg.function_call] : []);
|
|
124
|
+
if (toolCalls.length === 0 && !msg.isCacheBreakpoint) {
|
|
125
|
+
result.push({ role: 'assistant', content: textContent });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const content = [];
|
|
129
|
+
if (textContent) {
|
|
130
|
+
content.push({ type: 'text', text: textContent });
|
|
131
|
+
}
|
|
132
|
+
for (const fc of toolCalls) {
|
|
133
|
+
let parsedArgs;
|
|
134
|
+
try {
|
|
135
|
+
parsedArgs = JSON.parse(fc.arguments);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
parsedArgs = {};
|
|
139
|
+
}
|
|
140
|
+
content.push({
|
|
141
|
+
type: 'tool-call',
|
|
142
|
+
toolCallId: fc.id ?? 'unknown_function_call',
|
|
143
|
+
toolName: fc.name,
|
|
144
|
+
input: parsedArgs,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
result.push({
|
|
148
|
+
role: 'assistant',
|
|
149
|
+
content: applyAnthropicCacheBreakpoint(content, options.provider === 'anthropic' && !!msg.isCacheBreakpoint, options.anthropicCacheControlTtl),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'function': {
|
|
155
|
+
const textContent = stringifyParts(msg.message);
|
|
156
|
+
const content = [
|
|
157
|
+
{
|
|
158
|
+
type: 'tool-result',
|
|
159
|
+
toolCallId: msg.name,
|
|
160
|
+
toolName: msg.toolName ?? msg.name,
|
|
161
|
+
output: { type: 'text', value: textContent },
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
result.push({
|
|
165
|
+
role: 'tool',
|
|
166
|
+
content: applyAnthropicCacheBreakpoint(content, options.provider === 'anthropic' && !!msg.isCacheBreakpoint, options.anthropicCacheControlTtl),
|
|
167
|
+
});
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { anthropicModels } from '../../plugins/anthropic/anthropic.js';
|
|
2
|
+
import { generativeAiGoogleModels } from '../../plugins/google/google.js';
|
|
3
|
+
import { openaiModels } from '../../utils/openai.js';
|
|
4
|
+
const chatV2ModelRegistry = {
|
|
5
|
+
openai: openaiModels,
|
|
6
|
+
anthropic: anthropicModels,
|
|
7
|
+
google: generativeAiGoogleModels,
|
|
8
|
+
custom: {},
|
|
9
|
+
};
|
|
10
|
+
export function getChatV2ModelRegistry() {
|
|
11
|
+
return chatV2ModelRegistry;
|
|
12
|
+
}
|
|
13
|
+
export function getChatV2ModelInfo(provider, modelId) {
|
|
14
|
+
const providerModels = chatV2ModelRegistry[provider];
|
|
15
|
+
return providerModels[modelId];
|
|
16
|
+
}
|
|
17
|
+
export function calculateChatV2Cost(provider, modelId, promptTokens, completionTokens) {
|
|
18
|
+
const model = getChatV2ModelInfo(provider, modelId);
|
|
19
|
+
if (model == null) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return model.cost.prompt * promptTokens + model.cost.completion * completionTokens;
|
|
23
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
2
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
3
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
4
|
+
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
5
|
+
import { DEFAULT_CHAT_ENDPOINT } from '../../utils/defaults.js';
|
|
6
|
+
import { cleanHeaders } from '../../utils/inputs.js';
|
|
7
|
+
import { getChatV2ModelRegistry } from './modelRegistry.js';
|
|
8
|
+
export const chatV2ProviderOptions = [
|
|
9
|
+
{ value: 'openai', label: 'OpenAI' },
|
|
10
|
+
{ value: 'anthropic', label: 'Anthropic' },
|
|
11
|
+
{ value: 'google', label: 'Google' },
|
|
12
|
+
{ value: 'custom', label: 'Custom provider' },
|
|
13
|
+
];
|
|
14
|
+
export const openAIReasoningEffortOptions = [
|
|
15
|
+
{ value: '', label: 'Default' },
|
|
16
|
+
{ value: 'none', label: 'None' },
|
|
17
|
+
{ value: 'minimal', label: 'Minimal' },
|
|
18
|
+
{ value: 'low', label: 'Low' },
|
|
19
|
+
{ value: 'medium', label: 'Medium' },
|
|
20
|
+
{ value: 'high', label: 'High' },
|
|
21
|
+
{ value: 'xhigh', label: 'X-High' },
|
|
22
|
+
];
|
|
23
|
+
export const openAIWebSearchContextSizeOptions = [
|
|
24
|
+
{ value: 'low', label: 'Low' },
|
|
25
|
+
{ value: 'medium', label: 'Medium' },
|
|
26
|
+
{ value: 'high', label: 'High' },
|
|
27
|
+
];
|
|
28
|
+
export const anthropicThinkingModeOptions = [
|
|
29
|
+
{ value: '', label: 'Default' },
|
|
30
|
+
{ value: 'adaptive', label: 'Adaptive' },
|
|
31
|
+
{ value: 'enabled', label: 'Enabled' },
|
|
32
|
+
{ value: 'disabled', label: 'Disabled' },
|
|
33
|
+
];
|
|
34
|
+
export const anthropicEffortOptions = [
|
|
35
|
+
{ value: '', label: 'Default' },
|
|
36
|
+
{ value: 'low', label: 'Low' },
|
|
37
|
+
{ value: 'medium', label: 'Medium' },
|
|
38
|
+
{ value: 'high', label: 'High' },
|
|
39
|
+
{ value: 'max', label: 'Max' },
|
|
40
|
+
];
|
|
41
|
+
export const googleThinkingLevelOptions = [
|
|
42
|
+
{ value: '', label: 'Default' },
|
|
43
|
+
{ value: 'minimal', label: 'Minimal' },
|
|
44
|
+
{ value: 'low', label: 'Low' },
|
|
45
|
+
{ value: 'medium', label: 'Medium' },
|
|
46
|
+
{ value: 'high', label: 'High' },
|
|
47
|
+
];
|
|
48
|
+
export const anthropicCacheControlTtlOptions = [
|
|
49
|
+
{ value: '', label: 'Default' },
|
|
50
|
+
{ value: '5m', label: '5 minutes' },
|
|
51
|
+
{ value: '1h', label: '1 hour' },
|
|
52
|
+
];
|
|
53
|
+
export function getChatV2ProviderLabel(provider) {
|
|
54
|
+
return chatV2ProviderOptions.find((option) => option.value === provider)?.label ?? provider;
|
|
55
|
+
}
|
|
56
|
+
export function getChatV2ModelOptions(provider) {
|
|
57
|
+
const registry = getChatV2ModelRegistry()[provider];
|
|
58
|
+
return Object.entries(registry)
|
|
59
|
+
.map(([value, model]) => ({
|
|
60
|
+
value,
|
|
61
|
+
label: model.displayName,
|
|
62
|
+
}))
|
|
63
|
+
.sort((a, b) => a.label.localeCompare(b.label));
|
|
64
|
+
}
|
|
65
|
+
export function getDefaultChatV2Model(provider) {
|
|
66
|
+
switch (provider) {
|
|
67
|
+
case 'openai':
|
|
68
|
+
return 'gpt-5';
|
|
69
|
+
case 'anthropic':
|
|
70
|
+
return 'claude-sonnet-4-20250514';
|
|
71
|
+
case 'google':
|
|
72
|
+
return 'gemini-2.5-flash';
|
|
73
|
+
case 'custom':
|
|
74
|
+
return 'model-id';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function parseChatV2Provider(value) {
|
|
78
|
+
switch (value) {
|
|
79
|
+
case 'openai':
|
|
80
|
+
case 'anthropic':
|
|
81
|
+
case 'google':
|
|
82
|
+
case 'custom':
|
|
83
|
+
return value;
|
|
84
|
+
default:
|
|
85
|
+
throw new Error(`Unsupported LLM Chat provider: ${value}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function removeTrailingSlash(value) {
|
|
89
|
+
return value.endsWith('/') ? value.slice(0, -1) : value;
|
|
90
|
+
}
|
|
91
|
+
function openAIEndpointToBaseURL(endpoint) {
|
|
92
|
+
const normalized = endpoint.replace(/\/(chat\/completions|responses)\/?$/i, '');
|
|
93
|
+
try {
|
|
94
|
+
return removeTrailingSlash(new URL(normalized).toString());
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return removeTrailingSlash(normalized);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export function openAICompatibleEndpointToBaseURL(endpoint) {
|
|
101
|
+
return openAIEndpointToBaseURL(endpoint);
|
|
102
|
+
}
|
|
103
|
+
function openAIBaseURLToEndpoint(baseURL) {
|
|
104
|
+
const normalizedBaseURL = removeTrailingSlash(baseURL);
|
|
105
|
+
try {
|
|
106
|
+
const url = new URL(normalizedBaseURL);
|
|
107
|
+
url.pathname = `${url.pathname.replace(/\/$/, '')}/chat/completions`;
|
|
108
|
+
return url.toString();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return `${normalizedBaseURL}/chat/completions`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export async function resolveChatV2ProviderConfig(provider, modelId, context, options = {}) {
|
|
115
|
+
const headers = cleanHeaders({
|
|
116
|
+
...context.settings.chatNodeHeaders,
|
|
117
|
+
...options.headers,
|
|
118
|
+
});
|
|
119
|
+
switch (provider) {
|
|
120
|
+
case 'openai': {
|
|
121
|
+
const configuredBaseURL = options.baseURL
|
|
122
|
+
? options.baseURL
|
|
123
|
+
: openAIEndpointToBaseURL(context.settings.openAiEndpoint || DEFAULT_CHAT_ENDPOINT);
|
|
124
|
+
if (context.getChatNodeEndpoint == null) {
|
|
125
|
+
return {
|
|
126
|
+
baseURL: configuredBaseURL,
|
|
127
|
+
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const resolved = await context.getChatNodeEndpoint(openAIBaseURLToEndpoint(configuredBaseURL), modelId);
|
|
131
|
+
return {
|
|
132
|
+
baseURL: openAIEndpointToBaseURL(resolved.endpoint),
|
|
133
|
+
headers: cleanHeaders({
|
|
134
|
+
...headers,
|
|
135
|
+
...resolved.headers,
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
case 'anthropic':
|
|
140
|
+
return {
|
|
141
|
+
baseURL: options.baseURL || context.getPluginConfig('anthropicApiEndpoint') || undefined,
|
|
142
|
+
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
143
|
+
};
|
|
144
|
+
case 'google':
|
|
145
|
+
return {
|
|
146
|
+
baseURL: options.baseURL || undefined,
|
|
147
|
+
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
148
|
+
};
|
|
149
|
+
case 'custom': {
|
|
150
|
+
const configuredBaseURL = options.baseURL?.trim();
|
|
151
|
+
if (!configuredBaseURL) {
|
|
152
|
+
throw new Error('Provider base URL is required when provider is Custom provider.');
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
baseURL: openAICompatibleEndpointToBaseURL(configuredBaseURL),
|
|
156
|
+
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export function createChatV2Model(provider, modelId, context, options = {}) {
|
|
162
|
+
switch (provider) {
|
|
163
|
+
case 'openai': {
|
|
164
|
+
const providerInstance = createOpenAI({
|
|
165
|
+
apiKey: options.apiKey || context.settings.openAiKey || undefined,
|
|
166
|
+
organization: context.settings.openAiOrganization || undefined,
|
|
167
|
+
baseURL: options.baseURL || undefined,
|
|
168
|
+
headers: options.headers,
|
|
169
|
+
});
|
|
170
|
+
return providerInstance.responses(modelId);
|
|
171
|
+
}
|
|
172
|
+
case 'anthropic': {
|
|
173
|
+
const providerInstance = createAnthropic({
|
|
174
|
+
apiKey: options.apiKey || context.getPluginConfig('anthropicApiKey') || undefined,
|
|
175
|
+
baseURL: options.baseURL || context.getPluginConfig('anthropicApiEndpoint') || undefined,
|
|
176
|
+
headers: options.headers,
|
|
177
|
+
});
|
|
178
|
+
return providerInstance.messages(modelId);
|
|
179
|
+
}
|
|
180
|
+
case 'google': {
|
|
181
|
+
const providerInstance = createGoogleGenerativeAI({
|
|
182
|
+
apiKey: options.apiKey || context.getPluginConfig('googleApiKey') || undefined,
|
|
183
|
+
baseURL: options.baseURL || undefined,
|
|
184
|
+
headers: options.headers,
|
|
185
|
+
});
|
|
186
|
+
return providerInstance.chat(modelId);
|
|
187
|
+
}
|
|
188
|
+
case 'custom': {
|
|
189
|
+
if (!options.baseURL) {
|
|
190
|
+
throw new Error('Provider base URL is required when provider is Custom provider.');
|
|
191
|
+
}
|
|
192
|
+
const providerInstance = createOpenAICompatible({
|
|
193
|
+
name: 'custom',
|
|
194
|
+
apiKey: options.apiKey,
|
|
195
|
+
baseURL: options.baseURL,
|
|
196
|
+
headers: options.headers,
|
|
197
|
+
includeUsage: true,
|
|
198
|
+
});
|
|
199
|
+
return providerInstance.chatModel(modelId);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { runChatV2Pipeline } from './chatV2Pipeline.js';
|
|
2
|
+
function getToolNames(functions) {
|
|
3
|
+
return new Set((functions ?? []).map((fn) => fn.name).filter((name) => name.trim().length > 0));
|
|
4
|
+
}
|
|
5
|
+
function canAutoContinue(functionCalls, toolNames) {
|
|
6
|
+
return functionCalls.length > 0 && functionCalls.every((call) => toolNames.has(call.name));
|
|
7
|
+
}
|
|
8
|
+
function addUsage(accumulated, usage) {
|
|
9
|
+
if (usage == null) {
|
|
10
|
+
return accumulated;
|
|
11
|
+
}
|
|
12
|
+
if (accumulated == null) {
|
|
13
|
+
return { ...usage };
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
promptTokens: accumulated.promptTokens + usage.promptTokens,
|
|
17
|
+
completionTokens: accumulated.completionTokens + usage.completionTokens,
|
|
18
|
+
totalTokens: accumulated.totalTokens + usage.totalTokens,
|
|
19
|
+
cachedTokens: accumulated.cachedTokens + usage.cachedTokens,
|
|
20
|
+
reasoningTokens: accumulated.reasoningTokens + usage.reasoningTokens,
|
|
21
|
+
totalCost: accumulated.totalCost == null || usage.totalCost == null
|
|
22
|
+
? undefined
|
|
23
|
+
: accumulated.totalCost + usage.totalCost,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function applyAccumulatedUsage(result, usage, outputUsage) {
|
|
27
|
+
if (usage == null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
result.usage = usage;
|
|
31
|
+
result.commonOutputs['responseTokens'] = {
|
|
32
|
+
type: 'number',
|
|
33
|
+
value: usage.completionTokens,
|
|
34
|
+
};
|
|
35
|
+
if (outputUsage) {
|
|
36
|
+
result.commonOutputs['usage'] = {
|
|
37
|
+
type: 'object',
|
|
38
|
+
value: usage,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function appendReasoningRound(accumulated, reasoning) {
|
|
43
|
+
const roundReasoning = Array.isArray(reasoning) ? reasoning : [reasoning];
|
|
44
|
+
const nonEmptyReasoning = roundReasoning.map((part) => part.trim()).filter((part) => part.length > 0);
|
|
45
|
+
if (nonEmptyReasoning.length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
accumulated.push(...nonEmptyReasoning);
|
|
49
|
+
}
|
|
50
|
+
function applyAccumulatedReasoning(result, reasoningRounds, outputReasoning) {
|
|
51
|
+
if (reasoningRounds.length === 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const reasoning = [...reasoningRounds];
|
|
55
|
+
result.reasoning = reasoning;
|
|
56
|
+
if (outputReasoning) {
|
|
57
|
+
result.commonOutputs['reasoning'] = {
|
|
58
|
+
type: 'string[]',
|
|
59
|
+
value: reasoning,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export async function runChatV2PipelineWithToolContinuation(options) {
|
|
64
|
+
const { autoContinue, maxToolRounds, functions, delegateToolCall, runPipeline = runChatV2Pipeline, ...pipelineOptions } = options;
|
|
65
|
+
const toolNames = getToolNames(functions);
|
|
66
|
+
const maxRounds = Math.max(1, Math.floor(Number.isFinite(maxToolRounds) ? maxToolRounds : 1));
|
|
67
|
+
let currentPrompt = pipelineOptions.prompt;
|
|
68
|
+
let currentSystemPrompt = pipelineOptions.systemPrompt;
|
|
69
|
+
const delegatedToolCalls = [];
|
|
70
|
+
let accumulatedUsage;
|
|
71
|
+
const reasoningRounds = [];
|
|
72
|
+
for (let completedRounds = 0;; completedRounds++) {
|
|
73
|
+
const result = await runPipeline({
|
|
74
|
+
...pipelineOptions,
|
|
75
|
+
functions,
|
|
76
|
+
prompt: currentPrompt,
|
|
77
|
+
systemPrompt: currentSystemPrompt,
|
|
78
|
+
});
|
|
79
|
+
accumulatedUsage = autoContinue ? addUsage(accumulatedUsage, result.usage) : undefined;
|
|
80
|
+
if (autoContinue) {
|
|
81
|
+
appendReasoningRound(reasoningRounds, result.reasoning);
|
|
82
|
+
}
|
|
83
|
+
if (!autoContinue ||
|
|
84
|
+
completedRounds >= maxRounds ||
|
|
85
|
+
!canAutoContinue(result.functionCalls, toolNames)) {
|
|
86
|
+
if (result.functionCalls.length === 0 && delegatedToolCalls.length > 0 && pipelineOptions.includeFunctionCalls) {
|
|
87
|
+
result.commonOutputs['function-calls'] = {
|
|
88
|
+
type: 'object[]',
|
|
89
|
+
value: delegatedToolCalls,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (autoContinue) {
|
|
93
|
+
applyAccumulatedUsage(result, accumulatedUsage, pipelineOptions.outputUsage);
|
|
94
|
+
applyAccumulatedReasoning(result, reasoningRounds, pipelineOptions.outputReasoning);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
const toolResultMessages = await Promise.all(result.functionCalls.map(delegateToolCall));
|
|
99
|
+
delegatedToolCalls.push(...toolResultMessages
|
|
100
|
+
.map((message) => message.delegatedToolCall)
|
|
101
|
+
.filter((record) => record != null));
|
|
102
|
+
currentPrompt = {
|
|
103
|
+
type: 'chat-message[]',
|
|
104
|
+
value: [...result.allMessages, ...toolResultMessages.map((message) => message.value)],
|
|
105
|
+
};
|
|
106
|
+
currentSystemPrompt = undefined;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const INTERPOLATION_INPUT_DEFINITION_KIND = 'interpolation-input';
|
|
2
|
+
export function createInterpolationInputDefinition({ id, interpolationName, dataType, required, description, }) {
|
|
3
|
+
const definition = {
|
|
4
|
+
id: id ?? interpolationName,
|
|
5
|
+
title: interpolationName,
|
|
6
|
+
dataType,
|
|
7
|
+
data: {
|
|
8
|
+
kind: INTERPOLATION_INPUT_DEFINITION_KIND,
|
|
9
|
+
interpolationName,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
if (required != null) {
|
|
13
|
+
definition.required = required;
|
|
14
|
+
}
|
|
15
|
+
if (description != null) {
|
|
16
|
+
definition.description = description;
|
|
17
|
+
}
|
|
18
|
+
return definition;
|
|
19
|
+
}
|
|
20
|
+
export function getInterpolationInputDefinitionData(inputDefinition) {
|
|
21
|
+
if (typeof inputDefinition.data !== 'object' || inputDefinition.data == null) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const data = inputDefinition.data;
|
|
25
|
+
if (data?.kind !== INTERPOLATION_INPUT_DEFINITION_KIND ||
|
|
26
|
+
typeof data.interpolationName !== 'string') {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
kind: INTERPOLATION_INPUT_DEFINITION_KIND,
|
|
31
|
+
interpolationName: data.interpolationName,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function isInterpolationInputDefinition(inputDefinition) {
|
|
35
|
+
return getInterpolationInputDefinitionData(inputDefinition) != null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
2
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
3
|
+
import { dedent } from 'ts-dedent';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
6
|
+
export class AbortGraphNodeImpl extends NodeImpl {
|
|
7
|
+
static create() {
|
|
8
|
+
const chartNode = {
|
|
9
|
+
type: 'abortGraph',
|
|
10
|
+
title: 'Abort Graph',
|
|
11
|
+
id: nanoid(),
|
|
12
|
+
visualData: {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0,
|
|
15
|
+
width: 200,
|
|
16
|
+
},
|
|
17
|
+
data: {
|
|
18
|
+
successfully: true,
|
|
19
|
+
errorMessage: '',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return chartNode;
|
|
23
|
+
}
|
|
24
|
+
getInputDefinitions() {
|
|
25
|
+
const inputs = [
|
|
26
|
+
{
|
|
27
|
+
id: 'data',
|
|
28
|
+
title: 'Data or Error',
|
|
29
|
+
dataType: 'any',
|
|
30
|
+
description: 'The message to abort the graph with.',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
if (this.data.useSuccessfullyInput) {
|
|
34
|
+
inputs.push({
|
|
35
|
+
id: 'successfully',
|
|
36
|
+
title: 'Successfully',
|
|
37
|
+
dataType: 'boolean',
|
|
38
|
+
description: 'Whether to successfully abort the graph (early-exit), or error abort the graph.',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return inputs;
|
|
42
|
+
}
|
|
43
|
+
getOutputDefinitions() {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
getEditors() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
type: 'toggle',
|
|
50
|
+
label: 'Successfully Abort',
|
|
51
|
+
dataKey: 'successfully',
|
|
52
|
+
useInputToggleDataKey: 'useSuccessfullyInput',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'string',
|
|
56
|
+
label: 'Error Message (if not successfully aborting)',
|
|
57
|
+
dataKey: 'errorMessage',
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
getBody() {
|
|
62
|
+
return dedent `
|
|
63
|
+
${this.data.useSuccessfullyInput
|
|
64
|
+
? 'Success depends on input'
|
|
65
|
+
: this.data.successfully
|
|
66
|
+
? 'Successfully Abort'
|
|
67
|
+
: this.data.errorMessage
|
|
68
|
+
? `Error Abort: ${this.data.errorMessage}`
|
|
69
|
+
: 'Error Abort'}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
static getUIData() {
|
|
73
|
+
return {
|
|
74
|
+
infoBoxBody: dedent `
|
|
75
|
+
Aborts the execution of the entire graph immediately.
|
|
76
|
+
|
|
77
|
+
Can either "successfully" abort the graph (early-exit), or "error" abort the graph.
|
|
78
|
+
`,
|
|
79
|
+
infoBoxTitle: 'Abort Graph Node',
|
|
80
|
+
contextMenuTitle: 'Abort Graph',
|
|
81
|
+
group: ['Logic'],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async process(inputs, context) {
|
|
85
|
+
const successfully = this.data.useSuccessfullyInput
|
|
86
|
+
? coerceTypeOptional(inputs['successfully'], 'boolean') ?? this.data.successfully
|
|
87
|
+
: this.data.successfully;
|
|
88
|
+
if (successfully) {
|
|
89
|
+
context.abortGraph();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const errorMessage = coerceTypeOptional(inputs['data'], 'string')?.trim() ||
|
|
93
|
+
this.data.errorMessage ||
|
|
94
|
+
'Graph aborted with error';
|
|
95
|
+
context.abortGraph(errorMessage);
|
|
96
|
+
}
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export const abortGraphNode = nodeDefinition(AbortGraphNodeImpl, 'Abort Graph');
|