@browserbasehq/orca 3.0.8-stable → 3.0.9-alpha-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
@@ -2877,6 +2877,7 @@ declare class Page {
2877
2877
  * Supports iframe hop notation with '>>' (e.g., 'iframe#checkout >> .submit-btn').
2878
2878
  *
2879
2879
  * @param selector CSS selector to wait for (supports '>>' for iframe hops)
2880
+ * @param options
2880
2881
  * @param options.state Element state to wait for: 'attached' | 'detached' | 'visible' | 'hidden' (default: 'visible')
2881
2882
  * @param options.timeout Maximum time to wait in milliseconds (default: 30000)
2882
2883
  * @param options.pierceShadow Whether to search inside shadow DOM (default: true)
@@ -4041,16 +4042,23 @@ declare const scrollVisionTool: (v3: V3, provider?: string) => ai.Tool<{
4041
4042
  percentage?: number;
4042
4043
  }, ScrollVisionToolResult>;
4043
4044
 
4044
- declare const extractTool: (v3: V3, executionModel?: string, logger?: (message: LogLine) => void) => ai.Tool<{
4045
+ declare const extractTool: (v3: V3, executionModel?: string) => ai.Tool<{
4045
4046
  instruction: string;
4046
- schema?: string;
4047
+ schema?: {
4048
+ [x: string]: unknown;
4049
+ type?: string;
4050
+ properties?: Record<string, unknown>;
4051
+ items?: unknown;
4052
+ enum?: string[];
4053
+ format?: "email" | "uuid" | "url";
4054
+ };
4047
4055
  }, {
4048
4056
  success: boolean;
4049
- result: any;
4057
+ result: unknown;
4050
4058
  error?: undefined;
4051
4059
  } | {
4052
4060
  success: boolean;
4053
- error: any;
4061
+ error: string;
4054
4062
  result?: undefined;
4055
4063
  }>;
4056
4064
 
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.9-alpha-1";
204
204
  }
205
205
  });
206
206
 
@@ -6792,6 +6792,538 @@ var require_interceptor = __commonJS({
6792
6792
  }
6793
6793
  });
6794
6794
 
