@browserbasehq/browse-cli 0.4.2-alpha-2df4b01 → 0.5.0-alpha-666baf1
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 +85 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -164652,7 +164652,7 @@ var import_child_process4 = require("child_process");
|
|
|
164652
164652
|
var readline = __toESM(require("readline"));
|
|
164653
164653
|
|
|
164654
164654
|
// package.json
|
|
164655
|
-
var version3 = "0.
|
|
164655
|
+
var version3 = "0.5.0";
|
|
164656
164656
|
|
|
164657
164657
|
// src/local-strategy.ts
|
|
164658
164658
|
init_cjs_shims();
|
|
@@ -164843,6 +164843,9 @@ function getLocalConfigPath(session) {
|
|
|
164843
164843
|
function getLocalInfoPath(session) {
|
|
164844
164844
|
return path11.join(SOCKET_DIR, `browse-${session}.local-info`);
|
|
164845
164845
|
}
|
|
164846
|
+
function getSessionParamsPath(session) {
|
|
164847
|
+
return path11.join(SOCKET_DIR, `browse-${session}.session-params`);
|
|
164848
|
+
}
|
|
164846
164849
|
async function readLocalConfig(session) {
|
|
164847
164850
|
try {
|
|
164848
164851
|
const raw = await import_fs11.promises.readFile(getLocalConfigPath(session), "utf-8");
|
|
@@ -165099,7 +165102,8 @@ async function cleanupStaleFiles(session) {
|
|
|
165099
165102
|
// Client-written config, only cleaned on full shutdown
|
|
165100
165103
|
getContextPath(session),
|
|
165101
165104
|
getConnectPath(session),
|
|
165102
|
-
getLocalConfigPath(session)
|
|
165105
|
+
getLocalConfigPath(session),
|
|
165106
|
+
getSessionParamsPath(session)
|
|
165103
165107
|
];
|
|
165104
165108
|
for (const file2 of files) {
|
|
165105
165109
|
try {
|
|
@@ -165176,6 +165180,12 @@ async function runDaemon(session, headless) {
|
|
|
165176
165180
|
connectSessionId = (await import_fs11.promises.readFile(getConnectPath(session), "utf-8")).trim();
|
|
165177
165181
|
} catch {
|
|
165178
165182
|
}
|
|
165183
|
+
let sessionParams = {};
|
|
165184
|
+
try {
|
|
165185
|
+
const raw = await import_fs11.promises.readFile(getSessionParamsPath(session), "utf-8");
|
|
165186
|
+
sessionParams = JSON.parse(raw);
|
|
165187
|
+
} catch {
|
|
165188
|
+
}
|
|
165179
165189
|
let localLaunchOptions;
|
|
165180
165190
|
let localInfo;
|
|
165181
165191
|
if (!useBrowserbase) {
|
|
@@ -165200,14 +165210,19 @@ async function runDaemon(session, headless) {
|
|
|
165200
165210
|
keepAlive: true
|
|
165201
165211
|
} : {},
|
|
165202
165212
|
...!connectSessionId ? {
|
|
165203
|
-
browserbaseSessionCreateParams: {
|
|
165204
|
-
|
|
165205
|
-
...
|
|
165213
|
+
browserbaseSessionCreateParams: (() => {
|
|
165214
|
+
const sessionBrowserSettings = sessionParams.browserSettings || {};
|
|
165215
|
+
const { browserSettings: _2, ...sessionParamsWithoutBS } = sessionParams;
|
|
165216
|
+
void _2;
|
|
165217
|
+
return {
|
|
165218
|
+
userMetadata: { browse_cli: "true" },
|
|
165219
|
+
...sessionParamsWithoutBS,
|
|
165206
165220
|
browserSettings: {
|
|
165207
|
-
|
|
165221
|
+
...sessionBrowserSettings,
|
|
165222
|
+
...contextConfig ? { context: contextConfig } : {}
|
|
165208
165223
|
}
|
|
165209
|
-
}
|
|
165210
|
-
}
|
|
165224
|
+
};
|
|
165225
|
+
})()
|
|
165211
165226
|
} : {}
|
|
165212
165227
|
} : {
|
|
165213
165228
|
localBrowserLaunchOptions: localLaunchOptions
|
|
@@ -166019,6 +166034,24 @@ function getSession(opts) {
|
|
|
166019
166034
|
function isHeadless(opts) {
|
|
166020
166035
|
return opts.headless === true && opts.headed !== true;
|
|
166021
166036
|
}
|
|
166037
|
+
function buildSessionParamsFromOpts(opts) {
|
|
166038
|
+
const params = {};
|
|
166039
|
+
const browserSettings = {};
|
|
166040
|
+
if (opts.proxies) params.proxies = true;
|
|
166041
|
+
if (opts.region) params.region = opts.region;
|
|
166042
|
+
if (opts.keepAlive) params.keepAlive = true;
|
|
166043
|
+
if (opts.sessionTimeout !== void 0) params.timeout = opts.sessionTimeout;
|
|
166044
|
+
if (opts.advancedStealth) browserSettings.advancedStealth = true;
|
|
166045
|
+
if (opts.blockAds) browserSettings.blockAds = true;
|
|
166046
|
+
if (opts.solveCaptchas !== void 0) {
|
|
166047
|
+
browserSettings.solveCaptchas = opts.solveCaptchas;
|
|
166048
|
+
}
|
|
166049
|
+
if (Object.keys(browserSettings).length > 0) {
|
|
166050
|
+
params.browserSettings = browserSettings;
|
|
166051
|
+
}
|
|
166052
|
+
if (Object.keys(params).length === 0) return null;
|
|
166053
|
+
return params;
|
|
166054
|
+
}
|
|
166022
166055
|
function output(data, json2) {
|
|
166023
166056
|
if (json2) {
|
|
166024
166057
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -166073,6 +166106,29 @@ async function runCommand(command, args) {
|
|
|
166073
166106
|
} catch {
|
|
166074
166107
|
}
|
|
166075
166108
|
}
|
|
166109
|
+
const sessionParams = buildSessionParamsFromOpts(opts);
|
|
166110
|
+
if (sessionParams) {
|
|
166111
|
+
const desiredMode = await getDesiredMode(session);
|
|
166112
|
+
if (desiredMode !== "browserbase") {
|
|
166113
|
+
console.error(
|
|
166114
|
+
JSON.stringify({
|
|
166115
|
+
error: "Session flags (--proxies, --advanced-stealth, etc.) are only supported in remote mode. Run 'browse env remote' first."
|
|
166116
|
+
})
|
|
166117
|
+
);
|
|
166118
|
+
process.exit(1);
|
|
166119
|
+
}
|
|
166120
|
+
const paramsPath = getSessionParamsPath(session);
|
|
166121
|
+
const newParamsJson = JSON.stringify(sessionParams);
|
|
166122
|
+
let currentParamsJson = "";
|
|
166123
|
+
try {
|
|
166124
|
+
currentParamsJson = await import_fs11.promises.readFile(paramsPath, "utf-8");
|
|
166125
|
+
} catch {
|
|
166126
|
+
}
|
|
166127
|
+
await import_fs11.promises.writeFile(paramsPath, newParamsJson);
|
|
166128
|
+
if (currentParamsJson !== newParamsJson && await isDaemonRunning(session)) {
|
|
166129
|
+
await stopDaemonAndCleanup(session);
|
|
166130
|
+
}
|
|
166131
|
+
}
|
|
166076
166132
|
await ensureDaemon(session, headless);
|
|
166077
166133
|
return sendCommand(session, command, args, headless);
|
|
166078
166134
|
}
|
|
@@ -166085,6 +166141,19 @@ program.name("browse").description("Browser automation CLI for AI agents").versi
|
|
|
166085
166141
|
).option(
|
|
166086
166142
|
"--connect <session-id>",
|
|
166087
166143
|
"Connect to an existing Browserbase session by ID"
|
|
166144
|
+
).option("--proxies", "Enable Browserbase proxy (remote only)").option("--advanced-stealth", "Enable advanced stealth mode (remote only)").option("--solve-captchas", "Enable automatic CAPTCHA solving (remote only)").option(
|
|
166145
|
+
"--no-solve-captchas",
|
|
166146
|
+
"Disable automatic CAPTCHA solving (remote only)"
|
|
166147
|
+
).option("--block-ads", "Enable ad blocking (remote only)").option(
|
|
166148
|
+
"--region <region>",
|
|
166149
|
+
"Session region: us-west-2, us-east-1, eu-central-1, ap-southeast-1 (remote only)"
|
|
166150
|
+
).option(
|
|
166151
|
+
"--keep-alive",
|
|
166152
|
+
"Keep session alive after disconnection (remote only)"
|
|
166153
|
+
).option(
|
|
166154
|
+
"--session-timeout <seconds>",
|
|
166155
|
+
"Session timeout in seconds (remote only)",
|
|
166156
|
+
parseInt
|
|
166088
166157
|
);
|
|
166089
166158
|
program.command("start").description("Start browser daemon (auto-started by other commands)").action(async () => {
|
|
166090
166159
|
const opts = program.opts();
|
|
@@ -166144,6 +166213,12 @@ program.command("status").description("Check daemon status").action(async () =>
|
|
|
166144
166213
|
};
|
|
166145
166214
|
}
|
|
166146
166215
|
}
|
|
166216
|
+
let sessionParams = null;
|
|
166217
|
+
try {
|
|
166218
|
+
const raw = await import_fs11.promises.readFile(getSessionParamsPath(session), "utf-8");
|
|
166219
|
+
sessionParams = JSON.parse(raw);
|
|
166220
|
+
} catch {
|
|
166221
|
+
}
|
|
166147
166222
|
console.log(
|
|
166148
166223
|
JSON.stringify({
|
|
166149
166224
|
running,
|
|
@@ -166151,7 +166226,8 @@ program.command("status").description("Check daemon status").action(async () =>
|
|
|
166151
166226
|
wsUrl,
|
|
166152
166227
|
mode,
|
|
166153
166228
|
browserbaseSessionId,
|
|
166154
|
-
...localDetails
|
|
166229
|
+
...localDetails,
|
|
166230
|
+
...sessionParams ? { sessionParams } : {}
|
|
166155
166231
|
})
|
|
166156
166232
|
);
|
|
166157
166233
|
});
|