src / mcp / chatContextBridge.ts
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
* 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.
*/
export function bindChatContextToScratchpad(scratchpadPath: string): void {
setActiveChatContext({
chatId: String(Date.now()),
workingDir: scratchpadPath,
requestId: `bionic-${crypto.randomUUID()}`,
});
}
src / mcp / chatContextBridge.ts
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
* 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.
*/
export function bindChatContextToScratchpad(scratchpadPath: string): void {
setActiveChatContext({
chatId: String(Date.now()),
workingDir: scratchpadPath,
requestId: `bionic-${crypto.randomUUID()}`,
});
}