@bubblelab/bubble-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -0
- package/dist/bubble-bundle.d.ts +2021 -0
- package/dist/bubble-factory.d.ts +161 -0
- package/dist/bubble-factory.d.ts.map +1 -0
- package/dist/bubble-factory.js +426 -0
- package/dist/bubble-factory.js.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts +19 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.js +23 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts +15 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js +63 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js.map +1 -0
- package/dist/bubble-flow/sample/error-ts.d.ts +23 -0
- package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -0
- package/dist/bubble-flow/sample/error-ts.js +31 -0
- package/dist/bubble-flow/sample/error-ts.js.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts +10 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.js +13 -0
- package/dist/bubble-flow/sample/sanitytest.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts +19 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js +23 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts +10 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.js +18 -0
- package/dist/bubble-flow/sample/simple-webhook.js.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +29 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +150 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts +10 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.js +59 -0
- package/dist/bubble-flow/sample/slack-v0.1.js.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts +10 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.js +59 -0
- package/dist/bubble-flow/sample/slackagenttest.js.map +1 -0
- package/dist/bubble-trigger/index.d.ts +2 -0
- package/dist/bubble-trigger/index.d.ts.map +1 -0
- package/dist/bubble-trigger/index.js +2 -0
- package/dist/bubble-trigger/index.js.map +1 -0
- package/dist/bubble-trigger/types.d.ts +87 -0
- package/dist/bubble-trigger/types.d.ts.map +1 -0
- package/dist/bubble-trigger/types.js +14 -0
- package/dist/bubble-trigger/types.js.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts +428 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.js +881 -0
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -0
- package/dist/bubbles/service-bubble/gmail.d.ts +3073 -0
- package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/gmail.js +908 -0
- package/dist/bubbles/service-bubble/gmail.js.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts +3377 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.js +527 -0
- package/dist/bubbles/service-bubble/google-calendar.js.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts +1152 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.js +943 -0
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts +1811 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.js +904 -0
- package/dist/bubbles/service-bubble/google-sheets.js.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts +74 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.js +67 -0
- package/dist/bubbles/service-bubble/hello-world.js.map +1 -0
- package/dist/bubbles/service-bubble/http.d.ts +134 -0
- package/dist/bubbles/service-bubble/http.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/http.js +184 -0
- package/dist/bubbles/service-bubble/http.js.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts +180 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.js +448 -0
- package/dist/bubbles/service-bubble/postgresql.js.map +1 -0
- package/dist/bubbles/service-bubble/resend.d.ts +301 -0
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/resend.js +253 -0
- package/dist/bubbles/service-bubble/resend.js.map +1 -0
- package/dist/bubbles/service-bubble/slack.d.ts +5869 -0
- package/dist/bubbles/service-bubble/slack.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/slack.js +1536 -0
- package/dist/bubbles/service-bubble/slack.js.map +1 -0
- package/dist/bubbles/service-bubble/storage.d.ts +571 -0
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/storage.js +504 -0
- package/dist/bubbles/service-bubble/storage.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +308 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +285 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +416 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js +570 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +99 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +645 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +112 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js +82 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +413 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +327 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +122 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js +343 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +131 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js +147 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts +257 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.js +238 -0
- package/dist/bubbles/tool-bubble/tool-template.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts +8 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js +65 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts +125 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js +169 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +218 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js +255 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js +175 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +228 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js +214 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js +155 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +114 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +777 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts +97 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js +327 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +303 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js +297 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts +157 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js +310 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +543 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js +628 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +679 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js +604 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +1011 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +841 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +883 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +781 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +300 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +508 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +731 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +690 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +401 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +382 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts +144 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js +124 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/BubbleLogger.d.ts +146 -0
- package/dist/logging/BubbleLogger.d.ts.map +1 -0
- package/dist/logging/BubbleLogger.js +472 -0
- package/dist/logging/BubbleLogger.js.map +1 -0
- package/dist/logging/StreamingBubbleLogger.d.ts +85 -0
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -0
- package/dist/logging/StreamingBubbleLogger.js +340 -0
- package/dist/logging/StreamingBubbleLogger.js.map +1 -0
- package/dist/types/ai-models.d.ts +4 -0
- package/dist/types/ai-models.d.ts.map +1 -0
- package/dist/types/ai-models.js +14 -0
- package/dist/types/ai-models.js.map +1 -0
- package/dist/types/available-tools.d.ts +4 -0
- package/dist/types/available-tools.d.ts.map +1 -0
- package/dist/types/available-tools.js +19 -0
- package/dist/types/available-tools.js.map +1 -0
- package/dist/types/base-bubble-class.d.ts +47 -0
- package/dist/types/base-bubble-class.d.ts.map +1 -0
- package/dist/types/base-bubble-class.js +212 -0
- package/dist/types/base-bubble-class.js.map +1 -0
- package/dist/types/bubble-errors.d.ts +44 -0
- package/dist/types/bubble-errors.d.ts.map +1 -0
- package/dist/types/bubble-errors.js +51 -0
- package/dist/types/bubble-errors.js.map +1 -0
- package/dist/types/bubble.d.ts +73 -0
- package/dist/types/bubble.d.ts.map +1 -0
- package/dist/types/bubble.js +2 -0
- package/dist/types/bubble.js.map +1 -0
- package/dist/types/credentials.d.ts +6 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +6 -0
- package/dist/types/credentials.js.map +1 -0
- package/dist/types/service-bubble-class.d.ts +31 -0
- package/dist/types/service-bubble-class.d.ts.map +1 -0
- package/dist/types/service-bubble-class.js +36 -0
- package/dist/types/service-bubble-class.js.map +1 -0
- package/dist/types/streaming-events.d.ts +18 -0
- package/dist/types/streaming-events.d.ts.map +1 -0
- package/dist/types/streaming-events.js +5 -0
- package/dist/types/streaming-events.js.map +1 -0
- package/dist/types/tool-bubble-class.d.ts +19 -0
- package/dist/types/tool-bubble-class.d.ts.map +1 -0
- package/dist/types/tool-bubble-class.js +48 -0
- package/dist/types/tool-bubble-class.js.map +1 -0
- package/dist/types/workflow-bubble-class.d.ts +25 -0
- package/dist/types/workflow-bubble-class.d.ts.map +1 -0
- package/dist/types/workflow-bubble-class.js +30 -0
- package/dist/types/workflow-bubble-class.js.map +1 -0
- package/dist/utils/bubbleflow-parser.d.ts +32 -0
- package/dist/utils/bubbleflow-parser.d.ts.map +1 -0
- package/dist/utils/bubbleflow-parser.js +332 -0
- package/dist/utils/bubbleflow-parser.js.map +1 -0
- package/dist/utils/bubbleflow-validation.d.ts +9 -0
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -0
- package/dist/utils/bubbleflow-validation.js +116 -0
- package/dist/utils/bubbleflow-validation.js.map +1 -0
- package/dist/utils/json-parsing.d.ts +20 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +394 -0
- package/dist/utils/json-parsing.js.map +1 -0
- package/dist/utils/mock-data-generator.d.ts +43 -0
- package/dist/utils/mock-data-generator.d.ts.map +1 -0
- package/dist/utils/mock-data-generator.js +312 -0
- package/dist/utils/mock-data-generator.js.map +1 -0
- package/dist/utils/param-helper.d.ts +2 -0
- package/dist/utils/param-helper.d.ts.map +1 -0
- package/dist/utils/param-helper.js +5 -0
- package/dist/utils/param-helper.js.map +1 -0
- package/dist/utils/source-bubble-parser.d.ts +31 -0
- package/dist/utils/source-bubble-parser.d.ts.map +1 -0
- package/dist/utils/source-bubble-parser.js +231 -0
- package/dist/utils/source-bubble-parser.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { randomUUID } from 'crypto';
|
|
3
|
+
import { MockDataGenerator } from '@bubblelab/shared-schemas';
|
|
4
|
+
import { BubbleValidationError, BubbleExecutionError, } from './bubble-errors.js';
|
|
5
|
+
import { sanitizeParams } from '../utils/param-helper.js';
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for all bubble types
|
|
8
|
+
* Implements common properties and methods defined in IBubble interface
|
|
9
|
+
*/
|
|
10
|
+
export class BaseBubble {
|
|
11
|
+
name;
|
|
12
|
+
schema;
|
|
13
|
+
resultSchema;
|
|
14
|
+
shortDescription;
|
|
15
|
+
longDescription;
|
|
16
|
+
alias;
|
|
17
|
+
params;
|
|
18
|
+
context;
|
|
19
|
+
previousResult;
|
|
20
|
+
constructor(params, context) {
|
|
21
|
+
// Use static properties from the class - typed as required static metadata
|
|
22
|
+
const ctor = this.constructor;
|
|
23
|
+
this.name = ctor.bubbleName;
|
|
24
|
+
this.schema = ctor.schema;
|
|
25
|
+
this.resultSchema = ctor.resultSchema;
|
|
26
|
+
this.shortDescription = ctor.shortDescription;
|
|
27
|
+
this.longDescription = ctor.longDescription;
|
|
28
|
+
this.alias = ctor.alias;
|
|
29
|
+
try {
|
|
30
|
+
this.params = this.schema.parse(params);
|
|
31
|
+
// Enrich context with child variableId/currentUniqueId if dependencyGraph is provided
|
|
32
|
+
if (context && context.dependencyGraph && context.currentUniqueId) {
|
|
33
|
+
console.debug('Computing child context');
|
|
34
|
+
const next = this.computeChildContext(context);
|
|
35
|
+
this.context = next;
|
|
36
|
+
console.debug('Computed child context unique id:', this.context?.currentUniqueId);
|
|
37
|
+
//Prnt the var id of the computed child context
|
|
38
|
+
console.debug('Computed child context variable id:', this.context?.variableId);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.context = context;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
// Parse Zod validation errors to make them more user-friendly
|
|
46
|
+
if (error instanceof z.ZodError) {
|
|
47
|
+
const errorMessages = error.errors.map((err) => {
|
|
48
|
+
const path = err.path.length > 0 ? `${err.path.join('.')}: ` : '';
|
|
49
|
+
return `${path}${err.message}`;
|
|
50
|
+
});
|
|
51
|
+
throw new BubbleValidationError(`Parameter validation failed: ${errorMessages.join(', ')}`, {
|
|
52
|
+
variableId: context?.variableId,
|
|
53
|
+
bubbleName: ctor.bubbleName,
|
|
54
|
+
validationErrors: errorMessages,
|
|
55
|
+
cause: error,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
throw new BubbleValidationError(`Parameter validation failed: ${String(error)}`, {
|
|
59
|
+
variableId: context?.variableId,
|
|
60
|
+
bubbleName: ctor.bubbleName,
|
|
61
|
+
cause: error instanceof Error ? error : undefined,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compute child context based on dependency graph and current unique id.
|
|
67
|
+
* Finds the node matching currentUniqueId, then determines this child's unique id as
|
|
68
|
+
* `${currentUniqueId}.${this.name}#k` for the next ordinal k, and assigns the variableId from
|
|
69
|
+
* the dependency graph if present, otherwise keeps parent's variableId.
|
|
70
|
+
*/
|
|
71
|
+
computeChildContext(parentContext) {
|
|
72
|
+
const graph = parentContext.dependencyGraph;
|
|
73
|
+
const currentId = parentContext.currentUniqueId || '';
|
|
74
|
+
if (!graph)
|
|
75
|
+
return parentContext;
|
|
76
|
+
// Depth-first search to find node by uniqueId
|
|
77
|
+
const findByUniqueId = (node, target) => {
|
|
78
|
+
if (node.uniqueId === target)
|
|
79
|
+
return node;
|
|
80
|
+
for (const child of node.dependencies || []) {
|
|
81
|
+
const found = findByUniqueId(child, target);
|
|
82
|
+
if (found)
|
|
83
|
+
return found;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
const parentNode = currentId ? findByUniqueId(graph, currentId) : graph;
|
|
88
|
+
// If the current bubble matches the node at currentUniqueId, don't advance; keep IDs from that node
|
|
89
|
+
if (parentNode && parentNode.name === this.name) {
|
|
90
|
+
const sameNodeVarId = parentNode.variableId ??
|
|
91
|
+
parentContext.variableId;
|
|
92
|
+
return {
|
|
93
|
+
...parentContext,
|
|
94
|
+
variableId: sameNodeVarId,
|
|
95
|
+
currentUniqueId: currentId,
|
|
96
|
+
__uniqueIdCounters__: { ...(parentContext.__uniqueIdCounters__ || {}) },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Determine this bubble's ordinal under the parent using a counter map
|
|
100
|
+
const children = parentNode?.dependencies || [];
|
|
101
|
+
const counterKey = `${currentId || 'ROOT'}|${this.name}`;
|
|
102
|
+
const counters = { ...(parentContext.__uniqueIdCounters__ || {}) };
|
|
103
|
+
const ordinal = (counters[counterKey] || 0) + 1;
|
|
104
|
+
counters[counterKey] = ordinal;
|
|
105
|
+
// Try to select the nth child by name for an exact uniqueId match
|
|
106
|
+
const sameNameChildren = children.filter((c) => c.name === this.name);
|
|
107
|
+
const selectedChild = sameNameChildren[ordinal - 1];
|
|
108
|
+
const childUniqueId = selectedChild?.uniqueId ||
|
|
109
|
+
(currentId
|
|
110
|
+
? `${currentId}.${this.name}#${ordinal}`
|
|
111
|
+
: `${this.name}#${ordinal}`);
|
|
112
|
+
// Try to find a matching child node to get variableId; fallback to parent's
|
|
113
|
+
const matchingChild = selectedChild ||
|
|
114
|
+
children.find((c) => c.uniqueId === childUniqueId || c.name === this.name);
|
|
115
|
+
const childVariableId = (matchingChild && typeof matchingChild.variableId === 'number'
|
|
116
|
+
? matchingChild.variableId
|
|
117
|
+
: parentContext.variableId) || parentContext.variableId;
|
|
118
|
+
return {
|
|
119
|
+
...parentContext,
|
|
120
|
+
variableId: childVariableId,
|
|
121
|
+
currentUniqueId: childUniqueId,
|
|
122
|
+
__uniqueIdCounters__: counters,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
saveResult(result) {
|
|
126
|
+
this.previousResult = result;
|
|
127
|
+
}
|
|
128
|
+
clearSavedResult() {
|
|
129
|
+
this.previousResult = undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Execute the bubble - just runs the action
|
|
133
|
+
*/
|
|
134
|
+
async action() {
|
|
135
|
+
const logger = this.context?.logger;
|
|
136
|
+
logger?.logBubbleExecution(this.context?.variableId ?? -999, this.name, this.name, sanitizeParams(this.params));
|
|
137
|
+
// If we have a saved result, return it instead of executing
|
|
138
|
+
if (this.previousResult) {
|
|
139
|
+
logger?.debug(`[BubbleClass - ${this.name}] Returning saved result`);
|
|
140
|
+
// Narrow saved base result to current TResult by keeping metadata and
|
|
141
|
+
// treating data as unknown (caller side should only read known fields)
|
|
142
|
+
const savedResult = this.previousResult;
|
|
143
|
+
// Log bubble execution completion for saved result
|
|
144
|
+
logger?.logBubbleExecutionComplete(this.context?.variableId ?? -999, this.name, this.name, savedResult);
|
|
145
|
+
return savedResult;
|
|
146
|
+
}
|
|
147
|
+
const result = await this.performAction(this.context);
|
|
148
|
+
// Validate result if schema is provided
|
|
149
|
+
if (this.resultSchema) {
|
|
150
|
+
try {
|
|
151
|
+
const validatedResult = this.resultSchema.parse(result);
|
|
152
|
+
const finalResult = {
|
|
153
|
+
success: result.success,
|
|
154
|
+
// For data we strip out the success and error fields
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
+
data: (({ success: _success, error: _error, ...rest }) => rest)(validatedResult),
|
|
157
|
+
executionId: randomUUID(),
|
|
158
|
+
error: validatedResult.error || '',
|
|
159
|
+
timestamp: new Date(),
|
|
160
|
+
};
|
|
161
|
+
// Log bubble execution completion
|
|
162
|
+
logger?.logBubbleExecutionComplete(this.context?.variableId ?? -999, this.name, this.name, finalResult);
|
|
163
|
+
if (!finalResult.success) {
|
|
164
|
+
logger?.warn(`[${this.name}] Execution did not succeed: ${finalResult.error}. The flow will continue to run unless you manually catch and handle the error.`);
|
|
165
|
+
}
|
|
166
|
+
return finalResult;
|
|
167
|
+
}
|
|
168
|
+
catch (validationError) {
|
|
169
|
+
// Throw execution error for result validation failures
|
|
170
|
+
const errorMessage = validationError instanceof z.ZodError
|
|
171
|
+
? `Result schema validation failed: ${validationError.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`
|
|
172
|
+
: `Result validation failed: ${validationError instanceof Error ? validationError.message : 'Unknown validation error'}`;
|
|
173
|
+
throw new BubbleExecutionError(errorMessage, {
|
|
174
|
+
variableId: this.context?.variableId,
|
|
175
|
+
bubbleName: this.name,
|
|
176
|
+
executionPhase: 'validation',
|
|
177
|
+
cause: validationError instanceof Error ? validationError : undefined,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// No result schema defined - proceed without validation
|
|
182
|
+
const finalResult = {
|
|
183
|
+
success: result.success,
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
185
|
+
data: (({ success: _success, error: _error, ...rest }) => rest)(result),
|
|
186
|
+
error: result.error || '',
|
|
187
|
+
executionId: randomUUID(),
|
|
188
|
+
timestamp: new Date(),
|
|
189
|
+
};
|
|
190
|
+
if (!result.success) {
|
|
191
|
+
logger?.error(`[${this.name}] Execution error when performing action: ${result.error}`);
|
|
192
|
+
}
|
|
193
|
+
// Log bubble execution completion
|
|
194
|
+
logger?.logBubbleExecutionComplete(this.context?.variableId ?? -999, this.name, this.name, finalResult);
|
|
195
|
+
return finalResult;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Generate mock result data based on the result schema
|
|
199
|
+
* Useful for testing and development when you need sample data
|
|
200
|
+
*/
|
|
201
|
+
generateMockResult() {
|
|
202
|
+
return MockDataGenerator.generateMockResult(this.resultSchema);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Generate mock result with a specific seed for reproducible results
|
|
206
|
+
* Useful for consistent testing scenarios
|
|
207
|
+
*/
|
|
208
|
+
generateMockResultWithSeed(seed) {
|
|
209
|
+
return MockDataGenerator.generateMockWithSeed(this.resultSchema, seed);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=base-bubble-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-bubble-class.js","sourceRoot":"","sources":["../../src/types/base-bubble-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,oBAAoB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C,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAC7D,MAAM,CACI;YACZ,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,WAAW,EAAE,UAAU,EAAE;YACzB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,EAAE,KAAK,CACX,IAAI,IAAI,CAAC,IAAI,6CAA6C,MAAM,CAAC,KAAK,EAAE,CACzE,CAAC;QACJ,CAAC;QAED,kCAAkC;QAClC,MAAM,EAAE,0BAA0B,CAChC,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,CAAC,GAAG,EAChC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,WAAW,CACZ,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,iBAAiB,CAAC,kBAAkB,CAAU,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACH,0BAA0B,CAAC,IAAY;QACrC,OAAO,iBAAiB,CAAC,oBAAoB,CAC3C,IAAI,CAAC,YAAY,EACjB,IAAI,CACL,CAAC;IACJ,CAAC;CAMF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for bubble operations
|
|
3
|
+
* These errors carry metadata like variableId to enable better error tracking and logging
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base error class for all bubble-related errors
|
|
7
|
+
* Includes variableId and bubbleName for context tracking
|
|
8
|
+
*/
|
|
9
|
+
export declare class BubbleError extends Error {
|
|
10
|
+
readonly variableId?: number;
|
|
11
|
+
readonly bubbleName?: string;
|
|
12
|
+
constructor(message: string, options?: {
|
|
13
|
+
variableId?: number;
|
|
14
|
+
bubbleName?: string;
|
|
15
|
+
cause?: Error;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when bubble parameter validation fails
|
|
20
|
+
* Used in BaseBubble constructor when schema.parse() fails
|
|
21
|
+
*/
|
|
22
|
+
export declare class BubbleValidationError extends BubbleError {
|
|
23
|
+
readonly validationErrors?: string[];
|
|
24
|
+
constructor(message: string, options?: {
|
|
25
|
+
variableId?: number;
|
|
26
|
+
bubbleName?: string;
|
|
27
|
+
validationErrors?: string[];
|
|
28
|
+
cause?: Error;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when bubble execution fails during performAction
|
|
33
|
+
* Used in BaseBubble.action() when the operation fails
|
|
34
|
+
*/
|
|
35
|
+
export declare class BubbleExecutionError extends BubbleError {
|
|
36
|
+
readonly executionPhase?: 'instantiation' | 'execution' | 'validation';
|
|
37
|
+
constructor(message: string, options?: {
|
|
38
|
+
variableId?: number;
|
|
39
|
+
bubbleName?: string;
|
|
40
|
+
executionPhase?: 'instantiation' | 'execution' | 'validation';
|
|
41
|
+
cause?: Error;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=bubble-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble-errors.d.ts","sourceRoot":"","sources":["../../src/types/bubble-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAGlC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAiBJ;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IACpD,SAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;gBAG1C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAMJ;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,SAAgB,cAAc,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC;gBAG5E,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC;QAC9D,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAMJ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for bubble operations
|
|
3
|
+
* These errors carry metadata like variableId to enable better error tracking and logging
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base error class for all bubble-related errors
|
|
7
|
+
* Includes variableId and bubbleName for context tracking
|
|
8
|
+
*/
|
|
9
|
+
export class BubbleError extends Error {
|
|
10
|
+
variableId;
|
|
11
|
+
bubbleName;
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'BubbleError';
|
|
15
|
+
this.variableId = options?.variableId;
|
|
16
|
+
this.bubbleName = options?.bubbleName;
|
|
17
|
+
// Maintain proper stack trace for where our error was thrown (only available on V8)
|
|
18
|
+
if (Error.captureStackTrace) {
|
|
19
|
+
Error.captureStackTrace(this, this.constructor);
|
|
20
|
+
}
|
|
21
|
+
// Attach the original cause if provided
|
|
22
|
+
if (options?.cause) {
|
|
23
|
+
this.cause = options.cause;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when bubble parameter validation fails
|
|
29
|
+
* Used in BaseBubble constructor when schema.parse() fails
|
|
30
|
+
*/
|
|
31
|
+
export class BubbleValidationError extends BubbleError {
|
|
32
|
+
validationErrors;
|
|
33
|
+
constructor(message, options) {
|
|
34
|
+
super(message, options);
|
|
35
|
+
this.name = 'BubbleValidationError';
|
|
36
|
+
this.validationErrors = options?.validationErrors;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Thrown when bubble execution fails during performAction
|
|
41
|
+
* Used in BaseBubble.action() when the operation fails
|
|
42
|
+
*/
|
|
43
|
+
export class BubbleExecutionError extends BubbleError {
|
|
44
|
+
executionPhase;
|
|
45
|
+
constructor(message, options) {
|
|
46
|
+
super(message, options);
|
|
47
|
+
this.name = 'BubbleExecutionError';
|
|
48
|
+
this.executionPhase = options?.executionPhase;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=bubble-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble-errors.js","sourceRoot":"","sources":["../../src/types/bubble-errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,UAAU,CAAU;IACpB,UAAU,CAAU;IAEpC,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QAEtC,oFAAoF;QACpF,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,wCAAwC;QACxC,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACpC,gBAAgB,CAAY;IAE5C,YACE,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,CAAC;IACpD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnC,cAAc,CAAgD;IAE9E,YACE,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DatabaseMetadata, CredentialOptions, DependencyGraphNode } from '@bubblelab/shared-schemas';
|
|
3
|
+
import type { BubbleLogger } from '../logging/BubbleLogger';
|
|
4
|
+
export interface IBubble<TResult extends BubbleOperationResult = BubbleOperationResult> {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly schema: z.ZodObject<z.ZodRawShape>;
|
|
7
|
+
readonly resultSchema: z.ZodObject<z.ZodRawShape>;
|
|
8
|
+
readonly shortDescription: string;
|
|
9
|
+
readonly longDescription: string;
|
|
10
|
+
readonly alias?: string;
|
|
11
|
+
readonly type: 'service' | 'workflow' | 'tool' | 'ui' | 'infra';
|
|
12
|
+
previousResult: BubbleResult<BubbleOperationResult> | undefined;
|
|
13
|
+
action: () => Promise<BubbleResult<TResult>>;
|
|
14
|
+
saveResult: <R extends BubbleOperationResult>(result: BubbleResult<R>) => void;
|
|
15
|
+
clearSavedResult: () => void;
|
|
16
|
+
generateMockResult: () => BubbleResult<TResult>;
|
|
17
|
+
generateMockResultWithSeed: (seed: number) => BubbleResult<TResult>;
|
|
18
|
+
}
|
|
19
|
+
export interface IServiceBubble<TResult extends BubbleOperationResult = BubbleOperationResult> extends IBubble<TResult> {
|
|
20
|
+
readonly type: 'service';
|
|
21
|
+
authType?: 'oauth' | 'apikey' | 'none' | 'connection-string';
|
|
22
|
+
testCredential: () => Promise<boolean>;
|
|
23
|
+
setCredentials: (credentials: Record<string, string>) => void;
|
|
24
|
+
setParam: (paramName: string, paramValue: unknown) => void;
|
|
25
|
+
getCredentialMetadata: () => Promise<DatabaseMetadata | undefined>;
|
|
26
|
+
}
|
|
27
|
+
export interface IWorkflowBubble<TResult extends BubbleOperationResult = BubbleOperationResult> extends IBubble<TResult> {
|
|
28
|
+
readonly type: 'workflow';
|
|
29
|
+
}
|
|
30
|
+
export interface IToolBubble<TResult extends BubbleOperationResult = BubbleOperationResult> extends IBubble<TResult> {
|
|
31
|
+
readonly type: 'tool';
|
|
32
|
+
}
|
|
33
|
+
export interface IUIBubble extends IBubble {
|
|
34
|
+
readonly type: 'ui';
|
|
35
|
+
template: string;
|
|
36
|
+
}
|
|
37
|
+
export interface IInfraBubble extends IBubble {
|
|
38
|
+
readonly type: 'infra';
|
|
39
|
+
provider: 'aws' | 'gcp' | 'supabase';
|
|
40
|
+
resourceType: string;
|
|
41
|
+
}
|
|
42
|
+
export interface BubbleOperationResult {
|
|
43
|
+
success: boolean;
|
|
44
|
+
error: string;
|
|
45
|
+
}
|
|
46
|
+
export type BubbleFlowOperationResult = unknown;
|
|
47
|
+
export interface BubbleResult<T> extends BubbleOperationResult {
|
|
48
|
+
data: T;
|
|
49
|
+
executionId: string;
|
|
50
|
+
timestamp: Date;
|
|
51
|
+
}
|
|
52
|
+
export interface BubbleContext {
|
|
53
|
+
logger?: BubbleLogger;
|
|
54
|
+
variableId?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Dependency graph for the current bubble flow, used to deduce child variable IDs.
|
|
57
|
+
*/
|
|
58
|
+
dependencyGraph?: DependencyGraphNode;
|
|
59
|
+
/**
|
|
60
|
+
* The unique hierarchical id of the current bubble within the dependency graph.
|
|
61
|
+
* Root is typically something like `${bubbleName}#1`.
|
|
62
|
+
*/
|
|
63
|
+
currentUniqueId?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Internal usage counters keyed by `${currentUniqueId||'ROOT'}|${childName}` to derive next ordinal.
|
|
66
|
+
*/
|
|
67
|
+
__uniqueIdCounters__?: Record<string, number>;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
export type ServiceBubbleParams<T = unknown> = T & {
|
|
71
|
+
credentials?: CredentialOptions;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=bubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../../src/types/bubble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,WAAW,OAAO,CACtB,OAAO,SAAS,qBAAqB,GAAG,qBAAqB;IAE7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CA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,iBAAiB,CAAC;CACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble.js","sourceRoot":"","sources":["../../src/types/bubble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import CredentialType from shared schemas to maintain single source of truth
|
|
3
|
+
*/
|
|
4
|
+
import { CREDENTIAL_CONFIGURATION_MAP, CREDENTIAL_ENV_MAP } from '@bubblelab/shared-schemas';
|
|
5
|
+
export { CREDENTIAL_CONFIGURATION_MAP, CREDENTIAL_ENV_MAP };
|
|
6
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import CredentialType from shared schemas to maintain single source of truth
|
|
3
|
+
*/
|
|
4
|
+
import { CREDENTIAL_CONFIGURATION_MAP, CREDENTIAL_ENV_MAP, } from '@bubblelab/shared-schemas';
|
|
5
|
+
export { CREDENTIAL_CONFIGURATION_MAP, CREDENTIAL_ENV_MAP };
|
|
6
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BubbleOperationResult, ServiceBubbleParams, BubbleContext } from './bubble.js';
|
|
2
|
+
import { BaseBubble } from './base-bubble-class.js';
|
|
3
|
+
import type { DatabaseMetadata } from '@bubblelab/shared-schemas';
|
|
4
|
+
export declare abstract class ServiceBubble<TParams extends ServiceBubbleParams = ServiceBubbleParams, TResult extends BubbleOperationResult = BubbleOperationResult> extends BaseBubble<TParams, TResult> {
|
|
5
|
+
readonly type: "service";
|
|
6
|
+
authType?: 'oauth' | 'apikey' | 'none' | 'connection-string';
|
|
7
|
+
constructor(params: unknown, context?: BubbleContext);
|
|
8
|
+
abstract testCredential(): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Abstract method to choose the appropriate credential based on bubble parameters
|
|
11
|
+
* Should examine this.params to determine which credential to use from the injected credentials
|
|
12
|
+
* Must be implemented by all service bubbles
|
|
13
|
+
*/
|
|
14
|
+
protected abstract chooseCredential(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Abstract method to get the metadata of the credential
|
|
17
|
+
* Must be implemented by all service bubbles
|
|
18
|
+
*/
|
|
19
|
+
getCredentialMetadata(): Promise<DatabaseMetadata | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current parameters
|
|
22
|
+
*/
|
|
23
|
+
get currentParams(): TParams;
|
|
24
|
+
setCredentials(credentials: Record<string, string>): void;
|
|
25
|
+
setParam(paramName: string, paramValue: unknown): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current context
|
|
28
|
+
*/
|
|
29
|
+
get currentContext(): BubbleContext | undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=service-bubble-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-bubble-class.d.ts","sourceRoot":"","sources":["../../src/types/service-bubble-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,8BAAsB,aAAa,CACjC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,EACzD,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,CAC7D,SAAQ,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC;IACpC,SAAgB,IAAI,EAAG,SAAS,CAAU;IACnC,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,mBAAmB,CAAC;gBAExD,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa;aAIpC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAElD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAEzD;;;OAGG;IAEG,qBAAqB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAIpE;;OAEG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIlD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAKtD;;OAEG;IACH,IAAI,cAAc,IAAI,aAAa,GAAG,SAAS,CAE9C;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseBubble } from './base-bubble-class.js';
|
|
2
|
+
export class ServiceBubble extends BaseBubble {
|
|
3
|
+
type = 'service';
|
|
4
|
+
authType;
|
|
5
|
+
constructor(params, context) {
|
|
6
|
+
super(params, context);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Abstract method to get the metadata of the credential
|
|
10
|
+
* Must be implemented by all service bubbles
|
|
11
|
+
*/
|
|
12
|
+
// Optional method, only used for database bubbles
|
|
13
|
+
async getCredentialMetadata() {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the current parameters
|
|
18
|
+
*/
|
|
19
|
+
get currentParams() {
|
|
20
|
+
return this.params;
|
|
21
|
+
}
|
|
22
|
+
setCredentials(credentials) {
|
|
23
|
+
this.params.credentials = credentials;
|
|
24
|
+
}
|
|
25
|
+
setParam(paramName, paramValue) {
|
|
26
|
+
this.params[paramName] =
|
|
27
|
+
paramValue;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the current context
|
|
31
|
+
*/
|
|
32
|
+
get currentContext() {
|
|
33
|
+
return this.context;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=service-bubble-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-bubble-class.js","sourceRoot":"","sources":["../../src/types/service-bubble-class.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,MAAM,OAAgB,aAGpB,SAAQ,UAA4B;IACpB,IAAI,GAAG,SAAkB,CAAC;IACnC,QAAQ,CAAqD;IAEpE,YAAY,MAAe,EAAE,OAAuB;QAClD,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzB,CAAC;IAWD;;;OAGG;IACH,kDAAkD;IAClD,KAAK,CAAC,qBAAqB;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,cAAc,CAAC,WAAmC;QAChD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,SAAiB,EAAE,UAAmB;QAC7C,IAAI,CAAC,MAAM,CAAC,SAA0B,CAAC;YACrC,UAAoC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for streaming log events between backend and frontend
|
|
3
|
+
*/
|
|
4
|
+
export interface StreamingLogEvent {
|
|
5
|
+
type: 'log_line' | 'bubble_instantiation' | 'bubble_execution' | 'bubble_start' | 'bubble_complete' | 'execution_complete' | 'error' | 'stream_complete' | 'info' | 'warn' | 'debug' | 'trace' | 'fatal';
|
|
6
|
+
timestamp: string;
|
|
7
|
+
lineNumber?: number;
|
|
8
|
+
message: string;
|
|
9
|
+
bubbleId?: string;
|
|
10
|
+
bubbleName?: string;
|
|
11
|
+
variableName?: string;
|
|
12
|
+
additionalData?: Record<string, unknown>;
|
|
13
|
+
executionTime?: number;
|
|
14
|
+
memoryUsage?: number;
|
|
15
|
+
logLevel?: string;
|
|
16
|
+
}
|
|
17
|
+
export type StreamCallback = (event: StreamingLogEvent) => void | Promise<void>;
|
|
18
|
+
//# sourceMappingURL=streaming-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-events.d.ts","sourceRoot":"","sources":["../../src/types/streaming-events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EACA,UAAU,GACV,sBAAsB,GACtB,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,oBAAoB,GACpB,OAAO,GACP,iBAAiB,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-events.js","sourceRoot":"","sources":["../../src/types/streaming-events.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { IToolBubble, ServiceBubbleParams, BubbleContext, BubbleOperationResult, BubbleResult } from './bubble.js';
|
|
3
|
+
import { BaseBubble } from './base-bubble-class.js';
|
|
4
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
5
|
+
export interface LangGraphTool {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
schema: z.ZodSchema;
|
|
9
|
+
func<TResult extends BubbleOperationResult = BubbleOperationResult>(params: unknown): Promise<BubbleResult<TResult>>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Abstract base class for all tool bubbles that can be converted to LangGraph tools
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class ToolBubble<TParams extends ServiceBubbleParams = ServiceBubbleParams, TResult extends BubbleOperationResult = BubbleOperationResult> extends BaseBubble<TParams, TResult> implements IToolBubble<TResult> {
|
|
15
|
+
readonly type: "tool";
|
|
16
|
+
constructor(params: unknown, context?: BubbleContext);
|
|
17
|
+
static toolAgent(credentials?: Partial<Record<CredentialType, string>>, config?: Record<string, unknown>, context?: BubbleContext): LangGraphTool;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=tool-bubble-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-bubble-class.d.ts","sourceRoot":"","sources":["../../src/types/tool-bubble-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,IAAI,CAAC,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,EAChE,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,8BAAsB,UAAU,CAC5B,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,EACzD,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,CAE/D,SAAQ,UAAU,CAAC,OAAO,EAAE,OAAO,CACnC,YAAW,WAAW,CAAC,OAAO,CAAC;IAE/B,SAAgB,IAAI,EAAG,MAAM,CAAU;gBAE3B,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa;IAKpD,MAAM,CAAC,SAAS,CACd,WAAW,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,EACrD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa;CA4CjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseBubble } from './base-bubble-class.js';
|
|
3
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for all tool bubbles that can be converted to LangGraph tools
|
|
6
|
+
*/
|
|
7
|
+
export class ToolBubble extends BaseBubble {
|
|
8
|
+
type = 'tool';
|
|
9
|
+
constructor(params, context) {
|
|
10
|
+
super(params, context);
|
|
11
|
+
}
|
|
12
|
+
// Static method - returns LangChain tool with credentials injected
|
|
13
|
+
static toolAgent(credentials, config, context) {
|
|
14
|
+
// In static context, 'this' refers to the constructor/class
|
|
15
|
+
const ToolClass = this;
|
|
16
|
+
const { schema, bubbleName, shortDescription } = ToolClass;
|
|
17
|
+
if (!schema || !bubbleName || !shortDescription) {
|
|
18
|
+
throw new Error(`${ToolClass.name} must define static schema, bubbleName, and shortDescription`);
|
|
19
|
+
}
|
|
20
|
+
// Remove credentials from schema for agent use
|
|
21
|
+
// Remove config from schema for agent use
|
|
22
|
+
let agentSchema = schema;
|
|
23
|
+
if (schema.shape?.credentials) {
|
|
24
|
+
agentSchema = schema.omit({ credentials: true });
|
|
25
|
+
}
|
|
26
|
+
if (agentSchema.shape?.config) {
|
|
27
|
+
agentSchema = agentSchema.omit({ config: true });
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
name: bubbleName,
|
|
31
|
+
description: shortDescription,
|
|
32
|
+
schema: agentSchema,
|
|
33
|
+
func: async (toolParams) => {
|
|
34
|
+
// Create instance with credentials and config injected
|
|
35
|
+
const enrichedParams = {
|
|
36
|
+
...toolParams,
|
|
37
|
+
credentials,
|
|
38
|
+
config,
|
|
39
|
+
};
|
|
40
|
+
// 'this' in static context is the constructor
|
|
41
|
+
const instance = new ToolClass(enrichedParams, context);
|
|
42
|
+
// Use performAction directly to get raw result, not wrapped BubbleResult
|
|
43
|
+
return instance.action();
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=tool-bubble-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-bubble-class.js","sourceRoot":"","sources":["../../src/types/tool-bubble-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