@kamrankhan027/probe-ai 1.0.4 → 1.1.0
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.js +398 -242
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import dotenv from "dotenv";
|
|
10
|
-
import
|
|
10
|
+
import chalk8 from "chalk";
|
|
11
11
|
import ora from "ora";
|
|
12
12
|
import readline from "readline";
|
|
13
13
|
import { marked } from "marked";
|
|
@@ -15,7 +15,6 @@ import { markedTerminal } from "marked-terminal";
|
|
|
15
15
|
import { HumanMessage, AIMessage as AIMessage2 } from "@langchain/core/messages";
|
|
16
16
|
|
|
17
17
|
// src/agent.ts
|
|
18
|
-
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
19
18
|
import { StateGraph, START, Annotation } from "@langchain/langgraph";
|
|
20
19
|
import { SystemMessage } from "@langchain/core/messages";
|
|
21
20
|
import { ToolNode } from "@langchain/langgraph/prebuilt";
|
|
@@ -682,41 +681,41 @@ var ZodType = class {
|
|
|
682
681
|
get description() {
|
|
683
682
|
return this._def.description;
|
|
684
683
|
}
|
|
685
|
-
_getType(
|
|
686
|
-
return getParsedType(
|
|
684
|
+
_getType(input2) {
|
|
685
|
+
return getParsedType(input2.data);
|
|
687
686
|
}
|
|
688
|
-
_getOrReturnCtx(
|
|
687
|
+
_getOrReturnCtx(input2, ctx) {
|
|
689
688
|
return ctx || {
|
|
690
|
-
common:
|
|
691
|
-
data:
|
|
692
|
-
parsedType: getParsedType(
|
|
689
|
+
common: input2.parent.common,
|
|
690
|
+
data: input2.data,
|
|
691
|
+
parsedType: getParsedType(input2.data),
|
|
693
692
|
schemaErrorMap: this._def.errorMap,
|
|
694
|
-
path:
|
|
695
|
-
parent:
|
|
693
|
+
path: input2.path,
|
|
694
|
+
parent: input2.parent
|
|
696
695
|
};
|
|
697
696
|
}
|
|
698
|
-
_processInputParams(
|
|
697
|
+
_processInputParams(input2) {
|
|
699
698
|
return {
|
|
700
699
|
status: new ParseStatus(),
|
|
701
700
|
ctx: {
|
|
702
|
-
common:
|
|
703
|
-
data:
|
|
704
|
-
parsedType: getParsedType(
|
|
701
|
+
common: input2.parent.common,
|
|
702
|
+
data: input2.data,
|
|
703
|
+
parsedType: getParsedType(input2.data),
|
|
705
704
|
schemaErrorMap: this._def.errorMap,
|
|
706
|
-
path:
|
|
707
|
-
parent:
|
|
705
|
+
path: input2.path,
|
|
706
|
+
parent: input2.parent
|
|
708
707
|
}
|
|
709
708
|
};
|
|
710
709
|
}
|
|
711
|
-
_parseSync(
|
|
712
|
-
const result = this._parse(
|
|
710
|
+
_parseSync(input2) {
|
|
711
|
+
const result = this._parse(input2);
|
|
713
712
|
if (isAsync(result)) {
|
|
714
713
|
throw new Error("Synchronous parse encountered promise.");
|
|
715
714
|
}
|
|
716
715
|
return result;
|
|
717
716
|
}
|
|
718
|
-
_parseAsync(
|
|
719
|
-
const result = this._parse(
|
|
717
|
+
_parseAsync(input2) {
|
|
718
|
+
const result = this._parse(input2);
|
|
720
719
|
return Promise.resolve(result);
|
|
721
720
|
}
|
|
722
721
|
parse(data, params) {
|
|
@@ -1042,13 +1041,13 @@ function isValidCidr(ip, version) {
|
|
|
1042
1041
|
return false;
|
|
1043
1042
|
}
|
|
1044
1043
|
var ZodString = class _ZodString extends ZodType {
|
|
1045
|
-
_parse(
|
|
1044
|
+
_parse(input2) {
|
|
1046
1045
|
if (this._def.coerce) {
|
|
1047
|
-
|
|
1046
|
+
input2.data = String(input2.data);
|
|
1048
1047
|
}
|
|
1049
|
-
const parsedType = this._getType(
|
|
1048
|
+
const parsedType = this._getType(input2);
|
|
1050
1049
|
if (parsedType !== ZodParsedType.string) {
|
|
1051
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1050
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1052
1051
|
addIssueToContext(ctx2, {
|
|
1053
1052
|
code: ZodIssueCode.invalid_type,
|
|
1054
1053
|
expected: ZodParsedType.string,
|
|
@@ -1060,8 +1059,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1060
1059
|
let ctx = void 0;
|
|
1061
1060
|
for (const check of this._def.checks) {
|
|
1062
1061
|
if (check.kind === "min") {
|
|
1063
|
-
if (
|
|
1064
|
-
ctx = this._getOrReturnCtx(
|
|
1062
|
+
if (input2.data.length < check.value) {
|
|
1063
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1065
1064
|
addIssueToContext(ctx, {
|
|
1066
1065
|
code: ZodIssueCode.too_small,
|
|
1067
1066
|
minimum: check.value,
|
|
@@ -1073,8 +1072,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1073
1072
|
status.dirty();
|
|
1074
1073
|
}
|
|
1075
1074
|
} else if (check.kind === "max") {
|
|
1076
|
-
if (
|
|
1077
|
-
ctx = this._getOrReturnCtx(
|
|
1075
|
+
if (input2.data.length > check.value) {
|
|
1076
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1078
1077
|
addIssueToContext(ctx, {
|
|
1079
1078
|
code: ZodIssueCode.too_big,
|
|
1080
1079
|
maximum: check.value,
|
|
@@ -1086,10 +1085,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1086
1085
|
status.dirty();
|
|
1087
1086
|
}
|
|
1088
1087
|
} else if (check.kind === "length") {
|
|
1089
|
-
const tooBig =
|
|
1090
|
-
const tooSmall =
|
|
1088
|
+
const tooBig = input2.data.length > check.value;
|
|
1089
|
+
const tooSmall = input2.data.length < check.value;
|
|
1091
1090
|
if (tooBig || tooSmall) {
|
|
1092
|
-
ctx = this._getOrReturnCtx(
|
|
1091
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1093
1092
|
if (tooBig) {
|
|
1094
1093
|
addIssueToContext(ctx, {
|
|
1095
1094
|
code: ZodIssueCode.too_big,
|
|
@@ -1112,8 +1111,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1112
1111
|
status.dirty();
|
|
1113
1112
|
}
|
|
1114
1113
|
} else if (check.kind === "email") {
|
|
1115
|
-
if (!emailRegex.test(
|
|
1116
|
-
ctx = this._getOrReturnCtx(
|
|
1114
|
+
if (!emailRegex.test(input2.data)) {
|
|
1115
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1117
1116
|
addIssueToContext(ctx, {
|
|
1118
1117
|
validation: "email",
|
|
1119
1118
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1125,8 +1124,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1125
1124
|
if (!emojiRegex) {
|
|
1126
1125
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1127
1126
|
}
|
|
1128
|
-
if (!emojiRegex.test(
|
|
1129
|
-
ctx = this._getOrReturnCtx(
|
|
1127
|
+
if (!emojiRegex.test(input2.data)) {
|
|
1128
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1130
1129
|
addIssueToContext(ctx, {
|
|
1131
1130
|
validation: "emoji",
|
|
1132
1131
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1135,8 +1134,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1135
1134
|
status.dirty();
|
|
1136
1135
|
}
|
|
1137
1136
|
} else if (check.kind === "uuid") {
|
|
1138
|
-
if (!uuidRegex.test(
|
|
1139
|
-
ctx = this._getOrReturnCtx(
|
|
1137
|
+
if (!uuidRegex.test(input2.data)) {
|
|
1138
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1140
1139
|
addIssueToContext(ctx, {
|
|
1141
1140
|
validation: "uuid",
|
|
1142
1141
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1145,8 +1144,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1145
1144
|
status.dirty();
|
|
1146
1145
|
}
|
|
1147
1146
|
} else if (check.kind === "nanoid") {
|
|
1148
|
-
if (!nanoidRegex.test(
|
|
1149
|
-
ctx = this._getOrReturnCtx(
|
|
1147
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
1148
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1150
1149
|
addIssueToContext(ctx, {
|
|
1151
1150
|
validation: "nanoid",
|
|
1152
1151
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1155,8 +1154,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1155
1154
|
status.dirty();
|
|
1156
1155
|
}
|
|
1157
1156
|
} else if (check.kind === "cuid") {
|
|
1158
|
-
if (!cuidRegex.test(
|
|
1159
|
-
ctx = this._getOrReturnCtx(
|
|
1157
|
+
if (!cuidRegex.test(input2.data)) {
|
|
1158
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1160
1159
|
addIssueToContext(ctx, {
|
|
1161
1160
|
validation: "cuid",
|
|
1162
1161
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1165,8 +1164,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1165
1164
|
status.dirty();
|
|
1166
1165
|
}
|
|
1167
1166
|
} else if (check.kind === "cuid2") {
|
|
1168
|
-
if (!cuid2Regex.test(
|
|
1169
|
-
ctx = this._getOrReturnCtx(
|
|
1167
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
1168
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1170
1169
|
addIssueToContext(ctx, {
|
|
1171
1170
|
validation: "cuid2",
|
|
1172
1171
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1175,8 +1174,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1175
1174
|
status.dirty();
|
|
1176
1175
|
}
|
|
1177
1176
|
} else if (check.kind === "ulid") {
|
|
1178
|
-
if (!ulidRegex.test(
|
|
1179
|
-
ctx = this._getOrReturnCtx(
|
|
1177
|
+
if (!ulidRegex.test(input2.data)) {
|
|
1178
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1180
1179
|
addIssueToContext(ctx, {
|
|
1181
1180
|
validation: "ulid",
|
|
1182
1181
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1186,9 +1185,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1186
1185
|
}
|
|
1187
1186
|
} else if (check.kind === "url") {
|
|
1188
1187
|
try {
|
|
1189
|
-
new URL(
|
|
1188
|
+
new URL(input2.data);
|
|
1190
1189
|
} catch {
|
|
1191
|
-
ctx = this._getOrReturnCtx(
|
|
1190
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1192
1191
|
addIssueToContext(ctx, {
|
|
1193
1192
|
validation: "url",
|
|
1194
1193
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1198,9 +1197,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1198
1197
|
}
|
|
1199
1198
|
} else if (check.kind === "regex") {
|
|
1200
1199
|
check.regex.lastIndex = 0;
|
|
1201
|
-
const testResult = check.regex.test(
|
|
1200
|
+
const testResult = check.regex.test(input2.data);
|
|
1202
1201
|
if (!testResult) {
|
|
1203
|
-
ctx = this._getOrReturnCtx(
|
|
1202
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1204
1203
|
addIssueToContext(ctx, {
|
|
1205
1204
|
validation: "regex",
|
|
1206
1205
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1209,10 +1208,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1209
1208
|
status.dirty();
|
|
1210
1209
|
}
|
|
1211
1210
|
} else if (check.kind === "trim") {
|
|
1212
|
-
|
|
1211
|
+
input2.data = input2.data.trim();
|
|
1213
1212
|
} else if (check.kind === "includes") {
|
|
1214
|
-
if (!
|
|
1215
|
-
ctx = this._getOrReturnCtx(
|
|
1213
|
+
if (!input2.data.includes(check.value, check.position)) {
|
|
1214
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1216
1215
|
addIssueToContext(ctx, {
|
|
1217
1216
|
code: ZodIssueCode.invalid_string,
|
|
1218
1217
|
validation: { includes: check.value, position: check.position },
|
|
@@ -1221,12 +1220,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1221
1220
|
status.dirty();
|
|
1222
1221
|
}
|
|
1223
1222
|
} else if (check.kind === "toLowerCase") {
|
|
1224
|
-
|
|
1223
|
+
input2.data = input2.data.toLowerCase();
|
|
1225
1224
|
} else if (check.kind === "toUpperCase") {
|
|
1226
|
-
|
|
1225
|
+
input2.data = input2.data.toUpperCase();
|
|
1227
1226
|
} else if (check.kind === "startsWith") {
|
|
1228
|
-
if (!
|
|
1229
|
-
ctx = this._getOrReturnCtx(
|
|
1227
|
+
if (!input2.data.startsWith(check.value)) {
|
|
1228
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1230
1229
|
addIssueToContext(ctx, {
|
|
1231
1230
|
code: ZodIssueCode.invalid_string,
|
|
1232
1231
|
validation: { startsWith: check.value },
|
|
@@ -1235,8 +1234,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1235
1234
|
status.dirty();
|
|
1236
1235
|
}
|
|
1237
1236
|
} else if (check.kind === "endsWith") {
|
|
1238
|
-
if (!
|
|
1239
|
-
ctx = this._getOrReturnCtx(
|
|
1237
|
+
if (!input2.data.endsWith(check.value)) {
|
|
1238
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1240
1239
|
addIssueToContext(ctx, {
|
|
1241
1240
|
code: ZodIssueCode.invalid_string,
|
|
1242
1241
|
validation: { endsWith: check.value },
|
|
@@ -1246,8 +1245,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1246
1245
|
}
|
|
1247
1246
|
} else if (check.kind === "datetime") {
|
|
1248
1247
|
const regex = datetimeRegex(check);
|
|
1249
|
-
if (!regex.test(
|
|
1250
|
-
ctx = this._getOrReturnCtx(
|
|
1248
|
+
if (!regex.test(input2.data)) {
|
|
1249
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1251
1250
|
addIssueToContext(ctx, {
|
|
1252
1251
|
code: ZodIssueCode.invalid_string,
|
|
1253
1252
|
validation: "datetime",
|
|
@@ -1257,8 +1256,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1257
1256
|
}
|
|
1258
1257
|
} else if (check.kind === "date") {
|
|
1259
1258
|
const regex = dateRegex;
|
|
1260
|
-
if (!regex.test(
|
|
1261
|
-
ctx = this._getOrReturnCtx(
|
|
1259
|
+
if (!regex.test(input2.data)) {
|
|
1260
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1262
1261
|
addIssueToContext(ctx, {
|
|
1263
1262
|
code: ZodIssueCode.invalid_string,
|
|
1264
1263
|
validation: "date",
|
|
@@ -1268,8 +1267,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1268
1267
|
}
|
|
1269
1268
|
} else if (check.kind === "time") {
|
|
1270
1269
|
const regex = timeRegex(check);
|
|
1271
|
-
if (!regex.test(
|
|
1272
|
-
ctx = this._getOrReturnCtx(
|
|
1270
|
+
if (!regex.test(input2.data)) {
|
|
1271
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1273
1272
|
addIssueToContext(ctx, {
|
|
1274
1273
|
code: ZodIssueCode.invalid_string,
|
|
1275
1274
|
validation: "time",
|
|
@@ -1278,8 +1277,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1278
1277
|
status.dirty();
|
|
1279
1278
|
}
|
|
1280
1279
|
} else if (check.kind === "duration") {
|
|
1281
|
-
if (!durationRegex.test(
|
|
1282
|
-
ctx = this._getOrReturnCtx(
|
|
1280
|
+
if (!durationRegex.test(input2.data)) {
|
|
1281
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1283
1282
|
addIssueToContext(ctx, {
|
|
1284
1283
|
validation: "duration",
|
|
1285
1284
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1288,8 +1287,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1288
1287
|
status.dirty();
|
|
1289
1288
|
}
|
|
1290
1289
|
} else if (check.kind === "ip") {
|
|
1291
|
-
if (!isValidIP(
|
|
1292
|
-
ctx = this._getOrReturnCtx(
|
|
1290
|
+
if (!isValidIP(input2.data, check.version)) {
|
|
1291
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1293
1292
|
addIssueToContext(ctx, {
|
|
1294
1293
|
validation: "ip",
|
|
1295
1294
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1298,8 +1297,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1298
1297
|
status.dirty();
|
|
1299
1298
|
}
|
|
1300
1299
|
} else if (check.kind === "jwt") {
|
|
1301
|
-
if (!isValidJWT(
|
|
1302
|
-
ctx = this._getOrReturnCtx(
|
|
1300
|
+
if (!isValidJWT(input2.data, check.alg)) {
|
|
1301
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1303
1302
|
addIssueToContext(ctx, {
|
|
1304
1303
|
validation: "jwt",
|
|
1305
1304
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1308,8 +1307,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1308
1307
|
status.dirty();
|
|
1309
1308
|
}
|
|
1310
1309
|
} else if (check.kind === "cidr") {
|
|
1311
|
-
if (!isValidCidr(
|
|
1312
|
-
ctx = this._getOrReturnCtx(
|
|
1310
|
+
if (!isValidCidr(input2.data, check.version)) {
|
|
1311
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1313
1312
|
addIssueToContext(ctx, {
|
|
1314
1313
|
validation: "cidr",
|
|
1315
1314
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1318,8 +1317,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1318
1317
|
status.dirty();
|
|
1319
1318
|
}
|
|
1320
1319
|
} else if (check.kind === "base64") {
|
|
1321
|
-
if (!base64Regex.test(
|
|
1322
|
-
ctx = this._getOrReturnCtx(
|
|
1320
|
+
if (!base64Regex.test(input2.data)) {
|
|
1321
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1323
1322
|
addIssueToContext(ctx, {
|
|
1324
1323
|
validation: "base64",
|
|
1325
1324
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1328,8 +1327,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1328
1327
|
status.dirty();
|
|
1329
1328
|
}
|
|
1330
1329
|
} else if (check.kind === "base64url") {
|
|
1331
|
-
if (!base64urlRegex.test(
|
|
1332
|
-
ctx = this._getOrReturnCtx(
|
|
1330
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
1331
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1333
1332
|
addIssueToContext(ctx, {
|
|
1334
1333
|
validation: "base64url",
|
|
1335
1334
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1341,7 +1340,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1341
1340
|
util.assertNever(check);
|
|
1342
1341
|
}
|
|
1343
1342
|
}
|
|
1344
|
-
return { status: status.value, value:
|
|
1343
|
+
return { status: status.value, value: input2.data };
|
|
1345
1344
|
}
|
|
1346
1345
|
_regex(regex, validation, message) {
|
|
1347
1346
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1602,13 +1601,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1602
1601
|
this.max = this.lte;
|
|
1603
1602
|
this.step = this.multipleOf;
|
|
1604
1603
|
}
|
|
1605
|
-
_parse(
|
|
1604
|
+
_parse(input2) {
|
|
1606
1605
|
if (this._def.coerce) {
|
|
1607
|
-
|
|
1606
|
+
input2.data = Number(input2.data);
|
|
1608
1607
|
}
|
|
1609
|
-
const parsedType = this._getType(
|
|
1608
|
+
const parsedType = this._getType(input2);
|
|
1610
1609
|
if (parsedType !== ZodParsedType.number) {
|
|
1611
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1610
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1612
1611
|
addIssueToContext(ctx2, {
|
|
1613
1612
|
code: ZodIssueCode.invalid_type,
|
|
1614
1613
|
expected: ZodParsedType.number,
|
|
@@ -1620,8 +1619,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1620
1619
|
const status = new ParseStatus();
|
|
1621
1620
|
for (const check of this._def.checks) {
|
|
1622
1621
|
if (check.kind === "int") {
|
|
1623
|
-
if (!util.isInteger(
|
|
1624
|
-
ctx = this._getOrReturnCtx(
|
|
1622
|
+
if (!util.isInteger(input2.data)) {
|
|
1623
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1625
1624
|
addIssueToContext(ctx, {
|
|
1626
1625
|
code: ZodIssueCode.invalid_type,
|
|
1627
1626
|
expected: "integer",
|
|
@@ -1631,9 +1630,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1631
1630
|
status.dirty();
|
|
1632
1631
|
}
|
|
1633
1632
|
} else if (check.kind === "min") {
|
|
1634
|
-
const tooSmall = check.inclusive ?
|
|
1633
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1635
1634
|
if (tooSmall) {
|
|
1636
|
-
ctx = this._getOrReturnCtx(
|
|
1635
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1637
1636
|
addIssueToContext(ctx, {
|
|
1638
1637
|
code: ZodIssueCode.too_small,
|
|
1639
1638
|
minimum: check.value,
|
|
@@ -1645,9 +1644,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1645
1644
|
status.dirty();
|
|
1646
1645
|
}
|
|
1647
1646
|
} else if (check.kind === "max") {
|
|
1648
|
-
const tooBig = check.inclusive ?
|
|
1647
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1649
1648
|
if (tooBig) {
|
|
1650
|
-
ctx = this._getOrReturnCtx(
|
|
1649
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1651
1650
|
addIssueToContext(ctx, {
|
|
1652
1651
|
code: ZodIssueCode.too_big,
|
|
1653
1652
|
maximum: check.value,
|
|
@@ -1659,8 +1658,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1659
1658
|
status.dirty();
|
|
1660
1659
|
}
|
|
1661
1660
|
} else if (check.kind === "multipleOf") {
|
|
1662
|
-
if (floatSafeRemainder(
|
|
1663
|
-
ctx = this._getOrReturnCtx(
|
|
1661
|
+
if (floatSafeRemainder(input2.data, check.value) !== 0) {
|
|
1662
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1664
1663
|
addIssueToContext(ctx, {
|
|
1665
1664
|
code: ZodIssueCode.not_multiple_of,
|
|
1666
1665
|
multipleOf: check.value,
|
|
@@ -1669,8 +1668,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1669
1668
|
status.dirty();
|
|
1670
1669
|
}
|
|
1671
1670
|
} else if (check.kind === "finite") {
|
|
1672
|
-
if (!Number.isFinite(
|
|
1673
|
-
ctx = this._getOrReturnCtx(
|
|
1671
|
+
if (!Number.isFinite(input2.data)) {
|
|
1672
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1674
1673
|
addIssueToContext(ctx, {
|
|
1675
1674
|
code: ZodIssueCode.not_finite,
|
|
1676
1675
|
message: check.message
|
|
@@ -1681,7 +1680,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1681
1680
|
util.assertNever(check);
|
|
1682
1681
|
}
|
|
1683
1682
|
}
|
|
1684
|
-
return { status: status.value, value:
|
|
1683
|
+
return { status: status.value, value: input2.data };
|
|
1685
1684
|
}
|
|
1686
1685
|
gte(value, message) {
|
|
1687
1686
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1833,25 +1832,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1833
1832
|
this.min = this.gte;
|
|
1834
1833
|
this.max = this.lte;
|
|
1835
1834
|
}
|
|
1836
|
-
_parse(
|
|
1835
|
+
_parse(input2) {
|
|
1837
1836
|
if (this._def.coerce) {
|
|
1838
1837
|
try {
|
|
1839
|
-
|
|
1838
|
+
input2.data = BigInt(input2.data);
|
|
1840
1839
|
} catch {
|
|
1841
|
-
return this._getInvalidInput(
|
|
1840
|
+
return this._getInvalidInput(input2);
|
|
1842
1841
|
}
|
|
1843
1842
|
}
|
|
1844
|
-
const parsedType = this._getType(
|
|
1843
|
+
const parsedType = this._getType(input2);
|
|
1845
1844
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1846
|
-
return this._getInvalidInput(
|
|
1845
|
+
return this._getInvalidInput(input2);
|
|
1847
1846
|
}
|
|
1848
1847
|
let ctx = void 0;
|
|
1849
1848
|
const status = new ParseStatus();
|
|
1850
1849
|
for (const check of this._def.checks) {
|
|
1851
1850
|
if (check.kind === "min") {
|
|
1852
|
-
const tooSmall = check.inclusive ?
|
|
1851
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
1853
1852
|
if (tooSmall) {
|
|
1854
|
-
ctx = this._getOrReturnCtx(
|
|
1853
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1855
1854
|
addIssueToContext(ctx, {
|
|
1856
1855
|
code: ZodIssueCode.too_small,
|
|
1857
1856
|
type: "bigint",
|
|
@@ -1862,9 +1861,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1862
1861
|
status.dirty();
|
|
1863
1862
|
}
|
|
1864
1863
|
} else if (check.kind === "max") {
|
|
1865
|
-
const tooBig = check.inclusive ?
|
|
1864
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
1866
1865
|
if (tooBig) {
|
|
1867
|
-
ctx = this._getOrReturnCtx(
|
|
1866
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1868
1867
|
addIssueToContext(ctx, {
|
|
1869
1868
|
code: ZodIssueCode.too_big,
|
|
1870
1869
|
type: "bigint",
|
|
@@ -1875,8 +1874,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1875
1874
|
status.dirty();
|
|
1876
1875
|
}
|
|
1877
1876
|
} else if (check.kind === "multipleOf") {
|
|
1878
|
-
if (
|
|
1879
|
-
ctx = this._getOrReturnCtx(
|
|
1877
|
+
if (input2.data % check.value !== BigInt(0)) {
|
|
1878
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1880
1879
|
addIssueToContext(ctx, {
|
|
1881
1880
|
code: ZodIssueCode.not_multiple_of,
|
|
1882
1881
|
multipleOf: check.value,
|
|
@@ -1888,10 +1887,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1888
1887
|
util.assertNever(check);
|
|
1889
1888
|
}
|
|
1890
1889
|
}
|
|
1891
|
-
return { status: status.value, value:
|
|
1890
|
+
return { status: status.value, value: input2.data };
|
|
1892
1891
|
}
|
|
1893
|
-
_getInvalidInput(
|
|
1894
|
-
const ctx = this._getOrReturnCtx(
|
|
1892
|
+
_getInvalidInput(input2) {
|
|
1893
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
1895
1894
|
addIssueToContext(ctx, {
|
|
1896
1895
|
code: ZodIssueCode.invalid_type,
|
|
1897
1896
|
expected: ZodParsedType.bigint,
|
|
@@ -2000,13 +1999,13 @@ ZodBigInt.create = (params) => {
|
|
|
2000
1999
|
});
|
|
2001
2000
|
};
|
|
2002
2001
|
var ZodBoolean = class extends ZodType {
|
|
2003
|
-
_parse(
|
|
2002
|
+
_parse(input2) {
|
|
2004
2003
|
if (this._def.coerce) {
|
|
2005
|
-
|
|
2004
|
+
input2.data = Boolean(input2.data);
|
|
2006
2005
|
}
|
|
2007
|
-
const parsedType = this._getType(
|
|
2006
|
+
const parsedType = this._getType(input2);
|
|
2008
2007
|
if (parsedType !== ZodParsedType.boolean) {
|
|
2009
|
-
const ctx = this._getOrReturnCtx(
|
|
2008
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2010
2009
|
addIssueToContext(ctx, {
|
|
2011
2010
|
code: ZodIssueCode.invalid_type,
|
|
2012
2011
|
expected: ZodParsedType.boolean,
|
|
@@ -2014,7 +2013,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
2014
2013
|
});
|
|
2015
2014
|
return INVALID;
|
|
2016
2015
|
}
|
|
2017
|
-
return OK(
|
|
2016
|
+
return OK(input2.data);
|
|
2018
2017
|
}
|
|
2019
2018
|
};
|
|
2020
2019
|
ZodBoolean.create = (params) => {
|
|
@@ -2025,13 +2024,13 @@ ZodBoolean.create = (params) => {
|
|
|
2025
2024
|
});
|
|
2026
2025
|
};
|
|
2027
2026
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2028
|
-
_parse(
|
|
2027
|
+
_parse(input2) {
|
|
2029
2028
|
if (this._def.coerce) {
|
|
2030
|
-
|
|
2029
|
+
input2.data = new Date(input2.data);
|
|
2031
2030
|
}
|
|
2032
|
-
const parsedType = this._getType(
|
|
2031
|
+
const parsedType = this._getType(input2);
|
|
2033
2032
|
if (parsedType !== ZodParsedType.date) {
|
|
2034
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2033
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2035
2034
|
addIssueToContext(ctx2, {
|
|
2036
2035
|
code: ZodIssueCode.invalid_type,
|
|
2037
2036
|
expected: ZodParsedType.date,
|
|
@@ -2039,8 +2038,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2039
2038
|
});
|
|
2040
2039
|
return INVALID;
|
|
2041
2040
|
}
|
|
2042
|
-
if (Number.isNaN(
|
|
2043
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2041
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
2042
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2044
2043
|
addIssueToContext(ctx2, {
|
|
2045
2044
|
code: ZodIssueCode.invalid_date
|
|
2046
2045
|
});
|
|
@@ -2050,8 +2049,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2050
2049
|
let ctx = void 0;
|
|
2051
2050
|
for (const check of this._def.checks) {
|
|
2052
2051
|
if (check.kind === "min") {
|
|
2053
|
-
if (
|
|
2054
|
-
ctx = this._getOrReturnCtx(
|
|
2052
|
+
if (input2.data.getTime() < check.value) {
|
|
2053
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2055
2054
|
addIssueToContext(ctx, {
|
|
2056
2055
|
code: ZodIssueCode.too_small,
|
|
2057
2056
|
message: check.message,
|
|
@@ -2063,8 +2062,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2063
2062
|
status.dirty();
|
|
2064
2063
|
}
|
|
2065
2064
|
} else if (check.kind === "max") {
|
|
2066
|
-
if (
|
|
2067
|
-
ctx = this._getOrReturnCtx(
|
|
2065
|
+
if (input2.data.getTime() > check.value) {
|
|
2066
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2068
2067
|
addIssueToContext(ctx, {
|
|
2069
2068
|
code: ZodIssueCode.too_big,
|
|
2070
2069
|
message: check.message,
|
|
@@ -2081,7 +2080,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2081
2080
|
}
|
|
2082
2081
|
return {
|
|
2083
2082
|
status: status.value,
|
|
2084
|
-
value: new Date(
|
|
2083
|
+
value: new Date(input2.data.getTime())
|
|
2085
2084
|
};
|
|
2086
2085
|
}
|
|
2087
2086
|
_addCheck(check) {
|
|
@@ -2134,10 +2133,10 @@ ZodDate.create = (params) => {
|
|
|
2134
2133
|
});
|
|
2135
2134
|
};
|
|
2136
2135
|
var ZodSymbol = class extends ZodType {
|
|
2137
|
-
_parse(
|
|
2138
|
-
const parsedType = this._getType(
|
|
2136
|
+
_parse(input2) {
|
|
2137
|
+
const parsedType = this._getType(input2);
|
|
2139
2138
|
if (parsedType !== ZodParsedType.symbol) {
|
|
2140
|
-
const ctx = this._getOrReturnCtx(
|
|
2139
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2141
2140
|
addIssueToContext(ctx, {
|
|
2142
2141
|
code: ZodIssueCode.invalid_type,
|
|
2143
2142
|
expected: ZodParsedType.symbol,
|
|
@@ -2145,7 +2144,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
2145
2144
|
});
|
|
2146
2145
|
return INVALID;
|
|
2147
2146
|
}
|
|
2148
|
-
return OK(
|
|
2147
|
+
return OK(input2.data);
|
|
2149
2148
|
}
|
|
2150
2149
|
};
|
|
2151
2150
|
ZodSymbol.create = (params) => {
|
|
@@ -2155,10 +2154,10 @@ ZodSymbol.create = (params) => {
|
|
|
2155
2154
|
});
|
|
2156
2155
|
};
|
|
2157
2156
|
var ZodUndefined = class extends ZodType {
|
|
2158
|
-
_parse(
|
|
2159
|
-
const parsedType = this._getType(
|
|
2157
|
+
_parse(input2) {
|
|
2158
|
+
const parsedType = this._getType(input2);
|
|
2160
2159
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2161
|
-
const ctx = this._getOrReturnCtx(
|
|
2160
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2162
2161
|
addIssueToContext(ctx, {
|
|
2163
2162
|
code: ZodIssueCode.invalid_type,
|
|
2164
2163
|
expected: ZodParsedType.undefined,
|
|
@@ -2166,7 +2165,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
2166
2165
|
});
|
|
2167
2166
|
return INVALID;
|
|
2168
2167
|
}
|
|
2169
|
-
return OK(
|
|
2168
|
+
return OK(input2.data);
|
|
2170
2169
|
}
|
|
2171
2170
|
};
|
|
2172
2171
|
ZodUndefined.create = (params) => {
|
|
@@ -2176,10 +2175,10 @@ ZodUndefined.create = (params) => {
|
|
|
2176
2175
|
});
|
|
2177
2176
|
};
|
|
2178
2177
|
var ZodNull = class extends ZodType {
|
|
2179
|
-
_parse(
|
|
2180
|
-
const parsedType = this._getType(
|
|
2178
|
+
_parse(input2) {
|
|
2179
|
+
const parsedType = this._getType(input2);
|
|
2181
2180
|
if (parsedType !== ZodParsedType.null) {
|
|
2182
|
-
const ctx = this._getOrReturnCtx(
|
|
2181
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2183
2182
|
addIssueToContext(ctx, {
|
|
2184
2183
|
code: ZodIssueCode.invalid_type,
|
|
2185
2184
|
expected: ZodParsedType.null,
|
|
@@ -2187,7 +2186,7 @@ var ZodNull = class extends ZodType {
|
|
|
2187
2186
|
});
|
|
2188
2187
|
return INVALID;
|
|
2189
2188
|
}
|
|
2190
|
-
return OK(
|
|
2189
|
+
return OK(input2.data);
|
|
2191
2190
|
}
|
|
2192
2191
|
};
|
|
2193
2192
|
ZodNull.create = (params) => {
|
|
@@ -2201,8 +2200,8 @@ var ZodAny = class extends ZodType {
|
|
|
2201
2200
|
super(...arguments);
|
|
2202
2201
|
this._any = true;
|
|
2203
2202
|
}
|
|
2204
|
-
_parse(
|
|
2205
|
-
return OK(
|
|
2203
|
+
_parse(input2) {
|
|
2204
|
+
return OK(input2.data);
|
|
2206
2205
|
}
|
|
2207
2206
|
};
|
|
2208
2207
|
ZodAny.create = (params) => {
|
|
@@ -2216,8 +2215,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
2216
2215
|
super(...arguments);
|
|
2217
2216
|
this._unknown = true;
|
|
2218
2217
|
}
|
|
2219
|
-
_parse(
|
|
2220
|
-
return OK(
|
|
2218
|
+
_parse(input2) {
|
|
2219
|
+
return OK(input2.data);
|
|
2221
2220
|
}
|
|
2222
2221
|
};
|
|
2223
2222
|
ZodUnknown.create = (params) => {
|
|
@@ -2227,8 +2226,8 @@ ZodUnknown.create = (params) => {
|
|
|
2227
2226
|
});
|
|
2228
2227
|
};
|
|
2229
2228
|
var ZodNever = class extends ZodType {
|
|
2230
|
-
_parse(
|
|
2231
|
-
const ctx = this._getOrReturnCtx(
|
|
2229
|
+
_parse(input2) {
|
|
2230
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2232
2231
|
addIssueToContext(ctx, {
|
|
2233
2232
|
code: ZodIssueCode.invalid_type,
|
|
2234
2233
|
expected: ZodParsedType.never,
|
|
@@ -2244,10 +2243,10 @@ ZodNever.create = (params) => {
|
|
|
2244
2243
|
});
|
|
2245
2244
|
};
|
|
2246
2245
|
var ZodVoid = class extends ZodType {
|
|
2247
|
-
_parse(
|
|
2248
|
-
const parsedType = this._getType(
|
|
2246
|
+
_parse(input2) {
|
|
2247
|
+
const parsedType = this._getType(input2);
|
|
2249
2248
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2250
|
-
const ctx = this._getOrReturnCtx(
|
|
2249
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2251
2250
|
addIssueToContext(ctx, {
|
|
2252
2251
|
code: ZodIssueCode.invalid_type,
|
|
2253
2252
|
expected: ZodParsedType.void,
|
|
@@ -2255,7 +2254,7 @@ var ZodVoid = class extends ZodType {
|
|
|
2255
2254
|
});
|
|
2256
2255
|
return INVALID;
|
|
2257
2256
|
}
|
|
2258
|
-
return OK(
|
|
2257
|
+
return OK(input2.data);
|
|
2259
2258
|
}
|
|
2260
2259
|
};
|
|
2261
2260
|
ZodVoid.create = (params) => {
|
|
@@ -2265,8 +2264,8 @@ ZodVoid.create = (params) => {
|
|
|
2265
2264
|
});
|
|
2266
2265
|
};
|
|
2267
2266
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2268
|
-
_parse(
|
|
2269
|
-
const { ctx, status } = this._processInputParams(
|
|
2267
|
+
_parse(input2) {
|
|
2268
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
2270
2269
|
const def = this._def;
|
|
2271
2270
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
2272
2271
|
addIssueToContext(ctx, {
|
|
@@ -2406,10 +2405,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2406
2405
|
this._cached = { shape, keys };
|
|
2407
2406
|
return this._cached;
|
|
2408
2407
|
}
|
|
2409
|
-
_parse(
|
|
2410
|
-
const parsedType = this._getType(
|
|
2408
|
+
_parse(input2) {
|
|
2409
|
+
const parsedType = this._getType(input2);
|
|
2411
2410
|
if (parsedType !== ZodParsedType.object) {
|
|
2412
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2411
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2413
2412
|
addIssueToContext(ctx2, {
|
|
2414
2413
|
code: ZodIssueCode.invalid_type,
|
|
2415
2414
|
expected: ZodParsedType.object,
|
|
@@ -2417,7 +2416,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2417
2416
|
});
|
|
2418
2417
|
return INVALID;
|
|
2419
2418
|
}
|
|
2420
|
-
const { status, ctx } = this._processInputParams(
|
|
2419
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2421
2420
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2422
2421
|
const extraKeys = [];
|
|
2423
2422
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -2730,8 +2729,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
2730
2729
|
});
|
|
2731
2730
|
};
|
|
2732
2731
|
var ZodUnion = class extends ZodType {
|
|
2733
|
-
_parse(
|
|
2734
|
-
const { ctx } = this._processInputParams(
|
|
2732
|
+
_parse(input2) {
|
|
2733
|
+
const { ctx } = this._processInputParams(input2);
|
|
2735
2734
|
const options = this._def.options;
|
|
2736
2735
|
function handleResults(results) {
|
|
2737
2736
|
for (const result of results) {
|
|
@@ -2852,8 +2851,8 @@ var getDiscriminator = (type) => {
|
|
|
2852
2851
|
}
|
|
2853
2852
|
};
|
|
2854
2853
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
2855
|
-
_parse(
|
|
2856
|
-
const { ctx } = this._processInputParams(
|
|
2854
|
+
_parse(input2) {
|
|
2855
|
+
const { ctx } = this._processInputParams(input2);
|
|
2857
2856
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2858
2857
|
addIssueToContext(ctx, {
|
|
2859
2858
|
code: ZodIssueCode.invalid_type,
|
|
@@ -2966,8 +2965,8 @@ function mergeValues(a, b) {
|
|
|
2966
2965
|
}
|
|
2967
2966
|
}
|
|
2968
2967
|
var ZodIntersection = class extends ZodType {
|
|
2969
|
-
_parse(
|
|
2970
|
-
const { status, ctx } = this._processInputParams(
|
|
2968
|
+
_parse(input2) {
|
|
2969
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2971
2970
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
2972
2971
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
2973
2972
|
return INVALID;
|
|
@@ -3019,8 +3018,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
3019
3018
|
});
|
|
3020
3019
|
};
|
|
3021
3020
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3022
|
-
_parse(
|
|
3023
|
-
const { status, ctx } = this._processInputParams(
|
|
3021
|
+
_parse(input2) {
|
|
3022
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3024
3023
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
3025
3024
|
addIssueToContext(ctx, {
|
|
3026
3025
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3092,8 +3091,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3092
3091
|
get valueSchema() {
|
|
3093
3092
|
return this._def.valueType;
|
|
3094
3093
|
}
|
|
3095
|
-
_parse(
|
|
3096
|
-
const { status, ctx } = this._processInputParams(
|
|
3094
|
+
_parse(input2) {
|
|
3095
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3097
3096
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3098
3097
|
addIssueToContext(ctx, {
|
|
3099
3098
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3145,8 +3144,8 @@ var ZodMap = class extends ZodType {
|
|
|
3145
3144
|
get valueSchema() {
|
|
3146
3145
|
return this._def.valueType;
|
|
3147
3146
|
}
|
|
3148
|
-
_parse(
|
|
3149
|
-
const { status, ctx } = this._processInputParams(
|
|
3147
|
+
_parse(input2) {
|
|
3148
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3150
3149
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
3151
3150
|
addIssueToContext(ctx, {
|
|
3152
3151
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3205,8 +3204,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
3205
3204
|
});
|
|
3206
3205
|
};
|
|
3207
3206
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3208
|
-
_parse(
|
|
3209
|
-
const { status, ctx } = this._processInputParams(
|
|
3207
|
+
_parse(input2) {
|
|
3208
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3210
3209
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
3211
3210
|
addIssueToContext(ctx, {
|
|
3212
3211
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3294,8 +3293,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3294
3293
|
super(...arguments);
|
|
3295
3294
|
this.validate = this.implement;
|
|
3296
3295
|
}
|
|
3297
|
-
_parse(
|
|
3298
|
-
const { ctx } = this._processInputParams(
|
|
3296
|
+
_parse(input2) {
|
|
3297
|
+
const { ctx } = this._processInputParams(input2);
|
|
3299
3298
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3300
3299
|
addIssueToContext(ctx, {
|
|
3301
3300
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3398,8 +3397,8 @@ var ZodLazy = class extends ZodType {
|
|
|
3398
3397
|
get schema() {
|
|
3399
3398
|
return this._def.getter();
|
|
3400
3399
|
}
|
|
3401
|
-
_parse(
|
|
3402
|
-
const { ctx } = this._processInputParams(
|
|
3400
|
+
_parse(input2) {
|
|
3401
|
+
const { ctx } = this._processInputParams(input2);
|
|
3403
3402
|
const lazySchema = this._def.getter();
|
|
3404
3403
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3405
3404
|
}
|
|
@@ -3412,9 +3411,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
3412
3411
|
});
|
|
3413
3412
|
};
|
|
3414
3413
|
var ZodLiteral = class extends ZodType {
|
|
3415
|
-
_parse(
|
|
3416
|
-
if (
|
|
3417
|
-
const ctx = this._getOrReturnCtx(
|
|
3414
|
+
_parse(input2) {
|
|
3415
|
+
if (input2.data !== this._def.value) {
|
|
3416
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3418
3417
|
addIssueToContext(ctx, {
|
|
3419
3418
|
received: ctx.data,
|
|
3420
3419
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -3422,7 +3421,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
3422
3421
|
});
|
|
3423
3422
|
return INVALID;
|
|
3424
3423
|
}
|
|
3425
|
-
return { status: "valid", value:
|
|
3424
|
+
return { status: "valid", value: input2.data };
|
|
3426
3425
|
}
|
|
3427
3426
|
get value() {
|
|
3428
3427
|
return this._def.value;
|
|
@@ -3443,9 +3442,9 @@ function createZodEnum(values, params) {
|
|
|
3443
3442
|
});
|
|
3444
3443
|
}
|
|
3445
3444
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3446
|
-
_parse(
|
|
3447
|
-
if (typeof
|
|
3448
|
-
const ctx = this._getOrReturnCtx(
|
|
3445
|
+
_parse(input2) {
|
|
3446
|
+
if (typeof input2.data !== "string") {
|
|
3447
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3449
3448
|
const expectedValues = this._def.values;
|
|
3450
3449
|
addIssueToContext(ctx, {
|
|
3451
3450
|
expected: util.joinValues(expectedValues),
|
|
@@ -3457,8 +3456,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3457
3456
|
if (!this._cache) {
|
|
3458
3457
|
this._cache = new Set(this._def.values);
|
|
3459
3458
|
}
|
|
3460
|
-
if (!this._cache.has(
|
|
3461
|
-
const ctx = this._getOrReturnCtx(
|
|
3459
|
+
if (!this._cache.has(input2.data)) {
|
|
3460
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3462
3461
|
const expectedValues = this._def.values;
|
|
3463
3462
|
addIssueToContext(ctx, {
|
|
3464
3463
|
received: ctx.data,
|
|
@@ -3467,7 +3466,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3467
3466
|
});
|
|
3468
3467
|
return INVALID;
|
|
3469
3468
|
}
|
|
3470
|
-
return OK(
|
|
3469
|
+
return OK(input2.data);
|
|
3471
3470
|
}
|
|
3472
3471
|
get options() {
|
|
3473
3472
|
return this._def.values;
|
|
@@ -3508,9 +3507,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3508
3507
|
};
|
|
3509
3508
|
ZodEnum.create = createZodEnum;
|
|
3510
3509
|
var ZodNativeEnum = class extends ZodType {
|
|
3511
|
-
_parse(
|
|
3510
|
+
_parse(input2) {
|
|
3512
3511
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3513
|
-
const ctx = this._getOrReturnCtx(
|
|
3512
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3514
3513
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
3515
3514
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3516
3515
|
addIssueToContext(ctx, {
|
|
@@ -3523,7 +3522,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3523
3522
|
if (!this._cache) {
|
|
3524
3523
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3525
3524
|
}
|
|
3526
|
-
if (!this._cache.has(
|
|
3525
|
+
if (!this._cache.has(input2.data)) {
|
|
3527
3526
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3528
3527
|
addIssueToContext(ctx, {
|
|
3529
3528
|
received: ctx.data,
|
|
@@ -3532,7 +3531,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3532
3531
|
});
|
|
3533
3532
|
return INVALID;
|
|
3534
3533
|
}
|
|
3535
|
-
return OK(
|
|
3534
|
+
return OK(input2.data);
|
|
3536
3535
|
}
|
|
3537
3536
|
get enum() {
|
|
3538
3537
|
return this._def.values;
|
|
@@ -3549,8 +3548,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3549
3548
|
unwrap() {
|
|
3550
3549
|
return this._def.type;
|
|
3551
3550
|
}
|
|
3552
|
-
_parse(
|
|
3553
|
-
const { ctx } = this._processInputParams(
|
|
3551
|
+
_parse(input2) {
|
|
3552
|
+
const { ctx } = this._processInputParams(input2);
|
|
3554
3553
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
3555
3554
|
addIssueToContext(ctx, {
|
|
3556
3555
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3582,8 +3581,8 @@ var ZodEffects = class extends ZodType {
|
|
|
3582
3581
|
sourceType() {
|
|
3583
3582
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3584
3583
|
}
|
|
3585
|
-
_parse(
|
|
3586
|
-
const { status, ctx } = this._processInputParams(
|
|
3584
|
+
_parse(input2) {
|
|
3585
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3587
3586
|
const effect = this._def.effect || null;
|
|
3588
3587
|
const checkCtx = {
|
|
3589
3588
|
addIssue: (arg) => {
|
|
@@ -3715,12 +3714,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
|
3715
3714
|
});
|
|
3716
3715
|
};
|
|
3717
3716
|
var ZodOptional = class extends ZodType {
|
|
3718
|
-
_parse(
|
|
3719
|
-
const parsedType = this._getType(
|
|
3717
|
+
_parse(input2) {
|
|
3718
|
+
const parsedType = this._getType(input2);
|
|
3720
3719
|
if (parsedType === ZodParsedType.undefined) {
|
|
3721
3720
|
return OK(void 0);
|
|
3722
3721
|
}
|
|
3723
|
-
return this._def.innerType._parse(
|
|
3722
|
+
return this._def.innerType._parse(input2);
|
|
3724
3723
|
}
|
|
3725
3724
|
unwrap() {
|
|
3726
3725
|
return this._def.innerType;
|
|
@@ -3734,12 +3733,12 @@ ZodOptional.create = (type, params) => {
|
|
|
3734
3733
|
});
|
|
3735
3734
|
};
|
|
3736
3735
|
var ZodNullable = class extends ZodType {
|
|
3737
|
-
_parse(
|
|
3738
|
-
const parsedType = this._getType(
|
|
3736
|
+
_parse(input2) {
|
|
3737
|
+
const parsedType = this._getType(input2);
|
|
3739
3738
|
if (parsedType === ZodParsedType.null) {
|
|
3740
3739
|
return OK(null);
|
|
3741
3740
|
}
|
|
3742
|
-
return this._def.innerType._parse(
|
|
3741
|
+
return this._def.innerType._parse(input2);
|
|
3743
3742
|
}
|
|
3744
3743
|
unwrap() {
|
|
3745
3744
|
return this._def.innerType;
|
|
@@ -3753,8 +3752,8 @@ ZodNullable.create = (type, params) => {
|
|
|
3753
3752
|
});
|
|
3754
3753
|
};
|
|
3755
3754
|
var ZodDefault = class extends ZodType {
|
|
3756
|
-
_parse(
|
|
3757
|
-
const { ctx } = this._processInputParams(
|
|
3755
|
+
_parse(input2) {
|
|
3756
|
+
const { ctx } = this._processInputParams(input2);
|
|
3758
3757
|
let data = ctx.data;
|
|
3759
3758
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
3760
3759
|
data = this._def.defaultValue();
|
|
@@ -3778,8 +3777,8 @@ ZodDefault.create = (type, params) => {
|
|
|
3778
3777
|
});
|
|
3779
3778
|
};
|
|
3780
3779
|
var ZodCatch = class extends ZodType {
|
|
3781
|
-
_parse(
|
|
3782
|
-
const { ctx } = this._processInputParams(
|
|
3780
|
+
_parse(input2) {
|
|
3781
|
+
const { ctx } = this._processInputParams(input2);
|
|
3783
3782
|
const newCtx = {
|
|
3784
3783
|
...ctx,
|
|
3785
3784
|
common: {
|
|
@@ -3831,10 +3830,10 @@ ZodCatch.create = (type, params) => {
|
|
|
3831
3830
|
});
|
|
3832
3831
|
};
|
|
3833
3832
|
var ZodNaN = class extends ZodType {
|
|
3834
|
-
_parse(
|
|
3835
|
-
const parsedType = this._getType(
|
|
3833
|
+
_parse(input2) {
|
|
3834
|
+
const parsedType = this._getType(input2);
|
|
3836
3835
|
if (parsedType !== ZodParsedType.nan) {
|
|
3837
|
-
const ctx = this._getOrReturnCtx(
|
|
3836
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3838
3837
|
addIssueToContext(ctx, {
|
|
3839
3838
|
code: ZodIssueCode.invalid_type,
|
|
3840
3839
|
expected: ZodParsedType.nan,
|
|
@@ -3842,7 +3841,7 @@ var ZodNaN = class extends ZodType {
|
|
|
3842
3841
|
});
|
|
3843
3842
|
return INVALID;
|
|
3844
3843
|
}
|
|
3845
|
-
return { status: "valid", value:
|
|
3844
|
+
return { status: "valid", value: input2.data };
|
|
3846
3845
|
}
|
|
3847
3846
|
};
|
|
3848
3847
|
ZodNaN.create = (params) => {
|
|
@@ -3853,8 +3852,8 @@ ZodNaN.create = (params) => {
|
|
|
3853
3852
|
};
|
|
3854
3853
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3855
3854
|
var ZodBranded = class extends ZodType {
|
|
3856
|
-
_parse(
|
|
3857
|
-
const { ctx } = this._processInputParams(
|
|
3855
|
+
_parse(input2) {
|
|
3856
|
+
const { ctx } = this._processInputParams(input2);
|
|
3858
3857
|
const data = ctx.data;
|
|
3859
3858
|
return this._def.type._parse({
|
|
3860
3859
|
data,
|
|
@@ -3867,8 +3866,8 @@ var ZodBranded = class extends ZodType {
|
|
|
3867
3866
|
}
|
|
3868
3867
|
};
|
|
3869
3868
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
3870
|
-
_parse(
|
|
3871
|
-
const { status, ctx } = this._processInputParams(
|
|
3869
|
+
_parse(input2) {
|
|
3870
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3872
3871
|
if (ctx.common.async) {
|
|
3873
3872
|
const handleAsync = async () => {
|
|
3874
3873
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -3922,8 +3921,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3922
3921
|
}
|
|
3923
3922
|
};
|
|
3924
3923
|
var ZodReadonly = class extends ZodType {
|
|
3925
|
-
_parse(
|
|
3926
|
-
const result = this._def.innerType._parse(
|
|
3924
|
+
_parse(input2) {
|
|
3925
|
+
const result = this._def.innerType._parse(input2);
|
|
3927
3926
|
const freeze = (data) => {
|
|
3928
3927
|
if (isValid(data)) {
|
|
3929
3928
|
data.value = Object.freeze(data.value);
|
|
@@ -4565,6 +4564,70 @@ var saveHtmlAuditReportTool = tool5(
|
|
|
4565
4564
|
}
|
|
4566
4565
|
);
|
|
4567
4566
|
|
|
4567
|
+
// src/model-factory.ts
|
|
4568
|
+
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
4569
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
4570
|
+
import { ChatAnthropic } from "@langchain/anthropic";
|
|
4571
|
+
import { ChatOllama } from "@langchain/ollama";
|
|
4572
|
+
function createChatModel(config) {
|
|
4573
|
+
const { provider, apiKey = "", modelName, baseUrl } = config;
|
|
4574
|
+
switch (provider) {
|
|
4575
|
+
case "gemini":
|
|
4576
|
+
return new ChatGoogleGenerativeAI({
|
|
4577
|
+
model: modelName || process.env.GEMINI_MODEL || "gemini-2.5-flash",
|
|
4578
|
+
temperature: 0.2,
|
|
4579
|
+
apiKey,
|
|
4580
|
+
maxRetries: 3
|
|
4581
|
+
});
|
|
4582
|
+
case "openai":
|
|
4583
|
+
return new ChatOpenAI({
|
|
4584
|
+
model: modelName || process.env.OPENAI_MODEL || "gpt-4o",
|
|
4585
|
+
temperature: 0.2,
|
|
4586
|
+
apiKey,
|
|
4587
|
+
maxRetries: 3
|
|
4588
|
+
});
|
|
4589
|
+
case "anthropic":
|
|
4590
|
+
return new ChatAnthropic({
|
|
4591
|
+
model: modelName || process.env.ANTHROPIC_MODEL || "claude-3-5-sonnet-latest",
|
|
4592
|
+
temperature: 0.2,
|
|
4593
|
+
apiKey,
|
|
4594
|
+
maxRetries: 3
|
|
4595
|
+
});
|
|
4596
|
+
case "groq":
|
|
4597
|
+
return new ChatOpenAI({
|
|
4598
|
+
model: modelName || process.env.GROQ_MODEL || "llama-3.3-70b-versatile",
|
|
4599
|
+
temperature: 0.2,
|
|
4600
|
+
apiKey,
|
|
4601
|
+
configuration: {
|
|
4602
|
+
baseURL: "https://api.groq.com/openai/v1"
|
|
4603
|
+
},
|
|
4604
|
+
maxRetries: 3
|
|
4605
|
+
});
|
|
4606
|
+
case "openrouter":
|
|
4607
|
+
return new ChatOpenAI({
|
|
4608
|
+
model: modelName || process.env.OPENROUTER_MODEL || "qwen/qwen-2.5-coder-32b-instruct:free",
|
|
4609
|
+
temperature: 0.2,
|
|
4610
|
+
apiKey,
|
|
4611
|
+
configuration: {
|
|
4612
|
+
baseURL: "https://openrouter.ai/api/v1",
|
|
4613
|
+
defaultHeaders: {
|
|
4614
|
+
"HTTP-Referer": "https://github.com/kamran-027/probe-ai",
|
|
4615
|
+
"X-Title": "ProbeAI CLI"
|
|
4616
|
+
}
|
|
4617
|
+
},
|
|
4618
|
+
maxRetries: 3
|
|
4619
|
+
});
|
|
4620
|
+
case "ollama":
|
|
4621
|
+
return new ChatOllama({
|
|
4622
|
+
model: modelName || process.env.OLLAMA_MODEL || "qwen2.5-coder:7b",
|
|
4623
|
+
temperature: 0.2,
|
|
4624
|
+
baseUrl: baseUrl || process.env.OLLAMA_HOST || "http://localhost:11434"
|
|
4625
|
+
});
|
|
4626
|
+
default:
|
|
4627
|
+
throw new Error(`Unsupported AI provider: ${provider}`);
|
|
4628
|
+
}
|
|
4629
|
+
}
|
|
4630
|
+
|
|
4568
4631
|
// src/agent.ts
|
|
4569
4632
|
var tools = [
|
|
4570
4633
|
fetchOpenApiSpecTool,
|
|
@@ -4581,14 +4644,9 @@ var GraphState = Annotation.Root({
|
|
|
4581
4644
|
default: () => []
|
|
4582
4645
|
})
|
|
4583
4646
|
});
|
|
4584
|
-
function createProbeAgent(
|
|
4585
|
-
const
|
|
4586
|
-
|
|
4587
|
-
temperature: 0.2,
|
|
4588
|
-
apiKey,
|
|
4589
|
-
maxRetries: 3
|
|
4590
|
-
// Auto-retry on transient Google 503 spikes
|
|
4591
|
-
}).bindTools(tools);
|
|
4647
|
+
function createProbeAgent(config) {
|
|
4648
|
+
const baseModel = createChatModel(config);
|
|
4649
|
+
const model = baseModel.bindTools(tools);
|
|
4592
4650
|
const callModel = async (state) => {
|
|
4593
4651
|
const response = await model.invoke(state.messages);
|
|
4594
4652
|
return { messages: [response] };
|
|
@@ -4607,6 +4665,108 @@ var PROBE_SYSTEM_MESSAGE = new SystemMessage(
|
|
|
4607
4665
|
"You are ProbeAI, an expert Senior API Reliability and QA Test Engineer agent.\nWhen the user interacts with you:\n1. For API Inspection & Testing:\n - Call fetch_openapi_spec to discover endpoints & security schemes.\n - If authentication is required or requested, use authenticate_via_login or set_auth_header.\n - Formulate 3-4 distinct test cases (Happy Path, Query Filters, Error cases).\n - STRICT BUDGET RULE: Execute at most 4 to 5 execute_http_request calls in total.\n2. If requested to export Postman collections, call export_postman_collection.\n3. If requested to generate reports (or after running a comprehensive test suite), call save_html_audit_report.\n4. Always finish with a clear markdown summary table and reliability grade."
|
|
4608
4666
|
);
|
|
4609
4667
|
|
|
4668
|
+
// src/wizard.ts
|
|
4669
|
+
import chalk7 from "chalk";
|
|
4670
|
+
import { select, password, input } from "@inquirer/prompts";
|
|
4671
|
+
async function resolveProviderConfig() {
|
|
4672
|
+
if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) {
|
|
4673
|
+
return {
|
|
4674
|
+
provider: "gemini",
|
|
4675
|
+
apiKey: process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY,
|
|
4676
|
+
modelName: process.env.GEMINI_MODEL
|
|
4677
|
+
};
|
|
4678
|
+
}
|
|
4679
|
+
if (process.env.OPENAI_API_KEY) {
|
|
4680
|
+
return {
|
|
4681
|
+
provider: "openai",
|
|
4682
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
4683
|
+
modelName: process.env.OPENAI_MODEL
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4686
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
4687
|
+
return {
|
|
4688
|
+
provider: "anthropic",
|
|
4689
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
4690
|
+
modelName: process.env.ANTHROPIC_MODEL
|
|
4691
|
+
};
|
|
4692
|
+
}
|
|
4693
|
+
if (process.env.GROQ_API_KEY) {
|
|
4694
|
+
return {
|
|
4695
|
+
provider: "groq",
|
|
4696
|
+
apiKey: process.env.GROQ_API_KEY,
|
|
4697
|
+
modelName: process.env.GROQ_MODEL
|
|
4698
|
+
};
|
|
4699
|
+
}
|
|
4700
|
+
if (process.env.OPENROUTER_API_KEY) {
|
|
4701
|
+
return {
|
|
4702
|
+
provider: "openrouter",
|
|
4703
|
+
apiKey: process.env.OPENROUTER_API_KEY,
|
|
4704
|
+
modelName: process.env.OPENROUTER_MODEL
|
|
4705
|
+
};
|
|
4706
|
+
}
|
|
4707
|
+
console.log(chalk7.dim("Select your AI model provider to get started:\n"));
|
|
4708
|
+
const provider = await select({
|
|
4709
|
+
message: "Choose AI Engine Provider:",
|
|
4710
|
+
choices: [
|
|
4711
|
+
{
|
|
4712
|
+
name: `${chalk7.bold.cyan("\u{1F537} Google Gemini")} ${chalk7.dim("(Gemini 2.5 Flash / 3.6 Flash - Free & Fast)")}`,
|
|
4713
|
+
value: "gemini"
|
|
4714
|
+
},
|
|
4715
|
+
{
|
|
4716
|
+
name: `${chalk7.bold.green("\u{1F7E2} OpenAI")} ${chalk7.dim("(GPT-5.6 / GPT-4o / GPT-4o-mini)")}`,
|
|
4717
|
+
value: "openai"
|
|
4718
|
+
},
|
|
4719
|
+
{
|
|
4720
|
+
name: `${chalk7.bold.hex("#A855F7")("\u{1F7E3} Anthropic Claude")} ${chalk7.dim("(Sonnet 5 / Claude 3.5 Sonnet)")}`,
|
|
4721
|
+
value: "anthropic"
|
|
4722
|
+
},
|
|
4723
|
+
{
|
|
4724
|
+
name: `${chalk7.bold.yellow("\u26A1 Groq")} ${chalk7.dim("(Llama 3.3 70B - Free tier & Ultra-Fast)")}`,
|
|
4725
|
+
value: "groq"
|
|
4726
|
+
},
|
|
4727
|
+
{
|
|
4728
|
+
name: `${chalk7.bold.hex("#3B82F6")("\u{1F310} OpenRouter")} ${chalk7.dim("(DeepSeek / Qwen 2.5 - Free tiers)")}`,
|
|
4729
|
+
value: "openrouter"
|
|
4730
|
+
},
|
|
4731
|
+
{
|
|
4732
|
+
name: `${chalk7.bold.white("\u{1F999} Ollama")} ${chalk7.dim("(Local / 100% Offline - No API key needed)")}`,
|
|
4733
|
+
value: "ollama"
|
|
4734
|
+
}
|
|
4735
|
+
]
|
|
4736
|
+
});
|
|
4737
|
+
if (provider === "ollama") {
|
|
4738
|
+
const customModel2 = await input({
|
|
4739
|
+
message: "Enter Ollama model name (default: qwen2.5-coder:7b):",
|
|
4740
|
+
default: "qwen2.5-coder:7b"
|
|
4741
|
+
});
|
|
4742
|
+
return { provider: "ollama", modelName: customModel2 };
|
|
4743
|
+
}
|
|
4744
|
+
const keyLabels = {
|
|
4745
|
+
gemini: "Gemini API Key (https://aistudio.google.com):",
|
|
4746
|
+
openai: "OpenAI API Key (https://platform.openai.com):",
|
|
4747
|
+
anthropic: "Anthropic API Key (https://console.anthropic.com):",
|
|
4748
|
+
groq: "Groq API Key (https://console.groq.com):",
|
|
4749
|
+
openrouter: "OpenRouter API Key (https://openrouter.ai):"
|
|
4750
|
+
};
|
|
4751
|
+
const key = await password({
|
|
4752
|
+
message: `Enter your ${keyLabels[provider]}`,
|
|
4753
|
+
mask: "\u2022"
|
|
4754
|
+
});
|
|
4755
|
+
if (!key.trim()) {
|
|
4756
|
+
console.log(chalk7.red("\nError: An API key is required to proceed. Exiting...\n"));
|
|
4757
|
+
process.exit(1);
|
|
4758
|
+
}
|
|
4759
|
+
const customModel = await input({
|
|
4760
|
+
message: "Model ID (press Enter to use provider default):",
|
|
4761
|
+
default: ""
|
|
4762
|
+
});
|
|
4763
|
+
return {
|
|
4764
|
+
provider,
|
|
4765
|
+
apiKey: key.trim(),
|
|
4766
|
+
modelName: customModel.trim() || void 0
|
|
4767
|
+
};
|
|
4768
|
+
}
|
|
4769
|
+
|
|
4610
4770
|
// src/index.ts
|
|
4611
4771
|
dotenv.config();
|
|
4612
4772
|
marked.use(
|
|
@@ -4614,10 +4774,10 @@ marked.use(
|
|
|
4614
4774
|
width: 90,
|
|
4615
4775
|
reflowText: true,
|
|
4616
4776
|
tab: 2,
|
|
4617
|
-
heading:
|
|
4618
|
-
firstHeading:
|
|
4619
|
-
strong:
|
|
4620
|
-
listitem:
|
|
4777
|
+
heading: chalk8.bold.hex("#6366F1"),
|
|
4778
|
+
firstHeading: chalk8.bold.hex("#A855F7"),
|
|
4779
|
+
strong: chalk8.bold.white,
|
|
4780
|
+
listitem: chalk8.cyan,
|
|
4621
4781
|
tableOptions: {
|
|
4622
4782
|
style: {
|
|
4623
4783
|
head: ["cyan", "bold"],
|
|
@@ -4627,7 +4787,17 @@ marked.use(
|
|
|
4627
4787
|
})
|
|
4628
4788
|
);
|
|
4629
4789
|
async function main() {
|
|
4630
|
-
printModernBanner("1.0
|
|
4790
|
+
printModernBanner("1.1.0");
|
|
4791
|
+
const providerConfig = await resolveProviderConfig();
|
|
4792
|
+
console.log(
|
|
4793
|
+
chalk8.hex("#10B981")(
|
|
4794
|
+
`
|
|
4795
|
+
\u2713 Connected to ${providerConfig.provider.toUpperCase()} engine${providerConfig.modelName ? ` (${providerConfig.modelName})` : ""}
|
|
4796
|
+
`
|
|
4797
|
+
)
|
|
4798
|
+
);
|
|
4799
|
+
const app = createProbeAgent(providerConfig);
|
|
4800
|
+
const messages = [PROBE_SYSTEM_MESSAGE];
|
|
4631
4801
|
const rl = readline.createInterface({
|
|
4632
4802
|
input: process.stdin,
|
|
4633
4803
|
output: process.stdout
|
|
@@ -4639,35 +4809,21 @@ async function main() {
|
|
|
4639
4809
|
});
|
|
4640
4810
|
});
|
|
4641
4811
|
};
|
|
4642
|
-
let apiKey = process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY;
|
|
4643
|
-
if (!apiKey) {
|
|
4644
|
-
console.log(chalk7.yellow("\u{1F511} No GEMINI_API_KEY found in your environment or .env file."));
|
|
4645
|
-
console.log(chalk7.dim("Get a free key from https://aistudio.google.com/\n"));
|
|
4646
|
-
apiKey = await promptUser(chalk7.bold.hex("#6366F1")("Enter your Gemini API Key: "));
|
|
4647
|
-
if (!apiKey) {
|
|
4648
|
-
console.log(chalk7.red("\nError: An API key is required to run ProbeAI. Exiting...\n"));
|
|
4649
|
-
rl.close();
|
|
4650
|
-
process.exit(1);
|
|
4651
|
-
}
|
|
4652
|
-
console.log(chalk7.hex("#10B981")("\u2713 API Key registered for this session.\n"));
|
|
4653
|
-
}
|
|
4654
|
-
const app = createProbeAgent(apiKey);
|
|
4655
|
-
const messages = [PROBE_SYSTEM_MESSAGE];
|
|
4656
4812
|
while (true) {
|
|
4657
4813
|
try {
|
|
4658
|
-
const promptSymbol =
|
|
4659
|
-
const
|
|
4814
|
+
const promptSymbol = chalk8.bold.hex("#6366F1")("\u276F ");
|
|
4815
|
+
const input2 = await promptUser(`
|
|
4660
4816
|
${promptSymbol}`);
|
|
4661
|
-
if (!
|
|
4662
|
-
if (
|
|
4663
|
-
console.log(
|
|
4817
|
+
if (!input2) continue;
|
|
4818
|
+
if (input2.toLowerCase() === "exit" || input2.toLowerCase() === "quit") {
|
|
4819
|
+
console.log(chalk8.hex("#6366F1")("\nGoodbye! \u{1F44B}\n"));
|
|
4664
4820
|
rl.close();
|
|
4665
4821
|
process.exit(0);
|
|
4666
4822
|
}
|
|
4667
4823
|
console.log();
|
|
4668
|
-
messages.push(new HumanMessage(
|
|
4824
|
+
messages.push(new HumanMessage(input2));
|
|
4669
4825
|
const spinner = ora({
|
|
4670
|
-
text:
|
|
4826
|
+
text: chalk8.dim("Synthesizing test scenarios & auditing schemas..."),
|
|
4671
4827
|
color: "cyan"
|
|
4672
4828
|
}).start();
|
|
4673
4829
|
let finalResponse = "";
|
|
@@ -4683,7 +4839,7 @@ ${promptSymbol}`);
|
|
|
4683
4839
|
spinner.stop();
|
|
4684
4840
|
if (finalResponse) {
|
|
4685
4841
|
console.log(
|
|
4686
|
-
"\n" +
|
|
4842
|
+
"\n" + chalk8.hex("#6366F1")(
|
|
4687
4843
|
"\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 ProbeAI Assessment \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n"
|
|
4688
4844
|
)
|
|
4689
4845
|
);
|
|
@@ -4691,7 +4847,7 @@ ${promptSymbol}`);
|
|
|
4691
4847
|
console.log(rendered);
|
|
4692
4848
|
}
|
|
4693
4849
|
} catch (err) {
|
|
4694
|
-
console.log(
|
|
4850
|
+
console.log(chalk8.red(`
|
|
4695
4851
|
An error occurred: ${err.message}`));
|
|
4696
4852
|
}
|
|
4697
4853
|
}
|