@nodetool-ai/base-nodes 0.7.0-rc.11

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 (353) hide show
  1. package/dist/index.d.ts +72 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +270 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/lib/audio-wav.d.ts +66 -0
  6. package/dist/lib/audio-wav.d.ts.map +1 -0
  7. package/dist/lib/audio-wav.js +215 -0
  8. package/dist/lib/audio-wav.js.map +1 -0
  9. package/dist/nodes/agents.d.ts +253 -0
  10. package/dist/nodes/agents.d.ts.map +1 -0
  11. package/dist/nodes/agents.js +2784 -0
  12. package/dist/nodes/agents.js.map +1 -0
  13. package/dist/nodes/anthropic.d.ts +26 -0
  14. package/dist/nodes/anthropic.d.ts.map +1 -0
  15. package/dist/nodes/anthropic.js +133 -0
  16. package/dist/nodes/anthropic.js.map +1 -0
  17. package/dist/nodes/apify.d.ts +120 -0
  18. package/dist/nodes/apify.d.ts.map +1 -0
  19. package/dist/nodes/apify.js +618 -0
  20. package/dist/nodes/apify.js.map +1 -0
  21. package/dist/nodes/audio.d.ts +301 -0
  22. package/dist/nodes/audio.d.ts.map +1 -0
  23. package/dist/nodes/audio.js +1274 -0
  24. package/dist/nodes/audio.js.map +1 -0
  25. package/dist/nodes/code-node.d.ts +34 -0
  26. package/dist/nodes/code-node.d.ts.map +1 -0
  27. package/dist/nodes/code-node.js +343 -0
  28. package/dist/nodes/code-node.js.map +1 -0
  29. package/dist/nodes/code.d.ts +301 -0
  30. package/dist/nodes/code.d.ts.map +1 -0
  31. package/dist/nodes/code.js +850 -0
  32. package/dist/nodes/code.js.map +1 -0
  33. package/dist/nodes/compare.d.ts +18 -0
  34. package/dist/nodes/compare.d.ts.map +1 -0
  35. package/dist/nodes/compare.js +122 -0
  36. package/dist/nodes/compare.js.map +1 -0
  37. package/dist/nodes/constant.d.ts +315 -0
  38. package/dist/nodes/constant.d.ts.map +1 -0
  39. package/dist/nodes/constant.js +715 -0
  40. package/dist/nodes/constant.js.map +1 -0
  41. package/dist/nodes/control.d.ts +83 -0
  42. package/dist/nodes/control.d.ts.map +1 -0
  43. package/dist/nodes/control.js +212 -0
  44. package/dist/nodes/control.js.map +1 -0
  45. package/dist/nodes/data.d.ts +369 -0
  46. package/dist/nodes/data.d.ts.map +1 -0
  47. package/dist/nodes/data.js +1590 -0
  48. package/dist/nodes/data.js.map +1 -0
  49. package/dist/nodes/document.d.ts +134 -0
  50. package/dist/nodes/document.d.ts.map +1 -0
  51. package/dist/nodes/document.js +984 -0
  52. package/dist/nodes/document.js.map +1 -0
  53. package/dist/nodes/extended-placeholders.d.ts +6 -0
  54. package/dist/nodes/extended-placeholders.d.ts.map +1 -0
  55. package/dist/nodes/extended-placeholders.js +19 -0
  56. package/dist/nodes/extended-placeholders.js.map +1 -0
  57. package/dist/nodes/gemini.d.ts +109 -0
  58. package/dist/nodes/gemini.d.ts.map +1 -0
  59. package/dist/nodes/gemini.js +861 -0
  60. package/dist/nodes/gemini.js.map +1 -0
  61. package/dist/nodes/generators.d.ts +84 -0
  62. package/dist/nodes/generators.d.ts.map +1 -0
  63. package/dist/nodes/generators.js +937 -0
  64. package/dist/nodes/generators.js.map +1 -0
  65. package/dist/nodes/image.d.ts +232 -0
  66. package/dist/nodes/image.d.ts.map +1 -0
  67. package/dist/nodes/image.js +1395 -0
  68. package/dist/nodes/image.js.map +1 -0
  69. package/dist/nodes/input.d.ts +445 -0
  70. package/dist/nodes/input.d.ts.map +1 -0
  71. package/dist/nodes/input.js +1459 -0
  72. package/dist/nodes/input.js.map +1 -0
  73. package/dist/nodes/kie-dynamic.d.ts +31 -0
  74. package/dist/nodes/kie-dynamic.d.ts.map +1 -0
  75. package/dist/nodes/kie-dynamic.js +270 -0
  76. package/dist/nodes/kie-dynamic.js.map +1 -0
  77. package/dist/nodes/lib-audio-dsp.d.ts +85 -0
  78. package/dist/nodes/lib-audio-dsp.d.ts.map +1 -0
  79. package/dist/nodes/lib-audio-dsp.js +450 -0
  80. package/dist/nodes/lib-audio-dsp.js.map +1 -0
  81. package/dist/nodes/lib-audio-effects.d.ts +116 -0
  82. package/dist/nodes/lib-audio-effects.d.ts.map +1 -0
  83. package/dist/nodes/lib-audio-effects.js +905 -0
  84. package/dist/nodes/lib-audio-effects.js.map +1 -0
  85. package/dist/nodes/lib-browser.d.ts +99 -0
  86. package/dist/nodes/lib-browser.d.ts.map +1 -0
  87. package/dist/nodes/lib-browser.js +692 -0
  88. package/dist/nodes/lib-browser.js.map +1 -0
  89. package/dist/nodes/lib-charts.d.ts +20 -0
  90. package/dist/nodes/lib-charts.d.ts.map +1 -0
  91. package/dist/nodes/lib-charts.js +245 -0
  92. package/dist/nodes/lib-charts.js.map +1 -0
  93. package/dist/nodes/lib-datetime.d.ts +108 -0
  94. package/dist/nodes/lib-datetime.d.ts.map +1 -0
  95. package/dist/nodes/lib-datetime.js +421 -0
  96. package/dist/nodes/lib-datetime.js.map +1 -0
  97. package/dist/nodes/lib-doc-convert.d.ts +19 -0
  98. package/dist/nodes/lib-doc-convert.d.ts.map +1 -0
  99. package/dist/nodes/lib-doc-convert.js +257 -0
  100. package/dist/nodes/lib-doc-convert.js.map +1 -0
  101. package/dist/nodes/lib-doc-transform.d.ts +39 -0
  102. package/dist/nodes/lib-doc-transform.d.ts.map +1 -0
  103. package/dist/nodes/lib-doc-transform.js +335 -0
  104. package/dist/nodes/lib-doc-transform.js.map +1 -0
  105. package/dist/nodes/lib-docx.d.ts +106 -0
  106. package/dist/nodes/lib-docx.d.ts.map +1 -0
  107. package/dist/nodes/lib-docx.js +595 -0
  108. package/dist/nodes/lib-docx.js.map +1 -0
  109. package/dist/nodes/lib-epub.d.ts +55 -0
  110. package/dist/nodes/lib-epub.d.ts.map +1 -0
  111. package/dist/nodes/lib-epub.js +220 -0
  112. package/dist/nodes/lib-epub.js.map +1 -0
  113. package/dist/nodes/lib-excel.d.ts +74 -0
  114. package/dist/nodes/lib-excel.d.ts.map +1 -0
  115. package/dist/nodes/lib-excel.js +448 -0
  116. package/dist/nodes/lib-excel.js.map +1 -0
  117. package/dist/nodes/lib-graphql.d.ts +66 -0
  118. package/dist/nodes/lib-graphql.d.ts.map +1 -0
  119. package/dist/nodes/lib-graphql.js +333 -0
  120. package/dist/nodes/lib-graphql.js.map +1 -0
  121. package/dist/nodes/lib-grid.d.ts +27 -0
  122. package/dist/nodes/lib-grid.d.ts.map +1 -0
  123. package/dist/nodes/lib-grid.js +172 -0
  124. package/dist/nodes/lib-grid.js.map +1 -0
  125. package/dist/nodes/lib-html-parse.d.ts +108 -0
  126. package/dist/nodes/lib-html-parse.d.ts.map +1 -0
  127. package/dist/nodes/lib-html-parse.js +365 -0
  128. package/dist/nodes/lib-html-parse.js.map +1 -0
  129. package/dist/nodes/lib-http.d.ts +98 -0
  130. package/dist/nodes/lib-http.d.ts.map +1 -0
  131. package/dist/nodes/lib-http.js +267 -0
  132. package/dist/nodes/lib-http.js.map +1 -0
  133. package/dist/nodes/lib-image-color-grading.d.ts +3 -0
  134. package/dist/nodes/lib-image-color-grading.d.ts.map +1 -0
  135. package/dist/nodes/lib-image-color-grading.js +1386 -0
  136. package/dist/nodes/lib-image-color-grading.js.map +1 -0
  137. package/dist/nodes/lib-image-draw.d.ts +3 -0
  138. package/dist/nodes/lib-image-draw.d.ts.map +1 -0
  139. package/dist/nodes/lib-image-draw.js +470 -0
  140. package/dist/nodes/lib-image-draw.js.map +1 -0
  141. package/dist/nodes/lib-image-enhance.d.ts +3 -0
  142. package/dist/nodes/lib-image-enhance.d.ts.map +1 -0
  143. package/dist/nodes/lib-image-enhance.js +731 -0
  144. package/dist/nodes/lib-image-enhance.js.map +1 -0
  145. package/dist/nodes/lib-image-filter.d.ts +3 -0
  146. package/dist/nodes/lib-image-filter.d.ts.map +1 -0
  147. package/dist/nodes/lib-image-filter.js +684 -0
  148. package/dist/nodes/lib-image-filter.js.map +1 -0
  149. package/dist/nodes/lib-image-utils.d.ts +24 -0
  150. package/dist/nodes/lib-image-utils.d.ts.map +1 -0
  151. package/dist/nodes/lib-image-utils.js +150 -0
  152. package/dist/nodes/lib-image-utils.js.map +1 -0
  153. package/dist/nodes/lib-mail.d.ts +74 -0
  154. package/dist/nodes/lib-mail.d.ts.map +1 -0
  155. package/dist/nodes/lib-mail.js +452 -0
  156. package/dist/nodes/lib-mail.js.map +1 -0
  157. package/dist/nodes/lib-markdown.d.ts +70 -0
  158. package/dist/nodes/lib-markdown.d.ts.map +1 -0
  159. package/dist/nodes/lib-markdown.js +236 -0
  160. package/dist/nodes/lib-markdown.js.map +1 -0
  161. package/dist/nodes/lib-nlp.d.ts +98 -0
  162. package/dist/nodes/lib-nlp.d.ts.map +1 -0
  163. package/dist/nodes/lib-nlp.js +374 -0
  164. package/dist/nodes/lib-nlp.js.map +1 -0
  165. package/dist/nodes/lib-notion.d.ts +99 -0
  166. package/dist/nodes/lib-notion.d.ts.map +1 -0
  167. package/dist/nodes/lib-notion.js +601 -0
  168. package/dist/nodes/lib-notion.js.map +1 -0
  169. package/dist/nodes/lib-ocr.d.ts +31 -0
  170. package/dist/nodes/lib-ocr.d.ts.map +1 -0
  171. package/dist/nodes/lib-ocr.js +143 -0
  172. package/dist/nodes/lib-ocr.js.map +1 -0
  173. package/dist/nodes/lib-os.d.ts +312 -0
  174. package/dist/nodes/lib-os.d.ts.map +1 -0
  175. package/dist/nodes/lib-os.js +909 -0
  176. package/dist/nodes/lib-os.js.map +1 -0
  177. package/dist/nodes/lib-pdf.d.ts +142 -0
  178. package/dist/nodes/lib-pdf.d.ts.map +1 -0
  179. package/dist/nodes/lib-pdf.js +871 -0
  180. package/dist/nodes/lib-pdf.js.map +1 -0
  181. package/dist/nodes/lib-pptx.d.ts +29 -0
  182. package/dist/nodes/lib-pptx.d.ts.map +1 -0
  183. package/dist/nodes/lib-pptx.js +122 -0
  184. package/dist/nodes/lib-pptx.js.map +1 -0
  185. package/dist/nodes/lib-rss.d.ts +31 -0
  186. package/dist/nodes/lib-rss.d.ts.map +1 -0
  187. package/dist/nodes/lib-rss.js +163 -0
  188. package/dist/nodes/lib-rss.js.map +1 -0
  189. package/dist/nodes/lib-s3.d.ts +112 -0
  190. package/dist/nodes/lib-s3.d.ts.map +1 -0
  191. package/dist/nodes/lib-s3.js +521 -0
  192. package/dist/nodes/lib-s3.js.map +1 -0
  193. package/dist/nodes/lib-secret.d.ts +15 -0
  194. package/dist/nodes/lib-secret.d.ts.map +1 -0
  195. package/dist/nodes/lib-secret.js +42 -0
  196. package/dist/nodes/lib-secret.js.map +1 -0
  197. package/dist/nodes/lib-sqlite.d.ts +102 -0
  198. package/dist/nodes/lib-sqlite.d.ts.map +1 -0
  199. package/dist/nodes/lib-sqlite.js +532 -0
  200. package/dist/nodes/lib-sqlite.js.map +1 -0
  201. package/dist/nodes/lib-supabase.d.ts +86 -0
  202. package/dist/nodes/lib-supabase.d.ts.map +1 -0
  203. package/dist/nodes/lib-supabase.js +425 -0
  204. package/dist/nodes/lib-supabase.js.map +1 -0
  205. package/dist/nodes/lib-svg.d.ts +199 -0
  206. package/dist/nodes/lib-svg.d.ts.map +1 -0
  207. package/dist/nodes/lib-svg.js +1027 -0
  208. package/dist/nodes/lib-svg.js.map +1 -0
  209. package/dist/nodes/lib-tensorflow.d.ts +71 -0
  210. package/dist/nodes/lib-tensorflow.d.ts.map +1 -0
  211. package/dist/nodes/lib-tensorflow.js +351 -0
  212. package/dist/nodes/lib-tensorflow.js.map +1 -0
  213. package/dist/nodes/lib-twilio.d.ts +71 -0
  214. package/dist/nodes/lib-twilio.d.ts.map +1 -0
  215. package/dist/nodes/lib-twilio.js +469 -0
  216. package/dist/nodes/lib-twilio.js.map +1 -0
  217. package/dist/nodes/lib-validate.d.ts +84 -0
  218. package/dist/nodes/lib-validate.d.ts.map +1 -0
  219. package/dist/nodes/lib-validate.js +215 -0
  220. package/dist/nodes/lib-validate.js.map +1 -0
  221. package/dist/nodes/lib-video-download.d.ts +26 -0
  222. package/dist/nodes/lib-video-download.d.ts.map +1 -0
  223. package/dist/nodes/lib-video-download.js +299 -0
  224. package/dist/nodes/lib-video-download.js.map +1 -0
  225. package/dist/nodes/messaging.d.ts +88 -0
  226. package/dist/nodes/messaging.d.ts.map +1 -0
  227. package/dist/nodes/messaging.js +418 -0
  228. package/dist/nodes/messaging.js.map +1 -0
  229. package/dist/nodes/mistral.d.ts +83 -0
  230. package/dist/nodes/mistral.d.ts.map +1 -0
  231. package/dist/nodes/mistral.js +450 -0
  232. package/dist/nodes/mistral.js.map +1 -0
  233. package/dist/nodes/model3d/analysis.d.ts +13 -0
  234. package/dist/nodes/model3d/analysis.d.ts.map +1 -0
  235. package/dist/nodes/model3d/analysis.js +36 -0
  236. package/dist/nodes/model3d/analysis.js.map +1 -0
  237. package/dist/nodes/model3d/base.d.ts +11 -0
  238. package/dist/nodes/model3d/base.d.ts.map +1 -0
  239. package/dist/nodes/model3d/base.js +20 -0
  240. package/dist/nodes/model3d/base.js.map +1 -0
  241. package/dist/nodes/model3d/boolean-ops.d.ts +2 -0
  242. package/dist/nodes/model3d/boolean-ops.d.ts.map +1 -0
  243. package/dist/nodes/model3d/boolean-ops.js +172 -0
  244. package/dist/nodes/model3d/boolean-ops.js.map +1 -0
  245. package/dist/nodes/model3d/cleanup.d.ts +47 -0
  246. package/dist/nodes/model3d/cleanup.d.ts.map +1 -0
  247. package/dist/nodes/model3d/cleanup.js +136 -0
  248. package/dist/nodes/model3d/cleanup.js.map +1 -0
  249. package/dist/nodes/model3d/convert.d.ts +14 -0
  250. package/dist/nodes/model3d/convert.d.ts.map +1 -0
  251. package/dist/nodes/model3d/convert.js +64 -0
  252. package/dist/nodes/model3d/convert.js.map +1 -0
  253. package/dist/nodes/model3d/defaults.d.ts +34 -0
  254. package/dist/nodes/model3d/defaults.d.ts.map +1 -0
  255. package/dist/nodes/model3d/defaults.js +28 -0
  256. package/dist/nodes/model3d/defaults.js.map +1 -0
  257. package/dist/nodes/model3d/document-ops.d.ts +4 -0
  258. package/dist/nodes/model3d/document-ops.d.ts.map +1 -0
  259. package/dist/nodes/model3d/document-ops.js +40 -0
  260. package/dist/nodes/model3d/document-ops.js.map +1 -0
  261. package/dist/nodes/model3d/generation.d.ts +39 -0
  262. package/dist/nodes/model3d/generation.d.ts.map +1 -0
  263. package/dist/nodes/model3d/generation.js +179 -0
  264. package/dist/nodes/model3d/generation.js.map +1 -0
  265. package/dist/nodes/model3d/glb.d.ts +29 -0
  266. package/dist/nodes/model3d/glb.d.ts.map +1 -0
  267. package/dist/nodes/model3d/glb.js +255 -0
  268. package/dist/nodes/model3d/glb.js.map +1 -0
  269. package/dist/nodes/model3d/index.d.ts +20 -0
  270. package/dist/nodes/model3d/index.d.ts.map +1 -0
  271. package/dist/nodes/model3d/index.js +38 -0
  272. package/dist/nodes/model3d/index.js.map +1 -0
  273. package/dist/nodes/model3d/io.d.ts +38 -0
  274. package/dist/nodes/model3d/io.d.ts.map +1 -0
  275. package/dist/nodes/model3d/io.js +162 -0
  276. package/dist/nodes/model3d/io.js.map +1 -0
  277. package/dist/nodes/model3d/mesh-ops.d.ts +40 -0
  278. package/dist/nodes/model3d/mesh-ops.d.ts.map +1 -0
  279. package/dist/nodes/model3d/mesh-ops.js +775 -0
  280. package/dist/nodes/model3d/mesh-ops.js.map +1 -0
  281. package/dist/nodes/model3d/nodes.d.ts +2 -0
  282. package/dist/nodes/model3d/nodes.d.ts.map +1 -0
  283. package/dist/nodes/model3d/nodes.js +2 -0
  284. package/dist/nodes/model3d/nodes.js.map +1 -0
  285. package/dist/nodes/model3d/ops.d.ts +37 -0
  286. package/dist/nodes/model3d/ops.d.ts.map +1 -0
  287. package/dist/nodes/model3d/ops.js +137 -0
  288. package/dist/nodes/model3d/ops.js.map +1 -0
  289. package/dist/nodes/model3d/transforms.d.ts +49 -0
  290. package/dist/nodes/model3d/transforms.d.ts.map +1 -0
  291. package/dist/nodes/model3d/transforms.js +142 -0
  292. package/dist/nodes/model3d/transforms.js.map +1 -0
  293. package/dist/nodes/model3d/types.d.ts +81 -0
  294. package/dist/nodes/model3d/types.d.ts.map +1 -0
  295. package/dist/nodes/model3d/types.js +2 -0
  296. package/dist/nodes/model3d/types.js.map +1 -0
  297. package/dist/nodes/model3d/utils.d.ts +34 -0
  298. package/dist/nodes/model3d/utils.d.ts.map +1 -0
  299. package/dist/nodes/model3d/utils.js +185 -0
  300. package/dist/nodes/model3d/utils.js.map +1 -0
  301. package/dist/nodes/model3d.d.ts +2 -0
  302. package/dist/nodes/model3d.d.ts.map +1 -0
  303. package/dist/nodes/model3d.js +2 -0
  304. package/dist/nodes/model3d.js.map +1 -0
  305. package/dist/nodes/openai.d.ts +172 -0
  306. package/dist/nodes/openai.d.ts.map +1 -0
  307. package/dist/nodes/openai.js +1294 -0
  308. package/dist/nodes/openai.js.map +1 -0
  309. package/dist/nodes/output.d.ts +29 -0
  310. package/dist/nodes/output.d.ts.map +1 -0
  311. package/dist/nodes/output.js +87 -0
  312. package/dist/nodes/output.js.map +1 -0
  313. package/dist/nodes/sandbox.d.ts +67 -0
  314. package/dist/nodes/sandbox.d.ts.map +1 -0
  315. package/dist/nodes/sandbox.js +681 -0
  316. package/dist/nodes/sandbox.js.map +1 -0
  317. package/dist/nodes/search.d.ts +117 -0
  318. package/dist/nodes/search.d.ts.map +1 -0
  319. package/dist/nodes/search.js +607 -0
  320. package/dist/nodes/search.js.map +1 -0
  321. package/dist/nodes/team.d.ts +74 -0
  322. package/dist/nodes/team.d.ts.map +1 -0
  323. package/dist/nodes/team.js +304 -0
  324. package/dist/nodes/team.js.map +1 -0
  325. package/dist/nodes/text-extra.d.ts +633 -0
  326. package/dist/nodes/text-extra.d.ts.map +1 -0
  327. package/dist/nodes/text-extra.js +2226 -0
  328. package/dist/nodes/text-extra.js.map +1 -0
  329. package/dist/nodes/tool-agents.d.ts +334 -0
  330. package/dist/nodes/tool-agents.d.ts.map +1 -0
  331. package/dist/nodes/tool-agents.js +1861 -0
  332. package/dist/nodes/tool-agents.js.map +1 -0
  333. package/dist/nodes/triggers.d.ts +107 -0
  334. package/dist/nodes/triggers.d.ts.map +1 -0
  335. package/dist/nodes/triggers.js +706 -0
  336. package/dist/nodes/triggers.js.map +1 -0
  337. package/dist/nodes/vector.d.ts +168 -0
  338. package/dist/nodes/vector.d.ts.map +1 -0
  339. package/dist/nodes/vector.js +1121 -0
  340. package/dist/nodes/vector.js.map +1 -0
  341. package/dist/nodes/video.d.ts +387 -0
  342. package/dist/nodes/video.d.ts.map +1 -0
  343. package/dist/nodes/video.js +2361 -0
  344. package/dist/nodes/video.js.map +1 -0
  345. package/dist/nodes/workflow.d.ts +24 -0
  346. package/dist/nodes/workflow.d.ts.map +1 -0
  347. package/dist/nodes/workflow.js +146 -0
  348. package/dist/nodes/workflow.js.map +1 -0
  349. package/dist/nodes/workspace.d.ts +203 -0
  350. package/dist/nodes/workspace.d.ts.map +1 -0
  351. package/dist/nodes/workspace.js +795 -0
  352. package/dist/nodes/workspace.js.map +1 -0
  353. package/package.json +103 -0
