browser-use 0.2.0 → 0.3.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 (259) hide show
  1. package/README.md +295 -686
  2. package/dist/actor/element.d.ts +19 -0
  3. package/dist/actor/element.js +46 -0
  4. package/dist/actor/index.d.ts +4 -0
  5. package/dist/actor/index.js +4 -0
  6. package/dist/actor/mouse.d.ts +19 -0
  7. package/dist/actor/mouse.js +39 -0
  8. package/dist/actor/page.d.ts +29 -0
  9. package/dist/actor/page.js +88 -0
  10. package/dist/actor/utils.d.ts +4 -0
  11. package/dist/actor/utils.js +35 -0
  12. package/dist/agent/cloud-events.d.ts +18 -0
  13. package/dist/agent/cloud-events.js +65 -2
  14. package/dist/agent/gif.d.ts +1 -0
  15. package/dist/agent/gif.js +24 -2
  16. package/dist/agent/judge.d.ts +17 -0
  17. package/dist/agent/judge.js +197 -0
  18. package/dist/agent/message-manager/service.d.ts +12 -4
  19. package/dist/agent/message-manager/service.js +205 -39
  20. package/dist/agent/message-manager/utils.js +0 -1
  21. package/dist/agent/message-manager/views.d.ts +4 -0
  22. package/dist/agent/message-manager/views.js +11 -7
  23. package/dist/agent/prompts.d.ts +24 -3
  24. package/dist/agent/prompts.js +274 -59
  25. package/dist/agent/service.d.ts +99 -41
  26. package/dist/agent/service.js +2266 -472
  27. package/dist/agent/variable-detector.d.ts +12 -0
  28. package/dist/agent/variable-detector.js +211 -0
  29. package/dist/agent/views.d.ts +237 -18
  30. package/dist/agent/views.js +446 -33
  31. package/dist/browser/cloud/cloud.d.ts +20 -0
  32. package/dist/browser/cloud/cloud.js +129 -0
  33. package/dist/browser/cloud/index.d.ts +2 -0
  34. package/dist/browser/cloud/index.js +2 -0
  35. package/dist/browser/cloud/views.d.ts +41 -0
  36. package/dist/browser/cloud/views.js +35 -0
  37. package/dist/browser/events.d.ts +345 -0
  38. package/dist/browser/events.js +566 -0
  39. package/dist/browser/extensions.js +17 -17
  40. package/dist/browser/index.d.ts +4 -0
  41. package/dist/browser/index.js +4 -0
  42. package/dist/browser/profile.d.ts +8 -2
  43. package/dist/browser/profile.js +79 -12
  44. package/dist/browser/session-manager.d.ts +85 -0
  45. package/dist/browser/session-manager.js +208 -0
  46. package/dist/browser/session.d.ts +100 -8
  47. package/dist/browser/session.js +1097 -58
  48. package/dist/browser/types.d.ts +0 -2
  49. package/dist/browser/views.d.ts +39 -0
  50. package/dist/browser/views.js +32 -0
  51. package/dist/browser/watchdogs/aboutblank-watchdog.d.ts +12 -0
  52. package/dist/browser/watchdogs/aboutblank-watchdog.js +131 -0
  53. package/dist/browser/watchdogs/base.d.ts +21 -0
  54. package/dist/browser/watchdogs/base.js +81 -0
  55. package/dist/browser/watchdogs/cdp-session-watchdog.d.ts +14 -0
  56. package/dist/browser/watchdogs/cdp-session-watchdog.js +177 -0
  57. package/dist/browser/watchdogs/crash-watchdog.d.ts +38 -0
  58. package/dist/browser/watchdogs/crash-watchdog.js +296 -0
  59. package/dist/browser/watchdogs/default-action-watchdog.d.ts +49 -0
  60. package/dist/browser/watchdogs/default-action-watchdog.js +212 -0
  61. package/dist/browser/watchdogs/dom-watchdog.d.ts +8 -0
  62. package/dist/browser/watchdogs/dom-watchdog.js +31 -0
  63. package/dist/browser/watchdogs/downloads-watchdog.d.ts +77 -0
  64. package/dist/browser/watchdogs/downloads-watchdog.js +409 -0
  65. package/dist/browser/watchdogs/har-recording-watchdog.d.ts +19 -0
  66. package/dist/browser/watchdogs/har-recording-watchdog.js +317 -0
  67. package/dist/browser/watchdogs/index.d.ts +15 -0
  68. package/dist/browser/watchdogs/index.js +15 -0
  69. package/dist/browser/watchdogs/local-browser-watchdog.d.ts +10 -0
  70. package/dist/browser/watchdogs/local-browser-watchdog.js +32 -0
  71. package/dist/browser/watchdogs/permissions-watchdog.d.ts +8 -0
  72. package/dist/browser/watchdogs/permissions-watchdog.js +73 -0
  73. package/dist/browser/watchdogs/popups-watchdog.d.ts +13 -0
  74. package/dist/browser/watchdogs/popups-watchdog.js +77 -0
  75. package/dist/browser/watchdogs/recording-watchdog.d.ts +27 -0
  76. package/dist/browser/watchdogs/recording-watchdog.js +249 -0
  77. package/dist/browser/watchdogs/screenshot-watchdog.d.ts +6 -0
  78. package/dist/browser/watchdogs/screenshot-watchdog.js +13 -0
  79. package/dist/browser/watchdogs/security-watchdog.d.ts +10 -0
  80. package/dist/browser/watchdogs/security-watchdog.js +84 -0
  81. package/dist/browser/watchdogs/storage-state-watchdog.d.ts +24 -0
  82. package/dist/browser/watchdogs/storage-state-watchdog.js +288 -0
  83. package/dist/cli.d.ts +7 -2
  84. package/dist/cli.js +182 -25
  85. package/dist/code-use/formatting.d.ts +3 -0
  86. package/dist/code-use/formatting.js +18 -0
  87. package/dist/code-use/index.d.ts +6 -0
  88. package/dist/code-use/index.js +6 -0
  89. package/dist/code-use/namespace.d.ts +5 -0
  90. package/dist/code-use/namespace.js +81 -0
  91. package/dist/code-use/notebook-export.d.ts +3 -0
  92. package/dist/code-use/notebook-export.js +56 -0
  93. package/dist/code-use/service.d.ts +24 -0
  94. package/dist/code-use/service.js +104 -0
  95. package/dist/code-use/utils.d.ts +4 -0
  96. package/dist/code-use/utils.js +98 -0
  97. package/dist/code-use/views.d.ts +108 -0
  98. package/dist/code-use/views.js +165 -0
  99. package/dist/config.d.ts +13 -0
  100. package/dist/config.js +69 -3
  101. package/dist/controller/registry/service.d.ts +10 -1
  102. package/dist/controller/registry/service.js +266 -10
  103. package/dist/controller/registry/views.d.ts +4 -1
  104. package/dist/controller/registry/views.js +25 -2
  105. package/dist/controller/service.d.ts +10 -1
  106. package/dist/controller/service.js +1807 -268
  107. package/dist/controller/views.d.ts +78 -155
  108. package/dist/controller/views.js +61 -12
  109. package/dist/dom/history-tree-processor/service.d.ts +5 -0
  110. package/dist/dom/history-tree-processor/service.js +169 -14
  111. package/dist/dom/history-tree-processor/view.d.ts +7 -1
  112. package/dist/dom/history-tree-processor/view.js +10 -1
  113. package/dist/dom/markdown-extractor.d.ts +37 -0
  114. package/dist/dom/markdown-extractor.js +345 -0
  115. package/dist/dom/service.d.ts +3 -1
  116. package/dist/dom/service.js +76 -0
  117. package/dist/dom/views.d.ts +1 -0
  118. package/dist/dom/views.js +45 -0
  119. package/dist/event-bus.d.ts +107 -7
  120. package/dist/event-bus.js +313 -10
  121. package/dist/exceptions.d.ts +0 -3
  122. package/dist/exceptions.js +0 -7
  123. package/dist/filesystem/file-system.d.ts +18 -0
  124. package/dist/filesystem/file-system.js +503 -42
  125. package/dist/index.d.ts +7 -0
  126. package/dist/index.js +6 -0
  127. package/dist/integrations/gmail/actions.d.ts +3 -3
  128. package/dist/integrations/gmail/actions.js +4 -4
  129. package/dist/llm/anthropic/chat.d.ts +18 -1
  130. package/dist/llm/anthropic/chat.js +123 -55
  131. package/dist/llm/anthropic/serializer.d.ts +2 -0
  132. package/dist/llm/anthropic/serializer.js +81 -9
  133. package/dist/llm/aws/chat-anthropic.d.ts +17 -0
  134. package/dist/llm/aws/chat-anthropic.js +126 -26
  135. package/dist/llm/aws/chat-bedrock.d.ts +28 -1
  136. package/dist/llm/aws/chat-bedrock.js +161 -34
  137. package/dist/llm/aws/serializer.d.ts +13 -1
  138. package/dist/llm/aws/serializer.js +56 -17
  139. package/dist/llm/azure/chat.d.ts +53 -2
  140. package/dist/llm/azure/chat.js +366 -54
  141. package/dist/llm/base.d.ts +2 -0
  142. package/dist/llm/browser-use/chat.d.ts +40 -0
  143. package/dist/llm/browser-use/chat.js +305 -0
  144. package/dist/llm/browser-use/index.d.ts +1 -0
  145. package/dist/llm/browser-use/index.js +1 -0
  146. package/dist/llm/cerebras/chat.d.ts +39 -0
  147. package/dist/llm/cerebras/chat.js +178 -0
  148. package/dist/llm/cerebras/index.d.ts +2 -0
  149. package/dist/llm/cerebras/index.js +2 -0
  150. package/dist/llm/cerebras/serializer.d.ts +7 -0
  151. package/dist/llm/cerebras/serializer.js +82 -0
  152. package/dist/llm/deepseek/chat.d.ts +19 -2
  153. package/dist/llm/deepseek/chat.js +138 -25
  154. package/dist/llm/google/chat.d.ts +46 -2
  155. package/dist/llm/google/chat.js +267 -64
  156. package/dist/llm/google/serializer.d.ts +9 -1
  157. package/dist/llm/google/serializer.js +141 -34
  158. package/dist/llm/groq/chat.d.ts +21 -2
  159. package/dist/llm/groq/chat.js +125 -26
  160. package/dist/llm/groq/parser.js +3 -1
  161. package/dist/llm/mistral/chat.d.ts +43 -0
  162. package/dist/llm/mistral/chat.js +154 -0
  163. package/dist/llm/mistral/index.d.ts +2 -0
  164. package/dist/llm/mistral/index.js +2 -0
  165. package/dist/llm/mistral/schema.d.ts +8 -0
  166. package/dist/llm/mistral/schema.js +27 -0
  167. package/dist/llm/models.d.ts +2 -0
  168. package/dist/llm/models.js +317 -0
  169. package/dist/llm/ollama/chat.d.ts +13 -1
  170. package/dist/llm/ollama/chat.js +110 -19
  171. package/dist/llm/ollama/serializer.d.ts +1 -0
  172. package/dist/llm/ollama/serializer.js +34 -12
  173. package/dist/llm/openai/chat.d.ts +16 -0
  174. package/dist/llm/openai/chat.js +94 -44
  175. package/dist/llm/openai/like.d.ts +5 -3
  176. package/dist/llm/openai/like.js +7 -3
  177. package/dist/llm/openai/responses-serializer.d.ts +18 -0
  178. package/dist/llm/openai/responses-serializer.js +72 -0
  179. package/dist/llm/openrouter/chat.d.ts +28 -2
  180. package/dist/llm/openrouter/chat.js +115 -29
  181. package/dist/llm/schema.d.ts +11 -1
  182. package/dist/llm/schema.js +81 -1
  183. package/dist/llm/vercel/chat.d.ts +50 -0
  184. package/dist/llm/vercel/chat.js +276 -0
  185. package/dist/llm/vercel/index.d.ts +1 -0
  186. package/dist/llm/vercel/index.js +1 -0
  187. package/dist/llm/vercel/serializer.d.ts +5 -0
  188. package/dist/llm/vercel/serializer.js +7 -0
  189. package/dist/llm/views.d.ts +2 -1
  190. package/dist/llm/views.js +3 -1
  191. package/dist/logging-config.d.ts +2 -0
  192. package/dist/logging-config.js +82 -29
  193. package/dist/mcp/client.d.ts +10 -5
  194. package/dist/mcp/client.js +14 -9
  195. package/dist/mcp/controller.d.ts +42 -3
  196. package/dist/mcp/controller.js +56 -31
  197. package/dist/mcp/server.d.ts +14 -0
  198. package/dist/mcp/server.js +255 -52
  199. package/dist/observability.js +10 -4
  200. package/dist/sandbox/index.d.ts +2 -0
  201. package/dist/sandbox/index.js +2 -0
  202. package/dist/sandbox/sandbox.d.ts +19 -0
  203. package/dist/sandbox/sandbox.js +140 -0
  204. package/dist/sandbox/views.d.ts +67 -0
  205. package/dist/sandbox/views.js +121 -0
  206. package/dist/skill-cli/index.d.ts +3 -0
  207. package/dist/skill-cli/index.js +3 -0
  208. package/dist/skill-cli/protocol.d.ts +30 -0
  209. package/dist/skill-cli/protocol.js +48 -0
  210. package/dist/skill-cli/server.d.ts +11 -0
  211. package/dist/skill-cli/server.js +85 -0
  212. package/dist/skill-cli/sessions.d.ts +24 -0
  213. package/dist/skill-cli/sessions.js +47 -0
  214. package/dist/skills/index.d.ts +3 -0
  215. package/dist/skills/index.js +3 -0
  216. package/dist/skills/service.d.ts +27 -0
  217. package/dist/skills/service.js +266 -0
  218. package/dist/skills/utils.d.ts +6 -0
  219. package/dist/skills/utils.js +53 -0
  220. package/dist/skills/views.d.ts +40 -0
  221. package/dist/skills/views.js +10 -0
  222. package/dist/sync/auth.js +8 -3
  223. package/dist/sync/service.d.ts +6 -6
  224. package/dist/sync/service.js +54 -89
  225. package/dist/telemetry/views.d.ts +20 -6
  226. package/dist/telemetry/views.js +23 -5
  227. package/dist/tokens/custom-pricing.d.ts +2 -0
  228. package/dist/tokens/custom-pricing.js +22 -0
  229. package/dist/tokens/index.d.ts +2 -0
  230. package/dist/tokens/index.js +2 -0
  231. package/dist/tokens/mappings.d.ts +1 -0
  232. package/dist/tokens/mappings.js +3 -0
  233. package/dist/tokens/service.js +27 -8
  234. package/dist/tools/extraction/index.d.ts +2 -0
  235. package/dist/tools/extraction/index.js +2 -0
  236. package/dist/tools/extraction/schema-utils.d.ts +6 -0
  237. package/dist/tools/extraction/schema-utils.js +237 -0
  238. package/dist/tools/extraction/views.d.ts +7 -0
  239. package/dist/tools/index.d.ts +5 -0
  240. package/dist/tools/index.js +5 -0
  241. package/dist/tools/registry/index.d.ts +2 -0
  242. package/dist/tools/registry/index.js +2 -0
  243. package/dist/tools/registry/service.d.ts +1 -0
  244. package/dist/tools/registry/service.js +1 -0
  245. package/dist/tools/registry/views.d.ts +1 -0
  246. package/dist/tools/registry/views.js +1 -0
  247. package/dist/tools/service.d.ts +2 -0
  248. package/dist/tools/service.js +1 -0
  249. package/dist/tools/utils.d.ts +2 -0
  250. package/dist/tools/utils.js +57 -0
  251. package/dist/tools/views.d.ts +1 -0
  252. package/dist/tools/views.js +1 -0
  253. package/dist/utils.d.ts +10 -1
  254. package/dist/utils.js +70 -3
  255. package/package.json +87 -26
  256. package/dist/dom/playground/process-dom.js +0 -5
  257. package/dist/dom/playground/test-accessibility.d.ts +0 -44
  258. package/dist/dom/playground/test-accessibility.js +0 -111
  259. /package/dist/{dom/playground/process-dom.d.ts → tools/extraction/views.js} +0 -0
