command

package
v0.260806.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MPL-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const StopTimeout = time.Second

Variables

View Source
var (
	BuildVersion   = "dev"
	BuildGitCommit = "unknown"
	BuildBuildTime = "unknown"
	BuildGoVersion = "unknown"
	BuildPlatform  = "unknown"
)

Build information set by cli/tingly-box/main_kong.go at startup.

Functions

func ClearLine

func ClearLine()

ClearLine clears the current line in terminal

func DisplayQR

func DisplayQR(qrURL string) error

DisplayQR displays a QR code in the terminal It tries multiple methods and falls back to showing the URL

func DisplaySpinnerASCII

func DisplaySpinnerASCII(step int) string

DisplaySpinnerASCII returns a simple ASCII spinner

func DisplayStatus

func DisplayStatus(message string, showSpinner bool, step int)

DisplayStatus displays a status message with optional spinner

func PrintCCPassthroughHelp added in v0.260625.1

func PrintCCPassthroughHelp(cmdName string)

PrintCCPassthroughHelp prints shared help about passing arguments to Claude Code via the '--' separator. Used by both the cc and profile commands.

cmdName is "cc" or "profile" — drives command-specific examples and hints.

func PrintError

func PrintError(message string)

PrintError prints an error message

func PrintInfo

func PrintInfo(message string)

PrintInfo prints an info message

func PrintSuccess

func PrintSuccess(message string)

PrintSuccess prints a success message

func PrintWarning

func PrintWarning(message string)

PrintWarning prints a warning message

func RemotePairEnable added in v0.260507.1

func RemotePairEnable(appManager *AppManager, botUUID string, enable bool) error

RemotePairEnable enables or disables RequirePairing for a bot. Takes effect at next bot start.

func RemotePairRevoke added in v0.260507.1

func RemotePairRevoke(appManager *AppManager, botUUID, chatID string) error

RemotePairRevoke forgets the pairing for a specific chat. The chat will need to re-bind to issue commands.

func RemotePairStatus added in v0.260507.1

func RemotePairStatus(appManager *AppManager, botUUID string) error

RemotePairStatus shows whether RequirePairing is on and where to find the code.

func TruncateString

func TruncateString(s string, maxWidth int) string

TruncateString truncates a string to fit within max width

Types

type APIStyle

type APIStyle = protocol.APIStyle

APIStyle is re-exported from internal/protocol for the CLI prompts.

type AgentApplyFlagCmdKong added in v0.260507.1

type AgentApplyFlagCmdKong struct {
	AgentType  string `kong:"arg,optional,help='Agent type (cc/claude-code, oc/opencode, cx/codex)'"`
	Provider   string `kong:"flag,name='provider',help='Provider UUID (optional, uses routing rule if not specified)'"`
	Model      string `kong:"flag,name='model',help='Model name (optional, uses routing rule if not specified)'"`
	Unified    bool   `kong:"flag,name='unified',default='true',help='Unified mode (claude-code only)'"`
	StatusLine bool   `kong:"flag,name='status-line',help='Install status line integration (claude-code only)'"`
	Force      bool   `kong:"flag,name='force',help='Skip confirmation'"`
	Preview    bool   `kong:"flag,name='preview',help='Preview without applying'"`
}

AgentApplyFlagCmdKong applies agent configuration via flags

func (*AgentApplyFlagCmdKong) Run added in v0.260507.1

func (a *AgentApplyFlagCmdKong) Run(appManager *AppManager) error

type AgentCmdKong added in v0.260507.1

type AgentCmdKong struct {
	// Flag-based operations (primary interface)
	List    AgentListFlagCmdKong    `kong:"cmd,name='list',default='1',hidden,help='List configured agents (default)'"`
	Apply   AgentApplyFlagCmdKong   `kong:"cmd,help='Apply agent configuration'"`
	Show    AgentShowFlagCmdKong    `kong:"cmd,help='Show agent configuration details'"`
	Restore AgentRestoreFlagCmdKong `kong:"cmd,help='Restore agent configuration from backup'"`
}

AgentCmdKong is the Kong version of agent command with flag-based operations. The default behavior (no subcommand) is to list agents.

type AgentListFlagCmdKong added in v0.260507.1

type AgentListFlagCmdKong struct{}

AgentListFlagCmdKong lists configured agents (default behavior)

func (*AgentListFlagCmdKong) Run added in v0.260507.1

