import { SupabaseMcpClientSupport, SupabaseMcpContext, SupabaseMcpServer, SupabaseMcpState } from "./types.js"; import { CallToolResult } from "@modelcontextprotocol/server"; //#region src/session-state.d.ts declare const MCP_SESSION_HEADER = "mcp-session-id"; declare const DEFAULT_ACTIVE_WORKSPACE_TTL_SECONDS: number; /** * Extract a spec-valid visible-ASCII `Mcp-Session-Id` (`0x21..0x7E`, 1..1024 chars), * supporting UUIDs, `cs1__`, and `crun1..` session headers. */ declare function mcpSessionId(request: Request): string | null; /** * Stamp a fresh `cs1__` header onto a successful 2025 `initialize` * response when no `Mcp-Session-Id` header is already present. */ declare function issueMcpSessionId(response: Response, supports?: SupabaseMcpClientSupport, randomUUID?: () => string): Response; interface WorkspaceDescriptor { readonly id: string; readonly name: string; } interface ActiveWorkspaceStoreOptions { /** Configured namespace in `state.namespaces` (e.g. `"mcp.active-workspace"`). */ readonly namespace: string; /** Object key inside the session partition. Defaults to `"active-workspace"`. */ readonly key?: string; /** Defaults to 86,400 (24 hours), clamped to namespace `maxTtlSeconds` when known. */ readonly ttlSeconds?: number; } interface ActiveWorkspaceStore { read(): Promise<{ readonly workspaceId: string; readonly revision: number; } | null>; write(workspaceId: string): Promise; clear(revision: number): Promise; } declare function activeWorkspaceStore(sessionState: SupabaseMcpState, options: ActiveWorkspaceStoreOptions): ActiveWorkspaceStore; type WorkspaceRouteProblem = "no_session" | "no_choice" | "not_authorized" | "removed" | "unavailable"; interface WorkspaceRoutingTerminology { /** Argument name on scoped tools and `use_`. Defaults to `"workspace"`. */ readonly paramName?: string; /** Selector tool name. Defaults to `"use_workspace"`. */ readonly selectorToolName?: string; /** Discovery tool name that lists valid choices (e.g. `"list_workspaces"`). */ readonly listToolName: string; /** Human noun for prose messages. Defaults to `paramName` (e.g. `"project"`). */ readonly noun?: string; } declare function workspaceRequiredMessage(problem: WorkspaceRouteProblem, terminology: WorkspaceRoutingTerminology): string; interface ResolveActiveWorkspaceOptions extends ActiveWorkspaceStoreOptions, WorkspaceRoutingTerminology { /** Explicit argument passed on this tool call (`args.workspace`), if any. Always wins. */ readonly explicitId?: string; /** * Authoritative list of workspaces this caller currently reaches (e.g. via RLS query). * Re-evaluated on EVERY call — stored session state never bypasses authorization. */ listAuthorized(context: SupabaseMcpContext): readonly Workspace[] | Promise; /** Automatically select when the caller has exactly one authorized workspace. Defaults to `true`. */ readonly autoSelectSingle?: boolean; } type ResolveActiveWorkspaceResult = { readonly ok: true; readonly workspace: Workspace; readonly source: "explicit" | "single" | "session"; } | { readonly ok: false; readonly problem: WorkspaceRouteProblem; /** Ready-to-return `errorResult` naming the exact recovery action for this client. */ readonly error: CallToolResult; }; declare function resolveActiveWorkspace(context: SupabaseMcpContext, options: ResolveActiveWorkspaceOptions): Promise>; interface RegisterUseWorkspaceOptions extends Omit, "explicitId"> { readonly description?: string; } /** Register the `use_workspace` (or `use_`) tool on `server` for `context`. */ declare function registerUseWorkspace(server: SupabaseMcpServer, context: SupabaseMcpContext, options: RegisterUseWorkspaceOptions): void; /** * Echo the resolved workspace in both `content[].text` and `structuredContent[fieldName]` * on non-error results so multi-workspace calls are self-identifying. Preserves * `io.chumbo/collectionMaxBytes` when applied to a `collectionResult`. */ declare function withWorkspaceEcho(result: CallToolResult, workspace: Workspace, options?: { readonly fieldName?: string; readonly label?: string; }): CallToolResult; //#endregion export { ActiveWorkspaceStore, ActiveWorkspaceStoreOptions, DEFAULT_ACTIVE_WORKSPACE_TTL_SECONDS, MCP_SESSION_HEADER, RegisterUseWorkspaceOptions, ResolveActiveWorkspaceOptions, ResolveActiveWorkspaceResult, WorkspaceDescriptor, WorkspaceRouteProblem, WorkspaceRoutingTerminology, activeWorkspaceStore, issueMcpSessionId, mcpSessionId, registerUseWorkspace, resolveActiveWorkspace, withWorkspaceEcho, workspaceRequiredMessage }; //# sourceMappingURL=session-state.d.ts.map