@@ -0,0 +1,937 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
+ import { isChunkItem, isToolCallItem, streamProviderMessages, toProviderTools } from "./agents.js";
9
+ function asText(value) {
10
+ if (typeof value === "string")
11
+ return value;
12
+ if (typeof value === "number" || typeof value === "boolean")
13
+ return String(value);
14
+ if (!value)
15
+ return "";
16
+ return JSON.stringify(value);
17
+ }
18
+ function parseRequestedCount(prompt, fallback) {
19
+ const m = prompt.match(/\b(\d{1,3})\b/);
20
+ if (!m)
21
+ return fallback;
22
+ const n = Number(m[1]);
23
+ if (!Number.isFinite(n))
24
+ return fallback;
25
+ return Math.max(1, Math.min(200, Math.floor(n)));
26
+ }
27
+ function parseColumns(input) {
28
+ return parseColumnSpecs(input).map((column) => column.name);
29
+ }
30
+ function parseColumnSpecs(input) {
31
+ if (Array.isArray(input)) {
32
+ return input
33
+ .map((c) => {
34
+ if (c && typeof c === "object") {
35
+ const record = c;
36
+ const name = typeof record.name === "string"
37
+ ? record.name
38
+ : String(record.name ?? "");
39
+ const dataType = typeof record.data_type === "string"
40
+ ? record.data_type
41
+ : typeof record.type === "string"
42
+ ? record.type
43
+ : undefined;
44
+ return { name, data_type: dataType };
45
+ }
46
+ return { name: String(c) };
47
+ })
48
+ .filter((c) => c.name.length > 0);
49
+ }
50
+ if (input && typeof input === "object") {
51
+ const columns = input.columns;
52
+ if (Array.isArray(columns))
53
+ return parseColumnSpecs(columns);
54
+ }
55
+ return [];
56
+ }
57
+ function makeRows(columns, count, seedText) {
58
+ const names = columns.length > 0 ? columns : ["value"];
59
+ const rows = [];
60
+ for (let i = 0; i < count; i += 1) {
61
+ const row = {};
62
+ for (const col of names) {
63
+ const lower = col.toLowerCase();
64
+ if (lower.includes("id"))
65
+ row[col] = i + 1;
66
+ else if (lower.includes("name"))
67
+ row[col] = `${seedText || "item"}_${i + 1}`;
68
+ else if (lower.includes("date"))
69
+ row[col] = new Date(Date.now() + i * 86_400_000).toISOString();
70
+ else if (lower.includes("price") ||
71
+ lower.includes("amount") ||
72
+ lower.includes("score")) {
73
+ row[col] = Number((10 + i * 1.5).toFixed(2));
74
+ }
75
+ else if (lower.includes("active") || lower.startsWith("is_")) {
76
+ row[col] = i % 2 === 0;
77
+ }
78
+ else
79
+ row[col] = `${seedText || "value"}_${i + 1}`;
80
+ }
81
+ rows.push(row);
82
+ }
83
+ return rows;
84
+ }
85
+ function buildSchemaFromDynamicOutputs(outputs) {
86
+ if (!outputs || typeof outputs !== "object" || Array.isArray(outputs))
87
+ return null;
88
+ const properties = {};
89
+ const required = [];
90
+ for (const [name, spec] of Object.entries(outputs)) {
91
+ required.push(name);
92
+ const value = spec && typeof spec === "object" ? spec : {};
93
+ const declared = typeof value.type === "string" ? value.type.toLowerCase() : "str";
94
+ let type = "string";
95
+ if (["int", "integer"].includes(declared))
96
+ type = "integer";
97
+ else if (["float", "number"].includes(declared))
98
+ type = "number";
99
+ else if (["bool", "boolean"].includes(declared))
100
+ type = "boolean";
101
+ else if (["list", "array"].includes(declared))
102
+ type = "array";
103
+ else if (["dict", "object"].includes(declared))
104
+ type = "object";
105
+ properties[name] = { type };
106
+ }
107
+ if (required.length === 0)
108
+ return null;
109
+ return { type: "object", additionalProperties: false, required, properties };
110
+ }
111
+ function normalizeBinaryRef(value) {
112
+ if (!value || typeof value !== "object")
113
+ return null;
114
+ const record = value;
115
+ const out = {};
116
+ if (typeof record.uri === "string" && record.uri)
117
+ out.uri = record.uri;
118
+ if (record.data instanceof Uint8Array || typeof record.data === "string")
119
+ out.data = record.data;
120
+ if (typeof record.mimeType === "string" && record.mimeType)
121
+ out.mimeType = record.mimeType;
122
+ if (typeof record.mime_type === "string" && record.mime_type)
123
+ out.mimeType = record.mime_type;
124
+ return out.uri || out.data ? out : null;
125
+ }
126
+ function buildMessageContent(text, image, audio) {
127
+ const imageRef = normalizeBinaryRef(image);
128
+ const audioRef = normalizeBinaryRef(audio);
129
+ if (!imageRef && !audioRef)
130
+ return text;
131
+ const parts = [{ type: "text", text }];
132
+ if (imageRef)
133
+ parts.push({ type: "image", image: imageRef });
134
+ if (audioRef)
135
+ parts.push({ type: "audio", audio: audioRef });
136
+ return parts;
137
+ }
138
+ function getModelConfig(props) {
139
+ const model = (props.model ?? {}) ?? {};
140
+ return {
141
+ providerId: typeof model.provider === "string" ? model.provider : "",
142
+ modelId: typeof model.id === "string" ? model.id : ""
143
+ };
144
+ }
145
+ function hasProviderSupport(context, providerId, modelId) {
146
+ return (!!context &&
147
+ typeof context.runProviderPrediction === "function" &&
148
+ typeof context.streamProviderPrediction === "function" &&
149
+ !!providerId &&
150
+ !!modelId);
151
+ }
152
+ const LIST_GENERATOR_SYSTEM_PROMPT = "You generate a list by calling the `add_item` tool exactly once per item. " +
153
+ "Each call submits a single item as a short string. " +
154
+ "Do not output prose, explanations, or markdown — only emit tool calls. " +
155
+ "When the list is complete, stop without calling the tool again.";
156
+ function makeAddItemTool() {
157
+ return {
158
+ name: "add_item",
159
+ description: "Add one item to the output list. Call this once per item in the list.",
160
+ inputSchema: {
161
+ type: "object",
162
+ additionalProperties: false,
163
+ required: ["item"],
164
+ properties: {
165
+ item: {
166
+ type: "string",
167
+ description: "The list item content (a single string)."
168
+ }
169
+ }
170
+ },
171
+ process: async (_ctx, params) => {
172
+ const item = asText(params?.item ?? "");
173
+ return { ok: true, item };
174
+ }
175
+ };
176
+ }
177
+ async function* streamListItemsViaToolCalls(context, providerId, modelId, prompt, maxTokens) {
178
+ const provider = await context.getProvider(providerId);
179
+ const tool = makeAddItemTool();
180
+ const providerTools = toProviderTools([tool]);
181
+ const messages = [
182
+ { role: "system", content: LIST_GENERATOR_SYSTEM_PROMPT },
183
+ { role: "user", content: prompt }
184
+ ];
185
+ for await (const item of streamProviderMessages(provider, {
186
+ messages,
187
+ model: modelId,
188
+ tools: providerTools,
189
+ maxTokens
190
+ })) {
191
+ if (isToolCallItem(item) && item.name === "add_item") {
192
+ const text = asText(item.args?.item ?? "").trim();
193
+ if (text)
194
+ yield text;
195
+ }
196
+ else if (isChunkItem(item)) {
197
+ // Ignore narrative text — items only come via tool calls.
198
+ }
199
+ }
200
+ }
201
+ function dataframeFromRows(rows, columnsInput) {
202
+ const names = rows.length > 0
203
+ ? Object.keys(rows[0])
204
+ : parseColumnSpecs(columnsInput).map((s) => s.name);
205
+ return {
206
+ rows,
207
+ columns: names.map((name) => ({ name })),
208
+ data: rows.map((row) => names.map((name) => row[name] ?? null))
209
+ };
210
+ }
211
+ function parseCsv(text, specs) {
212
+ const lines = text
213
+ .split(/\r?\n/)
214
+ .map((l) => l.trim())
215
+ .filter((l) => l.length > 0 && !l.startsWith("```"));
216
+ if (lines.length < 2)
217
+ return [];
218
+ const header = lines[0].split(",").map((h) => h.trim().replace(/^"|"$/g, ""));
219
+ return lines.slice(1).map((line) => {
220
+ const cells = line.match(/(".*?"|[^,]+|(?<=,)(?=,)|(?<=,)$|^(?=,))/g) ??
221
+ line.split(",");
222
+ const row = {};
223
+ header.forEach((name, i) => {
224
+ const raw = (cells[i] ?? "").trim().replace(/^"|"$/g, "");
225
+ const spec = specs.find((s) => s.name === name);
226
+ const kind = (spec?.data_type ?? "").toLowerCase();
227
+ if (kind === "int" || kind === "integer") {
228
+ const n = Number.parseInt(raw, 10);
229
+ row[name] = Number.isFinite(n) ? n : raw;
230
+ }
231
+ else if (kind === "float" || kind === "number") {
232
+ const n = Number.parseFloat(raw);
233
+ row[name] = Number.isFinite(n) ? n : raw;
234
+ }
235
+ else {
236
+ row[name] = raw;
237
+ }
238
+ });
239
+ return row;
240
+ });
241
+ }
242
+ async function generateDataframeFromCsv(context, providerId, modelId, prompt, columnsInput, count, maxTokens) {
243
+ const specs = parseColumnSpecs(columnsInput);
244
+ const columnHint = specs.length > 0
245
+ ? `Use exactly these columns: ${specs.map((s) => s.name).join(", ")}.`
246
+ : "Choose appropriate columns for the data.";
247
+ const systemPrompt = `You are a data generator. Return ONLY a CSV with a header row and exactly ${count} data rows. No explanation, no markdown fences, no extra text. ${columnHint}`;
248
+ const result = await context.runProviderPrediction({
249
+ provider: providerId,
250
+ capability: "generate_message",
251
+ model: modelId,
252
+ params: {
253
+ model: modelId,
254
+ messages: [
255
+ { role: "system", content: systemPrompt },
256
+ { role: "user", content: prompt }
257
+ ],
258
+ max_tokens: maxTokens
259
+ }
260
+ });
261
+ const content = asText(result.content ?? result);
262
+ return parseCsv(content, specs);
263
+ }
264
+ export class StructuredOutputGeneratorNode extends BaseNode {
265
+ static nodeType = "nodetool.generators.StructuredOutputGenerator";
266
+ static title = "Structured Output Generator";
267
+ static description = "Generate structured JSON objects from instructions using LLM providers.\n data-generation, structured-data, json, synthesis\n\n Specialized for creating structured information:\n - Generating JSON that follows dynamic schemas\n - Fabricating records from requirements and guidance\n - Simulating sample data for downstream workflows\n - Producing consistent structured outputs for testing";
268
+ static basicFields = ["instructions", "context", "model"];
269
+ static supportsDynamicOutputs = true;
270
+ async process(context) {
271
+ const { providerId, modelId } = getModelConfig(this.serialize());
272
+ const schema = buildSchemaFromDynamicOutputs(this._dynamic_outputs);
273
+ if (schema && hasProviderSupport(context, providerId, modelId)) {
274
+ const instructions = asText(this.instructions ?? this.instructions ?? "");
275
+ const extraContext = asText(this.context ?? this.context ?? "");
276
+ const systemPrompt = asText(this.system_prompt ?? "");
277
+ const userText = [instructions, extraContext]
278
+ .filter(Boolean)
279
+ .join("\n\n");
280
+ const messages = [];
281
+ if (systemPrompt) {
282
+ messages.push({ role: "system", content: systemPrompt });
283
+ }
284
+ messages.push({
285
+ role: "user",
286
+ content: buildMessageContent(userText, this.image, this.audio)
287
+ });
288
+ const result = await context.runProviderPrediction({
289
+ provider: providerId,
290
+ capability: "generate_message",
291
+ model: modelId,
292
+ params: {
293
+ model: modelId,
294
+ messages,
295
+ response_format: {
296
+ type: "json_schema",
297
+ json_schema: {
298
+ name: "structured_output",
299
+ schema
300
+ }
301
+ }
302
+ }
303
+ });
304
+ if (result &&
305
+ typeof result === "object" &&
306
+ "content" in result) {
307
+ const content = asText(result.content ?? "");
308
+ try {
309
+ return JSON.parse(content);
310
+ }
311
+ catch {
312
+ return { output: content };
313
+ }
314
+ }
315
+ }
316
+ if (schema && typeof schema === "object" && !Array.isArray(schema)) {
317
+ const props = schema.properties ?? {};
318
+ const out = {};
319
+ for (const key of Object.keys(props)) {
320
+ const spec = props[key];
321
+ if (spec?.type === "number" || spec?.type === "integer")
322
+ out[key] = 0;
323
+ else if (spec?.type === "boolean")
324
+ out[key] = false;
325
+ else if (spec?.type === "array")
326
+ out[key] = [];
327
+ else if (spec?.type === "object")
328
+ out[key] = {};
329
+ else
330
+ out[key] = "";
331
+ }
332
+ return out;
333
+ }
334
+ const instructions = asText(this.instructions ?? this.instructions ?? "");
335
+ const contextText = asText(this.context ?? this.context ?? "");
336
+ return {
337
+ output: {
338
+ instructions,
339
+ context: contextText
340
+ }
341
+ };
342
+ }
343
+ }
344
+ __decorate([
345
+ prop({
346
+ type: "str",
347
+ default: "\nYou are a structured data generator focused on JSON outputs.\n\nGoal\n- Produce a high-quality JSON object that matches <JSON_SCHEMA> using the guidance in <INSTRUCTIONS> and any supplemental <CONTEXT>.\n\nOutput format (MANDATORY)\n- Output exactly ONE fenced code block labeled json containing ONLY the JSON object:\n\n ```json\n { ...single JSON object matching <JSON_SCHEMA>... }\n ```\n\n- No additional prose before or after the block.\n\nGeneration rules\n- Invent plausible, internally consistent values when not explicitly provided.\n- Honor all constraints from <JSON_SCHEMA> (types, enums, ranges, formats).\n- Prefer ISO 8601 for dates/times when applicable.\n- Ensure numbers respect reasonable magnitudes and relationships described in <INSTRUCTIONS>.\n- Avoid referencing external sources; rely solely on the provided guidance.\n\nValidation\n- Ensure the final JSON validates against <JSON_SCHEMA> exactly.\n",
348
+ title: "System Prompt",
349
+ description: "The system prompt guiding JSON generation."
350
+ })
351
+ ], StructuredOutputGeneratorNode.prototype, "system_prompt", void 0);
352
+ __decorate([
353
+ prop({
354
+ type: "language_model",
355
+ default: {
356
+ type: "language_model",
357
+ provider: "empty",
358
+ id: "",
359
+ name: "",
360
+ path: null,
361
+ supported_tasks: []
362
+ },
363
+ title: "Model",
364
+ description: "Model to use for structured generation."
365
+ })
366
+ ], StructuredOutputGeneratorNode.prototype, "model", void 0);
367
+ __decorate([
368
+ prop({
369
+ type: "str",
370
+ default: "",
371
+ title: "Instructions",
372
+ description: "Detailed instructions for the structured output."
373
+ })
374
+ ], StructuredOutputGeneratorNode.prototype, "instructions", void 0);
375
+ __decorate([
376
+ prop({
377
+ type: "str",
378
+ default: "",
379
+ title: "Context",
380
+ description: "Optional context to ground the generation."
381
+ })
382
+ ], StructuredOutputGeneratorNode.prototype, "context", void 0);
383
+ __decorate([
384
+ prop({
385
+ type: "int",
386
+ default: 4096,
387
+ title: "Max Tokens",
388
+ description: "The maximum number of tokens to generate.",
389
+ min: 1,
390
+ max: 16384
391
+ })
392
+ ], StructuredOutputGeneratorNode.prototype, "max_tokens", void 0);
393
+ __decorate([
394
+ prop({
395
+ type: "image",
396
+ default: {
397
+ type: "image",
398
+ uri: "",
399
+ asset_id: null,
400
+ data: null,
401
+ metadata: null
402
+ },
403
+ title: "Image",
404
+ description: "Optional image to include in the generation request."
405
+ })
406
+ ], StructuredOutputGeneratorNode.prototype, "image", void 0);
407
+ __decorate([
408
+ prop({
409
+ type: "audio",
410
+ default: {
411
+ type: "audio",
412
+ uri: "",
413
+ asset_id: null,
414
+ data: null,
415
+ metadata: null
416
+ },
417
+ title: "Audio",
418
+ description: "Optional audio to include in the generation request."
419
+ })
420
+ ], StructuredOutputGeneratorNode.prototype, "audio", void 0);
421
+ export class DataGeneratorNode extends BaseNode {
422
+ static nodeType = "nodetool.generators.DataGenerator";
423
+ static title = "Data Generator";
424
+ static description = "LLM Agent to create a dataframe based on a user prompt.\n llm, dataframe creation, data structuring\n\n Use cases:\n - Generating structured data from natural language descriptions\n - Creating sample datasets for testing or demonstration\n - Converting unstructured text into tabular format";
425
+ static metadataOutputTypes = {
426
+ record: "dict",
427
+ dataframe: "dataframe",
428
+ index: "int"
429
+ };
430
+ static basicFields = ["prompt", "model", "columns"];
431
+ static isStreamingOutput = true;
432
+ async process(context) {
433
+ const prompt = asText(this.prompt ?? this.prompt ?? "");
434
+ const inputText = asText(this.input_text ?? this.input_text ?? "");
435
+ const columnsInput = this.columns ?? this.columns;
436
+ const columns = parseColumns(columnsInput);
437
+ const count = parseRequestedCount(`${prompt} ${inputText}`, 5);
438
+ const { providerId, modelId } = getModelConfig(this.serialize());
439
+ if (hasProviderSupport(context, providerId, modelId)) {
440
+ const rows = await generateDataframeFromCsv(context, providerId, modelId, [prompt, inputText].filter(Boolean).join("\n\n"), columnsInput, count, Number(this.max_tokens ?? 4096));
441
+ if (rows.length > 0) {
442
+ return { output: dataframeFromRows(rows, columnsInput) };
443
+ }
444
+ }
445
+ const rows = makeRows(columns, count, inputText || prompt || "item");
446
+ return { output: dataframeFromRows(rows, columnsInput) };
447
+ }
448
+ async *genProcess(context) {
449
+ const full = await this.process(context);
450
+ const rows = (full.output.rows ?? []);
451
+ for (let i = 0; i < rows.length; i += 1) {
452
+ yield { record: rows[i], index: i, dataframe: null };
453
+ }
454
+ yield { record: null, index: null, dataframe: full.output };
455
+ }
456
+ }
457
+ __decorate([
458
+ prop({
459
+ type: "language_model",
460
+ default: {
461
+ type: "language_model",
462
+ provider: "empty",
463
+ id: "",
464
+ name: "",
465
+ path: null,
466
+ supported_tasks: []
467
+ },
468
+ title: "Model",
469
+ description: "The model to use for data generation."
470
+ })
471
+ ], DataGeneratorNode.prototype, "model", void 0);
472
+ __decorate([
473
+ prop({
474
+ type: "str",
475
+ default: "",
476
+ title: "Prompt",
477
+ description: "The user prompt"
478
+ })
479
+ ], DataGeneratorNode.prototype, "prompt", void 0);
480
+ __decorate([
481
+ prop({
482
+ type: "str",
483
+ default: "",
484
+ title: "Input Text",
485
+ description: "The input text to be analyzed by the agent."
486
+ })
487
+ ], DataGeneratorNode.prototype, "input_text", void 0);
488
+ __decorate([
489
+ prop({
490
+ type: "int",
491
+ default: 4096,
492
+ title: "Max Tokens",
493
+ description: "The maximum number of tokens to generate.",
494
+ min: 1,
495
+ max: 100000
496
+ })
497
+ ], DataGeneratorNode.prototype, "max_tokens", void 0);
498
+ __decorate([
499
+ prop({
500
+ type: "record_type",
501
+ default: {
502
+ type: "record_type",
503
+ columns: []
504
+ },
505
+ title: "Columns",
506
+ description: "The columns to use in the dataframe."
507
+ })
508
+ ], DataGeneratorNode.prototype, "columns", void 0);
509
+ export class ListGeneratorNode extends BaseNode {
510
+ static nodeType = "nodetool.generators.ListGenerator";
511
+ static title = "List Generator";
512
+ static description = "LLM Agent to create a stream of strings based on a user prompt.\n llm, text streaming\n\n Use cases:\n - Generating text from natural language descriptions\n - Streaming responses from an LLM";
513
+ static metadataOutputTypes = {
514
+ item: "str",
515
+ index: "int"
516
+ };
517
+ static basicFields = ["prompt", "model"];
518
+ static isStreamingOutput = true;
519
+ async process(context) {
520
+ const items = [];
521
+ for await (const chunk of this.genProcess(context)) {
522
+ const item = chunk.item;
523
+ if (typeof item === "string")
524
+ items.push(item);
525
+ }
526
+ return { output: items };
527
+ }
528
+ async *genProcess(context) {
529
+ const prompt = asText(this.prompt ?? "");
530
+ const inputText = asText(this.input_text ?? "");
531
+ const userMessage = [prompt, inputText].filter(Boolean).join("\n\n");
532
+ const { providerId, modelId } = getModelConfig(this.serialize());
533
+ if (context &&
534
+ typeof context.getProvider === "function" &&
535
+ providerId &&
536
+ modelId) {
537
+ let index = 0;
538
+ for await (const item of streamListItemsViaToolCalls(context, providerId, modelId, userMessage, Number(this.max_tokens ?? 128))) {
539
+ yield { item, index };
540
+ index += 1;
541
+ }
542
+ if (index === 0) {
543
+ throw new Error("Model returned no add_item tool calls — list is empty.");
544
+ }
545
+ return;
546
+ }
547
+ const seed = inputText || prompt || "item";
548
+ const count = parseRequestedCount(userMessage, 5);
549
+ for (let i = 0; i < count; i += 1) {
550
+ yield { item: `${seed}_${i + 1}`, index: i };
551
+ }
552
+ }
553
+ }
554
+ __decorate([
555
+ prop({
556
+ type: "language_model",
557
+ default: {
558
+ type: "language_model",
559
+ provider: "empty",
560
+ id: "",
561
+ name: "",
562
+ path: null,
563
+ supported_tasks: []
564
+ },
565
+ title: "Model",
566
+ description: "The model to use for string generation."
567
+ })
568
+ ], ListGeneratorNode.prototype, "model", void 0);
569
+ __decorate([
570
+ prop({
571
+ type: "str",
572
+ default: "",
573
+ title: "Prompt",
574
+ description: "The user prompt"
575
+ })
576
+ ], ListGeneratorNode.prototype, "prompt", void 0);
577
+ __decorate([
578
+ prop({
579
+ type: "str",
580
+ default: "",
581
+ title: "Input Text",
582
+ description: "The input text to be analyzed by the agent."
583
+ })
584
+ ], ListGeneratorNode.prototype, "input_text", void 0);
585
+ __decorate([
586
+ prop({
587
+ type: "int",
588
+ default: 4096,
589
+ title: "Max Tokens",
590
+ description: "The maximum number of tokens to generate.",
591
+ min: 1,
592
+ max: 100000
593
+ })
594
+ ], ListGeneratorNode.prototype, "max_tokens", void 0);
595
+ export class ChartGeneratorNode extends BaseNode {
596
+ static nodeType = "nodetool.generators.ChartGenerator";
597
+ static title = "Chart Generator";
598
+ static description = "LLM Agent to create Plotly Express charts based on natural language descriptions.\n llm, data visualization, charts\n\n Use cases:\n - Generating interactive charts from natural language descriptions\n - Creating data visualizations with minimal configuration\n - Converting data analysis requirements into visual representations";
599
+ static metadataOutputTypes = {
600
+ output: "chart_config"
601
+ };
602
+ static basicFields = ["prompt", "data", "model"];
603
+ async process(context) {
604
+ const prompt = asText(this.prompt ?? this.prompt ?? "");
605
+ const data = this.data ?? this.data ?? { rows: [] };
606
+ const rows = Array.isArray(data.rows)
607
+ ? (data.rows ?? [])
608
+ : [];
609
+ const keys = rows.length > 0 ? Object.keys(rows[0]) : [];
610
+ const xKey = keys[0] ?? "x";
611
+ const yKey = keys[1] ?? xKey;
612
+ const { providerId, modelId } = getModelConfig(this.serialize());
613
+ if (hasProviderSupport(context, providerId, modelId)) {
614
+ const dataSample = rows.length > 0
615
+ ? `Data columns: ${keys.join(", ")}\nSample rows:\n${JSON.stringify(rows.slice(0, 5), null, 2)}`
616
+ : "No data provided.";
617
+ const systemPrompt = `You are a Plotly visualization expert. Given a user's description and optional data, generate a Plotly chart configuration as JSON.
618
+ The JSON must conform to the provided schema. Choose appropriate chart types (bar, line, scatter, pie, histogram, box, heatmap, etc.) based on the user's description.
619
+ Use the data columns provided to set x_column, y_column, and label fields in the series array.
620
+ Set a descriptive title, axis labels, and legend settings.`;
621
+ const userMessage = `${prompt}\n\n${dataSample}`;
622
+ const chartSchema = {
623
+ type: "object",
624
+ additionalProperties: false,
625
+ required: ["title", "x_label", "y_label", "legend", "data"],
626
+ properties: {
627
+ title: { type: "string" },
628
+ x_label: { type: "string" },
629
+ y_label: { type: "string" },
630
+ legend: { type: "boolean" },
631
+ legend_position: { type: "string" },
632
+ data: {
633
+ type: "object",
634
+ additionalProperties: false,
635
+ required: ["series"],
636
+ properties: {
637
+ series: {
638
+ type: "array",
639
+ items: {
640
+ type: "object",
641
+ additionalProperties: false,
642
+ required: ["type", "x_column", "y_column", "label"],
643
+ properties: {
644
+ type: { type: "string" },
645
+ x_column: { type: "string" },
646
+ y_column: { type: "string" },
647
+ label: { type: "string" }
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
653
+ }
654
+ };
655
+ const result = await context.runProviderPrediction({
656
+ provider: providerId,
657
+ capability: "generate_message",
658
+ model: modelId,
659
+ params: {
660
+ model: modelId,
661
+ messages: [
662
+ { role: "system", content: systemPrompt },
663
+ { role: "user", content: userMessage }
664
+ ],
665
+ max_tokens: Number(this.max_tokens ?? 4096),
666
+ response_format: {
667
+ type: "json_schema",
668
+ json_schema: {
669
+ name: "chart_config",
670
+ schema: chartSchema
671
+ }
672
+ }
673
+ }
674
+ });
675
+ const content = asText(result.content ?? result);
676
+ try {
677
+ const parsed = JSON.parse(content);
678
+ return {
679
+ output: {
680
+ type: "chart_config",
681
+ ...parsed,
682
+ data: {
683
+ type: "chart_data",
684
+ ...(parsed.data ?? {}),
685
+ row: null,
686
+ col: null,
687
+ col_wrap: null
688
+ },
689
+ height: null,
690
+ aspect: null,
691
+ x_lim: null,
692
+ y_lim: null,
693
+ x_scale: null,
694
+ y_scale: null,
695
+ palette: null,
696
+ hue_order: null,
697
+ hue_norm: null,
698
+ sizes: null,
699
+ size_order: null,
700
+ size_norm: null,
701
+ marginal_kws: null,
702
+ joint_kws: null,
703
+ diag_kind: null,
704
+ corner: false,
705
+ center: null,
706
+ vmin: null,
707
+ vmax: null,
708
+ cmap: null,
709
+ annot: false,
710
+ fmt: ".2g",
711
+ square: false
712
+ }
713
+ };
714
+ }
715
+ catch {
716
+ // Fall through to hardcoded fallback
717
+ }
718
+ }
719
+ return {
720
+ output: {
721
+ type: "chart_config",
722
+ title: prompt || "Generated Chart",
723
+ x_label: xKey,
724
+ y_label: yKey,
725
+ legend: true,
726
+ data: {
727
+ type: "chart_data",
728
+ series: [
729
+ {
730
+ type: "bar",
731
+ x_column: xKey,
732
+ y_column: yKey,
733
+ label: prompt || "series"
734
+ }
735
+ ],
736
+ row: null,
737
+ col: null,
738
+ col_wrap: null
739
+ },
740
+ height: null,
741
+ aspect: null,
742
+ x_lim: null,
743
+ y_lim: null,
744
+ x_scale: null,
745
+ y_scale: null,
746
+ legend_position: "auto",
747
+ palette: null,
748
+ hue_order: null,
749
+ hue_norm: null,
750
+ sizes: null,
751
+ size_order: null,
752
+ size_norm: null,
753
+ marginal_kws: null,
754
+ joint_kws: null,
755
+ diag_kind: null,
756
+ corner: false,
757
+ center: null,
758
+ vmin: null,
759
+ vmax: null,
760
+ cmap: null,
761
+ annot: false,
762
+ fmt: ".2g",
763
+ square: false
764
+ }
765
+ };
766
+ }
767
+ }
768
+ __decorate([
769
+ prop({
770
+ type: "language_model",
771
+ default: {
772
+ type: "language_model",
773
+ provider: "empty",
774
+ id: "",
775
+ name: "",
776
+ path: null,
777
+ supported_tasks: []
778
+ },
779
+ title: "Model",
780
+ description: "The model to use for chart generation."
781
+ })
782
+ ], ChartGeneratorNode.prototype, "model", void 0);
783
+ __decorate([
784
+ prop({
785
+ type: "str",
786
+ default: "",
787
+ title: "Prompt",
788
+ description: "Natural language description of the desired chart"
789
+ })
790
+ ], ChartGeneratorNode.prototype, "prompt", void 0);
791
+ __decorate([
792
+ prop({
793
+ type: "dataframe",
794
+ default: {
795
+ type: "dataframe",
796
+ uri: "",
797
+ asset_id: null,
798
+ data: null,
799
+ metadata: null,
800
+ columns: null
801
+ },
802
+ title: "Data",
803
+ description: "The data to visualize"
804
+ })
805
+ ], ChartGeneratorNode.prototype, "data", void 0);
806
+ __decorate([
807
+ prop({
808
+ type: "int",
809
+ default: 4096,
810
+ title: "Max Tokens",
811
+ description: "The maximum number of tokens to generate.",
812
+ min: 1,
813
+ max: 100000
814
+ })
815
+ ], ChartGeneratorNode.prototype, "max_tokens", void 0);
816
+ export class SVGGeneratorNode extends BaseNode {
817
+ static nodeType = "nodetool.generators.SVGGenerator";
818
+ static title = "SVGGenerator";
819
+ static description = "LLM Agent to create SVG elements based on user prompts.\n svg, generator, vector, graphics\n\n Use cases:\n - Creating vector graphics from text descriptions\n - Generating scalable illustrations\n - Creating custom icons and diagrams";
820
+ static metadataOutputTypes = {
821
+ output: "list[svg_element]"
822
+ };
823
+ static basicFields = ["prompt", "image", "audio", "model"];
824
+ async process(context) {
825
+ const prompt = asText(this.prompt ?? this.prompt ?? "");
826
+ const width = Number(this.width ?? 512) || 512;
827
+ const height = Number(this.height ?? 512) || 512;
828
+ const { providerId, modelId } = getModelConfig(this.serialize());
829
+ if (hasProviderSupport(context, providerId, modelId)) {
830
+ const systemPrompt = `You are an SVG graphics expert. Generate SVG markup based on the user's description.
831
+ Return one or more complete <svg>...</svg> elements. Each SVG should use the xmlns="http://www.w3.org/2000/svg" attribute.
832
+ Default canvas size is ${width}x${height} unless the user specifies otherwise.
833
+ Output only SVG markup, no explanations or markdown fences.`;
834
+ const messages = [
835
+ { role: "system", content: systemPrompt },
836
+ {
837
+ role: "user",
838
+ content: buildMessageContent(prompt, this.image, this.audio)
839
+ }
840
+ ];
841
+ const result = await context.runProviderPrediction({
842
+ provider: providerId,
843
+ capability: "generate_message",
844
+ model: modelId,
845
+ params: {
846
+ model: modelId,
847
+ messages,
848
+ max_tokens: Number(this.max_tokens ?? 8192)
849
+ }
850
+ });
851
+ const content = asText(result.content ?? result);
852
+ const svgMatches = Array.from(content.matchAll(/<svg[\s\S]*?<\/svg>/gi));
853
+ if (svgMatches.length > 0) {
854
+ return {
855
+ output: svgMatches.map((m) => ({ content: m[0] }))
856
+ };
857
+ }
858
+ }
859
+ // Fallback: generate a simple placeholder SVG
860
+ const text = prompt || "SVG";
861
+ const safeText = text
862
+ .replace(/&/g, "&amp;")
863
+ .replace(/</g, "&lt;")
864
+ .replace(/>/g, "&gt;");
865
+ const svg = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="#f2f2f2"/><text x="16" y="32" font-size="20" fill="#111">${safeText}</text></svg>`;
866
+ return { output: [{ content: svg }] };
867
+ }
868
+ }
869
+ __decorate([
870
+ prop({
871
+ type: "language_model",
872
+ default: {
873
+ type: "language_model",
874
+ provider: "empty",
875
+ id: "",
876
+ name: "",
877
+ path: null,
878
+ supported_tasks: []
879
+ },
880
+ title: "Model",
881
+ description: "The language model to use for SVG generation."
882
+ })
883
+ ], SVGGeneratorNode.prototype, "model", void 0);
884
+ __decorate([
885
+ prop({
886
+ type: "str",
887
+ default: "",
888
+ title: "Prompt",
889
+ description: "The user prompt for SVG generation"
890
+ })
891
+ ], SVGGeneratorNode.prototype, "prompt", void 0);
892
+ __decorate([
893
+ prop({
894
+ type: "image",
895
+ default: {
896
+ type: "image",
897
+ uri: "",
898
+ asset_id: null,
899
+ data: null,
900
+ metadata: null
901
+ },
902
+ title: "Image",
903
+ description: "Image to use for generation"
904
+ })
905
+ ], SVGGeneratorNode.prototype, "image", void 0);
906
+ __decorate([
907
+ prop({
908
+ type: "audio",
909
+ default: {
910
+ type: "audio",
911
+ uri: "",
912
+ asset_id: null,
913
+ data: null,
914
+ metadata: null
915
+ },
916
+ title: "Audio",
917
+ description: "Audio to use for generation"
918
+ })
919
+ ], SVGGeneratorNode.prototype, "audio", void 0);
920
+ __decorate([
921
+ prop({
922
+ type: "int",
923
+ default: 8192,
924
+ title: "Max Tokens",
925
+ description: "The maximum number of tokens to generate.",
926
+ min: 1,
927
+ max: 100000
928
+ })
929
+ ], SVGGeneratorNode.prototype, "max_tokens", void 0);
930
+ export const GENERATOR_NODES = [
931
+ StructuredOutputGeneratorNode,
932
+ DataGeneratorNode,
933
+ ListGeneratorNode,
934
+ ChartGeneratorNode,
935
+ SVGGeneratorNode
936
+ ];
937
+ //# sourceMappingURL=generators.js.map