The shared type spine that keeps every package speaking the same language.
@alembic/contracts is the only package with no internal dependencies. It defines the shapes every other package uses: how to ask a model for a completion, how to report success or failure, how to score a business opportunity, and how to structure a distilled wiki package.
Two ideas are especially important:
Result; callers branch on ok instead of catching exceptions.Think of it like… the metric system in science: everyone uses the same units so measurements can be combined safely.
The package exports Zod schemas and inferred types: ModelRunInput, ModelRunResult, ModelAdapter, Tier, BusinessSignal, WikiPackage, CouncilDecision, and a hard-coded MODEL_REGISTRY mapping model ids to adapters, tiers, and per-1k pricing. To add a new model, you edit packages/contracts/src/registry.ts.
// pick the cheapest model for a tier
import { Tier, pickCheapestForTier } from '@alembic/contracts';
const entry = pickCheapestForTier(Tier.T2);
console.log(entry?.modelId);MODEL_REGISTRY is the single source of truth for model capability and cost. pickCheapestForTier filters by tier and returns the lowest-cost entry. The registry also records whether a model supports tool use, JSON mode, or vision, so the adapter layer can refuse incompatible requests.
Open packages/contracts/src/registry.ts and count how many models are registered. Which tier has the most options?