command

package
v0.260224.1130 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MPL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const StopTimeout = time.Second

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(appManager *AppManager) *cobra.Command

AddCommand represents the add provider command

func DeleteCommand

func DeleteCommand(appManager *AppManager) *cobra.Command

DeleteCommand represents the delete provider command

func ImportCommand

func ImportCommand(appManager *AppManager) *cobra.Command

ImportCommand represents the import rule command

func ListCommand

func ListCommand(appManager *AppManager) *cobra.Command

ListCommand represents the list providers command

func QuickstartCommand added in v0.260224.0

func QuickstartCommand(appManager *AppManager) *cobra.Command

QuickstartCommand creates the quickstart subcommand for guided setup

func RemoteCoderCommand added in v0.260224.0

func RemoteCoderCommand(appManager *AppManager) *cobra.Command

RemoteCoderCommand creates the `rc` subcommand for running remote-coder.

func RestartCommand

func RestartCommand(appManager *AppManager) *cobra.Command

RestartCommand represents the restart server command

func ShellCommand

func ShellCommand(appConfig *config.AppConfig) *cobra.Command

ShellCommand represents the interactive CLI command

func StartCommand

func StartCommand(appManager *AppManager) *cobra.Command

StartCommand represents the start server command

func StatusCommand

func StatusCommand(appManager *AppManager) *cobra.Command

StatusCommand represents the status command

func StopCommand

func StopCommand(appManager *AppManager) *cobra.Command

StopCommand represents the stop server command

func TokenCommand

func TokenCommand(appConfig *config.AppConfig) *cobra.Command

TokenCommand represents the generate token command

Types

type APIStyle

type APIStyle = protocol.APIStyle

type AppManager added in v0.260204.1200

type AppManager struct {
	// contains filtered or unexported fields
}

AppManager manages all application state and operations. It serves as the single source of truth for business logic that can be used by both CLI (cobra commands) and GUI (Wails services).

func NewAppManager added in v0.260204.1200

func NewAppManager(configDir string) (*AppManager, error)

NewAppManager creates a new AppManager with the given config directory.

func NewAppManagerWithConfig added in v0.260204.1200

func NewAppManagerWithConfig(appConfig *config.AppConfig) *AppManager

NewAppManagerWithConfig creates a new AppManager with an existing AppConfig.

func (*AppManager) AddProvider added in v0.260204.1200

func (am *AppManager) AddProvider(name, apiBase, token string, apiStyle protocol.APIStyle) error

AddProvider adds a new AI provider with the given configuration.

func (*AppManager) AddRule added in v0.260204.1200

func (am *AppManager) AddRule(rule typ.Rule) error

AddRule adds a new routing rule.

func (*AppManager) AppConfig added in v0.260204.1200

func (am *AppManager) AppConfig() *config.AppConfig

AppConfig returns the underlying AppConfig.

func (*AppManager) DeleteProvider added in v0.260204.1200

func (am *AppManager) DeleteProvider(name string) error

DeleteProvider removes an AI provider by name.

func (*AppManager) FetchAndSaveProviderModels added in v0.260224.0

func (am *AppManager) FetchAndSaveProviderModels(providerUUID string) error

FetchAndSaveProviderModels fetches models from a provider and saves them.

func (*AppManager) GetGlobalConfig added in v0.260224.0

func (am *AppManager) GetGlobalConfig() *serverconfig.Config

GetGlobalConfig returns the global configuration manager.

func (*AppManager) GetModelToken added in v0.260204.1200

func (am *AppManager) GetModelToken() string

GetModelToken returns the model API token.

func (*AppManager) GetProvider added in v0.260204.1200

func (am *AppManager) GetProvider(name string) (*typ.Provider, error)

GetProvider returns a provider by name, or nil if not found.

func (*AppManager) GetRuleByRequestModelAndScenario added in v0.260204.1200

func (am *AppManager) GetRuleByRequestModelAndScenario(requestModel string, scenario typ.RuleScenario) *typ.Rule

GetRuleByRequestModelAndScenario returns a rule by request model and scenario.

func (*AppManager) GetServerManager added in v0.260204.1200

func (am *AppManager) GetServerManager() *ServerManager

GetServerManager returns the server manager instance.

func (*AppManager) GetServerPort added in v0.260204.1200

func (am *AppManager) GetServerPort() int

GetServerPort returns the configured server port.

func (*AppManager) GetUserToken added in v0.260204.1200

func (am *AppManager) GetUserToken() string

GetUserToken returns the user authentication token.

func (*AppManager) HasModelToken added in v0.260204.1200

func (am *AppManager) HasModelToken() bool

HasModelToken returns true if a model token is configured.

func (*AppManager) ImportRuleFromJSONL added in v0.260204.1200

func (am *AppManager) ImportRuleFromJSONL(data string, opts ImportOptions) (*ImportResult, error)

ImportRuleFromJSONL imports a rule from JSONL format (either file content or stdin format). The data should be line-delimited JSON with: - Line 1: metadata (type="metadata") - Line 2: rule data (type="rule") - Subsequent lines: provider data (type="provider")

