@browserbasehq/orca 3.7.0-preview.1 → 3.7.2-gemini-cua

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 (165) hide show
  1. package/dist/cjs/lib/modelUtils.d.ts +10 -0
  2. package/dist/cjs/lib/modelUtils.js +11 -0
  3. package/dist/cjs/lib/modelUtils.js.map +1 -1
  4. package/dist/cjs/lib/v3/agent/AgentProvider.js +3 -0
  5. package/dist/cjs/lib/v3/agent/AgentProvider.js.map +1 -1
  6. package/dist/cjs/lib/v3/agent/GoogleCUAClient.d.ts +23 -0
  7. package/dist/cjs/lib/v3/agent/GoogleCUAClient.js +363 -206
  8. package/dist/cjs/lib/v3/agent/GoogleCUAClient.js.map +1 -1
  9. package/dist/cjs/lib/v3/agent/tools/click.js +16 -5
  10. package/dist/cjs/lib/v3/agent/tools/click.js.map +1 -1
  11. package/dist/cjs/lib/v3/agent/tools/clickAndHold.js +1 -1
  12. package/dist/cjs/lib/v3/agent/tools/clickAndHold.js.map +1 -1
  13. package/dist/cjs/lib/v3/agent/tools/dragAndDrop.js +2 -2
  14. package/dist/cjs/lib/v3/agent/tools/dragAndDrop.js.map +1 -1
  15. package/dist/cjs/lib/v3/agent/tools/fillFormVision.js +18 -7
  16. package/dist/cjs/lib/v3/agent/tools/fillFormVision.js.map +1 -1
  17. package/dist/cjs/lib/v3/agent/tools/scroll.js +1 -1
  18. package/dist/cjs/lib/v3/agent/tools/scroll.js.map +1 -1
  19. package/dist/cjs/lib/v3/agent/tools/type.js +13 -4
  20. package/dist/cjs/lib/v3/agent/tools/type.js.map +1 -1
  21. package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.d.ts +5 -2
  22. package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.js +5 -7
  23. package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.js.map +1 -1
  24. package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.js +3 -1
  25. package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -1
  26. package/dist/cjs/lib/v3/api.d.ts +1 -1
  27. package/dist/cjs/lib/v3/api.js +11 -1
  28. package/dist/cjs/lib/v3/api.js.map +1 -1
  29. package/dist/cjs/lib/v3/cache/AgentCache.js +6 -1
  30. package/dist/cjs/lib/v3/cache/AgentCache.js.map +1 -1
  31. package/dist/cjs/lib/v3/external_clients/aisdk.js +2 -0
  32. package/dist/cjs/lib/v3/external_clients/aisdk.js.map +1 -1
  33. package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.js +20 -0
  34. package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
  35. package/dist/cjs/lib/v3/handlers/v3AgentHandler.js +5 -4
  36. package/dist/cjs/lib/v3/handlers/v3AgentHandler.js.map +1 -1
  37. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.d.ts +4 -0
  38. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js +126 -20
  39. package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
  40. package/dist/cjs/lib/v3/index.d.ts +1 -1
  41. package/dist/cjs/lib/v3/launch/local.js +1 -1
  42. package/dist/cjs/lib/v3/launch/local.js.map +1 -1
  43. package/dist/cjs/lib/v3/llm/LLMProvider.js +9 -2
  44. package/dist/cjs/lib/v3/llm/LLMProvider.js.map +1 -1
  45. package/dist/cjs/lib/v3/llm/aisdk.js +5 -3
  46. package/dist/cjs/lib/v3/llm/aisdk.js.map +1 -1
  47. package/dist/cjs/lib/v3/llm/providerOptions.d.ts +7 -0
  48. package/dist/cjs/lib/v3/llm/providerOptions.js +9 -0
  49. package/dist/cjs/lib/v3/llm/providerOptions.js.map +1 -0
  50. package/dist/cjs/lib/v3/runtimePaths.js +0 -1
  51. package/dist/cjs/lib/v3/runtimePaths.js.map +1 -1
  52. package/dist/cjs/lib/v3/types/private/agent.d.ts +1 -1
  53. package/dist/cjs/lib/v3/types/private/agent.js +1 -0
  54. package/dist/cjs/lib/v3/types/private/agent.js.map +1 -1
  55. package/dist/cjs/lib/v3/types/public/agent.d.ts +1 -1
  56. package/dist/cjs/lib/v3/types/public/agent.js +3 -0
  57. package/dist/cjs/lib/v3/types/public/agent.js.map +1 -1
  58. package/dist/cjs/lib/v3/types/public/api.d.ts +53 -0
  59. package/dist/cjs/lib/v3/types/public/api.js +8 -0
  60. package/dist/cjs/lib/v3/types/public/api.js.map +1 -1
  61. package/dist/cjs/lib/v3/types/public/model.d.ts +12 -0
  62. package/dist/cjs/lib/v3/types/public/model.js.map +1 -1
  63. package/dist/cjs/lib/v3/types/public/options.d.ts +13 -0
  64. package/dist/cjs/lib/v3/types/public/options.js.map +1 -1
  65. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js +4 -3
  66. package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
  67. package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +39 -1
  68. package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -1
  69. package/dist/cjs/lib/v3/understudy/locator.d.ts +12 -0
  70. package/dist/cjs/lib/v3/understudy/locator.js +44 -0
  71. package/dist/cjs/lib/v3/understudy/locator.js.map +1 -1
  72. package/dist/cjs/lib/v3/understudy/page.d.ts +22 -3
  73. package/dist/cjs/lib/v3/understudy/page.js +55 -1
  74. package/dist/cjs/lib/v3/understudy/page.js.map +1 -1
  75. package/dist/cjs/lib/v3/v3.d.ts +14 -0
  76. package/dist/cjs/lib/v3/v3.js +81 -16
  77. package/dist/cjs/lib/v3/v3.js.map +1 -1
  78. package/dist/cjs/lib/v3/verifier/types.d.ts +3 -2
  79. package/dist/cjs/lib/v3/verifier/types.js.map +1 -1
  80. package/dist/cjs/lib/version.d.ts +1 -1
  81. package/dist/cjs/lib/version.js +1 -1
  82. package/dist/cjs/lib/version.js.map +1 -1
  83. package/dist/esm/lib/modelUtils.d.ts +10 -0
  84. package/dist/esm/lib/modelUtils.js +9 -0
  85. package/dist/esm/lib/modelUtils.js.map +1 -1
  86. package/dist/esm/lib/v3/agent/AgentProvider.js +3 -0
  87. package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -1
  88. package/dist/esm/lib/v3/agent/GoogleCUAClient.d.ts +23 -0
  89. package/dist/esm/lib/v3/agent/GoogleCUAClient.js +363 -206
  90. package/dist/esm/lib/v3/agent/GoogleCUAClient.js.map +1 -1
  91. package/dist/esm/lib/v3/agent/tools/click.js +16 -5
  92. package/dist/esm/lib/v3/agent/tools/click.js.map +1 -1
  93. package/dist/esm/lib/v3/agent/tools/clickAndHold.js +1 -1
  94. package/dist/esm/lib/v3/agent/tools/clickAndHold.js.map +1 -1
  95. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js +2 -2
  96. package/dist/esm/lib/v3/agent/tools/dragAndDrop.js.map +1 -1
  97. package/dist/esm/lib/v3/agent/tools/fillFormVision.js +19 -8
  98. package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -1
  99. package/dist/esm/lib/v3/agent/tools/scroll.js +1 -1
  100. package/dist/esm/lib/v3/agent/tools/scroll.js.map +1 -1
  101. package/dist/esm/lib/v3/agent/tools/type.js +13 -4
  102. package/dist/esm/lib/v3/agent/tools/type.js.map +1 -1
  103. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.d.ts +5 -2
  104. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js +5 -7
  105. package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js.map +1 -1
  106. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js +3 -1
  107. package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -1
  108. package/dist/esm/lib/v3/api.d.ts +1 -1
  109. package/dist/esm/lib/v3/api.js +11 -1
  110. package/dist/esm/lib/v3/api.js.map +1 -1
  111. package/dist/esm/lib/v3/cache/AgentCache.js +6 -1
  112. package/dist/esm/lib/v3/cache/AgentCache.js.map +1 -1
  113. package/dist/esm/lib/v3/external_clients/aisdk.js +2 -0
  114. package/dist/esm/lib/v3/external_clients/aisdk.js.map +1 -1
  115. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +20 -0
  116. package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
  117. package/dist/esm/lib/v3/handlers/v3AgentHandler.js +5 -4
  118. package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -1
  119. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.d.ts +4 -0
  120. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +126 -20
  121. package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
  122. package/dist/esm/lib/v3/index.d.ts +1 -1
  123. package/dist/esm/lib/v3/launch/local.js +1 -1
  124. package/dist/esm/lib/v3/launch/local.js.map +1 -1
  125. package/dist/esm/lib/v3/llm/LLMProvider.js +9 -2
  126. package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -1
  127. package/dist/esm/lib/v3/llm/aisdk.js +5 -3
  128. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
  129. package/dist/esm/lib/v3/llm/providerOptions.d.ts +7 -0
  130. package/dist/esm/lib/v3/llm/providerOptions.js +6 -0
  131. package/dist/esm/lib/v3/llm/providerOptions.js.map +1 -0
  132. package/dist/esm/lib/v3/runtimePaths.js +0 -1
  133. package/dist/esm/lib/v3/runtimePaths.js.map +1 -1
  134. package/dist/esm/lib/v3/types/private/agent.d.ts +1 -1
  135. package/dist/esm/lib/v3/types/private/agent.js +1 -0
  136. package/dist/esm/lib/v3/types/private/agent.js.map +1 -1
  137. package/dist/esm/lib/v3/types/public/agent.d.ts +1 -1
  138. package/dist/esm/lib/v3/types/public/agent.js +3 -0
  139. package/dist/esm/lib/v3/types/public/agent.js.map +1 -1
  140. package/dist/esm/lib/v3/types/public/api.d.ts +53 -0
  141. package/dist/esm/lib/v3/types/public/api.js +8 -0
  142. package/dist/esm/lib/v3/types/public/api.js.map +1 -1
  143. package/dist/esm/lib/v3/types/public/model.d.ts +12 -0
  144. package/dist/esm/lib/v3/types/public/model.js.map +1 -1
  145. package/dist/esm/lib/v3/types/public/options.d.ts +13 -0
  146. package/dist/esm/lib/v3/types/public/options.js.map +1 -1
  147. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +4 -3
  148. package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
  149. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +39 -1
  150. package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -1
  151. package/dist/esm/lib/v3/understudy/locator.d.ts +12 -0
  152. package/dist/esm/lib/v3/understudy/locator.js +44 -0
  153. package/dist/esm/lib/v3/understudy/locator.js.map +1 -1
  154. package/dist/esm/lib/v3/understudy/page.d.ts +22 -3
  155. package/dist/esm/lib/v3/understudy/page.js +55 -1
  156. package/dist/esm/lib/v3/understudy/page.js.map +1 -1
  157. package/dist/esm/lib/v3/v3.d.ts +14 -0
  158. package/dist/esm/lib/v3/v3.js +82 -17
  159. package/dist/esm/lib/v3/v3.js.map +1 -1
  160. package/dist/esm/lib/v3/verifier/types.d.ts +3 -2
  161. package/dist/esm/lib/v3/verifier/types.js.map +1 -1
  162. package/dist/esm/lib/version.d.ts +1 -1
  163. package/dist/esm/lib/version.js +1 -1
  164. package/dist/esm/lib/version.js.map +1 -1
  165. package/package.json +3 -3