func (a *AgentListFlagCmdKong) Run(appManager *AppManager) error

type AgentRestoreFlagCmdKong added in v0.260507.1

type AgentRestoreFlagCmdKong struct {
	AgentType string `kong:"arg,optional,help='Agent type to restore'"`
	Force     bool   `kong:"flag,name='force',help='Skip confirmation prompt'"`
}

AgentRestoreFlagCmdKong restores agent configuration from backup

func (*AgentRestoreFlagCmdKong) Run added in v0.260507.1

func (a *AgentRestoreFlagCmdKong) Run(appManager *AppManager) error

type AgentShowFlagCmdKong added in v0.260507.1

type AgentShowFlagCmdKong struct {
	AgentType string `kong:"arg,optional,help='Agent type to show'"`
}

AgentShowFlagCmdKong shows agent configuration details via flags

func (*AgentShowFlagCmdKong) Run added in v0.260507.1

func (a *AgentShowFlagCmdKong) Run(appManager *AppManager) error

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) (string, error)

AddProvider adds a new AI provider with the given configuration. Note: Provider name is not used as a unique identifier - multiple providers can have the same name. The system automatically generates a unique UUID for each. Returns the UUID of the newly created provider.

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

func (am *AppManager) CollectProvidersFromRule(rule *typ.Rule) ([]*typ.Provider, error)

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) DeleteRule added in v0.260531.1

func (am *AppManager) DeleteRule(uuid string) error

DeleteRule removes a rule by UUID.

func (*AppManager) ExportRule

func (am *AppManager) ExportRule(rule *typ.Rule, providers []*typ.Provider, format exportpkg.Format) (string, error)

ExportRule exports the providers referenced by a rule (or an explicit provider list) in the specified format. dataio export/import is provider-only; the rule itself is only used here, by the caller, to pick which providers to include — it is not part of the exported payload.

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) GetProviderByName added in v0.260507.1

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

GetProviderByName returns a provider by name, 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) GetRuleByUUID added in v0.260531.1

func (am *AppManager) GetRuleByUUID(uuid string) *typ.Rule

GetRuleByUUID returns the rule for the given UUID, or nil if not found.

func (*AppManager) GetRuntimeServerPort added in v0.260716.1

func (am *AppManager) GetRuntimeServerPort() int

GetRuntimeServerPort returns the port the running server is actually listening on. The server port is intentionally not persisted in the config file, so a server started with --port would be invisible to other CLI processes; the server therefore records its port in a runtime port file next to the PID lock. When the server is running (lock held) and the port file is readable, that port wins; otherwise this falls back to the configured port.

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 providers from data in the specified format. Despite the name (kept for call-site compatibility), only providers are imported — dataio export/import no longer carries rule data.

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 CCmdKong added in v0.260507.1

type CCmdKong struct {
	Profile string   `kong:"flag,name='profile',help='Claude Code profile to use'"`
	Port    int      `kong:"flag,name='port',help='Tingly-Box server port (default: detected from running server, else config or 12580)'"`
	Args    []string `kong:"arg,optional,passthrough='all',help='Additional arguments to pass to Claude Code (e.g., --model opus)'"`
}

CCmdKong launches Claude Code with tingly-box-specific flags. Put tingly-box flags before Claude Code args; unknown flags are passed through to Claude Code so users do not need to insert a literal '--'.

func (*CCmdKong) Run added in v0.260507.1

func (c *CCmdKong) Run(appManager *AppManager) error

type ConfigCmdKong added in v0.260507.1

type ConfigCmdKong struct {
	// Interactive mode (default when no subcommand is given)
	Interactive ConfigInteractiveCmdKong `kong:"cmd,name='interactive',default='1',hidden,help='Interactive configuration management'"`

	Provider ConfigProviderCmdKong `kong:"cmd,help='Manage providers (add/list/update/delete/get)'"`
	Rule     ConfigRuleCmdKong     `kong:"cmd,help='Manage routing rules (add/list/update/delete/export/import)'"`
}

ConfigCmdKong is the unified configuration management command. Two second-level groups are exposed:

config provider — provider CRUD
config rule     — rule CRUD + import/export

Finer-grained operations live under those groups and only appear in `config provider --help` / `config rule --help` (not in `config --help`).

type ConfigInteractiveCmdKong added in v0.260507.1

type ConfigInteractiveCmdKong struct{}

ConfigInteractiveCmdKong runs the interactive config menu.

