browser-use 0.7.0 → 0.7.2

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/cli.js CHANGED
@@ -34,6 +34,7 @@ import { get_browser_use_version } from './utils.js';
34
34
  import { setupLogging } from './logging-config.js';
35
35
  import { get_tunnel_manager } from './skill-cli/tunnel.js';
36
36
  import { DeviceAuthClient, save_cloud_api_token } from './sync/auth.js';
37
+ import { isMainModule } from './entrypoint.js';
37
38
  import dotenv from 'dotenv';
38
39
  dotenv.config({ quiet: true });
39
40
  const require = createRequire(import.meta.url);
@@ -2841,6 +2842,6 @@ export async function main(argv = process.argv.slice(2)) {
2841
2842
  process.exit(1);
2842
2843
  }
2843
2844
  }
2844
- if (import.meta.url === `file://${process.argv[1]}`) {
2845
- main();
2845
+ if (isMainModule(import.meta.url)) {
2846
+ void main();
2846
2847
  }
@@ -0,0 +1 @@
1
+ export declare const isMainModule: (moduleUrl: string, argv1?: string | undefined) => boolean;
@@ -0,0 +1,27 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const comparablePath = (filePath) => {
5
+ const absolutePath = path.resolve(filePath);
6
+ let resolvedPath = absolutePath;
7
+ try {
8
+ resolvedPath = fs.realpathSync.native(absolutePath);
9
+ }
10
+ catch {
11
+ resolvedPath = absolutePath;
12
+ }
13
+ return process.platform === 'win32'
14
+ ? resolvedPath.toLowerCase()
15
+ : resolvedPath;
16
+ };
17
+ export const isMainModule = (moduleUrl, argv1 = process.argv[1]) => {
18
+ if (!argv1) {
19
+ return false;
20
+ }
21
+ try {
22
+ return comparablePath(fileURLToPath(moduleUrl)) === comparablePath(argv1);
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ };
@@ -1,4 +1,4 @@
1
- import { GoogleGenAI } from '@google/genai';
1
+ import { GoogleGenAI, ThinkingLevel } from '@google/genai';
2
2
  import { ModelProviderError } from '../exceptions.js';
3
3
  import { ChatInvokeCompletion } from '../views.js';
4
4
  import { SchemaOptimizer, zodSchemaToJsonSchema } from '../schema.js';
@@ -19,6 +19,12 @@ const buildGoogleHttpOptions = (httpOptions) => {
19
19
  resolvedHttpOptions.headers = headers;
20
20
  return resolvedHttpOptions;
21
21
  };
22
+ const googleThinkingLevelByName = {
23
+ minimal: ThinkingLevel.MINIMAL,
24
+ low: ThinkingLevel.LOW,
25
+ medium: ThinkingLevel.MEDIUM,
26
+ high: ThinkingLevel.HIGH,
27
+ };
22
28
  export class ChatGoogle {
23
29
  model;
24
30
  provider = 'google';
@@ -212,15 +218,17 @@ export class ChatGoogle {
212
218
  async ainvoke(messages, output_format, options = {}) {
213
219
  const serializer = new GoogleMessageSerializer();
214
220
  const { contents, systemInstruction } = serializer.serializeWithSystem(messages, this.includeSystemInUser);
215
- const generationConfig = this.config ? { ...this.config } : {};
221
+ const requestConfig = this.config
222
+ ? { ...this.config }
223
+ : {};
216
224
  if (this.temperature !== null) {
217
- generationConfig.temperature = this.temperature;
225
+ requestConfig.temperature = this.temperature;
218
226
  }
219
227
  if (this.topP !== null) {
220
- generationConfig.topP = this.topP;
228
+ requestConfig.topP = this.topP;
221
229
  }
222
230
  if (this.seed !== null) {
223
- generationConfig.seed = this.seed;
231
+ requestConfig.seed = this.seed;
224
232
  }
225
233
  const isGemini3Pro = this.model.includes('gemini-3-pro');
226
234
  const isGemini3Flash = this.model.includes('gemini-3-flash');
@@ -229,18 +237,18 @@ export class ChatGoogle {
229
237
  if (level === 'minimal' || level === 'medium') {
230
238
  level = 'low';
231
239
  }
232
- generationConfig.thinkingConfig = {
233
- thinkingLevel: level.toUpperCase(),
240
+ requestConfig.thinkingConfig = {
241
+ thinkingLevel: googleThinkingLevelByName[level],
234
242
  };
235
243
  }
236
244
  else if (isGemini3Flash) {
237
245
  if (this.thinkingLevel !== null) {
238
- generationConfig.thinkingConfig = {
239
- thinkingLevel: this.thinkingLevel.toUpperCase(),
246
+ requestConfig.thinkingConfig = {
247
+ thinkingLevel: googleThinkingLevelByName[this.thinkingLevel],
240
248
  };
241
249
  }
242
250
  else {
243
- generationConfig.thinkingConfig = {
251
+ requestConfig.thinkingConfig = {
244
252
  thinkingBudget: this.thinkingBudget === null ? -1 : this.thinkingBudget,
245
253
  };
246
254
  }
@@ -253,11 +261,11 @@ export class ChatGoogle {
253
261
  budget = -1;
254
262
  }
255
263
  if (budget !== null) {
256
- generationConfig.thinkingConfig = { thinkingBudget: budget };
264
+ requestConfig.thinkingConfig = { thinkingBudget: budget };
257
265
  }
258
266
  }
259
267
  if (this.maxOutputTokens !== null) {
260
- generationConfig.maxOutputTokens = this.maxOutputTokens;
268
+ requestConfig.maxOutputTokens = this.maxOutputTokens;
261
269
  }
262
270
  // Try to get schema from output_format
263
271
  const schemaForJson = (() => {
@@ -289,8 +297,8 @@ export class ChatGoogle {
289
297
  }
290
298
  }
291
299
  if (cleanSchemaForJson && this.supportsStructuredOutput) {
292
- generationConfig.responseMimeType = 'application/json';
293
- generationConfig.responseSchema = cleanSchemaForJson;
300
+ requestConfig.responseMimeType = 'application/json';
301
+ requestConfig.responseSchema = cleanSchemaForJson;
294
302
  }
295
303
  const requestContents = contents.map((entry) => ({
296
304
  ...entry,
@@ -309,22 +317,25 @@ export class ChatGoogle {
309
317
  }
310
318
  }
311
319
  }
312
- const request = {
313
- model: this.model,
314
- contents: requestContents,
315
- };
316
320
  if (systemInstruction && !this.includeSystemInUser) {
317
- request.systemInstruction = {
321
+ requestConfig.systemInstruction = {
318
322
  role: 'system',
319
323
  parts: [{ text: systemInstruction }],
320
324
  };
321
325
  }
322
- if (Object.keys(generationConfig).length > 0) {
323
- request.generationConfig = generationConfig;
326
+ if (options.signal) {
327
+ requestConfig.abortSignal = options.signal;
328
+ }
329
+ const request = {
330
+ model: this.model,
331
+ contents: requestContents,
332
+ };
333
+ if (Object.keys(requestConfig).length > 0) {
334
+ request.config = requestConfig;
324
335
  }
325
336
  for (let attempt = 0; attempt < this.maxRetries; attempt += 1) {
326
337
  try {
327
- const result = await this.client.models.generateContent(request, options.signal ? { signal: options.signal } : undefined);
338
+ const result = await this.client.models.generateContent(request);
328
339
  const candidate = result.candidates?.[0];
329
340
  const textParts = candidate?.content?.parts?.filter((p) => p.text) || [];
330
341
  const text = textParts.map((p) => p.text).join('');
@@ -6,6 +6,7 @@ import net from 'node:net';
6
6
  import { spawn } from 'node:child_process';
7
7
  import { BrowserSession, systemChrome } from '../browser/session.js';
8
8
  import { CloudBrowserClient } from '../browser/cloud/cloud.js';
9
+ import { isMainModule } from '../entrypoint.js';
9
10
  const getSafeUserSegment = () => {
10
11
  if (typeof process.getuid === 'function') {
11
12
  return String(process.getuid());
@@ -1170,11 +1171,11 @@ export const run_direct_command = async (argv, options = {}) => {
1170
1171
  };
1171
1172
  export const main = async (argv = process.argv.slice(2)) => {
1172
1173
  const exitCode = await run_direct_command(argv);
1173
- if (import.meta.url === `file://${process.argv[1]}`) {
1174
+ if (isMainModule(import.meta.url)) {
1174
1175
  process.exit(exitCode);
1175
1176
  }
1176
1177
  return exitCode;
1177
1178
  };
1178
- if (import.meta.url === `file://${process.argv[1]}`) {
1179
+ if (isMainModule(import.meta.url)) {
1179
1180
  void main();
1180
1181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-use",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A TypeScript-first library for programmatic browser control, designed for building AI-powered web agents.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -354,7 +354,7 @@
354
354
  "@types/turndown": "^5.0.6",
355
355
  "@typescript-eslint/eslint-plugin": "^8.54.0",
356
356
  "@typescript-eslint/parser": "^8.54.0",
357
- "@vitest/coverage-v8": "^4.0.18",
357
+ "@vitest/coverage-v8": "^4.1.8",
358
358
  "commitizen": "^4.3.1",
359
359
  "cz-conventional-changelog": "^3.3.0",
360
360
  "eslint": "^9.39.2",
@@ -366,7 +366,7 @@
366
366
  "tsx": "^4.21.0",
367
367
  "typescript": "^5.9.3",
368
368
  "vite": "^7.3.2",
369
- "vitest": "^4.0.18"
369
+ "vitest": "^4.1.8"
370
370
  },
371
371
  "pnpm": {
372
372
  "onlyBuiltDependencies": [
@@ -384,7 +384,7 @@
384
384
  "fast-xml-builder": "1.2.0",
385
385
  "fast-xml-parser": "5.7.3",
386
386
  "flatted": "3.4.2",
387
- "hono": "4.12.18",
387
+ "hono": "4.12.23",
388
388
  "ip-address": "10.2.0",
389
389
  "lodash": "4.18.1",
390
390
  "minimatch": "10.2.4",
@@ -395,7 +395,7 @@
395
395
  "protobufjs": "7.6.1",
396
396
  "qs": "6.15.2",
397
397
  "rollup": "4.59.0",
398
- "tmp": "0.2.5",
398
+ "tmp": "0.2.6",
399
399
  "uuid": "11.1.1",
400
400
  "ws": "8.21.0"
401
401
  }