server

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

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

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

func WithConfig(cfg *config.AppConfig) Option

WithConfig sets the configuration directly. config.Load() can be used to generate the struct, which is then passed here.

func WithConfigPath

func WithConfigPath(path string) Option

WithConfigPath sets the configuration file path. Internally calls config.Load(path) during New().

func WithEnableVersion added in v0.1.1

func WithEnableVersion(versions ...int) Option

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

func WithKeyringVault(tenantID ...string) Option

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

func WithLogger(log logger.Logger) Option

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

func New(opts ...Option) (*Server, error)

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):

  1. Apply all Options
  2. Resolve Config (WithConfigPath -> Load, WithConfig -> use, none -> default)
  3. Resolve Logger (WithLogger or default from Config.Log)
  4. Resolve VaultStore (WithVaultStore or default from Config.Vault)
  5. 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

func (s *Server) GatewayToken() string

GatewayToken returns the internal gateway auth token.

func (*Server) Launch

func (s *Server) Launch(ctx context.Context) error

Launch starts all components. Non-blocking. Start order: Gateway -> WebSocket -> AgentService.

func (*Server) ReloadModelProfiles

func (s *Server) ReloadModelProfiles(path string) error

ReloadModelProfiles reloads the model profiles at runtime.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops all components in reverse launch order. Stop order: AgentService -> WebSocket -> Gateway.

func (*Server) TLSCACertPath

func (s *Server) TLSCACertPath() string

TLSCACertPath returns the CA certificate file path (for agent CLI). Empty if TLS is disabled.

func (*Server) TaskLog

func (s *Server) TaskLog() *tasklog.TaskLog

TaskLog returns the TaskLog instance. Callers can use TaskLog().Add() to inject log entries.

func (*Server) WebSocketURL

func (s *Server) WebSocketURL() string

WebSocketURL returns the WebSocket server URL. Returns empty string if the server has not been launched.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL