@bubblelab/shared-schemas 0.1.11 → 0.1.13

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 (109) hide show
  1. package/dist/index.d.ts +10076 -28
  2. package/dist/index.js +3328 -29
  3. package/dist/index.js.map +1 -1
  4. package/package.json +3 -2
  5. package/dist/agent-memory.d.ts +0 -21
  6. package/dist/agent-memory.d.ts.map +0 -1
  7. package/dist/agent-memory.js +0 -11
  8. package/dist/agent-memory.js.map +0 -1
  9. package/dist/ai-models.d.ts +0 -4
  10. package/dist/ai-models.d.ts.map +0 -1
  11. package/dist/ai-models.js +0 -31
  12. package/dist/ai-models.js.map +0 -1
  13. package/dist/api-schema.d.ts +0 -38
  14. package/dist/api-schema.d.ts.map +0 -1
  15. package/dist/api-schema.js +0 -26
  16. package/dist/api-schema.js.map +0 -1
  17. package/dist/bubble-definition-schema.d.ts +0 -840
  18. package/dist/bubble-definition-schema.d.ts.map +0 -1
  19. package/dist/bubble-definition-schema.js +0 -297
  20. package/dist/bubble-definition-schema.js.map +0 -1
  21. package/dist/bubbleflow-execution-schema.d.ts +0 -1261
  22. package/dist/bubbleflow-execution-schema.d.ts.map +0 -1
  23. package/dist/bubbleflow-execution-schema.js +0 -354
  24. package/dist/bubbleflow-execution-schema.js.map +0 -1
  25. package/dist/bubbleflow-generation-prompts.d.ts +0 -25
  26. package/dist/bubbleflow-generation-prompts.d.ts.map +0 -1
  27. package/dist/bubbleflow-generation-prompts.js +0 -426
  28. package/dist/bubbleflow-generation-prompts.js.map +0 -1
  29. package/dist/bubbleflow-schema.d.ts +0 -2071
  30. package/dist/bubbleflow-schema.d.ts.map +0 -1
  31. package/dist/bubbleflow-schema.js +0 -336
  32. package/dist/bubbleflow-schema.js.map +0 -1
  33. package/dist/coffee.d.ts +0 -2201
  34. package/dist/coffee.d.ts.map +0 -1
  35. package/dist/coffee.js +0 -258
  36. package/dist/coffee.js.map +0 -1
  37. package/dist/credential-schema.d.ts +0 -419
  38. package/dist/credential-schema.d.ts.map +0 -1
  39. package/dist/credential-schema.js +0 -458
  40. package/dist/credential-schema.js.map +0 -1
  41. package/dist/cron-utils.d.ts +0 -47
  42. package/dist/cron-utils.d.ts.map +0 -1
  43. package/dist/cron-utils.js +0 -228
  44. package/dist/cron-utils.js.map +0 -1
  45. package/dist/database-definition-schema.d.ts +0 -97
  46. package/dist/database-definition-schema.d.ts.map +0 -1
  47. package/dist/database-definition-schema.js +0 -36
  48. package/dist/database-definition-schema.js.map +0 -1
  49. package/dist/error-enhancer.d.ts +0 -6
  50. package/dist/error-enhancer.d.ts.map +0 -1
  51. package/dist/error-enhancer.js +0 -88
  52. package/dist/error-enhancer.js.map +0 -1
  53. package/dist/generate-bubbleflow-schema.d.ts +0 -1525
  54. package/dist/generate-bubbleflow-schema.d.ts.map +0 -1
  55. package/dist/generate-bubbleflow-schema.js +0 -304
  56. package/dist/generate-bubbleflow-schema.js.map +0 -1
  57. package/dist/hash-utils.d.ts +0 -26
  58. package/dist/hash-utils.d.ts.map +0 -1
  59. package/dist/hash-utils.js +0 -37
  60. package/dist/hash-utils.js.map +0 -1
  61. package/dist/index.d.ts.map +0 -1
  62. package/dist/milk-tea.d.ts +0 -106
  63. package/dist/milk-tea.d.ts.map +0 -1
  64. package/dist/milk-tea.js +0 -71
  65. package/dist/milk-tea.js.map +0 -1
  66. package/dist/mock-data-generator.d.ts +0 -51
  67. package/dist/mock-data-generator.d.ts.map +0 -1
  68. package/dist/mock-data-generator.js +0 -335
  69. package/dist/mock-data-generator.js.map +0 -1
  70. package/dist/oauth-schema.d.ts +0 -61
  71. package/dist/oauth-schema.d.ts.map +0 -1
  72. package/dist/oauth-schema.js +0 -75
  73. package/dist/oauth-schema.js.map +0 -1
  74. package/dist/param-utils.d.ts +0 -10
  75. package/dist/param-utils.d.ts.map +0 -1
  76. package/dist/param-utils.js +0 -13
  77. package/dist/param-utils.js.map +0 -1
  78. package/dist/pearl.d.ts +0 -346
  79. package/dist/pearl.d.ts.map +0 -1
  80. package/dist/pearl.js +0 -90
  81. package/dist/pearl.js.map +0 -1
  82. package/dist/storage-utils.d.ts +0 -19
  83. package/dist/storage-utils.d.ts.map +0 -1
  84. package/dist/storage-utils.js +0 -54
  85. package/dist/storage-utils.js.map +0 -1
  86. package/dist/streaming-events.d.ts +0 -132
  87. package/dist/streaming-events.d.ts.map +0 -1
  88. package/dist/streaming-events.js +0 -5
  89. package/dist/streaming-events.js.map +0 -1
  90. package/dist/subscription-status-schema.d.ts +0 -250
  91. package/dist/subscription-status-schema.d.ts.map +0 -1
  92. package/dist/subscription-status-schema.js +0 -144
  93. package/dist/subscription-status-schema.js.map +0 -1
  94. package/dist/trigger.d.ts +0 -113
  95. package/dist/trigger.d.ts.map +0 -1
  96. package/dist/trigger.js +0 -12
  97. package/dist/trigger.js.map +0 -1
  98. package/dist/types.d.ts +0 -29
  99. package/dist/types.d.ts.map +0 -1
  100. package/dist/types.js +0 -43
  101. package/dist/types.js.map +0 -1
  102. package/dist/waitlist-schema.d.ts +0 -30
  103. package/dist/waitlist-schema.d.ts.map +0 -1
  104. package/dist/waitlist-schema.js +0 -39
  105. package/dist/waitlist-schema.js.map +0 -1
  106. package/dist/webhook-schema.d.ts +0 -95
  107. package/dist/webhook-schema.d.ts.map +0 -1
  108. package/dist/webhook-schema.js +0 -50
  109. package/dist/webhook-schema.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,30 +1,3329 @@
