@productbrain/mcp 0.0.1-beta.12525 → 0.0.1-beta.12545
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/{chunk-AZT7HBBK.js → chunk-ATVNWS2Z.js} +18 -44
- package/dist/{chunk-AZT7HBBK.js.map → chunk-ATVNWS2Z.js.map} +1 -1
- package/dist/{chunk-HVA7TM6A.js → chunk-XKVKZIK5.js} +41 -45
- package/dist/chunk-XKVKZIK5.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/http.js +2 -2
- package/dist/index.js +2 -2
- package/dist/{setup-2HQQLBEZ.js → setup-WME5Z3NU.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-HVA7TM6A.js.map +0 -1
- /package/dist/{setup-2HQQLBEZ.js.map → setup-WME5Z3NU.js.map} +0 -0
|
@@ -962,6 +962,15 @@ function authorityRecovery(refusal) {
|
|
|
962
962
|
}
|
|
963
963
|
return typeof refusal?.requiredAction === "string" ? refusal.requiredAction : void 0;
|
|
964
964
|
}
|
|
965
|
+
function askNextLine(refusal) {
|
|
966
|
+
const seat = refusal?.routeTarget;
|
|
967
|
+
if (typeof seat?.roleEntryId !== "string" || refusal?.wayIn !== void 0 || refusal?.boundKey === true || refusal?.heldByAgent === true) return null;
|
|
968
|
+
return 'Next: `question action=create text="<your ask>"`.';
|
|
969
|
+
}
|
|
970
|
+
function returnedRefusal(refusal, fallback, clean = (s) => s) {
|
|
971
|
+
const fix = authorityRecovery(refusal) ?? (typeof refusal.requiredAction === "string" ? refusal.requiredAction : fallback);
|
|
972
|
+
return { message: `Refused: ${clean(refusal.reason)}`, recovery: [fix, askNextLine(refusal)].filter(Boolean).join("\n") };
|
|
973
|
+
}
|
|
965
974
|
function acceptPromptOf(details) {
|
|
966
975
|
const found = details?.find((d) => typeof d?.acceptRefusal === "object");
|
|
967
976
|
return typeof found?.acceptRefusal?.prompt === "string" ? found.acceptRefusal.prompt : null;
|
|
@@ -992,24 +1001,6 @@ function roleRetireNextLine(details) {
|
|
|
992
1001
|
function acceptCall(entryId, replaces) {
|
|
993
1002
|
return `\`entries action=accept entryId="${entryId}"${replaces ? ` replaces="${replaces}" reason="<why>"` : ""}\``;
|
|
994
1003
|
}
|
|
995
|
-
var GateError = class extends Error {
|
|
996
|
-
constructor(message) {
|
|
997
|
-
super(message);
|
|
998
|
-
this.name = "GateError";
|
|
999
|
-
}
|
|
1000
|
-
};
|
|
1001
|
-
var BackendError = class extends Error {
|
|
1002
|
-
constructor(message) {
|
|
1003
|
-
super(message);
|
|
1004
|
-
this.name = "BackendError";
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
var ValidationError = class extends Error {
|
|
1008
|
-
constructor(message) {
|
|
1009
|
-
super(message);
|
|
1010
|
-
this.name = "ValidationError";
|
|
1011
|
-
}
|
|
1012
|
-
};
|
|
1013
1004
|
var PASS_SESSION_ID = "Call `session action=start`, then pass the sessionId it returns as `sessionId` on every write: the connection does not remember your session between calls.";
|
|
1014
1005
|
var WORKSPACE_CLOSED = "WORKSPACE_CLOSED";
|
|
1015
1006
|
var GATE_PATTERNS = [
|
|
@@ -1041,20 +1032,6 @@ function orientationRefusal(err) {
|
|
|
1041
1032
|
}
|
|
1042
1033
|
function classifyError(err) {
|
|
1043
1034
|
const message = err instanceof Error ? err.message : String(err);
|
|
1044
|
-
if (err instanceof GateError) {
|
|
1045
|
-
return {
|
|
1046
|
-
code: "PERMISSION_DENIED",
|
|
1047
|
-
message,
|
|
1048
|
-
recovery: "Check permissions or use a readwrite API key.",
|
|
1049
|
-
availableActions: [{ tool: "workspace", description: "Check key scope", parameters: { action: "whoami" } }]
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
if (err instanceof BackendError) {
|
|
1053
|
-
return { code: "BACKEND_ERROR", message, recovery: "Retry the operation or check backend health." };
|
|
1054
|
-
}
|
|
1055
|
-
if (err instanceof ValidationError) {
|
|
1056
|
-
return { code: "VALIDATION_ERROR", message };
|
|
1057
|
-
}
|
|
1058
1035
|
const mcpErr = asKernelCallError(err);
|
|
1059
1036
|
if (mcpErr) {
|
|
1060
1037
|
const { code: convexCode, fn, cleanMessage, missingRequiredFields, fieldErrors } = mcpErr;
|
|
@@ -1085,13 +1062,8 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1085
1062
|
};
|
|
1086
1063
|
}
|
|
1087
1064
|
if (convexCode?.startsWith("AUTHZ_")) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
fn,
|
|
1091
|
-
message: cleanMessage,
|
|
1092
|
-
recovery: "Check permissions or use a readwrite API key.",
|
|
1093
|
-
availableActions: [{ tool: "workspace", description: "Check key scope", parameters: { action: "whoami" } }]
|
|
1094
|
-
};
|
|
1065
|
+
const recovery2 = authorityRecovery(mcpErr.details?.[0]);
|
|
1066
|
+
return { code: "PERMISSION_DENIED", fn, message: cleanMessage, ...recovery2 ? { recovery: recovery2 } : {} };
|
|
1095
1067
|
}
|
|
1096
1068
|
if (convexCode === "WORKSPACE_SLUG_TAKEN" || convexCode === "PERSON_ALREADY_EXISTS") {
|
|
1097
1069
|
return {
|
|
@@ -1109,11 +1081,12 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1109
1081
|
code: "rate-limited",
|
|
1110
1082
|
fn,
|
|
1111
1083
|
message: cleanMessage,
|
|
1112
|
-
recovery: `Rate limit hit for this API key. ${wait}, then retry the same call unchanged
|
|
1084
|
+
recovery: `Rate limit hit for this API key. ${wait}, then retry the same call unchanged; it is safe to retry.`
|
|
1113
1085
|
};
|
|
1114
1086
|
}
|
|
1115
1087
|
const next = spineNextLine(mcpErr.details);
|
|
1116
|
-
const
|
|
1088
|
+
const authority = mcpErr.details?.[0];
|
|
1089
|
+
const recovery = next ?? ([authorityRecovery(authority), askNextLine(authority)].filter(Boolean).join("\n") || void 0);
|
|
1117
1090
|
const said = recovery && !next ? cleanMessage.replace(/\s*\n\s*/g, " ") : cleanMessage;
|
|
1118
1091
|
return { code: convexCode, fn, message: withAcceptPrompt(recovery ? `${said}${next ? "\n" : " "}${recovery}` : cleanMessage, mcpErr.details), ...recovery ? { recovery } : {} };
|
|
1119
1092
|
}
|
|
@@ -1127,7 +1100,7 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1127
1100
|
return {
|
|
1128
1101
|
code: "GATEWAY_TIMEOUT",
|
|
1129
1102
|
message,
|
|
1130
|
-
recovery: mayHaveLanded ? "The server was reachable and may have completed this write
|
|
1103
|
+
recovery: mayHaveLanded ? "The server was reachable and may have completed this write. Verify before retrying: a blind retry can duplicate it." : "The server was reachable but did not answer in time. Nothing was written, so it is safe to retry."
|
|
1131
1104
|
};
|
|
1132
1105
|
}
|
|
1133
1106
|
if (/network error|fetch failed|ECONNREFUSED|ETIMEDOUT/i.test(message)) {
|
|
@@ -1640,7 +1613,7 @@ function requireActiveSession() {
|
|
|
1640
1613
|
const lc = sessionLifecycle();
|
|
1641
1614
|
if (!lc.agentSessionId) {
|
|
1642
1615
|
throw new Error(
|
|
1643
|
-
"
|
|
1616
|
+
"Session required for this read."
|
|
1644
1617
|
);
|
|
1645
1618
|
}
|
|
1646
1619
|
}
|
|
@@ -1729,6 +1702,7 @@ export {
|
|
|
1729
1702
|
formatInviteSentence,
|
|
1730
1703
|
ORGANISATION_VALIDATION_REFUSALS,
|
|
1731
1704
|
authorityRecovery,
|
|
1705
|
+
returnedRefusal,
|
|
1732
1706
|
withAcceptPrompt,
|
|
1733
1707
|
acceptCall,
|
|
1734
1708
|
PASS_SESSION_ID,
|
|
@@ -1774,4 +1748,4 @@ export {
|
|
|
1774
1748
|
appUrl,
|
|
1775
1749
|
apiKeysUrl
|
|
1776
1750
|
};
|
|
1777
|
-
//# sourceMappingURL=chunk-
|
|
1751
|
+
//# sourceMappingURL=chunk-ATVNWS2Z.js.map
|