@browserbasehq/stagehand 1.0.3 → 1.1.0-alpha.1
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/README.md +10 -5
- package/dist/evals/index.eval.js +1075 -0
- package/dist/evals/index.eval.js.map +1 -0
- package/dist/evals/playground.js +112 -0
- package/dist/evals/playground.js.map +1 -0
- package/dist/evals/utils.js +52 -0
- package/dist/evals/utils.js.map +1 -0
- package/dist/examples/2048.js +108 -0
- package/dist/examples/2048.js.map +1 -0
- package/dist/examples/debugUrl.js +35 -0
- package/dist/examples/debugUrl.js.map +1 -0
- package/dist/examples/example.js +37 -0
- package/dist/examples/example.js.map +1 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +629 -152
- package/dist/lib/browserbase.js +56 -0
- package/dist/lib/browserbase.js.map +1 -0
- package/dist/lib/cache.js +78 -0
- package/dist/lib/cache.js.map +1 -0
- package/dist/lib/dom/debug.js +119 -0
- package/dist/lib/dom/debug.js.map +1 -0
- package/dist/lib/dom/index.js +20 -0
- package/dist/lib/dom/index.js.map +1 -0
- package/dist/lib/dom/process.js +396 -0
- package/dist/lib/dom/process.js.map +1 -0
- package/dist/lib/dom/utils.js +28 -0
- package/dist/lib/dom/utils.js.map +1 -0
- package/dist/lib/index.js +978 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/inference.js +226 -0
- package/dist/lib/inference.js.map +1 -0
- package/dist/lib/llm/AnthropicClient.js +150 -0
- package/dist/lib/llm/AnthropicClient.js.map +1 -0
- package/dist/lib/llm/LLMClient.js +12 -0
- package/dist/lib/llm/LLMClient.js.map +1 -0
- package/dist/lib/llm/LLMProvider.js +34 -0
- package/dist/lib/llm/LLMProvider.js.map +1 -0
- package/dist/lib/llm/OpenAIClient.js +69 -0
- package/dist/lib/llm/OpenAIClient.js.map +1 -0
- package/dist/lib/prompt.js +288 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/vision.js +194 -0
- package/dist/lib/vision.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actTools = void 0;
|
|
4
|
+
exports.buildVerifyActCompletionSystemPrompt = buildVerifyActCompletionSystemPrompt;
|
|
5
|
+
exports.buildVerifyActCompletionUserPrompt = buildVerifyActCompletionUserPrompt;
|
|
6
|
+
exports.buildActSystemPrompt = buildActSystemPrompt;
|
|
7
|
+
exports.buildActUserPrompt = buildActUserPrompt;
|
|
8
|
+
exports.buildExtractSystemPrompt = buildExtractSystemPrompt;
|
|
9
|
+
exports.buildExtractUserPrompt = buildExtractUserPrompt;
|
|
10
|
+
exports.buildRefineSystemPrompt = buildRefineSystemPrompt;
|
|
11
|
+
exports.buildRefineUserPrompt = buildRefineUserPrompt;
|
|
12
|
+
exports.buildMetadataSystemPrompt = buildMetadataSystemPrompt;
|
|
13
|
+
exports.buildMetadataPrompt = buildMetadataPrompt;
|
|
14
|
+
exports.buildObserveSystemPrompt = buildObserveSystemPrompt;
|
|
15
|
+
exports.buildObserveUserMessage = buildObserveUserMessage;
|
|
16
|
+
exports.buildAskSystemPrompt = buildAskSystemPrompt;
|
|
17
|
+
exports.buildAskUserPrompt = buildAskUserPrompt;
|
|
18
|
+
// act
|
|
19
|
+
const actSystemPrompt = `
|
|
20
|
+
# Instructions
|
|
21
|
+
You are a browser automation assistant. Your job is to accomplish the user's goal across multiple model calls.
|
|
22
|
+
|
|
23
|
+
You are given:
|
|
24
|
+
1. the user's overall goal
|
|
25
|
+
2. the steps that you've taken so far
|
|
26
|
+
3. a list of active DOM elements in this chunk to consider to get closer to the goal.
|
|
27
|
+
|
|
28
|
+
You have 2 tools that you can call: doAction, and skipSection. Do action only performs Playwright actions. Do not perform any other actions.
|
|
29
|
+
|
|
30
|
+
Note: If there is a popup on the page for cookies or advertising that has nothing to do with the goal, try to close it first before proceeding. As this can block the goal from being completed.
|
|
31
|
+
|
|
32
|
+
Also, verify if the goal has been accomplished already. Do this by checking if the goal has been accomplished based on the previous steps completed, the current page DOM elements and the current page URL / starting page URL. If it has, set completed to true and finish the task.
|
|
33
|
+
|
|
34
|
+
Do exactly what the user's goal is. Do not exceed the scope of the goal.
|
|
35
|
+
`;
|
|
36
|
+
const verifyActCompletionSystemPrompt = `
|
|
37
|
+
You are a browser automation assistant. The job has given you a goal and a list of steps that have been taken so far. Your job is to determine if the user's goal has been completed based on the provided information.
|
|
38
|
+
|
|
39
|
+
# Input
|
|
40
|
+
You will receive:
|
|
41
|
+
1. The user's goal: A clear description of what the user wants to achieve.
|
|
42
|
+
2. Steps taken so far: A list of actions that have been performed up to this point.
|
|
43
|
+
3. An image of the current page
|
|
44
|
+
|
|
45
|
+
# Your Task
|
|
46
|
+
Analyze the provided information to determine if the user's goal has been fully completed.
|
|
47
|
+
|
|
48
|
+
# Output
|
|
49
|
+
Return a boolean value:
|
|
50
|
+
- true: If the goal has been definitively completed based on the steps taken and the current page.
|
|
51
|
+
- false: If the goal has not been completed or if there's any uncertainty about its completion.
|
|
52
|
+
|
|
53
|
+
# Important Considerations
|
|
54
|
+
- False positives are okay. False negatives are not okay.
|
|
55
|
+
- Look for evidence of errors on the page or something having gone wrong in completing the goal. If one does not exist, return true.
|
|
56
|
+
`;
|
|
57
|
+
// ## Examples for completion check
|
|
58
|
+
// ### Example 1
|
|
59
|
+
// 1. User's goal: "input data scientist into role"
|
|
60
|
+
// 2. Steps you've taken so far: "The role input field was filled with 'data scientist'."
|
|
61
|
+
// 3. Active DOM elements: ["<input id="c9" class="VfPpkd-fmcmS-wGMbrd " aria-expanded="false" data-axe="mdc-autocomplete">data scientist</input>", "<button class="VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-INsAgc lJ9FBc nDgy9d" type="submit">Search</button>"]
|
|
62
|
+
// Output: Will need to have completed set to true. Nothing else matters.
|
|
63
|
+
// Reasoning: The goal the user set has already been accomplished. We should not take any extra actions outside of the scope of the goal (for example, clicking on the search button is an invalid action - ie: not acceptable).
|
|
64
|
+
// ### Example 2
|
|
65
|
+
// 1. User's goal: "Sign up for the newsletter"
|
|
66
|
+
// 2. Steps you've taken so far: ["The email input field was filled with 'test@test.com'."]
|
|
67
|
+
// 3. Active DOM elements: ["<input type='email' id='newsletter-email' placeholder='Enter your email'></input>", "<button id='subscribe-button'>Subscribe</button>"]
|
|
68
|
+
// Output: Will need to have click on the subscribe button as action. And completed set to false.
|
|
69
|
+
// Reasoning: There might be an error when trying to submit the form and you need to make sure the goal is accomplished properly. So you set completed to false.
|
|
70
|
+
function buildVerifyActCompletionSystemPrompt() {
|
|
71
|
+
return {
|
|
72
|
+
role: "system",
|
|
73
|
+
content: verifyActCompletionSystemPrompt,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function buildVerifyActCompletionUserPrompt(goal, steps = "None", domElements) {
|
|
77
|
+
let actUserPrompt = `
|
|
78
|
+
# My Goal
|
|
79
|
+
${goal}
|
|
80
|
+
|
|
81
|
+
# Steps You've Taken So Far
|
|
82
|
+
${steps}
|
|
83
|
+
`;
|
|
84
|
+
if (domElements) {
|
|
85
|
+
actUserPrompt += `
|
|
86
|
+
# Active DOM Elements on the current page
|
|
87
|
+
${domElements}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
role: "user",
|
|
92
|
+
content: actUserPrompt,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function buildActSystemPrompt() {
|
|
96
|
+
return {
|
|
97
|
+
role: "system",
|
|
98
|
+
content: actSystemPrompt,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function buildActUserPrompt(action, steps = "None", domElements) {
|
|
102
|
+
const actUserPrompt = `
|
|
103
|
+
# My Goal
|
|
104
|
+
${action}
|
|
105
|
+
|
|
106
|
+
# Steps You've Taken So Far
|
|
107
|
+
${steps}
|
|
108
|
+
|
|
109
|
+
# Current Active Dom Elements
|
|
110
|
+
${domElements}
|
|
111
|
+
`;
|
|
112
|
+
return {
|
|
113
|
+
role: "user",
|
|
114
|
+
content: actUserPrompt,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
exports.actTools = [
|
|
118
|
+
{
|
|
119
|
+
type: "function",
|
|
120
|
+
function: {
|
|
121
|
+
name: "doAction",
|
|
122
|
+
description: "execute the next playwright step that directly accomplishes the goal",
|
|
123
|
+
parameters: {
|
|
124
|
+
type: "object",
|
|
125
|
+
required: ["method", "element", "args", "step", "completed"],
|
|
126
|
+
properties: {
|
|
127
|
+
method: {
|
|
128
|
+
type: "string",
|
|
129
|
+
description: "The playwright function to call.",
|
|
130
|
+
},
|
|
131
|
+
element: {
|
|
132
|
+
type: "number",
|
|
133
|
+
description: "The element number to act on",
|
|
134
|
+
},
|
|
135
|
+
args: {
|
|
136
|
+
type: "array",
|
|
137
|
+
description: "The required arguments",
|
|
138
|
+
items: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "The argument to pass to the function",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
step: {
|
|
144
|
+
type: "string",
|
|
145
|
+
description: "human readable description of the step that is taken in the past tense. Please be very detailed.",
|
|
146
|
+
},
|
|
147
|
+
why: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "why is this step taken? how does it advance the goal?",
|
|
150
|
+
},
|
|
151
|
+
completed: {
|
|
152
|
+
type: "boolean",
|
|
153
|
+
description: "true if the goal should be accomplished after this step",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: "function",
|
|
161
|
+
function: {
|
|
162
|
+
name: "skipSection",
|
|
163
|
+
description: "skips this area of the webpage because the current goal cannot be accomplished here",
|
|
164
|
+
parameters: {
|
|
165
|
+
type: "object",
|
|
166
|
+
properties: {
|
|
167
|
+
reason: {
|
|
168
|
+
type: "string",
|
|
169
|
+
description: "reason that no action is taken",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
// extract
|
|
177
|
+
const extractSystemPrompt = `You are extracting content on behalf of a user. You will be given:
|
|
178
|
+
1. An instruction
|
|
179
|
+
2. A list of DOM elements to extract from
|
|
180
|
+
|
|
181
|
+
Print the exact text from the DOM elements with all symbols, characters, and endlines as is.
|
|
182
|
+
Print null or an empty string if no new information is found.
|
|
183
|
+
|
|
184
|
+
ONLY print the content using the print_extracted_data tool provided.
|
|
185
|
+
ONLY print the content using the print_extracted_data tool provided.
|
|
186
|
+
`;
|
|
187
|
+
function buildExtractSystemPrompt() {
|
|
188
|
+
const content = extractSystemPrompt.replace(/\s+/g, " ");
|
|
189
|
+
return {
|
|
190
|
+
role: "system",
|
|
191
|
+
content,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function buildExtractUserPrompt(instruction, domElements) {
|
|
195
|
+
return {
|
|
196
|
+
role: "user",
|
|
197
|
+
content: `Instruction: ${instruction}
|
|
198
|
+
DOM: ${domElements}
|
|
199
|
+
|
|
200
|
+
ONLY print the content using the print_extracted_data tool provided.
|
|
201
|
+
ONLY print the content using the print_extracted_data tool provided.`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const refineSystemPrompt = `You are tasked with refining and filtering information for the final output based on newly extracted and previously extracted content. Your responsibilities are:
|
|
205
|
+
1. Remove exact duplicates for elements in arrays and objects.
|
|
206
|
+
2. For text fields, append or update relevant text if the new content is an extension, replacement, or continuation.
|
|
207
|
+
3. For non-text fields (e.g., numbers, booleans), update with new values if they differ.
|
|
208
|
+
4. Add any completely new fields or objects.
|
|
209
|
+
|
|
210
|
+
Return the updated content that includes both the previous content and the new, non-duplicate, or extended information.`;
|
|
211
|
+
function buildRefineSystemPrompt() {
|
|
212
|
+
return {
|
|
213
|
+
role: "system",
|
|
214
|
+
content: refineSystemPrompt,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function buildRefineUserPrompt(instruction, previouslyExtractedContent, newlyExtractedContent) {
|
|
218
|
+
return {
|
|
219
|
+
role: "user",
|
|
220
|
+
content: `Instruction: ${instruction}
|
|
221
|
+
Previously extracted content: ${JSON.stringify(previouslyExtractedContent, null, 2)}
|
|
222
|
+
Newly extracted content: ${JSON.stringify(newlyExtractedContent, null, 2)}
|
|
223
|
+
Refined content:`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const metadataSystemPrompt = `You are an AI assistant tasked with evaluating the progress and completion status of an extraction task.
|
|
227
|
+
Analyze the extraction response and determine if the task is completed or if more information is needed.
|
|
228
|
+
|
|
229
|
+
Strictly abide by the following criteria:
|
|
230
|
+
1. Once the instruction has been satisfied by the current extraction response, ALWAYS set completion status to true and stop processing, regardless of remaining chunks.
|
|
231
|
+
2. Only set completion status to false if BOTH of these conditions are true:
|
|
232
|
+
- The instruction has not been satisfied yet
|
|
233
|
+
- There are still chunks left to process (chunksTotal > chunksSeen)`;
|
|
234
|
+
function buildMetadataSystemPrompt() {
|
|
235
|
+
return {
|
|
236
|
+
role: "system",
|
|
237
|
+
content: metadataSystemPrompt,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function buildMetadataPrompt(instruction, extractionResponse, chunksSeen, chunksTotal) {
|
|
241
|
+
return {
|
|
242
|
+
role: "user",
|
|
243
|
+
content: `Instruction: ${instruction}
|
|
244
|
+
Extracted content: ${JSON.stringify(extractionResponse, null, 2)}
|
|
245
|
+
chunksSeen: ${chunksSeen}
|
|
246
|
+
chunksTotal: ${chunksTotal}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// observe
|
|
250
|
+
const observeSystemPrompt = `
|
|
251
|
+
You are helping the user automate the browser by finding elements based on what the user wants to observe in the page.
|
|
252
|
+
You will be given:
|
|
253
|
+
1. a instruction of elements to observe
|
|
254
|
+
2. a numbered list of possible elements or an annotated image of the page
|
|
255
|
+
|
|
256
|
+
Return an array of elements that match the instruction.
|
|
257
|
+
`;
|
|
258
|
+
function buildObserveSystemPrompt() {
|
|
259
|
+
const content = observeSystemPrompt.replace(/\s+/g, " ");
|
|
260
|
+
return {
|
|
261
|
+
role: "system",
|
|
262
|
+
content,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function buildObserveUserMessage(instruction, domElements) {
|
|
266
|
+
return {
|
|
267
|
+
role: "user",
|
|
268
|
+
content: `instruction: ${instruction}
|
|
269
|
+
DOM: ${domElements}`,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// ask
|
|
273
|
+
const askSystemPrompt = `
|
|
274
|
+
you are a simple question answering assistent given the user's question. respond with only the answer.
|
|
275
|
+
`;
|
|
276
|
+
function buildAskSystemPrompt() {
|
|
277
|
+
return {
|
|
278
|
+
role: "system",
|
|
279
|
+
content: askSystemPrompt,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function buildAskUserPrompt(question) {
|
|
283
|
+
return {
|
|
284
|
+
role: "user",
|
|
285
|
+
content: `question: ${question}`,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../lib/prompt.ts"],"names":[],"mappings":";;;AA4DA,oFAKC;AAED,gFAwBC;AAED,oDAKC;AAED,gDAoBC;AA+ED,4DAMC;AAED,wDAYC;AAUD,0DAKC;AAED,sDAYC;AAWD,8DAKC;AAED,kDAaC;AAWD,4DAOC;AAED,0DASC;AAMD,oDAKC;AAED,gDAOC;AAtUD,MAAM;AACN,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAC;AAEF,mCAAmC;AACnC,gBAAgB;AAChB,mDAAmD;AACnD,yFAAyF;AACzF,4PAA4P;AAE5P,yEAAyE;AACzE,gOAAgO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;QACd,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAChC,QAAgB;IAEhB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,aAAa,QAAQ,EAAE;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ScreenshotService = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
class ScreenshotService {
|
|
21
|
+
constructor(page, selectorMap, verbose, isDebugEnabled = false) {
|
|
22
|
+
this.annotationBoxes = [];
|
|
23
|
+
this.numberPositions = [];
|
|
24
|
+
this.page = page;
|
|
25
|
+
this.selectorMap = selectorMap;
|
|
26
|
+
this.isDebugEnabled = isDebugEnabled;
|
|
27
|
+
this.verbose = verbose;
|
|
28
|
+
}
|
|
29
|
+
log({ category, message, level = 1, }) {
|
|
30
|
+
if (this.verbose >= level) {
|
|
31
|
+
const categoryString = category ? `:${category}` : "";
|
|
32
|
+
console.log(`[stagehand${categoryString}] ${message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getScreenshot() {
|
|
36
|
+
return __awaiter(this, arguments, void 0, function* (fullpage = true, quality) {
|
|
37
|
+
if (quality && (quality < 0 || quality > 100)) {
|
|
38
|
+
throw new Error("quality must be between 0 and 100");
|
|
39
|
+
}
|
|
40
|
+
return yield this.page.screenshot({
|
|
41
|
+
fullPage: fullpage,
|
|
42
|
+
quality,
|
|
43
|
+
type: "jpeg",
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getScreenshotPixelCount(screenshot) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const image = (0, sharp_1.default)(screenshot);
|
|
50
|
+
const metadata = yield image.metadata();
|
|
51
|
+
if (!metadata.width || !metadata.height) {
|
|
52
|
+
this.log({
|
|
53
|
+
category: "Error",
|
|
54
|
+
message: "Unable to determine image dimensions.",
|
|
55
|
+
level: 0,
|
|
56
|
+
});
|
|
57
|
+
throw new Error("Unable to determine image dimensions.");
|
|
58
|
+
}
|
|
59
|
+
const pixelCount = metadata.width * metadata.height;
|
|
60
|
+
this.log({
|
|
61
|
+
category: "Info",
|
|
62
|
+
message: `Screenshot pixel count: ${pixelCount}`,
|
|
63
|
+
level: 1,
|
|
64
|
+
});
|
|
65
|
+
return pixelCount;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getAnnotatedScreenshot(fullpage) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
this.annotationBoxes = [];
|
|
71
|
+
this.numberPositions = [];
|
|
72
|
+
const screenshot = yield this.getScreenshot(fullpage);
|
|
73
|
+
const image = (0, sharp_1.default)(screenshot);
|
|
74
|
+
const { width, height } = yield image.metadata();
|
|
75
|
+
// this.log({
|
|
76
|
+
// category: "Debug",
|
|
77
|
+
// message: `Annotating screenshot ${JSON.stringify(this.selectorMap)}`,
|
|
78
|
+
// level: 2,
|
|
79
|
+
// });
|
|
80
|
+
const svgAnnotations = yield Promise.all(Object.entries(this.selectorMap).map((_a) => __awaiter(this, [_a], void 0, function* ([id, selector]) { return this.createElementAnnotation(id, selector); })));
|
|
81
|
+
const scrollPosition = yield this.page.evaluate(() => {
|
|
82
|
+
return {
|
|
83
|
+
scrollX: window.scrollX,
|
|
84
|
+
scrollY: window.scrollY,
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const svg = `
|
|
88
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" style="position:absolute;left:${-scrollPosition.scrollX}px;top:${-scrollPosition.scrollY}px;">
|
|
89
|
+
${svgAnnotations.join("")}
|
|
90
|
+
</svg>
|
|
91
|
+
`;
|
|
92
|
+
const annotatedScreenshot = yield image
|
|
93
|
+
.composite([{ input: Buffer.from(svg), top: 0, left: 0 }])
|
|
94
|
+
.toBuffer();
|
|
95
|
+
if (this.isDebugEnabled) {
|
|
96
|
+
yield ScreenshotService.saveAndOpenScreenshot(annotatedScreenshot);
|
|
97
|
+
}
|
|
98
|
+
return annotatedScreenshot;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
createElementAnnotation(id, selector) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
const element = yield this.page.locator(`xpath=${selector}`).first();
|
|
105
|
+
const box = yield element.boundingBox();
|
|
106
|
+
if (!box) {
|
|
107
|
+
this.log({
|
|
108
|
+
category: "Debug",
|
|
109
|
+
message: `No bounding box for element ${id}`,
|
|
110
|
+
level: 2,
|
|
111
|
+
});
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
const scrollPosition = yield this.page.evaluate(() => ({
|
|
115
|
+
scrollX: window.scrollX,
|
|
116
|
+
scrollY: window.scrollY,
|
|
117
|
+
}));
|
|
118
|
+
const adjustedBox = {
|
|
119
|
+
x: box.x + scrollPosition.scrollX,
|
|
120
|
+
y: box.y + scrollPosition.scrollY,
|
|
121
|
+
width: box.width,
|
|
122
|
+
height: box.height,
|
|
123
|
+
id: id,
|
|
124
|
+
};
|
|
125
|
+
this.annotationBoxes.push(adjustedBox);
|
|
126
|
+
const numberPosition = this.findNonOverlappingNumberPosition(adjustedBox);
|
|
127
|
+
const circleRadius = 12;
|
|
128
|
+
return `
|
|
129
|
+
<rect x="${adjustedBox.x}" y="${adjustedBox.y}" width="${adjustedBox.width}" height="${adjustedBox.height}"
|
|
130
|
+
fill="none" stroke="red" stroke-width="2" />
|
|
131
|
+
<circle cx="${numberPosition.x}" cy="${numberPosition.y}" r="${circleRadius}" fill="white" stroke="red" stroke-width="2" />
|
|
132
|
+
<text x="${numberPosition.x}" y="${numberPosition.y}" fill="red" font-size="16" font-weight="bold"
|
|
133
|
+
text-anchor="middle" dominant-baseline="central">
|
|
134
|
+
${id}
|
|
135
|
+
</text>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
this.log({
|
|
140
|
+
category: "Error",
|
|
141
|
+
message: `Failed to create annotation for element ${id}: ${error}`,
|
|
142
|
+
level: 0,
|
|
143
|
+
});
|
|
144
|
+
return "";
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
findNonOverlappingNumberPosition(box) {
|
|
149
|
+
const circleRadius = 12;
|
|
150
|
+
let position = {
|
|
151
|
+
x: box.x - circleRadius,
|
|
152
|
+
y: box.y - circleRadius,
|
|
153
|
+
};
|
|
154
|
+
let attempts = 0;
|
|
155
|
+
const maxAttempts = 10;
|
|
156
|
+
const offset = 5;
|
|
157
|
+
while (this.isNumberOverlapping(position) && attempts < maxAttempts) {
|
|
158
|
+
position.y += offset;
|
|
159
|
+
attempts++;
|
|
160
|
+
}
|
|
161
|
+
this.numberPositions.push(position);
|
|
162
|
+
return position;
|
|
163
|
+
}
|
|
164
|
+
isNumberOverlapping(position) {
|
|
165
|
+
const circleRadius = 12;
|
|
166
|
+
return this.numberPositions.some((existingPosition) => Math.sqrt(Math.pow(position.x - existingPosition.x, 2) +
|
|
167
|
+
Math.pow(position.y - existingPosition.y, 2)) <
|
|
168
|
+
circleRadius * 2);
|
|
169
|
+
}
|
|
170
|
+
static saveAndOpenScreenshot(screenshot) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
const screenshotDir = path_1.default.join(process.cwd(), "screenshots");
|
|
173
|
+
if (!fs_1.default.existsSync(screenshotDir)) {
|
|
174
|
+
fs_1.default.mkdirSync(screenshotDir);
|
|
175
|
+
}
|
|
176
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
177
|
+
const filename = path_1.default.join(screenshotDir, `screenshot-${timestamp}.png`);
|
|
178
|
+
fs_1.default.writeFileSync(filename, screenshot);
|
|
179
|
+
console.log(`Screenshot saved to: ${filename}`);
|
|
180
|
+
// Open the screenshot with the default image viewer
|
|
181
|
+
if (process.platform === "win32") {
|
|
182
|
+
(0, child_process_1.exec)(`start ${filename}`);
|
|
183
|
+
}
|
|
184
|
+
else if (process.platform === "darwin") {
|
|
185
|
+
(0, child_process_1.exec)(`open ${filename}`);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
(0, child_process_1.exec)(`xdg-open ${filename}`);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.ScreenshotService = ScreenshotService;
|
|
194
|
+
//# sourceMappingURL=vision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vision.js","sourceRoot":"","sources":["../../lib/vision.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAqC;AAerC,MAAa,iBAAiB;IAQ5B,YACE,IAAU,EACV,WAAmC,EACnC,OAAkB,EAClB,iBAA0B,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D,oDAAoD;YACpD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;gBACjC,IAAA,oBAAI,EAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;YAC5B,CAAC;iBAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBACzC,IAAA,oBAAI,EAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,IAAA,oBAAI,EAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;KAAA;CACF;AAhOD,8CAgOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserbasehq/stagehand",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-alpha.1",
|
|
4
4
|
"description": "An AI web browsing framework focused on simplicity and extensibility.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@anthropic-ai/sdk": "^0.27.3",
|
|
53
|
+
"@browserbasehq/sdk": "^2.0.0",
|
|
53
54
|
"anthropic": "^0.0.0",
|
|
54
55
|
"anthropic-ai": "^0.0.10",
|
|
55
56
|
"sharp": "^0.33.5",
|