Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions catalog/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
const bootstrapSource = "bootstrap"

// BootstrapSource returns the provenance label for the embedded catalog seed.
func BootstrapSource() string {

Check failure on line 8 in catalog/bootstrap.go

View workflow job for this annotation

GitHub Actions / deadcode

unreachable func: BootstrapSource
return bootstrapSource
}

// BootstrapCatalogV1 returns deployment/provider wiring only — no chat models.
// BootstrapCatalog returns deployment/provider wiring only — no chat models.
// Chat models come from the published catalog cache and live provider discovery.
func BootstrapCatalogV1() CatalogV1 {
func BootstrapCatalog() Catalog {
generatedAt := time.Now().UTC().Truncate(time.Second)
c := CatalogV1{
SchemaVersion: CatalogV1SchemaVersion,
c := Catalog{
SchemaVersion: CatalogSchemaVersion,
GeneratedAt: generatedAt,
StaleAfter: generatedAt.Add(24 * time.Hour),
Providers: defaultProvidersV1(),
APIProtocols: defaultAPIProtocolsV1(),
Deployments: defaultDeploymentsV1(),
Models: map[string]ModelV1{},
Providers: defaultProviders(),
Protocols: defaultProtocols(),
Deployments: defaultDeployments(),
Models: map[string]Model{},
Aliases: map[string]string{},
Offerings: nil,
Provenance: &CatalogProvenanceV1{Source: bootstrapSource, ObservedAt: generatedAt},
Provenance: &Provenance{Source: bootstrapSource, ObservedAt: generatedAt},
}
EnsureDeploymentEnvFallbacks(&c)
EnsureCredentialRegistryInCatalog(&c)
return c
}

// IsBootstrapCatalog reports whether c is the empty wiring-only catalog.
func IsBootstrapCatalog(c *CatalogV1) bool {
func IsBootstrapCatalog(c *Catalog) bool {
return c != nil && c.Provenance != nil && c.Provenance.Source == bootstrapSource
}
68 changes: 34 additions & 34 deletions catalog/catalog_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,36 +89,36 @@ func TestServerToolsFromOffering(t *testing.T) {
t.Parallel()
tests := []struct {
name string
offering ModelOfferingV1
offering ModelOffering
want []string
}{
{
name: "nil_server_tools",
offering: ModelOfferingV1{},
offering: ModelOffering{},
want: nil,
},
{
name: "supported_tool",
offering: ModelOfferingV1{
Capabilities: CapabilitySetV1{
offering: ModelOffering{
Capabilities: CapabilitySet{
ServerTools: map[string]CapabilityState{"web_search": CapabilitySupported},
},
},
want: []string{"web_search"},
},
{
name: "unsupported_tool_filtered",
offering: ModelOfferingV1{
Capabilities: CapabilitySetV1{
offering: ModelOffering{
Capabilities: CapabilitySet{
ServerTools: map[string]CapabilityState{"web_search": CapabilityUnsupported},
},
},
want: nil,
},
{
name: "mixed_tools",
offering: ModelOfferingV1{
Capabilities: CapabilitySetV1{
offering: ModelOffering{
Capabilities: CapabilitySet{
ServerTools: map[string]CapabilityState{
"web_search": CapabilitySupported,
"code_interp": CapabilityUnsupported,
Expand All @@ -130,8 +130,8 @@ func TestServerToolsFromOffering(t *testing.T) {
},
{
name: "empty_tool_name_filtered",
offering: ModelOfferingV1{
Capabilities: CapabilitySetV1{
offering: ModelOffering{
Capabilities: CapabilitySet{
ServerTools: map[string]CapabilityState{
"": CapabilitySupported,
"web_search": CapabilitySupported,
Expand Down Expand Up @@ -162,8 +162,8 @@ func TestModelEntryFromOffering(t *testing.T) {
t.Parallel()
tests := []struct {
name string
model ModelV1
offering ModelOfferingV1
model Model
offering ModelOffering
wantID string
wantContext int
wantMaxOut int
Expand All @@ -172,28 +172,28 @@ func TestModelEntryFromOffering(t *testing.T) {
}{
{
name: "uses_native_model_id",
model: ModelV1{ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet 4.6", ContextWindow: 200000, MaxOutput: 32000},
offering: ModelOfferingV1{
model: Model{ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet 4.6", ContextWindow: 200000, MaxOutput: 32000},
offering: ModelOffering{
NativeModelID: "claude-sonnet-4-6",
Pricing: PricingV1{RatesPer1M: map[string]float64{"input_tokens": 3, "output_tokens": 15}},
Pricing: Pricing{RatesPer1M: map[string]float64{"input_tokens": 3, "output_tokens": 15}},
},
wantID: "claude-sonnet-4-6", wantContext: 200000, wantMaxOut: 32000, wantInPrice: 3, wantOutPrice: 15,
},
{
name: "empty_native_falls_back_to_model_id",
model: ModelV1{ID: "openai/gpt-4o", Name: "GPT-4o"},
offering: ModelOfferingV1{
model: Model{ID: "openai/gpt-4o", Name: "GPT-4o"},
offering: ModelOffering{
NativeModelID: "",
Pricing: PricingV1{Status: PricingUnknown},
Pricing: Pricing{Status: PricingUnknown},
},
wantID: "openai/gpt-4o",
},
{
name: "nil_rates_zeroes_prices",
model: ModelV1{ID: "x/model", Name: "Model"},
offering: ModelOfferingV1{
model: Model{ID: "x/model", Name: "Model"},
offering: ModelOffering{
NativeModelID: "model",
Pricing: PricingV1{Status: PricingUnknown},
Pricing: Pricing{Status: PricingUnknown},
},
wantID: "model", wantInPrice: 0, wantOutPrice: 0,
},
Expand Down Expand Up @@ -232,8 +232,8 @@ func TestModelEntriesForProvider_NilCompiled(t *testing.T) {

func TestModelEntriesForProvider_EmptyProvider(t *testing.T) {
t.Parallel()
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"anthropic/claude-sonnet-4-6": {ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet", ProviderID: "anthropic"},
},
}
Expand All @@ -245,11 +245,11 @@ func TestModelEntriesForProvider_EmptyProvider(t *testing.T) {

func TestModelEntriesForProvider_DeduplicatesByNativeID(t *testing.T) {
t.Parallel()
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"anthropic/claude-sonnet-4-6": {ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet", ProviderID: "anthropic"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"anthropic-direct": {
{CanonicalModelID: "anthropic/claude-sonnet-4-6", DeploymentID: "anthropic-direct", NativeModelID: "claude-sonnet-4-6"},
},
Expand All @@ -267,7 +267,7 @@ func TestDiscoveryEnvKeysFromCatalog(t *testing.T) {
t.Parallel()
tests := []struct {
name string
compiled *CompiledCatalogV1
compiled *CompiledCatalog
wantNil bool
}{
{
Expand All @@ -277,7 +277,7 @@ func TestDiscoveryEnvKeysFromCatalog(t *testing.T) {
},
{
name: "nil_catalog",
compiled: &CompiledCatalogV1{},
compiled: &CompiledCatalog{},
wantNil: true,
},
}
Expand All @@ -293,8 +293,8 @@ func TestDiscoveryEnvKeysFromCatalog(t *testing.T) {

func TestDiscoveryEnvKeysFromCatalog_ReturnsUniqueKeys(t *testing.T) {
t.Parallel()
c := testLegacyCatalogV1()
compiled, err := CompileCatalogV1(&c)
c := SeedCatalog()
compiled, err := CompileCatalog(&c)
if err != nil {
t.Fatal(err)
}
Expand All @@ -318,8 +318,8 @@ func TestDiscoveryEnvKeysFromCatalog_ReturnsUniqueKeys(t *testing.T) {

func TestAPIKeyEnvsForProvider(t *testing.T) {
t.Parallel()
c := testLegacyCatalogV1()
compiled, err := CompileCatalogV1(&c)
c := SeedCatalog()
compiled, err := CompileCatalog(&c)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -378,8 +378,8 @@ func TestPrimaryAPIKeyEnvForDeployment(t *testing.T) {

func TestPrimaryAPIKeyEnvForDeployment_WithCompiled(t *testing.T) {
t.Parallel()
c := testLegacyCatalogV1()
compiled, err := CompileCatalogV1(&c)
c := SeedCatalog()
compiled, err := CompileCatalog(&c)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion catalog/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestGetModelDeprecationWarning(t *testing.T) {

func TestModelsForProvider(t *testing.T) {
t.Parallel()
cat := testLegacyModelCatalog()
cat := testModelCatalog()
models := cat.Providers["anthropic"]
if len(models) == 0 {
t.Error("expected anthropic models in default catalog")
Expand Down
18 changes: 9 additions & 9 deletions catalog/compiled_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// ModelEntriesForProvider lists models from a compiled v1 catalog for one provider.
// New models appear here automatically when the eyrie catalog is updated — hosts must not hardcode IDs.
func ModelEntriesForProvider(compiled *CompiledCatalogV1, provider string) []ModelCatalogEntry {
func ModelEntriesForProvider(compiled *CompiledCatalog, provider string) []ModelCatalogEntry {
if compiled == nil {
return nil
}
Expand All @@ -24,7 +24,7 @@
return modelEntriesByProviderID(compiled, provider)
}

func modelEntriesByProviderID(compiled *CompiledCatalogV1, provider string) []ModelCatalogEntry {
func modelEntriesByProviderID(compiled *CompiledCatalog, provider string) []ModelCatalogEntry {
seen := map[string]bool{}
var out []ModelCatalogEntry
ids := make([]string, 0, len(compiled.ModelsByID))
Expand All @@ -48,7 +48,7 @@

// CanonicalModelForProviderNative maps a picker native id to the canonical model for that provider's
// deployment, without using global catalog aliases (e.g. mimo-v2.5-pro → xiaomi, not opencodego).
func CanonicalModelForProviderNative(compiled *CompiledCatalogV1, providerID, modelID string) (string, bool) {
func CanonicalModelForProviderNative(compiled *CompiledCatalog, providerID, modelID string) (string, bool) {

Check failure on line 51 in catalog/compiled_list.go

View workflow job for this annotation

GitHub Actions / deadcode

unreachable func: CanonicalModelForProviderNative
if compiled == nil {
return "", false
}
Expand All @@ -70,7 +70,7 @@
return "", false
}

func modelEntriesForDeployment(compiled *CompiledCatalogV1, deploymentID string) []ModelCatalogEntry {
func modelEntriesForDeployment(compiled *CompiledCatalog, deploymentID string) []ModelCatalogEntry {
if compiled == nil || deploymentID == "" {
return nil
}
Expand All @@ -95,7 +95,7 @@
return out
}

func modelEntryFromOffering(model ModelV1, offering ModelOfferingV1) ModelCatalogEntry {
func modelEntryFromOffering(model Model, offering ModelOffering) ModelCatalogEntry {
id := strings.TrimSpace(model.ID)
if native := strings.TrimSpace(offering.NativeModelID); native != "" {
id = native
Expand Down Expand Up @@ -132,14 +132,14 @@
return strings.TrimSpace(meta.Description)
}

func modelOwnerFromOffering(offering ModelOfferingV1) string {
func modelOwnerFromOffering(offering ModelOffering) string {
if o := ownerFromLiveMetadata(offering.LiveMetadata); o != "" {
return o
}
return ownerFromModelID(offering.NativeModelID)
}

func serverToolsFromOffering(offering ModelOfferingV1) []string {
func serverToolsFromOffering(offering ModelOffering) []string {
if offering.Capabilities.ServerTools == nil {
return nil
}
Expand All @@ -153,10 +153,10 @@
return out
}

func firstOfferingForModel(compiled *CompiledCatalogV1, canonicalModelID string) ModelOfferingV1 {
func firstOfferingForModel(compiled *CompiledCatalog, canonicalModelID string) ModelOffering {
offerings := compiled.OfferingsByCanonicalModel[canonicalModelID]
if len(offerings) == 0 {
return ModelOfferingV1{}
return ModelOffering{}
}
sort.SliceStable(offerings, func(i, j int) bool {
return offerings[i].DeploymentID < offerings[j].DeploymentID
Expand Down
32 changes: 16 additions & 16 deletions catalog/compiled_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import "testing"
func TestModelEntriesForProvider_OpenRouterUsesOfferings(t *testing.T) {
t.Parallel()
raw := []byte(`{"id":"anthropic/claude-sonnet-4-6","architecture":{"modality":"text"}}`)
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"anthropic/claude-sonnet-4-6": {ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet", ProviderID: "anthropic"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"openrouter": {{
CanonicalModelID: "anthropic/claude-sonnet-4-6",
DeploymentID: "openrouter",
Expand All @@ -30,11 +30,11 @@ func TestModelEntriesForProvider_OpenRouterUsesOfferings(t *testing.T) {
func TestModelEntriesForProvider_CanopyWaveUsesDeploymentOfferings(t *testing.T) {
t.Parallel()
raw := []byte(`{"id":"moonshotai/kimi-k2.6","name":"Kimi K2.6","owned_by":"moonshotai"}`)
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"moonshotai/kimi-k2.6": {ID: "moonshotai/kimi-k2.6", Name: "Kimi K2.6", ProviderID: "moonshotai"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"canopywave": {{
CanonicalModelID: "moonshotai/kimi-k2.6",
DeploymentID: "canopywave",
Expand All @@ -54,13 +54,13 @@ func TestModelEntriesForProvider_CanopyWaveUsesDeploymentOfferings(t *testing.T)

func TestModelEntriesForProvider_GeminiUsesDirectDeploymentOfferings(t *testing.T) {
t.Parallel()
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"gemini-flash": {ID: "gemini-flash", Name: "Flash", ProviderID: "google"},
"gemini-pro": {ID: "gemini-pro", Name: "Pro", ProviderID: "google"},
"other-model": {ID: "other-model", Name: "Other", ProviderID: "google"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"gemini-direct": {
{CanonicalModelID: "gemini-flash", DeploymentID: "gemini-direct", NativeModelID: "gemini-flash"},
{CanonicalModelID: "gemini-pro", DeploymentID: "gemini-direct", NativeModelID: "gemini-pro"},
Expand All @@ -75,17 +75,17 @@ func TestModelEntriesForProvider_GeminiUsesDirectDeploymentOfferings(t *testing.

func TestCanonicalModelForProviderNative_PrefersDeploymentOverGlobalAlias(t *testing.T) {
t.Parallel()
compiled := &CompiledCatalogV1{
Catalog: &CatalogV1{
compiled := &CompiledCatalog{
Catalog: &Catalog{
Aliases: map[string]string{
"mimo-v2.5-pro": "opencodego/mimo-v2.5-pro",
},
},
ModelsByID: map[string]ModelV1{
ModelsByID: map[string]Model{
"opencodego/mimo-v2.5-pro": {ID: "opencodego/mimo-v2.5-pro", ProviderID: "opencodego"},
"xiaomi_mimo_token_plan/mimo-v2.5-pro": {ID: "xiaomi_mimo_token_plan/mimo-v2.5-pro", ProviderID: "xiaomi_mimo_token_plan"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"xiaomi_mimo_token_plan-direct": {{
CanonicalModelID: "xiaomi_mimo_token_plan/mimo-v2.5-pro",
DeploymentID: "xiaomi_mimo_token_plan-direct",
Expand All @@ -101,12 +101,12 @@ func TestCanonicalModelForProviderNative_PrefersDeploymentOverGlobalAlias(t *tes

func TestModelEntriesForProvider_AnthropicUsesDirectDeploymentOfferings(t *testing.T) {
t.Parallel()
compiled := &CompiledCatalogV1{
ModelsByID: map[string]ModelV1{
compiled := &CompiledCatalog{
ModelsByID: map[string]Model{
"anthropic/claude-sonnet-4-6": {ID: "anthropic/claude-sonnet-4-6", Name: "Sonnet", ProviderID: "anthropic"},
"openai/gpt-4o": {ID: "openai/gpt-4o", Name: "GPT-4o", ProviderID: "openai"},
},
OfferingsByDeployment: map[string][]ModelOfferingV1{
OfferingsByDeployment: map[string][]ModelOffering{
"anthropic-direct": {{
CanonicalModelID: "anthropic/claude-sonnet-4-6",
DeploymentID: "anthropic-direct",
Expand Down
Loading
Loading