@@ -18,41 +18,42 @@ const (
1818 DefaultOIDCScopes = "openid offline_access"
1919)
2020
21- // LLMConfig holds all LLM gateway settings persisted under the llm: key in
21+ // Config holds all LLM gateway settings persisted under the llm: key in
2222// ToolHive's config.yaml.
23- type LLMConfig struct {
24- GatewayURL string `yaml:"gateway_url,omitempty"`
25- OIDC LLMOIDCConfig `yaml:"oidc,omitempty"`
26- Proxy LLMProxyConfig `yaml:"proxy,omitempty"`
27- Auth LLMAuthState `yaml:"auth,omitempty"`
28- ConfiguredTools []LLMToolConfig `yaml:"configured_tools,omitempty"`
23+ type Config struct {
24+ GatewayURL string `yaml:"gateway_url,omitempty"`
25+ OIDC OIDCConfig `yaml:"oidc,omitempty"`
26+ Proxy ProxyConfig `yaml:"proxy,omitempty"`
27+ ConfiguredTools []ToolConfig `yaml:"configured_tools,omitempty"`
2928}
3029
31- // LLMOIDCConfig holds OIDC provider settings for the LLM gateway.
32- type LLMOIDCConfig struct {
30+ // OIDCConfig holds OIDC provider settings and cached token state for the LLM
31+ // gateway. Cached fields follow the same pattern as RegistryOAuthConfig in
32+ // pkg/config/config.go — token values are never stored here, only references
33+ // and expiry metadata.
34+ type OIDCConfig struct {
3335 Issuer string `yaml:"issuer,omitempty"`
3436 ClientID string `yaml:"client_id,omitempty"`
3537 Scopes []string `yaml:"scopes,omitempty"`
3638 Audience string `yaml:"audience,omitempty"`
3739 CallbackPort int `yaml:"callback_port,omitempty"`
38- }
3940
40- // LLMProxyConfig holds configuration for the localhost reverse proxy.
41- type LLMProxyConfig struct {
42- ListenPort int `yaml:"listen_port,omitempty"`
41+ // CachedRefreshTokenRef is the secrets-provider key under which the refresh
42+ // token is stored (never the token value itself).
43+ CachedRefreshTokenRef string `yaml:"cached_refresh_token_ref,omitempty"`
44+ // CachedTokenExpiry is the expiry of the most recently cached access token,
45+ // used to surface helpful messages when the token is about to expire.
46+ CachedTokenExpiry time.Time `yaml:"cached_token_expiry,omitempty"`
4347}
4448
45- // LLMAuthState records token lifecycle metadata persisted to config (no token
46- // values — those live in the secrets provider or memory only).
47- type LLMAuthState struct {
48- // CachedTokenExpiry is the expiry time of the most recently cached access
49- // token. Used to surface helpful messages when the token is about to expire.
50- CachedTokenExpiry time.Time `yaml:"cached_token_expiry,omitempty"`
49+ // ProxyConfig holds configuration for the localhost reverse proxy.
50+ type ProxyConfig struct {
51+ ListenPort int `yaml:"listen_port,omitempty"`
5152}
5253
53- // LLMToolConfig records a tool that setup has configured, so teardown knows
54+ // ToolConfig records a tool that setup has configured, so teardown knows
5455// exactly what to reverse.
55- type LLMToolConfig struct {
56+ type ToolConfig struct {
5657 // Tool is the canonical tool identifier (e.g. "claude-code", "cursor").
5758 Tool string `yaml:"tool"`
5859 // Mode is the authentication mode: "direct" or "proxy".
@@ -63,13 +64,13 @@ type LLMToolConfig struct {
6364
6465// IsConfigured reports whether the minimum required fields are present for the
6566// LLM gateway to be usable: gateway URL, OIDC issuer, and OIDC client ID.
66- func (c * LLMConfig ) IsConfigured () bool {
67+ func (c * Config ) IsConfigured () bool {
6768 return c .GatewayURL != "" && c .OIDC .Issuer != "" && c .OIDC .ClientID != ""
6869}
6970
7071// Validate performs full validation of the LLM config, including HTTPS
7172// enforcement, port range checks, and OIDC field requirements.
72- func (c * LLMConfig ) Validate () error {
73+ func (c * Config ) Validate () error {
7374 var errs []error
7475
7576 if c .GatewayURL == "" {
@@ -99,7 +100,7 @@ func (c *LLMConfig) Validate() error {
99100
100101// EffectiveProxyPort returns the configured proxy listen port, or
101102// DefaultProxyListenPort if none is set.
102- func (c * LLMConfig ) EffectiveProxyPort () int {
103+ func (c * Config ) EffectiveProxyPort () int {
103104 if c .Proxy .ListenPort > 0 {
104105 return c .Proxy .ListenPort
105106 }
@@ -108,7 +109,7 @@ func (c *LLMConfig) EffectiveProxyPort() int {
108109
109110// EffectiveScopes returns the configured OIDC scopes, or the default scopes
110111// (openid, offline_access) if none are set.
111- func (c * LLMOIDCConfig ) EffectiveScopes () []string {
112+ func (c * OIDCConfig ) EffectiveScopes () []string {
112113 if len (c .Scopes ) > 0 {
113114 return c .Scopes
114115 }
0 commit comments