@browserbasehq/browse-cli 0.4.0 → 0.4.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/dist/index.js +20 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -100088,6 +100088,18 @@ Return the element that matches the instruction if it exists. Otherwise, return
|
|
|
100088
100088
|
content: [content, buildUserInstructionsString(userProvidedInstructions)].filter(Boolean).join("\n\n")
|
|
100089
100089
|
};
|
|
100090
100090
|
}
|
|
100091
|
+
function buildActVariablesPrompt(variables) {
|
|
100092
|
+
if (!variables || Object.keys(variables).length === 0) {
|
|
100093
|
+
return "";
|
|
100094
|
+
}
|
|
100095
|
+
const variableNames = Object.keys(variables).map((key) => `%${key}%`).join(", ");
|
|
100096
|
+
return ` The user has provided the following variables to be used in the action: ${variableNames}
|
|
100097
|
+
|
|
100098
|
+
Note that these are the variable names/keys, and not the actual variable values.
|
|
100099
|
+
|
|
100100
|
+
To use the variables in the action, you must respond with the variable name inside the 'arguments' array. The variable name must be wrapped in percentage signs (eg, %variableNameHere%) so that it can be replaced with the actual variable value before the action is taken.
|
|
100101
|
+
`;
|
|
100102
|
+
}
|
|
100091
100103
|
function buildActPrompt(action, supportedActions, variables) {
|
|
100092
100104
|
let instruction = `Find the most relevant element to perform an action on given the following action: ${action}.
|
|
100093
100105
|
IF AND ONLY IF the action EXPLICITLY includes the word 'dropdown' and implies choosing/selecting an option from a dropdown, ignore the 'General Instructions' section, and follow the 'Dropdown Specific Instructions' section carefully.
|
|
@@ -100114,11 +100126,7 @@ function buildActPrompt(action, supportedActions, variables) {
|
|
|
100114
100126
|
- choose the 'click' method
|
|
100115
100127
|
- set twoStep to true.
|
|
100116
100128
|
`;
|
|
100117
|
-
|
|
100118
|
-
const variableNames = Object.keys(variables).map((key) => `%${key}%`).join(", ");
|
|
100119
|
-
const variablesPrompt = `The following variables are available to use in the action: ${variableNames}. Fill the argument variables with the variable name.`;
|
|
100120
|
-
instruction += ` ${variablesPrompt}`;
|
|
100121
|
-
}
|
|
100129
|
+
instruction += buildActVariablesPrompt(variables);
|
|
100122
100130
|
return instruction;
|
|
100123
100131
|
}
|
|
100124
100132
|
function buildStepTwoPrompt(originalUserAction, previousAction, supportedActions, variables) {
|
|
@@ -100136,11 +100144,7 @@ function buildStepTwoPrompt(originalUserAction, previousAction, supportedActions
|
|
|
100136
100144
|
If the user is asking to scroll to the next chunk/previous chunk, choose the nextChunk/prevChunk method. No arguments are required here.
|
|
100137
100145
|
If the action implies a key press, e.g., 'press enter', 'press a', 'press space', etc., always choose the press method with the appropriate key as argument \u2014 e.g. 'a', 'Enter', 'Space'. Do not choose a click action on an on-screen keyboard. Capitalize the first character like 'Enter', 'Tab', 'Escape' only for special keys.
|
|
100138
100146
|
`;
|
|
100139
|
-
|
|
100140
|
-
const variableNames = Object.keys(variables).map((key) => `%${key}%`).join(", ");
|
|
100141
|
-
const variablesPrompt = `The following variables are available to use in the action: ${variableNames}. Fill the argument variables with the variable name.`;
|
|
100142
|
-
instruction += ` ${variablesPrompt}`;
|
|
100143
|
-
}
|
|
100147
|
+
instruction += buildActVariablesPrompt(variables);
|
|
100144
100148
|
return instruction;
|
|
100145
100149
|
}
|
|
100146
100150
|
function buildGoogleCUASystemPrompt() {
|
|
@@ -100448,7 +100452,7 @@ async function observe({ instruction, domElements, llmClient, userProvidedInstru
|
|
|
100448
100452
|
async function act({ instruction, domElements, llmClient, userProvidedInstructions, logger, logInferenceToFile = false }) {
|
|
100449
100453
|
const isGPT5 = llmClient.modelName.includes("gpt-5");
|
|
100450
100454
|
const actSchema = external_exports.object({
|
|
100451
|
-
elementId: external_exports.string().regex(/^\d+-\d+$/).describe("the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."),
|
|
100455
|
+
elementId: external_exports.string().regex(/^\d+-\d+$/).describe("the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'. for example, '0-76' or '16-21'"),
|
|
100452
100456
|
description: external_exports.string().describe("a description of the accessible element and its purpose"),
|
|
100453
100457
|
method: external_exports.enum(
|
|
100454
100458
|
// Use Object.values() for Zod v3 compatibility - z.enum() in v3 doesn't accept TypeScript enums directly
|
|
@@ -160612,7 +160616,9 @@ function hasInjectableDOM(url2) {
|
|
|
160612
160616
|
return false;
|
|
160613
160617
|
}
|
|
160614
160618
|
function isNonWebTarget(info) {
|
|
160615
|
-
|
|
160619
|
+
if (info.type === "page")
|
|
160620
|
+
return false;
|
|
160621
|
+
return info.type !== "iframe" || !hasInjectableDOM(info.url);
|
|
160616
160622
|
}
|
|
160617
160623
|
function isTopLevelPage(info) {
|
|
160618
160624
|
const ti = info;
|
|
@@ -164620,7 +164626,7 @@ var import_child_process4 = require("child_process");
|
|
|
164620
164626
|
var readline = __toESM(require("readline"));
|
|
164621
164627
|
|
|
164622
164628
|
// package.json
|
|
164623
|
-
var version3 = "0.4.
|
|
164629
|
+
var version3 = "0.4.1";
|
|
164624
164630
|
|
|
164625
164631
|
// src/resolve-ws.ts
|
|
164626
164632
|
init_cjs_shims();
|
|
@@ -165104,7 +165110,7 @@ async function runDaemon(session, headless) {
|
|
|
165104
165110
|
} : {},
|
|
165105
165111
|
...!connectSessionId ? {
|
|
165106
165112
|
browserbaseSessionCreateParams: {
|
|
165107
|
-
userMetadata: {
|
|
165113
|
+
userMetadata: { browse_cli: "true" },
|
|
165108
165114
|
...contextConfig ? {
|
|
165109
165115
|
browserSettings: {
|
|
165110
165116
|
context: contextConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserbasehq/browse-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Browser automation CLI for AI agents, built on Stagehand",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"pino": "^9.6.0",
|
|
48
48
|
"pino-pretty": "^13.0.0",
|
|
49
49
|
"ws": "^8.18.0",
|
|
50
|
-
"@browserbasehq/stagehand": "3.2.1-alpha-
|
|
50
|
+
"@browserbasehq/stagehand": "3.2.1-alpha-ad055f91530a84bd5d0735f7d5be82912580914b"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^20.11.30",
|