refactor(webui): remove unused configuration schema
This commit is contained in:
1 parent
552ee93a47
commit
3b79155602
6 files changed
+32
-459
No files matched your search
@@ -724,26 +724,11 @@ func (b *boot) publishConfig(ctx context.Context, cfg config.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *boot) configOrigins() []webui.ConfigOrigin {
|
||||
provenance := b.currentProvenance.Load()
|
||||
if provenance == nil {
|
||||
return nil
|
||||
}
|
||||
origins := make([]webui.ConfigOrigin, 0, len(provenance.Origins))
|
||||
for _, origin := range provenance.Origins {
|
||||
origins = append(origins, webui.ConfigOrigin{
|
||||
Path: origin.Path, Role: string(origin.Role), Layer: string(origin.Layer), Feature: string(origin.Feature),
|
||||
})
|
||||
}
|
||||
return origins
|
||||
}
|
||||
|
||||
func (b *boot) configViewInput() webui.ConfigViewInput {
|
||||
catalog, _ := b.catalogState()
|
||||
in := webui.ConfigViewInput{
|
||||
Config: b.cfgHolder.Get(),
|
||||
Provenance: b.configOrigins(),
|
||||
Catalog: catalogView(catalog),
|
||||
Config: b.cfgHolder.Get(),
|
||||
Catalog: catalogView(catalog),
|
||||
}
|
||||
if b.lastReload != nil {
|
||||
status := b.lastReload()
|
||||
|
||||
@@ -64,9 +64,7 @@ func resolveProviderMap(scope string, providers map[string]config.Provider, regi
|
||||
}
|
||||
|
||||
// disableProvider clears a provider's credential so every consumer sees it as
|
||||
// unconfigured, and says why. The reference is cleared rather than left in
|
||||
// place: webui's ProviderView derives Configured from it, so keeping an
|
||||
// unresolvable reference would advertise a provider that cannot be used.
|
||||
// unconfigured, and says why.
|
||||
func disableProvider(providers map[string]config.Provider, id string, provider config.Provider, log *slog.Logger, reason string, cause error) {
|
||||
provider.APIKey = secret.SecretRef{}
|
||||
provider.APIKeyEnv = ""
|
||||
|
||||
+28
-205
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/channels/status"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
)
|
||||
|
||||
// ChannelView is one conversational front-end as shown on the dashboard's
|
||||
@@ -106,59 +105,24 @@ func channelStateDetail(state status.State, configured bool) string {
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigView is the read-only, secret-free projection of config.Config
|
||||
// shown on the dashboard's Configuration page. Every field here is an
|
||||
// explicit, hand-picked allowlist -- see handleConfig for why this is
|
||||
// built field by field rather than by marshalling config.Config directly.
|
||||
// ConfigView is the daemon's secret-free snapshot for dashboard handlers.
|
||||
// Only catalog, review and reload are exposed by /api/config.
|
||||
type ConfigView struct {
|
||||
Identity IdentityView `json:"identity"`
|
||||
Repositories []RepoView `json:"repositories"`
|
||||
Models map[string]string `json:"models"`
|
||||
Providers map[string]ProviderView `json:"providers"`
|
||||
Budgets BudgetsView `json:"budgets"`
|
||||
// Review is the layered pr-review policy: what a review may post, and
|
||||
// whether a human decides. It is a plain projection of the effective
|
||||
// cfg.Review, so the published snapshot tells a reader which dials are in
|
||||
// force.
|
||||
Review ReviewView `json:"review"`
|
||||
Storage StorageView `json:"storage"`
|
||||
Containers ContainersView `json:"containers"`
|
||||
Web WebView `json:"web"`
|
||||
// Chat carries the dashboard's own chat-page settings. They are
|
||||
// daemon configuration the page cannot otherwise see: a process that
|
||||
// renders a published snapshot has no [chat] section to read.
|
||||
Chat ChatView `json:"chat"`
|
||||
// Catalog lists the providers the model catalog found usable (their key
|
||||
// is set in the environment, or they are configured), with their models,
|
||||
// so Settings can offer to enable one and pick role models from it.
|
||||
Catalog []CatalogProviderView `json:"catalog"`
|
||||
Provenance []ConfigOrigin `json:"provenance"`
|
||||
// Reload reports the most recent config reload outcome. Omitted when
|
||||
// the reload status is unavailable.
|
||||
Reload *config.ReloadStatus `json:"reload,omitempty"`
|
||||
// Locked maps dotted config keys that cannot be changed from the
|
||||
// dashboard to the reason. The UI renders these rows disabled rather
|
||||
// than silently omitting the edit affordance.
|
||||
Locked map[string]string `json:"locked,omitempty"`
|
||||
// MultiIdentity reports that [[identities]] is configured, so Identity and
|
||||
// Repositories describe only the default identity.
|
||||
MultiIdentity bool `json:"multi_identity,omitempty"`
|
||||
// Identities lists each identity's forge and repositories. Empty for a
|
||||
// single-identity deployment.
|
||||
Identities []ForgeIdentityView `json:"identities,omitempty"`
|
||||
// Schema is the field-descriptor catalog for the configuration page.
|
||||
Schema []ConfigSection `json:"schema"`
|
||||
Identity IdentityView `json:"identity"`
|
||||
Repositories []ForgeRepoView `json:"repositories"`
|
||||
Review ReviewView `json:"review"`
|
||||
Chat ChatView `json:"chat"`
|
||||
Catalog []CatalogProviderView `json:"catalog"`
|
||||
Reload *config.ReloadStatus `json:"reload,omitempty"`
|
||||
MultiIdentity bool `json:"multi_identity,omitempty"`
|
||||
Identities []ForgeIdentityView `json:"identities,omitempty"`
|
||||
}
|
||||
|
||||
// IdentityView is who Archie is on the forge -- never the token that
|
||||
// authenticates as that identity.
|
||||
// IdentityView supplies setup and task forge coordinates.
|
||||
type IdentityView struct {
|
||||
BotUser string `json:"bot_user"`
|
||||
BotEmail string `json:"bot_email"`
|
||||
Label string `json:"label"`
|
||||
ForgeType string `json:"forge_type"`
|
||||
ForgeHost string `json:"forge_host"`
|
||||
DiffCapLines int `json:"diff_cap_lines"`
|
||||
BotUser string `json:"bot_user"`
|
||||
ForgeType string `json:"forge_type"`
|
||||
ForgeHost string `json:"forge_host"`
|
||||
}
|
||||
|
||||
// ForgeRepoView names one repository an identity owns. Owner and name are
|
||||
@@ -177,39 +141,6 @@ type ForgeIdentityView struct {
|
||||
Repos []ForgeRepoView `json:"repos,omitempty"`
|
||||
}
|
||||
|
||||
// RepoView is one managed repository and the quality gate it must pass.
|
||||
// Gate and Preflight are shell command argv lists -- test runners and
|
||||
// linters, not secrets -- so they are safe to show verbatim.
|
||||
type RepoView struct {
|
||||
Owner string `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
Base string `json:"base"`
|
||||
Gate [][]string `json:"gate"`
|
||||
Protect []string `json:"protect"`
|
||||
Ecosystem string `json:"ecosystem"`
|
||||
PersistentStorage bool `json:"persistent_storage"`
|
||||
AllowConcurrent bool `json:"allow_concurrent"`
|
||||
MaxRetries int `json:"max_retries"`
|
||||
}
|
||||
|
||||
// ProviderView is an LLM provider's shape, never its key. APIKeyEnv is the
|
||||
// name of an environment variable, not a value, so it is safe to show;
|
||||
// Configured reports whether either credential form (env or secret engine)
|
||||
// is actually set, without revealing which or what.
|
||||
type ProviderView struct {
|
||||
Class string `json:"class"`
|
||||
BaseURL string `json:"base_url,omitempty"`
|
||||
APIKeyEnv string `json:"api_key_env,omitempty"`
|
||||
Configured bool `json:"configured"`
|
||||
}
|
||||
|
||||
// BudgetsView mirrors config.Budgets, none of which is secret.
|
||||
type BudgetsView struct {
|
||||
MaxSteps int `json:"max_steps"`
|
||||
WallClock string `json:"wall_clock"`
|
||||
GateMaxFailures int `json:"gate_max_failures"`
|
||||
}
|
||||
|
||||
// ReviewView mirrors config.Review, neither field of which is secret. It
|
||||
// carries the value in force after the review-settings resource is layered over
|
||||
// the file's [review] section.
|
||||
@@ -218,25 +149,6 @@ type ReviewView struct {
|
||||
ApproveBeforePost bool `json:"approve_before_post"`
|
||||
}
|
||||
|
||||
// StorageView is where archied keeps its state on disk. All paths, no
|
||||
// secrets.
|
||||
type StorageView struct {
|
||||
WorkDir string `json:"work_dir"`
|
||||
StateDir string `json:"state_dir"`
|
||||
SkillsDir string `json:"skills_dir,omitempty"`
|
||||
}
|
||||
|
||||
// ContainersView is how sandboxed task execution is configured.
|
||||
type ContainersView struct {
|
||||
Image string `json:"image,omitempty"`
|
||||
MaxConcurrency int `json:"max_concurrency"`
|
||||
MaxUptime string `json:"max_uptime"`
|
||||
VolumeTTL string `json:"volume_ttl"`
|
||||
PullPolicy string `json:"pull_policy"`
|
||||
Network string `json:"network,omitempty"`
|
||||
}
|
||||
|
||||
// WebView is the dashboard's own listen address and proxy header trust settings.
|
||||
// ChatView carries the chat page's own settings and the facts the setup
|
||||
// checklist needs. Secret-free by construction: whether a channel has
|
||||
// credentials, never the credentials.
|
||||
@@ -251,11 +163,6 @@ type ChatView struct {
|
||||
ChannelConfigured bool `json:"channel_configured"`
|
||||
}
|
||||
|
||||
type WebView struct {
|
||||
Listen string `json:"listen"`
|
||||
TrustForwardedHeaders bool `json:"trust_forwarded_headers"`
|
||||
}
|
||||
|
||||
// ConfigViewSchema names ConfigView's JSON shape; it changes on incompatible
|
||||
// changes.
|
||||
const ConfigViewSchema = "webui.ConfigView/1"
|
||||
@@ -285,7 +192,11 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]any{})
|
||||
return
|
||||
}
|
||||
writeJSON(w, view)
|
||||
writeJSON(w, struct {
|
||||
Catalog []CatalogProviderView `json:"catalog"`
|
||||
Review ReviewView `json:"review"`
|
||||
Reload *config.ReloadStatus `json:"reload,omitempty"`
|
||||
}{Catalog: view.Catalog, Review: view.Review, Reload: view.Reload})
|
||||
}
|
||||
|
||||
// ConfigViewInput is everything BuildConfigView needs. The configuration
|
||||
@@ -295,9 +206,6 @@ type ConfigViewInput struct {
|
||||
// Config is one snapshot, read once. Under a Holder a reload swaps the
|
||||
// whole value, which is what a read-only view always wanted.
|
||||
Config config.Config
|
||||
// Provenance is the file chain that produced Config, in precedence
|
||||
// order.
|
||||
Provenance []ConfigOrigin
|
||||
// Reload is the most recent reload outcome, or nil when unavailable.
|
||||
Reload *config.ReloadStatus
|
||||
// Catalog is the usable-provider catalog the configuration owner loaded.
|
||||
@@ -319,60 +227,16 @@ type CatalogProviderView struct {
|
||||
// allowlist of fields.
|
||||
func BuildConfigView(in ConfigViewInput) ConfigView {
|
||||
cfg := in.Config
|
||||
provenance := append([]ConfigOrigin(nil), in.Provenance...)
|
||||
|
||||
view := ConfigView{
|
||||
Identity: IdentityView{
|
||||
BotUser: cfg.BotUser,
|
||||
BotEmail: cfg.BotEmail,
|
||||
Label: cfg.Label,
|
||||
ForgeType: cfg.Forge.Type,
|
||||
ForgeHost: cfg.Forge.Host,
|
||||
DiffCapLines: cfg.DiffCap(),
|
||||
},
|
||||
return ConfigView{
|
||||
Identity: IdentityView{BotUser: cfg.BotUser, ForgeType: cfg.Forge.Type, ForgeHost: cfg.Forge.Host},
|
||||
Repositories: reposView(cfg.Repos),
|
||||
MultiIdentity: len(cfg.Identities) > 0,
|
||||
Identities: identityForgesView(cfg.Identities),
|
||||
Models: cfg.Models,
|
||||
Providers: providersView(cfg.Providers),
|
||||
Budgets: BudgetsView{
|
||||
MaxSteps: cfg.Budgets.MaxSteps,
|
||||
WallClock: cfg.Budgets.WallClock.Std().String(),
|
||||
GateMaxFailures: cfg.Budgets.GateMaxFailures,
|
||||
},
|
||||
Review: ReviewView{
|
||||
PrecisionGate: cfg.Review.PrecisionGate,
|
||||
ApproveBeforePost: cfg.Review.ApproveBeforePost,
|
||||
},
|
||||
Storage: StorageView{
|
||||
WorkDir: cfg.WorkDir,
|
||||
StateDir: cfg.StateDir,
|
||||
SkillsDir: cfg.SkillsDir,
|
||||
},
|
||||
Containers: ContainersView{
|
||||
Image: cfg.Containers.Image,
|
||||
MaxConcurrency: cfg.Containers.MaxConcurrency,
|
||||
MaxUptime: cfg.Containers.MaxUptime.Std().String(),
|
||||
VolumeTTL: cfg.Containers.VolumeTTL.Std().String(),
|
||||
PullPolicy: cfg.Containers.PullPolicy,
|
||||
Network: cfg.Containers.Network,
|
||||
},
|
||||
Web: WebView{
|
||||
Listen: cfg.Web.Listen,
|
||||
TrustForwardedHeaders: cfg.Web.TrustForwardedHeaders,
|
||||
},
|
||||
Catalog: append([]CatalogProviderView{}, in.Catalog...),
|
||||
Chat: ChatView{
|
||||
ShowToolCalls: cfg.Chat.ShowToolCalls,
|
||||
Operator: strings.TrimSpace(cfg.Chat.Operator),
|
||||
ChannelConfigured: chatChannelConfigured(cfg.Chat),
|
||||
},
|
||||
Provenance: provenance,
|
||||
Reload: in.Reload,
|
||||
Review: ReviewView{PrecisionGate: cfg.Review.PrecisionGate, ApproveBeforePost: cfg.Review.ApproveBeforePost},
|
||||
Catalog: append([]CatalogProviderView{}, in.Catalog...),
|
||||
Chat: ChatView{ShowToolCalls: cfg.Chat.ShowToolCalls, Operator: strings.TrimSpace(cfg.Chat.Operator), ChannelConfigured: chatChannelConfigured(cfg.Chat)},
|
||||
Reload: in.Reload,
|
||||
}
|
||||
view.Schema = buildConfigSchema(view)
|
||||
view.Locked = lockedSchemaKeys(view.Schema)
|
||||
return view
|
||||
}
|
||||
|
||||
// chatChannelConfigured reports whether any chat front-end is configured.
|
||||
@@ -437,38 +301,10 @@ func RemoteConfigView(snapshots storecontract.ConfigSnapshotStore) ConfigViewSou
|
||||
}
|
||||
}
|
||||
|
||||
// lockedSchemaKeys returns the bootstrap-owned keys the schema exposes a row
|
||||
// for, with the reason shown in the UI. Keys the dashboard no longer renders,
|
||||
// such as the database URL, are omitted rather than advertised.
|
||||
func lockedSchemaKeys(sections []ConfigSection) map[string]string {
|
||||
out := make(map[string]string)
|
||||
for _, s := range sections {
|
||||
for _, f := range s.Fields {
|
||||
if reason, ok := configuration.DeniedKeys[f.Key]; ok {
|
||||
out[f.Key] = reason
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(out) == 0 {
|
||||
return nil
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func reposView(repos []config.Repo) []RepoView {
|
||||
out := make([]RepoView, 0, len(repos))
|
||||
func reposView(repos []config.Repo) []ForgeRepoView {
|
||||
out := make([]ForgeRepoView, 0, len(repos))
|
||||
for _, r := range repos {
|
||||
out = append(out, RepoView{
|
||||
Owner: r.Owner,
|
||||
Name: r.Name,
|
||||
Base: r.BaseBranch(),
|
||||
Gate: r.Gate,
|
||||
Protect: r.Protect,
|
||||
Ecosystem: r.Ecosystem,
|
||||
PersistentStorage: r.PersistentStorage,
|
||||
AllowConcurrent: r.AllowConcurrent,
|
||||
MaxRetries: r.MaxRetries,
|
||||
})
|
||||
out = append(out, ForgeRepoView{Owner: r.Owner, Name: r.Name})
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -491,16 +327,3 @@ func identityForgesView(identities []config.IdentityConfig) []ForgeIdentityView
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func providersView(providers map[string]config.Provider) map[string]ProviderView {
|
||||
out := make(map[string]ProviderView, len(providers))
|
||||
for name, p := range providers {
|
||||
out[name] = ProviderView{
|
||||
Class: p.Class,
|
||||
BaseURL: p.BaseURL,
|
||||
APIKeyEnv: p.APIKeyEnv,
|
||||
Configured: strings.TrimSpace(p.APIKeyEnv) != "" || strings.TrimSpace(p.APIKey.Key) != "",
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package webui
|
||||
|
||||
import "github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
|
||||
// ConfigFieldType is how the frontend's generic renderer decides what
|
||||
// control to show for a field. FieldStructured fields (repositories,
|
||||
// models, providers) opt out of the generic renderer entirely and keep
|
||||
// their dedicated editors.
|
||||
type ConfigFieldType string
|
||||
|
||||
const (
|
||||
FieldString ConfigFieldType = "string"
|
||||
FieldInt ConfigFieldType = "int"
|
||||
FieldBool ConfigFieldType = "bool"
|
||||
FieldDuration ConfigFieldType = "duration"
|
||||
FieldEnum ConfigFieldType = "enum"
|
||||
FieldStructured ConfigFieldType = "structured"
|
||||
)
|
||||
|
||||
// ConfigField is one field's rendering contract: what it is, what it means,
|
||||
// and what changing it would require. Value is attached by the caller
|
||||
// building the schema against a live ConfigView -- the
|
||||
// descriptor itself is data-independent.
|
||||
type ConfigField struct {
|
||||
// Key is the dotted path this field is addressed by.
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Type ConfigFieldType `json:"type"`
|
||||
Value any `json:"value,omitempty"`
|
||||
// LockedReason is set per instance from the running config's denied
|
||||
// keys (configuration.DeniedKeys), not hand-authored here.
|
||||
LockedReason string `json:"locked_reason,omitempty"`
|
||||
// Options lists the valid values for a FieldEnum field.
|
||||
Options []string `json:"options,omitempty"`
|
||||
// RestartRequired reports that a change takes effect only after a restart.
|
||||
// Kept in step with internal/app/archied/reload.go by hand.
|
||||
RestartRequired bool `json:"restart_required"`
|
||||
}
|
||||
|
||||
// ConfigSection groups fields the same way the settings page's cards
|
||||
// already do -- no new sections, this is metadata on existing rows.
|
||||
type ConfigSection struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Fields []ConfigField `json:"fields"`
|
||||
}
|
||||
|
||||
// configFieldDescriptors lists every ConfigView field with its section,
|
||||
// label, type and whether it needs a restart.
|
||||
func configFieldDescriptors() []ConfigSection {
|
||||
return []ConfigSection{
|
||||
{
|
||||
ID: "identity",
|
||||
Label: "Identity",
|
||||
Description: "Who Archie is on the forge, and how it addresses commits and comments.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "bot_user", Label: "Bot account", Type: FieldString},
|
||||
{Key: "bot_email", Label: "Commit author email", Type: FieldString},
|
||||
{Key: "label", Label: "Pickup label", Type: FieldString},
|
||||
{Key: "forge.type", Label: "Forge type", Type: FieldString, RestartRequired: true},
|
||||
{Key: "forge.host", Label: "Forge host", Type: FieldString},
|
||||
{Key: "diff_cap_lines", Label: "Max diff size (lines)", Description: "0 switches the cap off; leave unset for the default.", Type: FieldInt},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "repositories",
|
||||
Label: "Repositories",
|
||||
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
||||
Fields: []ConfigField{
|
||||
{
|
||||
Key: "repos",
|
||||
Label: "Repositories",
|
||||
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
||||
Type: FieldStructured,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "models",
|
||||
Label: "Models & providers",
|
||||
Description: "Which model handles each stage of work. Only the environment variable NAME is shown, never its value.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "models", Label: "Model roles", Type: FieldStructured},
|
||||
{Key: "providers", Label: "Providers", Type: FieldStructured},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "budgets",
|
||||
Label: "Budgets",
|
||||
Description: "The limits every autonomous stage runs under, so a stuck task cannot run forever.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "budgets.max_steps", Label: "Max steps", Description: "0 means unlimited.", Type: FieldInt},
|
||||
{Key: "budgets.wall_clock", Label: "Wall clock", Type: FieldDuration},
|
||||
{Key: "budgets.gate_max_failures", Label: "Max gate failures before parking", Description: "0 means unlimited.", Type: FieldInt},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "storage",
|
||||
Label: "Storage",
|
||||
Description: "Where archied keeps its state.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "work_dir", Label: "Work directory", Type: FieldString},
|
||||
{Key: "state_dir", Label: "State directory", Description: "Embedded NATS store, task logs and the readiness disk probe.", Type: FieldString},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "web",
|
||||
Label: "Dashboard",
|
||||
Description: "This dashboard's listen address.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "web.listen", Label: "Listen address", Description: `"off" disables the dashboard.`, Type: FieldString, RestartRequired: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// configFieldValues maps each descriptor key to its value in view.
|
||||
func configFieldValues(view ConfigView) map[string]any {
|
||||
return map[string]any{
|
||||
"bot_user": view.Identity.BotUser,
|
||||
"bot_email": view.Identity.BotEmail,
|
||||
"label": view.Identity.Label,
|
||||
"forge.type": view.Identity.ForgeType,
|
||||
"forge.host": view.Identity.ForgeHost,
|
||||
"diff_cap_lines": view.Identity.DiffCapLines,
|
||||
"repos": view.Repositories,
|
||||
"models": view.Models,
|
||||
"providers": view.Providers,
|
||||
"budgets.max_steps": view.Budgets.MaxSteps,
|
||||
"budgets.wall_clock": view.Budgets.WallClock,
|
||||
"budgets.gate_max_failures": view.Budgets.GateMaxFailures,
|
||||
"work_dir": view.Storage.WorkDir,
|
||||
"state_dir": view.Storage.StateDir,
|
||||
"web.listen": view.Web.Listen,
|
||||
}
|
||||
}
|
||||
|
||||
// buildConfigSchema attaches view's values and locked reasons to the
|
||||
// descriptor catalog.
|
||||
func buildConfigSchema(view ConfigView) []ConfigSection {
|
||||
values := configFieldValues(view)
|
||||
sections := configFieldDescriptors()
|
||||
for i := range sections {
|
||||
for j := range sections[i].Fields {
|
||||
f := §ions[i].Fields[j]
|
||||
f.Value = values[f.Key]
|
||||
f.LockedReason = configuration.DeniedKeys[f.Key]
|
||||
}
|
||||
}
|
||||
return sections
|
||||
}
|
||||
@@ -226,17 +226,6 @@ func (s *Server) trustForwardedHeaders() bool {
|
||||
return s.TrustForwardedHeaders
|
||||
}
|
||||
|
||||
// ConfigOrigin explains one source file contributing to the effective
|
||||
// configuration. Sources are ordered from lowest to highest precedence.
|
||||
type ConfigOrigin struct {
|
||||
Path string `json:"path"`
|
||||
Role string `json:"role"`
|
||||
Layer string `json:"layer"`
|
||||
Feature string `json:"feature,omitempty"`
|
||||
}
|
||||
|
||||
// SetProvenance publishes a fresh provenance list after a config reload.
|
||||
|
||||
// EventPublisher accepts events for the store and the live stream. The bus
|
||||
// in cmd/archied satisfies it.
|
||||
type EventPublisher interface {
|
||||
|
||||
@@ -1,46 +1,4 @@
|
||||
/**
|
||||
* What GET /api/config and the operator endpoints answer, as far as the six
|
||||
* System pages read them.
|
||||
*
|
||||
* Written by hand rather than generated: internal/webui/api_config.go's
|
||||
* ConfigView is an explicit allowlist whose whole purpose is to keep secrets
|
||||
* (forge tokens, provider API keys) out of this payload, so the type describes
|
||||
* what is served, not what config.Config holds.
|
||||
*/
|
||||
|
||||
/** How the generic renderer decides what control a field gets. A structured
|
||||
* field (repositories, models, providers) is owned by its own editor and
|
||||
* never appears in a generic row. */
|
||||
export type ConfigFieldType =
|
||||
"string" | "int" | "bool" | "duration" | "enum" | "structured";
|
||||
|
||||
export interface ConfigField {
|
||||
/** The dotted path this value lives at in the running config. */
|
||||
key: string;
|
||||
label: string;
|
||||
description?: string;
|
||||
type: ConfigFieldType;
|
||||
value?: unknown;
|
||||
locked_reason?: string;
|
||||
options?: string[];
|
||||
/** Changing it will not take effect until archied restarts. */
|
||||
restart_required?: boolean;
|
||||
}
|
||||
|
||||
export interface ConfigSection {
|
||||
id: string;
|
||||
label: string;
|
||||
description?: string;
|
||||
fields: ConfigField[];
|
||||
}
|
||||
|
||||
/** One file in the chain that produced the running configuration. */
|
||||
export interface ConfigOrigin {
|
||||
layer: string;
|
||||
role: string;
|
||||
feature?: string;
|
||||
path: string;
|
||||
}
|
||||
/** The read-only configuration summary served by /api/config. */
|
||||
|
||||
export interface ReloadStatus {
|
||||
last_error?: string;
|
||||
@@ -53,27 +11,6 @@ export interface ReviewView {
|
||||
approve_before_post: boolean;
|
||||
}
|
||||
|
||||
export interface RepoView {
|
||||
owner: string;
|
||||
name: string;
|
||||
base: string;
|
||||
gate: string[][];
|
||||
protect?: string[];
|
||||
ecosystem?: string;
|
||||
allow_concurrent: boolean;
|
||||
max_retries: number;
|
||||
}
|
||||
|
||||
/** A provider's shape, never its key: api_key_env is the NAME of an
|
||||
* environment variable, and configured says whether either credential form is
|
||||
* set without revealing which. */
|
||||
export interface ProviderView {
|
||||
class: string;
|
||||
base_url?: string;
|
||||
api_key_env?: string;
|
||||
configured: boolean;
|
||||
}
|
||||
|
||||
/** A provider the model catalog found usable, with its model ids. */
|
||||
export interface CatalogProvider {
|
||||
id: string;
|
||||
@@ -86,12 +23,6 @@ export interface CatalogProvider {
|
||||
|
||||
export interface ConfigView {
|
||||
catalog?: CatalogProvider[];
|
||||
repositories?: RepoView[];
|
||||
models?: Record<string, string>;
|
||||
providers?: Record<string, ProviderView>;
|
||||
review?: ReviewView;
|
||||
provenance?: ConfigOrigin[];
|
||||
reload?: ReloadStatus;
|
||||
schema?: ConfigSection[];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user