Documentation
¶
Overview ¶
Package server provides the tern (arctic-tern) core facade. Users interact with tern through the Server type, which orchestrates all components (LLM Gateway, Config, Vault, Logger).
Index ¶
- type Option
- func WithAgentService(as *agentservice.Server) Option
- func WithConfig(cfg *config.AppConfig) Option
- func WithConfigPath(path string) Option
- func WithEnableVersion(versions ...int) Option
- func WithGateway(gw llmgateway.LLMGatewayBackend) Option
- func WithKeyringVault(tenantID ...string) Option
- func WithLogger(log logger.Logger) Option
- func WithVaultStore(vs vault.VaultStore) Option
- type Server
- func (s *Server) AgentService() *agentservice.Server
- func (s *Server) Gateway() llmgateway.LLMGatewayBackend
- func (s *Server) GatewayToken() string
- func (s *Server) Launch(ctx context.Context) error
- func (s *Server) ReloadModelProfiles(path string) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) TLSCACertPath() string
- func (s *Server) TaskLog() *tasklog.TaskLog
- func (s *Server) WebSocketURL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
Option configures a Server.
func WithAgentService ¶
func WithAgentService(as *agentservice.Server) Option
WithAgentService injects an externally constructed AgentService server. When set, New() uses this instead of building one internally.
func WithConfig ¶
WithConfig sets the configuration directly. config.Load() can be used to generate the struct, which is then passed here.
func WithConfigPath ¶
WithConfigPath sets the configuration file path. Internally calls config.Load(path) during New().
func WithEnableVersion ¶ added in v0.1.1
WithEnableVersion specifies which API versions to enable. Supported versions: 1. If not called, all supported versions are enabled by default. Returns an error from New() if an unsupported version is specified.
func WithGateway ¶
func WithGateway(gw llmgateway.LLMGatewayBackend) Option
WithGateway injects a custom LLMGatewayBackend implementation. Useful for testing or custom backend implementations.
func WithKeyringVault ¶
WithKeyringVault configures the server to use OS Keyring for secret storage. This replaces the default EnvVaultBackend with KeyringVaultBackend. tenantID scopes the keyring entries; if empty, "default" is used.
func WithLogger ¶
WithLogger injects a custom Logger implementation. When nil, a default logger is created based on Config.Log settings.
func WithVaultStore ¶
func WithVaultStore(vs vault.VaultStore) Option
WithVaultStore injects a custom VaultStore implementation. When nil, a default backend is created based on Config.Vault settings.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the tern core facade that orchestrates all components. Users interact with tern through this type.
func New ¶
New creates a new tern Server with the given options. No goroutines are started; no network listeners are opened.
Initialization order (per 000-Architecture R3-3):
- Apply all Options
- Resolve Config (WithConfigPath -> Load, WithConfig -> use, none -> default)
- Resolve Logger (WithLogger or default from Config.Log)
- Resolve VaultStore (WithVaultStore or default from Config.Vault)
- Resolve Gateway (WithGateway or NewProxyServer from Config)
func (*Server) AgentService ¶
func (s *Server) AgentService() *agentservice.Server
AgentService returns the AgentService Server instance.
func (*Server) Gateway ¶
func (s *Server) Gateway() llmgateway.LLMGatewayBackend
Gateway returns the LLM Gateway Proxy backend.
func (*Server) GatewayToken ¶
GatewayToken returns the internal gateway auth token.
func (*Server) Launch ¶
Launch starts all components. Non-blocking. Start order: Gateway -> WebSocket -> AgentService.
func (*Server) ReloadModelProfiles ¶
ReloadModelProfiles reloads the model profiles at runtime.
func (*Server) Shutdown ¶
Shutdown gracefully stops all components in reverse launch order. Stop order: AgentService -> WebSocket -> Gateway.
func (*Server) TLSCACertPath ¶
TLSCACertPath returns the CA certificate file path (for agent CLI). Empty if TLS is disabled.
func (*Server) TaskLog ¶
TaskLog returns the TaskLog instance. Callers can use TaskLog().Add() to inject log entries.
func (*Server) WebSocketURL ¶
WebSocketURL returns the WebSocket server URL. Returns empty string if the server has not been launched.