fix(types): derive agent llm.vendor union from @jambonz/schema#10
Merged
Conversation
The AgentLlm.vendor union was hand-maintained and had drifted from the schema enum — it was missing baseten, azure-openai, groq, and huggingface, so valid vendors were rejected by TypeScript. Generate the vendor list from @jambonz/schema (agent.schema.json llm.vendor.enum) via scripts/gen-llm-vendors.mjs into a committed llm-vendors.generated.ts. Wired as prebuild/pretypecheck so published artifacts always track the installed schema version. Export LlmVendor and LLM_VENDORS for consumers. Add a drift test asserting the committed generated list matches the schema enum. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
AgentLlm.vendorunion insrc/types/verbs.tswas hand-maintained and had drifted from the source of truth (the@jambonz/schemaagent verb enum). It listed only 7 vendors and was missingbaseten,azure-openai,groq, andhuggingface— all valid at runtime (the@jambonz/llmadapter registry supports them) and present in the schema. The result: TypeScript rejected valid agent configs, forcing consumers into casts likevendor: 'baseten' as 'openai'.The schema and the MCP server were both correct — only the SDK's hand-written type lagged.
Fix
Derive the vendor list from the schema instead of duplicating it by hand:
scripts/gen-llm-vendors.mjs— readsllm.vendor.enumfrom@jambonz/schema'sverbs/agent.schema.jsonand emitssrc/types/llm-vendors.generated.ts(aconsttuple + derivedLlmVendortype).AgentLlm.vendornow references the generatedLlmVendortype.gen:typesintoprebuildandpretypecheck, so published artifacts and CI always track the installed schema version. A new vendor in the schema flows into the types automatically on the next build.LlmVendorandLLM_VENDORSfor consumers (validation, UI dropdowns, etc.).tscwork without a codegen step.Drift guard
Added a test in
schema-drift.test.tsasserting the committedLLM_VENDORSequals the schema enum — catches a stale generated file if the schema dep is bumped without re-runninggen:types. (The existing drift tests only compared property names, not enum values, which is how this slipped through.)Verification
npm run typecheck✅ (regenerates viapretypecheck)npm run build✅ — built.d.tsnow exports all 11 vendorsnpm test✅ 117 passing (was 116; +1 drift guard)🤖 Generated with Claude Code