neuro-vault-mcp 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +55 -8
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14263,6 +14263,16 @@ function date4(params) {
|
|
|
14263
14263
|
config(en_default());
|
|
14264
14264
|
|
|
14265
14265
|
// src/lib/input-coercion.ts
|
|
14266
|
+
var CoerceError = class extends Error {
|
|
14267
|
+
fieldName;
|
|
14268
|
+
bareMessage;
|
|
14269
|
+
constructor(fieldName, bareMessage) {
|
|
14270
|
+
super(`${fieldName}: ${bareMessage}`);
|
|
14271
|
+
this.name = "CoerceError";
|
|
14272
|
+
this.fieldName = fieldName;
|
|
14273
|
+
this.bareMessage = bareMessage;
|
|
14274
|
+
}
|
|
14275
|
+
};
|
|
14266
14276
|
function unwrap(schema) {
|
|
14267
14277
|
let current = schema;
|
|
14268
14278
|
while (current instanceof external_exports.ZodOptional || current instanceof external_exports.ZodNullable || current instanceof external_exports.ZodDefault) {
|
|
@@ -14275,35 +14285,62 @@ function unwrap(schema) {
|
|
|
14275
14285
|
function isPlainObject2(value) {
|
|
14276
14286
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14277
14287
|
}
|
|
14278
|
-
function
|
|
14288
|
+
function describeJsonShape(parsed) {
|
|
14289
|
+
if (parsed === null) return "null";
|
|
14290
|
+
if (Array.isArray(parsed)) return "array";
|
|
14291
|
+
return typeof parsed;
|
|
14292
|
+
}
|
|
14293
|
+
function coerceFieldValue(schema, value, fieldName = "value") {
|
|
14279
14294
|
if (value === null || value === void 0) return value;
|
|
14280
14295
|
const inner = unwrap(schema);
|
|
14281
14296
|
if (inner instanceof external_exports.ZodNumber) {
|
|
14282
|
-
if (typeof value === "
|
|
14297
|
+
if (typeof value === "number") return value;
|
|
14298
|
+
if (typeof value === "string") {
|
|
14299
|
+
if (value.trim() === "") return value;
|
|
14283
14300
|
const n = Number(value);
|
|
14284
14301
|
if (Number.isFinite(n)) return n;
|
|
14302
|
+
throw new CoerceError(
|
|
14303
|
+
fieldName,
|
|
14304
|
+
`expected number or numeric string, got ${JSON.stringify(value)}`
|
|
14305
|
+
);
|
|
14285
14306
|
}
|
|
14286
14307
|
return value;
|
|
14287
14308
|
}
|
|
14288
14309
|
if (inner instanceof external_exports.ZodBoolean) {
|
|
14310
|
+
if (typeof value === "boolean") return value;
|
|
14289
14311
|
if (value === "true") return true;
|
|
14290
14312
|
if (value === "false") return false;
|
|
14313
|
+
if (typeof value === "string") {
|
|
14314
|
+
throw new CoerceError(
|
|
14315
|
+
fieldName,
|
|
14316
|
+
`expected boolean or "true"/"false", got ${JSON.stringify(value)}`
|
|
14317
|
+
);
|
|
14318
|
+
}
|
|
14291
14319
|
return value;
|
|
14292
14320
|
}
|
|
14293
14321
|
if (inner instanceof external_exports.ZodObject || inner instanceof external_exports.ZodRecord) {
|
|
14322
|
+
if (isPlainObject2(value)) return value;
|
|
14294
14323
|
if (typeof value === "string") {
|
|
14324
|
+
let parsed;
|
|
14295
14325
|
try {
|
|
14296
|
-
|
|
14297
|
-
if (isPlainObject2(parsed)) return parsed;
|
|
14326
|
+
parsed = JSON.parse(value);
|
|
14298
14327
|
} catch {
|
|
14328
|
+
throw new CoerceError(
|
|
14329
|
+
fieldName,
|
|
14330
|
+
`expected object or JSON-string of one, failed to parse: ${JSON.stringify(value)}`
|
|
14331
|
+
);
|
|
14299
14332
|
}
|
|
14300
|
-
return
|
|
14333
|
+
if (isPlainObject2(parsed)) return parsed;
|
|
14334
|
+
throw new CoerceError(
|
|
14335
|
+
fieldName,
|
|
14336
|
+
`expected object, parsed JSON resolved to ${describeJsonShape(parsed)}`
|
|
14337
|
+
);
|
|
14301
14338
|
}
|
|
14302
14339
|
return value;
|
|
14303
14340
|
}
|
|
14304
14341
|
return value;
|
|
14305
14342
|
}
|
|
14306
|
-
function wrapField(field) {
|
|
14343
|
+
function wrapField(field, fieldName) {
|
|
14307
14344
|
let inner = field;
|
|
14308
14345
|
let isOptional = false;
|
|
14309
14346
|
while (inner instanceof external_exports.ZodOptional || inner instanceof external_exports.ZodNullable || inner instanceof external_exports.ZodDefault) {
|
|
@@ -14312,7 +14349,17 @@ function wrapField(field) {
|
|
|
14312
14349
|
if (!next) break;
|
|
14313
14350
|
inner = next;
|
|
14314
14351
|
}
|
|
14315
|
-
const wrapped = external_exports.preprocess((v) =>
|
|
14352
|
+
const wrapped = external_exports.preprocess((v, ctx) => {
|
|
14353
|
+
try {
|
|
14354
|
+
return coerceFieldValue(inner, v, fieldName);
|
|
14355
|
+
} catch (err) {
|
|
14356
|
+
if (err instanceof CoerceError) {
|
|
14357
|
+
ctx.addIssue({ code: "custom", message: err.bareMessage });
|
|
14358
|
+
return external_exports.NEVER;
|
|
14359
|
+
}
|
|
14360
|
+
throw err;
|
|
14361
|
+
}
|
|
14362
|
+
}, inner);
|
|
14316
14363
|
return isOptional ? wrapped.optional() : wrapped;
|
|
14317
14364
|
}
|
|
14318
14365
|
function wrapSchemaWithCoercion(schema) {
|
|
@@ -14320,7 +14367,7 @@ function wrapSchemaWithCoercion(schema) {
|
|
|
14320
14367
|
const shape = schema.shape;
|
|
14321
14368
|
const newShape = {};
|
|
14322
14369
|
for (const [key, field] of Object.entries(shape)) {
|
|
14323
|
-
newShape[key] = wrapField(field);
|
|
14370
|
+
newShape[key] = wrapField(field, key);
|
|
14324
14371
|
}
|
|
14325
14372
|
return external_exports.object(newShape);
|
|
14326
14373
|
}
|