@supatest/cli 0.0.4 → 0.0.6

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.
Files changed (2) hide show
  1. package/dist/index.js +3144 -248
  2. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -542,7 +542,7 @@ function getInstalledChromiumVersion() {
542
542
  if (!cachePath) return null;
543
543
  try {
544
544
  const entries = fs.readdirSync(cachePath);
545
- const chromiumVersions = entries.filter((entry) => entry.startsWith("chromium-") && !entry.includes("headless")).map((entry) => entry.replace("chromium-", "")).sort((a, b) => Number(b) - Number(a));
545
+ const chromiumVersions = entries.filter((entry) => entry.startsWith("chromium-") && !entry.includes("headless")).map((entry) => entry.replace("chromium-", "")).sort((a, b2) => Number(b2) - Number(a));
546
546
  return chromiumVersions[0] || null;
547
547
  } catch {
548
548
  return null;
@@ -824,11 +824,6 @@ ${projectInstructions}`
824
824
  if (msg.type === "assistant") {
825
825
  iterations++;
826
826
  const content = msg.message.content;
827
- const usage = msg.message.usage;
828
- if (usage) {
829
- const turnTokens = (usage.input_tokens || 0) + (usage.output_tokens || 0);
830
- await this.presenter.onUsageUpdate?.(turnTokens);
831
- }
832
827
  if (Array.isArray(content)) {
833
828
  for (const block of content) {
834
829
  if (block.type === "text") {
@@ -875,216 +870,3108 @@ ${projectInstructions}`
875
870
  }
876
871
  }
877
872
  };
