refactor: de-duplicate channel runtime and payload helpers

This commit is contained in:
Peter Steinberger
2026-02-23 21:25:20 +00:00
parent 0ae7f470a2
commit 0183610db3
44 changed files with 775 additions and 698 deletions

View File

@@ -223,12 +223,15 @@ export function resolveThreadSessionKeys(params: {
threadId?: string | null;
parentSessionKey?: string;
useSuffix?: boolean;
normalizeThreadId?: (threadId: string) => string;
}): { sessionKey: string; parentSessionKey?: string } {
const threadId = (params.threadId ?? "").trim();
if (!threadId) {
return { sessionKey: params.baseSessionKey, parentSessionKey: undefined };
}
const normalizedThreadId = threadId.toLowerCase();
const normalizedThreadId = (params.normalizeThreadId ?? ((value: string) => value.toLowerCase()))(
threadId,
);
const useSuffix = params.useSuffix ?? true;
const sessionKey = useSuffix
? `${params.baseSessionKey}:thread:${normalizedThreadId}`