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