878
- try {
879
- await runQuery(queryOptions);
880
- } catch (error) {
881
- const errorMessage = error instanceof Error ? error.message : String(error);
882
- const isAbortError = error instanceof Error && error.name === "AbortError" || errorMessage.toLowerCase().includes("aborted");
883
- if (isAbortError) {
884
- wasInterrupted = true;
885
- } else if (config2.providerSessionId && isSessionExpiredError(errorMessage)) {
886
- const expiredMessage = "Can't continue conversation older than 30 days. Please start a new session.";
887
- await this.presenter.onError(expiredMessage);
888
- hasError = true;
889
- errors.push(expiredMessage);
890
- } else {
891
- await this.presenter.onError(errorMessage);
892
- hasError = true;
893
- errors.push(errorMessage);
873
+ try {
874
+ await runQuery(queryOptions);
875
+ } catch (error) {
876
+ const errorMessage = error instanceof Error ? error.message : String(error);
877
+ const isAbortError = error instanceof Error && error.name === "AbortError" || errorMessage.toLowerCase().includes("aborted");
878
+ if (isAbortError) {
879
+ wasInterrupted = true;
880
+ } else if (config2.providerSessionId && isSessionExpiredError(errorMessage)) {
881
+ const expiredMessage = "Can't continue conversation older than 30 days. Please start a new session.";
882
+ await this.presenter.onError(expiredMessage);
883
+ hasError = true;
884
+ errors.push(expiredMessage);
885
+ } else {
886
+ await this.presenter.onError(errorMessage);
887
+ hasError = true;
888
+ errors.push(errorMessage);
889
+ }
890
+ }
891
+ const result = {
892
+ success: !hasError && errors.length === 0 && !wasInterrupted,
893
+ summary: wasInterrupted ? "Interrupted by user" : resultText || "Task completed",
894
+ filesModified: Array.from(filesModified),
895
+ iterations,
896
+ error: wasInterrupted ? "Interrupted by user" : errors.length > 0 ? errors.join("; ") : void 0,
897
+ // Include the provider session ID for resume capability
898
+ providerSessionId
899
+ };
900
+ await this.presenter.onComplete(result);
901
+ return result;
902
+ }
903
+ async resolveClaudeCodePath() {
904
+ if (config.claudeCodeExecutablePath) {
905
+ this.presenter.onLog(
906
+ `Using CLAUDE_CODE_EXECUTABLE_PATH: ${config.claudeCodeExecutablePath}`
907
+ );
908
+ return config.claudeCodeExecutablePath;
909
+ }
910
+ const isCompiledBinary2 = process.execPath && !process.execPath.includes("node");
911
+ let claudeCodePath;
912
+ if (isCompiledBinary2) {
913
+ claudeCodePath = join2(dirname(process.execPath), "claude-code-cli.js");
914
+ this.presenter.onLog(`Production mode: ${claudeCodePath}`);
915
+ } else {
916
+ const require2 = createRequire(import.meta.url);
917
+ const sdkPath = require2.resolve("@anthropic-ai/claude-agent-sdk/sdk.mjs");
918
+ claudeCodePath = join2(dirname(sdkPath), "cli.js");
919
+ this.presenter.onLog(`Development mode: ${claudeCodePath}`);
920
+ }
921
+ const fs4 = await import("fs/promises");
922
+ try {
923
+ await fs4.access(claudeCodePath);
924
+ this.presenter.onLog(`\u2713 Claude Code CLI found: ${claudeCodePath}`);
925
+ } catch {
926
+ const error = `Claude Code executable not found at: ${claudeCodePath}
927
+ For compiled binaries, ensure claude-code-cli.js is in the same directory as the binary.
928
+ Set CLAUDE_CODE_EXECUTABLE_PATH environment variable to override.`;
929
+ await this.presenter.onError(error);
930
+ throw new Error(error);
931
+ }
932
+ return claudeCodePath;
933
+ }
934
+ };
935
+ }
936
+ });
937
+
938
+ // ../shared/dist/shared.es.mjs
939
+ function fe() {
940
+ return ze;
941
+ }
942
+ function d(t, e) {
943
+ const r = fe(), n = me({
944
+ issueData: e,
945
+ data: t.data,
946
+ path: t.path,
947
+ errorMaps: [
948
+ t.common.contextualErrorMap,
949
+ // contextual error map is first priority
950
+ t.schemaErrorMap,
951
+ // then schema-bound map if available
952
+ r,
953
+ // then global override map
954
+ r === Q ? void 0 : Q
955
+ // then global default map
956
+ ].filter((s) => !!s)
957
+ });
958
+ t.common.issues.push(n);
959
+ }
960
+ function y(t) {
961
+ if (!t)
962
+ return {};
963
+ const { errorMap: e, invalid_type_error: r, required_error: n, description: s } = t;
964
+ if (e && (r || n))
965
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
966
+ return e ? { errorMap: e, description: s } : { errorMap: (i, c) => {
967
+ const { message: h } = t;
968
+ return i.code === "invalid_enum_value" ? { message: h ?? c.defaultError } : typeof c.data > "u" ? { message: h ?? n ?? c.defaultError } : i.code !== "invalid_type" ? { message: c.defaultError } : { message: h ?? r ?? c.defaultError };
969
+ }, description: s };
970
+ }
971
+ function je(t) {
972
+ let e = "[0-5]\\d";
973
+ t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
974
+ const r = t.precision ? "+" : "?";
975
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
976
+ }
977
+ function it(t) {
978
+ return new RegExp(`^${je(t)}$`);
979
+ }
980
+ function ct(t) {
981
+ let e = `${Ue}T${je(t)}`;
982
+ const r = [];
983
+ return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
984
+ }
985
+ function ot(t, e) {
986
+ return !!((e === "v4" || !e) && He.test(t) || (e === "v6" || !e) && tt.test(t));
987
+ }
988
+ function dt(t, e) {
989
+ if (!Qe.test(t))
990
+ return false;
991
+ try {
992
+ const [r] = t.split(".");
993
+ if (!r)
994
+ return false;
995
+ const n = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), s = JSON.parse(atob(n));
996
+ return !(typeof s != "object" || s === null || "typ" in s && (s == null ? void 0 : s.typ) !== "JWT" || !s.alg || e && s.alg !== e);
997
+ } catch {
998
+ return false;
999
+ }
1000
+ }
1001
+ function ut(t, e) {
1002
+ return !!((e === "v4" || !e) && et.test(t) || (e === "v6" || !e) && rt.test(t));
1003
+ }
1004
+ function lt(t, e) {
1005
+ const r = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = r > n ? r : n, a = Number.parseInt(t.toFixed(s).replace(".", "")), i = Number.parseInt(e.toFixed(s).replace(".", ""));
1006
+ return a % i / 10 ** s;
1007
+ }
1008
+ function V(t) {
1009
+ if (t instanceof x) {
1010
+ const e = {};
1011
+ for (const r in t.shape) {
1012
+ const n = t.shape[r];
1013
+ e[r] = M.create(V(n));
1014
+ }
1015
+ return new x({
1016
+ ...t._def,
1017
+ shape: () => e
1018
+ });
1019
+ } else return t instanceof I ? new I({
1020
+ ...t._def,
1021
+ type: V(t.element)
1022
+ }) : t instanceof M ? M.create(V(t.unwrap())) : t instanceof C ? C.create(V(t.unwrap())) : t instanceof P ? P.create(t.items.map((e) => V(e))) : t;
1023
+ }
1024
+ function ge(t, e) {
1025
+ const r = S(t), n = S(e);
1026
+ if (t === e)
1027
+ return { valid: true, data: t };
1028
+ if (r === u.object && n === u.object) {
1029
+ const s = E.objectKeys(e), a = E.objectKeys(t).filter((c) => s.indexOf(c) !== -1), i = { ...t, ...e };
1030
+ for (const c of a) {
1031
+ const h = ge(t[c], e[c]);
1032
+ if (!h.valid)
1033
+ return { valid: false };
1034
+ i[c] = h.data;
1035
+ }
1036
+ return { valid: true, data: i };
1037
+ } else if (r === u.array && n === u.array) {
1038
+ if (t.length !== e.length)
1039
+ return { valid: false };
1040
+ const s = [];
1041
+ for (let a = 0; a < t.length; a++) {
1042
+ const i = t[a], c = e[a], h = ge(i, c);
1043
+ if (!h.valid)
1044
+ return { valid: false };
1045
+ s.push(h.data);
1046
+ }
1047
+ return { valid: true, data: s };
1048
+ } else return r === u.date && n === u.date && +t == +e ? { valid: true, data: t } : { valid: false };
1049
+ }
1050
+ function $e(t, e) {
1051
+ return new j({
1052
+ values: t,
1053
+ typeName: p.ZodEnum,
1054
+ ...y(e)
1055
+ });
1056
+ }
1057
+ function Ct(t) {
1058
+ return {
1059
+ Grep: "Search",
1060
+ Glob: "Search",
1061
+ BashOutput: "Command Output"
1062
+ }[t] || t;
1063
+ }
1064
+ var E, be, u, S, o, A, Q, ze, me, k, _, W, b, Ne, Ae, z, re, f, w, Re, g, Be, Ge, Ye, We, qe, Qe, Xe, Ke, Je, he, He, et, tt, rt, nt, st, Ue, at, Z, B, X, _e, K, Ie, pe, ye, we, F, U, De, I, x, ne, D, Ee, se, P, ae, Ze, J, q, ve, ie, j, Te, H, $, M, C, ce, oe, Le, Ce, xe, de, p, m, L, ke, R, te, ee, T, ht, Ve, Y, Me, O, G, ft, Pe, xt, kt, Ot, bt, Nt, mt, Se, _t, At, pt, yt, gt, vt, Tt, Et, ue, It, wt, Dt, Zt, Lt, Mt, Pt;
1065
+ var init_shared_es = __esm({
1066
+ "../shared/dist/shared.es.mjs"() {
1067
+ "use strict";
1068
+ (function(t) {
1069
+ t.assertEqual = (s) => {
1070
+ };
1071
+ function e(s) {
1072
+ }
1073
+ t.assertIs = e;
1074
+ function r(s) {
1075
+ throw new Error();
1076
+ }
1077
+ t.assertNever = r, t.arrayToEnum = (s) => {
1078
+ const a = {};
1079
+ for (const i of s)
1080
+ a[i] = i;
1081
+ return a;
1082
+ }, t.getValidEnumValues = (s) => {
1083
+ const a = t.objectKeys(s).filter((c) => typeof s[s[c]] != "number"), i = {};
1084
+ for (const c of a)
1085
+ i[c] = s[c];
1086
+ return t.objectValues(i);
1087
+ }, t.objectValues = (s) => t.objectKeys(s).map(function(a) {
1088
+ return s[a];
1089
+ }), t.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
1090
+ const a = [];
1091
+ for (const i in s)
1092
+ Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
1093
+ return a;
1094
+ }, t.find = (s, a) => {
1095
+ for (const i of s)
1096
+ if (a(i))
1097
+ return i;
1098
+ }, t.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && Number.isFinite(s) && Math.floor(s) === s;
1099
+ function n(s, a = " | ") {
1100
+ return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
1101
+ }
1102
+ t.joinValues = n, t.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
1103
+ })(E || (E = {}));
1104
+ (function(t) {
1105
+ t.mergeShapes = (e, r) => ({
1106
+ ...e,
1107
+ ...r
1108
+ // second overwrites first
1109
+ });
1110
+ })(be || (be = {}));
1111
+ u = E.arrayToEnum([
1112
+ "string",
1113
+ "nan",
1114
+ "number",
1115
+ "integer",
1116
+ "float",
1117
+ "boolean",
1118
+ "date",
1119
+ "bigint",
1120
+ "symbol",
1121
+ "function",
1122
+ "undefined",
1123
+ "null",
1124
+ "array",
1125
+ "object",
1126
+ "unknown",
1127
+ "promise",
1128
+ "void",
1129
+ "never",
1130
+ "map",
1131
+ "set"
1132
+ ]);
1133
+ S = (t) => {
1134
+ switch (typeof t) {
1135
+ case "undefined":
1136
+ return u.undefined;
1137
+ case "string":
1138
+ return u.string;
1139
+ case "number":
1140
+ return Number.isNaN(t) ? u.nan : u.number;
1141
+ case "boolean":
1142
+ return u.boolean;
1143
+ case "function":
1144
+ return u.function;
1145
+ case "bigint":
1146
+ return u.bigint;
1147
+ case "symbol":
1148
+ return u.symbol;
1149
+ case "object":
1150
+ return Array.isArray(t) ? u.array : t === null ? u.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? u.promise : typeof Map < "u" && t instanceof Map ? u.map : typeof Set < "u" && t instanceof Set ? u.set : typeof Date < "u" && t instanceof Date ? u.date : u.object;
1151
+ default:
1152
+ return u.unknown;
1153
+ }
1154
+ };
1155
+ o = E.arrayToEnum([
1156
+ "invalid_type",
1157
+ "invalid_literal",
1158
+ "custom",
1159
+ "invalid_union",
1160
+ "invalid_union_discriminator",
1161
+ "invalid_enum_value",
1162
+ "unrecognized_keys",
1163
+ "invalid_arguments",
1164
+ "invalid_return_type",
1165
+ "invalid_date",
1166
+ "invalid_string",
1167
+ "too_small",
1168
+ "too_big",
1169
+ "invalid_intersection_types",
1170
+ "not_multiple_of",
1171
+ "not_finite"
1172
+ ]);
1173
+ A = class _A extends Error {
1174
+ get errors() {
1175
+ return this.issues;
1176
+ }
1177
+ constructor(e) {
1178
+ super(), this.issues = [], this.addIssue = (n) => {
1179
+ this.issues = [...this.issues, n];
1180
+ }, this.addIssues = (n = []) => {
1181
+ this.issues = [...this.issues, ...n];
1182
+ };
1183
+ const r = new.target.prototype;
1184
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
1185
+ }
1186
+ format(e) {
1187
+ const r = e || function(a) {
1188
+ return a.message;
1189
+ }, n = { _errors: [] }, s = (a) => {
1190
+ for (const i of a.issues)
1191
+ if (i.code === "invalid_union")
1192
+ i.unionErrors.map(s);
1193
+ else if (i.code === "invalid_return_type")
1194
+ s(i.returnTypeError);
1195
+ else if (i.code === "invalid_arguments")
1196
+ s(i.argumentsError);
1197
+ else if (i.path.length === 0)
1198
+ n._errors.push(r(i));
1199
+ else {
1200
+ let c = n, h = 0;
1201
+ for (; h < i.path.length; ) {
1202
+ const l = i.path[h];
1203
+ h === i.path.length - 1 ? (c[l] = c[l] || { _errors: [] }, c[l]._errors.push(r(i))) : c[l] = c[l] || { _errors: [] }, c = c[l], h++;
1204
+ }
1205
+ }
1206
+ };
1207
+ return s(this), n;
1208
+ }
1209
+ static assert(e) {
1210
+ if (!(e instanceof _A))
1211
+ throw new Error(`Not a ZodError: ${e}`);
1212
+ }
1213
+ toString() {
1214
+ return this.message;
1215
+ }
1216
+ get message() {
1217
+ return JSON.stringify(this.issues, E.jsonStringifyReplacer, 2);
1218
+ }
1219
+ get isEmpty() {
1220
+ return this.issues.length === 0;
1221
+ }
1222
+ flatten(e = (r) => r.message) {
1223
+ const r = {}, n = [];
1224
+ for (const s of this.issues)
1225
+ if (s.path.length > 0) {
1226
+ const a = s.path[0];
1227
+ r[a] = r[a] || [], r[a].push(e(s));
1228
+ } else
1229
+ n.push(e(s));
1230
+ return { formErrors: n, fieldErrors: r };
1231
+ }
1232
+ get formErrors() {
1233
+ return this.flatten();
1234
+ }
1235
+ };
1236
+ A.create = (t) => new A(t);
1237
+ Q = (t, e) => {
1238
+ let r;
1239
+ switch (t.code) {
1240
+ case o.invalid_type:
1241
+ t.received === u.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
1242
+ break;
1243
+ case o.invalid_literal:
1244
+ r = `Invalid literal value, expected ${JSON.stringify(t.expected, E.jsonStringifyReplacer)}`;
1245
+ break;
1246
+ case o.unrecognized_keys:
1247
+ r = `Unrecognized key(s) in object: ${E.joinValues(t.keys, ", ")}`;
1248
+ break;
1249
+ case o.invalid_union:
1250
+ r = "Invalid input";
1251
+ break;
1252
+ case o.invalid_union_discriminator:
1253
+ r = `Invalid discriminator value. Expected ${E.joinValues(t.options)}`;
1254
+ break;
1255
+ case o.invalid_enum_value:
1256
+ r = `Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;
1257
+ break;
1258
+ case o.invalid_arguments:
1259
+ r = "Invalid function arguments";
1260
+ break;
1261
+ case o.invalid_return_type:
1262
+ r = "Invalid function return type";
1263
+ break;
1264
+ case o.invalid_date:
1265
+ r = "Invalid date";
1266
+ break;
1267
+ case o.invalid_string:
1268
+ typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : E.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
1269
+ break;
1270
+ case o.too_small:
1271
+ t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
1272
+ break;
1273
+ case o.too_big:
1274
+ t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
1275
+ break;
1276
+ case o.custom:
1277
+ r = "Invalid input";
1278
+ break;
1279
+ case o.invalid_intersection_types:
1280
+ r = "Intersection results could not be merged";
1281
+ break;
1282
+ case o.not_multiple_of:
1283
+ r = `Number must be a multiple of ${t.multipleOf}`;
1284
+ break;
1285
+ case o.not_finite:
1286
+ r = "Number must be finite";
1287
+ break;
1288
+ default:
1289
+ r = e.defaultError, E.assertNever(t);
1290
+ }
1291
+ return { message: r };
1292
+ };
1293
+ ze = Q;
1294
+ me = (t) => {
1295
+ const { data: e, path: r, errorMaps: n, issueData: s } = t, a = [...r, ...s.path || []], i = {
1296
+ ...s,
1297
+ path: a
1298
+ };
1299
+ if (s.message !== void 0)
1300
+ return {
1301
+ ...s,
1302
+ path: a,
1303
+ message: s.message
1304
+ };
1305
+ let c = "";
1306
+ const h = n.filter((l) => !!l).slice().reverse();
1307
+ for (const l of h)
1308
+ c = l(i, { data: e, defaultError: c }).message;
1309
+ return {
1310
+ ...s,
1311
+ path: a,
1312
+ message: c
1313
+ };
1314
+ };
1315
+ k = class _k {
1316
+ constructor() {
1317
+ this.value = "valid";
1318
+ }
1319
+ dirty() {
1320
+ this.value === "valid" && (this.value = "dirty");
1321
+ }
1322
+ abort() {
1323
+ this.value !== "aborted" && (this.value = "aborted");
1324
+ }
1325
+ static mergeArray(e, r) {
1326
+ const n = [];
1327
+ for (const s of r) {
1328
+ if (s.status === "aborted")
1329
+ return _;
1330
+ s.status === "dirty" && e.dirty(), n.push(s.value);
1331
+ }
1332
+ return { status: e.value, value: n };
1333
+ }
1334
+ static async mergeObjectAsync(e, r) {
1335
+ const n = [];
1336
+ for (const s of r) {
1337
+ const a = await s.key, i = await s.value;
1338
+ n.push({
1339
+ key: a,
1340
+ value: i
1341
+ });
1342
+ }
1343
+ return _k.mergeObjectSync(e, n);
1344
+ }
1345
+ static mergeObjectSync(e, r) {
1346
+ const n = {};
1347
+ for (const s of r) {
1348
+ const { key: a, value: i } = s;
1349
+ if (a.status === "aborted" || i.status === "aborted")
1350
+ return _;
1351
+ a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (n[a.value] = i.value);
1352
+ }
1353
+ return { status: e.value, value: n };
1354
+ }
1355
+ };
1356
+ _ = Object.freeze({
1357
+ status: "aborted"
1358
+ });
1359
+ W = (t) => ({ status: "dirty", value: t });
1360
+ b = (t) => ({ status: "valid", value: t });
1361
+ Ne = (t) => t.status === "aborted";
1362
+ Ae = (t) => t.status === "dirty";
1363
+ z = (t) => t.status === "valid";
1364
+ re = (t) => typeof Promise < "u" && t instanceof Promise;
1365
+ (function(t) {
1366
+ t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
1367
+ })(f || (f = {}));
1368
+ w = class {
1369
+ constructor(e, r, n, s) {
1370
+ this._cachedPath = [], this.parent = e, this.data = r, this._path = n, this._key = s;
1371
+ }
1372
+ get path() {
1373
+ return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
1374
+ }
1375
+ };
1376
+ Re = (t, e) => {
1377
+ if (z(e))
1378
+ return { success: true, data: e.value };
1379
+ if (!t.common.issues.length)
1380
+ throw new Error("Validation failed but no issues detected.");
1381
+ return {
1382
+ success: false,
1383
+ get error() {
1384
+ if (this._error)
1385
+ return this._error;
1386
+ const r = new A(t.common.issues);
1387
+ return this._error = r, this._error;
1388
+ }
1389
+ };
1390
+ };
1391
+ g = class {
1392
+ get description() {
1393
+ return this._def.description;
1394
+ }
1395
+ _getType(e) {
1396
+ return S(e.data);
1397
+ }
1398
+ _getOrReturnCtx(e, r) {
1399
+ return r || {
1400
+ common: e.parent.common,
1401
+ data: e.data,
1402
+ parsedType: S(e.data),
1403
+ schemaErrorMap: this._def.errorMap,
1404
+ path: e.path,
1405
+ parent: e.parent
1406
+ };
1407
+ }
1408
+ _processInputParams(e) {
1409
+ return {
1410
+ status: new k(),
1411
+ ctx: {
1412
+ common: e.parent.common,
1413
+ data: e.data,
1414
+ parsedType: S(e.data),
1415
+ schemaErrorMap: this._def.errorMap,
1416
+ path: e.path,
1417
+ parent: e.parent
1418
+ }
1419
+ };
1420
+ }
1421
+ _parseSync(e) {
1422
+ const r = this._parse(e);
1423
+ if (re(r))
1424
+ throw new Error("Synchronous parse encountered promise.");
1425
+ return r;
1426
+ }
1427
+ _parseAsync(e) {
1428
+ const r = this._parse(e);
1429
+ return Promise.resolve(r);
1430
+ }
1431
+ parse(e, r) {
1432
+ const n = this.safeParse(e, r);
1433
+ if (n.success)
1434
+ return n.data;
1435
+ throw n.error;
1436
+ }
1437
+ safeParse(e, r) {
1438
+ const n = {
1439
+ common: {
1440
+ issues: [],
1441
+ async: (r == null ? void 0 : r.async) ?? false,
1442
+ contextualErrorMap: r == null ? void 0 : r.errorMap
1443
+ },
1444
+ path: (r == null ? void 0 : r.path) || [],
1445
+ schemaErrorMap: this._def.errorMap,
1446
+ parent: null,
1447
+ data: e,
1448
+ parsedType: S(e)
1449
+ }, s = this._parseSync({ data: e, path: n.path, parent: n });
1450
+ return Re(n, s);
1451
+ }
1452
+ "~validate"(e) {
1453
+ var n, s;
1454
+ const r = {
1455
+ common: {
1456
+ issues: [],
1457
+ async: !!this["~standard"].async
1458
+ },
1459
+ path: [],
1460
+ schemaErrorMap: this._def.errorMap,
1461
+ parent: null,
1462
+ data: e,
1463
+ parsedType: S(e)
1464
+ };
1465
+ if (!this["~standard"].async)
1466
+ try {
1467
+ const a = this._parseSync({ data: e, path: [], parent: r });
1468
+ return z(a) ? {
1469
+ value: a.value
1470
+ } : {
1471
+ issues: r.common.issues
1472
+ };
1473
+ } catch (a) {
1474
+ (s = (n = a == null ? void 0 : a.message) == null ? void 0 : n.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = true), r.common = {
1475
+ issues: [],
1476
+ async: true
1477
+ };
1478
+ }
1479
+ return this._parseAsync({ data: e, path: [], parent: r }).then((a) => z(a) ? {
1480
+ value: a.value
1481
+ } : {
1482
+ issues: r.common.issues
1483
+ });
1484
+ }
1485
+ async parseAsync(e, r) {
1486
+ const n = await this.safeParseAsync(e, r);
1487
+ if (n.success)
1488
+ return n.data;
1489
+ throw n.error;
1490
+ }
1491
+ async safeParseAsync(e, r) {
1492
+ const n = {
1493
+ common: {
1494
+ issues: [],
1495
+ contextualErrorMap: r == null ? void 0 : r.errorMap,
1496
+ async: true
1497
+ },
1498
+ path: (r == null ? void 0 : r.path) || [],
1499
+ schemaErrorMap: this._def.errorMap,
1500
+ parent: null,
1501
+ data: e,
1502
+ parsedType: S(e)
1503
+ }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (re(s) ? s : Promise.resolve(s));
1504
+ return Re(n, a);
1505
+ }
1506
+ refine(e, r) {
1507
+ const n = (s) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(s) : r;
1508
+ return this._refinement((s, a) => {
1509
+ const i = e(s), c = () => a.addIssue({
1510
+ code: o.custom,
1511
+ ...n(s)
1512
+ });
1513
+ return typeof Promise < "u" && i instanceof Promise ? i.then((h) => h ? true : (c(), false)) : i ? true : (c(), false);
1514
+ });
1515
+ }
1516
+ refinement(e, r) {
1517
+ return this._refinement((n, s) => e(n) ? true : (s.addIssue(typeof r == "function" ? r(n, s) : r), false));
1518
+ }
1519
+ _refinement(e) {
1520
+ return new $({
1521
+ schema: this,
1522
+ typeName: p.ZodEffects,
1523
+ effect: { type: "refinement", refinement: e }
1524
+ });
1525
+ }
1526
+ superRefine(e) {
1527
+ return this._refinement(e);
1528
+ }
1529
+ constructor(e) {
1530
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
1531
+ version: 1,
1532
+ vendor: "zod",
1533
+ validate: (r) => this["~validate"](r)
1534
+ };
1535
+ }
1536
+ optional() {
1537
+ return M.create(this, this._def);
1538
+ }
1539
+ nullable() {
1540
+ return C.create(this, this._def);
1541
+ }
1542
+ nullish() {
1543
+ return this.nullable().optional();
1544
+ }
1545
+ array() {
1546
+ return I.create(this);
1547
+ }
1548
+ promise() {
1549
+ return H.create(this, this._def);
1550
+ }
1551
+ or(e) {
1552
+ return ne.create([this, e], this._def);
1553
+ }
1554
+ and(e) {
1555
+ return se.create(this, e, this._def);
1556
+ }
1557
+ transform(e) {
1558
+ return new $({
1559
+ ...y(this._def),
1560
+ schema: this,
1561
+ typeName: p.ZodEffects,
1562
+ effect: { type: "transform", transform: e }
1563
+ });
1564
+ }
1565
+ default(e) {
1566
+ const r = typeof e == "function" ? e : () => e;
1567
+ return new ce({
1568
+ ...y(this._def),
1569
+ innerType: this,
1570
+ defaultValue: r,
1571
+ typeName: p.ZodDefault
1572
+ });
1573
+ }
1574
+ brand() {
1575
+ return new Ce({
1576
+ typeName: p.ZodBranded,
1577
+ type: this,
1578
+ ...y(this._def)
1579
+ });
1580
+ }
1581
+ catch(e) {
1582
+ const r = typeof e == "function" ? e : () => e;
1583
+ return new oe({
1584
+ ...y(this._def),
1585
+ innerType: this,
1586
+ catchValue: r,
1587
+ typeName: p.ZodCatch
1588
+ });
1589
+ }
1590
+ describe(e) {
1591
+ const r = this.constructor;
1592
+ return new r({
1593
+ ...this._def,
1594
+ description: e
1595
+ });
1596
+ }
1597
+ pipe(e) {
1598
+ return xe.create(this, e);
1599
+ }
1600
+ readonly() {
1601
+ return de.create(this);
1602
+ }
1603
+ isOptional() {
1604
+ return this.safeParse(void 0).success;
1605
+ }
1606
+ isNullable() {
1607
+ return this.safeParse(null).success;
1608
+ }
1609
+ };
1610
+ Be = /^c[^\s-]{8,}$/i;
1611
+ Ge = /^[0-9a-z]+$/;
1612
+ Ye = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1613
+ We = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
1614
+ qe = /^[a-z0-9_-]{21}$/i;
1615
+ Qe = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1616
+ Xe = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
1617
+ Ke = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1618
+ Je = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1619
+ He = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1620
+ et = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
1621
+ tt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
1622
+ rt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1623
+ nt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1624
+ st = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1625
+ Ue = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))";
1626
+ at = new RegExp(`^${Ue}$`);
1627
+ Z = class _Z extends g {
1628
+ _parse(e) {
1629
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== u.string) {
1630
+ const a = this._getOrReturnCtx(e);
1631
+ return d(a, {
1632
+ code: o.invalid_type,
1633
+ expected: u.string,
1634
+ received: a.parsedType
1635
+ }), _;
1636
+ }
1637
+ const n = new k();
1638
+ let s;
1639
+ for (const a of this._def.checks)
1640
+ if (a.kind === "min")
1641
+ e.data.length < a.value && (s = this._getOrReturnCtx(e, s), d(s, {
1642
+ code: o.too_small,
1643
+ minimum: a.value,
1644
+ type: "string",
1645
+ inclusive: true,
1646
+ exact: false,
1647
+ message: a.message
1648
+ }), n.dirty());
1649
+ else if (a.kind === "max")
1650
+ e.data.length > a.value && (s = this._getOrReturnCtx(e, s), d(s, {
1651
+ code: o.too_big,
1652
+ maximum: a.value,
1653
+ type: "string",
1654
+ inclusive: true,
1655
+ exact: false,
1656
+ message: a.message
1657
+ }), n.dirty());
1658
+ else if (a.kind === "length") {
1659
+ const i = e.data.length > a.value, c = e.data.length < a.value;
1660
+ (i || c) && (s = this._getOrReturnCtx(e, s), i ? d(s, {
1661
+ code: o.too_big,
1662
+ maximum: a.value,
1663
+ type: "string",
1664
+ inclusive: true,
1665
+ exact: true,
1666
+ message: a.message
1667
+ }) : c && d(s, {
1668
+ code: o.too_small,
1669
+ minimum: a.value,
1670
+ type: "string",
1671
+ inclusive: true,
1672
+ exact: true,
1673
+ message: a.message
1674
+ }), n.dirty());
1675
+ } else if (a.kind === "email")
1676
+ Ke.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1677
+ validation: "email",
1678
+ code: o.invalid_string,
1679
+ message: a.message
1680
+ }), n.dirty());
1681
+ else if (a.kind === "emoji")
1682
+ he || (he = new RegExp(Je, "u")), he.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1683
+ validation: "emoji",
1684
+ code: o.invalid_string,
1685
+ message: a.message
1686
+ }), n.dirty());
1687
+ else if (a.kind === "uuid")
1688
+ We.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1689
+ validation: "uuid",
1690
+ code: o.invalid_string,
1691
+ message: a.message
1692
+ }), n.dirty());
1693
+ else if (a.kind === "nanoid")
1694
+ qe.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1695
+ validation: "nanoid",
1696
+ code: o.invalid_string,
1697
+ message: a.message
1698
+ }), n.dirty());
1699
+ else if (a.kind === "cuid")
1700
+ Be.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1701
+ validation: "cuid",
1702
+ code: o.invalid_string,
1703
+ message: a.message
1704
+ }), n.dirty());
1705
+ else if (a.kind === "cuid2")
1706
+ Ge.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1707
+ validation: "cuid2",
1708
+ code: o.invalid_string,
1709
+ message: a.message
1710
+ }), n.dirty());
1711
+ else if (a.kind === "ulid")
1712
+ Ye.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1713
+ validation: "ulid",
1714
+ code: o.invalid_string,
1715
+ message: a.message
1716
+ }), n.dirty());
1717
+ else if (a.kind === "url")
1718
+ try {
1719
+ new URL(e.data);
1720
+ } catch {
1721
+ s = this._getOrReturnCtx(e, s), d(s, {
1722
+ validation: "url",
1723
+ code: o.invalid_string,
1724
+ message: a.message
1725
+ }), n.dirty();
1726
+ }
1727
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1728
+ validation: "regex",
1729
+ code: o.invalid_string,
1730
+ message: a.message
1731
+ }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), d(s, {
1732
+ code: o.invalid_string,
1733
+ validation: { includes: a.value, position: a.position },
1734
+ message: a.message
1735
+ }), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), d(s, {
1736
+ code: o.invalid_string,
1737
+ validation: { startsWith: a.value },
1738
+ message: a.message
1739
+ }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), d(s, {
1740
+ code: o.invalid_string,
1741
+ validation: { endsWith: a.value },
1742
+ message: a.message
1743
+ }), n.dirty()) : a.kind === "datetime" ? ct(a).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1744
+ code: o.invalid_string,
1745
+ validation: "datetime",
1746
+ message: a.message
1747
+ }), n.dirty()) : a.kind === "date" ? at.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1748
+ code: o.invalid_string,
1749
+ validation: "date",
1750
+ message: a.message
1751
+ }), n.dirty()) : a.kind === "time" ? it(a).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1752
+ code: o.invalid_string,
1753
+ validation: "time",
1754
+ message: a.message
1755
+ }), n.dirty()) : a.kind === "duration" ? Xe.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1756
+ validation: "duration",
1757
+ code: o.invalid_string,
1758
+ message: a.message
1759
+ }), n.dirty()) : a.kind === "ip" ? ot(e.data, a.version) || (s = this._getOrReturnCtx(e, s), d(s, {
1760
+ validation: "ip",
1761
+ code: o.invalid_string,
1762
+ message: a.message
1763
+ }), n.dirty()) : a.kind === "jwt" ? dt(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), d(s, {
1764
+ validation: "jwt",
1765
+ code: o.invalid_string,
1766
+ message: a.message
1767
+ }), n.dirty()) : a.kind === "cidr" ? ut(e.data, a.version) || (s = this._getOrReturnCtx(e, s), d(s, {
1768
+ validation: "cidr",
1769
+ code: o.invalid_string,
1770
+ message: a.message
1771
+ }), n.dirty()) : a.kind === "base64" ? nt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1772
+ validation: "base64",
1773
+ code: o.invalid_string,
1774
+ message: a.message
1775
+ }), n.dirty()) : a.kind === "base64url" ? st.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
1776
+ validation: "base64url",
1777
+ code: o.invalid_string,
1778
+ message: a.message
1779
+ }), n.dirty()) : E.assertNever(a);
1780
+ return { status: n.value, value: e.data };
1781
+ }
1782
+ _regex(e, r, n) {
1783
+ return this.refinement((s) => e.test(s), {
1784
+ validation: r,
1785
+ code: o.invalid_string,
1786
+ ...f.errToObj(n)
1787
+ });
1788
+ }
1789
+ _addCheck(e) {
1790
+ return new _Z({
1791
+ ...this._def,
1792
+ checks: [...this._def.checks, e]
1793
+ });
1794
+ }
1795
+ email(e) {
1796
+ return this._addCheck({ kind: "email", ...f.errToObj(e) });
1797
+ }
1798
+ url(e) {
1799
+ return this._addCheck({ kind: "url", ...f.errToObj(e) });
1800
+ }
1801
+ emoji(e) {
1802
+ return this._addCheck({ kind: "emoji", ...f.errToObj(e) });
1803
+ }
1804
+ uuid(e) {
1805
+ return this._addCheck({ kind: "uuid", ...f.errToObj(e) });
1806
+ }
1807
+ nanoid(e) {
1808
+ return this._addCheck({ kind: "nanoid", ...f.errToObj(e) });
1809
+ }
1810
+ cuid(e) {
1811
+ return this._addCheck({ kind: "cuid", ...f.errToObj(e) });
1812
+ }
1813
+ cuid2(e) {
1814
+ return this._addCheck({ kind: "cuid2", ...f.errToObj(e) });
1815
+ }
1816
+ ulid(e) {
1817
+ return this._addCheck({ kind: "ulid", ...f.errToObj(e) });
1818
+ }
1819
+ base64(e) {
1820
+ return this._addCheck({ kind: "base64", ...f.errToObj(e) });
1821
+ }
1822
+ base64url(e) {
1823
+ return this._addCheck({
1824
+ kind: "base64url",
1825
+ ...f.errToObj(e)
1826
+ });
1827
+ }
1828
+ jwt(e) {
1829
+ return this._addCheck({ kind: "jwt", ...f.errToObj(e) });
1830
+ }
1831
+ ip(e) {
1832
+ return this._addCheck({ kind: "ip", ...f.errToObj(e) });
1833
+ }
1834
+ cidr(e) {
1835
+ return this._addCheck({ kind: "cidr", ...f.errToObj(e) });
1836
+ }
1837
+ datetime(e) {
1838
+ return typeof e == "string" ? this._addCheck({
1839
+ kind: "datetime",
1840
+ precision: null,
1841
+ offset: false,
1842
+ local: false,
1843
+ message: e
1844
+ }) : this._addCheck({
1845
+ kind: "datetime",
1846
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1847
+ offset: (e == null ? void 0 : e.offset) ?? false,
1848
+ local: (e == null ? void 0 : e.local) ?? false,
1849
+ ...f.errToObj(e == null ? void 0 : e.message)
1850
+ });
1851
+ }
1852
+ date(e) {
1853
+ return this._addCheck({ kind: "date", message: e });
1854
+ }
1855
+ time(e) {
1856
+ return typeof e == "string" ? this._addCheck({
1857
+ kind: "time",
1858
+ precision: null,
1859
+ message: e
1860
+ }) : this._addCheck({
1861
+ kind: "time",
1862
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1863
+ ...f.errToObj(e == null ? void 0 : e.message)
1864
+ });
1865
+ }
1866
+ duration(e) {
1867
+ return this._addCheck({ kind: "duration", ...f.errToObj(e) });
1868
+ }
1869
+ regex(e, r) {
1870
+ return this._addCheck({
1871
+ kind: "regex",
1872
+ regex: e,
1873
+ ...f.errToObj(r)
1874
+ });
1875
+ }
1876
+ includes(e, r) {
1877
+ return this._addCheck({
1878
+ kind: "includes",
1879
+ value: e,
1880
+ position: r == null ? void 0 : r.position,
1881
+ ...f.errToObj(r == null ? void 0 : r.message)
1882
+ });
1883
+ }
1884
+ startsWith(e, r) {
1885
+ return this._addCheck({
1886
+ kind: "startsWith",
1887
+ value: e,
1888
+ ...f.errToObj(r)
1889
+ });
1890
+ }
1891
+ endsWith(e, r) {
1892
+ return this._addCheck({
1893
+ kind: "endsWith",
1894
+ value: e,
1895
+ ...f.errToObj(r)
1896
+ });
1897
+ }
1898
+ min(e, r) {
1899
+ return this._addCheck({
1900
+ kind: "min",
1901
+ value: e,
1902
+ ...f.errToObj(r)
1903
+ });
1904
+ }
1905
+ max(e, r) {
1906
+ return this._addCheck({
1907
+ kind: "max",
1908
+ value: e,
1909
+ ...f.errToObj(r)
1910
+ });
1911
+ }
1912
+ length(e, r) {
1913
+ return this._addCheck({
1914
+ kind: "length",
1915
+ value: e,
1916
+ ...f.errToObj(r)
1917
+ });
1918
+ }
1919
+ /**
1920
+ * Equivalent to `.min(1)`
1921
+ */
1922
+ nonempty(e) {
1923
+ return this.min(1, f.errToObj(e));
1924
+ }
1925
+ trim() {
1926
+ return new _Z({
1927
+ ...this._def,
1928
+ checks: [...this._def.checks, { kind: "trim" }]
1929
+ });
1930
+ }
1931
+ toLowerCase() {
1932
+ return new _Z({
1933
+ ...this._def,
1934
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1935
+ });
1936
+ }
1937
+ toUpperCase() {
1938
+ return new _Z({
1939
+ ...this._def,
1940
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1941
+ });
1942
+ }
1943
+ get isDatetime() {
1944
+ return !!this._def.checks.find((e) => e.kind === "datetime");
1945
+ }
1946
+ get isDate() {
1947
+ return !!this._def.checks.find((e) => e.kind === "date");
1948
+ }
1949
+ get isTime() {
1950
+ return !!this._def.checks.find((e) => e.kind === "time");
1951
+ }
1952
+ get isDuration() {
1953
+ return !!this._def.checks.find((e) => e.kind === "duration");
1954
+ }
1955
+ get isEmail() {
1956
+ return !!this._def.checks.find((e) => e.kind === "email");
1957
+ }
1958
+ get isURL() {
1959
+ return !!this._def.checks.find((e) => e.kind === "url");
1960
+ }
1961
+ get isEmoji() {
1962
+ return !!this._def.checks.find((e) => e.kind === "emoji");
1963
+ }
1964
+ get isUUID() {
1965
+ return !!this._def.checks.find((e) => e.kind === "uuid");
1966
+ }
1967
+ get isNANOID() {
1968
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
1969
+ }
1970
+ get isCUID() {
1971
+ return !!this._def.checks.find((e) => e.kind === "cuid");
1972
+ }
1973
+ get isCUID2() {
1974
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
1975
+ }
1976
+ get isULID() {
1977
+ return !!this._def.checks.find((e) => e.kind === "ulid");
1978
+ }
1979
+ get isIP() {
1980
+ return !!this._def.checks.find((e) => e.kind === "ip");
1981
+ }
1982
+ get isCIDR() {
1983
+ return !!this._def.checks.find((e) => e.kind === "cidr");
1984
+ }
1985
+ get isBase64() {
1986
+ return !!this._def.checks.find((e) => e.kind === "base64");
1987
+ }
1988
+ get isBase64url() {
1989
+ return !!this._def.checks.find((e) => e.kind === "base64url");
1990
+ }
1991
+ get minLength() {
1992
+ let e = null;
1993
+ for (const r of this._def.checks)
1994
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
1995
+ return e;
1996
+ }
1997
+ get maxLength() {
1998
+ let e = null;
1999
+ for (const r of this._def.checks)
2000
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
2001
+ return e;
2002
+ }
2003
+ };
2004
+ Z.create = (t) => new Z({
2005
+ checks: [],
2006
+ typeName: p.ZodString,
2007
+ coerce: (t == null ? void 0 : t.coerce) ?? false,
2008
+ ...y(t)
2009
+ });
2010
+ B = class _B extends g {
2011
+ constructor() {
2012
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
2013
+ }
2014
+ _parse(e) {
2015
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== u.number) {
2016
+ const a = this._getOrReturnCtx(e);
2017
+ return d(a, {
2018
+ code: o.invalid_type,
2019
+ expected: u.number,
2020
+ received: a.parsedType
2021
+ }), _;
2022
+ }
2023
+ let n;
2024
+ const s = new k();
2025
+ for (const a of this._def.checks)
2026
+ a.kind === "int" ? E.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), d(n, {
2027
+ code: o.invalid_type,
2028
+ expected: "integer",
2029
+ received: "float",
2030
+ message: a.message
2031
+ }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
2032
+ code: o.too_small,
2033
+ minimum: a.value,
2034
+ type: "number",
2035
+ inclusive: a.inclusive,
2036
+ exact: false,
2037
+ message: a.message
2038
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
2039
+ code: o.too_big,
2040
+ maximum: a.value,
2041
+ type: "number",
2042
+ inclusive: a.inclusive,
2043
+ exact: false,
2044
+ message: a.message
2045
+ }), s.dirty()) : a.kind === "multipleOf" ? lt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), d(n, {
2046
+ code: o.not_multiple_of,
2047
+ multipleOf: a.value,
2048
+ message: a.message
2049
+ }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), d(n, {
2050
+ code: o.not_finite,
2051
+ message: a.message
2052
+ }), s.dirty()) : E.assertNever(a);
2053
+ return { status: s.value, value: e.data };
2054
+ }
2055
+ gte(e, r) {
2056
+ return this.setLimit("min", e, true, f.toString(r));
2057
+ }
2058
+ gt(e, r) {
2059
+ return this.setLimit("min", e, false, f.toString(r));
2060
+ }
2061
+ lte(e, r) {
2062
+ return this.setLimit("max", e, true, f.toString(r));
2063
+ }
2064
+ lt(e, r) {
2065
+ return this.setLimit("max", e, false, f.toString(r));
2066
+ }
2067
+ setLimit(e, r, n, s) {
2068
+ return new _B({
2069
+ ...this._def,
2070
+ checks: [
2071
+ ...this._def.checks,
2072
+ {
2073
+ kind: e,
2074
+ value: r,
2075
+ inclusive: n,
2076
+ message: f.toString(s)
2077
+ }
2078
+ ]
2079
+ });
2080
+ }
2081
+ _addCheck(e) {
2082
+ return new _B({
2083
+ ...this._def,
2084
+ checks: [...this._def.checks, e]
2085
+ });
2086
+ }
2087
+ int(e) {
2088
+ return this._addCheck({
2089
+ kind: "int",
2090
+ message: f.toString(e)
2091
+ });
2092
+ }
2093
+ positive(e) {
2094
+ return this._addCheck({
2095
+ kind: "min",
2096
+ value: 0,
2097
+ inclusive: false,
2098
+ message: f.toString(e)
2099
+ });
2100
+ }
2101
+ negative(e) {
2102
+ return this._addCheck({
2103
+ kind: "max",
2104
+ value: 0,
2105
+ inclusive: false,
2106
+ message: f.toString(e)
2107
+ });
2108
+ }
2109
+ nonpositive(e) {
2110
+ return this._addCheck({
2111
+ kind: "max",
2112
+ value: 0,
2113
+ inclusive: true,
2114
+ message: f.toString(e)
2115
+ });
2116
+ }
2117
+ nonnegative(e) {
2118
+ return this._addCheck({
2119
+ kind: "min",
2120
+ value: 0,
2121
+ inclusive: true,
2122
+ message: f.toString(e)
2123
+ });
2124
+ }
2125
+ multipleOf(e, r) {
2126
+ return this._addCheck({
2127
+ kind: "multipleOf",
2128
+ value: e,
2129
+ message: f.toString(r)
2130
+ });
2131
+ }
2132
+ finite(e) {
2133
+ return this._addCheck({
2134
+ kind: "finite",
2135
+ message: f.toString(e)
2136
+ });
2137
+ }
2138
+ safe(e) {
2139
+ return this._addCheck({
2140
+ kind: "min",
2141
+ inclusive: true,
2142
+ value: Number.MIN_SAFE_INTEGER,
2143
+ message: f.toString(e)
2144
+ })._addCheck({
2145
+ kind: "max",
2146
+ inclusive: true,
2147
+ value: Number.MAX_SAFE_INTEGER,
2148
+ message: f.toString(e)
2149
+ });
2150
+ }
2151
+ get minValue() {
2152
+ let e = null;
2153
+ for (const r of this._def.checks)
2154
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
2155
+ return e;
2156
+ }
2157
+ get maxValue() {
2158
+ let e = null;
2159
+ for (const r of this._def.checks)
2160
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
2161
+ return e;
2162
+ }
2163
+ get isInt() {
2164
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && E.isInteger(e.value));
2165
+ }
2166
+ get isFinite() {
2167
+ let e = null, r = null;
2168
+ for (const n of this._def.checks) {
2169
+ if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
2170
+ return true;
2171
+ n.kind === "min" ? (r === null || n.value > r) && (r = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
2172
+ }
2173
+ return Number.isFinite(r) && Number.isFinite(e);
2174
+ }
2175
+ };
2176
+ B.create = (t) => new B({
2177
+ checks: [],
2178
+ typeName: p.ZodNumber,
2179
+ coerce: (t == null ? void 0 : t.coerce) || false,
2180
+ ...y(t)
2181
+ });
2182
+ X = class _X extends g {
2183
+ constructor() {
2184
+ super(...arguments), this.min = this.gte, this.max = this.lte;
2185
+ }
2186
+ _parse(e) {
2187
+ if (this._def.coerce)
2188
+ try {
2189
+ e.data = BigInt(e.data);
2190
+ } catch {
2191
+ return this._getInvalidInput(e);
2192
+ }
2193
+ if (this._getType(e) !== u.bigint)
2194
+ return this._getInvalidInput(e);
2195
+ let n;
2196
+ const s = new k();
2197
+ for (const a of this._def.checks)
2198
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
2199
+ code: o.too_small,
2200
+ type: "bigint",
2201
+ minimum: a.value,
2202
+ inclusive: a.inclusive,
2203
+ message: a.message
2204
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
2205
+ code: o.too_big,
2206
+ type: "bigint",
2207
+ maximum: a.value,
2208
+ inclusive: a.inclusive,
2209
+ message: a.message
2210
+ }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), d(n, {
2211
+ code: o.not_multiple_of,
2212
+ multipleOf: a.value,
2213
+ message: a.message
2214
+ }), s.dirty()) : E.assertNever(a);
2215
+ return { status: s.value, value: e.data };
2216
+ }
2217
+ _getInvalidInput(e) {
2218
+ const r = this._getOrReturnCtx(e);
2219
+ return d(r, {
2220
+ code: o.invalid_type,
2221
+ expected: u.bigint,
2222
+ received: r.parsedType
2223
+ }), _;
2224
+ }
2225
+ gte(e, r) {
2226
+ return this.setLimit("min", e, true, f.toString(r));
2227
+ }
2228
+ gt(e, r) {
2229
+ return this.setLimit("min", e, false, f.toString(r));
2230
+ }
2231
+ lte(e, r) {
2232
+ return this.setLimit("max", e, true, f.toString(r));
2233
+ }
2234
+ lt(e, r) {
2235
+ return this.setLimit("max", e, false, f.toString(r));
2236
+ }
2237
+ setLimit(e, r, n, s) {
2238
+ return new _X({
2239
+ ...this._def,
2240
+ checks: [
2241
+ ...this._def.checks,
2242
+ {
2243
+ kind: e,
2244
+ value: r,
2245
+ inclusive: n,
2246
+ message: f.toString(s)
2247
+ }
2248
+ ]
2249
+ });
2250
+ }
2251
+ _addCheck(e) {
2252
+ return new _X({
2253
+ ...this._def,
2254
+ checks: [...this._def.checks, e]
2255
+ });
2256
+ }
2257
+ positive(e) {
2258
+ return this._addCheck({
2259
+ kind: "min",
2260
+ value: BigInt(0),
2261
+ inclusive: false,
2262
+ message: f.toString(e)
2263
+ });
2264
+ }
2265
+ negative(e) {
2266
+ return this._addCheck({
2267
+ kind: "max",
2268
+ value: BigInt(0),
2269
+ inclusive: false,
2270
+ message: f.toString(e)
2271
+ });
2272
+ }
2273
+ nonpositive(e) {
2274
+ return this._addCheck({
2275
+ kind: "max",
2276
+ value: BigInt(0),
2277
+ inclusive: true,
2278
+ message: f.toString(e)
2279
+ });
2280
+ }
2281
+ nonnegative(e) {
2282
+ return this._addCheck({
2283
+ kind: "min",
2284
+ value: BigInt(0),
2285
+ inclusive: true,
2286
+ message: f.toString(e)
2287
+ });
2288
+ }
2289
+ multipleOf(e, r) {
2290
+ return this._addCheck({
2291
+ kind: "multipleOf",
2292
+ value: e,
2293
+ message: f.toString(r)
2294
+ });
2295
+ }
2296
+ get minValue() {
2297
+ let e = null;
2298
+ for (const r of this._def.checks)
2299
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
2300
+ return e;
2301
+ }
2302
+ get maxValue() {
2303
+ let e = null;
2304
+ for (const r of this._def.checks)
2305
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
2306
+ return e;
2307
+ }
2308
+ };
2309
+ X.create = (t) => new X({
2310
+ checks: [],
2311
+ typeName: p.ZodBigInt,
2312
+ coerce: (t == null ? void 0 : t.coerce) ?? false,
2313
+ ...y(t)
2314
+ });
2315
+ _e = class extends g {
2316
+ _parse(e) {
2317
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== u.boolean) {
2318
+ const n = this._getOrReturnCtx(e);
2319
+ return d(n, {
2320
+ code: o.invalid_type,
2321
+ expected: u.boolean,
2322
+ received: n.parsedType
2323
+ }), _;
2324
+ }
2325
+ return b(e.data);
2326
+ }
2327
+ };
2328
+ _e.create = (t) => new _e({
2329
+ typeName: p.ZodBoolean,
2330
+ coerce: (t == null ? void 0 : t.coerce) || false,
2331
+ ...y(t)
2332
+ });
2333
+ K = class _K extends g {
2334
+ _parse(e) {
2335
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== u.date) {
2336
+ const a = this._getOrReturnCtx(e);
2337
+ return d(a, {
2338
+ code: o.invalid_type,
2339
+ expected: u.date,
2340
+ received: a.parsedType
2341
+ }), _;
2342
+ }
2343
+ if (Number.isNaN(e.data.getTime())) {
2344
+ const a = this._getOrReturnCtx(e);
2345
+ return d(a, {
2346
+ code: o.invalid_date
2347
+ }), _;
2348
+ }
2349
+ const n = new k();
2350
+ let s;
2351
+ for (const a of this._def.checks)
2352
+ a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), d(s, {
2353
+ code: o.too_small,
2354
+ message: a.message,
2355
+ inclusive: true,
2356
+ exact: false,
2357
+ minimum: a.value,
2358
+ type: "date"
2359
+ }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), d(s, {
2360
+ code: o.too_big,
2361
+ message: a.message,
2362
+ inclusive: true,
2363
+ exact: false,
2364
+ maximum: a.value,
2365
+ type: "date"
2366
+ }), n.dirty()) : E.assertNever(a);
2367
+ return {
2368
+ status: n.value,
2369
+ value: new Date(e.data.getTime())
2370
+ };
2371
+ }
2372
+ _addCheck(e) {
2373
+ return new _K({
2374
+ ...this._def,
2375
+ checks: [...this._def.checks, e]
2376
+ });
2377
+ }
2378
+ min(e, r) {
2379
+ return this._addCheck({
2380
+ kind: "min",
2381
+ value: e.getTime(),
2382
+ message: f.toString(r)
2383
+ });
2384
+ }
2385
+ max(e, r) {
2386
+ return this._addCheck({
2387
+ kind: "max",
2388
+ value: e.getTime(),
2389
+ message: f.toString(r)
2390
+ });
2391
+ }
2392
+ get minDate() {
2393
+ let e = null;
2394
+ for (const r of this._def.checks)
2395
+ r.kind === "min" && (e === null || r.value > e) && (e = r.value);
2396
+ return e != null ? new Date(e) : null;
2397
+ }
2398
+ get maxDate() {
2399
+ let e = null;
2400
+ for (const r of this._def.checks)
2401
+ r.kind === "max" && (e === null || r.value < e) && (e = r.value);
2402
+ return e != null ? new Date(e) : null;
2403
+ }
2404
+ };
2405
+ K.create = (t) => new K({
2406
+ checks: [],
2407
+ coerce: (t == null ? void 0 : t.coerce) || false,
2408
+ typeName: p.ZodDate,
2409
+ ...y(t)
2410
+ });
2411
+ Ie = class extends g {
2412
+ _parse(e) {
2413
+ if (this._getType(e) !== u.symbol) {
2414
+ const n = this._getOrReturnCtx(e);
2415
+ return d(n, {
2416
+ code: o.invalid_type,
2417
+ expected: u.symbol,
2418
+ received: n.parsedType
2419
+ }), _;
2420
+ }
2421
+ return b(e.data);
2422
+ }
2423
+ };
2424
+ Ie.create = (t) => new Ie({
2425
+ typeName: p.ZodSymbol,
2426
+ ...y(t)
2427
+ });
2428
+ pe = class extends g {
2429
+ _parse(e) {
2430
+ if (this._getType(e) !== u.undefined) {
2431
+ const n = this._getOrReturnCtx(e);
2432
+ return d(n, {
2433
+ code: o.invalid_type,
2434
+ expected: u.undefined,
2435
+ received: n.parsedType
2436
+ }), _;
2437
+ }
2438
+ return b(e.data);
2439
+ }
2440
+ };
2441
+ pe.create = (t) => new pe({
2442
+ typeName: p.ZodUndefined,
2443
+ ...y(t)
2444
+ });
2445
+ ye = class extends g {
2446
+ _parse(e) {
2447
+ if (this._getType(e) !== u.null) {
2448
+ const n = this._getOrReturnCtx(e);
2449
+ return d(n, {
2450
+ code: o.invalid_type,
2451
+ expected: u.null,
2452
+ received: n.parsedType
2453
+ }), _;
2454
+ }
2455
+ return b(e.data);
2456
+ }
2457
+ };
2458
+ ye.create = (t) => new ye({
2459
+ typeName: p.ZodNull,
2460
+ ...y(t)
2461
+ });
2462
+ we = class extends g {
2463
+ constructor() {
2464
+ super(...arguments), this._any = true;
2465
+ }
2466
+ _parse(e) {
2467
+ return b(e.data);
2468
+ }
2469
+ };
2470
+ we.create = (t) => new we({
2471
+ typeName: p.ZodAny,
2472
+ ...y(t)
2473
+ });
2474
+ F = class extends g {
2475
+ constructor() {
2476
+ super(...arguments), this._unknown = true;
2477
+ }
2478
+ _parse(e) {
2479
+ return b(e.data);
2480
+ }
2481
+ };
2482
+ F.create = (t) => new F({
2483
+ typeName: p.ZodUnknown,
2484
+ ...y(t)
2485
+ });
2486
+ U = class extends g {
2487
+ _parse(e) {
2488
+ const r = this._getOrReturnCtx(e);
2489
+ return d(r, {
2490
+ code: o.invalid_type,
2491
+ expected: u.never,
2492
+ received: r.parsedType
2493
+ }), _;
2494
+ }
2495
+ };
2496
+ U.create = (t) => new U({
2497
+ typeName: p.ZodNever,
2498
+ ...y(t)
2499
+ });
2500
+ De = class extends g {
2501
+ _parse(e) {
2502
+ if (this._getType(e) !== u.undefined) {
2503
+ const n = this._getOrReturnCtx(e);
2504
+ return d(n, {
2505
+ code: o.invalid_type,
2506
+ expected: u.void,
2507
+ received: n.parsedType
2508
+ }), _;
2509
+ }
2510
+ return b(e.data);
2511
+ }
2512
+ };
2513
+ De.create = (t) => new De({
2514
+ typeName: p.ZodVoid,
2515
+ ...y(t)
2516
+ });
2517
+ I = class _I extends g {
2518
+ _parse(e) {
2519
+ const { ctx: r, status: n } = this._processInputParams(e), s = this._def;
2520
+ if (r.parsedType !== u.array)
2521
+ return d(r, {
2522
+ code: o.invalid_type,
2523
+ expected: u.array,
2524
+ received: r.parsedType
2525
+ }), _;
2526
+ if (s.exactLength !== null) {
2527
+ const i = r.data.length > s.exactLength.value, c = r.data.length < s.exactLength.value;
2528
+ (i || c) && (d(r, {
2529
+ code: i ? o.too_big : o.too_small,
2530
+ minimum: c ? s.exactLength.value : void 0,
2531
+ maximum: i ? s.exactLength.value : void 0,
2532
+ type: "array",
2533
+ inclusive: true,
2534
+ exact: true,
2535
+ message: s.exactLength.message
2536
+ }), n.dirty());
2537
+ }
2538
+ if (s.minLength !== null && r.data.length < s.minLength.value && (d(r, {
2539
+ code: o.too_small,
2540
+ minimum: s.minLength.value,
2541
+ type: "array",
2542
+ inclusive: true,
2543
+ exact: false,
2544
+ message: s.minLength.message
2545
+ }), n.dirty()), s.maxLength !== null && r.data.length > s.maxLength.value && (d(r, {
2546
+ code: o.too_big,
2547
+ maximum: s.maxLength.value,
2548
+ type: "array",
2549
+ inclusive: true,
2550
+ exact: false,
2551
+ message: s.maxLength.message
2552
+ }), n.dirty()), r.common.async)
2553
+ return Promise.all([...r.data].map((i, c) => s.type._parseAsync(new w(r, i, r.path, c)))).then((i) => k.mergeArray(n, i));
2554
+ const a = [...r.data].map((i, c) => s.type._parseSync(new w(r, i, r.path, c)));
2555
+ return k.mergeArray(n, a);
2556
+ }
2557
+ get element() {
2558
+ return this._def.type;
2559
+ }
2560
+ min(e, r) {
2561
+ return new _I({
2562
+ ...this._def,
2563
+ minLength: { value: e, message: f.toString(r) }
2564
+ });
2565
+ }
2566
+ max(e, r) {
2567
+ return new _I({
2568
+ ...this._def,
2569
+ maxLength: { value: e, message: f.toString(r) }
2570
+ });
2571
+ }
2572
+ length(e, r) {
2573
+ return new _I({
2574
+ ...this._def,
2575
+ exactLength: { value: e, message: f.toString(r) }
2576
+ });
2577
+ }
2578
+ nonempty(e) {
2579
+ return this.min(1, e);
2580
+ }
2581
+ };
2582
+ I.create = (t, e) => new I({
2583
+ type: t,
2584
+ minLength: null,
2585
+ maxLength: null,
2586
+ exactLength: null,
2587
+ typeName: p.ZodArray,
2588
+ ...y(e)
2589
+ });
2590
+ x = class _x extends g {
2591
+ constructor() {
2592
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
2593
+ }
2594
+ _getCached() {
2595
+ if (this._cached !== null)
2596
+ return this._cached;
2597
+ const e = this._def.shape(), r = E.objectKeys(e);
2598
+ return this._cached = { shape: e, keys: r }, this._cached;
2599
+ }
2600
+ _parse(e) {
2601
+ if (this._getType(e) !== u.object) {
2602
+ const l = this._getOrReturnCtx(e);
2603
+ return d(l, {
2604
+ code: o.invalid_type,
2605
+ expected: u.object,
2606
+ received: l.parsedType
2607
+ }), _;
2608
+ }
2609
+ const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), c = [];
2610
+ if (!(this._def.catchall instanceof U && this._def.unknownKeys === "strip"))
2611
+ for (const l in s.data)
2612
+ i.includes(l) || c.push(l);
2613
+ const h = [];
2614
+ for (const l of i) {
2615
+ const v = a[l], N = s.data[l];
2616
+ h.push({
2617
+ key: { status: "valid", value: l },
2618
+ value: v._parse(new w(s, N, s.path, l)),
2619
+ alwaysSet: l in s.data
2620
+ });
2621
+ }
2622
+ if (this._def.catchall instanceof U) {
2623
+ const l = this._def.unknownKeys;
2624
+ if (l === "passthrough")
2625
+ for (const v of c)
2626
+ h.push({
2627
+ key: { status: "valid", value: v },
2628
+ value: { status: "valid", value: s.data[v] }
2629
+ });
2630
+ else if (l === "strict")
2631
+ c.length > 0 && (d(s, {
2632
+ code: o.unrecognized_keys,
2633
+ keys: c
2634
+ }), n.dirty());
2635
+ else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2636
+ } else {
2637
+ const l = this._def.catchall;
2638
+ for (const v of c) {
2639
+ const N = s.data[v];
2640
+ h.push({
2641
+ key: { status: "valid", value: v },
2642
+ value: l._parse(
2643
+ new w(s, N, s.path, v)
2644
+ //, ctx.child(key), value, getParsedType(value)
2645
+ ),
2646
+ alwaysSet: v in s.data
2647
+ });
2648
+ }
2649
+ }
2650
+ return s.common.async ? Promise.resolve().then(async () => {
2651
+ const l = [];
2652
+ for (const v of h) {
2653
+ const N = await v.key, Oe = await v.value;
2654
+ l.push({
2655
+ key: N,
2656
+ value: Oe,
2657
+ alwaysSet: v.alwaysSet
2658
+ });
2659
+ }
2660
+ return l;
2661
+ }).then((l) => k.mergeObjectSync(n, l)) : k.mergeObjectSync(n, h);
2662
+ }
2663
+ get shape() {
2664
+ return this._def.shape();
2665
+ }
2666
+ strict(e) {
2667
+ return f.errToObj, new _x({
2668
+ ...this._def,
2669
+ unknownKeys: "strict",
2670
+ ...e !== void 0 ? {
2671
+ errorMap: (r, n) => {
2672
+ var a, i;
2673
+ const s = ((i = (a = this._def).errorMap) == null ? void 0 : i.call(a, r, n).message) ?? n.defaultError;
2674
+ return r.code === "unrecognized_keys" ? {
2675
+ message: f.errToObj(e).message ?? s
2676
+ } : {
2677
+ message: s
2678
+ };
2679
+ }
2680
+ } : {}
2681
+ });
2682
+ }
2683
+ strip() {
2684
+ return new _x({
2685
+ ...this._def,
2686
+ unknownKeys: "strip"
2687
+ });
2688
+ }
2689
+ passthrough() {
2690
+ return new _x({
2691
+ ...this._def,
2692
+ unknownKeys: "passthrough"
2693
+ });
2694
+ }
2695
+ // const AugmentFactory =
2696
+ // <Def extends ZodObjectDef>(def: Def) =>
2697
+ // <Augmentation extends ZodRawShape>(
2698
+ // augmentation: Augmentation
2699
+ // ): ZodObject<
2700
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2701
+ // Def["unknownKeys"],
2702
+ // Def["catchall"]
2703
+ // > => {
2704
+ // return new ZodObject({
2705
+ // ...def,
2706
+ // shape: () => ({
2707
+ // ...def.shape(),
2708
+ // ...augmentation,
2709
+ // }),
2710
+ // }) as any;
2711
+ // };
2712
+ extend(e) {
2713
+ return new _x({
2714
+ ...this._def,
2715
+ shape: () => ({
2716
+ ...this._def.shape(),
2717
+ ...e
2718
+ })
2719
+ });
2720
+ }
2721
+ /**
2722
+ * Prior to zod@1.0.12 there was a bug in the
2723
+ * inferred type of merged objects. Please
2724
+ * upgrade if you are experiencing issues.
2725
+ */
2726
+ merge(e) {
2727
+ return new _x({
2728
+ unknownKeys: e._def.unknownKeys,
2729
+ catchall: e._def.catchall,
2730
+ shape: () => ({
2731
+ ...this._def.shape(),
2732
+ ...e._def.shape()
2733
+ }),
2734
+ typeName: p.ZodObject
2735
+ });
2736
+ }
2737
+ // merge<
2738
+ // Incoming extends AnyZodObject,
2739
+ // Augmentation extends Incoming["shape"],
2740
+ // NewOutput extends {
2741
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2742
+ // ? Augmentation[k]["_output"]
2743
+ // : k extends keyof Output
2744
+ // ? Output[k]
2745
+ // : never;
2746
+ // },
2747
+ // NewInput extends {
2748
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2749
+ // ? Augmentation[k]["_input"]
2750
+ // : k extends keyof Input
2751
+ // ? Input[k]
2752
+ // : never;
2753
+ // }
2754
+ // >(
2755
+ // merging: Incoming
2756
+ // ): ZodObject<
2757
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2758
+ // Incoming["_def"]["unknownKeys"],
2759
+ // Incoming["_def"]["catchall"],
2760
+ // NewOutput,
2761
+ // NewInput
2762
+ // > {
2763
+ // const merged: any = new ZodObject({
2764
+ // unknownKeys: merging._def.unknownKeys,
2765
+ // catchall: merging._def.catchall,
2766
+ // shape: () =>
2767
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2768
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2769
+ // }) as any;
2770
+ // return merged;
2771
+ // }
2772
+ setKey(e, r) {
2773
+ return this.augment({ [e]: r });
2774
+ }
2775
+ // merge<Incoming extends AnyZodObject>(
2776
+ // merging: Incoming
2777
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2778
+ // ZodObject<
2779
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2780
+ // Incoming["_def"]["unknownKeys"],
2781
+ // Incoming["_def"]["catchall"]
2782
+ // > {
2783
+ // // const mergedShape = objectUtil.mergeShapes(
2784
+ // // this._def.shape(),
2785
+ // // merging._def.shape()
2786
+ // // );
2787
+ // const merged: any = new ZodObject({
2788
+ // unknownKeys: merging._def.unknownKeys,
2789
+ // catchall: merging._def.catchall,
2790
+ // shape: () =>
2791
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2792
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2793
+ // }) as any;
2794
+ // return merged;
2795
+ // }
2796
+ catchall(e) {
2797
+ return new _x({
2798
+ ...this._def,
2799
+ catchall: e
2800
+ });
2801
+ }
2802
+ pick(e) {
2803
+ const r = {};
2804
+ for (const n of E.objectKeys(e))
2805
+ e[n] && this.shape[n] && (r[n] = this.shape[n]);
2806
+ return new _x({
2807
+ ...this._def,
2808
+ shape: () => r
2809
+ });
2810
+ }
2811
+ omit(e) {
2812
+ const r = {};
2813
+ for (const n of E.objectKeys(this.shape))
2814
+ e[n] || (r[n] = this.shape[n]);
2815
+ return new _x({
2816
+ ...this._def,
2817
+ shape: () => r
2818
+ });
2819
+ }
2820
+ /**
2821
+ * @deprecated
2822
+ */
2823
+ deepPartial() {
2824
+ return V(this);
2825
+ }
2826
+ partial(e) {
2827
+ const r = {};
2828
+ for (const n of E.objectKeys(this.shape)) {
2829
+ const s = this.shape[n];
2830
+ e && !e[n] ? r[n] = s : r[n] = s.optional();
2831
+ }
2832
+ return new _x({
2833
+ ...this._def,
2834
+ shape: () => r
2835
+ });
2836
+ }
2837
+ required(e) {
2838
+ const r = {};
2839
+ for (const n of E.objectKeys(this.shape))
2840
+ if (e && !e[n])
2841
+ r[n] = this.shape[n];
2842
+ else {
2843
+ let a = this.shape[n];
2844
+ for (; a instanceof M; )
2845
+ a = a._def.innerType;
2846
+ r[n] = a;
2847
+ }
2848
+ return new _x({
2849
+ ...this._def,
2850
+ shape: () => r
2851
+ });
2852
+ }
2853
+ keyof() {
2854
+ return $e(E.objectKeys(this.shape));
2855
+ }
2856
+ };
2857
+ x.create = (t, e) => new x({
2858
+ shape: () => t,
2859
+ unknownKeys: "strip",
2860
+ catchall: U.create(),
2861
+ typeName: p.ZodObject,
2862
+ ...y(e)
2863
+ });
2864
+ x.strictCreate = (t, e) => new x({
2865
+ shape: () => t,
2866
+ unknownKeys: "strict",
2867
+ catchall: U.create(),
2868
+ typeName: p.ZodObject,
2869
+ ...y(e)
2870
+ });
2871
+ x.lazycreate = (t, e) => new x({
2872
+ shape: t,
2873
+ unknownKeys: "strip",
2874
+ catchall: U.create(),
2875
+ typeName: p.ZodObject,
2876
+ ...y(e)
2877
+ });
2878
+ ne = class extends g {
2879
+ _parse(e) {
2880
+ const { ctx: r } = this._processInputParams(e), n = this._def.options;
2881
+ function s(a) {
2882
+ for (const c of a)
2883
+ if (c.result.status === "valid")
2884
+ return c.result;
2885
+ for (const c of a)
2886
+ if (c.result.status === "dirty")
2887
+ return r.common.issues.push(...c.ctx.common.issues), c.result;
2888
+ const i = a.map((c) => new A(c.ctx.common.issues));
2889
+ return d(r, {
2890
+ code: o.invalid_union,
2891
+ unionErrors: i
2892
+ }), _;
2893
+ }
2894
+ if (r.common.async)
2895
+ return Promise.all(n.map(async (a) => {
2896
+ const i = {
2897
+ ...r,
2898
+ common: {
2899
+ ...r.common,
2900
+ issues: []
2901
+ },
2902
+ parent: null
2903
+ };
2904
+ return {
2905
+ result: await a._parseAsync({
2906
+ data: r.data,
2907
+ path: r.path,
2908
+ parent: i
2909
+ }),
2910
+ ctx: i
2911
+ };
2912
+ })).then(s);
2913
+ {
2914
+ let a;
2915
+ const i = [];
2916
+ for (const h of n) {
2917
+ const l = {
2918
+ ...r,
2919
+ common: {
2920
+ ...r.common,
2921
+ issues: []
2922
+ },
2923
+ parent: null
2924
+ }, v = h._parseSync({
2925
+ data: r.data,
2926
+ path: r.path,
2927
+ parent: l
2928
+ });
2929
+ if (v.status === "valid")
2930
+ return v;
2931
+ v.status === "dirty" && !a && (a = { result: v, ctx: l }), l.common.issues.length && i.push(l.common.issues);
2932
+ }
2933
+ if (a)
2934
+ return r.common.issues.push(...a.ctx.common.issues), a.result;
2935
+ const c = i.map((h) => new A(h));
2936
+ return d(r, {
2937
+ code: o.invalid_union,
2938
+ unionErrors: c
2939
+ }), _;
2940
+ }
2941
+ }
2942
+ get options() {
2943
+ return this._def.options;
2944
+ }
2945
+ };
2946
+ ne.create = (t, e) => new ne({
2947
+ options: t,
2948
+ typeName: p.ZodUnion,
2949
+ ...y(e)
2950
+ });
2951
+ D = (t) => t instanceof ve ? D(t.schema) : t instanceof $ ? D(t.innerType()) : t instanceof ie ? [t.value] : t instanceof j ? t.options : t instanceof Te ? E.objectValues(t.enum) : t instanceof ce ? D(t._def.innerType) : t instanceof pe ? [void 0] : t instanceof ye ? [null] : t instanceof M ? [void 0, ...D(t.unwrap())] : t instanceof C ? [null, ...D(t.unwrap())] : t instanceof Ce || t instanceof de ? D(t.unwrap()) : t instanceof oe ? D(t._def.innerType) : [];
2952
+ Ee = class _Ee extends g {
2953
+ _parse(e) {
2954
+ const { ctx: r } = this._processInputParams(e);
2955
+ if (r.parsedType !== u.object)
2956
+ return d(r, {
2957
+ code: o.invalid_type,
2958
+ expected: u.object,
2959
+ received: r.parsedType
2960
+ }), _;
2961
+ const n = this.discriminator, s = r.data[n], a = this.optionsMap.get(s);
2962
+ return a ? r.common.async ? a._parseAsync({
2963
+ data: r.data,
2964
+ path: r.path,
2965
+ parent: r
2966
+ }) : a._parseSync({
2967
+ data: r.data,
2968
+ path: r.path,
2969
+ parent: r
2970
+ }) : (d(r, {
2971
+ code: o.invalid_union_discriminator,
2972
+ options: Array.from(this.optionsMap.keys()),
2973
+ path: [n]
2974
+ }), _);
2975
+ }
2976
+ get discriminator() {
2977
+ return this._def.discriminator;
2978
+ }
2979
+ get options() {
2980
+ return this._def.options;
2981
+ }
2982
+ get optionsMap() {
2983
+ return this._def.optionsMap;
2984
+ }
2985
+ /**
2986
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2987
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2988
+ * have a different value for each object in the union.
2989
+ * @param discriminator the name of the discriminator property
2990
+ * @param types an array of object schemas
2991
+ * @param params
2992
+ */
2993
+ static create(e, r, n) {
2994
+ const s = /* @__PURE__ */ new Map();
2995
+ for (const a of r) {
2996
+ const i = D(a.shape[e]);
2997
+ if (!i.length)
2998
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2999
+ for (const c of i) {
3000
+ if (s.has(c))
3001
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
3002
+ s.set(c, a);
3003
+ }
3004
+ }
3005
+ return new _Ee({
3006
+ typeName: p.ZodDiscriminatedUnion,
3007
+ discriminator: e,
3008
+ options: r,
3009
+ optionsMap: s,
3010
+ ...y(n)
3011
+ });
3012
+ }
3013
+ };
3014
+ se = class extends g {
3015
+ _parse(e) {
3016
+ const { status: r, ctx: n } = this._processInputParams(e), s = (a, i) => {
3017
+ if (Ne(a) || Ne(i))
3018
+ return _;
3019
+ const c = ge(a.value, i.value);
3020
+ return c.valid ? ((Ae(a) || Ae(i)) && r.dirty(), { status: r.value, value: c.data }) : (d(n, {
3021
+ code: o.invalid_intersection_types
3022
+ }), _);
3023
+ };
3024
+ return n.common.async ? Promise.all([
3025
+ this._def.left._parseAsync({
3026
+ data: n.data,
3027
+ path: n.path,
3028
+ parent: n
3029
+ }),
3030
+ this._def.right._parseAsync({
3031
+ data: n.data,
3032
+ path: n.path,
3033
+ parent: n
3034
+ })
3035
+ ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
3036
+ data: n.data,
3037
+ path: n.path,
3038
+ parent: n
3039
+ }), this._def.right._parseSync({
3040
+ data: n.data,
3041
+ path: n.path,
3042
+ parent: n
3043
+ }));
3044
+ }
3045
+ };
3046
+ se.create = (t, e, r) => new se({
3047
+ left: t,
3048
+ right: e,
3049
+ typeName: p.ZodIntersection,
3050
+ ...y(r)
3051
+ });
3052
+ P = class _P extends g {
3053
+ _parse(e) {
3054
+ const { status: r, ctx: n } = this._processInputParams(e);
3055
+ if (n.parsedType !== u.array)
3056
+ return d(n, {
3057
+ code: o.invalid_type,
3058
+ expected: u.array,
3059
+ received: n.parsedType
3060
+ }), _;
3061
+ if (n.data.length < this._def.items.length)
3062
+ return d(n, {
3063
+ code: o.too_small,
3064
+ minimum: this._def.items.length,
3065
+ inclusive: true,
3066
+ exact: false,
3067
+ type: "array"
3068
+ }), _;
3069
+ !this._def.rest && n.data.length > this._def.items.length && (d(n, {
3070
+ code: o.too_big,
3071
+ maximum: this._def.items.length,
3072
+ inclusive: true,
3073
+ exact: false,
3074
+ type: "array"
3075
+ }), r.dirty());
3076
+ const a = [...n.data].map((i, c) => {
3077
+ const h = this._def.items[c] || this._def.rest;
3078
+ return h ? h._parse(new w(n, i, n.path, c)) : null;
3079
+ }).filter((i) => !!i);
3080
+ return n.common.async ? Promise.all(a).then((i) => k.mergeArray(r, i)) : k.mergeArray(r, a);
3081
+ }
3082
+ get items() {
3083
+ return this._def.items;
3084
+ }
3085
+ rest(e) {
3086
+ return new _P({
3087
+ ...this._def,
3088
+ rest: e
3089
+ });
3090
+ }
3091
+ };
3092
+ P.create = (t, e) => {
3093
+ if (!Array.isArray(t))
3094
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3095
+ return new P({
3096
+ items: t,
3097
+ typeName: p.ZodTuple,
3098
+ rest: null,
3099
+ ...y(e)
3100
+ });
3101
+ };
3102
+ ae = class _ae extends g {
3103
+ get keySchema() {
3104
+ return this._def.keyType;
3105
+ }
3106
+ get valueSchema() {
3107
+ return this._def.valueType;
3108
+ }
3109
+ _parse(e) {
3110
+ const { status: r, ctx: n } = this._processInputParams(e);
3111
+ if (n.parsedType !== u.object)
3112
+ return d(n, {
3113
+ code: o.invalid_type,
3114
+ expected: u.object,
3115
+ received: n.parsedType
3116
+ }), _;
3117
+ const s = [], a = this._def.keyType, i = this._def.valueType;
3118
+ for (const c in n.data)
3119
+ s.push({
3120
+ key: a._parse(new w(n, c, n.path, c)),
3121
+ value: i._parse(new w(n, n.data[c], n.path, c)),
3122
+ alwaysSet: c in n.data
3123
+ });
3124
+ return n.common.async ? k.mergeObjectAsync(r, s) : k.mergeObjectSync(r, s);
3125
+ }
3126
+ get element() {
3127
+ return this._def.valueType;
3128
+ }
3129
+ static create(e, r, n) {
3130
+ return r instanceof g ? new _ae({
3131
+ keyType: e,
3132
+ valueType: r,
3133
+ typeName: p.ZodRecord,
3134
+ ...y(n)
3135
+ }) : new _ae({
3136
+ keyType: Z.create(),
3137
+ valueType: e,
3138
+ typeName: p.ZodRecord,
3139
+ ...y(r)
3140
+ });
3141
+ }
3142
+ };
3143
+ Ze = class extends g {
3144
+ get keySchema() {
3145
+ return this._def.keyType;
3146
+ }
3147
+ get valueSchema() {
3148
+ return this._def.valueType;
3149
+ }
3150
+ _parse(e) {
3151
+ const { status: r, ctx: n } = this._processInputParams(e);
3152
+ if (n.parsedType !== u.map)
3153
+ return d(n, {
3154
+ code: o.invalid_type,
3155
+ expected: u.map,
3156
+ received: n.parsedType
3157
+ }), _;
3158
+ const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([c, h], l) => ({
3159
+ key: s._parse(new w(n, c, n.path, [l, "key"])),
3160
+ value: a._parse(new w(n, h, n.path, [l, "value"]))
3161
+ }));
3162
+ if (n.common.async) {
3163
+ const c = /* @__PURE__ */ new Map();
3164
+ return Promise.resolve().then(async () => {
3165
+ for (const h of i) {
3166
+ const l = await h.key, v = await h.value;
3167
+ if (l.status === "aborted" || v.status === "aborted")
3168
+ return _;
3169
+ (l.status === "dirty" || v.status === "dirty") && r.dirty(), c.set(l.value, v.value);
3170
+ }
3171
+ return { status: r.value, value: c };
3172
+ });
3173
+ } else {
3174
+ const c = /* @__PURE__ */ new Map();
3175
+ for (const h of i) {
3176
+ const l = h.key, v = h.value;
3177
+ if (l.status === "aborted" || v.status === "aborted")
3178
+ return _;
3179
+ (l.status === "dirty" || v.status === "dirty") && r.dirty(), c.set(l.value, v.value);
894
3180
  }
3181
+ return { status: r.value, value: c };
895
3182
  }
896
- const result = {
897
- success: !hasError && errors.length === 0 && !wasInterrupted,
898
- summary: wasInterrupted ? "Interrupted by user" : resultText || "Task completed",
899
- filesModified: Array.from(filesModified),
900
- iterations,
901
- error: wasInterrupted ? "Interrupted by user" : errors.length > 0 ? errors.join("; ") : void 0,
902
- // Include the provider session ID for resume capability
903
- providerSessionId
904
- };
905
- await this.presenter.onComplete(result);
906
- return result;
907
3183
  }
908
- async resolveClaudeCodePath() {
909
- if (config.claudeCodeExecutablePath) {
910
- this.presenter.onLog(
911
- `Using CLAUDE_CODE_EXECUTABLE_PATH: ${config.claudeCodeExecutablePath}`
912
- );
913
- return config.claudeCodeExecutablePath;
3184
+ };
3185
+ Ze.create = (t, e, r) => new Ze({
3186
+ valueType: e,
3187
+ keyType: t,
3188
+ typeName: p.ZodMap,
3189
+ ...y(r)
3190
+ });
3191
+ J = class _J extends g {
3192
+ _parse(e) {
3193
+ const { status: r, ctx: n } = this._processInputParams(e);
3194
+ if (n.parsedType !== u.set)
3195
+ return d(n, {
3196
+ code: o.invalid_type,
3197
+ expected: u.set,
3198
+ received: n.parsedType
3199
+ }), _;
3200
+ const s = this._def;
3201
+ s.minSize !== null && n.data.size < s.minSize.value && (d(n, {
3202
+ code: o.too_small,
3203
+ minimum: s.minSize.value,
3204
+ type: "set",
3205
+ inclusive: true,
3206
+ exact: false,
3207
+ message: s.minSize.message
3208
+ }), r.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (d(n, {
3209
+ code: o.too_big,
3210
+ maximum: s.maxSize.value,
3211
+ type: "set",
3212
+ inclusive: true,
3213
+ exact: false,
3214
+ message: s.maxSize.message
3215
+ }), r.dirty());
3216
+ const a = this._def.valueType;
3217
+ function i(h) {
3218
+ const l = /* @__PURE__ */ new Set();
3219
+ for (const v of h) {
3220
+ if (v.status === "aborted")
3221
+ return _;
3222
+ v.status === "dirty" && r.dirty(), l.add(v.value);
3223
+ }
3224
+ return { status: r.value, value: l };
914
3225
  }
915
- const isCompiledBinary2 = process.execPath && !process.execPath.includes("node");
916
- let claudeCodePath;
917
- if (isCompiledBinary2) {
918
- claudeCodePath = join2(dirname(process.execPath), "claude-code-cli.js");
919
- this.presenter.onLog(`Production mode: ${claudeCodePath}`);
3226
+ const c = [...n.data.values()].map((h, l) => a._parse(new w(n, h, n.path, l)));
3227
+ return n.common.async ? Promise.all(c).then((h) => i(h)) : i(c);
3228
+ }
3229
+ min(e, r) {
3230
+ return new _J({
3231
+ ...this._def,
3232
+ minSize: { value: e, message: f.toString(r) }
3233
+ });
3234
+ }
3235
+ max(e, r) {
3236
+ return new _J({
3237
+ ...this._def,
3238
+ maxSize: { value: e, message: f.toString(r) }
3239
+ });
3240
+ }
3241
+ size(e, r) {
3242
+ return this.min(e, r).max(e, r);
3243
+ }
3244
+ nonempty(e) {
3245
+ return this.min(1, e);
3246
+ }
3247
+ };
3248
+ J.create = (t, e) => new J({
3249
+ valueType: t,
3250
+ minSize: null,
3251
+ maxSize: null,
3252
+ typeName: p.ZodSet,
3253
+ ...y(e)
3254
+ });
3255
+ q = class _q extends g {
3256
+ constructor() {
3257
+ super(...arguments), this.validate = this.implement;
3258
+ }
3259
+ _parse(e) {
3260
+ const { ctx: r } = this._processInputParams(e);
3261
+ if (r.parsedType !== u.function)
3262
+ return d(r, {
3263
+ code: o.invalid_type,
3264
+ expected: u.function,
3265
+ received: r.parsedType
3266
+ }), _;
3267
+ function n(c, h) {
3268
+ return me({
3269
+ data: c,
3270
+ path: r.path,
3271
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, fe(), Q].filter((l) => !!l),
3272
+ issueData: {
3273
+ code: o.invalid_arguments,
3274
+ argumentsError: h
3275
+ }
3276
+ });
3277
+ }
3278
+ function s(c, h) {
3279
+ return me({
3280
+ data: c,
3281
+ path: r.path,
3282
+ errorMaps: [r.common.contextualErrorMap, r.schemaErrorMap, fe(), Q].filter((l) => !!l),
3283
+ issueData: {
3284
+ code: o.invalid_return_type,
3285
+ returnTypeError: h
3286
+ }
3287
+ });
3288
+ }
3289
+ const a = { errorMap: r.common.contextualErrorMap }, i = r.data;
3290
+ if (this._def.returns instanceof H) {
3291
+ const c = this;
3292
+ return b(async function(...h) {
3293
+ const l = new A([]), v = await c._def.args.parseAsync(h, a).catch((le) => {
3294
+ throw l.addIssue(n(h, le)), l;
3295
+ }), N = await Reflect.apply(i, this, v);
3296
+ return await c._def.returns._def.type.parseAsync(N, a).catch((le) => {
3297
+ throw l.addIssue(s(N, le)), l;
3298
+ });
3299
+ });
920
3300
  } else {
921
- const require2 = createRequire(import.meta.url);
922
- const sdkPath = require2.resolve("@anthropic-ai/claude-agent-sdk/sdk.mjs");
923
- claudeCodePath = join2(dirname(sdkPath), "cli.js");
924
- this.presenter.onLog(`Development mode: ${claudeCodePath}`);
3301
+ const c = this;
3302
+ return b(function(...h) {
3303
+ const l = c._def.args.safeParse(h, a);
3304
+ if (!l.success)
3305
+ throw new A([n(h, l.error)]);
3306
+ const v = Reflect.apply(i, this, l.data), N = c._def.returns.safeParse(v, a);
3307
+ if (!N.success)
3308
+ throw new A([s(v, N.error)]);
3309
+ return N.data;
3310
+ });
925
3311
  }
926
- const fs4 = await import("fs/promises");
927
- try {
928
- await fs4.access(claudeCodePath);
929
- this.presenter.onLog(`\u2713 Claude Code CLI found: ${claudeCodePath}`);
930
- } catch {
931
- const error = `Claude Code executable not found at: ${claudeCodePath}
932
- For compiled binaries, ensure claude-code-cli.js is in the same directory as the binary.
933
- Set CLAUDE_CODE_EXECUTABLE_PATH environment variable to override.`;
934
- await this.presenter.onError(error);
935
- throw new Error(error);
3312
+ }
3313
+ parameters() {
3314
+ return this._def.args;
3315
+ }
3316
+ returnType() {
3317
+ return this._def.returns;
3318
+ }
3319
+ args(...e) {
3320
+ return new _q({
3321
+ ...this._def,
3322
+ args: P.create(e).rest(F.create())
3323
+ });
3324
+ }
3325
+ returns(e) {
3326
+ return new _q({
3327
+ ...this._def,
3328
+ returns: e
3329
+ });
3330
+ }
3331
+ implement(e) {
3332
+ return this.parse(e);
3333
+ }
3334
+ strictImplement(e) {
3335
+ return this.parse(e);
3336
+ }
3337
+ static create(e, r, n) {
3338
+ return new _q({
3339
+ args: e || P.create([]).rest(F.create()),
3340
+ returns: r || F.create(),
3341
+ typeName: p.ZodFunction,
3342
+ ...y(n)
3343
+ });
3344
+ }
3345
+ };
3346
+ ve = class extends g {
3347
+ get schema() {
3348
+ return this._def.getter();
3349
+ }
3350
+ _parse(e) {
3351
+ const { ctx: r } = this._processInputParams(e);
3352
+ return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
3353
+ }
3354
+ };
3355
+ ve.create = (t, e) => new ve({
3356
+ getter: t,
3357
+ typeName: p.ZodLazy,
3358
+ ...y(e)
3359
+ });
3360
+ ie = class extends g {
3361
+ _parse(e) {
3362
+ if (e.data !== this._def.value) {
3363
+ const r = this._getOrReturnCtx(e);
3364
+ return d(r, {
3365
+ received: r.data,
3366
+ code: o.invalid_literal,
3367
+ expected: this._def.value
3368
+ }), _;
936
3369
  }
937
- return claudeCodePath;
3370
+ return { status: "valid", value: e.data };
3371
+ }
3372
+ get value() {
3373
+ return this._def.value;
938
3374
  }
939
3375
  };
940
- }
941
- });
942
-
943
- // src/shared/sessions.schema.ts
944
- import { z } from "zod";
945
- var textBlockSchema, toolUseBlockSchema, toolResultBlockSchema, thinkingBlockSchema, imageBlockSchema, contentBlockSchema, sessionSchema, createSessionRequestSchema, updateSessionRequestSchema, messageSchema, createMessageRequestSchema, cliEventSchema, createCLISessionRequestSchema;
946
- var init_sessions_schema = __esm({
947
- "src/shared/sessions.schema.ts"() {
948
- "use strict";
949
- textBlockSchema = z.object({
950
- type: z.literal("text"),
951
- text: z.string()
3376
+ ie.create = (t, e) => new ie({
3377
+ value: t,
3378
+ typeName: p.ZodLiteral,
3379
+ ...y(e)
3380
+ });
3381
+ j = class _j extends g {
3382
+ _parse(e) {
3383
+ if (typeof e.data != "string") {
3384
+ const r = this._getOrReturnCtx(e), n = this._def.values;
3385
+ return d(r, {
3386
+ expected: E.joinValues(n),
3387
+ received: r.parsedType,
3388
+ code: o.invalid_type
3389
+ }), _;
3390
+ }
3391
+ if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
3392
+ const r = this._getOrReturnCtx(e), n = this._def.values;
3393
+ return d(r, {
3394
+ received: r.data,
3395
+ code: o.invalid_enum_value,
3396
+ options: n
3397
+ }), _;
3398
+ }
3399
+ return b(e.data);
3400
+ }
3401
+ get options() {
3402
+ return this._def.values;
3403
+ }
3404
+ get enum() {
3405
+ const e = {};
3406
+ for (const r of this._def.values)
3407
+ e[r] = r;
3408
+ return e;
3409
+ }
3410
+ get Values() {
3411
+ const e = {};
3412
+ for (const r of this._def.values)
3413
+ e[r] = r;
3414
+ return e;
3415
+ }
3416
+ get Enum() {
3417
+ const e = {};
3418
+ for (const r of this._def.values)
3419
+ e[r] = r;
3420
+ return e;
3421
+ }
3422
+ extract(e, r = this._def) {
3423
+ return _j.create(e, {
3424
+ ...this._def,
3425
+ ...r
3426
+ });
3427
+ }
3428
+ exclude(e, r = this._def) {
3429
+ return _j.create(this.options.filter((n) => !e.includes(n)), {
3430
+ ...this._def,
3431
+ ...r
3432
+ });
3433
+ }
3434
+ };
3435
+ j.create = $e;
3436
+ Te = class extends g {
3437
+ _parse(e) {
3438
+ const r = E.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
3439
+ if (n.parsedType !== u.string && n.parsedType !== u.number) {
3440
+ const s = E.objectValues(r);
3441
+ return d(n, {
3442
+ expected: E.joinValues(s),
3443
+ received: n.parsedType,
3444
+ code: o.invalid_type
3445
+ }), _;
3446
+ }
3447
+ if (this._cache || (this._cache = new Set(E.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
3448
+ const s = E.objectValues(r);
3449
+ return d(n, {
3450
+ received: n.data,
3451
+ code: o.invalid_enum_value,
3452
+ options: s
3453
+ }), _;
3454
+ }
3455
+ return b(e.data);
3456
+ }
3457
+ get enum() {
3458
+ return this._def.values;
3459
+ }
3460
+ };
3461
+ Te.create = (t, e) => new Te({
3462
+ values: t,
3463
+ typeName: p.ZodNativeEnum,
3464
+ ...y(e)
3465
+ });
3466
+ H = class extends g {
3467
+ unwrap() {
3468
+ return this._def.type;
3469
+ }
3470
+ _parse(e) {
3471
+ const { ctx: r } = this._processInputParams(e);
3472
+ if (r.parsedType !== u.promise && r.common.async === false)
3473
+ return d(r, {
3474
+ code: o.invalid_type,
3475
+ expected: u.promise,
3476
+ received: r.parsedType
3477
+ }), _;
3478
+ const n = r.parsedType === u.promise ? r.data : Promise.resolve(r.data);
3479
+ return b(n.then((s) => this._def.type.parseAsync(s, {
3480
+ path: r.path,
3481
+ errorMap: r.common.contextualErrorMap
3482
+ })));
3483
+ }
3484
+ };
3485
+ H.create = (t, e) => new H({
3486
+ type: t,
3487
+ typeName: p.ZodPromise,
3488
+ ...y(e)
3489
+ });
3490
+ $ = class extends g {
3491
+ innerType() {
3492
+ return this._def.schema;
3493
+ }
3494
+ sourceType() {
3495
+ return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3496
+ }
3497
+ _parse(e) {
3498
+ const { status: r, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
3499
+ addIssue: (i) => {
3500
+ d(n, i), i.fatal ? r.abort() : r.dirty();
3501
+ },
3502
+ get path() {
3503
+ return n.path;
3504
+ }
3505
+ };
3506
+ if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
3507
+ const i = s.transform(n.data, a);
3508
+ if (n.common.async)
3509
+ return Promise.resolve(i).then(async (c) => {
3510
+ if (r.value === "aborted")
3511
+ return _;
3512
+ const h = await this._def.schema._parseAsync({
3513
+ data: c,
3514
+ path: n.path,
3515
+ parent: n
3516
+ });
3517
+ return h.status === "aborted" ? _ : h.status === "dirty" || r.value === "dirty" ? W(h.value) : h;
3518
+ });
3519
+ {
3520
+ if (r.value === "aborted")
3521
+ return _;
3522
+ const c = this._def.schema._parseSync({
3523
+ data: i,
3524
+ path: n.path,
3525
+ parent: n
3526
+ });
3527
+ return c.status === "aborted" ? _ : c.status === "dirty" || r.value === "dirty" ? W(c.value) : c;
3528
+ }
3529
+ }
3530
+ if (s.type === "refinement") {
3531
+ const i = (c) => {
3532
+ const h = s.refinement(c, a);
3533
+ if (n.common.async)
3534
+ return Promise.resolve(h);
3535
+ if (h instanceof Promise)
3536
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3537
+ return c;
3538
+ };
3539
+ if (n.common.async === false) {
3540
+ const c = this._def.schema._parseSync({
3541
+ data: n.data,
3542
+ path: n.path,
3543
+ parent: n
3544
+ });
3545
+ return c.status === "aborted" ? _ : (c.status === "dirty" && r.dirty(), i(c.value), { status: r.value, value: c.value });
3546
+ } else
3547
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((c) => c.status === "aborted" ? _ : (c.status === "dirty" && r.dirty(), i(c.value).then(() => ({ status: r.value, value: c.value }))));
3548
+ }
3549
+ if (s.type === "transform")
3550
+ if (n.common.async === false) {
3551
+ const i = this._def.schema._parseSync({
3552
+ data: n.data,
3553
+ path: n.path,
3554
+ parent: n
3555
+ });
3556
+ if (!z(i))
3557
+ return _;
3558
+ const c = s.transform(i.value, a);
3559
+ if (c instanceof Promise)
3560
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3561
+ return { status: r.value, value: c };
3562
+ } else
3563
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => z(i) ? Promise.resolve(s.transform(i.value, a)).then((c) => ({
3564
+ status: r.value,
3565
+ value: c
3566
+ })) : _);
3567
+ E.assertNever(s);
3568
+ }
3569
+ };
3570
+ $.create = (t, e, r) => new $({
3571
+ schema: t,
3572
+ typeName: p.ZodEffects,
3573
+ effect: e,
3574
+ ...y(r)
3575
+ });
3576
+ $.createWithPreprocess = (t, e, r) => new $({
3577
+ schema: e,
3578
+ effect: { type: "preprocess", transform: t },
3579
+ typeName: p.ZodEffects,
3580
+ ...y(r)
3581
+ });
3582
+ M = class extends g {
3583
+ _parse(e) {
3584
+ return this._getType(e) === u.undefined ? b(void 0) : this._def.innerType._parse(e);
3585
+ }
3586
+ unwrap() {
3587
+ return this._def.innerType;
3588
+ }
3589
+ };
3590
+ M.create = (t, e) => new M({
3591
+ innerType: t,
3592
+ typeName: p.ZodOptional,
3593
+ ...y(e)
3594
+ });
3595
+ C = class extends g {
3596
+ _parse(e) {
3597
+ return this._getType(e) === u.null ? b(null) : this._def.innerType._parse(e);
3598
+ }
3599
+ unwrap() {
3600
+ return this._def.innerType;
3601
+ }
3602
+ };
3603
+ C.create = (t, e) => new C({
3604
+ innerType: t,
3605
+ typeName: p.ZodNullable,
3606
+ ...y(e)
3607
+ });
3608
+ ce = class extends g {
3609
+ _parse(e) {
3610
+ const { ctx: r } = this._processInputParams(e);
3611
+ let n = r.data;
3612
+ return r.parsedType === u.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
3613
+ data: n,
3614
+ path: r.path,
3615
+ parent: r
3616
+ });
3617
+ }
3618
+ removeDefault() {
3619
+ return this._def.innerType;
3620
+ }
3621
+ };
3622
+ ce.create = (t, e) => new ce({
3623
+ innerType: t,
3624
+ typeName: p.ZodDefault,
3625
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
3626
+ ...y(e)
3627
+ });
3628
+ oe = class extends g {
3629
+ _parse(e) {
3630
+ const { ctx: r } = this._processInputParams(e), n = {
3631
+ ...r,
3632
+ common: {
3633
+ ...r.common,
3634
+ issues: []
3635
+ }
3636
+ }, s = this._def.innerType._parse({
3637
+ data: n.data,
3638
+ path: n.path,
3639
+ parent: {
3640
+ ...n
3641
+ }
3642
+ });
3643
+ return re(s) ? s.then((a) => ({
3644
+ status: "valid",
3645
+ value: a.status === "valid" ? a.value : this._def.catchValue({
3646
+ get error() {
3647
+ return new A(n.common.issues);
3648
+ },
3649
+ input: n.data
3650
+ })
3651
+ })) : {
3652
+ status: "valid",
3653
+ value: s.status === "valid" ? s.value : this._def.catchValue({
3654
+ get error() {
3655
+ return new A(n.common.issues);
3656
+ },
3657
+ input: n.data
3658
+ })
3659
+ };
3660
+ }
3661
+ removeCatch() {
3662
+ return this._def.innerType;
3663
+ }
3664
+ };
3665
+ oe.create = (t, e) => new oe({
3666
+ innerType: t,
3667
+ typeName: p.ZodCatch,
3668
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
3669
+ ...y(e)
3670
+ });
3671
+ Le = class extends g {
3672
+ _parse(e) {
3673
+ if (this._getType(e) !== u.nan) {
3674
+ const n = this._getOrReturnCtx(e);
3675
+ return d(n, {
3676
+ code: o.invalid_type,
3677
+ expected: u.nan,
3678
+ received: n.parsedType
3679
+ }), _;
3680
+ }
3681
+ return { status: "valid", value: e.data };
3682
+ }
3683
+ };
3684
+ Le.create = (t) => new Le({
3685
+ typeName: p.ZodNaN,
3686
+ ...y(t)
3687
+ });
3688
+ Ce = class extends g {
3689
+ _parse(e) {
3690
+ const { ctx: r } = this._processInputParams(e), n = r.data;
3691
+ return this._def.type._parse({
3692
+ data: n,
3693
+ path: r.path,
3694
+ parent: r
3695
+ });
3696
+ }
3697
+ unwrap() {
3698
+ return this._def.type;
3699
+ }
3700
+ };
3701
+ xe = class _xe extends g {
3702
+ _parse(e) {
3703
+ const { status: r, ctx: n } = this._processInputParams(e);
3704
+ if (n.common.async)
3705
+ return (async () => {
3706
+ const a = await this._def.in._parseAsync({
3707
+ data: n.data,
3708
+ path: n.path,
3709
+ parent: n
3710
+ });
3711
+ return a.status === "aborted" ? _ : a.status === "dirty" ? (r.dirty(), W(a.value)) : this._def.out._parseAsync({
3712
+ data: a.value,
3713
+ path: n.path,
3714
+ parent: n
3715
+ });
3716
+ })();
3717
+ {
3718
+ const s = this._def.in._parseSync({
3719
+ data: n.data,
3720
+ path: n.path,
3721
+ parent: n
3722
+ });
3723
+ return s.status === "aborted" ? _ : s.status === "dirty" ? (r.dirty(), {
3724
+ status: "dirty",
3725
+ value: s.value
3726
+ }) : this._def.out._parseSync({
3727
+ data: s.value,
3728
+ path: n.path,
3729
+ parent: n
3730
+ });
3731
+ }
3732
+ }
3733
+ static create(e, r) {
3734
+ return new _xe({
3735
+ in: e,
3736
+ out: r,
3737
+ typeName: p.ZodPipeline
3738
+ });
3739
+ }
3740
+ };
3741
+ de = class extends g {
3742
+ _parse(e) {
3743
+ const r = this._def.innerType._parse(e), n = (s) => (z(s) && (s.value = Object.freeze(s.value)), s);
3744
+ return re(r) ? r.then((s) => n(s)) : n(r);
3745
+ }
3746
+ unwrap() {
3747
+ return this._def.innerType;
3748
+ }
3749
+ };
3750
+ de.create = (t, e) => new de({
3751
+ innerType: t,
3752
+ typeName: p.ZodReadonly,
3753
+ ...y(e)
3754
+ });
3755
+ (function(t) {
3756
+ t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
3757
+ })(p || (p = {}));
3758
+ m = Z.create;
3759
+ L = B.create;
3760
+ ke = _e.create;
3761
+ R = K.create;
3762
+ te = F.create;
3763
+ U.create;
3764
+ ee = I.create;
3765
+ T = x.create;
3766
+ ht = ne.create;
3767
+ Ve = Ee.create;
3768
+ se.create;
3769
+ P.create;
3770
+ Y = ae.create;
3771
+ Me = q.create;
3772
+ O = ie.create;
3773
+ G = j.create;
3774
+ ft = H.create;
3775
+ M.create;
3776
+ C.create;
3777
+ Pe = 100;
3778
+ xt = T({
3779
+ id: m().uuid(),
3780
+ organizationId: m().uuid(),
3781
+ name: m(),
3782
+ keyHash: m(),
3783
+ keyPrefix: m(),
3784
+ keySuffix: m(),
3785
+ isActive: ke(),
3786
+ lastUsedAt: R().nullable(),
3787
+ createdAt: R(),
3788
+ updatedAt: R()
3789
+ });
3790
+ kt = T({
3791
+ id: m().uuid(),
3792
+ apiKeyId: m().uuid(),
3793
+ organizationId: m().uuid(),
3794
+ tokensUsed: L().int().positive(),
3795
+ model: m(),
3796
+ statusCode: L().int(),
3797
+ createdAt: R()
3798
+ });
3799
+ Ot = T({
3800
+ name: m().min(1, "API key name is required").max(
3801
+ Pe,
3802
+ `API key name must be less than ${Pe} characters`
3803
+ )
3804
+ });
3805
+ bt = T({
3806
+ id: m().uuid(),
3807
+ name: m(),
3808
+ keyPrefix: m(),
3809
+ keySuffix: m(),
3810
+ lastUsedAt: R().nullable(),
3811
+ createdAt: R(),
3812
+ currentMonthUsage: L().int().nonnegative(),
3813
+ // Full key is only returned once at creation
3814
+ key: m().optional()
3815
+ });
3816
+ Nt = T({
3817
+ totalTokens: L().int(),
3818
+ totalRequests: L().int(),
3819
+ successfulRequests: L().int(),
3820
+ failedRequests: L().int()
3821
+ });
3822
+ mt = T({
3823
+ error: m().describe("The error message")
3824
+ });
3825
+ T({
3826
+ error: m().describe("The error message")
3827
+ });
3828
+ Se = T({
3829
+ errors: Y(ee(m())).describe("Field validation errors"),
3830
+ message: m().optional().describe("General error message")
3831
+ });
3832
+ ht([
3833
+ mt,
3834
+ Se,
3835
+ T({
3836
+ response: T({
3837
+ clone: Me().returns(
3838
+ T({
3839
+ json: Me().returns(ft(Se))
3840
+ })
3841
+ )
3842
+ })
3843
+ })
3844
+ ]);
3845
+ _t = 100;
3846
+ At = T({
3847
+ id: m().uuid(),
3848
+ orgId: m(),
3849
+ timezone: m().nullable(),
3850
+ monthlyTokenLimit: L().int().positive(),
3851
+ createdAt: R(),
3852
+ updatedAt: R()
3853
+ });
3854
+ pt = T({
3855
+ timezone: m().max(_t, "Timezone must be less than 100 characters").nullable().optional(),
3856
+ monthlyTokenLimit: L().int().positive().optional()
952
3857
  });
953
- toolUseBlockSchema = z.object({
954
- type: z.literal("tool_use"),
955
- id: z.string(),
956
- name: z.string(),
957
- input: z.record(z.unknown())
3858
+ yt = T({
3859
+ type: O("text"),
3860
+ text: m()
958
3861
  });
959
- toolResultBlockSchema = z.object({
960
- type: z.literal("tool_result"),
961
- tool_use_id: z.string(),
962
- content: z.string(),
963
- is_error: z.boolean().optional()
3862
+ gt = T({
3863
+ type: O("tool_use"),
3864
+ id: m(),
3865
+ name: m(),
3866
+ input: Y(te())
964
3867
  });
965
- thinkingBlockSchema = z.object({
966
- type: z.literal("thinking"),
967
- thinking: z.string()
3868
+ vt = T({
3869
+ type: O("tool_result"),
3870
+ tool_use_id: m(),
3871
+ content: m(),
3872
+ is_error: ke().optional()
968
3873
  });
969
- imageBlockSchema = z.object({
970
- type: z.literal("image"),
971
- source: z.object({
972
- type: z.literal("base64"),
973
- media_type: z.string(),
974
- data: z.string()
3874
+ Tt = T({
3875
+ type: O("thinking"),
3876
+ thinking: m()
3877
+ });
3878
+ Et = T({
3879
+ type: O("image"),
3880
+ source: T({
3881
+ type: O("base64"),
3882
+ media_type: m(),
3883
+ data: m()
975
3884
  })
976
3885
  });
977
- contentBlockSchema = z.discriminatedUnion("type", [
978
- textBlockSchema,
979
- toolUseBlockSchema,
980
- toolResultBlockSchema,
981
- thinkingBlockSchema,
982
- imageBlockSchema
3886
+ ue = Ve("type", [
3887
+ yt,
3888
+ gt,
3889
+ vt,
3890
+ Tt,
3891
+ Et
983
3892
  ]);
984
- sessionSchema = z.object({
985
- id: z.string().uuid(),
986
- orgId: z.string(),
987
- userId: z.string().uuid(),
988
- title: z.string().nullable(),
989
- origin: z.enum(["cli", "web", "github"]).default("web"),
990
- originMetadata: z.record(z.unknown()).nullable().optional(),
991
- authMethod: z.enum(["clerk", "cli-token", "api-key"]).default("clerk"),
992
- authId: z.string().nullable().optional(),
993
- providerSessionId: z.string().nullable().optional(),
994
- createdAt: z.date(),
995
- updatedAt: z.date()
3893
+ It = T({
3894
+ id: m().uuid(),
3895
+ orgId: m(),
3896
+ userId: m().uuid(),
3897
+ title: m().nullable(),
3898
+ origin: G(["cli", "web", "github"]).default("web"),
3899
+ originMetadata: Y(te()).nullable().optional(),
3900
+ authMethod: G(["clerk", "cli-token", "api-key"]).default("clerk"),
3901
+ authId: m().nullable().optional(),
3902
+ // Claude Agent SDK session ID for resuming conversations
3903
+ // Sessions expire after ~30 days due to Anthropic's data retention policy
3904
+ providerSessionId: m().nullable().optional(),
3905
+ createdAt: R(),
3906
+ updatedAt: R()
996
3907
  });
997
- createSessionRequestSchema = z.object({
998
- title: z.string().optional(),
999
- origin: z.enum(["cli", "web", "github"]).optional(),
1000
- originMetadata: z.record(z.unknown()).optional()
3908
+ wt = T({
3909
+ title: m().optional(),
3910
+ origin: G(["cli", "web", "github"]).optional(),
3911
+ originMetadata: Y(te()).optional()
1001
3912
  });
1002
- updateSessionRequestSchema = z.object({
1003
- title: z.string().optional(),
1004
- providerSessionId: z.string().optional()
3913
+ Dt = T({
3914
+ title: m().optional(),
3915
+ providerSessionId: m().optional()
1005
3916
  });
1006
- messageSchema = z.object({
1007
- id: z.string().uuid(),
1008
- conversationId: z.string().uuid(),
1009
- role: z.enum(["user", "assistant"]),
1010
- content: z.array(contentBlockSchema),
1011
- createdAt: z.date()
3917
+ Zt = T({
3918
+ id: m().uuid(),
3919
+ conversationId: m().uuid(),
3920
+ role: G(["user", "assistant"]),
3921
+ content: ee(ue),
3922
+ createdAt: R()
1012
3923
  });
1013
- createMessageRequestSchema = z.object({
1014
- role: z.enum(["user", "assistant"]),
1015
- content: z.array(contentBlockSchema)
3924
+ Lt = T({
3925
+ role: G(["user", "assistant"]),
3926
+ content: ee(ue)
1016
3927
  });
1017
- cliEventSchema = z.discriminatedUnion("type", [
1018
- z.object({
1019
- type: z.literal("user_message"),
1020
- content: z.array(contentBlockSchema)
3928
+ Mt = Ve("type", [
3929
+ T({
3930
+ type: O("user_message"),
3931
+ content: ee(ue)
1021
3932
  }),
1022
- z.object({
1023
- type: z.literal("assistant_text"),
1024
- delta: z.string()
3933
+ T({
3934
+ type: O("assistant_text"),
3935
+ delta: m()
1025
3936
  }),
1026
- z.object({
1027
- type: z.literal("assistant_thinking"),
1028
- delta: z.string()
3937
+ T({
3938
+ type: O("assistant_thinking"),
3939
+ delta: m()
1029
3940
  }),
1030
- z.object({
1031
- type: z.literal("tool_use"),
1032
- id: z.string(),
1033
- name: z.string(),
1034
- input: z.record(z.unknown())
3941
+ T({
3942
+ type: O("tool_use"),
3943
+ id: m(),
3944
+ name: m(),
3945
+ input: Y(te())
1035
3946
  }),
1036
- z.object({
1037
- type: z.literal("tool_result"),
1038
- tool_use_id: z.string(),
1039
- content: z.string(),
1040
- is_error: z.boolean().optional()
3947
+ T({
3948
+ type: O("tool_result"),
3949
+ tool_use_id: m(),
3950
+ content: m(),
3951
+ is_error: ke().optional()
1041
3952
  }),
1042
- z.object({
1043
- type: z.literal("message_complete"),
1044
- message: z.object({
1045
- role: z.enum(["user", "assistant"]),
1046
- content: z.array(contentBlockSchema)
3953
+ T({
3954
+ type: O("message_complete"),
3955
+ message: T({
3956
+ role: G(["user", "assistant"]),
3957
+ content: ee(ue)
1047
3958
  })
1048
3959
  }),
1049
- z.object({
1050
- type: z.literal("session_complete")
3960
+ T({
3961
+ type: O("session_complete")
1051
3962
  }),
1052
- z.object({
1053
- type: z.literal("session_error"),
1054
- error: z.string()
3963
+ T({
3964
+ type: O("session_error"),
3965
+ error: m()
1055
3966
  })
1056
3967
  ]);
1057
- createCLISessionRequestSchema = z.object({
1058
- title: z.string(),
1059
- originMetadata: z.record(z.unknown()).optional()
3968
+ Pt = T({
3969
+ title: m(),
3970
+ originMetadata: Y(te()).optional()
1060
3971
  });
1061
3972
  }
1062
3973
  });
1063
3974
 
1064
- // src/shared/tool-name.ts
1065
- function getToolDisplayName(toolName) {
1066
- const displayNameMap = {
1067
- Grep: "Search",
1068
- Glob: "Search",
1069
- BashOutput: "Command Output"
1070
- };
1071
- return displayNameMap[toolName] || toolName;
1072
- }
1073
- var init_tool_name = __esm({
1074
- "src/shared/tool-name.ts"() {
1075
- "use strict";
1076
- }
1077
- });
1078
-
1079
- // src/shared/index.ts
1080
- var init_shared = __esm({
1081
- "src/shared/index.ts"() {
1082
- "use strict";
1083
- init_sessions_schema();
1084
- init_tool_name();
1085
- }
1086
- });
1087
-
1088
3975
  // src/utils/logger.ts
1089
3976
  import * as fs2 from "fs";
1090
3977
  import * as path2 from "path";
@@ -1537,6 +4424,15 @@ var init_api_client = __esm({
1537
4424
  }
1538
4425
  });
1539
4426
 
4427
+ // src/version.ts
4428
+ var CLI_VERSION;
4429
+ var init_version = __esm({
4430
+ "src/version.ts"() {
4431
+ "use strict";
4432
+ CLI_VERSION = "0.0.6";
4433
+ }
4434
+ });
4435
+
1540
4436
  // src/utils/banner.ts
1541
4437
  function getBanner() {
1542
4438
  const banner = `\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
@@ -1825,7 +4721,7 @@ var ReactPresenter;
1825
4721
  var init_react = __esm({
1826
4722
  "src/presenters/react.ts"() {
1827
4723
  "use strict";
1828
- init_shared();
4724
+ init_shared_es();
1829
4725
  ReactPresenter = class {
1830
4726
  callbacks;
1831
4727
  apiClient;
@@ -1900,7 +4796,7 @@ var init_react = __esm({
1900
4796
  const message = {
1901
4797
  type: "tool",
1902
4798
  content: getToolDescription(tool, input),
1903
- toolName: getToolDisplayName(tool),
4799
+ toolName: Ct(tool),
1904
4800
  toolInput: input,
1905
4801
  toolResult: void 0,
1906
4802
  isExpanded: false,
@@ -2428,9 +5324,23 @@ var init_AuthBanner = __esm({
2428
5324
  if (authState === "authenticated" /* Authenticated */) {
2429
5325
  return null;
2430
5326
  }
2431
- const message = authState === "authenticating" /* Authenticating */ ? "Authenticating..." : "Not logged in. Type /login to authenticate.";
2432
- const color = authState === "authenticating" /* Authenticating */ ? theme.text.info : theme.text.warning;
2433
- return /* @__PURE__ */ React.createElement(Box, { marginBottom: 0, paddingX: 1 }, /* @__PURE__ */ React.createElement(Text, { color }, message));
5327
+ if (authState === "authenticating" /* Authenticating */) {
5328
+ return /* @__PURE__ */ React.createElement(Box, { marginBottom: 0, paddingX: 1 }, /* @__PURE__ */ React.createElement(Text, { color: theme.text.info }, "Authenticating..."));
5329
+ }
5330
+ return /* @__PURE__ */ React.createElement(
5331
+ Box,
5332
+ {
5333
+ marginBottom: 0,
5334
+ paddingX: 1,
5335
+ paddingY: 0,
5336
+ borderStyle: "round",
5337
+ borderColor: theme.text.warning
5338
+ },
5339
+ /* @__PURE__ */ React.createElement(Text, { color: theme.text.warning, bold: true }, "Not logged in"),
5340
+ /* @__PURE__ */ React.createElement(Text, { color: theme.text.dim }, " - Type "),
5341
+ /* @__PURE__ */ React.createElement(Text, { color: theme.text.info }, "/login"),
5342
+ /* @__PURE__ */ React.createElement(Text, { color: theme.text.dim }, " to authenticate")
5343
+ );
2434
5344
  };
2435
5345
  }
2436
5346
  });
@@ -2645,17 +5555,17 @@ function parseSGRMouseEvent(buffer) {
2645
5555
  function parseX11MouseEvent(buffer) {
2646
5556
  const match = buffer.match(X11_MOUSE_REGEX);
2647
5557
  if (!match) return null;
2648
- const b = match[1].charCodeAt(0) - 32;
5558
+ const b2 = match[1].charCodeAt(0) - 32;
2649
5559
  const col = match[1].charCodeAt(1) - 32;
2650
5560
  const row = match[1].charCodeAt(2) - 32;
2651
- const shift = (b & 4) !== 0;
2652
- const meta = (b & 8) !== 0;
2653
- const ctrl = (b & 16) !== 0;
2654
- const isMove = (b & 32) !== 0;
2655
- const isWheel = (b & 64) !== 0;
5561
+ const shift = (b2 & 4) !== 0;
5562
+ const meta = (b2 & 8) !== 0;
5563
+ const ctrl = (b2 & 16) !== 0;
5564
+ const isMove = (b2 & 32) !== 0;
5565
+ const isWheel = (b2 & 64) !== 0;
2656
5566
  let name = null;
2657
5567
  if (isWheel) {
2658
- const button = b & 3;
5568
+ const button = b2 & 3;
2659
5569
  switch (button) {
2660
5570
  case 0:
2661
5571
  name = "scroll-up";
@@ -2669,7 +5579,7 @@ function parseX11MouseEvent(buffer) {
2669
5579
  } else if (isMove) {
2670
5580
  name = "move";
2671
5581
  } else {
2672
- const button = b & 3;
5582
+ const button = b2 & 3;
2673
5583
  if (button === 3) {
2674
5584
  name = "left-release";
2675
5585
  } else {
@@ -2689,7 +5599,7 @@ function parseX11MouseEvent(buffer) {
2689
5599
  }
2690
5600
  }
2691
5601
  if (name) {
2692
- let button = getButtonFromCode(b);
5602
+ let button = getButtonFromCode(b2);
2693
5603
  if (name === "left-release" && button === "none") {
2694
5604
  button = "left";
2695
5605
  }
@@ -3282,8 +6192,7 @@ var init_SessionContext = __esm({
3282
6192
  filesModified: /* @__PURE__ */ new Set(),
3283
6193
  commandsRun: [],
3284
6194
  iterations: 0,
3285
- startTime: Date.now(),
3286
- totalTokens: 0
6195
+ startTime: Date.now()
3287
6196
  });
3288
6197
  const [isAgentRunning, setIsAgentRunning] = useState2(false);
3289
6198
  const [shouldInterruptAgent, setShouldInterruptAgent] = useState2(false);
@@ -3339,8 +6248,7 @@ var init_SessionContext = __esm({
3339
6248
  filesModified: /* @__PURE__ */ new Set(),
3340
6249
  commandsRun: [],
3341
6250
  iterations: 0,
3342
- startTime: Date.now(),
3343
- totalTokens: 0
6251
+ startTime: Date.now()
3344
6252
  });
3345
6253
  console.clear();
3346
6254
  }, []);
@@ -3350,9 +6258,6 @@ var init_SessionContext = __esm({
3350
6258
  const updateStats = useCallback2((updates) => {
3351
6259
  setStats((prev) => ({ ...prev, ...updates }));
3352
6260
  }, []);
3353
- const addTokens = useCallback2((tokens) => {
3354
- setStats((prev) => ({ ...prev, totalTokens: prev.totalTokens + tokens }));
3355
- }, []);
3356
6261
  const toggleAllToolOutputs = useCallback2(() => {
3357
6262
  setAllToolsExpanded((prev) => {
3358
6263
  const newValue = !prev;
@@ -3379,7 +6284,6 @@ var init_SessionContext = __esm({
3379
6284
  setTodos,
3380
6285
  stats,
3381
6286
  updateStats,
3382
- addTokens,
3383
6287
  isAgentRunning,
3384
6288
  setIsAgentRunning,
3385
6289
  shouldInterruptAgent,
@@ -3509,7 +6413,7 @@ var init_InputPrompt = __esm({
3509
6413
  gitBranch,
3510
6414
  onInputChange
3511
6415
  }, ref) => {
3512
- const { messages, agentMode, stats } = useSession();
6416
+ const { messages, agentMode } = useSession();
3513
6417
  const [value, setValue] = useState3("");
3514
6418
  const [cursorOffset, setCursorOffset] = useState3(0);
3515
6419
  const [allFiles, setAllFiles] = useState3([]);
@@ -3570,7 +6474,7 @@ var init_InputPrompt = __esm({
3570
6474
  if (isValidStart) {
3571
6475
  const query2 = textBeforeCursor.slice(lastAt + 1);
3572
6476
  if (!/\s/.test(query2)) {
3573
- const matches = allFiles.filter((f) => f.toLowerCase().includes(query2.toLowerCase())).slice(0, 5);
6477
+ const matches = allFiles.filter((f2) => f2.toLowerCase().includes(query2.toLowerCase())).slice(0, 5);
3574
6478
  if (matches.length > 0) {
3575
6479
  setSuggestions(matches);
3576
6480
  setShowSuggestions(true);
@@ -3739,7 +6643,7 @@ var init_InputPrompt = __esm({
3739
6643
  }
3740
6644
  return /* @__PURE__ */ React6.createElement(Text4, { color: theme.text.primary, key: idx }, line);
3741
6645
  })), !hasContent && disabled && /* @__PURE__ */ React6.createElement(Text4, { color: theme.text.dim, italic: true }, "Waiting for agent to complete...")))
3742
- ), /* @__PURE__ */ React6.createElement(Box4, { paddingX: 1, justifyContent: "space-between" }, /* @__PURE__ */ React6.createElement(Box4, null, /* @__PURE__ */ React6.createElement(Text4, { color: agentMode === "plan" ? theme.status.inProgress : theme.text.dim }, agentMode === "plan" ? "\u23F8 plan mode on" : "\u25B6 build mode"), /* @__PURE__ */ React6.createElement(Text4, { color: theme.text.dim }, " (shift+tab to cycle)")), /* @__PURE__ */ React6.createElement(Text4, { color: theme.text.dim }, stats.totalTokens >= 1e6 ? `${(stats.totalTokens / 1e6).toFixed(1)}M tokens` : stats.totalTokens >= 1e3 ? `${(stats.totalTokens / 1e3).toFixed(1)}k tokens` : `${stats.totalTokens} tokens`)));
6646
+ ), /* @__PURE__ */ React6.createElement(Box4, { paddingX: 1 }, /* @__PURE__ */ React6.createElement(Text4, { color: agentMode === "plan" ? theme.status.inProgress : theme.text.dim }, agentMode === "plan" ? "\u23F8 plan mode on" : "\u25B6 build mode"), /* @__PURE__ */ React6.createElement(Text4, { color: theme.text.dim }, " (shift+tab to cycle)")));
3743
6647
  });
3744
6648
  InputPrompt.displayName = "InputPrompt";
3745
6649
  }
@@ -3754,8 +6658,10 @@ var init_Header = __esm({
3754
6658
  "src/ui/components/Header.tsx"() {
3755
6659
  "use strict";
3756
6660
  init_banner();
6661
+ init_version();
3757
6662
  init_theme();
3758
- Header = ({ version, currentFolder, gitBranch }) => {
6663
+ Header = ({ currentFolder, gitBranch }) => {
6664
+ const version = CLI_VERSION;
3759
6665
  const banner = getBanner();
3760
6666
  const infoParts = [`v${version}`];
3761
6667
  if (currentFolder) {
@@ -3881,16 +6787,16 @@ function parseMarkdownSections(text) {
3881
6787
  }
3882
6788
  function formatInline(text) {
3883
6789
  let result = text;
3884
- result = result.replace(/`([^`]+)`/g, (_, code) => {
6790
+ result = result.replace(/`([^`]+)`/g, (_2, code) => {
3885
6791
  return chalk6.cyan(code);
3886
6792
  });
3887
- result = result.replace(/(\*\*|__)([^*_]+)\1/g, (_, __, text2) => {
6793
+ result = result.replace(/(\*\*|__)([^*_]+)\1/g, (_2, __, text2) => {
3888
6794
  return chalk6.bold(text2);
3889
6795
  });
3890
- result = result.replace(/(?<!\*)\*(?!\*)([^*]+)\*(?!\*)/g, (_, text2) => {
6796
+ result = result.replace(/(?<!\*)\*(?!\*)([^*]+)\*(?!\*)/g, (_2, text2) => {
3891
6797
  return chalk6.italic(text2);
3892
6798
  });
3893
- result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, text2) => {
6799
+ result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_2, text2) => {
3894
6800
  return chalk6.cyan.underline(text2);
3895
6801
  });
3896
6802
  return result;
@@ -4388,7 +7294,7 @@ var ToolMessage;
4388
7294
  var init_ToolMessage = __esm({
4389
7295
  "src/ui/components/messages/ToolMessage.tsx"() {
4390
7296
  "use strict";
4391
- init_shared();
7297
+ init_shared_es();
4392
7298
  init_theme();
4393
7299
  ToolMessage = ({
4394
7300
  toolName,
@@ -4397,7 +7303,7 @@ var init_ToolMessage = __esm({
4397
7303
  result,
4398
7304
  isExpanded = true
4399
7305
  }) => {
4400
- const displayName = getToolDisplayName(toolName);
7306
+ const displayName = Ct(toolName);
4401
7307
  const { icon, color } = getToolStyle(toolName);
4402
7308
  const resultSummary = result ? getResultSummary(toolName, result) : null;
4403
7309
  const hasExpandableContent = !!result;
@@ -4855,7 +7761,7 @@ var init_MessageList = __esm({
4855
7761
  return null;
4856
7762
  }
4857
7763
  };
4858
- return /* @__PURE__ */ React18.createElement(Box15, { flexDirection: "column", flexGrow: 1, overflow: "hidden" }, /* @__PURE__ */ React18.createElement(Scrollable, { scrollToBottom: true }, /* @__PURE__ */ React18.createElement(Header, { currentFolder, gitBranch, key: "header", version: "0.0.2" }), messages.map((message) => /* @__PURE__ */ React18.createElement(Box15, { flexDirection: "column", key: message.id, width: "100%" }, renderMessage(message))), isAgentRunning && !messages.some((m) => m.type === "assistant" && m.isPending) && /* @__PURE__ */ React18.createElement(LoadingMessage, { key: "loading" })));
7764
+ return /* @__PURE__ */ React18.createElement(Box15, { flexDirection: "column", flexGrow: 1, overflow: "hidden" }, /* @__PURE__ */ React18.createElement(Scrollable, { scrollToBottom: true }, /* @__PURE__ */ React18.createElement(Header, { currentFolder, gitBranch, key: "header" }), messages.map((message) => /* @__PURE__ */ React18.createElement(Box15, { flexDirection: "column", key: message.id, width: "100%" }, renderMessage(message))), isAgentRunning && !messages.some((m2) => m2.type === "assistant" && m2.isPending) && /* @__PURE__ */ React18.createElement(LoadingMessage, { key: "loading" })));
4859
7765
  };
4860
7766
  }
4861
7767
  });
@@ -5446,7 +8352,7 @@ async function runInteractive(config2) {
5446
8352
  process.on("SIGTERM", handleSigInt);
5447
8353
  const isDev = process.env.NODE_ENV === "development";
5448
8354
  logger.enableFileLogging(isDev);
5449
- const apiUrl = config2.supatestApiUrl || "https://api.supatest.ai";
8355
+ const apiUrl = config2.supatestApiUrl || "https://code-api.supatest.ai";
5450
8356
  const apiClient = new ApiClient(apiUrl, config2.supatestApiKey);
5451
8357
  try {
5452
8358
  process.stdout.write("\x1Bc");
@@ -5458,7 +8364,7 @@ async function runInteractive(config2) {
5458
8364
  if (config2.task) {
5459
8365
  const truncatedTitle = config2.task.length > 50 ? config2.task.slice(0, 50) + "..." : config2.task;
5460
8366
  const session = await apiClient.createSession(truncatedTitle, {
5461
- cliVersion: CLI_VERSION2,
8367
+ cliVersion: CLI_VERSION,
5462
8368
  cwd: config2.cwd || process.cwd()
5463
8369
  });
5464
8370
  sessionId = session.sessionId;
@@ -5505,7 +8411,7 @@ async function runInteractive(config2) {
5505
8411
  process.exit(1);
5506
8412
  }
5507
8413
  }
5508
- var CLI_VERSION2, AgentRunner, InteractiveAppContent, InteractiveApp;
8414
+ var AgentRunner, InteractiveAppContent, InteractiveApp;
5509
8415
  var init_interactive = __esm({
5510
8416
  "src/modes/interactive.tsx"() {
5511
8417
  "use strict";
@@ -5521,7 +8427,7 @@ var init_interactive = __esm({
5521
8427
  init_mouse();
5522
8428
  init_logger();
5523
8429
  init_stdio();
5524
- CLI_VERSION2 = "0.0.1";
8430
+ init_version();
5525
8431
  AgentRunner = ({ config: config2, sessionId, apiClient, onComplete }) => {
5526
8432
  const {
5527
8433
  addMessage,
@@ -5529,7 +8435,6 @@ var init_interactive = __esm({
5529
8435
  updateMessageByToolId,
5530
8436
  setIsAgentRunning,
5531
8437
  updateStats,
5532
- addTokens,
5533
8438
  setTodos,
5534
8439
  shouldInterruptAgent,
5535
8440
  setShouldInterruptAgent,
@@ -5548,7 +8453,8 @@ var init_interactive = __esm({
5548
8453
  const runAgent2 = async () => {
5549
8454
  setIsAgentRunning(true);
5550
8455
  try {
5551
- const baseUrl = `${config2.supatestApiUrl}/v1/sessions/${sessionId}/anthropic`;
8456
+ const proxyUrl = config2.supatestApiUrl || "https://code-api.supatest.ai";
8457
+ const baseUrl = `${proxyUrl}/v1/sessions/${sessionId}/anthropic`;
5552
8458
  process.env.ANTHROPIC_BASE_URL = baseUrl;
5553
8459
  process.env.ANTHROPIC_API_KEY = config2.supatestApiKey;
5554
8460
  const presenter = new ReactPresenter(
@@ -5565,9 +8471,6 @@ var init_interactive = __esm({
5565
8471
  updateStats: (stats) => {
5566
8472
  if (isMounted) updateStats(stats);
5567
8473
  },
5568
- addTokens: (tokens) => {
5569
- if (isMounted) addTokens(tokens);
5570
- },
5571
8474
  setTodos: (todos) => {
5572
8475
  if (isMounted) setTodos(todos);
5573
8476
  },
@@ -5624,8 +8527,7 @@ var init_interactive = __esm({
5624
8527
  const {
5625
8528
  addMessage,
5626
8529
  loadMessages,
5627
- setSessionId: setContextSessionId,
5628
- updateStats
8530
+ setSessionId: setContextSessionId
5629
8531
  } = useSession();
5630
8532
  const [sessionId, setSessionId] = React22.useState(initialSessionId);
5631
8533
  const [currentTask, setCurrentTask] = React22.useState(config2.task);
@@ -5638,7 +8540,7 @@ var init_interactive = __esm({
5638
8540
  try {
5639
8541
  const truncatedTitle = task.length > 50 ? task.slice(0, 50) + "..." : task;
5640
8542
  const session = await apiClient.createSession(truncatedTitle, {
5641
- cliVersion: CLI_VERSION2,
8543
+ cliVersion: CLI_VERSION,
5642
8544
  cwd: config2.cwd || process.cwd()
5643
8545
  });
5644
8546
  setSessionId(session.sessionId);
@@ -5766,13 +8668,6 @@ var init_interactive = __esm({
5766
8668
  if (session.providerSessionId) {
5767
8669
  setProviderSessionId(session.providerSessionId);
5768
8670
  }
5769
- try {
5770
- const sessionDetails = await apiClient.getSession(session.id);
5771
- if (sessionDetails.totalTokens) {
5772
- updateStats({ totalTokens: sessionDetails.totalTokens });
5773
- }
5774
- } catch {
5775
- }
5776
8671
  uiMessages.push({
5777
8672
  id: `resume-info-${Date.now()}`,
5778
8673
  type: "error",
@@ -5831,37 +8726,37 @@ var CompositePresenter = class {
5831
8726
  this.presenters = presenters;
5832
8727
  }
5833
8728
  async onStart(config2) {
5834
- await Promise.all(this.presenters.map((p) => p.onStart(config2)));
8729
+ await Promise.all(this.presenters.map((p2) => p2.onStart(config2)));
5835
8730
  }
5836
8731
  onLog(message) {
5837
- for (const p of this.presenters) {
5838
- p.onLog(message);
8732
+ for (const p2 of this.presenters) {
8733
+ p2.onLog(message);
5839
8734
  }
5840
8735
  }
5841
8736
  async onAssistantText(text) {
5842
- await Promise.all(this.presenters.map((p) => p.onAssistantText(text)));
8737
+ await Promise.all(this.presenters.map((p2) => p2.onAssistantText(text)));
5843
8738
  }
5844
8739
  async onThinking(text) {
5845
- await Promise.all(this.presenters.map((p) => p.onThinking(text)));
8740
+ await Promise.all(this.presenters.map((p2) => p2.onThinking(text)));
5846
8741
  }
5847
8742
  async onToolUse(tool, input, toolId) {
5848
8743
  await Promise.all(
5849
- this.presenters.map((p) => p.onToolUse(tool, input, toolId))
8744
+ this.presenters.map((p2) => p2.onToolUse(tool, input, toolId))
5850
8745
  );
5851
8746
  }
5852
8747
  async onTurnComplete(content) {
5853
- await Promise.all(this.presenters.map((p) => p.onTurnComplete(content)));
8748
+ await Promise.all(this.presenters.map((p2) => p2.onTurnComplete(content)));
5854
8749
  }
5855
8750
  async onError(error) {
5856
- await Promise.all(this.presenters.map((p) => p.onError(error)));
8751
+ await Promise.all(this.presenters.map((p2) => p2.onError(error)));
5857
8752
  }
5858
8753
  async onComplete(result) {
5859
- await Promise.all(this.presenters.map((p) => p.onComplete(result)));
8754
+ await Promise.all(this.presenters.map((p2) => p2.onComplete(result)));
5860
8755
  }
5861
8756
  };
5862
8757
 
5863
8758
  // src/presenters/console.ts
5864
- init_shared();
8759
+ init_shared_es();
5865
8760
  init_logger();
5866
8761
  import chalk3 from "chalk";
5867
8762
  import ora from "ora";
@@ -6014,7 +8909,7 @@ var ConsolePresenter = class {
6014
8909
  }
6015
8910
  onToolUse(tool, input, _toolId) {
6016
8911
  if (this.spinner) {
6017
- const displayName = getToolDisplayName(tool);
8912
+ const displayName = Ct(tool);
6018
8913
  this.spinner.text = `Using ${displayName}...`;
6019
8914
  }
6020
8915
  this.stopSpinner();
@@ -6289,7 +9184,7 @@ var WebPresenter = class {
6289
9184
  // src/modes/headless.ts
6290
9185
  init_api_client();
6291
9186
  init_logger();
6292
- var CLI_VERSION = "0.0.1";
9187
+ init_version();
6293
9188
  async function runAgent(config2) {
6294
9189
  logger.setVerbose(config2.verbose);
6295
9190
  logger.raw("");
@@ -6311,7 +9206,7 @@ async function runAgent(config2) {
6311
9206
  }
6312
9207
  logger.raw(metadataParts.join(chalk4.dim(" \u2022 ")));
6313
9208
  logger.divider();
6314
- const apiUrl = config2.supatestApiUrl || "https://api.supatest.ai";
9209
+ const apiUrl = config2.supatestApiUrl || "https://code-api.supatest.ai";
6315
9210
  const apiClient = new ApiClient(apiUrl, config2.supatestApiKey);
6316
9211
  let sessionId;
6317
9212
  let webUrl;
@@ -6484,14 +9379,15 @@ async function readStdin() {
6484
9379
 
6485
9380
  // src/index.ts
6486
9381
  init_token_storage();
9382
+ init_version();
6487
9383
  var program = new Command();
6488
9384
  program.name("supatest").description(
6489
9385
  "AI-powered task automation CLI for CI/CD - fix tests, lint issues, and more"
6490
- ).version("1.0.0").argument("[task]", "Task description or prompt for the AI agent").option("-l, --logs <file>", "Path to log file to analyze").option("--stdin", "Read logs from stdin").option("-C, --cwd <path>", "Working directory for the agent", process.cwd()).option(
9386
+ ).version(CLI_VERSION).argument("[task]", "Task description or prompt for the AI agent").option("-l, --logs <file>", "Path to log file to analyze").option("--stdin", "Read logs from stdin").option("-C, --cwd <path>", "Working directory for the agent", process.cwd()).option(
6491
9387
  "-m, --max-iterations <number>",
6492
9388
  "Maximum number of iterations",
6493
9389
  "100"
6494
- ).option("--supatest-api-key <key>", "Supatest API key (or use SUPATEST_API_KEY env)").option("--supatest-api-url <url>", "Supatest API URL (or use SUPATEST_API_URL env, defaults to https://api.supatest.ai)").option("--headless", "Run in headless mode (for CI/CD, minimal output)").option("--verbose", "Enable verbose logging").action(async (task, options) => {
9390
+ ).option("--supatest-api-key <key>", "Supatest API key (or use SUPATEST_API_KEY env)").option("--supatest-api-url <url>", "Supatest API URL (or use SUPATEST_API_URL env, defaults to https://code-api.supatest.ai)").option("--headless", "Run in headless mode (for CI/CD, minimal output)").option("--verbose", "Enable verbose logging").action(async (task, options) => {
6495
9391
  try {
6496
9392
  checkNodeVersion2();
6497
9393
  const isHeadlessMode = options.headless || process.stdin.isTTY === false;