@bubblelab/bubble-core 0.1.10 → 0.1.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 (298) hide show
  1. package/dist/bubble-bundle.d.ts +759 -350
  2. package/dist/bubble-factory.d.ts.map +1 -1
  3. package/dist/bubble-factory.js +125 -35
  4. package/dist/bubble-factory.js.map +1 -1
  5. package/dist/bubble-flow/bubble-flow-class.d.ts +5 -0
  6. package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -1
  7. package/dist/bubble-flow/bubble-flow-class.js +20 -0
  8. package/dist/bubble-flow/bubble-flow-class.js.map +1 -1
  9. package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -1
  10. package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +6 -3
  11. package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -1
  12. package/dist/bubbles/service-bubble/agi-inc.d.ts +1121 -0
  13. package/dist/bubbles/service-bubble/agi-inc.d.ts.map +1 -0
  14. package/dist/bubbles/service-bubble/agi-inc.js +730 -0
  15. package/dist/bubbles/service-bubble/agi-inc.js.map +1 -0
  16. package/dist/bubbles/service-bubble/ai-agent.d.ts +277 -65
  17. package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -1
  18. package/dist/bubbles/service-bubble/ai-agent.js +533 -399
  19. package/dist/bubbles/service-bubble/ai-agent.js.map +1 -1
  20. package/dist/bubbles/service-bubble/airtable.d.ts +1753 -0
  21. package/dist/bubbles/service-bubble/airtable.d.ts.map +1 -0
  22. package/dist/bubbles/service-bubble/airtable.js +1173 -0
  23. package/dist/bubbles/service-bubble/airtable.js.map +1 -0
  24. package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts +240 -0
  25. package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts.map +1 -0
  26. package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.js +119 -0
  27. package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.js.map +1 -0
  28. package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +4 -4
  29. package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +14 -14
  30. package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts +137 -0
  31. package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts.map +1 -0
  32. package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.js +81 -0
  33. package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.js.map +1 -0
  34. package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +6 -6
  35. package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +32 -32
  36. package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts +488 -0
  37. package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts.map +1 -0
  38. package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.js +463 -0
  39. package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.js.map +1 -0
  40. package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts +262 -0
  41. package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts.map +1 -0
  42. package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.js +291 -0
  43. package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.js.map +1 -0
  44. package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +12 -12
  45. package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +1301 -170
  46. package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts.map +1 -1
  47. package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js +32 -0
  48. package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js.map +1 -1
  49. package/dist/bubbles/service-bubble/apify/apify.d.ts +162 -17
  50. package/dist/bubbles/service-bubble/apify/apify.d.ts.map +1 -1
  51. package/dist/bubbles/service-bubble/apify/apify.js +205 -32
  52. package/dist/bubbles/service-bubble/apify/apify.js.map +1 -1
  53. package/dist/bubbles/service-bubble/eleven-labs.d.ts +421 -0
  54. package/dist/bubbles/service-bubble/eleven-labs.d.ts.map +1 -0
  55. package/dist/bubbles/service-bubble/eleven-labs.js +479 -0
  56. package/dist/bubbles/service-bubble/eleven-labs.js.map +1 -0
  57. package/dist/bubbles/service-bubble/firecrawl.d.ts +37748 -0
  58. package/dist/bubbles/service-bubble/firecrawl.d.ts.map +1 -0
  59. package/dist/bubbles/service-bubble/firecrawl.js +1489 -0
  60. package/dist/bubbles/service-bubble/firecrawl.js.map +1 -0
  61. package/dist/bubbles/service-bubble/followupboss.d.ts +6822 -0
  62. package/dist/bubbles/service-bubble/followupboss.d.ts.map +1 -0
  63. package/dist/bubbles/service-bubble/followupboss.js +1394 -0
  64. package/dist/bubbles/service-bubble/followupboss.js.map +1 -0
  65. package/dist/bubbles/service-bubble/github.d.ts +2399 -0
  66. package/dist/bubbles/service-bubble/github.d.ts.map +1 -0
  67. package/dist/bubbles/service-bubble/github.js +1052 -0
  68. package/dist/bubbles/service-bubble/github.js.map +1 -0
  69. package/dist/bubbles/service-bubble/gmail.d.ts +180 -180
  70. package/dist/bubbles/service-bubble/google-calendar.d.ts +60 -60
  71. package/dist/bubbles/service-bubble/google-drive.d.ts +37 -36
  72. package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -1
  73. package/dist/bubbles/service-bubble/google-drive.js +35 -3
  74. package/dist/bubbles/service-bubble/google-drive.js.map +1 -1
  75. package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts +943 -0
  76. package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts.map +1 -0
  77. package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.d.ts +31 -0
  78. package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.d.ts.map +1 -0
  79. package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.js +184 -0
  80. package/dist/bubbles/service-bubble/google-sheets/google-sheets.integration.flow.js.map +1 -0
  81. package/dist/bubbles/service-bubble/google-sheets/google-sheets.js +401 -0
  82. package/dist/bubbles/service-bubble/google-sheets/google-sheets.js.map +1 -0
  83. package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts +1024 -0
  84. package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts.map +1 -0
  85. package/dist/bubbles/service-bubble/{google-sheets.js → google-sheets/google-sheets.schema.js} +45 -409
  86. package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.js.map +1 -0
  87. package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.d.ts +38 -0
  88. package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.d.ts.map +1 -0
  89. package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.js +183 -0
  90. package/dist/bubbles/service-bubble/google-sheets/google-sheets.utils.js.map +1 -0
  91. package/dist/bubbles/service-bubble/google-sheets/index.d.ts +4 -0
  92. package/dist/bubbles/service-bubble/google-sheets/index.d.ts.map +1 -0
  93. package/dist/bubbles/service-bubble/google-sheets/index.js +4 -0
  94. package/dist/bubbles/service-bubble/google-sheets/index.js.map +1 -0
  95. package/dist/bubbles/service-bubble/hello-world.d.ts +4 -4
  96. package/dist/bubbles/service-bubble/http.d.ts +4 -4
  97. package/dist/bubbles/service-bubble/http.d.ts.map +1 -1
  98. package/dist/bubbles/service-bubble/http.js +7 -1
  99. package/dist/bubbles/service-bubble/http.js.map +1 -1
  100. package/dist/bubbles/service-bubble/insforge-db.d.ts +140 -0
  101. package/dist/bubbles/service-bubble/insforge-db.d.ts.map +1 -0
  102. package/dist/bubbles/service-bubble/insforge-db.js +260 -0
  103. package/dist/bubbles/service-bubble/insforge-db.js.map +1 -0
  104. package/dist/bubbles/service-bubble/notion/index.d.ts +3 -0
  105. package/dist/bubbles/service-bubble/notion/index.d.ts.map +1 -0
  106. package/dist/bubbles/service-bubble/notion/index.js +3 -0
  107. package/dist/bubbles/service-bubble/notion/index.js.map +1 -0
  108. package/dist/bubbles/service-bubble/notion/notion.d.ts +35405 -0
  109. package/dist/bubbles/service-bubble/notion/notion.d.ts.map +1 -0
  110. package/dist/bubbles/service-bubble/notion/notion.js +1492 -0
  111. package/dist/bubbles/service-bubble/notion/notion.js.map +1 -0
  112. package/dist/bubbles/service-bubble/notion/property-schemas.d.ts +1148 -0
  113. package/dist/bubbles/service-bubble/notion/property-schemas.d.ts.map +1 -0
  114. package/dist/bubbles/service-bubble/notion/property-schemas.js +341 -0
  115. package/dist/bubbles/service-bubble/notion/property-schemas.js.map +1 -0
  116. package/dist/bubbles/service-bubble/postgresql.d.ts +12 -12
  117. package/dist/bubbles/service-bubble/resend.d.ts +34 -13
  118. package/dist/bubbles/service-bubble/resend.d.ts.map +1 -1
  119. package/dist/bubbles/service-bubble/resend.js +133 -2
  120. package/dist/bubbles/service-bubble/resend.js.map +1 -1
  121. package/dist/bubbles/service-bubble/slack.d.ts +241 -241
  122. package/dist/bubbles/service-bubble/slack.d.ts.map +1 -1
  123. package/dist/bubbles/service-bubble/slack.js +2 -2
  124. package/dist/bubbles/service-bubble/slack.js.map +1 -1
  125. package/dist/bubbles/service-bubble/storage.d.ts +25 -21
  126. package/dist/bubbles/service-bubble/storage.d.ts.map +1 -1
  127. package/dist/bubbles/service-bubble/storage.js +43 -2
  128. package/dist/bubbles/service-bubble/storage.js.map +1 -1
  129. package/dist/bubbles/service-bubble/telegram.d.ts +7742 -0
  130. package/dist/bubbles/service-bubble/telegram.d.ts.map +1 -0
  131. package/dist/bubbles/service-bubble/telegram.js +1132 -0
  132. package/dist/bubbles/service-bubble/telegram.js.map +1 -0
  133. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +76 -20
  134. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -1
  135. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +12 -0
  136. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -1
  137. package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +14 -14
  138. package/dist/bubbles/tool-bubble/code-edit-tool.d.ts +188 -0
  139. package/dist/bubbles/tool-bubble/code-edit-tool.d.ts.map +1 -0
  140. package/dist/bubbles/tool-bubble/code-edit-tool.js +321 -0
  141. package/dist/bubbles/tool-bubble/code-edit-tool.js.map +1 -0
  142. package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +8 -4
  143. package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -1
  144. package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +115 -10
  145. package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -1
  146. package/dist/bubbles/tool-bubble/google-maps-tool.d.ts +455 -0
  147. package/dist/bubbles/tool-bubble/google-maps-tool.d.ts.map +1 -0
  148. package/dist/bubbles/tool-bubble/google-maps-tool.js +205 -0
  149. package/dist/bubbles/tool-bubble/google-maps-tool.js.map +1 -0
  150. package/dist/bubbles/tool-bubble/instagram-tool.d.ts +36 -36
  151. package/dist/bubbles/tool-bubble/instagram-tool.d.ts.map +1 -1
  152. package/dist/bubbles/tool-bubble/instagram-tool.js +2 -2
  153. package/dist/bubbles/tool-bubble/instagram-tool.js.map +1 -1
  154. package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +824 -447
  155. package/dist/bubbles/tool-bubble/linkedin-tool.d.ts.map +1 -1
  156. package/dist/bubbles/tool-bubble/linkedin-tool.js +232 -12
  157. package/dist/bubbles/tool-bubble/linkedin-tool.js.map +1 -1
  158. package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +4 -4
  159. package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +66 -66
  160. package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +17 -16
  161. package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -1
  162. package/dist/bubbles/tool-bubble/research-agent-tool.js +26 -16
  163. package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -1
  164. package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +8 -8
  165. package/dist/bubbles/tool-bubble/tiktok-tool.d.ts +485 -0
  166. package/dist/bubbles/tool-bubble/tiktok-tool.d.ts.map +1 -0
  167. package/dist/bubbles/tool-bubble/tiktok-tool.js +226 -0
  168. package/dist/bubbles/tool-bubble/tiktok-tool.js.map +1 -0
  169. package/dist/bubbles/tool-bubble/tool-template.d.ts +8 -8
  170. package/dist/bubbles/tool-bubble/twitter-tool.d.ts +947 -0
  171. package/dist/bubbles/tool-bubble/twitter-tool.d.ts.map +1 -0
  172. package/dist/bubbles/tool-bubble/twitter-tool.js +494 -0
  173. package/dist/bubbles/tool-bubble/twitter-tool.js.map +1 -0
  174. package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +22 -16
  175. package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -1
  176. package/dist/bubbles/tool-bubble/web-crawl-tool.js +58 -59
  177. package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -1
  178. package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +8 -8
  179. package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -1
  180. package/dist/bubbles/tool-bubble/web-extract-tool.js +17 -17
  181. package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -1
  182. package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +15 -107
  183. package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -1
  184. package/dist/bubbles/tool-bubble/web-scrape-tool.js +51 -72
  185. package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -1
  186. package/dist/bubbles/tool-bubble/web-search-tool.d.ts +20 -9
  187. package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -1
  188. package/dist/bubbles/tool-bubble/web-search-tool.js +45 -35
  189. package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -1
  190. package/dist/bubbles/tool-bubble/youtube-tool.d.ts +25 -25
  191. package/dist/bubbles/tool-bubble/youtube-tool.d.ts.map +1 -1
  192. package/dist/bubbles/tool-bubble/youtube-tool.js +5 -5
  193. package/dist/bubbles/tool-bubble/youtube-tool.js.map +1 -1
  194. package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +4 -4
  195. package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +30 -30
  196. package/dist/bubbles/workflow-bubble/generate-document.workflow.js +1 -1
  197. package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +22 -22
  198. package/dist/bubbles/workflow-bubble/parse-document.workflow.js +1 -1
  199. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +54 -54
  200. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -1
  201. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +4 -4
  202. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -1
  203. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +36 -36
  204. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +1 -1
  205. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +14 -14
  206. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -1
  207. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +6 -6
  208. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -1
  209. package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +26 -26
  210. package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -1
  211. package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +24 -4
  212. package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -1
  213. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +19 -19
  214. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -1
  215. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +8 -8
  216. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -1
  217. package/dist/bubbles.json +220 -72
  218. package/dist/index.d.ts +23 -4
  219. package/dist/index.d.ts.map +1 -1
  220. package/dist/index.js +16 -3
  221. package/dist/index.js.map +1 -1
  222. package/dist/logging/BubbleLogger.d.ts +45 -16
  223. package/dist/logging/BubbleLogger.d.ts.map +1 -1
  224. package/dist/logging/BubbleLogger.js +178 -77
  225. package/dist/logging/BubbleLogger.js.map +1 -1
  226. package/dist/logging/StreamingBubbleLogger.d.ts +13 -1
  227. package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -1
  228. package/dist/logging/StreamingBubbleLogger.js +51 -8
  229. package/dist/logging/StreamingBubbleLogger.js.map +1 -1
  230. package/dist/logging/WebhookStreamLogger.d.ts +66 -0
  231. package/dist/logging/WebhookStreamLogger.d.ts.map +1 -0
  232. package/dist/logging/WebhookStreamLogger.js +291 -0
  233. package/dist/logging/WebhookStreamLogger.js.map +1 -0
  234. package/dist/types/available-tools.d.ts +1 -1
  235. package/dist/types/available-tools.d.ts.map +1 -1
  236. package/dist/types/available-tools.js +1 -0
  237. package/dist/types/available-tools.js.map +1 -1
  238. package/dist/types/base-bubble-class.d.ts +6 -4
  239. package/dist/types/base-bubble-class.d.ts.map +1 -1
  240. package/dist/types/base-bubble-class.js +35 -20
  241. package/dist/types/base-bubble-class.js.map +1 -1
  242. package/dist/types/bubble.d.ts +2 -0
  243. package/dist/types/bubble.d.ts.map +1 -1
  244. package/dist/types/service-bubble-class.d.ts +1 -1
  245. package/dist/types/service-bubble-class.d.ts.map +1 -1
  246. package/dist/types/service-bubble-class.js +2 -2
  247. package/dist/types/service-bubble-class.js.map +1 -1
  248. package/dist/types/tool-bubble-class.d.ts +1 -1
  249. package/dist/types/tool-bubble-class.d.ts.map +1 -1
  250. package/dist/types/tool-bubble-class.js +2 -2
  251. package/dist/types/tool-bubble-class.js.map +1 -1
  252. package/dist/types/workflow-bubble-class.d.ts +1 -1
  253. package/dist/types/workflow-bubble-class.d.ts.map +1 -1
  254. package/dist/types/workflow-bubble-class.js +2 -2
  255. package/dist/types/workflow-bubble-class.js.map +1 -1
  256. package/dist/utils/agent-formatter.d.ts +14 -2
  257. package/dist/utils/agent-formatter.d.ts.map +1 -1
  258. package/dist/utils/agent-formatter.js +174 -26
  259. package/dist/utils/agent-formatter.js.map +1 -1
  260. package/dist/utils/bubbleflow-validation.d.ts +7 -0
  261. package/dist/utils/bubbleflow-validation.d.ts.map +1 -1
  262. package/dist/utils/bubbleflow-validation.js +171 -6
  263. package/dist/utils/bubbleflow-validation.js.map +1 -1
  264. package/dist/utils/json-parsing.d.ts.map +1 -1
  265. package/dist/utils/json-parsing.js +146 -0
  266. package/dist/utils/json-parsing.js.map +1 -1
  267. package/dist/utils/safe-gemini-chat.d.ts +31 -0
  268. package/dist/utils/safe-gemini-chat.d.ts.map +1 -0
  269. package/dist/utils/safe-gemini-chat.js +93 -0
  270. package/dist/utils/safe-gemini-chat.js.map +1 -0
  271. package/dist/utils/schema-comparison.d.ts +92 -0
  272. package/dist/utils/schema-comparison.d.ts.map +1 -0
  273. package/dist/utils/schema-comparison.js +716 -0
  274. package/dist/utils/schema-comparison.js.map +1 -0
  275. package/dist/utils/zod-schema.d.ts +24 -0
  276. package/dist/utils/zod-schema.d.ts.map +1 -0
  277. package/dist/utils/zod-schema.js +56 -0
  278. package/dist/utils/zod-schema.js.map +1 -0
  279. package/package.json +5 -4
  280. package/dist/bubbles/service-bubble/google-sheets.d.ts +0 -1811
  281. package/dist/bubbles/service-bubble/google-sheets.d.ts.map +0 -1
  282. package/dist/bubbles/service-bubble/google-sheets.js.map +0 -1
  283. package/dist/bubbles/service-bubble/x-twitter.d.ts +0 -814
  284. package/dist/bubbles/service-bubble/x-twitter.d.ts.map +0 -1
  285. package/dist/bubbles/service-bubble/x-twitter.js +0 -445
  286. package/dist/bubbles/service-bubble/x-twitter.js.map +0 -1
  287. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +0 -125
  288. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +0 -1
  289. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +0 -808
  290. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +0 -1
  291. package/dist/test-gm.d.ts +0 -10
  292. package/dist/test-gm.d.ts.map +0 -1
  293. package/dist/test-gm.js +0 -95
  294. package/dist/test-gm.js.map +0 -1
  295. package/dist/utils/param-helper.d.ts +0 -2
  296. package/dist/utils/param-helper.d.ts.map +0 -1
  297. package/dist/utils/param-helper.js +0 -5
  298. package/dist/utils/param-helper.js.map +0 -1
