add getEventDisplayName

This commit is contained in:
Ishaan Jaffer 2026-02-11 19:22:24 -08:00
parent e6655accca
commit 4342ff110e

View file

@ -0,0 +1,20 @@
import { MCP_CALL_TYPES } from "./constants";
/**
* Derive a short, human-readable display name for a log entry.
* Strips provider prefixes, date suffixes, and version tags.
*/
export function getEventDisplayName(callType: string, model: string): string {
const raw = (model || "").trim();
const isMcp = MCP_CALL_TYPES.includes(callType);
if (isMcp) {
return raw.replace(/^mcp:\s*/i, "").split("/").pop() || raw || "mcp_tool";
}
const lastSegment = raw.split("/").pop() || raw;
const noSuffix = lastSegment.replace(/-20\d{6}.*$/i, "").replace(/:.*$/, "");
const claudeMatch = noSuffix.match(/claude-[a-z0-9-]+/i);
if (claudeMatch) return claudeMatch[0];
return noSuffix || "llm_call";
}