dist-mcp / mcp / chatContextBridge.js
import crypto from "node:crypto";
import { setActiveChatContext } from "../core-bundle.mjs";
/**
* Binds core/tools.ts's module-global active chat context (used for pN/iN/vN
* resolution against chat_media_state.json) to the given scratchpad path.
* chatId is synthetic — only its numeric shape (/^\d+$/) matters, since that
* is the gate core/tools.ts checks before trusting workingDir over its
* LM-Studio "latest conversation.json" fallback, which the MCP path must
* never trigger. Returns the chatId so callers can also build http_url links
* via toHttpOriginalUrl() with the exact same value.
*/
export function bindChatContextToScratchpad(scratchpadPath) {
const chatId = String(Date.now());
setActiveChatContext({
chatId,
workingDir: scratchpadPath,
requestId: `bionic-${crypto.randomUUID()}`,
});
return chatId;
}
dist-mcp / mcp / chatContextBridge.js
import crypto from "node:crypto";
import { setActiveChatContext } from "../core-bundle.mjs";
/**
* Binds core/tools.ts's module-global active chat context (used for pN/iN/vN
* resolution against chat_media_state.json) to the given scratchpad path.
* chatId is synthetic — only its numeric shape (/^\d+$/) matters, since that
* is the gate core/tools.ts checks before trusting workingDir over its
* LM-Studio "latest conversation.json" fallback, which the MCP path must
* never trigger. Returns the chatId so callers can also build http_url links
* via toHttpOriginalUrl() with the exact same value.
*/
export function bindChatContextToScratchpad(scratchpadPath) {
const chatId = String(Date.now());
setActiveChatContext({
chatId,
workingDir: scratchpadPath,
requestId: `bionic-${crypto.randomUUID()}`,
});
return chatId;
}