@browserbasehq/orca 3.0.8-stable → 3.0.8-stable-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.
package/dist/index.d.ts CHANGED
@@ -4041,16 +4041,23 @@ declare const scrollVisionTool: (v3: V3, provider?: string) => ai.Tool<{
4041
4041
  percentage?: number;
4042
4042
  }, ScrollVisionToolResult>;
4043
4043
 
4044
- declare const extractTool: (v3: V3, executionModel?: string, logger?: (message: LogLine) => void) => ai.Tool<{
4044
+ declare const extractTool: (v3: V3, executionModel?: string) => ai.Tool<{
4045
4045
  instruction: string;
4046
- schema?: string;
4046
+ schema?: {
4047
+ [x: string]: unknown;
4048
+ type?: string;
4049
+ properties?: Record<string, unknown>;
4050
+ items?: unknown;
4051
+ enum?: string[];
4052
+ format?: "email" | "uuid" | "url";
4053
+ };
4047
4054
  }, {
4048
4055
  success: boolean;
4049
- result: any;
4056
+ result: unknown;
4050
4057
  error?: undefined;
4051
4058
  } | {
4052
4059
  success: boolean;
4053
- error: any;
4060
+ error: string;
4054
4061
  result?: undefined;
4055
4062
  }>;
4056
4063
 
package/dist/index.js CHANGED
@@ -200,7 +200,7 @@ var init_zodCompat = __esm({
200
200
  var STAGEHAND_VERSION;
201
201
  var init_version = __esm({
202
202
  "lib/version.ts"() {
203
- STAGEHAND_VERSION = "3.0.8-stable";
203
+ STAGEHAND_VERSION = "3.0.8-stable-1";
204
204
  }
205
205
  });
206
206
 
@@ -32909,51 +32909,82 @@ var scrollVisionTool = (v3, provider) => (0, import_ai8.tool)({
32909
32909
  // lib/v3/agent/tools/extract.ts
32910
32910
  var import_ai9 = require("ai");
32911
32911
  var import_zod13 = require("zod");
32912
- function evaluateZodSchema(schemaStr, logger) {
32913
- var _a4;
32914
- try {
32915
- const fn = new Function("z", `return ${schemaStr}`);
32916
- return fn(import_zod13.z);
32917
- } catch (e2) {
32918
- logger == null ? void 0 : logger({
32919
- category: "agent",
32920
- message: `Failed to evaluate schema: ${(_a4 = e2 == null ? void 0 : e2.message) != null ? _a4 : String(e2)}`,
32921
- level: 0
32922
- });
32923
- return import_zod13.z.any();
32912
+ function jsonSchemaToZod2(schema) {
32913
+ switch (schema.type) {
32914
+ case "object": {
32915
+ const shape = {};
32916
+ if (schema.properties) {
32917
+ for (const [key, value] of Object.entries(schema.properties)) {
32918
+ shape[key] = jsonSchemaToZod2(value);
32919
+ }
32920
+ }
32921
+ return import_zod13.z.object(shape);
32922
+ }
32923
+ case "array":
32924
+ return import_zod13.z.array(schema.items ? jsonSchemaToZod2(schema.items) : import_zod13.z.any());
32925
+ case "string": {
32926
+ let s2 = import_zod13.z.string();
32927
+ if (schema.format === "url") s2 = s2.url();
32928
+ if (schema.format === "email") s2 = s2.email();
32929
+ if (schema.format === "uuid") s2 = s2.uuid();
32930
+ if (schema.enum && schema.enum.length > 0)
32931
+ return import_zod13.z.enum(schema.enum);
32932
+ return s2;
32933
+ }
32934
+ case "number":
32935
+ case "integer":
32936
+ return import_zod13.z.number();
32937
+ case "boolean":
32938
+ return import_zod13.z.boolean();
32939
+ case "null":
32940
+ return import_zod13.z.null();
32941
+ default:
32942
+ return import_zod13.z.any();
32924
32943
  }
32925
32944
  }
32926
- var extractTool = (v3, executionModel, logger) => (0, import_ai9.tool)({
32945
+ var extractTool = (v3, executionModel) => (0, import_ai9.tool)({
32927
32946
  description: `Extract structured data from the current page based on a provided schema.
32928
32947
 
32929
32948
  USAGE GUIDELINES:
32930
32949
  - Keep schemas MINIMAL - only include fields essential for the task
32931
- - IMPORANT: only use this if explicitly asked for structured output. In most scenarios, you should use the aria tree tool over this.
32932
- - If you need to extract a link, make sure the type defintion follows the format of z.string().url()
32950
+ - IMPORTANT: only use this if explicitly asked for structured output. In most scenarios, you should use the aria tree tool over this.
32951
+ - For URL fields, use format: "url"
32952
+
32933
32953
  EXAMPLES:
32934
32954
  1. Extract a single value:
32935
32955
  instruction: "extract the product price"
32936
- schema: "z.object({ price: z.number()})"
32956
+ schema: { type: "object", properties: { price: { type: "number" } } }
32937
32957
 
32938
32958
  2. Extract multiple fields:
32939
32959
  instruction: "extract product name and price"
32940
- schema: "z.object({ name: z.string(), price: z.number() })"
32960
+ schema: { type: "object", properties: { name: { type: "string" }, price: { type: "number" } } }
32941
32961
 
32942
32962
  3. Extract arrays:
32943
32963
  instruction: "extract all product names and prices"
32944
- schema: "z.object({ products: z.array(z.object({ name: z.string(), price: z.number() })) })"`,
32964
+ schema: { type: "object", properties: { products: { type: "array", items: { type: "object", properties: { name: { type: "string" }, price: { type: "number" } } } } } }
32965
+
32966
+ 4. Extract a URL:
32967
+ instruction: "extract the link"
32968
+ schema: { type: "object", properties: { url: { type: "string", format: "url" } } }`,
32945
32969
  inputSchema: import_zod13.z.object({
32946
32970
  instruction: import_zod13.z.string(),
32947
- schema: import_zod13.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })")
32971
+ schema: import_zod13.z.object({
32972
+ type: import_zod13.z.string().optional(),
32973
+ properties: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional(),
32974
+ items: import_zod13.z.unknown().optional(),
32975
+ enum: import_zod13.z.array(import_zod13.z.string()).optional(),
32976
+ format: import_zod13.z.enum(["url", "email", "uuid"]).optional()
32977
+ }).passthrough().optional().describe("JSON Schema object describing the structure to extract")
32948
32978
  }),
32949
32979
  execute: (_0) => __async(null, [_0], function* ({ instruction, schema }) {
32950
32980
  var _a4;
32951
32981
  try {
32952
- const parsedSchema = schema ? evaluateZodSchema(schema, logger) : void 0;
32982
+ const parsedSchema = schema ? jsonSchemaToZod2(schema) : void 0;
32953
32983
  const result = yield v3.extract(instruction, parsedSchema, __spreadValues({}, executionModel ? { model: executionModel } : {}));
32954
32984
  return { success: true, result };
32955
32985
  } catch (error) {
32956
- return { success: false, error: (_a4 = error == null ? void 0 : error.message) != null ? _a4 : String(error) };
32986
+ const err = error;
32987
+ return { success: false, error: (_a4 = err == null ? void 0 : err.message) != null ? _a4 : String(error) };
32957
32988
  }
32958
32989
  })
32959
32990
  });
@@ -33700,7 +33731,7 @@ function createAgentTools(v3, options) {
33700
33731
  click: clickTool(v3, provider),
33701
33732
  clickAndHold: clickAndHoldTool(v3, provider),
33702
33733
  dragAndDrop: dragAndDropTool(v3, provider),
33703
- extract: extractTool(v3, executionModel, options == null ? void 0 : options.logger),
33734
+ extract: extractTool(v3, executionModel),
33704
33735
  fillForm: fillFormTool(v3, executionModel),
33705
33736
  fillFormVision: fillFormVisionTool(v3, provider),
33706
33737
  goto: gotoTool(v3),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserbasehq/orca",
3
- "version": "3.0.8-stable",
3
+ "version": "3.0.8-stable-1",
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",