@bubblelab/bubble-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/LICENSE.txt +202 -0
  2. package/dist/bubble-bundle.d.ts +2021 -0
  3. package/dist/bubble-factory.d.ts +161 -0
  4. package/dist/bubble-factory.d.ts.map +1 -0
  5. package/dist/bubble-factory.js +426 -0
  6. package/dist/bubble-factory.js.map +1 -0
  7. package/dist/bubble-flow/bubble-flow-class.d.ts +19 -0
  8. package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -0
  9. package/dist/bubble-flow/bubble-flow-class.js +23 -0
  10. package/dist/bubble-flow/bubble-flow-class.js.map +1 -0
  11. package/dist/bubble-flow/sample/data-analyst-flow.d.ts +15 -0
  12. package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -0
  13. package/dist/bubble-flow/sample/data-analyst-flow.js +63 -0
  14. package/dist/bubble-flow/sample/data-analyst-flow.js.map +1 -0
  15. package/dist/bubble-flow/sample/error-ts.d.ts +23 -0
  16. package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -0
  17. package/dist/bubble-flow/sample/error-ts.js +31 -0
  18. package/dist/bubble-flow/sample/error-ts.js.map +1 -0
  19. package/dist/bubble-flow/sample/sanitytest.d.ts +10 -0
  20. package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -0
  21. package/dist/bubble-flow/sample/sanitytest.js +13 -0
  22. package/dist/bubble-flow/sample/sanitytest.js.map +1 -0
  23. package/dist/bubble-flow/sample/simple-webhook-2.d.ts +19 -0
  24. package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -0
  25. package/dist/bubble-flow/sample/simple-webhook-2.js +23 -0
  26. package/dist/bubble-flow/sample/simple-webhook-2.js.map +1 -0
  27. package/dist/bubble-flow/sample/simple-webhook.d.ts +10 -0
  28. package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -0
  29. package/dist/bubble-flow/sample/simple-webhook.js +18 -0
  30. package/dist/bubble-flow/sample/simple-webhook.js.map +1 -0
  31. package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +29 -0
  32. package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -0
  33. package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +150 -0
  34. package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -0
  35. package/dist/bubble-flow/sample/slack-v0.1.d.ts +10 -0
  36. package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -0
  37. package/dist/bubble-flow/sample/slack-v0.1.js +59 -0
  38. package/dist/bubble-flow/sample/slack-v0.1.js.map +1 -0
  39. package/dist/bubble-flow/sample/slackagenttest.d.ts +10 -0
  40. package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -0
  41. package/dist/bubble-flow/sample/slackagenttest.js +59 -0
  42. package/dist/bubble-flow/sample/slackagenttest.js.map +1 -0
  43. package/dist/bubble-trigger/index.d.ts +2 -0
  44. package/dist/bubble-trigger/index.d.ts.map +1 -0
  45. package/dist/bubble-trigger/index.js +2 -0
  46. package/dist/bubble-trigger/index.js.map +1 -0
  47. package/dist/bubble-trigger/types.d.ts +87 -0
  48. package/dist/bubble-trigger/types.d.ts.map +1 -0
  49. package/dist/bubble-trigger/types.js +14 -0
  50. package/dist/bubble-trigger/types.js.map +1 -0
  51. package/dist/bubbles/service-bubble/ai-agent.d.ts +428 -0
  52. package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -0
  53. package/dist/bubbles/service-bubble/ai-agent.js +881 -0
  54. package/dist/bubbles/service-bubble/ai-agent.js.map +1 -0
  55. package/dist/bubbles/service-bubble/gmail.d.ts +3073 -0
  56. package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -0
  57. package/dist/bubbles/service-bubble/gmail.js +908 -0
  58. package/dist/bubbles/service-bubble/gmail.js.map +1 -0
  59. package/dist/bubbles/service-bubble/google-calendar.d.ts +3377 -0
  60. package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -0
  61. package/dist/bubbles/service-bubble/google-calendar.js +527 -0
  62. package/dist/bubbles/service-bubble/google-calendar.js.map +1 -0
  63. package/dist/bubbles/service-bubble/google-drive.d.ts +1152 -0
  64. package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -0
  65. package/dist/bubbles/service-bubble/google-drive.js +943 -0
  66. package/dist/bubbles/service-bubble/google-drive.js.map +1 -0
  67. package/dist/bubbles/service-bubble/google-sheets.d.ts +1811 -0
  68. package/dist/bubbles/service-bubble/google-sheets.d.ts.map +1 -0
  69. package/dist/bubbles/service-bubble/google-sheets.js +904 -0
  70. package/dist/bubbles/service-bubble/google-sheets.js.map +1 -0
  71. package/dist/bubbles/service-bubble/hello-world.d.ts +74 -0
  72. package/dist/bubbles/service-bubble/hello-world.d.ts.map +1 -0
  73. package/dist/bubbles/service-bubble/hello-world.js +67 -0
  74. package/dist/bubbles/service-bubble/hello-world.js.map +1 -0
  75. package/dist/bubbles/service-bubble/http.d.ts +134 -0
  76. package/dist/bubbles/service-bubble/http.d.ts.map +1 -0
  77. package/dist/bubbles/service-bubble/http.js +184 -0
  78. package/dist/bubbles/service-bubble/http.js.map +1 -0
  79. package/dist/bubbles/service-bubble/postgresql.d.ts +180 -0
  80. package/dist/bubbles/service-bubble/postgresql.d.ts.map +1 -0
  81. package/dist/bubbles/service-bubble/postgresql.js +448 -0
  82. package/dist/bubbles/service-bubble/postgresql.js.map +1 -0
  83. package/dist/bubbles/service-bubble/resend.d.ts +301 -0
  84. package/dist/bubbles/service-bubble/resend.d.ts.map +1 -0
  85. package/dist/bubbles/service-bubble/resend.js +253 -0
  86. package/dist/bubbles/service-bubble/resend.js.map +1 -0
  87. package/dist/bubbles/service-bubble/slack.d.ts +5869 -0
  88. package/dist/bubbles/service-bubble/slack.d.ts.map +1 -0
  89. package/dist/bubbles/service-bubble/slack.js +1536 -0
  90. package/dist/bubbles/service-bubble/slack.js.map +1 -0
  91. package/dist/bubbles/service-bubble/storage.d.ts +571 -0
  92. package/dist/bubbles/service-bubble/storage.d.ts.map +1 -0
  93. package/dist/bubbles/service-bubble/storage.js +504 -0
  94. package/dist/bubbles/service-bubble/storage.js.map +1 -0
  95. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +308 -0
  96. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -0
  97. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +285 -0
  98. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -0
  99. package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +416 -0
  100. package/dist/bubbles/tool-bubble/chart-js-tool.d.ts.map +1 -0
  101. package/dist/bubbles/tool-bubble/chart-js-tool.js +570 -0
  102. package/dist/bubbles/tool-bubble/chart-js-tool.js.map +1 -0
  103. package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +99 -0
  104. package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -0
  105. package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +645 -0
  106. package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -0
  107. package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +112 -0
  108. package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts.map +1 -0
  109. package/dist/bubbles/tool-bubble/list-bubbles-tool.js +82 -0
  110. package/dist/bubbles/tool-bubble/list-bubbles-tool.js.map +1 -0
  111. package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +413 -0
  112. package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -0
  113. package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +327 -0
  114. package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -0
  115. package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +122 -0
  116. package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -0
  117. package/dist/bubbles/tool-bubble/research-agent-tool.js +343 -0
  118. package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -0
  119. package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +131 -0
  120. package/dist/bubbles/tool-bubble/sql-query-tool.d.ts.map +1 -0
  121. package/dist/bubbles/tool-bubble/sql-query-tool.js +147 -0
  122. package/dist/bubbles/tool-bubble/sql-query-tool.js.map +1 -0
  123. package/dist/bubbles/tool-bubble/tool-template.d.ts +257 -0
  124. package/dist/bubbles/tool-bubble/tool-template.d.ts.map +1 -0
  125. package/dist/bubbles/tool-bubble/tool-template.js +238 -0
  126. package/dist/bubbles/tool-bubble/tool-template.js.map +1 -0
  127. package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts +8 -0
  128. package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts.map +1 -0
  129. package/dist/bubbles/tool-bubble/virtual-file-editor-example.js +65 -0
  130. package/dist/bubbles/tool-bubble/virtual-file-editor-example.js.map +1 -0
  131. package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts +125 -0
  132. package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts.map +1 -0
  133. package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js +169 -0
  134. package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js.map +1 -0
  135. package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +218 -0
  136. package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -0
  137. package/dist/bubbles/tool-bubble/web-crawl-tool.js +255 -0
  138. package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -0
  139. package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +134 -0
  140. package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -0
  141. package/dist/bubbles/tool-bubble/web-extract-tool.js +175 -0
  142. package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -0
  143. package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +228 -0
  144. package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -0
  145. package/dist/bubbles/tool-bubble/web-scrape-tool.js +214 -0
  146. package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -0
  147. package/dist/bubbles/tool-bubble/web-search-tool.d.ts +134 -0
  148. package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -0
  149. package/dist/bubbles/tool-bubble/web-search-tool.js +155 -0
  150. package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -0
  151. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +114 -0
  152. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -0
  153. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +777 -0
  154. package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -0
  155. package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts +97 -0
  156. package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts.map +1 -0
  157. package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js +327 -0
  158. package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js.map +1 -0
  159. package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +303 -0
  160. package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts.map +1 -0
  161. package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js +297 -0
  162. package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js.map +1 -0
  163. package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts +157 -0
  164. package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts.map +1 -0
  165. package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js +310 -0
  166. package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js.map +1 -0
  167. package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +543 -0
  168. package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts.map +1 -0
  169. package/dist/bubbles/workflow-bubble/generate-document.workflow.js +628 -0
  170. package/dist/bubbles/workflow-bubble/generate-document.workflow.js.map +1 -0
  171. package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +679 -0
  172. package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts.map +1 -0
  173. package/dist/bubbles/workflow-bubble/parse-document.workflow.js +604 -0
  174. package/dist/bubbles/workflow-bubble/parse-document.workflow.js.map +1 -0
  175. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +1011 -0
  176. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -0
  177. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +841 -0
  178. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -0
  179. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +883 -0
  180. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -0
  181. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +781 -0
  182. package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -0
  183. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +300 -0
  184. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -0
  185. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +508 -0
  186. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -0
  187. package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +731 -0
  188. package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -0
  189. package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +690 -0
  190. package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -0
  191. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +401 -0
  192. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -0
  193. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +382 -0
  194. package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -0
  195. package/dist/bubbles/workflow-bubble/workflow-template.d.ts +144 -0
  196. package/dist/bubbles/workflow-bubble/workflow-template.d.ts.map +1 -0
  197. package/dist/bubbles/workflow-bubble/workflow-template.js +124 -0
  198. package/dist/bubbles/workflow-bubble/workflow-template.js.map +1 -0
  199. package/dist/index.d.ts +46 -0
  200. package/dist/index.d.ts.map +1 -0
  201. package/dist/index.js +53 -0
  202. package/dist/index.js.map +1 -0
  203. package/dist/logging/BubbleLogger.d.ts +146 -0
  204. package/dist/logging/BubbleLogger.d.ts.map +1 -0
  205. package/dist/logging/BubbleLogger.js +472 -0
  206. package/dist/logging/BubbleLogger.js.map +1 -0
  207. package/dist/logging/StreamingBubbleLogger.d.ts +85 -0
  208. package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -0
  209. package/dist/logging/StreamingBubbleLogger.js +340 -0
  210. package/dist/logging/StreamingBubbleLogger.js.map +1 -0
  211. package/dist/types/ai-models.d.ts +4 -0
  212. package/dist/types/ai-models.d.ts.map +1 -0
  213. package/dist/types/ai-models.js +14 -0
  214. package/dist/types/ai-models.js.map +1 -0
  215. package/dist/types/available-tools.d.ts +4 -0
  216. package/dist/types/available-tools.d.ts.map +1 -0
  217. package/dist/types/available-tools.js +19 -0
  218. package/dist/types/available-tools.js.map +1 -0
  219. package/dist/types/base-bubble-class.d.ts +47 -0
  220. package/dist/types/base-bubble-class.d.ts.map +1 -0
  221. package/dist/types/base-bubble-class.js +212 -0
  222. package/dist/types/base-bubble-class.js.map +1 -0
  223. package/dist/types/bubble-errors.d.ts +44 -0
  224. package/dist/types/bubble-errors.d.ts.map +1 -0
  225. package/dist/types/bubble-errors.js +51 -0
  226. package/dist/types/bubble-errors.js.map +1 -0
  227. package/dist/types/bubble.d.ts +73 -0
  228. package/dist/types/bubble.d.ts.map +1 -0
  229. package/dist/types/bubble.js +2 -0
  230. package/dist/types/bubble.js.map +1 -0
  231. package/dist/types/credentials.d.ts +6 -0
  232. package/dist/types/credentials.d.ts.map +1 -0
  233. package/dist/types/credentials.js +6 -0
  234. package/dist/types/credentials.js.map +1 -0
  235. package/dist/types/service-bubble-class.d.ts +31 -0
  236. package/dist/types/service-bubble-class.d.ts.map +1 -0
  237. package/dist/types/service-bubble-class.js +36 -0
  238. package/dist/types/service-bubble-class.js.map +1 -0
  239. package/dist/types/streaming-events.d.ts +18 -0
  240. package/dist/types/streaming-events.d.ts.map +1 -0
  241. package/dist/types/streaming-events.js +5 -0
  242. package/dist/types/streaming-events.js.map +1 -0
  243. package/dist/types/tool-bubble-class.d.ts +19 -0
  244. package/dist/types/tool-bubble-class.d.ts.map +1 -0
  245. package/dist/types/tool-bubble-class.js +48 -0
  246. package/dist/types/tool-bubble-class.js.map +1 -0
  247. package/dist/types/workflow-bubble-class.d.ts +25 -0
  248. package/dist/types/workflow-bubble-class.d.ts.map +1 -0
  249. package/dist/types/workflow-bubble-class.js +30 -0
  250. package/dist/types/workflow-bubble-class.js.map +1 -0
  251. package/dist/utils/bubbleflow-parser.d.ts +32 -0
  252. package/dist/utils/bubbleflow-parser.d.ts.map +1 -0
  253. package/dist/utils/bubbleflow-parser.js +332 -0
  254. package/dist/utils/bubbleflow-parser.js.map +1 -0
  255. package/dist/utils/bubbleflow-validation.d.ts +9 -0
  256. package/dist/utils/bubbleflow-validation.d.ts.map +1 -0
  257. package/dist/utils/bubbleflow-validation.js +116 -0
  258. package/dist/utils/bubbleflow-validation.js.map +1 -0
  259. package/dist/utils/json-parsing.d.ts +20 -0
  260. package/dist/utils/json-parsing.d.ts.map +1 -0
  261. package/dist/utils/json-parsing.js +394 -0
  262. package/dist/utils/json-parsing.js.map +1 -0
  263. package/dist/utils/mock-data-generator.d.ts +43 -0
  264. package/dist/utils/mock-data-generator.d.ts.map +1 -0
  265. package/dist/utils/mock-data-generator.js +312 -0
  266. package/dist/utils/mock-data-generator.js.map +1 -0
  267. package/dist/utils/param-helper.d.ts +2 -0
  268. package/dist/utils/param-helper.d.ts.map +1 -0
  269. package/dist/utils/param-helper.js +5 -0
  270. package/dist/utils/param-helper.js.map +1 -0
  271. package/dist/utils/source-bubble-parser.d.ts +31 -0
  272. package/dist/utils/source-bubble-parser.d.ts.map +1 -0
  273. package/dist/utils/source-bubble-parser.js +231 -0
  274. package/dist/utils/source-bubble-parser.js.map +1 -0
  275. package/package.json +63 -0
