@browserbasehq/orca 3.0.3-patch → 3.0.3-zod-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/LICENSE +21 -0
- package/dist/index.d.ts +56 -31
- package/dist/index.js +521 -256
- package/package.json +23 -21
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.3-
|
|
88
|
+
STAGEHAND_VERSION = "3.0.3-zod-1";
|
|
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,174 @@ var import_process2 = __toESM(require("process"));
|
|
|
7957
7960
|
// lib/utils.ts
|
|
7958
7961
|
init_sdkErrors();
|
|
7959
7962
|
var import_genai = require("@google/genai");
|
|
7960
|
-
var
|
|
7963
|
+
var import_zod2 = require("zod");
|
|
7964
|
+
var import_v3 = __toESM(require("zod/v3"));
|
|
7965
|
+
|
|
7966
|
+
// lib/v3/zodCompat.ts
|
|
7967
|
+
var import_zod = require("zod");
|
|
7968
|
+
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
|
|
7969
|
+
var isZod4Schema = (schema) => typeof schema._zod !== "undefined";
|
|
7970
|
+
var isZod3Schema = (schema) => !isZod4Schema(schema);
|
|
7971
|
+
function toJsonSchema(schema) {
|
|
7972
|
+
if (!isZod4Schema(schema)) {
|
|
7973
|
+
return (0, import_zod_to_json_schema.default)(schema);
|
|
7974
|
+
}
|
|
7975
|
+
const zodWithJsonSchema = import_zod.z;
|
|
7976
|
+
if (zodWithJsonSchema.toJSONSchema) {
|
|
7977
|
+
return zodWithJsonSchema.toJSONSchema(schema);
|
|
7978
|
+
}
|
|
7979
|
+
throw new Error("Zod v4 toJSONSchema method not found");
|
|
7980
|
+
}
|
|
7981
|
+
|
|
7982
|
+
// lib/utils.ts
|
|
7961
7983
|
var ID_PATTERN = /^\d+-\d+$/;
|
|
7984
|
+
var zFactories = {
|
|
7985
|
+
v4: import_zod2.z,
|
|
7986
|
+
v3: import_v3.default
|
|
7987
|
+
};
|
|
7988
|
+
function getZFactory(schema) {
|
|
7989
|
+
return isZod4Schema(schema) ? zFactories.v4 : zFactories.v3;
|
|
7990
|
+
}
|
|
7991
|
+
var TYPE_NAME_MAP = {
|
|
7992
|
+
ZodString: "string",
|
|
7993
|
+
string: "string",
|
|
7994
|
+
ZodNumber: "number",
|
|
7995
|
+
number: "number",
|
|
7996
|
+
ZodBoolean: "boolean",
|
|
7997
|
+
boolean: "boolean",
|
|
7998
|
+
ZodObject: "object",
|
|
7999
|
+
object: "object",
|
|
8000
|
+
ZodArray: "array",
|
|
8001
|
+
array: "array",
|
|
8002
|
+
ZodUnion: "union",
|
|
8003
|
+
union: "union",
|
|
8004
|
+
ZodIntersection: "intersection",
|
|
8005
|
+
intersection: "intersection",
|
|
8006
|
+
ZodOptional: "optional",
|
|
8007
|
+
optional: "optional",
|
|
8008
|
+
ZodNullable: "nullable",
|
|
8009
|
+
nullable: "nullable",
|
|
8010
|
+
ZodLiteral: "literal",
|
|
8011
|
+
literal: "literal",
|
|
8012
|
+
ZodEnum: "enum",
|
|
8013
|
+
enum: "enum",
|
|
8014
|
+
ZodDefault: "default",
|
|
8015
|
+
default: "default",
|
|
8016
|
+
ZodEffects: "effects",
|
|
8017
|
+
effects: "effects",
|
|
8018
|
+
pipe: "pipe"
|
|
8019
|
+
};
|
|
8020
|
+
function getZ4Def(schema) {
|
|
8021
|
+
var _a;
|
|
8022
|
+
return (_a = schema._zod) == null ? void 0 : _a.def;
|
|
8023
|
+
}
|
|
8024
|
+
function getZ4Bag(schema) {
|
|
8025
|
+
var _a;
|
|
8026
|
+
return (_a = schema._zod) == null ? void 0 : _a.bag;
|
|
8027
|
+
}
|
|
8028
|
+
function getZ3Def(schema) {
|
|
8029
|
+
return schema._def;
|
|
8030
|
+
}
|
|
8031
|
+
function getObjectShape(schema) {
|
|
8032
|
+
var _a, _b;
|
|
8033
|
+
const z4Shape = (_a = getZ4Def(schema)) == null ? void 0 : _a.shape;
|
|
8034
|
+
if (z4Shape) {
|
|
8035
|
+
return z4Shape;
|
|
8036
|
+
}
|
|
8037
|
+
const z3Shape = (_b = getZ3Def(schema)) == null ? void 0 : _b.shape;
|
|
8038
|
+
if (!z3Shape) {
|
|
8039
|
+
return void 0;
|
|
8040
|
+
}
|
|
8041
|
+
if (typeof z3Shape === "function") {
|
|
8042
|
+
return z3Shape();
|
|
8043
|
+
}
|
|
8044
|
+
return z3Shape;
|
|
8045
|
+
}
|
|
8046
|
+
function getArrayElement(schema) {
|
|
8047
|
+
var _a, _b, _c;
|
|
8048
|
+
return (_c = (_a = getZ4Def(schema)) == null ? void 0 : _a.element) != null ? _c : (_b = getZ3Def(schema)) == null ? void 0 : _b.type;
|
|
8049
|
+
}
|
|
8050
|
+
function getInnerType(schema) {
|
|
8051
|
+
var _a, _b, _c;
|
|
8052
|
+
return (_c = (_a = getZ4Def(schema)) == null ? void 0 : _a.innerType) != null ? _c : (_b = getZ3Def(schema)) == null ? void 0 : _b.innerType;
|
|
8053
|
+
}
|
|
8054
|
+
function getUnionOptions(schema) {
|
|
8055
|
+
var _a, _b;
|
|
8056
|
+
const z4Options = (_a = getZ4Def(schema)) == null ? void 0 : _a.options;
|
|
8057
|
+
if (Array.isArray(z4Options)) {
|
|
8058
|
+
return z4Options;
|
|
8059
|
+
}
|
|
8060
|
+
const z3Options = (_b = getZ3Def(schema)) == null ? void 0 : _b.options;
|
|
8061
|
+
return Array.isArray(z3Options) ? z3Options : void 0;
|
|
8062
|
+
}
|
|
8063
|
+
function getIntersectionSides(schema) {
|
|
8064
|
+
const z4Def = getZ4Def(schema);
|
|
8065
|
+
if ((z4Def == null ? void 0 : z4Def.left) || (z4Def == null ? void 0 : z4Def.right)) {
|
|
8066
|
+
return {
|
|
8067
|
+
left: z4Def == null ? void 0 : z4Def.left,
|
|
8068
|
+
right: z4Def == null ? void 0 : z4Def.right
|
|
8069
|
+
};
|
|
8070
|
+
}
|
|
8071
|
+
const z3Def = getZ3Def(schema);
|
|
8072
|
+
return {
|
|
8073
|
+
left: z3Def == null ? void 0 : z3Def.left,
|
|
8074
|
+
right: z3Def == null ? void 0 : z3Def.right
|
|
8075
|
+
};
|
|
8076
|
+
}
|
|
8077
|
+
function getEnumValues(schema) {
|
|
8078
|
+
var _a, _b;
|
|
8079
|
+
const z4Entries = (_a = getZ4Def(schema)) == null ? void 0 : _a.entries;
|
|
8080
|
+
if (z4Entries && typeof z4Entries === "object") {
|
|
8081
|
+
return Object.values(z4Entries);
|
|
8082
|
+
}
|
|
8083
|
+
const z3Values = (_b = getZ3Def(schema)) == null ? void 0 : _b.values;
|
|
8084
|
+
return Array.isArray(z3Values) ? z3Values : void 0;
|
|
8085
|
+
}
|
|
8086
|
+
function getLiteralValues(schema) {
|
|
8087
|
+
var _a, _b;
|
|
8088
|
+
const z4Values = (_a = getZ4Def(schema)) == null ? void 0 : _a.values;
|
|
8089
|
+
if (Array.isArray(z4Values)) {
|
|
8090
|
+
return z4Values;
|
|
8091
|
+
}
|
|
8092
|
+
const value = (_b = getZ3Def(schema)) == null ? void 0 : _b.value;
|
|
8093
|
+
return typeof value !== "undefined" ? [value] : [];
|
|
8094
|
+
}
|
|
8095
|
+
function getStringChecks(schema) {
|
|
8096
|
+
var _a, _b;
|
|
8097
|
+
const z4Checks = (_a = getZ4Def(schema)) == null ? void 0 : _a.checks;
|
|
8098
|
+
if (Array.isArray(z4Checks)) {
|
|
8099
|
+
return z4Checks;
|
|
8100
|
+
}
|
|
8101
|
+
const z3Checks = (_b = getZ3Def(schema)) == null ? void 0 : _b.checks;
|
|
8102
|
+
return Array.isArray(z3Checks) ? z3Checks : [];
|
|
8103
|
+
}
|
|
8104
|
+
function getStringFormat(schema) {
|
|
8105
|
+
var _a, _b, _c;
|
|
8106
|
+
const bagFormat = (_a = getZ4Bag(schema)) == null ? void 0 : _a.format;
|
|
8107
|
+
if (typeof bagFormat === "string") {
|
|
8108
|
+
return bagFormat;
|
|
8109
|
+
}
|
|
8110
|
+
const z4Format = (_b = getZ4Def(schema)) == null ? void 0 : _b.format;
|
|
8111
|
+
if (typeof z4Format === "string") {
|
|
8112
|
+
return z4Format;
|
|
8113
|
+
}
|
|
8114
|
+
const z3Format = (_c = getZ3Def(schema)) == null ? void 0 : _c.format;
|
|
8115
|
+
return typeof z3Format === "string" ? z3Format : void 0;
|
|
8116
|
+
}
|
|
8117
|
+
function getPipeEndpoints(schema) {
|
|
8118
|
+
const z4Def = getZ4Def(schema);
|
|
8119
|
+
if ((z4Def == null ? void 0 : z4Def.in) || (z4Def == null ? void 0 : z4Def.out)) {
|
|
8120
|
+
return {
|
|
8121
|
+
in: z4Def == null ? void 0 : z4Def.in,
|
|
8122
|
+
out: z4Def == null ? void 0 : z4Def.out
|
|
8123
|
+
};
|
|
8124
|
+
}
|
|
8125
|
+
return {};
|
|
8126
|
+
}
|
|
8127
|
+
function getEffectsBaseSchema(schema) {
|
|
8128
|
+
var _a;
|
|
8129
|
+
return (_a = getZ3Def(schema)) == null ? void 0 : _a.schema;
|
|
8130
|
+
}
|
|
7962
8131
|
function validateZodSchema(schema, data) {
|
|
7963
8132
|
const result = schema.safeParse(data);
|
|
7964
8133
|
if (result.success) {
|
|
@@ -7979,118 +8148,150 @@ function decorateGeminiSchema(geminiSchema, zodSchema2) {
|
|
|
7979
8148
|
return geminiSchema;
|
|
7980
8149
|
}
|
|
7981
8150
|
function toGeminiSchema(zodSchema2) {
|
|
8151
|
+
var _a, _b;
|
|
8152
|
+
const normalizedSchema = zodSchema2;
|
|
7982
8153
|
const zodType = getZodType(zodSchema2);
|
|
7983
8154
|
switch (zodType) {
|
|
7984
|
-
case "
|
|
8155
|
+
case "array": {
|
|
8156
|
+
const element = (_a = getArrayElement(zodSchema2)) != null ? _a : import_zod2.z.any();
|
|
7985
8157
|
return decorateGeminiSchema(
|
|
7986
8158
|
{
|
|
7987
8159
|
type: import_genai.Type.ARRAY,
|
|
7988
|
-
items: toGeminiSchema(
|
|
7989
|
-
zodSchema2.element
|
|
7990
|
-
)
|
|
8160
|
+
items: toGeminiSchema(element)
|
|
7991
8161
|
},
|
|
7992
|
-
|
|
8162
|
+
normalizedSchema
|
|
7993
8163
|
);
|
|
7994
8164
|
}
|
|
7995
|
-
case "
|
|
8165
|
+
case "object": {
|
|
7996
8166
|
const properties = {};
|
|
7997
8167
|
const required = [];
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8168
|
+
const shape = getObjectShape(zodSchema2);
|
|
8169
|
+
if (shape) {
|
|
8170
|
+
Object.entries(shape).forEach(
|
|
8171
|
+
([key, value]) => {
|
|
8172
|
+
properties[key] = toGeminiSchema(value);
|
|
8173
|
+
if (getZodType(value) !== "optional") {
|
|
8174
|
+
required.push(key);
|
|
8175
|
+
}
|
|
8003
8176
|
}
|
|
8004
|
-
|
|
8005
|
-
|
|
8177
|
+
);
|
|
8178
|
+
}
|
|
8006
8179
|
return decorateGeminiSchema(
|
|
8007
8180
|
{
|
|
8008
8181
|
type: import_genai.Type.OBJECT,
|
|
8009
8182
|
properties,
|
|
8010
8183
|
required: required.length > 0 ? required : void 0
|
|
8011
8184
|
},
|
|
8012
|
-
|
|
8185
|
+
normalizedSchema
|
|
8013
8186
|
);
|
|
8014
8187
|
}
|
|
8015
|
-
case "
|
|
8188
|
+
case "string":
|
|
8016
8189
|
return decorateGeminiSchema(
|
|
8017
8190
|
{
|
|
8018
8191
|
type: import_genai.Type.STRING
|
|
8019
8192
|
},
|
|
8020
|
-
|
|
8193
|
+
normalizedSchema
|
|
8021
8194
|
);
|
|
8022
|
-
case "
|
|
8195
|
+
case "number":
|
|
8023
8196
|
return decorateGeminiSchema(
|
|
8024
8197
|
{
|
|
8025
8198
|
type: import_genai.Type.NUMBER
|
|
8026
8199
|
},
|
|
8027
|
-
|
|
8200
|
+
normalizedSchema
|
|
8028
8201
|
);
|
|
8029
|
-
case "
|
|
8202
|
+
case "boolean":
|
|
8030
8203
|
return decorateGeminiSchema(
|
|
8031
8204
|
{
|
|
8032
8205
|
type: import_genai.Type.BOOLEAN
|
|
8033
8206
|
},
|
|
8034
|
-
|
|
8207
|
+
normalizedSchema
|
|
8035
8208
|
);
|
|
8036
|
-
case "
|
|
8209
|
+
case "enum": {
|
|
8210
|
+
const values = getEnumValues(zodSchema2);
|
|
8037
8211
|
return decorateGeminiSchema(
|
|
8038
8212
|
{
|
|
8039
8213
|
type: import_genai.Type.STRING,
|
|
8040
|
-
enum:
|
|
8214
|
+
enum: values
|
|
8041
8215
|
},
|
|
8042
|
-
|
|
8216
|
+
normalizedSchema
|
|
8043
8217
|
);
|
|
8044
|
-
|
|
8045
|
-
case "
|
|
8046
|
-
case "
|
|
8047
|
-
|
|
8218
|
+
}
|
|
8219
|
+
case "default":
|
|
8220
|
+
case "nullable":
|
|
8221
|
+
case "optional": {
|
|
8222
|
+
const innerType = (_b = getInnerType(zodSchema2)) != null ? _b : import_zod2.z.any();
|
|
8223
|
+
const innerSchema = toGeminiSchema(innerType);
|
|
8048
8224
|
return decorateGeminiSchema(
|
|
8049
8225
|
__spreadProps(__spreadValues({}, innerSchema), {
|
|
8050
8226
|
nullable: true
|
|
8051
8227
|
}),
|
|
8052
|
-
|
|
8228
|
+
normalizedSchema
|
|
8053
8229
|
);
|
|
8054
8230
|
}
|
|
8055
|
-
case "
|
|
8231
|
+
case "literal": {
|
|
8232
|
+
const values = getLiteralValues(zodSchema2);
|
|
8056
8233
|
return decorateGeminiSchema(
|
|
8057
8234
|
{
|
|
8058
8235
|
type: import_genai.Type.STRING,
|
|
8059
|
-
enum:
|
|
8236
|
+
enum: values
|
|
8237
|
+
},
|
|
8238
|
+
normalizedSchema
|
|
8239
|
+
);
|
|
8240
|
+
}
|
|
8241
|
+
case "pipe": {
|
|
8242
|
+
const endpoints = getPipeEndpoints(zodSchema2);
|
|
8243
|
+
if (endpoints.in) {
|
|
8244
|
+
return toGeminiSchema(endpoints.in);
|
|
8245
|
+
}
|
|
8246
|
+
return decorateGeminiSchema(
|
|
8247
|
+
{
|
|
8248
|
+
type: import_genai.Type.STRING
|
|
8060
8249
|
},
|
|
8061
|
-
|
|
8250
|
+
normalizedSchema
|
|
8062
8251
|
);
|
|
8252
|
+
}
|
|
8253
|
+
// Standalone transforms and any unknown types fall through to default
|
|
8063
8254
|
default:
|
|
8064
8255
|
return decorateGeminiSchema(
|
|
8065
8256
|
{
|
|
8066
|
-
type: import_genai.Type.
|
|
8067
|
-
nullable: true
|
|
8257
|
+
type: import_genai.Type.STRING
|
|
8068
8258
|
},
|
|
8069
|
-
|
|
8259
|
+
normalizedSchema
|
|
8070
8260
|
);
|
|
8071
8261
|
}
|
|
8072
8262
|
}
|
|
8073
8263
|
function getZodType(schema) {
|
|
8074
|
-
|
|
8264
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8265
|
+
const schemaWithDef = schema;
|
|
8266
|
+
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;
|
|
8267
|
+
if (!rawType) {
|
|
8268
|
+
return "unknown";
|
|
8269
|
+
}
|
|
8270
|
+
return (_g = TYPE_NAME_MAP[rawType]) != null ? _g : rawType;
|
|
8075
8271
|
}
|
|
8076
8272
|
function transformSchema(schema, currentPath) {
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
const
|
|
8080
|
-
|
|
8081
|
-
|
|
8273
|
+
if (isKind(schema, "string")) {
|
|
8274
|
+
const checks = getStringChecks(schema);
|
|
8275
|
+
const format = getStringFormat(schema);
|
|
8276
|
+
const hasUrlCheck = checks.some((check) => {
|
|
8277
|
+
var _a, _b, _c, _d;
|
|
8278
|
+
const candidate = check;
|
|
8279
|
+
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";
|
|
8280
|
+
}) || format === "url";
|
|
8082
8281
|
if (hasUrlCheck) {
|
|
8083
8282
|
return [makeIdStringSchema(schema), [{ segments: [] }]];
|
|
8084
8283
|
}
|
|
8085
8284
|
return [schema, []];
|
|
8086
8285
|
}
|
|
8087
|
-
if (isKind(schema,
|
|
8088
|
-
const shape = schema
|
|
8286
|
+
if (isKind(schema, "object")) {
|
|
8287
|
+
const shape = getObjectShape(schema);
|
|
8288
|
+
if (!shape) {
|
|
8289
|
+
return [schema, []];
|
|
8290
|
+
}
|
|
8089
8291
|
const newShape = {};
|
|
8090
8292
|
const urlPaths = [];
|
|
8091
8293
|
let changed = false;
|
|
8092
|
-
const
|
|
8093
|
-
for (const key of shapeKeys) {
|
|
8294
|
+
for (const key of Object.keys(shape)) {
|
|
8094
8295
|
const child = shape[key];
|
|
8095
8296
|
const [transformedChild, childPaths] = transformSchema(child, [
|
|
8096
8297
|
...currentPath,
|
|
@@ -8100,34 +8301,45 @@ function transformSchema(schema, currentPath) {
|
|
|
8100
8301
|
changed = true;
|
|
8101
8302
|
}
|
|
8102
8303
|
newShape[key] = transformedChild;
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
}
|
|
8107
|
-
}
|
|
8304
|
+
childPaths.forEach((cp) => {
|
|
8305
|
+
urlPaths.push({ segments: [key, ...cp.segments] });
|
|
8306
|
+
});
|
|
8108
8307
|
}
|
|
8109
8308
|
if (changed) {
|
|
8110
|
-
|
|
8309
|
+
const factory6 = getZFactory(schema);
|
|
8310
|
+
return [
|
|
8311
|
+
factory6.object(newShape),
|
|
8312
|
+
urlPaths
|
|
8313
|
+
];
|
|
8111
8314
|
}
|
|
8112
8315
|
return [schema, urlPaths];
|
|
8113
8316
|
}
|
|
8114
|
-
if (isKind(schema,
|
|
8115
|
-
const itemType = schema
|
|
8317
|
+
if (isKind(schema, "array")) {
|
|
8318
|
+
const itemType = getArrayElement(schema);
|
|
8319
|
+
if (!itemType) {
|
|
8320
|
+
return [schema, []];
|
|
8321
|
+
}
|
|
8116
8322
|
const [transformedItem, childPaths] = transformSchema(itemType, [
|
|
8117
8323
|
...currentPath,
|
|
8118
8324
|
"*"
|
|
8119
8325
|
]);
|
|
8120
|
-
const changed = transformedItem !== itemType;
|
|
8121
8326
|
const arrayPaths = childPaths.map((cp) => ({
|
|
8122
8327
|
segments: ["*", ...cp.segments]
|
|
8123
8328
|
}));
|
|
8124
|
-
if (
|
|
8125
|
-
|
|
8329
|
+
if (transformedItem !== itemType) {
|
|
8330
|
+
const factory6 = getZFactory(schema);
|
|
8331
|
+
return [
|
|
8332
|
+
factory6.array(transformedItem),
|
|
8333
|
+
arrayPaths
|
|
8334
|
+
];
|
|
8126
8335
|
}
|
|
8127
8336
|
return [schema, arrayPaths];
|
|
8128
8337
|
}
|
|
8129
|
-
if (isKind(schema,
|
|
8130
|
-
const unionOptions = schema
|
|
8338
|
+
if (isKind(schema, "union")) {
|
|
8339
|
+
const unionOptions = getUnionOptions(schema);
|
|
8340
|
+
if (!unionOptions || unionOptions.length === 0) {
|
|
8341
|
+
return [schema, []];
|
|
8342
|
+
}
|
|
8131
8343
|
const newOptions = [];
|
|
8132
8344
|
let changed = false;
|
|
8133
8345
|
let allPaths = [];
|
|
@@ -8143,54 +8355,94 @@ function transformSchema(schema, currentPath) {
|
|
|
8143
8355
|
allPaths = [...allPaths, ...childPaths];
|
|
8144
8356
|
});
|
|
8145
8357
|
if (changed) {
|
|
8358
|
+
const factory6 = getZFactory(schema);
|
|
8146
8359
|
return [
|
|
8147
|
-
|
|
8360
|
+
factory6.union(
|
|
8361
|
+
newOptions
|
|
8362
|
+
),
|
|
8148
8363
|
allPaths
|
|
8149
8364
|
];
|
|
8150
8365
|
}
|
|
8151
8366
|
return [schema, allPaths];
|
|
8152
8367
|
}
|
|
8153
|
-
if (isKind(schema,
|
|
8154
|
-
const
|
|
8155
|
-
|
|
8156
|
-
|
|
8368
|
+
if (isKind(schema, "intersection")) {
|
|
8369
|
+
const { left, right } = getIntersectionSides(schema);
|
|
8370
|
+
if (!left || !right) {
|
|
8371
|
+
return [schema, []];
|
|
8372
|
+
}
|
|
8373
|
+
const [newLeft, leftPaths] = transformSchema(left, [
|
|
8157
8374
|
...currentPath,
|
|
8158
8375
|
"intersection_left"
|
|
8159
8376
|
]);
|
|
8160
|
-
const [
|
|
8377
|
+
const [newRight, rightPaths] = transformSchema(right, [
|
|
8161
8378
|
...currentPath,
|
|
8162
8379
|
"intersection_right"
|
|
8163
8380
|
]);
|
|
8164
|
-
const changed =
|
|
8381
|
+
const changed = newLeft !== left || newRight !== right;
|
|
8165
8382
|
const allPaths = [...leftPaths, ...rightPaths];
|
|
8166
8383
|
if (changed) {
|
|
8167
|
-
|
|
8384
|
+
const factory6 = getZFactory(schema);
|
|
8385
|
+
return [
|
|
8386
|
+
factory6.intersection(
|
|
8387
|
+
newLeft,
|
|
8388
|
+
newRight
|
|
8389
|
+
),
|
|
8390
|
+
allPaths
|
|
8391
|
+
];
|
|
8168
8392
|
}
|
|
8169
8393
|
return [schema, allPaths];
|
|
8170
8394
|
}
|
|
8171
|
-
if (isKind(schema,
|
|
8172
|
-
const innerType = schema
|
|
8395
|
+
if (isKind(schema, "optional")) {
|
|
8396
|
+
const innerType = getInnerType(schema);
|
|
8397
|
+
if (!innerType) {
|
|
8398
|
+
return [schema, []];
|
|
8399
|
+
}
|
|
8173
8400
|
const [inner, innerPaths] = transformSchema(innerType, currentPath);
|
|
8174
8401
|
if (inner !== innerType) {
|
|
8175
|
-
return [
|
|
8402
|
+
return [
|
|
8403
|
+
inner.optional(),
|
|
8404
|
+
innerPaths
|
|
8405
|
+
];
|
|
8176
8406
|
}
|
|
8177
8407
|
return [schema, innerPaths];
|
|
8178
8408
|
}
|
|
8179
|
-
if (isKind(schema,
|
|
8180
|
-
const innerType = schema
|
|
8409
|
+
if (isKind(schema, "nullable")) {
|
|
8410
|
+
const innerType = getInnerType(schema);
|
|
8411
|
+
if (!innerType) {
|
|
8412
|
+
return [schema, []];
|
|
8413
|
+
}
|
|
8181
8414
|
const [inner, innerPaths] = transformSchema(innerType, currentPath);
|
|
8182
8415
|
if (inner !== innerType) {
|
|
8183
|
-
return [
|
|
8416
|
+
return [
|
|
8417
|
+
inner.nullable(),
|
|
8418
|
+
innerPaths
|
|
8419
|
+
];
|
|
8184
8420
|
}
|
|
8185
8421
|
return [schema, innerPaths];
|
|
8186
8422
|
}
|
|
8187
|
-
if (isKind(schema,
|
|
8188
|
-
const
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8423
|
+
if (isKind(schema, "pipe") && isZod4Schema(schema)) {
|
|
8424
|
+
const { in: inSchema, out: outSchema } = getPipeEndpoints(schema);
|
|
8425
|
+
if (!inSchema || !outSchema) {
|
|
8426
|
+
return [schema, []];
|
|
8427
|
+
}
|
|
8428
|
+
const [newIn, inPaths] = transformSchema(inSchema, currentPath);
|
|
8429
|
+
const [newOut, outPaths] = transformSchema(outSchema, currentPath);
|
|
8430
|
+
const allPaths = [...inPaths, ...outPaths];
|
|
8431
|
+
if (newIn !== inSchema || newOut !== outSchema) {
|
|
8432
|
+
const result = import_zod2.z.pipe(
|
|
8433
|
+
newIn,
|
|
8434
|
+
newOut
|
|
8435
|
+
);
|
|
8436
|
+
return [result, allPaths];
|
|
8192
8437
|
}
|
|
8193
|
-
return [schema,
|
|
8438
|
+
return [schema, allPaths];
|
|
8439
|
+
}
|
|
8440
|
+
if (isKind(schema, "effects")) {
|
|
8441
|
+
const baseSchema = getEffectsBaseSchema(schema);
|
|
8442
|
+
if (!baseSchema) {
|
|
8443
|
+
return [schema, []];
|
|
8444
|
+
}
|
|
8445
|
+
return transformSchema(baseSchema, currentPath);
|
|
8194
8446
|
}
|
|
8195
8447
|
return [schema, []];
|
|
8196
8448
|
}
|
|
@@ -8236,17 +8488,19 @@ function injectUrls(obj, path7, idToUrlMapping) {
|
|
|
8236
8488
|
}
|
|
8237
8489
|
}
|
|
8238
8490
|
function isKind(s, kind) {
|
|
8239
|
-
|
|
8491
|
+
try {
|
|
8492
|
+
return getZodType(s) === kind;
|
|
8493
|
+
} catch (e) {
|
|
8494
|
+
return false;
|
|
8495
|
+
}
|
|
8240
8496
|
}
|
|
8241
8497
|
function makeIdStringSchema(orig) {
|
|
8242
|
-
var _a
|
|
8243
|
-
const userDesc = (
|
|
8244
|
-
// Zod ≥3.23 exposes .description directly; fall back to _def for older minor versions
|
|
8245
|
-
(_c = (_b = orig.description) != null ? _b : (_a = orig._def) == null ? void 0 : _a.description) != null ? _c : ""
|
|
8246
|
-
);
|
|
8498
|
+
var _a;
|
|
8499
|
+
const userDesc = (_a = orig.description) != null ? _a : "";
|
|
8247
8500
|
const base = `This field must be the element-ID in the form 'frameId-backendId' (e.g. "0-432").`;
|
|
8248
8501
|
const composed = userDesc.trim().length > 0 ? `${base} that follows this user-defined description: ${userDesc}` : base;
|
|
8249
|
-
|
|
8502
|
+
const factory6 = getZFactory(orig);
|
|
8503
|
+
return factory6.string().regex(ID_PATTERN).describe(composed);
|
|
8250
8504
|
}
|
|
8251
8505
|
var providerEnvVarMap = {
|
|
8252
8506
|
openai: "OPENAI_API_KEY",
|
|
@@ -8292,7 +8546,7 @@ function jsonSchemaToZod(schema) {
|
|
|
8292
8546
|
for (const key in schema.properties) {
|
|
8293
8547
|
shape[key] = jsonSchemaToZod(schema.properties[key]);
|
|
8294
8548
|
}
|
|
8295
|
-
let zodObject =
|
|
8549
|
+
let zodObject = import_zod2.z.object(shape);
|
|
8296
8550
|
if (schema.required && Array.isArray(schema.required)) {
|
|
8297
8551
|
const requiredFields = schema.required.reduce(
|
|
8298
8552
|
(acc, field) => __spreadProps(__spreadValues({}, acc), { [field]: true }),
|
|
@@ -8305,30 +8559,37 @@ function jsonSchemaToZod(schema) {
|
|
|
8305
8559
|
}
|
|
8306
8560
|
return zodObject;
|
|
8307
8561
|
} else {
|
|
8308
|
-
return
|
|
8562
|
+
return import_zod2.z.object({});
|
|
8309
8563
|
}
|
|
8310
8564
|
case "array":
|
|
8311
8565
|
if (schema.items) {
|
|
8312
|
-
let zodArray =
|
|
8566
|
+
let zodArray = import_zod2.z.array(jsonSchemaToZod(schema.items));
|
|
8313
8567
|
if (schema.description) {
|
|
8314
8568
|
zodArray = zodArray.describe(schema.description);
|
|
8315
8569
|
}
|
|
8316
8570
|
return zodArray;
|
|
8317
8571
|
} else {
|
|
8318
|
-
return
|
|
8572
|
+
return import_zod2.z.array(import_zod2.z.any());
|
|
8319
8573
|
}
|
|
8320
8574
|
case "string": {
|
|
8321
8575
|
if (schema.enum) {
|
|
8322
|
-
return
|
|
8576
|
+
return import_zod2.z.string().refine((val) => schema.enum.includes(val));
|
|
8577
|
+
}
|
|
8578
|
+
let zodString = import_zod2.z.string();
|
|
8579
|
+
if (schema.format === "uri" || schema.format === "url") {
|
|
8580
|
+
zodString = zodString.url();
|
|
8581
|
+
} else if (schema.format === "email") {
|
|
8582
|
+
zodString = zodString.email();
|
|
8583
|
+
} else if (schema.format === "uuid") {
|
|
8584
|
+
zodString = zodString.uuid();
|
|
8323
8585
|
}
|
|
8324
|
-
let zodString = import_v3.z.string();
|
|
8325
8586
|
if (schema.description) {
|
|
8326
8587
|
zodString = zodString.describe(schema.description);
|
|
8327
8588
|
}
|
|
8328
8589
|
return zodString;
|
|
8329
8590
|
}
|
|
8330
8591
|
case "number": {
|
|
8331
|
-
let zodNumber =
|
|
8592
|
+
let zodNumber = import_zod2.z.number();
|
|
8332
8593
|
if (schema.minimum !== void 0) {
|
|
8333
8594
|
zodNumber = zodNumber.min(schema.minimum);
|
|
8334
8595
|
}
|
|
@@ -8341,14 +8602,14 @@ function jsonSchemaToZod(schema) {
|
|
|
8341
8602
|
return zodNumber;
|
|
8342
8603
|
}
|
|
8343
8604
|
case "boolean": {
|
|
8344
|
-
let zodBoolean =
|
|
8605
|
+
let zodBoolean = import_zod2.z.boolean();
|
|
8345
8606
|
if (schema.description) {
|
|
8346
8607
|
zodBoolean = zodBoolean.describe(schema.description);
|
|
8347
8608
|
}
|
|
8348
8609
|
return zodBoolean;
|
|
8349
8610
|
}
|
|
8350
8611
|
default:
|
|
8351
|
-
return
|
|
8612
|
+
return import_zod2.z.any();
|
|
8352
8613
|
}
|
|
8353
8614
|
}
|
|
8354
8615
|
|
|
@@ -9350,7 +9611,7 @@ var CacheStorage = class _CacheStorage {
|
|
|
9350
9611
|
};
|
|
9351
9612
|
|
|
9352
9613
|
// lib/inference.ts
|
|
9353
|
-
var
|
|
9614
|
+
var import_zod3 = require("zod");
|
|
9354
9615
|
|
|
9355
9616
|
// lib/prompt.ts
|
|
9356
9617
|
function buildUserInstructionsString(userProvidedInstructions) {
|
|
@@ -9609,11 +9870,11 @@ function extract(_0) {
|
|
|
9609
9870
|
logInferenceToFile = false
|
|
9610
9871
|
}) {
|
|
9611
9872
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
9612
|
-
const metadataSchema =
|
|
9613
|
-
progress:
|
|
9873
|
+
const metadataSchema = import_zod3.z.object({
|
|
9874
|
+
progress: import_zod3.z.string().describe(
|
|
9614
9875
|
"progress of what has been extracted so far, as concise as possible"
|
|
9615
9876
|
),
|
|
9616
|
-
completed:
|
|
9877
|
+
completed: import_zod3.z.boolean().describe(
|
|
9617
9878
|
"true if the goal is now accomplished. Use this conservatively, only when sure that the goal has been completed."
|
|
9618
9879
|
)
|
|
9619
9880
|
});
|
|
@@ -9771,20 +10032,20 @@ function observe(_0) {
|
|
|
9771
10032
|
}) {
|
|
9772
10033
|
var _a, _b, _c, _d, _e, _f;
|
|
9773
10034
|
const isGPT5 = llmClient.modelName.includes("gpt-5");
|
|
9774
|
-
const observeSchema =
|
|
9775
|
-
elements:
|
|
9776
|
-
|
|
9777
|
-
elementId:
|
|
10035
|
+
const observeSchema = import_zod3.z.object({
|
|
10036
|
+
elements: import_zod3.z.array(
|
|
10037
|
+
import_zod3.z.object({
|
|
10038
|
+
elementId: import_zod3.z.string().describe(
|
|
9778
10039
|
"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
|
|
9779
10040
|
),
|
|
9780
|
-
description:
|
|
10041
|
+
description: import_zod3.z.string().describe(
|
|
9781
10042
|
"a description of the accessible element and its purpose"
|
|
9782
10043
|
),
|
|
9783
|
-
method:
|
|
10044
|
+
method: import_zod3.z.string().describe(
|
|
9784
10045
|
"the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
|
|
9785
10046
|
),
|
|
9786
|
-
arguments:
|
|
9787
|
-
|
|
10047
|
+
arguments: import_zod3.z.array(
|
|
10048
|
+
import_zod3.z.string().describe(
|
|
9788
10049
|
"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."
|
|
9789
10050
|
)
|
|
9790
10051
|
)
|
|
@@ -9884,20 +10145,20 @@ function act(_0) {
|
|
|
9884
10145
|
}) {
|
|
9885
10146
|
var _a, _b, _c, _d;
|
|
9886
10147
|
const isGPT5 = llmClient.modelName.includes("gpt-5");
|
|
9887
|
-
const actSchema =
|
|
9888
|
-
elementId:
|
|
10148
|
+
const actSchema = import_zod3.z.object({
|
|
10149
|
+
elementId: import_zod3.z.string().describe(
|
|
9889
10150
|
"the ID string associated with the element. Never include surrounding square brackets. This field must follow the format of 'number-number'."
|
|
9890
10151
|
),
|
|
9891
|
-
description:
|
|
9892
|
-
method:
|
|
10152
|
+
description: import_zod3.z.string().describe("a description of the accessible element and its purpose"),
|
|
10153
|
+
method: import_zod3.z.string().describe(
|
|
9893
10154
|
"the candidate method/action to interact with the element. Select one of the available Playwright interaction methods."
|
|
9894
10155
|
),
|
|
9895
|
-
arguments:
|
|
9896
|
-
|
|
10156
|
+
arguments: import_zod3.z.array(
|
|
10157
|
+
import_zod3.z.string().describe(
|
|
9897
10158
|
"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."
|
|
9898
10159
|
)
|
|
9899
10160
|
),
|
|
9900
|
-
twoStep:
|
|
10161
|
+
twoStep: import_zod3.z.boolean()
|
|
9901
10162
|
});
|
|
9902
10163
|
const messages = [
|
|
9903
10164
|
buildActSystemPrompt(userProvidedInstructions),
|
|
@@ -9984,12 +10245,12 @@ function act(_0) {
|
|
|
9984
10245
|
init_logger();
|
|
9985
10246
|
|
|
9986
10247
|
// lib/v3/types/public/methods.ts
|
|
9987
|
-
var
|
|
9988
|
-
var defaultExtractSchema =
|
|
9989
|
-
extraction:
|
|
10248
|
+
var import_zod4 = require("zod");
|
|
10249
|
+
var defaultExtractSchema = import_zod4.z.object({
|
|
10250
|
+
extraction: import_zod4.z.string()
|
|
9990
10251
|
});
|
|
9991
|
-
var pageTextSchema =
|
|
9992
|
-
pageText:
|
|
10252
|
+
var pageTextSchema = import_zod4.z.object({
|
|
10253
|
+
pageText: import_zod4.z.string()
|
|
9993
10254
|
});
|
|
9994
10255
|
var V3FunctionName = /* @__PURE__ */ ((V3FunctionName2) => {
|
|
9995
10256
|
V3FunctionName2["ACT"] = "ACT";
|
|
@@ -11003,7 +11264,7 @@ var ActHandler = class {
|
|
|
11003
11264
|
// lib/v3/handlers/extractHandler.ts
|
|
11004
11265
|
init_logger();
|
|
11005
11266
|
init_snapshot();
|
|
11006
|
-
var
|
|
11267
|
+
var import_zod5 = require("zod");
|
|
11007
11268
|
init_sdkErrors();
|
|
11008
11269
|
function transformUrlStringsToNumericIds(schema) {
|
|
11009
11270
|
const [finalSchema, urlPaths] = transformSchema(schema, []);
|
|
@@ -11025,7 +11286,7 @@ var ExtractHandler = class {
|
|
|
11025
11286
|
const { instruction, schema, page, selector, timeout, model } = params;
|
|
11026
11287
|
const llmClient = this.resolveLlmClient(model);
|
|
11027
11288
|
const doExtract = () => __async(this, null, function* () {
|
|
11028
|
-
var _a, _b,
|
|
11289
|
+
var _a, _b, _d;
|
|
11029
11290
|
const noArgs = !instruction && !schema;
|
|
11030
11291
|
if (noArgs) {
|
|
11031
11292
|
const focusSelector2 = (_a = selector == null ? void 0 : selector.replace(/^xpath=/i, "")) != null ? _a : "";
|
|
@@ -11056,9 +11317,11 @@ var ExtractHandler = class {
|
|
|
11056
11317
|
auxiliary: instruction ? { instruction: { value: instruction, type: "string" } } : void 0
|
|
11057
11318
|
});
|
|
11058
11319
|
const baseSchema = schema != null ? schema : defaultExtractSchema;
|
|
11059
|
-
const isObjectSchema =
|
|
11320
|
+
const isObjectSchema = getZodType(baseSchema) === "object";
|
|
11060
11321
|
const WRAP_KEY = "value";
|
|
11061
|
-
const objectSchema = isObjectSchema ? baseSchema :
|
|
11322
|
+
const objectSchema = isObjectSchema ? baseSchema : import_zod5.z.object({
|
|
11323
|
+
[WRAP_KEY]: baseSchema
|
|
11324
|
+
});
|
|
11062
11325
|
const [transformedSchema, urlFieldPaths] = transformUrlStringsToNumericIds(objectSchema);
|
|
11063
11326
|
const extractionResponse = yield extract({
|
|
11064
11327
|
instruction,
|
|
@@ -11069,14 +11332,14 @@ var ExtractHandler = class {
|
|
|
11069
11332
|
logger: v3Logger,
|
|
11070
11333
|
logInferenceToFile: this.logInferenceToFile
|
|
11071
11334
|
});
|
|
11072
|
-
const
|
|
11335
|
+
const _c = extractionResponse, {
|
|
11073
11336
|
metadata: { completed },
|
|
11074
11337
|
prompt_tokens,
|
|
11075
11338
|
completion_tokens,
|
|
11076
11339
|
reasoning_tokens = 0,
|
|
11077
11340
|
cached_input_tokens = 0,
|
|
11078
11341
|
inference_time_ms
|
|
11079
|
-
} =
|
|
11342
|
+
} = _c, rest = __objRest(_c, [
|
|
11080
11343
|
"metadata",
|
|
11081
11344
|
"prompt_tokens",
|
|
11082
11345
|
"completion_tokens",
|
|
@@ -11101,7 +11364,7 @@ var ExtractHandler = class {
|
|
|
11101
11364
|
}
|
|
11102
11365
|
}
|
|
11103
11366
|
});
|
|
11104
|
-
(
|
|
11367
|
+
(_d = this.onMetrics) == null ? void 0 : _d.call(
|
|
11105
11368
|
this,
|
|
11106
11369
|
"EXTRACT" /* EXTRACT */,
|
|
11107
11370
|
prompt_tokens,
|
|
@@ -11126,12 +11389,14 @@ var ExtractHandler = class {
|
|
|
11126
11389
|
if (!timeout) return doExtract();
|
|
11127
11390
|
return yield Promise.race([
|
|
11128
11391
|
doExtract(),
|
|
11129
|
-
new Promise(
|
|
11130
|
-
|
|
11131
|
-
(
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11392
|
+
new Promise(
|
|
11393
|
+
(_, reject) => {
|
|
11394
|
+
setTimeout(
|
|
11395
|
+
() => reject(new Error(`extract() timed out after ${timeout}ms`)),
|
|
11396
|
+
timeout
|
|
11397
|
+
);
|
|
11398
|
+
}
|
|
11399
|
+
)
|
|
11135
11400
|
]);
|
|
11136
11401
|
});
|
|
11137
11402
|
}
|
|
@@ -11255,11 +11520,11 @@ var ObserveHandler = class {
|
|
|
11255
11520
|
|
|
11256
11521
|
// lib/v3/agent/tools/v3-goto.ts
|
|
11257
11522
|
var import_ai = require("ai");
|
|
11258
|
-
var
|
|
11523
|
+
var import_zod6 = require("zod");
|
|
11259
11524
|
var createGotoTool = (v3) => (0, import_ai.tool)({
|
|
11260
11525
|
description: "Navigate to a specific URL",
|
|
11261
|
-
inputSchema:
|
|
11262
|
-
url:
|
|
11526
|
+
inputSchema: import_zod6.z.object({
|
|
11527
|
+
url: import_zod6.z.string().describe("The URL to navigate to")
|
|
11263
11528
|
}),
|
|
11264
11529
|
execute: (_0) => __async(null, [_0], function* ({ url }) {
|
|
11265
11530
|
var _a;
|
|
@@ -11287,11 +11552,11 @@ var createGotoTool = (v3) => (0, import_ai.tool)({
|
|
|
11287
11552
|
|
|
11288
11553
|
// lib/v3/agent/tools/v3-act.ts
|
|
11289
11554
|
var import_ai2 = require("ai");
|
|
11290
|
-
var
|
|
11555
|
+
var import_zod7 = require("zod");
|
|
11291
11556
|
var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
|
|
11292
11557
|
description: "Perform an action on the page (click, type). Provide a short, specific phrase that mentions the element type.",
|
|
11293
|
-
inputSchema:
|
|
11294
|
-
action:
|
|
11558
|
+
inputSchema: import_zod7.z.object({
|
|
11559
|
+
action: import_zod7.z.string().describe(
|
|
11295
11560
|
'Describe what to click or type, e.g. "click the Login button" or "type "John" into the first name input"'
|
|
11296
11561
|
)
|
|
11297
11562
|
}),
|
|
@@ -11332,10 +11597,10 @@ var createActTool = (v3, executionModel) => (0, import_ai2.tool)({
|
|
|
11332
11597
|
|
|
11333
11598
|
// lib/v3/agent/tools/v3-screenshot.ts
|
|
11334
11599
|
var import_ai3 = require("ai");
|
|
11335
|
-
var
|
|
11600
|
+
var import_zod8 = require("zod");
|
|
11336
11601
|
var createScreenshotTool = (v3) => (0, import_ai3.tool)({
|
|
11337
11602
|
description: "Takes a screenshot (PNG) of the current page. Use this to quickly verify page state.",
|
|
11338
|
-
inputSchema:
|
|
11603
|
+
inputSchema: import_zod8.z.object({}),
|
|
11339
11604
|
execute: () => __async(null, null, function* () {
|
|
11340
11605
|
v3.logger({
|
|
11341
11606
|
category: "agent",
|
|
@@ -11359,11 +11624,11 @@ var createScreenshotTool = (v3) => (0, import_ai3.tool)({
|
|
|
11359
11624
|
|
|
11360
11625
|
// lib/v3/agent/tools/v3-wait.ts
|
|
11361
11626
|
var import_ai4 = require("ai");
|
|
11362
|
-
var
|
|
11627
|
+
var import_zod9 = require("zod");
|
|
11363
11628
|
var createWaitTool = (v3) => (0, import_ai4.tool)({
|
|
11364
11629
|
description: "Wait for a specified time",
|
|
11365
|
-
inputSchema:
|
|
11366
|
-
timeMs:
|
|
11630
|
+
inputSchema: import_zod9.z.object({
|
|
11631
|
+
timeMs: import_zod9.z.number().describe("Time in milliseconds")
|
|
11367
11632
|
}),
|
|
11368
11633
|
execute: (_0) => __async(null, [_0], function* ({ timeMs }) {
|
|
11369
11634
|
v3.logger({
|
|
@@ -11387,11 +11652,11 @@ var createWaitTool = (v3) => (0, import_ai4.tool)({
|
|
|
11387
11652
|
|
|
11388
11653
|
// lib/v3/agent/tools/v3-navback.ts
|
|
11389
11654
|
var import_ai5 = require("ai");
|
|
11390
|
-
var
|
|
11655
|
+
var import_zod10 = require("zod");
|
|
11391
11656
|
var createNavBackTool = (v3) => (0, import_ai5.tool)({
|
|
11392
11657
|
description: "Navigate back to the previous page",
|
|
11393
|
-
inputSchema:
|
|
11394
|
-
reasoningText:
|
|
11658
|
+
inputSchema: import_zod10.z.object({
|
|
11659
|
+
reasoningText: import_zod10.z.string().describe("Why you're going back")
|
|
11395
11660
|
}),
|
|
11396
11661
|
execute: () => __async(null, null, function* () {
|
|
11397
11662
|
v3.logger({
|
|
@@ -11411,12 +11676,12 @@ var createNavBackTool = (v3) => (0, import_ai5.tool)({
|
|
|
11411
11676
|
|
|
11412
11677
|
// lib/v3/agent/tools/v3-close.ts
|
|
11413
11678
|
var import_ai6 = require("ai");
|
|
11414
|
-
var
|
|
11679
|
+
var import_zod11 = require("zod");
|
|
11415
11680
|
var createCloseTool = () => (0, import_ai6.tool)({
|
|
11416
11681
|
description: "Complete the task and close",
|
|
11417
|
-
inputSchema:
|
|
11418
|
-
reasoning:
|
|
11419
|
-
taskComplete:
|
|
11682
|
+
inputSchema: import_zod11.z.object({
|
|
11683
|
+
reasoning: import_zod11.z.string().describe("Summary of what was accomplished"),
|
|
11684
|
+
taskComplete: import_zod11.z.boolean().describe("Whether the task was completed successfully")
|
|
11420
11685
|
}),
|
|
11421
11686
|
execute: (_0) => __async(null, [_0], function* ({ reasoning, taskComplete }) {
|
|
11422
11687
|
return { success: true, reasoning, taskComplete };
|
|
@@ -11425,10 +11690,10 @@ var createCloseTool = () => (0, import_ai6.tool)({
|
|
|
11425
11690
|
|
|
11426
11691
|
// lib/v3/agent/tools/v3-ariaTree.ts
|
|
11427
11692
|
var import_ai7 = require("ai");
|
|
11428
|
-
var
|
|
11693
|
+
var import_zod12 = require("zod");
|
|
11429
11694
|
var createAriaTreeTool = (v3) => (0, import_ai7.tool)({
|
|
11430
11695
|
description: "gets the accessibility (ARIA) hybrid tree text for the current page. use this to understand structure and content.",
|
|
11431
|
-
inputSchema:
|
|
11696
|
+
inputSchema: import_zod12.z.object({}),
|
|
11432
11697
|
execute: () => __async(null, null, function* () {
|
|
11433
11698
|
v3.logger({
|
|
11434
11699
|
category: "agent",
|
|
@@ -11456,17 +11721,17 @@ ${result.content}` }]
|
|
|
11456
11721
|
|
|
11457
11722
|
// lib/v3/agent/tools/v3-fillform.ts
|
|
11458
11723
|
var import_ai8 = require("ai");
|
|
11459
|
-
var
|
|
11724
|
+
var import_zod13 = require("zod");
|
|
11460
11725
|
var createFillFormTool = (v3, executionModel) => (0, import_ai8.tool)({
|
|
11461
11726
|
description: `\u{1F4DD} FORM FILL - MULTI-FIELD INPUT TOOL
|
|
11462
11727
|
For any form with 2+ inputs/textareas. Faster than individual typing.`,
|
|
11463
|
-
inputSchema:
|
|
11464
|
-
fields:
|
|
11465
|
-
|
|
11466
|
-
action:
|
|
11728
|
+
inputSchema: import_zod13.z.object({
|
|
11729
|
+
fields: import_zod13.z.array(
|
|
11730
|
+
import_zod13.z.object({
|
|
11731
|
+
action: import_zod13.z.string().describe(
|
|
11467
11732
|
'Description of typing action, e.g. "type foo into the email field"'
|
|
11468
11733
|
),
|
|
11469
|
-
value:
|
|
11734
|
+
value: import_zod13.z.string().describe("Text to type into the target")
|
|
11470
11735
|
})
|
|
11471
11736
|
).min(1, "Provide at least one field to fill")
|
|
11472
11737
|
}),
|
|
@@ -11510,12 +11775,12 @@ For any form with 2+ inputs/textareas. Faster than individual typing.`,
|
|
|
11510
11775
|
|
|
11511
11776
|
// lib/v3/agent/tools/v3-scroll.ts
|
|
11512
11777
|
var import_ai9 = require("ai");
|
|
11513
|
-
var
|
|
11778
|
+
var import_zod14 = require("zod");
|
|
11514
11779
|
var createScrollTool = (v3) => (0, import_ai9.tool)({
|
|
11515
11780
|
description: "Scroll the page",
|
|
11516
|
-
inputSchema:
|
|
11517
|
-
pixels:
|
|
11518
|
-
direction:
|
|
11781
|
+
inputSchema: import_zod14.z.object({
|
|
11782
|
+
pixels: import_zod14.z.number().describe("Number of pixels to scroll up or down"),
|
|
11783
|
+
direction: import_zod14.z.enum(["up", "down"]).describe("Direction to scroll")
|
|
11519
11784
|
}),
|
|
11520
11785
|
execute: (_0) => __async(null, [_0], function* ({ pixels, direction }) {
|
|
11521
11786
|
v3.logger({
|
|
@@ -11547,19 +11812,19 @@ var createScrollTool = (v3) => (0, import_ai9.tool)({
|
|
|
11547
11812
|
|
|
11548
11813
|
// lib/v3/agent/tools/v3-extract.ts
|
|
11549
11814
|
var import_ai10 = require("ai");
|
|
11550
|
-
var
|
|
11815
|
+
var import_zod15 = require("zod");
|
|
11551
11816
|
function evaluateZodSchema(schemaStr, logger) {
|
|
11552
11817
|
var _a;
|
|
11553
11818
|
try {
|
|
11554
11819
|
const fn = new Function("z", `return ${schemaStr}`);
|
|
11555
|
-
return fn(
|
|
11820
|
+
return fn(import_zod15.z);
|
|
11556
11821
|
} catch (e) {
|
|
11557
11822
|
logger == null ? void 0 : logger({
|
|
11558
11823
|
category: "agent",
|
|
11559
11824
|
message: `Failed to evaluate schema: ${(_a = e == null ? void 0 : e.message) != null ? _a : String(e)}`,
|
|
11560
11825
|
level: 0
|
|
11561
11826
|
});
|
|
11562
|
-
return
|
|
11827
|
+
return import_zod15.z.any();
|
|
11563
11828
|
}
|
|
11564
11829
|
}
|
|
11565
11830
|
var createExtractTool = (v3, executionModel, logger) => (0, import_ai10.tool)({
|
|
@@ -11581,9 +11846,9 @@ var createExtractTool = (v3, executionModel, logger) => (0, import_ai10.tool)({
|
|
|
11581
11846
|
3. Extract arrays:
|
|
11582
11847
|
instruction: "extract all product names and prices"
|
|
11583
11848
|
schema: "z.object({ products: z.array(z.object({ name: z.string(), price: z.number() })) })"`,
|
|
11584
|
-
inputSchema:
|
|
11585
|
-
instruction:
|
|
11586
|
-
schema:
|
|
11849
|
+
inputSchema: import_zod15.z.object({
|
|
11850
|
+
instruction: import_zod15.z.string(),
|
|
11851
|
+
schema: import_zod15.z.string().optional().describe("Zod schema as code, e.g. z.object({ title: z.string() })")
|
|
11587
11852
|
}),
|
|
11588
11853
|
execute: (_0) => __async(null, [_0], function* ({ instruction, schema }) {
|
|
11589
11854
|
var _a;
|
|
@@ -11995,7 +12260,6 @@ init_sdkErrors();
|
|
|
11995
12260
|
// lib/v3/agent/AnthropicCUAClient.ts
|
|
11996
12261
|
init_sdkErrors();
|
|
11997
12262
|
var import_sdk = __toESM(require("@anthropic-ai/sdk"));
|
|
11998
|
-
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
11999
12263
|
|
|
12000
12264
|
// lib/v3/agent/AgentClient.ts
|
|
12001
12265
|
var AgentClient = class {
|
|
@@ -12498,7 +12762,8 @@ var AnthropicCUAClient = class extends AgentClient {
|
|
|
12498
12762
|
};
|
|
12499
12763
|
if (this.tools && Object.keys(this.tools).length > 0) {
|
|
12500
12764
|
const customTools = Object.entries(this.tools).map(([name, tool12]) => {
|
|
12501
|
-
const
|
|
12765
|
+
const schema = tool12.inputSchema;
|
|
12766
|
+
const jsonSchema2 = toJsonSchema(schema);
|
|
12502
12767
|
const inputSchema = {
|
|
12503
12768
|
type: "object",
|
|
12504
12769
|
properties: jsonSchema2.properties || {},
|
|
@@ -13364,7 +13629,6 @@ init_sdkErrors();
|
|
|
13364
13629
|
|
|
13365
13630
|
// lib/v3/agent/utils/googleCustomToolHandler.ts
|
|
13366
13631
|
var import_genai2 = require("@google/genai");
|
|
13367
|
-
var import_zod_to_json_schema2 = require("zod-to-json-schema");
|
|
13368
13632
|
function executeGoogleCustomTool(toolName, toolArgs, tools, functionCall, logger) {
|
|
13369
13633
|
return __async(this, null, function* () {
|
|
13370
13634
|
try {
|
|
@@ -13432,7 +13696,8 @@ function convertToolSetToFunctionDeclarations(tools) {
|
|
|
13432
13696
|
}
|
|
13433
13697
|
function convertToolToFunctionDeclaration(name, tool12) {
|
|
13434
13698
|
try {
|
|
13435
|
-
const
|
|
13699
|
+
const schema = tool12.inputSchema;
|
|
13700
|
+
const jsonSchema2 = toJsonSchema(schema);
|
|
13436
13701
|
const parameters = convertJsonSchemaToGoogleParameters(jsonSchema2);
|
|
13437
13702
|
return {
|
|
13438
13703
|
name,
|
|
@@ -16103,7 +16368,6 @@ var AISdkClient = class extends LLMClient {
|
|
|
16103
16368
|
|
|
16104
16369
|
// lib/v3/llm/AnthropicClient.ts
|
|
16105
16370
|
var import_sdk3 = __toESM(require("@anthropic-ai/sdk"));
|
|
16106
|
-
var import_zod_to_json_schema3 = require("zod-to-json-schema");
|
|
16107
16371
|
init_sdkErrors();
|
|
16108
16372
|
var AnthropicClient = class extends LLMClient {
|
|
16109
16373
|
constructor({
|
|
@@ -16214,7 +16478,7 @@ var AnthropicClient = class extends LLMClient {
|
|
|
16214
16478
|
});
|
|
16215
16479
|
let toolDefinition;
|
|
16216
16480
|
if (options.response_model) {
|
|
16217
|
-
const jsonSchema2 = (
|
|
16481
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
16218
16482
|
const { properties: schemaProperties, required: schemaRequired } = extractSchemaProperties(jsonSchema2);
|
|
16219
16483
|
toolDefinition = {
|
|
16220
16484
|
name: "print_extracted_data",
|
|
@@ -16346,7 +16610,6 @@ var extractSchemaProperties = (jsonSchema2) => {
|
|
|
16346
16610
|
|
|
16347
16611
|
// lib/v3/llm/CerebrasClient.ts
|
|
16348
16612
|
var import_openai2 = __toESM(require("openai"));
|
|
16349
|
-
var import_zod_to_json_schema4 = require("zod-to-json-schema");
|
|
16350
16613
|
init_sdkErrors();
|
|
16351
16614
|
var CerebrasClient = class extends LLMClient {
|
|
16352
16615
|
constructor({
|
|
@@ -16409,7 +16672,7 @@ var CerebrasClient = class extends LLMClient {
|
|
|
16409
16672
|
}
|
|
16410
16673
|
}));
|
|
16411
16674
|
if (options.response_model) {
|
|
16412
|
-
const jsonSchema2 = (
|
|
16675
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
16413
16676
|
const schemaProperties = jsonSchema2.properties || {};
|
|
16414
16677
|
const schemaRequired = jsonSchema2.required || [];
|
|
16415
16678
|
const responseTool = {
|
|
@@ -16935,7 +17198,6 @@ ${firstPartText.text}`;
|
|
|
16935
17198
|
|
|
16936
17199
|
// lib/v3/llm/GroqClient.ts
|
|
16937
17200
|
var import_openai3 = __toESM(require("openai"));
|
|
16938
|
-
var import_zod_to_json_schema5 = require("zod-to-json-schema");
|
|
16939
17201
|
init_sdkErrors();
|
|
16940
17202
|
var GroqClient = class extends LLMClient {
|
|
16941
17203
|
constructor({
|
|
@@ -16998,7 +17260,7 @@ var GroqClient = class extends LLMClient {
|
|
|
16998
17260
|
}
|
|
16999
17261
|
}));
|
|
17000
17262
|
if (options.response_model) {
|
|
17001
|
-
const jsonSchema2 = (
|
|
17263
|
+
const jsonSchema2 = toJsonSchema(options.response_model.schema);
|
|
17002
17264
|
const schemaProperties = jsonSchema2.properties || {};
|
|
17003
17265
|
const schemaRequired = jsonSchema2.required || [];
|
|
17004
17266
|
const responseTool = {
|
|
@@ -17156,8 +17418,6 @@ var GroqClient = class extends LLMClient {
|
|
|
17156
17418
|
|
|
17157
17419
|
// lib/v3/llm/OpenAIClient.ts
|
|
17158
17420
|
var import_openai4 = __toESM(require("openai"));
|
|
17159
|
-
var import_zod = require("openai/helpers/zod");
|
|
17160
|
-
var import_zod_to_json_schema6 = __toESM(require("zod-to-json-schema"));
|
|
17161
17421
|
init_sdkErrors();
|
|
17162
17422
|
var OpenAIClient = class extends LLMClient {
|
|
17163
17423
|
constructor({
|
|
@@ -17264,12 +17524,12 @@ ${JSON.stringify(
|
|
|
17264
17524
|
};
|
|
17265
17525
|
options.messages.push(screenshotMessage);
|
|
17266
17526
|
}
|
|
17267
|
-
let responseFormat
|
|
17527
|
+
let responseFormat;
|
|
17268
17528
|
if (options.response_model) {
|
|
17269
17529
|
if (this.modelName.startsWith("o1") || this.modelName.startsWith("o3")) {
|
|
17270
17530
|
try {
|
|
17271
17531
|
const parsedSchema = JSON.stringify(
|
|
17272
|
-
(
|
|
17532
|
+
toJsonSchema(options.response_model.schema)
|
|
17273
17533
|
);
|
|
17274
17534
|
options.messages.push({
|
|
17275
17535
|
role: "user",
|
|
@@ -17295,10 +17555,13 @@ ${parsedSchema}
|
|
|
17295
17555
|
throw error;
|
|
17296
17556
|
}
|
|
17297
17557
|
} else {
|
|
17298
|
-
responseFormat =
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17558
|
+
responseFormat = {
|
|
17559
|
+
type: "json_schema",
|
|
17560
|
+
json_schema: {
|
|
17561
|
+
name: options.response_model.name,
|
|
17562
|
+
schema: toJsonSchema(options.response_model.schema)
|
|
17563
|
+
}
|
|
17564
|
+
};
|
|
17302
17565
|
}
|
|
17303
17566
|
}
|
|
17304
17567
|
const _d = __spreadProps(__spreadValues({}, optionsWithoutImageAndRequestId), {
|
|
@@ -17479,7 +17742,7 @@ ${parsedSchema}
|
|
|
17479
17742
|
}
|
|
17480
17743
|
};
|
|
17481
17744
|
|
|
17482
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@
|
|
17745
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17483
17746
|
var import_provider = require("@ai-sdk/provider");
|
|
17484
17747
|
var import_provider2 = require("@ai-sdk/provider");
|
|
17485
17748
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -17616,14 +17879,14 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
17616
17879
|
}
|
|
17617
17880
|
};
|
|
17618
17881
|
|
|
17619
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@
|
|
17882
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.12_zod@4.1.8/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
17620
17883
|
var import_provider9 = require("@ai-sdk/provider");
|
|
17621
17884
|
var import_provider10 = require("@ai-sdk/provider");
|
|
17622
17885
|
var import_provider11 = require("@ai-sdk/provider");
|
|
17623
17886
|
var z42 = __toESM(require("zod/v4"), 1);
|
|
17624
|
-
var
|
|
17625
|
-
var
|
|
17626
|
-
var
|
|
17887
|
+
var import_v32 = require("zod/v3");
|
|
17888
|
+
var import_v33 = require("zod/v3");
|
|
17889
|
+
var import_v34 = require("zod/v3");
|
|
17627
17890
|
function combineHeaders(...headers) {
|
|
17628
17891
|
return headers.reduce(
|
|
17629
17892
|
(combinedHeaders, currentHeaders) => __spreadValues(__spreadValues({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}),
|
|
@@ -18440,7 +18703,7 @@ function parseArrayDef(def, refs) {
|
|
|
18440
18703
|
const res = {
|
|
18441
18704
|
type: "array"
|
|
18442
18705
|
};
|
|
18443
|
-
if (((_a = def.type) == null ? void 0 : _a._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !==
|
|
18706
|
+
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) {
|
|
18444
18707
|
res.items = parseDef(def.type._def, __spreadProps(__spreadValues({}, refs), {
|
|
18445
18708
|
currentPath: [...refs.currentPath, "items"]
|
|
18446
18709
|
}));
|
|
@@ -18929,18 +19192,18 @@ function parseRecordDef(def, refs) {
|
|
|
18929
19192
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
18930
19193
|
}))) != null ? _a : refs.allowedAdditionalProperties
|
|
18931
19194
|
};
|
|
18932
|
-
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) ===
|
|
19195
|
+
if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === import_v34.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
18933
19196
|
const _a2 = parseStringDef(def.keyType._def, refs), { type } = _a2, keyType = __objRest(_a2, ["type"]);
|
|
18934
19197
|
return __spreadProps(__spreadValues({}, schema), {
|
|
18935
19198
|
propertyNames: keyType
|
|
18936
19199
|
});
|
|
18937
|
-
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) ===
|
|
19200
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === import_v34.ZodFirstPartyTypeKind.ZodEnum) {
|
|
18938
19201
|
return __spreadProps(__spreadValues({}, schema), {
|
|
18939
19202
|
propertyNames: {
|
|
18940
19203
|
enum: def.keyType._def.values
|
|
18941
19204
|
}
|
|
18942
19205
|
});
|
|
18943
|
-
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) ===
|
|
19206
|
+
} 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)) {
|
|
18944
19207
|
const _b2 = parseBrandedDef(
|
|
18945
19208
|
def.keyType._def,
|
|
18946
19209
|
refs
|
|
@@ -19266,73 +19529,73 @@ var parseReadonlyDef = (def, refs) => {
|
|
|
19266
19529
|
};
|
|
19267
19530
|
var selectParser = (def, typeName, refs) => {
|
|
19268
19531
|
switch (typeName) {
|
|
19269
|
-
case
|
|
19532
|
+
case import_v32.ZodFirstPartyTypeKind.ZodString:
|
|
19270
19533
|
return parseStringDef(def, refs);
|
|
19271
|
-
case
|
|
19534
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNumber:
|
|
19272
19535
|
return parseNumberDef(def);
|
|
19273
|
-
case
|
|
19536
|
+
case import_v32.ZodFirstPartyTypeKind.ZodObject:
|
|
19274
19537
|
return parseObjectDef(def, refs);
|
|
19275
|
-
case
|
|
19538
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBigInt:
|
|
19276
19539
|
return parseBigintDef(def);
|
|
19277
|
-
case
|
|
19540
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBoolean:
|
|
19278
19541
|
return parseBooleanDef();
|
|
19279
|
-
case
|
|
19542
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDate:
|
|
19280
19543
|
return parseDateDef(def, refs);
|
|
19281
|
-
case
|
|
19544
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUndefined:
|
|
19282
19545
|
return parseUndefinedDef();
|
|
19283
|
-
case
|
|
19546
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNull:
|
|
19284
19547
|
return parseNullDef();
|
|
19285
|
-
case
|
|
19548
|
+
case import_v32.ZodFirstPartyTypeKind.ZodArray:
|
|
19286
19549
|
return parseArrayDef(def, refs);
|
|
19287
|
-
case
|
|
19288
|
-
case
|
|
19550
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUnion:
|
|
19551
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
19289
19552
|
return parseUnionDef(def, refs);
|
|
19290
|
-
case
|
|
19553
|
+
case import_v32.ZodFirstPartyTypeKind.ZodIntersection:
|
|
19291
19554
|
return parseIntersectionDef(def, refs);
|
|
19292
|
-
case
|
|
19555
|
+
case import_v32.ZodFirstPartyTypeKind.ZodTuple:
|
|
19293
19556
|
return parseTupleDef(def, refs);
|
|
19294
|
-
case
|
|
19557
|
+
case import_v32.ZodFirstPartyTypeKind.ZodRecord:
|
|
19295
19558
|
return parseRecordDef(def, refs);
|
|
19296
|
-
case
|
|
19559
|
+
case import_v32.ZodFirstPartyTypeKind.ZodLiteral:
|
|
19297
19560
|
return parseLiteralDef(def);
|
|
19298
|
-
case
|
|
19561
|
+
case import_v32.ZodFirstPartyTypeKind.ZodEnum:
|
|
19299
19562
|
return parseEnumDef(def);
|
|
19300
|
-
case
|
|
19563
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
19301
19564
|
return parseNativeEnumDef(def);
|
|
19302
|
-
case
|
|
19565
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNullable:
|
|
19303
19566
|
return parseNullableDef(def, refs);
|
|
19304
|
-
case
|
|
19567
|
+
case import_v32.ZodFirstPartyTypeKind.ZodOptional:
|
|
19305
19568
|
return parseOptionalDef(def, refs);
|
|
19306
|
-
case
|
|
19569
|
+
case import_v32.ZodFirstPartyTypeKind.ZodMap:
|
|
19307
19570
|
return parseMapDef(def, refs);
|
|
19308
|
-
case
|
|
19571
|
+
case import_v32.ZodFirstPartyTypeKind.ZodSet:
|
|
19309
19572
|
return parseSetDef(def, refs);
|
|
19310
|
-
case
|
|
19573
|
+
case import_v32.ZodFirstPartyTypeKind.ZodLazy:
|
|
19311
19574
|
return () => def.getter()._def;
|
|
19312
|
-
case
|
|
19575
|
+
case import_v32.ZodFirstPartyTypeKind.ZodPromise:
|
|
19313
19576
|
return parsePromiseDef(def, refs);
|
|
19314
|
-
case
|
|
19315
|
-
case
|
|
19577
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNaN:
|
|
19578
|
+
case import_v32.ZodFirstPartyTypeKind.ZodNever:
|
|
19316
19579
|
return parseNeverDef();
|
|
19317
|
-
case
|
|
19580
|
+
case import_v32.ZodFirstPartyTypeKind.ZodEffects:
|
|
19318
19581
|
return parseEffectsDef(def, refs);
|
|
19319
|
-
case
|
|
19582
|
+
case import_v32.ZodFirstPartyTypeKind.ZodAny:
|
|
19320
19583
|
return parseAnyDef();
|
|
19321
|
-
case
|
|
19584
|
+
case import_v32.ZodFirstPartyTypeKind.ZodUnknown:
|
|
19322
19585
|
return parseUnknownDef();
|
|
19323
|
-
case
|
|
19586
|
+
case import_v32.ZodFirstPartyTypeKind.ZodDefault:
|
|
19324
19587
|
return parseDefaultDef(def, refs);
|
|
19325
|
-
case
|
|
19588
|
+
case import_v32.ZodFirstPartyTypeKind.ZodBranded:
|
|
19326
19589
|
return parseBrandedDef(def, refs);
|
|
19327
|
-
case
|
|
19590
|
+
case import_v32.ZodFirstPartyTypeKind.ZodReadonly:
|
|
19328
19591
|
return parseReadonlyDef(def, refs);
|
|
19329
|
-
case
|
|
19592
|
+
case import_v32.ZodFirstPartyTypeKind.ZodCatch:
|
|
19330
19593
|
return parseCatchDef(def, refs);
|
|
19331
|
-
case
|
|
19594
|
+
case import_v32.ZodFirstPartyTypeKind.ZodPipeline:
|
|
19332
19595
|
return parsePipelineDef(def, refs);
|
|
19333
|
-
case
|
|
19334
|
-
case
|
|
19335
|
-
case
|
|
19596
|
+
case import_v32.ZodFirstPartyTypeKind.ZodFunction:
|
|
19597
|
+
case import_v32.ZodFirstPartyTypeKind.ZodVoid:
|
|
19598
|
+
case import_v32.ZodFirstPartyTypeKind.ZodSymbol:
|
|
19336
19599
|
return void 0;
|
|
19337
19600
|
default:
|
|
19338
19601
|
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
@@ -19419,7 +19682,7 @@ var getRefs = (options) => {
|
|
|
19419
19682
|
)
|
|
19420
19683
|
});
|
|
19421
19684
|
};
|
|
19422
|
-
var
|
|
19685
|
+
var zodToJsonSchema2 = (schema, options) => {
|
|
19423
19686
|
var _a;
|
|
19424
19687
|
const refs = getRefs(options);
|
|
19425
19688
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
@@ -19464,7 +19727,7 @@ var zodToJsonSchema7 = (schema, options) => {
|
|
|
19464
19727
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
19465
19728
|
return combined;
|
|
19466
19729
|
};
|
|
19467
|
-
var zod_to_json_schema_default =
|
|
19730
|
+
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
19468
19731
|
function zod3Schema(zodSchema2, options) {
|
|
19469
19732
|
var _a;
|
|
19470
19733
|
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
@@ -19499,11 +19762,11 @@ function zod4Schema(zodSchema2, options) {
|
|
|
19499
19762
|
}
|
|
19500
19763
|
);
|
|
19501
19764
|
}
|
|
19502
|
-
function
|
|
19765
|
+
function isZod4Schema2(zodSchema2) {
|
|
19503
19766
|
return "_zod" in zodSchema2;
|
|
19504
19767
|
}
|
|
19505
19768
|
function zodSchema(zodSchema2, options) {
|
|
19506
|
-
if (
|
|
19769
|
+
if (isZod4Schema2(zodSchema2)) {
|
|
19507
19770
|
return zod4Schema(zodSchema2, options);
|
|
19508
19771
|
} else {
|
|
19509
19772
|
return zod3Schema(zodSchema2, options);
|
|
@@ -19556,7 +19819,7 @@ function withoutTrailingSlash(url) {
|
|
|
19556
19819
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
19557
19820
|
}
|
|
19558
19821
|
|
|
19559
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@
|
|
19822
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.8/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
19560
19823
|
var import_provider12 = require("@ai-sdk/provider");
|
|
19561
19824
|
var import_v4 = require("zod/v4");
|
|
19562
19825
|
var import_provider13 = require("@ai-sdk/provider");
|
|
@@ -23946,7 +24209,7 @@ function createOpenAI(options = {}) {
|
|
|
23946
24209
|
}
|
|
23947
24210
|
var openai = createOpenAI();
|
|
23948
24211
|
|
|
23949
|
-
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@
|
|
24212
|
+
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.34_zod@4.1.8/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
23950
24213
|
var import_provider20 = require("@ai-sdk/provider");
|
|
23951
24214
|
var import_provider21 = require("@ai-sdk/provider");
|
|
23952
24215
|
var import_v421 = require("zod/v4");
|
|
@@ -26985,7 +27248,7 @@ function createAnthropic(options = {}) {
|
|
|
26985
27248
|
}
|
|
26986
27249
|
var anthropic = createAnthropic();
|
|
26987
27250
|
|
|
26988
|
-
// ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@
|
|
27251
|
+
// ../../node_modules/.pnpm/@ai-sdk+google@2.0.23_zod@4.1.8/node_modules/@ai-sdk/google/dist/index.mjs
|
|
26989
27252
|
var import_provider24 = require("@ai-sdk/provider");
|
|
26990
27253
|
var import_v437 = require("zod/v4");
|
|
26991
27254
|
var import_v438 = require("zod/v4");
|
|
@@ -28537,7 +28800,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
28537
28800
|
}
|
|
28538
28801
|
var google = createGoogleGenerativeAI();
|
|
28539
28802
|
|
|
28540
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@
|
|
28803
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.22_zod@4.1.8/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
28541
28804
|
var import_provider27 = require("@ai-sdk/provider");
|
|
28542
28805
|
var import_v446 = require("zod/v4");
|
|
28543
28806
|
var import_provider28 = require("@ai-sdk/provider");
|
|
@@ -29857,7 +30120,7 @@ var openaiCompatibleImageResponseSchema = import_v453.z.object({
|
|
|
29857
30120
|
data: import_v453.z.array(import_v453.z.object({ b64_json: import_v453.z.string() }))
|
|
29858
30121
|
});
|
|
29859
30122
|
|
|
29860
|
-
// ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@
|
|
30123
|
+
// ../../node_modules/.pnpm/@ai-sdk+xai@2.0.26_zod@4.1.8/node_modules/@ai-sdk/xai/dist/index.mjs
|
|
29861
30124
|
var import_provider32 = require("@ai-sdk/provider");
|
|
29862
30125
|
var import_v454 = require("zod/v4");
|
|
29863
30126
|
var import_provider33 = require("@ai-sdk/provider");
|
|
@@ -30609,7 +30872,7 @@ function createXai(options = {}) {
|
|
|
30609
30872
|
}
|
|
30610
30873
|
var xai = createXai();
|
|
30611
30874
|
|
|
30612
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@
|
|
30875
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.53_zod@4.1.8/node_modules/@ai-sdk/openai/dist/internal/index.mjs
|
|
30613
30876
|
var import_provider35 = require("@ai-sdk/provider");
|
|
30614
30877
|
var import_v457 = require("zod/v4");
|
|
30615
30878
|
var import_provider36 = require("@ai-sdk/provider");
|
|
@@ -34832,7 +35095,7 @@ function mapWebSearchOutput2(action) {
|
|
|
34832
35095
|
}
|
|
34833
35096
|
}
|
|
34834
35097
|
|
|
34835
|
-
// ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@
|
|
35098
|
+
// ../../node_modules/.pnpm/@ai-sdk+azure@2.0.54_zod@4.1.8/node_modules/@ai-sdk/azure/dist/index.mjs
|
|
34836
35099
|
var azureOpenaiTools = {
|
|
34837
35100
|
codeInterpreter: codeInterpreter2,
|
|
34838
35101
|
fileSearch: fileSearch2,
|
|
@@ -34937,7 +35200,7 @@ function createAzure(options = {}) {
|
|
|
34937
35200
|
}
|
|
34938
35201
|
var azure = createAzure();
|
|
34939
35202
|
|
|
34940
|
-
// ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@
|
|
35203
|
+
// ../../node_modules/.pnpm/@ai-sdk+groq@2.0.24_zod@4.1.8/node_modules/@ai-sdk/groq/dist/index.mjs
|
|
34941
35204
|
var import_provider43 = require("@ai-sdk/provider");
|
|
34942
35205
|
var import_provider44 = require("@ai-sdk/provider");
|
|
34943
35206
|
var import_v477 = require("zod/v4");
|
|
@@ -35819,7 +36082,7 @@ function createGroq(options = {}) {
|
|
|
35819
36082
|
}
|
|
35820
36083
|
var groq = createGroq();
|
|
35821
36084
|
|
|
35822
|
-
// ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@
|
|
36085
|
+
// ../../node_modules/.pnpm/@ai-sdk+cerebras@1.0.25_zod@4.1.8/node_modules/@ai-sdk/cerebras/dist/index.mjs
|
|
35823
36086
|
var import_provider47 = require("@ai-sdk/provider");
|
|
35824
36087
|
var import_v482 = require("zod/v4");
|
|
35825
36088
|
var VERSION8 = true ? "1.0.25" : "0.0.0-test";
|
|
@@ -35871,7 +36134,7 @@ function createCerebras(options = {}) {
|
|
|
35871
36134
|
}
|
|
35872
36135
|
var cerebras = createCerebras();
|
|
35873
36136
|
|
|
35874
|
-
// ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@
|
|
36137
|
+
// ../../node_modules/.pnpm/@ai-sdk+togetherai@1.0.23_zod@4.1.8/node_modules/@ai-sdk/togetherai/dist/index.mjs
|
|
35875
36138
|
var import_v483 = require("zod/v4");
|
|
35876
36139
|
var TogetherAIImageModel = class {
|
|
35877
36140
|
constructor(modelId, config) {
|
|
@@ -36002,7 +36265,7 @@ function createTogetherAI(options = {}) {
|
|
|
36002
36265
|
}
|
|
36003
36266
|
var togetherai = createTogetherAI();
|
|
36004
36267
|
|
|
36005
|
-
// ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@
|
|
36268
|
+
// ../../node_modules/.pnpm/@ai-sdk+mistral@2.0.19_zod@4.1.8/node_modules/@ai-sdk/mistral/dist/index.mjs
|
|
36006
36269
|
var import_provider48 = require("@ai-sdk/provider");
|
|
36007
36270
|
var import_v484 = require("zod/v4");
|
|
36008
36271
|
var import_provider49 = require("@ai-sdk/provider");
|
|
@@ -36785,7 +37048,7 @@ function createMistral(options = {}) {
|
|
|
36785
37048
|
}
|
|
36786
37049
|
var mistral = createMistral();
|
|
36787
37050
|
|
|
36788
|
-
// ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@
|
|
37051
|
+
// ../../node_modules/.pnpm/@ai-sdk+deepseek@1.0.23_zod@4.1.8/node_modules/@ai-sdk/deepseek/dist/index.mjs
|
|
36789
37052
|
var import_provider52 = require("@ai-sdk/provider");
|
|
36790
37053
|
var import_v488 = require("zod/v4");
|
|
36791
37054
|
var buildDeepseekMetadata = (usage) => {
|
|
@@ -36875,7 +37138,7 @@ function createDeepSeek(options = {}) {
|
|
|
36875
37138
|
}
|
|
36876
37139
|
var deepseek = createDeepSeek();
|
|
36877
37140
|
|
|
36878
|
-
// ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@
|
|
37141
|
+
// ../../node_modules/.pnpm/@ai-sdk+perplexity@2.0.13_zod@4.1.8/node_modules/@ai-sdk/perplexity/dist/index.mjs
|
|
36879
37142
|
var import_provider53 = require("@ai-sdk/provider");
|
|
36880
37143
|
var import_v489 = require("zod/v4");
|
|
36881
37144
|
var import_provider54 = require("@ai-sdk/provider");
|
|
@@ -37305,7 +37568,7 @@ function createPerplexity(options = {}) {
|
|
|
37305
37568
|
}
|
|
37306
37569
|
var perplexity = createPerplexity();
|
|
37307
37570
|
|
|
37308
|
-
// ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@
|
|
37571
|
+
// ../../node_modules/.pnpm/ollama-ai-provider-v2@1.5.0_zod@4.1.8/node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
37309
37572
|
var import_provider55 = require("@ai-sdk/provider");
|
|
37310
37573
|
var import_v490 = require("zod/v4");
|
|
37311
37574
|
var import_v491 = require("zod/v4");
|
|
@@ -39844,7 +40107,6 @@ function resolveModel(model) {
|
|
|
39844
40107
|
|
|
39845
40108
|
// lib/v3/api.ts
|
|
39846
40109
|
var import_fetch_cookie = __toESM(require("fetch-cookie"));
|
|
39847
|
-
var import_zod_to_json_schema7 = __toESM(require("zod-to-json-schema"));
|
|
39848
40110
|
init_version();
|
|
39849
40111
|
var StagehandAPIClient = class {
|
|
39850
40112
|
constructor({ apiKey, projectId, logger }) {
|
|
@@ -39939,7 +40201,7 @@ var StagehandAPIClient = class {
|
|
|
39939
40201
|
options,
|
|
39940
40202
|
frameId
|
|
39941
40203
|
}) {
|
|
39942
|
-
const jsonSchema2 = zodSchema2 ? (
|
|
40204
|
+
const jsonSchema2 = zodSchema2 ? toJsonSchema(zodSchema2) : void 0;
|
|
39943
40205
|
const args = {
|
|
39944
40206
|
schema: jsonSchema2,
|
|
39945
40207
|
instruction,
|
|
@@ -41479,14 +41741,14 @@ function isObserveResult(v) {
|
|
|
41479
41741
|
|
|
41480
41742
|
// lib/v3Evaluator.ts
|
|
41481
41743
|
var import_dotenv2 = __toESM(require("dotenv"));
|
|
41482
|
-
var
|
|
41744
|
+
var import_zod16 = require("zod");
|
|
41483
41745
|
init_sdkErrors();
|
|
41484
41746
|
import_dotenv2.default.config();
|
|
41485
|
-
var EvaluationSchema =
|
|
41486
|
-
evaluation:
|
|
41487
|
-
reasoning:
|
|
41747
|
+
var EvaluationSchema = import_zod16.z.object({
|
|
41748
|
+
evaluation: import_zod16.z.enum(["YES", "NO"]),
|
|
41749
|
+
reasoning: import_zod16.z.string()
|
|
41488
41750
|
});
|
|
41489
|
-
var BatchEvaluationSchema =
|
|
41751
|
+
var BatchEvaluationSchema = import_zod16.z.array(EvaluationSchema);
|
|
41490
41752
|
var V3Evaluator = class {
|
|
41491
41753
|
constructor(v3, modelName, modelClientOptions) {
|
|
41492
41754
|
this.silentLogger = () => {
|
|
@@ -41777,12 +42039,15 @@ I'm providing ${screenshots.length} screenshots showing the progression of the t
|
|
|
41777
42039
|
getZodType,
|
|
41778
42040
|
injectUrls,
|
|
41779
42041
|
isRunningInBun,
|
|
42042
|
+
isZod3Schema,
|
|
42043
|
+
isZod4Schema,
|
|
41780
42044
|
jsonSchemaToZod,
|
|
41781
42045
|
loadApiKeyFromEnv,
|
|
41782
42046
|
modelToAgentProviderMap,
|
|
41783
42047
|
pageTextSchema,
|
|
41784
42048
|
providerEnvVarMap,
|
|
41785
42049
|
toGeminiSchema,
|
|
42050
|
+
toJsonSchema,
|
|
41786
42051
|
transformSchema,
|
|
41787
42052
|
trimTrailingTextNode,
|
|
41788
42053
|
validateZodSchema
|