@productbrain/mcp 0.0.1-beta.12332 → 0.0.1-beta.12342
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-MAMOO7UB.js → chunk-C4TYYBLL.js} +2 -28
- package/dist/chunk-C4TYYBLL.js.map +1 -0
- package/dist/{chunk-2IAKR6T4.js → chunk-QXBKHFWZ.js} +21 -19
- package/dist/{chunk-2IAKR6T4.js.map → chunk-QXBKHFWZ.js.map} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/http.js +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{setup-HG2UANX5.js → setup-RMEYY262.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-MAMOO7UB.js.map +0 -1
- /package/dist/{setup-HG2UANX5.js.map → setup-RMEYY262.js.map} +0 -0
|
@@ -40,39 +40,34 @@ import {
|
|
|
40
40
|
runWithToolContext,
|
|
41
41
|
setSessionOriented,
|
|
42
42
|
startAgentSession
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-C4TYYBLL.js";
|
|
44
44
|
|
|
45
45
|
// src/server.ts
|
|
46
46
|
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
47
47
|
import { z as z36 } from "zod/v3";
|
|
48
48
|
|
|
49
|
-
// src/lib/mcpGatewayClientMessages.ts
|
|
50
|
-
function agentSessionNotActiveMessage(status2) {
|
|
51
|
-
return `Agent session is ${status2}, not active`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
49
|
// src/callerSession.ts
|
|
50
|
+
var RENEWABLE_CODES = /* @__PURE__ */ new Set(["SESSION_ORPHANED", "SESSION_EXPIRED"]);
|
|
51
|
+
var ENDED_SESSION_CODES = /* @__PURE__ */ new Set([...RENEWABLE_CODES, "SESSION_CLOSED"]);
|
|
55
52
|
async function validateCallerSession(sessionId) {
|
|
56
53
|
const workspaceId = await getWorkspaceId();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (session.status !== "active" && session.status !== "orphaned" && session.status !== "expired") {
|
|
63
|
-
throw new KernelCallError(agentSessionNotActiveMessage(session.status), 400);
|
|
54
|
+
try {
|
|
55
|
+
const session = await kernelCall("agent.validateSession", { sessionId, workspaceId, requireActive: true });
|
|
56
|
+
return { lc: { agentSessionId: session._id, sessionOriented: session.oriented, conversationId: session.conversationId ?? null }, renewedFrom: null };
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if (!(err instanceof KernelCallError) || !err.code || !RENEWABLE_CODES.has(err.code)) throw err;
|
|
64
59
|
}
|
|
65
60
|
const apiKeyId = getApiKeyId();
|
|
66
61
|
if (!apiKeyId) throw new Error("Cannot renew session: API key ID not resolved. Ensure workspace resolution completed.");
|
|
67
62
|
const renewed = await kernelCall("agent.resumeSession", {
|
|
68
63
|
workspaceId,
|
|
69
64
|
apiKeyId,
|
|
70
|
-
previousSessionId:
|
|
65
|
+
previousSessionId: sessionId,
|
|
71
66
|
clientKind: "mcp"
|
|
72
67
|
});
|
|
73
|
-
return { lc: { agentSessionId: renewed.sessionId, sessionOriented: false,
|
|
68
|
+
return { lc: { agentSessionId: renewed.sessionId, sessionOriented: false, conversationId: renewed.conversationId ?? null }, renewedFrom: sessionId };
|
|
74
69
|
}
|
|
75
|
-
var sessionRenewedNotice = (
|
|
70
|
+
var sessionRenewedNotice = (oldId, newId) => `Your session [${oldId}] had closed; a new one was started and linked. Pass sessionId="${newId}" on your next calls.`;
|
|
76
71
|
|
|
77
72
|
// src/envelope.ts
|
|
78
73
|
import { z } from "zod/v3";
|
|
@@ -11887,7 +11882,7 @@ function acceptSessionIdOnEveryTool(server) {
|
|
|
11887
11882
|
if ("refused" in seated) return seated.refused;
|
|
11888
11883
|
const result2 = await runWithSeatedSession(seated.lc, () => cb(args, extra));
|
|
11889
11884
|
if (!seated.renewedFrom) return result2;
|
|
11890
|
-
return { ...result2, content: [{ type: "text", text: sessionRenewedNotice(seated.lc.agentSessionId) }, ...result2.content] };
|
|
11885
|
+
return { ...result2, content: [{ type: "text", text: sessionRenewedNotice(seated.renewedFrom, seated.lc.agentSessionId) }, ...result2.content] };
|
|
11891
11886
|
}
|
|
11892
11887
|
return cb(args, extra);
|
|
11893
11888
|
})
|
|
@@ -11899,7 +11894,14 @@ async function validateOrRefuse(sessionId) {
|
|
|
11899
11894
|
} catch (err) {
|
|
11900
11895
|
const { code, message, recovery } = classifyError(err);
|
|
11901
11896
|
const reason = message.split("\n")[0].replace(/\.?\s*$/, ".");
|
|
11902
|
-
const
|
|
11897
|
+
const ended = err instanceof KernelCallError && err.code !== void 0 && ENDED_SESSION_CODES.has(err.code);
|
|
11898
|
+
const result2 = ended ? failureResult(
|
|
11899
|
+
`[${code}] ${message} ${PASS_SESSION_ID}`,
|
|
11900
|
+
code,
|
|
11901
|
+
message,
|
|
11902
|
+
PASS_SESSION_ID,
|
|
11903
|
+
[{ tool: "session", description: "Start a session", parameters: { action: "start" } }]
|
|
11904
|
+
) : err instanceof KernelCallError && err.status >= 400 && err.status < 500 && err.status !== 429 && err.code !== WORKSPACE_CLOSED ? failureResult(
|
|
11903
11905
|
`[SESSION_INVALID] The sessionId you passed (${sessionId}) was refused: ${reason} ${PASS_SESSION_ID}`,
|
|
11904
11906
|
"SESSION_INVALID",
|
|
11905
11907
|
`sessionId refused: ${reason}`,
|
|
@@ -11941,4 +11943,4 @@ export {
|
|
|
11941
11943
|
SERVER_VERSION,
|
|
11942
11944
|
createProductBrainServer
|
|
11943
11945
|
};
|
|
11944
|
-
//# sourceMappingURL=chunk-
|
|
11946
|
+
//# sourceMappingURL=chunk-QXBKHFWZ.js.map
|