@bubblelab/bubble-core 0.1.150 → 0.1.151

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 (115) hide show
  1. package/dist/bubble-bundle.d.ts +76 -76
  2. package/dist/bubbles/service-bubble/agi-inc.d.ts +20 -20
  3. package/dist/bubbles/service-bubble/ai-agent.d.ts +74 -74
  4. package/dist/bubbles/service-bubble/airtable.d.ts +76 -76
  5. package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +2 -2
  6. package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +8 -8
  7. package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts +2 -2
  8. package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +22 -22
  9. package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-detail.d.ts +38 -38
  10. package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +52 -52
  11. package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts +6 -6
  12. package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts +12 -12
  13. package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +12 -12
  14. package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +126 -126
  15. package/dist/bubbles/service-bubble/apify/apify.d.ts +18 -18
  16. package/dist/bubbles/service-bubble/ashby/ashby.d.ts +2 -2
  17. package/dist/bubbles/service-bubble/ashby/ashby.schema.d.ts +2 -2
  18. package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts +38 -1
  19. package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts.map +1 -1
  20. package/dist/bubbles/service-bubble/browserbase/browserbase.js +80 -0
  21. package/dist/bubbles/service-bubble/browserbase/browserbase.js.map +1 -1
  22. package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts +34 -1
  23. package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts.map +1 -1
  24. package/dist/bubbles/service-bubble/browserbase/browserbase.schema.js +30 -0
  25. package/dist/bubbles/service-bubble/browserbase/browserbase.schema.js.map +1 -1
  26. package/dist/bubbles/service-bubble/firecrawl.d.ts +334 -334
  27. package/dist/bubbles/service-bubble/followupboss.d.ts +4 -4
  28. package/dist/bubbles/service-bubble/github.d.ts +60 -60
  29. package/dist/bubbles/service-bubble/gmail.d.ts +164 -164
  30. package/dist/bubbles/service-bubble/google-calendar.d.ts +6 -6
  31. package/dist/bubbles/service-bubble/google-drive.d.ts +9 -9
  32. package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -1
  33. package/dist/bubbles/service-bubble/google-drive.js +37 -1
  34. package/dist/bubbles/service-bubble/google-drive.js.map +1 -1
  35. package/dist/bubbles/service-bubble/http.d.ts +2 -2
  36. package/dist/bubbles/service-bubble/insforge-db.d.ts +8 -8
  37. package/dist/bubbles/service-bubble/jira/jira.d.ts +30 -30
  38. package/dist/bubbles/service-bubble/jira/jira.schema.d.ts +36 -36
  39. package/dist/bubbles/service-bubble/notion/notion.d.ts +164 -164
  40. package/dist/bubbles/service-bubble/notion/property-schemas.d.ts +8 -8
  41. package/dist/bubbles/service-bubble/postgresql.d.ts +8 -8
  42. package/dist/bubbles/service-bubble/resend.d.ts +4 -4
  43. package/dist/bubbles/service-bubble/salesforce/index.d.ts +4 -0
  44. package/dist/bubbles/service-bubble/salesforce/index.d.ts.map +1 -0
  45. package/dist/bubbles/service-bubble/salesforce/index.js +4 -0
  46. package/dist/bubbles/service-bubble/salesforce/index.js.map +1 -0
  47. package/dist/bubbles/service-bubble/salesforce/salesforce.d.ts +1331 -0
  48. package/dist/bubbles/service-bubble/salesforce/salesforce.d.ts.map +1 -0
  49. package/dist/bubbles/service-bubble/salesforce/salesforce.js +618 -0
  50. package/dist/bubbles/service-bubble/salesforce/salesforce.js.map +1 -0
  51. package/dist/bubbles/service-bubble/salesforce/salesforce.schema.d.ts +1445 -0
  52. package/dist/bubbles/service-bubble/salesforce/salesforce.schema.d.ts.map +1 -0
  53. package/dist/bubbles/service-bubble/salesforce/salesforce.schema.js +609 -0
  54. package/dist/bubbles/service-bubble/salesforce/salesforce.schema.js.map +1 -0
  55. package/dist/bubbles/service-bubble/salesforce/salesforce.utils.d.ts +87 -0
  56. package/dist/bubbles/service-bubble/salesforce/salesforce.utils.d.ts.map +1 -0
  57. package/dist/bubbles/service-bubble/salesforce/salesforce.utils.js +181 -0
  58. package/dist/bubbles/service-bubble/salesforce/salesforce.utils.js.map +1 -0
  59. package/dist/bubbles/service-bubble/slack/slack.d.ts +328 -328
  60. package/dist/bubbles/service-bubble/slack/slack.utils.d.ts.map +1 -1
  61. package/dist/bubbles/service-bubble/slack/slack.utils.js +17 -2
  62. package/dist/bubbles/service-bubble/slack/slack.utils.js.map +1 -1
  63. package/dist/bubbles/service-bubble/stripe/stripe.d.ts +24 -24
  64. package/dist/bubbles/service-bubble/stripe/stripe.schema.d.ts +28 -28
  65. package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.d.ts +6 -6
  66. package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.d.ts +8 -8
  67. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.d.ts +66 -0
  68. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.d.ts.map +1 -0
  69. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.js +484 -0
  70. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.js.map +1 -0
  71. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.types.d.ts +85 -0
  72. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.types.d.ts.map +1 -0
  73. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.types.js +2 -0
  74. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.types.js.map +1 -0
  75. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-fallback-step.d.ts +27 -0
  76. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-fallback-step.d.ts.map +1 -0
  77. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-fallback-step.js +77 -0
  78. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/ai-fallback-step.js.map +1 -0
  79. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/index.d.ts +4 -0
  80. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/index.d.ts.map +1 -0
  81. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/index.js +3 -0
  82. package/dist/bubbles/tool-bubble/browser-tools/_shared/ai/index.js.map +1 -0
  83. package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/tool.d.ts.map +1 -1
  84. package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/tool.js +254 -195
  85. package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/tool.js.map +1 -1
  86. package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.d.ts +2 -0
  87. package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.d.ts.map +1 -1
  88. package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.js +346 -229
  89. package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.js.map +1 -1
  90. package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.d.ts +34 -33
  91. package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.d.ts.map +1 -1
  92. package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.js +212 -151
  93. package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.js.map +1 -1
  94. package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.d.ts +33 -32
  95. package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.d.ts.map +1 -1
  96. package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.js +188 -127
  97. package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.js.map +1 -1
  98. package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +4 -4
  99. package/dist/bubbles/tool-bubble/company-enrichment-tool.d.ts +20 -20
  100. package/dist/bubbles/tool-bubble/linkedin-connection-tool/linkedin-connection-tool.d.ts +8 -8
  101. package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +380 -380
  102. package/dist/bubbles/tool-bubble/people-search-tool.d.ts +44 -44
  103. package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +10 -10
  104. package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +4 -4
  105. package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +4 -4
  106. package/dist/bubbles/tool-bubble/tiktok-tool.d.ts +60 -60
  107. package/dist/bubbles/tool-bubble/twitter-tool.d.ts +134 -134
  108. package/dist/bubbles/tool-bubble/yc-scraper-tool.d.ts +8 -8
  109. package/dist/bubbles/tool-bubble/youtube-tool.d.ts +20 -20
  110. package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +12 -12
  111. package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +8 -8
  112. package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +2 -2
  113. package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +18 -18
  114. package/dist/bubbles.json +73 -2
  115. package/package.json +1 -1
