import alibaba from '@lobehub/icons-static-svg/icons/alibaba.svg?raw'; import antigravity from '@lobehub/icons-static-svg/icons/antigravity.svg?raw'; import bedrock from '@lobehub/icons-static-svg/icons/bedrock.svg?raw'; import claude from '@lobehub/icons-static-svg/icons/claude.svg?raw'; import deepseek from '@lobehub/icons-static-svg/icons/deepseek.svg?raw'; import gemini from '@lobehub/icons-static-svg/icons/gemini.svg?raw'; import githubcopilot from '@lobehub/icons-static-svg/icons/githubcopilot.svg?raw'; import grok from '@lobehub/icons-static-svg/icons/grok.svg?raw'; import kimi from '@lobehub/icons-static-svg/icons/kimi.svg?raw'; import meta from '@lobehub/icons-static-svg/icons/meta.svg?raw'; import minimax from '@lobehub/icons-static-svg/icons/minimax.svg?raw'; import mistral from '@lobehub/icons-static-svg/icons/mistral.svg?raw'; import ollama from '@lobehub/icons-static-svg/icons/ollama.svg?raw'; import openai from '@lobehub/icons-static-svg/icons/openai.svg?raw'; import opencode from '@lobehub/icons-static-svg/icons/opencode.svg?raw'; import openrouter from '@lobehub/icons-static-svg/icons/openrouter.svg?raw'; import qwen from '@lobehub/icons-static-svg/icons/qwen.svg?raw'; import vertexai from '@lobehub/icons-static-svg/icons/vertexai.svg?raw'; import zhipu from '@lobehub/icons-static-svg/icons/zhipu.svg?raw'; import { providerName } from './usage'; // The usage screens draw one small monochrome mark beside a model or an account // (robot-docs/web.md). Each is one of @lobehub's static SVGs, imported at build // time and only the ones used here: the marks are the company's, so the bundle // carries exactly what is drawn and nothing else. They are painted as masks, so // a mark takes the muted text colour of wherever it sits and its own file's // colours never reach the page. /** The files that are imported, by the name the tables below use. */ const MARKS: Record = { alibaba, antigravity, bedrock, claude, deepseek, gemini, githubcopilot, grok, kimi, meta, minimax, mistral, ollama, openai, opencode, openrouter, qwen, vertexai, zhipu, }; /** * The mark for a model, from the name it was recorded under: the family a * person would read off the id. A name in no known family gets none rather * than another family's guess. */ const MODEL_MARKS: readonly (readonly [RegExp, string])[] = [ [/^(gpt-|chatgpt-|o\d)/i, 'openai'], [/^claude/i, 'claude'], [/^gemini/i, 'gemini'], [/^deepseek/i, 'deepseek'], [/^qwen/i, 'qwen'], [/^glm/i, 'zhipu'], [/^kimi/i, 'kimi'], [/^(mistral|codestral)/i, 'mistral'], [/^grok/i, 'grok'], [/^llama/i, 'meta'], [/^minimax/i, 'minimax'], ]; /** * The mark for a provider, from the name `providerName` reads off its endpoint: * an endpoint the usage naming knows about and has a mark for, and nothing for * the rest, so an unknown host never wears another provider's mark. */ const PROVIDER_MARKS: Record = { OpenAI: 'openai', ChatGPT: 'openai', Anthropic: 'claude', Ollama: 'ollama', Google: 'gemini', 'Vertex AI': 'vertexai', Bedrock: 'bedrock', OpenCode: 'opencode', OpenRouter: 'openrouter', DeepSeek: 'deepseek', Alibaba: 'alibaba', 'GitHub Copilot': 'githubcopilot', }; /** The mark for a model name, or null when its family is not one of these. */ export function modelMark(model: string): string | null { for (const [pattern, mark] of MODEL_MARKS) if (pattern.test(model)) return mark; return null; } /** * The mark for the provider a limit belongs to. A limit's provider is the * daemon's own name for the account it polls (`src/albedo/daemon/quota.gleam`), * not a usage provider string, so it has a table of its own: an account polled * under a name not in here draws no mark. */ const LIMIT_MARKS: Record = { anthropic: 'claude', 'openai-codex': 'openai', 'google-antigravity': 'antigravity', 'opencode-go': 'opencode', deepseek: 'deepseek', alibaba: 'alibaba', }; /** The mark for a recorded usage provider (`:`), or null when its host is not one of these. */ export function providerMark(provider: string): string | null { return PROVIDER_MARKS[providerName(provider)] ?? null; } /** The mark for a limit's provider, or null when the daemon polls it under a name this file does not know. */ export function limitMark(provider: string): string | null { return LIMIT_MARKS[provider] ?? null; } /** * A mark as a mask the element can paint: the file itself, as a data URL so no * request is made for it and only the imported ones exist. Percent-encoded * because an SVG holds `#`, `"` and spaces, which end a `url()`. */ export function markMask(mark: string): string { return `url("data:image/svg+xml,${encodeURIComponent(MARKS[mark])}")`; }