@productbrain/mcp 0.0.1-beta.12515 → 0.0.1-beta.12537
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-3INI2PMG.js → chunk-ATVNWS2Z.js} +18 -45
- package/dist/chunk-ATVNWS2Z.js.map +1 -0
- package/dist/{chunk-7LFO7LXT.js → chunk-XKVKZIK5.js} +41 -46
- 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-J7FELU7P.js → setup-WME5Z3NU.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-3INI2PMG.js.map +0 -1
- package/dist/chunk-7LFO7LXT.js.map +0 -1
- /package/dist/{setup-J7FELU7P.js.map → setup-WME5Z3NU.js.map} +0 -0
|
@@ -444,7 +444,6 @@ var ROUTE_TYPE_ENTRIES = {
|
|
|
444
444
|
"chain.auditCollections": "query",
|
|
445
445
|
"chain.exportDefinitions": "query",
|
|
446
446
|
"chain.updateCollection": "mutation",
|
|
447
|
-
"chain.listEntries": "query",
|
|
448
447
|
"chain.listEntriesPaged": "query",
|
|
449
448
|
"chain.getEntry": "query",
|
|
450
449
|
"chain.preflightEntry": "query",
|
|
@@ -963,6 +962,15 @@ function authorityRecovery(refusal) {
|
|
|
963
962
|
}
|
|
964
963
|
return typeof refusal?.requiredAction === "string" ? refusal.requiredAction : void 0;
|
|
965
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
|
+
}
|
|
966
974
|
function acceptPromptOf(details) {
|
|
967
975
|
const found = details?.find((d) => typeof d?.acceptRefusal === "object");
|
|
968
976
|
return typeof found?.acceptRefusal?.prompt === "string" ? found.acceptRefusal.prompt : null;
|
|
@@ -993,24 +1001,6 @@ function roleRetireNextLine(details) {
|
|
|
993
1001
|
function acceptCall(entryId, replaces) {
|
|
994
1002
|
return `\`entries action=accept entryId="${entryId}"${replaces ? ` replaces="${replaces}" reason="<why>"` : ""}\``;
|
|
995
1003
|
}
|
|
996
|
-
var GateError = class extends Error {
|
|
997
|
-
constructor(message) {
|
|
998
|
-
super(message);
|
|
999
|
-
this.name = "GateError";
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
var BackendError = class extends Error {
|
|
1003
|
-
constructor(message) {
|
|
1004
|
-
super(message);
|
|
1005
|
-
this.name = "BackendError";
|
|
1006
|
-
}
|
|
1007
|
-
};
|
|
1008
|
-
var ValidationError = class extends Error {
|
|
1009
|
-
constructor(message) {
|
|
1010
|
-
super(message);
|
|
1011
|
-
this.name = "ValidationError";
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
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.";
|
|
1015
1005
|
var WORKSPACE_CLOSED = "WORKSPACE_CLOSED";
|
|
1016
1006
|
var GATE_PATTERNS = [
|
|
@@ -1042,20 +1032,6 @@ function orientationRefusal(err) {
|
|
|
1042
1032
|
}
|
|
1043
1033
|
function classifyError(err) {
|
|
1044
1034
|
const message = err instanceof Error ? err.message : String(err);
|
|
1045
|
-
if (err instanceof GateError) {
|
|
1046
|
-
return {
|
|
1047
|
-
code: "PERMISSION_DENIED",
|
|
1048
|
-
message,
|
|
1049
|
-
recovery: "Check permissions or use a readwrite API key.",
|
|
1050
|
-
availableActions: [{ tool: "workspace", description: "Check key scope", parameters: { action: "whoami" } }]
|
|
1051
|
-
};
|
|
1052
|
-
}
|
|
1053
|
-
if (err instanceof BackendError) {
|
|
1054
|
-
return { code: "BACKEND_ERROR", message, recovery: "Retry the operation or check backend health." };
|
|
1055
|
-
}
|
|
1056
|
-
if (err instanceof ValidationError) {
|
|
1057
|
-
return { code: "VALIDATION_ERROR", message };
|
|
1058
|
-
}
|
|
1059
1035
|
const mcpErr = asKernelCallError(err);
|
|
1060
1036
|
if (mcpErr) {
|
|
1061
1037
|
const { code: convexCode, fn, cleanMessage, missingRequiredFields, fieldErrors } = mcpErr;
|
|
@@ -1086,13 +1062,8 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1086
1062
|
};
|
|
1087
1063
|
}
|
|
1088
1064
|
if (convexCode?.startsWith("AUTHZ_")) {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
fn,
|
|
1092
|
-
message: cleanMessage,
|
|
1093
|
-
recovery: "Check permissions or use a readwrite API key.",
|
|
1094
|
-
availableActions: [{ tool: "workspace", description: "Check key scope", parameters: { action: "whoami" } }]
|
|
1095
|
-
};
|
|
1065
|
+
const recovery2 = authorityRecovery(mcpErr.details?.[0]);
|
|
1066
|
+
return { code: "PERMISSION_DENIED", fn, message: cleanMessage, ...recovery2 ? { recovery: recovery2 } : {} };
|
|
1096
1067
|
}
|
|
1097
1068
|
if (convexCode === "WORKSPACE_SLUG_TAKEN" || convexCode === "PERSON_ALREADY_EXISTS") {
|
|
1098
1069
|
return {
|
|
@@ -1110,11 +1081,12 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1110
1081
|
code: "rate-limited",
|
|
1111
1082
|
fn,
|
|
1112
1083
|
message: cleanMessage,
|
|
1113
|
-
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.`
|
|
1114
1085
|
};
|
|
1115
1086
|
}
|
|
1116
1087
|
const next = spineNextLine(mcpErr.details);
|
|
1117
|
-
const
|
|
1088
|
+
const authority = mcpErr.details?.[0];
|
|
1089
|
+
const recovery = next ?? ([authorityRecovery(authority), askNextLine(authority)].filter(Boolean).join("\n") || void 0);
|
|
1118
1090
|
const said = recovery && !next ? cleanMessage.replace(/\s*\n\s*/g, " ") : cleanMessage;
|
|
1119
1091
|
return { code: convexCode, fn, message: withAcceptPrompt(recovery ? `${said}${next ? "\n" : " "}${recovery}` : cleanMessage, mcpErr.details), ...recovery ? { recovery } : {} };
|
|
1120
1092
|
}
|
|
@@ -1128,7 +1100,7 @@ ${next2}` : cleanMessage, mcpErr.details),
|
|
|
1128
1100
|
return {
|
|
1129
1101
|
code: "GATEWAY_TIMEOUT",
|
|
1130
1102
|
message,
|
|
1131
|
-
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."
|
|
1132
1104
|
};
|
|
1133
1105
|
}
|
|
1134
1106
|
if (/network error|fetch failed|ECONNREFUSED|ETIMEDOUT/i.test(message)) {
|
|
@@ -1641,7 +1613,7 @@ function requireActiveSession() {
|
|
|
1641
1613
|
const lc = sessionLifecycle();
|
|
1642
1614
|
if (!lc.agentSessionId) {
|
|
1643
1615
|
throw new Error(
|
|
1644
|
-
"
|
|
1616
|
+
"Session required for this read."
|
|
1645
1617
|
);
|
|
1646
1618
|
}
|
|
1647
1619
|
}
|
|
@@ -1730,6 +1702,7 @@ export {
|
|
|
1730
1702
|
formatInviteSentence,
|
|
1731
1703
|
ORGANISATION_VALIDATION_REFUSALS,
|
|
1732
1704
|
authorityRecovery,
|
|
1705
|
+
returnedRefusal,
|
|
1733
1706
|
withAcceptPrompt,
|
|
1734
1707
|
acceptCall,
|
|
1735
1708
|
PASS_SESSION_ID,
|
|
@@ -1775,4 +1748,4 @@ export {
|
|
|
1775
1748
|
appUrl,
|
|
1776
1749
|
apiKeysUrl
|
|
1777
1750
|
};
|
|
1778
|
-
//# sourceMappingURL=chunk-
|
|
1751
|
+
//# sourceMappingURL=chunk-ATVNWS2Z.js.map
|