1
- // Re-export all schemas and types from the routes file
2
- // Note: All schemas are defined in routes.ts
3
- export * from './api-schema.js';
4
- export * from './database-definition-schema.js';
5
- export * from './credential-schema.js';
6
- export * from './bubble-definition-schema.js';
7
- export * from './types.js';
8
- export * from './streaming-events.js';
9
- export * from './mock-data-generator.js';
10
- export * from './oauth-schema.js';
11
- export * from './waitlist-schema.js';
12
- export * from './bubbleflow-schema.js';
13
- export * from './bubbleflow-execution-schema.js';
14
- export * from './generate-bubbleflow-schema.js';
15
- export * from './webhook-schema.js';
16
- export * from './subscription-status-schema.js';
17
- export * from './api-schema.js';
18
- export * from './milk-tea.js';
19
- export * from './pearl.js';
20
- export * from './coffee.js';
21
- export * from './ai-models.js';
22
- export * from './cron-utils.js';
23
- export * from './trigger.js';
24
- export * from './bubbleflow-generation-prompts.js';
25
- export * from './storage-utils.js';
26
- export * from './param-utils.js';
27
- export * from './error-enhancer.js';
28
- export * from './hash-utils.js';
29
- export * from './agent-memory.js';
1
+ // src/api-schema.ts
2
+ import { z } from "@hono/zod-openapi";
3
+ var errorResponseSchema = z.object({
4
+ error: z.string().openapi({
5
+ description: "Error message",
6
+ example: "Validation failed"
7
+ }),
8
+ details: z.string().optional().openapi({
9
+ description: "Additional error details",
10
+ example: "Invalid field: name is required"
11
+ })
12
+ }).openapi("ErrorResponse");
13
+ var slackUrlVerificationSchema = z.object({
14
+ token: z.string(),
15
+ challenge: z.string(),
16
+ type: z.literal("url_verification")
17
+ });
18
+ var slackUrlVerificationResponseSchema = z.object({
19
+ challenge: z.string().openapi({ description: "Slack URL verification challenge" })
20
+ }).openapi("SlackUrlVerificationResponse");
21
+
22
+ // src/database-definition-schema.ts
23
+ import { z as z2 } from "@hono/zod-openapi";
24
+ var databaseMetadataSchema = z2.object({
25
+ // Core database definition - mapping of table names to column definitions
26
+ // Format: { [tableName]: { [columnName]: columnType } }
27
+ tables: z2.record(
28
+ z2.string(),
29
+ // table name
30
+ z2.record(
31
+ z2.string(),
32
+ // column name
33
+ z2.string()
34
+ // notes about it
35
+ )
36
+ ),
37
+ // Table-level notes - mapping of table names to notes about the entire table
38
+ tableNotes: z2.record(z2.string(), z2.string()).optional(),
39
+ // Optional metadata
40
+ databaseName: z2.string().optional(),
41
+ databaseType: z2.enum(["postgresql", "mysql", "sqlite", "mssql", "oracle"]).optional(),
42
+ // Rules and constraints - simplified to match frontend
43
+ rules: z2.array(
44
+ z2.object({
45
+ id: z2.string(),
46
+ text: z2.string(),
47
+ enabled: z2.boolean(),
48
+ createdAt: z2.string(),
49
+ // ISO string
50
+ updatedAt: z2.string()
51
+ // ISO string
52
+ })
53
+ ).optional(),
54
+ // Additional context
55
+ notes: z2.string().optional(),
56
+ tags: z2.array(z2.string()).optional()
57
+ });
58
+
59
+ // src/types.ts
60
+ var CredentialType = /* @__PURE__ */ ((CredentialType2) => {
61
+ CredentialType2["OPENAI_CRED"] = "OPENAI_CRED";
62
+ CredentialType2["GOOGLE_GEMINI_CRED"] = "GOOGLE_GEMINI_CRED";
63
+ CredentialType2["ANTHROPIC_CRED"] = "ANTHROPIC_CRED";
64
+ CredentialType2["OPENROUTER_CRED"] = "OPENROUTER_CRED";
65
+ CredentialType2["FIRECRAWL_API_KEY"] = "FIRECRAWL_API_KEY";
66
+ CredentialType2["DATABASE_CRED"] = "DATABASE_CRED";
67
+ CredentialType2["SLACK_CRED"] = "SLACK_CRED";
68
+ CredentialType2["TELEGRAM_BOT_TOKEN"] = "TELEGRAM_BOT_TOKEN";
69
+ CredentialType2["RESEND_CRED"] = "RESEND_CRED";
70
+ CredentialType2["CLOUDFLARE_R2_ACCESS_KEY"] = "CLOUDFLARE_R2_ACCESS_KEY";
71
+ CredentialType2["CLOUDFLARE_R2_SECRET_KEY"] = "CLOUDFLARE_R2_SECRET_KEY";
72
+ CredentialType2["CLOUDFLARE_R2_ACCOUNT_ID"] = "CLOUDFLARE_R2_ACCOUNT_ID";
73
+ CredentialType2["APIFY_CRED"] = "APIFY_CRED";
74
+ CredentialType2["ELEVENLABS_API_KEY"] = "ELEVENLABS_API_KEY";
75
+ CredentialType2["GOOGLE_DRIVE_CRED"] = "GOOGLE_DRIVE_CRED";
76
+ CredentialType2["GMAIL_CRED"] = "GMAIL_CRED";
77
+ CredentialType2["GOOGLE_SHEETS_CRED"] = "GOOGLE_SHEETS_CRED";
78
+ CredentialType2["GOOGLE_CALENDAR_CRED"] = "GOOGLE_CALENDAR_CRED";
79
+ CredentialType2["FUB_CRED"] = "FUB_CRED";
80
+ CredentialType2["NOTION_OAUTH_TOKEN"] = "NOTION_OAUTH_TOKEN";
81
+ CredentialType2["GITHUB_TOKEN"] = "GITHUB_TOKEN";
82
+ CredentialType2["AGI_API_KEY"] = "AGI_API_KEY";
83
+ CredentialType2["AIRTABLE_CRED"] = "AIRTABLE_CRED";
84
+ CredentialType2["INSFORGE_BASE_URL"] = "INSFORGE_BASE_URL";
85
+ CredentialType2["INSFORGE_API_KEY"] = "INSFORGE_API_KEY";
86
+ CredentialType2["CUSTOM_AUTH_KEY"] = "CUSTOM_AUTH_KEY";
87
+ CredentialType2["AMAZON_CRED"] = "AMAZON_CRED";
88
+ return CredentialType2;
89
+ })(CredentialType || {});
90
+
91
+ // src/credential-schema.ts
92
+ import { z as z3 } from "@hono/zod-openapi";
93
+ var CREDENTIAL_TYPE_CONFIG = {
94
+ ["OPENAI_CRED" /* OPENAI_CRED */]: {
95
+ label: "OpenAI",
96
+ description: "API key for OpenAI services (GPT models, embeddings, etc.)",
97
+ placeholder: "sk-...",
98
+ namePlaceholder: "My OpenAI API Key",
99
+ credentialConfigurations: {}
100
+ },
101
+ ["GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */]: {
102
+ label: "Google Gemini",
103
+ description: "API key for Google Gemini AI models",
104
+ placeholder: "AIza...",
105
+ namePlaceholder: "My Google Gemini Key",
106
+ credentialConfigurations: {
107
+ ignoreSSL: false
108
+ }
109
+ },
110
+ ["ANTHROPIC_CRED" /* ANTHROPIC_CRED */]: {
111
+ label: "Anthropic",
112
+ description: "API key for Anthropic Claude models",
113
+ placeholder: "sk-ant-...",
114
+ namePlaceholder: "My Anthropic API Key",
115
+ credentialConfigurations: {
116
+ ignoreSSL: false
117
+ }
118
+ },
119
+ ["DATABASE_CRED" /* DATABASE_CRED */]: {
120
+ label: "Database (PostgreSQL)",
121
+ description: "Database connection string for PostgreSQL",
122
+ placeholder: "postgresql://user:pass@host:port/dbname",
123
+ namePlaceholder: "My PostgreSQL Database",
124
+ credentialConfigurations: {
125
+ ignoreSSL: false
126
+ }
127
+ },
128
+ ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */]: {
129
+ label: "Firecrawl",
130
+ description: "API key for Firecrawl web scraping and search services",
131
+ placeholder: "fc-...",
132
+ namePlaceholder: "My Firecrawl API Key",
133
+ credentialConfigurations: {
134
+ ignoreSSL: false
135
+ }
136
+ },
137
+ ["SLACK_CRED" /* SLACK_CRED */]: {
138
+ label: "Slack",
139
+ description: "Slack Bot token (xoxb-) or User token (xoxp-) from api.slack.com/apps. Configure scopes in OAuth & Permissions.",
140
+ placeholder: "xoxb-... or xoxp-...",
141
+ namePlaceholder: "My Slack Token",
142
+ credentialConfigurations: {
143
+ ignoreSSL: false
144
+ }
145
+ },
146
+ ["RESEND_CRED" /* RESEND_CRED */]: {
147
+ label: "Resend",
148
+ description: "Your Resend API key for email services",
149
+ placeholder: "re_...",
150
+ namePlaceholder: "My Resend API Key",
151
+ credentialConfigurations: {
152
+ ignoreSSL: false
153
+ }
154
+ },
155
+ ["OPENROUTER_CRED" /* OPENROUTER_CRED */]: {
156
+ label: "OpenRouter",
157
+ description: "API key for OpenRouter services",
158
+ placeholder: "sk-or-...",
159
+ namePlaceholder: "My OpenRouter API Key",
160
+ credentialConfigurations: {
161
+ ignoreSSL: false
162
+ }
163
+ },
164
+ ["CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */]: {
165
+ label: "Cloudflare R2 Access Key",
166
+ description: "Access key for Cloudflare R2 storage",
167
+ placeholder: "Enter your access key",
168
+ namePlaceholder: "My R2 Access Key",
169
+ credentialConfigurations: {
170
+ ignoreSSL: false
171
+ }
172
+ },
173
+ ["CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */]: {
174
+ label: "Cloudflare R2 Secret Key",
175
+ description: "Secret key for Cloudflare R2 storage",
176
+ placeholder: "Enter your secret key",
177
+ namePlaceholder: "My R2 Secret Key",
178
+ credentialConfigurations: {
179
+ ignoreSSL: false
180
+ }
181
+ },
182
+ ["CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */]: {
183
+ label: "Cloudflare R2 Account ID",
184
+ description: "Account ID for Cloudflare R2 storage",
185
+ placeholder: "Enter your account ID",
186
+ namePlaceholder: "My R2 Account ID",
187
+ credentialConfigurations: {
188
+ ignoreSSL: false
189
+ }
190
+ },
191
+ ["APIFY_CRED" /* APIFY_CRED */]: {
192
+ label: "Apify",
193
+ description: "API token for Apify platform (web scraping, automation)",
194
+ placeholder: "apify_api_...",
195
+ namePlaceholder: "My Apify API Token",
196
+ credentialConfigurations: {}
197
+ },
198
+ ["GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */]: {
199
+ label: "Google Drive",
200
+ description: "OAuth connection to Google Drive for file access",
201
+ placeholder: "",
202
+ // Not used for OAuth
203
+ namePlaceholder: "My Google Drive Connection",
204
+ credentialConfigurations: {
205
+ ignoreSSL: false
206
+ }
207
+ },
208
+ ["GMAIL_CRED" /* GMAIL_CRED */]: {
209
+ label: "Gmail",
210
+ description: "OAuth connection to Gmail for email management",
211
+ placeholder: "",
212
+ // Not used for OAuth
213
+ namePlaceholder: "My Gmail Connection",
214
+ credentialConfigurations: {
215
+ ignoreSSL: false
216
+ }
217
+ },
218
+ ["GOOGLE_SHEETS_CRED" /* GOOGLE_SHEETS_CRED */]: {
219
+ label: "Google Sheets",
220
+ description: "OAuth connection to Google Sheets for spreadsheet management",
221
+ placeholder: "",
222
+ // Not used for OAuth
223
+ namePlaceholder: "My Google Sheets Connection",
224
+ credentialConfigurations: {
225
+ ignoreSSL: false
226
+ }
227
+ },
228
+ ["GOOGLE_CALENDAR_CRED" /* GOOGLE_CALENDAR_CRED */]: {
229
+ label: "Google Calendar",
230
+ description: "OAuth connection to Google Calendar for events and schedules",
231
+ placeholder: "",
232
+ // Not used for OAuth
233
+ namePlaceholder: "My Google Calendar Connection",
234
+ credentialConfigurations: {
235
+ ignoreSSL: false
236
+ }
237
+ },
238
+ ["FUB_CRED" /* FUB_CRED */]: {
239
+ label: "Follow Up Boss",
240
+ description: "OAuth connection to Follow Up Boss CRM for contacts, tasks, and deals",
241
+ placeholder: "",
242
+ // Not used for OAuth
243
+ namePlaceholder: "My Follow Up Boss Connection",
244
+ credentialConfigurations: {}
245
+ },
246
+ ["NOTION_OAUTH_TOKEN" /* NOTION_OAUTH_TOKEN */]: {
247
+ label: "Notion",
248
+ description: "OAuth connection to your Notion workspace (pages, databases, search)",
249
+ placeholder: "",
250
+ // Not used for OAuth
251
+ namePlaceholder: "My Notion Connection",
252
+ credentialConfigurations: {}
253
+ },
254
+ ["GITHUB_TOKEN" /* GITHUB_TOKEN */]: {
255
+ label: "GitHub",
256
+ description: "Personal Access Token for GitHub API (read repos, PRs, issues)",
257
+ placeholder: "github_pat...",
258
+ namePlaceholder: "My GitHub Token",
259
+ credentialConfigurations: {}
260
+ },
261
+ ["ELEVENLABS_API_KEY" /* ELEVENLABS_API_KEY */]: {
262
+ label: "Eleven Labs API Key",
263
+ description: "Your API key from Eleven Labs",
264
+ placeholder: "agent_...",
265
+ namePlaceholder: "My Eleven Labs Key",
266
+ credentialConfigurations: {}
267
+ },
268
+ ["AGI_API_KEY" /* AGI_API_KEY */]: {
269
+ label: "AGI Inc API Key",
270
+ description: "Your API key from AGI Inc",
271
+ placeholder: "api_...",
272
+ namePlaceholder: "My AGI Inc Key",
273
+ credentialConfigurations: {}
274
+ },
275
+ ["TELEGRAM_BOT_TOKEN" /* TELEGRAM_BOT_TOKEN */]: {
276
+ label: "Telegram Bot Token",
277
+ description: "Your Telegram bot token",
278
+ placeholder: "bot_...",
279
+ namePlaceholder: "My Telegram Bot Token",
280
+ credentialConfigurations: {}
281
+ },
282
+ ["AIRTABLE_CRED" /* AIRTABLE_CRED */]: {
283
+ label: "Airtable",
284
+ description: "Personal Access Token for Airtable API (manage bases, tables, records)",
285
+ placeholder: "pat...",
286
+ namePlaceholder: "My Airtable Token",
287
+ credentialConfigurations: {}
288
+ },
289
+ ["INSFORGE_BASE_URL" /* INSFORGE_BASE_URL */]: {
290
+ label: "InsForge Base URL",
291
+ description: "Base URL for your InsForge backend (e.g., https://your-app.region.insforge.app)",
292
+ placeholder: "https://your-app.region.insforge.app",
293
+ namePlaceholder: "My InsForge Backend URL",
294
+ credentialConfigurations: {}
295
+ },
296
+ ["INSFORGE_API_KEY" /* INSFORGE_API_KEY */]: {
297
+ label: "InsForge API Key",
298
+ description: "API key for your InsForge backend",
299
+ placeholder: "ik_...",
300
+ namePlaceholder: "My InsForge API Key",
301
+ credentialConfigurations: {}
302
+ },
303
+ ["CUSTOM_AUTH_KEY" /* CUSTOM_AUTH_KEY */]: {
304
+ label: "Custom Authentication Key",
305
+ description: "Custom API key or authentication token for HTTP requests (Bearer, Basic, X-API-Key, etc.)",
306
+ placeholder: "Enter your API key or token...",
307
+ namePlaceholder: "My Custom Auth Key",
308
+ credentialConfigurations: {}
309
+ },
310
+ ["AMAZON_CRED" /* AMAZON_CRED */]: {
311
+ label: "Amazon",
312
+ description: "Browser session authentication for Amazon shopping (cart, orders, purchases). Authenticate by logging into your Amazon account in a secure browser session.",
313
+ placeholder: "",
314
+ // Not used for browser session auth
315
+ namePlaceholder: "My Amazon Account",
316
+ credentialConfigurations: {}
317
+ }
318
+ };
319
+ function generateCredentialsSummary() {
320
+ const lines = ["Available credentials that users can configure:"];
321
+ for (const [credType, config] of Object.entries(CREDENTIAL_TYPE_CONFIG)) {
322
+ lines.push(`- ${config.label} (${credType}): ${config.description}`);
323
+ }
324
+ return lines.join("\n");
325
+ }
326
+ var CREDENTIAL_ENV_MAP = {
327
+ ["OPENAI_CRED" /* OPENAI_CRED */]: "OPENAI_API_KEY",
328
+ ["GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */]: "GOOGLE_API_KEY",
329
+ ["ANTHROPIC_CRED" /* ANTHROPIC_CRED */]: "ANTHROPIC_API_KEY",
330
+ ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */]: "FIRE_CRAWL_API_KEY",
331
+ ["DATABASE_CRED" /* DATABASE_CRED */]: "BUBBLE_CONNECTING_STRING_URL",
332
+ ["SLACK_CRED" /* SLACK_CRED */]: "SLACK_TOKEN",
333
+ ["TELEGRAM_BOT_TOKEN" /* TELEGRAM_BOT_TOKEN */]: "TELEGRAM_BOT_TOKEN",
334
+ ["RESEND_CRED" /* RESEND_CRED */]: "RESEND_API_KEY",
335
+ ["OPENROUTER_CRED" /* OPENROUTER_CRED */]: "OPENROUTER_API_KEY",
336
+ ["CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */]: "CLOUDFLARE_R2_ACCESS_KEY",
337
+ ["CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */]: "CLOUDFLARE_R2_SECRET_KEY",
338
+ ["CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */]: "CLOUDFLARE_R2_ACCOUNT_ID",
339
+ ["APIFY_CRED" /* APIFY_CRED */]: "APIFY_API_TOKEN",
340
+ ["ELEVENLABS_API_KEY" /* ELEVENLABS_API_KEY */]: "ELEVENLABS_API_KEY",
341
+ ["GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */]: "",
342
+ ["GMAIL_CRED" /* GMAIL_CRED */]: "",
343
+ ["GOOGLE_SHEETS_CRED" /* GOOGLE_SHEETS_CRED */]: "",
344
+ ["GOOGLE_CALENDAR_CRED" /* GOOGLE_CALENDAR_CRED */]: "",
345
+ ["FUB_CRED" /* FUB_CRED */]: "",
346
+ ["GITHUB_TOKEN" /* GITHUB_TOKEN */]: "GITHUB_TOKEN",
347
+ ["AGI_API_KEY" /* AGI_API_KEY */]: "AGI_API_KEY",
348
+ ["AIRTABLE_CRED" /* AIRTABLE_CRED */]: "AIRTABLE_API_KEY",
349
+ ["NOTION_OAUTH_TOKEN" /* NOTION_OAUTH_TOKEN */]: "",
350
+ ["INSFORGE_BASE_URL" /* INSFORGE_BASE_URL */]: "INSFORGE_BASE_URL",
351
+ ["INSFORGE_API_KEY" /* INSFORGE_API_KEY */]: "INSFORGE_API_KEY",
352
+ ["CUSTOM_AUTH_KEY" /* CUSTOM_AUTH_KEY */]: "",
353
+ // User-provided, no env var
354
+ ["AMAZON_CRED" /* AMAZON_CRED */]: ""
355
+ // Browser session credential, no env var
356
+ };
357
+ var SYSTEM_CREDENTIALS = /* @__PURE__ */ new Set([
358
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
359
+ "FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */,
360
+ "OPENAI_CRED" /* OPENAI_CRED */,
361
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
362
+ "RESEND_CRED" /* RESEND_CRED */,
363
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */,
364
+ // Cloudflare R2 Storage credentials
365
+ "CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */,
366
+ "CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */,
367
+ "CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */,
368
+ // Scraping credentials
369
+ "APIFY_CRED" /* APIFY_CRED */
370
+ ]);
371
+ var OPTIONAL_CREDENTIALS = /* @__PURE__ */ new Set([
372
+ "CUSTOM_AUTH_KEY" /* CUSTOM_AUTH_KEY */
373
+ ]);
374
+ var OAUTH_PROVIDERS = {
375
+ google: {
376
+ name: "google",
377
+ displayName: "Google",
378
+ credentialTypes: {
379
+ ["GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */]: {
380
+ displayName: "Google Drive",
381
+ defaultScopes: [
382
+ "https://www.googleapis.com/auth/drive.file",
383
+ "https://www.googleapis.com/auth/documents",
384
+ "https://www.googleapis.com/auth/spreadsheets",
385
+ "https://www.googleapis.com/auth/drive"
386
+ ],
387
+ description: "Access Google Drive files and folders",
388
+ scopeDescriptions: [
389
+ {
390
+ scope: "https://www.googleapis.com/auth/drive.file",
391
+ description: "View and manage Google Drive files and folders that you have created with Bubble Lab",
392
+ defaultEnabled: true
393
+ },
394
+ {
395
+ scope: "https://www.googleapis.com/auth/documents",
396
+ description: "View and manage your Google Docs documents",
397
+ defaultEnabled: true
398
+ },
399
+ {
400
+ scope: "https://www.googleapis.com/auth/spreadsheets",
401
+ description: "View and manage your Google Sheets spreadsheets",
402
+ defaultEnabled: true
403
+ },
404
+ {
405
+ scope: "https://www.googleapis.com/auth/drive",
406
+ description: 'View and manage all ofyour Google Drive files and folders (will see a warning about an "untrusted app" during authentication. Choose only if you need extra permissions)',
407
+ defaultEnabled: false
408
+ }
409
+ ]
410
+ },
411
+ ["GMAIL_CRED" /* GMAIL_CRED */]: {
412
+ displayName: "Gmail",
413
+ defaultScopes: [
414
+ "https://www.googleapis.com/auth/gmail.send",
415
+ "https://www.googleapis.com/auth/gmail.modify"
416
+ ],
417
+ description: "Access Gmail for sending emails",
418
+ scopeDescriptions: [
419
+ {
420
+ scope: "https://www.googleapis.com/auth/gmail.send",
421
+ description: "Send email on your behalf",
422
+ defaultEnabled: true
423
+ },
424
+ {
425
+ scope: "https://www.googleapis.com/auth/gmail.modify",
426
+ description: 'View and manage all of your Gmail emails and labels (might see a warning about an "untrusted app" during authentication. Choose only if you need extra permissions)',
427
+ defaultEnabled: false
428
+ }
429
+ ]
430
+ },
431
+ ["GOOGLE_SHEETS_CRED" /* GOOGLE_SHEETS_CRED */]: {
432
+ displayName: "Google Sheets",
433
+ defaultScopes: ["https://www.googleapis.com/auth/spreadsheets"],
434
+ description: "Access Google Sheets for reading and writing spreadsheet data",
435
+ scopeDescriptions: [
436
+ {
437
+ scope: "https://www.googleapis.com/auth/spreadsheets",
438
+ description: "View and manage your Google Sheets spreadsheets",
439
+ defaultEnabled: true
440
+ }
441
+ ]
442
+ },
443
+ ["GOOGLE_CALENDAR_CRED" /* GOOGLE_CALENDAR_CRED */]: {
444
+ displayName: "Google Calendar",
445
+ defaultScopes: ["https://www.googleapis.com/auth/calendar"],
446
+ description: "Access Google Calendar for reading and managing events",
447
+ scopeDescriptions: [
448
+ {
449
+ scope: "https://www.googleapis.com/auth/calendar",
450
+ description: "View and manage events on all your calendars",
451
+ defaultEnabled: true
452
+ }
453
+ ]
454
+ }
455
+ },
456
+ authorizationParams: {
457
+ access_type: "offline",
458
+ // Required for refresh tokens
459
+ prompt: "consent"
460
+ // Force consent screen to ensure refresh token is issued
461
+ }
462
+ },
463
+ followupboss: {
464
+ name: "followupboss",
465
+ displayName: "Follow Up Boss",
466
+ credentialTypes: {
467
+ ["FUB_CRED" /* FUB_CRED */]: {
468
+ displayName: "Follow Up Boss",
469
+ defaultScopes: [],
470
+ // FUB doesn't use granular scopes
471
+ description: "Access Follow Up Boss CRM for managing contacts, tasks, deals, and more"
472
+ }
473
+ },
474
+ authorizationParams: {
475
+ response_type: "auth_code",
476
+ // FUB uses 'auth_code' instead of standard 'code'
477
+ prompt: "login"
478
+ // FUB supports 'login' to force re-authentication
479
+ }
480
+ },
481
+ notion: {
482
+ name: "notion",
483
+ displayName: "Notion",
484
+ credentialTypes: {
485
+ ["NOTION_OAUTH_TOKEN" /* NOTION_OAUTH_TOKEN */]: {
486
+ displayName: "Notion Workspace",
487
+ defaultScopes: [],
488
+ // Notion scopes are managed in the integration capabilities
489
+ description: "Authorize access to your Notion workspace for searching and reading pages/databases"
490
+ }
491
+ }
492
+ }
493
+ };
494
+ function getOAuthProvider(credentialType) {
495
+ for (const [providerName, config] of Object.entries(OAUTH_PROVIDERS)) {
496
+ if (config.credentialTypes[credentialType]) {
497
+ return providerName;
498
+ }
499
+ }
500
+ return null;
501
+ }
502
+ function isOAuthCredential(credentialType) {
503
+ return getOAuthProvider(credentialType) !== null;
504
+ }
505
+ function getScopeDescriptions(credentialType) {
506
+ const provider = getOAuthProvider(credentialType);
507
+ if (!provider) {
508
+ return [];
509
+ }
510
+ const providerConfig = OAUTH_PROVIDERS[provider];
511
+ const credentialConfig = providerConfig?.credentialTypes[credentialType];
512
+ if (!credentialConfig?.scopeDescriptions) {
513
+ return credentialConfig?.defaultScopes.map((scope) => ({
514
+ scope,
515
+ description: `Access: ${scope}`,
516
+ defaultEnabled: true
517
+ // Default to enabled if in defaultScopes
518
+ })) || [];
519
+ }
520
+ return credentialConfig.scopeDescriptions;
521
+ }
522
+ var BROWSER_SESSION_PROVIDERS = {
523
+ browserbase: {
524
+ name: "browserbase",
525
+ displayName: "BrowserBase",
526
+ credentialTypes: {
527
+ ["AMAZON_CRED" /* AMAZON_CRED */]: {
528
+ displayName: "Amazon Account",
529
+ description: "Log into Amazon to enable cart, order, and purchase automation",
530
+ targetUrl: "https://www.amazon.com",
531
+ cookieDomain: "amazon"
532
+ }
533
+ }
534
+ }
535
+ };
536
+ function getBrowserSessionProvider(credentialType) {
537
+ for (const [providerName, config] of Object.entries(
538
+ BROWSER_SESSION_PROVIDERS
539
+ )) {
540
+ if (config.credentialTypes[credentialType]) {
541
+ return providerName;
542
+ }
543
+ }
544
+ return null;
545
+ }
546
+ function isBrowserSessionCredential(credentialType) {
547
+ return getBrowserSessionProvider(credentialType) !== null;
548
+ }
549
+ var BUBBLE_CREDENTIAL_OPTIONS = {
550
+ "ai-agent": [
551
+ "OPENAI_CRED" /* OPENAI_CRED */,
552
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
553
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
554
+ "FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */,
555
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */
556
+ ],
557
+ postgresql: ["DATABASE_CRED" /* DATABASE_CRED */],
558
+ slack: ["SLACK_CRED" /* SLACK_CRED */],
559
+ telegram: ["TELEGRAM_BOT_TOKEN" /* TELEGRAM_BOT_TOKEN */],
560
+ resend: ["RESEND_CRED" /* RESEND_CRED */],
561
+ "database-analyzer": ["DATABASE_CRED" /* DATABASE_CRED */],
562
+ "slack-notifier": [
563
+ "SLACK_CRED" /* SLACK_CRED */,
564
+ "OPENAI_CRED" /* OPENAI_CRED */,
565
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
566
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */
567
+ ],
568
+ "slack-formatter-agent": [
569
+ "OPENAI_CRED" /* OPENAI_CRED */,
570
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
571
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */
572
+ ],
573
+ "slack-data-assistant": [
574
+ "DATABASE_CRED" /* DATABASE_CRED */,
575
+ "SLACK_CRED" /* SLACK_CRED */,
576
+ "OPENAI_CRED" /* OPENAI_CRED */,
577
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
578
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */
579
+ ],
580
+ "hello-world": [],
581
+ http: ["CUSTOM_AUTH_KEY" /* CUSTOM_AUTH_KEY */],
582
+ "get-bubble-details-tool": [],
583
+ "list-bubbles-tool": [],
584
+ "sql-query-tool": ["DATABASE_CRED" /* DATABASE_CRED */],
585
+ "chart-js-tool": [],
586
+ "bubbleflow-validation-tool": [],
587
+ "code-edit-tool": ["OPENROUTER_CRED" /* OPENROUTER_CRED */],
588
+ "web-search-tool": ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */],
589
+ "web-scrape-tool": ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */],
590
+ "web-crawl-tool": [
591
+ "FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */,
592
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */
593
+ ],
594
+ "web-extract-tool": ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */],
595
+ "research-agent-tool": [
596
+ "FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */,
597
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
598
+ "APIFY_CRED" /* APIFY_CRED */
599
+ ],
600
+ "reddit-scrape-tool": [],
601
+ "bubbleflow-code-generator": [],
602
+ "bubbleflow-generator": [
603
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
604
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */
605
+ ],
606
+ "pdf-form-operations": [
607
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
608
+ "OPENAI_CRED" /* OPENAI_CRED */,
609
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
610
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */
611
+ ],
612
+ "pdf-ocr-workflow": [
613
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
614
+ "OPENAI_CRED" /* OPENAI_CRED */,
615
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
616
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */
617
+ ],
618
+ "generate-document-workflow": [
619
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
620
+ "OPENAI_CRED" /* OPENAI_CRED */,
621
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
622
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */
623
+ ],
624
+ "parse-document-workflow": [
625
+ "GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */,
626
+ "OPENAI_CRED" /* OPENAI_CRED */,
627
+ "ANTHROPIC_CRED" /* ANTHROPIC_CRED */,
628
+ "OPENROUTER_CRED" /* OPENROUTER_CRED */,
629
+ "CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */,
630
+ "CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */,
631
+ "CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */
632
+ ],
633
+ storage: [
634
+ "CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */,
635
+ "CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */,
636
+ "CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */
637
+ ],
638
+ "google-drive": ["GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */],
639
+ gmail: ["GMAIL_CRED" /* GMAIL_CRED */],
640
+ "google-sheets": ["GOOGLE_SHEETS_CRED" /* GOOGLE_SHEETS_CRED */],
641
+ "google-calendar": ["GOOGLE_CALENDAR_CRED" /* GOOGLE_CALENDAR_CRED */],
642
+ apify: ["APIFY_CRED" /* APIFY_CRED */],
643
+ "instagram-tool": ["APIFY_CRED" /* APIFY_CRED */],
644
+ "linkedin-tool": ["APIFY_CRED" /* APIFY_CRED */],
645
+ "tiktok-tool": ["APIFY_CRED" /* APIFY_CRED */],
646
+ "twitter-tool": ["APIFY_CRED" /* APIFY_CRED */],
647
+ "google-maps-tool": ["APIFY_CRED" /* APIFY_CRED */],
648
+ "youtube-tool": ["APIFY_CRED" /* APIFY_CRED */],
649
+ github: ["GITHUB_TOKEN" /* GITHUB_TOKEN */],
650
+ "eleven-labs": ["ELEVENLABS_API_KEY" /* ELEVENLABS_API_KEY */],
651
+ followupboss: ["FUB_CRED" /* FUB_CRED */],
652
+ "agi-inc": ["AGI_API_KEY" /* AGI_API_KEY */],
653
+ airtable: ["AIRTABLE_CRED" /* AIRTABLE_CRED */],
654
+ notion: ["NOTION_OAUTH_TOKEN" /* NOTION_OAUTH_TOKEN */],
655
+ firecrawl: ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */],
656
+ "insforge-db": [
657
+ "INSFORGE_BASE_URL" /* INSFORGE_BASE_URL */,
658
+ "INSFORGE_API_KEY" /* INSFORGE_API_KEY */
659
+ ],
660
+ browserbase: [
661
+ "AMAZON_CRED" /* AMAZON_CRED */,
662
+ "CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */,
663
+ "CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */,
664
+ "CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */
665
+ ],
666
+ "amazon-shopping-tool": [
667
+ "AMAZON_CRED" /* AMAZON_CRED */,
668
+ "CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */,
669
+ "CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */,
670
+ "CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */
671
+ ]
672
+ };
673
+ var createCredentialSchema = z3.object({
674
+ credentialType: z3.nativeEnum(CredentialType).openapi({
675
+ description: "Type of credential to store",
676
+ example: "OPENAI_CRED" /* OPENAI_CRED */
677
+ }),
678
+ value: z3.string().min(1).openapi({
679
+ description: "The credential value (will be encrypted)",
680
+ example: "sk-1234567890abcdef"
681
+ }),
682
+ name: z3.string().optional().openapi({
683
+ description: "Optional user-friendly name for the credential",
684
+ example: "My OpenAI Key"
685
+ }),
686
+ skipValidation: z3.boolean().optional().openapi({
687
+ description: "Skip credential validation before storing (for testing/admin use)",
688
+ example: false
689
+ }),
690
+ credentialConfigurations: z3.record(z3.string(), z3.unknown()).optional().openapi({
691
+ description: "Optional configurations for credential validation (e.g., ignoreSSL for PostgreSQL)",
692
+ example: { ignoreSSL: true }
693
+ }),
694
+ metadata: databaseMetadataSchema.optional().openapi({
695
+ description: "Optional metadata for the credential (e.g., database schema for DATABASE_CRED)",
696
+ example: {
697
+ tables: {
698
+ users: {
699
+ id: "integer",
700
+ email: "character varying",
701
+ created_at: "timestamp with time zone"
702
+ }
703
+ },
704
+ rules: [
705
+ {
706
+ id: "rule-1",
707
+ text: "No direct DELETE on users table",
708
+ enabled: true,
709
+ createdAt: "2024-01-01T00:00:00Z",
710
+ updatedAt: "2024-01-01T00:00:00Z"
711
+ }
712
+ ]
713
+ }
714
+ })
715
+ }).openapi("CreateCredentialRequest");
716
+ var updateCredentialSchema = z3.object({
717
+ value: z3.string().optional().openapi({
718
+ description: "The credential value (will be encrypted). Leave empty to keep current value.",
719
+ example: "sk-1234567890abcdef"
720
+ }),
721
+ name: z3.string().optional().openapi({
722
+ description: "Optional user-friendly name for the credential",
723
+ example: "My OpenAI Key"
724
+ }),
725
+ skipValidation: z3.boolean().optional().openapi({
726
+ description: "Skip credential validation before storing (for testing/admin use)",
727
+ example: false
728
+ }),
729
+ credentialConfigurations: z3.record(z3.string(), z3.unknown()).optional().openapi({
730
+ description: "Optional configurations for credential validation (e.g., ignoreSSL for PostgreSQL)",
731
+ example: { ignoreSSL: true }
732
+ }),
733
+ metadata: databaseMetadataSchema.optional().openapi({
734
+ description: "Optional metadata for the credential (e.g., database schema for DATABASE_CRED)",
735
+ example: {
736
+ tables: {
737
+ users: {
738
+ id: "integer",
739
+ email: "character varying",
740
+ created_at: "timestamp with time zone"
741
+ }
742
+ }
743
+ }
744
+ })
745
+ }).openapi("UpdateCredentialRequest");
746
+ var credentialResponseSchema = z3.object({
747
+ id: z3.number().openapi({ description: "Credential ID" }),
748
+ credentialType: z3.string().openapi({ description: "Type of credential" }),
749
+ name: z3.string().optional().openapi({ description: "Credential name" }),
750
+ metadata: databaseMetadataSchema.optional().openapi({ description: "Credential metadata" }),
751
+ createdAt: z3.string().openapi({ description: "Creation timestamp" }),
752
+ // OAuth-specific fields
753
+ isOauth: z3.boolean().optional().openapi({ description: "Whether this is an OAuth credential" }),
754
+ oauthProvider: z3.string().optional().openapi({ description: "OAuth provider name" }),
755
+ oauthExpiresAt: z3.string().optional().openapi({ description: "OAuth token expiration timestamp" }),
756
+ oauthScopes: z3.array(z3.string()).optional().openapi({ description: "OAuth scopes granted" }),
757
+ oauthStatus: z3.enum(["active", "expired", "needs_refresh"]).optional().openapi({ description: "OAuth token status" }),
758
+ // Browser session-specific fields
759
+ isBrowserSession: z3.boolean().optional().openapi({ description: "Whether this is a browser session credential" }),
760
+ browserbaseSessionData: z3.object({
761
+ capturedAt: z3.string(),
762
+ cookieCount: z3.number(),
763
+ domain: z3.string()
764
+ }).optional().openapi({ description: "Browser session metadata" })
765
+ }).openapi("CredentialResponse");
766
+ var createCredentialResponseSchema = z3.object({
767
+ id: z3.number().openapi({ description: "Credential ID" }),
768
+ message: z3.string().openapi({ description: "Success message" })
769
+ }).openapi("CreateCredentialResponse");
770
+ var updateCredentialResponseSchema = z3.object({
771
+ id: z3.number().openapi({ description: "Credential ID" }),
772
+ message: z3.string().openapi({ description: "Success message" })
773
+ }).openapi("UpdateCredentialResponse");
774
+ var successMessageResponseSchema = z3.object({
775
+ message: z3.string().openapi({ description: "Success message" })
776
+ }).openapi("SuccessMessageResponse");
777
+ var browserbaseSessionCreateRequestSchema = z3.object({
778
+ credentialType: z3.nativeEnum(CredentialType).openapi({
779
+ description: "Type of credential requiring browser authentication",
780
+ example: "AMAZON_CRED" /* AMAZON_CRED */
781
+ }),
782
+ name: z3.string().optional().openapi({
783
+ description: "User-friendly name for the credential",
784
+ example: "My Amazon Account"
785
+ })
786
+ }).openapi("BrowserbaseSessionCreateRequest");
787
+ var browserbaseSessionCreateResponseSchema = z3.object({
788
+ sessionId: z3.string().openapi({
789
+ description: "BrowserBase session ID"
790
+ }),
791
+ debugUrl: z3.string().openapi({
792
+ description: "URL to open for manual browser interaction"
793
+ }),
794
+ contextId: z3.string().openapi({
795
+ description: "BrowserBase context ID for session persistence"
796
+ }),
797
+ state: z3.string().openapi({
798
+ description: "State token for CSRF protection"
799
+ })
800
+ }).openapi("BrowserbaseSessionCreateResponse");
801
+ var browserbaseSessionCompleteRequestSchema = z3.object({
802
+ sessionId: z3.string().openapi({
803
+ description: "BrowserBase session ID to complete"
804
+ }),
805
+ state: z3.string().openapi({
806
+ description: "State token for verification"
807
+ }),
808
+ name: z3.string().optional().openapi({
809
+ description: "User-friendly name for the credential"
810
+ })
811
+ }).openapi("BrowserbaseSessionCompleteRequest");
812
+ var browserbaseSessionCompleteResponseSchema = z3.object({
813
+ id: z3.number().openapi({
814
+ description: "Created credential ID"
815
+ }),
816
+ message: z3.string().openapi({
817
+ description: "Success message"
818
+ })
819
+ }).openapi("BrowserbaseSessionCompleteResponse");
820
+ var browserbaseSessionReopenRequestSchema = z3.object({
821
+ credentialId: z3.number().openapi({
822
+ description: "ID of the credential to reopen session for"
823
+ })
824
+ }).openapi("BrowserbaseSessionReopenRequest");
825
+ var browserbaseSessionReopenResponseSchema = z3.object({
826
+ sessionId: z3.string().openapi({
827
+ description: "BrowserBase session ID"
828
+ }),
829
+ debugUrl: z3.string().openapi({
830
+ description: "URL to open for manual browser interaction"
831
+ })
832
+ }).openapi("BrowserbaseSessionReopenResponse");
833
+
834
+ // src/bubble-definition-schema.ts
835
+ import { z as z4 } from "zod";
836
+ var BubbleParameterType = /* @__PURE__ */ ((BubbleParameterType2) => {
837
+ BubbleParameterType2["STRING"] = "string";
838
+ BubbleParameterType2["NUMBER"] = "number";
839
+ BubbleParameterType2["BOOLEAN"] = "boolean";
840
+ BubbleParameterType2["OBJECT"] = "object";
841
+ BubbleParameterType2["ARRAY"] = "array";
842
+ BubbleParameterType2["ENV"] = "env";
843
+ BubbleParameterType2["VARIABLE"] = "variable";
844
+ BubbleParameterType2["EXPRESSION"] = "expression";
845
+ BubbleParameterType2["UNKNOWN"] = "unknown";
846
+ return BubbleParameterType2;
847
+ })(BubbleParameterType || {});
848
+ var CREDENTIAL_CONFIGURATION_MAP = {
849
+ ["DATABASE_CRED" /* DATABASE_CRED */]: {
850
+ ignoreSSL: "boolean" /* BOOLEAN */
851
+ },
852
+ ["TELEGRAM_BOT_TOKEN" /* TELEGRAM_BOT_TOKEN */]: {},
853
+ ["AGI_API_KEY" /* AGI_API_KEY */]: {},
854
+ ["FUB_CRED" /* FUB_CRED */]: {},
855
+ ["OPENAI_CRED" /* OPENAI_CRED */]: {},
856
+ ["GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */]: {},
857
+ ["ANTHROPIC_CRED" /* ANTHROPIC_CRED */]: {},
858
+ ["FIRECRAWL_API_KEY" /* FIRECRAWL_API_KEY */]: {},
859
+ ["SLACK_CRED" /* SLACK_CRED */]: {},
860
+ ["RESEND_CRED" /* RESEND_CRED */]: {},
861
+ ["OPENROUTER_CRED" /* OPENROUTER_CRED */]: {},
862
+ ["CLOUDFLARE_R2_ACCESS_KEY" /* CLOUDFLARE_R2_ACCESS_KEY */]: {},
863
+ ["CLOUDFLARE_R2_SECRET_KEY" /* CLOUDFLARE_R2_SECRET_KEY */]: {},
864
+ ["CLOUDFLARE_R2_ACCOUNT_ID" /* CLOUDFLARE_R2_ACCOUNT_ID */]: {},
865
+ ["APIFY_CRED" /* APIFY_CRED */]: {},
866
+ ["ELEVENLABS_API_KEY" /* ELEVENLABS_API_KEY */]: {},
867
+ ["GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */]: {},
868
+ ["GMAIL_CRED" /* GMAIL_CRED */]: {},
869
+ ["GOOGLE_SHEETS_CRED" /* GOOGLE_SHEETS_CRED */]: {},
870
+ ["GOOGLE_CALENDAR_CRED" /* GOOGLE_CALENDAR_CRED */]: {},
871
+ ["GITHUB_TOKEN" /* GITHUB_TOKEN */]: {},
872
+ ["AIRTABLE_CRED" /* AIRTABLE_CRED */]: {},
873
+ ["NOTION_OAUTH_TOKEN" /* NOTION_OAUTH_TOKEN */]: {},
874
+ ["INSFORGE_BASE_URL" /* INSFORGE_BASE_URL */]: {},
875
+ ["INSFORGE_API_KEY" /* INSFORGE_API_KEY */]: {},
876
+ ["CUSTOM_AUTH_KEY" /* CUSTOM_AUTH_KEY */]: {},
877
+ ["AMAZON_CRED" /* AMAZON_CRED */]: {}
878
+ };
879
+ var BUBBLE_NAMES_WITH_CONTEXT_INJECTION = [
880
+ "database-analyzer",
881
+ "slack-data-assistant"
882
+ ];
883
+ var BubbleParameterTypeSchema = z4.nativeEnum(BubbleParameterType);
884
+ var BubbleParameterSchema = z4.object({
885
+ location: z4.optional(
886
+ z4.object({
887
+ startLine: z4.number(),
888
+ startCol: z4.number(),
889
+ endLine: z4.number(),
890
+ endCol: z4.number()
891
+ })
892
+ ),
893
+ variableId: z4.number().optional().describe("The variable id of the parameter"),
894
+ name: z4.string().describe("The name of the parameter"),
895
+ value: z4.union([
896
+ z4.string(),
897
+ z4.number(),
898
+ z4.boolean(),
899
+ z4.record(z4.unknown()),
900
+ z4.array(z4.unknown())
901
+ ]).describe("The value of the parameter"),
902
+ type: BubbleParameterTypeSchema,
903
+ /**
904
+ * Source of the parameter - indicates whether it came from an object literal property
905
+ * or represents the entire first argument. Used to determine if spread pattern should be applied.
906
+ * Ex.
907
+ * const abc = '1234567890';
908
+ * new GoogleDriveBubble({
909
+ * fileId: abc,
910
+ * })
911
+ * source: 'object-property',
912
+ *
913
+ * new GoogleDriveBubble({
914
+ * url: 'https://www.google.com',
915
+ * ...args,
916
+ * })
917
+ * source: 'spread',
918
+ *
919
+ * source = 'first-arg'
920
+ * new GoogleDriveBubble(args)
921
+ */
922
+ source: z4.enum(["object-property", "first-arg", "spread"]).optional().describe(
923
+ "Source of the parameter - indicates if it came from an object literal property, represents the entire first argument, or came from a spread operator"
924
+ )
925
+ });
926
+ var BubbleNodeTypeSchema = z4.enum([
927
+ "service",
928
+ "tool",
929
+ "workflow",
930
+ "unknown"
931
+ ]);
932
+ var DependencyGraphNodeSchema = z4.lazy(
933
+ () => z4.object({
934
+ name: z4.string(),
935
+ variableName: z4.string().optional(),
936
+ nodeType: BubbleNodeTypeSchema,
937
+ uniqueId: z4.string().optional(),
938
+ variableId: z4.number().optional(),
939
+ dependencies: z4.array(DependencyGraphNodeSchema),
940
+ // Use lazy reference since FunctionCallWorkflowNodeSchema is defined later
941
+ functionCallChildren: z4.lazy(() => z4.array(FunctionCallWorkflowNodeSchema)).optional()
942
+ })
943
+ );
944
+ var ParsedBubbleSchema = z4.object({
945
+ variableName: z4.string(),
946
+ bubbleName: z4.string(),
947
+ className: z4.string(),
948
+ parameters: z4.array(BubbleParameterSchema),
949
+ hasAwait: z4.boolean(),
950
+ hasActionCall: z4.boolean(),
951
+ dependencies: z4.array(z4.string()).optional(),
952
+ dependencyGraph: DependencyGraphNodeSchema.optional()
953
+ });
954
+ var BubbleDependencySpecSchema = z4.object({
955
+ name: z4.string(),
956
+ tools: z4.array(z4.string()).optional()
957
+ });
958
+ var ParsedBubbleWithInfoSchema = z4.object({
959
+ variableName: z4.string(),
960
+ bubbleName: z4.string(),
961
+ className: z4.string(),
962
+ parameters: z4.array(BubbleParameterSchema),
963
+ hasAwait: z4.boolean(),
964
+ hasActionCall: z4.boolean(),
965
+ dependencies: z4.array(z4.string()).optional(),
966
+ dependencyGraph: DependencyGraphNodeSchema.optional(),
967
+ variableId: z4.number(),
968
+ nodeType: BubbleNodeTypeSchema,
969
+ location: z4.object({
970
+ startLine: z4.number(),
971
+ startCol: z4.number(),
972
+ endLine: z4.number(),
973
+ endCol: z4.number()
974
+ }),
975
+ description: z4.string().optional(),
976
+ invocationCallSiteKey: z4.string().optional(),
977
+ clonedFromVariableId: z4.number().optional(),
978
+ isInsideCustomTool: z4.boolean().optional(),
979
+ containingCustomToolId: z4.string().optional()
980
+ });
981
+ var WorkflowNodeTypeSchema = z4.enum([
982
+ "bubble",
983
+ "if",
984
+ "for",
985
+ "while",
986
+ "try_catch",
987
+ "variable_declaration",
988
+ "return",
989
+ "function_call",
990
+ "code_block",
991
+ "parallel_execution",
992
+ "transformation_function"
993
+ ]);
994
+ var LocationSchema = z4.object({
995
+ startLine: z4.number(),
996
+ startCol: z4.number(),
997
+ endLine: z4.number(),
998
+ endCol: z4.number()
999
+ });
1000
+ var BubbleWorkflowNodeSchema = z4.object(
1001
+ {
1002
+ type: z4.literal("bubble"),
1003
+ variableId: z4.number()
1004
+ }
1005
+ );
1006
+ var ControlFlowWorkflowNodeSchema = z4.lazy(
1007
+ () => z4.object({
1008
+ type: z4.enum(["if", "for", "while"]),
1009
+ location: LocationSchema,
1010
+ condition: z4.string().optional(),
1011
+ children: z4.array(WorkflowNodeSchema),
1012
+ elseBranch: z4.array(WorkflowNodeSchema).optional(),
1013
+ thenTerminates: z4.boolean().optional(),
1014
+ elseTerminates: z4.boolean().optional()
1015
+ })
1016
+ );
1017
+ var TryCatchWorkflowNodeSchema = z4.lazy(
1018
+ () => z4.object({
1019
+ type: z4.literal("try_catch"),
1020
+ location: LocationSchema,
1021
+ children: z4.array(WorkflowNodeSchema),
1022
+ catchBlock: z4.array(WorkflowNodeSchema).optional()
1023
+ })
1024
+ );
1025
+ var CodeBlockWorkflowNodeSchema = z4.lazy(
1026
+ () => z4.object({
1027
+ type: z4.literal("code_block"),
1028
+ location: LocationSchema,
1029
+ code: z4.string(),
1030
+ children: z4.array(WorkflowNodeSchema)
1031
+ })
1032
+ );
1033
+ var VariableDeclarationBlockNodeSchema = z4.lazy(
1034
+ () => z4.object({
1035
+ type: z4.literal("variable_declaration"),
1036
+ location: LocationSchema,
1037
+ code: z4.string(),
1038
+ variables: z4.array(
1039
+ z4.object({
1040
+ name: z4.string(),
1041
+ type: z4.enum(["const", "let", "var"]),
1042
+ hasInitializer: z4.boolean()
1043
+ })
1044
+ ),
1045
+ children: z4.array(WorkflowNodeSchema)
1046
+ })
1047
+ );
1048
+ var ReturnWorkflowNodeSchema = z4.lazy(
1049
+ () => z4.object({
1050
+ type: z4.literal("return"),
1051
+ location: LocationSchema,
1052
+ code: z4.string(),
1053
+ value: z4.string().optional(),
1054
+ children: z4.array(WorkflowNodeSchema)
1055
+ })
1056
+ );
1057
+ var FunctionCallWorkflowNodeSchema = z4.lazy(
1058
+ () => z4.object({
1059
+ type: z4.literal("function_call"),
1060
+ location: LocationSchema,
1061
+ functionName: z4.string(),
1062
+ isMethodCall: z4.boolean(),
1063
+ description: z4.string().optional(),
1064
+ arguments: z4.string().optional(),
1065
+ code: z4.string(),
1066
+ variableId: z4.number(),
1067
+ variableDeclaration: z4.object({
1068
+ variableName: z4.string(),
1069
+ variableType: z4.enum(["const", "let", "var"])
1070
+ }).optional(),
1071
+ methodDefinition: z4.object({
1072
+ location: z4.object({
1073
+ startLine: z4.number(),
1074
+ endLine: z4.number()
1075
+ }),
1076
+ isAsync: z4.boolean(),
1077
+ parameters: z4.array(z4.string())
1078
+ }).optional(),
1079
+ children: z4.array(WorkflowNodeSchema)
1080
+ })
1081
+ );
1082
+ var ParallelExecutionWorkflowNodeSchema = z4.lazy(
1083
+ () => z4.object({
1084
+ type: z4.literal("parallel_execution"),
1085
+ location: LocationSchema,
1086
+ code: z4.string(),
1087
+ variableDeclaration: z4.object({
1088
+ variableNames: z4.array(z4.string()),
1089
+ variableType: z4.enum(["const", "let", "var"])
1090
+ }).optional(),
1091
+ children: z4.array(WorkflowNodeSchema)
1092
+ })
1093
+ );
1094
+ var TransformationFunctionWorkflowNodeSchema = z4.object({
1095
+ type: z4.literal("transformation_function"),
1096
+ location: LocationSchema,
1097
+ code: z4.string(),
1098
+ functionName: z4.string(),
1099
+ isMethodCall: z4.boolean(),
1100
+ description: z4.string().optional(),
1101
+ arguments: z4.string().optional(),
1102
+ variableId: z4.number(),
1103
+ variableDeclaration: z4.object({
1104
+ variableName: z4.string(),
1105
+ variableType: z4.enum(["const", "let", "var"])
1106
+ }).optional(),
1107
+ methodDefinition: z4.object({
1108
+ location: z4.object({
1109
+ startLine: z4.number(),
1110
+ endLine: z4.number()
1111
+ }),
1112
+ isAsync: z4.boolean(),
1113
+ parameters: z4.array(z4.string())
1114
+ }).optional()
1115
+ });
1116
+ var WorkflowNodeSchema = z4.lazy(
1117
+ () => z4.union([
1118
+ BubbleWorkflowNodeSchema,
1119
+ ControlFlowWorkflowNodeSchema,
1120
+ TryCatchWorkflowNodeSchema,
1121
+ CodeBlockWorkflowNodeSchema,
1122
+ VariableDeclarationBlockNodeSchema,
1123
+ ReturnWorkflowNodeSchema,
1124
+ FunctionCallWorkflowNodeSchema,
1125
+ ParallelExecutionWorkflowNodeSchema,
1126
+ TransformationFunctionWorkflowNodeSchema
1127
+ ])
1128
+ );
1129
+ var ParsedWorkflowSchema = z4.object({
1130
+ root: z4.array(WorkflowNodeSchema),
1131
+ bubbles: z4.record(z4.number(), ParsedBubbleWithInfoSchema)
1132
+ });
1133
+
1134
+ // src/mock-data-generator.ts
1135
+ function generateUUID() {
1136
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
1137
+ return crypto.randomUUID();
1138
+ }
1139
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1140
+ const r = Math.random() * 16 | 0;
1141
+ const v = c === "x" ? r : r & 3 | 8;
1142
+ return v.toString(16);
1143
+ });
1144
+ }
1145
+ var MockDataGenerator = class {
1146
+ /**
1147
+ * Generate a complete mock BubbleResult from a result schema
1148
+ */
1149
+ static generateMockResult(resultSchema) {
1150
+ const mockData = this.generateMockFromSchema(resultSchema);
1151
+ return {
1152
+ success: true,
1153
+ data: mockData,
1154
+ executionId: generateUUID(),
1155
+ error: "",
1156
+ timestamp: /* @__PURE__ */ new Date()
1157
+ };
1158
+ }
1159
+ /**
1160
+ * Generate mock data from JSON Schema
1161
+ * Converts JSON Schema to mock data with realistic values
1162
+ */
1163
+ static generateMockFromJsonSchema(jsonSchema) {
1164
+ const mockData = {};
1165
+ if (!jsonSchema || typeof jsonSchema !== "object") {
1166
+ return mockData;
1167
+ }
1168
+ if (jsonSchema.type === "object" && jsonSchema.properties) {
1169
+ const properties = jsonSchema.properties;
1170
+ for (const [key, propertySchema] of Object.entries(properties)) {
1171
+ if (propertySchema && typeof propertySchema === "object") {
1172
+ const value = this.generateMockValueFromJsonSchema(
1173
+ propertySchema
1174
+ );
1175
+ if (value !== void 0) {
1176
+ mockData[key] = value;
1177
+ }
1178
+ }
1179
+ }
1180
+ }
1181
+ return mockData;
1182
+ }
1183
+ /**
1184
+ * Generate a mock value for a specific JSON Schema property
1185
+ */
1186
+ static generateMockValueFromJsonSchema(schema) {
1187
+ const type = schema.type;
1188
+ switch (type) {
1189
+ case "string": {
1190
+ if (schema.enum && Array.isArray(schema.enum)) {
1191
+ return schema.enum[Math.floor(Math.random() * schema.enum.length)];
1192
+ }
1193
+ if (schema.format === "email") {
1194
+ return "test@example.com";
1195
+ }
1196
+ if (schema.format === "date-time") {
1197
+ return (/* @__PURE__ */ new Date()).toISOString();
1198
+ }
1199
+ if (schema.format === "uuid") {
1200
+ return generateUUID();
1201
+ }
1202
+ const minLength = typeof schema.minLength === "number" ? schema.minLength : 1;
1203
+ const maxLength = typeof schema.maxLength === "number" ? schema.maxLength : 10;
1204
+ const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength;
1205
+ return "sample_" + Math.random().toString(36).substring(2, 2 + length);
1206
+ }
1207
+ case "number":
1208
+ case "integer": {
1209
+ const min = typeof schema.minimum === "number" ? schema.minimum : 0;
1210
+ const max = typeof schema.maximum === "number" ? schema.maximum : 100;
1211
+ const value = Math.random() * (max - min) + min;
1212
+ return type === "integer" ? Math.floor(value) : Math.round(value * 100) / 100;
1213
+ }
1214
+ case "boolean": {
1215
+ return Math.random() > 0.5;
1216
+ }
1217
+ case "array": {
1218
+ const items = schema.items;
1219
+ if (items) {
1220
+ const minItems = typeof schema.minItems === "number" ? schema.minItems : 1;
1221
+ const maxItems = typeof schema.maxItems === "number" ? schema.maxItems : 3;
1222
+ const length = Math.floor(Math.random() * (maxItems - minItems + 1)) + minItems;
1223
+ return Array.from(
1224
+ { length },
1225
+ () => this.generateMockValueFromJsonSchema(items)
1226
+ );
1227
+ }
1228
+ return [];
1229
+ }
1230
+ case "object": {
1231
+ return this.generateMockFromJsonSchema(schema);
1232
+ }
1233
+ default: {
1234
+ return null;
1235
+ }
1236
+ }
1237
+ }
1238
+ /**
1239
+ * Generate mock data object from a Zod schema
1240
+ * Recursively handles nested objects, arrays, and primitive types
1241
+ */
1242
+ static generateMockFromSchema(schema) {
1243
+ const mockData = {};
1244
+ if (!schema || typeof schema !== "object" || !("shape" in schema)) {
1245
+ return mockData;
1246
+ }
1247
+ const shape = schema.shape;
1248
+ for (const [key, zodType] of Object.entries(shape)) {
1249
+ if (key === "success" || key === "error") {
1250
+ continue;
1251
+ }
1252
+ if (zodType && typeof zodType === "object" && "_def" in zodType) {
1253
+ const value = this.generateMockValue(zodType);
1254
+ if (value !== void 0) {
1255
+ mockData[key] = value;
1256
+ }
1257
+ }
1258
+ }
1259
+ return mockData;
1260
+ }
1261
+ /**
1262
+ * Generate a mock value for a specific Zod type
1263
+ */
1264
+ static generateMockValue(zodType) {
1265
+ const def = zodType._def;
1266
+ switch (def.typeName) {
1267
+ case "ZodString": {
1268
+ return this.generateMockString(def);
1269
+ }
1270
+ case "ZodNumber": {
1271
+ return this.generateMockNumber(def);
1272
+ }
1273
+ case "ZodBoolean": {
1274
+ return Math.random() > 0.5;
1275
+ }
1276
+ case "ZodDate": {
1277
+ return /* @__PURE__ */ new Date();
1278
+ }
1279
+ case "ZodArray": {
1280
+ const elementType = def.type;
1281
+ if (elementType) {
1282
+ const arrayLength = Math.floor(Math.random() * 3) + 1;
1283
+ return Array.from(
1284
+ { length: arrayLength },
1285
+ () => this.generateMockValue(elementType)
1286
+ );
1287
+ }
1288
+ return [];
1289
+ }
1290
+ case "ZodObject": {
1291
+ if ("shape" in zodType) {
1292
+ const nestedMock = {};
1293
+ const shape = zodType.shape;
1294
+ for (const [key, value] of Object.entries(shape)) {
1295
+ if (value && typeof value === "object" && "_def" in value) {
1296
+ const nestedValue = this.generateMockValue(value);
1297
+ if (nestedValue !== void 0) {
1298
+ nestedMock[key] = nestedValue;
1299
+ }
1300
+ }
1301
+ }
1302
+ return nestedMock;
1303
+ }
1304
+ return {};
1305
+ }
1306
+ case "ZodOptional": {
1307
+ if (Math.random() > 0.3) {
1308
+ return this.generateMockValue(def.innerType);
1309
+ }
1310
+ return void 0;
1311
+ }
1312
+ case "ZodDefault": {
1313
+ if (Math.random() > 0.5) {
1314
+ return def.defaultValue();
1315
+ }
1316
+ return this.generateMockValue(def.innerType);
1317
+ }
1318
+ case "ZodEnum": {
1319
+ const values = def.values;
1320
+ return values[Math.floor(Math.random() * values.length)];
1321
+ }
1322
+ case "ZodLiteral": {
1323
+ return def.value;
1324
+ }
1325
+ case "ZodUnion": {
1326
+ const options = def.options;
1327
+ const randomOption = options[Math.floor(Math.random() * options.length)];
1328
+ return this.generateMockValue(randomOption);
1329
+ }
1330
+ case "ZodDiscriminatedUnion": {
1331
+ const discriminatedOptions = def.options;
1332
+ const randomDiscriminatedOption = discriminatedOptions[Math.floor(Math.random() * discriminatedOptions.length)];
1333
+ return this.generateMockValue(randomDiscriminatedOption);
1334
+ }
1335
+ case "ZodRecord": {
1336
+ const recordMock = {};
1337
+ const numKeys = Math.floor(Math.random() * 3) + 1;
1338
+ for (let i = 0; i < numKeys; i++) {
1339
+ const key = `key${i + 1}`;
1340
+ const value = this.generateMockValue(def.valueType);
1341
+ if (value !== void 0) {
1342
+ recordMock[key] = value;
1343
+ }
1344
+ }
1345
+ return recordMock;
1346
+ }
1347
+ case "ZodNullable": {
1348
+ if (Math.random() > 0.2) {
1349
+ return this.generateMockValue(def.innerType);
1350
+ }
1351
+ return null;
1352
+ }
1353
+ default: {
1354
+ console.warn(`Unknown Zod type for mock generation: ${def.typeName}`);
1355
+ return `mock_${def.typeName}`;
1356
+ }
1357
+ }
1358
+ }
1359
+ /**
1360
+ * Generate mock string values with format-specific handling
1361
+ */
1362
+ static generateMockString(def) {
1363
+ if (def.checks) {
1364
+ for (const check of def.checks) {
1365
+ switch (check.kind) {
1366
+ case "email": {
1367
+ return "test@example.com";
1368
+ }
1369
+ case "url": {
1370
+ return "https://example.com";
1371
+ }
1372
+ case "uuid": {
1373
+ return generateUUID();
1374
+ }
1375
+ case "regex": {
1376
+ const pattern = check.regex;
1377
+ if (pattern.source.includes("\\d+")) {
1378
+ return "12345";
1379
+ }
1380
+ if (pattern.source.includes("[a-z]")) {
1381
+ return "abcde";
1382
+ }
1383
+ return "mock_regex_match";
1384
+ }
1385
+ case "min": {
1386
+ return "a".repeat(check.value);
1387
+ }
1388
+ case "max": {
1389
+ return "mock".substring(0, check.value);
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ return "mock string";
1395
+ }
1396
+ /**
1397
+ * Generate mock number values respecting constraints
1398
+ */
1399
+ static generateMockNumber(def) {
1400
+ let min = 0;
1401
+ let max = 100;
1402
+ let isInt = false;
1403
+ if (def.checks) {
1404
+ for (const check of def.checks) {
1405
+ switch (check.kind) {
1406
+ case "min": {
1407
+ min = check.value;
1408
+ break;
1409
+ }
1410
+ case "max": {
1411
+ max = check.value;
1412
+ break;
1413
+ }
1414
+ case "int": {
1415
+ isInt = true;
1416
+ break;
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ const value = Math.random() * (max - min) + min;
1422
+ return isInt ? Math.floor(value) : Math.round(value * 100) / 100;
1423
+ }
1424
+ /**
1425
+ * Generate mock data with custom seed for reproducible results
1426
+ */
1427
+ static generateMockWithSeed(resultSchema, seed) {
1428
+ let currentSeed = seed;
1429
+ const seededRandom = () => {
1430
+ currentSeed = (currentSeed * 9301 + 49297) % 233280;
1431
+ return currentSeed / 233280;
1432
+ };
1433
+ const originalRandom = Math.random;
1434
+ Math.random = seededRandom;
1435
+ try {
1436
+ const mockData = this.generateMockFromSchema(resultSchema);
1437
+ const executionId = generateUUID();
1438
+ return {
1439
+ success: true,
1440
+ data: mockData,
1441
+ executionId,
1442
+ error: "",
1443
+ timestamp: /* @__PURE__ */ new Date()
1444
+ };
1445
+ } finally {
1446
+ Math.random = originalRandom;
1447
+ }
1448
+ }
1449
+ };
1450
+
1451
+ // src/oauth-schema.ts
1452
+ import { z as z5 } from "@hono/zod-openapi";
1453
+ var oauthInitiateRequestSchema = z5.object({
1454
+ credentialType: z5.nativeEnum(CredentialType).openapi({
1455
+ description: "The type of credential to create",
1456
+ example: "GOOGLE_DRIVE_CRED" /* GOOGLE_DRIVE_CRED */
1457
+ }),
1458
+ name: z5.string().optional().openapi({
1459
+ description: "Optional name for the credential",
1460
+ example: "My Google Drive"
1461
+ }),
1462
+ scopes: z5.array(z5.string()).optional().openapi({
1463
+ description: "Optional OAuth scopes to request (defaults based on credential type)",
1464
+ example: ["https://www.googleapis.com/auth/drive.readonly"]
1465
+ })
1466
+ }).openapi("OAuthInitiateRequest");
1467
+ var oauthInitiateResponseSchema = z5.object({
1468
+ authUrl: z5.string().url().openapi({
1469
+ description: "OAuth authorization URL to redirect user to",
1470
+ example: "https://accounts.google.com/oauth2/auth?client_id=..."
1471
+ }),
1472
+ state: z5.string().openapi({
1473
+ description: "CSRF protection state parameter",
1474
+ example: "abc123-def456-ghi789"
1475
+ })
1476
+ }).openapi("OAuthInitiateResponse");
1477
+ var oauthCallbackRequestSchema = z5.object({
1478
+ code: z5.string().openapi({
1479
+ description: "OAuth authorization code from provider",
1480
+ example: "abc123def456"
1481
+ }),
1482
+ state: z5.string().openapi({
1483
+ description: "CSRF protection state parameter",
1484
+ example: "abc123-def456-ghi789"
1485
+ }),
1486
+ name: z5.string().openapi({
1487
+ description: "Name for the credential",
1488
+ example: "My Google Drive"
1489
+ }),
1490
+ description: z5.string().optional().openapi({
1491
+ description: "Optional description for the credential"
1492
+ })
1493
+ }).openapi("OAuthCallbackRequest");
1494
+ var oauthTokenRefreshResponseSchema = z5.object({
1495
+ message: z5.string().openapi({
1496
+ description: "Success message",
1497
+ example: "Token refreshed successfully"
1498
+ })
1499
+ }).openapi("OAuthTokenRefreshResponse");
1500
+ var oauthRevokeResponseSchema = z5.object({
1501
+ message: z5.string().openapi({
1502
+ description: "Success message",
1503
+ example: "Credential revoked successfully"
1504
+ })
1505
+ }).openapi("OAuthRevokeResponse");
1506
+
1507
+ // src/waitlist-schema.ts
1508
+ import { z as z6 } from "@hono/zod-openapi";
1509
+ var joinWaitlistSchema = z6.object({
1510
+ name: z6.string().min(1, "Name is required").openapi({
1511
+ description: "Full name of the user",
1512
+ example: "John Doe"
1513
+ }),
1514
+ email: z6.string().email("Valid email is required").openapi({
1515
+ description: "Email address of the user",
1516
+ example: "john.doe@example.com"
1517
+ }),
1518
+ database: z6.string().min(1, "Database selection is required").openapi({
1519
+ description: "Database type the user wants to use",
1520
+ example: "postgres"
1521
+ }),
1522
+ otherDatabase: z6.string().optional().openapi({
1523
+ description: 'Other database type if "other" was selected',
1524
+ example: "Redis"
1525
+ })
1526
+ }).openapi("JoinWaitlistRequest");
1527
+ var joinWaitlistResponseSchema = z6.object({
1528
+ success: z6.boolean().openapi({
1529
+ description: "Whether the request was successful",
1530
+ example: true
1531
+ }),
1532
+ message: z6.string().openapi({
1533
+ description: "Success message",
1534
+ example: "Successfully joined the waitlist! Check your email for next steps."
1535
+ })
1536
+ }).openapi("JoinWaitlistResponse");
1537
+
1538
+ // src/bubbleflow-schema.ts
1539
+ import { z as z7 } from "@hono/zod-openapi";
1540
+ var createBubbleFlowSchema = z7.object({
1541
+ name: z7.string().min(1).max(100).openapi({
1542
+ description: "Name of the BubbleFlow",
1543
+ example: "My First BubbleFlow"
1544
+ }),
1545
+ description: z7.string().optional().openapi({
1546
+ description: "Optional description of what this BubbleFlow does",
1547
+ example: "A flow that processes webhook data"
1548
+ }),
1549
+ prompt: z7.string().optional().openapi({
1550
+ description: "Optional prompt used to generate the flow",
1551
+ example: "Create a flow that processes webhook data and sends notifications"
1552
+ }),
1553
+ code: z7.string().min(1).openapi({
1554
+ description: "TypeScript code that defines the BubbleFlow class",
1555
+ example: "export class MyFlow extends BubbleFlow { ... }"
1556
+ }),
1557
+ eventType: z7.string().min(1).openapi({
1558
+ description: "Event type this BubbleFlow responds to",
1559
+ example: "webhook/http"
1560
+ }),
1561
+ webhookPath: z7.string().min(1).max(50).regex(/^[a-zA-Z0-9-_]+$/).optional().openapi({
1562
+ description: "Custom webhook path (auto-generated if not provided)",
1563
+ example: "my-webhook"
1564
+ }),
1565
+ webhookActive: z7.boolean().default(false).optional().openapi({
1566
+ description: "Whether the webhook should be active immediately",
1567
+ example: true
1568
+ }),
1569
+ bubbleParameters: z7.record(z7.string(), ParsedBubbleWithInfoSchema).optional().openapi({
1570
+ description: "Optional pre-parsed bubble parameters with descriptions (from AI generation). If provided, will be used instead of re-parsing the code."
1571
+ })
1572
+ }).openapi("CreateBubbleFlowRequest");
1573
+ var createEmptyBubbleFlowSchema = z7.object({
1574
+ name: z7.string().min(1).max(100).openapi({
1575
+ description: "Name of the BubbleFlow",
1576
+ example: "My First BubbleFlow"
1577
+ }),
1578
+ description: z7.string().optional().openapi({
1579
+ description: "Optional description of what this BubbleFlow does",
1580
+ example: "A flow that processes webhook data"
1581
+ }),
1582
+ prompt: z7.string().openapi({
1583
+ description: "Prompt used to generate the flow code asynchronously",
1584
+ example: "Create a flow that processes webhook data and sends notifications"
1585
+ }),
1586
+ eventType: z7.string().min(1).openapi({
1587
+ description: "Event type this BubbleFlow responds to",
1588
+ example: "webhook/http"
1589
+ }),
1590
+ webhookPath: z7.string().min(1).max(50).regex(/^[a-zA-Z0-9-_]+$/).optional().openapi({
1591
+ description: "Custom webhook path (auto-generated if not provided)",
1592
+ example: "my-webhook"
1593
+ }),
1594
+ webhookActive: z7.boolean().default(false).optional().openapi({
1595
+ description: "Whether the webhook should be active immediately",
1596
+ example: true
1597
+ })
1598
+ }).openapi("CreateEmptyBubbleFlowRequest");
1599
+ var executeBubbleFlowSchema = z7.record(z7.string(), z7.unknown()).openapi("ExecuteBubbleFlowRequest");
1600
+ var updateBubbleFlowParametersSchema = z7.object({
1601
+ bubbleParameters: z7.record(
1602
+ z7.string(),
1603
+ z7.union([ParsedBubbleWithInfoSchema, ParsedBubbleSchema])
1604
+ )
1605
+ }).openapi("UpdateBubbleFlowParametersRequest");
1606
+ var updateBubbleFlowNameSchema = z7.object({
1607
+ name: z7.string().min(1).max(100).openapi({
1608
+ description: "New name for the BubbleFlow",
1609
+ example: "My Updated Flow"
1610
+ })
1611
+ }).openapi("UpdateBubbleFlowNameRequest");
1612
+ var createBubbleFlowResponseSchema = z7.object({
1613
+ id: z7.number().openapi({
1614
+ description: "ID of the created BubbleFlow",
1615
+ example: 123
1616
+ }),
1617
+ message: z7.string().openapi({
1618
+ description: "Success message",
1619
+ example: "BubbleFlow created successfully"
1620
+ }),
1621
+ inputSchema: z7.record(z7.string(), z7.unknown()).optional().openapi({
1622
+ description: "Input schema",
1623
+ example: {
1624
+ name: "string",
1625
+ age: "number"
1626
+ }
1627
+ }),
1628
+ bubbleParameters: z7.record(z7.string(), ParsedBubbleWithInfoSchema).openapi({
1629
+ description: "Parsed bubble parameters from the BubbleFlow code"
1630
+ }),
1631
+ workflow: ParsedWorkflowSchema.optional().openapi({
1632
+ description: "Hierarchical workflow structure with control flow"
1633
+ }),
1634
+ requiredCredentials: z7.record(z7.string(), z7.array(z7.nativeEnum(CredentialType))).optional().openapi({
1635
+ description: "Mapping of bubble names to their required credential types",
1636
+ example: {
1637
+ "database-connection": ["DATABASE_CRED" /* DATABASE_CRED */],
1638
+ "slack-notification": ["SLACK_CRED" /* SLACK_CRED */],
1639
+ "ai-analysis": ["GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */]
1640
+ }
1641
+ }),
1642
+ eventType: z7.string().min(1).openapi({
1643
+ description: "Event type this BubbleFlow responds to",
1644
+ example: "webhook/http"
1645
+ }),
1646
+ webhook: z7.object({
1647
+ id: z7.number().openapi({ description: "Webhook ID", example: 456 }),
1648
+ url: z7.string().openapi({
1649
+ description: "Full webhook URL",
1650
+ example: "http://localhost:3001/webhook/user123/my-webhook"
1651
+ }),
1652
+ path: z7.string().openapi({
1653
+ description: "Webhook path",
1654
+ example: "my-webhook"
1655
+ }),
1656
+ active: z7.boolean().openapi({
1657
+ description: "Whether webhook is active",
1658
+ example: true
1659
+ })
1660
+ }).optional().openapi({
1661
+ description: "Webhook information (if webhook was created)"
1662
+ })
1663
+ }).openapi("CreateBubbleFlowResponse");
1664
+ var createEmptyBubbleFlowResponseSchema = z7.object({
1665
+ id: z7.number().openapi({
1666
+ description: "ID of the created BubbleFlow (code will be generated asynchronously)",
1667
+ example: 123
1668
+ }),
1669
+ message: z7.string().openapi({
1670
+ description: "Success message",
1671
+ example: "BubbleFlow created successfully. Code generation in progress..."
1672
+ }),
1673
+ webhook: z7.object({
1674
+ id: z7.number().openapi({ description: "Webhook ID", example: 456 }),
1675
+ url: z7.string().openapi({
1676
+ description: "Full webhook URL",
1677
+ example: "http://localhost:3001/webhook/user123/my-webhook"
1678
+ }),
1679
+ path: z7.string().openapi({
1680
+ description: "Webhook path",
1681
+ example: "my-webhook"
1682
+ }),
1683
+ active: z7.boolean().openapi({
1684
+ description: "Whether webhook is active",
1685
+ example: false
1686
+ })
1687
+ }).optional().openapi({
1688
+ description: "Webhook information (if webhook was created)"
1689
+ })
1690
+ }).openapi("CreateEmptyBubbleFlowResponse");
1691
+ var bubbleFlowDetailsResponseSchema = z7.object({
1692
+ id: z7.number().openapi({ description: "BubbleFlow ID" }),
1693
+ name: z7.string().openapi({ description: "BubbleFlow name" }),
1694
+ description: z7.string().optional().openapi({ description: "Description" }),
1695
+ prompt: z7.string().optional().openapi({ description: "Original prompt used to generate the flow" }),
1696
+ eventType: z7.string().openapi({ description: "Event type" }),
1697
+ code: z7.string().openapi({ description: "TypeScript source code" }),
1698
+ generationError: z7.string().nullable().optional().openapi({ description: "Error message if code generation failed" }),
1699
+ inputSchema: z7.record(z7.string(), z7.unknown()).optional().openapi({ description: "Input schema" }),
1700
+ cron: z7.string().nullable().optional().openapi({ description: "Cron expression" }),
1701
+ cronActive: z7.boolean().optional().openapi({ description: "Whether cron scheduling is active" }),
1702
+ defaultInputs: z7.record(z7.string(), z7.unknown()).optional().openapi({ description: "Default inputs for cron scheduling" }),
1703
+ isActive: z7.boolean().openapi({ description: "Whether the BubbleFlow is active" }),
1704
+ requiredCredentials: z7.record(z7.string(), z7.array(z7.nativeEnum(CredentialType))).openapi({ description: "Required credentials by bubble" }),
1705
+ displayedBubbleParameters: z7.record(
1706
+ z7.string(),
1707
+ z7.object({
1708
+ variableName: z7.string(),
1709
+ bubbleName: z7.string(),
1710
+ className: z7.string(),
1711
+ parameters: z7.array(
1712
+ z7.object({
1713
+ name: z7.string(),
1714
+ value: z7.unknown(),
1715
+ type: z7.nativeEnum(BubbleParameterType)
1716
+ })
1717
+ ),
1718
+ hasAwait: z7.boolean(),
1719
+ hasActionCall: z7.boolean()
1720
+ })
1721
+ ).optional().openapi({
1722
+ description: "Displayed bubble parameters for visualization"
1723
+ }),
1724
+ bubbleParameters: z7.record(z7.string(), ParsedBubbleWithInfoSchema).openapi({
1725
+ description: "Bubble parameters"
1726
+ }),
1727
+ workflow: ParsedWorkflowSchema.optional().openapi({
1728
+ description: "Hierarchical workflow structure with control flow"
1729
+ }),
1730
+ metadata: z7.record(z7.string(), z7.unknown()).optional().openapi({
1731
+ description: "Flow metadata including conversation messages from generation"
1732
+ }),
1733
+ createdAt: z7.string().openapi({ description: "Creation timestamp" }),
1734
+ updatedAt: z7.string().openapi({ description: "Update timestamp" }),
1735
+ webhook_url: z7.string().openapi({ description: "Webhook URL for this bubble flow" })
1736
+ }).openapi("BubbleFlowDetailsResponse");
1737
+ var bubbleFlowListItemSchema = z7.object({
1738
+ id: z7.number().openapi({ description: "BubbleFlow ID" }),
1739
+ name: z7.string().openapi({ description: "BubbleFlow name" }),
1740
+ description: z7.string().optional().openapi({ description: "Description" }),
1741
+ eventType: z7.string().openapi({ description: "Event type" }),
1742
+ isActive: z7.boolean().openapi({ description: "Whether the BubbleFlow is active" }),
1743
+ cronActive: z7.boolean().openapi({ description: "Whether cron scheduling is active" }),
1744
+ cronSchedule: z7.string().optional().openapi({ description: "Cron schedule" }),
1745
+ webhookExecutionCount: z7.number().openapi({ description: "Webhook execution count" }),
1746
+ webhookFailureCount: z7.number().openapi({ description: "Webhook failure count" }),
1747
+ executionCount: z7.number().openapi({ description: "Total number of executions in history" }),
1748
+ bubbles: z7.array(
1749
+ z7.object({
1750
+ bubbleName: z7.string().openapi({ description: "Bubble name" }),
1751
+ className: z7.string().openapi({ description: "Bubble class name" })
1752
+ })
1753
+ ).optional().openapi({ description: "List of bubbles used in this flow" }),
1754
+ createdAt: z7.string().openapi({ description: "Creation timestamp" }),
1755
+ updatedAt: z7.string().openapi({ description: "Update timestamp" })
1756
+ });
1757
+ var bubbleFlowListResponseSchema = z7.object({
1758
+ bubbleFlows: z7.array(bubbleFlowListItemSchema).default([]),
1759
+ userMonthlyUsage: z7.object({
1760
+ count: z7.number().openapi({ description: "Current monthly usage count" })
1761
+ }).openapi({ description: "User monthly usage information" })
1762
+ });
1763
+ var activateBubbleFlowResponseSchema = z7.object({
1764
+ success: z7.boolean().openapi({
1765
+ description: "Whether the activation was successful",
1766
+ example: true
1767
+ }),
1768
+ webhookUrl: z7.string().openapi({
1769
+ description: "Webhook URL for the activated workflow",
1770
+ example: "https://api.nodex.dev/webhook/user123/workflow-123"
1771
+ }),
1772
+ message: z7.string().openapi({
1773
+ description: "Success message",
1774
+ example: "Workflow activated successfully! Your Slack bot is now ready."
1775
+ })
1776
+ }).openapi("ActivateBubbleFlowResponse");
1777
+
1778
+ // src/bubbleflow-execution-schema.ts
1779
+ import { z as z8 } from "@hono/zod-openapi";
1780
+ var ServiceUsageSchema = z8.object({
1781
+ service: z8.nativeEnum(CredentialType).openapi({
1782
+ description: "Service identifier",
1783
+ example: "OPENAI_CRED" /* OPENAI_CRED */
1784
+ }),
1785
+ subService: z8.string().optional().openapi({
1786
+ description: "Sub-service identifier",
1787
+ example: "gpt-4"
1788
+ }),
1789
+ unit: z8.string().openapi({
1790
+ description: "Unit type for this service",
1791
+ example: "per_1m_tokens"
1792
+ }),
1793
+ usage: z8.number().openapi({
1794
+ description: "Units used this month",
1795
+ example: 225e4
1796
+ }),
1797
+ unitCost: z8.number().openapi({
1798
+ description: "Bubble Lab price per unit (with multiplier applied)",
1799
+ example: 2.1
1800
+ }),
1801
+ totalCost: z8.number().openapi({
1802
+ description: "Total cost for this service (usage * unitCost)",
1803
+ example: 4.725
1804
+ })
1805
+ }).openapi("ServiceUsage");
1806
+ var ExecutionSummarySchema = z8.object({
1807
+ result: z8.any().optional().openapi({
1808
+ description: "Execution result",
1809
+ example: "Execution completed successfully"
1810
+ }),
1811
+ totalDuration: z8.number().openapi({
1812
+ description: "Total execution duration in milliseconds",
1813
+ example: 1500
1814
+ }),
1815
+ lineExecutionCount: z8.number().optional().openapi({
1816
+ description: "Number of lines executed",
1817
+ example: 25
1818
+ }),
1819
+ bubbleExecutionCount: z8.number().optional().openapi({
1820
+ description: "Number of bubbles executed",
1821
+ example: 5
1822
+ }),
1823
+ errorCount: z8.number().optional().openapi({
1824
+ description: "Number of errors encountered",
1825
+ example: 0
1826
+ }),
1827
+ totalCost: z8.number().openapi({ description: "Total cost of the execution" }),
1828
+ warningCount: z8.number().optional().openapi({
1829
+ description: "Number of warnings encountered",
1830
+ example: 1
1831
+ }),
1832
+ errors: z8.array(
1833
+ z8.object({
1834
+ message: z8.string().openapi({
1835
+ description: "Error message",
1836
+ example: "Failed to execute bubble"
1837
+ }),
1838
+ timestamp: z8.number().openapi({
1839
+ description: "Error timestamp (Unix timestamp)",
1840
+ example: 1703123457e3
1841
+ }),
1842
+ bubbleName: z8.string().optional().openapi({
1843
+ description: "Name of the bubble that caused the error",
1844
+ example: "AIAgentBubble"
1845
+ }),
1846
+ variableId: z8.number().optional().openapi({
1847
+ description: "Variable ID associated with the error",
1848
+ example: 1
1849
+ }),
1850
+ lineNumber: z8.number().optional().openapi({
1851
+ description: "Line number where the error occurred",
1852
+ example: 15
1853
+ }),
1854
+ additionalData: z8.any().optional().openapi({
1855
+ description: "Additional error details"
1856
+ })
1857
+ })
1858
+ ).optional().openapi({
1859
+ description: "Array of errors encountered during execution"
1860
+ }),
1861
+ warnings: z8.array(
1862
+ z8.object({
1863
+ message: z8.string().openapi({
1864
+ description: "Warning message",
1865
+ example: "Deprecated API usage detected"
1866
+ }),
1867
+ timestamp: z8.number().openapi({
1868
+ description: "Warning timestamp (Unix timestamp)",
1869
+ example: 1703123457e3
1870
+ }),
1871
+ bubbleName: z8.string().optional().openapi({
1872
+ description: "Name of the bubble that caused the warning",
1873
+ example: "HttpBubble"
1874
+ }),
1875
+ variableId: z8.number().optional().openapi({
1876
+ description: "Variable ID associated with the warning",
1877
+ example: 2
1878
+ }),
1879
+ lineNumber: z8.number().optional().openapi({
1880
+ description: "Line number where the warning occurred",
1881
+ example: 20
1882
+ }),
1883
+ additionalData: z8.any().optional().openapi({
1884
+ description: "Additional warning details"
1885
+ })
1886
+ })
1887
+ ).optional().openapi({
1888
+ description: "Array of warnings encountered during execution"
1889
+ }),
1890
+ averageLineExecutionTime: z8.number().optional().openapi({
1891
+ description: "Average execution time per line in milliseconds",
1892
+ example: 60
1893
+ }),
1894
+ slowestLines: z8.array(
1895
+ z8.object({
1896
+ lineNumber: z8.number().openapi({
1897
+ description: "Line number",
1898
+ example: 15
1899
+ }),
1900
+ duration: z8.number().openapi({
1901
+ description: "Execution duration in milliseconds",
1902
+ example: 250
1903
+ }),
1904
+ message: z8.string().openapi({
1905
+ description: "Description of what was executed on this line",
1906
+ example: "API call to external service"
1907
+ })
1908
+ })
1909
+ ).optional().openapi({
1910
+ description: "Array of the slowest executing lines"
1911
+ }),
1912
+ memoryPeakUsage: z8.any().optional().openapi({
1913
+ description: "Peak memory usage during execution (NodeJS.MemoryUsage type)"
1914
+ }),
1915
+ // NodeJS.MemoryUsage type
1916
+ startTime: z8.number().optional().openapi({
1917
+ description: "Execution start timestamp (Unix timestamp)",
1918
+ example: 1703123456789
1919
+ }),
1920
+ endTime: z8.number().optional().openapi({
1921
+ description: "Execution end timestamp (Unix timestamp)",
1922
+ example: 1703123458289
1923
+ }),
1924
+ serviceUsage: z8.array(ServiceUsageSchema).optional().openapi({
1925
+ description: "Token usage during execution"
1926
+ }),
1927
+ serviceUsageByService: z8.record(z8.string(), ServiceUsageSchema).optional().openapi({
1928
+ description: "Service usage breakdown by service"
1929
+ })
1930
+ }).openapi("ExecutionSummary");
1931
+ var bubbleFlowExecutionSchema = z8.object({
1932
+ id: z8.number().openapi({ description: "Execution ID" }),
1933
+ status: z8.enum(["running", "success", "error"]).openapi({ description: "Execution status" }),
1934
+ payload: z8.record(z8.string(), z8.any()).openapi({ description: "Execution payload" }),
1935
+ result: z8.any().optional().openapi({ description: "Execution result data" }),
1936
+ error: z8.string().optional().openapi({ description: "Error message if failed" }),
1937
+ startedAt: z8.string().openapi({ description: "Execution start timestamp" }),
1938
+ webhook_url: z8.string().openapi({ description: "Webhook URL" }),
1939
+ completedAt: z8.string().optional().openapi({ description: "Execution completion timestamp" }),
1940
+ code: z8.string().optional().openapi({
1941
+ description: "The code that was executed (snapshot of the code at execution time)"
1942
+ })
1943
+ });
1944
+ var listBubbleFlowExecutionsResponseSchema = z8.array(bubbleFlowExecutionSchema).openapi("ListBubbleFlowExecutionsResponse");
1945
+ var bubbleFlowExecutionDetailSchema = bubbleFlowExecutionSchema.extend(
1946
+ {
1947
+ executionLogs: z8.array(z8.any()).optional().openapi({
1948
+ description: "Array of streaming log events from the execution"
1949
+ })
1950
+ }
1951
+ );
1952
+ var executeBubbleFlowResponseSchema = z8.object({
1953
+ executionId: z8.number().openapi({
1954
+ description: "ID of the execution record",
1955
+ example: 789
1956
+ }),
1957
+ success: z8.boolean().openapi({
1958
+ description: "Whether the execution was successful",
1959
+ example: true
1960
+ }),
1961
+ data: z8.any().optional().openapi({
1962
+ description: "Data returned by the BubbleFlow (if successful)",
1963
+ example: { result: "processed successfully", count: 42 }
1964
+ }),
1965
+ summary: ExecutionSummarySchema.optional().openapi({
1966
+ description: "Execution summary"
1967
+ }),
1968
+ error: z8.string().optional().openapi({
1969
+ description: "Error message (if execution failed)",
1970
+ example: "Validation error in BubbleFlow"
1971
+ })
1972
+ }).openapi("ExecuteBubbleFlowResponse");
1973
+ var validateBubbleFlowCodeSchema = z8.object({
1974
+ code: z8.string().min(1).openapi({
1975
+ description: "TypeScript BubbleFlow code to validate",
1976
+ example: 'export class TestFlow extends BubbleFlow<"webhook/http"> { async handle() { return {}; } }'
1977
+ }),
1978
+ options: z8.object({
1979
+ includeDetails: z8.boolean().default(true).openapi({
1980
+ description: "Include detailed bubble analysis"
1981
+ }),
1982
+ strictMode: z8.boolean().default(true).openapi({
1983
+ description: "Enable strict TypeScript validation"
1984
+ }),
1985
+ syncInputsWithFlow: z8.boolean().default(false).openapi({
1986
+ description: "Whether to sync input values with the flow"
1987
+ })
1988
+ }).optional().openapi({
1989
+ description: "Validation options"
1990
+ }),
1991
+ flowId: z8.number().positive().optional().openapi({
1992
+ description: "Optional BubbleFlow ID to update with validation results if user owns the flow",
1993
+ example: 123
1994
+ }),
1995
+ credentials: z8.record(z8.string(), z8.record(z8.string(), z8.number())).optional().openapi({
1996
+ description: "Optional credentials mapping: bubble name -> credential type -> credential ID",
1997
+ example: {
1998
+ "slack-sender": {
1999
+ SLACK_CRED: 123
2000
+ },
2001
+ "ai-agent": {
2002
+ OPENAI_CRED: 456
2003
+ }
2004
+ }
2005
+ }),
2006
+ defaultInputs: z8.record(z8.unknown()).optional().openapi({
2007
+ description: "User-filled input values for cron execution",
2008
+ example: {
2009
+ message: "Hello World",
2010
+ channel: "#general"
2011
+ }
2012
+ }),
2013
+ activateCron: z8.boolean().optional().openapi({
2014
+ description: "Whether to activate/deactivate cron scheduling",
2015
+ example: true
2016
+ })
2017
+ });
2018
+ var validateBubbleFlowCodeResponseSchema = z8.object({
2019
+ eventType: z8.string().min(1).openapi({
2020
+ description: "Event type this BubbleFlow responds to",
2021
+ example: "webhook/http"
2022
+ }),
2023
+ webhookPath: z8.string().min(1).openapi({
2024
+ description: "Custom webhook path (auto-generated if not provided)",
2025
+ example: "my-webhook"
2026
+ }),
2027
+ valid: z8.boolean().openapi({
2028
+ description: "Whether the code is valid"
2029
+ }),
2030
+ errors: z8.array(z8.string()).optional().openapi({
2031
+ description: "List of validation errors if any"
2032
+ }),
2033
+ bubbleCount: z8.number().optional().openapi({
2034
+ description: "Number of bubbles found in the code"
2035
+ }),
2036
+ inputSchema: z8.record(z8.string(), z8.unknown()).openapi({
2037
+ description: "Input schema",
2038
+ example: {
2039
+ name: "string",
2040
+ age: "number"
2041
+ }
2042
+ }),
2043
+ bubbles: z8.record(z8.string(), ParsedBubbleWithInfoSchema).optional().openapi({
2044
+ description: "Record mapping bubble IDs to their detailed information"
2045
+ }),
2046
+ workflow: ParsedWorkflowSchema.optional().openapi({
2047
+ description: "Hierarchical workflow structure with control flow"
2048
+ }),
2049
+ requiredCredentials: z8.record(z8.string(), z8.array(z8.string())).optional().openapi({
2050
+ description: "Required credentials for the bubbles in the code"
2051
+ }),
2052
+ metadata: z8.object({
2053
+ validatedAt: z8.string().openapi({
2054
+ description: "Timestamp when validation was performed"
2055
+ }),
2056
+ codeLength: z8.number().openapi({
2057
+ description: "Length of the code in characters"
2058
+ }),
2059
+ strictMode: z8.boolean().openapi({
2060
+ description: "Whether strict mode was used"
2061
+ }),
2062
+ flowUpdated: z8.boolean().optional().openapi({
2063
+ description: "Whether the BubbleFlow was updated with validation results"
2064
+ })
2065
+ }).openapi({
2066
+ description: "Validation metadata"
2067
+ }),
2068
+ cron: z8.string().nullable().optional().openapi({
2069
+ description: "Cron expression extracted from code",
2070
+ example: "0 0 * * *"
2071
+ }),
2072
+ cronActive: z8.boolean().optional().openapi({
2073
+ description: "Whether cron scheduling is currently active",
2074
+ example: false
2075
+ }),
2076
+ defaultInputs: z8.record(z8.unknown()).optional().openapi({
2077
+ description: "User-filled input values for cron execution",
2078
+ example: {
2079
+ message: "Hello World",
2080
+ channel: "#general"
2081
+ }
2082
+ }),
2083
+ success: z8.boolean(),
2084
+ error: z8.string()
2085
+ });
2086
+
2087
+ // src/generate-bubbleflow-schema.ts
2088
+ import { z as z10 } from "@hono/zod-openapi";
2089
+
2090
+ // src/coffee.ts
2091
+ import { z as z9 } from "zod";
2092
+ var COFFEE_MAX_ITERATIONS = 30;
2093
+ var COFFEE_MAX_QUESTIONS = 5;
2094
+ var COFFEE_DEFAULT_MODEL = "google/gemini-3-pro-preview";
2095
+ var ClarificationChoiceSchema = z9.object({
2096
+ id: z9.string().describe("Unique identifier for this choice"),
2097
+ label: z9.string().describe("Short display label for the choice"),
2098
+ description: z9.string().optional().describe("Optional longer description explaining the choice")
2099
+ });
2100
+ var ClarificationQuestionSchema = z9.object({
2101
+ id: z9.string().describe("Unique identifier for this question"),
2102
+ question: z9.string().describe("The question text to display to the user"),
2103
+ choices: z9.array(ClarificationChoiceSchema).min(2).describe("Available choices for the user (minimum 2 options)"),
2104
+ context: z9.string().optional().describe("Optional context explaining why this question is being asked"),
2105
+ allowMultiple: z9.boolean().optional().default(false).describe(
2106
+ "If true, user can select multiple choices. Default is false (single selection)"
2107
+ )
2108
+ });
2109
+ var CoffeeClarificationEventSchema = z9.object({
2110
+ questions: z9.array(ClarificationQuestionSchema).min(1).max(COFFEE_MAX_QUESTIONS).describe(`List of clarification questions (1-${COFFEE_MAX_QUESTIONS})`)
2111
+ });
2112
+ var CoffeeRequestExternalContextEventSchema = z9.object({
2113
+ flowId: z9.string().describe("Unique ID for this context request"),
2114
+ flowCode: z9.string().describe("Validated BubbleFlow TypeScript code to execute"),
2115
+ requiredCredentials: z9.array(z9.nativeEnum(CredentialType)).describe("List of credential types needed to run this flow"),
2116
+ description: z9.string().describe("User-friendly description of what this flow will do")
2117
+ });
2118
+ var CoffeeContextAnswerSchema = z9.object({
2119
+ flowId: z9.string().describe("ID of the context request being answered"),
2120
+ status: z9.enum(["success", "rejected", "error"]).describe(
2121
+ "Status: success (got context), rejected (user skipped), error (execution failed)"
2122
+ ),
2123
+ result: z9.unknown().optional().describe("The result data from running the context-gathering flow"),
2124
+ error: z9.string().optional().describe("Error message if status is error"),
2125
+ originalRequest: CoffeeRequestExternalContextEventSchema.optional().describe(
2126
+ "The original context request that triggered this answer"
2127
+ )
2128
+ });
2129
+ var CoffeeContextRequestInfoSchema = z9.object({
2130
+ purpose: z9.string().describe("Why this context is needed"),
2131
+ flowDescription: z9.string().describe("User-facing description of what the flow will do")
2132
+ });
2133
+ var CoffeeContextEventSchema = z9.object({
2134
+ status: z9.enum(["gathering", "complete"]),
2135
+ miniFlowDescription: z9.string().optional(),
2136
+ result: z9.string().optional()
2137
+ });
2138
+ var PlanStepSchema = z9.object({
2139
+ title: z9.string().describe("Short title for this step"),
2140
+ description: z9.string().describe("Detailed description of what this step does"),
2141
+ bubblesUsed: z9.array(z9.string()).optional().describe("Names of bubbles used in this step")
2142
+ });
2143
+ var CoffeePlanEventSchema = z9.object({
2144
+ summary: z9.string().describe("Brief overview of the workflow"),
2145
+ steps: z9.array(PlanStepSchema).describe("Step-by-step implementation plan"),
2146
+ estimatedBubbles: z9.array(z9.string()).describe("All bubbles that will be used in the workflow")
2147
+ });
2148
+ var BaseMessageSchema = z9.object({
2149
+ id: z9.string().describe("Unique message identifier"),
2150
+ timestamp: z9.string().describe("ISO timestamp of message creation")
2151
+ });
2152
+ var UserMessageSchema = BaseMessageSchema.extend({
2153
+ type: z9.literal("user"),
2154
+ content: z9.string().describe("User message text")
2155
+ });
2156
+ var AssistantMessageSchema = BaseMessageSchema.extend({
2157
+ type: z9.literal("assistant"),
2158
+ content: z9.string().describe("Assistant response text"),
2159
+ code: z9.string().optional().describe("Generated code if applicable"),
2160
+ resultType: z9.enum(["code", "question", "answer", "reject"]).optional().describe("Type of assistant response"),
2161
+ bubbleParameters: z9.record(z9.string(), z9.unknown()).optional().describe("Bubble parameters for code responses")
2162
+ });
2163
+ var ClarificationRequestMessageSchema = BaseMessageSchema.extend({
2164
+ type: z9.literal("clarification_request"),
2165
+ questions: z9.array(ClarificationQuestionSchema).describe("Questions being asked")
2166
+ });
2167
+ var ClarificationResponseMessageSchema = BaseMessageSchema.extend({
2168
+ type: z9.literal("clarification_response"),
2169
+ answers: z9.record(z9.string(), z9.array(z9.string())).describe("questionId -> choiceIds"),
2170
+ originalQuestions: z9.array(ClarificationQuestionSchema).optional().describe("The questions that were answered (for display purposes)")
2171
+ });
2172
+ var ContextRequestMessageSchema = BaseMessageSchema.extend({
2173
+ type: z9.literal("context_request"),
2174
+ request: CoffeeRequestExternalContextEventSchema.describe(
2175
+ "Context gathering request details"
2176
+ )
2177
+ });
2178
+ var ContextResponseMessageSchema = BaseMessageSchema.extend({
2179
+ type: z9.literal("context_response"),
2180
+ answer: CoffeeContextAnswerSchema.describe(
2181
+ "User response to context request"
2182
+ ),
2183
+ credentialTypes: z9.array(z9.string()).optional().describe("Credential types used (for display, not actual secrets)")
2184
+ });
2185
+ var PlanMessageSchema = BaseMessageSchema.extend({
2186
+ type: z9.literal("plan"),
2187
+ plan: CoffeePlanEventSchema.describe("Generated implementation plan")
2188
+ });
2189
+ var PlanApprovalMessageSchema = BaseMessageSchema.extend({
2190
+ type: z9.literal("plan_approval"),
2191
+ approved: z9.boolean().describe("Whether the plan was approved"),
2192
+ comment: z9.string().optional().describe("Optional user comment on the plan")
2193
+ });
2194
+ var SystemMessageSchema = BaseMessageSchema.extend({
2195
+ type: z9.literal("system"),
2196
+ content: z9.string().describe("System message content")
2197
+ });
2198
+ var ToolResultMessageSchema = BaseMessageSchema.extend({
2199
+ type: z9.literal("tool_result"),
2200
+ toolName: z9.string().describe("Name of the tool that was called"),
2201
+ toolCallId: z9.string().describe("Unique ID for this tool call"),
2202
+ input: z9.unknown().describe("Input parameters passed to the tool"),
2203
+ output: z9.unknown().describe("Output/result from the tool"),
2204
+ duration: z9.number().describe("Duration of the tool call in milliseconds"),
2205
+ success: z9.boolean().describe("Whether the tool call succeeded")
2206
+ });
2207
+ var CoffeeMessageSchema = z9.discriminatedUnion("type", [
2208
+ UserMessageSchema,
2209
+ AssistantMessageSchema,
2210
+ ClarificationRequestMessageSchema,
2211
+ ClarificationResponseMessageSchema,
2212
+ ContextRequestMessageSchema,
2213
+ ContextResponseMessageSchema,
2214
+ PlanMessageSchema,
2215
+ PlanApprovalMessageSchema,
2216
+ SystemMessageSchema,
2217
+ ToolResultMessageSchema
2218
+ ]);
2219
+ var CoffeeRequestSchema = z9.object({
2220
+ prompt: z9.string().min(1).describe("The user prompt describing the workflow"),
2221
+ flowId: z9.number().optional().describe("Optional flow ID if updating existing flow"),
2222
+ messages: z9.array(CoffeeMessageSchema).optional().describe(
2223
+ "Full conversation history including clarification Q&A, context results, plan approvals"
2224
+ )
2225
+ });
2226
+ var CoffeeResponseSchema = z9.object({
2227
+ type: z9.enum(["clarification", "plan", "context_request", "error"]).describe("Response type"),
2228
+ clarification: CoffeeClarificationEventSchema.optional(),
2229
+ plan: CoffeePlanEventSchema.optional(),
2230
+ contextRequest: CoffeeRequestExternalContextEventSchema.optional(),
2231
+ error: z9.string().optional(),
2232
+ success: z9.boolean().describe("Whether the operation completed successfully")
2233
+ });
2234
+ var CoffeeAgentOutputSchema = z9.object({
2235
+ action: z9.enum(["askClarification", "generatePlan", "requestContext"]).describe("The action the agent wants to take"),
2236
+ questions: z9.array(ClarificationQuestionSchema).optional(),
2237
+ plan: CoffeePlanEventSchema.optional(),
2238
+ contextRequest: CoffeeContextRequestInfoSchema.optional()
2239
+ });
2240
+
2241
+ // src/generate-bubbleflow-schema.ts
2242
+ var generateBubbleFlowCodeSchema = z10.object({
2243
+ prompt: z10.string().min(1).openapi({
2244
+ description: "Natural language description of the desired BubbleFlow",
2245
+ example: "Create a flow that queries my database and sends results to Slack"
2246
+ }),
2247
+ flowId: z10.number().optional().openapi({
2248
+ description: "Optional flow ID to update with generated code (for async generation)",
2249
+ example: 123
2250
+ }),
2251
+ // Coffee agent unified messages (for planning phase)
2252
+ messages: z10.array(CoffeeMessageSchema).optional().openapi({
2253
+ description: "Full conversation history including clarification Q&A, context results, plan approvals"
2254
+ }),
2255
+ // Plan context (passed to Boba for enriched code generation)
2256
+ planContext: z10.string().optional().openapi({
2257
+ description: "Plan context from Coffee agent (passed to Boba for enriched generation)",
2258
+ example: "Plan: 1. Fetch data from API 2. Process with AI 3. Send to Slack"
2259
+ })
2260
+ });
2261
+ var generateBubbleFlowCodeResponseSchema = z10.object({
2262
+ generatedCode: z10.string().openapi({
2263
+ description: "The generated BubbleFlow TypeScript code"
2264
+ }),
2265
+ isValid: z10.boolean().openapi({
2266
+ description: "Whether the generated code is valid"
2267
+ }),
2268
+ success: z10.boolean(),
2269
+ error: z10.string(),
2270
+ bubbleParameters: z10.record(z10.string(), ParsedBubbleWithInfoSchema).openapi({
2271
+ description: "Parsed bubble parameters from the generated code"
2272
+ }),
2273
+ requiredCredentials: z10.record(z10.string(), z10.array(z10.string())).openapi({
2274
+ description: "Required credentials for the bubbles in the generated code"
2275
+ })
2276
+ });
2277
+ var GenerationResultSchema = z10.object({
2278
+ generatedCode: z10.string().describe("The generated BubbleFlow TypeScript code"),
2279
+ isValid: z10.boolean().describe("Whether the generated code is valid"),
2280
+ success: z10.boolean(),
2281
+ error: z10.string(),
2282
+ flowId: z10.number().optional().openapi({
2283
+ description: "ID of the generated BubbleFlow",
2284
+ example: 123
2285
+ }),
2286
+ toolCalls: z10.array(z10.unknown()).describe("The tool calls made by the AI agent"),
2287
+ summary: z10.string().default("").describe("High-level instructions for using the validated flow"),
2288
+ inputsSchema: z10.string().default("").describe("JSON Schema (string) representing the inputs of the flow"),
2289
+ serviceUsage: z10.array(ServiceUsageSchema).optional().openapi({
2290
+ description: "Service usage statistics for the generation (array of services used)"
2291
+ }),
2292
+ bubbleCount: z10.number().optional().openapi({
2293
+ description: "Number of bubbles used in the generated flow"
2294
+ }),
2295
+ codeLength: z10.number().optional().openapi({
2296
+ description: "Length of the generated code in characters"
2297
+ }),
2298
+ bubbleParameters: z10.record(z10.union([z10.string(), z10.number()]), ParsedBubbleWithInfoSchema).optional().openapi({
2299
+ description: "Parsed bubble parameters with descriptions from AI generation"
2300
+ })
2301
+ });
2302
+ var generateBubbleFlowTemplateSchema = z10.object({
2303
+ name: z10.string().min(1).max(100).openapi({
2304
+ description: "Name for the workflow",
2305
+ example: "Sam Dix Data Scientist Bot"
2306
+ }),
2307
+ description: z10.string().min(10).max(500).openapi({
2308
+ description: "Description of what the workflow should do",
2309
+ example: "A Slack bot that helps analyze user engagement data and provides insights"
2310
+ }),
2311
+ roles: z10.string().min(10).max(1e3).openapi({
2312
+ description: "Detailed description of the bot's roles and responsibilities",
2313
+ example: "Be prepared to answer any question on user engagement and come up with proactive insights..."
2314
+ }),
2315
+ useCase: z10.literal("slack-data-scientist").openapi({
2316
+ description: "The specific use case template to generate",
2317
+ example: "slack-data-scientist"
2318
+ }),
2319
+ // Optional configuration parameters
2320
+ verbosity: z10.enum(["1", "2", "3", "4", "5"]).optional().openapi({
2321
+ description: "Response verbosity level (1=concise, 5=comprehensive)",
2322
+ example: "3"
2323
+ }),
2324
+ technicality: z10.enum(["1", "2", "3", "4", "5"]).optional().openapi({
2325
+ description: "Technical complexity level (1=plain English, 5=expert)",
2326
+ example: "2"
2327
+ }),
2328
+ includeQuery: z10.boolean().optional().openapi({
2329
+ description: "Include the SQL query in the response",
2330
+ example: true
2331
+ }),
2332
+ includeExplanation: z10.boolean().optional().openapi({
2333
+ description: "Include query explanation in the response",
2334
+ example: true
2335
+ }),
2336
+ maxQueries: z10.number().optional().openapi({
2337
+ description: "Maximum number of queries to run",
2338
+ example: 10
2339
+ })
2340
+ }).openapi("GenerateBubbleFlowTemplateRequest");
2341
+ var generateDocumentGenerationTemplateSchema = z10.object({
2342
+ name: z10.string().min(1).max(100).openapi({
2343
+ description: "Name for the document processing workflow",
2344
+ example: "Expense Report Generator"
2345
+ }),
2346
+ description: z10.string().max(500).default("Document processing workflow").openapi({
2347
+ description: "Description of what the document processing workflow should do (optional)",
2348
+ example: "Process receipts and invoices to generate structured expense reports"
2349
+ }),
2350
+ outputDescription: z10.string().min(1).max(1e3).openapi({
2351
+ description: "Detailed description of the desired output format and data extraction",
2352
+ example: "Extract expense tracking data with vendor name, transaction date, amount, category, and description"
2353
+ }),
2354
+ // Optional configuration parameters
2355
+ outputFormat: z10.enum(["html", "csv", "json"]).optional().openapi({
2356
+ description: "Default output format for generated documents",
2357
+ example: "html"
2358
+ }),
2359
+ conversionOptions: z10.object({
2360
+ preserveStructure: z10.boolean().optional().openapi({
2361
+ description: "Preserve document structure during parsing",
2362
+ example: true
2363
+ }),
2364
+ includeVisualDescriptions: z10.boolean().optional().openapi({
2365
+ description: "Include descriptions of visual elements",
2366
+ example: true
2367
+ }),
2368
+ extractNumericalData: z10.boolean().optional().openapi({
2369
+ description: "Extract and process numerical data",
2370
+ example: true
2371
+ }),
2372
+ combinePages: z10.boolean().optional().openapi({
2373
+ description: "Combine multiple pages into single output",
2374
+ example: true
2375
+ })
2376
+ }).optional(),
2377
+ imageOptions: z10.object({
2378
+ format: z10.enum(["png", "jpg", "jpeg"]).optional().openapi({
2379
+ description: "Image format for document conversion",
2380
+ example: "png"
2381
+ }),
2382
+ quality: z10.number().min(0.1).max(1).optional().openapi({
2383
+ description: "Image quality (0.1 to 1.0)",
2384
+ example: 0.9
2385
+ }),
2386
+ dpi: z10.number().min(72).max(300).optional().openapi({
2387
+ description: "Image DPI for conversion",
2388
+ example: 200
2389
+ })
2390
+ }).optional(),
2391
+ aiOptions: z10.object({
2392
+ model: z10.string().optional().openapi({
2393
+ description: "AI model to use for processing",
2394
+ example: "google/gemini-2.5-flash"
2395
+ }),
2396
+ temperature: z10.number().min(0).max(2).optional().openapi({
2397
+ description: "AI model temperature (0 to 2)",
2398
+ example: 0.2
2399
+ }),
2400
+ maxTokens: z10.number().min(1e3).max(2e5).optional().openapi({
2401
+ description: "Maximum tokens for AI processing",
2402
+ example: 9e4
2403
+ }),
2404
+ jsonMode: z10.boolean().optional().openapi({
2405
+ description: "Enable JSON mode for structured output",
2406
+ example: false
2407
+ })
2408
+ }).optional(),
2409
+ metadata: z10.record(z10.string(), z10.unknown()).optional().openapi({
2410
+ description: "Additional metadata for the workflow (e.g., outputDescription)",
2411
+ example: { outputDescription: "Extract expense data from receipts" }
2412
+ })
2413
+ }).openapi("GenerateDocumentGenerationTemplateRequest");
2414
+ var bubbleFlowTemplateResponseSchema = z10.object({
2415
+ id: z10.number().openapi({
2416
+ description: "ID of the created BubbleFlow template",
2417
+ example: 123
2418
+ }),
2419
+ name: z10.string().openapi({
2420
+ description: "Name of the BubbleFlow",
2421
+ example: "Sam Dix Data Scientist Bot"
2422
+ }),
2423
+ description: z10.string().openapi({
2424
+ description: "Description of the BubbleFlow",
2425
+ example: "A Slack bot that helps analyze user engagement data"
2426
+ }),
2427
+ eventType: z10.string().openapi({
2428
+ description: "Event type this BubbleFlow responds to",
2429
+ example: "slack/bot_mentioned"
2430
+ }),
2431
+ displayedBubbleParameters: z10.record(
2432
+ z10.string(),
2433
+ z10.object({
2434
+ variableName: z10.string(),
2435
+ bubbleName: z10.string(),
2436
+ className: z10.string(),
2437
+ parameters: z10.array(
2438
+ z10.object({
2439
+ name: z10.string(),
2440
+ value: z10.unknown(),
2441
+ type: z10.nativeEnum(BubbleParameterType)
2442
+ })
2443
+ ),
2444
+ hasAwait: z10.boolean(),
2445
+ hasActionCall: z10.boolean()
2446
+ })
2447
+ ),
2448
+ bubbleParameters: z10.record(
2449
+ z10.string(),
2450
+ z10.object({
2451
+ variableName: z10.string(),
2452
+ bubbleName: z10.string(),
2453
+ className: z10.string(),
2454
+ parameters: z10.array(
2455
+ z10.object({
2456
+ name: z10.string(),
2457
+ value: z10.unknown(),
2458
+ type: z10.nativeEnum(BubbleParameterType)
2459
+ })
2460
+ ),
2461
+ hasAwait: z10.boolean(),
2462
+ hasActionCall: z10.boolean()
2463
+ })
2464
+ ).openapi({
2465
+ description: "Parsed bubble parameters from the BubbleFlow code"
2466
+ }),
2467
+ requiredCredentials: z10.record(z10.string(), z10.array(z10.nativeEnum(CredentialType))).optional().openapi({
2468
+ description: "Mapping of bubble names to their required credential types",
2469
+ example: {
2470
+ "database-connection": ["DATABASE_CRED" /* DATABASE_CRED */],
2471
+ "slack-notification": ["SLACK_CRED" /* SLACK_CRED */],
2472
+ "ai-analysis": ["GOOGLE_GEMINI_CRED" /* GOOGLE_GEMINI_CRED */]
2473
+ }
2474
+ }),
2475
+ createdAt: z10.string().openapi({
2476
+ description: "ISO timestamp when the template was created",
2477
+ example: "2025-01-15T10:30:00.000Z"
2478
+ }),
2479
+ updatedAt: z10.string().openapi({
2480
+ description: "ISO timestamp when the template was last updated",
2481
+ example: "2025-01-15T10:30:00.000Z"
2482
+ }),
2483
+ webhook: z10.object({
2484
+ id: z10.number().openapi({ description: "Webhook ID", example: 456 }),
2485
+ url: z10.string().openapi({
2486
+ description: "Full webhook URL",
2487
+ example: "http://localhost:3001/webhook/user123/my-webhook"
2488
+ }),
2489
+ path: z10.string().openapi({
2490
+ description: "Webhook path",
2491
+ example: "my-webhook"
2492
+ }),
2493
+ active: z10.boolean().openapi({
2494
+ description: "Whether webhook is active",
2495
+ example: true
2496
+ })
2497
+ }).optional().openapi({
2498
+ description: "Webhook information (if webhook was created)"
2499
+ })
2500
+ }).openapi("BubbleFlowTemplateResponse");
2501
+
2502
+ // src/webhook-schema.ts
2503
+ import { z as z11 } from "@hono/zod-openapi";
2504
+ var webhookExecutionResponseSchema = z11.object({
2505
+ executionId: z11.number().openapi({ description: "Execution ID" }),
2506
+ success: z11.boolean().openapi({ description: "Execution success" }),
2507
+ data: z11.unknown().optional().openapi({ description: "Result data" }),
2508
+ error: z11.string().optional().openapi({ description: "Error message" }),
2509
+ webhook: z11.object({
2510
+ userId: z11.string().openapi({ description: "User ID" }),
2511
+ path: z11.string().openapi({ description: "Webhook path" }),
2512
+ triggeredAt: z11.string().openapi({ description: "Trigger timestamp" }),
2513
+ method: z11.string().openapi({ description: "HTTP method" })
2514
+ }).openapi({ description: "Webhook info" })
2515
+ }).openapi("WebhookExecutionResponse");
2516
+ var webhookResponseSchema = z11.object({
2517
+ // Slack verification fields
2518
+ challenge: z11.string().optional().openapi({ description: "Slack URL verification challenge" }),
2519
+ // Execution fields
2520
+ executionId: z11.number().optional().openapi({ description: "Execution ID" }),
2521
+ success: z11.boolean().optional().openapi({ description: "Execution success" }),
2522
+ data: z11.record(z11.string(), z11.unknown()).or(z11.undefined()).optional().openapi({ description: "Result data" }),
2523
+ error: z11.string().optional().openapi({ description: "Error message" }),
2524
+ webhook: z11.object({
2525
+ userId: z11.string().openapi({ description: "User ID" }),
2526
+ path: z11.string().openapi({ description: "Webhook path" }),
2527
+ triggeredAt: z11.string().openapi({ description: "Trigger timestamp" }),
2528
+ method: z11.string().openapi({ description: "HTTP method" })
2529
+ }).optional().openapi({ description: "Webhook info" })
2530
+ }).openapi("WebhookResponse");
2531
+
2532
+ // src/subscription-status-schema.ts
2533
+ import { z as z12 } from "@hono/zod-openapi";
2534
+ var hackathonOfferSchema = z12.object({
2535
+ isActive: z12.boolean().openapi({
2536
+ description: "Whether a hackathon offer is currently active",
2537
+ example: true
2538
+ }),
2539
+ expiresAt: z12.string().openapi({
2540
+ description: "ISO date when the hackathon offer expires",
2541
+ example: "2025-01-15T14:30:00.000Z"
2542
+ }),
2543
+ redeemedAt: z12.string().openapi({
2544
+ description: "ISO date when the code was redeemed",
2545
+ example: "2025-01-14T14:30:00.000Z"
2546
+ })
2547
+ }).openapi("HackathonOffer");
2548
+ var specialOfferSchema = z12.object({
2549
+ isActive: z12.boolean().openapi({
2550
+ description: "Whether a special offer is currently active",
2551
+ example: true
2552
+ }),
2553
+ plan: z12.string().openapi({
2554
+ description: "The plan granted by the special offer",
2555
+ example: "unlimited"
2556
+ }),
2557
+ expiresAt: z12.string().nullable().openapi({
2558
+ description: "ISO date when the special offer expires (null = never expires)",
2559
+ example: "2025-06-15T14:30:00.000Z"
2560
+ })
2561
+ }).openapi("SpecialOffer");
2562
+ var redeemCouponRequestSchema = z12.object({
2563
+ code: z12.string().min(1).openapi({
2564
+ description: "The coupon code to redeem",
2565
+ example: "HACKATHON2025"
2566
+ })
2567
+ }).openapi("RedeemCouponRequest");
2568
+ var redeemCouponResponseSchema = z12.object({
2569
+ success: z12.boolean().openapi({
2570
+ description: "Whether the redemption was successful",
2571
+ example: true
2572
+ }),
2573
+ message: z12.string().openapi({
2574
+ description: "Human-readable message about the redemption result",
2575
+ example: "Coupon redeemed successfully! You now have Pro access."
2576
+ }),
2577
+ expiresAt: z12.string().optional().openapi({
2578
+ description: "When the offer expires (if successful)",
2579
+ example: "2025-01-15T14:30:00.000Z"
2580
+ })
2581
+ }).openapi("RedeemCouponResponse");
2582
+ var subscriptionStatusResponseSchema = z12.object({
2583
+ userId: z12.string().openapi({
2584
+ description: "User ID from Clerk",
2585
+ example: "user_30Gbwrzto1VZvAHcGUm5NLQhpkp"
2586
+ }),
2587
+ plan: z12.string().openapi({
2588
+ description: "Current subscription plan",
2589
+ example: "pro_plus"
2590
+ }),
2591
+ planDisplayName: z12.string().openapi({
2592
+ description: "Human-readable plan name",
2593
+ example: "Pro Plus"
2594
+ }),
2595
+ features: z12.array(z12.string()).openapi({
2596
+ description: "List of features available to the user",
2597
+ example: ["unlimited_usage", "priority_support"]
2598
+ }),
2599
+ usage: z12.object({
2600
+ executionCount: z12.number().openapi({
2601
+ description: "Current monthly execution count",
2602
+ example: 100
2603
+ }),
2604
+ executionLimit: z12.number().openapi({
2605
+ description: "Current monthly execution limit",
2606
+ example: 42
2607
+ }),
2608
+ creditLimit: z12.number().openapi({
2609
+ description: "Monthly credit limit",
2610
+ example: 100
2611
+ }),
2612
+ activeFlowLimit: z12.number().openapi({
2613
+ description: "Current monthly active flow limit",
2614
+ example: 2
2615
+ }),
2616
+ estimatedMonthlyCost: z12.number().openapi({
2617
+ description: "Projected monthly cost based on current usage trend",
2618
+ example: 14.19
2619
+ }),
2620
+ resetDate: z12.string().openapi({
2621
+ description: "ISO date when usage resets",
2622
+ example: "2025-02-01T00:00:00.000Z"
2623
+ }),
2624
+ tokenUsage: z12.array(
2625
+ z12.object({
2626
+ modelName: z12.string().openapi({
2627
+ description: "Model name",
2628
+ example: "gpt-4"
2629
+ }),
2630
+ inputTokens: z12.number().openapi({
2631
+ description: "Input tokens used this month",
2632
+ example: 1500
2633
+ }),
2634
+ outputTokens: z12.number().openapi({
2635
+ description: "Output tokens used this month",
2636
+ example: 750
2637
+ }),
2638
+ totalTokens: z12.number().openapi({
2639
+ description: "Total tokens used this month",
2640
+ example: 2250
2641
+ })
2642
+ })
2643
+ ).openapi({
2644
+ description: "Token usage breakdown by model for current month"
2645
+ }),
2646
+ serviceUsage: z12.array(ServiceUsageSchema).openapi({
2647
+ description: "Service usage and cost breakdown for current month"
2648
+ })
2649
+ }),
2650
+ isActive: z12.boolean().openapi({
2651
+ description: "Whether the subscription is active",
2652
+ example: true
2653
+ }),
2654
+ hackathonOffer: hackathonOfferSchema.optional().openapi({
2655
+ description: "Active hackathon promotional offer information"
2656
+ }),
2657
+ specialOffer: specialOfferSchema.optional().openapi({
2658
+ description: "Special offer from private metadata (takes precedence over hackathon offer)"
2659
+ })
2660
+ }).openapi("SubscriptionStatusResponse");
2661
+
2662
+ // src/milk-tea.ts
2663
+ import { z as z15 } from "zod";
2664
+
2665
+ // src/ai-models.ts
2666
+ import { z as z13 } from "zod";
2667
+ var AvailableModels = z13.enum([
2668
+ // OpenAI models
2669
+ "openai/gpt-5",
2670
+ "openai/gpt-5-mini",
2671
+ "openai/gpt-5.1",
2672
+ "openai/gpt-5.2",
2673
+ // Google Gemini models
2674
+ "google/gemini-2.5-pro",
2675
+ "google/gemini-2.5-flash",
2676
+ "google/gemini-2.5-flash-lite",
2677
+ "google/gemini-2.5-flash-image-preview",
2678
+ "google/gemini-3-pro-preview",
2679
+ "google/gemini-3-pro-image-preview",
2680
+ "google/gemini-3-flash-preview",
2681
+ // Anthropic models
2682
+ "anthropic/claude-sonnet-4-5",
2683
+ "anthropic/claude-opus-4-5",
2684
+ "anthropic/claude-haiku-4-5",
2685
+ // OpenRouter models
2686
+ "openrouter/x-ai/grok-code-fast-1",
2687
+ "openrouter/z-ai/glm-4.6",
2688
+ "openrouter/anthropic/claude-sonnet-4.5",
2689
+ "openrouter/google/gemini-3-pro-preview",
2690
+ "openrouter/morph/morph-v3-large",
2691
+ "openrouter/x-ai/grok-4.1-fast",
2692
+ "openrouter/openai/gpt-oss-120b",
2693
+ "openrouter/deepseek/deepseek-chat-v3.1"
2694
+ ]);
2695
+
2696
+ // src/agent-memory.ts
2697
+ import { z as z14 } from "zod";
2698
+ var TOOL_CALL_TO_DISCARD = ["get-bubble-details-tool"];
2699
+ var ConversationMessageSchema = z14.object({
2700
+ role: z14.enum(["user", "assistant", "tool"]).describe("The role of the message sender"),
2701
+ content: z14.string().describe("The message content"),
2702
+ toolCallId: z14.string().optional().describe("Tool call ID for tool messages"),
2703
+ name: z14.string().optional().describe("Tool name for tool messages")
2704
+ });
2705
+
2706
+ // src/milk-tea.ts
2707
+ var MilkTeaRequestSchema = z15.object({
2708
+ userRequest: z15.string().min(1, "User request is required").describe("The user request or question about configuring the bubble"),
2709
+ bubbleName: z15.string().min(1, "Bubble name is required").describe('The name of the bubble to configure (e.g., "email-tool")'),
2710
+ bubbleSchema: z15.record(z15.unknown()).describe(
2711
+ "The full schema/interface definition of the bubble including parameters and types"
2712
+ ),
2713
+ currentCode: z15.string().optional().describe("The current workflow code context for validation"),
2714
+ availableCredentials: z15.array(z15.string()).default([]).describe("List of credential types available to the user"),
2715
+ userName: z15.string().describe("Name of the user making the request"),
2716
+ insertLocation: z15.string().optional().describe("Location in code where the snippet should be inserted"),
2717
+ conversationHistory: z15.array(ConversationMessageSchema).optional().default([]).describe(
2718
+ "Previous conversation messages for multi-turn interactions (frontend manages state)"
2719
+ ),
2720
+ model: AvailableModels.default("google/gemini-2.5-pro").describe(
2721
+ "AI model to use for Milk Tea agent"
2722
+ )
2723
+ });
2724
+ var MilkTeaResponseSchema = z15.object({
2725
+ type: z15.enum(["code", "question", "reject"]).describe(
2726
+ "Type of response: code (generated snippet), question (needs clarification), reject (infeasible request)"
2727
+ ),
2728
+ message: z15.string().describe(
2729
+ "Human-readable message: explanation for code, question text, or rejection reason"
2730
+ ),
2731
+ snippet: z15.string().optional().describe(
2732
+ 'Generated TypeScript code snippet (only present when type is "code")'
2733
+ ),
2734
+ success: z15.boolean().describe("Whether the operation completed successfully"),
2735
+ error: z15.string().optional().describe("Error message if the operation failed")
2736
+ });
2737
+ var MilkTeaAgentOutputSchema = z15.object({
2738
+ type: z15.enum(["code", "question", "reject"]),
2739
+ message: z15.string(),
2740
+ snippet: z15.string().optional()
2741
+ });
2742
+
2743
+ // src/pearl.ts
2744
+ import { z as z16 } from "zod";
2745
+ var PEARL_DEFAULT_MODEL = "openrouter/anthropic/claude-sonnet-4.5";
2746
+ var PearlRequestSchema = z16.object({
2747
+ userRequest: z16.string().min(1, "User request is required").describe("The user request or question about building a workflow"),
2748
+ currentCode: z16.string().optional().describe("The current workflow code for context and modification"),
2749
+ userName: z16.string().describe("Name of the user making the request"),
2750
+ availableVariables: z16.array(z16.any()).describe("List of available variables in the current code"),
2751
+ conversationHistory: z16.array(ConversationMessageSchema).optional().default([]).describe(
2752
+ "Previous conversation messages for multi-turn interactions (frontend manages state)"
2753
+ ),
2754
+ model: AvailableModels.default(PEARL_DEFAULT_MODEL).describe(
2755
+ "AI model to use for Pearl agent"
2756
+ ),
2757
+ additionalContext: z16.string().optional().describe(
2758
+ "Additional context information like timezone, user preferences, etc."
2759
+ ),
2760
+ uploadedFiles: z16.array(
2761
+ z16.object({
2762
+ name: z16.string().describe("File name"),
2763
+ content: z16.string().describe(
2764
+ "File content: base64 for images, plain text for text files"
2765
+ ),
2766
+ fileType: z16.enum(["image", "text"]).describe("Type of file: image (base64) or text (plain text)")
2767
+ })
2768
+ ).optional().default([]).describe(
2769
+ "Files uploaded by the user: images as base64, text files as plain text"
2770
+ )
2771
+ });
2772
+ var PearlResponseSchema = z16.object({
2773
+ type: z16.enum(["code", "question", "answer", "reject"]).describe(
2774
+ "Type of response: code (generated workflow), question (needs clarification), answer (provides information/guidance), reject (infeasible request)"
2775
+ ),
2776
+ message: z16.string().describe(
2777
+ "Human-readable message: explanation for code, question text, or rejection reason"
2778
+ ),
2779
+ snippet: z16.string().optional().describe(
2780
+ 'Generated TypeScript code for complete workflow (only present when type is "code")'
2781
+ ),
2782
+ bubbleParameters: z16.record(z16.number(), ParsedBubbleWithInfoSchema).optional().describe(
2783
+ 'Parsed bubble parameters from the generated workflow (only present when type is "code")'
2784
+ ),
2785
+ inputSchema: z16.record(z16.unknown()).optional().describe(
2786
+ 'Input schema for the generated workflow (only present when type is "code")'
2787
+ ),
2788
+ requiredCredentials: z16.record(z16.string(), z16.array(z16.nativeEnum(CredentialType))).optional().describe(
2789
+ 'Required credentials for the bubbles in the workflow (only present when type is "code")'
2790
+ ),
2791
+ success: z16.boolean().describe("Whether the operation completed successfully"),
2792
+ error: z16.string().optional().describe("Error message if the operation failed")
2793
+ });
2794
+ var PearlAgentOutputSchema = z16.object({
2795
+ type: z16.enum(["code", "question", "answer", "reject", "text"]),
2796
+ message: z16.string(),
2797
+ snippet: z16.string().optional()
2798
+ });
2799
+
2800
+ // src/rice.ts
2801
+ import { z as z17 } from "zod";
2802
+
2803
+ // src/bubbleflow-generation-prompts.ts
2804
+ var RECOMMENDED_MODELS = {
2805
+ BEST: "google/gemini-3-pro-preview",
2806
+ BEST_ALT: "openai/gpt-5.2",
2807
+ PRO: "google/gemini-3-flash-preview",
2808
+ PRO_ALT: "anthropic/claude-sonnet-4-5",
2809
+ FAST: "google/gemini-3-flash-preview",
2810
+ FAST_ALT: "anthropic/claude-haiku-4-5",
2811
+ LITE: "google/gemini-2.5-flash-lite",
2812
+ IMAGE: "google/gemini-3-pro-image-preview"
2813
+ };
2814
+
2815
+ // src/rice.ts
2816
+ var RICE_DEFAULT_MODEL = RECOMMENDED_MODELS.FAST;
2817
+ var RiceIssueTypeSchema = z17.enum(["setup", "workflow", "input"]).nullable();
2818
+ var RiceEvaluationResultSchema = z17.object({
2819
+ working: z17.boolean().describe(
2820
+ "Whether the workflow is functioning correctly (true if no errors and expected behavior)"
2821
+ ),
2822
+ issueType: RiceIssueTypeSchema.describe(
2823
+ 'Category of issue: "setup" (config/credentials), "workflow" (code logic), "input" (bad input data), or null if working'
2824
+ ),
2825
+ summary: z17.string().describe(
2826
+ "Brief summary of the execution. If working: what happened and any external changes made. If not working: description of the issue."
2827
+ ),
2828
+ rating: z17.number().int().min(1).max(10).describe(
2829
+ "Quality rating 1-10: 1-3=severe issues, 4-6=partial functionality, 7-8=working with minor issues, 9-10=excellent"
2830
+ )
2831
+ });
2832
+ var RiceRequestSchema = z17.object({
2833
+ executionLogs: z17.array(z17.unknown()).describe("StreamingLogEvent[] from execution"),
2834
+ workflowCode: z17.string().describe("The original workflow code that was executed"),
2835
+ executionId: z17.number().describe("ID of the execution being evaluated"),
2836
+ bubbleFlowId: z17.number().describe("ID of the BubbleFlow being evaluated"),
2837
+ model: AvailableModels.optional().default(RICE_DEFAULT_MODEL).describe("AI model to use for Rice evaluation")
2838
+ });
2839
+ var RiceResponseSchema = z17.object({
2840
+ success: z17.boolean().describe("Whether the evaluation completed successfully"),
2841
+ evaluation: RiceEvaluationResultSchema.optional().describe(
2842
+ "Evaluation result (only present if success=true)"
2843
+ ),
2844
+ error: z17.string().optional().describe("Error message if the evaluation failed")
2845
+ });
2846
+
2847
+ // src/cron-utils.ts
2848
+ function parseCronExpression(cronString) {
2849
+ const parts = cronString.trim().split(/\s+/);
2850
+ if (parts.length !== 5) {
2851
+ throw new Error(
2852
+ `Invalid cron expression: expected 5 fields, got ${parts.length}`
2853
+ );
2854
+ }
2855
+ const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;
2856
+ return {
2857
+ minute,
2858
+ hour,
2859
+ dayOfMonth,
2860
+ month,
2861
+ dayOfWeek,
2862
+ original: cronString
2863
+ };
2864
+ }
2865
+ function validateCronExpression(cronString) {
2866
+ try {
2867
+ const expr = parseCronExpression(cronString);
2868
+ const validations = [
2869
+ validateCronField(expr.minute, 0, 59, "minute"),
2870
+ validateCronField(expr.hour, 0, 23, "hour"),
2871
+ validateCronField(expr.dayOfMonth, 1, 31, "day of month"),
2872
+ validateCronField(expr.month, 1, 12, "month"),
2873
+ validateCronField(expr.dayOfWeek, 0, 6, "day of week")
2874
+ ];
2875
+ for (const validation of validations) {
2876
+ if (!validation.valid) {
2877
+ return validation;
2878
+ }
2879
+ }
2880
+ return { valid: true };
2881
+ } catch (error) {
2882
+ return {
2883
+ valid: false,
2884
+ error: error instanceof Error ? error.message : "Invalid cron expression"
2885
+ };
2886
+ }
2887
+ }
2888
+ function validateCronField(field, min, max, fieldName) {
2889
+ if (field === "*") return { valid: true };
2890
+ if (field.startsWith("*/")) {
2891
+ const step = parseInt(field.substring(2), 10);
2892
+ if (isNaN(step) || step <= 0) {
2893
+ return {
2894
+ valid: false,
2895
+ error: `Invalid step value in ${fieldName}: ${field}`
2896
+ };
2897
+ }
2898
+ return { valid: true };
2899
+ }
2900
+ if (field.includes("-")) {
2901
+ const [start, end] = field.split("-").map((v) => parseInt(v, 10));
2902
+ if (isNaN(start) || isNaN(end) || start < min || end > max || start > end) {
2903
+ return {
2904
+ valid: false,
2905
+ error: `Invalid range in ${fieldName}: ${field} (must be ${min}-${max})`
2906
+ };
2907
+ }
2908
+ return { valid: true };
2909
+ }
2910
+ if (field.includes(",")) {
2911
+ const values = field.split(",").map((v) => parseInt(v.trim(), 10));
2912
+ for (const val of values) {
2913
+ if (isNaN(val) || val < min || val > max) {
2914
+ return {
2915
+ valid: false,
2916
+ error: `Invalid value in ${fieldName} list: ${val} (must be ${min}-${max})`
2917
+ };
2918
+ }
2919
+ }
2920
+ return { valid: true };
2921
+ }
2922
+ const value = parseInt(field, 10);
2923
+ if (isNaN(value) || value < min || value > max) {
2924
+ return {
2925
+ valid: false,
2926
+ error: `Invalid ${fieldName}: ${field} (must be ${min}-${max})`
2927
+ };
2928
+ }
2929
+ return { valid: true };
2930
+ }
2931
+ function describeCronExpression(cronString) {
2932
+ try {
2933
+ const expr = parseCronExpression(cronString);
2934
+ if (cronString === "* * * * *") return "Every minute";
2935
+ if (cronString === "0 * * * *") return "Every hour";
2936
+ if (cronString === "0 0 * * *") return "Daily at midnight";
2937
+ if (cronString === "0 0 * * 0") return "Weekly on Sunday at midnight";
2938
+ if (cronString === "0 0 1 * *") return "Monthly on the 1st at midnight";
2939
+ if (cronString === "0 0 1 1 *") return "Yearly on January 1st at midnight";
2940
+ if (expr.minute.startsWith("*/")) {
2941
+ const step = expr.minute.substring(2);
2942
+ return `Every ${step} minute${step === "1" ? "" : "s"}`;
2943
+ }
2944
+ if (expr.hour.startsWith("*/") && expr.minute === "0") {
2945
+ const step = expr.hour.substring(2);
2946
+ return `Every ${step} hour${step === "1" ? "" : "s"}`;
2947
+ }
2948
+ if (expr.dayOfWeek === "1-5" && expr.hour === "9" && expr.minute === "0") {
2949
+ return "Every weekday at 9:00 AM";
2950
+ }
2951
+ let description = "At ";
2952
+ if (expr.minute !== "*" && expr.hour !== "*") {
2953
+ const hour = parseInt(expr.hour, 10);
2954
+ const minute = parseInt(expr.minute, 10);
2955
+ const ampm = hour >= 12 ? "PM" : "AM";
2956
+ const hour12 = hour % 12 || 12;
2957
+ description += `${hour12}:${minute.toString().padStart(2, "0")} ${ampm}`;
2958
+ } else if (expr.minute !== "*") {
2959
+ description += `minute ${expr.minute}`;
2960
+ } else if (expr.hour !== "*") {
2961
+ description += `hour ${expr.hour}`;
2962
+ }
2963
+ if (expr.dayOfMonth !== "*") {
2964
+ description += ` on day ${expr.dayOfMonth}`;
2965
+ }
2966
+ if (expr.dayOfWeek !== "*") {
2967
+ const days = [
2968
+ "Sunday",
2969
+ "Monday",
2970
+ "Tuesday",
2971
+ "Wednesday",
2972
+ "Thursday",
2973
+ "Friday",
2974
+ "Saturday"
2975
+ ];
2976
+ if (expr.dayOfWeek.includes("-")) {
2977
+ const [start, end] = expr.dayOfWeek.split("-").map((v) => parseInt(v, 10));
2978
+ description += ` on ${days[start]} through ${days[end]}`;
2979
+ } else {
2980
+ const day = parseInt(expr.dayOfWeek, 10);
2981
+ description += ` on ${days[day]}`;
2982
+ }
2983
+ }
2984
+ if (expr.month !== "*") {
2985
+ const months = [
2986
+ "January",
2987
+ "February",
2988
+ "March",
2989
+ "April",
2990
+ "May",
2991
+ "June",
2992
+ "July",
2993
+ "August",
2994
+ "September",
2995
+ "October",
2996
+ "November",
2997
+ "December"
2998
+ ];
2999
+ const month = parseInt(expr.month, 10);
3000
+ description += ` in ${months[month - 1]}`;
3001
+ }
3002
+ return description;
3003
+ } catch (error) {
3004
+ return "Invalid cron expression";
3005
+ }
3006
+ }
3007
+ function getCronScheduleInfo(cronString) {
3008
+ const validation = validateCronExpression(cronString);
3009
+ if (!validation.valid) {
3010
+ return {
3011
+ expression: parseCronExpression(
3012
+ cronString.split(/\s+/).length === 5 ? cronString : "0 0 * * *"
3013
+ ),
3014
+ description: "Invalid cron expression",
3015
+ isValid: false,
3016
+ error: validation.error
3017
+ };
3018
+ }
3019
+ return {
3020
+ expression: parseCronExpression(cronString),
3021
+ description: describeCronExpression(cronString),
3022
+ isValid: true
3023
+ };
3024
+ }
3025
+
3026
+ // src/trigger.ts
3027
+ var BUBBLE_TRIGGER_EVENTS = {
3028
+ "slack/bot_mentioned": true,
3029
+ "schedule/cron": true,
3030
+ "webhook/http": true
3031
+ };
3032
+ function isValidBubbleTriggerEvent(eventType) {
3033
+ return eventType in BUBBLE_TRIGGER_EVENTS;
3034
+ }
3035
+
3036
+ // src/storage-utils.ts
3037
+ function prepareForStorage(value, options) {
3038
+ const maxBytes = options?.maxBytes ?? 1024 * 1024;
3039
+ const previewBytes = options?.previewBytes ?? 4096;
3040
+ try {
3041
+ const json = JSON.stringify(value);
3042
+ const sizeBytes = typeof TextEncoder !== "undefined" ? new TextEncoder().encode(json).length : globalThis.Buffer?.byteLength?.(json, "utf8") ?? json.length;
3043
+ if (sizeBytes > maxBytes) {
3044
+ console.warn(
3045
+ `[prepareForStorage] Size ${sizeBytes} > ${maxBytes}. Storing preview only.`
3046
+ );
3047
+ const previewBuffer = json.slice(0, previewBytes) + "....truncated due to size limit";
3048
+ return {
3049
+ truncated: true,
3050
+ preview: previewBuffer,
3051
+ sizeBytes
3052
+ };
3053
+ }
3054
+ return {
3055
+ truncated: false,
3056
+ preview: value,
3057
+ sizeBytes: 0
3058
+ };
3059
+ } catch (_err) {
3060
+ console.warn(
3061
+ "[prepareForStorage] Failed to serialize value for size check. Storing preview only."
3062
+ );
3063
+ return {
3064
+ truncated: true,
3065
+ preview: "",
3066
+ sizeBytes: 0
3067
+ };
3068
+ }
3069
+ }
3070
+ function cleanUpObjectForDisplayAndStorage(obj, maxBytes = 1024 * 1024) {
3071
+ const storageResult = prepareForStorage(obj, { maxBytes });
3072
+ if (storageResult.truncated) {
3073
+ return storageResult.preview;
3074
+ }
3075
+ return obj;
3076
+ }
3077
+
3078
+ // src/param-utils.ts
3079
+ function sanitizeParams(params) {
3080
+ return Object.fromEntries(
3081
+ Object.entries(params).filter(([key]) => !key.startsWith("credentials"))
3082
+ );
3083
+ }
3084
+
3085
+ // src/error-enhancer.ts
3086
+ function enhanceErrorMessage(errorMessage) {
3087
+ let enhanced = errorMessage;
3088
+ const triggerRegistryPattern = /does not satisfy the constraint 'keyof BubbleTriggerEventRegistry'/;
3089
+ if (triggerRegistryPattern.test(enhanced)) {
3090
+ const availableKeys = Object.keys(BUBBLE_TRIGGER_EVENTS);
3091
+ const hint = `
3092
+ Available trigger event types: ${availableKeys.map((k) => `'${k}'`).join(", ")}`;
3093
+ enhanced = enhanced + hint;
3094
+ }
3095
+ const keyofTriggerPattern = /Type '([^']+)' does not satisfy the constraint 'keyof BubbleTriggerEventRegistry'/;
3096
+ if (keyofTriggerPattern.test(enhanced) && !enhanced.includes("Available trigger event types")) {
3097
+ const availableKeys = Object.keys(BUBBLE_TRIGGER_EVENTS);
3098
+ const hint = `
3099
+ Available trigger event types: ${availableKeys.map((k) => `'${k}'`).join(", ")}`;
3100
+ enhanced = enhanced + hint;
3101
+ }
3102
+ const bubbleErrorPattern = /BubbleError/;
3103
+ if (bubbleErrorPattern.test(enhanced)) {
3104
+ const hint = `
3105
+ BubbleLogger.error() method signature:
3106
+ - this.logger?.error(message: string, error?: BubbleError, metadata?: Partial<LogMetadata>)
3107
+
3108
+ IMPORTANT: The second parameter must be a BubbleError instance, NOT a string!
3109
+
3110
+ \u274C INCORRECT: this.logger?.error("msg1", "msg2")
3111
+ \u274C INCORRECT: this.logger?.error(msg1, msg2) // where msg2 is a string
3112
+
3113
+ \u2705 CORRECT: this.logger?.error("Error message")
3114
+ \u2705 CORRECT: this.logger?.error("Error message", bubbleError)
3115
+ \u2705 CORRECT: this.logger?.error("Error message", bubbleError, { variableId: 1 })
3116
+
3117
+ BubbleError minimal interface:
3118
+ - message: string (from Error)
3119
+ - variableId?: number
3120
+ - bubbleName?: string
3121
+
3122
+ Creating a BubbleError:
3123
+ - new BubbleError("Error message", { variableId?: number, bubbleName?: string })
3124
+ - new BubbleValidationError("Validation failed", { variableId?: number, bubbleName?: string, validationErrors?: string[] })
3125
+ - new BubbleExecutionError("Execution failed", { variableId?: number, bubbleName?: string, executionPhase?: 'instantiation' | 'execution' | 'validation' })
3126
+
3127
+ LogMetadata minimal interface (for metadata parameter):
3128
+ - variableId?: number
3129
+ - bubbleName?: string
3130
+ - lineNumber?: number
3131
+ - additionalData?: Record<string, unknown>
3132
+
3133
+ Example usage:
3134
+ - this.logger?.error("Bubble execution failed", new BubbleError("Details", { variableId: 1, bubbleName: "MyBubble" }))
3135
+ - this.logger?.error("Error occurred", undefined, { variableId: 1, additionalData: { custom: "data" } })`;
3136
+ enhanced = enhanced + hint;
3137
+ }
3138
+ const logMetadataPropertyPattern = /'(\w+)' does not exist in type '(?:Partial<)?LogMetadata(?:>)?'/;
3139
+ const logMetadataMatch = enhanced.match(logMetadataPropertyPattern);
3140
+ if (logMetadataMatch) {
3141
+ const [, propertyName] = logMetadataMatch;
3142
+ const hint = `
3143
+ LogMetadata does not support '${propertyName}'. Available properties:
3144
+ - additionalData?: Record<string, unknown>`;
3145
+ enhanced = enhanced + hint;
3146
+ }
3147
+ const logMetadataTypePattern = /LogMetadata/;
3148
+ if (logMetadataTypePattern.test(enhanced) && !enhanced.includes("Available properties:")) {
3149
+ const hint = `
3150
+ LogMetadata interface properties:
3151
+ - additionalData?: Record<string, unknown> (optional)
3152
+
3153
+ To add custom data, use the additionalData property.`;
3154
+ enhanced = enhanced + hint;
3155
+ }
3156
+ const noExportedMemberPattern = /Module '([^']+)' has no exported member '(\w+)'/;
3157
+ const noExportedMemberMatch = enhanced.match(noExportedMemberPattern);
3158
+ if (noExportedMemberMatch) {
3159
+ const [, moduleName, memberName] = noExportedMemberMatch;
3160
+ const hint = `
3161
+ '${memberName}' is not exported from '${moduleName}'. Please remove it from your import statement or check the module's exports for the correct name.`;
3162
+ enhanced = enhanced + hint;
3163
+ }
3164
+ return enhanced;
3165
+ }
3166
+
3167
+ // src/hash-utils.ts
3168
+ function hashToVariableId(input) {
3169
+ let hash = 2166136261;
3170
+ for (let i = 0; i < input.length; i++) {
3171
+ hash ^= input.charCodeAt(i);
3172
+ hash = hash * 16777619 >>> 0;
3173
+ }
3174
+ const mapped = 1e5 + hash % 9e5;
3175
+ return mapped;
3176
+ }
3177
+ function buildCallSiteKey(methodName, invocationIndex) {
3178
+ return `${methodName}#${invocationIndex}`;
3179
+ }
3180
+ export {
3181
+ AssistantMessageSchema,
3182
+ AvailableModels,
3183
+ BROWSER_SESSION_PROVIDERS,
3184
+ BUBBLE_CREDENTIAL_OPTIONS,
3185
+ BUBBLE_NAMES_WITH_CONTEXT_INJECTION,
3186
+ BUBBLE_TRIGGER_EVENTS,
3187
+ BubbleDependencySpecSchema,
3188
+ BubbleNodeTypeSchema,
3189
+ BubbleParameterSchema,
3190
+ BubbleParameterType,
3191
+ BubbleParameterTypeSchema,
3192
+ BubbleWorkflowNodeSchema,
3193
+ COFFEE_DEFAULT_MODEL,
3194
+ COFFEE_MAX_ITERATIONS,
3195
+ COFFEE_MAX_QUESTIONS,
3196
+ CREDENTIAL_CONFIGURATION_MAP,
3197
+ CREDENTIAL_ENV_MAP,
3198
+ CREDENTIAL_TYPE_CONFIG,
3199
+ ClarificationChoiceSchema,
3200
+ ClarificationQuestionSchema,
3201
+ ClarificationRequestMessageSchema,
3202
+ ClarificationResponseMessageSchema,
3203
+ CodeBlockWorkflowNodeSchema,
3204
+ CoffeeAgentOutputSchema,
3205
+ CoffeeClarificationEventSchema,
3206
+ CoffeeContextAnswerSchema,
3207
+ CoffeeContextEventSchema,
3208
+ CoffeeContextRequestInfoSchema,
3209
+ CoffeeMessageSchema,
3210
+ CoffeePlanEventSchema,
3211
+ CoffeeRequestExternalContextEventSchema,
3212
+ CoffeeRequestSchema,
3213
+ CoffeeResponseSchema,
3214
+ ContextRequestMessageSchema,
3215
+ ContextResponseMessageSchema,
3216
+ ControlFlowWorkflowNodeSchema,
3217
+ ConversationMessageSchema,
3218
+ CredentialType,
3219
+ DependencyGraphNodeSchema,
3220
+ ExecutionSummarySchema,
3221
+ FunctionCallWorkflowNodeSchema,
3222
+ GenerationResultSchema,
3223
+ LocationSchema,
3224
+ MilkTeaAgentOutputSchema,
3225
+ MilkTeaRequestSchema,
3226
+ MilkTeaResponseSchema,
3227
+ MockDataGenerator,
3228
+ OAUTH_PROVIDERS,
3229
+ OPTIONAL_CREDENTIALS,
3230
+ PEARL_DEFAULT_MODEL,
3231
+ ParallelExecutionWorkflowNodeSchema,
3232
+ ParsedBubbleSchema,
3233
+ ParsedBubbleWithInfoSchema,
3234
+ ParsedWorkflowSchema,
3235
+ PearlAgentOutputSchema,
3236
+ PearlRequestSchema,
3237
+ PearlResponseSchema,
3238
+ PlanApprovalMessageSchema,
3239
+ PlanMessageSchema,
3240
+ PlanStepSchema,
3241
+ RECOMMENDED_MODELS,
3242
+ RICE_DEFAULT_MODEL,
3243
+ ReturnWorkflowNodeSchema,
3244
+ RiceEvaluationResultSchema,
3245
+ RiceIssueTypeSchema,
3246
+ RiceRequestSchema,
3247
+ RiceResponseSchema,
3248
+ SYSTEM_CREDENTIALS,
3249
+ ServiceUsageSchema,
3250
+ SystemMessageSchema,
3251
+ TOOL_CALL_TO_DISCARD,
3252
+ ToolResultMessageSchema,
3253
+ TransformationFunctionWorkflowNodeSchema,
3254
+ TryCatchWorkflowNodeSchema,
3255
+ UserMessageSchema,
3256
+ VariableDeclarationBlockNodeSchema,
3257
+ WorkflowNodeSchema,
3258
+ WorkflowNodeTypeSchema,
3259
+ activateBubbleFlowResponseSchema,
3260
+ browserbaseSessionCompleteRequestSchema,
3261
+ browserbaseSessionCompleteResponseSchema,
3262
+ browserbaseSessionCreateRequestSchema,
3263
+ browserbaseSessionCreateResponseSchema,
3264
+ browserbaseSessionReopenRequestSchema,
3265
+ browserbaseSessionReopenResponseSchema,
3266
+ bubbleFlowDetailsResponseSchema,
3267
+ bubbleFlowExecutionDetailSchema,
3268
+ bubbleFlowExecutionSchema,
3269
+ bubbleFlowListItemSchema,
3270
+ bubbleFlowListResponseSchema,
3271
+ bubbleFlowTemplateResponseSchema,
3272
+ buildCallSiteKey,
3273
+ cleanUpObjectForDisplayAndStorage,
3274
+ createBubbleFlowResponseSchema,
3275
+ createBubbleFlowSchema,
3276
+ createCredentialResponseSchema,
3277
+ createCredentialSchema,
3278
+ createEmptyBubbleFlowResponseSchema,
3279
+ createEmptyBubbleFlowSchema,
3280
+ credentialResponseSchema,
3281
+ databaseMetadataSchema,
3282
+ describeCronExpression,
3283
+ enhanceErrorMessage,
3284
+ errorResponseSchema,
3285
+ executeBubbleFlowResponseSchema,
3286
+ executeBubbleFlowSchema,
3287
+ generateBubbleFlowCodeResponseSchema,
3288
+ generateBubbleFlowCodeSchema,
3289
+ generateBubbleFlowTemplateSchema,
3290
+ generateCredentialsSummary,
3291
+ generateDocumentGenerationTemplateSchema,
3292
+ getBrowserSessionProvider,
3293
+ getCronScheduleInfo,
3294
+ getOAuthProvider,
3295
+ getScopeDescriptions,
3296
+ hackathonOfferSchema,
3297
+ hashToVariableId,
3298
+ isBrowserSessionCredential,
3299
+ isOAuthCredential,
3300
+ isValidBubbleTriggerEvent,
3301
+ joinWaitlistResponseSchema,
3302
+ joinWaitlistSchema,
3303
+ listBubbleFlowExecutionsResponseSchema,
3304
+ oauthCallbackRequestSchema,
3305
+ oauthInitiateRequestSchema,
3306
+ oauthInitiateResponseSchema,
3307
+ oauthRevokeResponseSchema,
3308
+ oauthTokenRefreshResponseSchema,
3309
+ parseCronExpression,
3310
+ prepareForStorage,
3311
+ redeemCouponRequestSchema,
3312
+ redeemCouponResponseSchema,
3313
+ sanitizeParams,
3314
+ slackUrlVerificationResponseSchema,
3315
+ slackUrlVerificationSchema,
3316
+ specialOfferSchema,
3317
+ subscriptionStatusResponseSchema,
3318
+ successMessageResponseSchema,
3319
+ updateBubbleFlowNameSchema,
3320
+ updateBubbleFlowParametersSchema,
3321
+ updateCredentialResponseSchema,
3322
+ updateCredentialSchema,
3323
+ validateBubbleFlowCodeResponseSchema,
3324
+ validateBubbleFlowCodeSchema,
3325
+ validateCronExpression,
3326
+ webhookExecutionResponseSchema,
3327
+ webhookResponseSchema
3328
+ };
30
3329
  //# sourceMappingURL=index.js.map