@browserbasehq/orca 3.0.2-zod34 → 3.0.2-zod3456

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ZodTypeAny, z, ZodError } from 'zod';
1
+ import { ZodTypeAny, z, ZodObject, ZodRawShape, ZodError } from 'zod';
2
2
  import * as z3 from 'zod/v3';
3
3
  import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
4
4
  import { LanguageModelV2 } from '@ai-sdk/provider';
@@ -19,7 +19,14 @@ import { ToolSet as ToolSet$1 } from 'ai/dist';
19
19
  import { Schema } from '@google/genai';
20
20
 
21
21
  type StagehandZodSchema = ZodTypeAny | z3.ZodTypeAny;
22
+ type StagehandZodObject = ZodObject<ZodRawShape> | z3.ZodObject<z3.ZodRawShape>;
22
23
  type InferStagehandSchema<T extends StagehandZodSchema> = T extends z3.ZodTypeAny ? z3.infer<T> : T extends ZodTypeAny ? z.infer<T> : never;
24
+ declare const isZod4Schema: (schema: StagehandZodSchema) => schema is ZodTypeAny & {
25
+ _zod: unknown;
26
+ };
27
+ declare const isZod3Schema: (schema: StagehandZodSchema) => schema is z3.ZodTypeAny;
28
+ type JsonSchemaDocument = Record<string, unknown>;
29
+ declare function toJsonSchema(schema: StagehandZodSchema): JsonSchemaDocument;
23
30
 
