browser-use 0.6.0 → 0.7.0

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.
Files changed (85) hide show
  1. package/README.md +29 -18
  2. package/dist/actor/element.js +24 -3
  3. package/dist/actor/mouse.js +21 -3
  4. package/dist/actor/page.js +33 -11
  5. package/dist/agent/gif.js +28 -3
  6. package/dist/agent/message-manager/service.js +2 -22
  7. package/dist/agent/message-manager/utils.js +15 -2
  8. package/dist/agent/message-manager/views.d.ts +7 -7
  9. package/dist/agent/message-manager/views.js +1 -0
  10. package/dist/agent/prompts.d.ts +3 -0
  11. package/dist/agent/prompts.js +22 -12
  12. package/dist/agent/service.d.ts +9 -1
  13. package/dist/agent/service.js +215 -81
  14. package/dist/agent/system_prompt.md +12 -11
  15. package/dist/agent/system_prompt_anthropic_flash.md +6 -5
  16. package/dist/agent/system_prompt_no_thinking.md +12 -11
  17. package/dist/agent/views.d.ts +2 -0
  18. package/dist/agent/views.js +48 -36
  19. package/dist/browser/extensions.js +20 -10
  20. package/dist/browser/profile.d.ts +4 -0
  21. package/dist/browser/profile.js +107 -4
  22. package/dist/browser/session.d.ts +28 -1
  23. package/dist/browser/session.js +1436 -528
  24. package/dist/browser/watchdogs/default-action-watchdog.js +32 -3
  25. package/dist/browser/watchdogs/downloads-watchdog.d.ts +4 -0
  26. package/dist/browser/watchdogs/downloads-watchdog.js +105 -9
  27. package/dist/browser/watchdogs/har-recording-watchdog.d.ts +1 -0
  28. package/dist/browser/watchdogs/har-recording-watchdog.js +54 -2
  29. package/dist/browser/watchdogs/permissions-watchdog.d.ts +5 -0
  30. package/dist/browser/watchdogs/permissions-watchdog.js +106 -3
  31. package/dist/browser/watchdogs/recording-watchdog.d.ts +2 -0
  32. package/dist/browser/watchdogs/recording-watchdog.js +54 -2
  33. package/dist/browser/watchdogs/security-watchdog.d.ts +1 -0
  34. package/dist/browser/watchdogs/security-watchdog.js +47 -7
  35. package/dist/browser/watchdogs/storage-state-watchdog.d.ts +6 -0
  36. package/dist/browser/watchdogs/storage-state-watchdog.js +206 -14
  37. package/dist/cli.d.ts +13 -2
  38. package/dist/cli.js +188 -8
  39. package/dist/code-use/namespace.js +52 -7
  40. package/dist/code-use/notebook-export.js +18 -2
  41. package/dist/code-use/service.js +1 -0
  42. package/dist/config.js +27 -5
  43. package/dist/controller/action-timeout.d.ts +9 -0
  44. package/dist/controller/action-timeout.js +95 -0
  45. package/dist/controller/registry/service.d.ts +1 -0
  46. package/dist/controller/registry/service.js +28 -1
  47. package/dist/controller/registry/views.d.ts +2 -0
  48. package/dist/controller/registry/views.js +44 -17
  49. package/dist/controller/service.d.ts +2 -1
  50. package/dist/controller/service.js +494 -329
  51. package/dist/filesystem/file-system.js +38 -8
  52. package/dist/integrations/gmail/service.js +30 -6
  53. package/dist/llm/browser-use/chat.js +2 -2
  54. package/dist/llm/codex/auth.d.ts +118 -0
  55. package/dist/llm/codex/auth.js +599 -0
  56. package/dist/llm/codex/chat.d.ts +70 -0
  57. package/dist/llm/codex/chat.js +392 -0
  58. package/dist/llm/codex/index.d.ts +2 -0
  59. package/dist/llm/codex/index.js +2 -0
  60. package/dist/llm/google/chat.js +18 -1
  61. package/dist/logging-config.js +22 -11
  62. package/dist/mcp/client.d.ts +1 -0
  63. package/dist/mcp/client.js +12 -10
  64. package/dist/mcp/redaction.d.ts +3 -0
  65. package/dist/mcp/redaction.js +132 -0
  66. package/dist/mcp/server.d.ts +2 -0
  67. package/dist/mcp/server.js +64 -22
  68. package/dist/observability.js +1 -1
  69. package/dist/screenshots/service.js +25 -2
  70. package/dist/skill-cli/direct.d.ts +4 -1
  71. package/dist/skill-cli/direct.js +260 -64
  72. package/dist/skill-cli/server.d.ts +1 -0
  73. package/dist/skill-cli/server.js +115 -25
  74. package/dist/skill-cli/tunnel.d.ts +1 -0
  75. package/dist/skill-cli/tunnel.js +16 -4
  76. package/dist/sync/auth.js +22 -9
  77. package/dist/telemetry/service.js +21 -2
  78. package/dist/telemetry/views.js +31 -8
  79. package/dist/tokens/custom-pricing.js +2 -2
  80. package/dist/tokens/openrouter-pricing.d.ts +11 -0
  81. package/dist/tokens/openrouter-pricing.js +102 -0
  82. package/dist/tokens/service.js +20 -16
  83. package/dist/utils.d.ts +3 -1
  84. package/dist/utils.js +4 -2
  85. package/package.json +75 -33
@@ -15,6 +15,38 @@ const getPageUrl = (page) => {
15
15
  }
