@browserbasehq/orca 3.0.2-zod370 → 3.0.2-zod373
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 +24 -12
- package/dist/index.js +581 -326
- package/package.json +9 -6
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
85
85
|
var STAGEHAND_VERSION;
|
|
86
86
|
var init_version = __esm({
|
|
87
87
|
"lib/version.ts"() {
|
|
88
|
-
STAGEHAND_VERSION = "3.0.2-
|
|
88
|
+
STAGEHAND_VERSION = "3.0.2-zod373";
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
|
|
@@ -7935,12 +7935,15 @@ __export(v3_exports, {
|
|
|
7935
7935
|
getZodType: () => getZodType,
|
|
7936
7936
|
injectUrls: () => injectUrls,
|
|
7937
7937
|
isRunningInBun: () => isRunningInBun,
|
|
7938
|
+
isZod3Schema: () => isZod3Schema,
|
|
7939
|
+
isZod4Schema: () => isZod4Schema,
|
|
7938
7940
|
jsonSchemaToZod: () => jsonSchemaToZod,
|
|
7939
7941
|
loadApiKeyFromEnv: () => loadApiKeyFromEnv,
|
|
7940
7942
|
modelToAgentProviderMap: () => modelToAgentProviderMap,
|
|
7941
7943
|
pageTextSchema: () => pageTextSchema,
|
|
7942
7944
|
providerEnvVarMap: () => providerEnvVarMap,
|
|
7943
7945
|
toGeminiSchema: () => toGeminiSchema,
|
|
7946
|
+
toJsonSchema: () => toJsonSchema,
|
|
7944
7947
|
transformSchema: () => transformSchema,
|
|
7945
7948
|
trimTrailingTextNode: () => trimTrailingTextNode,
|
|
7946
7949
|
validateZodSchema: () => validateZodSchema
|
|
@@ -7957,8 +7960,252 @@ var import_process2 = __toESM(require("process"));
|
|
|
7957
7960
|
// lib/utils.ts
|
|
7958
7961
|
init_sdkErrors();
|
|
7959
7962
|
var import_genai = require("@google/genai");
|
|
7963
|
+
var import_zod2 = require("zod");
|
|
7964
|
+
var import_v3 = __toESM(require("zod/v3"));
|
|
7965
|
+
|
|
7966
|
+
// lib/v3/zodCompat.ts
|
|
7960
7967
|
var import_zod = require("zod");
|
|
7968
|
+
var isZod4Schema = (schema) => typeof schema._zod !== "undefined";
|
|
7969
|
+
var isZod3Schema = (schema) => !isZod4Schema(schema);
|
|
7970
|
+
function ZodToJsonSchema(schema) {
|
|
7971
|
+
const _def = schema._def;
|
|
7972
|
+
if (!_def) {
|
|
7973
|
+
return { type: "null" };
|
|
7974
|
+
}
|
|
7975
|
+
const typeName = _def.typeName;
|
|
7976
|
+
switch (typeName) {
|
|
7977
|
+
case "ZodObject": {
|
|
7978
|
+
const shape = typeof _def.shape === "function" ? _def.shape() : _def.shape;
|
|
7979
|
+
const properties = {};
|
|
7980
|
+
const required = [];
|
|
7981
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
7982
|
+
properties[key] = ZodToJsonSchema(value);
|
|
7983
|
+
const valueDef = value._def;
|
|
7984
|
+
if ((valueDef == null ? void 0 : valueDef.typeName) !== "ZodOptional") {
|
|
7985
|
+
required.push(key);
|
|
7986
|
+
}
|
|
7987
|
+
}
|
|
7988
|
+
return {
|
|
7989
|
+
type: "object",
|
|
7990
|
+
properties,
|
|
7991
|
+
required,
|
|
7992
|
+
additionalProperties: _def.unknownKeys === "passthrough"
|
|
7993
|
+
};
|
|
7994
|
+
}
|
|
7995
|
+
case "ZodArray": {
|
|
7996
|
+
const itemType = _def.type;
|
|
7997
|
+
return {
|
|
7998
|
+
type: "array",
|
|
7999
|
+
items: ZodToJsonSchema(itemType)
|
|
8000
|
+
};
|
|
8001
|
+
}
|
|
8002
|
+
case "ZodString": {
|
|
8003
|
+
const result = { type: "string" };
|
|
8004
|
+
const checks = _def.checks;
|
|
8005
|
+
if (checks) {
|
|
8006
|
+
for (const check of checks) {
|
|
8007
|
+
if (check.kind === "url") {
|
|
8008
|
+
result.format = "url";
|
|
8009
|
+
break;
|
|
8010
|
+
}
|
|
8011
|
+
}
|
|
8012
|
+
}
|
|
8013
|
+
return result;
|
|
8014
|
+
}
|
|
8015
|
+
case "ZodNumber":
|
|
8016
|
+
return { type: "number" };
|
|
8017
|
+
case "ZodBoolean":
|
|
8018
|
+
return { type: "boolean" };
|
|
8019
|
+
case "ZodOptional":
|
|
8020
|
+
return ZodToJsonSchema(_def.innerType);
|
|
8021
|
+
case "ZodNullable": {
|
|
8022
|
+
const innerSchema = ZodToJsonSchema(_def.innerType);
|
|
8023
|
+
return __spreadProps(__spreadValues({}, innerSchema), {
|
|
8024
|
+
nullable: true
|
|
8025
|
+
});
|
|
8026
|
+
}
|
|
8027
|
+
case "ZodEnum":
|
|
8028
|
+
return {
|
|
8029
|
+
type: "string",
|
|
8030
|
+
enum: _def.values
|
|
8031
|
+
};
|
|
8032
|
+
case "ZodLiteral":
|
|
8033
|
+
return {
|
|
8034
|
+
type: typeof _def.value,
|
|
8035
|
+
const: _def.value
|
|
8036
|
+
};
|
|
8037
|
+
case "ZodUnion":
|
|
8038
|
+
return {
|
|
8039
|
+
anyOf: _def.options.map((opt) => ZodToJsonSchema(opt))
|
|
8040
|
+
};
|
|
8041
|
+
default:
|
|
8042
|
+
console.warn(`Unknown Zod type: ${typeName}`);
|
|
8043
|
+
return { type: "null" };
|
|
8044
|
+
}
|
|
8045
|
+
}
|
|
8046
|
+
function toJsonSchema(schema) {
|
|
8047
|
+
if (!isZod4Schema(schema)) {
|
|
8048
|
+
const result = __spreadValues({
|
|
8049
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
8050
|
+
}, ZodToJsonSchema(schema));
|
|
8051
|
+
return result;
|
|
8052
|
+
}
|
|
8053
|
+
const zodWithJsonSchema = import_zod.z;
|
|
8054
|
+
if (zodWithJsonSchema.toJSONSchema) {
|
|
8055
|
+
return zodWithJsonSchema.toJSONSchema(schema);
|
|
8056
|
+
}
|
|
8057
|
+
throw new Error("Zod v4 toJSONSchema method not found");
|
|
8058
|
+
}
|
|
8059
|
+
|
|
8060
|
+
// lib/utils.ts
|
|
7961
8061
|
var ID_PATTERN = /^\d+-\d+$/;
|
|
8062
|
+
var zFactories = {
|
|
8063
|
+
v4: import_zod2.z,
|
|
8064
|
+
v3: import_v3.default
|
|
8065
|
+
};
|
|
8066
|
+
function getZFactory(schema) {
|
|
8067
|
+
return isZod4Schema(schema) ? zFactories.v4 : zFactories.v3;
|
|
8068
|
+
}
|
|
8069
|
+
var TYPE_NAME_MAP = {
|
|
8070
|
+
ZodString: "string",
|
|
8071
|
+
string: "string",
|
|
8072
|
+
ZodNumber: "number",
|
|
8073
|
+
number: "number",
|
|
8074
|
+
ZodBoolean: "boolean",
|
|
8075
|
+
boolean: "boolean",
|
|
8076
|
+
ZodObject: "object",
|
|
8077
|
+
object: "object",
|
|
8078
|
+
ZodArray: "array",
|
|
8079
|
+
array: "array",
|
|
8080
|
+
ZodUnion: "union",
|
|
8081
|
+
union: "union",
|
|
8082
|
+
ZodIntersection: "intersection",
|
|
8083
|
+
intersection: "intersection",
|
|
8084
|
+
ZodOptional: "optional",
|
|
8085
|
+
optional: "optional",
|
|
8086
|
+
ZodNullable: "nullable",
|
|
8087
|
+
nullable: "nullable",
|
|
8088
|
+
ZodLiteral: "literal",
|
|
8089
|
+
literal: "literal",
|
|
8090
|
+
ZodEnum: "enum",
|
|
8091
|
+
enum: "enum",
|
|
8092
|
+
ZodDefault: "default",
|
|
8093
|
+
default: "default",
|
|
8094
|
+
ZodEffects: "effects",
|
|
8095
|
+
effects: "effects",
|
|
8096
|
+
pipe: "pipe"
|
|
8097
|
+
};
|
|
8098
|
+
function getZ4Def(schema) {
|
|
8099
|
+
var _a;
|
|
8100
|
+
return (_a = schema._zod) == null ? void 0 : _a.def;
|
|
8101
|
+
}
|
|
8102
|
+
function getZ4Bag(schema) {
|
|
8103
|
+
var _a;
|
|
8104
|
+
return (_a = schema._zod) == null ? void 0 : _a.bag;
|
|
8105
|
+
}
|
|
8106
|
+
function getZ3Def(schema) {
|
|
8107
|
+
return schema._def;
|
|
8108
|
+
}
|
|
8109
|
+
function getObjectShape(schema) {
|
|
8110
|
+
var _a, _b;
|
|
8111
|
+
const z4Shape = (_a = getZ4Def(schema)) == null ? void 0 : _a.shape;
|
|
8112
|
+
if (z4Shape) {
|
|
8113
|
+
return z4Shape;
|
|
8114
|
+
}
|
|
8115
|
+
const z3Shape = (_b = getZ3Def(schema)) == null ? void 0 : _b.shape;
|
|
8116
|
+
if (!z3Shape) {
|
|
8117
|
+
return void 0;
|
|
8118
|
+
}
|
|
8119
|
+
if (typeof z3Shape === "function") {
|
|
8120
|
+
return z3Shape();
|
|
8121
|
+
}
|
|
8122
|
+
return z3Shape;
|
|
8123
|
+
}
|
|
8124
|
+
function getArrayElement(schema) {
|
|
8125
|
+
var _a, _b, _c;
|
|
8126
|
+
return (_c = (_a = getZ4Def(schema)) == null ? void 0 : _a.element) != null ? _c : (_b = getZ3Def(schema)) == null ? void 0 : _b.type;
|
|
8127
|
+
}
|
|
8128
|
+
function getInnerType(schema) {
|
|
8129
|
+
var _a, _b, _c;
|
|
8130
|
+
return (_c = (_a = getZ4Def(schema)) == null ? void 0 : _a.innerType) != null ? _c : (_b = getZ3Def(schema)) == null ? void 0 : _b.innerType;
|
|
8131
|
+
}
|
|
8132
|
+
function getUnionOptions(schema) {
|
|
8133
|
+
var _a, _b;
|
|
8134
|
+
const z4Options = (_a = getZ4Def(schema)) == null ? void 0 : _a.options;
|
|
8135
|
+
if (Array.isArray(z4Options)) {
|
|
8136
|
+
return z4Options;
|
|
8137
|
+
}
|
|
8138
|
+
const z3Options = (_b = getZ3Def(schema)) == null ? void 0 : _b.options;
|
|
8139
|
+
return Array.isArray(z3Options) ? z3Options : void 0;
|
|
8140
|
+
}
|
|
8141
|
+
function getIntersectionSides(schema) {
|
|
8142
|
+
const z4Def = getZ4Def(schema);
|
|
8143
|
+
if ((z4Def == null ? void 0 : z4Def.left) || (z4Def == null ? void 0 : z4Def.right)) {
|
|
8144
|
+
return {
|
|
8145
|
+
left: z4Def == null ? void 0 : z4Def.left,
|
|
8146
|
+
right: z4Def == null ? void 0 : z4Def.right
|
|
8147
|
+
};
|
|
8148
|
+
}
|
|
8149
|
+
const z3Def = getZ3Def(schema);
|
|
8150
|
+
return {
|
|
8151
|
+
left: z3Def == null ? void 0 : z3Def.left,
|
|
8152
|
+
right: z3Def == null ? void 0 : z3Def.right
|
|
8153
|
+
};
|
|
8154
|
+
}
|
|
8155
|
+
function getEnumValues(schema) {
|
|
8156
|
+
var _a, _b;
|
|
8157
|
+
const z4Entries = (_a = getZ4Def(schema)) == null ? void 0 : _a.entries;
|
|
8158
|
+
if (z4Entries && typeof z4Entries === "object") {
|
|
8159
|
+
return Object.values(z4Entries);
|
|
8160
|
+
}
|
|
8161
|
+
const z3Values = (_b = getZ3Def(schema)) == null ? void 0 : _b.values;
|
|
8162
|
+
return Array.isArray(z3Values) ? z3Values : void 0;
|
|
8163
|
+
}
|
|
8164
|
+
function getLiteralValues(schema) {
|
|
8165
|
+
var _a, _b;
|
|
8166
|
+
const z4Values = (_a = getZ4Def(schema)) == null ? void 0 : _a.values;
|
|
8167
|
+
if (Array.isArray(z4Values)) {
|
|
8168
|
+
return z4Values;
|
|
8169
|
+
}
|
|
8170
|
+
const value = (_b = getZ3Def(schema)) == null ? void 0 : _b.value;
|
|
8171
|
+
return typeof value !== "undefined" ? [value] : [];
|
|
8172
|
+
}
|
|
8173
|
+
function getStringChecks(schema) {
|
|
8174
|
+
var _a, _b;
|
|
8175
|
+
const z4Checks = (_a = getZ4Def(schema)) == null ? void 0 : _a.checks;
|
|
8176
|
+
if (Array.isArray(z4Checks)) {
|
|
8177
|
+
return z4Checks;
|
|
8178
|
+
}
|
|
8179
|
+
const z3Checks = (_b = getZ3Def(schema)) == null ? void 0 : _b.checks;
|
|
8180
|
+
return Array.isArray(z3Checks) ? z3Checks : [];
|
|
8181
|
+
}
|
|
8182
|
+
function getStringFormat(schema) {
|
|
8183
|
+
var _a, _b, _c;
|
|
8184
|
+
const bagFormat = (_a = getZ4Bag(schema)) == null ? void 0 : _a.format;
|
|
8185
|
+
if (typeof bagFormat === "string") {
|
|
8186
|
+
return bagFormat;
|
|
8187
|
+
}
|
|
8188
|
+
const z4Format = (_b = getZ4Def(schema)) == null ? void 0 : _b.format;
|
|
8189
|
+
if (typeof z4Format === "string") {
|
|
8190
|
+
return z4Format;
|
|
8191
|
+
}
|
|
8192
|
+
const z3Format = (_c = getZ3Def(schema)) == null ? void 0 : _c.format;
|
|
8193
|
+
return typeof z3Format === "string" ? z3Format : void 0;
|
|
8194
|
+
}
|
|
8195
|
+
function getPipeEndpoints(schema) {
|
|
8196
|
+
const z4Def = getZ4Def(schema);
|
|
8197
|
+
if ((z4Def == null ? void 0 : z4Def.in) || (z4Def == null ? void 0 : z4Def.out)) {
|
|
8198
|
+
return {
|
|
8199
|
+
in: z4Def == null ? void 0 : z4Def.in,
|
|
8200
|
+
out: z4Def == null ? void 0 : z4Def.out
|
|
8201
|
+
};
|
|
8202
|
+
}
|
|
8203
|
+
return {};
|
|
8204
|
+
}
|
|
8205
|
+
function getEffectsBaseSchema(schema) {
|
|
8206
|
+
var _a;
|
|
8207
|
+
return (_a = getZ3Def(schema)) == null ? void 0 : _a.schema;
|
|
8208
|
+
}
|
|
7962
8209
|
function validateZodSchema(schema, data) {
|
|
7963
8210
|
const result = schema.safeParse(data);
|
|
7964
8211
|
if (result.success) {
|
|
@@ -7979,152 +8226,150 @@ function decorateGeminiSchema(geminiSchema, zodSchema2) {
|
|
|
7979
8226
|
return geminiSchema;
|
|
7980
8227
|
}
|
|
7981
8228
|
function toGeminiSchema(zodSchema2) {
|
|
8229
|
+
var _a, _b;
|
|
8230
|
+
const normalizedSchema = zodSchema2;
|
|
7982
8231
|
const zodType = getZodType(zodSchema2);
|
|
7983
8232
|
switch (zodType) {
|
|
7984
8233
|
case "array": {
|
|
7985
|
-
const
|
|
7986
|
-
const element = arraySchema._zod.def.element;
|
|
8234
|
+
const element = (_a = getArrayElement(zodSchema2)) != null ? _a : import_zod2.z.any();
|
|
7987
8235
|
return decorateGeminiSchema(
|
|
7988
8236
|
{
|
|
7989
8237
|
type: import_genai.Type.ARRAY,
|
|
7990
|
-
items: toGeminiSchema(element
|
|
8238
|
+
items: toGeminiSchema(element)
|
|
7991
8239
|
},
|
|
7992
|
-
|
|
8240
|
+
normalizedSchema
|
|
7993
8241
|
);
|
|
7994
8242
|
}
|
|
7995
8243
|
case "object": {
|
|
7996
8244
|
const properties = {};
|
|
7997
8245
|
const required = [];
|
|
7998
|
-
const
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8246
|
+
const shape = getObjectShape(zodSchema2);
|
|
8247
|
+
if (shape) {
|
|
8248
|
+
Object.entries(shape).forEach(
|
|
8249
|
+
([key, value]) => {
|
|
8250
|
+
properties[key] = toGeminiSchema(value);
|
|
8251
|
+
if (getZodType(value) !== "optional") {
|
|
8252
|
+
required.push(key);
|
|
8253
|
+
}
|
|
8254
|
+
}
|
|
8255
|
+
);
|
|
8256
|
+
}
|
|
8006
8257
|
return decorateGeminiSchema(
|
|
8007
8258
|
{
|
|
8008
8259
|
type: import_genai.Type.OBJECT,
|
|
8009
8260
|
properties,
|
|
8010
8261
|
required: required.length > 0 ? required : void 0
|
|
8011
8262
|
},
|
|
8012
|
-
|
|
8263
|
+
normalizedSchema
|
|
8013
8264
|
);
|
|
8014
8265
|
}
|
|
8015
8266
|
case "string":
|
|
8016
|
-
case "url":
|
|
8017
8267
|
return decorateGeminiSchema(
|
|
8018
8268
|
{
|
|
8019
8269
|
type: import_genai.Type.STRING
|
|
8020
8270
|
},
|
|
8021
|
-
|
|
8271
|
+
normalizedSchema
|
|
8022
8272
|
);
|
|
8023
8273
|
case "number":
|
|
8024
8274
|
return decorateGeminiSchema(
|
|
8025
8275
|
{
|
|
8026
8276
|
type: import_genai.Type.NUMBER
|
|
8027
8277
|
},
|
|
8028
|
-
|
|
8278
|
+
normalizedSchema
|
|
8029
8279
|
);
|
|
8030
8280
|
case "boolean":
|
|
8031
8281
|
return decorateGeminiSchema(
|
|
8032
8282
|
{
|
|
8033
8283
|
type: import_genai.Type.BOOLEAN
|
|
8034
8284
|
},
|
|
8035
|
-
|
|
8285
|
+
normalizedSchema
|
|
8036
8286
|
);
|
|
8037
8287
|
case "enum": {
|
|
8038
|
-
const
|
|
8039
|
-
const values = Object.values(enumSchema._zod.def.entries);
|
|
8288
|
+
const values = getEnumValues(zodSchema2);
|
|
8040
8289
|
return decorateGeminiSchema(
|
|
8041
8290
|
{
|
|
8042
8291
|
type: import_genai.Type.STRING,
|
|
8043
8292
|
enum: values
|
|
8044
8293
|
},
|
|
8045
|
-
|
|
8294
|
+
normalizedSchema
|
|
8046
8295
|
);
|
|
8047
8296
|
}
|
|
8048
8297
|
case "default":
|
|
8049
8298
|
case "nullable":
|
|
8050
8299
|
case "optional": {
|
|
8051
|
-
const
|
|
8052
|
-
const innerType = wrapperSchema._zod.def.innerType;
|
|
8300
|
+
const innerType = (_b = getInnerType(zodSchema2)) != null ? _b : import_zod2.z.any();
|
|
8053
8301
|
const innerSchema = toGeminiSchema(innerType);
|
|
8054
8302
|
return decorateGeminiSchema(
|
|
8055
8303
|
__spreadProps(__spreadValues({}, innerSchema), {
|
|
8056
8304
|
nullable: true
|
|
8057
8305
|
}),
|
|
8058
|
-
|
|
8306
|
+
normalizedSchema
|
|
8059
8307
|
);
|
|
8060
8308
|
}
|
|
8061
8309
|
case "literal": {
|
|
8062
|
-
const
|
|
8063
|
-
const values = literalSchema._zod.def.values;
|
|
8310
|
+
const values = getLiteralValues(zodSchema2);
|
|
8064
8311
|
return decorateGeminiSchema(
|
|
8065
8312
|
{
|
|
8066
8313
|
type: import_genai.Type.STRING,
|
|
8067
8314
|
enum: values
|
|
8068
8315
|
},
|
|
8069
|
-
|
|
8316
|
+
normalizedSchema
|
|
8070
8317
|
);
|
|
8071
8318
|
}
|
|
8072
8319
|
case "pipe": {
|
|
8073
|
-
const
|
|
8074
|
-
|
|
8075
|
-
|
|
8320
|
+
const endpoints = getPipeEndpoints(zodSchema2);
|
|
8321
|
+
if (endpoints.in) {
|
|
8322
|
+
return toGeminiSchema(endpoints.in);
|
|
8323
|
+
}
|
|
8324
|
+
return decorateGeminiSchema(
|
|
8325
|
+
{
|
|
8326
|
+
type: import_genai.Type.STRING
|
|
8327
|
+
},
|
|
8328
|
+
normalizedSchema
|
|
8329
|
+
);
|
|
8076
8330
|
}
|
|
8077
8331
|
// Standalone transforms and any unknown types fall through to default
|
|
8078
8332
|
default:
|
|
8079
8333
|
return decorateGeminiSchema(
|
|
8080
8334
|
{
|
|
8081
|
-
type: import_genai.Type.
|
|
8082
|
-
nullable: true
|
|
8335
|
+
type: import_genai.Type.STRING
|
|
8083
8336
|
},
|
|
8084
|
-
|
|
8337
|
+
normalizedSchema
|
|
8085
8338
|
);
|
|
8086
8339
|
}
|
|
8087
8340
|
}
|
|
8088
8341
|
function getZodType(schema) {
|
|
8089
|
-
var _a, _b;
|
|
8342
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8090
8343
|
const schemaWithDef = schema;
|
|
8091
|
-
|
|
8092
|
-
|
|
8344
|
+
const rawType = (_f = (_d = (_b = (_a = schemaWithDef._zod) == null ? void 0 : _a.def) == null ? void 0 : _b.type) != null ? _d : (_c = schemaWithDef._def) == null ? void 0 : _c.typeName) != null ? _f : (_e = schemaWithDef._def) == null ? void 0 : _e.type;
|
|
8345
|
+
if (!rawType) {
|
|
8346
|
+
return "unknown";
|
|
8093
8347
|
}
|
|
8094
|
-
|
|
8095
|
-
`Unable to determine Zod schema type. Schema: ${JSON.stringify(schema)}`
|
|
8096
|
-
);
|
|
8348
|
+
return (_g = TYPE_NAME_MAP[rawType]) != null ? _g : rawType;
|
|
8097
8349
|
}
|
|
8098
8350
|
function transformSchema(schema, currentPath) {
|
|
8099
|
-
var _a, _b;
|
|
8100
|
-
if (isKind(schema, "url")) {
|
|
8101
|
-
const transformed = makeIdStringSchema(schema);
|
|
8102
|
-
return [transformed, [{ segments: [] }]];
|
|
8103
|
-
}
|
|
8104
8351
|
if (isKind(schema, "string")) {
|
|
8105
|
-
const
|
|
8106
|
-
const
|
|
8107
|
-
const
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
return ((
|
|
8111
|
-
})
|
|
8352
|
+
const checks = getStringChecks(schema);
|
|
8353
|
+
const format = getStringFormat(schema);
|
|
8354
|
+
const hasUrlCheck = checks.some((check) => {
|
|
8355
|
+
var _a, _b, _c, _d;
|
|
8356
|
+
const candidate = check;
|
|
8357
|
+
return candidate.kind === "url" || candidate.format === "url" || ((_b = (_a = candidate._zod) == null ? void 0 : _a.def) == null ? void 0 : _b.check) === "url" || ((_d = (_c = candidate._zod) == null ? void 0 : _c.def) == null ? void 0 : _d.format) === "url";
|
|
8358
|
+
}) || format === "url";
|
|
8112
8359
|
if (hasUrlCheck) {
|
|
8113
8360
|
return [makeIdStringSchema(schema), [{ segments: [] }]];
|
|
8114
8361
|
}
|
|
8115
8362
|
return [schema, []];
|
|
8116
8363
|
}
|
|
8117
8364
|
if (isKind(schema, "object")) {
|
|
8118
|
-
const
|
|
8119
|
-
const shape = objectSchema._zod.def.shape;
|
|
8365
|
+
const shape = getObjectShape(schema);
|
|
8120
8366
|
if (!shape) {
|
|
8121
8367
|
return [schema, []];
|
|
8122
8368
|
}
|
|
8123
8369
|
const newShape = {};
|
|
8124
8370
|
const urlPaths = [];
|
|
8125
8371
|
let changed = false;
|
|
8126
|
-
const
|
|
8127
|
-
for (const key of shapeKeys) {
|
|
8372
|
+
for (const key of Object.keys(shape)) {
|
|
8128
8373
|
const child = shape[key];
|
|
8129
8374
|
const [transformedChild, childPaths] = transformSchema(child, [
|
|
8130
8375
|
...currentPath,
|
|
@@ -8134,21 +8379,21 @@ function transformSchema(schema, currentPath) {
|
|
|
8134
8379
|
changed = true;
|
|
8135
8380
|
}
|
|
8136
8381
|
newShape[key] = transformedChild;
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
}
|
|
8141
|
-
}
|
|
8382
|
+
childPaths.forEach((cp) => {
|
|
8383
|
+
urlPaths.push({ segments: [key, ...cp.segments] });
|
|
8384
|
+
});
|
|
8142
8385
|
}
|
|
8143
8386
|
if (changed) {
|
|
8144
|
-
const
|
|
8145
|
-
return [
|
|
8387
|
+
const factory6 = getZFactory(schema);
|
|
8388
|
+
return [
|
|
8389
|
+
factory6.object(newShape),
|
|
8390
|
+
urlPaths
|
|
8391
|
+
];
|
|
8146
8392
|
}
|
|
8147
8393
|
return [schema, urlPaths];
|
|
8148
8394
|
}
|
|
8149
8395
|
if (isKind(schema, "array")) {
|
|
8150
|
-
const
|
|
8151
|
-
const itemType = arraySchema._zod.def.element;
|
|
8396
|
+
const itemType = getArrayElement(schema);
|
|
8152
8397
|
if (!itemType) {
|
|
8153
8398
|
return [schema, []];
|
|
8154
8399
|
}
|
|
@@ -8156,19 +8401,20 @@ function transformSchema(schema, currentPath) {
|
|
|
8156
8401
|
...currentPath,
|
|
8157
8402
|
"*"
|
|
8158
8403
|
]);
|
|
8159
|
-
const changed = transformedItem !== itemType;
|
|
8160
8404
|
const arrayPaths = childPaths.map((cp) => ({
|
|
8161
8405
|
segments: ["*", ...cp.segments]
|
|
8162
8406
|
}));
|
|
8163
|
-
if (
|
|
8164
|
-
const
|
|
8165
|
-
return [
|
|
8407
|
+
if (transformedItem !== itemType) {
|
|
8408
|
+
const factory6 = getZFactory(schema);
|
|
8409
|
+
return [
|
|
8410
|
+
factory6.array(transformedItem),
|
|
8411
|
+
arrayPaths
|
|
8412
|
+
];
|
|
8166
8413
|
}
|
|
8167
8414
|
return [schema, arrayPaths];
|
|
8168
8415
|
}
|
|
8169
8416
|
if (isKind(schema, "union")) {
|
|
8170
|
-
const
|
|
8171
|
-
const unionOptions = unionSchema._zod.def.options;
|
|
8417
|
+
const unionOptions = getUnionOptions(schema);
|
|
8172
8418
|
if (!unionOptions || unionOptions.length === 0) {
|
|
8173
8419
|
return [schema, []];
|
|
8174
8420
|
}
|
|
@@ -8187,76 +8433,95 @@ function transformSchema(schema, currentPath) {
|
|
|
8187
8433
|
allPaths = [...allPaths, ...childPaths];
|
|
8188
8434
|
});
|
|
8189
8435
|
if (changed) {
|
|
8436
|
+
const factory6 = getZFactory(schema);
|
|
8190
8437
|
return [
|
|
8191
|
-
|
|
8438
|
+
factory6.union(
|
|
8439
|
+
newOptions
|
|
8440
|
+
),
|
|
8192
8441
|
allPaths
|
|
8193
8442
|
];
|
|
8194
8443
|
}
|
|
8195
8444
|
return [schema, allPaths];
|
|
8196
8445
|
}
|
|
8197
8446
|
if (isKind(schema, "intersection")) {
|
|
8198
|
-
const
|
|
8199
|
-
|
|
8200
|
-
const rightType = intersectionSchema._zod.def.right;
|
|
8201
|
-
if (!leftType || !rightType) {
|
|
8447
|
+
const { left, right } = getIntersectionSides(schema);
|
|
8448
|
+
if (!left || !right) {
|
|
8202
8449
|
return [schema, []];
|
|
8203
8450
|
}
|
|
8204
|
-
const [
|
|
8451
|
+
const [newLeft, leftPaths] = transformSchema(left, [
|
|
8205
8452
|
...currentPath,
|
|
8206
8453
|
"intersection_left"
|
|
8207
8454
|
]);
|
|
8208
|
-
const [
|
|
8455
|
+
const [newRight, rightPaths] = transformSchema(right, [
|
|
8209
8456
|
...currentPath,
|
|
8210
8457
|
"intersection_right"
|
|
8211
8458
|
]);
|
|
8212
|
-
const changed =
|
|
8459
|
+
const changed = newLeft !== left || newRight !== right;
|
|
8213
8460
|
const allPaths = [...leftPaths, ...rightPaths];
|
|
8214
8461
|
if (changed) {
|
|
8215
|
-
|
|
8462
|
+
const factory6 = getZFactory(schema);
|
|
8463
|
+
return [
|
|
8464
|
+
factory6.intersection(
|
|
8465
|
+
newLeft,
|
|
8466
|
+
newRight
|
|
8467
|
+
),
|
|
8468
|
+
allPaths
|
|
8469
|
+
];
|
|
8216
8470
|
}
|
|
8217
8471
|
return [schema, allPaths];
|
|
8218
8472
|
}
|
|
8219
8473
|
if (isKind(schema, "optional")) {
|
|
8220
|
-
const
|
|
8221
|
-
const innerType = optionalSchema._zod.def.innerType;
|
|
8474
|
+
const innerType = getInnerType(schema);
|
|
8222
8475
|
if (!innerType) {
|
|
8223
8476
|
return [schema, []];
|
|
8224
8477
|
}
|
|
8225
8478
|
const [inner, innerPaths] = transformSchema(innerType, currentPath);
|
|
8226
8479
|
if (inner !== innerType) {
|
|
8227
|
-
return [
|
|
8480
|
+
return [
|
|
8481
|
+
inner.optional(),
|
|
8482
|
+
innerPaths
|
|
8483
|
+
];
|
|
8228
8484
|
}
|
|
8229
8485
|
return [schema, innerPaths];
|
|
8230
8486
|
}
|
|
8231
8487
|
if (isKind(schema, "nullable")) {
|
|
8232
|
-
const
|
|
8233
|
-
const innerType = nullableSchema._zod.def.innerType;
|
|
8488
|
+
const innerType = getInnerType(schema);
|
|
8234
8489
|
if (!innerType) {
|
|
8235
8490
|
return [schema, []];
|
|
8236
8491
|
}
|
|
8237
8492
|
const [inner, innerPaths] = transformSchema(innerType, currentPath);
|
|
8238
8493
|
if (inner !== innerType) {
|
|
8239
|
-
return [
|
|
8494
|
+
return [
|
|
8495
|
+
inner.nullable(),
|
|
8496
|
+
innerPaths
|
|
8497
|
+
];
|
|
8240
8498
|
}
|
|
8241
8499
|
return [schema, innerPaths];
|
|
8242
8500
|
}
|
|
8243
|
-
if (isKind(schema, "pipe")) {
|
|
8244
|
-
const
|
|
8245
|
-
const inSchema = pipeSchema._zod.def.in;
|
|
8246
|
-
const outSchema = pipeSchema._zod.def.out;
|
|
8501
|
+
if (isKind(schema, "pipe") && isZod4Schema(schema)) {
|
|
8502
|
+
const { in: inSchema, out: outSchema } = getPipeEndpoints(schema);
|
|
8247
8503
|
if (!inSchema || !outSchema) {
|
|
8248
8504
|
return [schema, []];
|
|
8249
8505
|
}
|
|
8250
8506
|
const [newIn, inPaths] = transformSchema(inSchema, currentPath);
|
|
8251
8507
|
const [newOut, outPaths] = transformSchema(outSchema, currentPath);
|
|
8252
8508
|
const allPaths = [...inPaths, ...outPaths];
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8509
|
+
if (newIn !== inSchema || newOut !== outSchema) {
|
|
8510
|
+
const result = import_zod2.z.pipe(
|
|
8511
|
+
newIn,
|
|
8512
|
+
newOut
|
|
8513
|
+
);
|
|
8256
8514
|
return [result, allPaths];
|
|
8257
8515
|
}
|
|
8258
8516
|
return [schema, allPaths];
|
|
8259
8517
|
}
|
|
8518
|
+
if (isKind(schema, "effects")) {
|
|
8519
|
+
const baseSchema = getEffectsBaseSchema(schema);
|
|
8520
|
+
if (!baseSchema) {
|
|
8521
|
+
return [schema, []];
|
|
8522
|
+
}
|
|
8523
|
+
return transformSchema(baseSchema, currentPath);
|
|
8524
|
+
}
|
|
8260
8525
|
return [schema, []];
|
|
8261
8526
|
}
|
|
8262
8527
|
function injectUrls(obj, path7, idToUrlMapping) {
|
|
@@ -8312,7 +8577,8 @@ function makeIdStringSchema(orig) {
|
|
|
8312
8577
|
const userDesc = (_a = orig.description) != null ? _a : "";
|
|
8313
8578
|
const base = `This field must be the element-ID in the form 'frameId-backendId' (e.g. "0-432").`;
|
|
8314
8579
|
const composed = userDesc.trim().length > 0 ? `${base} that follows this user-defined description: ${userDesc}` : base;
|
|
8315
|
-
|
|
8580
|
+
const factory6 = getZFactory(orig);
|
|
8581
|
+
return factory6.string().regex(ID_PATTERN).describe(composed);
|
|
8316
8582
|
}
|
|
8317
8583
|
var providerEnvVarMap = {
|
|
8318
8584
|
openai: "OPENAI_API_KEY",
|
|
@@ -8358,7 +8624,7 @@ function jsonSchemaToZod(schema) {
|
|
|
8358
8624
|
for (const key in schema.properties) {
|
|
8359
8625
|
shape[key] = jsonSchemaToZod(schema.properties[key]);
|
|
8360
8626
|
}
|
|
8361
|
-
let zodObject =
|
|
8627
|
+
let zodObject = import_zod2.z.object(shape);
|
|
8362
8628
|
if (schema.required && Array.isArray(schema.required)) {
|
|
8363
8629
|
const requiredFields = schema.required.reduce(
|
|
8364
8630
|
(acc, field) => __spreadProps(__spreadValues({}, acc), { [field]: true }),
|
|
@@ -8371,30 +8637,37 @@ function jsonSchemaToZod(schema) {
|
|
|
8371
8637
|
}
|
|
8372
8638
|
return zodObject;
|
|
8373
8639
|
} else {
|
|
8374
|
-
return
|
|
8640
|
+
return import_zod2.z.object({});
|
|
8375
8641
|
}
|
|
8376
8642
|
case "array":
|
|
8377
8643
|
if (schema.items) {
|
|
8378
|
-
let zodArray =
|
|
8644
|
+
let zodArray = import_zod2.z.array(jsonSchemaToZod(schema.items));
|
|
8379
8645
|
if (schema.description) {
|
|
8380
8646
|
zodArray = zodArray.describe(schema.description);
|
|
8381
8647
|
}
|
|
8382
8648
|
return zodArray;
|
|
8383
8649
|
} else {
|
|
8384
|
-
return
|
|
8650
|
+
return import_zod2.z.array(import_zod2.z.any());
|
|
8385
8651
|
}
|
|
8386
8652
|
case "string": {
|
|
8387
8653
|
if (schema.enum) {
|
|
8388
|
-
return
|
|
8654
|
+
return import_zod2.z.string().refine((val) => schema.enum.includes(val));
|
|
8655
|
+
}
|
|
8656
|
+
let zodString = import_zod2.z.string();
|
|
8657
|
+
if (schema.format === "uri" || schema.format === "url") {
|
|
8658
|
+
zodString = zodString.url();
|
|
8659
|
+
} else if (schema.format === "email") {
|
|
8660
|
+
zodString = zodString.email();
|
|
8661
|
+
} else if (schema.format === "uuid") {
|
|
8662
|
+
zodString = zodString.uuid();
|
|
8389
8663
|
}
|
|
8390
|
-
let zodString = import_zod.z.string();
|
|
8391
8664
|
if (schema.description) {
|
|
8392
8665
|
zodString = zodString.describe(schema.description);
|
|
8393
8666
|
}
|
|
8394
8667
|
return zodString;
|
|
8395
8668
|
}
|
|
8396
8669
|
case "number": {
|
|
8397
|
-
let zodNumber =
|
|
8670
|
+
let zodNumber = import_zod2.z.number();
|
|
8398
8671
|
if (schema.minimum !== void 0) {
|
|
8399
8672
|
zodNumber = zodNumber.min(schema.minimum);
|
|
8400
8673
|
}
|
|
@@ -8407,14 +8680,14 @@ function jsonSchemaToZod(schema) {
|
|
|
8407
8680
|
return zodNumber;
|
|
8408
8681
|
}
|
|
8409
8682
|
case "boolean": {
|
|
8410
|
-
let zodBoolean =
|
|
8683
|
+
let zodBoolean = import_zod2.z.boolean();
|
|
8411
8684
|
if (schema.description) {
|
|
8412
8685
|
zodBoolean = zodBoolean.describe(schema.description);
|
|
8413
8686
|
}
|
|
8414
8687
|
return zodBoolean;
|
|
8415
8688
|
}
|
|
8416
8689
|
default:
|
|
8417
|
-
return
|
|
8690
|
+
return import_zod2.z.any();
|
|
8418
8691
|
}
|
|
8419
8692
|
}
|
|
8420
8693
|
|
|
@@ -9416,7 +9689,7 @@ var CacheStorage = class _CacheStorage {
|
|
|
9416
9689
|
};
|
|
9417
9690
|
|
|
9418
9691
|
// lib/inference.ts
|
|
9419
|
-
var
|
|
9692
|
+
var import_zod3 = require("zod");
|
|
9420
9693
|
|
|
9421
9694
|
// lib/prompt.ts
|
|
9422
9695
|
function buildUserInstructionsString(userProvidedInstructions) {
|
|
@@ -9675,11 +9948,11 @@ function extract(_0) {
|
|
|
9675
9948
|
logInferenceToFile = false
|
|
9676
9949
|
}) {
|
|
9677
9950
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
9678
|
-
const metadataSchema =
|
|
9679
|
-
progress:
|
|
9951
|
+
const metadataSchema = import_zod3.z.object({
|
|
9952
|
+
progress: import_zod3.z.string().describe(
|
|
9680
9953
|
"progress of what has been extracted so far, as concise as possible"
|
|
9681
9954
|
),
|
|
9682
|
-
completed:
|
|
9955
|
+
completed: import_zod3.z.boolean().describe(
|
|
9683
9956
|
"true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed."
|
|
9684
9957
|
)
|
|
9685
9958
|
});
|
|
@@ -9837,20 +10110,20 @@ function observe(_0) {
|
|
|
9837
10110
|
}) {
|
|
9838
10111
|
var _a, _b, _c, _d, _e, _f;
|
|
9839
10112
|
const isGPT5 = llmClient.modelName.includes("gpt-5");
|
|
9840
|
-
const observeSchema =
|
|
9841
|
-
elements:
|
|
9842
|
-
|
|
9843
|
-
elementId:
|
|
10113
|
+
const observeSchema = import_zod3.z.object({
|
|
10114
|
+
elements: import_zod3.z.array(
|
|
10115
|
+
import_zod3.z.object({
|
|
10116
|
+
elementId: import_zod3.z.string().describe(
|
|
9844
10117
|
"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
|
|
9845
10118
|
),
|
|
9846
|
-
description:
|
|
10119
|
+
description: import_zod3.z.string().describe(
|
|
9847
10120
|
"a description of the accessible element and its purpose"
|
|
9848
10121
|
),
|
|
9849
|
-
method:
|
|
10122
|
+
method: import_zod3.z.string().describe(
|
|
9850
10123
|
"the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
|
|
9851
10124
|
),
|
|
9852
|
-
arguments:
|
|
9853
|
-
|
|
10125
|
+
arguments: import_zod3.z.array(
|
|
10126
|
+
import_zod3.z.string().describe(
|
|
9854
10127
|
"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."
|
|
9855
10128
|
)
|
|
9856
10129
|
)
|
|
@@ -9950,20 +10223,20 @@ function act(_0) {
|
|
|
9950
10223
|
}) {
|
|
9951
10224
|
var _a, _b, _c, _d;
|
|
9952
10225
|
const isGPT5 = llmClient.modelName.includes("gpt-5");
|
|
9953
|
-
const actSchema =
|
|
9954
|
-
elementId:
|
|
10226
|
+
const actSchema = import_zod3.z.object({
|
|
10227
|
+
elementId: import_zod3.z.string().describe(
|
|
9955
10228
|
"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
|
|
9956
10229
|
),
|
|
9957
|
-
description:
|
|
9958
|
-
method:
|
|
10230
|
+
description: import_zod3.z.string().describe("a description of the accessible element and its purpose"),
|
|
10231
|
+
method: import_zod3.z.string().describe(
|
|
9959
10232
|
"the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
|
|
9960
10233
|
),
|
|
9961
|
-
arguments:
|
|
9962
|
-
|
|
10234
|
+
arguments: import_zod3.z.array(
|
|
10235
|
+
import_zod3.z.string().describe(
|
|
9963
10236
|
"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."
|
|
9964
10237
|
)
|
|
9965
10238
|
),
|
|
9966
|
-
twoStep:
|
|
10239
|
+
twoStep: import_zod3.z.boolean()
|
|
9967
10240
|
});
|
|
9968
10241
|
const messages = [
|
|
9969
10242
|
buildActSystemPrompt(userProvidedInstructions),
|
|
@@ -10050,12 +10323,12 @@ function act(_0) {
|
|
|
10050
10323
|
init_logger();
|
|
10051
10324
|
|
|
10052
10325
|
// lib/v3/types/public/methods.ts
|
|
10053
|
-
var
|
|
10054
|
-
var defaultExtractSchema =
|
|
10055
|
-
extraction:
|
|
10326
|
+
var import_zod4 = require("zod");
|
|
10327
|
+
var defaultExtractSchema = import_zod4.z.object({
|
|
10328
|
+
extraction: import_zod4.z.string()
|
|
10056
10329
|
});
|
|
10057
|
-
var pageTextSchema =
|
|
10058
|
-
pageText:
|
|
10330
|
+
var pageTextSchema = import_zod4.z.object({
|
|
10331
|
+
pageText: import_zod4.z.string()
|
|
10059
10332
|
});
|
|
10060
10333
|
var V3FunctionName = /* @__PURE__ */ ((V3FunctionName2) => {
|
|
10061
10334
|
V3FunctionName2["ACT"] = "ACT";
|
|
@@ -11069,7 +11342,7 @@ var ActHandler = class {
|
|
|
11069
11342
|
// lib/v3/handlers/extractHandler.ts
|
|
11070
11343
|
init_logger();
|
|
11071
11344
|
init_snapshot();
|
|
11072
|
-
var
|
|
11345
|
+
var import_zod5 = require("zod");
|
|
11073
11346
|
init_sdkErrors();
|
|
11074
11347
|
function transformUrlStringsToNumericIds(schema) {
|
|
11075
11348
|
const [finalSchema, urlPaths] = transformSchema(schema, []);
|
|
@@ -11091,7 +11364,7 @@ var ExtractHandler = class {
|
|
|
11091
11364
|
const { instruction, schema, page, selector, timeout, model } = params;
|
|
11092
11365
|
const llmClient = this.resolveLlmClient(model);
|
|
11093
11366
|
const doExtract = () => __async(this, null, function* () {
|
|
11094
|
-
var _a, _b,
|
|
11367
|
+
var _a, _b, _d;
|
|
11095
11368
|
const noArgs = !instruction && !schema;
|
|
11096
11369
|
if (noArgs) {
|
|
11097
11370
|
const focusSelector2 = (_a = selector == null ? void 0 : selector.replace(/^xpath=/i, "")) != null ? _a : "";
|
|
@@ -11122,9 +11395,11 @@ var ExtractHandler = class {
|
|
|
11122
11395
|
auxiliary: instruction ? { instruction: { value: instruction, type: "string" } } : void 0
|
|
11123
11396
|
});
|
|
11124
11397
|
const baseSchema = schema != null ? schema : defaultExtractSchema;
|
|
11125
|
-
const isObjectSchema =
|
|
11398
|
+
const isObjectSchema = getZodType(baseSchema) === "object";
|
|
11126
11399
|
const WRAP_KEY = "value";
|
|
11127
|
-
const objectSchema = isObjectSchema ? baseSchema :
|
|
11400
|
+
const objectSchema = isObjectSchema ? baseSchema : import_zod5.z.object({
|
|
11401
|
+
[WRAP_KEY]: baseSchema
|
|
11402
|
+
});
|
|
11128
11403
|
const [transformedSchema, urlFieldPaths] = transformUrlStringsToNumericIds(objectSchema);
|
|
11129
11404
|
const extractionResponse = yield extract({
|
|
11130
11405
|
instruction,
|
|
@@ -11135,14 +11410,14 @@ var ExtractHandler = class {
|
|
|
11135
11410
|
logger: v3Logger,
|
|
11136
11411
|
logInferenceToFile: this.logInferenceToFile
|
|
11137
11412
|
});
|
|
11138
|
-
const
|
|
11413
|
+
const _c = extractionResponse, {
|
|
11139
11414
|
metadata: { completed },
|
|
11140
11415
|
prompt_tokens,
|
|
11141
11416
|
completion_tokens,
|
|
11142
11417
|
reasoning_tokens = 0,
|
|
11143
11418
|
cached_input_tokens = 0,
|
|
11144
11419
|
inference_time_ms
|
|
11145
|
-
} =
|
|
11420
|
+
} = _c, rest = __objRest(_c, [
|
|
11146
11421
|
"metadata",
|
|
11147
11422
|
"prompt_tokens",
|
|
11148
11423
|
"completion_tokens",
|
|
@@ -11167,7 +11442,7 @@ var ExtractHandler = class {
|
|
|
11167
11442
|
}
|
|
11168
11443
|
}
|
|
11169
11444
|
});
|
|
11170
|
-
(
|
|
11445
|
+
(_d = this.onMetrics) == null ? void 0 : _d.call(
|
|
11171
11446
|
this,
|
|
11172
11447
|
"EXTRACT" /* EXTRACT */,
|
|
11173
11448
|
prompt_tokens,
|
|
@@ -11192,12 +11467,14 @@ var ExtractHandler = class {
|
|
|
11192
11467
|
if (!timeout) return doExtract();
|
|
11193
11468
|
return yield Promise.race([
|
|
11194
11469
|
doExtract(),
|
|
11195
|
-
new Promise(
|
|
11196
|
-
|
|
11197
|
-
(
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11470
|
+
new Promise(
|
|
11471
|
+
(_, reject) => {
|
|
11472
|
+
setTimeout(
|
|
11473
|
+
() => reject(new Error(`extract() timed out after ${timeout}ms`)),
|
|
11474
|
+
timeout
|
|
11475
|
+
);
|
|
11476
|
+
}
|
|
11477
|
+
)
|
|
11201
11478
|
]);
|
|
11202
11479
|
});
|
|
11203
11480
|
}
|
|
@@ -11321,11 +11598,11 @@ var ObserveHandler = class {
|
|
|
11321
11598
|
|
|
11322
11599
|
// lib/v3/agent/tools/v3-goto.ts
|
|
11323
11600
|
var import_ai = require("ai");
|
|
11324
|
-
var
|
|
11601
|
+
var import_zod6 = require("zod");
|
|
11325
11602
|
var createGotoTool = (v3) => (0, import_ai.tool)({
|
|
11326
11603
|
description: "Navigate to a specific URL",
|
|
11327
|
-
inputSchema:
|
|
11328
|
-
url:
|
|
11604
|
+
inputSchema: import_zod6.z.object({
|
|
11605
|
+
url: import_zod6.z.string().describe("The URL to navigate to")
|
|
11329
11606
|
}),
|
|
11330
11607
|
execute: (_0) => __async(null, [_0], function* ({ url }) {
|
|
11331
11608
|
var _a;
|
|
@@ -11353,11 +11630,11 @@ var createGotoTool = (v3) => (0, import_ai.tool)({
|
|
|
11353
11630
|
|
|
11354
11631
|
// lib/v3/agent/tools/v3-act.ts
|
|
11355
11632
|
var import_ai2 = require("ai");
|
|
11356
|
-
var
|
|
11633
|
+
var import_zod7 = require("zod");
|
|
11357
11634
|
var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
|
|
11358
11635
|
description: "Perform an action on the page (click, type). Provide a short, specific phrase that mentions the element type.",
|
|
11359
|
-
inputSchema:
|
|
11360
|
-
action:
|
|
11636
|
+
inputSchema: import_zod7.z.object({
|
|
11637
|
+
action: import_zod7.z.string().describe(
|
|
11361
11638
|
'Describe what to click or type, e.g. "click the Login button" or "type "John" into the first name input"'
|
|
11362
11639
|
)
|
|
11363
11640
|
}),
|
|
@@ -11398,10 +11675,10 @@ var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
|
|
|
11398
11675
|
|
|
11399
11676
|
// lib/v3/agent/tools/v3-screenshot.ts
|
|
11400
11677
|
var import_ai3 = require("ai");
|
|
11401
|
-
var
|
|
11678
|
+
var import_zod8 = require("zod");
|
|
11402
11679
|
var createScreenshotTool = (v3) => (0, import_ai3.tool)({
|
|
11403
11680
|
description: "Takes a screenshot (PNG) of the current page. Use this to quickly verify page state.",
|
|
11404
|
-
inputSchema:
|
|
11681
|
+
inputSchema: import_zod8.z.object({}),
|
|
11405
11682
|
execute: () => __async(null, null, function* () {
|
|
11406
11683
|
v3.logger({
|
|
11407
11684
|
category: "agent",
|
|
@@ -11425,11 +11702,11 @@ var createScreenshotTool = (v3) => (0, import_ai3.tool)({
|
|
|
11425
11702
|
|
|
11426
11703
|
// lib/v3/agent/tools/v3-wait.ts
|
|
11427
11704
|
var import_ai4 = require("ai");
|
|
11428
|
-
var
|
|
11705
|
+
var import_zod9 = require("zod");
|
|
11429
11706
|
var createWaitTool = (v3) => (0, import_ai4.tool)({
|
|
11430
11707
|
description: "Wait for a specified time",
|
|
11431
|
-
inputSchema:
|
|
11432
|
-
timeMs:
|
|
11708
|
+
inputSchema: import_zod9.z.object({
|
|
11709
|
+
timeMs: import_zod9.z.number().describe("Time in milliseconds")
|
|
11433
11710
|
}),
|
|
11434
11711
|
execute: (_0) => __async(null, [_0], function* ({ timeMs }) {
|
|
11435
11712
|
v3.logger({
|
|
@@ -11453,11 +11730,11 @@ var createWaitTool = (v3) => (0, import_ai4.tool)({
|
|
|
11453
11730
|
|
|
11454
11731
|
// lib/v3/agent/tools/v3-navback.ts
|
|
11455
11732
|
var import_ai5 = require("ai");
|
|
11456
|
-
var
|
|
11733
|
+
var import_zod10 = require("zod");
|
|
11457
11734
|
var createNavBackTool = (v3) => (0, import_ai5.tool)({
|
|
11458
11735
|
description: "Navigate back to the previous page",
|
|
11459
|
-
inputSchema:
|
|
11460
|
-
reasoningText:
|
|
11736
|
+
inputSchema: import_zod10.z.object({
|
|
11737
|
+
reasoningText: import_zod10.z.string().describe("Why you're going back")
|
|
11461
11738
|
}),
|
|
11462
11739
|
execute: () => __async(null, null, function* () {
|
|
11463
11740
|
v3.logger({
|
|
@@ -11477,12 +11754,12 @@ var createNavBackTool = (v3) => (0, import_ai5.tool)({
|
|
|
11477
11754
|
|
|
11478
11755
|
// lib/v3/agent/tools/v3-close.ts
|
|
11479
11756
|
var import_ai6 = require("ai");
|
|
11480
|
-
var
|
|
11757
|
+
var import_zod11 = require("zod");
|
|
11481
11758
|
var createCloseTool = () => (0, import_ai6.tool)({
|
|
11482
11759
|
description: "Complete the task and close",
|
|
11483
|
-
inputSchema:
|
|
11484
|
-
reasoning:
|
|
11485
|
-
taskComplete:
|
|
11760
|
+
inputSchema: import_zod11.z.object({
|
|
11761
|
+
reasoning: import_zod11.z.string().describe("Summary of what was accomplished"),
|
|
11762
|
+
taskComplete: import_zod11.z.boolean().describe("Whether the task was completed successfully")
|
|
11486
11763
|
}),
|
|
11487
11764
|
execute: (_0) => __async(null, [_0], function* ({ reasoning, taskComplete }) {
|
|
11488
11765
|
return { success: true, reasoning, taskComplete };
|
|
@@ -11491,10 +11768,10 @@ var createCloseTool = () => (0, import_ai6.tool)({
|
|
|
11491
11768
|
|
|
11492
11769
|
// lib/v3/agent/tools/v3-ariaTree.ts
|
|
11493
11770
|
var import_ai7 = require("ai");
|
|
11494
|
-
var
|
|
11771
|
+
var import_zod12 = require("zod");
|
|
11495
11772
|
var createAriaTreeTool = (v3) => (0, import_ai7.tool)({
|
|
11496
11773
|
description: "gets the accessibility (ARIA) hybrid tree text for the current page. use this to understand structure and content.",
|
|
11497
|
-
inputSchema:
|
|
11774
|
+
inputSchema: import_zod12.z.object({}),
|
|
11498
11775
|
execute: () => __async(null, null, function* () {
|
|
11499
11776
|
v3.logger({
|
|
11500
11777
|
category: "agent",
|
|
@@ -11522,17 +11799,17 @@ ${result.content}` }]
|
|
|
11522
11799
|
|
|
11523
11800
|
// lib/v3/agent/tools/v3-fillform.ts
|
|
11524
11801
|
var import_ai8 = require("ai");
|
|
11525
|
-
var
|
|
11802
|
+
var import_zod13 = require("zod");
|
|
11526
11803
|
var createFillFormTool = (v3, executionModel) => (0, import_ai8.tool)({
|
|
11527
11804
|
description: `\u{1F4DD} FORM FILL - MULTI-FIELD INPUT TOOL
|
|
11528
11805
|
For any form with 2+ inputs/textareas. Faster than individual typing.`,
|
|
11529
|
-
inputSchema:
|
|
11530
|
-
fields:
|
|
11531
|
-
|
|
11532
|
-
action:
|
|
11806
|
+
inputSchema: import_zod13.z.object({
|
|
11807
|
+
fields: import_zod13.z.array(
|
|
11808
|
+
import_zod13.z.object({
|
|
11809
|
+
action: import_zod13.z.string().describe(
|
|
11533
11810
|
'Description of typing action, e.g. "type foo into the email field"'
|
|
11534
11811
|
),
|
|
11535
|
-
value:
|
|
11812
|
+
value: import_zod13.z.string().describe("Text to type into the target")
|
|
11536
11813
|
})
|
|
11537
11814
|
).min(1, "Provide at least one field to fill")
|
|
11538
11815
|
}),
|
|
@@ -11576,12 +11853,12 @@ For any form with 2+ inputs/textareas. Faster than individual typing.`,
|
|
|
11576
11853
|
|
|
11577
11854
|
// lib/v3/agent/tools/v3-scroll.ts
|
|
11578
11855
|
var import_ai9 = require("ai");
|
|
11579
|
-
var
|
|
11856
|
+
var import_zod14 = require("zod");
|
|
11580
11857
|
var createScrollTool = (v3) => (0, import_ai9.tool)({
|
|
11581
11858
|
description: "Scroll the page",
|
|
11582
|
-
inputSchema:
|
|
11583
|
-
pixels:
|
|
11584
|
-
direction:
|
|
11859
|
+
inputSchema: import_zod14.z.object({
|
|
11860
|
+
pixels: import_zod14.z.number().describe("Number of pixels to scroll up or down"),
|
|
11861
|
+
direction: import_zod14.z.enum(["up", "down"]).describe("Direction to scroll")
|
|
11585
11862
|
}),
|
|
11586
11863
|
execute: (_0) => __async(null, [_0], function* ({ pixels, direction }) {
|
|
11587
11864
|
v3.logger({
|
|
@@ -11613,19 +11890,19 @@ var createScrollTool = (v3) => (0, import_ai9.tool)({
|
|
|
11613
11890
|
|
|
11614
11891
|
// lib/v3/agent/tools/v3-extract.ts
|
|
11615
11892
|
var import_ai10 = require("ai");
|
|
11616
|
-
var
|
|
11893
|
+
var import_zod15 = require("zod");
|
|
11617
11894
|
function evaluateZodSchema(schemaStr, logger) {
|
|
11618
11895
|
var _a;
|
|
11619
11896
|
try {
|
|
11620
11897
|
const fn = new Function("z", `return ${schemaStr}`);
|
|
11621
|
-
return fn(
|
|
11898
|
+
return fn(import_zod15.z);
|
|
11622
11899
|
} catch (e) {
|
|
11623
11900
|
logger == null ? void 0 : logger({
|
|
11624
11901
|
category: "agent",
|
|
11625
11902
|
message: `Failed to evaluate schema: ${(_a = e == null ? void 0 : e.message) != null ? _a : String(e)}`,
|
|
11626
11903
|
level: 0
|
|
11627
11904
|
});
|
|
11628
|
-
return
|
|
11905
|
+
return import_zod15.z.any();
|
|
11629
11906
|
}
|
|
11630
11907
|
}
|
|
11631
11908
|
var createExtractTool = (v3, executionModel, logger) => (0, import_ai10.tool)({
|
|
@@ -11647,9 +11924,9 @@ var createExtractTool = (v3, executionModel, logger) => (0, import_ai10.tool)({
|
|
|
11647
11924
|
3. Extract arrays:
|
|
11648
11925
|
instruction: "extract all product names and prices"
|
|
11649
11926
|
schema: "z.object({ products: z.array(z.object({ name: z.string(), price: z.number() })) })"`,
|
|
11650
|
-
inputSchema:
|
|
11651
|
-
instruction:
|
|
11652
|
-
schema:
|
|
11927
|
+
inputSchema: import_zod15.z.object({
|
|
11928
|
+
instruction: import_zod15.z.string(),
|
|
11929
|
+
schema: import_zod15.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })")
|
|
11653
11930
|
}),
|
|
11654
11931
|
execute: (_0) => __async(null, [_0], function* ({ instruction, schema }) {
|
|
11655
11932
|
var _a;
|
|
@@ -12061,7 +12338,6 @@ init_sdkErrors();
|
|
|
12061
12338
|
// lib/v3/agent/AnthropicCUAClient.ts
|
|
12062
12339
|
init_sdkErrors();
|
|
12063
12340
|
var import_sdk = __toESM(require("@anthropic-ai/sdk"));
|
|
12064
|
-
var import_zod15 = require("zod");
|
|
12065
12341
|
|
|
12066
12342
|
// lib/v3/agent/AgentClient.ts
|
|
12067
12343
|
var AgentClient = class {
|
|
@@ -12564,7 +12840,19 @@ var AnthropicCUAClient = class extends AgentClient {
|
|
|
12564
12840
|
};
|
|
12565
12841
|
if (this.tools && Object.keys(this.tools).length > 0) {
|
|
12566
12842
|
const customTools = Object.entries(this.tools).map(([name, tool12]) => {
|
|
12567
|
-
const
|
|
12843
|
+
const schema = tool12.inputSchema;
|
|
12844
|
+
if (!schema) {
|
|
12845
|
+
return {
|
|
12846
|
+
name,
|
|
12847
|
+
description: tool12.description,
|
|
12848
|
+
input_schema: {
|
|
12849
|
+
type: "object",
|
|
12850
|
+
properties: {},
|
|
12851
|
+
required: []
|
|
12852
|
+
}
|
|
12853
|
+
};
|
|
12854
|
+
}
|
|
12855
|
+
const jsonSchema2 = toJsonSchema(schema);
|
|
12568
12856
|
const inputSchema = {
|
|
12569
12857
|
type: "object",
|
|
12570
12858
|
properties: jsonSchema2.properties || {},
|
|
@@ -13430,7 +13718,6 @@ init_sdkErrors();
|
|
|
13430
13718
|
|
|
13431
13719
|
// lib/v3/agent/utils/googleCustomToolHandler.ts
|
|
13432
13720
|
var import_genai2 = require("@google/genai");
|
|
13433
|
-
var import_zod16 = require("zod");
|
|
13434
13721
|
function executeGoogleCustomTool(toolName, toolArgs, tools, functionCall, logger) {
|
|
13435
13722
|
return __async(this, null, function* () {
|
|
13436
13723
|
try {
|
|
@@ -13498,7 +13785,11 @@ function convertToolSetToFunctionDeclarations(tools) {
|
|
|
13498
13785
|
}
|
|
13499
13786
|
function convertToolToFunctionDeclaration(name, tool12) {
|
|
13500
13787
|
try {
|
|
13501
|
-
const
|
|
13788
|
+
const schema = tool12.inputSchema;
|
|
13789
|
+
if (!schema) {
|
|
13790
|
+
return null;
|
|
13791
|
+
}
|
|
13792
|
+
const jsonSchema2 = toJsonSchema(schema);
|
|
13502
13793
|
const parameters = convertJsonSchemaToGoogleParameters(jsonSchema2);
|
|
13503
13794
|
return {
|
|
13504
13795
|
name,
|
|
@@ -16169,7 +16460,6 @@ var AISdkClient = class extends LLMClient {
|
|
|
16169
16460
|
|
|
16170
16461
|
// lib/v3/llm/AnthropicClient.ts
|
|
16171
16462
|
var import_sdk3 = __toESM(require("@anthropic-ai/sdk"));
|
|
16172
|
-
var import_zod17 = require("zod");
|
|
16173
16463
|
init_sdkErrors();
|
|
16174
16464
|
var AnthropicClient = class extends LLMClient {
|
|
16175
16465
|
constructor({
|
|
@@ -16280,7 +16570,7 @@ var AnthropicClient = class extends LLMClient {
|
|
|
16280
16570
|
});
|
|
16281
16571
|
let toolDefinition;
|
|
16282
16572
|
if (options.response_model) {
|
|
16283
|
-
const jsonSchema2 =
|
|
16573
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
16284
16574
|
const { properties: schemaProperties, required: schemaRequired } = extractSchemaProperties(jsonSchema2);
|
|
16285
16575
|
toolDefinition = {
|
|
16286
16576
|
name: "print_extracted_data",
|
|
@@ -16412,7 +16702,6 @@ var extractSchemaProperties = (jsonSchema2) => {
|
|
|
16412
16702
|
|
|
16413
16703
|
// lib/v3/llm/CerebrasClient.ts
|
|
16414
16704
|
var import_openai2 = __toESM(require("openai"));
|
|
16415
|
-
var import_zod18 = require("zod");
|
|
16416
16705
|
init_sdkErrors();
|
|
16417
16706
|
var CerebrasClient = class extends LLMClient {
|
|
16418
16707
|
constructor({
|
|
@@ -16475,7 +16764,7 @@ var CerebrasClient = class extends LLMClient {
|
|
|
16475
16764
|
}
|
|
16476
16765
|
}));
|
|
16477
16766
|
if (options.response_model) {
|
|
16478
|
-
const jsonSchema2 =
|
|
16767
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
16479
16768
|
const schemaProperties = jsonSchema2.properties || {};
|
|
16480
16769
|
const schemaRequired = jsonSchema2.required || [];
|
|
16481
16770
|
const responseTool = {
|
|
@@ -17001,7 +17290,6 @@ ${firstPartText.text}`;
|
|
|
17001
17290
|
|
|
17002
17291
|
// lib/v3/llm/GroqClient.ts
|
|
17003
17292
|
var import_openai3 = __toESM(require("openai"));
|
|
17004
|
-
var import_zod19 = require("zod");
|
|
17005
17293
|
init_sdkErrors();
|
|
17006
17294
|
var GroqClient = class extends LLMClient {
|
|
17007
17295
|
constructor({
|
|
@@ -17064,7 +17352,7 @@ var GroqClient = class extends LLMClient {
|
|
|
17064
17352
|
}
|
|
17065
17353
|
}));
|
|
17066
17354
|
if (options.response_model) {
|
|
17067
|
-
const jsonSchema2 =
|
|
17355
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
17068
17356
|
const schemaProperties = jsonSchema2.properties || {};
|
|
17069
17357
|
const schemaRequired = jsonSchema2.required || [];
|
|
17070
17358
|
const responseTool = {
|
|
@@ -17222,8 +17510,7 @@ var GroqClient = class extends LLMClient {
|
|
|
17222
17510
|
|
|
17223
17511
|
// lib/v3/llm/OpenAIClient.ts
|
|
17224
17512
|
var import_openai4 = __toESM(require("openai"));
|
|
17225
|
-
var
|
|
17226
|
-
var import_zod21 = require("zod");
|
|
17513
|
+
var import_zod16 = require("openai/helpers/zod");
|
|
17227
17514
|
init_sdkErrors();
|
|
17228
17515
|
var OpenAIClient = class extends LLMClient {
|
|
17229
17516
|
constructor({
|
|
@@ -17330,12 +17617,12 @@ ${JSON.stringify(
|
|
|
17330
17617
|
};
|
|
17331
17618
|
options.messages.push(screenshotMessage);
|
|
17332
17619
|
}
|
|
17333
|
-
let responseFormat
|
|
17620
|
+
let responseFormat;
|
|
17334
17621
|
if (options.response_model) {
|
|
17335
17622
|
if (this.modelName.startsWith("o1") || this.modelName.startsWith("o3")) {
|
|
17336
17623
|
try {
|
|
17337
17624
|
const parsedSchema = JSON.stringify(
|
|
17338
|
-
|
|
17625
|
+
toJsonSchema(options.response_model.schema)
|
|
17339
17626
|
);
|
|
17340
17627
|
options.messages.push({
|
|
17341
17628
|
role: "user",
|
|
@@ -17360,11 +17647,19 @@ ${parsedSchema}
|
|
|
17360
17647
|
}
|
|
17361
17648
|
throw error;
|
|
17362
17649
|
}
|
|
17363
|
-
} else {
|
|
17364
|
-
responseFormat = (0,
|
|
17650
|
+
} else if (isZod4Schema(options.response_model.schema)) {
|
|
17651
|
+
responseFormat = (0, import_zod16.zodResponseFormat)(
|
|
17365
17652
|
options.response_model.schema,
|
|
17366
17653
|
options.response_model.name
|
|
17367
17654
|
);
|
|
17655
|
+
} else {
|
|
17656
|
+
responseFormat = {
|
|
17657
|
+
type: "json_schema",
|
|
17658
|
+
json_schema: {
|
|
17659
|
+
name: options.response_model.name,
|
|
17660
|
+
schema: toJsonSchema(options.response_model.schema)
|
|
17661
|
+
}
|
|
17662
|
+
};
|
|
17368
17663
|
}
|
|
17369
17664
|
}
|
|
17370
17665
|
const _d = __spreadProps(__spreadValues({}, optionsWithoutImageAndRequestId), {
|
|
@@ -17545,7 +17840,7 @@ ${parsedSchema}
|
|
|
17545
17840
|
}
|
|
17546
17841
|
};
|
|
17547
17842
|
|
|
17548
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.
|
|
17843
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17549
17844
|
var import_provider = require("@ai-sdk/provider");
|
|
17550
17845
|
var import_provider2 = require("@ai-sdk/provider");
|
|
17551
17846
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -17682,14 +17977,14 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
17682
17977
|
}
|
|
17683
17978
|
};
|
|
17684
17979
|
|
|
17685
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.
|
|
17980
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17686
17981
|
var import_provider9 = require("@ai-sdk/provider");
|
|
17687
17982
|
var import_provider10 = require("@ai-sdk/provider");
|
|
17688
17983
|
var import_provider11 = require("@ai-sdk/provider");
|
|
17689
17984
|
var z42 = __toESM(require("zod/v4"), 1);
|
|
17690
|
-
var import_v3 = require("zod/v3");
|
|
17691
17985
|
var import_v32 = require("zod/v3");
|
|
17692
17986
|
var import_v33 = require("zod/v3");
|
|
17987
|
+
var import_v34 = require("zod/v3");
|
|
17693
17988
|
function combineHeaders(...headers) {
|
|
17694
17989
|
return headers.reduce(
|
|
17695
17990
|
(combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
|
|
@@ -18506,7 +18801,7 @@ function parseArrayDef(def, refs) {
|
|
|
18506
18801
|
const res = {
|
|
18507
18802
|
type: "array"
|
|
18508
18803
|
};
|
|
18509
|
-
if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !==
|
|
18804
|
+
if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== import_v33.ZodFirstPartyTypeKind.ZodAny) {
|
|
18510
18805
|
res.items = parseDef(def.type._def, __spreadProps(__spreadValues({}, refs), {
|
|
18511
18806
|
currentPath: [...refs.currentPath, "items"]
|
|
18512
18807
|
}));
|
|
@@ -18995,18 +19290,18 @@ function parseRecordDef(def, refs) {
|
|
|
18995
19290
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
18996
19291
|
}))) != null ? _a : refs.allowedAdditionalProperties
|
|
18997
19292
|
};
|
|
18998
|
-
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) ===
|
|
19293
|
+
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === import_v34.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
18999
19294
|
const _a2 = parseStringDef(def.keyType._def, refs), { type } = _a2, keyType = __objRest(_a2, ["type"]);
|
|
19000
19295
|
return __spreadProps(__spreadValues({}, schema), {
|
|
19001
19296
|
propertyNames: keyType
|
|
19002
19297
|
});
|
|
19003
|
-
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) ===
|
|
19298
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === import_v34.ZodFirstPartyTypeKind.ZodEnum) {
|
|
19004
19299
|
return __spreadProps(__spreadValues({}, schema), {
|
|
19005
19300
|
propertyNames: {
|
|
19006
19301
|
enum: def.keyType._def.values
|
|
19007
19302
|
}
|
|
19008
19303
|
});
|
|
19009
|
-
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) ===
|
|
19304
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === import_v34.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === import_v34.ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
19010
19305
|
const _b2 = parseBrandedDef(
|
|
19011
19306
|
def.keyType._def,
|
|
19012
19307
|
refs
|
|
@@ -19332,73 +19627,73 @@ var parseReadonlyDef = (def, refs) => {
|
|
|
19332
19627
|
};
|
|
19333
19628
|
var selectParser = (def, typeName, refs) => {
|
|
19334
19629
|
switch (typeName) {
|
|
19335
|
-
case
|
|
19630
|
+
case import_v32.ZodFirstPartyTypeKind.ZodString:
|
|
19336
19631
|
return parseStringDef(def, refs);
|
|
19337
|
-
case
|
|
19632
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNumber:
|
|
19338
19633
|
return parseNumberDef(def);
|
|
19339
|
-
case
|
|
19634
|
+
case import_v32.ZodFirstPartyTypeKind.ZodObject:
|
|
19340
19635
|
return parseObjectDef(def, refs);
|
|
19341
|
-
case
|
|
19636
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBigInt:
|
|
19342
19637
|
return parseBigintDef(def);
|
|
19343
|
-
case
|
|
19638
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBoolean:
|
|
19344
19639
|
return parseBooleanDef();
|
|
19345
|
-
case
|
|
19640
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDate:
|
|
19346
19641
|
return parseDateDef(def, refs);
|
|
19347
|
-
case
|
|
19642
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUndefined:
|
|
19348
19643
|
return parseUndefinedDef();
|
|
19349
|
-
case
|
|
19644
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNull:
|
|
19350
19645
|
return parseNullDef();
|
|
19351
|
-
case
|
|
19646
|
+
case import_v32.ZodFirstPartyTypeKind.ZodArray:
|
|
19352
19647
|
return parseArrayDef(def, refs);
|
|
19353
|
-
case
|
|
19354
|
-
case
|
|
19648
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUnion:
|
|
19649
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
19355
19650
|
return parseUnionDef(def, refs);
|
|
19356
|
-
case
|
|
19651
|
+
case import_v32.ZodFirstPartyTypeKind.ZodIntersection:
|
|
19357
19652
|
return parseIntersectionDef(def, refs);
|
|
19358
|
-
case
|
|
19653
|
+
case import_v32.ZodFirstPartyTypeKind.ZodTuple:
|
|
19359
19654
|
return parseTupleDef(def, refs);
|
|
19360
|
-
case
|
|
19655
|
+
case import_v32.ZodFirstPartyTypeKind.ZodRecord:
|
|
19361
19656
|
return parseRecordDef(def, refs);
|
|
19362
|
-
case
|
|
19657
|
+
case import_v32.ZodFirstPartyTypeKind.ZodLiteral:
|
|
19363
19658
|
return parseLiteralDef(def);
|
|
19364
|
-
case
|
|
19659
|
+
case import_v32.ZodFirstPartyTypeKind.ZodEnum:
|
|
19365
19660
|
return parseEnumDef(def);
|
|
19366
|
-
case
|
|
19661
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
19367
19662
|
return parseNativeEnumDef(def);
|
|
19368
|
-
case
|
|
19663
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNullable:
|
|
19369
19664
|
return parseNullableDef(def, refs);
|
|
19370
|
-
case
|
|
19665
|
+
case import_v32.ZodFirstPartyTypeKind.ZodOptional:
|
|
19371
19666
|
return parseOptionalDef(def, refs);
|
|
19372
|
-
case
|
|
19667
|
+
case import_v32.ZodFirstPartyTypeKind.ZodMap:
|
|
19373
19668
|
return parseMapDef(def, refs);
|
|
19374
|
-
case
|
|
19669
|
+
case import_v32.ZodFirstPartyTypeKind.ZodSet:
|
|
19375
19670
|
return parseSetDef(def, refs);
|
|
19376
|
-
case
|
|
19671
|
+
case import_v32.ZodFirstPartyTypeKind.ZodLazy:
|
|
19377
19672
|
return () => def.getter()._def;
|
|
19378
|
-
case
|
|
19673
|
+
case import_v32.ZodFirstPartyTypeKind.ZodPromise:
|
|
19379
19674
|
return parsePromiseDef(def, refs);
|
|
19380
|
-
case
|
|
19381
|
-
case
|
|
19675
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNaN:
|
|
19676
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNever:
|
|
19382
19677
|
return parseNeverDef();
|
|
19383
|
-
case
|
|
19678
|
+
case import_v32.ZodFirstPartyTypeKind.ZodEffects:
|
|
19384
19679
|
return parseEffectsDef(def, refs);
|
|
19385
|
-
case
|
|
19680
|
+
case import_v32.ZodFirstPartyTypeKind.ZodAny:
|
|
19386
19681
|
return parseAnyDef();
|
|
19387
|
-
case
|
|
19682
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUnknown:
|
|
19388
19683
|
return parseUnknownDef();
|
|
19389
|
-
case
|
|
19684
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDefault:
|
|
19390
19685
|
return parseDefaultDef(def, refs);
|
|
19391
|
-
case
|
|
19686
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBranded:
|
|
19392
19687
|
return parseBrandedDef(def, refs);
|
|
19393
|
-
case
|
|
19688
|
+
case import_v32.ZodFirstPartyTypeKind.ZodReadonly:
|
|
19394
19689
|
return parseReadonlyDef(def, refs);
|
|
19395
|
-
case
|
|
19690
|
+
case import_v32.ZodFirstPartyTypeKind.ZodCatch:
|
|
19396
19691
|
return parseCatchDef(def, refs);
|
|
19397
|
-
case
|
|
19692
|
+
case import_v32.ZodFirstPartyTypeKind.ZodPipeline:
|
|
19398
19693
|
return parsePipelineDef(def, refs);
|
|
19399
|
-
case
|
|
19400
|
-
case
|
|
19401
|
-
case
|
|
19694
|
+
case import_v32.ZodFirstPartyTypeKind.ZodFunction:
|
|
19695
|
+
case import_v32.ZodFirstPartyTypeKind.ZodVoid:
|
|
19696
|
+
case import_v32.ZodFirstPartyTypeKind.ZodSymbol:
|
|
19402
19697
|
return void 0;
|
|
19403
19698
|
default:
|
|
19404
19699
|
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
@@ -19565,11 +19860,11 @@ function zod4Schema(zodSchema2, options) {
|
|
|
19565
19860
|
}
|
|
19566
19861
|
);
|
|
19567
19862
|
}
|
|
19568
|
-
function
|
|
19863
|
+
function isZod4Schema2(zodSchema2) {
|
|
19569
19864
|
return "_zod" in zodSchema2;
|
|
19570
19865
|
}
|
|
19571
19866
|
function zodSchema(zodSchema2, options) {
|
|
19572
|
-
if (
|
|
19867
|
+
if (isZod4Schema2(zodSchema2)) {
|
|
19573
19868
|
return zod4Schema(zodSchema2, options);
|
|
19574
19869
|
} else {
|
|
19575
19870
|
return zod3Schema(zodSchema2, options);
|
|
@@ -19622,7 +19917,7 @@ function withoutTrailingSlash(url) {
|
|
|
19622
19917
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
19623
19918
|
}
|
|
19624
19919
|
|
|
19625
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.
|
|
19920
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.8/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
19626
19921
|
var import_provider12 = require("@ai-sdk/provider");
|
|
19627
19922
|
var import_v4 = require("zod/v4");
|
|
19628
19923
|
var import_provider13 = require("@ai-sdk/provider");
|
|
@@ -24012,7 +24307,7 @@ function createOpenAI(options = {}) {
|
|
|
24012
24307
|
}
|
|
24013
24308
|
var openai = createOpenAI();
|
|
24014
24309
|
|
|
24015
|
-
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@4.1.
|
|
24310
|
+
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@4.1.8/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
24016
24311
|
var import_provider20 = require("@ai-sdk/provider");
|
|
24017
24312
|
var import_provider21 = require("@ai-sdk/provider");
|
|
24018
24313
|
var import_v421 = require("zod/v4");
|
|
@@ -27051,7 +27346,7 @@ function createAnthropic(options = {}) {
|
|
|
27051
27346
|
}
|
|
27052
27347
|
var anthropic = createAnthropic();
|
|
27053
27348
|
|
|
27054
|
-
// ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@4.1.
|
|
27349
|
+
// ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@4.1.8/node_modules/@ai-sdk/google/dist/index.mjs
|
|
27055
27350
|
var import_provider24 = require("@ai-sdk/provider");
|
|
27056
27351
|
var import_v437 = require("zod/v4");
|
|
27057
27352
|
var import_v438 = require("zod/v4");
|
|
@@ -28603,7 +28898,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
28603
28898
|
}
|
|
28604
28899
|
var google = createGoogleGenerativeAI();
|
|
28605
28900
|
|
|
28606
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@4.1.
|
|
28901
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@4.1.8/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
28607
28902
|
var import_provider27 = require("@ai-sdk/provider");
|
|
28608
28903
|
var import_v446 = require("zod/v4");
|
|
28609
28904
|
var import_provider28 = require("@ai-sdk/provider");
|
|
@@ -29923,7 +30218,7 @@ var openaiCompatibleImageResponseSchema = import_v453.z.object({
|
|
|
29923
30218
|
data: import_v453.z.array(import_v453.z.object({ b64_json: import_v453.z.string() }))
|
|
29924
30219
|
});
|
|
29925
30220
|
|
|
29926
|
-
// ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@4.1.
|
|
30221
|
+
// ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@4.1.8/node_modules/@ai-sdk/xai/dist/index.mjs
|
|
29927
30222
|
var import_provider32 = require("@ai-sdk/provider");
|
|
29928
30223
|
var import_v454 = require("zod/v4");
|
|
29929
30224
|
var import_provider33 = require("@ai-sdk/provider");
|
|
@@ -30675,7 +30970,7 @@ function createXai(options = {}) {
|
|
|
30675
30970
|
}
|
|
30676
30971
|
var xai = createXai();
|
|
30677
30972
|
|
|
30678
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.
|
|
30973
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.8/node_modules/@ai-sdk/openai/dist/internal/index.mjs
|
|
30679
30974
|
var import_provider35 = require("@ai-sdk/provider");
|
|
30680
30975
|
var import_v457 = require("zod/v4");
|
|
30681
30976
|
var import_provider36 = require("@ai-sdk/provider");
|
|
@@ -34898,7 +35193,7 @@ function mapWebSearchOutput2(action) {
|
|
|
34898
35193
|
}
|
|
34899
35194
|
}
|
|
34900
35195
|
|
|
34901
|
-
// ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@4.1.
|
|
35196
|
+
// ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@4.1.8/node_modules/@ai-sdk/azure/dist/index.mjs
|
|
34902
35197
|
var azureOpenaiTools = {
|
|
34903
35198
|
codeInterpreter: codeInterpreter2,
|
|
34904
35199
|
fileSearch: fileSearch2,
|
|
@@ -35003,7 +35298,7 @@ function createAzure(options = {}) {
|
|
|
35003
35298
|
}
|
|
35004
35299
|
var azure = createAzure();
|
|
35005
35300
|
|
|
35006
|
-
// ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@4.1.
|
|
35301
|
+
// ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@4.1.8/node_modules/@ai-sdk/groq/dist/index.mjs
|
|
35007
35302
|
var import_provider43 = require("@ai-sdk/provider");
|
|
35008
35303
|
var import_provider44 = require("@ai-sdk/provider");
|
|
35009
35304
|
var import_v477 = require("zod/v4");
|
|
@@ -35885,7 +36180,7 @@ function createGroq(options = {}) {
|
|
|
35885
36180
|
}
|
|
35886
36181
|
var groq = createGroq();
|
|
35887
36182
|
|
|
35888
|
-
// ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@4.1.
|
|
36183
|
+
// ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@4.1.8/node_modules/@ai-sdk/cerebras/dist/index.mjs
|
|
35889
36184
|
var import_provider47 = require("@ai-sdk/provider");
|
|
35890
36185
|
var import_v482 = require("zod/v4");
|
|
35891
36186
|
var VERSION8 = true ? "1.0.25" : "0.0.0-test";
|
|
@@ -35937,7 +36232,7 @@ function createCerebras(options = {}) {
|
|
|
35937
36232
|
}
|
|
35938
36233
|
var cerebras = createCerebras();
|
|
35939
36234
|
|
|
35940
|
-
// ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@4.1.
|
|
36235
|
+
// ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@4.1.8/node_modules/@ai-sdk/togetherai/dist/index.mjs
|
|
35941
36236
|
var import_v483 = require("zod/v4");
|
|
35942
36237
|
var TogetherAIImageModel = class {
|
|
35943
36238
|
constructor(modelId, config) {
|
|
@@ -36068,7 +36363,7 @@ function createTogetherAI(options = {}) {
|
|
|
36068
36363
|
}
|
|
36069
36364
|
var togetherai = createTogetherAI();
|
|
36070
36365
|
|
|
36071
|
-
// ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@4.1.
|
|
36366
|
+
// ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@4.1.8/node_modules/@ai-sdk/mistral/dist/index.mjs
|
|
36072
36367
|
var import_provider48 = require("@ai-sdk/provider");
|
|
36073
36368
|
var import_v484 = require("zod/v4");
|
|
36074
36369
|
var import_provider49 = require("@ai-sdk/provider");
|
|
@@ -36851,7 +37146,7 @@ function createMistral(options = {}) {
|
|
|
36851
37146
|
}
|
|
36852
37147
|
var mistral = createMistral();
|
|
36853
37148
|
|
|
36854
|
-
// ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@4.1.
|
|
37149
|
+
// ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@4.1.8/node_modules/@ai-sdk/deepseek/dist/index.mjs
|
|
36855
37150
|
var import_provider52 = require("@ai-sdk/provider");
|
|
36856
37151
|
var import_v488 = require("zod/v4");
|
|
36857
37152
|
var buildDeepseekMetadata = (usage) => {
|
|
@@ -36941,7 +37236,7 @@ function createDeepSeek(options = {}) {
|
|
|
36941
37236
|
}
|
|
36942
37237
|
var deepseek = createDeepSeek();
|
|
36943
37238
|
|
|
36944
|
-
// ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@4.1.
|
|
37239
|
+
// ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@4.1.8/node_modules/@ai-sdk/perplexity/dist/index.mjs
|
|
36945
37240
|
var import_provider53 = require("@ai-sdk/provider");
|
|
36946
37241
|
var import_v489 = require("zod/v4");
|
|
36947
37242
|
var import_provider54 = require("@ai-sdk/provider");
|
|
@@ -37371,7 +37666,7 @@ function createPerplexity(options = {}) {
|
|
|
37371
37666
|
}
|
|
37372
37667
|
var perplexity = createPerplexity();
|
|
37373
37668
|
|
|
37374
|
-
// ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@4.1.
|
|
37669
|
+
// ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@4.1.8/node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
37375
37670
|
var import_provider55 = require("@ai-sdk/provider");
|
|
37376
37671
|
var import_v490 = require("zod/v4");
|
|
37377
37672
|
var import_v491 = require("zod/v4");
|
|
@@ -39137,7 +39432,7 @@ var CdpConnection = class _CdpConnection {
|
|
|
39137
39432
|
yield this.send("Target.setAutoAttach", {
|
|
39138
39433
|
autoAttach: true,
|
|
39139
39434
|
flatten: true,
|
|
39140
|
-
waitForDebuggerOnStart:
|
|
39435
|
+
waitForDebuggerOnStart: false,
|
|
39141
39436
|
filter: [
|
|
39142
39437
|
{ type: "worker", exclude: true },
|
|
39143
39438
|
{ type: "shared_worker", exclude: true },
|
|
@@ -39320,12 +39615,15 @@ init_logger();
|
|
|
39320
39615
|
// lib/v3/dom/build/scriptV3Content.ts
|
|
39321
39616
|
var v3ScriptContent = '(()=>{function b(_={}){let S=n=>{let{hostToRoot:l}=n,m=t=>{let o=[];if(t instanceof Document)return t.documentElement&&o.push(t.documentElement),o;if(t instanceof ShadowRoot||t instanceof DocumentFragment)return o.push(...Array.from(t.children)),o;if(t instanceof Element){o.push(...Array.from(t.children));let a=t.shadowRoot;a&&o.push(...Array.from(a.children));let r=l.get(t);return r&&o.push(...Array.from(r.children)),o}return o},v=t=>{let o=[],a=[...m(t)];for(;a.length;){let r=a.shift();o.push(r),a.push(...m(r))}return o},y=t=>{let o=String(t||"").trim();if(!o)return null;let a=o.replace(/^xpath=/i,""),r=[];{let e=0;for(;e<a.length;){let d="child";a.startsWith("//",e)?(d="desc",e+=2):a[e]==="/"&&(d="child",e+=1);let h=e;for(;e<a.length&&a[e]!=="/";)e++;let u=a.slice(h,e).trim();if(!u)continue;let p=u.match(/^(.*?)(\\[(\\d+)\\])?$/u),i=(p?.[1]??u).trim(),c=p?.[3]?Math.max(1,Number(p[3])):null,R=i===""?"*":i.toLowerCase();r.push({axis:d,raw:u,tag:R,index:c})}}n.debug&&console.info("[v3-piercer][resolve] start",{url:location.href,steps:r.map(e=>({axis:e.axis,raw:e.raw,tag:e.tag,index:e.index}))});let g=[document];for(let e of r){let d=e.index,h=null;for(let u of g){let p=e.axis==="child"?m(u):v(u),i=[];for(let c of p)(e.tag==="*"||c.localName===e.tag)&&i.push(c);if(n.debug&&console.info("[v3-piercer][resolve] step",{axis:e.axis,tag:e.tag,index:d,poolCount:p.length,matchesCount:i.length}),!!i.length){if(d!=null){let c=d-1;h=c>=0&&c<i.length?i[c]:null}else h=i[0];if(h)break}}if(!h)return n.debug&&console.info("[v3-piercer][resolve] no-match",{step:e.raw}),null;g=[h]}let E=g.length?g[0]:null;return n.debug&&console.info("[v3-piercer][resolve] done",{found:!!E,tag:E?.localName??""}),E};window.__stagehandV3__={getClosedRoot:t=>l.get(t),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:n.openCount,closed:n.closedCount}),resolveSimpleXPath:y}},f=Element.prototype.attachShadow;if(f.__v3Patched&&f.__v3State){f.__v3State.debug=!0,S(f.__v3State);return}let s={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},x=f,w=function(n){let l=n?.mode??"open",m=x.call(this,n);try{s.hostToRoot.set(this,m),l==="closed"?s.closedCount++:s.openCount++,s.debug&&console.info("[v3-piercer] attachShadow",{tag:this.tagName?.toLowerCase()??"",mode:l,url:location.href})}catch{}return m};if(w.__v3Patched=!0,w.__v3State=s,Object.defineProperty(Element.prototype,"attachShadow",{configurable:!0,writable:!0,value:w}),_.tagExisting)try{let n=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;n.nextNode();){let l=n.currentNode;l.shadowRoot&&(s.hostToRoot.set(l,l.shadowRoot),s.openCount++)}}catch{}window.__stagehandV3Injected=!0,S(s),s.debug&&console.info("[v3-piercer] installed",{url:location.href,isTop:window.top===window,readyState:document.readyState})}b({debug:!0,tagExisting:!1});})();\n';
|
|
39322
39617
|
|
|
39618
|
+
// lib/v3/dom/build/reRenderScriptContent.ts
|
|
39619
|
+
var reRenderScriptContent = '(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!="function")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??"";if(!n.includes("-")||typeof customElements?.get!="function"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info("[v3-piercer] rerender",{count:t.length})}catch(o){console.info("[v3-piercer] rerender error",{message:String(o??"")})}}s();})();\n';
|
|
39620
|
+
|
|
39323
39621
|
// lib/v3/understudy/piercer.ts
|
|
39324
39622
|
function installV3PiercerIntoSession(session) {
|
|
39325
39623
|
return __async(this, null, function* () {
|
|
39326
39624
|
var _a, _b;
|
|
39327
|
-
yield session.send("Page.enable").catch(() =>
|
|
39328
|
-
|
|
39625
|
+
const pageEnabled = yield session.send("Page.enable").then(() => true).catch(() => false);
|
|
39626
|
+
if (!pageEnabled) return false;
|
|
39329
39627
|
yield session.send("Runtime.enable").catch(() => {
|
|
39330
39628
|
});
|
|
39331
39629
|
try {
|
|
@@ -39335,7 +39633,7 @@ function installV3PiercerIntoSession(session) {
|
|
|
39335
39633
|
);
|
|
39336
39634
|
} catch (e) {
|
|
39337
39635
|
const msg = String((_b = (_a = e == null ? void 0 : e.message) != null ? _a : e) != null ? _b : "");
|
|
39338
|
-
if (msg.includes("Session with given id not found")) return;
|
|
39636
|
+
if (msg.includes("Session with given id not found")) return false;
|
|
39339
39637
|
}
|
|
39340
39638
|
yield session.send("Runtime.evaluate", {
|
|
39341
39639
|
expression: v3ScriptContent,
|
|
@@ -39343,6 +39641,13 @@ function installV3PiercerIntoSession(session) {
|
|
|
39343
39641
|
awaitPromise: true
|
|
39344
39642
|
}).catch(() => {
|
|
39345
39643
|
});
|
|
39644
|
+
yield session.send("Runtime.evaluate", {
|
|
39645
|
+
expression: reRenderScriptContent,
|
|
39646
|
+
returnByValue: true,
|
|
39647
|
+
awaitPromise: false
|
|
39648
|
+
}).catch(() => {
|
|
39649
|
+
});
|
|
39650
|
+
return true;
|
|
39346
39651
|
});
|
|
39347
39652
|
}
|
|
39348
39653
|
|
|
@@ -39449,9 +39754,12 @@ var V3Context = class _V3Context {
|
|
|
39449
39754
|
ensurePiercer(session) {
|
|
39450
39755
|
return __async(this, null, function* () {
|
|
39451
39756
|
const key = this.sessionKey(session);
|
|
39452
|
-
if (this._piercerInstalled.has(key)) return;
|
|
39453
|
-
yield installV3PiercerIntoSession(session);
|
|
39454
|
-
|
|
39757
|
+
if (this._piercerInstalled.has(key)) return true;
|
|
39758
|
+
const installed = yield installV3PiercerIntoSession(session);
|
|
39759
|
+
if (installed) {
|
|
39760
|
+
this._piercerInstalled.add(key);
|
|
39761
|
+
}
|
|
39762
|
+
return installed;
|
|
39455
39763
|
});
|
|
39456
39764
|
}
|
|
39457
39765
|
/** Mark a page target as the most-recent one (active). */
|
|
@@ -39589,11 +39897,7 @@ var V3Context = class _V3Context {
|
|
|
39589
39897
|
this.conn.on(
|
|
39590
39898
|
"Target.attachedToTarget",
|
|
39591
39899
|
(evt) => __async(this, null, function* () {
|
|
39592
|
-
yield this.onAttachedToTarget(
|
|
39593
|
-
evt.targetInfo,
|
|
39594
|
-
evt.sessionId,
|
|
39595
|
-
evt.waitingForDebugger === true
|
|
39596
|
-
);
|
|
39900
|
+
yield this.onAttachedToTarget(evt.targetInfo, evt.sessionId);
|
|
39597
39901
|
})
|
|
39598
39902
|
);
|
|
39599
39903
|
this.conn.on(
|
|
@@ -39646,29 +39950,20 @@ var V3Context = class _V3Context {
|
|
|
39646
39950
|
* if the parent is known; otherwise stage until parent `frameAttached`.
|
|
39647
39951
|
* - Resume the target only after listeners are wired.
|
|
39648
39952
|
*/
|
|
39649
|
-
onAttachedToTarget(info, sessionId
|
|
39953
|
+
onAttachedToTarget(info, sessionId) {
|
|
39650
39954
|
return __async(this, null, function* () {
|
|
39651
39955
|
var _a;
|
|
39652
39956
|
const session = this.conn.getSession(sessionId);
|
|
39653
39957
|
if (!session) return;
|
|
39654
39958
|
if (this._sessionInit.has(sessionId)) return;
|
|
39655
39959
|
this._sessionInit.add(sessionId);
|
|
39656
|
-
const pageEnabled = yield session.send("Page.enable").then(() => true).catch(() => false);
|
|
39657
|
-
if (!pageEnabled) {
|
|
39658
|
-
if (waitingForDebugger) {
|
|
39659
|
-
yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
|
|
39660
|
-
});
|
|
39661
|
-
}
|
|
39662
|
-
return;
|
|
39663
|
-
}
|
|
39664
|
-
yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
|
|
39665
|
-
});
|
|
39666
39960
|
yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
|
|
39667
39961
|
});
|
|
39668
39962
|
executionContexts.attachSession(session);
|
|
39669
|
-
yield
|
|
39963
|
+
const piercerReady = yield this.ensurePiercer(session);
|
|
39964
|
+
if (!piercerReady) return;
|
|
39965
|
+
yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
|
|
39670
39966
|
});
|
|
39671
|
-
yield this.ensurePiercer(session);
|
|
39672
39967
|
if (isTopLevelPage(info)) {
|
|
39673
39968
|
const page = yield Page.create(
|
|
39674
39969
|
this.conn,
|
|
@@ -39692,10 +39987,6 @@ var V3Context = class _V3Context {
|
|
|
39692
39987
|
page.seedCurrentUrl((_a = pendingSeedUrl != null ? pendingSeedUrl : info.url) != null ? _a : "");
|
|
39693
39988
|
this._pushActive(info.targetId);
|
|
39694
39989
|
this.installFrameEventBridges(sessionId, page);
|
|
39695
|
-
if (waitingForDebugger) {
|
|
39696
|
-
yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
|
|
39697
|
-
});
|
|
39698
|
-
}
|
|
39699
39990
|
return;
|
|
39700
39991
|
}
|
|
39701
39992
|
try {
|
|
@@ -39723,51 +40014,13 @@ var V3Context = class _V3Context {
|
|
|
39723
40014
|
owner.adoptOopifSession(session, childMainId);
|
|
39724
40015
|
this.sessionOwnerPage.set(sessionId, owner);
|
|
39725
40016
|
this.installFrameEventBridges(sessionId, owner);
|
|
40017
|
+
void executionContexts.waitForMainWorld(session, childMainId).catch(() => {
|
|
40018
|
+
});
|
|
39726
40019
|
} else {
|
|
39727
40020
|
this.pendingOopifByMainFrame.set(childMainId, sessionId);
|
|
39728
40021
|
}
|
|
39729
40022
|
} catch (e) {
|
|
39730
40023
|
}
|
|
39731
|
-
if (info.type === "iframe" && !waitingForDebugger) {
|
|
39732
|
-
try {
|
|
39733
|
-
yield session.send("Page.setLifecycleEventsEnabled", { enabled: true }).catch(() => {
|
|
39734
|
-
});
|
|
39735
|
-
const loadWait = new Promise((resolve2) => {
|
|
39736
|
-
const handler = (evt) => {
|
|
39737
|
-
if (evt.name === "load") {
|
|
39738
|
-
session.off("Page.lifecycleEvent", handler);
|
|
39739
|
-
resolve2();
|
|
39740
|
-
}
|
|
39741
|
-
};
|
|
39742
|
-
session.on("Page.lifecycleEvent", handler);
|
|
39743
|
-
});
|
|
39744
|
-
yield session.send("Runtime.evaluate", {
|
|
39745
|
-
expression: "location.reload()",
|
|
39746
|
-
returnByValue: true,
|
|
39747
|
-
awaitPromise: false
|
|
39748
|
-
}).catch(() => {
|
|
39749
|
-
});
|
|
39750
|
-
yield Promise.race([
|
|
39751
|
-
loadWait,
|
|
39752
|
-
new Promise((r) => setTimeout(r, 3e3))
|
|
39753
|
-
]);
|
|
39754
|
-
yield this.ensurePiercer(session);
|
|
39755
|
-
} catch (e) {
|
|
39756
|
-
v3Logger({
|
|
39757
|
-
category: "ctx",
|
|
39758
|
-
message: "child reload attempt failed (continuing)",
|
|
39759
|
-
level: 2,
|
|
39760
|
-
auxiliary: {
|
|
39761
|
-
sessionId: { value: String(sessionId), type: "string" },
|
|
39762
|
-
err: { value: String(e), type: "string" }
|
|
39763
|
-
}
|
|
39764
|
-
});
|
|
39765
|
-
}
|
|
39766
|
-
}
|
|
39767
|
-
if (waitingForDebugger) {
|
|
39768
|
-
yield session.send("Runtime.runIfWaitingForDebugger").catch(() => {
|
|
39769
|
-
});
|
|
39770
|
-
}
|
|
39771
40024
|
});
|
|
39772
40025
|
}
|
|
39773
40026
|
/**
|
|
@@ -39952,7 +40205,6 @@ function resolveModel(model) {
|
|
|
39952
40205
|
|
|
39953
40206
|
// lib/v3/api.ts
|
|
39954
40207
|
var import_fetch_cookie = __toESM(require("fetch-cookie"));
|
|
39955
|
-
var import_zod22 = require("zod");
|
|
39956
40208
|
init_version();
|
|
39957
40209
|
var StagehandAPIClient = class {
|
|
39958
40210
|
constructor({ apiKey, projectId, logger }) {
|
|
@@ -40047,7 +40299,7 @@ var StagehandAPIClient = class {
|
|
|
40047
40299
|
options,
|
|
40048
40300
|
frameId
|
|
40049
40301
|
}) {
|
|
40050
|
-
const jsonSchema2 = zodSchema2 ?
|
|
40302
|
+
const jsonSchema2 = zodSchema2 ? toJsonSchema(zodSchema2) : void 0;
|
|
40051
40303
|
const args = {
|
|
40052
40304
|
schema: jsonSchema2,
|
|
40053
40305
|
instruction,
|
|
@@ -41587,14 +41839,14 @@ function isObserveResult(v) {
|
|
|
41587
41839
|
|
|
41588
41840
|
// lib/v3Evaluator.ts
|
|
41589
41841
|
var import_dotenv2 = __toESM(require("dotenv"));
|
|
41590
|
-
var
|
|
41842
|
+
var import_zod17 = require("zod");
|
|
41591
41843
|
init_sdkErrors();
|
|
41592
41844
|
import_dotenv2.default.config();
|
|
41593
|
-
var EvaluationSchema =
|
|
41594
|
-
evaluation:
|
|
41595
|
-
reasoning:
|
|
41845
|
+
var EvaluationSchema = import_zod17.z.object({
|
|
41846
|
+
evaluation: import_zod17.z.enum(["YES", "NO"]),
|
|
41847
|
+
reasoning: import_zod17.z.string()
|
|
41596
41848
|
});
|
|
41597
|
-
var BatchEvaluationSchema =
|
|
41849
|
+
var BatchEvaluationSchema = import_zod17.z.array(EvaluationSchema);
|
|
41598
41850
|
var V3Evaluator = class {
|
|
41599
41851
|
constructor(v3, modelName, modelClientOptions) {
|
|
41600
41852
|
this.silentLogger = () => {
|
|
@@ -41885,12 +42137,15 @@ I'm providing ${screenshots.length} screenshots showing the progression of the t
|
|
|
41885
42137
|
getZodType,
|
|
41886
42138
|
injectUrls,
|
|
41887
42139
|
isRunningInBun,
|
|
42140
|
+
isZod3Schema,
|
|
42141
|
+
isZod4Schema,
|
|
41888
42142
|
jsonSchemaToZod,
|
|
41889
42143
|
loadApiKeyFromEnv,
|
|
41890
42144
|
modelToAgentProviderMap,
|
|
41891
42145
|
pageTextSchema,
|
|
41892
42146
|
providerEnvVarMap,
|
|
41893
42147
|
toGeminiSchema,
|
|
42148
|
+
toJsonSchema,
|
|
41894
42149
|
transformSchema,
|
|
41895
42150
|
trimTrailingTextNode,
|
|
41896
42151
|
validateZodSchema
|