Documentation
¶
Overview ¶
Package tui provides a terminal-based management interface for CLIProxyAPI.
Index ¶
- Variables
- func CurrentLocale() string
- func Run(port int, secretKey string, hook *LogHook, output io.Writer) error
- func RunWithBaseURL(baseURL string, secretKey string, hook *LogHook, output io.Writer) error
- func SetLocale(locale string)
- func T(key string) string
- func TabNames() []string
- func ToggleLocale()
- type App
- type Client
- func (c *Client) AddAPIKey(key string) error
- func (c *Client) BaseURL() string
- func (c *Client) CancelAuthSession(state string) error
- func (c *Client) CheckManagementSupport() error
- func (c *Client) DeleteAPIKey(index int, expected ...string) error
- func (c *Client) DeleteAuthFile(name string) error
- func (c *Client) DeleteField(path string) error
- func (c *Client) EditAPIKey(index int, newValue string, expected ...string) error
- func (c *Client) GetAPIKeys() ([]string, error)
- func (c *Client) GetAuthFiles() ([]map[string]any, error)
- func (c *Client) GetAuthStatus(state string) (string, string, error)
- func (c *Client) GetClaudeKeys() ([]map[string]any, error)
- func (c *Client) GetCodexKeys() ([]map[string]any, error)
- func (c *Client) GetConfig() (map[string]any, error)
- func (c *Client) GetConfigYAML() (string, error)
- func (c *Client) GetDebug() (bool, error)
- func (c *Client) GetGeminiKeys() ([]map[string]any, error)
- func (c *Client) GetInteractionsKeys() ([]map[string]any, error)
- func (c *Client) GetLogs(after int64, limit int) ([]string, int64, error)
- func (c *Client) GetOpenAICompat() ([]map[string]any, error)
- func (c *Client) GetVertexKeys() ([]map[string]any, error)
- func (c *Client) GetXAIKeys() ([]map[string]any, error)
- func (c *Client) PatchAuthFileFields(name string, fields map[string]any) error
- func (c *Client) PutBoolField(path string, value bool) error
- func (c *Client) PutConfigYAML(yamlContent string) error
- func (c *Client) PutIntField(path string, value int) error
- func (c *Client) PutStringField(path string, value string) error
- func (c *Client) RefreshAllAuthFiles() error
- func (c *Client) RefreshAuthFile(name string) error
- func (c *Client) SetSecretKey(secretKey string)
- func (c *Client) StartOAuthFlow(legacyAPIPath string) (map[string]any, error)
- func (c *Client) SubmitOAuthCallback(providerKey, redirectURL, state string) error
- func (c *Client) ToggleAuthFile(name string, disabled bool) error
- type LogHook
Constants ¶
This section is empty.
Variables ¶
var ErrManagementUnsupported = fmt.Errorf("management API not supported by target server")
ErrManagementUnsupported is returned by CheckManagementSupport when neither the v8 nor the v0 management contract is reachable on the target server.
Functions ¶
func Run ¶
Run starts the TUI application targeting localhost on the given port. output specifies where bubbletea renders. If nil, defaults to os.Stdout.
func RunWithBaseURL ¶
RunWithBaseURL starts the TUI application targeting the specified management base URL. output specifies where bubbletea renders. If nil, defaults to os.Stdout.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the root bubbletea model that contains all tab sub-models.
func NewAppWithBaseURL ¶
NewAppWithBaseURL creates the root TUI application model targeting the specified management base URL.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps HTTP calls to the management API.
The client prefers the v8 management contract and falls back to the deprecated /v0/management routes only when the v8 route is not implemented (404/405/501) by the target server. Configuration reads normalize the v8 tree-shaped document into the flat key set the TUI presents, so the tab models keep working on either contract.
func NewClient ¶
NewClient creates a new management API client targeting localhost on the given port.
func NewClientWithBaseURL ¶
NewClientWithBaseURL creates a new management API client targeting the specified base URL.
func (*Client) AddAPIKey ¶
AddAPIKey adds a new API key. On v8 it appends to access.api-keys; on v0 it falls back to the legacy patch contract.
func (*Client) CancelAuthSession ¶
CancelAuthSession cancels a pending OAuth session on the management server.
func (*Client) CheckManagementSupport ¶ added in v8.0.68
CheckManagementSupport reports whether the target exposes a usable management API on either contract. It is definitive only when a contract is actually served or clearly absent; a transient failure on one contract does not get reported as "unsupported" while the other is merely unreachable.
func (*Client) DeleteAPIKey ¶
DeleteAPIKey deletes an API key by index. expected optionally binds the key value shown to the user, so a concurrent reorder/delete is refused rather than removing the wrong entry.
func (*Client) DeleteAuthFile ¶
DeleteAuthFile deletes a single auth file by name.
func (*Client) DeleteField ¶
DeleteField sends a DELETE request for a config field, preferring v8.
func (*Client) EditAPIKey ¶
EditAPIKey replaces an API key at the given index. expected is the key value the caller displayed when the user chose this index; if the server list no longer has that value at this position the write is refused instead of silently editing a shifted entry.
func (*Client) GetAPIKeys ¶
GetAPIKeys fetches the list of API keys. API returns {"api-keys": [...]} on v0; the v8 equivalent is the bare array at /v8/management/config/access/api-keys.
func (*Client) GetAuthFiles ¶
GetAuthFiles lists auth credential files. API returns {"files": [...]}.
func (*Client) GetAuthStatus ¶
GetAuthStatus polls the OAuth session status. Returns status ("wait", "ok", "error") and optional error message.
func (*Client) GetClaudeKeys ¶
GetClaudeKeys fetches Claude API keys. API returns {"claude-api-key": [...]}.
func (*Client) GetCodexKeys ¶
GetCodexKeys fetches Codex API keys. API returns {"codex-api-key": [...]}.
func (*Client) GetConfig ¶
GetConfig fetches the parsed config. It prefers the v8 document, normalized to the flat shape the TUI presents, and falls back to the legacy v0 config.
func (*Client) GetConfigYAML ¶
GetConfigYAML fetches the raw config.yaml content.
func (*Client) GetGeminiKeys ¶
GetGeminiKeys fetches Gemini API keys. API returns {"gemini-api-key": [...]}.
func (*Client) GetInteractionsKeys ¶
GetInteractionsKeys fetches native Interactions API keys. API returns {"interactions-api-key": [...]}.
func (*Client) GetOpenAICompat ¶
GetOpenAICompat fetches OpenAI compatibility entries. API returns {"openai-compatibility": [...]}.
func (*Client) GetVertexKeys ¶
GetVertexKeys fetches Vertex API keys. API returns {"vertex-api-key": [...]}.
func (*Client) GetXAIKeys ¶
GetXAIKeys fetches xAI API keys. API returns {"xai-api-key": [...]}.
func (*Client) PatchAuthFileFields ¶
PatchAuthFileFields updates editable fields on an auth file.
func (*Client) PutBoolField ¶
PutBoolField updates a boolean config field.
func (*Client) PutConfigYAML ¶
PutConfigYAML uploads new config.yaml content, preferring the v8 endpoint.
func (*Client) PutIntField ¶
PutIntField updates an integer config field.
func (*Client) PutStringField ¶
PutStringField updates a string config field.
func (*Client) RefreshAllAuthFiles ¶
RefreshAllAuthFiles triggers a forced refresh of all auth credentials.
func (*Client) RefreshAuthFile ¶
RefreshAuthFile triggers a forced refresh of a single auth credential.
func (*Client) SetSecretKey ¶
SetSecretKey updates management API bearer token used by this client.
func (*Client) StartOAuthFlow ¶ added in v8.0.68
StartOAuthFlow begins an OAuth login for the given provider. It prefers the shared v8 endpoint and falls back to the provider-specific v0 route. legacyAPIPath is the v0 path segment (e.g. "codex-auth-url").
func (*Client) SubmitOAuthCallback ¶ added in v8.0.68
SubmitOAuthCallback posts a callback URL to the management server, preferring the v8 callback endpoint.
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 ¶
NewLogHook creates a new LogHook with a buffered channel of the given size.
func (*LogHook) SetFormatter ¶
SetFormatter sets a custom formatter for the hook.