24
31
  type AnthropicJsonSchemaObject = {
25
32
  definitions?: {
@@ -2096,6 +2103,7 @@ interface JsonSchemaProperty {
2096
2103
  minimum?: number;
2097
2104
  maximum?: number;
2098
2105
  description?: string;
2106
+ format?: string;
2099
2107
  }
2100
2108
  interface JsonSchema extends JsonSchemaProperty {
2101
2109
  type: string;
@@ -2136,4 +2144,4 @@ declare class V3Evaluator {
2136
2144
  private _evaluateWithMultipleScreenshots;
2137
2145
  }
2138
2146
 
2139
- export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, TimeoutError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
2147
+ export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, type InferStagehandSchema, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaDocument, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type StagehandZodObject, type StagehandZodSchema, TimeoutError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, isZod3Schema, isZod4Schema, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ var __async = (__this, __arguments, generator) => {
85
85
  var STAGEHAND_VERSION;
86
86
  var init_version = __esm({
87
87
  "lib/version.ts"() {
88
- STAGEHAND_VERSION = "3.0.2-zod34";
88
+ STAGEHAND_VERSION = "3.0.2-zod3456";
89
89
  }
90
90
  });
91
91
 
@@ -7935,12 +7935,15 @@ __export(v3_exports, {
7935
7935
  getZodType: () => getZodType,
7936
7936
  injectUrls: () => injectUrls,
7937
7937
  isRunningInBun: () => isRunningInBun,
7938
+ isZod3Schema: () => isZod3Schema,
7939
+ isZod4Schema: () => isZod4Schema,
7938
7940
  jsonSchemaToZod: () => jsonSchemaToZod,
7939
7941
  loadApiKeyFromEnv: () => loadApiKeyFromEnv,
7940
7942
  modelToAgentProviderMap: () => modelToAgentProviderMap,
7941
7943
  pageTextSchema: () => pageTextSchema,
7942
7944
  providerEnvVarMap: () => providerEnvVarMap,
7943
7945
  toGeminiSchema: () => toGeminiSchema,
7946
+ toJsonSchema: () => toJsonSchema,
7944
7947
  transformSchema: () => transformSchema,
7945
7948
  trimTrailingTextNode: () => trimTrailingTextNode,
7946
7949
  validateZodSchema: () => validateZodSchema
@@ -7962,16 +7965,96 @@ var import_v3 = __toESM(require("zod/v3"));
7962
7965
 
7963
7966
  // lib/v3/zodCompat.ts
7964
7967
  var import_zod = require("zod");
7965
- var import_zod_to_json_schema = require("zod-to-json-schema");
7966
7968
  var isZod4Schema = (schema) => typeof schema._zod !== "undefined";
7967
- function toJsonSchema(schema, options) {
7968
- if (isZod4Schema(schema) && typeof import_zod.z.toJSONSchema === "function" && !options) {
7969
- return import_zod.z.toJSONSchema(schema);
7969
+ var isZod3Schema = (schema) => !isZod4Schema(schema);
7970
+ function ZodToJsonSchema(schema) {
7971
+ const _def = schema._def;
7972
+ if (!_def) {
7973
+ return { type: "null" };
7970
7974
  }
7971
- return (0, import_zod_to_json_schema.zodToJsonSchema)(
7972
- schema,
7973
- options != null ? options : { $refStrategy: "none" }
7974
- );
7975
+ const typeName = _def.typeName;
7976
+ switch (typeName) {
7977
+ case "ZodObject": {
7978
+ const shape = typeof _def.shape === "function" ? _def.shape() : _def.shape;
7979
+ const properties = {};
7980
+ const required = [];
7981
+ for (const [key, value] of Object.entries(shape)) {
7982
+ properties[key] = ZodToJsonSchema(value);
7983
+ const valueDef = value._def;
7984
+ if ((valueDef == null ? void 0 : valueDef.typeName) !== "ZodOptional") {
7985
+ required.push(key);
7986
+ }
7987
+ }
7988
+ return {
7989
+ type: "object",
7990
+ properties,
7991
+ required,
7992
+ additionalProperties: _def.unknownKeys === "passthrough"
7993
+ };
7994
+ }
7995
+ case "ZodArray": {
7996
+ const itemType = _def.type;
7997
+ return {
7998
+ type: "array",
7999
+ items: ZodToJsonSchema(itemType)
8000
+ };
8001
+ }
8002
+ case "ZodString": {
8003
+ const result = { type: "string" };
8004
+ const checks = _def.checks;
8005
+ if (checks) {
8006
+ for (const check of checks) {
8007
+ if (check.kind === "url") {
8008
+ result.format = "url";
8009
+ break;
8010
+ }
8011
+ }
8012
+ }
8013
+ return result;
8014
+ }
8015
+ case "ZodNumber":
8016
+ return { type: "number" };
8017
+ case "ZodBoolean":
8018
+ return { type: "boolean" };
8019
+ case "ZodOptional":
8020
+ return ZodToJsonSchema(_def.innerType);
8021
+ case "ZodNullable": {
8022
+ const innerSchema = ZodToJsonSchema(_def.innerType);
8023
+ return __spreadProps(__spreadValues({}, innerSchema), {
8024
+ nullable: true
8025
+ });
8026
+ }
8027
+ case "ZodEnum":
8028
+ return {
8029
+ type: "string",
8030
+ enum: _def.values
8031
+ };
8032
+ case "ZodLiteral":
8033
+ return {
8034
+ type: typeof _def.value,
8035
+ const: _def.value
8036
+ };
8037
+ case "ZodUnion":
8038
+ return {
8039
+ anyOf: _def.options.map((opt) => ZodToJsonSchema(opt))
8040
+ };
8041
+ default:
8042
+ console.warn(`Unknown Zod type: ${typeName}`);
8043
+ return { type: "null" };
8044
+ }
8045
+ }
8046
+ function toJsonSchema(schema) {
8047
+ if (!isZod4Schema(schema)) {
8048
+ const result = __spreadValues({
8049
+ $schema: "http://json-schema.org/draft-07/schema#"
8050
+ }, ZodToJsonSchema(schema));
8051
+ return result;
8052
+ }
8053
+ const zodWithJsonSchema = import_zod.z;
8054
+ if (zodWithJsonSchema.toJSONSchema) {
8055
+ return zodWithJsonSchema.toJSONSchema(schema);
8056
+ }
8057
+ throw new Error("Zod v4 toJSONSchema method not found");
7975
8058
  }
7976
8059
 
7977
8060
  // lib/utils.ts
@@ -8571,6 +8654,13 @@ function jsonSchemaToZod(schema) {
8571
8654
  return import_zod2.z.string().refine((val) => schema.enum.includes(val));
8572
8655
  }
8573
8656
  let zodString = import_zod2.z.string();
8657
+ if (schema.format === "uri" || schema.format === "url") {
8658
+ zodString = zodString.url();
8659
+ } else if (schema.format === "email") {
8660
+ zodString = zodString.email();
8661
+ } else if (schema.format === "uuid") {
8662
+ zodString = zodString.uuid();
8663
+ }
8574
8664
  if (schema.description) {
8575
8665
  zodString = zodString.describe(schema.description);
8576
8666
  }
@@ -19690,7 +19780,7 @@ var getRefs = (options) => {
19690
19780
  )
19691
19781
  });
19692
19782
  };
19693
- var zodToJsonSchema2 = (schema, options) => {
19783
+ var zodToJsonSchema = (schema, options) => {
19694
19784
  var _a;
19695
19785
  const refs = getRefs(options);
19696
19786
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
@@ -19735,7 +19825,7 @@ var zodToJsonSchema2 = (schema, options) => {
19735
19825
  combined.$schema = "http://json-schema.org/draft-07/schema#";
19736
19826
  return combined;
19737
19827
  };
19738
- var zod_to_json_schema_default = zodToJsonSchema2;
19828
+ var zod_to_json_schema_default = zodToJsonSchema;
19739
19829
  function zod3Schema(zodSchema2, options) {
19740
19830
  var _a;
19741
19831
  const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
@@ -39342,7 +39432,7 @@ var CdpConnection = class _CdpConnection {
39342
39432
  yield this.send("Target.setAutoAttach", {
39343
39433
  autoAttach: true,
39344
39434
  flatten: true,
39345
- waitForDebuggerOnStart: true,
39435
+ waitForDebuggerOnStart: false,
39346
39436
  filter: [
39347
39437
  { type: "worker", exclude: true },
39348
39438
  { type: "shared_worker", exclude: true },
@@ -39525,12 +39615,15 @@ init_logger();
39525
39615
  // lib/v3/dom/build/scriptV3Content.ts
39526
39616
  var v3ScriptContent = '(()=>{function b(_={}){let S=n=>{let{hostToRoot:l}=n,m=t=>{let o=[];if(t instanceof Document)return t.documentElement&&o.push(t.documentElement),o;if(t instanceof ShadowRoot||t instanceof DocumentFragment)return o.push(...Array.from(t.children)),o;if(t instanceof Element){o.push(...Array.from(t.children));let a=t.shadowRoot;a&&o.push(...Array.from(a.children));let r=l.get(t);return r&&o.push(...Array.from(r.children)),o}return o},v=t=>{let o=[],a=[...m(t)];for(;a.length;){let r=a.shift();o.push(r),a.push(...m(r))}return o},y=t=>{let o=String(t||"").trim();if(!o)return null;let a=o.replace(/^xpath=/i,""),r=[];{let e=0;for(;e<a.length;){let d="child";a.startsWith("//",e)?(d="desc",e+=2):a[e]==="/"&&(d="child",e+=1);let h=e;for(;e<a.length&&a[e]!=="/";)e++;let u=a.slice(h,e).trim();if(!u)continue;let p=u.match(/^(.*?)(\\[(\\d+)\\])?$/u),i=(p?.[1]??u).trim(),c=p?.[3]?Math.max(1,Number(p[3])):null,R=i===""?"*":i.toLowerCase();r.push({axis:d,raw:u,tag:R,index:c})}}n.debug&&console.info("[v3-piercer][resolve] start",{url:location.href,steps:r.map(e=>({axis:e.axis,raw:e.raw,tag:e.tag,index:e.index}))});let g=[document];for(let e of r){let d=e.index,h=null;for(let u of g){let p=e.axis==="child"?m(u):v(u),i=[];for(let c of p)(e.tag==="*"||c.localName===e.tag)&&i.push(c);if(n.debug&&console.info("[v3-piercer][resolve] step",{axis:e.axis,tag:e.tag,index:d,poolCount:p.length,matchesCount:i.length}),!!i.length){if(d!=null){let c=d-1;h=c>=0&&c<i.length?i[c]:null}else h=i[0];if(h)break}}if(!h)return n.debug&&console.info("[v3-piercer][resolve] no-match",{step:e.raw}),null;g=[h]}let E=g.length?g[0]:null;return n.debug&&console.info("[v3-piercer][resolve] done",{found:!!E,tag:E?.localName??""}),E};window.__stagehandV3__={getClosedRoot:t=>l.get(t),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:n.openCount,closed:n.closedCount}),resolveSimpleXPath:y}},f=Element.prototype.attachShadow;if(f.__v3Patched&&f.__v3State){f.__v3State.debug=!0,S(f.__v3State);return}let s={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},x=f,w=function(n){let l=n?.mode??"open",m=x.call(this,n);try{s.hostToRoot.set(this,m),l==="closed"?s.closedCount++:s.openCount++,s.debug&&console.info("[v3-piercer] attachShadow",{tag:this.tagName?.toLowerCase()??"",mode:l,url:location.href})}catch{}return m};if(w.__v3Patched=!0,w.__v3State=s,Object.defineProperty(Element.prototype,"attachShadow",{configurable:!0,writable:!0,value:w}),_.tagExisting)try{let n=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;n.nextNode();){let l=n.currentNode;l.shadowRoot&&(s.hostToRoot.set(l,l.shadowRoot),s.openCount++)}}catch{}window.__stagehandV3Injected=!0,S(s),s.debug&&console.info("[v3-piercer] installed",{url:location.href,isTop:window.top===window,readyState:document.readyState})}b({debug:!0,tagExisting:!1});})();\n';
39527
39617
 
39618
+ // lib/v3/dom/build/reRenderScriptContent.ts
39619
+ var reRenderScriptContent = '(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!="function")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??"";if(!n.includes("-")||typeof customElements?.get!="function"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info("[v3-piercer] rerender",{count:t.length})}catch(o){console.info("[v3-piercer] rerender error",{message:String(o??"")})}}s();})();\n';
39620
+
39528
39621
  // lib/v3/understudy/piercer.ts
39529
39622
  function installV3PiercerIntoSession(session) {
39530
39623
  return __async(this, null, function* () {
39531
39624
  var _a, _b;
39532
- yield session.send("Page.enable").catch(() => {
39533
- });
39625
+ const pageEnabled = yield session.send("Page.enable").then(() => true).catch(() => false);
39626
+ if (!pageEnabled) return false;
39534
39627
  yield session.send("Runtime.enable").catch(() => {
39535
39628
  });
39536
39629
  try {
@@ -39540,7 +39633,7 @@ function installV3PiercerIntoSession(session) {
39540
39633
  );
39541
39634
  } catch (e) {
39542
39635
  const msg = String((_b = (_a = e == null ? void 0 : e.message) != null ? _a : e) != null ? _b : "");
39543
- if (msg.includes("Session with given id not found")) return;
39636
+ if (msg.includes("Session with given id not found")) return false;
39544
39637
  }
39545
39638
  yield session.send("Runtime.evaluate", {
39546
39639
  expression: v3ScriptContent,
@@ -39548,6 +39641,13 @@ function installV3PiercerIntoSession(session) {
39548
39641
  awaitPromise: true
39549
39642
  }).catch(() => {
39550
39643
  });
39644
+ yield session.send("Runtime.evaluate", {
39645
+ expression: reRenderScriptContent,
39646
+ returnByValue: true,
39647
+ awaitPromise: false
39648
+ }).catch(() => {
39649
+ });
39650
+ return true;
39551
39651
  });
39552
39652
  }
39553
39653
 
@@ -39654,9 +39754,12 @@ var V3Context = class _V3Context {
39654
39754
  ensurePiercer(session) {
39655
39755
  return __async(this, null, function* () {
39656
39756
  const key = this.sessionKey(session);
39657
- if (this._piercerInstalled.has(key)) return;
39658
- yield installV3PiercerIntoSession(session);
39659
- this._piercerInstalled.add(key);
39757
+ if (this._piercerInstalled.has(key)) return true;
39758
+ const installed = yield installV3PiercerIntoSession(session);
39759
+ if (installed) {
39760
+ this._piercerInstalled.add(key);
39761
+ }
39762
+ return installed;
39660
39763
  });
39661
39764
  }
39662
39765
  /** Mark a page target as the most-recent one (active). */
@@ -39794,11 +39897,7 @@ var V3Context = class _V3Context {
39794
39897
  this.conn.on(
39795
39898
  "Target.attachedToTarget",
39796
39899
  (evt) => __async(this, null, function* () {
39797
- yield this.onAttachedToTarget(
39798
- evt.targetInfo,
39799
- evt.sessionId,
39800
- evt.waitingForDebugger === true
39801
- );
39900
+ yield this.onAttachedToTarget(evt.targetInfo, evt.sessionId);
39802
39901
  })
39803
39902
  );
39804
39903
  this.conn.on(
@@ -39851,29 +39950,20 @@ var V3Context = class _V3Context {
39851
39950
  * if the parent is known; otherwise stage until parent `frameAttached`.
39852
39951
  * - Resume the target only after listeners are wired.
39853
39952
  */
39854
- onAttachedToTarget(info, sessionId, waitingForDebugger) {
39953
+ onAttachedToTarget(info, sessionId) {
39855
39954
  return __async(this, null, function* () {
39856
39955
  var _a;
39857
39956
  const session = this.conn.getSession(sessionId);
39858
39957
  if (!session) return;
39859
39958
  if (this._sessionInit.has(sessionId)) return;
39860
39959
  this._sessionInit.add(sessionId);
39861
- const pageEnabled = yield session.send("Page.enable").then(() => true).catch(() => false);
39862
- if (!pageEnabled) {
39863
- if (waitingForDebugger) {
39864
- yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
39865
- });
39866
- }
39867
- return;
39868
- }
39869
- yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
39870
- });
39871
39960
  yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
39872
39961
  });
39873
39962
  executionContexts.attachSession(session);
39874
- yield session.send("Runtime.enable").catch(() => {
39963
+ const piercerReady = yield this.ensurePiercer(session);
39964
+ if (!piercerReady) return;
39965
+ yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
39875
39966
  });
39876
- yield this.ensurePiercer(session);
39877
39967
  if (isTopLevelPage(info)) {
39878
39968
  const page = yield Page.create(
39879
39969
  this.conn,
@@ -39897,10 +39987,6 @@ var V3Context = class _V3Context {
39897
39987
  page.seedCurrentUrl((_a = pendingSeedUrl != null ? pendingSeedUrl : info.url) != null ? _a : "");
39898
39988
  this._pushActive(info.targetId);
39899
39989
  this.installFrameEventBridges(sessionId, page);
39900
- if (waitingForDebugger) {
39901
- yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
39902
- });
39903
- }
39904
39990
  return;
39905
39991
  }
39906
39992
  try {
@@ -39928,51 +40014,13 @@ var V3Context = class _V3Context {
39928
40014
  owner.adoptOopifSession(session, childMainId);
39929
40015
  this.sessionOwnerPage.set(sessionId, owner);
39930
40016
  this.installFrameEventBridges(sessionId, owner);
40017
+ void executionContexts.waitForMainWorld(session, childMainId).catch(() => {
40018
+ });
39931
40019
  } else {
39932
40020
  this.pendingOopifByMainFrame.set(childMainId, sessionId);
39933
40021
  }
39934
40022
  } catch (e) {
39935
40023
  }
39936
- if (info.type === "iframe" && !waitingForDebugger) {
39937
- try {
39938
- yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
39939
- });
39940
- const loadWait = new Promise((resolve2) => {
39941
- const handler = (evt) => {
39942
- if (evt.name === "load") {
39943
- session.off("Page.lifecycleEvent", handler);
39944
- resolve2();
39945
- }
39946
- };
39947
- session.on("Page.lifecycleEvent", handler);
39948
- });
39949
- yield session.send("Runtime.evaluate", {
39950
- expression: "location.reload()",
39951
- returnByValue: true,
39952
- awaitPromise: false
39953
- }).catch(() => {
39954
- });
39955
- yield Promise.race([
39956
- loadWait,
39957
- new Promise((r) => setTimeout(r, 3e3))
39958
- ]);
39959
- yield this.ensurePiercer(session);
39960
- } catch (e) {
39961
- v3Logger({
39962
- category: "ctx",
39963
- message: "child reload attempt failed (continuing)",
39964
- level: 2,
39965
- auxiliary: {
39966
- sessionId: { value: String(sessionId), type: "string" },
39967
- err: { value: String(e), type: "string" }
39968
- }
39969
- });
39970
- }
39971
- }
39972
- if (waitingForDebugger) {
39973
- yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
39974
- });
39975
- }
39976
40024
  });
39977
40025
  }
39978
40026
  /**
@@ -42089,12 +42137,15 @@ I'm providing ${screenshots.length} screenshots showing the progression of the t
42089
42137
  getZodType,
42090
42138
  injectUrls,
42091
42139
  isRunningInBun,
42140
+ isZod3Schema,
42141
+ isZod4Schema,
42092
42142
  jsonSchemaToZod,
42093
42143
  loadApiKeyFromEnv,
42094
42144
  modelToAgentProviderMap,
42095
42145
  pageTextSchema,
42096
42146
  providerEnvVarMap,
42097
42147
  toGeminiSchema,
42148
+ toJsonSchema,
42098
42149
  transformSchema,
42099
42150
  trimTrailingTextNode,
42100
42151
  validateZodSchema
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserbasehq/orca",
3
- "version": "3.0.2-zod34",
3
+ "version": "3.0.2-zod3456",
4
4
  "description": "An AI web browsing framework focused on simplicity and extensibility.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "peerDependencies": {
25
25
  "deepmerge": "^4.3.1",
26
26
  "dotenv": "^16.4.5",
27
- "zod": "^3.25.0 || ^4.0.0"
27
+ "zod": "^3.25.67 || ^4.1.8"
28
28
  },
29
29
  "dependencies": {
30
30
  "@ai-sdk/provider": "^2.0.0",
@@ -40,8 +40,7 @@
40
40
  "pino": "^9.6.0",
41
41
  "pino-pretty": "^13.0.0",
42
42
  "playwright": "^1.52.0",
43
- "ws": "^8.18.0",
44
- "zod-to-json-schema": "^3.24.5"
43
+ "ws": "^8.18.0"
45
44
  },
46
45
  "optionalDependencies": {
47
46
  "@ai-sdk/anthropic": "^2.0.34",
@@ -69,6 +68,7 @@
69
68
  "tsup": "^8.2.1",
70
69
  "tsx": "^4.10.5",
71
70
  "typescript": "^5.2.2",
71
+ "vitest": "^4.0.8",
72
72
  "zod": "^4.1.8"
73
73
  },
74
74
  "repository": {
@@ -92,6 +92,7 @@
92
92
  "e2e:local": "playwright test --config=lib/v3/tests/v3.local.playwright.config.ts",
93
93
  "e2e:bb": "playwright test --config=lib/v3/tests/v3.bb.playwright.config.ts",
94
94
  "lint": "cd ../.. && prettier --check packages/core && cd packages/core && eslint .",
95
- "format": "prettier --write ."
95
+ "format": "prettier --write .",
96
+ "test:vitest": "pnpm run build-js && vitest run --config vitest.config.ts"
96
97
  }
97
98
  }