@@ -73,6 +73,14 @@ export declare class V3 {
73
73
  * @deprecated Use `isVerified` instead. This alias will be removed in a future version.
74
74
  */
75
75
  get isAdvancedStealth(): boolean;
76
+ /**
77
+ * Whether coordinate pointer actions should actuate as touch instead of mouse.
78
+ *
79
+ * Explicit opt-in via the `useTouch` option — no session-derived or probed
80
+ * detection, so the answer is known before the first action, is stable for the
81
+ * whole run, and never surprises a caller who didn't ask for touch.
82
+ */
83
+ get usesTouch(): boolean;
76
84
  /**
77
85
  * Returns the configured viewport dimensions from launch options.
78
86
  * Falls back to default 1288x711 if not configured.
@@ -81,6 +89,12 @@ export declare class V3 {
81
89
  width: number;
82
90
  height: number;
83
91
  };
92
+ get hasConfiguredViewport(): boolean;
93
+ private rawConfiguredViewport;
94
+ resolveViewport(): Promise<{
95
+ width: number;
96
+ height: number;
97
+ }>;
84
98
  private _onCdpClosed;
85
99
  readonly experimental: boolean;
86
100
  readonly logInferenceToFile: boolean;
@@ -60,7 +60,7 @@ import { resolveTools } from "./mcp/utils.js";
60
60
  import { HYBRID_CAPABLE_MODEL_PATTERNS } from "./types/private/agent.js";
61
61
  import { AVAILABLE_CUA_MODELS, defaultExtractSchema, V3FunctionName, CuaModelRequiredError, StagehandInvalidArgumentError, StagehandNotInitializedError, MissingEnvironmentVariableError, StagehandInitError, } from "./types/public/index.js";
62
62
  import { V3Context } from "./understudy/context.js";
63
- import { resolveModel } from "../modelUtils.js";
63
+ import { AUTO_MODEL_NAME, isAutoModel, resolveModel } from "../modelUtils.js";
64
64
  import { StagehandAPIClient } from "./api.js";
65
65
  import { validateExperimentalFeatures } from "./agent/utils/validateExperimentalFeatures.js";
66
66
  import { flattenVariables } from "./agent/utils/variables.js";
@@ -69,6 +69,7 @@ import { EventEmitterWithWildcardSupport } from "./flowlogger/EventEmitter.js";
69
69
  import { EventStore } from "./flowlogger/EventStore.js";
70
70
  import { createTimeoutGuard } from "./handlers/handlerUtils/timeoutGuard.js";
71
71
  import { ActTimeoutError } from "./types/public/sdkErrors.js";
72
+ const AUTO_MODEL_API_ONLY_MESSAGE = `model: "${AUTO_MODEL_NAME}" is only supported when running through the Stagehand API (env: "BROWSERBASE" with disableAPI: false and experimental: false). Specify a concrete model (e.g. "openai/gpt-5") instead.`;
72
73
  const DEFAULT_MODEL_NAME = "openai/gpt-4.1-mini";
73
74
  const DEFAULT_VIEWPORT = { width: 1288, height: 711 };
74
75
  const DEFAULT_AGENT_TOOL_TIMEOUT_MS = 45000;
@@ -190,27 +191,55 @@ let V3 = (() => {
190
191
  get isAdvancedStealth() {
191
192
  return this.isVerified;
192
193
  }
194
+ /**
195
+ * Whether coordinate pointer actions should actuate as touch instead of mouse.
196
+ *
197
+ * Explicit opt-in via the `useTouch` option — no session-derived or probed
198
+ * detection, so the answer is known before the first action, is stable for the
199
+ * whole run, and never surprises a caller who didn't ask for touch.
200
+ */
201
+ get usesTouch() {
202
+ return this.opts.useTouch === true;
203
+ }
193
204
  /**
194
205
  * Returns the configured viewport dimensions from launch options.
195
206
  * Falls back to default 1288x711 if not configured.
196
207
  */
197
208
  get configuredViewport() {
198
- const defaultWidth = 1288;
199
- const defaultHeight = 711;
200
- if (this.opts.env === "BROWSERBASE") {
201
- const vp = this.opts.browserbaseSessionCreateParams?.browserSettings?.viewport;
202
- return {
203
- width: vp?.width ?? defaultWidth,
204
- height: vp?.height ?? defaultHeight,
205
- };
206
- }
207
- // LOCAL env
208
- const vp = this.opts.localBrowserLaunchOptions?.viewport;
209
+ const viewport = this.rawConfiguredViewport();
209
210
  return {
210
- width: vp?.width ?? defaultWidth,
211
- height: vp?.height ?? defaultHeight,
211
+ width: viewport?.width ?? 1288,
212
+ height: viewport?.height ?? 711,
212
213
  };
213
214
  }
215
+ get hasConfiguredViewport() {
216
+ return this.rawConfiguredViewport() !== undefined;
217
+ }
218
+ rawConfiguredViewport() {
219
+ if (this.opts.env === "BROWSERBASE") {
220
+ return this.opts.browserbaseSessionCreateParams?.browserSettings
221
+ ?.viewport;
222
+ }
223
+ return this.opts.localBrowserLaunchOptions?.viewport;
224
+ }
225
+ async resolveViewport() {
226
+ // Verified / advanced-stealth sessions do not honor the requested
227
+ // viewport (Browserbase picks a real-device size, e.g. 1280x720 for a
228
+ // requested 2560x1440), so trust the configured value only otherwise.
229
+ const configured = this.rawConfiguredViewport();
230
+ if (configured && !this.isVerified)
231
+ return this.configuredViewport;
232
+ try {
233
+ const page = await this.context.awaitActivePage();
234
+ const { width, height } = await page.mainFrame().evaluate("({ width: window.innerWidth, height: window.innerHeight })");
235
+ if (width && height)
236
+ return { width, height };
237
+ }
238
+ catch {
239
+ //
240
+ }
241
+ return this.configuredViewport;
242
+ }
214
243
  _onCdpClosed = (why) => {
215
244
  if (this.state.kind === "BROWSERBASE") {
216
245
  void this._logBrowserbaseSessionStatus();
@@ -310,7 +339,18 @@ let V3 = (() => {
310
339
  const baseClientOptions = clientOptions
311
340
  ? { ...clientOptions }
312
341
  : {};
313
- if (opts.llmClient) {
342
+ if (isAutoModel(this.modelName)) {
343
+ if (opts.llmClient ||
344
+ opts.env !== "BROWSERBASE" ||
345
+ this.disableAPI ||
346
+ this.experimental) {
347
+ throw new StagehandInvalidArgumentError(AUTO_MODEL_API_ONLY_MESSAGE);
348
+ }
349
+ // "auto" delegates model selection to the Stagehand API, so no local
350
+ // LLM client is created and no provider API key is required.
351
+ this.modelClientOptions = baseClientOptions;
352
+ }
353
+ else if (opts.llmClient) {
314
354
  this.llmClient = opts.llmClient;
315
355
  this.modelClientOptions = baseClientOptions;
316
356
  this.disableAPI = true;
@@ -486,6 +526,15 @@ let V3 = (() => {
486
526
  clientOptions = rest;
487
527
  perCallMiddleware = middleware;
488
528
  }
529
+ if (isAutoModel(modelName)) {
530
+ if (!this.apiClient) {
531
+ throw new StagehandInvalidArgumentError(AUTO_MODEL_API_ONLY_MESSAGE);
532
+ }
533
+ // The Stagehand API resolves "auto" server-side and intercepts every
534
+ // act/extract/observe, so the local client is never dereferenced here.
535
+ // Note it is undefined when the session's base model is also "auto".
536
+ return this.llmClient;
537
+ }
489
538
  if (modelName === this.modelName &&
490
539
  !perCallMiddleware &&
491
540
  (!clientOptions || Object.keys(clientOptions).length === 0)) {
@@ -838,10 +887,21 @@ let V3 = (() => {
838
887
  verbose: this.verbose,
839
888
  systemPrompt: this.opts.systemPrompt,
840
889
  selfHeal: this.opts.selfHeal,
890
+ useTouch: this.opts.useTouch,
841
891
  browserbaseSessionCreateParams: createSessionPayload,
842
892
  browserbaseSessionID: this.opts.browserbaseSessionID,
843
893
  });
844
894
  if (!available) {
895
+ if (isAutoModel(this.modelName)) {
896
+ // "auto" has no local fallback; end the just-created session
897
+ // best-effort before surfacing the error. Never end a
898
+ // caller-supplied (resumed) session we didn't create.
899
+ if (!this.opts.browserbaseSessionID) {
900
+ await this.apiClient.end().catch(() => { });
901
+ }
902
+ this.apiClient = null;
903
+ throw new StagehandInitError(`model: "${AUTO_MODEL_NAME}" requires the Stagehand API, but it is unavailable for this session (sessionId: ${sessionId}). Specify a concrete model (e.g. "openai/gpt-5") instead.`);
904
+ }
845
905
  this.apiClient = null;
846
906
  }
847
907
  this.opts.browserbaseSessionID = sessionId;
@@ -994,7 +1054,10 @@ let V3 = (() => {
994
1054
  let actCacheContext = null;
995
1055
  const canUseCache = typeof input === "string" &&
996
1056
  !this.isAgentReplayRecording() &&
997
- this.actCache.enabled;
1057
+ this.actCache.enabled &&
1058
+ // "auto" sessions have no local LLM client for replay self-heal;
1059
+ // rely on the API (and its server-side cache) instead.
1060
+ !isAutoModel(this.modelName);
998
1061
  if (canUseCache) {
999
1062
  actCacheContext = await this.actCache.prepareContext(input, page, flattenVariables(options?.variables));
1000
1063
  if (actCacheContext) {
@@ -1478,7 +1541,9 @@ let V3 = (() => {
1478
1541
  cua: { value: isCuaMode ? "true" : "false", type: "boolean" },
1479
1542
  mode: { value: loggedMode, type: "string" },
1480
1543
  model: {
1481
- value: extractModelName(options?.model) ?? this.llmClient.modelName,
1544
+ value: extractModelName(options?.model) ??
1545
+ this.llmClient?.modelName ??
1546
+ this.modelName,
1482
1547
  type: "string",
1483
1548
  },
1484
1549
  systemPrompt: { value: options?.systemPrompt ?? "", type: "string" },