@agentproto/catalog-sync 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/changelog.ts","../src/added-at.ts","../src/runner.ts","../src/generators/llm-openrouter.ts","../src/generators/llm-requesty.ts","../src/generators/llm-opencode.ts","../src/generators/llm-huggingface.ts","../src/generators/serialize-voices.ts","../src/generators/voice-elevenlabs.ts","../src/generators/voice-minimax.ts","../src/generators/image-replicate.ts","../src/refresh-workflow.ts","../src/sources/openai.ts"],"names":["__dirname","dirname","fileURLToPath","catalogSyncDir","resolve","join","existsSync","readFileSync","OUTPUT_PATH","ModelSchema","z","SnapshotSchema","round6","per1m","fmt","vendorOf","serializeEntry","serializeFile","LEDGER_ID","generate","sources","snapshotPath","repoRoot","readIfExists","resolveHeaders","mkdirSync","writeFileSync"],"mappings":";;;;;;;;;;;;;AAsDO,SAAS,gBAAgB,CAAA,EAAuC;AACrE,EAAA,OAAO,CAAA;AACT;;;ACjCA,IAAM,aAAA,GAAgB,wBAAA;AAGf,SAAS,iBAAiB,MAAA,EAA6B;AAC5D,EAAA,MAAM,GAAA,uBAAU,GAAA,EAAY;AAC5B,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,CAAO,QAAA,CAAS,aAAa,CAAA,EAAG;AAC9C,IAAA,IAAI,CAAA,CAAE,CAAC,CAAA,KAAM,MAAA,MAAe,GAAA,CAAI,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,GAAA;AACT;AAQO,SAAS,YAAA,CAAa,QAA4B,KAAA,EAA4B;AACnF,EAAA,MAAM,YAAY,MAAA,KAAW,MAAA,GAAY,iBAAiB,MAAM,CAAA,uBAAQ,GAAA,EAAY;AACpF,EAAA,MAAM,QAAA,GAAW,iBAAiB,KAAK,CAAA;AACvC,EAAA,MAAM,KAAA,GAAQ,CAAC,GAAG,QAA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,IAAM,iBAAA,GAAuC;AAAA,EAClD,MAAA,EAAQ;AAAA,IACN,EAAA,EAAI,YAAA;AAAA,IACJ,GAAA,EAAK;AAAA,GACP;AAAA,EACA,WAAA,EAAa,KAAA;AAAA,EACb,KAAA,EACE;AAKJ;AAGO,IAAM,cAAA,GAAsC,CAAC,iBAAiB","file":"index.mjs","sourcesContent":["/**\n * catalog-sync generator contract.\n *\n * FROZEN — a sibling agent builds provider generators against this surface.\n * Do not change field names, shapes, or the `defineGenerator` signature\n * without coordinating. Adding new generators is the expected extension\n * path; editing this file is not.\n */\n\nexport interface CatalogSource {\n id: string\n url: string\n /** HTTP method for the live (`--refresh`) fetch. Default `\"GET\"`. */\n method?: \"GET\" | \"POST\"\n /**\n * Request headers for the live fetch. A value may embed `env:VAR_NAME`\n * tokens, resolved from `process.env` at fetch time (e.g.\n * `{ \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" }` or\n * `{ Authorization: \"Bearer env:MINIMAX_API_KEY\" }`). If any referenced env\n * var is unset, the source is treated as un-refreshable — the committed\n * snapshot is reused rather than fetched without auth. Offline reads\n * (default, no `--refresh`) ignore headers entirely.\n */\n headers?: Record<string, string>\n /** JSON request body for POST sources (e.g. MiniMax `get_voice`). */\n body?: unknown\n}\n\nexport interface GeneratorContext {\n /**\n * Reads the pinned snapshot at `snapshots/<src.id>.json`; if missing and\n * `refresh=true`, fetches `src.url` and writes the snapshot. Returns\n * parsed JSON.\n *\n * Offline by default: when no snapshot exists and `refresh` is false this\n * throws — generators MUST be runnable without network access so CI and\n * tests are deterministic. The only network path is behind `--refresh`.\n */\n fetchSource(src: CatalogSource): Promise<unknown>\n refresh: boolean\n}\n\n/** Repo-relative path → TS source text. */\nexport type GeneratedFiles = Record<string, string>\n\nexport interface CatalogGenerator {\n /** e.g. \"llm:openrouter\" */\n name: string\n modality: \"llm\" | \"image\" | \"video\" | \"audio\" | \"voice\"\n sources: CatalogSource[]\n generate(ctx: GeneratorContext): Promise<GeneratedFiles>\n}\n\n/** Identity helper — lets a generator module declare itself with type inference. */\nexport function defineGenerator(g: CatalogGenerator): CatalogGenerator {\n return g\n}\n","/**\n * `CATALOG-CHANGELOG.md` — a human-readable \"what models changed\" log,\n * distinct from the changesets-driven `CHANGELOG.md` next to it (that's\n * package-version history, one entry per publish). This file answers \"what\n * models did catalog-sync add or remove, and when\" by reading top-to-bottom.\n *\n * Wired into `runner.ts`: every `runGenerators` call diffs each changed\n * `*.generated.ts` file's top-level id keys (before vs after) and, when a\n * run actually adds or removes model ids for at least one generator,\n * APPENDS one dated section (`## YYYY-MM-DD`) with a `### <generator name>`\n * subsection per affected generator. Sections are appended at the END of\n * the file (newest last) — a plain, non-destructive `+=`, so the writer\n * never has to parse and re-emit prior history.\n *\n * A run with no id-level drift (pricing-only changes, or a `--check` with\n * nothing to report) appends NOTHING — no empty section, no touched file,\n * no diff. addedAt ledger files (`ledger/*.json`) are intentionally NOT\n * diffed here — they never lose an id (see `added-at.ts`), so they carry no\n * \"removed\" signal, and every id they'd report as \"added\" is already\n * covered by the generator's own `*.generated.ts` diff.\n */\n\n/** Matches a top-level (2-space-indented) quoted key of a `Record<string, X>` literal. */\nconst RECORD_KEY_RE = /^ {2}\"([^\"]+)\":\\s*\\{/gm\n\n/** Extracts the top-level quoted ids of a generated `Record<string, X>` map. */\nexport function extractRecordIds(source: string): Set<string> {\n const ids = new Set<string>()\n for (const m of source.matchAll(RECORD_KEY_RE)) {\n if (m[1] !== undefined) ids.add(m[1])\n }\n return ids\n}\n\nexport interface ModelIdDiff {\n added: string[]\n removed: string[]\n}\n\n/** Diffs the id sets of a generated file's before/after content. `before` undefined = new file (no removals possible). */\nexport function diffModelIds(before: string | undefined, after: string): ModelIdDiff {\n const beforeIds = before !== undefined ? extractRecordIds(before) : new Set<string>()\n const afterIds = extractRecordIds(after)\n const added = [...afterIds].filter((id) => !beforeIds.has(id)).sort()\n const removed = [...beforeIds].filter((id) => !afterIds.has(id)).sort()\n return { added, removed }\n}\n\nexport interface GeneratorChangelogEntry {\n /** The owning generator's `name` (e.g. `\"llm:openrouter\"`). */\n generator: string\n added: string[]\n removed: string[]\n}\n\n/** Renders a dated section, or `\"\"` when every entry is empty (nothing to report). */\nexport function renderChangelogSection(date: string, entries: readonly GeneratorChangelogEntry[]): string {\n const nonEmpty = entries.filter((e) => e.added.length > 0 || e.removed.length > 0)\n if (nonEmpty.length === 0) return \"\"\n const lines: string[] = [`## ${date}`, \"\"]\n for (const e of nonEmpty) {\n lines.push(`### ${e.generator}`)\n if (e.added.length > 0) lines.push(`- Added: ${e.added.join(\", \")}`)\n if (e.removed.length > 0) lines.push(`- Removed: ${e.removed.join(\", \")}`)\n lines.push(\"\")\n }\n return lines.join(\"\\n\").replace(/\\n+$/, \"\\n\")\n}\n\nexport const CATALOG_CHANGELOG_HEADER = `# Catalog Changelog\n\nHuman-readable log of model additions/removals detected by\n\\`@agentproto/catalog-sync\\` runs — NOT \\`CHANGELOG.md\\` next to it (that one is\nchangesets-driven package-version history). A dated section is appended\nautomatically here whenever a sync run adds or removes model ids; sections\nare appended at the END of the file (newest last). Pricing-only drift (no id\nadded/removed) is not logged here — see the generated files' own git history\nfor that.\n`\n\n/**\n * Appends a new dated section to `existing` changelog content.\n *\n * Returns `undefined` when there is nothing to report (no generator has an\n * added/removed id this run) — the caller should leave the file untouched\n * in that case, not write an unchanged copy.\n */\nexport function appendChangelog(\n existing: string | undefined,\n date: string,\n entries: readonly GeneratorChangelogEntry[]\n): string | undefined {\n const section = renderChangelogSection(date, entries)\n if (section === \"\") return undefined\n const base = existing !== undefined && existing.length > 0 ? existing.replace(/\\n+$/, \"\\n\") : CATALOG_CHANGELOG_HEADER\n return `${base}\\n${section}`\n}\n","/**\n * `addedAt` ledger — tracks, per generator, the ISO date each model id was\n * FIRST seen by a sync run. See `README.md` (\"addedAt convention\") for the\n * full contract; this module is the mechanism.\n *\n * Invariant: once an id has a ledger entry, that date is NEVER overwritten —\n * not even if the source's own `created` timestamp for that id later\n * resolves to something different (a provider backdating/correcting its own\n * metadata must not rewrite catalog history). New ids are backfilled from\n * the source's own creation timestamp when it has one, else stamped with\n * the current run's date.\n *\n * Ledger entries are never dropped when an id disappears from a run — the\n * ledger records \"first ever seen\", not \"currently present\". A model that\n * vanishes from a provider's list and later reappears keeps its original\n * `addedAt` rather than looking newly added.\n *\n * Each generator owns one ledger file, committed at\n * `packages/catalog-sync/ledger/<generator-id>.json` (id → ISO date, sorted\n * keys, deterministic serialization) — included as a normal entry in the\n * generator's `GeneratedFiles` return value, so `runner.ts`'s existing\n * diff/write logic covers it for free (including `--check` drift detection).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/** The catalog-sync package directory — see `runner.ts`'s `catalogSyncDir`. */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a generator's committed addedAt ledger. */\nexport function ledgerAbsPath(ledgerId: string): string {\n return join(catalogSyncDir(), \"ledger\", `${ledgerId}.json`)\n}\n\n/** Repo-relative path for a ledger — for inclusion in a generator's `GeneratedFiles`. */\nexport function ledgerRelPath(ledgerId: string): string {\n return `packages/catalog-sync/ledger/${ledgerId}.json`\n}\n\nexport type AddedAtLedger = Record<string, string>\n\n/** Reads a committed ledger from disk. Missing/unparseable → empty ledger. */\nexport function readLedger(ledgerId: string): AddedAtLedger {\n const path = ledgerAbsPath(ledgerId)\n if (!existsSync(path)) return {}\n try {\n const parsed: unknown = JSON.parse(readFileSync(path, \"utf8\"))\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return {}\n return parsed as AddedAtLedger\n } catch {\n return {}\n }\n}\n\n/** Deterministic (sorted-key) JSON serialization, matching the `*.generated.ts` style of a trailing newline. */\nexport function serializeLedger(ledger: AddedAtLedger): string {\n const sorted: AddedAtLedger = {}\n for (const id of Object.keys(ledger).sort()) sorted[id] = ledger[id]!\n return `${JSON.stringify(sorted, null, 2)}\\n`\n}\n\n/**\n * Merge the current run's ids into a ledger.\n *\n * - id already in `previous` → keep the existing stamp verbatim (never\n * mutated), regardless of what `createdAt` says this run.\n * - id new to the ledger, source has a native creation timestamp for it →\n * backfill with `createdAt[id]`.\n * - id new to the ledger, no native timestamp → stamp with `today`.\n * - ids in `previous` but absent from `currentIds` this run are kept as-is\n * (see module doc comment — the ledger is \"first ever seen\").\n */\nexport function computeAddedAtLedger(\n currentIds: readonly string[],\n previous: AddedAtLedger,\n createdAt: Readonly<Record<string, string>>,\n today: string\n): AddedAtLedger {\n const next: AddedAtLedger = { ...previous }\n for (const id of currentIds) {\n if (next[id] !== undefined) continue\n next[id] = createdAt[id] ?? today\n }\n return next\n}\n\n/** Today's date as `YYYY-MM-DD`, in UTC. */\nexport function todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\n/** Converts a provider's Unix-seconds creation timestamp to `YYYY-MM-DD`. */\nexport function isoDateFromUnixSeconds(seconds: number): string {\n return new Date(seconds * 1000).toISOString().slice(0, 10)\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\nimport { appendChangelog, diffModelIds, type GeneratorChangelogEntry } from \"./changelog.js\"\nimport { todayIso } from \"./added-at.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/**\n * The catalog-sync package directory. Resolves the same way whether the\n * module is loaded from `src/` (vitest, type-checking) or `dist/` (built) —\n * both sit one level below the package root, so walking up one directory\n * from this file lands on `packages/catalog-sync/`.\n */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a committed/pinned source snapshot. */\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\n/**\n * The monorepo root. Resolved by walking up from the catalog-sync package\n * until `pnpm-workspace.yaml` is found. Generated-file paths in\n * {@link GeneratedFiles} are repo-relative and are resolved against this.\n */\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n // Fallback: catalog-sync lives at <root>/packages/catalog-sync.\n return dirname(dirname(catalogSyncDir()))\n}\n\n/** Reads an existing file as UTF-8, or returns undefined when absent. */\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\n/**\n * Resolve `env:VAR_NAME` tokens inside header values from `process.env`.\n * Returns the materialized headers plus the names of any referenced env vars\n * that are unset — the caller uses `missing` to decide whether the source can\n * be refreshed (we never fetch an authed endpoint without its key).\n */\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n/** Repo-relative path of the human-readable model-add/remove log (see `changelog.ts`). */\nexport const CATALOG_CHANGELOG_PATH = \"packages/model-catalog/CATALOG-CHANGELOG.md\"\n\n/** Generated files whose top-level id keys are worth diffing for the changelog. */\nfunction isChangelogEligible(relPath: string): boolean {\n if (!relPath.endsWith(\".generated.ts\")) return false\n // The catalog-sync/generated/ dir is gitignored scratch output: on every\n // fresh run (the weekly Action) the file isn't on disk, so `existing` is\n // undefined and the id diff reports the whole roster as \"Added\" — one\n // identical changelog section per sync. Only tracked outputs (the consumed\n // model-catalog artifacts) carry a meaningful before/after diff.\n if (relPath.startsWith(\"packages/catalog-sync/generated/\")) return false\n return true\n}\n\nexport interface RunGeneratorsOptions {\n /** When true, missing snapshots are fetched from their pinned `url`. */\n refresh: boolean\n /** When true, generated files are written to disk at their repo-relative path. */\n write: boolean\n}\n\nexport interface RunGeneratorsResult {\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from what is on disk. */\n changed: string[]\n}\n\n/**\n * Runs each generator, gathering its emitted files, then (optionally) writes\n * them. `changed` is ALWAYS computed — it is the diff of generated content\n * vs disk — so `--check` (write=false) can surface drift without mutating\n * anything. Writes only happen when `write=true` AND a path differs.\n *\n * Also appends `CATALOG_CHANGELOG_PATH` (see `changelog.ts`) when this run's\n * per-generator diffs add or remove any model id — folded into the same\n * `files`/`changed` bookkeeping as every other generated file, so `--check`\n * catches an un-committed changelog entry too.\n */\nexport async function runGenerators(\n gens: CatalogGenerator[],\n opts: RunGeneratorsOptions\n): Promise<RunGeneratorsResult> {\n const files: GeneratedFiles = {}\n const pathToGenerator: Record<string, string> = {}\n\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n\n // Offline path (default): reuse the committed snapshot; error if none.\n if (!opts.refresh) {\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" ` +\n `(${path}), and --refresh is not set. Run ` +\n `\\`catalog-sync generate --refresh\\` to fetch ${src.url}.`\n )\n }\n\n // --refresh: force a live re-fetch (do NOT short-circuit on an existing\n // snapshot — refreshing is the whole point). Auth headers may embed\n // `env:VAR` tokens; if a referenced var is unset we can't authenticate,\n // so reuse the committed snapshot rather than fetch unauthenticated.\n const { headers, missing } = resolveHeaders(src.headers)\n if (missing.length > 0) {\n if (existing !== undefined) {\n process.stderr.write(\n `catalog-sync: skipping refresh of \"${src.id}\" — missing env ` +\n `${missing.join(\", \")}; reusing committed snapshot.\\n`\n )\n return JSON.parse(existing)\n }\n throw new Error(\n `catalog-sync: cannot refresh \"${src.id}\" — missing env ` +\n `${missing.join(\", \")} and no committed snapshot.`\n )\n }\n const res = await fetch(src.url, {\n method: src.method ?? \"GET\",\n headers,\n ...(src.body !== undefined\n ? { body: JSON.stringify(src.body) }\n : {}),\n })\n if (!res.ok) {\n throw new Error(\n `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`\n )\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, `${JSON.stringify(parsed, null, 2)}\\n`, \"utf8\")\n return parsed\n },\n }\n\n const out = await gen.generate(ctx)\n for (const [path, content] of Object.entries(out)) {\n files[path] = content\n pathToGenerator[path] = gen.name\n }\n }\n\n const root = repoRoot()\n const changed: string[] = []\n const changelogEntries: GeneratorChangelogEntry[] = []\n for (const [relPath, content] of Object.entries(files)) {\n const abs = join(root, relPath)\n const existing = readIfExists(abs)\n if (existing !== content) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, content, \"utf8\")\n }\n }\n if (isChangelogEligible(relPath)) {\n const { added, removed } = diffModelIds(existing, content)\n if (added.length > 0 || removed.length > 0) {\n changelogEntries.push({ generator: pathToGenerator[relPath] ?? relPath, added, removed })\n }\n }\n }\n\n // CATALOG-CHANGELOG.md: appended (never touched when there's nothing to\n // report) from the per-generator id diffs gathered above. Goes through the\n // same changed/write bookkeeping as any other generated file.\n const changelogAbs = join(root, CATALOG_CHANGELOG_PATH)\n const changelogExisting = readIfExists(changelogAbs)\n const newChangelog = appendChangelog(changelogExisting, todayIso(), changelogEntries)\n if (newChangelog !== undefined) {\n files[CATALOG_CHANGELOG_PATH] = newChangelog\n changed.push(CATALOG_CHANGELOG_PATH)\n if (opts.write) {\n mkdirSync(dirname(changelogAbs), { recursive: true })\n writeFileSync(changelogAbs, newChangelog, \"utf8\")\n }\n }\n\n return { files, changed }\n}\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n isoDateFromUnixSeconds,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * PINNED source. The OpenRouter `/api/v1/models` payload lists every route\n * the router exposes with per-token USD pricing. We never fetch it at build\n * or test time — only behind `--refresh`, which writes\n * `snapshots/llm-openrouter.json` so the next offline run is deterministic.\n */\nconst OPENROUTER_MODELS_URL = \"https://openrouter.ai/api/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/openrouter-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// OpenRouter prices are STRINGS of USD-per-token (e.g. \"0.000003\" = $3/1M).\n// `input_cache_read` / `input_cache_write` are optional and only present for\n// models that support prompt caching (Anthropic, etc.). These are the REAL\n// OpenRouter field names (verified against the live /v1/models payload) — an\n// earlier draft used `cache_read`/`cache_write`, which never matched, so cache\n// multipliers were silently always absent. passthrough() keeps the other live\n// keys (web_search, image, audio, internal_reasoning, input_cache_write_1h)\n// forward-compatible without a regenerate — we only read what we model.\n\nconst PricingSchema = z\n .object({\n prompt: z.string().optional(),\n completion: z.string().optional(),\n input_cache_read: z.string().optional(),\n input_cache_write: z.string().optional(),\n })\n .passthrough()\n\n// `created` is Unix seconds — OpenRouter's own route-creation timestamp,\n// used to backfill `addedAt` for ids not already in the ledger (see\n// `../added-at.ts`). Verified present on the live payload (2026-08-31).\nconst ModelSchema = z\n .object({\n id: z.string(),\n pricing: PricingSchema.optional(),\n created: z.number().optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/openrouter-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier / cacheWriteMultiplier WHEN the source\n// carries cache_read / cache_write. The existing committed file omits cache\n// fields; this generator emits them when present (per the P3 spec: \"plus\n// cache fields if the source has them\"). Fields are optional on LLMPricing,\n// so the output remains drop-in compatible.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: \"openrouter\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Convert a per-token USD string to USD-per-1M-tokens, or undefined if unpriced. */\nfunction per1m(tokenPrice: string | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n const n = Number(tokenPrice)\n if (!Number.isFinite(n)) return undefined\n return round6(n * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the OpenRouter route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:openrouter).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${OPENROUTER_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus cache\",\n \"// multipliers (cacheReadMultiplier / cacheWriteMultiplier) derived from the\",\n \"// source's input_cache_read / input_cache_write per-token fields when present.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `created` timestamp, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const OPENROUTER_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as OpenRouter routes by the picker. */\")\n lines.push(\"export const OPENROUTER_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nconst LEDGER_ID = \"llm-openrouter\"\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:openrouter: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n const createdAt: Record<string, string> = {}\n for (const model of parsed.data) {\n const pricing = model.pricing\n if (!pricing) continue\n const inputPer1M = per1m(pricing.prompt)\n const outputPer1M = per1m(pricing.completion)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes (e.g. openrouter/auto, which carries \"0\" pricing).\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"openrouter\",\n }\n\n const cacheReadPer1M = per1m(pricing.input_cache_read)\n const cacheWritePer1M = per1m(pricing.input_cache_write)\n if (cacheReadPer1M !== undefined && cacheReadPer1M > 0 && inputPer1M > 0) {\n entry.cacheReadMultiplier = round6(cacheReadPer1M / inputPer1M)\n }\n if (cacheWritePer1M !== undefined && cacheWritePer1M > 0 && inputPer1M > 0) {\n entry.cacheWriteMultiplier = round6(cacheWritePer1M / inputPer1M)\n }\n\n entries[model.id] = entry\n if (model.created !== undefined) createdAt[model.id] = isoDateFromUnixSeconds(model.created)\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(LEDGER_ID),\n createdAt,\n todayIso()\n )\n for (const [id, entry] of Object.entries(entries)) entry.addedAt = ledger[id]\n\n return {\n [OUTPUT_PATH]: serializeFile(entries),\n [ledgerRelPath(LEDGER_ID)]: serializeLedger(ledger),\n }\n}\n\nconst sources = [{ id: \"llm-openrouter\", url: OPENROUTER_MODELS_URL }]\n\nexport const llmOpenRouterGenerator = defineGenerator({\n name: \"llm:openrouter\",\n modality: \"llm\",\n sources,\n generate,\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n isoDateFromUnixSeconds,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * PINNED source. The Requesty `/v1/models` payload lists every route the\n * router exposes with per-token USD pricing. We never fetch it at build or\n * test time — only behind `--refresh`, which writes\n * `snapshots/llm-requesty.json` so the next offline run is deterministic.\n * Live fetch requires `Authorization: Bearer $REQUESTY_API_KEY` (see\n * `sources` below) — without the key set, the framework reuses the\n * committed snapshot rather than fetching unauthenticated.\n */\nconst REQUESTY_MODELS_URL = \"https://router.requesty.ai/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/requesty-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// UNLIKE OpenRouter, Requesty prices are JSON **numbers** in USD-PER-TOKEN\n// (e.g. `4e-7` = $0.40/1M), not strings, and live flat on the model entry\n// rather than nested under a `pricing` object. `cached_price` is a cache\n// READ price (no cache-write price exists in this source — we never emit\n// `cacheWriteMultiplier`). `supports_caching` gates whether `cached_price`\n// is actually meaningful: some entries carry a non-zero `cached_price` with\n// `supports_caching: false` (cache pricing published but not offered), so\n// the multiplier must only be derived when the flag is true. passthrough()\n// keeps the other live keys (context_window, supports_vision, description,\n// …) forward-compatible without a regenerate — we only read what we model.\n\n// `created` is Unix seconds — Requesty's own route-creation timestamp, used\n// to backfill `addedAt` for ids not already in the ledger (see\n// `../added-at.ts`). Verified present on the live payload (2026-08-31).\nconst ModelSchema = z\n .object({\n id: z.string(),\n input_price: z.number().optional(),\n output_price: z.number().optional(),\n cached_price: z.number().optional(),\n supports_caching: z.boolean().optional(),\n created: z.number().optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/requesty-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier when the source carries a meaningful\n// `cached_price`. No `cacheWriteMultiplier` — Requesty has no cache-write\n// price to derive one from.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: \"requesty\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/**\n * Convert a per-token USD number to USD-per-1M-tokens, or undefined if\n * unpriced. UNLIKE OpenRouter (per-token USD strings), Requesty already\n * gives per-token USD as a JSON number, so there's no `Number(...)` parse\n * step — just the same ×1e6 + round6 normalization.\n */\nfunction per1m(tokenPrice: number | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n if (!Number.isFinite(tokenPrice)) return undefined\n return round6(tokenPrice * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the Requesty route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:requesty).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${REQUESTY_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus a cache\",\n \"// multiplier (cacheReadMultiplier) derived from the source's cached_price\",\n \"// per-token field when `supports_caching` is true. Requesty has no\",\n \"// cache-write price, so cacheWriteMultiplier is never emitted.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `created` timestamp, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const REQUESTY_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as Requesty routes by the picker. */\")\n lines.push(\"export const REQUESTY_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nconst LEDGER_ID = \"llm-requesty\"\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:requesty: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n const createdAt: Record<string, string> = {}\n for (const model of parsed.data) {\n const inputPer1M = per1m(model.input_price)\n const outputPer1M = per1m(model.output_price)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes.\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"requesty\",\n }\n\n if (model.supports_caching === true && inputPer1M > 0) {\n const cachePer1M = per1m(model.cached_price)\n if (cachePer1M !== undefined) {\n entry.cacheReadMultiplier = round6(cachePer1M / inputPer1M)\n }\n }\n\n entries[model.id] = entry\n if (model.created !== undefined) createdAt[model.id] = isoDateFromUnixSeconds(model.created)\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(LEDGER_ID),\n createdAt,\n todayIso()\n )\n for (const [id, entry] of Object.entries(entries)) entry.addedAt = ledger[id]\n\n return {\n [OUTPUT_PATH]: serializeFile(entries),\n [ledgerRelPath(LEDGER_ID)]: serializeLedger(ledger),\n }\n}\n\nconst sources = [\n {\n id: \"llm-requesty\",\n url: REQUESTY_MODELS_URL,\n // Live refresh needs the account key (Bearer). Without REQUESTY_API_KEY\n // set, the framework reuses the committed snapshot.\n headers: { Authorization: \"Bearer env:REQUESTY_API_KEY\" },\n },\n]\n\nexport const llmRequestyGenerator = defineGenerator({\n name: \"llm:requesty\",\n modality: \"llm\",\n sources,\n generate,\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * OpenCode's two hosted billing endpoints, both sourced from models.dev.\n *\n * - `opencode-go` — OpenCode Go, the flat $10/mo API-key subscription.\n * - `opencode` — OpenCode Zen, the pay-as-you-go sibling.\n *\n * They are DIFFERENT endpoints with different per-model prices and different\n * model lineups (Go serves no Claude/Gemini; Zen serves both), so each gets\n * its own generator, ledger, snapshot and route table. They only share a\n * source URL and an env var name (`OPENCODE_API_KEY` — see the note in\n * `@agentproto/model-catalog`'s `PROVIDER_KEY_ENV`: same name, two distinct\n * secrets).\n *\n * PINNED source. models.dev's `api.json` is the whole ecosystem's catalog\n * (~4.6 MB, 213 providers) and is fetched UNAUTHENTICATED — unlike Requesty,\n * there is no key to gate the refresh on, so `sources` carries no headers and\n * `--refresh` always hits the live URL.\n *\n * Because the payload is 4.6 MB and we model two providers out of 213, the\n * committed snapshot is a PROJECTION, not the raw response: each generator\n * emits `snapshots/<ledger-id>.json` as one of its {@link GeneratedFiles},\n * narrowed to its own provider and to the fields below, with deterministic key\n * order. The runner's `--refresh` writes the raw response to that path first\n * and this projection immediately overwrites it in the same run, so a refresh\n * never leaves 4.6 MB of unrelated providers in the tree. The projection keeps\n * the SOURCE's own shape (nested `provider.npm`, nested `cost`), so\n * {@link SnapshotSchema} parses the raw payload and the committed projection\n * identically and re-projecting a projection is a no-op.\n */\nconst MODELS_DEV_URL = \"https://models.dev/api.json\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// Everything is optional + passthrough: this schema is applied to the FULL\n// models.dev payload (213 providers), so one unrelated provider drifting a\n// field must not break our two generators. Prices are USD **per 1M tokens\n// ALREADY** (`cost.input: 1.4` = $1.40/1M) — unlike Requesty's per-token\n// numbers, so there is no ×1e6 conversion here. `cost.cache_read` /\n// `cost.cache_write` are absolute per-1M prices too, from which the\n// multipliers are derived. `cost.tiers` / `cost.context_over_200k` exist on\n// some entries and are deliberately NOT modelled: LLMPricing has no tiered\n// shape, and inventing one from an un-consumed field would be fabricated\n// pricing.\n\nconst ModelSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().optional(),\n family: z.string().optional(),\n /** ISO `YYYY-MM-DD` already — no unix-seconds conversion (cf. Requesty). */\n release_date: z.string().optional(),\n provider: z\n .object({\n /** Which AI-SDK package serves this model — the ONLY discriminator\n * for the endpoint's three wire surfaces (see\n * {@link anthropicSurfaceIds}). */\n npm: z.string().optional(),\n })\n .passthrough()\n .optional(),\n cost: z\n .object({\n input: z.number().optional(),\n output: z.number().optional(),\n cache_read: z.number().optional(),\n cache_write: z.number().optional(),\n })\n .passthrough()\n .optional(),\n })\n .passthrough()\n\ntype SourceModel = z.infer<typeof ModelSchema>\n\nconst ProviderSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().optional(),\n /** The endpoint's base URL, e.g. `https://opencode.ai/zen/go/v1`. */\n api: z.string().optional(),\n doc: z.string().optional(),\n env: z.array(z.string()).optional(),\n npm: z.string().optional(),\n models: z.record(z.string(), ModelSchema).optional(),\n })\n .passthrough()\n\ntype SourceProvider = z.infer<typeof ProviderSchema>\n\n/** models.dev's whole payload is `{ [providerId]: provider }`; a committed\n * projection is the same map narrowed to one key. */\nconst SnapshotSchema = z.record(z.string(), ProviderSchema)\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: string\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the division. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Shortest faithful decimal string (matches the other generated files). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/**\n * A cache price relative to the base input price. Only meaningful when the\n * base price is positive: every `-free` variant on Zen carries\n * `cost.input: 0` alongside `cost.cache_read: 0`, and 0/0 is NaN — a free\n * model has no cache DISCOUNT to express, so no multiplier is emitted.\n */\nfunction cacheMultiplier(\n cachePer1M: number | undefined,\n inputPer1M: number\n): number | undefined {\n if (cachePer1M === undefined || !Number.isFinite(cachePer1M)) return undefined\n if (inputPer1M <= 0) return undefined\n return round6(cachePer1M / inputPer1M)\n}\n\n// ── Vendor attribution ──────────────────────────────────────────────────\n\n/**\n * Model id prefix → vendor (who BUILT the model), matched in order.\n *\n * HEURISTIC by necessity: models.dev's opencode/opencode-go entries carry\n * BARE product ids (`glm-5.3`, not `z-ai/glm-5.3`) and no vendor field at\n * all — `family` is a product line (`glm`, `deepseek-flash`), not a builder.\n * Each slug below is the one the repo's own catalog already uses for that\n * builder (verified against `OPENROUTER_ROUTES`' `vendor` values, which is\n * why it's `x-ai` and not `xai`, `moonshotai` and not `moonshot`), and each\n * attribution was cross-checked against another models.dev provider that\n * namespaces the SAME id under its builder (`inclusionai/ling-3.0-flash`,\n * `nvidia/nemotron-3-super-…`, `arcee-ai/trinity-large-…`,\n * `poolside/laguna-s-2.1`, `cohere/north-mini-code`, `meta/muse-spark-1.2`).\n * A new id that matches nothing here falls back to `opencode` — the handful\n * of unattributed ids on these endpoints (`omen-alpha`, `ox-alpha-free`,\n * `big-pickle`, `x-preview-f-free`) are opencode's own stealth/preview\n * models with no disclosed builder.\n *\n * `vendor` is METADATA on the pricing entry. It is NOT the route key: the\n * route tables are keyed `<provider>/<bare-id>` (see {@link routeKey}), so a\n * mis-attributed vendor can never mis-route or mis-bill a spawn.\n */\nconst VENDOR_BY_ID_PREFIX: ReadonlyArray<readonly [RegExp, string]> = [\n [/^claude-/, \"anthropic\"],\n [/^gemini-/, \"google\"],\n [/^gpt-/, \"openai\"],\n [/^grok-/, \"x-ai\"],\n [/^glm-/, \"z-ai\"],\n [/^kimi-/, \"moonshotai\"],\n [/^deepseek-/, \"deepseek\"],\n [/^minimax-/, \"minimax\"],\n [/^qwen/, \"qwen\"],\n [/^mimo-/, \"xiaomi\"],\n [/^hy\\d/, \"tencent\"],\n [/^longcat-/, \"meituan\"],\n [/^(ling|ring)-/, \"inclusionai\"],\n [/^nemotron-/, \"nvidia\"],\n [/^trinity-/, \"arcee-ai\"],\n [/^laguna-/, \"poolside\"],\n [/^north-/, \"cohere\"],\n [/^muse-spark-/, \"meta\"],\n]\n\n/** Vendor for a bare model id — see {@link VENDOR_BY_ID_PREFIX}. */\nexport function vendorForOpencodeModelId(bareId: string): string {\n for (const [pattern, vendor] of VENDOR_BY_ID_PREFIX) {\n if (pattern.test(bareId)) return vendor\n }\n return \"opencode\"\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\n/**\n * Route-table key: `<provider>/<bare-id>` — `opencode-go/glm-5.3`,\n * `opencode/claude-sonnet-4-6`.\n *\n * Deliberately NOT `<vendor>/<product>` like the OpenRouter / Requesty\n * tables. Those routers namespace their own ids by vendor, so their keys\n * round-trip through route-identity's `vendor/product@route` grammar.\n * models.dev gives these two endpoints BARE ids, and opencode's own config\n * spells them `opencode-go/glm-5.3` — which is also the form the runtime\n * derives the billing endpoint from (`modelIdPrefixProvider`) and the form\n * the opencode adapter puts on the wire. Keying by the provider makes all\n * three agree on one string, and `route-identity`'s opencode branches key\n * off exactly this (see the comment there for why they must run ahead of the\n * direct-vendor branch).\n */\nfunction routeKey(provider: string, bareId: string): string {\n return `${provider}/${bareId}`\n}\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\n/** One endpoint's identity — everything the emitted files need to describe it. */\ninterface OpencodeEndpoint {\n /** models.dev provider key, and this repo's `CatalogProvider` value. */\n providerKey: string\n /** Generator + snapshot + ledger id. */\n ledgerId: string\n /** `llm:<name>` generator name. */\n generatorName: string\n /** Repo-relative emitted route table. */\n outputPath: string\n /** Exported route-table const. */\n routesConst: string\n /** Exported Anthropic-surface id list const. */\n anthropicConst: string\n /** Human label, used only in generated comments. */\n label: string\n}\n\nconst GO: OpencodeEndpoint = {\n providerKey: \"opencode-go\",\n ledgerId: \"llm-opencode-go\",\n generatorName: \"llm:opencode-go\",\n outputPath: \"packages/model-catalog/src/llm/opencode-go-routes.generated.ts\",\n routesConst: \"OPENCODE_GO_ROUTES\",\n anthropicConst: \"OPENCODE_GO_ANTHROPIC_MODELS\",\n label: \"OpenCode Go\",\n}\n\nconst ZEN: OpencodeEndpoint = {\n providerKey: \"opencode\",\n ledgerId: \"llm-opencode-zen\",\n generatorName: \"llm:opencode-zen\",\n outputPath: \"packages/model-catalog/src/llm/opencode-zen-routes.generated.ts\",\n routesConst: \"OPENCODE_ZEN_ROUTES\",\n anthropicConst: \"OPENCODE_ZEN_ANTHROPIC_MODELS\",\n label: \"OpenCode Zen\",\n}\n\nfunction serializeFile(\n endpoint: OpencodeEndpoint,\n entries: Record<string, LLMPricingEntry>,\n anthropicIds: readonly string[]\n): string {\n const keys = Object.keys(entries).sort()\n\n const lines: string[] = [\n `// AUTO-GENERATED by @agentproto/catalog-sync (${endpoint.generatorName}).`,\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${MODELS_DEV_URL} (provider \"${endpoint.providerKey}\" — ${endpoint.label})`,\n \"// Prices come VERBATIM from the source's cost.input / cost.output, which\",\n \"// models.dev already publishes as USD per 1M tokens (no per-token\",\n \"// conversion, unlike the Requesty table). cacheReadMultiplier /\",\n \"// cacheWriteMultiplier are cost.cache_read / cost.cache_write expressed\",\n \"// relative to cost.input, and are omitted when the base input price is 0\",\n \"// (every `-free` variant) because a free model has no cache discount.\",\n \"// Zero-priced models are KEPT — on these endpoints zero is the truth, not\",\n \"// a missing price.\",\n \"// Keys are `<provider>/<bare-id>`, the form opencode's own config uses and\",\n \"// the form the runtime derives the billing endpoint from; `vendor` is a\",\n \"// heuristic attribution of the model's BUILDER and is metadata only.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `release_date`, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n `export const ${endpoint.routesConst}: Record<string, LLMPricing> = {`,\n ]\n for (const key of keys) {\n lines.push(` ${JSON.stringify(key)}: ${serializeEntry(entries[key]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/**\")\n lines.push(` * BARE ids on ${endpoint.label} whose wire surface is the Anthropic Messages`)\n lines.push(\" * API — the source's `provider.npm === \\\"@ai-sdk/anthropic\\\"`. These are the\")\n lines.push(\" * ONLY ids reachable through the Anthropic-compatible gateway preset of the\")\n lines.push(\" * same name (claude-code / claude-sdk); the rest of the endpoint's lineup\")\n lines.push(\" * speaks OpenAI chat/completions or the OpenAI Responses API and has to go\")\n lines.push(\" * through the opencode adapter instead. Bare (not `<provider>/<id>`) because\")\n lines.push(\" * that is what an Anthropic client puts in `ANTHROPIC_MODEL` / on the wire.\")\n lines.push(\" */\")\n lines.push(`export const ${endpoint.anthropicConst}: readonly string[] = [`)\n for (const id of [...anthropicIds].sort()) {\n lines.push(` ${JSON.stringify(id)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Snapshot projection ─────────────────────────────────────────────────\n\n/** The committed snapshot's per-model shape — a strict subset of the source's\n * own, so one schema parses both. */\ninterface ProjectedModel {\n id?: string\n name?: string\n family?: string\n release_date?: string\n provider?: { npm: string }\n cost?: {\n input?: number\n output?: number\n cache_read?: number\n cache_write?: number\n }\n}\n\n/** The committed snapshot's per-provider shape (see {@link ProjectedModel}). */\ninterface ProjectedProvider {\n id?: string\n name?: string\n api?: string\n doc?: string\n env?: readonly string[]\n npm?: string\n models: Record<string, ProjectedModel>\n}\n\n/**\n * Narrow the raw models.dev payload to one provider and to the fields this\n * generator models, with deterministic (sorted) model order and a fixed field\n * order. Shape-identical to the source, so {@link SnapshotSchema} parses this\n * projection and re-projecting it is a no-op — which is what makes `--check`\n * drift detection meaningful on the snapshot itself.\n */\nfunction projectSnapshot(providerKey: string, provider: SourceProvider): string {\n const models: Record<string, ProjectedModel> = {}\n for (const bareId of Object.keys(provider.models ?? {}).sort()) {\n const model = provider.models?.[bareId]\n if (!model) continue\n // Object-literal spreads, not assignments: JSON.stringify emits keys in\n // insertion order, so a FIXED literal order is what makes the committed\n // snapshot byte-stable across runs.\n models[bareId] = {\n ...(model.id !== undefined ? { id: model.id } : {}),\n ...(model.name !== undefined ? { name: model.name } : {}),\n ...(model.family !== undefined ? { family: model.family } : {}),\n ...(model.release_date !== undefined ? { release_date: model.release_date } : {}),\n ...(model.provider?.npm !== undefined ? { provider: { npm: model.provider.npm } } : {}),\n ...(model.cost !== undefined\n ? {\n cost: {\n ...(model.cost.input !== undefined ? { input: model.cost.input } : {}),\n ...(model.cost.output !== undefined ? { output: model.cost.output } : {}),\n ...(model.cost.cache_read !== undefined\n ? { cache_read: model.cost.cache_read }\n : {}),\n ...(model.cost.cache_write !== undefined\n ? { cache_write: model.cost.cache_write }\n : {}),\n },\n }\n : {}),\n }\n }\n\n const projected: ProjectedProvider = {\n ...(provider.id !== undefined ? { id: provider.id } : {}),\n ...(provider.name !== undefined ? { name: provider.name } : {}),\n ...(provider.api !== undefined ? { api: provider.api } : {}),\n ...(provider.doc !== undefined ? { doc: provider.doc } : {}),\n ...(provider.env !== undefined ? { env: provider.env } : {}),\n ...(provider.npm !== undefined ? { npm: provider.npm } : {}),\n models,\n }\n\n return `${JSON.stringify({ [providerKey]: projected }, null, 2)}\\n`\n}\n\n/** Repo-relative snapshot path for a source id — mirrors `runner.ts`'s\n * `snapshotPath`, expressed repo-relative so the projection can ride along\n * in {@link GeneratedFiles}. */\nfunction snapshotRelPath(ledgerId: string): string {\n return `packages/catalog-sync/snapshots/${ledgerId}.json`\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\n/**\n * The bare ids served on the Anthropic Messages surface. models.dev\n * discriminates an endpoint's wire surfaces per model via `provider.npm`:\n * absent ⇒ OpenAI chat/completions, `@ai-sdk/anthropic` ⇒ Anthropic\n * Messages, `@ai-sdk/openai` ⇒ OpenAI Responses, `@ai-sdk/google` ⇒ Gemini.\n * Only the Anthropic set is emitted, because that is the one a caller has to\n * know: it is exactly what the gateway preset can serve.\n */\nfunction anthropicSurfaceIds(models: Readonly<Record<string, SourceModel>>): string[] {\n return Object.entries(models)\n .filter(([, model]) => model.provider?.npm === \"@ai-sdk/anthropic\")\n .map(([bareId]) => bareId)\n .sort()\n}\n\nasync function generateFor(\n endpoint: OpencodeEndpoint,\n source: { id: string; url: string },\n ctx: GeneratorContext\n): Promise<GeneratedFiles> {\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(source))\n const provider = parsed[endpoint.providerKey]\n if (!provider) {\n throw new Error(\n `${endpoint.generatorName}: models.dev payload carries no \"${endpoint.providerKey}\" provider ` +\n `(source ${source.url}). Refusing to emit an empty route table.`\n )\n }\n const models = provider.models ?? {}\n\n const entries: Record<string, LLMPricingEntry> = {}\n const releasedAt: Record<string, string> = {}\n for (const [bareId, model] of Object.entries(models)) {\n const inputPer1M = model.cost?.input\n const outputPer1M = model.cost?.output\n // An entry with no published price at all is skipped: a fabricated 0 would\n // read as \"free\" to the billing surface. An explicit 0 IS kept (the `-free`\n // variants) — see the header comment in the emitted file.\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n if (!Number.isFinite(inputPer1M) || !Number.isFinite(outputPer1M)) continue\n\n const key = routeKey(endpoint.providerKey, bareId)\n const entry: LLMPricingEntry = {\n inputPer1M: round6(inputPer1M),\n outputPer1M: round6(outputPer1M),\n vendor: vendorForOpencodeModelId(bareId),\n provider: endpoint.providerKey,\n }\n const read = cacheMultiplier(model.cost?.cache_read, inputPer1M)\n if (read !== undefined) entry.cacheReadMultiplier = read\n const write = cacheMultiplier(model.cost?.cache_write, inputPer1M)\n if (write !== undefined) entry.cacheWriteMultiplier = write\n\n entries[key] = entry\n if (model.release_date !== undefined) releasedAt[key] = model.release_date\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(endpoint.ledgerId),\n releasedAt,\n todayIso()\n )\n for (const [key, entry] of Object.entries(entries)) entry.addedAt = ledger[key]\n\n return {\n [endpoint.outputPath]: serializeFile(endpoint, entries, anthropicSurfaceIds(models)),\n [ledgerRelPath(endpoint.ledgerId)]: serializeLedger(ledger),\n [snapshotRelPath(endpoint.ledgerId)]: projectSnapshot(endpoint.providerKey, provider),\n }\n}\n\n/** models.dev needs no credential, so `headers` is deliberately absent — the\n * runner only reuses a committed snapshot instead of refreshing when a\n * referenced env var is missing, and there is none to miss here. */\nconst goSources = [{ id: GO.ledgerId, url: MODELS_DEV_URL }]\nconst zenSources = [{ id: ZEN.ledgerId, url: MODELS_DEV_URL }]\n\nexport const llmOpencodeGoGenerator = defineGenerator({\n name: GO.generatorName,\n modality: \"llm\",\n sources: goSources,\n generate: ctx => generateFor(GO, goSources[0]!, ctx),\n})\n\nexport const llmOpencodeZenGenerator = defineGenerator({\n name: ZEN.generatorName,\n modality: \"llm\",\n sources: zenSources,\n generate: ctx => generateFor(ZEN, zenSources[0]!, ctx),\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\n\n/**\n * PINNED source. The HuggingFace router `/v1/models` payload lists every\n * model the router knows about, each carrying a per-model `providers[]`\n * array — one entry per inference provider currently serving it. We never\n * fetch it at build or test time — only behind `--refresh`, which writes\n * `snapshots/llm-huggingface.json` so the next offline run is deterministic.\n * No auth required — the listing endpoint returns HTTP 200 unauthenticated\n * (verified 2026-07-18).\n */\nconst HUGGINGFACE_MODELS_URL = \"https://router.huggingface.co/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/huggingface-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// Every per-provider field except `provider`/`status` is optional — some\n// entries are sparse (provider+status only). `pricing.input`/`pricing.output`\n// are USD-PER-1M-TOKENS NUMBERS (unlike OpenRouter's per-token strings),\n// already at the scale LLMPricing expects — no ×1e6 conversion needed.\n// passthrough() keeps unread live fields (owned_by, architecture, is_free,\n// throughput, …) forward-compatible without a regenerate — we only read\n// what we model.\n\nconst HFProviderSchema = z\n .object({\n provider: z.string(),\n status: z.string(),\n context_length: z.number().optional(),\n pricing: z\n .object({\n input: z.number().optional(),\n output: z.number().optional(),\n })\n .optional(),\n supports_tools: z.boolean().optional(),\n supports_structured_output: z.boolean().optional(),\n })\n .passthrough()\n\nconst HFModelSchema = z\n .object({\n id: z.string(),\n providers: z.array(HFProviderSchema).optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(HFModelSchema),\n})\n\n// ── Output shape (drop-in for model-catalog's route-identity resolver) ────\n\ninterface HuggingFaceRouteProviderEntry {\n provider: string\n status: string\n contextLength?: number\n inputPer1M?: number\n outputPer1M?: number\n supportsTools?: boolean\n supportsStructuredOutput?: boolean\n}\n\ninterface HuggingFaceRouteEntry {\n wireId: string\n providers: HuggingFaceRouteProviderEntry[]\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 4 decimal places, killing binary-float noise from the source payload. */\nfunction round4(n: number): number {\n return Math.round(n * 10_000) / 10_000\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeProvider(p: HuggingFaceRouteProviderEntry): string {\n const fields: string[] = [\n `provider: ${JSON.stringify(p.provider)}`,\n `status: ${JSON.stringify(p.status)}`,\n ]\n if (p.contextLength !== undefined) fields.push(`contextLength: ${p.contextLength}`)\n if (p.inputPer1M !== undefined) fields.push(`inputPer1M: ${p.inputPer1M}`)\n if (p.outputPer1M !== undefined) fields.push(`outputPer1M: ${p.outputPer1M}`)\n if (p.supportsTools !== undefined) fields.push(`supportsTools: ${p.supportsTools}`)\n if (p.supportsStructuredOutput !== undefined) {\n fields.push(`supportsStructuredOutput: ${p.supportsStructuredOutput}`)\n }\n return ` {\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeEntry(id: string, e: HuggingFaceRouteEntry): string {\n const providerLines = e.providers.map(serializeProvider).join(\",\\n\")\n return [\n ` ${JSON.stringify(id)}: {`,\n ` wireId: ${JSON.stringify(e.wireId)},`,\n ` providers: [`,\n providerLines,\n ` ],`,\n ` },`,\n ].join(\"\\n\")\n}\n\nfunction serializeFile(entries: Record<string, HuggingFaceRouteEntry>): string {\n const ids = Object.keys(entries).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:huggingface).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${HUGGINGFACE_MODELS_URL}`,\n \"// Per-model LIVE inference providers from the HuggingFace router. HF wire\",\n \"// ids are case-sensitive and preserved verbatim. Provider entries are\",\n \"// SPARSE on some models — every field below except provider/status is\",\n \"// optional and emitted only when the upstream response carries it. Only\",\n '// providers with status === \"live\" are kept; models with zero live',\n \"// providers are skipped. inputPer1M/outputPer1M are USD per 1M tokens\",\n \"// (HuggingFace router convention — already at that scale, unlike\",\n \"// OpenRouter's per-token strings).\",\n \"\",\n \"export interface HuggingFaceRouteProvider {\",\n \" provider: string\",\n \" status: string\",\n \" contextLength?: number\",\n \" inputPer1M?: number\",\n \" outputPer1M?: number\",\n \" supportsTools?: boolean\",\n \" supportsStructuredOutput?: boolean\",\n \"}\",\n \"\",\n \"export interface HuggingFaceRoute {\",\n \" wireId: string\",\n \" providers: HuggingFaceRouteProvider[]\",\n \"}\",\n \"\",\n \"export const HUGGINGFACE_ROUTES: Record<string, HuggingFaceRoute> = {\",\n ]\n for (const id of ids) {\n lines.push(serializeEntry(id, entries[id]!))\n }\n lines.push(\"}\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:huggingface: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, HuggingFaceRouteEntry> = {}\n for (const model of parsed.data) {\n const liveProviders = (model.providers ?? []).filter((p) => p.status === \"live\")\n if (liveProviders.length === 0) continue\n\n const providers: HuggingFaceRouteProviderEntry[] = liveProviders\n .map((p) => {\n const entry: HuggingFaceRouteProviderEntry = {\n provider: p.provider,\n status: p.status,\n }\n if (p.context_length !== undefined) entry.contextLength = p.context_length\n if (p.pricing?.input !== undefined) entry.inputPer1M = round4(p.pricing.input)\n if (p.pricing?.output !== undefined) entry.outputPer1M = round4(p.pricing.output)\n if (p.supports_tools !== undefined) entry.supportsTools = p.supports_tools\n if (p.supports_structured_output !== undefined) {\n entry.supportsStructuredOutput = p.supports_structured_output\n }\n return entry\n })\n .sort((a, b) => a.provider.localeCompare(b.provider))\n\n entries[model.id] = { wireId: model.id, providers }\n }\n\n return { [OUTPUT_PATH]: serializeFile(entries) }\n}\n\nconst sources = [\n {\n id: \"llm-huggingface\",\n url: HUGGINGFACE_MODELS_URL,\n },\n]\n\nexport const llmHuggingfaceGenerator = defineGenerator({\n name: \"llm:huggingface\",\n modality: \"llm\",\n sources,\n generate,\n})\n","/**\n * Shared CatalogVoice[] → TS-source serializer for the voice generators.\n *\n * The mapping (raw provider JSON → CatalogVoice) lives in\n * `@agentproto/model-catalog/providers` so build time and runtime share it;\n * this module only turns the mapped voices into a committed `*.generated.ts`.\n * Field emit order is fixed (matches the historical generator output) so the\n * generated file stays diff-stable across runs.\n */\n\nimport type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"\n\nfunction serializeVoice(v: CatalogVoice): string {\n const lines: string[] = [\" {\"]\n lines.push(` catalogId: ${JSON.stringify(v.catalogId)},`)\n lines.push(` providerVoiceId: ${JSON.stringify(v.providerVoiceId)},`)\n lines.push(` provider: ${JSON.stringify(v.provider)},`)\n lines.push(` label: ${JSON.stringify(v.label)},`)\n lines.push(` description: ${JSON.stringify(v.description)},`)\n lines.push(` gender: ${JSON.stringify(v.gender)},`)\n lines.push(` primaryLanguage: ${JSON.stringify(v.primaryLanguage)},`)\n lines.push(\n ` supportedLanguages: [${v.supportedLanguages.map(l => JSON.stringify(l)).join(\", \")}],`,\n )\n if (v.quality !== undefined) lines.push(` quality: ${JSON.stringify(v.quality)},`)\n if (v.featured !== undefined) lines.push(` featured: ${v.featured},`)\n if (v.samplePath !== undefined) lines.push(` samplePath: ${JSON.stringify(v.samplePath)},`)\n if (v.age !== undefined) lines.push(` age: ${JSON.stringify(v.age)},`)\n lines.push(\" },\")\n return lines.join(\"\\n\")\n}\n\n/**\n * Render a full generated voice module.\n *\n * @param generatorName e.g. `voice:elevenlabs` (goes in the header comment)\n * @param exportName e.g. `ELEVENLABS_VOICES`\n * @param voices mapped voices, in emit order\n */\nexport function serializeVoiceModule(\n generatorName: string,\n exportName: string,\n voices: readonly CatalogVoice[],\n): string {\n const lines: string[] = [\n `// Generated by @agentproto/catalog-sync generator ${generatorName}`,\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n 'import type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"',\n \"\",\n `export const ${exportName}: readonly CatalogVoice[] = [`,\n ]\n for (const v of voices) lines.push(serializeVoice(v))\n lines.push(\"] as const\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n","/**\n * voice-elevenlabs generator — reads the ElevenLabs /v1/voices snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n ElevenLabsVoicesSnapshotSchema,\n mapElevenLabsVoices,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (and is the single,\n// dist-safe reader; generators never touch the filesystem themselves).\nexport const ELEVENLABS_SOURCE: CatalogSource = {\n id: \"voice-elevenlabs\",\n url: \"https://api.elevenlabs.io/v1/voices\",\n // Live refresh needs the account key; offline reads ignore this.\n headers: { \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-elevenlabs.generated.ts\"\n\nexport const voiceElevenlabs: CatalogGenerator = defineGenerator({\n name: \"voice:elevenlabs\",\n modality: \"voice\",\n sources: [ELEVENLABS_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = ElevenLabsVoicesSnapshotSchema.parse(\n await ctx.fetchSource(ELEVENLABS_SOURCE),\n )\n const voices = mapElevenLabsVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:elevenlabs\",\n \"ELEVENLABS_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * voice-minimax generator — reads the MiniMax /v1/get_voice snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n mapMinimaxVoices,\n MinimaxVoicesSnapshotSchema,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const MINIMAX_SOURCE: CatalogSource = {\n id: \"voice-minimax\",\n url: \"https://api.minimax.io/v1/get_voice\",\n // get_voice is a POST; live refresh needs the account key (Bearer). Without\n // MINIMAX_API_KEY set, the framework reuses the committed snapshot.\n method: \"POST\",\n headers: {\n Authorization: \"Bearer env:MINIMAX_API_KEY\",\n \"Content-Type\": \"application/json\",\n },\n body: { voice_type: \"system\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-minimax.generated.ts\"\n\nexport const voiceMinimax: CatalogGenerator = defineGenerator({\n name: \"voice:minimax\",\n modality: \"voice\",\n sources: [MINIMAX_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = MinimaxVoicesSnapshotSchema.parse(\n await ctx.fetchSource(MINIMAX_SOURCE),\n )\n const voices = mapMinimaxVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:minimax\",\n \"MINIMAX_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * image-replicate generator — reads a curated Replicate image-models\n * snapshot and emits ImageModelDefinition[]-shaped generated TS entries.\n *\n * Mirrors the shape from packages/model-catalog/src/image/catalog.ts exactly.\n * Provider-native ids only; no product-specific aliases.\n */\n\nimport { z } from \"zod\"\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\n\n// ── Replicate snapshot shapes ───────────────────────────────────────────\n\ninterface ReplicateOpenApiSchema {\n input: { type: string; properties: Record<string, { type: string; items?: { type: string }; format?: string }> }\n output: { type: string; items?: { type: string; format?: string }; format?: string }\n}\n\ninterface ReplicateLatestVersion {\n id: string\n created_at: string\n openapi_schema: ReplicateOpenApiSchema\n}\n\ninterface ReplicateModel {\n owner: string\n name: string\n description: string | null\n visibility: string\n run_count: number\n cover_image_url: string | null\n latest_version: ReplicateLatestVersion\n}\n\n// The live Replicate API returns DRF-paginated `{results, next, previous}`,\n// while the committed snapshot is hand-authored `{_meta, models}`. Accept both.\n// The API can return `description: null` for some models (observed in live run).\nconst ReplicateModelSchema = z\n .object({\n owner: z.string(),\n name: z.string(),\n description: z.string().nullable(),\n visibility: z.string(),\n run_count: z.number(),\n cover_image_url: z.string().nullable(),\n latest_version: z.object({\n id: z.string(),\n created_at: z.string(),\n openapi_schema: z.any(),\n }),\n })\n .passthrough()\n\nconst ReplicateSnapshotSchema = z\n .object({\n // DRF-paginated shape (live API)\n results: z.array(ReplicateModelSchema).optional(),\n next: z.string().nullable().optional(),\n previous: z.string().nullable().optional(),\n // Hand-authored fixture shape (committed snapshot)\n _meta: z.record(z.string(), z.unknown()).optional(),\n models: z.array(ReplicateModelSchema).optional(),\n })\n .passthrough()\n\ntype ReplicateSnapshot = z.infer<typeof ReplicateSnapshotSchema>\n\n// ── ImageModelDefinition mirror (from packages/model-catalog/src/image/catalog.ts) ──\n\ninterface ImageModelPricing {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n billingUnit: \"per_image\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\ninterface ImageModelCapabilities {\n generate: boolean\n edit: boolean\n upscale?: boolean\n}\n\ninterface ImageModelReferenceImages {\n supported: boolean\n fieldName: \"image_input\" | \"input_images\" | \"input_image\" | \"none\"\n maxCount: number\n singular: boolean\n}\n\ninterface ImageModelAspectRatio {\n supported: string[]\n default: string\n}\n\ninterface ImageModelEntry {\n id: string\n name: string\n providerId: string\n provider: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n pricing: ImageModelPricing\n description: string\n agentVisible: boolean\n triggerWord?: string\n}\n\n// ── Pricing (hand-authored, mirrors model-catalog) ──────────────────────\n\ninterface PricingRecord {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\nconst PRICING: Record<string, PricingRecord> = {\n \"nano-banana-pro\": { costPerImage: 0.15, costTier: \"high\", baseCost: 0.15, creditCost: 10 },\n \"nano-banana-2\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 5 },\n \"nano-banana\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-2-dev\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"flux-kontext-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-kontext-max\": { costPerImage: 0.08, costTier: \"medium\", baseCost: 0.08, creditCost: 8 },\n \"flux-1.1-pro-ultra\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 8 },\n \"seedream-4\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"recraft-v3\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"image-01\": { costPerImage: 0.02, costTier: \"low\", baseCost: 0.02, creditCost: 2 },\n \"gpt-image-1\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"ideogram-v3-turbo\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 4 },\n \"flux-1.1-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n}\n\n// Models visible to agents (the active generation ones)\nconst AGENT_VISIBLE = new Set([\n \"nano-banana-pro\",\n \"nano-banana-2\",\n \"nano-banana\",\n \"flux-2-dev\",\n \"flux-kontext-pro\",\n \"flux-kontext-max\",\n \"flux-1.1-pro-ultra\",\n \"seedream-4\",\n \"recraft-v3\",\n \"image-01\",\n \"gpt-image-1\",\n \"ideogram-v3-turbo\",\n])\n\nconst ASPECT_RATIOS_DEFAULT: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_WIDE: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\", \"4:5\", \"5:4\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_ULTRA: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"21:9\", \"9:21\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_NBPRO: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\", \"21:9\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_NB2: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_SQUARE: ImageModelAspectRatio = {\n supported: [\"1:1\"],\n default: \"1:1\",\n}\n\ninterface ModelSpec {\n id: string\n name: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n triggerWord?: string\n}\n\nconst MODEL_SPECS: Record<string, ModelSpec> = {\n \"nano-banana-pro\": {\n id: \"nano-banana-pro\",\n name: \"Nano Banana Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 14, singular: false },\n aspectRatio: ASPECT_RATIOS_NBPRO,\n output: \"string\",\n },\n \"nano-banana-2\": {\n id: \"nano-banana-2\",\n name: \"Nano Banana 2\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_NB2,\n output: \"string\",\n },\n \"nano-banana\": {\n id: \"nano-banana\",\n name: \"Nano Banana\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-2-dev\": {\n id: \"flux-2-dev\",\n name: \"Flux 2 Dev\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_images\", maxCount: 5, singular: false },\n aspectRatio: ASPECT_RATIOS_WIDE,\n output: \"string\",\n },\n \"flux-kontext-pro\": {\n id: \"flux-kontext-pro\",\n name: \"Flux Kontext Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-kontext-max\": {\n id: \"flux-kontext-max\",\n name: \"Flux Kontext Max\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-1.1-pro-ultra\": {\n id: \"flux-1.1-pro-ultra\",\n name: \"Flux 1.1 Pro Ultra\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_ULTRA,\n output: \"string\",\n },\n \"seedream-4\": {\n id: \"seedream-4\",\n name: \"SeedReam 4\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 10, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"recraft-v3\": {\n id: \"recraft\",\n name: \"Recraft V3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_SQUARE,\n output: \"string\",\n },\n \"image-01\": {\n id: \"minimax\",\n name: \"MiniMax Image\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"3:4\", \"4:3\"], default: \"1:1\" },\n output: \"array\",\n },\n \"gpt-image-1\": {\n id: \"gpt-image-1\",\n name: \"OpenAI GPT Image 1\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: { supported: [\"1:1\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"ideogram-v3-turbo\": {\n id: \"ideogram-v3\",\n name: \"Ideogram v3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"flux-1.1-pro\": {\n id: \"flux\",\n name: \"Flux 1.1 Pro\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\"], default: \"1:1\" },\n output: \"string\",\n },\n}\n\nfunction mapModel(raw: ReplicateModel): ImageModelEntry {\n const providerId = `${raw.owner}/${raw.name}`\n const spec = MODEL_SPECS[raw.name] ?? {\n id: raw.name,\n name: raw.name,\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\" as const, maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\" as const,\n }\n\n const pricing = PRICING[raw.name] ?? {\n costPerImage: 0.03,\n costTier: \"low\" as const,\n baseCost: 0.03,\n creditCost: 3,\n }\n\n return {\n id: spec.id,\n name: spec.name,\n providerId,\n provider: raw.owner === \"openai\" ? \"openai\" : raw.owner === \"minimax\" ? \"minimax\" : \"replicate\",\n capabilities: spec.capabilities,\n referenceImages: spec.referenceImages,\n aspectRatio: spec.aspectRatio,\n output: spec.output,\n pricing: {\n costPerImage: pricing.costPerImage,\n costTier: pricing.costTier,\n billingUnit: \"per_image\" as const,\n baseCost: pricing.baseCost,\n ...(pricing.creditCost !== undefined ? { creditCost: pricing.creditCost } : {}),\n ...(pricing.overrideCreditCost !== undefined ? { overrideCreditCost: pricing.overrideCreditCost } : {}),\n },\n description: raw.description ?? \"\",\n agentVisible: AGENT_VISIBLE.has(raw.name),\n ...(spec.triggerWord ? { triggerWord: spec.triggerWord } : {}),\n }\n}\n\n// ── Generator ────────────────────────────────────────────────────────────\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\n// The Replicate models endpoint is authed. Declare the token as an `env:` header\n// token so the runner's missing-env gate (runner.ts `resolveHeaders`) SKIPS the\n// refresh and reuses the committed snapshot when `REPLICATE_API_TOKEN` is absent\n// — exactly like the authed LLM sources (Anthropic/Groq/xAI/Moonshot). Without\n// this a token-less `catalog-sync generate --refresh` fetched unauthenticated,\n// 401'd, and threw — crashing the whole run for anyone (or the weekly Action)\n// without the secret. `--check` never fetches, so it is unaffected.\nexport const REPLICATE_SOURCE: CatalogSource = {\n id: \"image-replicate\",\n url: \"https://api.replicate.com/v1/collections/text-to-image\",\n headers: { Authorization: \"Bearer env:REPLICATE_API_TOKEN\" },\n}\n\nexport const imageReplicate: CatalogGenerator = defineGenerator({\n name: \"image:replicate\",\n modality: \"image\",\n sources: [REPLICATE_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const raw = await ctx.fetchSource(REPLICATE_SOURCE)\n const data = ReplicateSnapshotSchema.parse(raw)\n\n // Normalize: extract models from either `results` (live API) or `models` (fixture)\n const models = data.results ?? data.models\n if (!models) {\n throw new Error(\n \"Replicate snapshot has neither `results` nor `models` array — invalid shape\"\n )\n }\n\n // Filter to curated models only — live API returns unfiltered mix (text LLMs, video, etc.)\n const curatedModels = models.filter(m => MODEL_SPECS[m.name])\n if (curatedModels.length === 0) {\n const sampleNames = [...AGENT_VISIBLE].slice(0, 3).join(\", \")\n throw new Error(\n `image:replicate: none of the curated models (${sampleNames}…) present in source payload (${models.length} entries) — API shape or roster drift`\n )\n }\n\n const entries = curatedModels.map(mapModel)\n\n const lines: string[] = [\n \"// Generated by @agentproto/catalog-sync generator image:replicate\",\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n \"import type { ImageModelDefinition } from \\\"@agentproto/model-catalog/image\\\"\",\n \"\",\n \"export const REPLICATE_IMAGE_MODELS: Record<string, ImageModelDefinition> = {\",\n ]\n\n for (const e of entries) {\n const trigger = e.triggerWord ? `,\\n triggerWord: ${JSON.stringify(e.triggerWord)}` : \"\"\n const creditCost = e.pricing.creditCost !== undefined\n ? `,\\n creditCost: ${e.pricing.creditCost}`\n : \"\"\n const override = e.pricing.overrideCreditCost !== undefined\n ? `,\\n overrideCreditCost: ${e.pricing.overrideCreditCost}`\n : \"\"\n\n lines.push(` ${JSON.stringify(e.id)}: {`)\n lines.push(` id: ${JSON.stringify(e.id)},`)\n lines.push(` name: ${JSON.stringify(e.name)},`)\n lines.push(` providerId: ${JSON.stringify(e.providerId)},`)\n lines.push(` provider: ${JSON.stringify(e.provider)},`)\n lines.push(` capabilities: { generate: ${e.capabilities.generate}, edit: ${e.capabilities.edit}${e.capabilities.upscale ? `, upscale: ${e.capabilities.upscale}` : \"\"} },`)\n lines.push(` referenceImages: {`)\n lines.push(` supported: ${e.referenceImages.supported},`)\n lines.push(` fieldName: ${JSON.stringify(e.referenceImages.fieldName)},`)\n lines.push(` maxCount: ${e.referenceImages.maxCount},`)\n lines.push(` singular: ${e.referenceImages.singular},`)\n lines.push(` },`)\n lines.push(` aspectRatio: {`)\n lines.push(` supported: [${e.aspectRatio.supported.map(a => JSON.stringify(a)).join(\", \")}],`)\n lines.push(` default: ${JSON.stringify(e.aspectRatio.default)},`)\n lines.push(` },`)\n lines.push(` output: ${JSON.stringify(e.output)},`)\n lines.push(` pricing: {`)\n lines.push(` costPerImage: ${e.pricing.costPerImage},`)\n lines.push(` costTier: ${JSON.stringify(e.pricing.costTier)},`)\n lines.push(` billingUnit: ${JSON.stringify(e.pricing.billingUnit)},`)\n lines.push(` baseCost: ${e.pricing.baseCost},${creditCost}${override}`)\n lines.push(` },`)\n lines.push(` description: ${JSON.stringify(e.description)},`)\n lines.push(` agentVisible: ${e.agentVisible},${trigger}`)\n lines.push(` },`)\n }\n\n lines.push(\"}\")\n lines.push(\"\")\n\n const outputPath = \"packages/catalog-sync/generated/image-replicate.generated.ts\"\n return { [outputPath]: lines.join(\"\\n\") }\n },\n})\n","/**\n * Reviewed refresh workflow for catalog-sync.\n *\n * Extends the existing generator framework with explicit, reviewable diffs and\n * source-level metadata so operators can see exactly what changed and why.\n *\n * Design constraints (per project convention):\n * - Pricing is never fabricated.\n * - Refresh only hits pinned source URLs; unrefreshable sources are skipped\n * with an explanation.\n * - The committed snapshot is the single source of truth for offline runs.\n * - Availability-only local cache stays separate from the reviewed refresh.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return dirname(dirname(catalogSyncDir()))\n}\n\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n// ── Source metadata ────────────────────────────────────────────────────────\n\n/**\n * Source-level refresh metadata. Wraps a frozen {@link CatalogSource} without\n * mutating it, so existing generators keep compiling unchanged.\n */\nexport interface RefreshableSource {\n source: CatalogSource\n /** When false, the source is skipped by --refresh and documented in results. */\n refreshable: boolean\n /** Human-readable explanation of the source contract or gap. */\n notes?: string\n}\n\nexport interface SourceRefreshResult {\n id: string\n url: string\n /** True when a live fetch was attempted and succeeded. */\n refreshed: boolean\n /** True when the source is known to be unrefreshable. */\n skipped?: boolean\n /** Human-readable status / gap explanation. */\n notes?: string\n /** Present when refresh was attempted but failed. */\n error?: string\n}\n\n// ── File diff ──────────────────────────────────────────────────────────────\n\nexport interface CatalogFileDiff {\n /** Repo-relative path. */\n path: string\n /** Content currently on disk, or undefined when the file does not exist. */\n before: string | undefined\n /** Generated content. */\n after: string\n /** True when before !== after. */\n changed: boolean\n}\n\n// ── Options / result ───────────────────────────────────────────────────────\n\nexport interface ReviewedRefreshOptions {\n /** When true, attempt live fetches for refreshable sources. */\n refresh: boolean\n /** When true, write generated files to disk. */\n write: boolean\n /**\n * Optional fetch implementation for tests. Defaults to the global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\nexport interface ReviewedRefreshResult {\n /** Generated repo-relative path → content. */\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from disk. */\n changed: string[]\n /** Per-file before/after reviewable diffs. */\n diffs: CatalogFileDiff[]\n /** Per-source refresh status. */\n sources: SourceRefreshResult[]\n}\n\n// ── Implementation ─────────────────────────────────────────────────────────\n\n/**\n * Fetch every refreshable source and record the outcome.\n *\n * Unrefreshable sources (e.g. OpenAI, which has no stable pricing endpoint)\n * are reported as skipped rather than silently ignored or scraped.\n */\nexport async function refreshSources(\n sources: RefreshableSource[],\n opts: Pick<ReviewedRefreshOptions, \"refresh\" | \"fetchImpl\">\n): Promise<SourceRefreshResult[]> {\n const results: SourceRefreshResult[] = []\n const fetchImpl = opts.fetchImpl ?? fetch\n\n for (const { source, refreshable, notes } of sources) {\n if (!opts.refresh) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n notes: \"Offline mode: using committed snapshot.\",\n })\n continue\n }\n\n if (!refreshable) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n skipped: true,\n notes: notes ?? \"Source is not refreshable.\",\n })\n continue\n }\n\n const { headers, missing } = resolveHeaders(source.headers)\n if (missing.length > 0) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `Missing env vars: ${missing.join(\", \")}`,\n })\n continue\n }\n\n try {\n const res = await fetchImpl(source.url, {\n method: source.method ?? \"GET\",\n headers,\n ...(source.body !== undefined\n ? { body: JSON.stringify(source.body) }\n : {}),\n })\n if (!res.ok) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `${res.status} ${res.statusText}`,\n })\n continue\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(snapshotPath(source.id)), { recursive: true })\n writeFileSync(\n snapshotPath(source.id),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf8\"\n )\n results.push({\n id: source.id,\n url: source.url,\n refreshed: true,\n notes: \"Snapshot updated from live source.\",\n })\n } catch (err) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: err instanceof Error ? err.message : String(err),\n })\n }\n }\n\n return results\n}\n\n/**\n * Run generators using the current snapshots (whether refreshed or committed)\n * and produce reviewable file diffs.\n */\nexport async function reviewedRefresh(\n gens: CatalogGenerator[],\n refreshableSources: RefreshableSource[],\n opts: ReviewedRefreshOptions\n): Promise<ReviewedRefreshResult> {\n const sourceResults = await refreshSources(refreshableSources, opts)\n\n const files: GeneratedFiles = {}\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" (${path}).`\n )\n },\n }\n const out = await gen.generate(ctx)\n Object.assign(files, out)\n }\n\n const root = repoRoot()\n const diffs: CatalogFileDiff[] = []\n const changed: string[] = []\n\n for (const [relPath, after] of Object.entries(files)) {\n const abs = join(root, relPath)\n const before = readIfExists(abs)\n const isChanged = before !== after\n diffs.push({ path: relPath, before, after, changed: isChanged })\n if (isChanged) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, after, \"utf8\")\n }\n }\n }\n\n return { files, changed, diffs, sources: sourceResults }\n}\n","/**\n * OpenAI LLM source contract.\n *\n * OpenAI does **not** publish a stable, machine-readable pricing/model catalog\n * endpoint. The authoritative pricing page is `openai.com/api/pricing`, but it\n * is HTML-only, not a documented API, and has historically changed layout\n * without notice.\n *\n * Therefore this source is intentionally **not refreshable** in the automated\n * `catalog-sync` workflow. Pricing is committed by hand from the official page\n * and cross-checked with third-party aggregators where noted. We do not scrape\n * or guess.\n *\n * If OpenAI releases a stable `/v1/models` endpoint that includes pricing, or\n * a documented pricing JSON feed, this source can be upgraded to refreshable.\n * Until then, the gap is recorded honestly in refresh results.\n */\n\nimport type { RefreshableSource } from \"../refresh-workflow.js\"\n\nexport const OPENAI_LLM_SOURCE: RefreshableSource = {\n source: {\n id: \"llm-openai\",\n url: \"https://openai.com/api/pricing\",\n },\n refreshable: false,\n notes:\n \"OpenAI has no stable machine-readable pricing endpoint. \" +\n \"Pricing in @agentproto/model-catalog is committed manually from \" +\n \"openai.com/api/pricing and verified against independent aggregators \" +\n \"where possible. Automated refresh is disabled to avoid scraping or \" +\n \"fabricating prices.\",\n}\n\n/** Convenience array for workflows that want to include the OpenAI contract. */\nexport const OPENAI_SOURCES: RefreshableSource[] = [OPENAI_LLM_SOURCE]\n"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/changelog.ts","../src/added-at.ts","../src/runner.ts","../src/generators/llm-openrouter.ts","../src/generators/llm-requesty.ts","../src/generators/llm-opencode.ts","../src/generators/llm-huggingface.ts","../src/generators/serialize-voices.ts","../src/generators/voice-elevenlabs.ts","../src/generators/voice-minimax.ts","../src/generators/image-replicate.ts","../src/refresh-workflow.ts","../src/sources/openai.ts"],"names":["__dirname","dirname","fileURLToPath","catalogSyncDir","resolve","join","existsSync","readFileSync","OUTPUT_PATH","ModelSchema","z","SnapshotSchema","round6","per1m","fmt","vendorOf","serializeEntry","serializeFile","LEDGER_ID","generate","sources","snapshotPath","repoRoot","readIfExists","resolveHeaders","mkdirSync","writeFileSync"],"mappings":";;;;;;;;;;;;;AAsDO,SAAS,gBAAgB,CAAA,EAAuC;AACrE,EAAA,OAAO,CAAA;AACT;;;ACjCA,IAAM,aAAA,GAAgB,wBAAA;AAGf,SAAS,iBAAiB,MAAA,EAA6B;AAC5D,EAAA,MAAM,GAAA,uBAAU,GAAA,EAAY;AAC5B,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,CAAO,QAAA,CAAS,aAAa,CAAA,EAAG;AAC9C,IAAA,IAAI,CAAA,CAAE,CAAC,CAAA,KAAM,MAAA,MAAe,GAAA,CAAI,CAAA,CAAE,CAAC,CAAC,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,GAAA;AACT;AAQO,SAAS,YAAA,CAAa,QAA4B,KAAA,EAA4B;AACnF,EAAA,MAAM,YAAY,MAAA,KAAW,MAAA,GAAY,iBAAiB,MAAM,CAAA,uBAAQ,GAAA,EAAY;AACpF,EAAA,MAAM,QAAA,GAAW,iBAAiB,KAAK,CAAA;AACvC,EAAA,MAAM,KAAA,GAAQ,CAAC,GAAG,QAAQ,EAAE,MAAA,CAAO,CAAC,EAAA,KAAO,CAAC,SAAA,CAAU,GAAA,CAAI,EAAE,CAAC,EAAE,IAAA,EAA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GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAC3C,QAAAyB,aAAAA,CAAc,GAAA,EAAK,KAAA,EAAO,MAAM,CAAA;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,SAAS,aAAA,EAAc;AACzD;;;AC9PO,IAAM,iBAAA,GAAuC;AAAA,EAClD,MAAA,EAAQ;AAAA,IACN,EAAA,EAAI,YAAA;AAAA,IACJ,GAAA,EAAK;AAAA,GACP;AAAA,EACA,WAAA,EAAa,KAAA;AAAA,EACb,KAAA,EACE;AAKJ;AAGO,IAAM,cAAA,GAAsC,CAAC,iBAAiB","file":"index.mjs","sourcesContent":["/**\n * catalog-sync generator contract.\n *\n * FROZEN — a sibling agent builds provider generators against this surface.\n * Do not change field names, shapes, or the `defineGenerator` signature\n * without coordinating. Adding new generators is the expected extension\n * path; editing this file is not.\n */\n\nexport interface CatalogSource {\n id: string\n url: string\n /** HTTP method for the live (`--refresh`) fetch. Default `\"GET\"`. */\n method?: \"GET\" | \"POST\"\n /**\n * Request headers for the live fetch. A value may embed `env:VAR_NAME`\n * tokens, resolved from `process.env` at fetch time (e.g.\n * `{ \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" }` or\n * `{ Authorization: \"Bearer env:MINIMAX_API_KEY\" }`). If any referenced env\n * var is unset, the source is treated as un-refreshable — the committed\n * snapshot is reused rather than fetched without auth. Offline reads\n * (default, no `--refresh`) ignore headers entirely.\n */\n headers?: Record<string, string>\n /** JSON request body for POST sources (e.g. MiniMax `get_voice`). */\n body?: unknown\n}\n\nexport interface GeneratorContext {\n /**\n * Reads the pinned snapshot at `snapshots/<src.id>.json`; if missing and\n * `refresh=true`, fetches `src.url` and writes the snapshot. Returns\n * parsed JSON.\n *\n * Offline by default: when no snapshot exists and `refresh` is false this\n * throws — generators MUST be runnable without network access so CI and\n * tests are deterministic. The only network path is behind `--refresh`.\n */\n fetchSource(src: CatalogSource): Promise<unknown>\n refresh: boolean\n}\n\n/** Repo-relative path → TS source text. */\nexport type GeneratedFiles = Record<string, string>\n\nexport interface CatalogGenerator {\n /** e.g. \"llm:openrouter\" */\n name: string\n modality: \"llm\" | \"image\" | \"video\" | \"audio\" | \"voice\"\n sources: CatalogSource[]\n generate(ctx: GeneratorContext): Promise<GeneratedFiles>\n}\n\n/** Identity helper — lets a generator module declare itself with type inference. */\nexport function defineGenerator(g: CatalogGenerator): CatalogGenerator {\n return g\n}\n","/**\n * `CATALOG-CHANGELOG.md` — a human-readable \"what models changed\" log,\n * distinct from the changesets-driven `CHANGELOG.md` next to it (that's\n * package-version history, one entry per publish). This file answers \"what\n * models did catalog-sync add or remove, and when\" by reading top-to-bottom.\n *\n * Wired into `runner.ts`: every `runGenerators` call diffs each changed\n * `*.generated.ts` file's top-level id keys (before vs after) and, when a\n * run actually adds or removes model ids for at least one generator,\n * APPENDS one dated section (`## YYYY-MM-DD`) with a `### <generator name>`\n * subsection per affected generator. Sections are appended at the END of\n * the file (newest last) — a plain, non-destructive `+=`, so the writer\n * never has to parse and re-emit prior history.\n *\n * A run with no id-level drift (pricing-only changes, or a `--check` with\n * nothing to report) appends NOTHING — no empty section, no touched file,\n * no diff. addedAt ledger files (`ledger/*.json`) are intentionally NOT\n * diffed here — they never lose an id (see `added-at.ts`), so they carry no\n * \"removed\" signal, and every id they'd report as \"added\" is already\n * covered by the generator's own `*.generated.ts` diff.\n */\n\n/** Matches a top-level (2-space-indented) quoted key of a `Record<string, X>` literal. */\nconst RECORD_KEY_RE = /^ {2}\"([^\"]+)\":\\s*\\{/gm\n\n/** Extracts the top-level quoted ids of a generated `Record<string, X>` map. */\nexport function extractRecordIds(source: string): Set<string> {\n const ids = new Set<string>()\n for (const m of source.matchAll(RECORD_KEY_RE)) {\n if (m[1] !== undefined) ids.add(m[1])\n }\n return ids\n}\n\nexport interface ModelIdDiff {\n added: string[]\n removed: string[]\n}\n\n/** Diffs the id sets of a generated file's before/after content. `before` undefined = new file (no removals possible). */\nexport function diffModelIds(before: string | undefined, after: string): ModelIdDiff {\n const beforeIds = before !== undefined ? extractRecordIds(before) : new Set<string>()\n const afterIds = extractRecordIds(after)\n const added = [...afterIds].filter((id) => !beforeIds.has(id)).sort()\n const removed = [...beforeIds].filter((id) => !afterIds.has(id)).sort()\n return { added, removed }\n}\n\nexport interface GeneratorChangelogEntry {\n /** The owning generator's `name` (e.g. `\"llm:openrouter\"`). */\n generator: string\n added: string[]\n removed: string[]\n}\n\n/** Renders a dated section, or `\"\"` when every entry is empty (nothing to report). */\nexport function renderChangelogSection(date: string, entries: readonly GeneratorChangelogEntry[]): string {\n const nonEmpty = entries.filter((e) => e.added.length > 0 || e.removed.length > 0)\n if (nonEmpty.length === 0) return \"\"\n const lines: string[] = [`## ${date}`, \"\"]\n for (const e of nonEmpty) {\n lines.push(`### ${e.generator}`)\n if (e.added.length > 0) lines.push(`- Added: ${e.added.join(\", \")}`)\n if (e.removed.length > 0) lines.push(`- Removed: ${e.removed.join(\", \")}`)\n lines.push(\"\")\n }\n return lines.join(\"\\n\").replace(/\\n+$/, \"\\n\")\n}\n\nexport const CATALOG_CHANGELOG_HEADER = `# Catalog Changelog\n\nHuman-readable log of model additions/removals detected by\n\\`@agentproto/catalog-sync\\` runs — NOT \\`CHANGELOG.md\\` next to it (that one is\nchangesets-driven package-version history). A dated section is appended\nautomatically here whenever a sync run adds or removes model ids; sections\nare appended at the END of the file (newest last). Pricing-only drift (no id\nadded/removed) is not logged here — see the generated files' own git history\nfor that.\n`\n\n/**\n * Appends a new dated section to `existing` changelog content.\n *\n * Returns `undefined` when there is nothing to report (no generator has an\n * added/removed id this run) — the caller should leave the file untouched\n * in that case, not write an unchanged copy.\n */\nexport function appendChangelog(\n existing: string | undefined,\n date: string,\n entries: readonly GeneratorChangelogEntry[]\n): string | undefined {\n const section = renderChangelogSection(date, entries)\n if (section === \"\") return undefined\n const base = existing !== undefined && existing.length > 0 ? existing.replace(/\\n+$/, \"\\n\") : CATALOG_CHANGELOG_HEADER\n return `${base}\\n${section}`\n}\n","/**\n * `addedAt` ledger — tracks, per generator, the ISO date each model id was\n * FIRST seen by a sync run. See `README.md` (\"addedAt convention\") for the\n * full contract; this module is the mechanism.\n *\n * Invariant: once an id has a ledger entry, that date is NEVER overwritten —\n * not even if the source's own `created` timestamp for that id later\n * resolves to something different (a provider backdating/correcting its own\n * metadata must not rewrite catalog history). New ids are backfilled from\n * the source's own creation timestamp when it has one, else stamped with\n * the current run's date.\n *\n * Ledger entries are never dropped when an id disappears from a run — the\n * ledger records \"first ever seen\", not \"currently present\". A model that\n * vanishes from a provider's list and later reappears keeps its original\n * `addedAt` rather than looking newly added.\n *\n * Each generator owns one ledger file, committed at\n * `packages/catalog-sync/ledger/<generator-id>.json` (id → ISO date, sorted\n * keys, deterministic serialization) — included as a normal entry in the\n * generator's `GeneratedFiles` return value, so `runner.ts`'s existing\n * diff/write logic covers it for free (including `--check` drift detection).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/** The catalog-sync package directory — see `runner.ts`'s `catalogSyncDir`. */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a generator's committed addedAt ledger. */\nexport function ledgerAbsPath(ledgerId: string): string {\n return join(catalogSyncDir(), \"ledger\", `${ledgerId}.json`)\n}\n\n/** Repo-relative path for a ledger — for inclusion in a generator's `GeneratedFiles`. */\nexport function ledgerRelPath(ledgerId: string): string {\n return `packages/catalog-sync/ledger/${ledgerId}.json`\n}\n\nexport type AddedAtLedger = Record<string, string>\n\n/** Reads a committed ledger from disk. Missing/unparseable → empty ledger. */\nexport function readLedger(ledgerId: string): AddedAtLedger {\n const path = ledgerAbsPath(ledgerId)\n if (!existsSync(path)) return {}\n try {\n const parsed: unknown = JSON.parse(readFileSync(path, \"utf8\"))\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return {}\n return parsed as AddedAtLedger\n } catch {\n return {}\n }\n}\n\n/** Deterministic (sorted-key) JSON serialization, matching the `*.generated.ts` style of a trailing newline. */\nexport function serializeLedger(ledger: AddedAtLedger): string {\n const sorted: AddedAtLedger = {}\n for (const id of Object.keys(ledger).sort()) sorted[id] = ledger[id]!\n return `${JSON.stringify(sorted, null, 2)}\\n`\n}\n\n/**\n * Merge the current run's ids into a ledger.\n *\n * - id already in `previous` → keep the existing stamp verbatim (never\n * mutated), regardless of what `createdAt` says this run.\n * - id new to the ledger, source has a native creation timestamp for it →\n * backfill with `createdAt[id]`.\n * - id new to the ledger, no native timestamp → stamp with `today`.\n * - ids in `previous` but absent from `currentIds` this run are kept as-is\n * (see module doc comment — the ledger is \"first ever seen\").\n */\nexport function computeAddedAtLedger(\n currentIds: readonly string[],\n previous: AddedAtLedger,\n createdAt: Readonly<Record<string, string>>,\n today: string\n): AddedAtLedger {\n const next: AddedAtLedger = { ...previous }\n for (const id of currentIds) {\n if (next[id] !== undefined) continue\n next[id] = createdAt[id] ?? today\n }\n return next\n}\n\n/** Today's date as `YYYY-MM-DD`, in UTC. */\nexport function todayIso(): string {\n return new Date().toISOString().slice(0, 10)\n}\n\n/** Converts a provider's Unix-seconds creation timestamp to `YYYY-MM-DD`. */\nexport function isoDateFromUnixSeconds(seconds: number): string {\n return new Date(seconds * 1000).toISOString().slice(0, 10)\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\nimport { appendChangelog, diffModelIds, type GeneratorChangelogEntry } from \"./changelog.js\"\nimport { todayIso } from \"./added-at.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/**\n * The catalog-sync package directory. Resolves the same way whether the\n * module is loaded from `src/` (vitest, type-checking) or `dist/` (built) —\n * both sit one level below the package root, so walking up one directory\n * from this file lands on `packages/catalog-sync/`.\n */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a committed/pinned source snapshot. */\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\n/**\n * The monorepo root. Resolved by walking up from the catalog-sync package\n * until `pnpm-workspace.yaml` is found. Generated-file paths in\n * {@link GeneratedFiles} are repo-relative and are resolved against this.\n */\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n // Fallback: catalog-sync lives at <root>/packages/catalog-sync.\n return dirname(dirname(catalogSyncDir()))\n}\n\n/** Reads an existing file as UTF-8, or returns undefined when absent. */\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\n/**\n * Resolve `env:VAR_NAME` tokens inside header values from `process.env`.\n * Returns the materialized headers plus the names of any referenced env vars\n * that are unset — the caller uses `missing` to decide whether the source can\n * be refreshed (we never fetch an authed endpoint without its key).\n */\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n/** Repo-relative path of the human-readable model-add/remove log (see `changelog.ts`). */\nexport const CATALOG_CHANGELOG_PATH = \"packages/model-catalog/CATALOG-CHANGELOG.md\"\n\n/** Generated files whose top-level id keys are worth diffing for the changelog. */\nfunction isChangelogEligible(relPath: string): boolean {\n if (!relPath.endsWith(\".generated.ts\")) return false\n // The catalog-sync/generated/ dir is gitignored scratch output: on every\n // fresh run (the weekly Action) the file isn't on disk, so `existing` is\n // undefined and the id diff reports the whole roster as \"Added\" — one\n // identical changelog section per sync. Only tracked outputs (the consumed\n // model-catalog artifacts) carry a meaningful before/after diff.\n if (relPath.startsWith(\"packages/catalog-sync/generated/\")) return false\n return true\n}\n\nexport interface RunGeneratorsOptions {\n /** When true, missing snapshots are fetched from their pinned `url`. */\n refresh: boolean\n /** When true, generated files are written to disk at their repo-relative path. */\n write: boolean\n}\n\nexport interface RunGeneratorsResult {\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from what is on disk. */\n changed: string[]\n}\n\n/**\n * Runs each generator, gathering its emitted files, then (optionally) writes\n * them. `changed` is ALWAYS computed — it is the diff of generated content\n * vs disk — so `--check` (write=false) can surface drift without mutating\n * anything. Writes only happen when `write=true` AND a path differs.\n *\n * Also appends `CATALOG_CHANGELOG_PATH` (see `changelog.ts`) when this run's\n * per-generator diffs add or remove any model id — folded into the same\n * `files`/`changed` bookkeeping as every other generated file, so `--check`\n * catches an un-committed changelog entry too.\n */\nexport async function runGenerators(\n gens: CatalogGenerator[],\n opts: RunGeneratorsOptions\n): Promise<RunGeneratorsResult> {\n const files: GeneratedFiles = {}\n const pathToGenerator: Record<string, string> = {}\n\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n\n // Offline path (default): reuse the committed snapshot; error if none.\n if (!opts.refresh) {\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" ` +\n `(${path}), and --refresh is not set. Run ` +\n `\\`catalog-sync generate --refresh\\` to fetch ${src.url}.`\n )\n }\n\n // --refresh: force a live re-fetch (do NOT short-circuit on an existing\n // snapshot — refreshing is the whole point). Auth headers may embed\n // `env:VAR` tokens; if a referenced var is unset we can't authenticate,\n // so reuse the committed snapshot rather than fetch unauthenticated.\n const { headers, missing } = resolveHeaders(src.headers)\n if (missing.length > 0) {\n if (existing !== undefined) {\n process.stderr.write(\n `catalog-sync: skipping refresh of \"${src.id}\" — missing env ` +\n `${missing.join(\", \")}; reusing committed snapshot.\\n`\n )\n return JSON.parse(existing)\n }\n throw new Error(\n `catalog-sync: cannot refresh \"${src.id}\" — missing env ` +\n `${missing.join(\", \")} and no committed snapshot.`\n )\n }\n const res = await fetch(src.url, {\n method: src.method ?? \"GET\",\n headers,\n ...(src.body !== undefined\n ? { body: JSON.stringify(src.body) }\n : {}),\n })\n if (!res.ok) {\n // A failing endpoint (e.g. xAI 403 on exhausted credits) must not\n // crash the whole multi-provider run when a committed snapshot\n // exists — degrade to offline, like the missing-env branch above.\n if (existing !== undefined) {\n process.stderr.write(\n `catalog-sync: skipping refresh of \"${src.id}\" — fetch ${src.url} ` +\n `failed: ${res.status} ${res.statusText}; reusing committed snapshot.\\n`\n )\n return JSON.parse(existing)\n }\n throw new Error(\n `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`\n )\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, `${JSON.stringify(parsed, null, 2)}\\n`, \"utf8\")\n return parsed\n },\n }\n\n const out = await gen.generate(ctx)\n for (const [path, content] of Object.entries(out)) {\n files[path] = content\n pathToGenerator[path] = gen.name\n }\n }\n\n const root = repoRoot()\n const changed: string[] = []\n const changelogEntries: GeneratorChangelogEntry[] = []\n for (const [relPath, content] of Object.entries(files)) {\n const abs = join(root, relPath)\n const existing = readIfExists(abs)\n if (existing !== content) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, content, \"utf8\")\n }\n }\n if (isChangelogEligible(relPath)) {\n const { added, removed } = diffModelIds(existing, content)\n if (added.length > 0 || removed.length > 0) {\n changelogEntries.push({ generator: pathToGenerator[relPath] ?? relPath, added, removed })\n }\n }\n }\n\n // CATALOG-CHANGELOG.md: appended (never touched when there's nothing to\n // report) from the per-generator id diffs gathered above. Goes through the\n // same changed/write bookkeeping as any other generated file.\n const changelogAbs = join(root, CATALOG_CHANGELOG_PATH)\n const changelogExisting = readIfExists(changelogAbs)\n const newChangelog = appendChangelog(changelogExisting, todayIso(), changelogEntries)\n if (newChangelog !== undefined) {\n files[CATALOG_CHANGELOG_PATH] = newChangelog\n changed.push(CATALOG_CHANGELOG_PATH)\n if (opts.write) {\n mkdirSync(dirname(changelogAbs), { recursive: true })\n writeFileSync(changelogAbs, newChangelog, \"utf8\")\n }\n }\n\n return { files, changed }\n}\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n isoDateFromUnixSeconds,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * PINNED source. The OpenRouter `/api/v1/models` payload lists every route\n * the router exposes with per-token USD pricing. We never fetch it at build\n * or test time — only behind `--refresh`, which writes\n * `snapshots/llm-openrouter.json` so the next offline run is deterministic.\n */\nconst OPENROUTER_MODELS_URL = \"https://openrouter.ai/api/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/openrouter-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// OpenRouter prices are STRINGS of USD-per-token (e.g. \"0.000003\" = $3/1M).\n// `input_cache_read` / `input_cache_write` are optional and only present for\n// models that support prompt caching (Anthropic, etc.). These are the REAL\n// OpenRouter field names (verified against the live /v1/models payload) — an\n// earlier draft used `cache_read`/`cache_write`, which never matched, so cache\n// multipliers were silently always absent. passthrough() keeps the other live\n// keys (web_search, image, audio, internal_reasoning, input_cache_write_1h)\n// forward-compatible without a regenerate — we only read what we model.\n\nconst PricingSchema = z\n .object({\n prompt: z.string().optional(),\n completion: z.string().optional(),\n input_cache_read: z.string().optional(),\n input_cache_write: z.string().optional(),\n })\n .passthrough()\n\n// `created` is Unix seconds — OpenRouter's own route-creation timestamp,\n// used to backfill `addedAt` for ids not already in the ledger (see\n// `../added-at.ts`). Verified present on the live payload (2026-08-31).\nconst ModelSchema = z\n .object({\n id: z.string(),\n pricing: PricingSchema.optional(),\n created: z.number().optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/openrouter-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier / cacheWriteMultiplier WHEN the source\n// carries cache_read / cache_write. The existing committed file omits cache\n// fields; this generator emits them when present (per the P3 spec: \"plus\n// cache fields if the source has them\"). Fields are optional on LLMPricing,\n// so the output remains drop-in compatible.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: \"openrouter\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Convert a per-token USD string to USD-per-1M-tokens, or undefined if unpriced. */\nfunction per1m(tokenPrice: string | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n const n = Number(tokenPrice)\n if (!Number.isFinite(n)) return undefined\n return round6(n * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the OpenRouter route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:openrouter).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${OPENROUTER_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus cache\",\n \"// multipliers (cacheReadMultiplier / cacheWriteMultiplier) derived from the\",\n \"// source's input_cache_read / input_cache_write per-token fields when present.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `created` timestamp, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const OPENROUTER_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as OpenRouter routes by the picker. */\")\n lines.push(\"export const OPENROUTER_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nconst LEDGER_ID = \"llm-openrouter\"\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:openrouter: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n const createdAt: Record<string, string> = {}\n for (const model of parsed.data) {\n const pricing = model.pricing\n if (!pricing) continue\n const inputPer1M = per1m(pricing.prompt)\n const outputPer1M = per1m(pricing.completion)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes (e.g. openrouter/auto, which carries \"0\" pricing).\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"openrouter\",\n }\n\n const cacheReadPer1M = per1m(pricing.input_cache_read)\n const cacheWritePer1M = per1m(pricing.input_cache_write)\n if (cacheReadPer1M !== undefined && cacheReadPer1M > 0 && inputPer1M > 0) {\n entry.cacheReadMultiplier = round6(cacheReadPer1M / inputPer1M)\n }\n if (cacheWritePer1M !== undefined && cacheWritePer1M > 0 && inputPer1M > 0) {\n entry.cacheWriteMultiplier = round6(cacheWritePer1M / inputPer1M)\n }\n\n entries[model.id] = entry\n if (model.created !== undefined) createdAt[model.id] = isoDateFromUnixSeconds(model.created)\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(LEDGER_ID),\n createdAt,\n todayIso()\n )\n for (const [id, entry] of Object.entries(entries)) entry.addedAt = ledger[id]\n\n return {\n [OUTPUT_PATH]: serializeFile(entries),\n [ledgerRelPath(LEDGER_ID)]: serializeLedger(ledger),\n }\n}\n\nconst sources = [{ id: \"llm-openrouter\", url: OPENROUTER_MODELS_URL }]\n\nexport const llmOpenRouterGenerator = defineGenerator({\n name: \"llm:openrouter\",\n modality: \"llm\",\n sources,\n generate,\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n isoDateFromUnixSeconds,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * PINNED source. The Requesty `/v1/models` payload lists every route the\n * router exposes with per-token USD pricing. We never fetch it at build or\n * test time — only behind `--refresh`, which writes\n * `snapshots/llm-requesty.json` so the next offline run is deterministic.\n * Live fetch requires `Authorization: Bearer $REQUESTY_API_KEY` (see\n * `sources` below) — without the key set, the framework reuses the\n * committed snapshot rather than fetching unauthenticated.\n */\nconst REQUESTY_MODELS_URL = \"https://router.requesty.ai/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/requesty-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// UNLIKE OpenRouter, Requesty prices are JSON **numbers** in USD-PER-TOKEN\n// (e.g. `4e-7` = $0.40/1M), not strings, and live flat on the model entry\n// rather than nested under a `pricing` object. `cached_price` is a cache\n// READ price (no cache-write price exists in this source — we never emit\n// `cacheWriteMultiplier`). `supports_caching` gates whether `cached_price`\n// is actually meaningful: some entries carry a non-zero `cached_price` with\n// `supports_caching: false` (cache pricing published but not offered), so\n// the multiplier must only be derived when the flag is true. passthrough()\n// keeps the other live keys (context_window, supports_vision, description,\n// …) forward-compatible without a regenerate — we only read what we model.\n\n// `created` is Unix seconds — Requesty's own route-creation timestamp, used\n// to backfill `addedAt` for ids not already in the ledger (see\n// `../added-at.ts`). Verified present on the live payload (2026-08-31).\nconst ModelSchema = z\n .object({\n id: z.string(),\n input_price: z.number().optional(),\n output_price: z.number().optional(),\n cached_price: z.number().optional(),\n supports_caching: z.boolean().optional(),\n created: z.number().optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/requesty-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier when the source carries a meaningful\n// `cached_price`. No `cacheWriteMultiplier` — Requesty has no cache-write\n// price to derive one from.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: \"requesty\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/**\n * Convert a per-token USD number to USD-per-1M-tokens, or undefined if\n * unpriced. UNLIKE OpenRouter (per-token USD strings), Requesty already\n * gives per-token USD as a JSON number, so there's no `Number(...)` parse\n * step — just the same ×1e6 + round6 normalization.\n */\nfunction per1m(tokenPrice: number | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n if (!Number.isFinite(tokenPrice)) return undefined\n return round6(tokenPrice * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the Requesty route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:requesty).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${REQUESTY_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus a cache\",\n \"// multiplier (cacheReadMultiplier) derived from the source's cached_price\",\n \"// per-token field when `supports_caching` is true. Requesty has no\",\n \"// cache-write price, so cacheWriteMultiplier is never emitted.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `created` timestamp, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const REQUESTY_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as Requesty routes by the picker. */\")\n lines.push(\"export const REQUESTY_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nconst LEDGER_ID = \"llm-requesty\"\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:requesty: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n const createdAt: Record<string, string> = {}\n for (const model of parsed.data) {\n const inputPer1M = per1m(model.input_price)\n const outputPer1M = per1m(model.output_price)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes.\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"requesty\",\n }\n\n if (model.supports_caching === true && inputPer1M > 0) {\n const cachePer1M = per1m(model.cached_price)\n if (cachePer1M !== undefined) {\n entry.cacheReadMultiplier = round6(cachePer1M / inputPer1M)\n }\n }\n\n entries[model.id] = entry\n if (model.created !== undefined) createdAt[model.id] = isoDateFromUnixSeconds(model.created)\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(LEDGER_ID),\n createdAt,\n todayIso()\n )\n for (const [id, entry] of Object.entries(entries)) entry.addedAt = ledger[id]\n\n return {\n [OUTPUT_PATH]: serializeFile(entries),\n [ledgerRelPath(LEDGER_ID)]: serializeLedger(ledger),\n }\n}\n\nconst sources = [\n {\n id: \"llm-requesty\",\n url: REQUESTY_MODELS_URL,\n // Live refresh needs the account key (Bearer). Without REQUESTY_API_KEY\n // set, the framework reuses the committed snapshot.\n headers: { Authorization: \"Bearer env:REQUESTY_API_KEY\" },\n },\n]\n\nexport const llmRequestyGenerator = defineGenerator({\n name: \"llm:requesty\",\n modality: \"llm\",\n sources,\n generate,\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\nimport {\n computeAddedAtLedger,\n ledgerRelPath,\n readLedger,\n serializeLedger,\n todayIso,\n} from \"../added-at.js\"\n\n/**\n * OpenCode's two hosted billing endpoints, both sourced from models.dev.\n *\n * - `opencode-go` — OpenCode Go, the flat $10/mo API-key subscription.\n * - `opencode` — OpenCode Zen, the pay-as-you-go sibling.\n *\n * They are DIFFERENT endpoints with different per-model prices and different\n * model lineups (Go serves no Claude/Gemini; Zen serves both), so each gets\n * its own generator, ledger, snapshot and route table. They only share a\n * source URL and an env var name (`OPENCODE_API_KEY` — see the note in\n * `@agentproto/model-catalog`'s `PROVIDER_KEY_ENV`: same name, two distinct\n * secrets).\n *\n * PINNED source. models.dev's `api.json` is the whole ecosystem's catalog\n * (~4.6 MB, 213 providers) and is fetched UNAUTHENTICATED — unlike Requesty,\n * there is no key to gate the refresh on, so `sources` carries no headers and\n * `--refresh` always hits the live URL.\n *\n * Because the payload is 4.6 MB and we model two providers out of 213, the\n * committed snapshot is a PROJECTION, not the raw response: each generator\n * emits `snapshots/<ledger-id>.json` as one of its {@link GeneratedFiles},\n * narrowed to its own provider and to the fields below, with deterministic key\n * order. The runner's `--refresh` writes the raw response to that path first\n * and this projection immediately overwrites it in the same run, so a refresh\n * never leaves 4.6 MB of unrelated providers in the tree. The projection keeps\n * the SOURCE's own shape (nested `provider.npm`, nested `cost`), so\n * {@link SnapshotSchema} parses the raw payload and the committed projection\n * identically and re-projecting a projection is a no-op.\n */\nconst MODELS_DEV_URL = \"https://models.dev/api.json\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// Everything is optional + passthrough: this schema is applied to the FULL\n// models.dev payload (213 providers), so one unrelated provider drifting a\n// field must not break our two generators. Prices are USD **per 1M tokens\n// ALREADY** (`cost.input: 1.4` = $1.40/1M) — unlike Requesty's per-token\n// numbers, so there is no ×1e6 conversion here. `cost.cache_read` /\n// `cost.cache_write` are absolute per-1M prices too, from which the\n// multipliers are derived. `cost.tiers` / `cost.context_over_200k` exist on\n// some entries and are deliberately NOT modelled: LLMPricing has no tiered\n// shape, and inventing one from an un-consumed field would be fabricated\n// pricing.\n\nconst ModelSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().optional(),\n family: z.string().optional(),\n /** ISO `YYYY-MM-DD` already — no unix-seconds conversion (cf. Requesty). */\n release_date: z.string().optional(),\n provider: z\n .object({\n /** Which AI-SDK package serves this model — the ONLY discriminator\n * for the endpoint's three wire surfaces (see\n * {@link anthropicSurfaceIds}). */\n npm: z.string().optional(),\n })\n .passthrough()\n .optional(),\n cost: z\n .object({\n input: z.number().optional(),\n output: z.number().optional(),\n cache_read: z.number().optional(),\n cache_write: z.number().optional(),\n })\n .passthrough()\n .optional(),\n })\n .passthrough()\n\ntype SourceModel = z.infer<typeof ModelSchema>\n\nconst ProviderSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().optional(),\n /** The endpoint's base URL, e.g. `https://opencode.ai/zen/go/v1`. */\n api: z.string().optional(),\n doc: z.string().optional(),\n env: z.array(z.string()).optional(),\n npm: z.string().optional(),\n models: z.record(z.string(), ModelSchema).optional(),\n })\n .passthrough()\n\ntype SourceProvider = z.infer<typeof ProviderSchema>\n\n/** models.dev's whole payload is `{ [providerId]: provider }`; a committed\n * projection is the same map narrowed to one key. */\nconst SnapshotSchema = z.record(z.string(), ProviderSchema)\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n /** ISO date this id was first seen by a sync run. See `../added-at.ts`. */\n addedAt?: string\n vendor: string\n provider: string\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the division. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Shortest faithful decimal string (matches the other generated files). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/**\n * A cache price relative to the base input price. Only meaningful when the\n * base price is positive: every `-free` variant on Zen carries\n * `cost.input: 0` alongside `cost.cache_read: 0`, and 0/0 is NaN — a free\n * model has no cache DISCOUNT to express, so no multiplier is emitted.\n */\nfunction cacheMultiplier(\n cachePer1M: number | undefined,\n inputPer1M: number\n): number | undefined {\n if (cachePer1M === undefined || !Number.isFinite(cachePer1M)) return undefined\n if (inputPer1M <= 0) return undefined\n return round6(cachePer1M / inputPer1M)\n}\n\n// ── Vendor attribution ──────────────────────────────────────────────────\n\n/**\n * Model id prefix → vendor (who BUILT the model), matched in order.\n *\n * HEURISTIC by necessity: models.dev's opencode/opencode-go entries carry\n * BARE product ids (`glm-5.3`, not `z-ai/glm-5.3`) and no vendor field at\n * all — `family` is a product line (`glm`, `deepseek-flash`), not a builder.\n * Each slug below is the one the repo's own catalog already uses for that\n * builder (verified against `OPENROUTER_ROUTES`' `vendor` values, which is\n * why it's `x-ai` and not `xai`, `moonshotai` and not `moonshot`), and each\n * attribution was cross-checked against another models.dev provider that\n * namespaces the SAME id under its builder (`inclusionai/ling-3.0-flash`,\n * `nvidia/nemotron-3-super-…`, `arcee-ai/trinity-large-…`,\n * `poolside/laguna-s-2.1`, `cohere/north-mini-code`, `meta/muse-spark-1.2`).\n * A new id that matches nothing here falls back to `opencode` — the handful\n * of unattributed ids on these endpoints (`omen-alpha`, `ox-alpha-free`,\n * `big-pickle`, `x-preview-f-free`) are opencode's own stealth/preview\n * models with no disclosed builder.\n *\n * `vendor` is METADATA on the pricing entry. It is NOT the route key: the\n * route tables are keyed `<provider>/<bare-id>` (see {@link routeKey}), so a\n * mis-attributed vendor can never mis-route or mis-bill a spawn.\n */\nconst VENDOR_BY_ID_PREFIX: ReadonlyArray<readonly [RegExp, string]> = [\n [/^claude-/, \"anthropic\"],\n [/^gemini-/, \"google\"],\n [/^gpt-/, \"openai\"],\n [/^grok-/, \"x-ai\"],\n [/^glm-/, \"z-ai\"],\n [/^kimi-/, \"moonshotai\"],\n [/^deepseek-/, \"deepseek\"],\n [/^minimax-/, \"minimax\"],\n [/^qwen/, \"qwen\"],\n [/^mimo-/, \"xiaomi\"],\n [/^hy\\d/, \"tencent\"],\n [/^longcat-/, \"meituan\"],\n [/^(ling|ring)-/, \"inclusionai\"],\n [/^nemotron-/, \"nvidia\"],\n [/^trinity-/, \"arcee-ai\"],\n [/^laguna-/, \"poolside\"],\n [/^north-/, \"cohere\"],\n [/^muse-spark-/, \"meta\"],\n]\n\n/** Vendor for a bare model id — see {@link VENDOR_BY_ID_PREFIX}. */\nexport function vendorForOpencodeModelId(bareId: string): string {\n for (const [pattern, vendor] of VENDOR_BY_ID_PREFIX) {\n if (pattern.test(bareId)) return vendor\n }\n return \"opencode\"\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\n/**\n * Route-table key: `<provider>/<bare-id>` — `opencode-go/glm-5.3`,\n * `opencode/claude-sonnet-4-6`.\n *\n * Deliberately NOT `<vendor>/<product>` like the OpenRouter / Requesty\n * tables. Those routers namespace their own ids by vendor, so their keys\n * round-trip through route-identity's `vendor/product@route` grammar.\n * models.dev gives these two endpoints BARE ids, and opencode's own config\n * spells them `opencode-go/glm-5.3` — which is also the form the runtime\n * derives the billing endpoint from (`modelIdPrefixProvider`) and the form\n * the opencode adapter puts on the wire. Keying by the provider makes all\n * three agree on one string, and `route-identity`'s opencode branches key\n * off exactly this (see the comment there for why they must run ahead of the\n * direct-vendor branch).\n */\nfunction routeKey(provider: string, bareId: string): string {\n return `${provider}/${bareId}`\n}\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n if (e.addedAt !== undefined) {\n fields.push(`addedAt: ${JSON.stringify(e.addedAt)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\n/** One endpoint's identity — everything the emitted files need to describe it. */\ninterface OpencodeEndpoint {\n /** models.dev provider key, and this repo's `CatalogProvider` value. */\n providerKey: string\n /** Generator + snapshot + ledger id. */\n ledgerId: string\n /** `llm:<name>` generator name. */\n generatorName: string\n /** Repo-relative emitted route table. */\n outputPath: string\n /** Exported route-table const. */\n routesConst: string\n /** Exported Anthropic-surface id list const. */\n anthropicConst: string\n /** Human label, used only in generated comments. */\n label: string\n}\n\nconst GO: OpencodeEndpoint = {\n providerKey: \"opencode-go\",\n ledgerId: \"llm-opencode-go\",\n generatorName: \"llm:opencode-go\",\n outputPath: \"packages/model-catalog/src/llm/opencode-go-routes.generated.ts\",\n routesConst: \"OPENCODE_GO_ROUTES\",\n anthropicConst: \"OPENCODE_GO_ANTHROPIC_MODELS\",\n label: \"OpenCode Go\",\n}\n\nconst ZEN: OpencodeEndpoint = {\n providerKey: \"opencode\",\n ledgerId: \"llm-opencode-zen\",\n generatorName: \"llm:opencode-zen\",\n outputPath: \"packages/model-catalog/src/llm/opencode-zen-routes.generated.ts\",\n routesConst: \"OPENCODE_ZEN_ROUTES\",\n anthropicConst: \"OPENCODE_ZEN_ANTHROPIC_MODELS\",\n label: \"OpenCode Zen\",\n}\n\nfunction serializeFile(\n endpoint: OpencodeEndpoint,\n entries: Record<string, LLMPricingEntry>,\n anthropicIds: readonly string[]\n): string {\n const keys = Object.keys(entries).sort()\n\n const lines: string[] = [\n `// AUTO-GENERATED by @agentproto/catalog-sync (${endpoint.generatorName}).`,\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${MODELS_DEV_URL} (provider \"${endpoint.providerKey}\" — ${endpoint.label})`,\n \"// Prices come VERBATIM from the source's cost.input / cost.output, which\",\n \"// models.dev already publishes as USD per 1M tokens (no per-token\",\n \"// conversion, unlike the Requesty table). cacheReadMultiplier /\",\n \"// cacheWriteMultiplier are cost.cache_read / cost.cache_write expressed\",\n \"// relative to cost.input, and are omitted when the base input price is 0\",\n \"// (every `-free` variant) because a free model has no cache discount.\",\n \"// Zero-priced models are KEPT — on these endpoints zero is the truth, not\",\n \"// a missing price.\",\n \"// Keys are `<provider>/<bare-id>`, the form opencode's own config uses and\",\n \"// the form the runtime derives the billing endpoint from; `vendor` is a\",\n \"// heuristic attribution of the model's BUILDER and is metadata only.\",\n \"// addedAt is the ISO date this id was first seen by a sync run — backfilled\",\n \"// from the source's own `release_date`, then NEVER mutated; see\",\n \"// packages/catalog-sync/src/added-at.ts and the package README.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n `export const ${endpoint.routesConst}: Record<string, LLMPricing> = {`,\n ]\n for (const key of keys) {\n lines.push(` ${JSON.stringify(key)}: ${serializeEntry(entries[key]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/**\")\n lines.push(` * BARE ids on ${endpoint.label} whose wire surface is the Anthropic Messages`)\n lines.push(\" * API — the source's `provider.npm === \\\"@ai-sdk/anthropic\\\"`. These are the\")\n lines.push(\" * ONLY ids reachable through the Anthropic-compatible gateway preset of the\")\n lines.push(\" * same name (claude-code / claude-sdk); the rest of the endpoint's lineup\")\n lines.push(\" * speaks OpenAI chat/completions or the OpenAI Responses API and has to go\")\n lines.push(\" * through the opencode adapter instead. Bare (not `<provider>/<id>`) because\")\n lines.push(\" * that is what an Anthropic client puts in `ANTHROPIC_MODEL` / on the wire.\")\n lines.push(\" */\")\n lines.push(`export const ${endpoint.anthropicConst}: readonly string[] = [`)\n for (const id of [...anthropicIds].sort()) {\n lines.push(` ${JSON.stringify(id)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Snapshot projection ─────────────────────────────────────────────────\n\n/** The committed snapshot's per-model shape — a strict subset of the source's\n * own, so one schema parses both. */\ninterface ProjectedModel {\n id?: string\n name?: string\n family?: string\n release_date?: string\n provider?: { npm: string }\n cost?: {\n input?: number\n output?: number\n cache_read?: number\n cache_write?: number\n }\n}\n\n/** The committed snapshot's per-provider shape (see {@link ProjectedModel}). */\ninterface ProjectedProvider {\n id?: string\n name?: string\n api?: string\n doc?: string\n env?: readonly string[]\n npm?: string\n models: Record<string, ProjectedModel>\n}\n\n/**\n * Narrow the raw models.dev payload to one provider and to the fields this\n * generator models, with deterministic (sorted) model order and a fixed field\n * order. Shape-identical to the source, so {@link SnapshotSchema} parses this\n * projection and re-projecting it is a no-op — which is what makes `--check`\n * drift detection meaningful on the snapshot itself.\n */\nfunction projectSnapshot(providerKey: string, provider: SourceProvider): string {\n const models: Record<string, ProjectedModel> = {}\n for (const bareId of Object.keys(provider.models ?? {}).sort()) {\n const model = provider.models?.[bareId]\n if (!model) continue\n // Object-literal spreads, not assignments: JSON.stringify emits keys in\n // insertion order, so a FIXED literal order is what makes the committed\n // snapshot byte-stable across runs.\n models[bareId] = {\n ...(model.id !== undefined ? { id: model.id } : {}),\n ...(model.name !== undefined ? { name: model.name } : {}),\n ...(model.family !== undefined ? { family: model.family } : {}),\n ...(model.release_date !== undefined ? { release_date: model.release_date } : {}),\n ...(model.provider?.npm !== undefined ? { provider: { npm: model.provider.npm } } : {}),\n ...(model.cost !== undefined\n ? {\n cost: {\n ...(model.cost.input !== undefined ? { input: model.cost.input } : {}),\n ...(model.cost.output !== undefined ? { output: model.cost.output } : {}),\n ...(model.cost.cache_read !== undefined\n ? { cache_read: model.cost.cache_read }\n : {}),\n ...(model.cost.cache_write !== undefined\n ? { cache_write: model.cost.cache_write }\n : {}),\n },\n }\n : {}),\n }\n }\n\n const projected: ProjectedProvider = {\n ...(provider.id !== undefined ? { id: provider.id } : {}),\n ...(provider.name !== undefined ? { name: provider.name } : {}),\n ...(provider.api !== undefined ? { api: provider.api } : {}),\n ...(provider.doc !== undefined ? { doc: provider.doc } : {}),\n ...(provider.env !== undefined ? { env: provider.env } : {}),\n ...(provider.npm !== undefined ? { npm: provider.npm } : {}),\n models,\n }\n\n return `${JSON.stringify({ [providerKey]: projected }, null, 2)}\\n`\n}\n\n/** Repo-relative snapshot path for a source id — mirrors `runner.ts`'s\n * `snapshotPath`, expressed repo-relative so the projection can ride along\n * in {@link GeneratedFiles}. */\nfunction snapshotRelPath(ledgerId: string): string {\n return `packages/catalog-sync/snapshots/${ledgerId}.json`\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\n/**\n * The bare ids served on the Anthropic Messages surface. models.dev\n * discriminates an endpoint's wire surfaces per model via `provider.npm`:\n * absent ⇒ OpenAI chat/completions, `@ai-sdk/anthropic` ⇒ Anthropic\n * Messages, `@ai-sdk/openai` ⇒ OpenAI Responses, `@ai-sdk/google` ⇒ Gemini.\n * Only the Anthropic set is emitted, because that is the one a caller has to\n * know: it is exactly what the gateway preset can serve.\n */\nfunction anthropicSurfaceIds(models: Readonly<Record<string, SourceModel>>): string[] {\n return Object.entries(models)\n .filter(([, model]) => model.provider?.npm === \"@ai-sdk/anthropic\")\n .map(([bareId]) => bareId)\n .sort()\n}\n\nasync function generateFor(\n endpoint: OpencodeEndpoint,\n source: { id: string; url: string },\n ctx: GeneratorContext\n): Promise<GeneratedFiles> {\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(source))\n const provider = parsed[endpoint.providerKey]\n if (!provider) {\n throw new Error(\n `${endpoint.generatorName}: models.dev payload carries no \"${endpoint.providerKey}\" provider ` +\n `(source ${source.url}). Refusing to emit an empty route table.`\n )\n }\n const models = provider.models ?? {}\n\n const entries: Record<string, LLMPricingEntry> = {}\n const releasedAt: Record<string, string> = {}\n for (const [bareId, model] of Object.entries(models)) {\n const inputPer1M = model.cost?.input\n const outputPer1M = model.cost?.output\n // An entry with no published price at all is skipped: a fabricated 0 would\n // read as \"free\" to the billing surface. An explicit 0 IS kept (the `-free`\n // variants) — see the header comment in the emitted file.\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n if (!Number.isFinite(inputPer1M) || !Number.isFinite(outputPer1M)) continue\n\n const key = routeKey(endpoint.providerKey, bareId)\n const entry: LLMPricingEntry = {\n inputPer1M: round6(inputPer1M),\n outputPer1M: round6(outputPer1M),\n vendor: vendorForOpencodeModelId(bareId),\n provider: endpoint.providerKey,\n }\n const read = cacheMultiplier(model.cost?.cache_read, inputPer1M)\n if (read !== undefined) entry.cacheReadMultiplier = read\n const write = cacheMultiplier(model.cost?.cache_write, inputPer1M)\n if (write !== undefined) entry.cacheWriteMultiplier = write\n\n entries[key] = entry\n if (model.release_date !== undefined) releasedAt[key] = model.release_date\n }\n\n const ledger = computeAddedAtLedger(\n Object.keys(entries),\n readLedger(endpoint.ledgerId),\n releasedAt,\n todayIso()\n )\n for (const [key, entry] of Object.entries(entries)) entry.addedAt = ledger[key]\n\n return {\n [endpoint.outputPath]: serializeFile(endpoint, entries, anthropicSurfaceIds(models)),\n [ledgerRelPath(endpoint.ledgerId)]: serializeLedger(ledger),\n [snapshotRelPath(endpoint.ledgerId)]: projectSnapshot(endpoint.providerKey, provider),\n }\n}\n\n/** models.dev needs no credential, so `headers` is deliberately absent — the\n * runner only reuses a committed snapshot instead of refreshing when a\n * referenced env var is missing, and there is none to miss here. */\nconst goSources = [{ id: GO.ledgerId, url: MODELS_DEV_URL }]\nconst zenSources = [{ id: ZEN.ledgerId, url: MODELS_DEV_URL }]\n\nexport const llmOpencodeGoGenerator = defineGenerator({\n name: GO.generatorName,\n modality: \"llm\",\n sources: goSources,\n generate: ctx => generateFor(GO, goSources[0]!, ctx),\n})\n\nexport const llmOpencodeZenGenerator = defineGenerator({\n name: ZEN.generatorName,\n modality: \"llm\",\n sources: zenSources,\n generate: ctx => generateFor(ZEN, zenSources[0]!, ctx),\n})\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\n\n/**\n * PINNED source. The HuggingFace router `/v1/models` payload lists every\n * model the router knows about, each carrying a per-model `providers[]`\n * array — one entry per inference provider currently serving it. We never\n * fetch it at build or test time — only behind `--refresh`, which writes\n * `snapshots/llm-huggingface.json` so the next offline run is deterministic.\n * No auth required — the listing endpoint returns HTTP 200 unauthenticated\n * (verified 2026-07-18).\n */\nconst HUGGINGFACE_MODELS_URL = \"https://router.huggingface.co/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/huggingface-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// Every per-provider field except `provider`/`status` is optional — some\n// entries are sparse (provider+status only). `pricing.input`/`pricing.output`\n// are USD-PER-1M-TOKENS NUMBERS (unlike OpenRouter's per-token strings),\n// already at the scale LLMPricing expects — no ×1e6 conversion needed.\n// passthrough() keeps unread live fields (owned_by, architecture, is_free,\n// throughput, …) forward-compatible without a regenerate — we only read\n// what we model.\n\nconst HFProviderSchema = z\n .object({\n provider: z.string(),\n status: z.string(),\n context_length: z.number().optional(),\n pricing: z\n .object({\n input: z.number().optional(),\n output: z.number().optional(),\n })\n .optional(),\n supports_tools: z.boolean().optional(),\n supports_structured_output: z.boolean().optional(),\n })\n .passthrough()\n\nconst HFModelSchema = z\n .object({\n id: z.string(),\n providers: z.array(HFProviderSchema).optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(HFModelSchema),\n})\n\n// ── Output shape (drop-in for model-catalog's route-identity resolver) ────\n\ninterface HuggingFaceRouteProviderEntry {\n provider: string\n status: string\n contextLength?: number\n inputPer1M?: number\n outputPer1M?: number\n supportsTools?: boolean\n supportsStructuredOutput?: boolean\n}\n\ninterface HuggingFaceRouteEntry {\n wireId: string\n providers: HuggingFaceRouteProviderEntry[]\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 4 decimal places, killing binary-float noise from the source payload. */\nfunction round4(n: number): number {\n return Math.round(n * 10_000) / 10_000\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeProvider(p: HuggingFaceRouteProviderEntry): string {\n const fields: string[] = [\n `provider: ${JSON.stringify(p.provider)}`,\n `status: ${JSON.stringify(p.status)}`,\n ]\n if (p.contextLength !== undefined) fields.push(`contextLength: ${p.contextLength}`)\n if (p.inputPer1M !== undefined) fields.push(`inputPer1M: ${p.inputPer1M}`)\n if (p.outputPer1M !== undefined) fields.push(`outputPer1M: ${p.outputPer1M}`)\n if (p.supportsTools !== undefined) fields.push(`supportsTools: ${p.supportsTools}`)\n if (p.supportsStructuredOutput !== undefined) {\n fields.push(`supportsStructuredOutput: ${p.supportsStructuredOutput}`)\n }\n return ` {\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeEntry(id: string, e: HuggingFaceRouteEntry): string {\n const providerLines = e.providers.map(serializeProvider).join(\",\\n\")\n return [\n ` ${JSON.stringify(id)}: {`,\n ` wireId: ${JSON.stringify(e.wireId)},`,\n ` providers: [`,\n providerLines,\n ` ],`,\n ` },`,\n ].join(\"\\n\")\n}\n\nfunction serializeFile(entries: Record<string, HuggingFaceRouteEntry>): string {\n const ids = Object.keys(entries).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:huggingface).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${HUGGINGFACE_MODELS_URL}`,\n \"// Per-model LIVE inference providers from the HuggingFace router. HF wire\",\n \"// ids are case-sensitive and preserved verbatim. Provider entries are\",\n \"// SPARSE on some models — every field below except provider/status is\",\n \"// optional and emitted only when the upstream response carries it. Only\",\n '// providers with status === \"live\" are kept; models with zero live',\n \"// providers are skipped. inputPer1M/outputPer1M are USD per 1M tokens\",\n \"// (HuggingFace router convention — already at that scale, unlike\",\n \"// OpenRouter's per-token strings).\",\n \"\",\n \"export interface HuggingFaceRouteProvider {\",\n \" provider: string\",\n \" status: string\",\n \" contextLength?: number\",\n \" inputPer1M?: number\",\n \" outputPer1M?: number\",\n \" supportsTools?: boolean\",\n \" supportsStructuredOutput?: boolean\",\n \"}\",\n \"\",\n \"export interface HuggingFaceRoute {\",\n \" wireId: string\",\n \" providers: HuggingFaceRouteProvider[]\",\n \"}\",\n \"\",\n \"export const HUGGINGFACE_ROUTES: Record<string, HuggingFaceRoute> = {\",\n ]\n for (const id of ids) {\n lines.push(serializeEntry(id, entries[id]!))\n }\n lines.push(\"}\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:huggingface: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, HuggingFaceRouteEntry> = {}\n for (const model of parsed.data) {\n const liveProviders = (model.providers ?? []).filter((p) => p.status === \"live\")\n if (liveProviders.length === 0) continue\n\n const providers: HuggingFaceRouteProviderEntry[] = liveProviders\n .map((p) => {\n const entry: HuggingFaceRouteProviderEntry = {\n provider: p.provider,\n status: p.status,\n }\n if (p.context_length !== undefined) entry.contextLength = p.context_length\n if (p.pricing?.input !== undefined) entry.inputPer1M = round4(p.pricing.input)\n if (p.pricing?.output !== undefined) entry.outputPer1M = round4(p.pricing.output)\n if (p.supports_tools !== undefined) entry.supportsTools = p.supports_tools\n if (p.supports_structured_output !== undefined) {\n entry.supportsStructuredOutput = p.supports_structured_output\n }\n return entry\n })\n .sort((a, b) => a.provider.localeCompare(b.provider))\n\n entries[model.id] = { wireId: model.id, providers }\n }\n\n return { [OUTPUT_PATH]: serializeFile(entries) }\n}\n\nconst sources = [\n {\n id: \"llm-huggingface\",\n url: HUGGINGFACE_MODELS_URL,\n },\n]\n\nexport const llmHuggingfaceGenerator = defineGenerator({\n name: \"llm:huggingface\",\n modality: \"llm\",\n sources,\n generate,\n})\n","/**\n * Shared CatalogVoice[] → TS-source serializer for the voice generators.\n *\n * The mapping (raw provider JSON → CatalogVoice) lives in\n * `@agentproto/model-catalog/providers` so build time and runtime share it;\n * this module only turns the mapped voices into a committed `*.generated.ts`.\n * Field emit order is fixed (matches the historical generator output) so the\n * generated file stays diff-stable across runs.\n */\n\nimport type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"\n\nfunction serializeVoice(v: CatalogVoice): string {\n const lines: string[] = [\" {\"]\n lines.push(` catalogId: ${JSON.stringify(v.catalogId)},`)\n lines.push(` providerVoiceId: ${JSON.stringify(v.providerVoiceId)},`)\n lines.push(` provider: ${JSON.stringify(v.provider)},`)\n lines.push(` label: ${JSON.stringify(v.label)},`)\n lines.push(` description: ${JSON.stringify(v.description)},`)\n lines.push(` gender: ${JSON.stringify(v.gender)},`)\n lines.push(` primaryLanguage: ${JSON.stringify(v.primaryLanguage)},`)\n lines.push(\n ` supportedLanguages: [${v.supportedLanguages.map(l => JSON.stringify(l)).join(\", \")}],`,\n )\n if (v.quality !== undefined) lines.push(` quality: ${JSON.stringify(v.quality)},`)\n if (v.featured !== undefined) lines.push(` featured: ${v.featured},`)\n if (v.samplePath !== undefined) lines.push(` samplePath: ${JSON.stringify(v.samplePath)},`)\n if (v.age !== undefined) lines.push(` age: ${JSON.stringify(v.age)},`)\n lines.push(\" },\")\n return lines.join(\"\\n\")\n}\n\n/**\n * Render a full generated voice module.\n *\n * @param generatorName e.g. `voice:elevenlabs` (goes in the header comment)\n * @param exportName e.g. `ELEVENLABS_VOICES`\n * @param voices mapped voices, in emit order\n */\nexport function serializeVoiceModule(\n generatorName: string,\n exportName: string,\n voices: readonly CatalogVoice[],\n): string {\n const lines: string[] = [\n `// Generated by @agentproto/catalog-sync generator ${generatorName}`,\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n 'import type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"',\n \"\",\n `export const ${exportName}: readonly CatalogVoice[] = [`,\n ]\n for (const v of voices) lines.push(serializeVoice(v))\n lines.push(\"] as const\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n","/**\n * voice-elevenlabs generator — reads the ElevenLabs /v1/voices snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n ElevenLabsVoicesSnapshotSchema,\n mapElevenLabsVoices,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (and is the single,\n// dist-safe reader; generators never touch the filesystem themselves).\nexport const ELEVENLABS_SOURCE: CatalogSource = {\n id: \"voice-elevenlabs\",\n url: \"https://api.elevenlabs.io/v1/voices\",\n // Live refresh needs the account key; offline reads ignore this.\n headers: { \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-elevenlabs.generated.ts\"\n\nexport const voiceElevenlabs: CatalogGenerator = defineGenerator({\n name: \"voice:elevenlabs\",\n modality: \"voice\",\n sources: [ELEVENLABS_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = ElevenLabsVoicesSnapshotSchema.parse(\n await ctx.fetchSource(ELEVENLABS_SOURCE),\n )\n const voices = mapElevenLabsVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:elevenlabs\",\n \"ELEVENLABS_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * voice-minimax generator — reads the MiniMax /v1/get_voice snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n mapMinimaxVoices,\n MinimaxVoicesSnapshotSchema,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const MINIMAX_SOURCE: CatalogSource = {\n id: \"voice-minimax\",\n url: \"https://api.minimax.io/v1/get_voice\",\n // get_voice is a POST; live refresh needs the account key (Bearer). Without\n // MINIMAX_API_KEY set, the framework reuses the committed snapshot.\n method: \"POST\",\n headers: {\n Authorization: \"Bearer env:MINIMAX_API_KEY\",\n \"Content-Type\": \"application/json\",\n },\n body: { voice_type: \"system\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-minimax.generated.ts\"\n\nexport const voiceMinimax: CatalogGenerator = defineGenerator({\n name: \"voice:minimax\",\n modality: \"voice\",\n sources: [MINIMAX_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = MinimaxVoicesSnapshotSchema.parse(\n await ctx.fetchSource(MINIMAX_SOURCE),\n )\n const voices = mapMinimaxVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:minimax\",\n \"MINIMAX_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * image-replicate generator — reads a curated Replicate image-models\n * snapshot and emits ImageModelDefinition[]-shaped generated TS entries.\n *\n * Mirrors the shape from packages/model-catalog/src/image/catalog.ts exactly.\n * Provider-native ids only; no product-specific aliases.\n */\n\nimport { z } from \"zod\"\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\n\n// ── Replicate snapshot shapes ───────────────────────────────────────────\n\ninterface ReplicateOpenApiSchema {\n input: { type: string; properties: Record<string, { type: string; items?: { type: string }; format?: string }> }\n output: { type: string; items?: { type: string; format?: string }; format?: string }\n}\n\ninterface ReplicateLatestVersion {\n id: string\n created_at: string\n openapi_schema: ReplicateOpenApiSchema\n}\n\ninterface ReplicateModel {\n owner: string\n name: string\n description: string | null\n visibility: string\n run_count: number\n cover_image_url: string | null\n latest_version: ReplicateLatestVersion\n}\n\n// The live Replicate API returns DRF-paginated `{results, next, previous}`,\n// while the committed snapshot is hand-authored `{_meta, models}`. Accept both.\n// The API can return `description: null` for some models (observed in live run).\nconst ReplicateModelSchema = z\n .object({\n owner: z.string(),\n name: z.string(),\n description: z.string().nullable(),\n visibility: z.string(),\n run_count: z.number(),\n cover_image_url: z.string().nullable(),\n latest_version: z.object({\n id: z.string(),\n created_at: z.string(),\n openapi_schema: z.any(),\n }),\n })\n .passthrough()\n\nconst ReplicateSnapshotSchema = z\n .object({\n // DRF-paginated shape (live API)\n results: z.array(ReplicateModelSchema).optional(),\n next: z.string().nullable().optional(),\n previous: z.string().nullable().optional(),\n // Hand-authored fixture shape (committed snapshot)\n _meta: z.record(z.string(), z.unknown()).optional(),\n models: z.array(ReplicateModelSchema).optional(),\n })\n .passthrough()\n\ntype ReplicateSnapshot = z.infer<typeof ReplicateSnapshotSchema>\n\n// ── ImageModelDefinition mirror (from packages/model-catalog/src/image/catalog.ts) ──\n\ninterface ImageModelPricing {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n billingUnit: \"per_image\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\ninterface ImageModelCapabilities {\n generate: boolean\n edit: boolean\n upscale?: boolean\n}\n\ninterface ImageModelReferenceImages {\n supported: boolean\n fieldName: \"image_input\" | \"input_images\" | \"input_image\" | \"none\"\n maxCount: number\n singular: boolean\n}\n\ninterface ImageModelAspectRatio {\n supported: string[]\n default: string\n}\n\ninterface ImageModelEntry {\n id: string\n name: string\n providerId: string\n provider: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n pricing: ImageModelPricing\n description: string\n agentVisible: boolean\n triggerWord?: string\n}\n\n// ── Pricing (hand-authored, mirrors model-catalog) ──────────────────────\n\ninterface PricingRecord {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\nconst PRICING: Record<string, PricingRecord> = {\n \"nano-banana-pro\": { costPerImage: 0.15, costTier: \"high\", baseCost: 0.15, creditCost: 10 },\n \"nano-banana-2\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 5 },\n \"nano-banana\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-2-dev\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"flux-kontext-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-kontext-max\": { costPerImage: 0.08, costTier: \"medium\", baseCost: 0.08, creditCost: 8 },\n \"flux-1.1-pro-ultra\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 8 },\n \"seedream-4\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"recraft-v3\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"image-01\": { costPerImage: 0.02, costTier: \"low\", baseCost: 0.02, creditCost: 2 },\n \"gpt-image-1\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"ideogram-v3-turbo\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 4 },\n \"flux-1.1-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n}\n\n// Models visible to agents (the active generation ones)\nconst AGENT_VISIBLE = new Set([\n \"nano-banana-pro\",\n \"nano-banana-2\",\n \"nano-banana\",\n \"flux-2-dev\",\n \"flux-kontext-pro\",\n \"flux-kontext-max\",\n \"flux-1.1-pro-ultra\",\n \"seedream-4\",\n \"recraft-v3\",\n \"image-01\",\n \"gpt-image-1\",\n \"ideogram-v3-turbo\",\n])\n\nconst ASPECT_RATIOS_DEFAULT: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_WIDE: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\", \"4:5\", \"5:4\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_ULTRA: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"21:9\", \"9:21\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_NBPRO: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\", \"21:9\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_NB2: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_SQUARE: ImageModelAspectRatio = {\n supported: [\"1:1\"],\n default: \"1:1\",\n}\n\ninterface ModelSpec {\n id: string\n name: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n triggerWord?: string\n}\n\nconst MODEL_SPECS: Record<string, ModelSpec> = {\n \"nano-banana-pro\": {\n id: \"nano-banana-pro\",\n name: \"Nano Banana Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 14, singular: false },\n aspectRatio: ASPECT_RATIOS_NBPRO,\n output: \"string\",\n },\n \"nano-banana-2\": {\n id: \"nano-banana-2\",\n name: \"Nano Banana 2\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_NB2,\n output: \"string\",\n },\n \"nano-banana\": {\n id: \"nano-banana\",\n name: \"Nano Banana\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-2-dev\": {\n id: \"flux-2-dev\",\n name: \"Flux 2 Dev\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_images\", maxCount: 5, singular: false },\n aspectRatio: ASPECT_RATIOS_WIDE,\n output: \"string\",\n },\n \"flux-kontext-pro\": {\n id: \"flux-kontext-pro\",\n name: \"Flux Kontext Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-kontext-max\": {\n id: \"flux-kontext-max\",\n name: \"Flux Kontext Max\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-1.1-pro-ultra\": {\n id: \"flux-1.1-pro-ultra\",\n name: \"Flux 1.1 Pro Ultra\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_ULTRA,\n output: \"string\",\n },\n \"seedream-4\": {\n id: \"seedream-4\",\n name: \"SeedReam 4\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 10, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"recraft-v3\": {\n id: \"recraft\",\n name: \"Recraft V3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_SQUARE,\n output: \"string\",\n },\n \"image-01\": {\n id: \"minimax\",\n name: \"MiniMax Image\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"3:4\", \"4:3\"], default: \"1:1\" },\n output: \"array\",\n },\n \"gpt-image-1\": {\n id: \"gpt-image-1\",\n name: \"OpenAI GPT Image 1\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: { supported: [\"1:1\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"ideogram-v3-turbo\": {\n id: \"ideogram-v3\",\n name: \"Ideogram v3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"flux-1.1-pro\": {\n id: \"flux\",\n name: \"Flux 1.1 Pro\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\"], default: \"1:1\" },\n output: \"string\",\n },\n}\n\nfunction mapModel(raw: ReplicateModel): ImageModelEntry {\n const providerId = `${raw.owner}/${raw.name}`\n const spec = MODEL_SPECS[raw.name] ?? {\n id: raw.name,\n name: raw.name,\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\" as const, maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\" as const,\n }\n\n const pricing = PRICING[raw.name] ?? {\n costPerImage: 0.03,\n costTier: \"low\" as const,\n baseCost: 0.03,\n creditCost: 3,\n }\n\n return {\n id: spec.id,\n name: spec.name,\n providerId,\n provider: raw.owner === \"openai\" ? \"openai\" : raw.owner === \"minimax\" ? \"minimax\" : \"replicate\",\n capabilities: spec.capabilities,\n referenceImages: spec.referenceImages,\n aspectRatio: spec.aspectRatio,\n output: spec.output,\n pricing: {\n costPerImage: pricing.costPerImage,\n costTier: pricing.costTier,\n billingUnit: \"per_image\" as const,\n baseCost: pricing.baseCost,\n ...(pricing.creditCost !== undefined ? { creditCost: pricing.creditCost } : {}),\n ...(pricing.overrideCreditCost !== undefined ? { overrideCreditCost: pricing.overrideCreditCost } : {}),\n },\n description: raw.description ?? \"\",\n agentVisible: AGENT_VISIBLE.has(raw.name),\n ...(spec.triggerWord ? { triggerWord: spec.triggerWord } : {}),\n }\n}\n\n// ── Generator ────────────────────────────────────────────────────────────\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\n// The Replicate models endpoint is authed. Declare the token as an `env:` header\n// token so the runner's missing-env gate (runner.ts `resolveHeaders`) SKIPS the\n// refresh and reuses the committed snapshot when `REPLICATE_API_TOKEN` is absent\n// — exactly like the authed LLM sources (Anthropic/Groq/xAI/Moonshot). Without\n// this a token-less `catalog-sync generate --refresh` fetched unauthenticated,\n// 401'd, and threw — crashing the whole run for anyone (or the weekly Action)\n// without the secret. `--check` never fetches, so it is unaffected.\nexport const REPLICATE_SOURCE: CatalogSource = {\n id: \"image-replicate\",\n url: \"https://api.replicate.com/v1/collections/text-to-image\",\n headers: { Authorization: \"Bearer env:REPLICATE_API_TOKEN\" },\n}\n\nexport const imageReplicate: CatalogGenerator = defineGenerator({\n name: \"image:replicate\",\n modality: \"image\",\n sources: [REPLICATE_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const raw = await ctx.fetchSource(REPLICATE_SOURCE)\n const data = ReplicateSnapshotSchema.parse(raw)\n\n // Normalize: extract models from either `results` (live API) or `models` (fixture)\n const models = data.results ?? data.models\n if (!models) {\n throw new Error(\n \"Replicate snapshot has neither `results` nor `models` array — invalid shape\"\n )\n }\n\n // Filter to curated models only — live API returns unfiltered mix (text LLMs, video, etc.)\n const curatedModels = models.filter(m => MODEL_SPECS[m.name])\n if (curatedModels.length === 0) {\n const sampleNames = [...AGENT_VISIBLE].slice(0, 3).join(\", \")\n throw new Error(\n `image:replicate: none of the curated models (${sampleNames}…) present in source payload (${models.length} entries) — API shape or roster drift`\n )\n }\n\n const entries = curatedModels.map(mapModel)\n\n const lines: string[] = [\n \"// Generated by @agentproto/catalog-sync generator image:replicate\",\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n \"import type { ImageModelDefinition } from \\\"@agentproto/model-catalog/image\\\"\",\n \"\",\n \"export const REPLICATE_IMAGE_MODELS: Record<string, ImageModelDefinition> = {\",\n ]\n\n for (const e of entries) {\n const trigger = e.triggerWord ? `,\\n triggerWord: ${JSON.stringify(e.triggerWord)}` : \"\"\n const creditCost = e.pricing.creditCost !== undefined\n ? `,\\n creditCost: ${e.pricing.creditCost}`\n : \"\"\n const override = e.pricing.overrideCreditCost !== undefined\n ? `,\\n overrideCreditCost: ${e.pricing.overrideCreditCost}`\n : \"\"\n\n lines.push(` ${JSON.stringify(e.id)}: {`)\n lines.push(` id: ${JSON.stringify(e.id)},`)\n lines.push(` name: ${JSON.stringify(e.name)},`)\n lines.push(` providerId: ${JSON.stringify(e.providerId)},`)\n lines.push(` provider: ${JSON.stringify(e.provider)},`)\n lines.push(` capabilities: { generate: ${e.capabilities.generate}, edit: ${e.capabilities.edit}${e.capabilities.upscale ? `, upscale: ${e.capabilities.upscale}` : \"\"} },`)\n lines.push(` referenceImages: {`)\n lines.push(` supported: ${e.referenceImages.supported},`)\n lines.push(` fieldName: ${JSON.stringify(e.referenceImages.fieldName)},`)\n lines.push(` maxCount: ${e.referenceImages.maxCount},`)\n lines.push(` singular: ${e.referenceImages.singular},`)\n lines.push(` },`)\n lines.push(` aspectRatio: {`)\n lines.push(` supported: [${e.aspectRatio.supported.map(a => JSON.stringify(a)).join(\", \")}],`)\n lines.push(` default: ${JSON.stringify(e.aspectRatio.default)},`)\n lines.push(` },`)\n lines.push(` output: ${JSON.stringify(e.output)},`)\n lines.push(` pricing: {`)\n lines.push(` costPerImage: ${e.pricing.costPerImage},`)\n lines.push(` costTier: ${JSON.stringify(e.pricing.costTier)},`)\n lines.push(` billingUnit: ${JSON.stringify(e.pricing.billingUnit)},`)\n lines.push(` baseCost: ${e.pricing.baseCost},${creditCost}${override}`)\n lines.push(` },`)\n lines.push(` description: ${JSON.stringify(e.description)},`)\n lines.push(` agentVisible: ${e.agentVisible},${trigger}`)\n lines.push(` },`)\n }\n\n lines.push(\"}\")\n lines.push(\"\")\n\n const outputPath = \"packages/catalog-sync/generated/image-replicate.generated.ts\"\n return { [outputPath]: lines.join(\"\\n\") }\n },\n})\n","/**\n * Reviewed refresh workflow for catalog-sync.\n *\n * Extends the existing generator framework with explicit, reviewable diffs and\n * source-level metadata so operators can see exactly what changed and why.\n *\n * Design constraints (per project convention):\n * - Pricing is never fabricated.\n * - Refresh only hits pinned source URLs; unrefreshable sources are skipped\n * with an explanation.\n * - The committed snapshot is the single source of truth for offline runs.\n * - Availability-only local cache stays separate from the reviewed refresh.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return dirname(dirname(catalogSyncDir()))\n}\n\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n// ── Source metadata ────────────────────────────────────────────────────────\n\n/**\n * Source-level refresh metadata. Wraps a frozen {@link CatalogSource} without\n * mutating it, so existing generators keep compiling unchanged.\n */\nexport interface RefreshableSource {\n source: CatalogSource\n /** When false, the source is skipped by --refresh and documented in results. */\n refreshable: boolean\n /** Human-readable explanation of the source contract or gap. */\n notes?: string\n}\n\nexport interface SourceRefreshResult {\n id: string\n url: string\n /** True when a live fetch was attempted and succeeded. */\n refreshed: boolean\n /** True when the source is known to be unrefreshable. */\n skipped?: boolean\n /** Human-readable status / gap explanation. */\n notes?: string\n /** Present when refresh was attempted but failed. */\n error?: string\n}\n\n// ── File diff ──────────────────────────────────────────────────────────────\n\nexport interface CatalogFileDiff {\n /** Repo-relative path. */\n path: string\n /** Content currently on disk, or undefined when the file does not exist. */\n before: string | undefined\n /** Generated content. */\n after: string\n /** True when before !== after. */\n changed: boolean\n}\n\n// ── Options / result ───────────────────────────────────────────────────────\n\nexport interface ReviewedRefreshOptions {\n /** When true, attempt live fetches for refreshable sources. */\n refresh: boolean\n /** When true, write generated files to disk. */\n write: boolean\n /**\n * Optional fetch implementation for tests. Defaults to the global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\nexport interface ReviewedRefreshResult {\n /** Generated repo-relative path → content. */\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from disk. */\n changed: string[]\n /** Per-file before/after reviewable diffs. */\n diffs: CatalogFileDiff[]\n /** Per-source refresh status. */\n sources: SourceRefreshResult[]\n}\n\n// ── Implementation ─────────────────────────────────────────────────────────\n\n/**\n * Fetch every refreshable source and record the outcome.\n *\n * Unrefreshable sources (e.g. OpenAI, which has no stable pricing endpoint)\n * are reported as skipped rather than silently ignored or scraped.\n */\nexport async function refreshSources(\n sources: RefreshableSource[],\n opts: Pick<ReviewedRefreshOptions, \"refresh\" | \"fetchImpl\">\n): Promise<SourceRefreshResult[]> {\n const results: SourceRefreshResult[] = []\n const fetchImpl = opts.fetchImpl ?? fetch\n\n for (const { source, refreshable, notes } of sources) {\n if (!opts.refresh) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n notes: \"Offline mode: using committed snapshot.\",\n })\n continue\n }\n\n if (!refreshable) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n skipped: true,\n notes: notes ?? \"Source is not refreshable.\",\n })\n continue\n }\n\n const { headers, missing } = resolveHeaders(source.headers)\n if (missing.length > 0) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `Missing env vars: ${missing.join(\", \")}`,\n })\n continue\n }\n\n try {\n const res = await fetchImpl(source.url, {\n method: source.method ?? \"GET\",\n headers,\n ...(source.body !== undefined\n ? { body: JSON.stringify(source.body) }\n : {}),\n })\n if (!res.ok) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `${res.status} ${res.statusText}`,\n })\n continue\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(snapshotPath(source.id)), { recursive: true })\n writeFileSync(\n snapshotPath(source.id),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf8\"\n )\n results.push({\n id: source.id,\n url: source.url,\n refreshed: true,\n notes: \"Snapshot updated from live source.\",\n })\n } catch (err) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: err instanceof Error ? err.message : String(err),\n })\n }\n }\n\n return results\n}\n\n/**\n * Run generators using the current snapshots (whether refreshed or committed)\n * and produce reviewable file diffs.\n */\nexport async function reviewedRefresh(\n gens: CatalogGenerator[],\n refreshableSources: RefreshableSource[],\n opts: ReviewedRefreshOptions\n): Promise<ReviewedRefreshResult> {\n const sourceResults = await refreshSources(refreshableSources, opts)\n\n const files: GeneratedFiles = {}\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" (${path}).`\n )\n },\n }\n const out = await gen.generate(ctx)\n Object.assign(files, out)\n }\n\n const root = repoRoot()\n const diffs: CatalogFileDiff[] = []\n const changed: string[] = []\n\n for (const [relPath, after] of Object.entries(files)) {\n const abs = join(root, relPath)\n const before = readIfExists(abs)\n const isChanged = before !== after\n diffs.push({ path: relPath, before, after, changed: isChanged })\n if (isChanged) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, after, \"utf8\")\n }\n }\n }\n\n return { files, changed, diffs, sources: sourceResults }\n}\n","/**\n * OpenAI LLM source contract.\n *\n * OpenAI does **not** publish a stable, machine-readable pricing/model catalog\n * endpoint. The authoritative pricing page is `openai.com/api/pricing`, but it\n * is HTML-only, not a documented API, and has historically changed layout\n * without notice.\n *\n * Therefore this source is intentionally **not refreshable** in the automated\n * `catalog-sync` workflow. Pricing is committed by hand from the official page\n * and cross-checked with third-party aggregators where noted. We do not scrape\n * or guess.\n *\n * If OpenAI releases a stable `/v1/models` endpoint that includes pricing, or\n * a documented pricing JSON feed, this source can be upgraded to refreshable.\n * Until then, the gap is recorded honestly in refresh results.\n */\n\nimport type { RefreshableSource } from \"../refresh-workflow.js\"\n\nexport const OPENAI_LLM_SOURCE: RefreshableSource = {\n source: {\n id: \"llm-openai\",\n url: \"https://openai.com/api/pricing\",\n },\n refreshable: false,\n notes:\n \"OpenAI has no stable machine-readable pricing endpoint. \" +\n \"Pricing in @agentproto/model-catalog is committed manually from \" +\n \"openai.com/api/pricing and verified against independent aggregators \" +\n \"where possible. Automated refresh is disabled to avoid scraping or \" +\n \"fabricating prices.\",\n}\n\n/** Convenience array for workflows that want to include the OpenAI contract. */\nexport const OPENAI_SOURCES: RefreshableSource[] = [OPENAI_LLM_SOURCE]\n"]}