func (*ConfigInteractiveCmdKong) Run added in v0.260507.1

func (c *ConfigInteractiveCmdKong) Run(appManager *AppManager) error

type ConfigProviderAddCmdKong added in v0.260531.1

type ConfigProviderAddCmdKong struct {
	Name     string `kong:"arg,optional,help='Provider name'"`
	BaseURL  string `kong:"arg,optional,help='API base URL'"`
	Token    string `kong:"arg,optional,help='API token'"`
	APIStyle string `kong:"arg,optional,help='API style (openai, anthropic)'"`
}

ConfigProviderAddCmdKong adds a new provider.

func (*ConfigProviderAddCmdKong) Run added in v0.260531.1

func (c *ConfigProviderAddCmdKong) Run(appManager *AppManager) error

type ConfigProviderCmdKong added in v0.260531.1

type ConfigProviderCmdKong struct {
	Interactive ConfigProviderInteractiveCmdKong `kong:"cmd,name='interactive',default='1',hidden,help='Interactive provider management'"`

	Add    ConfigProviderAddCmdKong    `kong:"cmd,help='Add a new provider'"`
	List   ConfigProviderListCmdKong   `kong:"cmd,help='List all providers'"`
	Delete ConfigProviderDeleteCmdKong `kong:"cmd,help='Delete a provider (interactive)'"`
	Update ConfigProviderUpdateCmdKong `kong:"cmd,help='Update a provider (interactive)'"`
	Get    ConfigProviderGetCmdKong    `kong:"cmd,help='Get provider details by UUID'"`
}

ConfigProviderCmdKong groups provider operations under `config provider`. The default (no subcommand) drops into the provider sub-menu so it mirrors the interactive top-level config menu.

type ConfigProviderDeleteCmdKong added in v0.260531.1

type ConfigProviderDeleteCmdKong struct{}

ConfigProviderDeleteCmdKong deletes a provider via interactive selection.

func (*ConfigProviderDeleteCmdKong) Run added in v0.260531.1

func (c *ConfigProviderDeleteCmdKong) Run(appManager *AppManager) error

type ConfigProviderGetCmdKong added in v0.260531.1

type ConfigProviderGetCmdKong struct {
	UUID string `kong:"arg,optional,help='Provider UUID'"`
}

ConfigProviderGetCmdKong displays a provider's details by UUID. Names are not unique (UUID is the PK), so we require UUID. Empty UUID drops to interactive selection.

func (*ConfigProviderGetCmdKong) Run added in v0.260531.1

func (c *ConfigProviderGetCmdKong) Run(appManager *AppManager) error

type ConfigProviderInteractiveCmdKong added in v0.260531.1

type ConfigProviderInteractiveCmdKong struct{}

ConfigProviderInteractiveCmdKong runs the provider interactive sub-menu.

func (*ConfigProviderInteractiveCmdKong) Run added in v0.260531.1

type ConfigProviderListCmdKong added in v0.260531.1

type ConfigProviderListCmdKong struct{}

ConfigProviderListCmdKong lists all providers.

func (*ConfigProviderListCmdKong) Run added in v0.260531.1

func (c *ConfigProviderListCmdKong) Run(appManager *AppManager) error

type ConfigProviderUpdateCmdKong added in v0.260531.1

type ConfigProviderUpdateCmdKong struct{}

ConfigProviderUpdateCmdKong updates a provider via interactive selection.

func (*ConfigProviderUpdateCmdKong) Run added in v0.260531.1

func (c *ConfigProviderUpdateCmdKong) Run(appManager *AppManager) error

type ConfigRuleAddCmdKong added in v0.260531.1

type ConfigRuleAddCmdKong struct {
	Scenario     string `kong:"flag,name='scenario',help='Rule scenario (e.g. openai, anthropic, claude_code)'"`
	RequestModel string `kong:"flag,name='request-model',help='Request model (e.g. gpt-4o, tingly/cc)'"`
	Provider     string `kong:"flag,name='provider',help='Provider UUID or name'"`
	Model        string `kong:"flag,name='model',help='Model name on the provider'"`
}

ConfigRuleAddCmdKong adds a rule. The flag form is the CI path: provide all four flags and it runs non-interactively. With no flags it drops into the bufio prompts (kept as a thin shim — for richer interactive use, prefer `tingly-box tui rule`).

func (*ConfigRuleAddCmdKong) Run added in v0.260531.1

func (c *ConfigRuleAddCmdKong) Run(appManager *AppManager) error

