Share configuration settings across the public boundary

This commit is contained in:
2026-11-21 14:15:14 +00:00
parent 38a2dcca52
commit 76c8789e65
7 changed files with 310 additions and 131 deletions

View File

@@ -0,0 +1,187 @@
// Package settings contains the shared public configuration data declarations.
package settings
// Settings is the effective PromptKit configuration section.
type Settings struct {
// SchemaRoot is the default root for schema_path references.
SchemaRoot *string `yaml:"schema_root"`
// Backends defines the root backend resources.
Backends []BackendSettings `yaml:"backends"`
// Profiles defines the root profile resources.
Profiles []ProfileSettings `yaml:"profiles"`
// Prompts defines the root prompt resources.
Prompts []PromptSettings `yaml:"prompts"`
// Collections holds namespaced resources.
Collections map[string]CollectionSettings `yaml:"collections"`
// Application retains unrecognized application-owned fields.
Application map[string]any `yaml:",inline"`
}
// CollectionSettings contains resources within one namespace.
type CollectionSettings struct {
// ReleaseVersion is descriptive collection metadata.
ReleaseVersion *string `yaml:"release_version"`
// SchemaRoot overrides the root schema directory for this collection.
SchemaRoot *string `yaml:"schema_root"`
// Backends defines collection backends.
Backends []BackendSettings `yaml:"backends"`
// Profiles defines collection profiles.
Profiles []ProfileSettings `yaml:"profiles"`
// Prompts defines collection prompts.
Prompts []PromptSettings `yaml:"prompts"`
// Application retains unrecognized application-owned fields.
Application map[string]any `yaml:",inline"`
}
// BackendSettings describes an effective backend.
type BackendSettings struct {
// ID identifies the backend in its resource list.
ID string `yaml:"id"`
// Endpoint is the backend's absolute base URL.
Endpoint *string `yaml:"endpoint"`
// APIKeyEnv names an environment variable containing a credential.
APIKeyEnv *string `yaml:"api_key_env"`
// ConcurrencyLimit controls simultaneous generations; zero is unlimited.
ConcurrencyLimit *int `yaml:"concurrency_limit"`
// QueueCapacity controls waiting requests when concurrency is limited.
QueueCapacity *int `yaml:"queue_capacity"`
// ExtraParams supplies provider request defaults.
ExtraParams map[string]any `yaml:"extra_params"`
// SmokeTests supplies diagnostic settings.
SmokeTests *BackendSmokeTestConfig `yaml:"smoke_tests"`
// Application retains unrecognized application-owned fields.
Application map[string]any `yaml:",inline"`
}
// ProfileSettings describes an effective execution profile.
type ProfileSettings struct {
// ID identifies the profile in its resource list.
ID string `yaml:"id"`
// Backend selects a backend by ID.
Backend *string `yaml:"backend"`
// Endpoint overrides the backend endpoint.
Endpoint *string `yaml:"endpoint"`
// Model selects the provider model.
Model *string `yaml:"model"`
// Temperature controls sampling temperature.
Temperature *float64 `yaml:"temperature"`
// TopP controls nucleus sampling.
TopP *float64 `yaml:"top_p"`
// MaxTokens limits generated tokens.
MaxTokens *int `yaml:"max_tokens"`
// TimeoutSeconds limits the model request duration.
TimeoutSeconds *int `yaml:"timeout_seconds"`
// ServiceTier selects a provider service tier.
ServiceTier *string `yaml:"service_tier"`
// ReasoningEffort selects provider reasoning effort.
ReasoningEffort *string `yaml:"reasoning_effort"`
// APIKeyEnv names an environment variable containing a credential.
APIKeyEnv *string `yaml:"api_key_env"`
// APIKeyRequired controls whether a credential is required.
APIKeyRequired *bool `yaml:"api_key_required"`
// ExtraParams supplies provider request parameters.
ExtraParams map[string]any `yaml:"extra_params"`
// Application retains unrecognized application-owned fields.
Application map[string]any `yaml:",inline"`
}
// PromptSettings describes an effective prompt.
type PromptSettings struct {
// ID identifies the prompt in its resource list.
ID string `yaml:"id"`
// DefaultProfile selects the default profile ID.
DefaultProfile *string `yaml:"default_profile"`
// Description describes the prompt.
Description *string `yaml:"description"`
// SessionID is a session template.
SessionID *string `yaml:"session_id"`
// Inputs declares named prompt inputs.
Inputs []PromptInputSettings `yaml:"inputs"`
// Messages defines the prompt message templates.
Messages []PromptMessageSettings `yaml:"messages"`
// Output defines the output contract.
Output *PromptOutputSettings `yaml:"output"`
// Application retains unrecognized application-owned fields.
Application map[string]any `yaml:",inline"`
}
// PromptInputSettings describes a declared prompt input.
type PromptInputSettings struct {
// Name is the input name.
Name string `yaml:"name"`
// Required indicates whether the input is required.
Required bool `yaml:"required"`
// ContentType identifies the input content type.
ContentType *string `yaml:"content_type"`
// Description describes the input.
Description *string `yaml:"description"`
}
// PromptMessageSettings describes one prompt message.
type PromptMessageSettings struct {
// Role is the message role.
Role *string `yaml:"role"`
// Content is inline message template text.
Content *string `yaml:"content"`
// ContentFile names a source-relative message template.
ContentFile *string `yaml:"content_file"`
// CacheControl specifies message cache metadata.
CacheControl *PromptCacheControlSettings `yaml:"cache_control"`
}
// PromptCacheControlSettings describes message cache metadata.
type PromptCacheControlSettings struct {
// Type identifies the cache-control mode.
Type *string `yaml:"type"`
// TTL selects an optional cache duration.
TTL *string `yaml:"ttl"`
}
// PromptOutputSettings describes the configured output contract.
type PromptOutputSettings struct {
// Format identifies the output format.
Format *string `yaml:"format"`
// ValidationMode selects the output validation mode.
ValidationMode *string `yaml:"validation_mode"`
// Schema provides an inline JSON Schema.
Schema any `yaml:"schema"`
// SchemaFile names a source-relative JSON Schema.
SchemaFile *string `yaml:"schema_file"`
// SchemaPath names a JSON Schema under the selected schema root.
SchemaPath *string `yaml:"schema_path"`
// RepairAttempts sets an optional correction budget.
RepairAttempts *int `yaml:"repair_attempts"`
}
// BackendSmokeTestConfig contains optional diagnostic settings associated with a backend.
type BackendSmokeTestConfig struct {
// DefaultProfile is the exact profile ID selected as the backend's
// diagnostic inference default. A supplied value must not be blank; the ID
// is resolved only when that default is selected.
DefaultProfile *string `json:"default_profile,omitempty" yaml:"default_profile,omitempty"`
// Reachability optionally selects a full HTTP destination for reachability
// diagnostics. A nil endpoint uses the effective backend endpoint.
Reachability *ReachabilityProbeConfig `json:"reachability,omitempty" yaml:"reachability,omitempty"`
// Authentication optionally declares a named authentication diagnostic.
// A supplied object requires Kind.
Authentication *AuthenticationProbeConfig `json:"authentication,omitempty" yaml:"authentication,omitempty"`
}
// ReachabilityProbeConfig configures an optional reachability destination.
type ReachabilityProbeConfig struct {
// Endpoint is an absolute HTTP(S) URL, including any desired path or query.
// Nil selects the effective backend endpoint; an explicit blank value is
// invalid.
Endpoint *string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
}
// AuthenticationProbeConfig configures an optional named authentication diagnostic.
type AuthenticationProbeConfig struct {
// Kind selects the authentication adapter. Supported values are "none" and
// "openrouter_key"; surrounding whitespace and case are normalized.
Kind *string `json:"kind,omitempty" yaml:"kind,omitempty"`
// Endpoint is an absolute HTTP(S) URL, including any desired path or query.
// Nil selects the adapter's backend-relative destination; an explicit blank
// value is invalid.
Endpoint *string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
}