feat: URL-derived provider keys (hs-<hostname>) + dedup providers sharing same gateway URL

- GatewayProviderKey() derives stable key from gateway URL hostname
  e.g. https://llmgw.h.raczylo.com/v1 → hs-llmgw-h-raczylo-com
- AbsorbDuplicateProviders() merges providers sharing the same baseURL
  into our canonical entry; user-crafted model metadata wins for overlaps
- kilo: renders to opencode.jsonc (primary config), deep-merges providers,
  deletes enabled_providers filter that was hiding our gateway
- opencode: absorbs duplicate providers from existing config
- All adapters use GatewayProviderKey() instead of hardcoded string
- Fix goose URL doubling (was /v1/v1/chat/completions → /chat/completions)
- Fix token propagation: api_key written directly (not env var ref)
- Zed: adds prompt_cache_key capability, deletes context_servers key
  to avoid ContextServerSettingsContent serde untagged-enum parse error
This commit is contained in:
2026-05-23 21:13:16 +01:00
parent 77158d9f2b
commit fb02b165d7
16 changed files with 180 additions and 57 deletions
+10 -6
View File
@@ -126,14 +126,18 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
"enabled_providers": nil, // delete filter
}
// Deep-merge provider: add our entries INTO the existing provider map.
// Deep-merge provider: add our entries INTO the existing provider map,
// then absorb any duplicate providers that share the same gateway URL.
if newProv, ok := overlay["provider"].(map[string]any); ok && len(newProv) > 0 {
existing, _ := ocBase["provider"].(map[string]any)
if existing == nil {
existing = map[string]any{}
existingProv, _ := ocBase["provider"].(map[string]any)
if existingProv == nil {
existingProv = map[string]any{}
}
maps.Copy(existing, newProv)
ocOverlay["provider"] = existing
maps.Copy(existingProv, newProv)
// Absorb providers at the same URL into harness-sync-gateway,
// preserving user-crafted display names and custom limits.
merged := common.AbsorbDuplicateProviders(existingProv, common.GatewayProviderKey(b.Profile.Gateway.URL), b.Profile.Gateway.URL)
ocOverlay["provider"] = merged
}
// Copy model/small_model/mcp from the kilo.json overlay.
for _, k := range []string{"model", "small_model", "mcp"} {