tui

package
v6.8.21 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package tui provides a terminal-based management interface for CLIProxyAPI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentLocale

func CurrentLocale() string

CurrentLocale returns the active locale code.

func Run

func Run(port int, secretKey string, hook *LogHook, output io.Writer) error

Run starts the TUI application. output specifies where bubbletea renders. If nil, defaults to os.Stdout.

func SetLocale

func SetLocale(locale string)

SetLocale changes the active locale.

func T

func T(key string) string

T returns the translated string for the given key.

func TabNames

func TabNames() []string

TabNames returns tab names in the current locale.

func ToggleLocale

func ToggleLocale()

ToggleLocale switches between zh and en.

Types

type App

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

App is the root bubbletea model that contains all tab sub-models.

func NewApp

func NewApp(port int, secretKey string, hook *LogHook) App

NewApp creates the root TUI application model.

func (App) Init

func (a App) Init() tea.Cmd

func (App) Update

func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (App) View

func (a App) View() string

type Client

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

Client wraps HTTP calls to the management API.

func NewClient

func NewClient(port int, secretKey string) *Client

NewClient creates a new management API client.

func (*Client) AddAPIKey

func (c *Client) AddAPIKey(key string) error

AddAPIKey adds a new API key by sending old=nil, new=key which appends.

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(index int) error

DeleteAPIKey deletes an API key by index.

func (*Client) DeleteAuthFile

func (c *Client) DeleteAuthFile(name string) error

DeleteAuthFile deletes a single auth file by name.

func (*Client) DeleteField

func (c *Client) DeleteField(path string) error

DeleteField sends a DELETE request for a config field.

func (*Client) EditAPIKey

func (c *Client) EditAPIKey(index int, newValue string) error

EditAPIKey replaces an API key at the given index.

func (*Client) GetAPIKeys

func (c *Client) GetAPIKeys() ([]string, error)

GetAPIKeys fetches the list of API keys. API returns {"api-keys": [...]}.

func (*Client) GetAuthFiles

func (c *Client) GetAuthFiles() ([]map[string]any, error)

GetAuthFiles lists auth credential files. API returns {"files": [...]}.

func (*Client) GetAuthStatus

func (c *Client) GetAuthStatus(state string) (string, string, error)

GetAuthStatus polls the OAuth session status. Returns status ("wait", "ok", "error") and optional error message.

func (*Client) GetClaudeKeys

func (c *Client) GetClaudeKeys() ([]map[string]any, error)

GetClaudeKeys fetches Claude API keys.

func (*Client) GetCodexKeys

func (c *Client) GetCodexKeys() ([]map[string]any, error)

GetCodexKeys fetches Codex API keys.

func (*Client) GetConfig

func (c *Client) GetConfig() (map[string]any, error)

GetConfig fetches the parsed config.

func (*Client) GetConfigYAML

func (c *Client) GetConfigYAML() (string, error)

GetConfigYAML fetches the raw config.yaml content.

func (*Client) GetDebug

func (c *Client) GetDebug() (bool, error)

GetDebug fetches the current debug setting.

func (*Client) GetGeminiKeys

func (c *Client) GetGeminiKeys() ([]map[string]any, error)

GetGeminiKeys fetches Gemini API keys. API returns {"gemini-api-key": [...]}.

func (*Client) GetLogs

func (c *Client) GetLogs(after int64, limit int) ([]string, int64, error)

GetLogs fetches log lines from the server.

func (*Client) GetOpenAICompat

func (c *Client) GetOpenAICompat() ([]map[string]any, error)

GetOpenAICompat fetches OpenAI compatibility entries.

func (*Client) GetUsage

func (c *Client) GetUsage() (map[string]any, error)

GetUsage fetches usage statistics.

func (*Client) GetVertexKeys

func (c *Client) GetVertexKeys() ([]map[string]any, error)

GetVertexKeys fetches Vertex API keys.

func (*Client) PatchAuthFileFields

func (c *Client) PatchAuthFileFields(name string, fields map[string]any) error

PatchAuthFileFields updates editable fields on an auth file.

func (*Client) PutBoolField

func (c *Client) PutBoolField(path string, value bool) error

PutBoolField updates a boolean config field.

func (*Client) PutConfigYAML

func (c *Client) PutConfigYAML(yamlContent string) error

PutConfigYAML uploads new config.yaml content.

func (*Client) PutIntField

func (c *Client) PutIntField(path string, value int) error

PutIntField updates an integer config field.

func (*Client) PutStringField

func (c *Client) PutStringField(path string, value string) error

PutStringField updates a string config field.

func (*Client) SetSecretKey

func (c *Client) SetSecretKey(secretKey string)

SetSecretKey updates management API bearer token used by this client.

func (*Client) ToggleAuthFile

func (c *Client) ToggleAuthFile(name string, disabled bool) error

ToggleAuthFile enables or disables an auth file.

type LogHook

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

LogHook is a logrus hook that captures log entries and sends them to a channel.

func NewLogHook

func NewLogHook(bufSize int) *LogHook

NewLogHook creates a new LogHook with a buffered channel of the given size.

func (*LogHook) Chan

func (h *LogHook) Chan() <-chan string

Chan returns the channel to read log lines from.

func (*LogHook) Fire

func (h *LogHook) Fire(entry *log.Entry) error

Fire is called by logrus when a log entry is fired.

func (*LogHook) Levels

func (h *LogHook) Levels() []log.Level

Levels returns the log levels this hook should fire on.

func (*LogHook) SetFormatter

func (h *LogHook) SetFormatter(f log.Formatter)

SetFormatter sets a custom formatter for the hook.

Jump to

Keyboard shortcuts

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