catalog

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalog embeds AgentKit's model catalog and turns a model id into a core.Model descriptor. It lists models for the three providers an agent can run on (Providers): anthropic, openrouter and ollama.

Lookup resolves a Claude model id and is what the driver calls. Select is the offline entry point for all three providers: it turns a provider, a model and an effort into the Selection a run will use. The model is either a tier name, SIMPLE, STANDARD or ADVANCED, which the catalog's fixed tier table maps to a model id and an effort for the provider, or a model id, which bypasses the table. An explicit effort overrides the tier's.

The catalog supplies exactly the metadata no provider API returns and no pass-through can synthesize: context window, output cap, pricing, how the model takes thinking and its compatibility profile. Every one of those is load-bearing before the first byte is sent — the max_tokens cap, the cost of a turn and how thinking is encoded all read it — which is why "just pass the model string through" is not an option.

The catalog is NOT an allowlist. An id it does not list gets a usable default descriptor (Lookup, Select), so a model that ships after this snapshot works the day it ships; each provider has its own fallback window and output cap, and none has a price. All model metadata — prices, token limits, how a model takes thinking — lives here and nowhere else.

Layering

catalog imports core and nothing else in the module. It holds no mutable package-level state: Default is a sync.OnceValue over the embedded bytes and every returned core.Model is a deep copy, so a caller who edits a resolved descriptor cannot corrupt the process-wide catalog.

Index

Constants

View Source
const (
	DefaultContextWindow = 1_000_000
	DefaultMaxTokens     = 128_000
)

Default context window and output cap for a Claude model the catalog does not list.

View Source
const (
	OpenRouterDefaultContextWindow = 131_072
	OpenRouterDefaultMaxTokens     = 32_768
	OllamaDefaultContextWindow     = 32_768
	OllamaDefaultMaxTokens         = 32_768
)

Default context window and output cap for an id the catalog does not list under openrouter or ollama. Like the pair above they are documented guesses, not a lookup at the vendor, and the descriptor they belong to has no price and no effort map.

View Source
const (
	ProviderAnthropic  = "anthropic"
	ProviderOpenRouter = "openrouter"
	ProviderOllama     = "ollama"
)

The providers this build can run. The set is fixed in code, not taken from the catalog's vendors: a vendor section that names a provider with no client behind it must not be selectable. Each name equals the catalog vendor id of the same spelling.

View Source
const SchemaVersion = 1

SchemaVersion is the catalog file format this build understands.

The catalog is versioned separately from the SDK, so a caller may hand Parse a file newer than this binary. A file that declares a different schema_version is rejected rather than parsed on a guess: the failure mode of guessing is a silently wrong price or context window, which surfaces as a 400 deep into a long session or as a mis-billed run, and neither is detectable from the result.

View Source
const Vendor = "anthropic"

Vendor is the vendor Lookup resolves against. The catalog lists a vendor for each of the other providers too (see Providers).

Variables

View Source
var (
	// ErrUnknownProvider is the provider name Select does not know.
	ErrUnknownProvider = errors.New("agentkit: unknown provider")
	// ErrUnknownEffort is an effort outside low, medium, high, xhigh and max.
	ErrUnknownEffort = errors.New("agentkit: unknown effort")
	// ErrNoModel is an empty model string: neither a tier nor a model id.
	ErrNoModel = errors.New("agentkit: no model")
)

The errors Select returns for bad input. Each is wrapped with the value given and the valid choices, so errors.Is classifies it and the message still says what to type instead.

View Source
var ErrCorruptCatalog = errors.New("agentkit: model catalog is corrupt")

ErrCorruptCatalog is the sentinel every Parse failure matches.

Functions

func Lookup

func Lookup(id string) (core.Model, bool)

Lookup returns the descriptor for a Claude model id, with or without the "anthropic/" prefix, and whether the catalog lists it.

An id the catalog does not list is not refused: it gets a usable default with the requested id, a 1,000,000-token window, a 128,000-token output cap, adaptive thinking and no price, so a model released after this snapshot works the day it ships.

func Providers

func Providers() []string

Providers lists the providers in the order anthropic, openrouter, ollama. Every call returns a new slice.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is one parsed, validated, immutable model catalog.

All lookup state is precomputed at Parse time, so resolution is map lookups and never a scan. A *Catalog is safe for concurrent use; nothing mutates it after Parse returns.

func Default

func Default() *Catalog

Default returns the embedded catalog, parsing it on first use.

It panics if the embedded catalog is corrupt and panics identically on every later call. It never returns a silently empty catalog.

func Parse

func Parse(data []byte) (*Catalog, error)

