ponch-mcp-server 1.0.74 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +63 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6401,6 +6401,19 @@ function wrapWithContract(contract, helper, options = {}) {
|
|
|
6401
6401
|
}
|
|
6402
6402
|
const parseResult = contract.paramsSchema.safeParse(input);
|
|
6403
6403
|
if (!parseResult.success) {
|
|
6404
|
+
const validationErrors = parseResult.error.issues.map((i) => {
|
|
6405
|
+
const issue = i;
|
|
6406
|
+
return {
|
|
6407
|
+
path: i.path,
|
|
6408
|
+
code: i.code,
|
|
6409
|
+
message: i.message,
|
|
6410
|
+
received: issue.received,
|
|
6411
|
+
expected: issue.expected
|
|
6412
|
+
};
|
|
6413
|
+
});
|
|
6414
|
+
const camposFallidos = validationErrors.map((v) => v.path.join(".")).filter(Boolean);
|
|
6415
|
+
const baseMsg = getWrapperMessage("input_invalido", locale);
|
|
6416
|
+
const text = camposFallidos.length ? locale === "en" ? `${baseMsg} Issues with: ${camposFallidos.join(", ")}.` : `${baseMsg} Hubo problemas con: ${camposFallidos.join(", ")}.` : baseMsg;
|
|
6404
6417
|
await writeAuditLog({
|
|
6405
6418
|
tenantId: ctx.tenantId,
|
|
6406
6419
|
brandId: ctx.brandId ?? null,
|
|
@@ -6409,13 +6422,14 @@ function wrapWithContract(contract, helper, options = {}) {
|
|
|
6409
6422
|
motivo: "Input inv\xE1lido \u2014 Zod parse failed",
|
|
6410
6423
|
conversacionId: ctx.conversacionId ?? null,
|
|
6411
6424
|
status: "error",
|
|
6412
|
-
errorMessage: `Input shape inv\xE1lido: ${
|
|
6425
|
+
errorMessage: `Input shape inv\xE1lido: ${validationErrors.map((v) => `${v.path.join(".")}: ${v.code} (${v.message})`).join("; ")}`,
|
|
6413
6426
|
durationMs: Date.now() - startMs
|
|
6414
6427
|
});
|
|
6415
6428
|
return {
|
|
6416
|
-
text
|
|
6429
|
+
text,
|
|
6417
6430
|
structuredOutput: null,
|
|
6418
|
-
state: "error"
|
|
6431
|
+
state: "error",
|
|
6432
|
+
validationErrors
|
|
6419
6433
|
};
|
|
6420
6434
|
}
|
|
6421
6435
|
const parsedInput = parseResult.data;
|
|
@@ -6462,7 +6476,6 @@ function wrapWithContract(contract, helper, options = {}) {
|
|
|
6462
6476
|
let output;
|
|
6463
6477
|
try {
|
|
6464
6478
|
output = await helper(parsedInput);
|
|
6465
|
-
contract.outputSchema.parse(output);
|
|
6466
6479
|
} catch (err) {
|
|
6467
6480
|
await writeAuditLog({
|
|
6468
6481
|
tenantId: ctx.tenantId,
|
|
@@ -6481,6 +6494,36 @@ function wrapWithContract(contract, helper, options = {}) {
|
|
|
6481
6494
|
state: "error"
|
|
6482
6495
|
};
|
|
6483
6496
|
}
|
|
6497
|
+
const outputParse = contract.outputSchema.safeParse(output);
|
|
6498
|
+
if (!outputParse.success) {
|
|
6499
|
+
const validationErrors = outputParse.error.issues.map((i) => {
|
|
6500
|
+
const issue = i;
|
|
6501
|
+
return {
|
|
6502
|
+
path: i.path,
|
|
6503
|
+
code: i.code,
|
|
6504
|
+
message: i.message,
|
|
6505
|
+
received: issue.received,
|
|
6506
|
+
expected: issue.expected
|
|
6507
|
+
};
|
|
6508
|
+
});
|
|
6509
|
+
await writeAuditLog({
|
|
6510
|
+
tenantId: ctx.tenantId,
|
|
6511
|
+
brandId: ctx.brandId ?? null,
|
|
6512
|
+
actor: { type: "martin", uid: ctx.user.uid, nombre: ctx.user.nombre },
|
|
6513
|
+
action: contract.auditAction,
|
|
6514
|
+
motivo: `Output del helper inv\xE1lido \u2014 bug de "${contract.name}"`,
|
|
6515
|
+
conversacionId: ctx.conversacionId ?? null,
|
|
6516
|
+
status: "error",
|
|
6517
|
+
errorMessage: `Output shape inv\xE1lido: ${validationErrors.map((v) => `${v.path.join(".")}: ${v.code} (${v.message})`).join("; ")}`,
|
|
6518
|
+
durationMs: Date.now() - startMs
|
|
6519
|
+
});
|
|
6520
|
+
return {
|
|
6521
|
+
text: martinSafeError(new Error("output_invalid"), locale),
|
|
6522
|
+
structuredOutput: null,
|
|
6523
|
+
state: "error",
|
|
6524
|
+
validationErrors
|
|
6525
|
+
};
|
|
6526
|
+
}
|
|
6484
6527
|
const maybeDisabled = output;
|
|
6485
6528
|
if (maybeDisabled.disabled === true) {
|
|
6486
6529
|
const code = maybeDisabled.code;
|
|
@@ -7838,7 +7881,14 @@ function registerMarketingTools(server, session) {
|
|
|
7838
7881
|
input: { tenantId, brandId, plan },
|
|
7839
7882
|
ctx
|
|
7840
7883
|
});
|
|
7841
|
-
const payload = result.state === "success" ? result.structuredOutput : {
|
|
7884
|
+
const payload = result.state === "success" ? result.structuredOutput : {
|
|
7885
|
+
ok: false,
|
|
7886
|
+
state: result.state,
|
|
7887
|
+
mensaje: result.text,
|
|
7888
|
+
// HITO 6 A6.7: incluir detalles Zod estructurados para que
|
|
7889
|
+
// Claude (LLM) pueda auto-recuperarse en el siguiente intento.
|
|
7890
|
+
...result.validationErrors && result.validationErrors.length > 0 ? { validationErrors: result.validationErrors } : {}
|
|
7891
|
+
};
|
|
7842
7892
|
return { content: [{ type: "text", text: JSON.stringify(payload) }] };
|
|
7843
7893
|
}
|
|
7844
7894
|
);
|
|
@@ -8046,7 +8096,14 @@ Si pasas campos dentro de "datos", se hace merge con los datos existentes (no lo
|
|
|
8046
8096
|
input: { tenantId, brandId, mes, semana, slotIndex, cambios, accionContenidoExistente },
|
|
8047
8097
|
ctx
|
|
8048
8098
|
});
|
|
8049
|
-
const payload = result.state === "success" ? result.structuredOutput : {
|
|
8099
|
+
const payload = result.state === "success" ? result.structuredOutput : {
|
|
8100
|
+
ok: false,
|
|
8101
|
+
state: result.state,
|
|
8102
|
+
mensaje: result.text,
|
|
8103
|
+
// HITO 6 A6.7: incluir detalles Zod estructurados para que
|
|
8104
|
+
// Claude (LLM) pueda auto-recuperarse en el siguiente intento.
|
|
8105
|
+
...result.validationErrors && result.validationErrors.length > 0 ? { validationErrors: result.validationErrors } : {}
|
|
8106
|
+
};
|
|
8050
8107
|
return { content: [{ type: "text", text: JSON.stringify(payload) }] };
|
|
8051
8108
|
}
|
|
8052
8109
|
);
|