Files
archie/internal/infrastructure/staterpc/model_provider_wire.go
T
sam 854c371c2d fix(staterpc): carry each model provider's credential reference
The State Store wire described a provider's class, base URL and key variable
but never where its key lives, so every provider reached the daemon
credential-less. A task then built its runtime with no key: the egress session
had nothing to bind and the agent parked on 'APIKey is required'.

Carry api_key_engine and api_key_key alongside the provider. They are a
reference, not a secret; the key is still resolved daemon-side and never
travels to a container.
2026-10-20 07:10:58 +11:00

30 lines
954 B
Go

package staterpc
import (
"github.com/samcharles93/archie-core/internal/config"
pb "github.com/samcharles93/archie-core/internal/contracts/state/v1"
)
// modelProviderToPB describes a provider on the State Store wire. The
// credential reference travels with it: it names where the key lives, not the
// key, and the daemon cannot resolve a model egress credential without it.
func modelProviderToPB(p config.Provider) *pb.ModelProvider {
return &pb.ModelProvider{
Class: p.Class,
BaseUrl: p.BaseURL,
ApiKeyEnv: p.APIKeyEnv,
ApiKeyEngine: p.APIKey.Engine,
ApiKeyKey: p.APIKey.Key,
}
}
// modelProviderFromPB rebuilds a provider from the State Store wire.
func modelProviderFromPB(p *pb.ModelProvider) config.Provider {
return config.Provider{
Class: p.GetClass(),
BaseURL: p.GetBaseUrl(),
APIKeyEnv: p.GetApiKeyEnv(),
APIKey: config.SecretRef{Engine: p.GetApiKeyEngine(), Key: p.GetApiKeyKey()},
}
}