type ConfigRuleCmdKong added in v0.260531.1

type ConfigRuleCmdKong struct {
	Interactive ConfigRuleInteractiveCmdKong `kong:"cmd,name='interactive',default='1',hidden,help='Interactive rule management'"`

	Add    ConfigRuleAddCmdKong    `kong:"cmd,help='Add a rule (CI: pass all four flags for non-interactive mode)'"`
	List   ConfigRuleListCmdKong   `kong:"cmd,help='List all rules'"`
	Update ConfigRuleUpdateCmdKong `kong:"cmd,help='Update the service on an existing rule'"`
	Delete ConfigRuleDeleteCmdKong `kong:"cmd,help='Delete a rule'"`
	Export ConfigRuleExportCmdKong `kong:"cmd,help='Export a rule with its providers'"`
	Import ConfigRuleImportCmdKong `kong:"cmd,help='Import a rule with its providers'"`
}

ConfigRuleCmdKong groups rule operations under `config rule`. Rule operations are deliberately simpler than provider operations: add/update only let the operator pick a single service (one provider + model); for richer multi-service rules use `config rule import` or the web UI.

type ConfigRuleDeleteCmdKong added in v0.260531.1

type ConfigRuleDeleteCmdKong struct {
	UUID string `kong:"arg,optional,help='Rule UUID'"`
}

ConfigRuleDeleteCmdKong deletes a rule by UUID, with interactive fallback.

func (*ConfigRuleDeleteCmdKong) Run added in v0.260531.1

func (c *ConfigRuleDeleteCmdKong) Run(appManager *AppManager) error

type ConfigRuleExportCmdKong added in v0.260531.1

type ConfigRuleExportCmdKong struct {
	UUID   string `kong:"arg,optional,help='Rule UUID'"`
	Format string `kong:"flag,name='format',default='jsonl',help='Export format: jsonl or base64'"`
	Output string `kong:"flag,name='output',help='Output file path (default: stdout)'"`
}

ConfigRuleExportCmdKong exports a rule (with its referenced providers). Without UUID it drops into interactive selection. Format/output stay as flags so scripts can pipe deterministically.

func (*ConfigRuleExportCmdKong) Run added in v0.260531.1

func (c *ConfigRuleExportCmdKong) Run(appManager *AppManager) error

type ConfigRuleImportCmdKong added in v0.260531.1

type ConfigRuleImportCmdKong struct {
	File   string `kong:"arg,optional,help='Import file path (reads from stdin if omitted)'"`
	Format string `kong:"flag,name='format',default='auto',help='Import format: auto, jsonl, or base64'"`
}

ConfigRuleImportCmdKong imports a rule (with its providers) from a bundle.

func (*ConfigRuleImportCmdKong) Run added in v0.260531.1

func (c *ConfigRuleImportCmdKong) Run(appManager *AppManager) error

type ConfigRuleInteractiveCmdKong added in v0.260531.1

type ConfigRuleInteractiveCmdKong struct{}

ConfigRuleInteractiveCmdKong runs the rule interactive sub-menu.

func (*ConfigRuleInteractiveCmdKong) Run added in v0.260531.1

func (c *ConfigRuleInteractiveCmdKong) Run(appManager *AppManager) error

type ConfigRuleListCmdKong added in v0.260531.1

type ConfigRuleListCmdKong struct{}

ConfigRuleListCmdKong lists all rules.

func (*ConfigRuleListCmdKong) Run added in v0.260531.1

func (c *ConfigRuleListCmdKong) Run(appManager *AppManager) error

type ConfigRuleUpdateCmdKong added in v0.260531.1

type ConfigRuleUpdateCmdKong struct {
	UUID string `kong:"arg,optional,help='Rule UUID'"`
}

ConfigRuleUpdateCmdKong updates a rule's service. Without UUID it drops into interactive selection. Only the service is re-picked; request-model and scenario remain unchanged.

func (*ConfigRuleUpdateCmdKong) Run added in v0.260531.1

func (c *ConfigRuleUpdateCmdKong) Run(appManager *AppManager) error

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
	// Quiet suppresses progress output
	Quiet bool
}

ImportOptions controls how imports are handled when conflicts occur.

type ImportResult

type ImportResult struct {
	ProvidersCreated int
	ProvidersUsed    int
	Providers        []ProviderImportInfo
	ProviderMap      map[string]string // old UUID -> new UUID
}

