@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,286 @@
|
|
|
1
|
+
import { dedent } from './misc.js';
|
|
2
|
+
import { get as lodashGet } from 'lodash-es';
|
|
3
|
+
export const ESCAPED_TOKEN_REGEX = /\{\{\{([^}]+?)\}\}\}/g;
|
|
4
|
+
export const ESCAPED_ESCAPED_TOKEN_REGEX = /\\\{\\\{([^}]+?)\\\}\\\}/g;
|
|
5
|
+
const processingFunctions = {
|
|
6
|
+
indent: (input, spaces = 0) => {
|
|
7
|
+
const indent = ' '.repeat(spaces);
|
|
8
|
+
return input
|
|
9
|
+
.split('\n')
|
|
10
|
+
.map((line) => `${indent}${line}`)
|
|
11
|
+
.join('\n');
|
|
12
|
+
},
|
|
13
|
+
quote: (input, level = 1) => {
|
|
14
|
+
const quotePrefix = '> '.repeat(level);
|
|
15
|
+
return input
|
|
16
|
+
.split('\n')
|
|
17
|
+
.map((line) => `${quotePrefix}${line}`)
|
|
18
|
+
.join('\n');
|
|
19
|
+
},
|
|
20
|
+
uppercase: (input) => {
|
|
21
|
+
return input.toUpperCase();
|
|
22
|
+
},
|
|
23
|
+
lowercase: (input) => {
|
|
24
|
+
return input.toLowerCase();
|
|
25
|
+
},
|
|
26
|
+
trim: (input) => {
|
|
27
|
+
return input.trim();
|
|
28
|
+
},
|
|
29
|
+
truncate: (input, length = 50) => {
|
|
30
|
+
if (input.length <= length)
|
|
31
|
+
return input;
|
|
32
|
+
return input.slice(0, length) + '...';
|
|
33
|
+
},
|
|
34
|
+
list: (input, level = 1) => {
|
|
35
|
+
const indent = ' '.repeat(level - 1);
|
|
36
|
+
return input
|
|
37
|
+
.split('\n')
|
|
38
|
+
.map((line) => `${indent}- ${line}`)
|
|
39
|
+
.join('\n');
|
|
40
|
+
},
|
|
41
|
+
sort: (input) => {
|
|
42
|
+
return input.split('\n').sort().join('\n');
|
|
43
|
+
},
|
|
44
|
+
dedent: (input) => {
|
|
45
|
+
return dedent(input);
|
|
46
|
+
},
|
|
47
|
+
wrap: (input, width = 80) => {
|
|
48
|
+
const words = input.split(/\s+/);
|
|
49
|
+
const lines = [];
|
|
50
|
+
let currentLine = '';
|
|
51
|
+
for (const word of words) {
|
|
52
|
+
if (currentLine.length + word.length + 1 <= width) {
|
|
53
|
+
currentLine += (currentLine ? ' ' : '') + word;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
lines.push(currentLine);
|
|
57
|
+
currentLine = word;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (currentLine) {
|
|
61
|
+
lines.push(currentLine);
|
|
62
|
+
}
|
|
63
|
+
return lines.join('\n');
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
// Helper function to check and potentially unwrap a DataValue-like object
|
|
67
|
+
export function unwrapPotentialDataValue(value) {
|
|
68
|
+
if (typeof value === 'object' &&
|
|
69
|
+
value !== null &&
|
|
70
|
+
typeof value.type === 'string' &&
|
|
71
|
+
Object.prototype.hasOwnProperty.call(value, 'value') // More robust check for 'value' property
|
|
72
|
+
) {
|
|
73
|
+
return value.value;
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
// Renamed from resolveExpression, now exported and returns raw value
|
|
78
|
+
export function resolveExpressionRawValue(source, expression, sourceType) {
|
|
79
|
+
if (!source) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
// Regex to capture the main key and the optional path starting with . or [
|
|
83
|
+
// Allows for spaces around the key, path, ., and []
|
|
84
|
+
// Key: Group 1; Path: Group 2
|
|
85
|
+
const match = expression.trim().match(/^([^[.\s]+)\s*(.*)$/);
|
|
86
|
+
let key;
|
|
87
|
+
let path;
|
|
88
|
+
// Check if match is successful AND group 1 (the key) was captured
|
|
89
|
+
if (match && typeof match[1] === 'string') {
|
|
90
|
+
key = match[1];
|
|
91
|
+
const rawPath = match[2]; // Group 2 (the path part, might start with . or [)
|
|
92
|
+
// Clean and assign path only if rawPath is not empty
|
|
93
|
+
if (rawPath) {
|
|
94
|
+
// Clean path: Trim whitespace, then remove spaces around separators '.', '[', ']'
|
|
95
|
+
// Preserve the leading '.' or '[' as lodashGet handles them.
|
|
96
|
+
path = rawPath.trim().replace(/\s*(\.|\[|\])\s*/g, '$1');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
path = undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// If match failed or group 1 wasn't captured (fallback)
|
|
104
|
+
// Assume the entire expression is the key and there's no path
|
|
105
|
+
key = expression.trim();
|
|
106
|
+
path = undefined;
|
|
107
|
+
}
|
|
108
|
+
if (!key) {
|
|
109
|
+
// If key is empty after trimming, it's invalid.
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const topLevelValue = source[key];
|
|
113
|
+
if (topLevelValue === undefined) {
|
|
114
|
+
return undefined; // Key not found in source
|
|
115
|
+
}
|
|
116
|
+
// Get the base value by potentially unwrapping the top-level value using the shared helper
|
|
117
|
+
const baseValue = unwrapPotentialDataValue(topLevelValue);
|
|
118
|
+
// If there's a path, try to resolve it using lodashGet on the baseValue
|
|
119
|
+
let finalValue;
|
|
120
|
+
if (path) {
|
|
121
|
+
try {
|
|
122
|
+
finalValue = lodashGet(baseValue, path);
|
|
123
|
+
// IMPORTANT: After getting a potentially nested value via path,
|
|
124
|
+
// we might *still* have a DataValue (if the context stores them nested).
|
|
125
|
+
// Unwrap again to be safe.
|
|
126
|
+
finalValue = unwrapPotentialDataValue(finalValue);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.warn(`Error accessing path "${path}" in ${sourceType} value for key "${key}":`, error);
|
|
130
|
+
return undefined; // Error during path access
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
finalValue = baseValue; // No path, use the (potentially unwrapped) base value
|
|
135
|
+
}
|
|
136
|
+
// Return the raw final value
|
|
137
|
+
return finalValue;
|
|
138
|
+
}
|
|
139
|
+
export function resolveExpressionToString(source, expression, sourceType) {
|
|
140
|
+
const finalValue = resolveExpressionRawValue(source, expression, sourceType);
|
|
141
|
+
if (finalValue === undefined) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
// Convert the final value to a string for TextNode context
|
|
145
|
+
if (typeof finalValue === 'object' && finalValue !== null) {
|
|
146
|
+
try {
|
|
147
|
+
return JSON.stringify(finalValue);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.warn(`Error stringifying object/array in ${sourceType} for expression "${expression}":`, error);
|
|
151
|
+
return '[object Object]'; // Fallback
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// For primitives
|
|
155
|
+
return String(finalValue);
|
|
156
|
+
}
|
|
157
|
+
// Helper function to parse processing instructions like "indent 2" or "quote" into function name and parameter
|
|
158
|
+
function parseProcessing(instruction) {
|
|
159
|
+
const parts = instruction.trim().split(/\s+/);
|
|
160
|
+
return {
|
|
161
|
+
func: parts[0],
|
|
162
|
+
param: parts[1] ? parseInt(parts[1], 10) : undefined,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// Apply a chain of processing functions to a string
|
|
166
|
+
function applyProcessing(value, processingChain) {
|
|
167
|
+
const instructions = processingChain
|
|
168
|
+
.split('|')
|
|
169
|
+
.map((instruction) => instruction.trim())
|
|
170
|
+
.filter((instruction) => instruction !== '');
|
|
171
|
+
return instructions.reduce((result, instruction) => {
|
|
172
|
+
const { func, param } = parseProcessing(instruction);
|
|
173
|
+
const processingFunc = processingFunctions[func];
|
|
174
|
+
if (!processingFunc) {
|
|
175
|
+
console.warn(`Unknown processing function: ${func}`);
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
return processingFunc(result, param);
|
|
179
|
+
}, value);
|
|
180
|
+
}
|
|
181
|
+
export function protectEscapedInterpolationTokens(template) {
|
|
182
|
+
return template.replace(ESCAPED_TOKEN_REGEX, (_match, expression) => `\\{\\{${expression}\\}\\}`);
|
|
183
|
+
}
|
|
184
|
+
export function restoreEscapedInterpolationTokens(template) {
|
|
185
|
+
return template.replace(ESCAPED_ESCAPED_TOKEN_REGEX, (_match, expression) => `{{${expression}}}`);
|
|
186
|
+
}
|
|
187
|
+
export function findInterpolationTokenSpans(template) {
|
|
188
|
+
const spans = [];
|
|
189
|
+
let searchIndex = 0;
|
|
190
|
+
while (searchIndex < template.length) {
|
|
191
|
+
const openIndex = template.indexOf('{{', searchIndex);
|
|
192
|
+
if (openIndex === -1) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
const closeIndex = template.indexOf('}}', openIndex + 2);
|
|
196
|
+
if (closeIndex === -1) {
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
const nestedOpenIndex = template.indexOf('{{', openIndex + 2);
|
|
200
|
+
if (nestedOpenIndex !== -1 && nestedOpenIndex < closeIndex) {
|
|
201
|
+
searchIndex = nestedOpenIndex;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
spans.push({
|
|
205
|
+
start: openIndex,
|
|
206
|
+
end: closeIndex + 2,
|
|
207
|
+
rawInner: template.slice(openIndex + 2, closeIndex),
|
|
208
|
+
});
|
|
209
|
+
searchIndex = closeIndex + 2;
|
|
210
|
+
}
|
|
211
|
+
return spans;
|
|
212
|
+
}
|
|
213
|
+
export function getInterpolationTokenName(rawInner) {
|
|
214
|
+
const [tokenPart] = rawInner.split('|');
|
|
215
|
+
if (!tokenPart) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const token = tokenPart.trim();
|
|
219
|
+
return token === '' ? undefined : token;
|
|
220
|
+
}
|
|
221
|
+
export function replaceInterpolationTokens(template, getReplacement, options = {}) {
|
|
222
|
+
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
223
|
+
const tokenSpans = findInterpolationTokenSpans(protectedTemplate);
|
|
224
|
+
if (tokenSpans.length === 0) {
|
|
225
|
+
const restoredTemplate = restoreEscapedInterpolationTokens(protectedTemplate);
|
|
226
|
+
return options.trim ? restoredTemplate.trim() : restoredTemplate;
|
|
227
|
+
}
|
|
228
|
+
let result = '';
|
|
229
|
+
let cursor = 0;
|
|
230
|
+
for (const tokenSpan of tokenSpans) {
|
|
231
|
+
result += protectedTemplate.slice(cursor, tokenSpan.start);
|
|
232
|
+
result += getReplacement({
|
|
233
|
+
rawInner: tokenSpan.rawInner,
|
|
234
|
+
span: tokenSpan,
|
|
235
|
+
tokenName: getInterpolationTokenName(tokenSpan.rawInner),
|
|
236
|
+
});
|
|
237
|
+
cursor = tokenSpan.end;
|
|
238
|
+
}
|
|
239
|
+
result += protectedTemplate.slice(cursor);
|
|
240
|
+
const restoredResult = restoreEscapedInterpolationTokens(result);
|
|
241
|
+
return options.trim ? restoredResult.trim() : restoredResult;
|
|
242
|
+
}
|
|
243
|
+
export function interpolate(template, variables, graphInputValues, contextValues) {
|
|
244
|
+
return replaceInterpolationTokens(template, ({ rawInner }) => {
|
|
245
|
+
const parts = rawInner.split('|').map((s) => s.trim());
|
|
246
|
+
const expression = parts[0]; // The variable name or path, e.g., @context.foo.bar or myVar
|
|
247
|
+
const processingChain = parts.slice(1).join('|'); // e.g., indent 2 | quote
|
|
248
|
+
let resolvedValue;
|
|
249
|
+
if (expression.startsWith('@graphInputs.')) {
|
|
250
|
+
resolvedValue = resolveExpressionToString(graphInputValues, expression.substring('@graphInputs.'.length), 'graphInputs');
|
|
251
|
+
}
|
|
252
|
+
else if (expression.startsWith('@context.')) {
|
|
253
|
+
resolvedValue = resolveExpressionToString(contextValues, expression.substring('@context.'.length), 'context');
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
const simpleVar = variables[expression];
|
|
257
|
+
if (simpleVar !== undefined) {
|
|
258
|
+
resolvedValue = String(unwrapPotentialDataValue(simpleVar) ?? '');
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
resolvedValue = undefined;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (resolvedValue === undefined) {
|
|
265
|
+
console.warn(`Interpolation variable or path "${expression}" not found or resolved to undefined.`);
|
|
266
|
+
return '';
|
|
267
|
+
}
|
|
268
|
+
else if (processingChain) {
|
|
269
|
+
return applyProcessing(resolvedValue, processingChain);
|
|
270
|
+
}
|
|
271
|
+
return resolvedValue;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
// Extract all unique variable names from a template string
|
|
275
|
+
// Ignores variables starting with @graphInputs. or @context., as they are treated as special references.
|
|
276
|
+
export function extractInterpolationVariables(template) {
|
|
277
|
+
const protectedTemplate = protectEscapedInterpolationTokens(template);
|
|
278
|
+
const variables = new Set();
|
|
279
|
+
for (const match of findInterpolationTokenSpans(protectedTemplate)) {
|
|
280
|
+
const token = getInterpolationTokenName(match.rawInner);
|
|
281
|
+
if (token && !token.startsWith('@graphInputs.') && !token.startsWith('@context.')) {
|
|
282
|
+
variables.add(token);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return Array.from(variables);
|
|
286
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dedent } from 'ts-dedent';
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { orderBy } from 'lodash-es';
|
|
2
|
+
import { DEFAULT_CHAT_NODE_TIMEOUT } from './defaults.js';
|
|
3
|
+
import fetchEventSource from './fetchEventSource.js';
|
|
4
|
+
import { parseProviderJsonChunk } from './providerStreamParsing.js';
|
|
5
|
+
export const defaultOpenaiSupported = {
|
|
6
|
+
parallelFunctionCalls: true,
|
|
7
|
+
};
|
|
8
|
+
export const openaiModels = {
|
|
9
|
+
'gpt-5': {
|
|
10
|
+
maxTokens: 400000,
|
|
11
|
+
cost: {
|
|
12
|
+
prompt: 1.25e-6,
|
|
13
|
+
completion: 10e-6,
|
|
14
|
+
},
|
|
15
|
+
displayName: 'GPT-5',
|
|
16
|
+
supported: {
|
|
17
|
+
parallelFunctionCalls: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
'gpt-5-mini': {
|
|
21
|
+
maxTokens: 400000,
|
|
22
|
+
cost: {
|
|
23
|
+
prompt: 0.25 - 6,
|
|
24
|
+
completion: 2e-6,
|
|
25
|
+
},
|
|
26
|
+
displayName: 'GPT-5 mini',
|
|
27
|
+
supported: {
|
|
28
|
+
parallelFunctionCalls: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
'gpt-5-nano': {
|
|
32
|
+
maxTokens: 400000,
|
|
33
|
+
cost: {
|
|
34
|
+
prompt: 0.05e-6,
|
|
35
|
+
completion: 0.4e-6,
|
|
36
|
+
},
|
|
37
|
+
displayName: 'GPT-5 nano',
|
|
38
|
+
supported: {
|
|
39
|
+
parallelFunctionCalls: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
'gpt-4o': {
|
|
43
|
+
maxTokens: 128000,
|
|
44
|
+
cost: {
|
|
45
|
+
prompt: 0.005,
|
|
46
|
+
completion: 0.015,
|
|
47
|
+
},
|
|
48
|
+
displayName: 'GPT-4o',
|
|
49
|
+
},
|
|
50
|
+
'gpt-4o-mini': {
|
|
51
|
+
maxTokens: 128000,
|
|
52
|
+
cost: {
|
|
53
|
+
prompt: 0.00015,
|
|
54
|
+
completion: 0.00075,
|
|
55
|
+
},
|
|
56
|
+
displayName: 'GPT-4o mini',
|
|
57
|
+
},
|
|
58
|
+
o1: {
|
|
59
|
+
maxTokens: 128000,
|
|
60
|
+
cost: {
|
|
61
|
+
prompt: 0.015,
|
|
62
|
+
completion: 0.6,
|
|
63
|
+
},
|
|
64
|
+
displayName: 'o1',
|
|
65
|
+
supported: {
|
|
66
|
+
parallelFunctionCalls: false,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
'o1-mini': {
|
|
70
|
+
maxTokens: 128000,
|
|
71
|
+
cost: {
|
|
72
|
+
prompt: 0.0011,
|
|
73
|
+
completion: 0.0044,
|
|
74
|
+
},
|
|
75
|
+
displayName: 'o1-mini',
|
|
76
|
+
supported: {
|
|
77
|
+
parallelFunctionCalls: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
'o3-mini': {
|
|
81
|
+
maxTokens: 200000,
|
|
82
|
+
cost: {
|
|
83
|
+
prompt: 0.0011,
|
|
84
|
+
completion: 0.0044,
|
|
85
|
+
},
|
|
86
|
+
displayName: 'o3-mini',
|
|
87
|
+
supported: {
|
|
88
|
+
parallelFunctionCalls: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
'gpt-4o-audio-preview': {
|
|
92
|
+
maxTokens: 128000,
|
|
93
|
+
cost: {
|
|
94
|
+
prompt: 0.0025,
|
|
95
|
+
completion: 0.01,
|
|
96
|
+
audioPrompt: 0.04,
|
|
97
|
+
audioCompletion: 0.08,
|
|
98
|
+
},
|
|
99
|
+
displayName: 'GPT-4o Audio (Preview)',
|
|
100
|
+
},
|
|
101
|
+
'gpt-4.1': {
|
|
102
|
+
maxTokens: 1_047_576,
|
|
103
|
+
cost: {
|
|
104
|
+
prompt: 2e-6,
|
|
105
|
+
completion: 8e-6,
|
|
106
|
+
},
|
|
107
|
+
displayName: 'GPT-4.1',
|
|
108
|
+
},
|
|
109
|
+
o3: {
|
|
110
|
+
maxTokens: 200_000,
|
|
111
|
+
cost: {
|
|
112
|
+
prompt: 10e-6,
|
|
113
|
+
completion: 40e-6,
|
|
114
|
+
},
|
|
115
|
+
displayName: 'o3',
|
|
116
|
+
},
|
|
117
|
+
'o4-mini': {
|
|
118
|
+
maxTokens: 200_000,
|
|
119
|
+
cost: {
|
|
120
|
+
prompt: 1.1e-6,
|
|
121
|
+
completion: 4.4e-6,
|
|
122
|
+
},
|
|
123
|
+
displayName: 'o4-mini',
|
|
124
|
+
},
|
|
125
|
+
'local-model': {
|
|
126
|
+
maxTokens: Number.MAX_SAFE_INTEGER,
|
|
127
|
+
cost: {
|
|
128
|
+
prompt: 0,
|
|
129
|
+
completion: 0,
|
|
130
|
+
},
|
|
131
|
+
displayName: 'Local Model',
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
export const openAiModelOptions = orderBy(Object.entries(openaiModels).map(([id, { displayName }]) => ({
|
|
135
|
+
value: id,
|
|
136
|
+
label: displayName,
|
|
137
|
+
})), 'label');
|
|
138
|
+
export class OpenAIError extends Error {
|
|
139
|
+
status;
|
|
140
|
+
responseJson;
|
|
141
|
+
constructor(status, responseJson) {
|
|
142
|
+
super(`OpenAIError: ${status} ${JSON.stringify(responseJson)}`);
|
|
143
|
+
this.status = status;
|
|
144
|
+
this.responseJson = responseJson;
|
|
145
|
+
this.name = 'OpenAIError';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export async function chatCompletions({ endpoint, auth, signal, headers, timeout, ...rest }) {
|
|
149
|
+
const abortSignal = signal ?? new AbortController().signal;
|
|
150
|
+
const response = await fetch(endpoint, {
|
|
151
|
+
method: 'POST',
|
|
152
|
+
headers: {
|
|
153
|
+
'Content-Type': 'application/json',
|
|
154
|
+
Authorization: `Bearer ${auth.apiKey}`,
|
|
155
|
+
...(auth.organization ? { 'OpenAI-Organization': auth.organization } : {}),
|
|
156
|
+
...headers,
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify(rest),
|
|
159
|
+
signal: abortSignal,
|
|
160
|
+
});
|
|
161
|
+
return response.json();
|
|
162
|
+
}
|
|
163
|
+
export async function* streamChatCompletions({ endpoint, auth, signal, headers, timeout, ...rest }) {
|
|
164
|
+
const abortSignal = signal ?? new AbortController().signal;
|
|
165
|
+
const response = await fetchEventSource(endpoint, {
|
|
166
|
+
method: 'POST',
|
|
167
|
+
headers: {
|
|
168
|
+
'Content-Type': 'application/json',
|
|
169
|
+
Authorization: `Bearer ${auth.apiKey}`,
|
|
170
|
+
...(auth.organization ? { 'OpenAI-Organization': auth.organization } : {}),
|
|
171
|
+
...headers,
|
|
172
|
+
},
|
|
173
|
+
body: JSON.stringify({
|
|
174
|
+
...rest,
|
|
175
|
+
stream: true,
|
|
176
|
+
stream_options: {
|
|
177
|
+
include_usage: true,
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
signal: abortSignal,
|
|
181
|
+
}, timeout ?? DEFAULT_CHAT_NODE_TIMEOUT);
|
|
182
|
+
let hadChunks = false;
|
|
183
|
+
for await (const chunk of response.events()) {
|
|
184
|
+
hadChunks = true;
|
|
185
|
+
if (chunk === '[DONE]' || abortSignal?.aborted) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const data = parseProviderJsonChunk('OpenAI', chunk);
|
|
189
|
+
yield data;
|
|
190
|
+
}
|
|
191
|
+
if (!hadChunks) {
|
|
192
|
+
const responseJson = await response.json();
|
|
193
|
+
throw new OpenAIError(response.status, responseJson);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
export const openAIFilePurposeOptions = [
|
|
197
|
+
{ value: 'fine-tune', label: 'Fine-tuning' },
|
|
198
|
+
{ value: 'fine-tune-results', label: 'Fine-tuning Results' },
|
|
199
|
+
{ value: 'assistants', label: 'Assistants' },
|
|
200
|
+
{ value: 'assistants_output', label: 'Assistants Output' },
|
|
201
|
+
];
|
|
202
|
+
export const openAIFileUploadPurposeOptions = [
|
|
203
|
+
{ value: 'fine-tune', label: 'Fine-tuning' },
|
|
204
|
+
{ value: 'assistants', label: 'Assistants' },
|
|
205
|
+
{ value: 'assistants_output', label: 'Assistants Output' },
|
|
206
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function sanitizeIdentifierPortValue(value) {
|
|
2
|
+
return value.trim().replace(/[^a-zA-Z0-9_]/g, '_');
|
|
3
|
+
}
|
|
4
|
+
export function resolveUniqueValueDerivedPortIds(values) {
|
|
5
|
+
return Array.from(new Set(values.map(sanitizeIdentifierPortValue))).filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
export function buildLegacyOrderedPortIds(length, pattern) {
|
|
8
|
+
return Array.from({ length }, (_, index) => `${pattern.prefix}${index + pattern.startIndex}`);
|
|
9
|
+
}
|
|
10
|
+
export function hasValidStoredOrderedPortIds(length, storedIds) {
|
|
11
|
+
if (!Array.isArray(storedIds) || storedIds.length !== length) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const seenIds = new Set();
|
|
15
|
+
return storedIds.every((id) => {
|
|
16
|
+
if (typeof id !== 'string' || id.length === 0 || seenIds.has(id)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
seenIds.add(id);
|
|
20
|
+
return true;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function resolveStoredOrderedPortIds(length, storedIds, legacyPattern) {
|
|
24
|
+
return hasValidStoredOrderedPortIds(length, storedIds)
|
|
25
|
+
? [...storedIds]
|
|
26
|
+
: buildLegacyOrderedPortIds(length, legacyPattern);
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expectType } from './expectType.js';
|
|
2
|
+
import { WarningsPort } from './symbols.js';
|
|
3
|
+
export function addWarning(outputs, warning) {
|
|
4
|
+
if (!outputs[WarningsPort]) {
|
|
5
|
+
outputs[WarningsPort] = { type: 'string[]', value: [] };
|
|
6
|
+
}
|
|
7
|
+
outputs[WarningsPort].value.push(warning);
|
|
8
|
+
}
|
|
9
|
+
export function getWarnings(outputs) {
|
|
10
|
+
if (!outputs?.[WarningsPort]) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return expectType(outputs[WarningsPort], 'string[]');
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import PQueueImport from 'p-queue';
|
|
2
|
+
/**
|
|
3
|
+
* p-queue v7+ is ESM-only. The CJS bundle (built by bundle.esbuild.ts) aliases
|
|
4
|
+
* `p-queue` to `p-queue-6` (a CJS-compatible older version). That version wraps
|
|
5
|
+
* the default export so that `import PQueue from 'p-queue'` resolves to
|
|
6
|
+
* `{ default: PQueue }` instead of the class directly. This module normalizes
|
|
7
|
+
* the import so that consumers never need a runtime type check.
|
|
8
|
+
*/
|
|
9
|
+
const PQueue = typeof PQueueImport === 'function'
|
|
10
|
+
? PQueueImport
|
|
11
|
+
: PQueueImport.default;
|
|
12
|
+
export default PQueue;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export function createTreeFromPaths(paths, rootPath) {
|
|
2
|
+
// Helper to get all parent paths of a given path
|
|
3
|
+
const getParentPaths = (path) => {
|
|
4
|
+
const parts = path.split('/').filter((p) => p);
|
|
5
|
+
return parts.slice(0, -1).map((_, index) => parts.slice(0, index + 1).join('/'));
|
|
6
|
+
};
|
|
7
|
+
// First, create a unique set of all directories
|
|
8
|
+
const directories = new Set();
|
|
9
|
+
paths.forEach((path) => {
|
|
10
|
+
// Add all parent directories of this path
|
|
11
|
+
const cleanPath = path.replace(/^\/+|\/+$/g, '');
|
|
12
|
+
getParentPaths(cleanPath).forEach((dir) => directories.add(dir));
|
|
13
|
+
// If the path itself ends with /, it's a directory
|
|
14
|
+
if (path.endsWith('/')) {
|
|
15
|
+
directories.add(cleanPath);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
// Create the root node
|
|
19
|
+
const root = {
|
|
20
|
+
path: rootPath,
|
|
21
|
+
name: rootPath || 'root',
|
|
22
|
+
isDirectory: true,
|
|
23
|
+
children: [],
|
|
24
|
+
};
|
|
25
|
+
// Create a map for quick node lookups - use full paths as keys
|
|
26
|
+
const nodeMap = new Map();
|
|
27
|
+
nodeMap.set(rootPath, root);
|
|
28
|
+
// Helper to get or create a node for a path
|
|
29
|
+
const getOrCreateNode = (fullPath) => {
|
|
30
|
+
const cleanPath = fullPath.replace(/^\/+|\/+$/g, '');
|
|
31
|
+
if (nodeMap.has(cleanPath)) {
|
|
32
|
+
return nodeMap.get(cleanPath);
|
|
33
|
+
}
|
|
34
|
+
const parts = cleanPath.split('/').filter((p) => p);
|
|
35
|
+
const name = parts[parts.length - 1] || cleanPath;
|
|
36
|
+
const node = {
|
|
37
|
+
path: name, // Just use the name as the path
|
|
38
|
+
name,
|
|
39
|
+
isDirectory: directories.has(cleanPath),
|
|
40
|
+
children: [],
|
|
41
|
+
};
|
|
42
|
+
nodeMap.set(cleanPath, node); // Still use full path for lookup
|
|
43
|
+
// Important: Create parent-child relationship immediately
|
|
44
|
+
if (parts.length > 1) {
|
|
45
|
+
const parentPath = parts.slice(0, -1).join('/');
|
|
46
|
+
const parent = getOrCreateNode(parentPath);
|
|
47
|
+
if (!parent.children.some((child) => child.name === name)) {
|
|
48
|
+
parent.children.push(node);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (cleanPath && rootPath !== cleanPath) {
|
|
52
|
+
// Top-level node
|
|
53
|
+
if (!root.children.some((child) => child.name === name)) {
|
|
54
|
+
root.children.push(node);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return node;
|
|
58
|
+
};
|
|
59
|
+
// Process all paths to build the tree
|
|
60
|
+
paths
|
|
61
|
+
.filter((path) => path.trim())
|
|
62
|
+
.forEach((path) => {
|
|
63
|
+
const cleanPath = path.replace(/^\/+|\/+$/g, '');
|
|
64
|
+
if (cleanPath) {
|
|
65
|
+
getOrCreateNode(cleanPath);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
// Sort children of all nodes
|
|
69
|
+
const sortNode = (node) => {
|
|
70
|
+
node.children.sort((a, b) => {
|
|
71
|
+
if (a.isDirectory !== b.isDirectory) {
|
|
72
|
+
return a.isDirectory ? -1 : 1;
|
|
73
|
+
}
|
|
74
|
+
return a.name.localeCompare(b.name);
|
|
75
|
+
});
|
|
76
|
+
node.children.forEach(sortNode);
|
|
77
|
+
};
|
|
78
|
+
sortNode(root);
|
|
79
|
+
return root;
|
|
80
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { logRuntimeDebug, summarizeErrorForLog } from './runtimeLogging.js';
|
|
2
|
+
export function parseProviderJsonChunk(provider, chunk) {
|
|
3
|
+
try {
|
|
4
|
+
return JSON.parse(chunk);
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
logRuntimeDebug('Provider stream JSON parse failed', {
|
|
8
|
+
provider,
|
|
9
|
+
chunkLength: chunk.length,
|
|
10
|
+
error: summarizeErrorForLog(error),
|
|
11
|
+
});
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|