@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.
Files changed (381) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +176 -0
  3. package/dist/cjs/bundle.cjs +18915 -0
  4. package/dist/cjs/bundle.cjs.map +7 -0
  5. package/dist/esm/api/createProcessor.js +131 -0
  6. package/dist/esm/api/streaming.js +116 -0
  7. package/dist/esm/exports.js +32 -0
  8. package/dist/esm/index.js +2 -0
  9. package/dist/esm/integrations/AudioProvider.js +1 -0
  10. package/dist/esm/integrations/DatasetProvider.js +92 -0
  11. package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
  12. package/dist/esm/integrations/GptTokenizerTokenizer.js +65 -0
  13. package/dist/esm/integrations/LLMProvider.js +1 -0
  14. package/dist/esm/integrations/Tokenizer.js +1 -0
  15. package/dist/esm/integrations/VectorDatabase.js +1 -0
  16. package/dist/esm/integrations/enableIntegrations.js +3 -0
  17. package/dist/esm/integrations/integrations.js +19 -0
  18. package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +23 -0
  19. package/dist/esm/model/DataValue.js +176 -0
  20. package/dist/esm/model/Dataset.js +1 -0
  21. package/dist/esm/model/EditorDefinition.js +1 -0
  22. package/dist/esm/model/GraphProcessor.js +1198 -0
  23. package/dist/esm/model/NodeBase.js +1 -0
  24. package/dist/esm/model/NodeBodySpec.js +1 -0
  25. package/dist/esm/model/NodeDefinition.js +12 -0
  26. package/dist/esm/model/NodeGraph.js +14 -0
  27. package/dist/esm/model/NodeImpl.js +49 -0
  28. package/dist/esm/model/NodeRegistration.js +144 -0
  29. package/dist/esm/model/Nodes.js +227 -0
  30. package/dist/esm/model/PluginLoadSpec.js +1 -0
  31. package/dist/esm/model/ProcessContext.js +1 -0
  32. package/dist/esm/model/Project.js +2 -0
  33. package/dist/esm/model/RivetPlugin.js +1 -0
  34. package/dist/esm/model/RivetUIContext.js +1 -0
  35. package/dist/esm/model/Settings.js +1 -0
  36. package/dist/esm/model/nodes/AbortGraphNode.js +100 -0
  37. package/dist/esm/model/nodes/AppendToDatasetNode.js +115 -0
  38. package/dist/esm/model/nodes/ArrayNode.js +144 -0
  39. package/dist/esm/model/nodes/AssembleMessageNode.js +199 -0
  40. package/dist/esm/model/nodes/AssemblePromptNode.js +129 -0
  41. package/dist/esm/model/nodes/AudioNode.js +101 -0
  42. package/dist/esm/model/nodes/BooleanNode.js +74 -0
  43. package/dist/esm/model/nodes/CallGraphNode.js +136 -0
  44. package/dist/esm/model/nodes/ChatNode.js +964 -0
  45. package/dist/esm/model/nodes/ChunkNode.js +166 -0
  46. package/dist/esm/model/nodes/CoalesceNode.js +104 -0
  47. package/dist/esm/model/nodes/CodeNode.js +136 -0
  48. package/dist/esm/model/nodes/CommentNode.js +69 -0
  49. package/dist/esm/model/nodes/CompareNode.js +138 -0
  50. package/dist/esm/model/nodes/ContextNode.js +99 -0
  51. package/dist/esm/model/nodes/CreateDatasetNode.js +71 -0
  52. package/dist/esm/model/nodes/DatasetNearestNeigborsNode.js +97 -0
  53. package/dist/esm/model/nodes/DelayNode.js +105 -0
  54. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +136 -0
  55. package/dist/esm/model/nodes/DestructureNode.js +86 -0
  56. package/dist/esm/model/nodes/EvaluateNode.js +141 -0
  57. package/dist/esm/model/nodes/ExternalCallNode.js +162 -0
  58. package/dist/esm/model/nodes/ExtractJsonNode.js +122 -0
  59. package/dist/esm/model/nodes/ExtractMarkdownCodeBlocksNode.js +100 -0
  60. package/dist/esm/model/nodes/ExtractObjectPathNode.js +128 -0
  61. package/dist/esm/model/nodes/ExtractRegexNode.js +201 -0
  62. package/dist/esm/model/nodes/ExtractYamlNode.js +214 -0
  63. package/dist/esm/model/nodes/FilterNode.js +73 -0
  64. package/dist/esm/model/nodes/GetAllDatasetsNode.js +53 -0
  65. package/dist/esm/model/nodes/GetDatasetRowNode.js +99 -0
  66. package/dist/esm/model/nodes/GetEmbeddingNode.js +130 -0
  67. package/dist/esm/model/nodes/GetGlobalNode.js +139 -0
  68. package/dist/esm/model/nodes/GptFunctionNode.js +169 -0
  69. package/dist/esm/model/nodes/GraphInputNode.js +130 -0
  70. package/dist/esm/model/nodes/GraphOutputNode.js +104 -0
  71. package/dist/esm/model/nodes/GraphReferenceNode.js +128 -0
  72. package/dist/esm/model/nodes/HashNode.js +97 -0
  73. package/dist/esm/model/nodes/HttpCallNode.js +257 -0
  74. package/dist/esm/model/nodes/IfElseNode.js +138 -0
  75. package/dist/esm/model/nodes/IfNode.js +124 -0
  76. package/dist/esm/model/nodes/ImageNode.js +107 -0
  77. package/dist/esm/model/nodes/JoinNode.js +135 -0
  78. package/dist/esm/model/nodes/ListGraphsNode.js +61 -0
  79. package/dist/esm/model/nodes/LoadDatasetNode.js +83 -0
  80. package/dist/esm/model/nodes/LoopControllerNode.js +206 -0
  81. package/dist/esm/model/nodes/MatchNode.js +137 -0
  82. package/dist/esm/model/nodes/NumberNode.js +86 -0
  83. package/dist/esm/model/nodes/ObjectNode.js +121 -0
  84. package/dist/esm/model/nodes/PassthroughNode.js +78 -0
  85. package/dist/esm/model/nodes/PlayAudioNode.js +61 -0
  86. package/dist/esm/model/nodes/PopNode.js +89 -0
  87. package/dist/esm/model/nodes/PromptNode.js +227 -0
  88. package/dist/esm/model/nodes/RaceInputsNode.js +86 -0
  89. package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
  90. package/dist/esm/model/nodes/RandomNumberNode.js +106 -0
  91. package/dist/esm/model/nodes/ReadDirectoryNode.js +165 -0
  92. package/dist/esm/model/nodes/ReadFileNode.js +114 -0
  93. package/dist/esm/model/nodes/ReplaceDatasetNode.js +118 -0
  94. package/dist/esm/model/nodes/SetGlobalNode.js +124 -0
  95. package/dist/esm/model/nodes/ShuffleNode.js +64 -0
  96. package/dist/esm/model/nodes/SliceNode.js +100 -0
  97. package/dist/esm/model/nodes/SplitNode.js +101 -0
  98. package/dist/esm/model/nodes/SubGraphNode.js +181 -0
  99. package/dist/esm/model/nodes/TextNode.js +97 -0
  100. package/dist/esm/model/nodes/ToJsonNode.js +78 -0
  101. package/dist/esm/model/nodes/ToYamlNode.js +68 -0
  102. package/dist/esm/model/nodes/TrimChatMessagesNode.js +120 -0
  103. package/dist/esm/model/nodes/URLReferenceNode.js +79 -0
  104. package/dist/esm/model/nodes/UserInputNode.js +111 -0
  105. package/dist/esm/model/nodes/VectorNearestNeighborsNode.js +127 -0
  106. package/dist/esm/model/nodes/VectorStoreNode.js +124 -0
  107. package/dist/esm/model/nodes/WaitForEventNode.js +88 -0
  108. package/dist/esm/native/BaseDir.js +32 -0
  109. package/dist/esm/native/BrowserNativeApi.js +19 -0
  110. package/dist/esm/native/NativeApi.js +1 -0
  111. package/dist/esm/plugins/aidon/index.js +2 -0
  112. package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +215 -0
  113. package/dist/esm/plugins/aidon/plugin.js +9 -0
  114. package/dist/esm/plugins/anthropic/anthropic.js +187 -0
  115. package/dist/esm/plugins/anthropic/fetchEventSource.js +106 -0
  116. package/dist/esm/plugins/anthropic/index.js +2 -0
  117. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +652 -0
  118. package/dist/esm/plugins/anthropic/plugin.js +18 -0
  119. package/dist/esm/plugins/assemblyAi/LemurActionItemsNode.js +75 -0
  120. package/dist/esm/plugins/assemblyAi/LemurQaNode.js +155 -0
  121. package/dist/esm/plugins/assemblyAi/LemurSummaryNode.js +79 -0
  122. package/dist/esm/plugins/assemblyAi/LemurTaskNode.js +82 -0
  123. package/dist/esm/plugins/assemblyAi/TranscribeAudioNode.js +125 -0
  124. package/dist/esm/plugins/assemblyAi/index.js +2 -0
  125. package/dist/esm/plugins/assemblyAi/lemurHelpers.js +114 -0
  126. package/dist/esm/plugins/assemblyAi/plugin.js +32 -0
  127. package/dist/esm/plugins/autoevals/AutoEvalsNode.js +223 -0
  128. package/dist/esm/plugins/autoevals/index.js +2 -0
  129. package/dist/esm/plugins/autoevals/plugin.js +8 -0
  130. package/dist/esm/plugins/gentrace/index.js +2 -0
  131. package/dist/esm/plugins/gentrace/plugin.js +192 -0
  132. package/dist/esm/plugins/google/google.js +60 -0
  133. package/dist/esm/plugins/google/index.js +2 -0
  134. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +364 -0
  135. package/dist/esm/plugins/google/plugin.js +32 -0
  136. package/dist/esm/plugins/huggingface/index.js +2 -0
  137. package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +243 -0
  138. package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +189 -0
  139. package/dist/esm/plugins/huggingface/plugin.js +26 -0
  140. package/dist/esm/plugins/openai/handleOpenaiError.js +17 -0
  141. package/dist/esm/plugins/openai/index.js +2 -0
  142. package/dist/esm/plugins/openai/nodes/AttachAssistantFileNode.js +123 -0
  143. package/dist/esm/plugins/openai/nodes/CreateAssistantNode.js +289 -0
  144. package/dist/esm/plugins/openai/nodes/CreateThreadMessageNode.js +176 -0
  145. package/dist/esm/plugins/openai/nodes/CreateThreadNode.js +157 -0
  146. package/dist/esm/plugins/openai/nodes/DeleteAssistantNode.js +104 -0
  147. package/dist/esm/plugins/openai/nodes/DeleteThreadNode.js +97 -0
  148. package/dist/esm/plugins/openai/nodes/GetAssistantNode.js +118 -0
  149. package/dist/esm/plugins/openai/nodes/GetOpenAIFileNode.js +100 -0
  150. package/dist/esm/plugins/openai/nodes/GetThreadNode.js +108 -0
  151. package/dist/esm/plugins/openai/nodes/ListAssistantsNode.js +202 -0
  152. package/dist/esm/plugins/openai/nodes/ListOpenAIFilesNode.js +94 -0
  153. package/dist/esm/plugins/openai/nodes/ListThreadMessagesNode.js +224 -0
  154. package/dist/esm/plugins/openai/nodes/RunThreadNode.js +630 -0
  155. package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +145 -0
  156. package/dist/esm/plugins/openai/nodes/UploadFileNode.js +121 -0
  157. package/dist/esm/plugins/openai/plugin.js +44 -0
  158. package/dist/esm/plugins/pinecone/PineconeVectorDatabase.js +88 -0
  159. package/dist/esm/plugins/pinecone/index.js +2 -0
  160. package/dist/esm/plugins/pinecone/plugin.js +19 -0
  161. package/dist/esm/plugins.js +21 -0
  162. package/dist/esm/recording/ExecutionRecorder.js +177 -0
  163. package/dist/esm/recording/RecordedEvents.js +1 -0
  164. package/dist/esm/utils/assertNever.js +3 -0
  165. package/dist/esm/utils/base64.js +25 -0
  166. package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +60 -0
  167. package/dist/esm/utils/coerceType.js +322 -0
  168. package/dist/esm/utils/compatibility.js +27 -0
  169. package/dist/esm/utils/copyToClipboard.js +10 -0
  170. package/dist/esm/utils/defaults.js +2 -0
  171. package/dist/esm/utils/errors.js +7 -0
  172. package/dist/esm/utils/expectType.js +34 -0
  173. package/dist/esm/utils/fetchEventSource.js +120 -0
  174. package/dist/esm/utils/genericUtilFunctions.js +25 -0
  175. package/dist/esm/utils/getPluginConfig.js +23 -0
  176. package/dist/esm/utils/handleEscapeCharacters.js +11 -0
  177. package/dist/esm/utils/index.js +14 -0
  178. package/dist/esm/utils/inputs.js +16 -0
  179. package/dist/esm/utils/interpolation.js +6 -0
  180. package/dist/esm/utils/misc.js +1 -0
  181. package/dist/esm/utils/newId.js +4 -0
  182. package/dist/esm/utils/openai.js +219 -0
  183. package/dist/esm/utils/outputs.js +14 -0
  184. package/dist/esm/utils/serialization/serialization.js +86 -0
  185. package/dist/esm/utils/serialization/serializationUtils.js +13 -0
  186. package/dist/esm/utils/serialization/serialization_v1.js +19 -0
  187. package/dist/esm/utils/serialization/serialization_v2.js +24 -0
  188. package/dist/esm/utils/serialization/serialization_v3.js +145 -0
  189. package/dist/esm/utils/serialization/serialization_v4.js +200 -0
  190. package/dist/esm/utils/symbols.js +2 -0
  191. package/dist/esm/utils/time.js +14 -0
  192. package/dist/esm/utils/typeSafety.js +42 -0
  193. package/dist/types/api/createProcessor.d.ts +37 -0
  194. package/dist/types/api/streaming.d.ts +56 -0
  195. package/dist/types/exports.d.ts +33 -0
  196. package/dist/types/index.d.ts +4 -0
  197. package/dist/types/integrations/AudioProvider.d.ts +4 -0
  198. package/dist/types/integrations/DatasetProvider.d.ts +33 -0
  199. package/dist/types/integrations/EmbeddingGenerator.d.ts +3 -0
  200. package/dist/types/integrations/GptTokenizerTokenizer.d.ts +20 -0
  201. package/dist/types/integrations/LLMProvider.d.ts +7 -0
  202. package/dist/types/integrations/Tokenizer.d.ts +11 -0
  203. package/dist/types/integrations/VectorDatabase.d.ts +7 -0
  204. package/dist/types/integrations/enableIntegrations.d.ts +1 -0
  205. package/dist/types/integrations/integrations.d.ts +12 -0
  206. package/dist/types/integrations/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
  207. package/dist/types/model/DataValue.d.ts +138 -0
  208. package/dist/types/model/Dataset.d.ts +19 -0
  209. package/dist/types/model/EditorDefinition.d.ts +142 -0
  210. package/dist/types/model/GraphProcessor.d.ts +192 -0
  211. package/dist/types/model/NodeBase.d.ts +110 -0
  212. package/dist/types/model/NodeBodySpec.d.ts +19 -0
  213. package/dist/types/model/NodeDefinition.d.ts +13 -0
  214. package/dist/types/model/NodeGraph.d.ts +15 -0
  215. package/dist/types/model/NodeImpl.d.ts +55 -0
  216. package/dist/types/model/NodeRegistration.d.ts +24 -0
  217. package/dist/types/model/Nodes.d.ts +84 -0
  218. package/dist/types/model/PluginLoadSpec.d.ts +17 -0
  219. package/dist/types/model/ProcessContext.d.ts +69 -0
  220. package/dist/types/model/Project.d.ts +17 -0
  221. package/dist/types/model/RivetPlugin.d.ts +45 -0
  222. package/dist/types/model/RivetUIContext.d.ts +18 -0
  223. package/dist/types/model/Settings.d.ts +15 -0
  224. package/dist/types/model/nodes/AbortGraphNode.d.ts +22 -0
  225. package/dist/types/model/nodes/AppendToDatasetNode.d.ts +21 -0
  226. package/dist/types/model/nodes/ArrayNode.d.ts +20 -0
  227. package/dist/types/model/nodes/AssembleMessageNode.d.ts +23 -0
  228. package/dist/types/model/nodes/AssemblePromptNode.d.ts +20 -0
  229. package/dist/types/model/nodes/AudioNode.d.ts +20 -0
  230. package/dist/types/model/nodes/BooleanNode.d.ts +19 -0
  231. package/dist/types/model/nodes/CallGraphNode.d.ts +16 -0
  232. package/dist/types/model/nodes/ChatNode.d.ts +77 -0
  233. package/dist/types/model/nodes/ChunkNode.d.ts +22 -0
  234. package/dist/types/model/nodes/CoalesceNode.d.ts +14 -0
  235. package/dist/types/model/nodes/CodeNode.d.ts +21 -0
  236. package/dist/types/model/nodes/CommentNode.d.ts +20 -0
  237. package/dist/types/model/nodes/CompareNode.d.ts +19 -0
  238. package/dist/types/model/nodes/ContextNode.d.ts +24 -0
  239. package/dist/types/model/nodes/CreateDatasetNode.d.ts +13 -0
  240. package/dist/types/model/nodes/DatasetNearestNeigborsNode.d.ts +19 -0
  241. package/dist/types/model/nodes/DelayNode.d.ts +20 -0
  242. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +25 -0
  243. package/dist/types/model/nodes/DestructureNode.d.ts +18 -0
  244. package/dist/types/model/nodes/EvaluateNode.d.ts +19 -0
  245. package/dist/types/model/nodes/ExternalCallNode.d.ts +22 -0
  246. package/dist/types/model/nodes/ExtractJsonNode.d.ts +13 -0
  247. package/dist/types/model/nodes/ExtractMarkdownCodeBlocksNode.d.ts +12 -0
  248. package/dist/types/model/nodes/ExtractObjectPathNode.d.ts +19 -0
  249. package/dist/types/model/nodes/ExtractRegexNode.d.ts +22 -0
  250. package/dist/types/model/nodes/ExtractYamlNode.d.ts +21 -0
  251. package/dist/types/model/nodes/FilterNode.d.ts +13 -0
  252. package/dist/types/model/nodes/GetAllDatasetsNode.d.ts +14 -0
  253. package/dist/types/model/nodes/GetDatasetRowNode.d.ts +19 -0
  254. package/dist/types/model/nodes/GetEmbeddingNode.d.ts +24 -0
  255. package/dist/types/model/nodes/GetGlobalNode.d.ts +29 -0
  256. package/dist/types/model/nodes/GptFunctionNode.d.ts +25 -0
  257. package/dist/types/model/nodes/GraphInputNode.d.ts +24 -0
  258. package/dist/types/model/nodes/GraphOutputNode.d.ts +22 -0
  259. package/dist/types/model/nodes/GraphReferenceNode.d.ts +22 -0
  260. package/dist/types/model/nodes/HashNode.d.ts +17 -0
  261. package/dist/types/model/nodes/HttpCallNode.d.ts +27 -0
  262. package/dist/types/model/nodes/IfElseNode.d.ts +18 -0
  263. package/dist/types/model/nodes/IfNode.d.ts +17 -0
  264. package/dist/types/model/nodes/ImageNode.d.ts +20 -0
  265. package/dist/types/model/nodes/JoinNode.d.ts +21 -0
  266. package/dist/types/model/nodes/ListGraphsNode.d.ts +14 -0
  267. package/dist/types/model/nodes/LoadDatasetNode.d.ts +17 -0
  268. package/dist/types/model/nodes/LoopControllerNode.d.ts +20 -0
  269. package/dist/types/model/nodes/MatchNode.d.ts +19 -0
  270. package/dist/types/model/nodes/NumberNode.d.ts +21 -0
  271. package/dist/types/model/nodes/ObjectNode.d.ts +18 -0
  272. package/dist/types/model/nodes/PassthroughNode.d.ts +14 -0
  273. package/dist/types/model/nodes/PlayAudioNode.d.ts +15 -0
  274. package/dist/types/model/nodes/PopNode.d.ts +19 -0
  275. package/dist/types/model/nodes/PromptNode.d.ts +23 -0
  276. package/dist/types/model/nodes/RaceInputsNode.d.ts +17 -0
  277. package/dist/types/model/nodes/RaiseEventNode.d.ts +22 -0
  278. package/dist/types/model/nodes/RandomNumberNode.d.ts +23 -0
  279. package/dist/types/model/nodes/ReadDirectoryNode.d.ts +30 -0
  280. package/dist/types/model/nodes/ReadFileNode.d.ts +23 -0
  281. package/dist/types/model/nodes/ReplaceDatasetNode.d.ts +21 -0
  282. package/dist/types/model/nodes/SetGlobalNode.d.ts +23 -0
  283. package/dist/types/model/nodes/ShuffleNode.d.ts +12 -0
  284. package/dist/types/model/nodes/SliceNode.d.ts +22 -0
  285. package/dist/types/model/nodes/SplitNode.d.ts +19 -0
  286. package/dist/types/model/nodes/SubGraphNode.d.ts +29 -0
  287. package/dist/types/model/nodes/TextNode.d.ts +18 -0
  288. package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
  289. package/dist/types/model/nodes/ToYamlNode.d.ts +13 -0
  290. package/dist/types/model/nodes/TrimChatMessagesNode.d.ts +20 -0
  291. package/dist/types/model/nodes/URLReferenceNode.d.ts +19 -0
  292. package/dist/types/model/nodes/UserInputNode.d.ts +21 -0
  293. package/dist/types/model/nodes/VectorNearestNeighborsNode.d.ts +24 -0
  294. package/dist/types/model/nodes/VectorStoreNode.d.ts +22 -0
  295. package/dist/types/model/nodes/WaitForEventNode.d.ts +21 -0
  296. package/dist/types/native/BaseDir.d.ts +29 -0
  297. package/dist/types/native/BrowserNativeApi.d.ts +11 -0
  298. package/dist/types/native/NativeApi.d.ts +17 -0
  299. package/dist/types/plugins/aidon/index.d.ts +2 -0
  300. package/dist/types/plugins/aidon/nodes/ChatAidonNode.d.ts +3 -0
  301. package/dist/types/plugins/aidon/plugin.d.ts +2 -0
  302. package/dist/types/plugins/anthropic/anthropic.d.ts +216 -0
  303. package/dist/types/plugins/anthropic/fetchEventSource.d.ts +11 -0
  304. package/dist/types/plugins/anthropic/index.d.ts +2 -0
  305. package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +30 -0
  306. package/dist/types/plugins/anthropic/plugin.d.ts +2 -0
  307. package/dist/types/plugins/assemblyAi/LemurActionItemsNode.d.ts +6 -0
  308. package/dist/types/plugins/assemblyAi/LemurQaNode.d.ts +22 -0
  309. package/dist/types/plugins/assemblyAi/LemurSummaryNode.d.ts +8 -0
  310. package/dist/types/plugins/assemblyAi/LemurTaskNode.d.ts +8 -0
  311. package/dist/types/plugins/assemblyAi/TranscribeAudioNode.d.ts +7 -0
  312. package/dist/types/plugins/assemblyAi/index.d.ts +2 -0
  313. package/dist/types/plugins/assemblyAi/lemurHelpers.d.ts +67 -0
  314. package/dist/types/plugins/assemblyAi/plugin.d.ts +2 -0
  315. package/dist/types/plugins/autoevals/AutoEvalsNode.d.ts +8 -0
  316. package/dist/types/plugins/autoevals/index.d.ts +2 -0
  317. package/dist/types/plugins/autoevals/plugin.d.ts +2 -0
  318. package/dist/types/plugins/gentrace/index.d.ts +2 -0
  319. package/dist/types/plugins/gentrace/plugin.d.ts +5 -0
  320. package/dist/types/plugins/google/google.d.ts +60 -0
  321. package/dist/types/plugins/google/index.d.ts +2 -0
  322. package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +27 -0
  323. package/dist/types/plugins/google/plugin.d.ts +2 -0
  324. package/dist/types/plugins/huggingface/index.d.ts +2 -0
  325. package/dist/types/plugins/huggingface/nodes/ChatHuggingFace.d.ts +24 -0
  326. package/dist/types/plugins/huggingface/nodes/TextToImageHuggingFace.d.ts +20 -0
  327. package/dist/types/plugins/huggingface/plugin.d.ts +2 -0
  328. package/dist/types/plugins/openai/handleOpenaiError.d.ts +1 -0
  329. package/dist/types/plugins/openai/index.d.ts +2 -0
  330. package/dist/types/plugins/openai/nodes/AttachAssistantFileNode.d.ts +10 -0
  331. package/dist/types/plugins/openai/nodes/CreateAssistantNode.d.ts +26 -0
  332. package/dist/types/plugins/openai/nodes/CreateThreadMessageNode.d.ts +15 -0
  333. package/dist/types/plugins/openai/nodes/CreateThreadNode.d.ts +13 -0
  334. package/dist/types/plugins/openai/nodes/DeleteAssistantNode.d.ts +8 -0
  335. package/dist/types/plugins/openai/nodes/DeleteThreadNode.d.ts +8 -0
  336. package/dist/types/plugins/openai/nodes/GetAssistantNode.d.ts +8 -0
  337. package/dist/types/plugins/openai/nodes/GetOpenAIFileNode.d.ts +8 -0
  338. package/dist/types/plugins/openai/nodes/GetThreadNode.d.ts +8 -0
  339. package/dist/types/plugins/openai/nodes/ListAssistantsNode.d.ts +14 -0
  340. package/dist/types/plugins/openai/nodes/ListOpenAIFilesNode.d.ts +8 -0
  341. package/dist/types/plugins/openai/nodes/ListThreadMessagesNode.d.ts +16 -0
  342. package/dist/types/plugins/openai/nodes/RunThreadNode.d.ts +28 -0
  343. package/dist/types/plugins/openai/nodes/ThreadMessageNode.d.ts +14 -0
  344. package/dist/types/plugins/openai/nodes/UploadFileNode.d.ts +7 -0
  345. package/dist/types/plugins/openai/plugin.d.ts +2 -0
  346. package/dist/types/plugins/pinecone/PineconeVectorDatabase.d.ts +9 -0
  347. package/dist/types/plugins/pinecone/index.d.ts +2 -0
  348. package/dist/types/plugins/pinecone/plugin.d.ts +2 -0
  349. package/dist/types/plugins.d.ts +20 -0
  350. package/dist/types/recording/ExecutionRecorder.d.ts +25 -0
  351. package/dist/types/recording/RecordedEvents.d.ts +100 -0
  352. package/dist/types/utils/assertNever.d.ts +1 -0
  353. package/dist/types/utils/base64.d.ts +2 -0
  354. package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -0
  355. package/dist/types/utils/coerceType.d.ts +6 -0
  356. package/dist/types/utils/compatibility.d.ts +3 -0
  357. package/dist/types/utils/copyToClipboard.d.ts +1 -0
  358. package/dist/types/utils/defaults.d.ts +2 -0
  359. package/dist/types/utils/errors.d.ts +2 -0
  360. package/dist/types/utils/expectType.d.ts +3 -0
  361. package/dist/types/utils/fetchEventSource.d.ts +12 -0
  362. package/dist/types/utils/genericUtilFunctions.d.ts +21 -0
  363. package/dist/types/utils/getPluginConfig.d.ts +2 -0
  364. package/dist/types/utils/handleEscapeCharacters.d.ts +2 -0
  365. package/dist/types/utils/index.d.ts +14 -0
  366. package/dist/types/utils/inputs.d.ts +3 -0
  367. package/dist/types/utils/interpolation.d.ts +1 -0
  368. package/dist/types/utils/misc.d.ts +1 -0
  369. package/dist/types/utils/newId.d.ts +1 -0
  370. package/dist/types/utils/openai.d.ts +739 -0
  371. package/dist/types/utils/outputs.d.ts +3 -0
  372. package/dist/types/utils/serialization/serialization.d.ts +12 -0
  373. package/dist/types/utils/serialization/serializationUtils.d.ts +6 -0
  374. package/dist/types/utils/serialization/serialization_v1.d.ts +3 -0
  375. package/dist/types/utils/serialization/serialization_v2.d.ts +3 -0
  376. package/dist/types/utils/serialization/serialization_v3.d.ts +19 -0
  377. package/dist/types/utils/serialization/serialization_v4.d.ts +9 -0
  378. package/dist/types/utils/symbols.d.ts +3 -0
  379. package/dist/types/utils/time.d.ts +22 -0
  380. package/dist/types/utils/typeSafety.d.ts +37 -0
  381. package/package.json +97 -0
