import type { EnvironmentId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";export interface McpProviderSessionConfig { readonly environmentId: EnvironmentId; readonly threadId: ThreadId; readonly providerSessionId: string; readonly providerInstanceId: ProviderInstanceId; readonly endpoint: string; readonly authorizationHeader: string; /** * Whether this credential includes the "preview" capability. Adapters read * it to keep developer instructions truthful: when the user withholds agent * browser access, the prompt must not advertise `preview_*` tools that every * call would reject. */ readonly browserToolsAvailable: boolean;}const sessionsByThread = new Map<ThreadId, McpProviderSessionConfig>();export function setMcpProviderSession(config: McpProviderSessionConfig): void { sessionsByThread.set(config.threadId, config);}export function readMcpProviderSession(threadId: ThreadId): McpProviderSessionConfig | undefined { return sessionsByThread.get(threadId);}export function clearMcpProviderSession(threadId: ThreadId): void { sessionsByThread.delete(threadId);}export function clearAllMcpProviderSessions(): void { sessionsByThread.clear();}
import type { EnvironmentId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
export interface McpProviderSessionConfig {
readonly environmentId: EnvironmentId;
readonly threadId: ThreadId;
readonly providerSessionId: string;
readonly providerInstanceId: ProviderInstanceId;
readonly endpoint: string;
readonly authorizationHeader: string;
/**
* Whether this credential includes the "preview" capability. Adapters read
* it to keep developer instructions truthful: when the user withholds agent
* browser access, the prompt must not advertise `preview_*` tools that every
* call would reject.
*/
readonly browserToolsAvailable: boolean;
}
const sessionsByThread = new Map<ThreadId, McpProviderSessionConfig>();
export function setMcpProviderSession(config: McpProviderSessionConfig): void {
sessionsByThread.set(config.threadId, config);
}
export function readMcpProviderSession(threadId: ThreadId): McpProviderSessionConfig | undefined {
return sessionsByThread.get(threadId);
}
export function clearMcpProviderSession(threadId: ThreadId): void {
sessionsByThread.delete(threadId);
}
export function clearAllMcpProviderSessions(): void {
sessionsByThread.clear();
}