package/dist/cli.d.ts CHANGED
@@ -1,17 +1,21 @@
1
1
  #!/usr/bin/env node
2
+ import { BrowserProfile } from './browser/profile.js';
2
3
  import type { BaseChatModel } from './llm/base.js';
3
- type CliModelProvider = 'openai' | 'anthropic' | 'google' | 'deepseek' | 'groq' | 'openrouter' | 'azure' | 'aws-anthropic' | 'aws' | 'ollama';
4
+ type CliModelProvider = 'openai' | 'anthropic' | 'google' | 'deepseek' | 'groq' | 'openrouter' | 'azure' | 'mistral' | 'cerebras' | 'vercel' | 'oci' | 'aws-anthropic' | 'aws' | 'ollama' | 'browser-use';
4
5
  export interface ParsedCliArgs {
5
6
  help: boolean;
6
7
  version: boolean;
7
8
  debug: boolean;
8
- allow_insecure: boolean;
9
9
  headless: boolean | null;
10
10
  window_width: number | null;
11
11
  window_height: number | null;
12
12
  user_data_dir: string | null;
13
13
  profile_directory: string | null;
14
14
  allowed_domains: string[] | null;
15
+ proxy_url: string | null;
16
+ no_proxy: string | null;
17
+ proxy_username: string | null;
18
+ proxy_password: string | null;
15
19
  cdp_url: string | null;
16
20
  model: string | null;
17
21
  provider: CliModelProvider | null;
@@ -33,6 +37,7 @@ export declare const shouldStartInteractiveMode: (task: string | null, options?:
33
37
  outputIsTTY?: boolean;
34
38
  }) => boolean;
