@browserbasehq/stagehand 1.0.3-alpha.2 → 1.0.3
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/dom/build/types.js +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +43 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,9 @@ declare class Stagehand {
|
|
|
81
81
|
debugUrl: string;
|
|
82
82
|
sessionUrl: string;
|
|
83
83
|
}>;
|
|
84
|
+
initFromPage(page: Page, modelName?: AvailableModel): Promise<{
|
|
85
|
+
context: BrowserContext;
|
|
86
|
+
}>;
|
|
84
87
|
private pending_logs_to_send_to_browserbase;
|
|
85
88
|
private is_processing_browserbase_logs;
|
|
86
89
|
log({ message, category, level, }: {
|
package/dist/index.js
CHANGED
|
@@ -283,8 +283,10 @@ var metadataSystemPrompt = `You are an AI assistant tasked with evaluating the p
|
|
|
283
283
|
Analyze the extraction response and determine if the task is completed or if more information is needed.
|
|
284
284
|
|
|
285
285
|
Strictly abide by the following criteria:
|
|
286
|
-
1.
|
|
287
|
-
2.
|
|
286
|
+
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.
|
|
287
|
+
2. Only set completion status to false if BOTH of these conditions are true:
|
|
288
|
+
- The instruction has not been satisfied yet
|
|
289
|
+
- There are still chunks left to process (chunksTotal > chunksSeen)`;
|
|
288
290
|
function buildMetadataSystemPrompt() {
|
|
289
291
|
return {
|
|
290
292
|
role: "system",
|
|
@@ -296,8 +298,8 @@ function buildMetadataPrompt(instruction, extractionResponse, chunksSeen, chunks
|
|
|
296
298
|
role: "user",
|
|
297
299
|
content: `Instruction: ${instruction}
|
|
298
300
|
Extracted content: ${JSON.stringify(extractionResponse, null, 2)}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
+
chunksSeen: ${chunksSeen}
|
|
302
|
+
chunksTotal: ${chunksTotal}`
|
|
301
303
|
};
|
|
302
304
|
}
|
|
303
305
|
var observeSystemPrompt = `
|
|
@@ -768,6 +770,9 @@ var LLMProvider = class {
|
|
|
768
770
|
}
|
|
769
771
|
};
|
|
770
772
|
|
|
773
|
+
// lib/index.ts
|
|
774
|
+
var import_path2 = __toESM(require("path"));
|
|
775
|
+
|
|
771
776
|
// lib/browserbase.ts
|
|
772
777
|
var Browserbase = class {
|
|
773
778
|
createSession() {
|
|
@@ -1169,11 +1174,44 @@ var Stagehand = class {
|
|
|
1169
1174
|
yield this.page.setViewportSize({ width: 1280, height: 720 });
|
|
1170
1175
|
}
|
|
1171
1176
|
yield this.page.addInitScript({
|
|
1172
|
-
|
|
1177
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "process.js")
|
|
1178
|
+
});
|
|
1179
|
+
yield this.page.addInitScript({
|
|
1180
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "utils.js")
|
|
1181
|
+
});
|
|
1182
|
+
yield this.page.addInitScript({
|
|
1183
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "debug.js")
|
|
1173
1184
|
});
|
|
1174
1185
|
return { debugUrl, sessionUrl };
|
|
1175
1186
|
});
|
|
1176
1187
|
}
|
|
1188
|
+
initFromPage(page, modelName) {
|
|
1189
|
+
return __async(this, null, function* () {
|
|
1190
|
+
this.page = page;
|
|
1191
|
+
this.context = page.context();
|
|
1192
|
+
this.defaultModelName = modelName || this.defaultModelName;
|
|
1193
|
+
const originalGoto = this.page.goto.bind(this.page);
|
|
1194
|
+
this.page.goto = (url, options) => __async(this, null, function* () {
|
|
1195
|
+
const result = yield originalGoto(url, options);
|
|
1196
|
+
yield this.page.waitForLoadState("domcontentloaded");
|
|
1197
|
+
yield this._waitForSettledDom();
|
|
1198
|
+
return result;
|
|
1199
|
+
});
|
|
1200
|
+
if (this.headless) {
|
|
1201
|
+
yield this.page.setViewportSize({ width: 1280, height: 720 });
|
|
1202
|
+
}
|
|
1203
|
+
yield this.page.addInitScript({
|
|
1204
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "process.js")
|
|
1205
|
+
});
|
|
1206
|
+
yield this.page.addInitScript({
|
|
1207
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "utils.js")
|
|
1208
|
+
});
|
|
1209
|
+
yield this.page.addInitScript({
|
|
1210
|
+
path: import_path2.default.join(__dirname, "..", "dist", "dom", "build", "debug.js")
|
|
1211
|
+
});
|
|
1212
|
+
return { context: this.context };
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1177
1215
|
log({
|
|
1178
1216
|
message,
|
|
1179
1217
|
category,
|
package/package.json
CHANGED