Open History to see the last commit
1import type { EnvironmentId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
2
3export interface McpProviderSessionConfig {
4 readonly environmentId: EnvironmentId;
5 readonly threadId: ThreadId;
6 readonly providerSessionId: string;
7 readonly providerInstanceId: ProviderInstanceId;
8 readonly endpoint: string;
9 readonly authorizationHeader: string;
10 /**
11 * Whether this credential includes the "preview" capability. Adapters read
12 * it to keep developer instructions truthful: when the user withholds agent
13 * browser access, the prompt must not advertise `preview_*` tools that every
14 * call would reject.
15 */
16 readonly browserToolsAvailable: boolean;
17}
18
19const sessionsByThread = new Map<ThreadId, McpProviderSessionConfig>();
20
21export function setMcpProviderSession(config: McpProviderSessionConfig): void {
22 sessionsByThread.set(config.threadId, config);
23}
24
25export function readMcpProviderSession(threadId: ThreadId): McpProviderSessionConfig | undefined {
26 return sessionsByThread.get(threadId);
27}
28
29export function clearMcpProviderSession(threadId: ThreadId): void {
30 sessionsByThread.delete(threadId);
31}
32
33export function clearAllMcpProviderSessions(): void {
34 sessionsByThread.clear();
35}