ImportResult contains the results of an import operation.

type LaunchSource added in v0.260801.1

type LaunchSource string

LaunchSource is how the running tingly-box process was invoked (binary, npx, npx-bundle) — see internal/shortcut for the source constants. It comes from the global --source flag and is bound into Kong's Run() calls, so any subcommand that needs it (shortcut, start, restart) can read it directly without persisting it anywhere.

type LogCmdKong added in v0.260514.1

type LogCmdKong struct {
	Once     bool          `kong:"flag,name='once',help='Fetch logs once and exit (default is real-time follow)'"`
	Limit    int           `kong:"flag,name='limit',short='n',default='50',help='Number of recent log entries per fetch (max 1000)'"`
	Interval time.Duration `kong:"flag,name='interval',short='i',default='2s',help='Poll interval for real-time follow mode'"`
	Level    string        `kong:"flag,name='level',help='Filter by minimum log level (debug|info|warn|error)'"`
	Host     string        `kong:"flag,name='host',default='localhost',help='Server host'"`
	Port     int           `kong:"flag,name='port',short='p',help='Server port (defaults to configured port)'"`
}

LogCmdKong streams or fetches system logs from the running tingly-box server via its HTTP API (/api/v1/system/logs). Default mode is real-time follow.

func (*LogCmdKong) Run added in v0.260514.1

func (l *LogCmdKong) Run(appManager *AppManager) error

type MCPBuiltinCmdKong added in v0.260507.1

type MCPBuiltinCmdKong struct{}

MCPBuiltinCmdKong starts the builtin MCP server. Registered at the top level as "mcp-builtin" to match the legacy command path, which is consumed by internal/mcp/runtime/builtin_registry.go.

func (*MCPBuiltinCmdKong) Run added in v0.260507.1

func (m *MCPBuiltinCmdKong) Run(appManager *AppManager) error

type OAuthCmdKong added in v0.260507.1

type OAuthCmdKong struct {
	// Positional argument (optional)
	Provider string `kong:"arg,optional,help='Provider type (e.g., claude_code, qwen_code, codex)'"`

	// Flags
	Name     string `kong:"flag,name='name',short='n',help='Custom name for the provider'"`
	Port     int    `kong:"flag,name='port',short='p',help='Callback server port'"`
	ProxyURL string `kong:"flag,name='proxy',short='x',help='Proxy URL for OAuth requests'"`
}

OAuthCmdKong handles OAuth authentication

func (*OAuthCmdKong) Run added in v0.260507.1

func (o *OAuthCmdKong) Run(appManager *AppManager) error

type OpenCmdKong added in v0.260507.1

type OpenCmdKong struct {
	// Embed StartCmdKong to share server flags
	StartCmdKong
}

OpenCmdKong opens the web UI

func (*OpenCmdKong) Run added in v0.260507.1

func (o *OpenCmdKong) Run(appManager *AppManager) error

type ProfileCmdKong added in v0.260611.1

type ProfileCmdKong struct {
	List      bool     `kong:"flag,name='list',help='List all profiles (non-interactive)'"`
	Show      bool     `kong:"flag,name='show',help='Show profile details instead of launching'"`
	Port      int      `` /* 127-byte string literal not displayed */
	ProfileID string   `kong:"arg,optional,help='Profile name or ID to launch Claude Code with'"`
	Args      []string `kong:"arg,optional,passthrough='all',help='Additional arguments to pass to Claude Code (e.g., --model opus)'"`
}

ProfileCmdKong is the Kong command for managing and using Claude Code profiles.

Management mode:

tingly-box profile --list             → list all profiles (non-interactive)
tingly-box profile --show p1          → show profile details

Launch mode:

tingly-box profile                    → list profiles (interactive on TTY, select to launch)
tingly-box profile p1                 → launch Claude Code with profile p1
tingly-box profile --port 12580 p1    → launch Claude Code with profile p1 on port 12580
tingly-box profile p1 --model opus    → launch with profile p1, passing --model opus to Claude
tingly-box profile p1 -p hi           → launch with profile p1, using Claude's print mode

Put tingly-box flags before the profile name; after the profile name, flags are treated as Claude Code arguments. A literal '--' still works for compatibility.

func (*ProfileCmdKong) Run added in v0.260611.1

func (p *ProfileCmdKong) Run(appManager *AppManager) error

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

type ProviderInfo struct {
	Type        string
	DisplayName string
	Description string
}

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 QRDisplay