@@ -1,808 +0,0 @@
1
- /**
2
- * SIMPLE BUBBLEFLOW GENERATOR WORKFLOW
3
- *
4
- * A simplified BubbleFlow generator that uses AI agent with tools to generate
5
- * and validate BubbleFlow code from natural language prompts.
6
- *
7
- * Much simpler than the complex workflow - just AI + validation tool!
8
- */
9
- import { z } from 'zod';
10
- import { WorkflowBubble } from '../../types/workflow-bubble-class.js';
11
- import { CredentialType, GenerationResultSchema, CRITICAL_INSTRUCTIONS, VALIDATION_PROCESS, BUBBLE_SPECIFIC_INSTRUCTIONS, } from '@bubblelab/shared-schemas';
12
- import { AIAgentBubble, } from '../service-bubble/ai-agent.js';
13
- import { ToolMessage } from '@langchain/core/messages';
14
- import { BubbleFactory } from '../../bubble-factory.js';
15
- /**
16
- * Extract unique bubble names from validation result
17
- */
18
- function extractBubbleNames(validationResult) {
19
- if (!validationResult?.bubbles) {
20
- return [];
21
- }
22
- const bubbleNames = validationResult.bubbles.map((b) => b.bubbleName);
23
- return Array.from(new Set(bubbleNames));
24
- }
25
- /**
26
- * Parameters schema for the simple BubbleFlow generator
27
- */
28
- const BubbleFlowGeneratorParamsSchema = z.object({
29
- prompt: z
30
- .string()
31
- .min(1, 'Prompt is required')
32
- .describe('Natural language description of the desired BubbleFlow'),
33
- credentials: z
34
- .record(z.nativeEnum(CredentialType), z.string())
35
- .optional()
36
- .describe('Credentials for AI agent operations'),
37
- });
38
- // Shared constants and prompts
39
- const AI_MODEL_CONFIG = {
40
- model: 'google/gemini-2.5-pro',
41
- temperature: 0.3,
42
- };
43
- const MAX_ITERATIONS = 20;
44
- const TOOL_NAMES = {
45
- VALIDATION: 'bubbleflow-validation-tool',
46
- BUBBLE_DETAILS: 'get-bubble-details-tool',
47
- LIST_BUBBLES: 'list-bubbles-tool',
48
- };
49
- const SYSTEM_PROMPT_BASE = `You are an expert TypeScript developer who specializes in creating BubbleFlow workflows. Generate clean, well-structured code that follows best practices.
50
-
51
- WORKFLOW:
52
- 1. First identify bubbles needed from the available list
53
- 2. Use get-bubble-details-tool for each bubble to understand proper usage
54
- 3. Write code using exact patterns from bubble details
55
- 4. Use bubbleflow-validation iteratively until valid
56
- 5. Do not provide a response until your code is fully validated`;
57
- // CRITICAL_INSTRUCTIONS and VALIDATION_PROCESS are now imported from @bubblelab/shared-schemas
58
- /**
59
- * Simple BubbleFlow Generator using AI agent with tools
60
- */
61
- export class BubbleFlowGeneratorWorkflow extends WorkflowBubble {
62
- static type = 'workflow';
63
- static bubbleName = 'bubbleflow-generator';
64
- static schema = BubbleFlowGeneratorParamsSchema;
65
- static resultSchema = GenerationResultSchema;
66
- static shortDescription = 'Generate BubbleFlow code from natural language';
67
- static longDescription = `
68
- Simple BubbleFlow generator that uses AI with validation tools.
69
-
70
- Just provide a natural language prompt describing what you want your BubbleFlow to do,
71
- and it will generate complete TypeScript code with proper validation.
72
-
73
- Example prompts:
74
- - "Create a flow that queries my database and sends results to Slack"
75
- - "Build a workflow that processes user data with AI and stores it"
76
- - "Make a flow that analyzes text and generates a summary"
77
- `;
78
- static alias = 'generate-flow';
79
- bubbleFactory;
80
- constructor(params, context) {
81
- super(params, context);
82
- this.bubbleFactory = new BubbleFactory();
83
- }
84
- async runValidationAgent(code, credentials, streamingCallback) {
85
- const validationAgent = new AIAgentBubble({
86
- name: 'Validation Agent',
87
- message: `You are a validationAgent. Validate the provided BubbleFlow TypeScript code using the bubbleflow-validation tool. ` +
88
- `If validation fails, fix the code and validate again until it passes with valid: true. ` +
89
- `Return ONLY the final validated TypeScript code with no markdown. If needed, use the list-bubbles-tool to get the list of available bubbles and bubble details to get the correct parameters and usage.\n\n` +
90
- `CODE:\n\n\n` +
91
- code,
92
- systemPrompt: `You must use the bubbleflow-validation tool to validate code. Repeat validation/fix until valid. ` +
93
- `Do not explain anything. Output only the final TypeScript code when validation passes.`,
94
- model: AI_MODEL_CONFIG,
95
- tools: [
96
- {
97
- name: TOOL_NAMES.VALIDATION,
98
- credentials: credentials || {},
99
- },
100
- {
101
- name: TOOL_NAMES.BUBBLE_DETAILS,
102
- credentials: credentials || {},
103
- },
104
- {
105
- name: TOOL_NAMES.LIST_BUBBLES,
106
- credentials: credentials || {},
107
- },
108
- ],
109
- maxIterations: 10,
110
- credentials,
111
- }, this.context);
112
- const validationRun = streamingCallback
113
- ? await validationAgent.actionWithStreaming(streamingCallback)
114
- : await validationAgent.action();
115
- let validatedCode = code;
116
- let isValid = false;
117
- let validationError = 'Validation agent failed';
118
- let bubblesUsed = [];
119
- // Handle both streaming (direct response) and non-streaming (wrapped in data) results
120
- const isStreamingResult = 'response' in validationRun;
121
- const response = isStreamingResult
122
- ? validationRun.response
123
- : validationRun.data?.response;
124
- const toolCalls = isStreamingResult
125
- ? validationRun.toolCalls
126
- : validationRun.data?.toolCalls;
127
- if (validationRun.success && response) {
128
- validatedCode = response
129
- .replace(/```typescript/g, '')
130
- .replace(/```/g, '')
131
- .trim();
132
- if (toolCalls && toolCalls.length > 0) {
133
- const lastToolCall = toolCalls[toolCalls.length - 1];
134
- if ((lastToolCall.tool === TOOL_NAMES.VALIDATION ||
135
- lastToolCall.tool === 'bubbleflow-validation') &&
136
- lastToolCall.output) {
137
- try {
138
- let validationContent;
139
- if (lastToolCall.output instanceof ToolMessage) {
140
- const content = lastToolCall.output.content;
141
- validationContent =
142
- typeof content === 'string' ? content : JSON.stringify(content);
143
- }
144
- else if (typeof lastToolCall.output === 'object' &&
145
- lastToolCall.output !== null &&
146
- 'content' in lastToolCall.output) {
147
- const content = lastToolCall.output.content;
148
- validationContent =
149
- typeof content === 'string' ? content : JSON.stringify(content);
150
- }
151
- else if (typeof lastToolCall.output === 'string') {
152
- validationContent = lastToolCall.output;
153
- }
154
- else {
155
- validationContent = JSON.stringify(lastToolCall.output);
156
- }
157
- const parsedResult = JSON.parse(validationContent);
158
- console.log('[BubbleFlowGenerator] Raw validation result structure:', {
159
- hasData: !!parsedResult.data,
160
- hasTopLevelValid: 'valid' in parsedResult,
161
- hasNestedValid: parsedResult.data && 'valid' in parsedResult.data,
162
- });
163
- // Unwrap the result if it's wrapped in a data object
164
- const validationResult = parsedResult.data || parsedResult;
165
- isValid = validationResult.valid === true;
166
- validationError =
167
- validationResult.error ||
168
- (validationResult.errors && validationResult.errors.join('; ')) ||
169
- '';
170
- // Extract bubble names from validation result
171
- bubblesUsed = extractBubbleNames(validationResult);
172
- console.log('[BubbleFlowGenerator] ✅ Validation parsed - valid:', isValid, 'error:', validationError || 'none', 'bubblesUsed:', bubblesUsed);
173
- }
174
- catch (e) {
175
- isValid = true;
176
- validationError = '';
177
- }
178
- }
179
- }
180
- }
181
- return {
182
- validatedCode,
183
- isValid,
184
- validationError,
185
- toolCalls,
186
- bubblesUsed,
187
- };
188
- }
189
- async runSummarizeAgent(validatedCode, credentials, streamingCallback) {
190
- const summarizeAgent = new AIAgentBubble({
191
- name: 'Flow Summary Agent',
192
- message: `You are summarizeAgent. Analyze the provided validated BubbleFlow TypeScript code and:
193
- 1) Output a concise human-readable summary of what a user needs to do to use this flow (credentials, setup, trigger, expected outputs).
194
- 2) Extract and output a JSON Schema describing the input payload (types and required fields) of the flow. under the key inputsSchema.\n\nReturn a JSON object of the shape: { "summary": string, "inputsSchema": string } where inputsSchema is a JSON Schema string.\n\nCODE:\n\n\n` +
195
- validatedCode,
196
- systemPrompt: `Return only a strict JSON object with keys summary and inputsSchema. inputsSchema must be a JSON Schema string for the flow's input. Do not include markdown. For the input schema, directly use the schema payload: CustomWebhookPayload, don't add any other fields that the user is to provide at minimum, don't worry about any fields of WebhookEvent.`,
197
- model: {
198
- jsonMode: true,
199
- },
200
- tools: [],
201
- maxIterations: 5,
202
- credentials,
203
- }, this.context);
204
- console.log('[BubbleFlowGenerator] Starting summarizeAgent...');
205
- const summarizeRun = streamingCallback
206
- ? await summarizeAgent.actionWithStreaming(streamingCallback)
207
- : await summarizeAgent.action();
208
- let summary = '';
209
- let inputsSchema = '';
210
- console.log('[BubbleFlowGenerator] SummarizeAgent result:', {
211
- success: summarizeRun.success,
212
- hasResponse: !!('response' in summarizeRun
213
- ? summarizeRun.response
214
- : summarizeRun.data?.response),
215
- error: summarizeRun.error,
216
- });
217
- // Handle both streaming (direct response) and non-streaming (wrapped in data) results
218
- const isStreamingResult = 'response' in summarizeRun;
219
- const response = isStreamingResult
220
- ? summarizeRun.response
221
- : summarizeRun.data?.response;
222
- if (summarizeRun.success && response) {
223
- try {
224
- const raw = response.trim();
225
- console.log('[BubbleFlowGenerator] Raw summarizeAgent response:', raw);
226
- const parsed = JSON.parse(raw);
227
- console.log('[BubbleFlowGenerator] Parsed summarizeAgent response:', parsed);
228
- summary = typeof parsed.summary === 'string' ? parsed.summary : '';
229
- inputsSchema =
230
- typeof parsed.inputsSchema === 'string' ? parsed.inputsSchema : '';
231
- console.log('[BubbleFlowGenerator] Extracted summary and schema:', {
232
- summary,
233
- inputsSchema,
234
- });
235
- }
236
- catch (parseError) {
237
- console.error('[BubbleFlowGenerator] Failed to parse summarizeAgent response:', parseError);
238
- summary = '';
239
- inputsSchema = '';
240
- }
241
- }
242
- else {
243
- console.log('[BubbleFlowGenerator] SummarizeAgent failed or no response:', {
244
- success: summarizeRun.success,
245
- response: response,
246
- error: summarizeRun.error,
247
- });
248
- }
249
- return { summary, inputsSchema };
250
- }
251
- createSystemPrompt(boilerplate, bubbleDescriptions) {
252
- return `${SYSTEM_PROMPT_BASE}
253
-
254
- Here's the boilerplate template you should use as a starting point:
255
- \`\`\`typescript
256
- ${boilerplate}
257
- \`\`\`
258
-
259
- Available bubbles in the system:
260
- ${bubbleDescriptions}
261
-
262
- ${CRITICAL_INSTRUCTIONS}
263
-
264
- ${BUBBLE_SPECIFIC_INSTRUCTIONS}
265
-
266
- ${VALIDATION_PROCESS}`;
267
- }
268
- createStreamingSystemPrompt(boilerplate, bubbleDescriptions) {
269
- return `${SYSTEM_PROMPT_BASE}
270
-
271
- Here's the boilerplate template you should use as a starting point:
272
- \`\`\`typescript
273
- ${boilerplate}
274
- \`\`\`
275
-
276
- Available bubbles in the system:
277
- ${bubbleDescriptions}
278
-
279
- ${CRITICAL_INSTRUCTIONS}
280
-
281
- ${VALIDATION_PROCESS}`;
282
- }
283
- async performAction(context) {
284
- void context;
285
- console.log('[BubbleFlowGenerator] Starting generation process...');
286
- console.log('[BubbleFlowGenerator] Prompt:', this.params.prompt);
287
- try {
288
- console.log('[BubbleFlowGenerator] Registering defaults...');
289
- await this.bubbleFactory.registerDefaults();
290
- // Get available bubbles info
291
- console.log('[BubbleFlowGenerator] Getting available bubbles...');
292
- const availableBubbles = this.bubbleFactory.listBubblesForCodeGenerator();
293
- console.log('[BubbleFlowGenerator] Available bubbles:', availableBubbles);
294
- const bubbleDescriptions = availableBubbles
295
- .map((name) => {
296
- const metadata = this.bubbleFactory.getMetadata(name);
297
- return `- ${name}: ${metadata?.shortDescription || 'No description'}`;
298
- })
299
- .join('\n');
300
- // Get boilerplate template
301
- console.log('[BubbleFlowGenerator] Generating boilerplate template...');
302
- const boilerplate = this.bubbleFactory.generateBubbleFlowBoilerplate();
303
- // Create AI agent with validation tool attached
304
- console.log('[BubbleFlowGenerator] Creating AI agent with validation tool...');
305
- const aiAgent = new AIAgentBubble({
306
- name: 'Bubble Flow Generator Agent',
307
- message: `Generate a complete BubbleFlow TypeScript class based on this request: "${this.params.prompt}"`,
308
- systemPrompt: this.createSystemPrompt(boilerplate, bubbleDescriptions),
309
- model: AI_MODEL_CONFIG,
310
- tools: [
311
- {
312
- name: TOOL_NAMES.VALIDATION,
313
- credentials: this.params.credentials || {},
314
- },
315
- {
316
- name: TOOL_NAMES.BUBBLE_DETAILS,
317
- credentials: this.params.credentials || {},
318
- },
319
- ],
320
- maxIterations: MAX_ITERATIONS,
321
- credentials: this.params.credentials,
322
- }, this.context);
323
- // Generate the code
324
- console.log('[BubbleFlowGenerator] Starting AI agent execution...');
325
- const result = await aiAgent.action();
326
- console.log('[BubbleFlowGenerator] AI agent execution completed');
327
- console.log('[BubbleFlowGenerator] Result success:', result.success);
328
- console.log('[BubbleFlowGenerator] Result error:', result.error);
329
- console.log('[BubbleFlowGenerator] Response length:', result.data?.response?.length || 0);
330
- if (!result.success || !result.data?.response) {
331
- console.log('[BubbleFlowGenerator] AI agent failed or no response');
332
- return {
333
- toolCalls: [],
334
- generatedCode: '',
335
- isValid: false,
336
- success: false,
337
- error: result.error || 'Failed to generate code',
338
- summary: '',
339
- inputsSchema: '',
340
- bubblesUsed: [],
341
- };
342
- }
343
- console.log('[BubbleFlowGenerator] Processing AI response...');
344
- const generatedCode = result.data.response
345
- .replace(/```typescript/g, '')
346
- .replace(/```/g, '')
347
- .trim();
348
- // Check if the AI made any tool calls and get validation from the last one
349
- let isValid = true;
350
- let validationError = '';
351
- let bubblesUsed = [];
352
- let needsValidationAgent = false;
353
- if (result.data.toolCalls && result.data.toolCalls.length > 0) {
354
- console.log('[BubbleFlowGenerator] Found', result.data.toolCalls.length, 'tool calls');
355
- // Get the last tool call (should be the validation)
356
- const lastToolCall = result.data.toolCalls[result.data.toolCalls.length - 1];
357
- console.log('[BubbleFlowGenerator] Last tool call:', lastToolCall.tool);
358
- if ((lastToolCall.tool === TOOL_NAMES.VALIDATION ||
359
- lastToolCall.tool === 'bubbleflow-validation') &&
360
- lastToolCall.output) {
361
- console.log('[BubbleFlowGenerator] Using validation tool result');
362
- try {
363
- // Handle ToolMessage object with content property
364
- let validationContent;
365
- if (lastToolCall.output instanceof ToolMessage) {
366
- const content = lastToolCall.output.content;
367
- validationContent =
368
- typeof content === 'string' ? content : JSON.stringify(content);
369
- }
370
- else if (typeof lastToolCall.output === 'object' &&
371
- lastToolCall.output !== null &&
372
- 'content' in lastToolCall.output) {
373
- const content = lastToolCall.output.content;
374
- validationContent =
375
- typeof content === 'string' ? content : JSON.stringify(content);
376
- }
377
- else if (typeof lastToolCall.output === 'string') {
378
- validationContent = lastToolCall.output;
379
- }
380
- else {
381
- console.log('[BubbleFlowGenerator] Unexpected output type:', typeof lastToolCall.output);
382
- validationContent = JSON.stringify(lastToolCall.output);
383
- }
384
- const parsedResult = JSON.parse(validationContent);
385
- console.log('[BubbleFlowGenerator] 🔍 Validation tool output structure:', {
386
- hasData: !!parsedResult.data,
387
- hasTopLevelValid: 'valid' in parsedResult,
388
- hasNestedValid: parsedResult.data && 'valid' in parsedResult.data,
389
- topLevelValid: parsedResult.valid,
390
- nestedValid: parsedResult.data?.valid,
391
- });
392
- // Unwrap the result if it's wrapped in a data object
393
- // The ToolBubble base class wraps results in { success, data, error }
394
- const validationResult = parsedResult.data || parsedResult;
395
- isValid = validationResult.valid === true;
396
- validationError =
397
- validationResult.error ||
398
- (validationResult.errors && validationResult.errors.join('; ')) ||
399
- '';
400
- // Extract bubble names from validation result
401
- bubblesUsed = extractBubbleNames(validationResult);
402
- console.log('[BubbleFlowGenerator] ✅ Validation result - valid:', isValid, 'needsAgent:', !isValid, 'bubblesUsed:', bubblesUsed);
403
- // If validation ran but code is still invalid, trigger validationAgent to self-heal
404
- if (!isValid) {
405
- console.log('[BubbleFlowGenerator] ⚠️ Validation FAILED, will spawn validation agent. Errors:', validationError);
406
- needsValidationAgent = true;
407
- }
408
- else {
409
- console.log('[BubbleFlowGenerator] ✓ Validation PASSED, no validation agent needed');
410
- }
411
- }
412
- catch (parseError) {
413
- console.log('[BubbleFlowGenerator] Failed to parse validation output:', parseError);
414
- // Fallback to assuming valid if we can't parse
415
- isValid = true;
416
- }
417
- }
418
- else {
419
- console.log('[BubbleFlowGenerator] No validation tool call found from AI agent - will run validationAgent');
420
- needsValidationAgent = true;
421
- }
422
- }
423
- else {
424
- console.log('[BubbleFlowGenerator] No tool calls found - will run validationAgent');
425
- needsValidationAgent = true;
426
- }
427
- if (needsValidationAgent) {
428
- console.log('[BubbleFlowGenerator] Spawning validationAgent to validate code...');
429
- const { validatedCode, isValid: validated, validationError: vErr, bubblesUsed: validationBubbles, } = await this.runValidationAgent(generatedCode, this.params.credentials);
430
- isValid = validated;
431
- validationError = vErr;
432
- bubblesUsed = validationBubbles;
433
- const { summary, inputsSchema } = isValid
434
- ? await this.runSummarizeAgent(validatedCode, this.params.credentials)
435
- : { summary: '', inputsSchema: '' };
436
- return {
437
- toolCalls: result.data.toolCalls,
438
- generatedCode: validatedCode,
439
- isValid,
440
- success: true,
441
- error: validationError,
442
- summary,
443
- inputsSchema,
444
- bubblesUsed,
445
- };
446
- }
447
- console.log('[BubbleFlowGenerator] Generation completed');
448
- console.log('[BubbleFlowGenerator] Validation status:', isValid);
449
- console.log('[BubbleFlowGenerator] Validation error:', validationError);
450
- // Always return success=true if we got code, but include validation status
451
- // This allows the IDE to display the code even if validation failed
452
- const { summary, inputsSchema } = isValid
453
- ? await this.runSummarizeAgent(generatedCode, this.params.credentials)
454
- : { summary: '', inputsSchema: '' };
455
- return {
456
- toolCalls: result.data.toolCalls,
457
- generatedCode,
458
- isValid,
459
- success: true, // Always true if we have code
460
- error: validationError, // Include validation error for reference
461
- summary,
462
- inputsSchema,
463
- bubblesUsed,
464
- };
465
- }
466
- catch (error) {
467
- console.error('[BubbleFlowGenerator] Error during generation:', error);
468
- return {
469
- toolCalls: [],
470
- generatedCode: '',
471
- isValid: false,
472
- success: false,
473
- error: error instanceof Error
474
- ? error.message
475
- : 'Unknown error during generation',
476
- summary: '',
477
- inputsSchema: '',
478
- bubblesUsed: [],
479
- };
480
- }
481
- }
482
- /**
483
- * Execute the workflow with streaming support for real-time code generation feedback
484
- */
485
- async actionWithStreaming(streamingCallback, context) {
486
- void context;
487
- console.log('[BubbleFlowGenerator] Starting streaming generation process with prompt: ' +
488
- this.params.prompt);
489
- console.log('[BubbleFlowGenerator] Prompt:', this.params.prompt);
490
- try {
491
- await streamingCallback({
492
- type: 'start',
493
- data: {
494
- message: `Generating BubbleFlow code for: ${this.params.prompt}`,
495
- maxIterations: MAX_ITERATIONS,
496
- timestamp: new Date().toISOString(),
497
- },
498
- });
499
- console.log('[BubbleFlowGenerator] Registering defaults...');
500
- await this.bubbleFactory.registerDefaults();
501
- // Get available bubbles info
502
- console.log('[BubbleFlowGenerator] Getting available bubbles...');
503
- const availableBubbles = this.bubbleFactory.listBubblesForCodeGenerator();
504
- console.log('[BubbleFlowGenerator] Available bubbles:', availableBubbles);
505
- await streamingCallback({
506
- type: 'tool_start',
507
- data: {
508
- tool: 'bubble-discovery',
509
- input: { action: 'listing_available_bubbles' },
510
- callId: 'discovery-1',
511
- },
512
- });
513
- const bubbleDescriptions = availableBubbles
514
- .map((name) => {
515
- const metadata = this.bubbleFactory.getMetadata(name);
516
- return `- ${name}: ${metadata?.shortDescription || 'No description'}`;
517
- })
518
- .join('\n');
519
- await streamingCallback({
520
- type: 'tool_complete',
521
- data: {
522
- callId: 'discovery-1',
523
- tool: 'bubble-discovery',
524
- input: {
525
- action: 'listing_available_bubbles',
526
- },
527
- output: {
528
- availableBubbles: availableBubbles.length,
529
- descriptions: bubbleDescriptions,
530
- },
531
- duration: 100,
532
- },
533
- });
534
- // Get boilerplate template
535
- console.log('[BubbleFlowGenerator] Generating boilerplate template...');
536
- const boilerplate = this.bubbleFactory.generateBubbleFlowBoilerplate();
537
- await streamingCallback({
538
- type: 'tool_start',
539
- data: {
540
- tool: 'template-generation',
541
- input: { action: 'generating_boilerplate' },
542
- callId: 'template-1',
543
- },
544
- });
545
- await streamingCallback({
546
- type: 'tool_complete',
547
- data: {
548
- tool: 'template-generation',
549
- input: { action: 'generating_boilerplate' },
550
- callId: 'template-1',
551
- output: { templateGenerated: true, length: boilerplate.length },
552
- duration: 50,
553
- },
554
- });
555
- // Create AI agent with validation tool attached
556
- console.log('[BubbleFlowGenerator] Creating AI agent with validation tool...');
557
- const aiAgent = new AIAgentBubble({
558
- name: 'Bubble Flow Generator Agent',
559
- message: `Generate a complete BubbleFlow TypeScript class based on this request: "${this.params.prompt}"`,
560
- systemPrompt: this.createStreamingSystemPrompt(boilerplate, bubbleDescriptions),
561
- model: AI_MODEL_CONFIG,
562
- tools: [
563
- {
564
- name: TOOL_NAMES.VALIDATION,
565
- credentials: this.params.credentials || {},
566
- },
567
- {
568
- name: TOOL_NAMES.BUBBLE_DETAILS,
569
- credentials: this.params.credentials || {},
570
- },
571
- ],
572
- maxIterations: MAX_ITERATIONS,
573
- credentials: this.params.credentials,
574
- }, this.context);
575
- // Generate the code with streaming
576
- console.log('[BubbleFlowGenerator] Starting AI agent execution with streaming...');
577
- const result = await aiAgent.actionWithStreaming(streamingCallback);
578
- console.log('[BubbleFlowGenerator] AI agent execution completed');
579
- console.log('[BubbleFlowGenerator] Result success:', result.success);
580
- if (!result.success || !result.response) {
581
- console.log('[BubbleFlowGenerator] AI agent failed or no response');
582
- return {
583
- toolCalls: result.toolCalls,
584
- generatedCode: '',
585
- isValid: false,
586
- success: false,
587
- error: result.error || 'Failed to generate code',
588
- summary: '',
589
- inputsSchema: '',
590
- bubblesUsed: [],
591
- };
592
- }
593
- let generatedCode = result.response
594
- .replace(/```typescript/g, '')
595
- .replace(/```/g, '')
596
- .trim();
597
- // Check validation status from tool calls
598
- let isValid = true;
599
- let validationError = '';
600
- let bubblesUsed = [];
601
- console.log('[BubbleFlowGenerator] Checking validation status...');
602
- let needsValidationAgent = false;
603
- if (result.toolCalls && result.toolCalls.length > 0) {
604
- // Get the last tool call (should be the validation)
605
- const lastToolCall = result.toolCalls[result.toolCalls.length - 1];
606
- if ((lastToolCall.tool === TOOL_NAMES.VALIDATION ||
607
- lastToolCall.tool === 'bubbleflow-validation') &&
608
- lastToolCall.output) {
609
- try {
610
- // Handle ToolMessage object with content property
611
- let validationContent;
612
- console.log('[BubbleFlowGenerator] Last tool call output:', lastToolCall.input);
613
- // Parse the input as a JSON object
614
- const input = JSON.parse(lastToolCall.input.input);
615
- generatedCode = input.code;
616
- if (lastToolCall.output instanceof ToolMessage) {
617
- const content = lastToolCall.output.content;
618
- validationContent =
619
- typeof content === 'string' ? content : JSON.stringify(content);
620
- }
621
- else if (typeof lastToolCall.output === 'object' &&
622
- lastToolCall.output !== null &&
623
- 'content' in lastToolCall.output) {
624
- const content = lastToolCall.output.content;
625
- validationContent =
626
- typeof content === 'string' ? content : JSON.stringify(content);
627
- }
628
- else if (typeof lastToolCall.output === 'string') {
629
- validationContent = lastToolCall.output;
630
- }
631
- else {
632
- console.log('[BubbleFlowGenerator] Unexpected output type:', typeof lastToolCall.output);
633
- validationContent = JSON.stringify(lastToolCall.output);
634
- }
635
- const parsedResult = JSON.parse(validationContent);
636
- console.log('[BubbleFlowGenerator] 🔍 Validation agent output structure:', {
637
- hasData: !!parsedResult.data,
638
- hasTopLevelValid: 'valid' in parsedResult,
639
- hasNestedValid: parsedResult.data && 'valid' in parsedResult.data,
640
- topLevelValid: parsedResult.valid,
641
- nestedValid: parsedResult.data?.valid,
642
- });
643
- // Unwrap the result if it's wrapped in a data object
644
- const validationResult = parsedResult.data || parsedResult;
645
- isValid = validationResult.valid === true;
646
- validationError =
647
- validationResult.error ||
648
- (validationResult.errors && validationResult.errors.join('; ')) ||
649
- '';
650
- // Extract bubble names from validation result
651
- bubblesUsed = extractBubbleNames(validationResult);
652
- console.log('[BubbleFlowGenerator] ✅ Validation agent result - valid:', isValid, 'bubblesUsed:', bubblesUsed);
653
- if (!isValid) {
654
- console.log('[BubbleFlowGenerator] ⚠️ Validation agent says INVALID, will try again. First error:', validationResult.errors?.[0]?.substring(0, 100));
655
- needsValidationAgent = true;
656
- }
657
- else {
658
- console.log('[BubbleFlowGenerator] ✓ Validation agent says VALID');
659
- }
660
- }
661
- catch (parseError) {
662
- console.log('Failed to parse validation output:', parseError);
663
- console.log('Raw output:', lastToolCall.output);
664
- isValid = true; // Fallback
665
- }
666
- }
667
- else {
668
- // No validation tool call found - run a dedicated validationAgent
669
- console.log('[BubbleFlowGenerator] No validation tool call found - will run validationAgent');
670
- needsValidationAgent = true;
671
- }
672
- }
673
- else {
674
- console.log('[BubbleFlowGenerator] No tool calls found - will run validationAgent');
675
- needsValidationAgent = true;
676
- }
677
- if (needsValidationAgent) {
678
- await streamingCallback({
679
- type: 'tool_start',
680
- data: {
681
- tool: 'validation-agent',
682
- input: { action: 'validating_generated_code' },
683
- callId: 'validation-agent-1',
684
- },
685
- });
686
- const { validatedCode, isValid: validated, validationError: vErr, bubblesUsed: validationBubbles, } = await this.runValidationAgent(generatedCode, this.params.credentials, streamingCallback);
687
- await streamingCallback({
688
- type: 'tool_complete',
689
- data: {
690
- tool: 'validation-agent',
691
- input: { action: 'validating_generated_code' },
692
- callId: 'validation-agent-1',
693
- output: { success: validated },
694
- duration: 100,
695
- },
696
- });
697
- isValid = validated;
698
- validationError = vErr;
699
- bubblesUsed = validationBubbles;
700
- let summary = '';
701
- let inputsSchema = '';
702
- if (isValid) {
703
- await streamingCallback({
704
- type: 'tool_start',
705
- data: {
706
- tool: 'summary-agent',
707
- input: { action: 'generating_summary_and_schema' },
708
- callId: 'summary-agent-1',
709
- },
710
- });
711
- const summaryResult = await this.runSummarizeAgent(validatedCode, this.params.credentials, streamingCallback);
712
- summary = summaryResult.summary;
713
- inputsSchema = summaryResult.inputsSchema;
714
- await streamingCallback({
715
- type: 'tool_complete',
716
- data: {
717
- callId: 'summary-agent-1',
718
- tool: 'summary-agent',
719
- input: { action: 'generating_summary_and_schema' },
720
- output: {
721
- summaryGenerated: !!summary,
722
- schemaGenerated: !!inputsSchema,
723
- },
724
- duration: 100,
725
- },
726
- });
727
- }
728
- return {
729
- toolCalls: result.toolCalls,
730
- generatedCode: validatedCode,
731
- isValid,
732
- success: true,
733
- error: validationError,
734
- summary,
735
- inputsSchema,
736
- bubblesUsed,
737
- };
738
- }
739
- console.log('[BubbleFlowGenerator] Streaming generation completed');
740
- console.log('[BubbleFlowGenerator] Validation status:', isValid);
741
- console.log('[BubbleFlowGenerator] Validation error:', validationError);
742
- // Note: Bubble parameters extraction is now handled at the route level
743
- let summary = '';
744
- let inputsSchema = '';
745
- if (isValid) {
746
- await streamingCallback({
747
- type: 'tool_start',
748
- data: {
749
- tool: 'summary-agent',
750
- input: { action: 'generating_summary_and_schema' },
751
- callId: 'summary-agent-final',
752
- },
753
- });
754
- const summaryResult = await this.runSummarizeAgent(generatedCode, this.params.credentials, streamingCallback);
755
- summary = summaryResult.summary;
756
- inputsSchema = summaryResult.inputsSchema;
757
- await streamingCallback({
758
- type: 'tool_complete',
759
- data: {
760
- callId: 'summary-agent-final',
761
- tool: 'summary-agent',
762
- input: { action: 'generating_summary_and_schema' },
763
- output: {
764
- summaryGenerated: !!summary,
765
- schemaGenerated: !!inputsSchema,
766
- },
767
- duration: 100,
768
- },
769
- });
770
- }
771
- return {
772
- toolCalls: result.toolCalls,
773
- generatedCode,
774
- isValid,
775
- success: true,
776
- error: validationError,
777
- summary,
778
- inputsSchema,
779
- bubblesUsed,
780
- };
781
- }
782
- catch (error) {
783
- console.error('[BubbleFlowGenerator] Error during streaming generation:', error);
784
- await streamingCallback({
785
- type: 'error',
786
- data: {
787
- error: error instanceof Error
788
- ? error.message
789
- : 'Unknown error during generation',
790
- recoverable: true, // Mark workflow errors as recoverable
791
- },
792
- });
793
- return {
794
- toolCalls: [],
795
- generatedCode: '',
796
- isValid: false,
797
- success: false,
798
- error: error instanceof Error
799
- ? error.message
800
- : 'Unknown error during generation',
801
- summary: '',
802
- inputsSchema: '',
803
- bubblesUsed: [],
804
- };
805
- }
806
- }
807
- }
808
- //# sourceMappingURL=bubbleflow-generator.workflow.js.map