@productbrain/mcp 0.0.1-beta.14272 → 0.0.1-beta.14280

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.
@@ -11,8 +11,10 @@ function runWithAuth(auth, fn) {
11
11
  function getRequestApiKey() {
12
12
  return requestStore.getStore()?.apiKey;
13
13
  }
14
- function getRequestMcpSessionId() {
15
- return requestStore.getStore()?.mcpSessionId;
14
+ var getRequestId = () => requestStore.getStore()?.requestId;
15
+ function getRequestLifecycle() {
16
+ const store = requestStore.getStore();
17
+ return store?.requestId ? store.lifecycle ??= { agentSessionId: null, sessionOriented: false } : void 0;
16
18
  }
17
19
  var SESSION_TTL_MS = 30 * 60 * 1e3;
18
20
  var MAX_KEYS = 100;
@@ -1299,8 +1301,8 @@ async function probeDeploymentCandidates(candidates, apiKey) {
1299
1301
  // src/client.ts
1300
1302
  var _conversationId;
1301
1303
  function getConversationId() {
1302
- const mcpSid = getRequestMcpSessionId();
1303
- if (mcpSid) return sessionLifecycle().conversationId ?? `mcp:${mcpSid}`;
1304
+ const requestId = getRequestId();
1305
+ if (requestId) return sessionLifecycle().conversationId ?? `mcp:${requestId}`;
1304
1306
  if (getRequestApiKey()) return null;
1305
1307
  if (_conversationId === void 0) _conversationId = resolveConversationId() ?? `mcp:${randomUUID2()}`;
1306
1308
  return _conversationId;
@@ -1378,24 +1380,10 @@ function getActiveApiKey() {
1378
1380
  if (!fromEnv) throw new Error(httpMode ? "No API key on this request. Send it as a Bearer token." : "No API key. Set PRODUCTBRAIN_API_KEY for this server.");
1379
1381
  return fromEnv;
1380
1382
  }
1381
- var _sessionLifecycleByStream = /* @__PURE__ */ new Map();
1382
- var MAX_SESSION_STREAMS = 500;
1383
1383
  function sessionLifecycle() {
1384
1384
  const seated = seatedSessionStore.getStore();
1385
1385
  if (seated) return seated;
1386
- const mcpSid = getRequestMcpSessionId();
1387
- if (!mcpSid) return state();
1388
- const key = `${cacheScope()}:${mcpSid}`;
1389
- let lc = _sessionLifecycleByStream.get(key);
1390
- if (!lc) {
1391
- if (_sessionLifecycleByStream.size >= MAX_SESSION_STREAMS) {
1392
- const oldest = _sessionLifecycleByStream.keys().next().value;
1393
- if (oldest !== void 0) _sessionLifecycleByStream.delete(oldest);
1394
- }
1395
- lc = { agentSessionId: null, sessionOriented: false };
1396
- _sessionLifecycleByStream.set(key, lc);
1397
- }
1398
- return lc;
1386
+ return getRequestLifecycle() ?? state();
1399
1387
  }
1400
1388
  function getAgentSessionId() {
1401
1389
  return sessionLifecycle().agentSessionId;
@@ -1412,7 +1400,6 @@ function getApiKeyScope() {
1412
1400
  var seatedSessionStore = new AsyncLocalStorage3();
1413
1401
  var getApiKeyId = () => state().apiKeyId;
1414
1402
  var runWithSeatedSession = (lc, fn) => seatedSessionStore.run(lc, fn);
1415
- var forgetStreamLifecycle = (keyHash, mcpSessionId) => _sessionLifecycleByStream.delete(`${keyHash}:${mcpSessionId}`);
1416
1403
  async function startAgentSession(role, team, clientName, preview = {}) {
1417
1404
  const workspaceId = await getWorkspaceId();
1418
1405
  const s = state();
@@ -1839,7 +1826,6 @@ export {
1839
1826
  getApiKeyScope,
1840
1827
  getApiKeyId,
1841
1828
  runWithSeatedSession,
1842
- forgetStreamLifecycle,
1843
1829
  startAgentSession,
1844
1830
  closeAgentSession,
1845
1831
  orphanAgentSession,
@@ -1859,4 +1845,4 @@ export {
1859
1845
  appUrl,
1860
1846
  apiKeysUrl
1861
1847
  };
1862
- //# sourceMappingURL=chunk-F4FYLPGO.js.map
1848
+ //# sourceMappingURL=chunk-RHPRF4OG.js.map