@@ -0,0 +1,206 @@
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 { coerceType } from '../../utils/coerceType.js';
7
+ import {} from '../ProcessContext.js';
8
+ import { dedent } from 'ts-dedent';
9
+ import {} from '../../index.js';
10
+ import { entries, values } from '../../utils/typeSafety.js';
11
+ export class LoopControllerNodeImpl extends NodeImpl {
12
+ static create() {
13
+ const chartNode = {
14
+ type: 'loopController',
15
+ title: 'Loop Controller',
16
+ id: nanoid(),
17
+ visualData: {
18
+ x: 0,
19
+ y: 0,
20
+ width: 250,
21
+ },
22
+ data: {
23
+ maxIterations: 100,
24
+ },
25
+ };
26
+ return chartNode;
27
+ }
28
+ getInputDefinitions(connections, nodes) {
29
+ const inputs = [];
30
+ const messageCount = this.#getInputPortCount(connections);
31
+ inputs.push({
32
+ dataType: 'any',
33
+ id: 'continue',
34
+ title: 'Continue',
35
+ });
36
+ let i = 1;
37
+ for (; i <= messageCount + 1; i++) {
38
+ const input = {
39
+ dataType: 'any',
40
+ id: `input${i}`,
41
+ title: `Input ${i}`,
42
+ };
43
+ const inputConnection = connections.find((connection) => connection.inputId === input.id && connection.inputNodeId === this.id);
44
+ if (inputConnection && nodes[inputConnection.outputNodeId]) {
45
+ input.title = nodes[inputConnection.outputNodeId].title;
46
+ }
47
+ const inputDefault = {
48
+ dataType: 'any',
49
+ id: `input${i}Default`,
50
+ title: `Input ${i} Default`,
51
+ };
52
+ const inputDefaultConnection = connections.find((connection) => connection.inputId === inputDefault.id && connection.inputNodeId === this.id);
53
+ if (inputDefaultConnection && nodes[inputDefaultConnection.outputNodeId]) {
54
+ inputDefault.title = `${nodes[inputDefaultConnection.outputNodeId].title} (Default)`;
55
+ }
56
+ inputs.push(input);
57
+ inputs.push(inputDefault);
58
+ }
59
+ return inputs;
60
+ }
61
+ getOutputDefinitions(connections, nodes) {
62
+ const messageCount = this.#getInputPortCount(connections);
63
+ const outputs = [];
64
+ outputs.push({
65
+ dataType: 'any',
66
+ id: 'break',
67
+ title: 'Break',
68
+ });
69
+ outputs.push({
70
+ dataType: 'number',
71
+ id: 'iteration',
72
+ title: 'Iteration',
73
+ });
74
+ for (let i = 1; i <= messageCount; i++) {
75
+ const output = {
76
+ dataType: 'any',
77
+ id: `output${i}`,
78
+ title: `Output ${i}`,
79
+ };
80
+ const inputConnection = connections.find((connection) => connection.inputId === `input${i}` && connection.inputNodeId === this.id);
81
+ if (inputConnection && nodes[inputConnection.outputNodeId]) {
82
+ output.title = `${nodes[inputConnection.outputNodeId].title}?`;
83
+ }
84
+ outputs.push(output);
85
+ }
86
+ return outputs;
87
+ }
88
+ getEditors() {
89
+ return [
90
+ {
91
+ type: 'number',
92
+ label: 'Max Iterations',
93
+ dataKey: 'maxIterations',
94
+ },
95
+ {
96
+ type: 'dropdown',
97
+ options: [
98
+ {
99
+ label: 'Break',
100
+ value: 'break',
101
+ },
102
+ {
103
+ label: 'Error',
104
+ value: 'error',
105
+ },
106
+ ],
107
+ label: 'At Max Iterations',
108
+ dataKey: 'atMaxIterationsAction',
109
+ defaultValue: 'error',
110
+ helperMessage: 'What should happen when the max iterations is reached?',
111
+ },
112
+ ];
113
+ }
114
+ static getUIData() {
115
+ return {
116
+ infoBoxBody: dedent `
117
+ Defines the entry point for a loop. Values from inside the loop should be passed back through the "Input" ports, and their corresponding "Default" values can be specified on the input ports as well.
118
+
119
+ If the "continue" input is falsey, then the "break" output will run.
120
+ `,
121
+ infoBoxTitle: 'Loop Controller Node',
122
+ contextMenuTitle: 'Loop Controller',
123
+ group: ['Logic'],
124
+ };
125
+ }
126
+ #getInputPortCount(connections) {
127
+ const inputNodeId = this.chartNode.id;
128
+ const messageConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
129
+ let maxMessageNumber = 0;
130
+ for (const connection of messageConnections) {
131
+ const messageNumber = parseInt(connection.inputId.replace('input', ''));
132
+ if (messageNumber > maxMessageNumber) {
133
+ maxMessageNumber = messageNumber;
134
+ }
135
+ }
136
+ return maxMessageNumber;
137
+ }
138
+ async process(inputs, context) {
139
+ const output = {};
140
+ let inputCount = 0;
141
+ while (inputs[`input${inputCount + 1}`] || inputs[`input${inputCount + 1}Default`]) {
142
+ inputCount++;
143
+ }
144
+ const defaultInputs = entries(inputs).filter(([key]) => key.endsWith('Default'));
145
+ // If any of the default inputs are control-flow-excluded, then exclude all outputs.
146
+ // Technically, it should be "any node outside of the cycle" but this should be good enough?
147
+ if (defaultInputs.some(([, value]) => value?.type === 'control-flow-excluded')) {
148
+ for (let i = 0; i <= inputCount; i++) {
149
+ output[`output${i}`] = { type: 'control-flow-excluded', value: undefined };
150
+ }
151
+ output['break'] = { type: 'control-flow-excluded', value: undefined };
152
+ return output;
153
+ }
154
+ const iterationCount = context.attachedData.loopInfo?.iterationCount ?? 0;
155
+ output['iteration'] = { type: 'number', value: iterationCount + 1 };
156
+ if (iterationCount >= (this.data.maxIterations ?? 100) && this.data.atMaxIterationsAction !== 'break') {
157
+ throw new Error(`Loop controller exceeded max iterations of ${this.data.maxIterations ?? 100}`);
158
+ }
159
+ // If the continue port is not connected (so undefined), or if it's undefined before it's
160
+ // inside the loop itself (connection has not ran yet), then we should continue by default.
161
+ let continueValue = false;
162
+ if (inputs['continue'] === undefined) {
163
+ continueValue = true;
164
+ }
165
+ else {
166
+ const continueDataValue = inputs['continue'];
167
+ if (continueDataValue.type === 'control-flow-excluded') {
168
+ continueValue = false;
169
+ }
170
+ else {
171
+ continueValue = coerceType(continueDataValue, 'boolean');
172
+ }
173
+ }
174
+ if (iterationCount >= (this.data.maxIterations ?? 100) && this.data.atMaxIterationsAction === 'break') {
175
+ continueValue = false;
176
+ }
177
+ if (continueValue) {
178
+ output['break'] = { type: 'control-flow-excluded', value: 'loop-not-broken' };
179
+ }
180
+ else {
181
+ const inputValues = [];
182
+ for (let i = 1; i <= inputCount; i++) {
183
+ inputValues.push(inputs[`input${i}`]?.value);
184
+ }
185
+ // Break gets an array of all the input values
186
+ output['break'] = { type: 'any[]', value: inputValues };
187
+ }
188
+ for (let i = 1; i <= inputCount; i++) {
189
+ if (continueValue) {
190
+ const inputId = `input${i}`;
191
+ const outputId = `output${i}`;
192
+ if (inputs[inputId]) {
193
+ output[outputId] = inputs[inputId];
194
+ }
195
+ else {
196
+ output[outputId] = inputs[`${inputId}Default`];
197
+ }
198
+ }
199
+ else {
200
+ output[`output${i}`] = { type: 'control-flow-excluded', value: undefined };
201
+ }
202
+ }
203
+ return output;
204
+ }
205
+ }
206
+ export const loopControllerNode = nodeDefinition(LoopControllerNodeImpl, 'Loop Controller');
@@ -0,0 +1,137 @@
1
+ import {} from '../NodeBase.js';
2
+ import { nanoid } from 'nanoid/non-secure';
3
+ import { NodeImpl } from '../NodeImpl.js';
4
+ import { nodeDefinition } from '../NodeDefinition.js';
5
+ import {} from '../DataValue.js';
6
+ import {} from '../../index.js';
7
+ import { dedent } from 'ts-dedent';
8
+ import { coerceType } from '../../utils/coerceType.js';
9
+ export class MatchNodeImpl extends NodeImpl {
10
+ static create() {
11
+ const chartNode = {
12
+ type: 'match',
13
+ title: 'Match',
14
+ id: nanoid(),
15
+ visualData: {
16
+ x: 0,
17
+ y: 0,
18
+ width: 250,
19
+ },
20
+ data: {
21
+ cases: ['YES', 'NO'],
22
+ },
23
+ };
24
+ return chartNode;
25
+ }
26
+ getInputDefinitions() {
27
+ const inputs = [
28
+ {
29
+ id: 'input',
30
+ title: 'Test',
31
+ dataType: 'string',
32
+ required: true,
33
+ description: 'The value that will be tested against each of the cases.',
34
+ },
35
+ {
36
+ id: 'value',
37
+ title: 'Value',
38
+ dataType: 'any',
39
+ description: 'The value passed through to the output port that matches. If unconnected, the test value will be passed through.',
40
+ },
41
+ ];
42
+ return inputs;
43
+ }
44
+ getOutputDefinitions() {
45
+ const outputs = [];
46
+ for (let i = 0; i < this.data.cases.length; i++) {
47
+ outputs.push({
48
+ id: `case${i + 1}`,
49
+ title: this.data.cases[i]?.trim() ? this.data.cases[i] : `Case ${i + 1}`,
50
+ dataType: 'string',
51
+ description: `The 'value' (or 'test' if value is unconnected) passed through if the test value matches this regex: /${this
52
+ .data.cases[i]}/`,
53
+ });
54
+ }
55
+ outputs.push({
56
+ id: 'unmatched',
57
+ title: 'Unmatched',
58
+ dataType: 'string',
59
+ description: 'The value (or test if value is unconnected) passed through if no regexes match.',
60
+ });
61
+ return outputs;
62
+ }
63
+ getBody() {
64
+ return dedent `
65
+ ${this.data.exclusive ? 'First Matching Case' : 'All Matching Cases'}
66
+ ${this.data.cases.length} Cases
67
+ `;
68
+ }
69
+ getEditors() {
70
+ return [
71
+ {
72
+ type: 'toggle',
73
+ dataKey: 'exclusive',
74
+ label: 'Exclusive',
75
+ helperMessage: 'If enabled, only the first matching branch will be ran.',
76
+ },
77
+ {
78
+ type: 'stringList',
79
+ dataKey: 'cases',
80
+ label: 'Cases',
81
+ placeholder: 'Case (regular expression)',
82
+ helperMessage: '(Regular expressions)',
83
+ },
84
+ ];
85
+ }
86
+ static getUIData() {
87
+ return {
88
+ infoBoxBody: dedent `
89
+ Any number of regular expressions can be configured, each corresponding to an output of the node. The output port of the first matching regex will be ran, and all other output ports will not be ran.
90
+ `,
91
+ infoBoxTitle: 'Match Node',
92
+ contextMenuTitle: 'Match',
93
+ group: ['Logic'],
94
+ };
95
+ }
96
+ async process(inputs) {
97
+ const inputString = coerceType(inputs['input'], 'string');
98
+ const value = inputs['value'];
99
+ const outputType = value === undefined ? 'string' : value.type;
100
+ const outputValue = value === undefined ? inputString : value.value;
101
+ const cases = this.data.cases;
102
+ let matched = false;
103
+ const output = {};
104
+ for (let i = 0; i < cases.length; i++) {
105
+ const regExp = new RegExp(cases[i]);
106
+ const match = regExp.test(inputString);
107
+ const canMatch = !this.data.exclusive || !matched;
108
+ if (match && canMatch) {
109
+ matched = true;
110
+ output[`case${i + 1}`] = {
111
+ type: outputType,
112
+ value: outputValue,
113
+ };
114
+ }
115
+ else {
116
+ output[`case${i + 1}`] = {
117
+ type: 'control-flow-excluded',
118
+ value: undefined,
119
+ };
120
+ }
121
+ }
122
+ if (!matched) {
123
+ output['unmatched'] = {
124
+ type: outputType,
125
+ value: outputValue,
126
+ };
127
+ }
128
+ else {
129
+ output['unmatched'] = {
130
+ type: 'control-flow-excluded',
131
+ value: undefined,
132
+ };
133
+ }
134
+ return output;
135
+ }
136
+ }
137
+ export const matchNode = nodeDefinition(MatchNodeImpl, 'Match');
@@ -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 '../../index.js';
7
+ import { dedent } from 'ts-dedent';
8
+ import { coerceTypeOptional } from '../../utils/coerceType.js';
9
+ export class NumberNodeImpl extends NodeImpl {
10
+ static create() {
11
+ const chartNode = {
12
+ type: 'number',
13
+ title: 'Number',
14
+ id: nanoid(),
15
+ visualData: {
16
+ x: 0,
17
+ y: 0,
18
+ width: 200,
19
+ },
20
+ data: {
21
+ value: 0,
22
+ round: false,
23
+ roundTo: 0,
24
+ },
25
+ };
26
+ return chartNode;
27
+ }
28
+ getInputDefinitions() {
29
+ return this.data.useValueInput
30
+ ? [
31
+ {
32
+ dataType: 'any',
33
+ id: 'input',
34
+ title: 'Input',
35
+ },
36
+ ]
37
+ : [];
38
+ }
39
+ getOutputDefinitions() {
40
+ return [
41
+ {
42
+ dataType: 'number',
43
+ id: 'value',
44
+ title: 'Value',
45
+ },
46
+ ];
47
+ }
48
+ getEditors() {
49
+ return [
50
+ { type: 'number', label: 'Value', dataKey: 'value', useInputToggleDataKey: 'useValueInput' },
51
+ { type: 'toggle', label: 'Round', dataKey: 'round' },
52
+ { type: 'number', label: 'Round To', dataKey: 'roundTo' },
53
+ ];
54
+ }
55
+ getBody() {
56
+ return this.data.useValueInput ? `(Input to number)` : (this.data.value ?? 0).toLocaleString();
57
+ }
58
+ static getUIData() {
59
+ return {
60
+ infoBoxBody: dedent `
61
+ Outputs a number constant, or converts an input value into a number.
62
+
63
+ Can be configured to round the number to a certain number of decimal places.
64
+ `,
65
+ infoBoxTitle: 'Number Node',
66
+ contextMenuTitle: 'Number',
67
+ group: ['Numbers'],
68
+ };
69
+ }
70
+ async process(inputs) {
71
+ let value = this.data.useValueInput
72
+ ? coerceTypeOptional(inputs['input'], 'number') ?? this.data.value ?? 0
73
+ : this.data.value ?? 0;
74
+ const { roundTo = 0, round = false } = this.data;
75
+ if (round) {
76
+ value = Math.round(value * Math.pow(10, roundTo)) / Math.pow(10, roundTo);
77
+ }
78
+ return {
79
+ ['value']: {
80
+ type: 'number',
81
+ value,
82
+ },
83
+ };
84
+ }
85
+ }
86
+ export const numberNode = nodeDefinition(NumberNodeImpl, 'Number');
@@ -0,0 +1,121 @@
1
+ import {} from '../NodeBase.js';
2
+ import { nanoid } from 'nanoid/non-secure';
3
+ import { NodeImpl } from '../NodeImpl.js';
4
+ import { nodeDefinition } from '../NodeDefinition.js';
5
+ import {} from '../DataValue.js';
6
+ import { dedent } from 'ts-dedent';
7
+ import {} from '../EditorDefinition.js';
8
+ const DEFAULT_JSON_TEMPLATE = `{
9
+ "key": "{{input}}"
10
+ }`;
11
+ export class ObjectNodeImpl extends NodeImpl {
12
+ static create() {
13
+ const chartNode = {
14
+ type: 'object',
15
+ title: 'Object',
16
+ id: nanoid(),
17
+ visualData: {
18
+ x: 0,
19
+ y: 0,
20
+ width: 200,
21
+ },
22
+ data: {
23
+ jsonTemplate: DEFAULT_JSON_TEMPLATE,
24
+ },
25
+ };
26
+ return chartNode;
27
+ }
28
+ getInputDefinitions(connections) {
29
+ // Extract inputs from text, everything like {{input}}
30
+ const inputNames = [...new Set(this.chartNode.data.jsonTemplate.match(/\{\{([^}]+)\}\}/g))];
31
+ return (inputNames?.map((inputName) => {
32
+ return {
33
+ // id and title should not have the {{ and }}
34
+ id: inputName.slice(2, -2),
35
+ title: inputName.slice(2, -2),
36
+ dataType: 'any',
37
+ required: false,
38
+ };
39
+ }) ?? []);
40
+ }
41
+ getOutputDefinitions() {
42
+ return [
43
+ {
44
+ dataType: ['object', 'object[]'],
45
+ id: 'output',
46
+ title: 'Output',
47
+ },
48
+ ];
49
+ }
50
+ getEditors() {
51
+ return [
52
+ {
53
+ type: 'custom',
54
+ customEditorId: 'ObjectNodeAiAssist',
55
+ label: 'AI Assist',
56
+ },
57
+ {
58
+ type: 'code',
59
+ label: 'JSON Template',
60
+ dataKey: 'jsonTemplate',
61
+ language: 'json',
62
+ theme: 'prompt-interpolation',
63
+ },
64
+ ];
65
+ }
66
+ static getUIData() {
67
+ return {
68
+ infoBoxBody: dedent `
69
+ Creates an object from input values and a JSON template, escaping the input values and inserting them into the template.
70
+
71
+ Use double-quotes around the input values to escape them. String values are automatically escaped.
72
+
73
+ Useful for creating objects from multiple inputs.
74
+ `,
75
+ infoBoxTitle: 'Object Node',
76
+ contextMenuTitle: 'Object',
77
+ group: ['Objects'],
78
+ };
79
+ }
80
+ interpolate(baseString, values) {
81
+ return baseString.replace(/("?)\{\{([^}]+)\}\}("?)/g, (_m, openQuote, key, _closeQuote) => {
82
+ const isQuoted = Boolean(openQuote);
83
+ const value = values[key];
84
+ if (value == null) {
85
+ return 'null';
86
+ }
87
+ if (isQuoted && typeof value === 'string') {
88
+ // Adds double-quotes back.
89
+ return JSON.stringify(value);
90
+ }
91
+ if (isQuoted) {
92
+ // Non-strings require a double-stringify, first to turn them into a string, then to escape that string and add quotes.
93
+ return JSON.stringify(JSON.stringify(value));
94
+ }
95
+ // Otherwise, it was not quoted, so no need to double-stringify
96
+ return JSON.stringify(value);
97
+ });
98
+ }
99
+ async process(inputs) {
100
+ const inputMap = Object.keys(inputs).reduce((acc, key) => {
101
+ acc[key] = inputs[key]?.value;
102
+ return acc;
103
+ }, {});
104
+ const outputValue = JSON.parse(this.interpolate(this.chartNode.data.jsonTemplate, inputMap));
105
+ if (Array.isArray(outputValue)) {
106
+ return {
107
+ output: {
108
+ type: 'object[]',
109
+ value: outputValue,
110
+ },
111
+ };
112
+ }
113
+ return {
114
+ output: {
115
+ type: 'object',
116
+ value: outputValue,
117
+ },
118
+ };
119
+ }
120
+ }
121
+ export const objectNode = nodeDefinition(ObjectNodeImpl, 'Object');
@@ -0,0 +1,78 @@
1
+ import { NodeImpl } from '../NodeImpl.js';
2
+ import { nodeDefinition } from '../NodeDefinition.js';
3
+ import {} from '../NodeBase.js';
4
+ import { nanoid } from 'nanoid/non-secure';
5
+ import {} from '../GraphProcessor.js';
6
+ import { dedent } from 'ts-dedent';
7
+ export class PassthroughNodeImpl extends NodeImpl {
8
+ static create = () => {
9
+ const chartNode = {
10
+ type: 'passthrough',
11
+ title: 'Passthrough',
12
+ id: nanoid(),
13
+ data: {},
14
+ visualData: {
15
+ x: 0,
16
+ y: 0,
17
+ width: 175,
18
+ },
19
+ };
20
+ return chartNode;
21
+ };
22
+ getInputDefinitions(connections) {
23
+ const inputs = [];
24
+ const inputCount = this.#getInputPortCount(connections);
25
+ for (let i = 1; i <= inputCount; i++) {
26
+ inputs.push({
27
+ dataType: 'any',
28
+ id: `input${i}`,
29
+ title: `Input ${i}`,
30
+ });
31
+ }
32
+ return inputs;
33
+ }
34
+ getOutputDefinitions(connections) {
35
+ const outputs = [];
36
+ const inputCount = this.#getInputPortCount(connections);
37
+ for (let i = 1; i <= inputCount - 1; i++) {
38
+ outputs.push({
39
+ dataType: 'any',
40
+ id: `output${i}`,
41
+ title: `Output ${i}`,
42
+ });
43
+ }
44
+ return outputs;
45
+ }
46
+ static getUIData() {
47
+ return {
48
+ infoBoxBody: dedent `
49
+ Simply passes the input value to the output without any modifications.
50
+ `,
51
+ infoBoxTitle: 'Passthrough Node',
52
+ contextMenuTitle: 'Passthrough',
53
+ group: ['Logic'],
54
+ };
55
+ }
56
+ #getInputPortCount(connections) {
57
+ const inputNodeId = this.chartNode.id;
58
+ const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
59
+ let maxInputNumber = 0;
60
+ for (const connection of inputConnections) {
61
+ const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
62
+ if (messageNumber > maxInputNumber) {
63
+ maxInputNumber = messageNumber;
64
+ }
65
+ }
66
+ return maxInputNumber + 1;
67
+ }
68
+ async process(inputData) {
69
+ const inputCount = Object.keys(inputData).filter((key) => key.startsWith('input')).length;
70
+ const outputs = {};
71
+ for (let i = 1; i <= inputCount; i++) {
72
+ const input = inputData[`input${i}`];
73
+ outputs[`output${i}`] = input;
74
+ }
75
+ return outputs;
76
+ }
77
+ }
78
+ export const passthroughNode = nodeDefinition(PassthroughNodeImpl, 'Passthrough');
@@ -0,0 +1,61 @@
1
+ import {} from '../NodeBase.js';
2
+ import { NodeImpl } from '../NodeImpl.js';
3
+ import { nanoid } from 'nanoid/non-secure';
4
+ import {} from '../../index.js';
5
+ import { expectType } from '../../utils/index.js';
6
+ import { nodeDefinition } from '../NodeDefinition.js';
7
+ export class PlayAudioNodeImpl extends NodeImpl {
8
+ static create() {
9
+ return {
10
+ id: nanoid(),
11
+ type: 'playAudio',
12
+ title: 'Play Audio',
13
+ visualData: { x: 0, y: 0, width: 200 },
14
+ data: {},
15
+ };
16
+ }
17
+ getInputDefinitions() {
18
+ const inputDefinitions = [];
19
+ inputDefinitions.push({
20
+ id: 'data',
21
+ title: 'Data',
22
+ dataType: 'audio',
23
+ coerced: false,
24
+ });
25
+ return inputDefinitions;
26
+ }
27
+ getOutputDefinitions() {
28
+ return [
29
+ {
30
+ id: 'data',
31
+ title: 'Audio Data',
32
+ dataType: 'audio',
33
+ },
34
+ ];
35
+ }
36
+ getEditors() {
37
+ return [];
38
+ }
39
+ static getUIData() {
40
+ return {
41
+ contextMenuTitle: 'Play Audio',
42
+ group: 'Input/Output',
43
+ infoBoxTitle: 'Play Audio Node',
44
+ infoBoxBody: 'Plays audio data to the speakers.',
45
+ };
46
+ }
47
+ async process(inputData, context) {
48
+ if (!context.audioProvider) {
49
+ throw new Error('Playing audio is not supported in this context');
50
+ }
51
+ const data = expectType(inputData['data'], 'audio');
52
+ await context.audioProvider.playAudio({ type: 'audio', value: data }, context.signal);
53
+ return {
54
+ ['data']: {
55
+ type: 'audio',
56
+ value: data,
57
+ },
58
+ };
59
+ }
60
+ }
61
+ export const playAudioNode = nodeDefinition(PlayAudioNodeImpl, 'Play Audio');