Documentation
¶
Index ¶
- Constants
- func AgentCommand(appManager *AppManager) *cobra.Command
- func CCCommand(appManager *AppManager) *cobra.Command
- func ClearLine()
- func DisplayQR(qrURL string) error
- func DisplaySpinnerASCII(step int) string
- func DisplayStatus(message string, showSpinner bool, step int)
- func ExportCommand(appManager *AppManager) *cobra.Command
- func ImportCommand(appManager *AppManager) *cobra.Command
- func MCPBuiltinCommand() *cobra.Command
- func OAuthCommand(appManager interface{}) interface{}
- func OpenCommand(appManager *AppManager) *cobra.Command
- func PrintError(message string)
- func PrintInfo(message string)
- func PrintSuccess(message string)
- func PrintWarning(message string)
- func ProviderCommand(appManager *AppManager) *cobra.Command
- func QuickstartCommand(appManager *AppManager) *cobra.Command
- func QuotaCommand(appManager *AppManager) *cobra.Command
- func RemoteCoderCommand(appManager *AppManager) *cobra.Command
- func RemoteCommand(appManager *AppManager) *cobra.Command
- func RestartCommand(appManager *AppManager) *cobra.Command
- func StartCommand(appManager *AppManager) *cobra.Command
- func StartCommandWithHook(appManager *AppManager, hooks ...func(*ServerManager) error) *cobra.Command
- func StatusCommand(appManager *AppManager) *cobra.Command
- func StopCommand(appManager *AppManager) *cobra.Command
- func SwaggerCommand(appManager *AppManager) *cobra.Command
- func TokenCommand(appConfig *config.AppConfig) *cobra.Command
- func TruncateString(s string, maxWidth int) string
- type APIStyle
- type AppManager
- func (am *AppManager) AddProvider(name, apiBase, token string, apiStyle protocol.APIStyle) error
- func (am *AppManager) AddRule(rule typ.Rule) error
- func (am *AppManager) AppConfig() *config.AppConfig
- func (am *AppManager) CollectProvidersFromRule(rule *typ.Rule) ([]*typ.Provider, error)
- func (am *AppManager) DeleteProvider(name string) error
- func (am *AppManager) DeleteProviderByUUID(uuid string) error
- func (am *AppManager) ExportRule(rule *typ.Rule, providers []*typ.Provider, format exportpkg.Format) (string, error)
- func (am *AppManager) FetchAndSaveProviderModels(providerUUID string) error
- func (am *AppManager) GetGlobalConfig() *serverconfig.Config
- func (am *AppManager) GetModelToken() string
- func (am *AppManager) GetProvider(uuid string) (*typ.Provider, error)
- func (am *AppManager) GetProviderByUUID(uuid string) (*typ.Provider, error)
- func (am *AppManager) GetRuleByRequestModelAndScenario(requestModel string, scenario typ.RuleScenario) *typ.Rule
- func (am *AppManager) GetServerManager() *ServerManager
- func (am *AppManager) GetServerPort() int
- func (am *AppManager) GetUserToken() string
- func (am *AppManager) HasModelToken() bool
- func (am *AppManager) ImportRule(data string, format exportpkg.Format, opts ImportOptions) (*ImportResult, error)
- func (am *AppManager) ImportRuleFromJSONL(data string, opts ImportOptions) (*ImportResult, error)deprecated
- func (am *AppManager) ListProviders() []*typ.Provider
- func (am *AppManager) ListRules() []typ.Rule
- func (am *AppManager) SaveConfig() error
- func (am *AppManager) SetServerPort(port int) error
- func (am *AppManager) SetupServer(port int, opts ...server.ServerOption) error
- func (am *AppManager) SetupServerWithPort(port int) error
- func (am *AppManager) StartServer() error
- func (am *AppManager) UpdateProviderByUUID(uuid string, provider *typ.Provider) error
- func (am *AppManager) UpdateRule(uuid string, rule typ.Rule) error
- type BannerConfig
- type ImportOptions
- type ImportResult
- type ProviderImportInfo
- type ProviderInfo
- type ProviderOAuthConfig
- type QRDisplay
- type ServerManager
- func (sm *ServerManager) Cleanup()
- func (sm *ServerManager) GetGinEngine() *gin.Engine
- func (sm *ServerManager) GetTBServer() *server.Server
- func (sm *ServerManager) IsRunning() bool
- func (sm *ServerManager) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (sm *ServerManager) Setup(port int) error
- func (sm *ServerManager) Start() error
- func (sm *ServerManager) Stop() error
Constants ¶
const StopTimeout = time.Second
Variables ¶
This section is empty.
Functions ¶
func AgentCommand ¶
func AgentCommand(appManager *AppManager) *cobra.Command
AgentCommand creates the agent management command
func CCCommand ¶
func CCCommand(appManager *AppManager) *cobra.Command
CCCommand creates the `cc` subcommand that configures and launches Claude Code.
func DisplayQR ¶
DisplayQR displays a QR code in the terminal It tries multiple methods and falls back to showing the URL
func DisplaySpinnerASCII ¶
DisplaySpinnerASCII returns a simple ASCII spinner
func DisplayStatus ¶
DisplayStatus displays a status message with optional spinner
func ExportCommand ¶
func ExportCommand(appManager *AppManager) *cobra.Command
ExportCommand represents the export rule command
func ImportCommand ¶
func ImportCommand(appManager *AppManager) *cobra.Command
ImportCommand represents the import rule command
func MCPBuiltinCommand ¶ added in v0.260418.2200
MCPBuiltinCommand creates the cobra command for the builtin MCP server.
func OAuthCommand ¶
func OAuthCommand(appManager interface{}) interface{}
OAuthCommand returns the oauth command group
func OpenCommand ¶
func OpenCommand(appManager *AppManager) *cobra.Command
OpenCommand represents the open web UI command
func ProviderCommand ¶
func ProviderCommand(appManager *AppManager) *cobra.Command
ProviderCommand represents the unified provider management command It provides both interactive mode (no args) and subcommands for specific operations
func QuickstartCommand ¶
func QuickstartCommand(appManager *AppManager) *cobra.Command
QuickstartCommand creates the quickstart subcommand for guided setup
func QuotaCommand ¶ added in v0.260402.2330
func QuotaCommand(appManager *AppManager) *cobra.Command
QuotaCommand represents the quota management command
func RemoteCoderCommand ¶
func RemoteCoderCommand(appManager *AppManager) *cobra.Command
RemoteCoderCommand is deprecated. Use RemoteCommand instead.
func RemoteCommand ¶
func RemoteCommand(appManager *AppManager) *cobra.Command
RemoteCommand creates the `remote` subcommand for bot management.
func RestartCommand ¶
func RestartCommand(appManager *AppManager) *cobra.Command
RestartCommand represents the restart server command
func StartCommand ¶
func StartCommand(appManager *AppManager) *cobra.Command
StartCommand represents the start server command
func StartCommandWithHook ¶
func StartCommandWithHook(appManager *AppManager, hooks ...func(*ServerManager) error) *cobra.Command
StartCommandWithHook represents the start server command with setup hooks that run after the server manager is created and before the server starts.
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 SwaggerCommand ¶ added in v0.260418.2200
func SwaggerCommand(appManager *AppManager) *cobra.Command
SwaggerCommand creates the swagger command
func TokenCommand ¶
TokenCommand represents the generate token command
func TruncateString ¶
TruncateString truncates a string to fit within max width
Types ¶
type AppManager ¶
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 CreateAppManagerForDir ¶
func CreateAppManagerForDir(configDir string) (*AppManager, error)
CreateAppManagerForDir creates a new AppManager for the specified config directory. This is used when a command specifies a different config directory than the global one.
func NewAppManager ¶
func NewAppManager(configDir string) (*AppManager, error)
NewAppManager creates a new AppManager with the given config directory.
func NewAppManagerWithConfig ¶
func NewAppManagerWithConfig(appConfig *config.AppConfig) *AppManager
NewAppManagerWithConfig creates a new AppManager with an existing AppConfig.
func (*AppManager) AddProvider ¶
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 ¶
func (am *AppManager) AddRule(rule typ.Rule) error
AddRule adds a new routing rule.
func (*AppManager) AppConfig ¶
func (am *AppManager) AppConfig() *config.AppConfig
AppConfig returns the underlying AppConfig.
func (*AppManager) CollectProvidersFromRule ¶
CollectProvidersFromRule collects all providers referenced by the rule's services. This is a helper function for gathering providers to export with a rule.
func (*AppManager) DeleteProvider ¶
func (am *AppManager) DeleteProvider(name string) error
DeleteProvider removes an AI provider by name.
func (*AppManager) DeleteProviderByUUID ¶
func (am *AppManager) DeleteProviderByUUID(uuid string) error
DeleteProviderByUUID removes an AI provider by UUID.
func (*AppManager) ExportRule ¶
func (am *AppManager) ExportRule(rule *typ.Rule, providers []*typ.Provider, format exportpkg.Format) (string, error)
ExportRule exports a rule with its providers, or providers only, in the specified format. At least one of rule or providers must be specified.
func (*AppManager) FetchAndSaveProviderModels ¶
func (am *AppManager) FetchAndSaveProviderModels(providerUUID string) error
FetchAndSaveProviderModels fetches models from a provider and saves them.
func (*AppManager) GetGlobalConfig ¶
func (am *AppManager) GetGlobalConfig() *serverconfig.Config
GetGlobalConfig returns the global configuration manager.
func (*AppManager) GetModelToken ¶
func (am *AppManager) GetModelToken() string
GetModelToken returns the model API token.
func (*AppManager) GetProvider ¶
func (am *AppManager) GetProvider(uuid string) (*typ.Provider, error)
GetProvider returns a provider by UUID, or nil if not found.
func (*AppManager) GetProviderByUUID ¶ added in v0.260402.2330
func (am *AppManager) GetProviderByUUID(uuid string) (*typ.Provider, error)
GetProviderByUUID returns a provider by UUID (implements quota.ProviderManager interface)
func (*AppManager) GetRuleByRequestModelAndScenario ¶
func (am *AppManager) GetRuleByRequestModelAndScenario(requestModel string, scenario typ.RuleScenario) *typ.Rule
GetRuleByRequestModelAndScenario returns a rule by request model and scenario.
func (*AppManager) GetServerManager ¶
func (am *AppManager) GetServerManager() *ServerManager
GetServerManager returns the server manager instance.
func (*AppManager) GetServerPort ¶
func (am *AppManager) GetServerPort() int
GetServerPort returns the configured server port.
func (*AppManager) GetUserToken ¶
func (am *AppManager) GetUserToken() string
GetUserToken returns the user authentication token.
func (*AppManager) HasModelToken ¶
func (am *AppManager) HasModelToken() bool
HasModelToken returns true if a model token is configured.
func (*AppManager) ImportRule ¶
func (am *AppManager) ImportRule(data string, format exportpkg.Format, opts ImportOptions) (*ImportResult, error)
ImportRule imports a rule from data in the specified format
func (*AppManager) ImportRuleFromJSONL
deprecated
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")
Deprecated: Use ImportRule with FormatAuto instead. This method is kept for backward compatibility.
func (*AppManager) ListProviders ¶
func (am *AppManager) ListProviders() []*typ.Provider
ListProviders returns all configured providers.
func (*AppManager) ListRules ¶
func (am *AppManager) ListRules() []typ.Rule
ListRules returns all configured rules.
func (*AppManager) SaveConfig ¶
func (am *AppManager) SaveConfig() error
SaveConfig saves the current configuration to disk.
func (*AppManager) SetServerPort ¶
func (am *AppManager) SetServerPort(port int) error
SetServerPort sets the server port.
func (*AppManager) SetupServer ¶
func (am *AppManager) SetupServer(port int, opts ...server.ServerOption) error
SetupServer initializes the server manager with the given port and options.
func (*AppManager) SetupServerWithPort ¶
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 ¶
func (am *AppManager) StartServer() error
StartServer starts the server if it has been set up.
func (*AppManager) UpdateProviderByUUID ¶
func (am *AppManager) UpdateProviderByUUID(uuid string, provider *typ.Provider) error
UpdateProviderByUUID updates an existing provider by UUID.
func (*AppManager) UpdateRule ¶
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
}
BannerConfig holds configuration for banner display
type ImportOptions ¶
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 ¶
type ImportResult struct {
RuleCreated bool
RuleUpdated bool
ProvidersCreated int
ProvidersUsed int
Providers []ProviderImportInfo
ProviderMap map[string]string // old UUID -> new UUID
}
ImportResult contains the results of an import operation.
type ProviderImportInfo ¶ added in v0.260414.2000
type ProviderImportInfo struct {
UUID string
Name string
Action string // "created", "used", "skipped"
}
ProviderImportInfo contains information about an imported or used provider
type ProviderInfo ¶
ProviderInfo holds information about an OAuth provider
type ProviderOAuthConfig ¶
type ProviderOAuthConfig struct {
Type string
DisplayName string
APIBase string
APIStyle string
OAuthMethod string // "pkce" or "device_code"
NeedsPort1455 bool
}
ProviderOAuthConfig holds OAuth configuration for a provider
type ServerManager ¶
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) GetTBServer ¶
func (sm *ServerManager) GetTBServer() *server.Server
GetTBServer returns the underlying TinglyBox server instance
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)