@@ -15,15 +15,15 @@ export declare const CartItemSchema: z.ZodObject<{
15
15
  price: string;
16
16
  quantity: number;
17
17
  asin: string;
18
- image?: string | undefined;
19
18
  url?: string | undefined;
19
+ image?: string | undefined;
20
20
  }, {
21
21
  title: string;
22
22
  price: string;
23
23
  quantity: number;
24
24
  asin: string;
25
- image?: string | undefined;
26
25
  url?: string | undefined;
26
+ image?: string | undefined;
27
27
  }>;
28
28
  export type CartItem = z.infer<typeof CartItemSchema>;
29
29
  /**
@@ -98,12 +98,12 @@ export declare const AmazonShoppingToolParamsSchema: z.ZodDiscriminatedUnion<"op
98
98
  }, "strip", z.ZodTypeAny, {
99
99
  operation: "screenshot";
100
100
  full_page: boolean;
101
- credentials?: Partial<Record<CredentialType, string>> | undefined;
102
101
  url?: string | undefined;
102
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
103
103
  }, {
104
104
  operation: "screenshot";
105
- credentials?: Partial<Record<CredentialType, string>> | undefined;
106
105
  url?: string | undefined;
106
+ credentials?: Partial<Record<CredentialType, string>> | undefined;
107
107
  full_page?: boolean | undefined;
108
108
  }>]>;
109
109
  /**
@@ -212,15 +212,15 @@ export declare const AmazonShoppingToolResultSchema: z.ZodDiscriminatedUnion<"op
212
212
  price: string;
213
213
  quantity: number;
214
214
  asin: string;
215
- image?: string | undefined;
216
215
  url?: string | undefined;
216
+ image?: string | undefined;
217
217
  }, {
218
218
  title: string;
219
219
  price: string;
220
220
  quantity: number;
221
221
  asin: string;
222
- image?: string | undefined;
223
222
  url?: string | undefined;
223
+ image?: string | undefined;
224
224
  }>, "many">>;
225
225
  subtotal: z.ZodOptional<z.ZodString>;
226
226
  total_items: z.ZodOptional<z.ZodNumber>;
@@ -235,8 +235,8 @@ export declare const AmazonShoppingToolResultSchema: z.ZodDiscriminatedUnion<"op
235
235
  price: string;
236
236
  quantity: number;
237
237
  asin: string;
238
- image?: string | undefined;
239
238
  url?: string | undefined;
239
+ image?: string | undefined;
240
240
  }[] | undefined;
241
241
  subtotal?: string | undefined;
242
242
  total_items?: number | undefined;
@@ -250,8 +250,8 @@ export declare const AmazonShoppingToolResultSchema: z.ZodDiscriminatedUnion<"op
250
250
  price: string;
251
251
  quantity: number;
252
252
  asin: string;
253
- image?: string | undefined;
254
253
  url?: string | undefined;
254
+ image?: string | undefined;
255
255
  }[] | undefined;
256
256
  subtotal?: string | undefined;
257
257
  total_items?: number | undefined;
@@ -0,0 +1,66 @@
1
+ import type { z } from 'zod';
2
+ import type { AIBrowserAction, AIBrowserAgentConfig } from './ai-browser-agent.types.js';
3
+ /**
4
+ * AI Browser Agent for error recovery and data extraction.
5
+ *
6
+ * Uses AIAgentBubble from @bubblelab/bubble-core to analyze screenshots
7
+ * and suggest recovery actions or extract structured data.
8
+ */
9
+ export declare class AIBrowserAgent {
10
+ private sessionId;
11
+ private context?;
12
+ private credentials?;
13
+ constructor(config: AIBrowserAgentConfig);
14
+ /**
15
+ * Suggest a recovery action for a failed step.
16
+ *
17
+ * @param task - Description of what the step was trying to accomplish
18
+ * @param error - The error message from the failed step
19
+ * @returns The suggested recovery action
20
+ */
21
+ suggestRecoveryAction(task: string, error: string): Promise<AIBrowserAction>;
22
+ /**
23
+ * Extract structured data from the page using AI vision.
24
+ *
25
+ * @param schema - Zod schema defining the expected data structure
26
+ * @param task - Description of what data to extract
27
+ * @returns The extracted data matching the schema, or null if extraction fails
28
+ */
29
+ extractData<T>(schema: z.ZodType<T>, task: string): Promise<T | null>;
30
+ /**
31
+ * Execute the suggested recovery action on the page.
32
+ *
33
+ * @param action - The action to execute
34
+ * @returns true if the action was executed successfully
35
+ */
36
+ executeAction(action: AIBrowserAction): Promise<boolean>;
37
+ /**
38
+ * Capture a screenshot from the current browser session.
39
+ */
40
+ private captureScreenshot;
41
+ /**
42
+ * Get the current page URL.
43
+ */
44
+ private getCurrentUrl;
45
+ /**
46
+ * Extract interactive elements from the page.
47
+ */
48
+ private extractInteractiveElements;
49
+ /**
50
+ * Call the AI agent with a message and optional screenshot.
51
+ */
52
+ private callAI;
53
+ /**
54
+ * Build the prompt for recovery action suggestion.
55
+ */
56
+ private buildRecoveryPrompt;
57
+ /**
58
+ * Parse the AI response into a typed action.
59
+ */
60
+ private parseRecoveryAction;
61
+ /**
62
+ * Generate a human-readable description of a Zod schema.
63
+ */
64
+ private describeZodSchema;
65
+ }
66
+ //# sourceMappingURL=ai-browser-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-browser-agent.d.ts","sourceRoot":"","sources":["../../../../../../src/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AA4HrC;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,WAAW,CAAC,CAAyB;gBAEjC,MAAM,EAAE,oBAAoB;IAMxC;;;;;;OAMG;IACG,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC;IAqD3B;;;;;;OAMG;IACG,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAgD3E;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAsE9D;;OAEG;YACW,iBAAiB;IAe/B;;OAEG;YACW,aAAa;IAW3B;;OAEG;YACW,0BAA0B;IAaxC;;OAEG;YACW,MAAM;IA6CpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA0E3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;CA6B1B"}
@@ -0,0 +1,484 @@
1
+ import { AIAgentBubble } from '../../../../service-bubble/ai-agent.js';
2
+ import { BrowserBaseBubble } from '../../../../service-bubble/browserbase/index.js';
3
+ import { CredentialType } from '@bubblelab/shared-schemas';
4
+ /**
5
+ * Script to extract interactive elements from the page.
6
+ * Finds buttons, links, inputs, and other interactive elements.
7
+ * Limited to 100 elements to avoid overwhelming the AI.
8
+ * Only includes elements that are truly visible (not in closed dropdowns, etc.)
9
+ */
10
+ const EXTRACT_ELEMENTS_SCRIPT = `
11
+ (() => {
12
+ const selectors = 'button, a, input, select, textarea, [role="button"], [role="link"], [onclick]';
13
+ const elements = document.querySelectorAll(selectors);
14
+
15
+ // Check if element is truly visible (not just has dimensions)
16
+ function isElementVisible(el) {
17
+ const rect = el.getBoundingClientRect();
18
+ if (rect.width === 0 || rect.height === 0) return false;
19
+
20
+ // Check if element is within viewport
21
+ if (rect.bottom < 0 || rect.top > window.innerHeight) return false;
22
+ if (rect.right < 0 || rect.left > window.innerWidth) return false;
23
+
24
+ // Check computed styles
25
+ const style = window.getComputedStyle(el);
26
+ if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;
27
+
28
+ // Check if any parent hides it (dropdown items in closed dropdowns)
29
+ let parent = el.parentElement;
30
+ while (parent) {
31
+ const parentStyle = window.getComputedStyle(parent);
32
+ if (parentStyle.display === 'none' || parentStyle.visibility === 'hidden') return false;
33
+ // Check for closed dropdown containers (common patterns)
34
+ if (parent.classList.contains('artdeco-dropdown__content') ||
35
+ parent.classList.contains('dropdown-menu')) {
36
+ if (!parent.classList.contains('artdeco-dropdown__content--is-open') &&
37
+ !parent.classList.contains('show') &&
38
+ !parent.classList.contains('open')) {
39
+ return false;
40
+ }
41
+ }
42
+ parent = parent.parentElement;
43
+ }
44
+
45
+ return true;
46
+ }
47
+
48
+ return [...elements].filter(isElementVisible).slice(0, 100).map(el => {
49
+ const rect = el.getBoundingClientRect();
50
+ let selector = el.tagName.toLowerCase();
51
+ if (el.id) {
52
+ selector = '#' + el.id;
53
+ } else if (el.className && typeof el.className === 'string') {
54
+ const classes = el.className.trim().split(/\\s+/).slice(0, 3).join('.');
55
+ if (classes) selector = el.tagName.toLowerCase() + '.' + classes;
56
+ }
57
+ return {
58
+ tagName: el.tagName.toLowerCase(),
59
+ role: el.getAttribute('role') || undefined,
60
+ name: el.getAttribute('aria-label') || el.textContent?.trim().slice(0, 50) || undefined,
61
+ id: el.id || undefined,
62
+ selector,
63
+ boundingBox: {
64
+ x: Math.round(rect.x),
65
+ y: Math.round(rect.y),
66
+ width: Math.round(rect.width),
67
+ height: Math.round(rect.height)
68
+ },
69
+ isVisible: true,
70
+ isEnabled: !el.disabled
71
+ };
72
+ });
73
+ })()
74
+ `;
75
+ /**
76
+ * System prompt for the AI browser agent when suggesting recovery actions.
77
+ */
78
+ const RECOVERY_SYSTEM_PROMPT = `You are an AI browser automation assistant. You analyze screenshots and page context to help recover from failed browser automation steps.
79
+
80
+ When a step fails, you receive:
81
+ 1. A screenshot of the current page state
82
+ 2. The task that was being attempted
83
+ 3. The error that occurred
84
+ 4. A list of interactive elements on the page
85
+
86
+ Your job is to suggest ONE action to help recover from the error. Choose from:
87
+
88
+ - click: Click an element by CSS selector
89
+ - click_coordinates: Click at specific x,y coordinates (use when selector is unreliable)
90
+ - type: Type text into an input field
91
+ - scroll: Scroll the page up or down
92
+ - wait: Wait for content to load
93
+ - none: If you cannot help, explain why
94
+
95
+ Respond ONLY with valid JSON in this exact format:
96
+ {"action": "click", "selector": "#submit-btn"}
97
+ {"action": "click_coordinates", "coordinates": [500, 300]}
98
+ {"action": "type", "selector": "#email-input", "value": "test@example.com"}
99
+ {"action": "scroll", "direction": "down", "amount": 500}
100
+ {"action": "wait", "milliseconds": 2000}
101
+ {"action": "none", "reason": "explanation here"}
102
+
103
+ Be concise and precise. Analyze the screenshot carefully to find the right element.`;
104
+ /**
105
+ * System prompt for data extraction.
106
+ */
107
+ const EXTRACTION_SYSTEM_PROMPT = `You are an AI data extraction assistant. You analyze screenshots to extract structured data.
108
+
109
+ You will receive:
110
+ 1. A screenshot of the current page
111
+ 2. A description of what data to extract
112
+ 3. The expected data structure (field names and types)
113
+
114
+ Your job is to extract the requested data from the screenshot and return it as valid JSON.
115
+
116
+ Rules:
117
+ - Only extract information that is clearly visible in the screenshot
118
+ - Use null for fields that cannot be determined
119
+ - Keep string values concise and accurate
120
+ - Follow the exact structure requested
121
+
122
+ Respond ONLY with valid JSON matching the requested structure.`;
123
+ /**
124
+ * AI Browser Agent for error recovery and data extraction.
125
+ *
126
+ * Uses AIAgentBubble from @bubblelab/bubble-core to analyze screenshots
127
+ * and suggest recovery actions or extract structured data.
128
+ */
129
+ export class AIBrowserAgent {
130
+ sessionId;
131
+ context;
132
+ credentials;
133
+ constructor(config) {
134
+ this.sessionId = config.sessionId;
135
+ this.context = config.context;
136
+ this.credentials = config.credentials;
137
+ }
138
+ /**
139
+ * Suggest a recovery action for a failed step.
140
+ *
141
+ * @param task - Description of what the step was trying to accomplish
142
+ * @param error - The error message from the failed step
143
+ * @returns The suggested recovery action
144
+ */
145
+ async suggestRecoveryAction(task, error) {
146
+ try {
147
+ // Capture current page state
148
+ const screenshot = await this.captureScreenshot();
149
+ if (!screenshot) {
150
+ return { action: 'none', reason: 'Could not capture screenshot' };
151
+ }
152
+ const currentUrl = await this.getCurrentUrl();
153
+ const elements = await this.extractInteractiveElements();
154
+ // Log elements for debugging
155
+ console.log(`[AIBrowserAgent] Found ${elements.length} interactive elements:`);
156
+ elements.slice(0, 20).forEach((el, i) => {
157
+ console.log(` ${i + 1}. ${el.tagName}${el.id ? '#' + el.id : ''} - "${el.name?.slice(0, 40) || 'no name'}" at (${el.boundingBox.x},${el.boundingBox.y})`);
158
+ });
159
+ if (elements.length > 20) {
160
+ console.log(` ... and ${elements.length - 20} more elements`);
161
+ }
162
+ // Build the user message
163
+ const userMessage = this.buildRecoveryPrompt(task, error, currentUrl, elements);
164
+ // Call AI
165
+ const response = await this.callAI(userMessage, screenshot, RECOVERY_SYSTEM_PROMPT);
166
+ // Log raw AI response
167
+ console.log(`[AIBrowserAgent] AI raw response: ${response}`);
168
+ // Parse and validate response
169
+ return this.parseRecoveryAction(response);
170
+ }
171
+ catch (err) {
172
+ console.error('[AIBrowserAgent] Error suggesting recovery action:', err);
173
+ return {
174
+ action: 'none',
175
+ reason: err instanceof Error ? err.message : 'Unknown error',
176
+ };
177
+ }
178
+ }
179
+ /**
180
+ * Extract structured data from the page using AI vision.
181
+ *
182
+ * @param schema - Zod schema defining the expected data structure
183
+ * @param task - Description of what data to extract
184
+ * @returns The extracted data matching the schema, or null if extraction fails
185
+ */
186
+ async extractData(schema, task) {
187
+ try {
188
+ // Capture screenshot
189
+ const screenshot = await this.captureScreenshot();
190
+ if (!screenshot) {
191
+ console.error('[AIBrowserAgent] Could not capture screenshot for extraction');
192
+ return null;
193
+ }
194
+ // Generate schema description for the AI
195
+ const schemaDescription = this.describeZodSchema(schema);
196
+ // Build user message
197
+ const userMessage = `Task: ${task}
198
+
199
+ Extract the following data from the screenshot:
200
+ ${schemaDescription}
201
+
202
+ Respond with ONLY valid JSON matching this structure.`;
203
+ // Call AI
204
+ const response = await this.callAI(userMessage, screenshot, EXTRACTION_SYSTEM_PROMPT);
205
+ // Parse and validate with Zod
206
+ const parsed = JSON.parse(response);
207
+ const validated = schema.safeParse(parsed);
208
+ if (validated.success) {
209
+ return validated.data;
210
+ }
211
+ console.error('[AIBrowserAgent] Extracted data did not match schema:', validated.error);
212
+ return null;
213
+ }
214
+ catch (err) {
215
+ console.error('[AIBrowserAgent] Error extracting data:', err);
216
+ return null;
217
+ }
218
+ }
219
+ /**
220
+ * Execute the suggested recovery action on the page.
221
+ *
222
+ * @param action - The action to execute
223
+ * @returns true if the action was executed successfully
224
+ */
225
+ async executeAction(action) {
226
+ try {
227
+ const session = BrowserBaseBubble.getSession(this.sessionId);
228
+ if (!session) {
229
+ console.error('[AIBrowserAgent] No active session');
230
+ return false;
231
+ }
232
+ const page = session.page;
233
+ switch (action.action) {
234
+ case 'click': {
235
+ await page.waitForSelector(action.selector, { timeout: 5000 });
236
+ await page.click(action.selector);
237
+ return true;
238
+ }
239
+ case 'click_coordinates': {
240
+ const [x, y] = action.coordinates;
241
+ await page.mouse.click(x, y);
242
+ return true;
243
+ }
244
+ case 'type': {
245
+ // Clear existing content first
246
+ await page.waitForSelector(action.selector, { timeout: 5000 });
247
+ await page.click(action.selector);
248
+ // Clear via evaluate with string to avoid type issues
249
+ const clearScript = `
250
+ (() => {
251
+ const el = document.querySelector(${JSON.stringify(action.selector)});
252
+ if (el && 'value' in el) el.value = '';
253
+ })()
254
+ `;
255
+ await page.evaluate(clearScript);
256
+ await page.type(action.selector, action.value, { delay: 50 });
257
+ return true;
258
+ }
259
+ case 'scroll': {
260
+ const amount = action.direction === 'down' ? action.amount : -action.amount;
261
+ const scrollScript = `window.scrollBy({ top: ${amount}, behavior: 'smooth' })`;
262
+ await page.evaluate(scrollScript);
263
+ // Wait for scroll to complete
264
+ await new Promise((r) => setTimeout(r, 500));
265
+ return true;
266
+ }
267
+ case 'wait': {
268
+ await new Promise((r) => setTimeout(r, action.milliseconds));
269
+ return true;
270
+ }
271
+ case 'extract':
272
+ case 'none':
273
+ // These don't require page interaction
274
+ return action.action === 'extract';
275
+ default:
276
+ return false;
277
+ }
278
+ }
279
+ catch (err) {
280
+ console.error('[AIBrowserAgent] Error executing action:', err);
281
+ return false;
282
+ }
283
+ }
284
+ // ==================== Private Methods ====================
285
+ /**
286
+ * Capture a screenshot from the current browser session.
287
+ */
288
+ async captureScreenshot() {
289
+ const session = BrowserBaseBubble.getSession(this.sessionId);
290
+ if (!session)
291
+ return null;
292
+ try {
293
+ return (await session.page.screenshot({
294
+ encoding: 'base64',
295
+ type: 'png',
296
+ }));
297
+ }
298
+ catch (err) {
299
+ console.error('[AIBrowserAgent] Screenshot capture failed:', err);
300
+ return null;
301
+ }
302
+ }
303
+ /**
304
+ * Get the current page URL.
305
+ */
306
+ async getCurrentUrl() {
307
+ const session = BrowserBaseBubble.getSession(this.sessionId);
308
+ if (!session)
309
+ return '';
310
+ try {
311
+ return session.page.url();
312
+ }
313
+ catch {
314
+ return '';
315
+ }
316
+ }
317
+ /**
318
+ * Extract interactive elements from the page.
319
+ */
320
+ async extractInteractiveElements() {
321
+ const session = BrowserBaseBubble.getSession(this.sessionId);
322
+ if (!session)
323
+ return [];
324
+ try {
325
+ const elements = await session.page.evaluate(EXTRACT_ELEMENTS_SCRIPT);
326
+ return elements;
327
+ }
328
+ catch (err) {
329
+ console.error('[AIBrowserAgent] Element extraction failed:', err);
330
+ return [];
331
+ }
332
+ }
333
+ /**
334
+ * Call the AI agent with a message and optional screenshot.
335
+ */
336
+ async callAI(message, screenshotBase64, systemPrompt) {
337
+ const geminiKey = this.credentials?.[CredentialType.GOOGLE_GEMINI_CRED];
338
+ if (!geminiKey) {
339
+ throw new Error('No Google Gemini credentials provided for AI fallback');
340
+ }
341
+ const agent = new AIAgentBubble({
342
+ name: 'Browser Recovery Agent',
343
+ message,
344
+ systemPrompt,
345
+ model: {
346
+ model: 'google/gemini-3-flash-preview',
347
+ temperature: 0.1,
348
+ jsonMode: true,
349
+ },
350
+ images: [
351
+ {
352
+ type: 'base64',
353
+ data: screenshotBase64,
354
+ mimeType: 'image/png',
355
+ },
356
+ ],
357
+ credentials: {
358
+ [CredentialType.GOOGLE_GEMINI_CRED]: geminiKey,
359
+ },
360
+ // Disable tools for simple JSON responses
361
+ tools: [],
362
+ }, this.context);
363
+ const result = await agent.action();
364
+ if (!result.data?.response) {
365
+ throw new Error('No response from AI agent');
366
+ }
367
+ return result.data.response;
368
+ }
369
+ /**
370
+ * Build the prompt for recovery action suggestion.
371
+ */
372
+ buildRecoveryPrompt(task, error, currentUrl, elements) {
373
+ // Summarize elements for context (limit to key info)
374
+ const elementSummary = elements
375
+ .slice(0, 30)
376
+ .map((el) => {
377
+ const parts = [el.tagName];
378
+ if (el.name)
379
+ parts.push(`"${el.name}"`);
380
+ if (el.id)
381
+ parts.push(`#${el.id}`);
382
+ if (el.role)
383
+ parts.push(`[role="${el.role}"]`);
384
+ parts.push(`at (${el.boundingBox.x},${el.boundingBox.y})`);
385
+ return parts.join(' ');
386
+ })
387
+ .join('\n');
388
+ return `Task: ${task}
389
+
390
+ Error: ${error}
391
+
392
+ Current URL: ${currentUrl}
393
+
394
+ Interactive elements on page:
395
+ ${elementSummary || 'No interactive elements found'}
396
+
397
+ Analyze the screenshot and suggest ONE action to help recover from this error.`;
398
+ }
399
+ /**
400
+ * Parse the AI response into a typed action.
401
+ */
402
+ parseRecoveryAction(response) {
403
+ try {
404
+ const parsed = JSON.parse(response);
405
+ // Validate action type
406
+ switch (parsed.action) {
407
+ case 'click':
408
+ if (typeof parsed.selector === 'string') {
409
+ return { action: 'click', selector: parsed.selector };
410
+ }
411
+ break;
412
+ case 'click_coordinates':
413
+ if (Array.isArray(parsed.coordinates) &&
414
+ parsed.coordinates.length === 2 &&
415
+ typeof parsed.coordinates[0] === 'number' &&
416
+ typeof parsed.coordinates[1] === 'number') {
417
+ return {
418
+ action: 'click_coordinates',
419
+ coordinates: parsed.coordinates,
420
+ };
421
+ }
422
+ break;
423
+ case 'type':
424
+ if (typeof parsed.selector === 'string' &&
425
+ typeof parsed.value === 'string') {
426
+ return {
427
+ action: 'type',
428
+ selector: parsed.selector,
429
+ value: parsed.value,
430
+ };
431
+ }
432
+ break;
433
+ case 'scroll':
434
+ if ((parsed.direction === 'up' || parsed.direction === 'down') &&
435
+ typeof parsed.amount === 'number') {
436
+ return {
437
+ action: 'scroll',
438
+ direction: parsed.direction,
439
+ amount: parsed.amount,
440
+ };
441
+ }
442
+ break;
443
+ case 'wait':
444
+ if (typeof parsed.milliseconds === 'number') {
445
+ return { action: 'wait', milliseconds: parsed.milliseconds };
446
+ }
447
+ break;
448
+ case 'none':
449
+ return {
450
+ action: 'none',
451
+ reason: typeof parsed.reason === 'string'
452
+ ? parsed.reason
453
+ : 'Unknown reason',
454
+ };
455
+ }
456
+ return { action: 'none', reason: 'Invalid action format from AI' };
457
+ }
458
+ catch {
459
+ return { action: 'none', reason: 'Failed to parse AI response' };
460
+ }
461
+ }
462
+ /**
463
+ * Generate a human-readable description of a Zod schema.
464
+ */
465
+ describeZodSchema(schema) {
466
+ // Get the shape if it's an object schema
467
+ const def = schema._def;
468
+ if (def.typeName === 'ZodObject' && def.shape) {
469
+ const shape = def.shape();
470
+ const fields = Object.entries(shape).map(([key, fieldSchema]) => {
471
+ const fieldDef = fieldSchema._def;
472
+ const type = fieldDef.typeName?.replace('Zod', '').toLowerCase() || 'unknown';
473
+ const optional = fieldDef.typeName === 'ZodOptional' ? ' (optional)' : '';
474
+ const desc = fieldDef.description ? ` - ${fieldDef.description}` : '';
475
+ return ` "${key}": ${type}${optional}${desc}`;
476
+ });
477
+ return `{
478
+ ${fields.join(',\n')}
479
+ }`;
480
+ }
481
+ return 'JSON object';
482
+ }
483
+ }
484
+ //# sourceMappingURL=ai-browser-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-browser-agent.js","sourceRoot":"","sources":["../../../../../../src/bubbles/tool-bubble/browser-tools/_shared/ai/ai-browser-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAO3D;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgE/B,CAAC;AAEF;;GAEG;AACH,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;oFAyBqD,CAAC;AAErF;;GAEG;AACH,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;+DAe8B,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACjB,SAAS,CAAS;IAClB,OAAO,CAAiB;IACxB,WAAW,CAA0B;IAE7C,YAAY,MAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAoC,CAAC;QAC3D,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACxC,CAAC;IAED;;;;;;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