Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
1.4 kB · 34 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435const DISPLAY_ID_LENGTH = 12;const HEX_ID_PATTERN = /^[0-9a-f]+$/;
export function formatSessionDisplayId(id: string): string { const normalized = normalizeHexSessionId(id); if (!normalized) { return id.length > DISPLAY_ID_LENGTH ? id.slice(-DISPLAY_ID_LENGTH) : id; } return normalized.length > DISPLAY_ID_LENGTH ? normalized.slice(-DISPLAY_ID_LENGTH) : normalized;}
export function matchesSessionIdSuffix(candidate: string, suffix: string): boolean { const normalizedCandidate = normalizeHexSessionId(candidate); const normalizedSuffix = normalizeHexSessionId(suffix); return !!normalizedCandidate && !!normalizedSuffix && normalizedCandidate.endsWith(normalizedSuffix);}
export function matchesSavedSessionSelector(candidate: string, selector: string): boolean { const normalizedCandidate = normalizeHexSessionId(candidate); const normalizedSelector = normalizeHexSessionId(selector); if (normalizedCandidate && normalizedSelector) { return normalizedCandidate.startsWith(normalizedSelector) || normalizedCandidate.endsWith(normalizedSelector); } return candidate.startsWith(selector);}
export function normalizeSessionId(id: string): string { return id.replaceAll("-", "").toLowerCase();}
function normalizeHexSessionId(id: string): string | undefined { const normalized = normalizeSessionId(id); return normalized && HEX_ID_PATTERN.test(normalized) ? normalized : undefined;}