@bubblelab/bubble-core 0.1.165 → 0.1.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bubble-bundle.d.ts +141 -141
- package/dist/bubbles/service-bubble/agi-inc.d.ts +60 -60
- package/dist/bubbles/service-bubble/ai-agent.d.ts +9 -10
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.js +40 -76
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -1
- package/dist/bubbles/service-bubble/airtable.d.ts +50 -50
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts +2 -2
- package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +4 -4
- package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +12 -12
- package/dist/bubbles/service-bubble/apify/actors/linkedin-jobs-scraper.d.ts +2 -2
- package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +10 -10
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-detail.d.ts +54 -54
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +22 -22
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts +12 -12
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts +28 -28
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +12 -12
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +144 -144
- package/dist/bubbles/service-bubble/apify/apify.d.ts +12 -12
- package/dist/bubbles/service-bubble/ashby/ashby.d.ts +62 -62
- package/dist/bubbles/service-bubble/ashby/ashby.schema.d.ts +84 -84
- package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts +28 -28
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts +30 -30
- package/dist/bubbles/service-bubble/confluence/confluence.d.ts +24 -24
- package/dist/bubbles/service-bubble/confluence/confluence.schema.d.ts +24 -24
- package/dist/bubbles/service-bubble/crustdata/crustdata.d.ts +126 -126
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.d.ts +158 -158
- package/dist/bubbles/service-bubble/eleven-labs.d.ts +28 -28
- package/dist/bubbles/service-bubble/firecrawl.d.ts +628 -628
- package/dist/bubbles/service-bubble/followupboss.d.ts +140 -140
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.d.ts +68 -68
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.schema.d.ts +108 -108
- package/dist/bubbles/service-bubble/github.d.ts +104 -104
- package/dist/bubbles/service-bubble/gmail.d.ts +92 -92
- package/dist/bubbles/service-bubble/google-calendar.d.ts +138 -138
- package/dist/bubbles/service-bubble/google-drive.d.ts +60 -60
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts +44 -44
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts +48 -48
- package/dist/bubbles/service-bubble/hello-world.d.ts +8 -8
- package/dist/bubbles/service-bubble/http.d.ts +16 -16
- package/dist/bubbles/service-bubble/insforge-db.d.ts +8 -8
- package/dist/bubbles/service-bubble/jira/jira.d.ts +86 -86
- package/dist/bubbles/service-bubble/jira/jira.schema.d.ts +94 -94
- package/dist/bubbles/service-bubble/notion/notion.d.ts +534 -534
- package/dist/bubbles/service-bubble/notion/property-schemas.d.ts +8 -8
- package/dist/bubbles/service-bubble/postgresql.d.ts +10 -10
- package/dist/bubbles/service-bubble/posthog/posthog.d.ts +22 -22
- package/dist/bubbles/service-bubble/posthog/posthog.schema.d.ts +26 -26
- package/dist/bubbles/service-bubble/resend.d.ts +32 -32
- package/dist/bubbles/service-bubble/sendsafely/sendsafely.d.ts +10 -10
- package/dist/bubbles/service-bubble/sendsafely/sendsafely.schema.d.ts +12 -12
- package/dist/bubbles/service-bubble/slack/slack.d.ts +316 -316
- package/dist/bubbles/service-bubble/storage.d.ts +20 -20
- package/dist/bubbles/service-bubble/stripe/stripe.d.ts +125 -125
- package/dist/bubbles/service-bubble/stripe/stripe.schema.d.ts +143 -143
- package/dist/bubbles/service-bubble/telegram.d.ts +1562 -1562
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.d.ts +13 -13
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.d.ts +13 -13
- package/dist/bubbles/tool-bubble/browser-tools/_shared/schema.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/schema.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/schema.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/schema.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/schema.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +16 -16
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +26 -26
- package/dist/bubbles/tool-bubble/code-edit-tool.d.ts +36 -97
- package/dist/bubbles/tool-bubble/code-edit-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/code-edit-tool.js +79 -202
- package/dist/bubbles/tool-bubble/code-edit-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/company-enrichment-tool.d.ts +22 -22
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/get-trigger-detail-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/google-maps-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/instagram-tool.d.ts +14 -14
- package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +212 -212
- package/dist/bubbles/tool-bubble/list-airtable-bases-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/list-airtable-tables-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/list-capabilities-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/people-search-tool.d.ts +14 -14
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +28 -28
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/tiktok-tool.d.ts +36 -36
- package/dist/bubbles/tool-bubble/tool-template.d.ts +4 -4
- package/dist/bubbles/tool-bubble/twitter-tool.d.ts +64 -64
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +22 -22
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/yc-scraper-tool.d.ts +22 -22
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts +28 -28
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +4 -4
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +28 -28
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +8 -8
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +72 -72
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +32 -32
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +30 -30
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +90 -90
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +8 -8
- package/dist/bubbles.json +16 -51
- package/package.json +2 -2
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EDIT BUBBLEFLOW TOOL
|
|
3
3
|
*
|
|
4
|
-
* A tool bubble that applies code edits to BubbleFlow files using
|
|
5
|
-
* This tool
|
|
6
|
-
* specified by an AI agent into existing BubbleFlow code, following the Fast Apply
|
|
7
|
-
* pattern used in Cursor.
|
|
4
|
+
* A tool bubble that applies code edits to BubbleFlow files using find-and-replace.
|
|
5
|
+
* This tool performs simple string replacement matching Claude Code's Edit tool behavior.
|
|
8
6
|
*
|
|
9
7
|
* Features:
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* - Detailed diff reporting
|
|
8
|
+
* - Exact string find-and-replace
|
|
9
|
+
* - Uniqueness validation (prevents ambiguous edits)
|
|
10
|
+
* - Replace-all mode for renaming variables/strings
|
|
11
|
+
* - No external API calls required
|
|
15
12
|
*/
|
|
16
13
|
import { z } from 'zod';
|
|
17
14
|
import { ToolBubble } from '../../types/tool-bubble-class.js';
|
|
18
|
-
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
19
|
-
import { HttpBubble } from '../service-bubble/http.js';
|
|
20
15
|
/**
|
|
21
16
|
* Define the parameters schema using Zod
|
|
22
17
|
* This schema validates and types the input parameters for the edit tool
|
|
23
18
|
*/
|
|
24
19
|
const EditBubbleFlowToolParamsSchema = z.object({
|
|
25
|
-
// The
|
|
26
|
-
initialCode: z.string().describe('The
|
|
27
|
-
// The
|
|
28
|
-
|
|
20
|
+
// The current code to apply the edit to
|
|
21
|
+
initialCode: z.string().describe('The current code to apply the edit to'),
|
|
22
|
+
// The exact text to replace
|
|
23
|
+
old_string: z
|
|
29
24
|
.string()
|
|
30
|
-
.describe('
|
|
31
|
-
// The
|
|
32
|
-
|
|
25
|
+
.describe('The exact text to replace. Must be unique in the code — if not unique, provide more surrounding context to disambiguate.'),
|
|
26
|
+
// The replacement text
|
|
27
|
+
new_string: z
|
|
33
28
|
.string()
|
|
34
|
-
.describe('The
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
.default(
|
|
29
|
+
.describe('The replacement text. Must be different from old_string.'),
|
|
30
|
+
// Whether to replace all occurrences
|
|
31
|
+
replace_all: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.default(false)
|
|
39
34
|
.optional()
|
|
40
|
-
.describe('
|
|
35
|
+
.describe('Replace all occurrences of old_string (default false). Use for renaming variables/strings across the file.'),
|
|
41
36
|
// Credentials (injected at runtime)
|
|
42
37
|
credentials: z
|
|
43
38
|
.record(z.string(), z.string())
|
|
@@ -58,27 +53,13 @@ const EditBubbleFlowToolResultSchema = z.object({
|
|
|
58
53
|
mergedCode: z.string().describe('The final code after applying edits'),
|
|
59
54
|
// Success indicator
|
|
60
55
|
applied: z.boolean().describe('Whether the edit was successfully applied'),
|
|
61
|
-
// Optional diff information
|
|
62
|
-
diff: z
|
|
63
|
-
.string()
|
|
64
|
-
.optional()
|
|
65
|
-
.describe('Unified diff showing the changes made (if available)'),
|
|
66
|
-
// Metadata
|
|
67
|
-
metadata: z.object({
|
|
68
|
-
editedAt: z.string().describe('Timestamp when edit was performed'),
|
|
69
|
-
originalLength: z
|
|
70
|
-
.number()
|
|
71
|
-
.describe('Length of original code in characters'),
|
|
72
|
-
finalLength: z.number().describe('Length of final code in characters'),
|
|
73
|
-
morphModel: z.string().describe('Morph model used for the edit'),
|
|
74
|
-
}),
|
|
75
56
|
// Standard result fields
|
|
76
57
|
success: z.boolean().describe('Whether the edit operation was successful'),
|
|
77
58
|
error: z.string().describe('Error message if edit failed'),
|
|
78
59
|
});
|
|
79
60
|
/**
|
|
80
61
|
* Edit BubbleFlow Tool
|
|
81
|
-
* Applies code edits using
|
|
62
|
+
* Applies code edits using find-and-replace
|
|
82
63
|
*/
|
|
83
64
|
export class EditBubbleFlowTool extends ToolBubble {
|
|
84
65
|
/**
|
|
@@ -92,226 +73,122 @@ export class EditBubbleFlowTool extends ToolBubble {
|
|
|
92
73
|
static schema = EditBubbleFlowToolParamsSchema;
|
|
93
74
|
static resultSchema = EditBubbleFlowToolResultSchema;
|
|
94
75
|
// Short description
|
|
95
|
-
static shortDescription = 'Applies code edits to BubbleFlow files using
|
|
76
|
+
static shortDescription = 'Applies code edits to BubbleFlow files using find-and-replace';
|
|
96
77
|
// Long description with detailed information
|
|
97
78
|
static longDescription = `
|
|
98
|
-
A tool for
|
|
99
|
-
Uses the Morph Fast Apply API via OpenRouter to merge lazy code edits into existing code.
|
|
79
|
+
A tool for applying code edits to BubbleFlow TypeScript files using find-and-replace.
|
|
100
80
|
|
|
101
81
|
What it does:
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
82
|
+
- Finds exact text matches in code and replaces them
|
|
83
|
+
- Validates uniqueness to prevent ambiguous edits
|
|
84
|
+
- Supports replace-all mode for renaming variables/strings
|
|
85
|
+
- No external API calls required
|
|
106
86
|
|
|
107
87
|
How it works:
|
|
108
|
-
- Takes
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
- Returns the final code ready to be written to file
|
|
88
|
+
- Takes the current code, old_string (text to find), and new_string (replacement)
|
|
89
|
+
- Validates that old_string exists and is unique (unless replace_all is true)
|
|
90
|
+
- Performs the replacement and returns the updated code
|
|
112
91
|
|
|
113
92
|
Use cases:
|
|
114
93
|
- When an AI agent needs to make edits to BubbleFlow code
|
|
115
|
-
- When applying multiple distinct edits to a file at once
|
|
116
94
|
- When making targeted changes without rewriting entire files
|
|
117
|
-
- When
|
|
95
|
+
- When renaming variables or strings across a file
|
|
118
96
|
|
|
119
97
|
Important:
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
98
|
+
- old_string must be an exact match of text in the code
|
|
99
|
+
- If old_string appears multiple times, provide more context or use replace_all
|
|
100
|
+
- new_string must be different from old_string
|
|
123
101
|
`;
|
|
124
102
|
// Short alias for the tool
|
|
125
103
|
static alias = 'code-edit';
|
|
126
104
|
/**
|
|
127
|
-
*
|
|
105
|
+
* Count occurrences of a substring in a string
|
|
106
|
+
*/
|
|
107
|
+
countOccurrences(str, substr) {
|
|
108
|
+
let count = 0;
|
|
109
|
+
let pos = 0;
|
|
110
|
+
while ((pos = str.indexOf(substr, pos)) !== -1) {
|
|
111
|
+
count++;
|
|
112
|
+
pos += substr.length;
|
|
113
|
+
}
|
|
114
|
+
return count;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Main action method - performs find-and-replace code editing
|
|
128
118
|
*/
|
|
129
119
|
async performAction() {
|
|
130
120
|
try {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// Validate inputs
|
|
121
|
+
const { initialCode, old_string, new_string, replace_all } = this.params;
|
|
122
|
+
// Validate initialCode is not empty
|
|
134
123
|
if (!initialCode || initialCode.trim().length === 0) {
|
|
135
124
|
return {
|
|
136
125
|
mergedCode: '',
|
|
137
126
|
applied: false,
|
|
138
|
-
metadata: {
|
|
139
|
-
editedAt: new Date().toISOString(),
|
|
140
|
-
originalLength: 0,
|
|
141
|
-
finalLength: 0,
|
|
142
|
-
morphModel: morphModel ?? 'morph/morph-v3-large',
|
|
143
|
-
},
|
|
144
127
|
success: false,
|
|
145
128
|
error: 'Initial code cannot be empty',
|
|
146
129
|
};
|
|
147
130
|
}
|
|
148
|
-
|
|
131
|
+
// Validate old_string is not empty
|
|
132
|
+
if (!old_string || old_string.length === 0) {
|
|
149
133
|
return {
|
|
150
134
|
mergedCode: initialCode,
|
|
151
135
|
applied: false,
|
|
152
|
-
metadata: {
|
|
153
|
-
editedAt: new Date().toISOString(),
|
|
154
|
-
originalLength: initialCode.length,
|
|
155
|
-
finalLength: initialCode.length,
|
|
156
|
-
morphModel: morphModel ?? 'morph/morph-v3-large',
|
|
157
|
-
},
|
|
158
136
|
success: false,
|
|
159
|
-
error: '
|
|
137
|
+
error: 'old_string cannot be empty',
|
|
160
138
|
};
|
|
161
139
|
}
|
|
162
|
-
|
|
140
|
+
// Validate old_string !== new_string
|
|
141
|
+
if (old_string === new_string) {
|
|
163
142
|
return {
|
|
164
143
|
mergedCode: initialCode,
|
|
165
144
|
applied: false,
|
|
166
|
-
metadata: {
|
|
167
|
-
editedAt: new Date().toISOString(),
|
|
168
|
-
originalLength: initialCode.length,
|
|
169
|
-
finalLength: initialCode.length,
|
|
170
|
-
morphModel: morphModel ?? 'morph/morph-v3-large',
|
|
171
|
-
},
|
|
172
145
|
success: false,
|
|
173
|
-
error: '
|
|
146
|
+
error: 'new_string must be different from old_string',
|
|
174
147
|
};
|
|
175
148
|
}
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
if (!apiKey) {
|
|
149
|
+
// Check old_string exists in initialCode
|
|
150
|
+
if (!initialCode.includes(old_string)) {
|
|
179
151
|
return {
|
|
180
152
|
mergedCode: initialCode,
|
|
181
153
|
applied: false,
|
|
182
|
-
metadata: {
|
|
183
|
-
editedAt: new Date().toISOString(),
|
|
184
|
-
originalLength: initialCode.length,
|
|
185
|
-
finalLength: initialCode.length,
|
|
186
|
-
morphModel: morphModel ?? 'morph/morph-v3-large',
|
|
187
|
-
},
|
|
188
154
|
success: false,
|
|
189
|
-
error: '
|
|
155
|
+
error: 'old_string not found in code',
|
|
190
156
|
};
|
|
191
157
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
url: 'https://openrouter.ai/api/v1/chat/completions',
|
|
197
|
-
method: 'POST',
|
|
198
|
-
headers: {
|
|
199
|
-
Authorization: `Bearer ${apiKey}`,
|
|
200
|
-
'Content-Type': 'application/json',
|
|
201
|
-
},
|
|
202
|
-
body: {
|
|
203
|
-
model: 'morph/morph-v3-large',
|
|
204
|
-
messages: [
|
|
205
|
-
{
|
|
206
|
-
role: 'user',
|
|
207
|
-
content: morphPrompt,
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
timeout: 60000, // 60 second timeout for code generation
|
|
212
|
-
}, this.context);
|
|
213
|
-
// Execute the HTTP request
|
|
214
|
-
const result = await httpBubble.action();
|
|
215
|
-
if (!result.success || !result.data?.json) {
|
|
216
|
-
return {
|
|
217
|
-
mergedCode: initialCode,
|
|
218
|
-
applied: false,
|
|
219
|
-
metadata: {
|
|
220
|
-
editedAt: new Date().toISOString(),
|
|
221
|
-
originalLength: initialCode.length,
|
|
222
|
-
finalLength: initialCode.length,
|
|
223
|
-
morphModel: morphModel ?? 'morph/morph-v3-large',
|
|
224
|
-
},
|
|
225
|
-
success: false,
|
|
226
|
-
error: result.error || 'Morph API returned empty response',
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
const responseData = result.data.json;
|
|
230
|
-
// Extract token usage - OpenRouter uses 'usage' field (OpenAI format)
|
|
231
|
-
// Fallback to usage_metadata if present (some providers use this)
|
|
232
|
-
let inputTokens = 0;
|
|
233
|
-
let outputTokens = 0;
|
|
234
|
-
let totalTokens = 0;
|
|
235
|
-
if (responseData.usage) {
|
|
236
|
-
// OpenAI format: usage.prompt_tokens, usage.completion_tokens
|
|
237
|
-
inputTokens = responseData.usage.prompt_tokens ?? 0;
|
|
238
|
-
outputTokens = responseData.usage.completion_tokens ?? 0;
|
|
239
|
-
totalTokens = responseData.usage.total_tokens ?? 0;
|
|
240
|
-
}
|
|
241
|
-
else if (responseData.usage_metadata) {
|
|
242
|
-
// Alternative format: usage_metadata.input_tokens, usage_metadata.output_tokens
|
|
243
|
-
inputTokens = responseData.usage_metadata.input_tokens ?? 0;
|
|
244
|
-
outputTokens = responseData.usage_metadata.output_tokens ?? 0;
|
|
245
|
-
totalTokens = responseData.usage_metadata.total_tokens ?? 0;
|
|
246
|
-
}
|
|
247
|
-
const tokenUsage = {
|
|
248
|
-
inputTokens,
|
|
249
|
-
outputTokens,
|
|
250
|
-
totalTokens,
|
|
251
|
-
modelName: morphModel ?? 'morph/morph-v3-large',
|
|
252
|
-
};
|
|
253
|
-
if (this.context?.logger) {
|
|
254
|
-
this.context.logger.logTokenUsage({
|
|
255
|
-
usage: tokenUsage.inputTokens,
|
|
256
|
-
service: CredentialType.OPENROUTER_CRED,
|
|
257
|
-
unit: 'input_tokens',
|
|
258
|
-
subService: morphModel ?? 'morph/morph-v3-large',
|
|
259
|
-
}, `LLM completion: ${tokenUsage.inputTokens} input`, {
|
|
260
|
-
bubbleName: 'code-edit-tool',
|
|
261
|
-
variableId: this.context?.variableId,
|
|
262
|
-
operationType: 'bubble_execution',
|
|
263
|
-
});
|
|
264
|
-
this.context.logger.logTokenUsage({
|
|
265
|
-
usage: tokenUsage.outputTokens,
|
|
266
|
-
service: CredentialType.OPENROUTER_CRED,
|
|
267
|
-
unit: 'output_tokens',
|
|
268
|
-
subService: morphModel ?? 'morph/morph-v3-large',
|
|
269
|
-
}, `LLM completion: ${tokenUsage.outputTokens} output`, {
|
|
270
|
-
bubbleName: 'code-edit-tool',
|
|
271
|
-
variableId: this.context?.variableId,
|
|
272
|
-
operationType: 'bubble_execution',
|
|
273
|
-
});
|
|
158
|
+
let result;
|
|
159
|
+
if (replace_all) {
|
|
160
|
+
// Replace ALL occurrences
|
|
161
|
+
result = initialCode.replaceAll(old_string, new_string);
|
|
274
162
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
163
|
+
else {
|
|
164
|
+
// Check uniqueness
|
|
165
|
+
const count = this.countOccurrences(initialCode, old_string);
|
|
166
|
+
if (count > 1) {
|
|
167
|
+
return {
|
|
168
|
+
mergedCode: initialCode,
|
|
169
|
+
applied: false,
|
|
170
|
+
success: false,
|
|
171
|
+
error: 'old_string is not unique in the code. Provide a larger string with more surrounding context to make it unique, or use replace_all to change every instance.',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Replace the single occurrence
|
|
175
|
+
const index = initialCode.indexOf(old_string);
|
|
176
|
+
result =
|
|
177
|
+
initialCode.slice(0, index) +
|
|
178
|
+
new_string +
|
|
179
|
+
initialCode.slice(index + old_string.length);
|
|
289
180
|
}
|
|
290
|
-
// Return successful result
|
|
291
181
|
return {
|
|
292
|
-
mergedCode,
|
|
182
|
+
mergedCode: result,
|
|
293
183
|
applied: true,
|
|
294
|
-
metadata: {
|
|
295
|
-
editedAt: new Date().toISOString(),
|
|
296
|
-
originalLength: initialCode.length,
|
|
297
|
-
finalLength: mergedCode.length,
|
|
298
|
-
morphModel: morphModel ?? 'openrouter/morph/morph-v3-large',
|
|
299
|
-
},
|
|
300
184
|
success: true,
|
|
301
185
|
error: '',
|
|
302
186
|
};
|
|
303
187
|
}
|
|
304
188
|
catch (error) {
|
|
305
|
-
// Handle unexpected errors gracefully
|
|
306
189
|
return {
|
|
307
190
|
mergedCode: this.params.initialCode || '',
|
|
308
191
|
applied: false,
|
|
309
|
-
metadata: {
|
|
310
|
-
editedAt: new Date().toISOString(),
|
|
311
|
-
originalLength: this.params.initialCode?.length || 0,
|
|
312
|
-
finalLength: this.params.initialCode?.length || 0,
|
|
313
|
-
morphModel: this.params.morphModel ?? 'openrouter/morph/morph-v3-large',
|
|
314
|
-
},
|
|
315
192
|
success: false,
|
|
316
193
|
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
317
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-edit-tool.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/code-edit-tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"code-edit-tool.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/code-edit-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D;;;GAGG;AACH,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,wCAAwC;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C,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC;YAED,OAAO;gBACL,UAAU,EAAE,MAAM;gBAClB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,EAAE;aACV,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE;gBACzC,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,KAAK;gBACd,KAAK,EACH,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;aACpE,CAAC;QACJ,CAAC;IACH,CAAC"}
|
|
@@ -66,8 +66,8 @@ declare const ContactSchema: z.ZodObject<{
|
|
|
66
66
|
}, "strip", z.ZodTypeAny, {
|
|
67
67
|
title: string | null;
|
|
68
68
|
name: string | null;
|
|
69
|
-
summary: string | null;
|
|
70
69
|
role: "cxo" | "decision_maker" | "founder";
|
|
70
|
+
summary: string | null;
|
|
71
71
|
location: string | null;
|
|
72
72
|
headline: string | null;
|
|
73
73
|
linkedinUrl: string | null;
|
|
@@ -97,8 +97,8 @@ declare const ContactSchema: z.ZodObject<{
|
|
|
97
97
|
}, {
|
|
98
98
|
title: string | null;
|
|
99
99
|
name: string | null;
|
|
100
|
-
summary: string | null;
|
|
101
100
|
role: "cxo" | "decision_maker" | "founder";
|
|
101
|
+
summary: string | null;
|
|
102
102
|
location: string | null;
|
|
103
103
|
headline: string | null;
|
|
104
104
|
linkedinUrl: string | null;
|
|
@@ -204,8 +204,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
204
204
|
}, "strip", z.ZodTypeAny, {
|
|
205
205
|
title: string | null;
|
|
206
206
|
name: string | null;
|
|
207
|
-
summary: string | null;
|
|
208
207
|
role: "cxo" | "decision_maker" | "founder";
|
|
208
|
+
summary: string | null;
|
|
209
209
|
location: string | null;
|
|
210
210
|
headline: string | null;
|
|
211
211
|
linkedinUrl: string | null;
|
|
@@ -235,8 +235,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
235
235
|
}, {
|
|
236
236
|
title: string | null;
|
|
237
237
|
name: string | null;
|
|
238
|
-
summary: string | null;
|
|
239
238
|
role: "cxo" | "decision_maker" | "founder";
|
|
239
|
+
summary: string | null;
|
|
240
240
|
location: string | null;
|
|
241
241
|
headline: string | null;
|
|
242
242
|
linkedinUrl: string | null;
|
|
@@ -281,8 +281,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
281
281
|
name: string | null;
|
|
282
282
|
linkedinUrl: string | null;
|
|
283
283
|
website: string | null;
|
|
284
|
-
industry: string | null;
|
|
285
284
|
headcount: number | null;
|
|
285
|
+
industry: string | null;
|
|
286
286
|
hqCity: string | null;
|
|
287
287
|
hqCountry: string | null;
|
|
288
288
|
yearFounded: number | null;
|
|
@@ -293,8 +293,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
293
293
|
name: string | null;
|
|
294
294
|
linkedinUrl: string | null;
|
|
295
295
|
website: string | null;
|
|
296
|
-
industry: string | null;
|
|
297
296
|
headcount: number | null;
|
|
297
|
+
industry: string | null;
|
|
298
298
|
hqCity: string | null;
|
|
299
299
|
hqCountry: string | null;
|
|
300
300
|
yearFounded: number | null;
|
|
@@ -305,15 +305,15 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
305
305
|
success: z.ZodBoolean;
|
|
306
306
|
error: z.ZodString;
|
|
307
307
|
}, "strip", z.ZodTypeAny, {
|
|
308
|
-
error: string;
|
|
309
308
|
success: boolean;
|
|
309
|
+
error: string;
|
|
310
310
|
company: {
|
|
311
311
|
description: string | null;
|
|
312
312
|
name: string | null;
|
|
313
313
|
linkedinUrl: string | null;
|
|
314
314
|
website: string | null;
|
|
315
|
-
industry: string | null;
|
|
316
315
|
headcount: number | null;
|
|
316
|
+
industry: string | null;
|
|
317
317
|
hqCity: string | null;
|
|
318
318
|
hqCountry: string | null;
|
|
319
319
|
yearFounded: number | null;
|
|
@@ -323,8 +323,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
323
323
|
contacts: {
|
|
324
324
|
title: string | null;
|
|
325
325
|
name: string | null;
|
|
326
|
-
summary: string | null;
|
|
327
326
|
role: "cxo" | "decision_maker" | "founder";
|
|
327
|
+
summary: string | null;
|
|
328
328
|
location: string | null;
|
|
329
329
|
headline: string | null;
|
|
330
330
|
linkedinUrl: string | null;
|
|
@@ -354,15 +354,15 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
354
354
|
}[];
|
|
355
355
|
totalContacts: number;
|
|
356
356
|
}, {
|
|
357
|
-
error: string;
|
|
358
357
|
success: boolean;
|
|
358
|
+
error: string;
|
|
359
359
|
company: {
|
|
360
360
|
description: string | null;
|
|
361
361
|
name: string | null;
|
|
362
362
|
linkedinUrl: string | null;
|
|
363
363
|
website: string | null;
|
|
364
|
-
industry: string | null;
|
|
365
364
|
headcount: number | null;
|
|
365
|
+
industry: string | null;
|
|
366
366
|
hqCity: string | null;
|
|
367
367
|
hqCountry: string | null;
|
|
368
368
|
yearFounded: number | null;
|
|
@@ -372,8 +372,8 @@ declare const CompanyEnrichmentToolResultSchema: z.ZodObject<{
|
|
|
372
372
|
contacts: {
|
|
373
373
|
title: string | null;
|
|
374
374
|
name: string | null;
|
|
375
|
-
summary: string | null;
|
|
376
375
|
role: "cxo" | "decision_maker" | "founder";
|
|
376
|
+
summary: string | null;
|
|
377
377
|
location: string | null;
|
|
378
378
|
headline: string | null;
|
|
379
379
|
linkedinUrl: string | null;
|
|
@@ -505,8 +505,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
505
505
|
}, "strip", z.ZodTypeAny, {
|
|
506
506
|
title: string | null;
|
|
507
507
|
name: string | null;
|
|
508
|
-
summary: string | null;
|
|
509
508
|
role: "cxo" | "decision_maker" | "founder";
|
|
509
|
+
summary: string | null;
|
|
510
510
|
location: string | null;
|
|
511
511
|
headline: string | null;
|
|
512
512
|
linkedinUrl: string | null;
|
|
@@ -536,8 +536,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
536
536
|
}, {
|
|
537
537
|
title: string | null;
|
|
538
538
|
name: string | null;
|
|
539
|
-
summary: string | null;
|
|
540
539
|
role: "cxo" | "decision_maker" | "founder";
|
|
540
|
+
summary: string | null;
|
|
541
541
|
location: string | null;
|
|
542
542
|
headline: string | null;
|
|
543
543
|
linkedinUrl: string | null;
|
|
@@ -582,8 +582,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
582
582
|
name: string | null;
|
|
583
583
|
linkedinUrl: string | null;
|
|
584
584
|
website: string | null;
|
|
585
|
-
industry: string | null;
|
|
586
585
|
headcount: number | null;
|
|
586
|
+
industry: string | null;
|
|
587
587
|
hqCity: string | null;
|
|
588
588
|
hqCountry: string | null;
|
|
589
589
|
yearFounded: number | null;
|
|
@@ -594,8 +594,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
594
594
|
name: string | null;
|
|
595
595
|
linkedinUrl: string | null;
|
|
596
596
|
website: string | null;
|
|
597
|
-
industry: string | null;
|
|
598
597
|
headcount: number | null;
|
|
598
|
+
industry: string | null;
|
|
599
599
|
hqCity: string | null;
|
|
600
600
|
hqCountry: string | null;
|
|
601
601
|
yearFounded: number | null;
|
|
@@ -606,15 +606,15 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
606
606
|
success: z.ZodBoolean;
|
|
607
607
|
error: z.ZodString;
|
|
608
608
|
}, "strip", z.ZodTypeAny, {
|
|
609
|
-
error: string;
|
|
610
609
|
success: boolean;
|
|
610
|
+
error: string;
|
|
611
611
|
company: {
|
|
612
612
|
description: string | null;
|
|
613
613
|
name: string | null;
|
|
614
614
|
linkedinUrl: string | null;
|
|
615
615
|
website: string | null;
|
|
616
|
-
industry: string | null;
|
|
617
616
|
headcount: number | null;
|
|
617
|
+
industry: string | null;
|
|
618
618
|
hqCity: string | null;
|
|
619
619
|
hqCountry: string | null;
|
|
620
620
|
yearFounded: number | null;
|
|
@@ -624,8 +624,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
624
624
|
contacts: {
|
|
625
625
|
title: string | null;
|
|
626
626
|
name: string | null;
|
|
627
|
-
summary: string | null;
|
|
628
627
|
role: "cxo" | "decision_maker" | "founder";
|
|
628
|
+
summary: string | null;
|
|
629
629
|
location: string | null;
|
|
630
630
|
headline: string | null;
|
|
631
631
|
linkedinUrl: string | null;
|
|
@@ -655,15 +655,15 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
655
655
|
}[];
|
|
656
656
|
totalContacts: number;
|
|
657
657
|
}, {
|
|
658
|
-
error: string;
|
|
659
658
|
success: boolean;
|
|
659
|
+
error: string;
|
|
660
660
|
company: {
|
|
661
661
|
description: string | null;
|
|
662
662
|
name: string | null;
|
|
663
663
|
linkedinUrl: string | null;
|
|
664
664
|
website: string | null;
|
|
665
|
-
industry: string | null;
|
|
666
665
|
headcount: number | null;
|
|
666
|
+
industry: string | null;
|
|
667
667
|
hqCity: string | null;
|
|
668
668
|
hqCountry: string | null;
|
|
669
669
|
yearFounded: number | null;
|
|
@@ -673,8 +673,8 @@ export declare class CompanyEnrichmentTool extends ToolBubble<CompanyEnrichmentT
|
|
|
673
673
|
contacts: {
|
|
674
674
|
title: string | null;
|
|
675
675
|
name: string | null;
|
|
676
|
-
summary: string | null;
|
|
677
676
|
role: "cxo" | "decision_maker" | "founder";
|
|
677
|
+
summary: string | null;
|
|
678
678
|
location: string | null;
|
|
679
679
|
headline: string | null;
|
|
680
680
|
linkedinUrl: string | null;
|