diff --git a/apps/server/src/telemetry/AnalyticsProperties.test.ts b/apps/server/src/telemetry/AnalyticsProperties.test.ts index 4b8ff659f..3b9b411db 100644 --- a/apps/server/src/telemetry/AnalyticsProperties.test.ts +++ b/apps/server/src/telemetry/AnalyticsProperties.test.ts @@ -95,6 +95,51 @@ describe("AnalyticsProperties", () => { modelFamily: "gpt", }); assert.strictEqual(normalizeAnalyticsModel("openai/o4-mini").model, "o4-mini"); + // Antigravity, Cursor, and Claude variant shapes. + assert.strictEqual(normalizeAnalyticsModel("gpt-6-1").model, "gpt-6-1"); + assert.strictEqual(normalizeAnalyticsModel("gpt-oss-120b-medium").model, "gpt-oss-120b-medium"); + assert.strictEqual(normalizeAnalyticsModel("gemini-pro-agent").model, "gemini-pro-agent"); + assert.strictEqual(normalizeAnalyticsModel("gemini-4-pro-xhigh").model, "gemini-4-pro-xhigh"); + assert.strictEqual( + normalizeAnalyticsModel("gemini-4-flash-extra").model, + "gemini-4-flash-extra", + ); + assert.strictEqual(normalizeAnalyticsModel("composer-2.5-fast").model, "composer-2.5-fast"); + assert.strictEqual(normalizeAnalyticsModel("grok-build-0.1").model, "grok-build-0.1"); + assert.strictEqual( + normalizeAnalyticsModel("claude-4.6-opus-high-thinking").model, + "claude-4-6-opus-high-thinking", + ); + assert.deepStrictEqual(normalizeAnalyticsModel("opus-4.6"), { + model: "claude-opus-4-6", + modelKind: "known", + modelFamily: "claude", + }); + assert.deepStrictEqual(normalizeAnalyticsModel("opus-4.6-thinking"), { + model: "claude-opus-4-6-thinking", + modelKind: "known", + modelFamily: "claude", + }); + assert.deepStrictEqual(normalizeAnalyticsModel("opus"), { + model: "opus", + modelKind: "known", + modelFamily: "claude", + }); + assert.deepStrictEqual(normalizeAnalyticsModel("claude-opus-5-5[1m]"), { + model: "claude-opus-5-5", + modelKind: "known", + modelFamily: "claude", + }); + assert.strictEqual(normalizeAnalyticsModel("gpt-5.4[reasoning=high]").model, "gpt-5.4"); + assert.strictEqual( + normalizeAnalyticsModel("gpt-5.4[reasoning=xhigh,fast=true,context=1m]").model, + "gpt-5.4", + ); + assert.strictEqual( + normalizeAnalyticsModel("openrouter/anthropic/claude-opus-5.5:batch").model, + "claude-opus-5-5", + ); + assert.strictEqual(normalizeAnalyticsModel("kimi-for-coding").model, "kimi-for-coding"); }); it("redacts custom and provider-prefixed model strings", () => { @@ -111,23 +156,45 @@ describe("AnalyticsProperties", () => { const privateNames = [ // A public name behind a gateway nobody knows, or an Azure deployment. "acme-gateway/claude-sonnet-5-5", + "acme-gateway/deepseek-v4-pro", + "acme-gateway/big-pickle", "azure/gpt-5.4", "openrouter/acme/claude-sonnet-5-5", + "openrouter/acme/deepseek-v4-pro", // A user's own model added under a public provider's name, or named // like a public one with no provider at all. "openai/gpt-5.4-acme-payroll", "gpt-5.4-acme-payroll", "gpt-4o-acme-payroll", "gpt-5x-sol", + "gpt-oss-120b-acme", "google/gemini-2.5-acme-payroll", "gemini-4-acme", "muse-acme-payroll", "muse-4242-1717", "gpt-5-4242-1717", "grok-4-12-34-56-78", + "mistral/mistral-small-12-34-56-78", + "deepseek-v4-0101-0202-0303", + "qwen3-12-34-56-78", + "llama-4-12-34-56-78", "claude-sonnet-4-20999999", "claude-mythos-5-acme", "o3-acme", + "deepseek-v4-4242", + "qwen3-acme-payroll", + "glm-5.3-acme", + "kimi-k3-acme", + "minimax-m3-acme", + "llama-4-acme", + // Private bracket traits or unknown colon modifiers. + "gpt-5.4[acme=secret]", + "cloudflare-workers-ai/@cf/openai/gpt-oss-120b[acme=secret]", + "claude-opus-5-5[acme]", + "gpt-5.4:acme", + // Bare single English words from the catalog stay custom without a provider. + "apex", + "fusion", "openai/gpt-5.4-123456789012", // Whatever made a long name private may be past the cut. `gpt-5-${"a".repeat(96)}:acme`, @@ -166,7 +233,7 @@ describe("AnalyticsProperties", () => { ); }); - it("names a Pi model when Pi itself ships it, whatever its words", () => { + it("names public models across OpenCode, fx, Pi, and community agents", () => { assert.deepStrictEqual(normalizeAnalyticsModel("deepseek/deepseek-v4-pro", "pi"), { model: "deepseek-v4-pro", modelKind: "known", @@ -181,16 +248,75 @@ describe("AnalyticsProperties", () => { normalizeAnalyticsModel("amazon-bedrock/global.openai.gpt-6-sol", "pi").model, "global.openai.gpt-6-sol", ); - // A model the user added to Pi isn't on Pi's list. + // OpenCode, fx, and community agents share the same public model families and catalog. + assert.strictEqual( + normalizeAnalyticsModel("deepseek/deepseek-v4-pro", "opencode").model, + "deepseek-v4-pro", + ); + assert.strictEqual( + normalizeAnalyticsModel("opencode/big-pickle", "opencode").model, + "big-pickle", + ); + assert.strictEqual( + normalizeAnalyticsModel("opencode-go/mimo-v2.6-pro", "opencode").model, + "mimo-v2.6-pro", + ); + assert.strictEqual(normalizeAnalyticsModel("moonshotai/kimi-k3", "fx").model, "kimi-k3"); + assert.strictEqual(normalizeAnalyticsModel("spacexai/grok-4.6", "fx").model, "grok-4.6"); + assert.strictEqual(normalizeAnalyticsModel("alibaba/qwen-3-235b", "fx").model, "qwen-3-235b"); + assert.strictEqual( + normalizeAnalyticsModel("vercel-ai-gateway/moonshotai/kimi-k3", "opencode").model, + "kimi-k3", + ); + assert.strictEqual( + normalizeAnalyticsModel("openrouter/baidu/ernie-5.5-flash-preview:free", "opencode").model, + "ernie-5.5-flash-preview", + ); + assert.strictEqual( + normalizeAnalyticsModel( + "cloudflare-workers-ai/@cf/openai/gpt-oss-120b[reasoning=high]", + "opencode", + ).model, + "gpt-oss-120b", + ); + assert.strictEqual(normalizeAnalyticsModel("alibaba/qwen3.8-max", "fx").model, "qwen3.8-max"); + assert.strictEqual( + normalizeAnalyticsModel("qwen3-coder-plus", "acpRegistry").model, + "qwen3-coder-plus", + ); + assert.strictEqual(normalizeAnalyticsModel("glm-5.3", "acpRegistry").model, "glm-5.3"); + assert.strictEqual( + normalizeAnalyticsModel("openrouter/z-ai/glm-5.3", "opencode").model, + "glm-5.3", + ); + assert.strictEqual( + normalizeAnalyticsModel("minimax/minimax-m3.1-flash", "acpRegistry").model, + "minimax-m3.1-flash", + ); + assert.strictEqual( + normalizeAnalyticsModel("mistral/devstral-2512", "opencode").model, + "devstral-2512", + ); + assert.strictEqual( + normalizeAnalyticsModel("meta-llama/llama-4-scout-17b-16e-instruct", "opencode").model, + "llama-4-scout-17b-16e-instruct", + ); + assert.strictEqual( + normalizeAnalyticsModel("openrouter/google/gemma-4-26b-a4b-it:free", "opencode").model, + "gemma-4-26b-a4b-it", + ); + // A user-added model under a public provider stays custom everywhere. assert.strictEqual( normalizeAnalyticsModel("deepseek/deepseek-acme-payroll", "pi").model, "custom", ); - // Pi's list vouches for Pi's models only. assert.strictEqual( - normalizeAnalyticsModel("deepseek/deepseek-v4-pro", "opencode").model, + normalizeAnalyticsModel("deepseek/deepseek-acme-payroll", "opencode").model, "custom", ); + // Azure stays custom outside built-in Pi. + assert.strictEqual(normalizeAnalyticsModel("azure/gpt-5.4", "opencode").model, "custom"); + assert.strictEqual(normalizeAnalyticsModel("azure/gpt-5.4", "pi").model, "gpt-5.4"); }); it("names a community agent by its registry id", () => { diff --git a/apps/server/src/telemetry/AnalyticsProperties.ts b/apps/server/src/telemetry/AnalyticsProperties.ts index 14863be4c..ddf147b22 100644 --- a/apps/server/src/telemetry/AnalyticsProperties.ts +++ b/apps/server/src/telemetry/AnalyticsProperties.ts @@ -67,6 +67,7 @@ const KNOWN_SAFE_MODELS = new Set([ "default", "composer-1.5", "composer-2", + "gemini-pro-agent", "gpt-5.2", "gpt-5.3-codex", "gpt-5.3-codex-spark", @@ -94,40 +95,94 @@ const KNOWN_SAFE_MODELS = new Set([ const SAFE_PUBLIC_MODEL_PATTERNS = [ // `gpt-4o` and its kin end their version in an "o"; no other letter. - /^gpt-\d{1,2}o?(?:\.\d{1,2})?(?:-(?:mini|nano|pro|turbo|preview|latest|chat|codex|spark|astra|sol|luna|terra|max|high|low|medium|fast))+(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, - /^gpt-\d{1,2}o?(?:\.\d{1,2})?(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, - /^o\d{1,2}(?:-(?:mini|pro|preview|high|low|medium))?(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, - /^claude-(?:fable|mythos|haiku|opus|sonnet)-\d{1,2}(?:-\d{1,2})?(?:-20[2-3]\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01]))?$/, - /^gemini-\d{1,2}(?:\.\d{1,2})?-(?:pro|flash|ultra|lite|argon|carbon|hydrogen|neon|sonar|exp|preview)(?:-(?:pro|flash|lite|sonar|exp|preview|latest|thinking|customtools|high|low|medium|minimal))*(?:-(?:0\d{2}|(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])))?$/, + /^gpt-\d{1,2}o?(?:[.-]\d{1,2})?(?:-(?:mini|nano|pro|turbo|preview|latest|chat|codex|spark|astra|sol|luna|terra|max|high|low|medium|xhigh|extra|minimal|none|fast|thinking|batch))+(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, + /^gpt-\d{1,2}o?(?:[.-]\d{1,2})?(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, + /^gpt-oss-(?:safeguard-)?\d{1,3}b(?:-(?:high|low|medium|xhigh|fast|free))?$/, + /^o\d{1,2}(?:-(?:mini|pro|preview|high|low|medium|xhigh|fast|batch))?(?:-20[2-3]\d-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))?$/, + /^claude-(?:fable|mythos|haiku|opus|sonnet)-\d{1,2}(?:-\d{1,2})?(?:-(?:thinking|fast|batch|high|low|medium|xhigh|max|minimal))*(?:-20[2-3]\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01]))?$/, + /^claude-\d{1,2}(?:-\d{1,2})?-(?:fable|mythos|haiku|opus|sonnet)(?:-(?:thinking|fast|batch|high|low|medium|xhigh|max|minimal))*$/, + /^(?:fable|mythos|haiku|opus|sonnet)(?:-\d{1,2}(?:-\d{1,2})?(?:-(?:thinking|fast|high|low|medium|xhigh|max|minimal))*)?$/, + /^gemini-\d{1,2}(?:\.\d{1,2})?-(?:pro|flash|ultra|lite|argon|carbon|hydrogen|neon|sonar|exp|preview)(?:-(?:pro|flash|lite|sonar|exp|preview|latest|thinking|customtools|high|low|medium|xhigh|extra|minimal))*(?:-(?:0\d{2}|(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])))?$/, /^muse-(?:spark|wonder|ember|glimmer)(?:-\d{1,2}(?:\.\d{1,2})?|-\d{1,3}b)?(?:-(?:open|contributor))?$/, - /^composer-\d{1,2}(?:\.\d{1,2})?$/, - /^grok-(?:code|\d{1,2}(?:\.\d{1,2})?)(?:-(?:fast|mini|pro|build|beta|latest|reasoning|code))*(?:-\d{1,2})?$/, + /^composer-\d{1,2}(?:\.\d{1,2})?(?:-(?:fast|mini|pro|turbo|preview|latest))?$/, + /^grok-(?:code|build|\d{1,2}(?:\.\d{1,2})?)(?:-(?:fast|mini|pro|build|beta|latest|reasoning|code))*(?:-\d{1,2}(?:\.\d{1,2})?)?$/, + /^deepseek-(?:v\d{1,2}(?:[.-]\d{1,2})?|r\d{1,2}(?:[.-]\d{1,2})?|chat|reasoner|coder|flash|pro)(?:-(?:pro|flash|chat|lite|mini|coder|reasoner|distill|thinking|free|latest|fast|preview))*(?:-(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01]))?$/, + /^glm-\d{1,2}(?:[.-]\d{1,2})?(?:-(?:air|airx|flash|flashx|plus|pro|turbo|fast|highspeed|free|latest|preview|vision|v))*$/, + /^qwen-?\d{1,2}(?:\.\d{1,2})?(?:-(?:coder|max|plus|turbo|flash|omni|vl|next|prime))*(?:-\d{1,3}(?:\.\d)?[bt])?(?:-a\d{1,3}b)?(?:-(?:instruct|thinking|preview|latest|free|fast|fp8))*(?:-(?:2[4-9]|3\d)(?:0[1-9]|1[0-2]))?$/, + /^kimi-(?:k\d{1,2}(?:[.-]\d{1,2})?|for-coding|latest|fast)(?:-(?:pro|code|thinking|preview|latest|fast|highspeed|turbo|free|instruct|256k))*$/, + /^minimax-m\d{1,2}(?:[.-]\d{1,2})?(?:-(?:flash|pro|fast|highspeed|free|latest|preview))*$/, + /^(?:mistral|devstral|codestral|ministral|magistral)-(?:large|medium|small|tiny|mini|nemo|saba|latest|\d{1,3}b)(?:-\d{1,2}(?:\.\d{1,2})?)?(?:-\d{1,3}b)?(?:-(?:instruct|latest|preview|free))?(?:-(?:2[4-9]|3\d)(?:0[1-9]|1[0-2]))?$/, + /^(?:mistral|devstral|codestral|ministral|magistral)-(?:2[4-9]|3\d)(?:0[1-9]|1[0-2])$/, + /^llama-?\d{1,2}(?:[.-]\d{1,2})?(?:-(?:scout|maverick|vision))?(?:-\d{1,3}b)?(?:-\d{1,2}e)?(?:-(?:instruct|versatile|instant|fast|fp8|preview|latest|free))*$/, + /^gemma-\d{1,2}(?:\.\d{1,2})?-\d{1,3}b(?:-a\d{1,2}b)?(?:-(?:it|pt|free|latest))*$/, /^(?:auto|default)$/, ]; /** * Public providers whose own catalog names follow them in a model id, the - * way agents that reach many providers write it (Pi, OpenCode): + * way agents that reach many providers write it (Pi, OpenCode, fx): * `google/gemini-2.5-pro`, `openrouter/anthropic/claude-sonnet-4.5`. Only * these prefixes come off. Any other prefix may name a private gateway, and * an Azure deployment name is the user's own words, so those stay custom. */ const PUBLIC_MODEL_PROVIDER_PREFIXES: ReadonlySet = new Set([ + "alibaba", + "amazon", + "amazon-bedrock", "anthropic", + "cerebras", "cloudflare-ai-gateway", + "cloudflare-workers-ai", + "cohere", + "deepseek", + "deepseek-ai", + "fireworks", "gemini", "github-copilot", "google", "google-antigravity", "google-gemini-cli", "google-vertex", + "groq", + "huggingface", + "kimi-coding", + "meta", + "meta-llama", + "minimax", + "minimax-cn", + "minimaxai", + "mistral", + "mistralai", + "moonshotai", + "moonshotai-cn", + "nvidia", "openai", "openai-codex", "opencode", + "opencode-go", "openrouter", + "qwen", + "qwen-token-plan", + "qwen-token-plan-cn", + "qwen-token-plan-individual", + "qwen-token-plan-individual-cn", + "spacexai", + "stepfun", + "stepfun-ai", + "tencent", + "together", "vercel", "vercel-ai-gateway", + "x-ai", "xai", + "xiaomi", + "xiaomi-token-plan-ams", + "xiaomi-token-plan-cn", + "xiaomi-token-plan-sgp", + "z-ai", + "zai", + "zai-coding-cn", + "zai-org", ]); /** @@ -139,8 +194,11 @@ const PUBLIC_MODEL_PROVIDER_PREFIXES: ReadonlySet = new Set([ * in KNOWN_SAFE_MODELS need no check. */ const PUBLIC_MODEL_WORDS: ReadonlySet = new Set([ + "air", + "airx", "argon", "astra", + "batch", "beta", // Grok Build's own models: `grok-4.7-build-fast`. "build", @@ -148,57 +206,146 @@ const PUBLIC_MODEL_WORDS: ReadonlySet = new Set([ "chat", "claude", "code", + "coder", + "codestral", "codex", + "coding", "composer", "contributor", "customtools", + "deepseek", + "devstral", + "distill", "ember", "exp", + "extra", "fable", "fast", "flash", + "flashx", + "for", + "fp8", + "free", "gemini", + "gemma", "glimmer", + "glm", "gpt", "grok", "haiku", "high", + "highspeed", "hydrogen", + "instant", + "instruct", + "it", + "kimi", + "large", "latest", "lite", + "llama", "low", "luna", + "magistral", + "maverick", "max", "medium", "mini", "minimal", + "minimax", + "ministral", + "mistral", "muse", "mythos", "nano", + "nemo", "neon", + "next", + "none", + "omni", "open", "opus", + "oss", + "plus", "preview", + "prime", "pro", + "pt", + "qwen", + "reasoner", "reasoning", + "saba", + "safeguard", + "scout", + "small", "sol", "sonar", "sonnet", "spark", "terra", "thinking", + "tiny", "turbo", "ultra", + "v", + "versatile", + "vision", + "vl", "wonder", + "xhigh", ]); +const SAFE_BRACKET_TRAIT_ENTRY = + /^(?:1m|(?:reasoning|effort|context|context_size|fast|thinking)=(?:none|minimal|low|medium|high|xhigh|extra-high|max|true|false|\d{1,4}[km]))$/; + +const VERSIONED_CLAUDE_SHORTHAND = /^(?:fable|mythos|haiku|opus|sonnet)-\d/; + +const PUBLIC_VERSION_TOKEN = + /^(?:o\d{1,2}|qwen\d{1,2}|llama\d{1,2}|[vrkm]\d{1,2}|\d{1,2}[a-z]?|0\d{2}|\d{1,3}[bkt]|a\d{1,3}b|\d{1,2}e|(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])|(?:2[4-9]|3\d)(?:0[1-9]|1[0-2])|20[2-3]\d|20[2-3]\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01]))$/; + +function stripSafeModelSuffixes(bare: string): string { + let result = bare; + if (result.endsWith(":free")) { + result = result.slice(0, -":free".length); + } else if (result.endsWith(":batch")) { + result = result.slice(0, -":batch".length); + } + const bracketStart = result.indexOf("["); + if (bracketStart !== -1 && result.endsWith("]")) { + const inside = result.slice(bracketStart + 1, -1); + const parts = inside.split(","); + if (parts.length > 0 && parts.every((part) => SAFE_BRACKET_TRAIT_ENTRY.test(part))) { + result = result.slice(0, bracketStart); + } + } + return result; +} + +/** + * Exact public bare model ids published in Pi's catalog (excluding Azure, where + * deployment names are user-chosen, and plain single words like `apex` or + * `free` that could collide with an arbitrary bare internal name). + */ +const PUBLIC_CATALOG_BARE_MODELS: ReadonlySet = (() => { + const models = new Set(); + for (const slug of PI_PUBLIC_MODELS) { + if (slug.startsWith("azure/")) continue; + const bare = stripSafeModelSuffixes(slug.slice(slug.lastIndexOf("/") + 1)); + if (!bare || (!bare.includes("-") && !/\d/.test(bare))) continue; + models.add(bare); + } + return models; +})(); + function normalizeModelString(model: string | null | undefined): string | undefined { return model?.trim().toLowerCase() || undefined; } function inferModelFamily(model: string | undefined): AnalyticsModelFamily { if (!model) return "unknown"; - if (model.includes("claude")) return "claude"; + if (model.includes("claude") || /^(?:fable|mythos|haiku|opus|sonnet)(?:$|[-.])/.test(model)) { + return "claude"; + } if (model.includes("gpt") || /^o\d/.test(model)) return "gpt"; if (model.includes("gemini")) return "gemini"; if (model.includes("composer") || model.includes("cursor")) return "cursor"; @@ -222,43 +369,59 @@ function isSafeKnownModel(model: string): boolean { /** * The public name a model id may be reported as, or undefined when it may * not. Claude versions get dashes the way Anthropic writes them (GitHub - * Copilot writes `claude-sonnet-4.5`). A name behind provider prefixes must - * have only public providers in front and only public words in it. + * Copilot writes `claude-sonnet-4.5`), and versioned Claude shorthands like + * `opus-4.6` normalize to `claude-opus-4-6`. A name behind provider prefixes + * must have only public providers in front and either match a known public + * pattern (using only public words) or appear verbatim in the pinned public + * catalog. */ function publicModelName(model: string): string | undefined { // Too long to report whole, and a cut-off name could hide what made it private. if (model.length > MAX_ANALYTICS_MODEL_LENGTH) return undefined; const segments = model.split("/"); - const bare = segments.pop() ?? ""; + const rawBare = segments.pop() ?? ""; if (!segments.every((segment) => PUBLIC_MODEL_PROVIDER_PREFIXES.has(segment))) { return undefined; } - const name = bare.startsWith("claude-") ? bare.replaceAll(".", "-") : bare; - if (!isSafeKnownModel(name)) return undefined; - return KNOWN_SAFE_MODELS.has(name) || - name - .split(/[-.]/) - .every( - (word) => - /^(?:o\d{1,2}|\d{1,2}[a-z]?|0\d{2}|\d{1,3}b|20[2-3]\d|20[2-3]\d(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01]))$/.test( - word, - ) || PUBLIC_MODEL_WORDS.has(word), - ) - ? name - : undefined; + const bare = stripSafeModelSuffixes(rawBare); + const name = bare.startsWith("claude-") + ? bare.replaceAll(".", "-") + : VERSIONED_CLAUDE_SHORTHAND.test(bare) + ? `claude-${bare.replaceAll(".", "-")}` + : bare; + if ( + isSafeKnownModel(name) && + (KNOWN_SAFE_MODELS.has(name) || + name + .split(/[-.]/) + .every((word) => PUBLIC_VERSION_TOKEN.test(word) || PUBLIC_MODEL_WORDS.has(word))) + ) { + return name; + } + if (PUBLIC_CATALOG_BARE_MODELS.has(bare)) { + return bare; + } + return undefined; } /** - * A Pi model's name when Pi itself ships it: its `provider/id` is on Pi's - * published list, so the name is public whatever words it uses (`deepseek-v4-pro`, - * `global.openai.gpt-6-sol`). A model a user added in Pi's `models.json` or an - * extension isn't on it and stays custom. The provider part comes off the way - * it does for other agents, so the same model groups across them. + * A model's name when its full `provider/id` slug is on the pinned public + * catalog (`PI_PUBLIC_MODELS`), covering multi-segment gateway routes (such as + * Cloudflare Workers AI or OpenRouter vendors) whose inner prefixes are not + * in `PUBLIC_MODEL_PROVIDER_PREFIXES`. Azure entries apply only to built-in Pi. */ -function piCatalogModelName(slug: string): string | undefined { - if (!PI_PUBLIC_MODELS.has(slug)) return undefined; - const id = slug.slice(slug.indexOf("/") + 1); - return publicModelName(id) ?? id; +function catalogModelName(slug: string, provider?: string): string | undefined { + if (provider !== "pi" && slug.startsWith("azure/")) return undefined; + const lastSlash = slug.lastIndexOf("/"); + if (lastSlash === -1) return undefined; + const prefix = slug.slice(0, lastSlash + 1); + const rawBare = slug.slice(lastSlash + 1); + const bare = stripSafeModelSuffixes(rawBare); + const strippedSlug = `${prefix}${bare}`; + if (!PI_PUBLIC_MODELS.has(slug) && !PI_PUBLIC_MODELS.has(strippedSlug)) { + return undefined; + } + return publicModelName(bare) ?? bare; } export function normalizeAnalyticsModel( @@ -274,8 +437,7 @@ export function normalizeAnalyticsModel( }; } - const name = - publicModelName(normalized) ?? (provider === "pi" ? piCatalogModelName(normalized) : undefined); + const name = publicModelName(normalized) ?? catalogModelName(normalized, provider); if (name !== undefined) { return { model: name, diff --git a/docs/telemetry.md b/docs/telemetry.md index fb432065c..b45db3360 100644 --- a/docs/telemetry.md +++ b/docs/telemetry.md @@ -85,13 +85,15 @@ Threadlines sends product and reliability events such as: why (you stopped typing, or it started work or asked something on its own) and how long it had been running; - selected model family and sanitized model slug for provider turns. A model - name is reported only when every word in it is one public model names use. - One sent through a well-known provider (`google/gemini-2.5-pro`, - `openrouter/anthropic/claude-sonnet-4.5`) is reported without the - provider part (`gemini-2.5-pro`). A Pi model is also reported by name when its - name is on the list of models Pi itself ships (`deepseek-v4-pro`); a model - you name yourself in Pi is not on it. Any other model name is reported - only as `custom`; + name is reported only when it matches a known public model shape using public + words, or appears verbatim in the pinned public model catalog shipped with + Threadlines (`deepseek-v4-pro`, `kimi-k3`, `glm-5.3`, `qwen3.8-max`, + `big-pickle`). One sent through a well-known provider + (`google/gemini-2.5-pro`, `openrouter/anthropic/claude-sonnet-4.5`, + `moonshotai/kimi-k3`) is reported without the provider part, and known option + suffixes (`[1m]`, `[reasoning=high]`, `:free`, `:batch`) are stripped. Models + behind private gateways, Azure deployments (outside Pi's own built-in list), + or custom user-named models are reported only as `custom`; - for a community agent added from the ACP registry, its public registry id (such as `pi-acp`) on provider session, turn, fork, rollback, request, model reroute, deletion, and failure events, so reports can tell community