MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / extractSessionToken

Function extractSessionToken

website/api/v1/query.ts:4–20  ·  view source on GitHub ↗
(args: Record<string, unknown> | null | undefined)

Source from the content-addressed store, hash-verified

2import { createClient } from "@supabase/supabase-js";
3
4function extractSessionToken(args: Record<string, unknown> | null | undefined): string {
5 if (!args || typeof args !== "object") return "";
6 const direct = args.session_id ?? args.sessionId ?? args.session ?? args.cgc_session_id;
7 if (direct != null && String(direct).trim()) return String(direct).trim().toLowerCase();
8 const sessionLabel = /\bsession[:\s]+([a-z0-9]{6})\b/i;
9 for (const value of Object.values(args)) {
10 if (typeof value !== "string" || !value.trim()) continue;
11 const labeled = value.match(sessionLabel);
12 if (labeled?.[1]) return labeled[1].toLowerCase();
13 }
14 for (const value of Object.values(args)) {
15 if (typeof value !== "string") continue;
16 const trimmed = value.trim().toLowerCase();
17 if (/^[a-z0-9]{6}$/.test(trimmed)) return trimmed;
18 }
19 return "";
20}
21
22const MISSING_SESSION_PAYLOAD = {
23 status: "missing_session",

Callers 1

handleQueryFunction · 0.70

Calls 2

valuesMethod · 0.80
StringClass · 0.50

Tested by

no test coverage detected