Add typed prompt sources and backend inheritance

This commit is contained in:
2026-11-06 15:27:08 +00:00
parent ea63a7b0ff
commit 27966c1686
3 changed files with 140 additions and 1 deletions

View File

@@ -19,10 +19,13 @@ const BackendLocal = "local"
// explicit zero or blank values. A nil ExtraParams map is omitted; a non-nil
// empty map supplies an empty mapping. A nil SmokeTests pointer is omitted; a
// non-nil pointer supplies a smoke_tests mapping. Use raw ConfigKit Mapping
// inputs for explicit null. BackendConfig has no stable JSON representation.
// inputs for explicit null. Extends names a sibling backend in the same list.
// BackendConfig has no stable JSON representation.
type BackendConfig struct {
// ID is the local backend identity within its resource list.
ID string
// Extends names a sibling backend to inherit through ConfigKit.
Extends *string
// Endpoint is the required absolute HTTP(S) base URL after all layers merge.
Endpoint *string
// APIKeyEnv optionally names an environment variable, not a credential.
@@ -84,6 +87,9 @@ func BackendSource(label string, backends []BackendConfig) configkit.Source {
definitions := make([]any, 0, len(backends))
for _, config := range backends {
fields := map[string]any{"id": config.ID}
if config.Extends != nil {
fields["extends"] = map[string]any{"id": *config.Extends}
}
if config.Endpoint != nil {
fields["endpoint"] = *config.Endpoint
}