@@ -0,0 +1,343 @@
1
+ import { z } from 'zod';
2
+ import { ToolBubble } from '../../types/tool-bubble-class.js';
3
+ import { CredentialType } from '@bubblelab/shared-schemas';
4
+ import { AIAgentBubble } from '../service-bubble/ai-agent.js';
5
+ import { AvailableModels } from '../../types/ai-models.js';
6
+ import { parseJsonWithFallbacks } from '../../utils/json-parsing.js';
7
+ // Schema for the expected JSON result structure
8
+ const ExpectedResultSchema = z
9
+ .string()
10
+ .describe('JSON schema string defining the expected structure of the research result');
11
+ // Define the parameters schema for the Research Agent Tool
12
+ const ResearchAgentToolParamsSchema = z.object({
13
+ task: z
14
+ .string()
15
+ .min(1, 'Research task is required')
16
+ .describe('The research task that requires searching the internet and gathering information'),
17
+ expectedResultSchema: ExpectedResultSchema.describe('JSON schema string that defines the expected structure of the research result. Out'),
18
+ model: AvailableModels.describe('Model to use for the research agent (default: google/gemini-2.5-flash)')
19
+ .default('google/gemini-2.5-flash')
20
+ .optional()
21
+ .describe('Model to use for the research agent (default: google/gemini-2.5-flash)'),
22
+ maxTokens: z
23
+ .number()
24
+ .min(40000)
25
+ .default(40000)
26
+ .optional()
27
+ .describe('Maximum number of tokens for the research agent (default: 40000)'),
28
+ maxIterations: z
29
+ .number()
30
+ .min(1)
31
+ .max(100)
32
+ .default(100)
33
+ .describe('Maximum number of iterations for the research agent (default: 100)'),
34
+ credentials: z
35
+ .record(z.nativeEnum(CredentialType), z.string())
36
+ .optional()
37
+ .describe('Required credentials'),
38
+ });
39
+ // Result schema for the research agent tool
40
+ const ResearchAgentToolResultSchema = z.object({
41
+ result: z
42
+ .any(z.unknown())
43
+ .describe('The research result matching the expected JSON schema structure, parsed to object'),
44
+ summary: z
45
+ .string()
46
+ .describe('1-2 sentence summary of what research was conducted and completed'),
47
+ sourcesUsed: z
48
+ .array(z.string())
49
+ .describe('Array of URLs and sources that were searched and scraped during research'),
50
+ iterationsUsed: z
51
+ .number()
52
+ .describe('Number of AI agent iterations used to complete the research'),
53
+ success: z
54
+ .boolean()
55
+ .describe('Whether the research task was completed successfully'),
56
+ error: z.string().describe('Error message if research failed'),
57
+ });
58
+ export class ResearchAgentTool extends ToolBubble {
59
+ // Required static metadata
60
+ static bubbleName = 'research-agent-tool';
61
+ static schema = ResearchAgentToolParamsSchema;
62
+ static resultSchema = ResearchAgentToolResultSchema;
63
+ static shortDescription = 'AI-powered research agent that searches and scrapes the internet to gather structured information';
64
+ static longDescription = `
65
+ A sophisticated research agent that strategically combines web search and selective web scraping to gather and structure information from the internet.
66
+
67
+ Features:
68
+ - Intelligent web search using Firecrawl's search API to find relevant sources
69
+ - Strategic web scraping - for detailed content from specific high-value pages
70
+ - Multi-page web crawling - for comprehensive coverage across entire websites
71
+ - AI-powered analysis to synthesize information into the requested JSON structure
72
+ - Up to 100 iterations for thorough research and data gathering
73
+ - Structured result formatting based on provided JSON schema
74
+ - Comprehensive source tracking and research summary
75
+
76
+ Research Strategy:
77
+ - Prioritizes efficient web search to gather comprehensive information
78
+ - Uses scraping strategically for detailed content from specific pages
79
+ - Uses crawling for comprehensive coverage across multiple related pages
80
+ - Only uses scraping/crawling when search results lack sufficient detail
81
+ - Focuses on quality over quantity in content extraction
82
+
83
+ Use cases:
84
+ - Market research with structured competitor analysis
85
+ - Academic research gathering from multiple sources
86
+ - Product research with feature comparisons
87
+ - News and trend analysis with categorized findings
88
+ - Technical research requiring documentation synthesis
89
+ - Any research task requiring web data in a specific format
90
+
91
+ The agent starts with systematic web searches, then strategically uses scraping for specific pages or crawling for comprehensive site coverage when additional detail is needed. It provides a summary of the research conducted and lists all sources used.
92
+ `;
93
+ static alias = 'research';
94
+ static type = 'tool';
95
+ constructor(params = {
96
+ task: '',
97
+ expectedResultSchema: '{"result": "string"}',
98
+ }, context) {
99
+ super(params, context);
100
+ }
101
+ async performAction(context) {
102
+ if (!this.params?.credentials?.[CredentialType.FIRECRAWL_API_KEY]) {
103
+ return {
104
+ result: {},
105
+ summary: 'Research failed: FIRECRAWL_API_KEY is required',
106
+ sourcesUsed: [],
107
+ iterationsUsed: 0,
108
+ success: false,
109
+ error: 'FIRECRAWL_API_KEY is required',
110
+ };
111
+ }
112
+ void context; // Context available but not currently used
113
+ const { task, expectedResultSchema, maxIterations } = this.params;
114
+ try {
115
+ console.log('[ResearchAgentTool] Starting research task:', task.substring(0, 100) + '...');
116
+ console.log('[ResearchAgentTool] Expected result schema:', expectedResultSchema.substring(0, 200) + '...');
117
+ console.log('[ResearchAgentTool] Max iterations:', maxIterations);
118
+ // Create the AI agent with web search and scraping tools
119
+ const researchSubAgent = new AIAgentBubble({
120
+ message: this.buildResearchPrompt(task, expectedResultSchema),
121
+ systemPrompt: this.buildSystemPrompt(),
122
+ model: {
123
+ model: this.params.model,
124
+ temperature: 0.7,
125
+ maxTokens: this.params.maxTokens,
126
+ jsonMode: true, // Enable JSON mode for structured output
127
+ },
128
+ tools: [
129
+ { name: 'web-search-tool' },
130
+ { name: 'web-scrape-tool' },
131
+ { name: 'web-crawl-tool' },
132
+ { name: 'web-extract-tool' },
133
+ { name: 'reddit-scrape-tool' },
134
+ ],
135
+ maxIterations,
136
+ credentials: this.params.credentials,
137
+ streaming: false,
138
+ }, this.context);
139
+ console.log('[ResearchAgentTool] Executing AI agent...');
140
+ const agentResult = await researchSubAgent.action();
141
+ if (!agentResult.success) {
142
+ throw new Error(`AI Agent failed: ${agentResult.error}`);
143
+ }
144
+ const agentData = agentResult.data;
145
+ console.log('[ResearchAgentTool] AI agent completed successfully');
146
+ console.log('[ResearchAgentTool] Iterations used:', agentData.iterations);
147
+ console.log('[ResearchAgentTool] Tool calls made:', agentData.toolCalls.length);
148
+ // Parse the AI agent's response as JSON with robust error handling
149
+ let parsedResult;
150
+ // Use the robust JSON parsing utilities that handle malformed JSON
151
+ const parseResult = parseJsonWithFallbacks(agentData.response);
152
+ if (!parseResult.success || parseResult.error) {
153
+ // Check if this is already a processed error from the AI agent
154
+ if (agentData.error &&
155
+ agentData.error.includes('failed to generate valid JSON')) {
156
+ throw new Error(`ResearchAgentTool failed: ${agentData.error}`);
157
+ }
158
+ // Use the robust parser's error message
159
+ throw new Error(`ResearchAgentTool failed: AI Agent returned malformed JSON that could not be parsed: ${parseResult.error}. Response: ${agentData.response.substring(0, 200)}...`);
160
+ }
161
+ try {
162
+ parsedResult = JSON.parse(parseResult.response);
163
+ }
164
+ catch (finalParseError) {
165
+ // This should not happen with the robust parser, but just in case
166
+ const originalError = finalParseError instanceof Error
167
+ ? finalParseError.message
168
+ : 'Unknown parsing error';
169
+ throw new Error(`ResearchAgentTool failed: Final JSON parsing failed after robust processing: ${originalError}. Response: ${parseResult.response.substring(0, 200)}...`);
170
+ }
171
+ // Extract sources from tool calls
172
+ const sourcesUsed = this.extractSourcesFromToolCalls(agentData.toolCalls);
173
+ // Generate summary from the research process
174
+ const summary = this.generateResearchSummary(task, agentData.toolCalls.length, sourcesUsed.length);
175
+ console.log('[ResearchAgentTool] Research completed successfully');
176
+ console.log('[ResearchAgentTool] Sources used:', sourcesUsed.length);
177
+ console.log('[ResearchAgentTool] Summary:', summary);
178
+ return {
179
+ result: parsedResult,
180
+ summary,
181
+ sourcesUsed,
182
+ iterationsUsed: agentData.iterations,
183
+ success: true,
184
+ error: '',
185
+ };
186
+ }
187
+ catch (error) {
188
+ console.error('[ResearchAgentTool] Research error:', error);
189
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
190
+ return {
191
+ result: {},
192
+ summary: `Research failed: ${errorMessage}`,
193
+ sourcesUsed: [],
194
+ iterationsUsed: 0,
195
+ success: false,
196
+ error: errorMessage,
197
+ };
198
+ }
199
+ }
200
+ /**
201
+ * Build the main research prompt for the AI agent
202
+ */
203
+ buildResearchPrompt(task, expectedResultSchema) {
204
+ return `
205
+ Research Task: ${task}
206
+
207
+ Required Output Format (JSON Schema): ${expectedResultSchema}
208
+
209
+ Instructions:
210
+ 1. Use web-search-tool to find relevant sources
211
+ 2. Analyze the sources and choose the right tool:
212
+ - If you need structured data extraction (images, prices, specific fields) → use web-extract-tool with a detailed prompt and schema
213
+ - If multiple sources come from the same website → use web-crawl-tool for that site
214
+ - If you're certain all needed info is on one specific page → use web-scrape-tool for that page
215
+ - If scraping doesn't give complete results → use web-crawl-tool instead of more scraping
216
+ 3. Never scrape multiple pages individually - always crawl the site instead
217
+ 4. Return the final JSON result matching the expected schema
218
+
219
+ SPECIAL INSTRUCTIONS FOR IMAGE URL EXTRACTION:
220
+ - When extracting image URLs, look for the LARGEST, HIGHEST QUALITY product images
221
+ - Extract the DIRECT URL to the image file (ending in .jpg, .jpeg, .png, .webp, etc.)
222
+ - Avoid thumbnail or small preview images - find the main product gallery images
223
+ - Look for image URLs in src attributes, data-src attributes, or image CDN URLs
224
+ - Test that the URLs are accessible and point to actual image files
225
+ - If needed, convert relative URLs to absolute URLs with the proper domain
226
+
227
+ CRITICAL: Return ONLY the final JSON result that matches the expected schema structure.
228
+
229
+ DO NOT include:
230
+ - Markdown code blocks with backticks
231
+ - Any explanatory text before or after the JSON
232
+ - Prefixes like "Here's the result:" or "The JSON is:"
233
+
234
+ Your response must start with { or [ and end with } or ] - nothing else.
235
+ `.trim();
236
+ }
237
+ /**
238
+ * Build the system prompt that defines the AI agent's behavior
239
+ */
240
+ buildSystemPrompt() {
241
+ return `
242
+ You are a professional research agent specialized in gathering and structuring information from the internet. Your task is to use the following tools to gather information:
243
+
244
+ 1. SEARCH SYSTEMATICALLY: Use web search to find the most relevant and authoritative sources
245
+ 2. SCRAPE THOROUGHLY: Extract comprehensive information from discovered web pages, or when you are certain that the information you need is on one specific page, use the web-scrape-tool to scrape that page
246
+ 3. CRAWL THOROUGHLY: Crawl the entire website to gather all the information you need if the scraping doesn't give complete results
247
+ 3. RESEARCH RECURSIVELY: Continue searching and scraping until you have sufficient data
248
+ 4. SYNTHESIZE INTELLIGENTLY: Organize all findings into the requested JSON structure
249
+
250
+ CRITICAL INSTRUCTIONS:
251
+ - DO NOT MAKE UP INFORMATION! All information must be from the sources you found.
252
+
253
+ Research Guidelines:
254
+ - Start with web search to find relevant sources
255
+ - For structured data extraction (product info, images, prices) → use web-extract-tool with detailed prompts
256
+ - If search results show multiple pages from the same website → crawl that website
257
+ - If you're certain one page has all the info → scrape that specific page
258
+ - If scraping gives incomplete results → crawl the site instead of more scraping
259
+ - Never scrape multiple individual pages - always crawl the entire site instead
260
+
261
+ IMAGE EXTRACTION GUIDELINES:
262
+ - When extracting images, prioritize main product images over thumbnails
263
+ - Look for high-resolution images (usually larger file sizes, higher dimensions)
264
+ - Common image URL patterns: /images/, /media/, /assets/, CDN domains
265
+ - Check for lazy-loaded images in data-src, data-lazy-src attributes
266
+ - Ensure URLs are absolute (include https:// and domain)
267
+ - Validate that URLs end with image extensions (.jpg, .jpeg, .png, .webp, .gif)
268
+
269
+ Output Requirements:
270
+ - Return ONLY valid JSON that matches the provided schema
271
+ - NO markdown code blocks, explanations, or additional text
272
+ - NO prefixes like "Here's the result:" or "The JSON is:"
273
+ - Start your response directly with { or [ (the JSON structure)
274
+ - End your response with } or ] (closing the JSON structure)
275
+ - Ensure all required schema fields are addressed, if not available leave empty
276
+ - Include all relevant information you discovered
277
+ - Maintain data accuracy and cite reliable sources in your research process
278
+
279
+ JSON FORMATTING RULES:
280
+ - Use double quotes for all strings and property names
281
+ - No trailing commas
282
+ - No single quotes
283
+ - No unescaped newlines in strings
284
+ - Properly escape special characters in strings
285
+
286
+ You have access to web-search-tool, web-scrape-tool, web-crawl-tool, and web-extract-tool. Use web-extract-tool for structured data extraction (like product images, prices, specific fields). Prefer web-crawl-tool over web-scrape-tool when you need information from multiple pages of a website.
287
+ `.trim();
288
+ }
289
+ /**
290
+ * Extract URLs and sources from the tool calls made during research
291
+ */
292
+ extractSourcesFromToolCalls(toolCalls) {
293
+ const sources = [];
294
+ for (const toolCall of toolCalls) {
295
+ if (toolCall.tool === 'web-search-tool' && toolCall.output) {
296
+ // Extract URLs from search results
297
+ const output = toolCall.output;
298
+ if (output.results) {
299
+ for (const result of output.results) {
300
+ if (result.url) {
301
+ sources.push(result.url);
302
+ }
303
+ }
304
+ }
305
+ }
306
+ else if (toolCall.tool === 'web-scrape-tool' && toolCall.input) {
307
+ // Extract URL from scrape input
308
+ const input = toolCall.input;
309
+ if (input.url) {
310
+ sources.push(input.url);
311
+ }
312
+ }
313
+ else if (toolCall.tool === 'web-crawl-tool' && toolCall.input) {
314
+ // Extract URL from crawl input
315
+ const input = toolCall.input;
316
+ if (input.url) {
317
+ sources.push(input.url);
318
+ }
319
+ // Also extract URLs from crawl output if available
320
+ if (toolCall.output) {
321
+ const output = toolCall.output;
322
+ if (output.pages) {
323
+ for (const page of output.pages) {
324
+ if (page.url) {
325
+ sources.push(page.url);
326
+ }
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ // Remove duplicates and return
333
+ return [...new Set(sources)];
334
+ }
335
+ /**
336
+ * Generate a concise summary of the research conducted
337
+ */
338
+ generateResearchSummary(task, toolCallsCount, sourcesCount) {
339
+ const taskPreview = task.length > 50 ? task.substring(0, 50) + '...' : task;
340
+ return `Completed research on "${taskPreview}" using ${toolCallsCount} tool operations across ${sourcesCount} web sources. Gathered and structured information according to the requested schema format.`;
341
+ }
342
+ }
343
+ //# sourceMappingURL=research-agent-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"research-agent-tool.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/research-agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAmB,MAAM,2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;iBAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAChE,+BAA+B;gBAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAyB,CAAC;gBACjD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;oBACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC1B,CAAC;gBACD,mDAAmD;gBACnD,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACpB,MAAM,MAAM,GAAG,QAAQ,CAAC,MAA6C,CAAC;oBACtE,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;wBACjB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;4BAChC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;gCACb,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BACzB,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACK,uBAAuB,CAC7B,IAAY,EACZ,cAAsB,EACtB,YAAoB;QAEpB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAE5E,OAAO,0BAA0B,WAAW,WAAW,cAAc,2BAA2B,YAAY,6FAA6F,CAAC;IAC5M,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { ToolBubble } from '../../types/tool-bubble-class.js';
3
+ import type { BubbleContext } from '../../types/bubble.js';
4
+ import { CredentialType } from '@bubblelab/shared-schemas';
5
+ declare const SQLQueryToolParamsSchema: z.ZodObject<{
6
+ query: z.ZodString;
7
+ reasoning: z.ZodString;
8
+ credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
9
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ reasoning: string;
12
+ query: string;
13
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
14
+ config?: Record<string, unknown> | undefined;
15
+ }, {
16
+ reasoning: string;
17
+ query: string;
18
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
19
+ config?: Record<string, unknown> | undefined;
20
+ }>;
21
+ type SQLQueryToolParamsInput = z.input<typeof SQLQueryToolParamsSchema>;
22
+ type SQLQueryToolParams = z.output<typeof SQLQueryToolParamsSchema>;
23
+ type SQLQueryToolResult = z.output<typeof SQLQueryToolResultSchema>;
24
+ declare const SQLQueryToolResultSchema: z.ZodObject<{
25
+ rows: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
26
+ rowCount: z.ZodNumber;
27
+ executionTime: z.ZodNumber;
28
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
29
+ name: z.ZodString;
30
+ dataTypeID: z.ZodOptional<z.ZodNumber>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ name: string;
33
+ dataTypeID?: number | undefined;
34
+ }, {
35
+ name: string;
36
+ dataTypeID?: number | undefined;
37
+ }>, "many">>;
38
+ success: z.ZodBoolean;
39
+ error: z.ZodString;
40
+ }, "strip", z.ZodTypeAny, {
41
+ success: boolean;
42
+ error: string;
43
+ rowCount: number;
44
+ executionTime: number;
45
+ rows?: Record<string, unknown>[] | undefined;
46
+ fields?: {
47
+ name: string;
48
+ dataTypeID?: number | undefined;
49
+ }[] | undefined;
50
+ }, {
51
+ success: boolean;
52
+ error: string;
53
+ rowCount: number;
54
+ executionTime: number;
55
+ rows?: Record<string, unknown>[] | undefined;
56
+ fields?: {
57
+ name: string;
58
+ dataTypeID?: number | undefined;
59
+ }[] | undefined;
60
+ }>;
61
+ /**
62
+ * SQLQueryTool - Execute SQL queries against PostgreSQL databases
63
+ *
64
+ * This tool bubble provides a safe, read-only interface for AI agents to query
65
+ * PostgreSQL databases. It's designed for data analysis, exploration, and
66
+ * business intelligence tasks.
67
+ */
68
+ export declare class SQLQueryTool extends ToolBubble<SQLQueryToolParams, SQLQueryToolResult> {
69
+ static readonly type: "tool";
70
+ static readonly bubbleName = "sql-query-tool";
71
+ static readonly schema: z.ZodObject<{
72
+ query: z.ZodString;
73
+ reasoning: z.ZodString;
74
+ credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
75
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ reasoning: string;
78
+ query: string;
79
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
80
+ config?: Record<string, unknown> | undefined;
81
+ }, {
82
+ reasoning: string;
83
+ query: string;
84
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
85
+ config?: Record<string, unknown> | undefined;
86
+ }>;
87
+ static readonly resultSchema: z.ZodObject<{
88
+ rows: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
89
+ rowCount: z.ZodNumber;
90
+ executionTime: z.ZodNumber;
91
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
92
+ name: z.ZodString;
93
+ dataTypeID: z.ZodOptional<z.ZodNumber>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ name: string;
96
+ dataTypeID?: number | undefined;
97
+ }, {
98
+ name: string;
99
+ dataTypeID?: number | undefined;
100
+ }>, "many">>;
101
+ success: z.ZodBoolean;
102
+ error: z.ZodString;
103
+ }, "strip", z.ZodTypeAny, {
104
+ success: boolean;
105
+ error: string;
106
+ rowCount: number;
107
+ executionTime: number;
108
+ rows?: Record<string, unknown>[] | undefined;
109
+ fields?: {
110
+ name: string;
111
+ dataTypeID?: number | undefined;
112
+ }[] | undefined;
113
+ }, {
114
+ success: boolean;
115
+ error: string;
116
+ rowCount: number;
117
+ executionTime: number;
118
+ rows?: Record<string, unknown>[] | undefined;
119
+ fields?: {
120
+ name: string;
121
+ dataTypeID?: number | undefined;
122
+ }[] | undefined;
123
+ }>;
124
+ static readonly shortDescription = "Execute read-only SQL queries against PostgreSQL databases for data analysis";
125
+ static readonly longDescription = "\n A tool bubble that provides safe, read-only SQL query execution against PostgreSQL databases.\n \n Features:\n - Execute SELECT, WITH, EXPLAIN, ANALYZE, SHOW, and DESCRIBE queries\n - Automatic query timeout and row limit enforcement (30s timeout, 1000 rows max)\n - Clean JSON formatting of results for AI consumption\n - Detailed execution metadata including timing and row counts\n \n Security:\n - Read-only operations enforced\n - Query timeout protection (30 seconds)\n - Row limit protection (1000 rows max)\n \n Use cases:\n - AI agents performing iterative database exploration\n - Data analysis and business intelligence queries\n - Schema discovery and table introspection\n - Performance analysis with EXPLAIN queries\n - Automated reporting and data extraction\n ";
126
+ static readonly alias = "sql";
127
+ constructor(params: SQLQueryToolParamsInput, context?: BubbleContext);
128
+ performAction(context?: BubbleContext): Promise<SQLQueryToolResult>;
129
+ }
130
+ export {};
131
+ //# sourceMappingURL=sql-query-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-query-tool.d.ts","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/sql-query-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;EAmB5B,CAAC;AAGH,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACxE,KAAK,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACpE,KAAK,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAGpE,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B5B,CAAC;AAEH;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,UAAU,CAC1C,kBAAkB,EAClB,kBAAkB,CACnB;IACC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAU;IACvC,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAoB;IAC9C,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;OAA4B;IAClD,MAAM,CAAC,QAAQ,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA4B;IACxD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,kFACiD;IACjF,MAAM,CAAC,QAAQ,CAAC,eAAe,20BAoB7B;IACF,MAAM,CAAC,QAAQ,CAAC,KAAK,SAAS;gBAElB,MAAM,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,aAAa;IAI9D,aAAa,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA0E1E"}
@@ -0,0 +1,147 @@
1
+ import { z } from 'zod';
2
+ import { ToolBubble } from '../../types/tool-bubble-class.js';
3
+ import { CredentialType } from '@bubblelab/shared-schemas';
4
+ import { PostgreSQLBubble } from '../service-bubble/postgresql.js';
5
+ // Define the parameters schema
6
+ const SQLQueryToolParamsSchema = z.object({
7
+ query: z
8
+ .string()
9
+ .describe('SQL query to execute (SELECT, WITH, EXPLAIN, ANALYZE, SHOW, DESCRIBE only)'),
10
+ reasoning: z
11
+ .string()
12
+ .describe("Explain why you're running this specific query and what you hope to learn from it"),
13
+ credentials: z
14
+ .record(z.nativeEnum(CredentialType), z.string())
15
+ .optional()
16
+ .describe('Database credentials (injected at runtime)'),
17
+ config: z
18
+ .record(z.string(), z.unknown())
19
+ .optional()
20
+ .describe('Configuration for the tool bubble'),
21
+ });
22
+ // Result schema for validation
23
+ const SQLQueryToolResultSchema = z.object({
24
+ // Query results
25
+ rows: z
26
+ .array(z.record(z.unknown()))
27
+ .optional()
28
+ .describe('Array of query result rows as objects'),
29
+ rowCount: z.number().describe('Number of rows returned by the query'),
30
+ // Metadata
31
+ executionTime: z.number().describe('Query execution time in milliseconds'),
32
+ fields: z
33
+ .array(z.object({
34
+ name: z.string().describe('Name of the column'),
35
+ dataTypeID: z
36
+ .number()
37
+ .optional()
38
+ .describe('PostgreSQL data type ID for the column'),
39
+ }))
40
+ .optional()
41
+ .describe('Array of column metadata from the query result'),
42
+ // Standard result fields
43
+ success: z.boolean().describe('Whether the query execution was successful'),
44
+ error: z.string().describe('Error message if query execution failed'),
45
+ });
46
+ /**
47
+ * SQLQueryTool - Execute SQL queries against PostgreSQL databases
48
+ *
49
+ * This tool bubble provides a safe, read-only interface for AI agents to query
50
+ * PostgreSQL databases. It's designed for data analysis, exploration, and
51
+ * business intelligence tasks.
52
+ */
53
+ export class SQLQueryTool extends ToolBubble {
54
+ static type = 'tool';
55
+ static bubbleName = 'sql-query-tool';
56
+ static schema = SQLQueryToolParamsSchema;
57
+ static resultSchema = SQLQueryToolResultSchema;
58
+ static shortDescription = 'Execute read-only SQL queries against PostgreSQL databases for data analysis';
59
+ static longDescription = `
60
+ A tool bubble that provides safe, read-only SQL query execution against PostgreSQL databases.
61
+
62
+ Features:
63
+ - Execute SELECT, WITH, EXPLAIN, ANALYZE, SHOW, and DESCRIBE queries
64
+ - Automatic query timeout and row limit enforcement (30s timeout, 1000 rows max)
65
+ - Clean JSON formatting of results for AI consumption
66
+ - Detailed execution metadata including timing and row counts
67
+
68
+ Security:
69
+ - Read-only operations enforced
70
+ - Query timeout protection (30 seconds)
71
+ - Row limit protection (1000 rows max)
72
+
73
+ Use cases:
74
+ - AI agents performing iterative database exploration
75
+ - Data analysis and business intelligence queries
76
+ - Schema discovery and table introspection
77
+ - Performance analysis with EXPLAIN queries
78
+ - Automated reporting and data extraction
79
+ `;
80
+ static alias = 'sql';
81
+ constructor(params, context) {
82
+ super(params, context);
83
+ }
84
+ async performAction(context) {
85
+ void context; // Context available but not currently used
86
+ const startTime = Date.now();
87
+ try {
88
+ // Log query execution
89
+ console.debug(`\nšŸ” [SQLQueryTool] Executing SQL query...`);
90
+ console.debug(`šŸ’­ [SQLQueryTool] Reasoning: ${this.params.reasoning}`);
91
+ console.debug(`šŸ“ [SQLQueryTool] Query: ${this.params.query.substring(0, 200)}${this.params.query.length > 200 ? '...' : ''}`);
92
+ // Create PostgreSQL bubble with default settings
93
+ const pgBubble = new PostgreSQLBubble({
94
+ query: this.params.query,
95
+ allowedOperations: [
96
+ 'SELECT',
97
+ 'WITH',
98
+ 'EXPLAIN',
99
+ 'ANALYZE',
100
+ 'SHOW',
101
+ 'DESCRIBE',
102
+ 'DESC',
103
+ ],
104
+ timeout: 30000, // 30 seconds
105
+ maxRows: 1000, // Reasonable limit for analysis
106
+ credentials: this.params.credentials,
107
+ ...(this.params.config || {}),
108
+ }, this.context);
109
+ // Execute the query
110
+ const result = await pgBubble.action();
111
+ const executionTime = Date.now() - startTime;
112
+ if (!result.success) {
113
+ console.log(`āŒ [SQLQueryTool] Query failed: ${result.error}`);
114
+ return {
115
+ rowCount: 0,
116
+ executionTime,
117
+ success: false,
118
+ error: result.error,
119
+ };
120
+ }
121
+ const rowCount = result.data?.rowCount || result.data?.rows?.length || 0;
122
+ console.log(`āœ… [SQLQueryTool] Query successful:`);
123
+ console.log(`šŸ“Š [SQLQueryTool] Rows returned: ${rowCount}`);
124
+ console.log(`ā±ļø [SQLQueryTool] Execution time: ${executionTime}ms`);
125
+ return {
126
+ rows: result.data?.rows,
127
+ rowCount,
128
+ executionTime,
129
+ fields: result.data?.fields,
130
+ success: true,
131
+ error: '',
132
+ };
133
+ }
134
+ catch (error) {
135
+ const executionTime = Date.now() - startTime;
136
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
137
+ console.log(`šŸ’„ [SQLQueryTool] Query error: ${errorMessage}`);
138
+ return {
139
+ rowCount: 0,
140
+ executionTime,
141
+ success: false,
142
+ error: errorMessage,
143
+ };
144
+ }
145
+ }
146
+ }
147
+ //# sourceMappingURL=sql-query-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-query-tool.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/sql-query-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,+BAA+B;AAC/B,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,CACP,4EAA4E,CAC7E;IACH,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,CACP,mFAAmF,CACpF;IACH,WAAW,EAAE,CAAC;SACX,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;SAChD,QAAQ,EAAE;SACV,QAAQ,CAAC,4CAA4C,CAAC;IACzD,MAAM,EAAE,CAAC;SACN,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,QAAQ,EAAE;SACV,QAAQ,CAAC,mCAAmC,CAAC;CACjD,CAAC,CAAC;AAOH,+BAA+B;AAC/B,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAA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