type QRDisplay struct {
	URL       string
	ExpiresIn int // seconds
}

QRDisplay represents the QR code display

type QuickstartCmdKong added in v0.260507.1

type QuickstartCmdKong struct{}

QuickstartCmdKong is a hidden alias kept for backward compatibility with scripts and muscle memory; it goes straight to the guided wizard rather than the mode menu.

func (*QuickstartCmdKong) Run added in v0.260604.1

func (q *QuickstartCmdKong) Run(appManager *AppManager) error

type QuotaCmdKong added in v0.260507.1

type QuotaCmdKong struct {
	NoRefresh    bool   `kong:"flag,name='no-refresh',help='Skip refresh and show cached data only'"`
	AllProviders bool   `kong:"flag,name='all',short='a',help='Show all providers instead of interactive mode'"`
	Provider     string `kong:"arg,optional,help='Provider name or UUID (interactive mode if omitted)'"`
}

QuotaCmdKong is the streamlined quota command. Default behavior: interactive mode to select provider.

func (*QuotaCmdKong) Run added in v0.260625.1

func (q *QuotaCmdKong) Run(appManager *AppManager) error

type RemoteAddCmdKong added in v0.260507.1

type RemoteAddCmdKong struct{}

RemoteAddCmdKong adds a new bot configuration (interactive).

func (*RemoteAddCmdKong) Run added in v0.260507.1

func (r *RemoteAddCmdKong) Run(appManager *AppManager) error

type RemoteCmdKong added in v0.260507.1

type RemoteCmdKong struct {
	Default RemoteListCmdKong   `kong:"cmd,name='default',default='1',hidden,help='List remote sessions (default)'"`
	List    RemoteListCmdKong   `kong:"cmd,help='List remote sessions'"`
	Start   RemoteStartCmdKong  `kong:"cmd,help='Start a remote session'"`
	Config  RemoteConfigCmdKong `kong:"cmd,help='Configure remote settings'"`
	Add     RemoteAddCmdKong    `kong:"cmd,help='Add a new bot configuration'"`
	Pair    RemotePairCmdKong   `kong:"cmd,help='Manage TOFU pairing for an imbot'"`
}

RemoteCmdKong manages remote control. The hidden Default subcommand is marked default so `tingly-box remote` (no further args) lists sessions.

type RemoteConfigCmdKong added in v0.260507.1

type RemoteConfigCmdKong struct {
	UUID     string `kong:"arg,optional,help='Bot UUID (interactive selection if omitted)'"`
	Show     bool   `kong:"flag,name='show',help='Show current configuration'"`
	Provider string `kong:"flag,name='provider',help='Provider UUID for smartguide'"`
	Model    string `kong:"flag,name='model',help='Model name for smartguide'"`
}

RemoteConfigCmdKong configures remote settings

func (*RemoteConfigCmdKong) Run added in v0.260507.1

func (r *RemoteConfigCmdKong) Run(appManager *AppManager) error

type RemoteListCmdKong added in v0.260507.1

type RemoteListCmdKong struct{}

RemoteListCmdKong lists remote sessions

func (*RemoteListCmdKong) Run added in v0.260507.1

func (r *RemoteListCmdKong) Run(appManager *AppManager) error

type RemotePairCmdKong added in v0.260507.1

type RemotePairCmdKong struct {
	Enable  RemotePairEnableCmdKong  `kong:"cmd,help='Turn on RequirePairing for a bot'"`
	Disable RemotePairDisableCmdKong `kong:"cmd,help='Turn off RequirePairing for a bot'"`
	Revoke  RemotePairRevokeCmdKong  `kong:"cmd,help='Forget the pairing for a specific chat'"`
	Status  RemotePairStatusCmdKong  `kong:"cmd,help='Show pairing status for a bot'"`
}

RemotePairCmdKong manages TOFU pairing for imbots

func (*RemotePairCmdKong) Run added in v0.260507.1

func (r *RemotePairCmdKong) Run(appManager *AppManager) error

type RemotePairDisableCmdKong added in v0.260507.1

type RemotePairDisableCmdKong struct {
	BotUUID string `kong:"arg,help='Bot UUID'"`
}

RemotePairDisableCmdKong turns off RequirePairing for a bot

func (*RemotePairDisableCmdKong) Run added in v0.260507.1

func (r *RemotePairDisableCmdKong) Run(appManager *AppManager) error

type RemotePairEnableCmdKong added in v0.260507.1