16
16
  return candidate ?? '';
17
17
  };
18
+ // Render an action's param schema as compact JSON Schema for the LLM prompt.
19
+ // Replaces a prior raw dump of zod's private `_def` AST, which leaked
20
+ // internal keys like `innerType`/`defaultValue` and confused the LLM into
21
+ // copying default booleans into numeric fields (see scroll.num_pages bug).
22
+ export function renderParamsJsonSchema(schema, skipKeys) {
23
+ // `io: 'input'` makes zod render the *input* shape (what the LLM is
24
+ // expected to provide). Without it, fields with `.default(...)` get marked
25
+ // as required in the JSON Schema (because the parsed *output* always has
26
+ // them), which misleads the model — e.g. scroll.num_pages, done.success.
27
+ const raw = z.toJSONSchema(schema, {
28
+ io: 'input',
29
+ unrepresentable: 'any',
30
+ });
31
+ // Strip dialect noise the LLM doesn't need.
32
+ delete raw.$schema;
33
+ const properties = raw.properties ?? {};
34
+ const filteredProps = {};
35
+ for (const [key, value] of Object.entries(properties)) {
36
+ if (skipKeys.has(key)) {
37
+ continue;
38
+ }
39
+ filteredProps[key] = value;
40
+ }
41
+ raw.properties = filteredProps;
42
+ if (Array.isArray(raw.required)) {
43
+ raw.required = raw.required.filter((key) => typeof key === 'string' && !skipKeys.has(key));
44
+ if (raw.required.length === 0) {
45
+ delete raw.required;
46
+ }
47
+ }
48
+ return raw;
49
+ }
18
50
  export class RegisteredAction {
19
51
  name;
20
52
  description;
@@ -32,10 +64,12 @@ export class RegisteredAction {
32
64
  this.pageFilter = pageFilter;
33
65
  this.terminates_sequence = terminates_sequence;
34
66
  }
35
- promptDescription() {
67
+ // Returns the JSON Schema rendered for the LLM prompt, with the same
68
+ // skipKeys logic applied as in `promptDescription`. Exposed so tooling
69
+ // (e.g. scripts/dump-schema.ts) can exercise the exact code path the
70
+ // model sees.
71
+ getPromptJsonSchema() {
36
72
  const skipKeys = new Set(['title']);
37
- let description = `${this.description}: \n`;
38
- description += `{${this.name}: `;
39
73
  const schemaShape = (this.paramSchema instanceof z.ZodObject && this.paramSchema.shape) ||
40
74
  ('shape' in this.paramSchema ? this.paramSchema.shape : null);
41
75
  const hideStructuredDoneSuccess = Boolean(this.name === 'done' &&
@@ -46,26 +80,19 @@ export class RegisteredAction {
46
80
  if (hideStructuredDoneSuccess) {
47
81
  skipKeys.add('success');
48
82
  }
49
- const hideExtractOutputSchema = Boolean(this.name === 'extract_structured_data' &&
83
+ const hideExtractOutputSchema = Boolean((this.name === 'extract_structured_data' || this.name === 'extract') &&
50
84
  schemaShape &&
51
85
  typeof schemaShape === 'object' &&
52
86
  Object.prototype.hasOwnProperty.call(schemaShape, 'output_schema'));
53
87
  if (hideExtractOutputSchema) {
54
88
  skipKeys.add('output_schema');
55
89
  }
56
- if (schemaShape) {
57
- const props = Object.fromEntries(Object.entries(schemaShape)
58
- .filter(([key]) => !skipKeys.has(key))
59
- .map(([key, value]) => {
60
- const entries = value instanceof z.ZodType ? value._def : value;
61
- const cleanEntries = Object.fromEntries(Object.entries(entries).filter(([propKey]) => !skipKeys.has(propKey)));
62
- return [key, cleanEntries];
63
- }));
64
- description += JSON.stringify(props);
65
- }
66
- else {
67
- description += '{}';
68
- }
90
+ return renderParamsJsonSchema(this.paramSchema, skipKeys);
91
+ }
92
+ promptDescription() {
93
+ let description = `${this.description}: \n`;
94
+ description += `{${this.name}: `;
95
+ description += JSON.stringify(this.getPromptJsonSchema());
69
96
  description += '}';
70
97
  return description;
71
98
  }
@@ -24,6 +24,7 @@ export interface ActParams<Context = unknown> {
24
24
  file_system?: FileSystem | null;
25
25
  context?: Context | null;
26
26
  signal?: AbortSignal | null;
27
+ action_timeout?: number | null;
27
28
  }
28
29
  export declare class Controller<Context = unknown> {
29
30
  registry: Registry<Context>;
@@ -53,6 +54,6 @@ export declare class Controller<Context = unknown> {
53
54
  exclude_action(actionName: string): void;
54
55
  set_coordinate_clicking(enabled: boolean): void;
55
56
  action(description: string, options?: {}): <Params = any>(handler: import("./index.js").RegistryActionHandler<Params, Context>) => any;
56
- act(action: Record<string, unknown>, { browser_session, page_extraction_llm, sensitive_data, available_file_paths, file_system, context, signal, }: ActParams<Context>): Promise<ActionResult>;
57
+ act(action: Record<string, unknown>, { browser_session, page_extraction_llm, sensitive_data, available_file_paths, file_system, context, signal, action_timeout, }: ActParams<Context>): Promise<ActionResult>;
57
58
  }
58
59
  export {};