create-bubblelab-app 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/README.md +78 -0
- package/bin/cli.js +124 -0
- package/package.json +36 -0
- package/templates/basic/.env.example +10 -0
- package/templates/basic/README.md +256 -0
- package/templates/basic/package.json +20 -0
- package/templates/basic/src/index.ts +72 -0
- package/templates/basic/src/weather-flow.ts +56 -0
- package/templates/basic/tsconfig.json +20 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Bubble Lab, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# create-bubblelab-app
|
|
2
|
+
|
|
3
|
+
The easiest way to get started with BubbleLab - the AI agent workflow framework.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Create a new BubbleLab application with one command:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx create-bubblelab-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or with your preferred package manager:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# pnpm
|
|
17
|
+
pnpm create bubblelab-app
|
|
18
|
+
|
|
19
|
+
# yarn
|
|
20
|
+
yarn create bubblelab-app
|
|
21
|
+
|
|
22
|
+
# npm
|
|
23
|
+
npm create bubblelab-app
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What You Get
|
|
27
|
+
|
|
28
|
+
The CLI will:
|
|
29
|
+
|
|
30
|
+
1. Prompt you for a project name
|
|
31
|
+
2. Let you choose a template (Weather Agent, more coming soon)
|
|
32
|
+
3. Set up a complete BubbleLab project with:
|
|
33
|
+
- TypeScript configuration
|
|
34
|
+
- Example AI agent workflow
|
|
35
|
+
- Comprehensive documentation
|
|
36
|
+
- Environment setup guide
|
|
37
|
+
|
|
38
|
+
## Templates
|
|
39
|
+
|
|
40
|
+
### Weather Agent (Recommended)
|
|
41
|
+
|
|
42
|
+
A complete example showing how to build an AI agent that:
|
|
43
|
+
|
|
44
|
+
- Uses Google Gemini AI
|
|
45
|
+
- Performs web research
|
|
46
|
+
- Handles dynamic parameters
|
|
47
|
+
- Returns structured results
|
|
48
|
+
|
|
49
|
+
Perfect for learning BubbleLab basics!
|
|
50
|
+
|
|
51
|
+
## After Creation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd your-project-name
|
|
55
|
+
|
|
56
|
+
# Set up your API keys
|
|
57
|
+
cp .env.example .env
|
|
58
|
+
# Edit .env with your keys
|
|
59
|
+
|
|
60
|
+
# Run the example
|
|
61
|
+
npm run dev
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Requirements
|
|
65
|
+
|
|
66
|
+
- Node.js 18+
|
|
67
|
+
- A Google Gemini API key (free tier available)
|
|
68
|
+
- A Firecrawl API key for web search
|
|
69
|
+
|
|
70
|
+
## Learn More
|
|
71
|
+
|
|
72
|
+
- [BubbleLab GitHub](https://github.com/bubblelabai/BubbleLab)
|
|
73
|
+
- [Documentation](https://github.com/bubblelabai/BubbleLab/tree/main/docs)
|
|
74
|
+
- [Examples](https://github.com/bubblelabai/BubbleLab/tree/main/examples)
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
Apache-2.0 Ā© Bubble Lab, Inc.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import prompts from 'prompts';
|
|
7
|
+
import pc from 'picocolors';
|
|
8
|
+
import { execSync } from 'child_process';
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
console.log(pc.cyan('\nš«§ Welcome to BubbleLab!\n'));
|
|
14
|
+
|
|
15
|
+
const response = await prompts([
|
|
16
|
+
{
|
|
17
|
+
type: 'text',
|
|
18
|
+
name: 'projectName',
|
|
19
|
+
message: 'What is your project name?',
|
|
20
|
+
initial: 'my-bubblelab-app',
|
|
21
|
+
validate: (value) =>
|
|
22
|
+
/^[a-z0-9-_]+$/.test(value)
|
|
23
|
+
? true
|
|
24
|
+
: 'Project name must contain only lowercase letters, numbers, hyphens, and underscores',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'select',
|
|
28
|
+
name: 'template',
|
|
29
|
+
message: 'Select a template:',
|
|
30
|
+
choices: [
|
|
31
|
+
{
|
|
32
|
+
title: 'Weather Agent (Recommended)',
|
|
33
|
+
value: 'basic',
|
|
34
|
+
description: 'AI agent that researches weather using web search',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
initial: 0,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'select',
|
|
41
|
+
name: 'packageManager',
|
|
42
|
+
message: 'Select a package manager:',
|
|
43
|
+
choices: [
|
|
44
|
+
{ title: 'pnpm', value: 'pnpm' },
|
|
45
|
+
{ title: 'npm', value: 'npm' },
|
|
46
|
+
{ title: 'yarn', value: 'yarn' },
|
|
47
|
+
],
|
|
48
|
+
initial: 0,
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
if (!response.projectName) {
|
|
53
|
+
console.log(pc.red('\nā Project creation cancelled'));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { projectName, template, packageManager } = response;
|
|
58
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
59
|
+
|
|
60
|
+
// Check if directory exists
|
|
61
|
+
if (fs.existsSync(targetDir)) {
|
|
62
|
+
console.log(pc.red(`\nā Directory ${projectName} already exists`));
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Create directory
|
|
67
|
+
console.log(pc.cyan(`\nš Creating ${projectName}...\n`));
|
|
68
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
69
|
+
|
|
70
|
+
// Copy template
|
|
71
|
+
const templateDir = path.join(__dirname, '..', 'templates', template);
|
|
72
|
+
copyDirectory(templateDir, targetDir);
|
|
73
|
+
|
|
74
|
+
// Update package.json with project name
|
|
75
|
+
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
76
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
77
|
+
packageJson.name = projectName;
|
|
78
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
79
|
+
|
|
80
|
+
// Install dependencies
|
|
81
|
+
console.log(pc.cyan('š¦ Installing dependencies...\n'));
|
|
82
|
+
try {
|
|
83
|
+
const installCmd =
|
|
84
|
+
packageManager === 'yarn' ? 'yarn' : `${packageManager} install`;
|
|
85
|
+
execSync(installCmd, { cwd: targetDir, stdio: 'inherit' });
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.log(
|
|
88
|
+
pc.yellow('\nā ļø Failed to install dependencies automatically')
|
|
89
|
+
);
|
|
90
|
+
console.log(
|
|
91
|
+
pc.yellow(`Please run: cd ${projectName} && ${packageManager} install\n`)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Success message
|
|
96
|
+
console.log(pc.green('\nā
Project created successfully!\n'));
|
|
97
|
+
console.log(pc.bold('Next steps:\n'));
|
|
98
|
+
console.log(pc.cyan(` cd ${projectName}`));
|
|
99
|
+
console.log(
|
|
100
|
+
pc.cyan(` ${packageManager === 'npm' ? 'npm run' : packageManager} dev\n`)
|
|
101
|
+
);
|
|
102
|
+
console.log(pc.dim('š Read the README.md for more information\n'));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function copyDirectory(src, dest) {
|
|
106
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
107
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
108
|
+
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const srcPath = path.join(src, entry.name);
|
|
111
|
+
const destPath = path.join(dest, entry.name);
|
|
112
|
+
|
|
113
|
+
if (entry.isDirectory()) {
|
|
114
|
+
copyDirectory(srcPath, destPath);
|
|
115
|
+
} else {
|
|
116
|
+
fs.copyFileSync(srcPath, destPath);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
main().catch((error) => {
|
|
122
|
+
console.error(pc.red('\nā Error:'), error);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-bubblelab-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"description": "Create BubbleLab AI agent applications with one command",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-bubblelab-app": "./bin/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"templates",
|
|
13
|
+
"LICENSE.txt"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/bubblelabai/BubbleLab.git",
|
|
18
|
+
"directory": "packages/create-bubblelab-app"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"bubblelab",
|
|
22
|
+
"ai",
|
|
23
|
+
"agent",
|
|
24
|
+
"llm",
|
|
25
|
+
"scaffold",
|
|
26
|
+
"cli"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"prompts": "^2.4.2",
|
|
30
|
+
"picocolors": "^1.1.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.12.12",
|
|
34
|
+
"@types/prompts": "^2.4.9"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Google Gemini API Key (required for AI agent)
|
|
2
|
+
# Get your key at: https://aistudio.google.com/app/apikey
|
|
3
|
+
GOOGLE_API_KEY=your_google_api_key_here
|
|
4
|
+
|
|
5
|
+
# Firecrawl API Key (required for web research)
|
|
6
|
+
# Get your key at: https://www.firecrawl.dev/
|
|
7
|
+
FIRECRAWL_API_KEY=your_firecrawl_api_key_here
|
|
8
|
+
|
|
9
|
+
# Optional: Specify a city for weather research
|
|
10
|
+
CITY=New York
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# BubbleLab Weather Agent
|
|
2
|
+
|
|
3
|
+
Welcome to your first BubbleLab application! This starter template demonstrates how to build AI agents using BubbleLab's powerful workflow engine.
|
|
4
|
+
|
|
5
|
+
## šÆ What This Does
|
|
6
|
+
|
|
7
|
+
This example creates an AI agent that:
|
|
8
|
+
|
|
9
|
+
- Researches weather information for any city
|
|
10
|
+
- Uses Google Gemini AI for intelligent processing
|
|
11
|
+
- Performs web searches to find current weather data
|
|
12
|
+
- Returns detailed weather reports
|
|
13
|
+
|
|
14
|
+
## š Quick Start
|
|
15
|
+
|
|
16
|
+
### 1. Set Up Environment Variables
|
|
17
|
+
|
|
18
|
+
Copy the example environment file:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cp .env.example .env
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Edit `.env` and add your API keys:
|
|
25
|
+
|
|
26
|
+
```env
|
|
27
|
+
GOOGLE_API_KEY=your_google_api_key_here
|
|
28
|
+
FIRECRAWL_API_KEY=your_firecrawl_api_key_here
|
|
29
|
+
CITY=New York # Optional: default city
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Get API Keys
|
|
33
|
+
|
|
34
|
+
- **Google Gemini API**: https://aistudio.google.com/app/apikey (Free tier available)
|
|
35
|
+
- **Firecrawl API**: https://www.firecrawl.dev/ (Required for web research)
|
|
36
|
+
|
|
37
|
+
### 2. Run the Example
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
or
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm dev
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You should see output like:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
š«§ BubbleLab Weather Agent
|
|
53
|
+
|
|
54
|
+
ā
BubbleFactory initialized
|
|
55
|
+
ā
BubbleRunner created
|
|
56
|
+
š Researching weather for: New York
|
|
57
|
+
š¤ Running AI agent...
|
|
58
|
+
|
|
59
|
+
š Results:
|
|
60
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
61
|
+
{
|
|
62
|
+
"city": "New York",
|
|
63
|
+
"weather": "Current weather in New York is...",
|
|
64
|
+
"status": "success"
|
|
65
|
+
}
|
|
66
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## š Project Structure
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
my-bubblelab-app/
|
|
73
|
+
āāā src/
|
|
74
|
+
ā āāā index.ts # Main entry point
|
|
75
|
+
ā āāā weather-flow.ts # Weather agent flow definition
|
|
76
|
+
āāā package.json
|
|
77
|
+
āāā tsconfig.json
|
|
78
|
+
āāā .env.example
|
|
79
|
+
āāā README.md
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## š§© Understanding the Code
|
|
83
|
+
|
|
84
|
+
### BubbleFlow
|
|
85
|
+
|
|
86
|
+
A `BubbleFlow` is a workflow definition that handles events:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
export class WeatherFlow extends BubbleFlow<'webhook/http'> {
|
|
90
|
+
async handle(payload: WeatherPayload) {
|
|
91
|
+
// Your workflow logic here
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### AIAgentBubble
|
|
97
|
+
|
|
98
|
+
An `AIAgentBubble` is an AI-powered action node:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const weatherAgent = new AIAgentBubble({
|
|
102
|
+
message: 'What is the weather in New York?',
|
|
103
|
+
model: { model: 'google/gemini-2.5-flash' },
|
|
104
|
+
tools: [{ name: 'research-agent-tool' }],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Key concepts:**
|
|
109
|
+
|
|
110
|
+
- `message`: The task/prompt for the AI agent
|
|
111
|
+
- `model`: Which AI model to use
|
|
112
|
+
- `tools`: Additional capabilities (like web search)
|
|
113
|
+
|
|
114
|
+
### BubbleRunner
|
|
115
|
+
|
|
116
|
+
The `BubbleRunner` executes your flow:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const runner = new BubbleRunner(WeatherFlow, bubbleFactory);
|
|
120
|
+
const result = await runner.runAll();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## šØ Customization
|
|
124
|
+
|
|
125
|
+
### Change the City
|
|
126
|
+
|
|
127
|
+
Set the `CITY` environment variable:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
CITY="Los Angeles" npm run dev
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Or modify the code in `src/index.ts`:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const city = 'Los Angeles';
|
|
137
|
+
runner.injector.changeBubbleParameters(
|
|
138
|
+
bubbleIds[0],
|
|
139
|
+
'message',
|
|
140
|
+
`What is the weather in ${city}?`
|
|
141
|
+
);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Use Different AI Models
|
|
145
|
+
|
|
146
|
+
BubbleLab supports multiple AI providers:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// OpenAI
|
|
150
|
+
model: {
|
|
151
|
+
model: 'openai/gpt-4';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Anthropic Claude
|
|
155
|
+
model: {
|
|
156
|
+
model: 'anthropic/claude-3-sonnet';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Google Gemini (default)
|
|
160
|
+
model: {
|
|
161
|
+
model: 'google/gemini-2.5-flash';
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Add More Tools
|
|
166
|
+
|
|
167
|
+
Available tools:
|
|
168
|
+
|
|
169
|
+
- `research-agent-tool` - Web search
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
tools: [{ name: 'research-agent-tool' }, { name: 'code-interpreter' }];
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## š§ Development
|
|
176
|
+
|
|
177
|
+
### Build for Production
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm run build
|
|
181
|
+
npm start
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Project Scripts
|
|
185
|
+
|
|
186
|
+
- `npm run dev` - Run with hot reload (tsx)
|
|
187
|
+
- `npm run build` - Compile TypeScript to JavaScript
|
|
188
|
+
- `npm start` - Run compiled JavaScript
|
|
189
|
+
|
|
190
|
+
## š Next Steps
|
|
191
|
+
|
|
192
|
+
### Learn More
|
|
193
|
+
|
|
194
|
+
- [BubbleLab Documentation](https://github.com/bubblelabai/BubbleLab)
|
|
195
|
+
- [Examples & Tutorials](https://github.com/bubblelabai/BubbleLab/tree/main/examples)
|
|
196
|
+
|
|
197
|
+
### Build More Complex Flows
|
|
198
|
+
|
|
199
|
+
Try adding:
|
|
200
|
+
|
|
201
|
+
- Multiple AI agents working together
|
|
202
|
+
- Conditional logic and branching
|
|
203
|
+
- Error handling and retries
|
|
204
|
+
- Data transformation and validation
|
|
205
|
+
- Integration with external APIs
|
|
206
|
+
|
|
207
|
+
### Example: Multi-Step Flow
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
export class MultiStepFlow extends BubbleFlow<'webhook/http'> {
|
|
211
|
+
async handle(payload: any) {
|
|
212
|
+
// Step 1: Research
|
|
213
|
+
const research = await new AIAgentBubble({
|
|
214
|
+
message: 'Research current weather trends',
|
|
215
|
+
tools: [{ name: 'research-agent-tool' }],
|
|
216
|
+
}).action();
|
|
217
|
+
|
|
218
|
+
// Step 2: Analyze
|
|
219
|
+
const analysis = await new AIAgentBubble({
|
|
220
|
+
message: `Analyze this data: ${research.data?.response}`,
|
|
221
|
+
model: { model: 'google/gemini-2.5-flash' },
|
|
222
|
+
}).action();
|
|
223
|
+
|
|
224
|
+
return { research, analysis };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## š Troubleshooting
|
|
230
|
+
|
|
231
|
+
### Error: API Key Not Found
|
|
232
|
+
|
|
233
|
+
Make sure `.env` file exists and contains valid API keys.
|
|
234
|
+
|
|
235
|
+
### Error: Module Not Found
|
|
236
|
+
|
|
237
|
+
Run `npm install` to install dependencies.
|
|
238
|
+
|
|
239
|
+
### Agent Takes Too Long
|
|
240
|
+
|
|
241
|
+
- Check your internet connection
|
|
242
|
+
- Verify API keys are valid
|
|
243
|
+
- Try a simpler prompt first
|
|
244
|
+
|
|
245
|
+
## š¬ Support
|
|
246
|
+
|
|
247
|
+
- **Issues**: [GitHub Issues](https://github.com/bubblelabai/BubbleLab/issues)
|
|
248
|
+
- **Discussions**: [GitHub Discussions](https://github.com/bubblelabai/BubbleLab/discussions)
|
|
249
|
+
|
|
250
|
+
## š License
|
|
251
|
+
|
|
252
|
+
Apache-2.0 Ā© Bubble Lab, Inc.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
**Happy Building! š«§**
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-bubblelab-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsx src/index.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@bubblelab/bubble-core": "^0.1.0",
|
|
13
|
+
"@bubblelab/bubble-runtime": "^0.1.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20.12.12",
|
|
17
|
+
"tsx": "^4.20.3",
|
|
18
|
+
"typescript": "^5.4.5"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BubbleLab Weather Agent Example
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to:
|
|
5
|
+
* 1. Create and configure a BubbleRunner
|
|
6
|
+
* 2. Register default bubble types
|
|
7
|
+
* 3. Inject parameters dynamically
|
|
8
|
+
* 4. Execute AI agent workflows
|
|
9
|
+
* 5. Handle and display results
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { BubbleRunner } from '@bubblelab/bubble-runtime';
|
|
13
|
+
import { BubbleFactory } from '@bubblelab/bubble-core';
|
|
14
|
+
import { WeatherFlow } from './weather-flow.js';
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
console.log('š«§ BubbleLab Weather Agent\n');
|
|
18
|
+
|
|
19
|
+
// Step 1: Create a BubbleFactory and register defaults
|
|
20
|
+
const bubbleFactory = new BubbleFactory();
|
|
21
|
+
await bubbleFactory.registerDefaults();
|
|
22
|
+
console.log('ā
BubbleFactory initialized\n');
|
|
23
|
+
|
|
24
|
+
// Step 2: Create a BubbleRunner with your flow
|
|
25
|
+
const runner = new BubbleRunner(WeatherFlow, bubbleFactory);
|
|
26
|
+
console.log('ā
BubbleRunner created\n');
|
|
27
|
+
|
|
28
|
+
// Step 3: (Optional) Modify bubble parameters dynamically
|
|
29
|
+
const bubbles = runner.getParsedBubbles();
|
|
30
|
+
const bubbleIds = Object.keys(bubbles).map(Number);
|
|
31
|
+
|
|
32
|
+
if (bubbleIds.length > 0) {
|
|
33
|
+
const city = process.env.CITY || 'New York';
|
|
34
|
+
console.log(`š Researching weather for: ${city}\n`);
|
|
35
|
+
|
|
36
|
+
runner.injector.changeBubbleParameters(
|
|
37
|
+
bubbleIds[0],
|
|
38
|
+
'message',
|
|
39
|
+
`What is the current weather in ${city}? Find information from the web and provide a detailed report.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Step 4: Execute the flow
|
|
44
|
+
console.log('š¤ Running AI agent...\n');
|
|
45
|
+
const result = await runner.runAll();
|
|
46
|
+
|
|
47
|
+
// Step 5: Display results
|
|
48
|
+
console.log('š Results:');
|
|
49
|
+
console.log('ā'.repeat(50));
|
|
50
|
+
console.log(JSON.stringify(result, null, 2));
|
|
51
|
+
console.log('ā'.repeat(50));
|
|
52
|
+
|
|
53
|
+
// Optional: View execution logs
|
|
54
|
+
const logs = runner.getLogger()?.getLogs();
|
|
55
|
+
if (logs && logs.length > 0) {
|
|
56
|
+
console.log('\nš Execution Logs:');
|
|
57
|
+
console.log(logs.slice(0, 5)); // Show first 5 logs
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Optional: View execution summary
|
|
61
|
+
const summary = runner.getLogger()?.getExecutionSummary();
|
|
62
|
+
if (summary) {
|
|
63
|
+
console.log('\nš Execution Summary:');
|
|
64
|
+
console.log(summary);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Run the example
|
|
69
|
+
main().catch((error) => {
|
|
70
|
+
console.error('ā Error:', error);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weather Research Flow
|
|
3
|
+
*
|
|
4
|
+
* This is a simple BubbleFlow that uses an AI agent to research weather information
|
|
5
|
+
* for a given city using web search capabilities.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
BubbleFlow,
|
|
10
|
+
AIAgentBubble,
|
|
11
|
+
WebhookEvent,
|
|
12
|
+
} from '@bubblelab/bubble-core';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Payload interface for the weather flow
|
|
16
|
+
* Extends WebhookEvent to include city information
|
|
17
|
+
*/
|
|
18
|
+
interface WeatherPayload extends WebhookEvent {
|
|
19
|
+
city: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WeatherFlow - Researches weather for a specified city
|
|
24
|
+
*
|
|
25
|
+
* This flow demonstrates:
|
|
26
|
+
* - Using AIAgentBubble for intelligent tasks
|
|
27
|
+
* - Configuring AI models (Google Gemini)
|
|
28
|
+
* - Using tools (research-agent-tool for web search)
|
|
29
|
+
* - Handling async operations
|
|
30
|
+
*/
|
|
31
|
+
export class WeatherFlow extends BubbleFlow<'webhook/http'> {
|
|
32
|
+
async handle(payload: WeatherPayload) {
|
|
33
|
+
const city = payload.city || 'San Francisco';
|
|
34
|
+
|
|
35
|
+
// Create an AI agent bubble configured to research weather
|
|
36
|
+
const weatherAgent: AIAgentBubble = new AIAgentBubble({
|
|
37
|
+
message: `What is the current weather in ${city}? Find information from the web and provide a detailed report including temperature, conditions, and forecast.`,
|
|
38
|
+
model: {
|
|
39
|
+
model: 'google/gemini-2.5-flash',
|
|
40
|
+
},
|
|
41
|
+
tools: [
|
|
42
|
+
{ name: 'research-agent-tool' }, // Enables web search capability
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Execute the agent and get results
|
|
47
|
+
const weatherResult = await weatherAgent.action();
|
|
48
|
+
|
|
49
|
+
// Return the weather information
|
|
50
|
+
return {
|
|
51
|
+
city,
|
|
52
|
+
weather: weatherResult.data?.response,
|
|
53
|
+
status: 'success',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ES2022",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"],
|
|
19
|
+
"exclude": ["node_modules", "dist"]
|
|
20
|
+
}
|