type RemotePairEnableCmdKong struct {
	BotUUID string `kong:"arg,help='Bot UUID'"`
}

RemotePairEnableCmdKong turns on RequirePairing for a bot

func (*RemotePairEnableCmdKong) Run added in v0.260507.1

func (r *RemotePairEnableCmdKong) Run(appManager *AppManager) error

type RemotePairRevokeCmdKong added in v0.260507.1

type RemotePairRevokeCmdKong struct {
	BotUUID string `kong:"arg,help='Bot UUID'"`
	ChatID  string `kong:"arg,help='Chat ID to unpair'"`
}

RemotePairRevokeCmdKong forgets the pairing for a specific chat

func (*RemotePairRevokeCmdKong) Run added in v0.260507.1

func (r *RemotePairRevokeCmdKong) Run(appManager *AppManager) error

type RemotePairStatusCmdKong added in v0.260507.1

type RemotePairStatusCmdKong struct {
	BotUUID string `kong:"arg,help='Bot UUID'"`
}

RemotePairStatusCmdKong shows pairing status for a bot

func (*RemotePairStatusCmdKong) Run added in v0.260507.1

func (r *RemotePairStatusCmdKong) Run(appManager *AppManager) error

type RemoteStartCmdKong added in v0.260507.1

type RemoteStartCmdKong struct {
	UUID     string `kong:"arg,optional,help='Bot UUID (interactive selection if omitted)'"`
	DataPath string `kong:"flag,name='data-path',help='Data directory for bot state'"`
	Provider string `kong:"flag,name='provider',help='Provider UUID for smartguide'"`
	Model    string `kong:"flag,name='model',help='Model name for smartguide'"`
	Force    bool   `kong:"flag,name='force',help='Skip provider validation and force start'"`
}

RemoteStartCmdKong starts a remote session

func (*RemoteStartCmdKong) Run added in v0.260507.1

func (r *RemoteStartCmdKong) Run(appManager *AppManager) error

type RestartCmdKong added in v0.260507.1

type RestartCmdKong struct {
	StartCmdKong
}

RestartCmdKong is the Kong version of restart command

func (*RestartCmdKong) Run added in v0.260507.1

func (r *RestartCmdKong) Run(appManager *AppManager, source LaunchSource) error

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

func (*ServerManager) Stop

func (sm *ServerManager) Stop() error

Stop stops the server gracefully

type ShortcutCmdKong added in v0.260801.1

type ShortcutCmdKong struct {
	Name      string `kong:"flag,name='name',default='Tingly Box',help='Shortcut name'"`
	NoDesktop bool   `kong:"flag,name='no-desktop',help='Do not create a desktop shortcut'"`
	NoMenu    bool   `kong:"flag,name='no-menu',help='Do not create a Start Menu / application menu entry'"`
}

ShortcutCmdKong creates a desktop / start-menu shortcut that launches Tingly Box (restart in daemon mode and open the web UI) with a double-click, so users don't have to remember and type the startup command — especially on Windows.

func (*ShortcutCmdKong) Run added in v0.260801.1

func (s *ShortcutCmdKong) Run(source LaunchSource) error

type StartCmdKong added in v0.260507.1

type StartCmdKong struct {
	Port                 int    `kong:"flag,name='port',short='p',help='Server port'"`
	Host                 string `kong:"flag,name='host',help='Server host'"`
	EnableUI             bool   `kong:"flag,name='ui',short='u',default='true',help='Enable web UI'"`
	EnableDebug          bool   `kong:"flag,name='debug',help='Enable debug mode'"`
	EnableOpenBrowser    bool   `kong:"flag,name='browser',default='true',help='Auto-open browser'"`
	EnableStyleTransform bool   `kong:"flag,name='adapter',default='true',help='Enable API style transform'"`
	Daemon               bool   `kong:"flag,name='daemon',help='Run as daemon'"`
	LogFile              string `kong:"flag,name='log-file',help='Log file path'"`
	PromptRestart        bool   `kong:"flag,name='prompt-restart',help='Prompt to restart if running'"`
	RecordMode           string `kong:"flag,name='record-mode',help='Record mode'"`
	RecordDir            string `kong:"flag,name='record-dir',help='Record directory'"`
	EnableShortcut       bool   `kong:"flag,name='shortcut',help='Also create/refresh a desktop shortcut for next time'"`
}

StartCmdKong is the Kong version of start command

func (*StartCmdKong) Run added in v0.260507.1

func (s *StartCmdKong) Run(appManager *AppManager, source LaunchSource) error

type StatusCmdKong added in v0.260507.1

type StatusCmdKong struct{}

StatusCmdKong is the Kong version of status command

func (*StatusCmdKong) Run added in v0.260507.1

func (s *StatusCmdKong) Run(appManager *AppManager) error

type StopCmdKong added in v0.260507.1

type StopCmdKong struct{}

StopCmdKong is the Kong version of stop command

func (*StopCmdKong) Run added in v0.260507.1

func (s *StopCmdKong) Run(appManager *AppManager) error

type SwaggerCmdKong added in v0.260507.1

type SwaggerCmdKong struct {
	Output string `kong:"flag,name='output',short='o',help='Output file path'"`
	Stdout bool   `kong:"flag,name='stdout',help='Write to stdout'"`
}

SwaggerCmdKong generates OpenAPI schema

func (*SwaggerCmdKong) Run added in v0.260507.1

func (s *SwaggerCmdKong) Run(appManager *AppManager) error

type TUICmdKong added in v0.260507.1

type TUICmdKong struct{}

TUICmdKong runs the interactive TUI. On entry users pick a mode (QuickStart, Provider, Rule, Agent) and manage that area of config freely. Backward-compatible: `tingly-box quickstart` still drops straight into the guided wizard via QuickstartCmdKong.

func (*TUICmdKong) Run added in v0.260507.1

func (t *TUICmdKong) Run(appManager *AppManager) error

type TokenCmdKong added in v0.260514.1

type TokenCmdKong struct {
	List    TokenListCmdKong    `kong:"cmd,name='list',default='1',hidden,help='List tingly-box tokens (default)'"`
	View    TokenViewCmdKong    `kong:"cmd,help='View a tingly-box token (auth or model)'"`
	Refresh TokenRefreshCmdKong `kong:"cmd,help='Refresh (rotate) a tingly-box token (auth or model)'"`
}

TokenCmdKong manages tingly-box's own auth and model tokens. Upstream provider credentials are not handled here — those live under the `provider` and `oauth` commands.

type TokenKind added in v0.260514.1

type TokenKind string

TokenKind identifies which tingly-box token a sub-command operates on. "auth" is the UserToken (control panel + control API). "model" is the ModelToken (used by AI clients hitting the box's OpenAI/Anthropic endpoints). Both are managed independently from upstream provider creds.

type TokenListCmdKong added in v0.260514.1

type TokenListCmdKong struct{}

TokenListCmdKong prints both tokens with masked previews.

func (*TokenListCmdKong) Run added in v0.260514.1

func (t *TokenListCmdKong) Run(appManager *AppManager) error

type TokenRefreshCmdKong added in v0.260514.1

type TokenRefreshCmdKong struct {
	Kind   string `kong:"arg,optional,help='Which token to refresh: auth or model'"`
	Reveal bool   `kong:"flag,name='reveal',short='r',help='Print the full rotated token after success'"`
	Yes    bool   `kong:"flag,name='yes',short='y',help='Skip the rotation confirmation prompt'"`
}

TokenRefreshCmdKong rotates a tingly-box token (auth or model) and persists the new value. Existing clients using the old token will need to be updated.

func (*TokenRefreshCmdKong) Run added in v0.260514.1

func (t *TokenRefreshCmdKong) Run(appManager *AppManager) error

type TokenViewCmdKong added in v0.260514.1

type TokenViewCmdKong struct {
	Kind   string `kong:"arg,optional,help='Which token to view: auth or model'"`
	Reveal bool   `kong:"flag,name='reveal',short='r',help='Print the full token instead of a masked preview'"`
}

TokenViewCmdKong shows a single tingly-box token. When kind is omitted, the user is prompted interactively.

func (*TokenViewCmdKong) Run added in v0.260514.1

func (t *TokenViewCmdKong) Run(appManager *AppManager) error

type VersionCmdKong added in v0.260507.1

type VersionCmdKong struct{}

VersionCmdKong is the Kong version of version command

func (*VersionCmdKong) Run added in v0.260507.1

func (v *VersionCmdKong) Run(appManager *AppManager) error

Directories

Path Synopsis
Package tui provides interactive terminal prompts for the tingly-box CLI.
Package tui provides interactive terminal prompts for the tingly-box CLI.

Jump to

Keyboard shortcuts

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