Initialize onboarding agent scaffold

This commit is contained in:
dahyeon committed 2026-04-16 13:48:53 -07:00
commit 4294f3c92e
57 files changed
+14388

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
import { createHash } from "node:crypto";
const EVAL_ANON_SALT = "lolympus-agent-v1" as const;
function shortHash(value: string): string {
return createHash("sha256")
.update(`${EVAL_ANON_SALT}:${value}`)
.digest("hex")
.slice(0, 8);
}
export function anonymizeIdentifier(
prefix: string,
value: string | undefined,
): string | undefined {
if (!value?.trim()) {
return undefined;
}
return `${prefix}_${shortHash(value)}`;
}
export function anonymizeNickname(value: string | undefined): string | undefined {
if (!value?.trim()) {
return undefined;
}
return `<nick:${shortHash(value)}>`;
}
export function anonymizeText(value: string): string {
return value
.replace(/01[016789][- ]?\d{3,4}[- ]?\d{4}/gu, "[REDACTED:phone]")
.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu, "[REDACTED:email]")
.replace(/\b(?:\d[ -]?){13,19}\b/gu, "[REDACTED:card]")
.replace(/https?:\/\/open\.kakao\.com\/o\/[^\s)]+/giu, "[REDACTED:kakao-link]")
.replace(/https?:\/\/discord\.gg\/[^\s)]+/giu, "[REDACTED:discord-link]")
.replace(/discord\.gg\/[^\s)]+/giu, "[REDACTED:discord-link]");
}
export function anonymizeRelativeTimestamp(
value: Date | string,
baseTimestamp: Date,
): string {
const timestamp =
value instanceof Date ? value.getTime() : Date.parse(value);
if (!Number.isFinite(timestamp)) {
return "+0s";
}
const seconds = Math.round((timestamp - baseTimestamp.getTime()) / 1000);
return `${seconds >= 0 ? "+" : ""}${seconds}s`;
}