@productbrain/mcp 0.0.1-beta.189 → 0.0.1-beta.190
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.
|
@@ -741,7 +741,7 @@ async function resolveCollection(params) {
|
|
|
741
741
|
import { z } from "zod";
|
|
742
742
|
|
|
743
743
|
// src/errors.ts
|
|
744
|
-
var MCP_CALL_ERROR_RE = /^MCP call "[^"]+" failed \(\d+\): (.+)$/s;
|
|
744
|
+
var MCP_CALL_ERROR_RE = /^MCP call "([^"]+)" failed \(\d+\): (.+)$/s;
|
|
745
745
|
function asKernelCallError(err) {
|
|
746
746
|
if (err instanceof Error && typeof err.code === "string") {
|
|
747
747
|
const code = err.code;
|
|
@@ -750,7 +750,9 @@ function asKernelCallError(err) {
|
|
|
750
750
|
const e = err;
|
|
751
751
|
return {
|
|
752
752
|
code,
|
|
753
|
-
|
|
753
|
+
fn: match[1],
|
|
754
|
+
cleanMessage: match[2],
|
|
755
|
+
// NOTE: match[2] not match[1] — group 1 is now fn scope (DEC-798)
|
|
754
756
|
missingRequiredFields: Array.isArray(e.missingRequiredFields) ? e.missingRequiredFields : void 0,
|
|
755
757
|
fieldErrors: Array.isArray(e.fieldErrors) ? e.fieldErrors : void 0
|
|
756
758
|
};
|
|
@@ -820,11 +822,12 @@ function classifyError(err) {
|
|
|
820
822
|
}
|
|
821
823
|
const mcpErr = asKernelCallError(err);
|
|
822
824
|
if (mcpErr) {
|
|
823
|
-
const { code: convexCode, cleanMessage, missingRequiredFields, fieldErrors } = mcpErr;
|
|
825
|
+
const { code: convexCode, fn, cleanMessage, missingRequiredFields, fieldErrors } = mcpErr;
|
|
824
826
|
if (convexCode === "VALIDATION_FAILED") {
|
|
825
827
|
const hasDiagnostics = missingRequiredFields?.length || fieldErrors?.length;
|
|
826
828
|
return {
|
|
827
829
|
code: "VALIDATION_ERROR",
|
|
830
|
+
fn,
|
|
828
831
|
message: cleanMessage,
|
|
829
832
|
...hasDiagnostics ? {
|
|
830
833
|
diagnostics: {
|
|
@@ -837,6 +840,7 @@ function classifyError(err) {
|
|
|
837
840
|
if (convexCode === "NOT_FOUND") {
|
|
838
841
|
return {
|
|
839
842
|
code: "NOT_FOUND",
|
|
843
|
+
fn,
|
|
840
844
|
message: cleanMessage,
|
|
841
845
|
recovery: "Use entries action=search to find the correct ID.",
|
|
842
846
|
availableActions: [{ tool: "entries", description: "Search entries", parameters: { action: "search" } }]
|
|
@@ -845,11 +849,13 @@ function classifyError(err) {
|
|
|
845
849
|
if (convexCode === "WORKSPACE_SLUG_TAKEN" || convexCode === "PERSON_ALREADY_EXISTS") {
|
|
846
850
|
return {
|
|
847
851
|
code: "DUPLICATE",
|
|
852
|
+
fn,
|
|
848
853
|
message: cleanMessage,
|
|
849
854
|
recovery: "Use entries action=get to inspect the existing entry.",
|
|
850
855
|
availableActions: [{ tool: "entries", description: "Get entry", parameters: { action: "get" } }]
|
|
851
856
|
};
|
|
852
857
|
}
|
|
858
|
+
return { code: convexCode, fn, message: cleanMessage };
|
|
853
859
|
}
|
|
854
860
|
for (const { pattern, code, recovery, action } of GATE_PATTERNS) {
|
|
855
861
|
if (pattern.test(message)) {
|
|
@@ -859,25 +865,6 @@ function classifyError(err) {
|
|
|
859
865
|
if (/network error|fetch failed|ECONNREFUSED|ETIMEDOUT/i.test(message)) {
|
|
860
866
|
return { code: "BACKEND_UNAVAILABLE", message, recovery: "Retry in a few seconds." };
|
|
861
867
|
}
|
|
862
|
-
if (/not found/i.test(message)) {
|
|
863
|
-
return {
|
|
864
|
-
code: "NOT_FOUND",
|
|
865
|
-
message,
|
|
866
|
-
recovery: "Use entries action=search to find the correct ID.",
|
|
867
|
-
availableActions: [{ tool: "entries", description: "Search entries", parameters: { action: "search" } }]
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
if (/duplicate|already exists/i.test(message)) {
|
|
871
|
-
return {
|
|
872
|
-
code: "DUPLICATE",
|
|
873
|
-
message,
|
|
874
|
-
recovery: "Use entries action=get to inspect the existing entry.",
|
|
875
|
-
availableActions: [{ tool: "entries", description: "Get entry", parameters: { action: "get" } }]
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
if (/invalid|validation|required field/i.test(message)) {
|
|
879
|
-
return { code: "VALIDATION_ERROR", message };
|
|
880
|
-
}
|
|
881
868
|
return { code: "INTERNAL_ERROR", message: message || "An unexpected error occurred." };
|
|
882
869
|
}
|
|
883
870
|
|
|
@@ -988,7 +975,10 @@ function thinWrapper(handler) {
|
|
|
988
975
|
_meta: { durationMs }
|
|
989
976
|
};
|
|
990
977
|
return {
|
|
991
|
-
content: [{
|
|
978
|
+
content: [{
|
|
979
|
+
type: "text",
|
|
980
|
+
text: classified.fn ? `[${classified.code}/${classified.fn}] ${classified.message}` : `[${classified.code}] ${classified.message}`
|
|
981
|
+
}],
|
|
992
982
|
structuredContent: envelope,
|
|
993
983
|
isError: true
|
|
994
984
|
};
|
|
@@ -15733,4 +15723,4 @@ export {
|
|
|
15733
15723
|
createProductBrainServer,
|
|
15734
15724
|
initFeatureFlags
|
|
15735
15725
|
};
|
|
15736
|
-
//# sourceMappingURL=chunk-
|
|
15726
|
+
//# sourceMappingURL=chunk-ZF6N62QQ.js.map
|