35
39
  export declare const getLlmFromCliArgs: (args: ParsedCliArgs) => BaseChatModel;
40
+ export declare const buildBrowserProfileFromCliArgs: (args: ParsedCliArgs) => BrowserProfile | null;
36
41
  export declare const getCliUsage: () => string;
37
42
  export declare function main(argv?: string[]): Promise<void>;
38
43
  export {};
package/dist/cli.js CHANGED
@@ -16,8 +16,12 @@ import { ChatGroq } from './llm/groq/chat.js';
16
16
  import { ChatOpenRouter } from './llm/openrouter/chat.js';
17
17
  import { ChatAzure } from './llm/azure/chat.js';
18
18
  import { ChatOllama } from './llm/ollama/chat.js';
19
+ import { ChatMistral } from './llm/mistral/chat.js';
20
+ import { ChatCerebras } from './llm/cerebras/chat.js';
21
+ import { ChatVercel } from './llm/vercel/chat.js';
19
22
  import { ChatAnthropicBedrock } from './llm/aws/chat-anthropic.js';
20
23
  import { ChatBedrockConverse } from './llm/aws/chat-bedrock.js';
24
+ import { ChatBrowserUse } from './llm/browser-use/chat.js';
21
25
  import { MCPServer } from './mcp/server.js';
