refactor(messages): centralize per-agent prefixes

This commit is contained in:
Peter Steinberger
2026-01-09 16:52:25 +01:00
parent 8341b662af
commit 36bdec0f2c
14 changed files with 144 additions and 48 deletions

View File

@@ -7,6 +7,13 @@ export type ParsedAgentSessionKey = {
rest: string;
};
export function resolveAgentIdFromSessionKey(
sessionKey: string | undefined | null,
): string {
const parsed = parseAgentSessionKey(sessionKey);
return normalizeAgentId(parsed?.agentId ?? DEFAULT_AGENT_ID);
}
export function normalizeAgentId(value: string | undefined | null): string {
const trimmed = (value ?? "").trim();
if (!trimmed) return DEFAULT_AGENT_ID;