func (*AppManager) ListProviders added in v0.260204.1200

func (am *AppManager) ListProviders() []*typ.Provider

ListProviders returns all configured providers.

func (*AppManager) ListRules added in v0.260204.1200

func (am *AppManager) ListRules() []typ.Rule

ListRules returns all configured rules.

func (*AppManager) SaveConfig added in v0.260204.1200

func (am *AppManager) SaveConfig() error

SaveConfig saves the current configuration to disk.

func (*AppManager) SetServerPort added in v0.260204.1200

func (am *AppManager) SetServerPort(port int) error

SetServerPort sets the server port.

func (*AppManager) SetupServer added in v0.260204.1200

func (am *AppManager) SetupServer(port int, opts ...server.ServerOption) error

SetupServer initializes the server manager with the given port and options.

func (*AppManager) SetupServerWithPort added in v0.260224.0

func (am *AppManager) SetupServerWithPort(port int) error

SetupServerWithPort initializes the server manager with just a port (no options). This is a convenience method for the TUI wizard.

func (*AppManager) StartServer added in v0.260224.0

func (am *AppManager) StartServer() error

StartServer starts the server if it has been set up.

func (*AppManager) UpdateRule added in v0.260204.1200

func (am *AppManager) UpdateRule(uuid string, rule typ.Rule) error

UpdateRule updates an existing rule by UUID.

type BannerConfig

type BannerConfig struct {
	Port         int
	Host         string
	EnableUI     bool
	GlobalConfig *serverconfig.Config
	IsDaemon     bool
	HTTPEnabled  bool
}

BannerConfig holds configuration for banner display

type ExportLine

type ExportLine struct {
	Type string `json:"type"`
}

ExportLine represents a generic line in the export file

type ExportMetadata

type ExportMetadata struct {
	Type       string `json:"type"`
	Version    string `json:"version"`
	ExportedAt string `json:"exported_at"`
}

ExportMetadata represents the metadata line

type ExportProviderData

type ExportProviderData struct {
	Type        string           `json:"type"`
	UUID        string           `json:"uuid"`
	Name        string           `json:"name"`
	APIBase     string           `json:"api_base"`
	APIStyle    string           `json:"api_style"`
	AuthType    string           `json:"auth_type"`
	Token       string           `json:"token"`
	OAuthDetail *typ.OAuthDetail `json:"oauth_detail"`
	Enabled     bool             `json:"enabled"`
	ProxyURL    string           `json:"proxy_url"`
	Timeout     int64            `json:"timeout"`
	Tags        []string         `json:"tags"`
	Models      []string         `json:"models"`
}

ExportProviderData represents the provider export data

type ExportRuleData

type ExportRuleData struct {
	Type          string                 `json:"type"`
	UUID          string                 `json:"uuid"`
	Scenario      string                 `json:"scenario"`
	RequestModel  string                 `json:"request_model"`
	ResponseModel string                 `json:"response_model"`
	Description   string                 `json:"description"`
	Services      []*loadbalance.Service `json:"services"`
	LBTactic      typ.Tactic             `json:"lb_tactic"`
	Active        bool                   `json:"active"`
	SmartEnabled  bool                   `json:"smart_enabled"`
	SmartRouting  []interface{}          `json:"smart_routing"`
}

ExportRuleData represents the rule export data

type ImportOptions added in v0.260204.1200

type ImportOptions struct {
	// OnProviderConflict specifies what to do when a provider already exists.
	// "use" - use existing provider, "skip" - skip this provider, "suffix" - create with suffixed name
	OnProviderConflict string
	// OnRuleConflict specifies what to do when a rule already exists.
	// "skip" - skip import, "update" - update existing rule, "new" - create with new name
	OnRuleConflict string
	// Quiet suppresses progress output
	Quiet bool
}

ImportOptions controls how imports are handled when conflicts occur.

type ImportResult added in v0.260204.1200

type ImportResult struct {
	RuleCreated      bool
	RuleUpdated      bool
	ProvidersCreated int
	ProvidersUsed    int
	ProviderMap      map[string]string // old UUID -> new UUID
}

ImportResult contains the results of an import operation.

type ServerManager

type ServerManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ServerManager manages the HTTP server lifecycle

func NewServerManager

func NewServerManager(appConfig *config.AppConfig, opts ...server.ServerOption) *ServerManager

NewServerManager creates a new server manager. opts are server options passed directly to the underlying server.

func (*ServerManager) Cleanup

func (sm *ServerManager) Cleanup()

func (*ServerManager) GetGinEngine

func (sm *ServerManager) GetGinEngine() *gin.Engine

func (*ServerManager) IsRunning

func (sm *ServerManager) IsRunning() bool

IsRunning checks if the server is currently running

func (*ServerManager) ServeHTTP

func (sm *ServerManager) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ServerManager) Setup

func (sm *ServerManager) Setup(port int) error

Setup creates and configures the server without starting it

func (*ServerManager) Start

func (sm *ServerManager) Start() error

Start starts the server (requires Setup to be called first)

func (*ServerManager) Stop

func (sm *ServerManager) Stop() error

Stop stops the server gracefully

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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