22
26
  import { get_browser_use_version } from './utils.js';
23
27
  import { setupLogging } from './logging-config.js';
@@ -32,7 +36,14 @@ const CLI_PROVIDER_ALIASES = {
32
36
  groq: 'groq',
33
37
  openrouter: 'openrouter',
34
38
  azure: 'azure',
39
+ mistral: 'mistral',
40
+ cerebras: 'cerebras',
41
+ vercel: 'vercel',
42
+ oci: 'oci',
35
43
  ollama: 'ollama',
44
+ 'browser-use': 'browser-use',
45
+ browseruse: 'browser-use',
46
+ bu: 'browser-use',
36
47
  bedrock: 'aws',
37
48
  aws: 'aws',
38
49
  'aws-anthropic': 'aws-anthropic',
@@ -62,7 +73,7 @@ const parseProvider = (value) => {
62
73
  const normalized = value.trim().toLowerCase();
63
74
  const provider = CLI_PROVIDER_ALIASES[normalized];
64
75
  if (!provider) {
65
- throw new Error(`Unsupported provider "${value}". Supported values: openai, anthropic, google, deepseek, groq, openrouter, azure, ollama, aws, aws-anthropic.`);
76
+ throw new Error(`Unsupported provider "${value}". Supported values: openai, anthropic, google, deepseek, groq, openrouter, azure, mistral, cerebras, vercel, oci, ollama, browser-use, aws, aws-anthropic.`);
66
77
  }
67
78
  return provider;
68
79
  };
@@ -102,13 +113,16 @@ export const parseCliArgs = (argv) => {
102
113
  help: false,
103
114
  version: false,
104
115
  debug: false,
105
- allow_insecure: false,
106
116
  headless: null,
107
117
  window_width: null,
108
118
  window_height: null,
109
119
  user_data_dir: null,
110
120
  profile_directory: null,
111
121
  allowed_domains: null,
122
+ proxy_url: null,
123
+ no_proxy: null,
124
+ proxy_username: null,
125
+ proxy_password: null,
112
126
  cdp_url: null,
113
127
  model: null,
114
128
  provider: null,
@@ -134,10 +148,6 @@ export const parseCliArgs = (argv) => {
134
148
  parsed.debug = true;
135
149
  continue;
136
150
  }
137
- if (arg === '--allow-insecure') {
138
- parsed.allow_insecure = true;
139
- continue;
140
- }
141
151
  if (arg === '--headless') {
142
152
  parsed.headless = true;
143
153
  continue;
@@ -196,6 +206,30 @@ export const parseCliArgs = (argv) => {
196
206
  i = nextIndex;
197
207
  continue;
198
208
  }
209
+ if (arg === '--proxy-url' || arg.startsWith('--proxy-url=')) {
210
+ const { value, nextIndex } = takeOptionValue(arg, i, argv);
211
+ parsed.proxy_url = value.trim();
212
+ i = nextIndex;
213
+ continue;
214
+ }
215
+ if (arg === '--no-proxy' || arg.startsWith('--no-proxy=')) {
216
+ const { value, nextIndex } = takeOptionValue(arg, i, argv);
217
+ parsed.no_proxy = value;
218
+ i = nextIndex;
219
+ continue;
220
+ }
221
+ if (arg === '--proxy-username' || arg.startsWith('--proxy-username=')) {
222
+ const { value, nextIndex } = takeOptionValue(arg, i, argv);
223
+ parsed.proxy_username = value;
224
+ i = nextIndex;
225
+ continue;
226
+ }
227
+ if (arg === '--proxy-password' || arg.startsWith('--proxy-password=')) {
228
+ const { value, nextIndex } = takeOptionValue(arg, i, argv);
229
+ parsed.proxy_password = value;
230
+ i = nextIndex;
231
+ continue;
232
+ }
199
233
  if (arg === '--cdp-url' || arg.startsWith('--cdp-url=')) {
200
234
  const { value, nextIndex } = takeOptionValue(arg, i, argv);
201
235
  parsed.cdp_url = value;
@@ -298,9 +332,37 @@ const inferProviderFromModel = (model) => {
298
332
  if (lower.startsWith('azure:')) {
299
333
  return 'azure';
300
334
  }
335
+ if (lower.startsWith('mistral:')) {
336
+ return 'mistral';
337
+ }
338
+ if (lower.startsWith('cerebras:')) {
339
+ return 'cerebras';
340
+ }
341
+ if (lower.startsWith('vercel:')) {
342
+ return 'vercel';
343
+ }
344
+ if (lower.startsWith('oci:')) {
345
+ return 'oci';
346
+ }
347
+ if (lower.startsWith('mistral-') ||
348
+ lower.startsWith('codestral') ||
349
+ lower.startsWith('pixtral')) {
350
+ return 'mistral';
351
+ }
352
+ if (lower.startsWith('llama3.') ||
353
+ lower.startsWith('llama-4-') ||
354
+ lower.startsWith('gpt-oss-') ||
355
+ lower.startsWith('qwen-3-')) {
356
+ return 'cerebras';
357
+ }
301
358
  if (lower.startsWith('ollama:')) {
302
359
  return 'ollama';
303
360
  }
361
+ if (lower.startsWith('browser-use:') ||
362
+ lower.startsWith('bu-') ||
363
+ lower.startsWith('browser-use/')) {
364
+ return 'browser-use';
365
+ }
304
366
  if (lower.startsWith('bedrock:anthropic.')) {
305
367
  return 'aws-anthropic';
306
368
  }
@@ -328,9 +390,27 @@ const normalizeModelValue = (model, provider) => {
328
390
  if (provider === 'azure' && lower.startsWith('azure:')) {
329
391
  return model.slice('azure:'.length);
330
392
  }
393
+ if (provider === 'mistral' && lower.startsWith('mistral:')) {
394
+ return model.slice('mistral:'.length);
395
+ }
396
+ if (provider === 'cerebras' && lower.startsWith('cerebras:')) {
397
+ return model.slice('cerebras:'.length);
398
+ }
399
+ if (provider === 'vercel' && lower.startsWith('vercel:')) {
400
+ return model.slice('vercel:'.length);
401
+ }
402
+ if (provider === 'oci' && lower.startsWith('oci:')) {
403
+ return model.slice('oci:'.length);
404
+ }
331
405
  if (provider === 'ollama' && lower.startsWith('ollama:')) {
332
406
  return model.slice('ollama:'.length);
333
407
  }
408
+ if (provider === 'browser-use' && lower.startsWith('browser-use:')) {
409
+ return model.slice('browser-use:'.length);
410
+ }
411
+ if (provider === 'browser-use' && lower.startsWith('bu_')) {
412
+ return model.replace(/_/g, '-');
413
+ }
334
414
  if (provider === 'aws-anthropic' && lower.startsWith('bedrock:')) {
335
415
  return model.slice('bedrock:'.length);
336
416
  }
@@ -352,23 +432,33 @@ const providersAreCompatible = (explicitProvider, inferredProvider) => {
352
432
  const getDefaultModelForProvider = (provider) => {
353
433
  switch (provider) {
354
434
  case 'openai':
355
- return 'gpt-4o';
435
+ return 'gpt-5-mini';
356
436
  case 'anthropic':
357
- return 'claude-sonnet-4-20250514';
437
+ return 'claude-4-sonnet';
358
438
  case 'google':
359
- return 'gemini-2.5-flash';
439
+ return 'gemini-2.5-pro';
360
440
  case 'deepseek':
361
441
  return 'deepseek-chat';
362
442
  case 'groq':
363
443
  return 'llama-3.1-70b-versatile';
364
444
  case 'openrouter':
365
- return 'openai/gpt-4o';
445
+ return 'openai/gpt-5-mini';
366
446
  case 'azure':
367
447
  return 'gpt-4o';
448
+ case 'mistral':
449
+ return 'mistral-large-latest';
450
+ case 'cerebras':
451
+ return 'llama3.1-8b';
452
+ case 'vercel':
453
+ return 'openai/gpt-5-mini';
454
+ case 'oci':
455
+ return null;
368
456
  case 'aws-anthropic':
369
457
  return 'anthropic.claude-3-5-sonnet-20241022-v2:0';
370
458
  case 'ollama':
371
459
  return process.env.OLLAMA_MODEL || 'qwen2.5:latest';
460
+ case 'browser-use':
461
+ return 'bu-latest';
372
462
  case 'aws':
373
463
  return null;
374
464
  default:
@@ -403,10 +493,35 @@ const createLlmForProvider = (provider, model) => {
403
493
  requireEnv('AZURE_OPENAI_API_KEY');
404
494
  requireEnv('AZURE_OPENAI_ENDPOINT');
405
495
  return new ChatAzure(model);
496
+ case 'mistral':
497
+ return new ChatMistral({
498
+ model,
499
+ apiKey: requireEnv('MISTRAL_API_KEY'),
500
+ baseURL: process.env.MISTRAL_BASE_URL,
501
+ });
502
+ case 'cerebras':
503
+ return new ChatCerebras({
504
+ model,
505
+ apiKey: requireEnv('CEREBRAS_API_KEY'),
506
+ baseURL: process.env.CEREBRAS_BASE_URL,
507
+ });
508
+ case 'vercel':
509
+ return new ChatVercel({
510
+ model,
511
+ apiKey: requireEnv('VERCEL_API_KEY'),
512
+ baseURL: process.env.VERCEL_BASE_URL,
513
+ });
514
+ case 'oci':
515
+ throw new Error('OCI models require manual configuration in TypeScript runtime. Use a custom BaseChatModel integration for OCI credentials and endpoint setup.');
406
516
  case 'ollama': {
407
517
  const host = process.env.OLLAMA_HOST || 'http://localhost:11434';
408
518
  return new ChatOllama(model, host);
409
519
  }
520
+ case 'browser-use':
521
+ return new ChatBrowserUse({
522
+ model,
523
+ apiKey: requireEnv('BROWSER_USE_API_KEY'),
524
+ });
410
525
  case 'aws-anthropic':
411
526
  return new ChatAnthropicBedrock({
412
527
  model,
@@ -428,7 +543,7 @@ export const getLlmFromCliArgs = (args) => {
428
543
  }
429
544
  const provider = args.provider ?? inferredProvider;
430
545
  if (!provider) {
431
- throw new Error(`Cannot infer provider from model "${args.model}". Provide --provider or use a supported model prefix: gpt*/o*, claude*, gemini*, deepseek*, groq:, openrouter:, azure:, ollama:, bedrock:.`);
546
+ throw new Error(`Cannot infer provider from model "${args.model}". Provide --provider or use a supported model prefix: gpt*/o*, claude*, gemini*, deepseek*, groq:, openrouter:, azure:, mistral:, cerebras:, vercel:, oci:, ollama:, browser-use:, bu-*, bedrock:.`);
432
547
  }
433
548
  const normalizedModel = normalizeModelValue(args.model, provider);
434
549
  return createLlmForProvider(provider, normalizedModel);
@@ -442,18 +557,18 @@ export const getLlmFromCliArgs = (args) => {
442
557
  }
443
558
  if (process.env.OPENAI_API_KEY) {
444
559
  return new ChatOpenAI({
445
- model: 'gpt-4o',
560
+ model: 'gpt-5-mini',
446
561
  apiKey: process.env.OPENAI_API_KEY,
447
562
  });
448
563
  }
449
564
  if (process.env.ANTHROPIC_API_KEY) {
450
565
  return new ChatAnthropic({
451
- model: 'claude-sonnet-4-20250514',
566
+ model: 'claude-4-sonnet',
452
567
  apiKey: process.env.ANTHROPIC_API_KEY,
453
568
  });
454
569
  }
455
570
  if (process.env.GOOGLE_API_KEY) {
456
- return new ChatGoogle('gemini-2.5-flash');
571
+ return new ChatGoogle('gemini-2.5-pro');
457
572
  }
458
573
  if (process.env.DEEPSEEK_API_KEY) {
459
574
  return new ChatDeepSeek('deepseek-chat');
@@ -462,11 +577,32 @@ export const getLlmFromCliArgs = (args) => {
462
577
  return new ChatGroq('llama-3.1-70b-versatile');
463
578
  }
464
579
  if (process.env.OPENROUTER_API_KEY) {
465
- return new ChatOpenRouter('openai/gpt-4o');
580
+ return new ChatOpenRouter('openai/gpt-5-mini');
466
581
  }
467
582
  if (process.env.AZURE_OPENAI_API_KEY && process.env.AZURE_OPENAI_ENDPOINT) {
468
583
  return new ChatAzure('gpt-4o');
469
584
  }
585
+ if (process.env.MISTRAL_API_KEY) {
586
+ return new ChatMistral({
587
+ model: 'mistral-large-latest',
588
+ apiKey: process.env.MISTRAL_API_KEY,
589
+ baseURL: process.env.MISTRAL_BASE_URL,
590
+ });
591
+ }
592
+ if (process.env.CEREBRAS_API_KEY) {
593
+ return new ChatCerebras({
594
+ model: 'llama3.1-8b',
595
+ apiKey: process.env.CEREBRAS_API_KEY,
596
+ baseURL: process.env.CEREBRAS_BASE_URL,
597
+ });
598
+ }
599
+ if (process.env.VERCEL_API_KEY) {
600
+ return new ChatVercel({
601
+ model: 'openai/gpt-5-mini',
602
+ apiKey: process.env.VERCEL_API_KEY,
603
+ baseURL: process.env.VERCEL_BASE_URL,
604
+ });
605
+ }
470
606
  if (process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE) {
471
607
  return new ChatAnthropicBedrock({
472
608
  model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
@@ -475,7 +611,11 @@ export const getLlmFromCliArgs = (args) => {
475
611
  }
476
612
  return new ChatOllama(process.env.OLLAMA_MODEL || 'qwen2.5:latest', process.env.OLLAMA_HOST || 'http://localhost:11434');
477
613
  };
478
- const buildBrowserProfileFromCliArgs = (args) => {
614
+ const parseCommaSeparatedList = (value) => value
615
+ .split(',')
616
+ .map((entry) => entry.trim())
617
+ .filter((entry) => entry.length > 0);
618
+ export const buildBrowserProfileFromCliArgs = (args) => {
479
619
  const profile = {};
480
620
  if (args.headless !== null) {
481
621
  profile.headless = args.headless;
@@ -495,12 +635,31 @@ const buildBrowserProfileFromCliArgs = (args) => {
495
635
  if (args.allowed_domains && args.allowed_domains.length > 0) {
496
636
  profile.allowed_domains = args.allowed_domains;
497
637
  }
638
+ if (args.proxy_url ||
639
+ args.no_proxy ||
640
+ args.proxy_username ||
641
+ args.proxy_password) {
642
+ const proxy = {};
643
+ if (args.proxy_url) {
644
+ proxy.server = args.proxy_url;
645
+ }
646
+ if (args.no_proxy) {
647
+ proxy.bypass = parseCommaSeparatedList(args.no_proxy).join(',');
648
+ }
649
+ if (args.proxy_username) {
650
+ proxy.username = args.proxy_username;
651
+ }
652
+ if (args.proxy_password) {
653
+ proxy.password = args.proxy_password;
654
+ }
655
+ profile.proxy = proxy;
656
+ }
498
657
  if (Object.keys(profile).length === 0) {
499
658
  return null;
500
659
  }
501
660
  return new BrowserProfile(profile);
502
661
  };
503
- const runAgentTask = async ({ task, llm, browserProfile, browserSession, sessionAttachmentMode, allowInsecureSensitiveData, }) => {
662
+ const runAgentTask = async ({ task, llm, browserProfile, browserSession, sessionAttachmentMode, }) => {
504
663
  const agent = new Agent({
505
664
  task,
506
665
  llm,
@@ -509,9 +668,6 @@ const runAgentTask = async ({ task, llm, browserProfile, browserSession, session
509
668
  ...(sessionAttachmentMode
510
669
  ? { session_attachment_mode: sessionAttachmentMode }
511
670
  : {}),
512
- ...(allowInsecureSensitiveData
513
- ? { allow_insecure_sensitive_data: true }
514
- : {}),
515
671
  source: 'cli',
516
672
  });
517
673
  await agent.run();
@@ -560,7 +716,6 @@ const runInteractiveMode = async (args, llm) => {
560
716
  browserProfile,
561
717
  browserSession,
562
718
  sessionAttachmentMode: 'strict',
563
- allowInsecureSensitiveData: args.allow_insecure,
564
719
  });
565
720
  }
566
721
  catch (error) {
@@ -595,16 +750,19 @@ Options:
595
750
  -h, --help Show this help message
596
751
  --version Print version and exit
597
752
  --mcp Run as MCP server
598
- --provider <name> Force provider (openai|anthropic|google|deepseek|groq|openrouter|azure|ollama|aws|aws-anthropic)
599
- --model <model> Set model (e.g., gpt-4o, claude-sonnet-4-20250514, gemini-2.5-flash)
753
+ --provider <name> Force provider (openai|anthropic|google|deepseek|groq|openrouter|azure|mistral|cerebras|vercel|oci|ollama|browser-use|aws|aws-anthropic)
754
+ --model <model> Set model (e.g., gpt-5-mini, claude-4-sonnet, gemini-2.5-pro)
600
755
  -p, --prompt <task> Run a single task
601
756
  --headless Run browser in headless mode
602
757
  --allowed-domains <items> Comma-separated allowlist (e.g., example.com,*.example.org)
603
- --allow-insecure Allow sensitive_data without domain restrictions (unsafe)
604
758
  --window-width <px> Browser window width
605
759
  --window-height <px> Browser window height
606
760
  --user-data-dir <path> Chrome user data directory
607
761
  --profile-directory <name> Chrome profile directory (Default, Profile 1, ...)
762
+ --proxy-url <url> Proxy server URL (e.g., http://proxy.example.com:8080)
763
+ --no-proxy <items> Comma-separated proxy bypass list
764
+ --proxy-username <value> Proxy username
765
+ --proxy-password <value> Proxy password
608
766
  --cdp-url <url> Connect to an existing Chromium instance via CDP
609
767
  --debug Enable debug logging`;
610
768
  async function runMcpServer() {
@@ -684,7 +842,6 @@ export async function main(argv = process.argv.slice(2)) {
684
842
  llm,
685
843
  browserProfile,
686
844
  browserSession,
687
- allowInsecureSensitiveData: args.allow_insecure,
688
845
  });
689
846
  }
690
847
  catch (error) {
@@ -0,0 +1,3 @@
1
+ import type { BrowserStateSummary } from '../browser/views.js';
2
+ import type { BrowserSession } from '../browser/session.js';
3
+ export declare const format_browser_state_for_llm: (state: BrowserStateSummary, namespace: Record<string, unknown>, _browser_session: BrowserSession) => Promise<string>;
@@ -0,0 +1,18 @@
1
+ export const format_browser_state_for_llm = async (state, namespace, _browser_session) => {
2
+ const lines = [];
3
+ lines.push('## Browser State');
4
+ lines.push(`**URL:** ${state.url}`);
5
+ lines.push(`**Title:** ${state.title}`);
6
+ lines.push('');
7
+ const vars = Object.keys(namespace)
8
+ .filter((key) => !key.startsWith('_'))
9
+ .sort();
10
+ lines.push(`**Available:** ${vars.length > 0 ? vars.join(', ') : '(none)'}`);
11
+ lines.push('');
12
+ const dom = typeof state.llm_representation === 'function'
13
+ ? state.llm_representation()
14
+ : '';
15
+ lines.push('**DOM Structure:**');
16
+ lines.push(dom || 'Empty DOM tree (you might have to wait for page load)');
17
+ return lines.join('\n');
18
+ };
@@ -0,0 +1,6 @@
1
+ export * from './views.js';
2
+ export * from './utils.js';
3
+ export * from './namespace.js';
4
+ export * from './service.js';
5
+ export * from './formatting.js';
6
+ export * from './notebook-export.js';
@@ -0,0 +1,6 @@
1
+ export * from './views.js';
2
+ export * from './utils.js';
3
+ export * from './namespace.js';
4
+ export * from './service.js';
5
+ export * from './formatting.js';
6
+ export * from './notebook-export.js';
@@ -0,0 +1,5 @@
1
+ import type { BrowserSession } from '../browser/session.js';
2
+ export interface CreateNamespaceOptions {
3
+ namespace?: Record<string, unknown>;
4
+ }
5
+ export declare const create_namespace: (browser_session: BrowserSession, options?: CreateNamespaceOptions) => Record<string, unknown>;
@@ -0,0 +1,81 @@
1
+ const buildExpression = (source, args) => `(${source})(${args.map((arg) => JSON.stringify(arg)).join(',')})`;
2
+ export const create_namespace = (browser_session, options = {}) => {
3
+ const namespace = options.namespace ?? {};
4
+ namespace.browser = browser_session;
5
+ namespace.navigate = async (url, init = {}) => {
6
+ await browser_session.navigate_to(url, init);
7
+ };
8
+ namespace.go_back = async () => {
9
+ await browser_session.go_back();
10
+ };
11
+ namespace.go_forward = async () => {
12
+ await browser_session.go_forward();
13
+ };
14
+ namespace.refresh = async () => {
15
+ await browser_session.refresh();
16
+ };
17
+ namespace.wait = async (seconds) => {
18
+ await browser_session.wait(seconds);
19
+ };
20
+ namespace.click = async (index) => {
21
+ const node = await browser_session.get_dom_element_by_index(index);
22
+ if (!node) {
23
+ throw new Error(`Element index ${index} not found`);
24
+ }
25
+ return browser_session._click_element_node(node);
26
+ };
27
+ namespace.input = async (index, text, clear = true) => {
28
+ const node = await browser_session.get_dom_element_by_index(index);
29
+ if (!node) {
30
+ throw new Error(`Element index ${index} not found`);
31
+ }
32
+ return browser_session._input_text_element_node(node, text, {
33
+ clear,
34
+ });
35
+ };
36
+ namespace.select_dropdown = async (index, text) => {
37
+ const node = await browser_session.get_dom_element_by_index(index);
38
+ if (!node) {
39
+ throw new Error(`Element index ${index} not found`);
40
+ }
41
+ return browser_session.select_dropdown_option(node, text);
42
+ };
43
+ namespace.upload_file = async (index, file_path) => {
44
+ const node = await browser_session.get_dom_element_by_index(index);
45
+ if (!node) {
46
+ throw new Error(`Element index ${index} not found`);
47
+ }
48
+ return browser_session.upload_file(node, file_path);
49
+ };
50
+ namespace.screenshot = async (full_page = false) => {
51
+ return browser_session.take_screenshot(full_page);
52
+ };
53
+ namespace.send_keys = async (keys) => {
54
+ await browser_session.send_keys(keys);
55
+ };
56
+ namespace.evaluate = async (code, ...args) => {
57
+ const page = await browser_session.get_current_page();
58
+ if (!page) {
59
+ throw new Error('No active page for evaluate');
60
+ }
61
+ if (typeof code === 'function') {
62
+ return page.evaluate(code, ...args);
63
+ }
64
+ if (args.length === 0) {
65
+ return page.evaluate(code);
66
+ }
67
+ return page.evaluate(buildExpression(code, args));
68
+ };
69
+ namespace.done = (result = null, success = true) => {
70
+ namespace._task_done = true;
71
+ namespace._task_success = success;
72
+ namespace._task_result =
73
+ typeof result === 'string'
74
+ ? result
75
+ : result == null
76
+ ? null
77
+ : JSON.stringify(result);
78
+ return result;
79
+ };
80
+ return namespace;
81
+ };
@@ -0,0 +1,3 @@
1
+ import type { CodeAgent } from './service.js';
2
+ export declare const export_to_ipynb: (agent: CodeAgent, output_path: string) => string;
3
+ export declare const session_to_python_script: (agent: CodeAgent) => string;
@@ -0,0 +1,56 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export const export_to_ipynb = (agent, output_path) => {
4
+ const notebook = {
5
+ nbformat: 4,
6
+ nbformat_minor: 5,
7
+ metadata: {
8
+ kernelspec: {
9
+ display_name: 'Node.js',
10
+ language: 'javascript',
11
+ name: 'javascript',
12
+ },
13
+ },
14
+ cells: agent.session.cells.map((cell) => {
15
+ if (cell.cell_type === 'markdown') {
16
+ return {
17
+ cell_type: 'markdown',
18
+ metadata: {},
19
+ source: cell.source.split('\n').map((entry) => `${entry}\n`),
20
+ };
21
+ }
22
+ return {
23
+ cell_type: 'code',
24
+ metadata: {},
25
+ source: cell.source.split('\n').map((entry) => `${entry}\n`),
26
+ execution_count: cell.execution_count,
27
+ outputs: cell.output
28
+ ? [
29
+ {
30
+ output_type: 'stream',
31
+ name: 'stdout',
32
+ text: `${cell.output}\n`,
33
+ },
34
+ ]
35
+ : [],
36
+ };
37
+ }),
38
+ };
39
+ const resolved = path.resolve(output_path);
40
+ fs.mkdirSync(path.dirname(resolved), { recursive: true });
41
+ fs.writeFileSync(resolved, JSON.stringify(notebook, null, 2), 'utf-8');
42
+ return resolved;
43
+ };
44
+ export const session_to_python_script = (agent) => {
45
+ const lines = [];
46
+ lines.push('# Generated from browser-use code-use session');
47
+ lines.push('');
48
+ for (const cell of agent.session.cells) {
49
+ if (cell.cell_type !== 'code') {
50
+ continue;
51
+ }
52
+ lines.push(cell.source);
53
+ lines.push('');
54
+ }
55
+ return lines.join('\n');
56
+ };
@@ -0,0 +1,24 @@
1
+ import { CodeAgentHistory, CodeAgentHistoryList, NotebookSession } from './views.js';
2
+ import type { BrowserSession } from '../browser/session.js';
3
+ type ExecutorFn = (source: string, namespace: Record<string, unknown>) => Promise<unknown>;
4
+ export interface CodeAgentOptions {
5
+ task: string;
6
+ browser_session: BrowserSession;
7
+ namespace?: Record<string, unknown>;
8
+ executor?: ExecutorFn;
9
+ }
10
+ export declare class CodeAgent {
11
+ task: string;
12
+ browser_session: BrowserSession;
13
+ session: NotebookSession;
14
+ namespace: Record<string, unknown>;
15
+ complete_history: CodeAgentHistory[];
16
+ private readonly executor;
17
+ constructor(options: CodeAgentOptions);
18
+ add_cell(source: string): import("./views.js").CodeCell;
19
+ execute_cell(source: string): Promise<import("./views.js").CodeCell>;
20
+ run(max_steps?: number): Promise<CodeAgentHistoryList>;
21
+ get history(): CodeAgentHistoryList;
22
+ close(): Promise<void>;
23
+ }
24
+ export {};