Parse decodes and validates a catalog document, such as a caller's own in place of the embedded one. It is the only constructor; there is no partially-valid Catalog, because a catalog that loaded "mostly" is one whose missing row silently resolves to the default descriptor, with a plausible, wrong context window and no price.

func (*Catalog) DefaultModelID

func (c *Catalog) DefaultModelID(vendor string) string

DefaultModelID is the id of the vendor's default_model row, its most representative current model. It returns "" for an unknown vendor.

func (*Catalog) KnownVendor

func (c *Catalog) KnownVendor(id string) bool

KnownVendor reports whether id names a vendor. It tells whether the segment before the first slash of a model spec is a vendor prefix or just part of an OpenRouter-style model id.

func (*Catalog) Lookup

func (c *Catalog) Lookup(id string) (core.Model, bool)

Lookup is the package-level Lookup against this catalog.

func (*Catalog) Models

func (c *Catalog) Models(vendor string) []string

Models lists the model ids of one vendor in sorted order. It returns nil for an unknown vendor.

func (*Catalog) Note

func (c *Catalog) Note() string

Note is the catalog document's maintenance note, including how to regenerate the file.

func (*Catalog) Select

func (c *Catalog) Select(provider, model string, effort core.Effort) (Selection, error)

Select turns a provider, a model and an effort into the catalog row and the effort a run will use. It is offline: it reads no environment variable and makes no request, and every Model it returns is a deep copy.

The provider is trimmed and matched without regard to case; an empty one means anthropic, and a name that is not one of Providers is refused (ErrUnknownProvider), whatever vendors the catalog holds.

The model is a tier name or a model id. A string that, trimmed, is SIMPLE, STANDARD or ADVANCED in any case is always the tier, never an id: it picks the model and the effort from the provider's tier table, and Selection.Tier is the canonical tier. A tiers block always names a row, so Listed is true; a provider whose section in a parsed catalog has no tiers block is an error naming the provider and the tier. Anything else is an id. An id is only trimmed, never case-folded, and is looked up among the rows of the provider's own vendor, so a row of one provider is never returned for another. On anthropic the id goes through Lookup, which accepts an optional "anthropic/" prefix. An id the catalog does not list is served, not refused, with the provider's fallback limits, no price and Listed false.

The effort is trimmed and folded to one of the five levels, or empty for none (ErrUnknownEffort otherwise). Selection.Effort is the explicit effort, else the tier's, else empty. It is reported as asked: Select neither filters nor clamps it against Model.Efforts, which is the provider's reading.

The inputs are checked in the order provider, model, effort, and the first that fails is the error returned, with the zero Selection.

func (*Catalog) Vendors

func (c *Catalog) Vendors() []string

Vendors lists known vendor ids in sorted order.

func (*Catalog) Version

func (c *Catalog) Version() string

Version is the catalog document's own version, which moves independently of the SDK's.

type ParseError

type ParseError struct {
	Path   string // "vendors.anthropic.models.claude-opus-4-5.cost.input", or "" for whole-file failures
	Reason string
}

ParseError names the exact row that failed validation. A catalog is edited by hand whenever it is regenerated, so "corrupt" without a path is a message that costs an hour.

func (*ParseError) Error

func (e *ParseError) Error() string

Error names the failing path and the reason.

func (*ParseError) Is

func (e *ParseError) Is(target error) bool

Is reports ErrCorruptCatalog so callers can classify without type-asserting.

type Selection

type Selection struct {
	// Provider is the canonical provider name: one of Providers().
	Provider string
	// Tier is the canonical tier when the model string named one, else "".
	Tier Tier
	// Model is a deep copy of the catalog row, or the provider's fallback
	// descriptor for an id the catalog does not list. Model.ID is the id the
	// vendor will receive.
	Model core.Model
	// Effort is the effort to request: the explicit one, else the tier's, else
	// "". Whether it is sent, and in what form, is the provider's reading of
	// Model.Efforts, as on Anthropic today; Select never clamps it.
	Effort core.Effort
	// Listed reports whether Model is a row of the provider's vendor section.
	Listed bool
}

Selection is what Select resolves a (provider, model, effort) triple to.

func Select

func Select(provider, model string, effort core.Effort) (Selection, error)

Select resolves a (provider, model, effort) triple against the embedded catalog; see (*Catalog).Select.

type Tier

type Tier string

Tier is a model preset: a name that picks a model id and an effort for the chosen provider from the catalog's tier table.

const (
	TierSimple   Tier = "SIMPLE"
	TierStandard Tier = "STANDARD"
	TierAdvanced Tier = "ADVANCED"
)

The three tiers. The table is fixed per release; an embedder that wants another mapping names the model and the effort directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL