@alpic80/rivet-core 1.19.1-aidon.1
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 +176 -0
- package/dist/cjs/bundle.cjs +18915 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +131 -0
- package/dist/esm/api/streaming.js +116 -0
- package/dist/esm/exports.js +32 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/integrations/AudioProvider.js +1 -0
- package/dist/esm/integrations/DatasetProvider.js +92 -0
- package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +65 -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/openai/OpenAIEmbeddingGenerator.js +23 -0
- package/dist/esm/model/DataValue.js +176 -0
- package/dist/esm/model/Dataset.js +1 -0
- package/dist/esm/model/EditorDefinition.js +1 -0
- package/dist/esm/model/GraphProcessor.js +1198 -0
- package/dist/esm/model/NodeBase.js +1 -0
- package/dist/esm/model/NodeBodySpec.js +1 -0
- package/dist/esm/model/NodeDefinition.js +12 -0
- package/dist/esm/model/NodeGraph.js +14 -0
- package/dist/esm/model/NodeImpl.js +49 -0
- package/dist/esm/model/NodeRegistration.js +144 -0
- package/dist/esm/model/Nodes.js +227 -0
- package/dist/esm/model/PluginLoadSpec.js +1 -0
- package/dist/esm/model/ProcessContext.js +1 -0
- package/dist/esm/model/Project.js +2 -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/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 +199 -0
- package/dist/esm/model/nodes/AssemblePromptNode.js +129 -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 +136 -0
- package/dist/esm/model/nodes/ChatNode.js +964 -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 +136 -0
- package/dist/esm/model/nodes/CommentNode.js +69 -0
- package/dist/esm/model/nodes/CompareNode.js +138 -0
- package/dist/esm/model/nodes/ContextNode.js +99 -0
- package/dist/esm/model/nodes/CreateDatasetNode.js +71 -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 +136 -0
- package/dist/esm/model/nodes/DestructureNode.js +86 -0
- package/dist/esm/model/nodes/EvaluateNode.js +141 -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 +128 -0
- package/dist/esm/model/nodes/ExtractRegexNode.js +201 -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/GptFunctionNode.js +169 -0
- package/dist/esm/model/nodes/GraphInputNode.js +130 -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 +257 -0
- package/dist/esm/model/nodes/IfElseNode.js +138 -0
- package/dist/esm/model/nodes/IfNode.js +124 -0
- package/dist/esm/model/nodes/ImageNode.js +107 -0
- package/dist/esm/model/nodes/JoinNode.js +135 -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/MatchNode.js +137 -0
- package/dist/esm/model/nodes/NumberNode.js +86 -0
- package/dist/esm/model/nodes/ObjectNode.js +121 -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 +227 -0
- package/dist/esm/model/nodes/RaceInputsNode.js +86 -0
- package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
- package/dist/esm/model/nodes/RandomNumberNode.js +106 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +165 -0
- package/dist/esm/model/nodes/ReadFileNode.js +114 -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 +100 -0
- package/dist/esm/model/nodes/SplitNode.js +101 -0
- package/dist/esm/model/nodes/SubGraphNode.js +181 -0
- package/dist/esm/model/nodes/TextNode.js +97 -0
- package/dist/esm/model/nodes/ToJsonNode.js +78 -0
- package/dist/esm/model/nodes/ToYamlNode.js +68 -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 +111 -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/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/aidon/index.js +2 -0
- package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +215 -0
- package/dist/esm/plugins/aidon/plugin.js +9 -0
- package/dist/esm/plugins/anthropic/anthropic.js +187 -0
- package/dist/esm/plugins/anthropic/fetchEventSource.js +106 -0
- package/dist/esm/plugins/anthropic/index.js +2 -0
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +652 -0
- package/dist/esm/plugins/anthropic/plugin.js +18 -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 +125 -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 +2 -0
- package/dist/esm/plugins/gentrace/plugin.js +192 -0
- package/dist/esm/plugins/google/google.js +60 -0
- package/dist/esm/plugins/google/index.js +2 -0
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +364 -0
- package/dist/esm/plugins/google/plugin.js +32 -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 +145 -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 +21 -0
- package/dist/esm/recording/ExecutionRecorder.js +177 -0
- package/dist/esm/recording/RecordedEvents.js +1 -0
- package/dist/esm/utils/assertNever.js +3 -0
- package/dist/esm/utils/base64.js +25 -0
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +60 -0
- package/dist/esm/utils/coerceType.js +322 -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/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 +14 -0
- package/dist/esm/utils/inputs.js +16 -0
- package/dist/esm/utils/interpolation.js +6 -0
- package/dist/esm/utils/misc.js +1 -0
- package/dist/esm/utils/newId.js +4 -0
- package/dist/esm/utils/openai.js +219 -0
- package/dist/esm/utils/outputs.js +14 -0
- package/dist/esm/utils/serialization/serialization.js +86 -0
- package/dist/esm/utils/serialization/serializationUtils.js +13 -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 +145 -0
- package/dist/esm/utils/serialization/serialization_v4.js +200 -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/types/api/createProcessor.d.ts +37 -0
- package/dist/types/api/streaming.d.ts +56 -0
- package/dist/types/exports.d.ts +33 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/integrations/AudioProvider.d.ts +4 -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/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
- package/dist/types/model/DataValue.d.ts +138 -0
- package/dist/types/model/Dataset.d.ts +19 -0
- package/dist/types/model/EditorDefinition.d.ts +142 -0
- package/dist/types/model/GraphProcessor.d.ts +192 -0
- package/dist/types/model/NodeBase.d.ts +110 -0
- package/dist/types/model/NodeBodySpec.d.ts +19 -0
- package/dist/types/model/NodeDefinition.d.ts +13 -0
- package/dist/types/model/NodeGraph.d.ts +15 -0
- package/dist/types/model/NodeImpl.d.ts +55 -0
- package/dist/types/model/NodeRegistration.d.ts +24 -0
- package/dist/types/model/Nodes.d.ts +84 -0
- package/dist/types/model/PluginLoadSpec.d.ts +17 -0
- package/dist/types/model/ProcessContext.d.ts +69 -0
- package/dist/types/model/Project.d.ts +17 -0
- package/dist/types/model/RivetPlugin.d.ts +45 -0
- package/dist/types/model/RivetUIContext.d.ts +18 -0
- package/dist/types/model/Settings.d.ts +15 -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 +20 -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/ChatNode.d.ts +77 -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 +21 -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/DatasetNearestNeigborsNode.d.ts +19 -0
- package/dist/types/model/nodes/DelayNode.d.ts +20 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +25 -0
- package/dist/types/model/nodes/DestructureNode.d.ts +18 -0
- package/dist/types/model/nodes/EvaluateNode.d.ts +19 -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 +19 -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/GptFunctionNode.d.ts +25 -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 +27 -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/JoinNode.d.ts +21 -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/MatchNode.d.ts +19 -0
- package/dist/types/model/nodes/NumberNode.d.ts +21 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +18 -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 +23 -0
- package/dist/types/model/nodes/RaceInputsNode.d.ts +17 -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/ReadDirectoryNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadFileNode.d.ts +23 -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 +18 -0
- package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
- package/dist/types/model/nodes/ToYamlNode.d.ts +13 -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 +21 -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/native/BaseDir.d.ts +29 -0
- package/dist/types/native/BrowserNativeApi.d.ts +11 -0
- package/dist/types/native/NativeApi.d.ts +17 -0
- package/dist/types/plugins/aidon/index.d.ts +2 -0
- package/dist/types/plugins/aidon/nodes/ChatAidonNode.d.ts +3 -0
- package/dist/types/plugins/aidon/plugin.d.ts +2 -0
- package/dist/types/plugins/anthropic/anthropic.d.ts +216 -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 +30 -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 +5 -0
- package/dist/types/plugins/google/google.d.ts +60 -0
- package/dist/types/plugins/google/index.d.ts +2 -0
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +27 -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 +20 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +25 -0
- package/dist/types/recording/RecordedEvents.d.ts +100 -0
- package/dist/types/utils/assertNever.d.ts +1 -0
- package/dist/types/utils/base64.d.ts +2 -0
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -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/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 +14 -0
- package/dist/types/utils/inputs.d.ts +3 -0
- package/dist/types/utils/interpolation.d.ts +1 -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 +739 -0
- package/dist/types/utils/outputs.d.ts +3 -0
- package/dist/types/utils/serialization/serialization.d.ts +12 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +6 -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/package.json +97 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import { dedent } from 'ts-dedent';
|
|
7
|
+
export class PopNodeImpl extends NodeImpl {
|
|
8
|
+
static create() {
|
|
9
|
+
const baseNode = {
|
|
10
|
+
type: 'pop',
|
|
11
|
+
title: 'Pop',
|
|
12
|
+
id: nanoid(),
|
|
13
|
+
visualData: {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0,
|
|
16
|
+
width: 200,
|
|
17
|
+
},
|
|
18
|
+
data: {},
|
|
19
|
+
};
|
|
20
|
+
return baseNode;
|
|
21
|
+
}
|
|
22
|
+
getInputDefinitions() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
dataType: 'any[]',
|
|
26
|
+
id: 'array',
|
|
27
|
+
title: 'Array',
|
|
28
|
+
coerced: false,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
getOutputDefinitions() {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
dataType: 'any',
|
|
36
|
+
id: 'lastItem',
|
|
37
|
+
title: this.data.fromFront ? 'First' : 'Last',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
dataType: 'any',
|
|
41
|
+
id: 'restOfArray',
|
|
42
|
+
title: 'Rest',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
getEditors(_context) {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
label: 'Pop from front',
|
|
50
|
+
type: 'toggle',
|
|
51
|
+
dataKey: 'fromFront',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
static getUIData() {
|
|
56
|
+
return {
|
|
57
|
+
infoBoxBody: dedent `
|
|
58
|
+
Pops the last value off the input array and outputs the new array and the popped value.
|
|
59
|
+
|
|
60
|
+
Can also be used to just extract the last value from an array.
|
|
61
|
+
`,
|
|
62
|
+
infoBoxTitle: 'Pop Node',
|
|
63
|
+
contextMenuTitle: 'Pop',
|
|
64
|
+
group: ['Lists'],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getBody(_context) {
|
|
68
|
+
return this.data.fromFront ? 'From front' : 'From back';
|
|
69
|
+
}
|
|
70
|
+
async process(inputs) {
|
|
71
|
+
const inputArray = inputs['array']?.value;
|
|
72
|
+
if (!Array.isArray(inputArray) || inputArray.length === 0) {
|
|
73
|
+
throw new Error('Input array is empty or not an array');
|
|
74
|
+
}
|
|
75
|
+
const lastItem = this.data.fromFront ? inputArray[0] : inputArray[inputArray.length - 1];
|
|
76
|
+
const rest = this.data.fromFront ? inputArray.slice(1) : inputArray.slice(0, inputArray.length - 1);
|
|
77
|
+
return {
|
|
78
|
+
['lastItem']: {
|
|
79
|
+
type: 'any',
|
|
80
|
+
value: lastItem,
|
|
81
|
+
},
|
|
82
|
+
['restOfArray']: {
|
|
83
|
+
type: 'any[]',
|
|
84
|
+
value: rest,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export const popNode = nodeDefinition(PopNodeImpl, 'Pop');
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../../index.js';
|
|
6
|
+
import { mapValues } from 'lodash-es';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import { coerceType, coerceTypeOptional } from '../../utils/coerceType.js';
|
|
9
|
+
import { getInputOrData } from '../../utils/index.js';
|
|
10
|
+
import { interpolate } from '../../utils/interpolation.js';
|
|
11
|
+
import { match } from 'ts-pattern';
|
|
12
|
+
export class PromptNodeImpl extends NodeImpl {
|
|
13
|
+
static create() {
|
|
14
|
+
const chartNode = {
|
|
15
|
+
type: 'prompt',
|
|
16
|
+
title: 'Prompt',
|
|
17
|
+
id: nanoid(),
|
|
18
|
+
visualData: {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
width: 250,
|
|
22
|
+
},
|
|
23
|
+
data: {
|
|
24
|
+
type: 'user',
|
|
25
|
+
useTypeInput: false,
|
|
26
|
+
promptText: '{{input}}',
|
|
27
|
+
enableFunctionCall: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
return chartNode;
|
|
31
|
+
}
|
|
32
|
+
getInputDefinitions() {
|
|
33
|
+
let inputs = [];
|
|
34
|
+
if (this.data.enableFunctionCall) {
|
|
35
|
+
inputs.push({
|
|
36
|
+
id: 'function-call',
|
|
37
|
+
title: 'Function Call',
|
|
38
|
+
dataType: 'object',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (this.data.useTypeInput) {
|
|
42
|
+
inputs.push({
|
|
43
|
+
id: 'type',
|
|
44
|
+
title: 'Type',
|
|
45
|
+
dataType: 'string',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (this.data.useNameInput) {
|
|
49
|
+
inputs.push({
|
|
50
|
+
id: 'name',
|
|
51
|
+
title: 'Name/ID',
|
|
52
|
+
dataType: 'string',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Extract inputs from promptText, everything like {{input}}
|
|
56
|
+
const inputNames = [...new Set(this.chartNode.data.promptText.match(/\{\{([^}]+)\}\}/g))];
|
|
57
|
+
inputs = [
|
|
58
|
+
...inputs,
|
|
59
|
+
...(inputNames?.map((inputName) => {
|
|
60
|
+
return {
|
|
61
|
+
// id and title should not have the {{ and }}
|
|
62
|
+
id: inputName.slice(2, -2),
|
|
63
|
+
title: inputName.slice(2, -2),
|
|
64
|
+
dataType: 'string',
|
|
65
|
+
required: false,
|
|
66
|
+
};
|
|
67
|
+
}) ?? []),
|
|
68
|
+
];
|
|
69
|
+
return inputs;
|
|
70
|
+
}
|
|
71
|
+
getOutputDefinitions() {
|
|
72
|
+
const outputs = [
|
|
73
|
+
{
|
|
74
|
+
id: 'output',
|
|
75
|
+
title: 'Output',
|
|
76
|
+
dataType: 'chat-message',
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
if (this.chartNode.data.computeTokenCount) {
|
|
80
|
+
outputs.push({
|
|
81
|
+
id: 'tokenCount',
|
|
82
|
+
title: 'Token Count',
|
|
83
|
+
dataType: 'number',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return outputs;
|
|
87
|
+
}
|
|
88
|
+
getEditors() {
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
type: 'dropdown',
|
|
92
|
+
label: 'Type',
|
|
93
|
+
options: [
|
|
94
|
+
{ value: 'system', label: 'System' },
|
|
95
|
+
{ value: 'user', label: 'User' },
|
|
96
|
+
{ value: 'assistant', label: 'Assistant' },
|
|
97
|
+
{ value: 'function', label: 'Function' },
|
|
98
|
+
],
|
|
99
|
+
dataKey: 'type',
|
|
100
|
+
useInputToggleDataKey: 'useTypeInput',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'string',
|
|
104
|
+
label: 'Name',
|
|
105
|
+
dataKey: 'name',
|
|
106
|
+
useInputToggleDataKey: 'useNameInput',
|
|
107
|
+
hideIf: (data) => data.type !== 'function',
|
|
108
|
+
helperMessage: 'For OpenAI, this is the tool call ID. Otherwise, it is the name of the function that is outputting the message.',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: 'toggle',
|
|
112
|
+
label: 'Enable Function Call',
|
|
113
|
+
dataKey: 'enableFunctionCall',
|
|
114
|
+
hideIf: (data) => data.type !== 'assistant',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'toggle',
|
|
118
|
+
label: 'Compute Token Count',
|
|
119
|
+
dataKey: 'computeTokenCount',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: 'code',
|
|
123
|
+
label: 'Prompt Text',
|
|
124
|
+
dataKey: 'promptText',
|
|
125
|
+
language: 'prompt-interpolation-markdown',
|
|
126
|
+
theme: 'prompt-interpolation',
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
getBody() {
|
|
131
|
+
return [
|
|
132
|
+
{
|
|
133
|
+
type: 'markdown',
|
|
134
|
+
text: dedent `
|
|
135
|
+
_${typeDisplay[this.data.type]}${this.data.name ? ` (${this.data.name})` : ''}_
|
|
136
|
+
`,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'colorized',
|
|
140
|
+
text: this.data.promptText.split('\n').slice(0, 15).join('\n').trim(),
|
|
141
|
+
language: 'prompt-interpolation-markdown',
|
|
142
|
+
theme: 'prompt-interpolation',
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
static getUIData() {
|
|
147
|
+
return {
|
|
148
|
+
infoBoxBody: dedent `
|
|
149
|
+
Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System) and optionally an attached "name".
|
|
150
|
+
|
|
151
|
+
Also provides the same <span style="color: var(--primary)">{{interpolation}}</span> capabilities as a Text node.
|
|
152
|
+
|
|
153
|
+
Can change one chat message type into another chat message type. For example, changing a User message into a System message.
|
|
154
|
+
`,
|
|
155
|
+
infoBoxTitle: 'Prompt Node',
|
|
156
|
+
contextMenuTitle: 'Prompt',
|
|
157
|
+
group: ['Text'],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async process(inputs, context) {
|
|
161
|
+
const inputMap = mapValues(inputs, (input) => coerceType(input, 'string'));
|
|
162
|
+
const outputValue = interpolate(this.chartNode.data.promptText, inputMap);
|
|
163
|
+
const type = getInputOrData(this.data, inputs, 'type', 'string');
|
|
164
|
+
if (['assistant', 'system', 'user', 'function'].includes(type) === false) {
|
|
165
|
+
throw new Error(`Invalid type: ${type}`);
|
|
166
|
+
}
|
|
167
|
+
const message = match(type)
|
|
168
|
+
.with('system', (type) => ({
|
|
169
|
+
type,
|
|
170
|
+
message: outputValue,
|
|
171
|
+
}))
|
|
172
|
+
.with('user', (type) => ({
|
|
173
|
+
type,
|
|
174
|
+
message: outputValue,
|
|
175
|
+
}))
|
|
176
|
+
.with('assistant', (type) => {
|
|
177
|
+
let functionCall = this.data.enableFunctionCall
|
|
178
|
+
? coerceTypeOptional(inputs['function-call'], 'object')
|
|
179
|
+
: undefined;
|
|
180
|
+
// If no name is specified, ignore the function call
|
|
181
|
+
if (!functionCall?.name || !functionCall?.arguments) {
|
|
182
|
+
functionCall = undefined;
|
|
183
|
+
}
|
|
184
|
+
// GPT is weird - the arguments should be a stringified JSON object https://platform.openai.com/docs/api-reference/chat/create
|
|
185
|
+
if (functionCall?.arguments && typeof functionCall.arguments !== 'string') {
|
|
186
|
+
functionCall.arguments = JSON.stringify(functionCall.arguments);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
type,
|
|
190
|
+
message: outputValue,
|
|
191
|
+
function_call: functionCall,
|
|
192
|
+
function_calls: functionCall ? [functionCall] : undefined,
|
|
193
|
+
};
|
|
194
|
+
})
|
|
195
|
+
.with('function', (type) => ({
|
|
196
|
+
type,
|
|
197
|
+
message: outputValue,
|
|
198
|
+
name: getInputOrData(this.data, inputs, 'name', 'string'),
|
|
199
|
+
}))
|
|
200
|
+
.otherwise(() => {
|
|
201
|
+
throw new Error(`Invalid chat-message type: ${type}`);
|
|
202
|
+
});
|
|
203
|
+
const outputs = {
|
|
204
|
+
['output']: {
|
|
205
|
+
type: 'chat-message',
|
|
206
|
+
value: message,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
if (this.chartNode.data.computeTokenCount) {
|
|
210
|
+
const tokenCount = await context.tokenizer.getTokenCountForMessages([message], undefined, {
|
|
211
|
+
node: this.chartNode,
|
|
212
|
+
});
|
|
213
|
+
outputs['tokenCount'] = {
|
|
214
|
+
type: 'number',
|
|
215
|
+
value: tokenCount,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return outputs;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
export const promptNode = nodeDefinition(PromptNodeImpl, 'Prompt');
|
|
222
|
+
const typeDisplay = {
|
|
223
|
+
assistant: 'Assistant',
|
|
224
|
+
system: 'System',
|
|
225
|
+
user: 'User',
|
|
226
|
+
function: 'Function',
|
|
227
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import {} from '../ProcessContext.js';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import {} from '../../index.js';
|
|
9
|
+
export class RaceInputsNodeImpl extends NodeImpl {
|
|
10
|
+
static create() {
|
|
11
|
+
const chartNode = {
|
|
12
|
+
type: 'raceInputs',
|
|
13
|
+
title: 'Race Inputs',
|
|
14
|
+
id: nanoid(),
|
|
15
|
+
visualData: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: 300,
|
|
19
|
+
},
|
|
20
|
+
data: {},
|
|
21
|
+
};
|
|
22
|
+
return chartNode;
|
|
23
|
+
}
|
|
24
|
+
#getInputPortCount(connections) {
|
|
25
|
+
const inputNodeId = this.chartNode.id;
|
|
26
|
+
const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
27
|
+
let maxInputNumber = 0;
|
|
28
|
+
for (const connection of inputConnections) {
|
|
29
|
+
const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
|
|
30
|
+
if (messageNumber > maxInputNumber) {
|
|
31
|
+
maxInputNumber = messageNumber;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return maxInputNumber + 1;
|
|
35
|
+
}
|
|
36
|
+
getInputDefinitions(connections) {
|
|
37
|
+
const inputs = [];
|
|
38
|
+
const inputCount = this.#getInputPortCount(connections);
|
|
39
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
40
|
+
inputs.push({
|
|
41
|
+
dataType: 'any',
|
|
42
|
+
id: `input${i}`,
|
|
43
|
+
title: `Input ${i}`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return inputs;
|
|
47
|
+
}
|
|
48
|
+
getOutputDefinitions() {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: 'result',
|
|
52
|
+
title: 'Result',
|
|
53
|
+
dataType: 'any',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
getEditors() {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
static getUIData() {
|
|
61
|
+
return {
|
|
62
|
+
infoBoxBody: dedent `
|
|
63
|
+
Takes in multiple inputs and outputs the value of the first one to finish. The other inputs are cancelled.
|
|
64
|
+
`,
|
|
65
|
+
infoBoxTitle: 'Race Inputs Node',
|
|
66
|
+
contextMenuTitle: 'Race Inputs',
|
|
67
|
+
group: ['Logic'],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async process(inputs, context) {
|
|
71
|
+
// GraphProcessor handles most of the racing/aborting logic for us.
|
|
72
|
+
const value = Object.entries(inputs).find(([key, value]) => key.startsWith('input') && value !== undefined && value.type !== 'control-flow-excluded');
|
|
73
|
+
if (!value) {
|
|
74
|
+
return {
|
|
75
|
+
['result']: {
|
|
76
|
+
type: 'control-flow-excluded',
|
|
77
|
+
value: undefined,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
['result']: value[1],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export const raceInputsNode = nodeDefinition(RaceInputsNodeImpl, 'Race Inputs');
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
3
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
|
+
import {} from '../DataValue.js';
|
|
5
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
6
|
+
import {} from '../GraphProcessor.js';
|
|
7
|
+
import { coerceType } from '../../utils/coerceType.js';
|
|
8
|
+
import {} from '../ProcessContext.js';
|
|
9
|
+
import { dedent } from 'ts-dedent';
|
|
10
|
+
import {} from '../EditorDefinition.js';
|
|
11
|
+
import {} from '../NodeBodySpec.js';
|
|
12
|
+
export class RaiseEventNodeImpl extends NodeImpl {
|
|
13
|
+
static create() {
|
|
14
|
+
return {
|
|
15
|
+
id: nanoid(),
|
|
16
|
+
type: 'raiseEvent',
|
|
17
|
+
title: 'Raise Event',
|
|
18
|
+
visualData: { x: 0, y: 0, width: 150 },
|
|
19
|
+
data: {
|
|
20
|
+
eventName: 'toast',
|
|
21
|
+
useEventNameInput: false,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getInputDefinitions() {
|
|
26
|
+
const inputDefinitions = [];
|
|
27
|
+
if (this.chartNode.data.useEventNameInput) {
|
|
28
|
+
inputDefinitions.push({
|
|
29
|
+
id: 'eventName',
|
|
30
|
+
title: 'Event Name',
|
|
31
|
+
dataType: 'string',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
inputDefinitions.push({
|
|
35
|
+
id: 'data',
|
|
36
|
+
title: 'Data',
|
|
37
|
+
dataType: 'any',
|
|
38
|
+
});
|
|
39
|
+
return inputDefinitions;
|
|
40
|
+
}
|
|
41
|
+
getOutputDefinitions() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
id: 'result',
|
|
45
|
+
title: 'Result',
|
|
46
|
+
dataType: 'any',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
getEditors() {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
type: 'string',
|
|
54
|
+
label: 'Event Name',
|
|
55
|
+
dataKey: 'eventName',
|
|
56
|
+
useInputToggleDataKey: 'useEventNameInput',
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
getBody() {
|
|
61
|
+
return this.data.useEventNameInput ? '(Using Input)' : this.data.eventName;
|
|
62
|
+
}
|
|
63
|
+
static getUIData() {
|
|
64
|
+
return {
|
|
65
|
+
infoBoxBody: dedent `
|
|
66
|
+
Raises an event that the host project or a 'Wait For Event' node can listen for.
|
|
67
|
+
`,
|
|
68
|
+
infoBoxTitle: 'Raise Event Node',
|
|
69
|
+
contextMenuTitle: 'Raise Event',
|
|
70
|
+
group: ['Advanced'],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async process(inputs, context) {
|
|
74
|
+
const eventName = this.chartNode.data.useEventNameInput
|
|
75
|
+
? coerceType(inputs['eventName'], 'string')
|
|
76
|
+
: this.chartNode.data.eventName;
|
|
77
|
+
const eventData = inputs['data'];
|
|
78
|
+
context.raiseEvent(eventName, eventData);
|
|
79
|
+
return {
|
|
80
|
+
result: eventData,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const raiseEventNode = nodeDefinition(RaiseEventNodeImpl, 'Raise Event');
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import {} from '../../index.js';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
9
|
+
export class RandomNumberNodeImpl extends NodeImpl {
|
|
10
|
+
static create() {
|
|
11
|
+
const chartNode = {
|
|
12
|
+
type: 'randomNumber',
|
|
13
|
+
title: 'RNG',
|
|
14
|
+
id: nanoid(),
|
|
15
|
+
visualData: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: 150,
|
|
19
|
+
},
|
|
20
|
+
data: {
|
|
21
|
+
min: 0,
|
|
22
|
+
max: 1,
|
|
23
|
+
integers: false,
|
|
24
|
+
maxInclusive: false,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return chartNode;
|
|
28
|
+
}
|
|
29
|
+
getInputDefinitions() {
|
|
30
|
+
const inputs = [];
|
|
31
|
+
if (this.data.useMinInput) {
|
|
32
|
+
inputs.push({
|
|
33
|
+
dataType: 'number',
|
|
34
|
+
id: 'min',
|
|
35
|
+
title: 'Min',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (this.data.useMaxInput) {
|
|
39
|
+
inputs.push({
|
|
40
|
+
dataType: 'number',
|
|
41
|
+
id: 'max',
|
|
42
|
+
title: 'Max',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return inputs;
|
|
46
|
+
}
|
|
47
|
+
getOutputDefinitions() {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
dataType: 'number',
|
|
51
|
+
id: 'value',
|
|
52
|
+
title: 'Value',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
getEditors() {
|
|
57
|
+
return [
|
|
58
|
+
{ type: 'number', label: 'Min', dataKey: 'min', useInputToggleDataKey: 'useMinInput' },
|
|
59
|
+
{ type: 'number', label: 'Max', dataKey: 'max', useInputToggleDataKey: 'useMaxInput' },
|
|
60
|
+
{ type: 'toggle', label: 'Integers', dataKey: 'integers' },
|
|
61
|
+
{ type: 'toggle', label: 'Max Inclusive', dataKey: 'maxInclusive' },
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
getBody() {
|
|
65
|
+
return dedent `
|
|
66
|
+
Min: ${this.data.useMinInput ? '(Input)' : this.data.min ?? 0}
|
|
67
|
+
Max: ${this.data.useMaxInput ? '(Input)' : this.data.max ?? 1}
|
|
68
|
+
${this.data.integers ? 'Integers' : 'Floats'}
|
|
69
|
+
${this.data.maxInclusive ? 'Max Inclusive' : 'Max Exclusive'}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
static getUIData() {
|
|
73
|
+
return {
|
|
74
|
+
infoBoxBody: dedent `
|
|
75
|
+
Outputs a random number between the configured min and max values.
|
|
76
|
+
|
|
77
|
+
Can be configured to output only integers, and whether the max value is inclusive or exclusive.
|
|
78
|
+
`,
|
|
79
|
+
infoBoxTitle: 'RNG Node',
|
|
80
|
+
contextMenuTitle: 'RNG',
|
|
81
|
+
group: ['Numbers'],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async process(inputs) {
|
|
85
|
+
const min = this.data.useMinInput
|
|
86
|
+
? coerceTypeOptional(inputs['min'], 'number') ?? this.data.min ?? 0
|
|
87
|
+
: this.data.min ?? 0;
|
|
88
|
+
let max = this.data.useMaxInput
|
|
89
|
+
? coerceTypeOptional(inputs['max'], 'number') ?? this.data.max ?? 1
|
|
90
|
+
: this.data.max ?? 1;
|
|
91
|
+
if (this.data.integers && this.data.maxInclusive) {
|
|
92
|
+
max += 1;
|
|
93
|
+
}
|
|
94
|
+
let value = Math.random() * (max - min) + min;
|
|
95
|
+
if (this.data.integers) {
|
|
96
|
+
value = Math.floor(value);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
['value']: {
|
|
100
|
+
type: 'number',
|
|
101
|
+
value,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export const randomNumberNode = nodeDefinition(RandomNumberNodeImpl, 'Random Number');
|