@browserbasehq/orca 3.0.0-preview.7 → 3.0.0-test.1

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 (3) hide show
  1. package/dist/index.d.ts +47 -32
  2. package/dist/index.js +303 -232
  3. package/package.json +3 -4
package/dist/index.js CHANGED
@@ -3102,6 +3102,11 @@ var init_deepLocator = __esm({
3102
3102
  return (yield this.real()).sendClickEvent(options);
3103
3103
  });
3104
3104
  }
3105
+ setInputFiles(files) {
3106
+ return __async(this, null, function* () {
3107
+ return (yield this.real()).setInputFiles(files);
3108
+ });
3109
+ }
3105
3110
  first() {
3106
3111
  return this.nth(0);
3107
3112
  }
@@ -6290,7 +6295,7 @@ var import_path5 = __toESM(require("path"));
6290
6295
  var import_process2 = __toESM(require("process"));
6291
6296
 
6292
6297
  // lib/version.ts
6293
- var STAGEHAND_VERSION = "3.0.0-preview.7";
6298
+ var STAGEHAND_VERSION = "3.0.0-test.1";
6294
6299
 
6295
6300
  // lib/v3/types/public/sdkErrors.ts
6296
6301
  var StagehandError = class extends Error {
@@ -6515,7 +6520,7 @@ var StagehandShadowSegmentNotFoundError = class extends StagehandError {
6515
6520
 
6516
6521
  // lib/utils.ts
6517
6522
  var import_genai = require("@google/genai");
6518
- var import_v3 = require("zod/v3");
6523
+ var import_zod = require("zod");
6519
6524
  var ID_PATTERN = /^\d+-\d+$/;
6520
6525
  function validateZodSchema(schema, data) {
6521
6526
  const result = schema.safeParse(data);
@@ -6539,28 +6544,28 @@ function decorateGeminiSchema(geminiSchema, zodSchema2) {
6539
6544
  function toGeminiSchema(zodSchema2) {
6540
6545
  const zodType = getZodType(zodSchema2);
6541
6546
  switch (zodType) {
6542
- case "ZodArray": {
6547
+ case "array": {
6548
+ const arraySchema = zodSchema2;
6549
+ const element = arraySchema._zod.def.element;
6543
6550
  return decorateGeminiSchema(
6544
6551
  {
6545
6552
  type: import_genai.Type.ARRAY,
6546
- items: toGeminiSchema(
6547
- zodSchema2.element
6548
- )
6553
+ items: toGeminiSchema(element != null ? element : import_zod.z.any())
6549
6554
  },
6550
6555
  zodSchema2
6551
6556
  );
6552
6557
  }
6553
- case "ZodObject": {
6558
+ case "object": {
6554
6559
  const properties = {};
6555
6560
  const required = [];
6556
- Object.entries(zodSchema2.shape).forEach(
6557
- ([key, value]) => {
6558
- properties[key] = toGeminiSchema(value);
6559
- if (getZodType(value) !== "ZodOptional") {
6560
- required.push(key);
6561
- }
6561
+ const objectSchema = zodSchema2;
6562
+ const shape = objectSchema._zod.def.shape;
6563
+ Object.entries(shape).forEach(([key, value]) => {
6564
+ properties[key] = toGeminiSchema(value);
6565
+ if (getZodType(value) !== "optional") {
6566
+ required.push(key);
6562
6567
  }
6563
- );
6568
+ });
6564
6569
  return decorateGeminiSchema(
6565
6570
  {
6566
6571
  type: import_genai.Type.OBJECT,
@@ -6570,39 +6575,45 @@ function toGeminiSchema(zodSchema2) {
6570
6575
  zodSchema2
6571
6576
  );
6572
6577
  }
6573
- case "ZodString":
6578
+ case "string":
6579
+ case "url":
6574
6580
  return decorateGeminiSchema(
6575
6581
  {
6576
6582
  type: import_genai.Type.STRING
6577
6583
  },
6578
6584
  zodSchema2
6579
6585
  );
6580
- case "ZodNumber":
6586
+ case "number":
6581
6587
  return decorateGeminiSchema(
6582
6588
  {
6583
6589
  type: import_genai.Type.NUMBER
6584
6590
  },
6585
6591
  zodSchema2
6586
6592
  );
6587
- case "ZodBoolean":
6593
+ case "boolean":
6588
6594
  return decorateGeminiSchema(
6589
6595
  {
6590
6596
  type: import_genai.Type.BOOLEAN
6591
6597
  },
6592
6598
  zodSchema2
6593
6599
  );
6594
- case "ZodEnum":
6600
+ case "enum": {
6601
+ const enumSchema = zodSchema2;
6602
+ const values = Object.values(enumSchema._zod.def.entries);
6595
6603
  return decorateGeminiSchema(
6596
6604
  {
6597
6605
  type: import_genai.Type.STRING,
6598
- enum: zodSchema2._def.values
6606
+ enum: values
6599
6607
  },
6600
6608
  zodSchema2
6601
6609
  );
6602
- case "ZodDefault":
6603
- case "ZodNullable":
6604
- case "ZodOptional": {
6605
- const innerSchema = toGeminiSchema(zodSchema2._def.innerType);
6610
+ }
6611
+ case "default":
6612
+ case "nullable":
6613
+ case "optional": {
6614
+ const wrapperSchema = zodSchema2;
6615
+ const innerType = wrapperSchema._zod.def.innerType;
6616
+ const innerSchema = toGeminiSchema(innerType);
6606
6617
  return decorateGeminiSchema(
6607
6618
  __spreadProps(__spreadValues({}, innerSchema), {
6608
6619
  nullable: true
@@ -6610,14 +6621,23 @@ function toGeminiSchema(zodSchema2) {
6610
6621
  zodSchema2
6611
6622
  );
6612
6623
  }
6613
- case "ZodLiteral":
6624
+ case "literal": {
6625
+ const literalSchema = zodSchema2;
6626
+ const values = literalSchema._zod.def.values;
6614
6627
  return decorateGeminiSchema(
6615
6628
  {
6616
6629
  type: import_genai.Type.STRING,
6617
- enum: [zodSchema2._def.value]
6630
+ enum: values
6618
6631
  },
6619
6632
  zodSchema2
6620
6633
  );
6634
+ }
6635
+ case "pipe": {
6636
+ const pipeSchema = zodSchema2;
6637
+ const inSchema = pipeSchema._zod.def.in;
6638
+ return toGeminiSchema(inSchema);
6639
+ }
6640
+ // Standalone transforms and any unknown types fall through to default
6621
6641
  default:
6622
6642
  return decorateGeminiSchema(
6623
6643
  {
@@ -6629,21 +6649,40 @@ function toGeminiSchema(zodSchema2) {
6629
6649
  }
6630
6650
  }
6631
6651
  function getZodType(schema) {
6632
- return schema._def.typeName;
6652
+ var _a, _b;
6653
+ const schemaWithDef = schema;
6654
+ if ((_b = (_a = schemaWithDef._zod) == null ? void 0 : _a.def) == null ? void 0 : _b.type) {
6655
+ return schemaWithDef._zod.def.type;
6656
+ }
6657
+ throw new Error(
6658
+ `Unable to determine Zod schema type. Schema: ${JSON.stringify(schema)}`
6659
+ );
6633
6660
  }
6634
6661
  function transformSchema(schema, currentPath) {
6635
6662
  var _a, _b;
6636
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodString)) {
6637
- const hasUrlCheck = (_b = (_a = schema._def.checks) == null ? void 0 : _a.some(
6638
- (check) => check.kind === "url"
6639
- )) != null ? _b : false;
6663
+ if (isKind(schema, "url")) {
6664
+ const transformed = makeIdStringSchema(schema);
6665
+ return [transformed, [{ segments: [] }]];
6666
+ }
6667
+ if (isKind(schema, "string")) {
6668
+ const stringSchema = schema;
6669
+ const checks = stringSchema._zod.def.checks;
6670
+ const format = (_a = stringSchema._zod.bag) == null ? void 0 : _a.format;
6671
+ const hasUrlCheck = ((_b = checks == null ? void 0 : checks.some((check) => {
6672
+ var _a2, _b2;
6673
+ return ((_b2 = (_a2 = check._zod) == null ? void 0 : _a2.def) == null ? void 0 : _b2.check) === "url";
6674
+ })) != null ? _b : false) || format === "url";
6640
6675
  if (hasUrlCheck) {
6641
6676
  return [makeIdStringSchema(schema), [{ segments: [] }]];
6642
6677
  }
6643
6678
  return [schema, []];
6644
6679
  }
6645
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodObject)) {
6646
- const shape = schema._def.shape();
6680
+ if (isKind(schema, "object")) {
6681
+ const objectSchema = schema;
6682
+ const shape = objectSchema._zod.def.shape;
6683
+ if (!shape) {
6684
+ return [schema, []];
6685
+ }
6647
6686
  const newShape = {};
6648
6687
  const urlPaths = [];
6649
6688
  let changed = false;
@@ -6665,12 +6704,17 @@ function transformSchema(schema, currentPath) {
6665
6704
  }
6666
6705
  }
6667
6706
  if (changed) {
6668
- return [import_v3.z.object(newShape), urlPaths];
6707
+ const newSchema = import_zod.z.object(newShape);
6708
+ return [newSchema, urlPaths];
6669
6709
  }
6670
6710
  return [schema, urlPaths];
6671
6711
  }
6672
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodArray)) {
6673
- const itemType = schema._def.type;
6712
+ if (isKind(schema, "array")) {
6713
+ const arraySchema = schema;
6714
+ const itemType = arraySchema._zod.def.element;
6715
+ if (!itemType) {
6716
+ return [schema, []];
6717
+ }
6674
6718
  const [transformedItem, childPaths] = transformSchema(itemType, [
6675
6719
  ...currentPath,
6676
6720
  "*"
@@ -6680,12 +6724,17 @@ function transformSchema(schema, currentPath) {
6680
6724
  segments: ["*", ...cp.segments]
6681
6725
  }));
6682
6726
  if (changed) {
6683
- return [import_v3.z.array(transformedItem), arrayPaths];
6727
+ const newSchema = import_zod.z.array(transformedItem);
6728
+ return [newSchema, arrayPaths];
6684
6729
  }
6685
6730
  return [schema, arrayPaths];
6686
6731
  }
6687
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodUnion)) {
6688
- const unionOptions = schema._def.options;
6732
+ if (isKind(schema, "union")) {
6733
+ const unionSchema = schema;
6734
+ const unionOptions = unionSchema._zod.def.options;
6735
+ if (!unionOptions || unionOptions.length === 0) {
6736
+ return [schema, []];
6737
+ }
6689
6738
  const newOptions = [];
6690
6739
  let changed = false;
6691
6740
  let allPaths = [];
@@ -6702,15 +6751,19 @@ function transformSchema(schema, currentPath) {
6702
6751
  });
6703
6752
  if (changed) {
6704
6753
  return [
6705
- import_v3.z.union(newOptions),
6754
+ import_zod.z.union(newOptions),
6706
6755
  allPaths
6707
6756
  ];
6708
6757
  }
6709
6758
  return [schema, allPaths];
6710
6759
  }
6711
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodIntersection)) {
6712
- const leftType = schema._def.left;
6713
- const rightType = schema._def.right;
6760
+ if (isKind(schema, "intersection")) {
6761
+ const intersectionSchema = schema;
6762
+ const leftType = intersectionSchema._zod.def.left;
6763
+ const rightType = intersectionSchema._zod.def.right;
6764
+ if (!leftType || !rightType) {
6765
+ return [schema, []];
6766
+ }
6714
6767
  const [left, leftPaths] = transformSchema(leftType, [
6715
6768
  ...currentPath,
6716
6769
  "intersection_left"
@@ -6722,33 +6775,50 @@ function transformSchema(schema, currentPath) {
6722
6775
  const changed = left !== leftType || right !== rightType;
6723
6776
  const allPaths = [...leftPaths, ...rightPaths];
6724
6777
  if (changed) {
6725
- return [import_v3.z.intersection(left, right), allPaths];
6778
+ return [import_zod.z.intersection(left, right), allPaths];
6726
6779
  }
6727
6780
  return [schema, allPaths];
6728
6781
  }
6729
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodOptional)) {
6730
- const innerType = schema._def.innerType;
6782
+ if (isKind(schema, "optional")) {
6783
+ const optionalSchema = schema;
6784
+ const innerType = optionalSchema._zod.def.innerType;
6785
+ if (!innerType) {
6786
+ return [schema, []];
6787
+ }
6731
6788
  const [inner, innerPaths] = transformSchema(innerType, currentPath);
6732
6789
  if (inner !== innerType) {
6733
- return [import_v3.z.optional(inner), innerPaths];
6790
+ return [import_zod.z.optional(inner), innerPaths];
6734
6791
  }
6735
6792
  return [schema, innerPaths];
6736
6793
  }
6737
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodNullable)) {
6738
- const innerType = schema._def.innerType;
6794
+ if (isKind(schema, "nullable")) {
6795
+ const nullableSchema = schema;
6796
+ const innerType = nullableSchema._zod.def.innerType;
6797
+ if (!innerType) {
6798
+ return [schema, []];
6799
+ }
6739
6800
  const [inner, innerPaths] = transformSchema(innerType, currentPath);
6740
6801
  if (inner !== innerType) {
6741
- return [import_v3.z.nullable(inner), innerPaths];
6802
+ return [import_zod.z.nullable(inner), innerPaths];
6742
6803
  }
6743
6804
  return [schema, innerPaths];
6744
6805
  }
6745
- if (isKind(schema, import_v3.ZodFirstPartyTypeKind.ZodEffects)) {
6746
- const baseSchema = schema._def.schema;
6747
- const [newBaseSchema, basePaths] = transformSchema(baseSchema, currentPath);
6748
- if (newBaseSchema !== baseSchema) {
6749
- return [import_v3.z.effect(newBaseSchema, schema._def.effect), basePaths];
6806
+ if (isKind(schema, "pipe")) {
6807
+ const pipeSchema = schema;
6808
+ const inSchema = pipeSchema._zod.def.in;
6809
+ const outSchema = pipeSchema._zod.def.out;
6810
+ if (!inSchema || !outSchema) {
6811
+ return [schema, []];
6812
+ }
6813
+ const [newIn, inPaths] = transformSchema(inSchema, currentPath);
6814
+ const [newOut, outPaths] = transformSchema(outSchema, currentPath);
6815
+ const allPaths = [...inPaths, ...outPaths];
6816
+ const changed = newIn !== inSchema || newOut !== outSchema;
6817
+ if (changed) {
6818
+ const result = import_zod.z.pipe(newIn, newOut);
6819
+ return [result, allPaths];
6750
6820
  }
6751
- return [schema, basePaths];
6821
+ return [schema, allPaths];
6752
6822
  }
6753
6823
  return [schema, []];
6754
6824
  }
@@ -6794,17 +6864,18 @@ function injectUrls(obj, path6, idToUrlMapping) {
6794
6864
  }
6795
6865
  }
6796
6866
  function isKind(s, kind) {
6797
- return s._def.typeName === kind;
6867
+ try {
6868
+ return getZodType(s) === kind;
6869
+ } catch (e) {
6870
+ return false;
6871
+ }
6798
6872
  }
6799
6873
  function makeIdStringSchema(orig) {
6800
- var _a, _b, _c;
6801
- const userDesc = (
6802
- // Zod ≥3.23 exposes .description directly; fall back to _def for older minor versions
6803
- (_c = (_b = orig.description) != null ? _b : (_a = orig._def) == null ? void 0 : _a.description) != null ? _c : ""
6804
- );
6874
+ var _a;
6875
+ const userDesc = (_a = orig.description) != null ? _a : "";
6805
6876
  const base = `This field must be the element-ID in the form 'frameId-backendId' (e.g. "0-432").`;
6806
6877
  const composed = userDesc.trim().length > 0 ? `${base} that follows this user-defined description: ${userDesc}` : base;
6807
- return import_v3.z.string().regex(ID_PATTERN).describe(composed);
6878
+ return import_zod.z.string().regex(ID_PATTERN).describe(composed);
6808
6879
  }
6809
6880
  var providerEnvVarMap = {
6810
6881
  openai: "OPENAI_API_KEY",
@@ -6850,7 +6921,7 @@ function jsonSchemaToZod(schema) {
6850
6921
  for (const key in schema.properties) {
6851
6922
  shape[key] = jsonSchemaToZod(schema.properties[key]);
6852
6923
  }
6853
- let zodObject = import_v3.z.object(shape);
6924
+ let zodObject = import_zod.z.object(shape);
6854
6925
  if (schema.required && Array.isArray(schema.required)) {
6855
6926
  const requiredFields = schema.required.reduce(
6856
6927
  (acc, field) => __spreadProps(__spreadValues({}, acc), { [field]: true }),
@@ -6863,30 +6934,30 @@ function jsonSchemaToZod(schema) {
6863
6934
  }
6864
6935
  return zodObject;
6865
6936
  } else {
6866
- return import_v3.z.object({});
6937
+ return import_zod.z.object({});
6867
6938
  }
6868
6939
  case "array":
6869
6940
  if (schema.items) {
6870
- let zodArray = import_v3.z.array(jsonSchemaToZod(schema.items));
6941
+ let zodArray = import_zod.z.array(jsonSchemaToZod(schema.items));
6871
6942
  if (schema.description) {
6872
6943
  zodArray = zodArray.describe(schema.description);
6873
6944
  }
6874
6945
  return zodArray;
6875
6946
  } else {
6876
- return import_v3.z.array(import_v3.z.any());
6947
+ return import_zod.z.array(import_zod.z.any());
6877
6948
  }
6878
6949
  case "string": {
6879
6950
  if (schema.enum) {
6880
- return import_v3.z.string().refine((val) => schema.enum.includes(val));
6951
+ return import_zod.z.string().refine((val) => schema.enum.includes(val));
6881
6952
  }
6882
- let zodString = import_v3.z.string();
6953
+ let zodString = import_zod.z.string();
6883
6954
  if (schema.description) {
6884
6955
  zodString = zodString.describe(schema.description);
6885
6956
  }
6886
6957
  return zodString;
6887
6958
  }
6888
6959
  case "number": {
6889
- let zodNumber = import_v3.z.number();
6960
+ let zodNumber = import_zod.z.number();
6890
6961
  if (schema.minimum !== void 0) {
6891
6962
  zodNumber = zodNumber.min(schema.minimum);
6892
6963
  }
@@ -6899,14 +6970,14 @@ function jsonSchemaToZod(schema) {
6899
6970
  return zodNumber;
6900
6971
  }
6901
6972
  case "boolean": {
6902
- let zodBoolean = import_v3.z.boolean();
6973
+ let zodBoolean = import_zod.z.boolean();
6903
6974
  if (schema.description) {
6904
6975
  zodBoolean = zodBoolean.describe(schema.description);
6905
6976
  }
6906
6977
  return zodBoolean;
6907
6978
  }
6908
6979
  default:
6909
- return import_v3.z.any();
6980
+ return import_zod.z.any();
6910
6981
  }
6911
6982
  }
6912
6983
 
@@ -7827,7 +7898,7 @@ var CacheStorage = class _CacheStorage {
7827
7898
  };
7828
7899
 
7829
7900
  // lib/inference.ts
7830
- var import_v32 = require("zod/v3");
7901
+ var import_zod2 = require("zod");
7831
7902
 
7832
7903
  // lib/prompt.ts
7833
7904
  function buildUserInstructionsString(userProvidedInstructions) {
@@ -8086,11 +8157,11 @@ function extract(_0) {
8086
8157
  logInferenceToFile = false
8087
8158
  }) {
8088
8159
  var _a, _b, _c, _d, _e, _f, _g, _h;
8089
- const metadataSchema = import_v32.z.object({
8090
- progress: import_v32.z.string().describe(
8160
+ const metadataSchema = import_zod2.z.object({
8161
+ progress: import_zod2.z.string().describe(
8091
8162
  "progress of what has been extracted so far, as concise as possible"
8092
8163
  ),
8093
- completed: import_v32.z.boolean().describe(
8164
+ completed: import_zod2.z.boolean().describe(
8094
8165
  "true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed."
8095
8166
  )
8096
8167
  });
@@ -8240,20 +8311,20 @@ function observe(_0) {
8240
8311
  }) {
8241
8312
  var _a, _b, _c, _d;
8242
8313
  const isGPT5 = llmClient.modelName.includes("gpt-5");
8243
- const observeSchema = import_v32.z.object({
8244
- elements: import_v32.z.array(
8245
- import_v32.z.object({
8246
- elementId: import_v32.z.string().describe(
8314
+ const observeSchema = import_zod2.z.object({
8315
+ elements: import_zod2.z.array(
8316
+ import_zod2.z.object({
8317
+ elementId: import_zod2.z.string().describe(
8247
8318
  "the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
8248
8319
  ),
8249
- description: import_v32.z.string().describe(
8320
+ description: import_zod2.z.string().describe(
8250
8321
  "a description of the accessible element and its purpose"
8251
8322
  ),
8252
- method: import_v32.z.string().describe(
8323
+ method: import_zod2.z.string().describe(
8253
8324
  "the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
8254
8325
  ),
8255
- arguments: import_v32.z.array(
8256
- import_v32.z.string().describe(
8326
+ arguments: import_zod2.z.array(
8327
+ import_zod2.z.string().describe(
8257
8328
  "the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in."
8258
8329
  )
8259
8330
  )
@@ -8347,20 +8418,20 @@ function act(_0) {
8347
8418
  }) {
8348
8419
  var _a, _b;
8349
8420
  const isGPT5 = llmClient.modelName.includes("gpt-5");
8350
- const actSchema = import_v32.z.object({
8351
- elementId: import_v32.z.string().describe(
8421
+ const actSchema = import_zod2.z.object({
8422
+ elementId: import_zod2.z.string().describe(
8352
8423
  "the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
8353
8424
  ),
8354
- description: import_v32.z.string().describe("a description of the accessible element and its purpose"),
8355
- method: import_v32.z.string().describe(
8425
+ description: import_zod2.z.string().describe("a description of the accessible element and its purpose"),
8426
+ method: import_zod2.z.string().describe(
8356
8427
  "the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
8357
8428
  ),
8358
- arguments: import_v32.z.array(
8359
- import_v32.z.string().describe(
8429
+ arguments: import_zod2.z.array(
8430
+ import_zod2.z.string().describe(
8360
8431
  "the arguments to pass to the method. For example, for a click, the arguments are empty, but for a fill, the arguments are the value to fill in."
8361
8432
  )
8362
8433
  ),
8363
- twoStep: import_v32.z.boolean()
8434
+ twoStep: import_zod2.z.boolean()
8364
8435
  });
8365
8436
  const messages = [
8366
8437
  buildActSystemPrompt(userProvidedInstructions),
@@ -8441,12 +8512,12 @@ function act(_0) {
8441
8512
  init_logger();
8442
8513
 
8443
8514
  // lib/v3/types/public/methods.ts
8444
- var import_v33 = require("zod/v3");
8445
- var defaultExtractSchema = import_v33.z.object({
8446
- extraction: import_v33.z.string()
8515
+ var import_zod3 = require("zod");
8516
+ var defaultExtractSchema = import_zod3.z.object({
8517
+ extraction: import_zod3.z.string()
8447
8518
  });
8448
- var pageTextSchema = import_v33.z.object({
8449
- pageText: import_v33.z.string()
8519
+ var pageTextSchema = import_zod3.z.object({
8520
+ pageText: import_zod3.z.string()
8450
8521
  });
8451
8522
  var V3FunctionName = /* @__PURE__ */ ((V3FunctionName2) => {
8452
8523
  V3FunctionName2["ACT"] = "ACT";
@@ -9429,7 +9500,7 @@ var ActHandler = class {
9429
9500
  // lib/v3/handlers/extractHandler.ts
9430
9501
  init_logger();
9431
9502
  init_snapshot();
9432
- var import_v34 = require("zod/v3");
9503
+ var import_zod4 = require("zod");
9433
9504
  function transformUrlStringsToNumericIds(schema) {
9434
9505
  const [finalSchema, urlPaths] = transformSchema(schema, []);
9435
9506
  return [finalSchema, urlPaths];
@@ -9483,7 +9554,7 @@ var ExtractHandler = class {
9483
9554
  const baseSchema = schema != null ? schema : defaultExtractSchema;
9484
9555
  const isObjectSchema = !!((_c = baseSchema._def) == null ? void 0 : _c.shape);
9485
9556
  const WRAP_KEY = "value";
9486
- const objectSchema = isObjectSchema ? baseSchema : import_v34.z.object({ [WRAP_KEY]: baseSchema });
9557
+ const objectSchema = isObjectSchema ? baseSchema : import_zod4.z.object({ [WRAP_KEY]: baseSchema });
9487
9558
  const [transformedSchema, urlFieldPaths] = transformUrlStringsToNumericIds(objectSchema);
9488
9559
  const extractionResponse = yield extract({
9489
9560
  instruction,
@@ -9670,11 +9741,11 @@ var ObserveHandler = class {
9670
9741
 
9671
9742
  // lib/v3/agent/tools/v3-goto.ts
9672
9743
  var import_ai = require("ai");
9673
- var import_v35 = require("zod/v3");
9744
+ var import_zod5 = require("zod");
9674
9745
  var createGotoTool = (v3) => (0, import_ai.tool)({
9675
9746
  description: "Navigate to a specific URL",
9676
- inputSchema: import_v35.z.object({
9677
- url: import_v35.z.string().describe("The URL to navigate to")
9747
+ inputSchema: import_zod5.z.object({
9748
+ url: import_zod5.z.string().describe("The URL to navigate to")
9678
9749
  }),
9679
9750
  execute: (_0) => __async(null, [_0], function* ({ url }) {
9680
9751
  var _a;
@@ -9702,11 +9773,11 @@ var createGotoTool = (v3) => (0, import_ai.tool)({
9702
9773
 
9703
9774
  // lib/v3/agent/tools/v3-act.ts
9704
9775
  var import_ai2 = require("ai");
9705
- var import_v36 = require("zod/v3");
9776
+ var import_zod6 = require("zod");
9706
9777
  var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
9707
9778
  description: "Perform an action on the page (click, type). Provide a short, specific phrase that mentions the element type.",
9708
- inputSchema: import_v36.z.object({
9709
- action: import_v36.z.string().describe(
9779
+ inputSchema: import_zod6.z.object({
9780
+ action: import_zod6.z.string().describe(
9710
9781
  'Describe what to click or type, e.g. "click the Login button" or "type "John" into the first name input"'
9711
9782
  )
9712
9783
  }),
@@ -9747,10 +9818,10 @@ var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
9747
9818
 
9748
9819
  // lib/v3/agent/tools/v3-screenshot.ts
9749
9820
  var import_ai3 = require("ai");
9750
- var import_v37 = require("zod/v3");
9821
+ var import_zod7 = require("zod");
9751
9822
  var createScreenshotTool = (v3) => (0, import_ai3.tool)({
9752
9823
  description: "Takes a screenshot (PNG) of the current page. Use this to quickly verify page state.",
9753
- inputSchema: import_v37.z.object({}),
9824
+ inputSchema: import_zod7.z.object({}),
9754
9825
  execute: () => __async(null, null, function* () {
9755
9826
  v3.logger({
9756
9827
  category: "agent",
@@ -9774,11 +9845,11 @@ var createScreenshotTool = (v3) => (0, import_ai3.tool)({
9774
9845
 
9775
9846
  // lib/v3/agent/tools/v3-wait.ts
9776
9847
  var import_ai4 = require("ai");
9777
- var import_v38 = require("zod/v3");
9848
+ var import_zod8 = require("zod");
9778
9849
  var createWaitTool = (v3) => (0, import_ai4.tool)({
9779
9850
  description: "Wait for a specified time",
9780
- inputSchema: import_v38.z.object({
9781
- timeMs: import_v38.z.number().describe("Time in milliseconds")
9851
+ inputSchema: import_zod8.z.object({
9852
+ timeMs: import_zod8.z.number().describe("Time in milliseconds")
9782
9853
  }),
9783
9854
  execute: (_0) => __async(null, [_0], function* ({ timeMs }) {
9784
9855
  v3.logger({
@@ -9802,11 +9873,11 @@ var createWaitTool = (v3) => (0, import_ai4.tool)({
9802
9873
 
9803
9874
  // lib/v3/agent/tools/v3-navback.ts
9804
9875
  var import_ai5 = require("ai");
9805
- var import_v39 = require("zod/v3");
9876
+ var import_zod9 = require("zod");
9806
9877
  var createNavBackTool = (v3) => (0, import_ai5.tool)({
9807
9878
  description: "Navigate back to the previous page",
9808
- inputSchema: import_v39.z.object({
9809
- reasoningText: import_v39.z.string().describe("Why you're going back")
9879
+ inputSchema: import_zod9.z.object({
9880
+ reasoningText: import_zod9.z.string().describe("Why you're going back")
9810
9881
  }),
9811
9882
  execute: () => __async(null, null, function* () {
9812
9883
  v3.logger({
@@ -9826,12 +9897,12 @@ var createNavBackTool = (v3) => (0, import_ai5.tool)({
9826
9897
 
9827
9898
  // lib/v3/agent/tools/v3-close.ts
9828
9899
  var import_ai6 = require("ai");
9829
- var import_v310 = require("zod/v3");
9900
+ var import_zod10 = require("zod");
9830
9901
  var createCloseTool = () => (0, import_ai6.tool)({
9831
9902
  description: "Complete the task and close",
9832
- inputSchema: import_v310.z.object({
9833
- reasoning: import_v310.z.string().describe("Summary of what was accomplished"),
9834
- taskComplete: import_v310.z.boolean().describe("Whether the task was completed successfully")
9903
+ inputSchema: import_zod10.z.object({
9904
+ reasoning: import_zod10.z.string().describe("Summary of what was accomplished"),
9905
+ taskComplete: import_zod10.z.boolean().describe("Whether the task was completed successfully")
9835
9906
  }),
9836
9907
  execute: (_0) => __async(null, [_0], function* ({ reasoning, taskComplete }) {
9837
9908
  return { success: true, reasoning, taskComplete };
@@ -9840,10 +9911,10 @@ var createCloseTool = () => (0, import_ai6.tool)({
9840
9911
 
9841
9912
  // lib/v3/agent/tools/v3-ariaTree.ts
9842
9913
  var import_ai7 = require("ai");
9843
- var import_v311 = require("zod/v3");
9914
+ var import_zod11 = require("zod");
9844
9915
  var createAriaTreeTool = (v3) => (0, import_ai7.tool)({
9845
9916
  description: "gets the accessibility (ARIA) hybrid tree text for the current page. use this to understand structure and content.",
9846
- inputSchema: import_v311.z.object({}),
9917
+ inputSchema: import_zod11.z.object({}),
9847
9918
  execute: () => __async(null, null, function* () {
9848
9919
  v3.logger({
9849
9920
  category: "agent",
@@ -9871,17 +9942,17 @@ ${result.content}` }]
9871
9942
 
9872
9943
  // lib/v3/agent/tools/v3-fillform.ts
9873
9944
  var import_ai8 = require("ai");
9874
- var import_v312 = require("zod/v3");
9945
+ var import_zod12 = require("zod");
9875
9946
  var createFillFormTool = (v3, executionModel) => (0, import_ai8.tool)({
9876
9947
  description: `\u{1F4DD} FORM FILL - MULTI-FIELD INPUT TOOL
9877
9948
  For any form with 2+ inputs/textareas. Faster than individual typing.`,
9878
- inputSchema: import_v312.z.object({
9879
- fields: import_v312.z.array(
9880
- import_v312.z.object({
9881
- action: import_v312.z.string().describe(
9949
+ inputSchema: import_zod12.z.object({
9950
+ fields: import_zod12.z.array(
9951
+ import_zod12.z.object({
9952
+ action: import_zod12.z.string().describe(
9882
9953
  'Description of typing action, e.g. "type foo into the email field"'
9883
9954
  ),
9884
- value: import_v312.z.string().describe("Text to type into the target")
9955
+ value: import_zod12.z.string().describe("Text to type into the target")
9885
9956
  })
9886
9957
  ).min(1, "Provide at least one field to fill")
9887
9958
  }),
@@ -9925,12 +9996,12 @@ For any form with 2+ inputs/textareas. Faster than individual typing.`,
9925
9996
 
9926
9997
  // lib/v3/agent/tools/v3-scroll.ts
9927
9998
  var import_ai9 = require("ai");
9928
- var import_v313 = require("zod/v3");
9999
+ var import_zod13 = require("zod");
9929
10000
  var createScrollTool = (v3) => (0, import_ai9.tool)({
9930
10001
  description: "Scroll the page",
9931
- inputSchema: import_v313.z.object({
9932
- pixels: import_v313.z.number().describe("Number of pixels to scroll up or down"),
9933
- direction: import_v313.z.enum(["up", "down"]).describe("Direction to scroll")
10002
+ inputSchema: import_zod13.z.object({
10003
+ pixels: import_zod13.z.number().describe("Number of pixels to scroll up or down"),
10004
+ direction: import_zod13.z.enum(["up", "down"]).describe("Direction to scroll")
9934
10005
  }),
9935
10006
  execute: (_0) => __async(null, [_0], function* ({ pixels, direction }) {
9936
10007
  v3.logger({
@@ -9962,12 +10033,12 @@ var createScrollTool = (v3) => (0, import_ai9.tool)({
9962
10033
 
9963
10034
  // lib/v3/agent/tools/v3-extract.ts
9964
10035
  var import_ai10 = require("ai");
9965
- var import_v314 = require("zod/v3");
10036
+ var import_zod14 = require("zod");
9966
10037
  function evaluateZodSchema(schemaStr, logger) {
9967
10038
  var _a;
9968
10039
  try {
9969
10040
  const fn = new Function("z", `return ${schemaStr}`);
9970
- return fn(import_v314.z);
10041
+ return fn(import_zod14.z);
9971
10042
  } catch (e) {
9972
10043
  logger == null ? void 0 : logger({
9973
10044
  category: "agent",
@@ -9981,10 +10052,10 @@ function evaluateZodSchema(schemaStr, logger) {
9981
10052
  }
9982
10053
  var createExtractTool = (v3, executionModel, logger) => (0, import_ai10.tool)({
9983
10054
  description: "Extract structured data. Optionally provide an instruction and Zod schema.",
9984
- inputSchema: import_v314.z.object({
9985
- instruction: import_v314.z.string().optional(),
9986
- schema: import_v314.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })"),
9987
- selector: import_v314.z.string().optional()
10055
+ inputSchema: import_zod14.z.object({
10056
+ instruction: import_zod14.z.string().optional(),
10057
+ schema: import_zod14.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })"),
10058
+ selector: import_zod14.z.string().optional()
9988
10059
  }),
9989
10060
  execute: (_0) => __async(null, [_0], function* ({ instruction, schema, selector }) {
9990
10061
  var _a;
@@ -10386,7 +10457,7 @@ init_snapshot();
10386
10457
 
10387
10458
  // lib/v3/agent/AnthropicCUAClient.ts
10388
10459
  var import_sdk = __toESM(require("@anthropic-ai/sdk"));
10389
- var import_zod_to_json_schema = require("zod-to-json-schema");
10460
+ var import_zod15 = require("zod");
10390
10461
 
10391
10462
  // lib/v3/agent/AgentClient.ts
10392
10463
  var AgentClient = class {
@@ -10889,7 +10960,7 @@ var AnthropicCUAClient = class extends AgentClient {
10889
10960
  };
10890
10961
  if (this.tools && Object.keys(this.tools).length > 0) {
10891
10962
  const customTools = Object.entries(this.tools).map(([name, tool12]) => {
10892
- const jsonSchema2 = (0, import_zod_to_json_schema.zodToJsonSchema)(tool12.inputSchema);
10963
+ const jsonSchema2 = import_zod15.z.toJSONSchema(tool12.inputSchema);
10893
10964
  const inputSchema = {
10894
10965
  type: "object",
10895
10966
  properties: jsonSchema2.properties || {},
@@ -11753,7 +11824,7 @@ var import_genai3 = require("@google/genai");
11753
11824
 
11754
11825
  // lib/v3/agent/utils/googleCustomToolHandler.ts
11755
11826
  var import_genai2 = require("@google/genai");
11756
- var import_zod_to_json_schema2 = require("zod-to-json-schema");
11827
+ var import_zod16 = require("zod");
11757
11828
  function executeGoogleCustomTool(toolName, toolArgs, tools, functionCall, logger) {
11758
11829
  return __async(this, null, function* () {
11759
11830
  try {
@@ -11821,7 +11892,7 @@ function convertToolSetToFunctionDeclarations(tools) {
11821
11892
  }
11822
11893
  function convertToolToFunctionDeclaration(name, tool12) {
11823
11894
  try {
11824
- const jsonSchema2 = (0, import_zod_to_json_schema2.zodToJsonSchema)(tool12.inputSchema);
11895
+ const jsonSchema2 = import_zod16.z.toJSONSchema(tool12.inputSchema);
11825
11896
  const parameters = convertJsonSchemaToGoogleParameters(jsonSchema2);
11826
11897
  return {
11827
11898
  name,
@@ -14478,7 +14549,7 @@ var AISdkClient = class extends LLMClient {
14478
14549
 
14479
14550
  // lib/v3/llm/AnthropicClient.ts
14480
14551
  var import_sdk3 = __toESM(require("@anthropic-ai/sdk"));
14481
- var import_zod_to_json_schema3 = require("zod-to-json-schema");
14552
+ var import_zod17 = require("zod");
14482
14553
  var AnthropicClient = class extends LLMClient {
14483
14554
  constructor({
14484
14555
  modelName,
@@ -14588,7 +14659,7 @@ var AnthropicClient = class extends LLMClient {
14588
14659
  });
14589
14660
  let toolDefinition;
14590
14661
  if (options.response_model) {
14591
- const jsonSchema2 = (0, import_zod_to_json_schema3.zodToJsonSchema)(options.response_model.schema);
14662
+ const jsonSchema2 = import_zod17.z.toJSONSchema(options.response_model.schema);
14592
14663
  const { properties: schemaProperties, required: schemaRequired } = extractSchemaProperties(jsonSchema2);
14593
14664
  toolDefinition = {
14594
14665
  name: "print_extracted_data",
@@ -14720,7 +14791,7 @@ var extractSchemaProperties = (jsonSchema2) => {
14720
14791
 
14721
14792
  // lib/v3/llm/CerebrasClient.ts
14722
14793
  var import_openai2 = __toESM(require("openai"));
14723
- var import_zod_to_json_schema4 = require("zod-to-json-schema");
14794
+ var import_zod18 = require("zod");
14724
14795
  var CerebrasClient = class extends LLMClient {
14725
14796
  constructor({
14726
14797
  modelName,
@@ -14782,7 +14853,7 @@ var CerebrasClient = class extends LLMClient {
14782
14853
  }
14783
14854
  }));
14784
14855
  if (options.response_model) {
14785
- const jsonSchema2 = (0, import_zod_to_json_schema4.zodToJsonSchema)(options.response_model.schema);
14856
+ const jsonSchema2 = import_zod18.z.toJSONSchema(options.response_model.schema);
14786
14857
  const schemaProperties = jsonSchema2.properties || {};
14787
14858
  const schemaRequired = jsonSchema2.required || [];
14788
14859
  const responseTool = {
@@ -15307,7 +15378,7 @@ ${firstPartText.text}`;
15307
15378
 
15308
15379
  // lib/v3/llm/GroqClient.ts
15309
15380
  var import_openai3 = __toESM(require("openai"));
15310
- var import_zod_to_json_schema5 = require("zod-to-json-schema");
15381
+ var import_zod19 = require("zod");
15311
15382
  var GroqClient = class extends LLMClient {
15312
15383
  constructor({
15313
15384
  modelName,
@@ -15369,7 +15440,7 @@ var GroqClient = class extends LLMClient {
15369
15440
  }
15370
15441
  }));
15371
15442
  if (options.response_model) {
15372
- const jsonSchema2 = (0, import_zod_to_json_schema5.zodToJsonSchema)(options.response_model.schema);
15443
+ const jsonSchema2 = import_zod19.z.toJSONSchema(options.response_model.schema);
15373
15444
  const schemaProperties = jsonSchema2.properties || {};
15374
15445
  const schemaRequired = jsonSchema2.required || [];
15375
15446
  const responseTool = {
@@ -15527,8 +15598,8 @@ var GroqClient = class extends LLMClient {
15527
15598
 
15528
15599
  // lib/v3/llm/OpenAIClient.ts
15529
15600
  var import_openai4 = __toESM(require("openai"));
15530
- var import_zod = require("openai/helpers/zod");
15531
- var import_zod_to_json_schema6 = __toESM(require("zod-to-json-schema"));
15601
+ var import_zod20 = require("openai/helpers/zod");
15602
+ var import_zod21 = require("zod");
15532
15603
  var OpenAIClient = class extends LLMClient {
15533
15604
  constructor({
15534
15605
  modelName,
@@ -15639,7 +15710,7 @@ ${JSON.stringify(
15639
15710
  if (this.modelName.startsWith("o1") || this.modelName.startsWith("o3")) {
15640
15711
  try {
15641
15712
  const parsedSchema = JSON.stringify(
15642
- (0, import_zod_to_json_schema6.default)(options.response_model.schema)
15713
+ import_zod21.z.toJSONSchema(options.response_model.schema)
15643
15714
  );
15644
15715
  options.messages.push({
15645
15716
  role: "user",
@@ -15665,7 +15736,7 @@ ${parsedSchema}
15665
15736
  throw error;
15666
15737
  }
15667
15738
  } else {
15668
- responseFormat = (0, import_zod.zodResponseFormat)(
15739
+ responseFormat = (0, import_zod20.zodResponseFormat)(
15669
15740
  options.response_model.schema,
15670
15741
  options.response_model.name
15671
15742
  );
@@ -15849,7 +15920,7 @@ ${parsedSchema}
15849
15920
  }
15850
15921
  };
15851
15922
 
15852
- // ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@3.25.67/node_modules/@ai-sdk/provider-utils/dist/index.mjs
15923
+ // ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.12/node_modules/@ai-sdk/provider-utils/dist/index.mjs
15853
15924
  var import_provider = require("@ai-sdk/provider");
15854
15925
  var import_provider2 = require("@ai-sdk/provider");
15855
15926
  var import_provider3 = require("@ai-sdk/provider");
@@ -15986,14 +16057,14 @@ var EventSourceParserStream = class extends TransformStream {
15986
16057
  }
15987
16058
  };
15988
16059
 
15989
- // ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@3.25.67/node_modules/@ai-sdk/provider-utils/dist/index.mjs
16060
+ // ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.12/node_modules/@ai-sdk/provider-utils/dist/index.mjs
15990
16061
  var import_provider9 = require("@ai-sdk/provider");
15991
16062
  var import_provider10 = require("@ai-sdk/provider");
15992
16063
  var import_provider11 = require("@ai-sdk/provider");
15993
16064
  var z42 = __toESM(require("zod/v4"), 1);
15994
- var import_v315 = require("zod/v3");
15995
- var import_v316 = require("zod/v3");
15996
- var import_v317 = require("zod/v3");
16065
+ var import_v3 = require("zod/v3");
16066
+ var import_v32 = require("zod/v3");
16067
+ var import_v33 = require("zod/v3");
15997
16068
  function combineHeaders(...headers) {
15998
16069
  return headers.reduce(
15999
16070
  (combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
@@ -16810,7 +16881,7 @@ function parseArrayDef(def, refs) {
16810
16881
  const res = {
16811
16882
  type: "array"
16812
16883
  };
16813
- if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== import_v316.ZodFirstPartyTypeKind.ZodAny) {
16884
+ if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== import_v32.ZodFirstPartyTypeKind.ZodAny) {
16814
16885
  res.items = parseDef(def.type._def, __spreadProps(__spreadValues({}, refs), {
16815
16886
  currentPath: [...refs.currentPath, "items"]
16816
16887
  }));
@@ -17299,18 +17370,18 @@ function parseRecordDef(def, refs) {
17299
17370
  currentPath: [...refs.currentPath, "additionalProperties"]
17300
17371
  }))) != null ? _a : refs.allowedAdditionalProperties
17301
17372
  };
17302
- if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === import_v317.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
17373
+ if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === import_v33.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
17303
17374
  const _a2 = parseStringDef(def.keyType._def, refs), { type } = _a2, keyType = __objRest(_a2, ["type"]);
17304
17375
  return __spreadProps(__spreadValues({}, schema), {
17305
17376
  propertyNames: keyType
17306
17377
  });
17307
- } else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === import_v317.ZodFirstPartyTypeKind.ZodEnum) {
17378
+ } else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === import_v33.ZodFirstPartyTypeKind.ZodEnum) {
17308
17379
  return __spreadProps(__spreadValues({}, schema), {
17309
17380
  propertyNames: {
17310
17381
  enum: def.keyType._def.values
17311
17382
  }
17312
17383
  });
17313
- } else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === import_v317.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_v317.ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
17384
+ } else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === import_v33.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_v33.ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
17314
17385
  const _b2 = parseBrandedDef(
17315
17386
  def.keyType._def,
17316
17387
  refs
@@ -17636,73 +17707,73 @@ var parseReadonlyDef = (def, refs) => {
17636
17707
  };
17637
17708
  var selectParser = (def, typeName, refs) => {
17638
17709
  switch (typeName) {
17639
- case import_v315.ZodFirstPartyTypeKind.ZodString:
17710
+ case import_v3.ZodFirstPartyTypeKind.ZodString:
17640
17711
  return parseStringDef(def, refs);
17641
- case import_v315.ZodFirstPartyTypeKind.ZodNumber:
17712
+ case import_v3.ZodFirstPartyTypeKind.ZodNumber:
17642
17713
  return parseNumberDef(def);
17643
- case import_v315.ZodFirstPartyTypeKind.ZodObject:
17714
+ case import_v3.ZodFirstPartyTypeKind.ZodObject:
17644
17715
  return parseObjectDef(def, refs);
17645
- case import_v315.ZodFirstPartyTypeKind.ZodBigInt:
17716
+ case import_v3.ZodFirstPartyTypeKind.ZodBigInt:
17646
17717
  return parseBigintDef(def);
17647
- case import_v315.ZodFirstPartyTypeKind.ZodBoolean:
17718
+ case import_v3.ZodFirstPartyTypeKind.ZodBoolean:
17648
17719
  return parseBooleanDef();
17649
- case import_v315.ZodFirstPartyTypeKind.ZodDate:
17720
+ case import_v3.ZodFirstPartyTypeKind.ZodDate:
17650
17721
  return parseDateDef(def, refs);
17651
- case import_v315.ZodFirstPartyTypeKind.ZodUndefined:
17722
+ case import_v3.ZodFirstPartyTypeKind.ZodUndefined:
17652
17723
  return parseUndefinedDef();
17653
- case import_v315.ZodFirstPartyTypeKind.ZodNull:
17724
+ case import_v3.ZodFirstPartyTypeKind.ZodNull:
17654
17725
  return parseNullDef();
17655
- case import_v315.ZodFirstPartyTypeKind.ZodArray:
17726
+ case import_v3.ZodFirstPartyTypeKind.ZodArray:
17656
17727
  return parseArrayDef(def, refs);
17657
- case import_v315.ZodFirstPartyTypeKind.ZodUnion:
17658
- case import_v315.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
17728
+ case import_v3.ZodFirstPartyTypeKind.ZodUnion:
17729
+ case import_v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
17659
17730
  return parseUnionDef(def, refs);
17660
- case import_v315.ZodFirstPartyTypeKind.ZodIntersection:
17731
+ case import_v3.ZodFirstPartyTypeKind.ZodIntersection:
17661
17732
  return parseIntersectionDef(def, refs);
17662
- case import_v315.ZodFirstPartyTypeKind.ZodTuple:
17733
+ case import_v3.ZodFirstPartyTypeKind.ZodTuple:
17663
17734
  return parseTupleDef(def, refs);
17664
- case import_v315.ZodFirstPartyTypeKind.ZodRecord:
17735
+ case import_v3.ZodFirstPartyTypeKind.ZodRecord:
17665
17736
  return parseRecordDef(def, refs);
17666
- case import_v315.ZodFirstPartyTypeKind.ZodLiteral:
17737
+ case import_v3.ZodFirstPartyTypeKind.ZodLiteral:
17667
17738
  return parseLiteralDef(def);
17668
- case import_v315.ZodFirstPartyTypeKind.ZodEnum:
17739
+ case import_v3.ZodFirstPartyTypeKind.ZodEnum:
17669
17740
  return parseEnumDef(def);
17670
- case import_v315.ZodFirstPartyTypeKind.ZodNativeEnum:
17741
+ case import_v3.ZodFirstPartyTypeKind.ZodNativeEnum:
17671
17742
  return parseNativeEnumDef(def);
17672
- case import_v315.ZodFirstPartyTypeKind.ZodNullable:
17743
+ case import_v3.ZodFirstPartyTypeKind.ZodNullable:
17673
17744
  return parseNullableDef(def, refs);
17674
- case import_v315.ZodFirstPartyTypeKind.ZodOptional:
17745
+ case import_v3.ZodFirstPartyTypeKind.ZodOptional:
17675
17746
  return parseOptionalDef(def, refs);
17676
- case import_v315.ZodFirstPartyTypeKind.ZodMap:
17747
+ case import_v3.ZodFirstPartyTypeKind.ZodMap:
17677
17748
  return parseMapDef(def, refs);
17678
- case import_v315.ZodFirstPartyTypeKind.ZodSet:
17749
+ case import_v3.ZodFirstPartyTypeKind.ZodSet:
17679
17750
  return parseSetDef(def, refs);
17680
- case import_v315.ZodFirstPartyTypeKind.ZodLazy:
17751
+ case import_v3.ZodFirstPartyTypeKind.ZodLazy:
17681
17752
  return () => def.getter()._def;
17682
- case import_v315.ZodFirstPartyTypeKind.ZodPromise:
17753
+ case import_v3.ZodFirstPartyTypeKind.ZodPromise:
17683
17754
  return parsePromiseDef(def, refs);
17684
- case import_v315.ZodFirstPartyTypeKind.ZodNaN:
17685
- case import_v315.ZodFirstPartyTypeKind.ZodNever:
17755
+ case import_v3.ZodFirstPartyTypeKind.ZodNaN:
17756
+ case import_v3.ZodFirstPartyTypeKind.ZodNever:
17686
17757
  return parseNeverDef();
17687
- case import_v315.ZodFirstPartyTypeKind.ZodEffects:
17758
+ case import_v3.ZodFirstPartyTypeKind.ZodEffects:
17688
17759
  return parseEffectsDef(def, refs);
17689
- case import_v315.ZodFirstPartyTypeKind.ZodAny:
17760
+ case import_v3.ZodFirstPartyTypeKind.ZodAny:
17690
17761
  return parseAnyDef();
17691
- case import_v315.ZodFirstPartyTypeKind.ZodUnknown:
17762
+ case import_v3.ZodFirstPartyTypeKind.ZodUnknown:
17692
17763
  return parseUnknownDef();
17693
- case import_v315.ZodFirstPartyTypeKind.ZodDefault:
17764
+ case import_v3.ZodFirstPartyTypeKind.ZodDefault:
17694
17765
  return parseDefaultDef(def, refs);
17695
- case import_v315.ZodFirstPartyTypeKind.ZodBranded:
17766
+ case import_v3.ZodFirstPartyTypeKind.ZodBranded:
17696
17767
  return parseBrandedDef(def, refs);
17697
- case import_v315.ZodFirstPartyTypeKind.ZodReadonly:
17768
+ case import_v3.ZodFirstPartyTypeKind.ZodReadonly:
17698
17769
  return parseReadonlyDef(def, refs);
17699
- case import_v315.ZodFirstPartyTypeKind.ZodCatch:
17770
+ case import_v3.ZodFirstPartyTypeKind.ZodCatch:
17700
17771
  return parseCatchDef(def, refs);
17701
- case import_v315.ZodFirstPartyTypeKind.ZodPipeline:
17772
+ case import_v3.ZodFirstPartyTypeKind.ZodPipeline:
17702
17773
  return parsePipelineDef(def, refs);
17703
- case import_v315.ZodFirstPartyTypeKind.ZodFunction:
17704
- case import_v315.ZodFirstPartyTypeKind.ZodVoid:
17705
- case import_v315.ZodFirstPartyTypeKind.ZodSymbol:
17774
+ case import_v3.ZodFirstPartyTypeKind.ZodFunction:
17775
+ case import_v3.ZodFirstPartyTypeKind.ZodVoid:
17776
+ case import_v3.ZodFirstPartyTypeKind.ZodSymbol:
17706
17777
  return void 0;
17707
17778
  default:
17708
17779
  return /* @__PURE__ */ ((_) => void 0)(typeName);
@@ -17789,7 +17860,7 @@ var getRefs = (options) => {
17789
17860
  )
17790
17861
  });
17791
17862
  };
17792
- var zodToJsonSchema7 = (schema, options) => {
17863
+ var zodToJsonSchema = (schema, options) => {
17793
17864
  var _a;
17794
17865
  const refs = getRefs(options);
17795
17866
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
@@ -17834,7 +17905,7 @@ var zodToJsonSchema7 = (schema, options) => {
17834
17905
  combined.$schema = "http://json-schema.org/draft-07/schema#";
17835
17906
  return combined;
17836
17907
  };
17837
- var zod_to_json_schema_default = zodToJsonSchema7;
17908
+ var zod_to_json_schema_default = zodToJsonSchema;
17838
17909
  function zod3Schema(zodSchema2, options) {
17839
17910
  var _a;
17840
17911
  const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
@@ -17926,7 +17997,7 @@ function withoutTrailingSlash(url) {
17926
17997
  return url == null ? void 0 : url.replace(/\/$/, "");
17927
17998
  }
17928
17999
 
17929
- // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@3.25.67/node_modules/@ai-sdk/openai/dist/index.mjs
18000
+ // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.12/node_modules/@ai-sdk/openai/dist/index.mjs
17930
18001
  var import_provider12 = require("@ai-sdk/provider");
17931
18002
  var import_v4 = require("zod/v4");
17932
18003
  var import_provider13 = require("@ai-sdk/provider");
@@ -22316,7 +22387,7 @@ function createOpenAI(options = {}) {
22316
22387
  }
22317
22388
  var openai = createOpenAI();
22318
22389
 
22319
- // ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@3.25.67/node_modules/@ai-sdk/anthropic/dist/index.mjs
22390
+ // ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@4.1.12/node_modules/@ai-sdk/anthropic/dist/index.mjs
22320
22391
  var import_provider20 = require("@ai-sdk/provider");
22321
22392
  var import_provider21 = require("@ai-sdk/provider");
22322
22393
  var import_v421 = require("zod/v4");
@@ -25355,7 +25426,7 @@ function createAnthropic(options = {}) {
25355
25426
  }
25356
25427
  var anthropic = createAnthropic();
25357
25428
 
25358
- // ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@3.25.67/node_modules/@ai-sdk/google/dist/index.mjs
25429
+ // ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@4.1.12/node_modules/@ai-sdk/google/dist/index.mjs
25359
25430
  var import_provider24 = require("@ai-sdk/provider");
25360
25431
  var import_v437 = require("zod/v4");
25361
25432
  var import_v438 = require("zod/v4");
@@ -26907,7 +26978,7 @@ function createGoogleGenerativeAI(options = {}) {
26907
26978
  }
26908
26979
  var google = createGoogleGenerativeAI();
26909
26980
 
26910
- // ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@3.25.67/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
26981
+ // ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@4.1.12/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
26911
26982
  var import_provider27 = require("@ai-sdk/provider");
26912
26983
  var import_v446 = require("zod/v4");
26913
26984
  var import_provider28 = require("@ai-sdk/provider");
@@ -28227,7 +28298,7 @@ var openaiCompatibleImageResponseSchema = import_v453.z.object({
28227
28298
  data: import_v453.z.array(import_v453.z.object({ b64_json: import_v453.z.string() }))
28228
28299
  });
28229
28300
 
28230
- // ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@3.25.67/node_modules/@ai-sdk/xai/dist/index.mjs
28301
+ // ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@4.1.12/node_modules/@ai-sdk/xai/dist/index.mjs
28231
28302
  var import_provider32 = require("@ai-sdk/provider");
28232
28303
  var import_v454 = require("zod/v4");
28233
28304
  var import_provider33 = require("@ai-sdk/provider");
@@ -28979,7 +29050,7 @@ function createXai(options = {}) {
28979
29050
  }
28980
29051
  var xai = createXai();
28981
29052
 
28982
- // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@3.25.67/node_modules/@ai-sdk/openai/dist/internal/index.mjs
29053
+ // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.12/node_modules/@ai-sdk/openai/dist/internal/index.mjs
28983
29054
  var import_provider35 = require("@ai-sdk/provider");
28984
29055
  var import_v457 = require("zod/v4");
28985
29056
  var import_provider36 = require("@ai-sdk/provider");
@@ -33202,7 +33273,7 @@ function mapWebSearchOutput2(action) {
33202
33273
  }
33203
33274
  }
33204
33275
 
33205
- // ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@3.25.67/node_modules/@ai-sdk/azure/dist/index.mjs
33276
+ // ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@4.1.12/node_modules/@ai-sdk/azure/dist/index.mjs
33206
33277
  var azureOpenaiTools = {
33207
33278
  codeInterpreter: codeInterpreter2,
33208
33279
  fileSearch: fileSearch2,
@@ -33307,7 +33378,7 @@ function createAzure(options = {}) {
33307
33378
  }
33308
33379
  var azure = createAzure();
33309
33380
 
33310
- // ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@3.25.67/node_modules/@ai-sdk/groq/dist/index.mjs
33381
+ // ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@4.1.12/node_modules/@ai-sdk/groq/dist/index.mjs
33311
33382
  var import_provider43 = require("@ai-sdk/provider");
33312
33383
  var import_provider44 = require("@ai-sdk/provider");
33313
33384
  var import_v477 = require("zod/v4");
@@ -34189,7 +34260,7 @@ function createGroq(options = {}) {
34189
34260
  }
34190
34261
  var groq = createGroq();
34191
34262
 
34192
- // ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@3.25.67/node_modules/@ai-sdk/cerebras/dist/index.mjs
34263
+ // ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@4.1.12/node_modules/@ai-sdk/cerebras/dist/index.mjs
34193
34264
  var import_provider47 = require("@ai-sdk/provider");
34194
34265
  var import_v482 = require("zod/v4");
34195
34266
  var VERSION8 = true ? "1.0.25" : "0.0.0-test";
@@ -34241,7 +34312,7 @@ function createCerebras(options = {}) {
34241
34312
  }
34242
34313
  var cerebras = createCerebras();
34243
34314
 
34244
- // ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@3.25.67/node_modules/@ai-sdk/togetherai/dist/index.mjs
34315
+ // ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@4.1.12/node_modules/@ai-sdk/togetherai/dist/index.mjs
34245
34316
  var import_v483 = require("zod/v4");
34246
34317
  var TogetherAIImageModel = class {
34247
34318
  constructor(modelId, config) {
@@ -34372,7 +34443,7 @@ function createTogetherAI(options = {}) {
34372
34443
  }
34373
34444
  var togetherai = createTogetherAI();
34374
34445
 
34375
- // ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@3.25.67/node_modules/@ai-sdk/mistral/dist/index.mjs
34446
+ // ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@4.1.12/node_modules/@ai-sdk/mistral/dist/index.mjs
34376
34447
  var import_provider48 = require("@ai-sdk/provider");
34377
34448
  var import_v484 = require("zod/v4");
34378
34449
  var import_provider49 = require("@ai-sdk/provider");
@@ -35155,7 +35226,7 @@ function createMistral(options = {}) {
35155
35226
  }
35156
35227
  var mistral = createMistral();
35157
35228
 
35158
- // ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@3.25.67/node_modules/@ai-sdk/deepseek/dist/index.mjs
35229
+ // ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@4.1.12/node_modules/@ai-sdk/deepseek/dist/index.mjs
35159
35230
  var import_provider52 = require("@ai-sdk/provider");
35160
35231
  var import_v488 = require("zod/v4");
35161
35232
  var buildDeepseekMetadata = (usage) => {
@@ -35245,7 +35316,7 @@ function createDeepSeek(options = {}) {
35245
35316
  }
35246
35317
  var deepseek = createDeepSeek();
35247
35318
 
35248
- // ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@3.25.67/node_modules/@ai-sdk/perplexity/dist/index.mjs
35319
+ // ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@4.1.12/node_modules/@ai-sdk/perplexity/dist/index.mjs
35249
35320
  var import_provider53 = require("@ai-sdk/provider");
35250
35321
  var import_v489 = require("zod/v4");
35251
35322
  var import_provider54 = require("@ai-sdk/provider");
@@ -35675,7 +35746,7 @@ function createPerplexity(options = {}) {
35675
35746
  }
35676
35747
  var perplexity = createPerplexity();
35677
35748
 
35678
- // ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@3.25.67/node_modules/ollama-ai-provider-v2/dist/index.mjs
35749
+ // ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@4.1.12/node_modules/ollama-ai-provider-v2/dist/index.mjs
35679
35750
  var import_provider55 = require("@ai-sdk/provider");
35680
35751
  var import_v490 = require("zod/v4");
35681
35752
  var import_v491 = require("zod/v4");
@@ -38110,7 +38181,7 @@ function resolveModel(model) {
38110
38181
 
38111
38182
  // lib/v3/api.ts
38112
38183
  var import_fetch_cookie = __toESM(require("fetch-cookie"));
38113
- var import_zod_to_json_schema7 = __toESM(require("zod-to-json-schema"));
38184
+ var import_zod22 = require("zod");
38114
38185
  var StagehandAPIClient = class {
38115
38186
  constructor({ apiKey, projectId, logger }) {
38116
38187
  this.apiKey = apiKey;
@@ -38204,7 +38275,7 @@ var StagehandAPIClient = class {
38204
38275
  options,
38205
38276
  frameId
38206
38277
  }) {
38207
- const jsonSchema2 = zodSchema2 ? (0, import_zod_to_json_schema7.default)(zodSchema2) : void 0;
38278
+ const jsonSchema2 = zodSchema2 ? import_zod22.z.toJSONSchema(zodSchema2) : void 0;
38208
38279
  const args = {
38209
38280
  schema: jsonSchema2,
38210
38281
  instruction,
@@ -38438,7 +38509,7 @@ var _V3 = class _V3 {
38438
38509
  this.verbose = 1;
38439
38510
  this._history = [];
38440
38511
  this.apiClient = null;
38441
- this.v3Metrics = {
38512
+ this.stagehandMetrics = {
38442
38513
  actPromptTokens: 0,
38443
38514
  actCompletionTokens: 0,
38444
38515
  actInferenceTimeMs: 0,
@@ -38546,7 +38617,7 @@ var _V3 = class _V3 {
38546
38617
  * Returning a Promise future-proofs async aggregation/storage.
38547
38618
  */
38548
38619
  get metrics() {
38549
- return Promise.resolve(this.v3Metrics);
38620
+ return Promise.resolve(this.stagehandMetrics);
38550
38621
  }
38551
38622
  resolveLlmClient(model) {
38552
38623
  if (!model) {
@@ -38625,32 +38696,32 @@ var _V3 = class _V3 {
38625
38696
  updateMetrics(functionName, promptTokens, completionTokens, inferenceTimeMs) {
38626
38697
  switch (functionName) {
38627
38698
  case "ACT" /* ACT */:
38628
- this.v3Metrics.actPromptTokens += promptTokens;
38629
- this.v3Metrics.actCompletionTokens += completionTokens;
38630
- this.v3Metrics.actInferenceTimeMs += inferenceTimeMs;
38699
+ this.stagehandMetrics.actPromptTokens += promptTokens;
38700
+ this.stagehandMetrics.actCompletionTokens += completionTokens;
38701
+ this.stagehandMetrics.actInferenceTimeMs += inferenceTimeMs;
38631
38702
  break;
38632
38703
  case "EXTRACT" /* EXTRACT */:
38633
- this.v3Metrics.extractPromptTokens += promptTokens;
38634
- this.v3Metrics.extractCompletionTokens += completionTokens;
38635
- this.v3Metrics.extractInferenceTimeMs += inferenceTimeMs;
38704
+ this.stagehandMetrics.extractPromptTokens += promptTokens;
38705
+ this.stagehandMetrics.extractCompletionTokens += completionTokens;
38706
+ this.stagehandMetrics.extractInferenceTimeMs += inferenceTimeMs;
38636
38707
  break;
38637
38708
  case "OBSERVE" /* OBSERVE */:
38638
- this.v3Metrics.observePromptTokens += promptTokens;
38639
- this.v3Metrics.observeCompletionTokens += completionTokens;
38640
- this.v3Metrics.observeInferenceTimeMs += inferenceTimeMs;
38709
+ this.stagehandMetrics.observePromptTokens += promptTokens;
38710
+ this.stagehandMetrics.observeCompletionTokens += completionTokens;
38711
+ this.stagehandMetrics.observeInferenceTimeMs += inferenceTimeMs;
38641
38712
  break;
38642
38713
  case "AGENT" /* AGENT */:
38643
- this.v3Metrics.agentPromptTokens += promptTokens;
38644
- this.v3Metrics.agentCompletionTokens += completionTokens;
38645
- this.v3Metrics.agentInferenceTimeMs += inferenceTimeMs;
38714
+ this.stagehandMetrics.agentPromptTokens += promptTokens;
38715
+ this.stagehandMetrics.agentCompletionTokens += completionTokens;
38716
+ this.stagehandMetrics.agentInferenceTimeMs += inferenceTimeMs;
38646
38717
  break;
38647
38718
  }
38648
38719
  this.updateTotalMetrics(promptTokens, completionTokens, inferenceTimeMs);
38649
38720
  }
38650
38721
  updateTotalMetrics(promptTokens, completionTokens, inferenceTimeMs) {
38651
- this.v3Metrics.totalPromptTokens += promptTokens;
38652
- this.v3Metrics.totalCompletionTokens += completionTokens;
38653
- this.v3Metrics.totalInferenceTimeMs += inferenceTimeMs;
38722
+ this.stagehandMetrics.totalPromptTokens += promptTokens;
38723
+ this.stagehandMetrics.totalCompletionTokens += completionTokens;
38724
+ this.stagehandMetrics.totalInferenceTimeMs += inferenceTimeMs;
38654
38725
  }
38655
38726
  _immediateShutdown(reason) {
38656
38727
  return __async(this, null, function* () {
@@ -39590,13 +39661,13 @@ function isObserveResult(v) {
39590
39661
 
39591
39662
  // lib/v3Evaluator.ts
39592
39663
  var import_dotenv2 = __toESM(require("dotenv"));
39593
- var import_v318 = require("zod/v3");
39664
+ var import_zod23 = require("zod");
39594
39665
  import_dotenv2.default.config();
39595
- var EvaluationSchema = import_v318.z.object({
39596
- evaluation: import_v318.z.enum(["YES", "NO"]),
39597
- reasoning: import_v318.z.string()
39666
+ var EvaluationSchema = import_zod23.z.object({
39667
+ evaluation: import_zod23.z.enum(["YES", "NO"]),
39668
+ reasoning: import_zod23.z.string()
39598
39669
  });
39599
- var BatchEvaluationSchema = import_v318.z.array(EvaluationSchema);
39670
+ var BatchEvaluationSchema = import_zod23.z.array(EvaluationSchema);
39600
39671
  var V3Evaluator = class {
39601
39672
  constructor(v3, modelName, modelClientOptions) {
39602
39673
  this.silentLogger = () => {