6795
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
6796
+ var require_common3 = __commonJS({
6797
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports2, module2) {
6798
+ function setup(env) {
6799
+ createDebug.debug = createDebug;
6800
+ createDebug.default = createDebug;
6801
+ createDebug.coerce = coerce;
6802
+ createDebug.disable = disable;
6803
+ createDebug.enable = enable;
6804
+ createDebug.enabled = enabled;
6805
+ createDebug.humanize = require_ms();
6806
+ createDebug.destroy = destroy;
6807
+ Object.keys(env).forEach((key) => {
6808
+ createDebug[key] = env[key];
6809
+ });
6810
+ createDebug.names = [];
6811
+ createDebug.skips = [];
6812
+ createDebug.formatters = {};
6813
+ function selectColor(namespace) {
6814
+ let hash = 0;
6815
+ for (let i2 = 0; i2 < namespace.length; i2++) {
6816
+ hash = (hash << 5) - hash + namespace.charCodeAt(i2);
6817
+ hash |= 0;
6818
+ }
6819
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
6820
+ }
6821
+ createDebug.selectColor = selectColor;
6822
+ function createDebug(namespace) {
6823
+ let prevTime;
6824
+ let enableOverride = null;
6825
+ let namespacesCache;
6826
+ let enabledCache;
6827
+ function debug2(...args) {
6828
+ if (!debug2.enabled) {
6829
+ return;
6830
+ }
6831
+ const self2 = debug2;
6832
+ const curr = Number(/* @__PURE__ */ new Date());
6833
+ const ms = curr - (prevTime || curr);
6834
+ self2.diff = ms;
6835
+ self2.prev = prevTime;
6836
+ self2.curr = curr;
6837
+ prevTime = curr;
6838
+ args[0] = createDebug.coerce(args[0]);
6839
+ if (typeof args[0] !== "string") {
6840
+ args.unshift("%O");
6841
+ }
6842
+ let index = 0;
6843
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
6844
+ if (match === "%%") {
6845
+ return "%";
6846
+ }
6847
+ index++;
6848
+ const formatter = createDebug.formatters[format];
6849
+ if (typeof formatter === "function") {
6850
+ const val = args[index];
6851
+ match = formatter.call(self2, val);
6852
+ args.splice(index, 1);
6853
+ index--;
6854
+ }
6855
+ return match;
6856
+ });
6857
+ createDebug.formatArgs.call(self2, args);
6858
+ const logFn = self2.log || createDebug.log;
6859
+ logFn.apply(self2, args);
6860
+ }
6861
+ debug2.namespace = namespace;
6862
+ debug2.useColors = createDebug.useColors();
6863
+ debug2.color = createDebug.selectColor(namespace);
6864
+ debug2.extend = extend;
6865
+ debug2.destroy = createDebug.destroy;
6866
+ Object.defineProperty(debug2, "enabled", {
6867
+ enumerable: true,
6868
+ configurable: false,
6869
+ get: () => {
6870
+ if (enableOverride !== null) {
6871
+ return enableOverride;
6872
+ }
6873
+ if (namespacesCache !== createDebug.namespaces) {
6874
+ namespacesCache = createDebug.namespaces;
6875
+ enabledCache = createDebug.enabled(namespace);
6876
+ }
6877
+ return enabledCache;
6878
+ },
6879
+ set: (v) => {
6880
+ enableOverride = v;
6881
+ }
6882
+ });
6883
+ if (typeof createDebug.init === "function") {
6884
+ createDebug.init(debug2);
6885
+ }
6886
+ return debug2;
6887
+ }
6888
+ function extend(namespace, delimiter) {
6889
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
6890
+ newDebug.log = this.log;
6891
+ return newDebug;
6892
+ }
6893
+ function enable(namespaces) {
6894
+ createDebug.save(namespaces);
6895
+ createDebug.namespaces = namespaces;
6896
+ createDebug.names = [];
6897
+ createDebug.skips = [];
6898
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
6899
+ for (const ns of split) {
6900
+ if (ns[0] === "-") {
6901
+ createDebug.skips.push(ns.slice(1));
6902
+ } else {
6903
+ createDebug.names.push(ns);
6904
+ }
6905
+ }
6906
+ }
6907
+ function matchesTemplate(search, template) {
6908
+ let searchIndex = 0;
6909
+ let templateIndex = 0;
6910
+ let starIndex = -1;
6911
+ let matchIndex = 0;
6912
+ while (searchIndex < search.length) {
6913
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
6914
+ if (template[templateIndex] === "*") {
6915
+ starIndex = templateIndex;
6916
+ matchIndex = searchIndex;
6917
+ templateIndex++;
6918
+ } else {
6919
+ searchIndex++;
6920
+ templateIndex++;
6921
+ }
6922
+ } else if (starIndex !== -1) {
6923
+ templateIndex = starIndex + 1;
6924
+ matchIndex++;
6925
+ searchIndex = matchIndex;
6926
+ } else {
6927
+ return false;
6928
+ }
6929
+ }
6930
+ while (templateIndex < template.length && template[templateIndex] === "*") {
6931
+ templateIndex++;
6932
+ }
6933
+ return templateIndex === template.length;
6934
+ }
6935
+ function disable() {
6936
+ const namespaces = [
6937
+ ...createDebug.names,
6938
+ ...createDebug.skips.map((namespace) => "-" + namespace)
6939
+ ].join(",");
6940
+ createDebug.enable("");
6941
+ return namespaces;
6942
+ }
6943
+ function enabled(name) {
6944
+ for (const skip of createDebug.skips) {
6945
+ if (matchesTemplate(name, skip)) {
6946
+ return false;
6947
+ }
6948
+ }
6949
+ for (const ns of createDebug.names) {
6950
+ if (matchesTemplate(name, ns)) {
6951
+ return true;
6952
+ }
6953
+ }
6954
+ return false;
6955
+ }
6956
+ function coerce(val) {
6957
+ if (val instanceof Error) {
6958
+ return val.stack || val.message;
6959
+ }
6960
+ return val;
6961
+ }
6962
+ function destroy() {
6963
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
6964
+ }
6965
+ createDebug.enable(createDebug.load());
6966
+ return createDebug;
6967
+ }
6968
+ module2.exports = setup;
6969
+ }
6970
+ });
6971
+
6972
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
6973
+ var require_browser2 = __commonJS({
6974
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports2, module2) {
6975
+ exports2.formatArgs = formatArgs2;
6976
+ exports2.save = save;
6977
+ exports2.load = load;
6978
+ exports2.useColors = useColors;
6979
+ exports2.storage = localstorage();
6980
+ exports2.destroy = /* @__PURE__ */ (() => {
6981
+ let warned = false;
6982
+ return () => {
6983
+ if (!warned) {
6984
+ warned = true;
6985
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
6986
+ }
6987
+ };
6988
+ })();
6989
+ exports2.colors = [
6990
+ "#0000CC",
6991
+ "#0000FF",
6992
+ "#0033CC",
6993
+ "#0033FF",
6994
+ "#0066CC",
6995
+ "#0066FF",
6996
+ "#0099CC",
6997
+ "#0099FF",
6998
+ "#00CC00",
6999
+ "#00CC33",
7000
+ "#00CC66",
7001
+ "#00CC99",
7002
+ "#00CCCC",
7003
+ "#00CCFF",
7004
+ "#3300CC",
7005
+ "#3300FF",
7006
+ "#3333CC",
7007
+ "#3333FF",
7008
+ "#3366CC",
7009
+ "#3366FF",
7010
+ "#3399CC",
7011
+ "#3399FF",
7012
+ "#33CC00",
7013
+ "#33CC33",
7014
+ "#33CC66",
7015
+ "#33CC99",
7016
+ "#33CCCC",
7017
+ "#33CCFF",
7018
+ "#6600CC",
7019
+ "#6600FF",
7020
+ "#6633CC",
7021
+ "#6633FF",
7022
+ "#66CC00",
7023
+ "#66CC33",
7024
+ "#9900CC",
7025
+ "#9900FF",
7026
+ "#9933CC",
7027
+ "#9933FF",
7028
+ "#99CC00",
7029
+ "#99CC33",
7030
+ "#CC0000",
7031
+ "#CC0033",
7032
+ "#CC0066",
7033
+ "#CC0099",
7034
+ "#CC00CC",
7035
+ "#CC00FF",
7036
+ "#CC3300",
7037
+ "#CC3333",
7038
+ "#CC3366",
7039
+ "#CC3399",
7040
+ "#CC33CC",
7041
+ "#CC33FF",
7042
+ "#CC6600",
7043
+ "#CC6633",
7044
+ "#CC9900",
7045
+ "#CC9933",
7046
+ "#CCCC00",
7047
+ "#CCCC33",
7048
+ "#FF0000",
7049
+ "#FF0033",
7050
+ "#FF0066",
7051
+ "#FF0099",
7052
+ "#FF00CC",
7053
+ "#FF00FF",
7054
+ "#FF3300",
7055
+ "#FF3333",
7056
+ "#FF3366",
7057
+ "#FF3399",
7058
+ "#FF33CC",
7059
+ "#FF33FF",
7060
+ "#FF6600",
7061
+ "#FF6633",
7062
+ "#FF9900",
7063
+ "#FF9933",
7064
+ "#FFCC00",
7065
+ "#FFCC33"
7066
+ ];
7067
+ function useColors() {
7068
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
7069
+ return true;
7070
+ }
7071
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
7072
+ return false;
7073
+ }
7074
+ let m2;
7075
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
7076
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
7077
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
7078
+ typeof navigator !== "undefined" && navigator.userAgent && (m2 = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m2[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
7079
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
7080
+ }
7081
+ function formatArgs2(args) {
7082
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
7083
+ if (!this.useColors) {
7084
+ return;
7085
+ }
7086
+ const c = "color: " + this.color;
7087
+ args.splice(1, 0, c, "color: inherit");
7088
+ let index = 0;
7089
+ let lastC = 0;
7090
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
7091
+ if (match === "%%") {
7092
+ return;
7093
+ }
7094
+ index++;
7095
+ if (match === "%c") {
7096
+ lastC = index;
7097
+ }
7098
+ });
7099
+ args.splice(lastC, 0, c);
7100
+ }
7101
+ exports2.log = console.debug || console.log || (() => {
7102
+ });
7103
+ function save(namespaces) {
7104
+ try {
7105
+ if (namespaces) {
7106
+ exports2.storage.setItem("debug", namespaces);
7107
+ } else {
7108
+ exports2.storage.removeItem("debug");
7109
+ }
7110
+ } catch (error) {
7111
+ }
7112
+ }
7113
+ function load() {
7114
+ let r2;
7115
+ try {
7116
+ r2 = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
7117
+ } catch (error) {
7118
+ }
7119
+ if (!r2 && typeof process !== "undefined" && "env" in process) {
7120
+ r2 = process.env.DEBUG;
7121
+ }
7122
+ return r2;
7123
+ }
7124
+ function localstorage() {
7125
+ try {
7126
+ return localStorage;
7127
+ } catch (error) {
7128
+ }
7129
+ }
7130
+ module2.exports = require_common3()(exports2);
7131
+ var { formatters } = module2.exports;
7132
+ formatters.j = function(v) {
7133
+ try {
7134
+ return JSON.stringify(v);
7135
+ } catch (error) {
7136
+ return "[UnexpectedJSONParseError]: " + error.message;
7137
+ }
7138
+ };
7139
+ }
7140
+ });
7141
+
7142
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
7143
+ var require_node2 = __commonJS({
7144
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports2, module2) {
7145
+ var tty = require("tty");
7146
+ var util = require("util");
7147
+ exports2.init = init;
7148
+ exports2.log = log;
7149
+ exports2.formatArgs = formatArgs2;
7150
+ exports2.save = save;
7151
+ exports2.load = load;
7152
+ exports2.useColors = useColors;
7153
+ exports2.destroy = util.deprecate(
7154
+ () => {
7155
+ },
7156
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
7157
+ );
7158
+ exports2.colors = [6, 2, 3, 4, 5, 1];
7159
+ try {
7160
+ const supportsColor = require_supports_color();
7161
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
7162
+ exports2.colors = [
7163
+ 20,
7164
+ 21,
7165
+ 26,
7166
+ 27,
7167
+ 32,
7168
+ 33,
7169
+ 38,
7170
+ 39,
7171
+ 40,
7172
+ 41,
7173
+ 42,
7174
+ 43,
7175
+ 44,
7176
+ 45,
7177
+ 56,
7178
+ 57,
7179
+ 62,
7180
+ 63,
7181
+ 68,
7182
+ 69,
7183
+ 74,
7184
+ 75,
7185
+ 76,
7186
+ 77,
7187
+ 78,
7188
+ 79,
7189
+ 80,
7190
+ 81,
7191
+ 92,
7192
+ 93,
7193
+ 98,
7194
+ 99,
7195
+ 112,
7196
+ 113,
7197
+ 128,
7198
+ 129,
7199
+ 134,
7200
+ 135,
7201
+ 148,
7202
+ 149,
7203
+ 160,
7204
+ 161,
7205
+ 162,
7206
+ 163,
7207
+ 164,
7208
+ 165,
7209
+ 166,
7210
+ 167,
7211
+ 168,
7212
+ 169,
7213
+ 170,
7214
+ 171,
7215
+ 172,
7216
+ 173,
7217
+ 178,
7218
+ 179,
7219
+ 184,
7220
+ 185,
7221
+ 196,
7222
+ 197,
7223
+ 198,
7224
+ 199,
7225
+ 200,
7226
+ 201,
7227
+ 202,
7228
+ 203,
7229
+ 204,
7230
+ 205,
7231
+ 206,
7232
+ 207,
7233
+ 208,
7234
+ 209,
7235
+ 214,
7236
+ 215,
7237
+ 220,
7238
+ 221
7239
+ ];
7240
+ }
7241
+ } catch (error) {
7242
+ }
7243
+ exports2.inspectOpts = Object.keys(process.env).filter((key) => {
7244
+ return /^debug_/i.test(key);
7245
+ }).reduce((obj, key) => {
7246
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
7247
+ return k.toUpperCase();
7248
+ });
7249
+ let val = process.env[key];
7250
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
7251
+ val = true;
7252
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
7253
+ val = false;
7254
+ } else if (val === "null") {
7255
+ val = null;
7256
+ } else {
7257
+ val = Number(val);
7258
+ }
7259
+ obj[prop] = val;
7260
+ return obj;
7261
+ }, {});
7262
+ function useColors() {
7263
+ return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
7264
+ }
7265
+ function formatArgs2(args) {
7266
+ const { namespace: name, useColors: useColors2 } = this;
7267
+ if (useColors2) {
7268
+ const c = this.color;
7269
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
7270
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
7271
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
7272
+ args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
7273
+ } else {
7274
+ args[0] = getDate() + name + " " + args[0];
7275
+ }
7276
+ }
7277
+ function getDate() {
7278
+ if (exports2.inspectOpts.hideDate) {
7279
+ return "";
7280
+ }
7281
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
7282
+ }
7283
+ function log(...args) {
7284
+ return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
7285
+ }
7286
+ function save(namespaces) {
7287
+ if (namespaces) {
7288
+ process.env.DEBUG = namespaces;
7289
+ } else {
7290
+ delete process.env.DEBUG;
7291
+ }
7292
+ }
7293
+ function load() {
7294
+ return process.env.DEBUG;
7295
+ }
7296
+ function init(debug2) {
7297
+ debug2.inspectOpts = {};
7298
+ const keys = Object.keys(exports2.inspectOpts);
7299
+ for (let i2 = 0; i2 < keys.length; i2++) {
7300
+ debug2.inspectOpts[keys[i2]] = exports2.inspectOpts[keys[i2]];
7301
+ }
7302
+ }
7303
+ module2.exports = require_common3()(exports2);
7304
+ var { formatters } = module2.exports;
7305
+ formatters.o = function(v) {
7306
+ this.inspectOpts.colors = this.useColors;
7307
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
7308
+ };
7309
+ formatters.O = function(v) {
7310
+ this.inspectOpts.colors = this.useColors;
7311
+ return util.inspect(v, this.inspectOpts);
7312
+ };
7313
+ }
7314
+ });
7315
+
7316
+ // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
7317
+ var require_src2 = __commonJS({
7318
+ "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports2, module2) {
7319
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
7320
+ module2.exports = require_browser2();
7321
+ } else {
7322
+ module2.exports = require_node2();
7323
+ }
7324
+ }
7325
+ });
7326
+
6795
7327
  // ../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/helpers.js
