@bubblelab/bubble-core 0.1.9 → 0.1.10
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.
- package/dist/bubble-bundle.d.ts +252 -1686
- package/dist/bubble-factory.d.ts.map +1 -1
- package/dist/bubble-factory.js +51 -19
- package/dist/bubble-factory.js.map +1 -1
- package/dist/bubble-flow/bubble-flow-class.d.ts +17 -1
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -1
- package/dist/bubble-flow/bubble-flow-class.js +16 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -1
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts +1 -1
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -1
- package/dist/bubble-flow/sample/error-ts.d.ts +1 -1
- package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -1
- package/dist/bubble-flow/sample/sanitytest.d.ts +1 -1
- package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -1
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts +1 -1
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -1
- package/dist/bubble-flow/sample/simple-webhook.d.ts +1 -1
- package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -1
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +1 -1
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -1
- package/dist/bubble-flow/sample/slack-v0.1.d.ts +1 -1
- package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -1
- package/dist/bubble-flow/sample/slackagenttest.d.ts +1 -1
- package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.d.ts +30 -30
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.js +3 -1
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -1
- package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +34 -34
- package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +42 -42
- package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +21 -21
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +6 -6
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +184 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.js +145 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-transcript-scraper.d.ts +52 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-transcript-scraper.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-transcript-scraper.js +29 -0
- package/dist/bubbles/service-bubble/apify/actors/youtube-transcript-scraper.js.map +1 -0
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +338 -109
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js +16 -0
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.js.map +1 -1
- package/dist/bubbles/service-bubble/apify/apify.d.ts +10 -10
- package/dist/bubbles/service-bubble/apify/index.d.ts +2 -0
- package/dist/bubbles/service-bubble/apify/index.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/apify/index.js +3 -0
- package/dist/bubbles/service-bubble/apify/index.js.map +1 -1
- package/dist/bubbles/service-bubble/apify/types.js +1 -2
- package/dist/bubbles/service-bubble/apify/types.js.map +1 -1
- package/dist/bubbles/service-bubble/gmail.d.ts +678 -184
- package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/gmail.js +435 -7
- package/dist/bubbles/service-bubble/gmail.js.map +1 -1
- package/dist/bubbles/service-bubble/google-calendar.d.ts +60 -60
- package/dist/bubbles/service-bubble/google-drive.d.ts +301 -72
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/google-drive.js +65 -75
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -1
- package/dist/bubbles/service-bubble/google-sheets.d.ts +76 -76
- package/dist/bubbles/service-bubble/hello-world.d.ts +4 -4
- package/dist/bubbles/service-bubble/hello-world.js +2 -2
- package/dist/bubbles/service-bubble/hello-world.js.map +1 -1
- package/dist/bubbles/service-bubble/http.d.ts +10 -10
- package/dist/bubbles/service-bubble/postgresql.d.ts +12 -12
- package/dist/bubbles/service-bubble/resend.d.ts +16 -16
- package/dist/bubbles/service-bubble/slack.d.ts +469 -469
- package/dist/bubbles/service-bubble/storage.d.ts +36 -36
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/storage.js +16 -5
- package/dist/bubbles/service-bubble/storage.js.map +1 -1
- package/dist/bubbles/service-bubble/x-twitter.d.ts +814 -0
- package/dist/bubbles/service-bubble/x-twitter.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/x-twitter.js +445 -0
- package/dist/bubbles/service-bubble/x-twitter.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +20 -20
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +10 -10
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +17 -9
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/instagram-tool.d.ts +86 -86
- package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +134 -134
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +69 -64
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +97 -22
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +6 -6
- package/dist/bubbles/tool-bubble/research-agent-tool.js +4 -4
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/tool-template.d.ts +8 -8
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +10 -10
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +12 -12
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +11 -10
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/web-search-tool.js +5 -1
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts +394 -0
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/youtube-tool.js +352 -0
- package/dist/bubbles/tool-bubble/youtube-tool.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +47 -36
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +91 -65
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -1
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +4 -4
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +70 -70
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +66 -66
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +56 -56
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -1
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +44 -44
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -1
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +1 -1
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -1
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +32 -32
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +58 -58
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +18 -18
- package/dist/bubbles.json +69 -54
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logging/BubbleLogger.d.ts.map +1 -1
- package/dist/logging/BubbleLogger.js +20 -13
- package/dist/logging/BubbleLogger.js.map +1 -1
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -1
- package/dist/logging/StreamingBubbleLogger.js +5 -5
- package/dist/logging/StreamingBubbleLogger.js.map +1 -1
- package/dist/test-gm.d.ts +10 -0
- package/dist/test-gm.d.ts.map +1 -0
- package/dist/test-gm.js +95 -0
- package/dist/test-gm.js.map +1 -0
- package/dist/types/base-bubble-class.d.ts +1 -1
- package/dist/types/base-bubble-class.d.ts.map +1 -1
- package/dist/types/base-bubble-class.js +29 -21
- package/dist/types/base-bubble-class.js.map +1 -1
- package/dist/types/bubble.d.ts +1 -10
- package/dist/types/bubble.d.ts.map +1 -1
- package/dist/types/bubble.js +1 -1
- package/dist/types/bubble.js.map +1 -1
- package/dist/types/service-bubble-class.d.ts +1 -1
- package/dist/types/service-bubble-class.d.ts.map +1 -1
- package/dist/types/tool-bubble-class.d.ts +1 -1
- package/dist/types/tool-bubble-class.d.ts.map +1 -1
- package/dist/types/tool-bubble-class.js +0 -2
- package/dist/types/tool-bubble-class.js.map +1 -1
- package/dist/types/workflow-bubble-class.d.ts +1 -1
- package/dist/types/workflow-bubble-class.d.ts.map +1 -1
- package/dist/utils/agent-formatter.d.ts.map +1 -1
- package/dist/utils/agent-formatter.js +2 -2
- package/dist/utils/agent-formatter.js.map +1 -1
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -1
- package/dist/utils/bubbleflow-validation.js +89 -32
- package/dist/utils/bubbleflow-validation.js.map +1 -1
- package/dist/utils/error-sanitizer.d.ts +12 -0
- package/dist/utils/error-sanitizer.d.ts.map +1 -0
- package/dist/utils/error-sanitizer.js +77 -0
- package/dist/utils/error-sanitizer.js.map +1 -0
- package/package.json +4 -4
- package/dist/bubble-trigger/index.d.ts +0 -2
- package/dist/bubble-trigger/index.d.ts.map +0 -1
- package/dist/bubble-trigger/index.js +0 -2
- package/dist/bubble-trigger/index.js.map +0 -1
- package/dist/bubble-trigger/types.d.ts +0 -87
- package/dist/bubble-trigger/types.d.ts.map +0 -1
- package/dist/bubble-trigger/types.js +0 -14
- package/dist/bubble-trigger/types.js.map +0 -1
- package/dist/bubbles/service-bubble/apify/api-scraper.schema.d.ts +0 -370
- package/dist/bubbles/service-bubble/apify/api-scraper.schema.d.ts.map +0 -1
- package/dist/bubbles/service-bubble/apify/api-scraper.schema.js +0 -14
- package/dist/bubbles/service-bubble/apify/api-scraper.schema.js.map +0 -1
- package/dist/bubbles/service-bubble/apify.d.ts +0 -136
- package/dist/bubbles/service-bubble/apify.d.ts.map +0 -1
- package/dist/bubbles/service-bubble/apify.js +0 -282
- package/dist/bubbles/service-bubble/apify.js.map +0 -1
- package/dist/types/ai-models.d.ts +0 -4
- package/dist/types/ai-models.d.ts.map +0 -1
- package/dist/types/ai-models.js +0 -20
- package/dist/types/ai-models.js.map +0 -1
- package/dist/types/api-scraper.schema.d.ts +0 -453
- package/dist/types/api-scraper.schema.d.ts.map +0 -1
- package/dist/types/api-scraper.schema.js +0 -160
- package/dist/types/api-scraper.schema.js.map +0 -1
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ToolBubble } from '../../types/tool-bubble-class.js';
|
|
3
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
4
|
+
import { ApifyBubble } from '../service-bubble/apify/apify.js';
|
|
5
|
+
// Unified YouTube data types (service-agnostic)
|
|
6
|
+
const YouTubeVideoSchema = z.object({
|
|
7
|
+
title: z.string().nullable().describe('Video title'),
|
|
8
|
+
id: z.string().nullable().describe('YouTube video ID'),
|
|
9
|
+
url: z.string().nullable().describe('Video URL'),
|
|
10
|
+
viewCount: z.number().nullable().describe('Number of views'),
|
|
11
|
+
likes: z.number().nullable().describe('Number of likes'),
|
|
12
|
+
date: z.string().nullable().describe('Upload date (ISO format)'),
|
|
13
|
+
channelName: z.string().nullable().describe('Channel name'),
|
|
14
|
+
channelUrl: z.string().nullable().describe('Channel URL'),
|
|
15
|
+
subscribers: z.number().nullable().describe('Number of channel subscribers'),
|
|
16
|
+
duration: z.string().nullable().describe('Video duration (HH:MM:SS)'),
|
|
17
|
+
description: z.string().nullable().describe('Video description'),
|
|
18
|
+
comments: z.number().nullable().describe('Number of comments'),
|
|
19
|
+
thumbnail: z.string().nullable().describe('Thumbnail URL'),
|
|
20
|
+
});
|
|
21
|
+
const YouTubeTranscriptSegmentSchema = z.object({
|
|
22
|
+
start: z.string().nullable().describe('Start time in seconds'),
|
|
23
|
+
duration: z.string().nullable().describe('Duration in seconds'),
|
|
24
|
+
text: z.string().nullable().describe('Transcript text'),
|
|
25
|
+
});
|
|
26
|
+
// Tool params schema
|
|
27
|
+
const YouTubeToolParamsSchema = z.object({
|
|
28
|
+
operation: z
|
|
29
|
+
.enum(['searchVideos', 'getTranscript', 'scrapeChannel'])
|
|
30
|
+
.describe('Operation: searchVideos for search/URLs, getTranscript for transcripts, scrapeChannel for channel videos. Not all videos will have transcript available.'),
|
|
31
|
+
// Search operation fields
|
|
32
|
+
searchQueries: z
|
|
33
|
+
.array(z.string())
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Search queries for YouTube (for searchVideos). Examples: ["AI tutorials", "react hooks"]'),
|
|
36
|
+
videoUrls: z
|
|
37
|
+
.array(z.string().url())
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Direct YouTube URLs - videos, channels, playlists (for searchVideos or getTranscript)'),
|
|
40
|
+
// Channel scraping
|
|
41
|
+
channelUrl: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe('YouTube channel URL (for scrapeChannel operation)'),
|
|
45
|
+
// Transcript operation field
|
|
46
|
+
videoUrl: z
|
|
47
|
+
.string()
|
|
48
|
+
.url()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Single video URL for transcript extraction (for getTranscript)'),
|
|
51
|
+
// Common fields
|
|
52
|
+
maxResults: z
|
|
53
|
+
.number()
|
|
54
|
+
.min(0)
|
|
55
|
+
.max(200)
|
|
56
|
+
.default(20)
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('Max videos to fetch (default: 20)'),
|
|
59
|
+
includeShorts: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.default(false)
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Include YouTube Shorts in results'),
|
|
64
|
+
credentials: z
|
|
65
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('Required credentials (auto-injected)'),
|
|
68
|
+
});
|
|
69
|
+
// Tool result schema
|
|
70
|
+
const YouTubeToolResultSchema = z.object({
|
|
71
|
+
operation: z
|
|
72
|
+
.enum(['searchVideos', 'getTranscript', 'scrapeChannel'])
|
|
73
|
+
.describe('Operation performed'),
|
|
74
|
+
// Video data (for searchVideos and scrapeChannel)
|
|
75
|
+
videos: z
|
|
76
|
+
.array(YouTubeVideoSchema)
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Array of YouTube videos'),
|
|
79
|
+
// Transcript data (for getTranscript)
|
|
80
|
+
transcript: z
|
|
81
|
+
.array(YouTubeTranscriptSegmentSchema)
|
|
82
|
+
.optional()
|
|
83
|
+
.describe('Video transcript with timestamps'),
|
|
84
|
+
fullTranscriptText: z
|
|
85
|
+
.string()
|
|
86
|
+
.optional()
|
|
87
|
+
.describe('Complete transcript as plain text'),
|
|
88
|
+
// Common fields
|
|
89
|
+
totalResults: z.number().describe('Total number of results'),
|
|
90
|
+
success: z.boolean().describe('Whether operation succeeded'),
|
|
91
|
+
error: z.string().describe('Error message if failed'),
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Simple, dev-friendly YouTube tool
|
|
95
|
+
*
|
|
96
|
+
* Provides easy access to YouTube data through three operations:
|
|
97
|
+
* - searchVideos: Search YouTube or scrape video/channel/playlist URLs
|
|
98
|
+
* - getTranscript: Extract video transcripts with timestamps
|
|
99
|
+
* - scrapeChannel: Get all videos from a channel
|
|
100
|
+
*/
|
|
101
|
+
export class YouTubeTool extends ToolBubble {
|
|
102
|
+
static bubbleName = 'youtube-tool';
|
|
103
|
+
static schema = YouTubeToolParamsSchema;
|
|
104
|
+
static resultSchema = YouTubeToolResultSchema;
|
|
105
|
+
static shortDescription = 'Search YouTube videos, extract transcripts, and scrape channel content with a simple interface';
|
|
106
|
+
static longDescription = `
|
|
107
|
+
Universal YouTube tool for video search, transcript extraction, and channel scraping.
|
|
108
|
+
|
|
109
|
+
**OPERATIONS:**
|
|
110
|
+
1. **searchVideos**: Search YouTube or scrape specific URLs
|
|
111
|
+
- Search by keywords
|
|
112
|
+
- Scrape videos, channels, playlists, or hashtags
|
|
113
|
+
- Get video metadata, views, likes, channel info
|
|
114
|
+
|
|
115
|
+
2. **getTranscript**: Extract video transcripts
|
|
116
|
+
- Get timestamped transcript segments
|
|
117
|
+
- Full transcript text available
|
|
118
|
+
- Perfect for content analysis or subtitles
|
|
119
|
+
|
|
120
|
+
3. **scrapeChannel**: Get all videos from a channel
|
|
121
|
+
- Fetch recent videos from any channel
|
|
122
|
+
- Sort by newest, popular, or oldest
|
|
123
|
+
- Get comprehensive video data
|
|
124
|
+
|
|
125
|
+
**WHEN TO USE THIS TOOL:**
|
|
126
|
+
- YouTube video search and discovery
|
|
127
|
+
- Content analysis and research
|
|
128
|
+
- Transcript extraction for AI/ML
|
|
129
|
+
- Channel monitoring and tracking
|
|
130
|
+
- Video metadata collection
|
|
131
|
+
|
|
132
|
+
**Simple Interface:**
|
|
133
|
+
Just specify the operation and provide search terms or URLs.
|
|
134
|
+
The tool handles service selection, data transformation, and error handling.
|
|
135
|
+
|
|
136
|
+
**What you get:**
|
|
137
|
+
- Clean, structured video data
|
|
138
|
+
- Timestamped transcripts
|
|
139
|
+
- Channel and engagement metrics
|
|
140
|
+
- Ready for analysis or processing
|
|
141
|
+
`;
|
|
142
|
+
static alias = 'yt';
|
|
143
|
+
static type = 'tool';
|
|
144
|
+
constructor(params = {
|
|
145
|
+
operation: 'searchVideos',
|
|
146
|
+
searchQueries: ['AI tutorials'],
|
|
147
|
+
maxResults: 20,
|
|
148
|
+
}, context) {
|
|
149
|
+
super(params, context);
|
|
150
|
+
}
|
|
151
|
+
async performAction() {
|
|
152
|
+
const credentials = this.params?.credentials;
|
|
153
|
+
if (!credentials || !credentials[CredentialType.APIFY_CRED]) {
|
|
154
|
+
return this.createErrorResult('YouTube scraping requires authentication. Please configure APIFY_CRED.');
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const { operation } = this.params;
|
|
158
|
+
// Validate required fields
|
|
159
|
+
if (operation === 'searchVideos') {
|
|
160
|
+
if ((!this.params.searchQueries ||
|
|
161
|
+
this.params.searchQueries.length === 0) &&
|
|
162
|
+
(!this.params.videoUrls || this.params.videoUrls.length === 0)) {
|
|
163
|
+
return this.createErrorResult('searchVideos requires either searchQueries or videoUrls');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (operation === 'getTranscript' && !this.params.videoUrl) {
|
|
167
|
+
return this.createErrorResult('getTranscript requires a videoUrl parameter');
|
|
168
|
+
}
|
|
169
|
+
if (operation === 'scrapeChannel' && !this.params.channelUrl) {
|
|
170
|
+
return this.createErrorResult('scrapeChannel requires a channelUrl parameter');
|
|
171
|
+
}
|
|
172
|
+
// Execute operation
|
|
173
|
+
switch (operation) {
|
|
174
|
+
case 'searchVideos':
|
|
175
|
+
return await this.handleSearchVideos();
|
|
176
|
+
case 'getTranscript':
|
|
177
|
+
return await this.handleGetTranscript();
|
|
178
|
+
case 'scrapeChannel':
|
|
179
|
+
return await this.handleScrapeChannel();
|
|
180
|
+
default:
|
|
181
|
+
throw new Error(`Unsupported operation: ${operation}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
return this.createErrorResult(error instanceof Error ? error.message : 'Unknown error occurred');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Create error result
|
|
190
|
+
*/
|
|
191
|
+
createErrorResult(errorMessage) {
|
|
192
|
+
const { operation } = this.params;
|
|
193
|
+
return {
|
|
194
|
+
operation: operation || 'searchVideos',
|
|
195
|
+
videos: operation === 'searchVideos' || operation === 'scrapeChannel'
|
|
196
|
+
? []
|
|
197
|
+
: undefined,
|
|
198
|
+
transcript: operation === 'getTranscript' ? [] : undefined,
|
|
199
|
+
fullTranscriptText: operation === 'getTranscript' ? '' : undefined,
|
|
200
|
+
totalResults: 0,
|
|
201
|
+
success: false,
|
|
202
|
+
error: errorMessage,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Handle searchVideos operation
|
|
207
|
+
*/
|
|
208
|
+
async handleSearchVideos() {
|
|
209
|
+
const searchVideo = new ApifyBubble({
|
|
210
|
+
actorId: 'streamers/youtube-scraper',
|
|
211
|
+
input: {
|
|
212
|
+
searchQueries: this.params.searchQueries,
|
|
213
|
+
startUrls: this.params.videoUrls?.map((url) => ({ url })),
|
|
214
|
+
maxResults: this.params.maxResults || 20,
|
|
215
|
+
maxResultsShorts: this.params.includeShorts
|
|
216
|
+
? this.params.maxResults || 20
|
|
217
|
+
: 0,
|
|
218
|
+
},
|
|
219
|
+
waitForFinish: true,
|
|
220
|
+
timeout: 180000,
|
|
221
|
+
credentials: this.params.credentials,
|
|
222
|
+
}, this.context);
|
|
223
|
+
const result = await searchVideo.action();
|
|
224
|
+
if (!result.data.success) {
|
|
225
|
+
return this.createErrorResult(result.data.error || 'Failed to search YouTube videos');
|
|
226
|
+
}
|
|
227
|
+
const items = result.data.items || [];
|
|
228
|
+
const videos = this.transformVideos(items);
|
|
229
|
+
return {
|
|
230
|
+
operation: 'searchVideos',
|
|
231
|
+
videos,
|
|
232
|
+
totalResults: videos.length,
|
|
233
|
+
success: true,
|
|
234
|
+
error: '',
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Handle getTranscript operation
|
|
239
|
+
*/
|
|
240
|
+
async handleGetTranscript() {
|
|
241
|
+
const transcriptScraper = new ApifyBubble({
|
|
242
|
+
actorId: 'pintostudio/youtube-transcript-scraper',
|
|
243
|
+
input: {
|
|
244
|
+
videoUrl: this.params.videoUrl,
|
|
245
|
+
},
|
|
246
|
+
waitForFinish: true,
|
|
247
|
+
timeout: 120000,
|
|
248
|
+
credentials: this.params.credentials,
|
|
249
|
+
}, this.context);
|
|
250
|
+
const result = await transcriptScraper.action();
|
|
251
|
+
if (!result.data.success) {
|
|
252
|
+
return this.createErrorResult(result.data.error || 'Failed to extract transcript');
|
|
253
|
+
}
|
|
254
|
+
const items = result.data.items || [];
|
|
255
|
+
const firstItem = items[0];
|
|
256
|
+
if (!firstItem || typeof firstItem !== 'object') {
|
|
257
|
+
return this.createErrorResult('No transcript data returned');
|
|
258
|
+
}
|
|
259
|
+
const anyItem = firstItem;
|
|
260
|
+
const transcriptData = anyItem.data || [];
|
|
261
|
+
const transcript = transcriptData.map((segment) => ({
|
|
262
|
+
start: segment.start || null,
|
|
263
|
+
duration: segment.dur || null,
|
|
264
|
+
text: segment.text || null,
|
|
265
|
+
}));
|
|
266
|
+
const fullText = transcript.map((seg) => seg.text || '').join(' ');
|
|
267
|
+
return {
|
|
268
|
+
operation: 'getTranscript',
|
|
269
|
+
transcript,
|
|
270
|
+
fullTranscriptText: fullText,
|
|
271
|
+
totalResults: transcript.length,
|
|
272
|
+
success: true,
|
|
273
|
+
error: '',
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Handle scrapeChannel operation
|
|
278
|
+
*/
|
|
279
|
+
async handleScrapeChannel() {
|
|
280
|
+
const channelScraper = new ApifyBubble({
|
|
281
|
+
actorId: 'streamers/youtube-scraper',
|
|
282
|
+
input: {
|
|
283
|
+
startUrls: [{ url: this.params.channelUrl }],
|
|
284
|
+
maxResults: this.params.maxResults || 20,
|
|
285
|
+
sortVideosBy: 'NEWEST',
|
|
286
|
+
},
|
|
287
|
+
waitForFinish: true,
|
|
288
|
+
timeout: 180000,
|
|
289
|
+
credentials: this.params.credentials,
|
|
290
|
+
}, this.context);
|
|
291
|
+
const result = await channelScraper.action();
|
|
292
|
+
if (!result.data.success) {
|
|
293
|
+
return this.createErrorResult(result.data.error || 'Failed to scrape channel');
|
|
294
|
+
}
|
|
295
|
+
const items = result.data.items || [];
|
|
296
|
+
const videos = this.transformVideos(items);
|
|
297
|
+
return {
|
|
298
|
+
operation: 'scrapeChannel',
|
|
299
|
+
videos,
|
|
300
|
+
totalResults: videos.length,
|
|
301
|
+
success: true,
|
|
302
|
+
error: '',
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Transform Apify video data to unified format
|
|
307
|
+
*/
|
|
308
|
+
transformVideos(items) {
|
|
309
|
+
return items.map((item) => {
|
|
310
|
+
if (typeof item !== 'object' || item === null) {
|
|
311
|
+
return this.createEmptyVideo();
|
|
312
|
+
}
|
|
313
|
+
const anyItem = item;
|
|
314
|
+
return {
|
|
315
|
+
title: anyItem.title || null,
|
|
316
|
+
id: anyItem.id || null,
|
|
317
|
+
url: anyItem.url || null,
|
|
318
|
+
viewCount: anyItem.viewCount || null,
|
|
319
|
+
likes: anyItem.likes || null,
|
|
320
|
+
date: anyItem.date || null,
|
|
321
|
+
channelName: anyItem.channelName || null,
|
|
322
|
+
channelUrl: anyItem.channelUrl || null,
|
|
323
|
+
subscribers: anyItem.numberOfSubscribers || null,
|
|
324
|
+
duration: anyItem.duration || null,
|
|
325
|
+
description: anyItem.text || null,
|
|
326
|
+
comments: anyItem.commentsCount || null,
|
|
327
|
+
thumbnail: anyItem.thumbnailUrl || null,
|
|
328
|
+
};
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Create empty video object
|
|
333
|
+
*/
|
|
334
|
+
createEmptyVideo() {
|
|
335
|
+
return {
|
|
336
|
+
title: null,
|
|
337
|
+
id: null,
|
|
338
|
+
url: null,
|
|
339
|
+
viewCount: null,
|
|
340
|
+
likes: null,
|
|
341
|
+
date: null,
|
|
342
|
+
channelName: null,
|
|
343
|
+
channelUrl: null,
|
|
344
|
+
subscribers: null,
|
|
345
|
+
duration: null,
|
|
346
|
+
description: null,
|
|
347
|
+
comments: null,
|
|
348
|
+
thumbnail: null,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=youtube-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"youtube-tool.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/youtube-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,2BAA2B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAG/D,gDAAgD;AAChD,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;IACpD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,Q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
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { WorkflowBubble } from '../../types/workflow-bubble-class.js';
|
|
11
11
|
import type { BubbleContext } from '../../types/bubble.js';
|
|
12
|
-
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
12
|
+
import { CredentialType, type GenerationResult } from '@bubblelab/shared-schemas';
|
|
13
13
|
import { type StreamingCallback } from '../service-bubble/ai-agent.js';
|
|
14
14
|
/**
|
|
15
15
|
* Parameters schema for the simple BubbleFlow generator
|
|
@@ -24,40 +24,11 @@ declare const BubbleFlowGeneratorParamsSchema: z.ZodObject<{
|
|
|
24
24
|
prompt: string;
|
|
25
25
|
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
26
26
|
}>;
|
|
27
|
-
/**
|
|
28
|
-
* Result schema
|
|
29
|
-
*/
|
|
30
|
-
declare const BubbleFlowGeneratorResultSchema: z.ZodObject<{
|
|
31
|
-
generatedCode: z.ZodString;
|
|
32
|
-
isValid: z.ZodBoolean;
|
|
33
|
-
success: z.ZodBoolean;
|
|
34
|
-
error: z.ZodString;
|
|
35
|
-
toolCalls: z.ZodArray<z.ZodAny, "many">;
|
|
36
|
-
summary: z.ZodDefault<z.ZodString>;
|
|
37
|
-
inputsSchema: z.ZodDefault<z.ZodString>;
|
|
38
|
-
}, "strip", z.ZodTypeAny, {
|
|
39
|
-
success: boolean;
|
|
40
|
-
error: string;
|
|
41
|
-
toolCalls: any[];
|
|
42
|
-
summary: string;
|
|
43
|
-
generatedCode: string;
|
|
44
|
-
isValid: boolean;
|
|
45
|
-
inputsSchema: string;
|
|
46
|
-
}, {
|
|
47
|
-
success: boolean;
|
|
48
|
-
error: string;
|
|
49
|
-
toolCalls: any[];
|
|
50
|
-
generatedCode: string;
|
|
51
|
-
isValid: boolean;
|
|
52
|
-
summary?: string | undefined;
|
|
53
|
-
inputsSchema?: string | undefined;
|
|
54
|
-
}>;
|
|
55
27
|
type BubbleFlowGeneratorParams = z.output<typeof BubbleFlowGeneratorParamsSchema>;
|
|
56
|
-
type BubbleFlowGeneratorResult = z.output<typeof BubbleFlowGeneratorResultSchema>;
|
|
57
28
|
/**
|
|
58
29
|
* Simple BubbleFlow Generator using AI agent with tools
|
|
59
30
|
*/
|
|
60
|
-
export declare class BubbleFlowGeneratorWorkflow extends WorkflowBubble<BubbleFlowGeneratorParams,
|
|
31
|
+
export declare class BubbleFlowGeneratorWorkflow extends WorkflowBubble<BubbleFlowGeneratorParams, GenerationResult> {
|
|
61
32
|
static readonly type: "workflow";
|
|
62
33
|
static readonly bubbleName = "bubbleflow-generator";
|
|
63
34
|
static readonly schema: z.ZodObject<{
|
|
@@ -75,25 +46,65 @@ export declare class BubbleFlowGeneratorWorkflow extends WorkflowBubble<BubbleFl
|
|
|
75
46
|
isValid: z.ZodBoolean;
|
|
76
47
|
success: z.ZodBoolean;
|
|
77
48
|
error: z.ZodString;
|
|
78
|
-
|
|
49
|
+
flowId: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
toolCalls: z.ZodArray<z.ZodUnknown, "many">;
|
|
79
51
|
summary: z.ZodDefault<z.ZodString>;
|
|
80
52
|
inputsSchema: z.ZodDefault<z.ZodString>;
|
|
53
|
+
bubblesUsed: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
54
|
+
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
inputTokens: z.ZodNumber;
|
|
56
|
+
outputTokens: z.ZodNumber;
|
|
57
|
+
totalTokens: z.ZodNumber;
|
|
58
|
+
modelName: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
inputTokens: number;
|
|
61
|
+
outputTokens: number;
|
|
62
|
+
totalTokens: number;
|
|
63
|
+
modelName?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
inputTokens: number;
|
|
66
|
+
outputTokens: number;
|
|
67
|
+
totalTokens: number;
|
|
68
|
+
modelName?: string | undefined;
|
|
69
|
+
}>>;
|
|
70
|
+
bubbleCount: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
codeLength: z.ZodOptional<z.ZodNumber>;
|
|
81
72
|
}, "strip", z.ZodTypeAny, {
|
|
82
73
|
success: boolean;
|
|
83
74
|
error: string;
|
|
84
|
-
toolCalls: any[];
|
|
85
75
|
summary: string;
|
|
86
76
|
generatedCode: string;
|
|
87
77
|
isValid: boolean;
|
|
78
|
+
toolCalls: unknown[];
|
|
88
79
|
inputsSchema: string;
|
|
80
|
+
bubblesUsed: string[];
|
|
81
|
+
tokenUsage?: {
|
|
82
|
+
inputTokens: number;
|
|
83
|
+
outputTokens: number;
|
|
84
|
+
totalTokens: number;
|
|
85
|
+
modelName?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
flowId?: number | undefined;
|
|
88
|
+
bubbleCount?: number | undefined;
|
|
89
|
+
codeLength?: number | undefined;
|
|
89
90
|
}, {
|
|
90
91
|
success: boolean;
|
|
91
92
|
error: string;
|
|
92
|
-
toolCalls: any[];
|
|
93
93
|
generatedCode: string;
|
|
94
94
|
isValid: boolean;
|
|
95
|
+
toolCalls: unknown[];
|
|
96
|
+
tokenUsage?: {
|
|
97
|
+
inputTokens: number;
|
|
98
|
+
outputTokens: number;
|
|
99
|
+
totalTokens: number;
|
|
100
|
+
modelName?: string | undefined;
|
|
101
|
+
} | undefined;
|
|
95
102
|
summary?: string | undefined;
|
|
103
|
+
flowId?: number | undefined;
|
|
104
|
+
bubbleCount?: number | undefined;
|
|
105
|
+
codeLength?: number | undefined;
|
|
96
106
|
inputsSchema?: string | undefined;
|
|
107
|
+
bubblesUsed?: string[] | undefined;
|
|
97
108
|
}>;
|
|
98
109
|
static readonly shortDescription = "Generate BubbleFlow code from natural language";
|
|
99
110
|
static readonly longDescription = "\n Simple BubbleFlow generator that uses AI with validation tools.\n \n Just provide a natural language prompt describing what you want your BubbleFlow to do,\n and it will generate complete TypeScript code with proper validation.\n \n Example prompts:\n - \"Create a flow that queries my database and sends results to Slack\"\n - \"Build a workflow that processes user data with AI and stores it\"\n - \"Make a flow that analyzes text and generates a summary\"\n ";
|
|
@@ -104,11 +115,11 @@ export declare class BubbleFlowGeneratorWorkflow extends WorkflowBubble<BubbleFl
|
|
|
104
115
|
private runSummarizeAgent;
|
|
105
116
|
private createSystemPrompt;
|
|
106
117
|
private createStreamingSystemPrompt;
|
|
107
|
-
protected performAction(context?: BubbleContext): Promise<
|
|
118
|
+
protected performAction(context?: BubbleContext): Promise<GenerationResult>;
|
|
108
119
|
/**
|
|
109
120
|
* Execute the workflow with streaming support for real-time code generation feedback
|
|
110
121
|
*/
|
|
111
|
-
actionWithStreaming(streamingCallback: StreamingCallback, context?: BubbleContext): Promise<
|
|
122
|
+
actionWithStreaming(streamingCallback: StreamingCallback, context?: BubbleContext): Promise<GenerationResult>;
|
|
112
123
|
}
|
|
113
124
|
export {};
|
|
114
125
|
//# sourceMappingURL=bubbleflow-generator.workflow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubbleflow-generator.workflow.d.ts","sourceRoot":"","sources":["../../../src/bubbles/workflow-bubble/bubbleflow-generator.workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"bubbleflow-generator.workflow.d.ts","sourceRoot":"","sources":["../../../src/bubbles/workflow-bubble/bubbleflow-generator.workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,E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