6796
7328
  var require_helpers = __commonJS({
6797
7329
  "../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/helpers.js"(exports2) {
@@ -7044,7 +7576,7 @@ var require_parse_proxy_response = __commonJS({
7044
7576
  };
7045
7577
  Object.defineProperty(exports2, "__esModule", { value: true });
7046
7578
  exports2.parseProxyResponse = void 0;
7047
- var debug_1 = __importDefault(require_src());
7579
+ var debug_1 = __importDefault(require_src2());
7048
7580
  var debug2 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
7049
7581
  function parseProxyResponse(socket) {
7050
7582
  return new Promise((resolve3, reject) => {
@@ -7170,7 +7702,7 @@ var require_dist2 = __commonJS({
7170
7702
  var net2 = __importStar(require("net"));
7171
7703
  var tls = __importStar(require("tls"));
7172
7704
  var assert_1 = __importDefault(require("assert"));
7173
- var debug_1 = __importDefault(require_src());
7705
+ var debug_1 = __importDefault(require_src2());
7174
7706
  var agent_base_1 = require_dist();
7175
7707
  var url_1 = require("url");
7176
7708
  var parse_proxy_response_1 = require_parse_proxy_response();
@@ -14350,7 +14882,7 @@ Content-Type: ${partContentType}\r
14350
14882
  });
14351
14883
 
14352
14884
  // ../../node_modules/.pnpm/gaxios@7.1.3/node_modules/gaxios/build/cjs/src/index.js
14353
- var require_src2 = __commonJS({
14885
+ var require_src3 = __commonJS({
14354
14886
  "../../node_modules/.pnpm/gaxios@7.1.3/node_modules/gaxios/build/cjs/src/index.js"(exports2) {
14355
14887
  "use strict";
14356
14888
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m2, k, k2) {
@@ -16556,7 +17088,7 @@ var require_logging_utils = __commonJS({
16556
17088
  });
16557
17089
 
16558
17090
  // ../../node_modules/.pnpm/google-logging-utils@1.1.3/node_modules/google-logging-utils/build/src/index.js
16559
- var require_src3 = __commonJS({
17091
+ var require_src4 = __commonJS({
16560
17092
  "../../node_modules/.pnpm/google-logging-utils@1.1.3/node_modules/google-logging-utils/build/src/index.js"(exports2) {
16561
17093
  "use strict";
16562
17094
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m2, k, k2) {
@@ -16581,7 +17113,7 @@ var require_src3 = __commonJS({
16581
17113
  });
16582
17114
 
16583
17115
  // ../../node_modules/.pnpm/gcp-metadata@8.1.2/node_modules/gcp-metadata/build/src/index.js
16584
- var require_src4 = __commonJS({
17116
+ var require_src5 = __commonJS({
16585
17117
  "../../node_modules/.pnpm/gcp-metadata@8.1.2/node_modules/gcp-metadata/build/src/index.js"(exports2) {
16586
17118
  "use strict";
16587
17119
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m2, k, k2) {
@@ -16635,10 +17167,10 @@ var require_src4 = __commonJS({
16635
17167
  exports2.getGCPResidency = getGCPResidency;
16636
17168
  exports2.setGCPResidency = setGCPResidency;
16637
17169
  exports2.requestTimeout = requestTimeout;
16638
- var gaxios_1 = require_src2();
17170
+ var gaxios_1 = require_src3();
16639
17171
  var jsonBigint = require_json_bigint();
16640
17172
  var gcp_residency_1 = require_gcp_residency();
16641
- var logger = __importStar(require_src3());
17173
+ var logger = __importStar(require_src4());
16642
17174
  exports2.BASE_PATH = "/computeMetadata/v1";
16643
17175
  exports2.HOST_ADDRESS = "http://169.254.169.254";
16644
17176
  exports2.SECONDARY_HOST_ADDRESS = "http://metadata.google.internal.";
@@ -17638,9 +18170,9 @@ var require_authclient = __commonJS({
17638
18170
  Object.defineProperty(exports2, "__esModule", { value: true });
17639
18171
  exports2.AuthClient = exports2.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS = exports2.DEFAULT_UNIVERSE = void 0;
17640
18172
  var events_1 = require("events");
17641
- var gaxios_1 = require_src2();
18173
+ var gaxios_1 = require_src3();
17642
18174
  var util_1 = require_util2();
17643
- var google_logging_utils_1 = require_src3();
18175
+ var google_logging_utils_1 = require_src4();
17644
18176
  var shared_cjs_1 = require_shared2();
17645
18177
  exports2.DEFAULT_UNIVERSE = "googleapis.com";
17646
18178
  exports2.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS = 5 * 60 * 1e3;
@@ -17927,7 +18459,7 @@ var require_oauth2client = __commonJS({
17927
18459
  "use strict";
17928
18460
  Object.defineProperty(exports2, "__esModule", { value: true });
17929
18461
  exports2.OAuth2Client = exports2.ClientAuthentication = exports2.CertificateFormat = exports2.CodeChallengeMethod = void 0;
17930
- var gaxios_1 = require_src2();
18462
+ var gaxios_1 = require_src3();
17931
18463
  var querystring = require("querystring");
17932
18464
  var stream = require("stream");
17933
18465
  var formatEcdsa = require_ecdsa_sig_formatter();
@@ -18637,8 +19169,8 @@ var require_computeclient = __commonJS({
18637
19169
  "use strict";
18638
19170
  Object.defineProperty(exports2, "__esModule", { value: true });
18639
19171
  exports2.Compute = void 0;
18640
- var gaxios_1 = require_src2();
18641
- var gcpMetadata = require_src4();
19172
+ var gaxios_1 = require_src3();
19173
+ var gcpMetadata = require_src5();
18642
19174
  var oauth2client_1 = require_oauth2client();
18643
19175
  var Compute = class extends oauth2client_1.OAuth2Client {
18644
19176
  /**
@@ -18783,7 +19315,7 @@ var require_envDetect = __commonJS({
18783
19315
  exports2.GCPEnv = void 0;
18784
19316
  exports2.clear = clear2;
18785
19317
  exports2.getEnv = getEnv;
18786
- var gcpMetadata = require_src4();
19318
+ var gcpMetadata = require_src5();
18787
19319
  var GCPEnv;
18788
19320
  (function(GCPEnv2) {
18789
19321
  GCPEnv2["APP_ENGINE"] = "APP_ENGINE";
@@ -19383,7 +19915,7 @@ var require_jws = __commonJS({
19383
19915
  });
19384
19916
 
19385
19917
  // ../../node_modules/.pnpm/gtoken@8.0.0/node_modules/gtoken/build/cjs/src/index.cjs
19386
- var require_src5 = __commonJS({
19918
+ var require_src6 = __commonJS({
19387
19919
  "../../node_modules/.pnpm/gtoken@8.0.0/node_modules/gtoken/build/cjs/src/index.cjs"(exports2) {
19388
19920
  "use strict";
19389
19921
  Object.defineProperty(exports2, "__esModule", {
@@ -19391,7 +19923,7 @@ var require_src5 = __commonJS({
19391
19923
  });
19392
19924
  exports2.GoogleToken = void 0;
19393
19925
  var fs12 = _interopRequireWildcard(require("fs"));
19394
- var _gaxios = require_src2();
19926
+ var _gaxios = require_src3();
19395
19927
  var jws = _interopRequireWildcard(require_jws());
19396
19928
  var path8 = _interopRequireWildcard(require("path"));
19397
19929
  var _util = require("util");
@@ -20197,7 +20729,7 @@ var require_jwtclient = __commonJS({
20197
20729
  "use strict";
20198
20730
  Object.defineProperty(exports2, "__esModule", { value: true });
20199
20731
  exports2.JWT = void 0;
20200
- var gtoken_1 = require_src5();
20732
+ var gtoken_1 = require_src6();
20201
20733
  var jwtaccess_1 = require_jwtaccess();
20202
20734
  var oauth2client_1 = require_oauth2client();
20203
20735
  var authclient_1 = require_authclient();
@@ -20611,7 +21143,7 @@ var require_impersonated = __commonJS({
20611
21143
  Object.defineProperty(exports2, "__esModule", { value: true });
20612
21144
  exports2.Impersonated = exports2.IMPERSONATED_ACCOUNT_TYPE = void 0;
20613
21145
  var oauth2client_1 = require_oauth2client();
20614
- var gaxios_1 = require_src2();
21146
+ var gaxios_1 = require_src3();
20615
21147
  var util_1 = require_util2();
20616
21148
  exports2.IMPERSONATED_ACCOUNT_TYPE = "impersonated_service_account";
20617
21149
  var Impersonated = class _Impersonated extends oauth2client_1.OAuth2Client {
@@ -20796,7 +21328,7 @@ var require_oauth2common = __commonJS({
20796
21328
  Object.defineProperty(exports2, "__esModule", { value: true });
20797
21329
  exports2.OAuthClientAuthHandler = void 0;
20798
21330
  exports2.getErrorFromOAuthErrorResponse = getErrorFromOAuthErrorResponse;
20799
- var gaxios_1 = require_src2();
21331
+ var gaxios_1 = require_src3();
20800
21332
  var crypto_1 = require_crypto3();
20801
21333
  var METHODS_SUPPORTING_REQUEST_BODY = ["PUT", "POST", "PATCH"];
20802
21334
  var _crypto, _clientAuthentication;
@@ -20948,7 +21480,7 @@ var require_stscredentials = __commonJS({
20948
21480
  "use strict";
20949
21481
  Object.defineProperty(exports2, "__esModule", { value: true });
20950
21482
  exports2.StsCredentials = void 0;
20951
- var gaxios_1 = require_src2();
21483
+ var gaxios_1 = require_src3();
20952
21484
  var authclient_1 = require_authclient();
20953
21485
  var oauth2common_1 = require_oauth2common();
20954
21486
  var util_1 = require_util2();
@@ -21040,7 +21572,7 @@ var require_baseexternalclient = __commonJS({
21040
21572
  "use strict";
21041
21573
  Object.defineProperty(exports2, "__esModule", { value: true });
21042
21574
  exports2.BaseExternalAccountClient = exports2.CLOUD_RESOURCE_MANAGER = exports2.EXTERNAL_ACCOUNT_TYPE = exports2.EXPIRATION_TIME_OFFSET = void 0;
21043
- var gaxios_1 = require_src2();
21575
+ var gaxios_1 = require_src3();
21044
21576
  var stream = require("stream");
21045
21577
  var authclient_1 = require_authclient();
21046
21578
  var sts = require_stscredentials();
@@ -21751,7 +22283,7 @@ var require_identitypoolclient = __commonJS({
21751
22283
  var urlsubjecttokensupplier_1 = require_urlsubjecttokensupplier();
21752
22284
  var certificatesubjecttokensupplier_1 = require_certificatesubjecttokensupplier();
21753
22285
  var stscredentials_1 = require_stscredentials();
21754
- var gaxios_1 = require_src2();
22286
+ var gaxios_1 = require_src3();
21755
22287
  var IdentityPoolClient = class _IdentityPoolClient extends baseexternalclient_1.BaseExternalAccountClient {
21756
22288
  /**
21757
22289
  * Instantiate an IdentityPoolClient instance using the provided JSON
@@ -21858,7 +22390,7 @@ var require_awsrequestsigner = __commonJS({
21858
22390
  "use strict";
21859
22391
  Object.defineProperty(exports2, "__esModule", { value: true });
21860
22392
  exports2.AwsRequestSigner = void 0;
21861
- var gaxios_1 = require_src2();
22393
+ var gaxios_1 = require_src3();
21862
22394
  var crypto_1 = require_crypto3();
21863
22395
  var AWS_ALGORITHM = "AWS4-HMAC-SHA256";
21864
22396
  var AWS_REQUEST_TYPE = "aws4_request";
@@ -22161,7 +22693,7 @@ var require_awsclient = __commonJS({
22161
22693
  var baseexternalclient_1 = require_baseexternalclient();
22162
22694
  var defaultawssecuritycredentialssupplier_1 = require_defaultawssecuritycredentialssupplier();
22163
22695
  var util_1 = require_util2();
22164
- var gaxios_1 = require_src2();
22696
+ var gaxios_1 = require_src3();
22165
22697
  var _DEFAULT_AWS_REGIONAL_CREDENTIAL_VERIFICATION_URL;
22166
22698
  var _AwsClient = class _AwsClient extends baseexternalclient_1.BaseExternalAccountClient {
22167
22699
  /**
@@ -22731,7 +23263,7 @@ var require_externalAccountAuthorizedUserClient = __commonJS({
22731
23263
  exports2.ExternalAccountAuthorizedUserClient = exports2.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE = void 0;
22732
23264
  var authclient_1 = require_authclient();
22733
23265
  var oauth2common_1 = require_oauth2common();
22734
- var gaxios_1 = require_src2();
23266
+ var gaxios_1 = require_src3();
22735
23267
  var stream = require("stream");
22736
23268
  var baseexternalclient_1 = require_baseexternalclient();
22737
23269
  exports2.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE = "external_account_authorized_user";
@@ -22930,8 +23462,8 @@ var require_googleauth = __commonJS({
22930
23462
  exports2.GoogleAuth = exports2.GoogleAuthExceptionMessages = void 0;
22931
23463
  var child_process_1 = require("child_process");
22932
23464
  var fs12 = require("fs");
22933
- var gaxios_1 = require_src2();
22934
- var gcpMetadata = require_src4();
23465
+ var gaxios_1 = require_src3();
23466
+ var gcpMetadata = require_src5();
22935
23467
  var os3 = require("os");
22936
23468
  var path8 = require("path");
22937
23469
  var crypto_1 = require_crypto3();
@@ -23804,7 +24336,7 @@ var require_downscopedclient = __commonJS({
23804
24336
  "use strict";
23805
24337
  Object.defineProperty(exports2, "__esModule", { value: true });
23806
24338
  exports2.DownscopedClient = exports2.EXPIRATION_TIME_OFFSET = exports2.MAX_ACCESS_BOUNDARY_RULES_COUNT = void 0;
23807
- var gaxios_1 = require_src2();
24339
+ var gaxios_1 = require_src3();
23808
24340
  var stream = require("stream");
23809
24341
  var authclient_1 = require_authclient();
23810
24342
  var sts = require_stscredentials();
@@ -24044,7 +24576,7 @@ var require_passthrough = __commonJS({
24044
24576
  });
24045
24577
 
24046
24578
  // ../../node_modules/.pnpm/google-auth-library@10.5.0/node_modules/google-auth-library/build/src/index.js
24047
- var require_src6 = __commonJS({
24579
+ var require_src7 = __commonJS({
24048
24580
  "../../node_modules/.pnpm/google-auth-library@10.5.0/node_modules/google-auth-library/build/src/index.js"(exports2) {
24049
24581
  "use strict";
24050
24582
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -24053,8 +24585,8 @@ var require_src6 = __commonJS({
24053
24585
  Object.defineProperty(exports2, "GoogleAuth", { enumerable: true, get: function() {
24054
24586
  return googleauth_1.GoogleAuth;
24055
24587
  } });
24056
- exports2.gcpMetadata = require_src4();
24057
- exports2.gaxios = require_src2();
24588
+ exports2.gcpMetadata = require_src5();
24589
+ exports2.gaxios = require_src3();
24058
24590
  var authclient_1 = require_authclient();
24059
24591
  Object.defineProperty(exports2, "AuthClient", { enumerable: true, get: function() {
24060
24592
  return authclient_1.AuthClient;
@@ -30654,7 +31186,10 @@ function buildMetadataPrompt(instruction, extractionResponse) {
30654
31186
  Extracted content: ${JSON.stringify(extractionResponse, null, 2)}`
30655
31187
  };
30656
31188
  }
30657
- function buildObserveSystemPrompt(userProvidedInstructions) {
31189
+ function buildObserveSystemPrompt(userProvidedInstructions, supportedActions) {
31190
+ const actionsString = (supportedActions == null ? void 0 : supportedActions.length) ? `
31191
+
31192
+ Supported actions: ${supportedActions.join(", ")}` : "";
30658
31193
  const observeSystemPrompt = `
30659
31194
  You are helping the user automate the browser by finding elements based on what the user wants to observe in the page.
30660
31195
 
@@ -30662,7 +31197,8 @@ You will be given:
30662
31197
  1. a instruction of elements to observe
30663
31198
  2. a hierarchical accessibility tree showing the semantic structure of the page. The tree is a hybrid of the DOM and the accessibility tree.
30664
31199
 
30665
- Return an array of elements that match the instruction if they exist, otherwise return an empty array.`;
31200
+ Return an array of elements that match the instruction if they exist, otherwise return an empty array.
31201
+ When returning elements, include the appropriate method from the supported actions list.${actionsString}`;
30666
31202
  const content = observeSystemPrompt.replace(/\s+/g, " ");
30667
31203
  return {
30668
31204
  role: "system",
@@ -30988,7 +31524,8 @@ function observe(_0) {
30988
31524
  llmClient,
30989
31525
  userProvidedInstructions,
30990
31526
  logger,
30991
- logInferenceToFile = false
31527
+ logInferenceToFile = false,
31528
+ supportedActions
30992
31529
  }) {
30993
31530
  var _a4, _b, _c, _d2, _e, _f;
30994
31531
  const isGPT5 = llmClient.modelName.includes("gpt-5");
@@ -31013,7 +31550,7 @@ function observe(_0) {
31013
31550
  ).describe("an array of accessible elements that match the instruction")
31014
31551
  });
31015
31552
  const messages = [
31016
- buildObserveSystemPrompt(userProvidedInstructions),
31553
+ buildObserveSystemPrompt(userProvidedInstructions, supportedActions),
31017
31554
  buildObserveUserMessage(instruction, domElements)
31018
31555
  ];
31019
31556
  let callTimestamp = "";
@@ -31209,18 +31746,20 @@ init_sdkErrors();
31209
31746
  init_snapshot();
31210
31747
 
31211
31748
  // lib/v3/types/private/handlers.ts
31212
- var SupportedPlaywrightAction = /* @__PURE__ */ ((SupportedPlaywrightAction2) => {
31213
- SupportedPlaywrightAction2["CLICK"] = "click";
31214
- SupportedPlaywrightAction2["FILL"] = "fill";
31215
- SupportedPlaywrightAction2["TYPE"] = "type";
31216
- SupportedPlaywrightAction2["PRESS"] = "press";
31217
- SupportedPlaywrightAction2["SCROLL"] = "scrollTo";
31218
- SupportedPlaywrightAction2["NEXT_CHUNK"] = "nextChunk";
31219
- SupportedPlaywrightAction2["PREV_CHUNK"] = "prevChunk";
31220
- SupportedPlaywrightAction2["SELECT_OPTION_FROM_DROPDOWN"] = "selectOptionFromDropdown";
31221
- SupportedPlaywrightAction2["HOVER"] = "hover";
31222
- return SupportedPlaywrightAction2;
31223
- })(SupportedPlaywrightAction || {});
31749
+ var SupportedUnderstudyAction = /* @__PURE__ */ ((SupportedUnderstudyAction2) => {
31750
+ SupportedUnderstudyAction2["CLICK"] = "click";
31751
+ SupportedUnderstudyAction2["FILL"] = "fill";
31752
+ SupportedUnderstudyAction2["TYPE"] = "type";
31753
+ SupportedUnderstudyAction2["PRESS"] = "press";
31754
+ SupportedUnderstudyAction2["SCROLL"] = "scrollTo";
31755
+ SupportedUnderstudyAction2["NEXT_CHUNK"] = "nextChunk";
31756
+ SupportedUnderstudyAction2["PREV_CHUNK"] = "prevChunk";
31757
+ SupportedUnderstudyAction2["SELECT_OPTION_FROM_DROPDOWN"] = "selectOptionFromDropdown";
31758
+ SupportedUnderstudyAction2["HOVER"] = "hover";
31759
+ SupportedUnderstudyAction2["DOUBLE_CLICK"] = "doubleClick";
31760
+ SupportedUnderstudyAction2["DRAG_AND_DROP"] = "dragAndDrop";
31761
+ return SupportedUnderstudyAction2;
31762
+ })(SupportedUnderstudyAction || {});
31224
31763
 
31225
31764
  // lib/v3/handlers/handlerUtils/actHandlerUtils.ts
31226
31765
  init_deepLocator();
@@ -31960,7 +32499,7 @@ var ActHandler = class {
31960
32499
  );
31961
32500
  const actInstruction = buildActPrompt(
31962
32501
  instruction,
31963
- Object.values(SupportedPlaywrightAction),
32502
+ Object.values(SupportedUnderstudyAction),
31964
32503
  variables
31965
32504
  );
31966
32505
  ensureTimeRemaining();
@@ -32007,7 +32546,7 @@ var ActHandler = class {
32007
32546
  const stepTwoInstructions = buildStepTwoPrompt(
32008
32547
  instruction,
32009
32548
  previousAction,
32010
- Object.values(SupportedPlaywrightAction).filter(
32549
+ Object.values(SupportedUnderstudyAction).filter(
32011
32550
  (action) => action !== "selectOptionFromDropdown" /* SELECT_OPTION_FROM_DROPDOWN */
32012
32551
  ),
32013
32552
  variables
@@ -32116,7 +32655,7 @@ var ActHandler = class {
32116
32655
  });
32117
32656
  const instruction = buildActPrompt(
32118
32657
  actCommand,
32119
- Object.values(SupportedPlaywrightAction),
32658
+ Object.values(SupportedUnderstudyAction),
32120
32659
  {}
32121
32660
  );
32122
32661
  ensureTimeRemaining == null ? void 0 : ensureTimeRemaining();
@@ -32202,10 +32741,43 @@ function normalizeActInferenceElement(element, xpathMap, requireMethodAndArgumen
32202
32741
  if (!trimmed) {
32203
32742
  return void 0;
32204
32743
  }
32744
+ let resolvedArgs = hasArgs ? args : void 0;
32745
+ if (method === "dragAndDrop" && hasArgs && args.length > 0) {
32746
+ const targetArg = args[0];
32747
+ if (typeof targetArg === "string" && /^\d+-\d+$/.test(targetArg)) {
32748
+ const argXpath = xpathMap[targetArg];
32749
+ const trimmedArgXpath = trimTrailingTextNode(argXpath);
32750
+ if (trimmedArgXpath) {
32751
+ resolvedArgs = [`xpath=${trimmedArgXpath}`, ...args.slice(1)];
32752
+ } else {
32753
+ v3Logger({
32754
+ category: "action",
32755
+ message: "dragAndDrop target element lookup failed",
32756
+ level: 1,
32757
+ auxiliary: {
32758
+ targetElementId: { value: targetArg, type: "string" },
32759
+ sourceElementId: { value: elementId, type: "string" }
32760
+ }
32761
+ });
32762
+ return void 0;
32763
+ }
32764
+ } else {
32765
+ v3Logger({
32766
+ category: "action",
32767
+ message: "dragAndDrop target element invalid ID format",
32768
+ level: 0,
32769
+ auxiliary: {
32770
+ targetElementId: { value: String(targetArg), type: "string" },
32771
+ sourceElementId: { value: elementId, type: "string" }
32772
+ }
32773
+ });
32774
+ return void 0;
32775
+ }
32776
+ }
32205
32777
  return {
32206
32778
  description,
32207
32779
  method,
32208
- arguments: hasArgs ? args : void 0,
32780
+ arguments: resolvedArgs,
32209
32781
  selector: `xpath=${trimmed}`
32210
32782
  };
32211
32783
  }
@@ -32418,7 +32990,8 @@ var ObserveHandler = class {
32418
32990
  llmClient,
32419
32991
  userProvidedInstructions: this.systemPrompt,
32420
32992
  logger: v3Logger,
32421
- logInferenceToFile: this.logInferenceToFile
32993
+ logInferenceToFile: this.logInferenceToFile,
32994
+ supportedActions: Object.values(SupportedUnderstudyAction)
32422
32995
  });
32423
32996
  const {
32424
32997
  prompt_tokens = 0,
@@ -32444,7 +33017,44 @@ var ObserveHandler = class {
32444
33017
  const xpath = combinedXpathMap[lookUpIndex];
32445
33018
  const trimmedXpath = trimTrailingTextNode(xpath);
32446
33019
  if (!trimmedXpath) return void 0;
33020
+ let resolvedArgs = rest.arguments;
33021
+ if (rest.method === "dragAndDrop" && Array.isArray(rest.arguments) && rest.arguments.length > 0) {
33022
+ const targetArg = rest.arguments[0];
33023
+ if (typeof targetArg === "string" && /^\d+-\d+$/.test(targetArg)) {
33024
+ const argXpath = combinedXpathMap[targetArg];
33025
+ const trimmedArgXpath = trimTrailingTextNode(argXpath);
33026
+ if (trimmedArgXpath) {
33027
+ resolvedArgs = [
33028
+ `xpath=${trimmedArgXpath}`,
33029
+ ...rest.arguments.slice(1)
33030
+ ];
33031
+ } else {
33032
+ v3Logger({
33033
+ category: "observation",
33034
+ message: "dragAndDrop target element lookup failed",
33035
+ level: 0,
33036
+ auxiliary: {
33037
+ targetElementId: { value: targetArg, type: "string" },
33038
+ sourceElementId: { value: elementId, type: "string" }
33039
+ }
33040
+ });
33041
+ return void 0;
33042
+ }
33043
+ } else {
33044
+ v3Logger({
33045
+ category: "observation",
33046
+ message: "dragAndDrop target element invalid ID format",
33047
+ level: 0,
33048
+ auxiliary: {
33049
+ targetElementId: { value: targetArg, type: "string" },
33050
+ sourceElementId: { value: elementId, type: "string" }
33051
+ }
33052
+ });
33053
+ return void 0;
33054
+ }
33055
+ }
32447
33056
  return __spreadProps(__spreadValues({}, rest), {
33057
+ arguments: resolvedArgs,
32448
33058
  selector: `xpath=${trimmedXpath}`
32449
33059
  });
32450
33060
  }
@@ -32909,51 +33519,82 @@ var scrollVisionTool = (v3, provider) => (0, import_ai8.tool)({
32909
33519
  // lib/v3/agent/tools/extract.ts
32910
33520
  var import_ai9 = require("ai");
32911
33521
  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();
33522
+ function jsonSchemaToZod2(schema) {
33523
+ switch (schema.type) {
33524
+ case "object": {
33525
+ const shape = {};
33526
+ if (schema.properties) {
33527
+ for (const [key, value] of Object.entries(schema.properties)) {
33528
+ shape[key] = jsonSchemaToZod2(value);
33529
+ }
33530
+ }
33531
+ return import_zod13.z.object(shape);
33532
+ }
33533
+ case "array":
33534
+ return import_zod13.z.array(schema.items ? jsonSchemaToZod2(schema.items) : import_zod13.z.any());
33535
+ case "string": {
33536
+ let s2 = import_zod13.z.string();
33537
+ if (schema.format === "url") s2 = s2.url();
33538
+ if (schema.format === "email") s2 = s2.email();
33539
+ if (schema.format === "uuid") s2 = s2.uuid();
33540
+ if (schema.enum && schema.enum.length > 0)
33541
+ return import_zod13.z.enum(schema.enum);
33542
+ return s2;
33543
+ }
33544
+ case "number":
33545
+ case "integer":
33546
+ return import_zod13.z.number();
33547
+ case "boolean":
33548
+ return import_zod13.z.boolean();
33549
+ case "null":
33550
+ return import_zod13.z.null();
33551
+ default:
33552
+ return import_zod13.z.any();
32924
33553
  }
32925
33554
  }
32926
- var extractTool = (v3, executionModel, logger) => (0, import_ai9.tool)({
33555
+ var extractTool = (v3, executionModel) => (0, import_ai9.tool)({
32927
33556
  description: `Extract structured data from the current page based on a provided schema.
32928
33557
 
32929
33558
  USAGE GUIDELINES:
32930
33559
  - 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()
33560
+ - IMPORTANT: only use this if explicitly asked for structured output. In most scenarios, you should use the aria tree tool over this.
33561
+ - For URL fields, use format: "url"
33562
+
32933
33563
  EXAMPLES:
32934
33564
  1. Extract a single value:
32935
33565
  instruction: "extract the product price"
32936
- schema: "z.object({ price: z.number()})"
33566
+ schema: { type: "object", properties: { price: { type: "number" } } }
32937
33567
 
32938
33568
  2. Extract multiple fields:
32939
33569
  instruction: "extract product name and price"
32940
- schema: "z.object({ name: z.string(), price: z.number() })"
33570
+ schema: { type: "object", properties: { name: { type: "string" }, price: { type: "number" } } }
32941
33571
 
32942
33572
  3. Extract arrays:
32943
33573
  instruction: "extract all product names and prices"
32944
- schema: "z.object({ products: z.array(z.object({ name: z.string(), price: z.number() })) })"`,
33574
+ schema: { type: "object", properties: { products: { type: "array", items: { type: "object", properties: { name: { type: "string" }, price: { type: "number" } } } } } }
33575
+
33576
+ 4. Extract a URL:
33577
+ instruction: "extract the link"
33578
+ schema: { type: "object", properties: { url: { type: "string", format: "url" } } }`,
32945
33579
  inputSchema: import_zod13.z.object({
32946
33580
  instruction: import_zod13.z.string(),
32947
- schema: import_zod13.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })")
33581
+ schema: import_zod13.z.object({
33582
+ type: import_zod13.z.string().optional(),
33583
+ properties: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional(),
33584
+ items: import_zod13.z.unknown().optional(),
33585
+ enum: import_zod13.z.array(import_zod13.z.string()).optional(),
33586
+ format: import_zod13.z.enum(["url", "email", "uuid"]).optional()
33587
+ }).passthrough().optional().describe("JSON Schema object describing the structure to extract")
32948
33588
  }),
32949
33589
  execute: (_0) => __async(null, [_0], function* ({ instruction, schema }) {
32950
33590
  var _a4;
32951
33591
  try {
32952
- const parsedSchema = schema ? evaluateZodSchema(schema, logger) : void 0;
33592
+ const parsedSchema = schema ? jsonSchemaToZod2(schema) : void 0;
32953
33593
  const result = yield v3.extract(instruction, parsedSchema, __spreadValues({}, executionModel ? { model: executionModel } : {}));
32954
33594
  return { success: true, result };
32955
33595
  } catch (error) {
32956
- return { success: false, error: (_a4 = error == null ? void 0 : error.message) != null ? _a4 : String(error) };
33596
+ const err = error;
33597
+ return { success: false, error: (_a4 = err == null ? void 0 : err.message) != null ? _a4 : String(error) };
32957
33598
  }
32958
33599
  })
32959
33600
  });
@@ -33700,7 +34341,7 @@ function createAgentTools(v3, options) {
33700
34341
  click: clickTool(v3, provider),
33701
34342
  clickAndHold: clickAndHoldTool(v3, provider),
33702
34343
  dragAndDrop: dragAndDropTool(v3, provider),
33703
- extract: extractTool(v3, executionModel, options == null ? void 0 : options.logger),
34344
+ extract: extractTool(v3, executionModel),
33704
34345
  fillForm: fillFormTool(v3, executionModel),
33705
34346
  fillFormVision: fillFormVisionTool(v3, provider),
33706
34347
  goto: gotoTool(v3),
@@ -34563,13 +35204,13 @@ var V3AgentHandler = class {
34563
35204
  }
34564
35205
  const endTime = Date.now();
34565
35206
  const inferenceTimeMs = endTime - startTime;
34566
- if (result.usage) {
35207
+ if (result.totalUsage) {
34567
35208
  this.v3.updateMetrics(
34568
35209
  "AGENT" /* AGENT */,
34569
- result.usage.inputTokens || 0,
34570
- result.usage.outputTokens || 0,
34571
- result.usage.reasoningTokens || 0,
34572
- result.usage.cachedInputTokens || 0,
35210
+ result.totalUsage.inputTokens || 0,
35211
+ result.totalUsage.outputTokens || 0,
35212
+ result.totalUsage.reasoningTokens || 0,
35213
+ result.totalUsage.cachedInputTokens || 0,
34573
35214
  inferenceTimeMs
34574
35215
  );
34575
35216
  }
@@ -34579,11 +35220,11 @@ var V3AgentHandler = class {
34579
35220
  actions: state.actions,
34580
35221
  completed: state.completed,
34581
35222
  output,
34582
- usage: result.usage ? {
34583
- input_tokens: result.usage.inputTokens || 0,
34584
- output_tokens: result.usage.outputTokens || 0,
34585
- reasoning_tokens: result.usage.reasoningTokens || 0,
34586
- cached_input_tokens: result.usage.cachedInputTokens || 0,
35223
+ usage: result.totalUsage ? {
35224
+ input_tokens: result.totalUsage.inputTokens || 0,
35225
+ output_tokens: result.totalUsage.outputTokens || 0,
35226
+ reasoning_tokens: result.totalUsage.reasoningTokens || 0,
35227
+ cached_input_tokens: result.totalUsage.cachedInputTokens || 0,
34587
35228
  inference_time_ms: inferenceTimeMs
34588
35229
  } : void 0,
34589
35230
  messages: inputMessages
@@ -49407,7 +50048,7 @@ function withoutTrailingSlash2(url) {
49407
50048
  }
49408
50049
 
49409
50050
  // ../../node_modules/.pnpm/@ai-sdk+google-vertex@3.0.85_zod@4.2.1/node_modules/@ai-sdk/google-vertex/dist/index.mjs
49410
- var import_google_auth_library = __toESM(require_src6(), 1);
50051
+ var import_google_auth_library = __toESM(require_src7(), 1);
49411
50052
 
49412
50053
  // ../../node_modules/.pnpm/@ai-sdk+google@2.0.44_zod@4.2.1/node_modules/@ai-sdk/google/dist/internal/index.mjs
49413
50054
  var import_v421 = require("zod/v4");
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.9-alpha-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",