internal

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: Apache-2.0, Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

version.go: Build-time versioning info for TmuxAI (set via -ldflags)

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Version, Commit, Date are injected at build time.

View Source
var AllowedConfigKeys = []string{
	"max_capture_lines",
	"max_context_size",
	"wait_interval",
	"send_keys_confirm",
	"paste_multiline_confirm",
	"exec_confirm",
	"openrouter.model",
	"openai.api_key",
	"openai.model",
	"openai.base_url",
	"azure_openai.api_key",
	"azure_openai.deployment_name",
	"azure_openai.api_base",
	"azure_openai.api_version",
}

AllowedConfigKeys defines the list of configuration keys that users are allowed to modify

Functions

This section is empty.

Types

type AIResponse

type AIResponse struct {
	Message                string
	SendKeys               []string
	ExecCommand            []string
	PasteMultilineContent  string
	RequestAccomplished    bool
	ExecPaneSeemsBusy      bool
	WaitingForUserResponse bool
	NoComment              bool
}

func (*AIResponse) String

func (ai *AIResponse) String() string

type AiClient

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

AiClient represents an AI client for interacting with OpenAI-compatible APIs including Azure OpenAI

func NewAiClient

func NewAiClient(cfg *config.Config) *AiClient

func (*AiClient) ChatCompletion

func (c *AiClient) ChatCompletion(ctx context.Context, messages []Message, model string) (string, error)

ChatCompletion sends a chat completion request to the OpenRouter API

func (*AiClient) GetResponseFromChatMessages

func (c *AiClient) GetResponseFromChatMessages(ctx context.Context, chatMessages []ChatMessage, model string) (string, error)

GetResponseFromChatMessages gets a response from the AI based on chat messages

func (*AiClient) Response added in v1.1.3

func (c *AiClient) Response(ctx context.Context, messages []Message, model string) (string, error)

Response sends a request to the OpenAI Responses API

type CLIInterface

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

func NewCLIInterface

func NewCLIInterface(manager *Manager) *CLIInterface

func (*CLIInterface) Start

func (c *CLIInterface) Start(initMessage string) error

Start starts the CLI interface

type ChatCompletionChoice

type ChatCompletionChoice struct {
	Index   int     `json:"index"`
	Message Message `json:"message"`
}

ChatCompletionChoice represents a choice in the chat completion response

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model    string    `json:"model,omitempty"`
	Messages []Message `json:"messages"`
}

ChatCompletionRequest represents a request to the chat completion API

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID      string                 `json:"id"`
	Object  string                 `json:"object"`
	Created int64                  `json:"created"`
	Choices []ChatCompletionChoice `json:"choices"`
}

ChatCompletionResponse represents a response from the chat completion API

type ChatMessage

type ChatMessage struct {
	Content   string
	FromUser  bool
	Timestamp time.Time
}

Message represents a chat message

type CommandExecHistory

type CommandExecHistory struct {
	Command string
	Output  string
	Code    int
}

Parsed only when pane is prepared

type Manager

type Manager struct {
	Config           *config.Config
	AiClient         *AiClient
	Status           string // running, waiting, done
	PaneId           string
	ExecPane         *system.TmuxPaneDetails
	Messages         []ChatMessage
	ExecHistory      []CommandExecHistory
	WatchMode        bool
	OS               string
	SessionOverrides map[string]interface{} // session-only config overrides
	// contains filtered or unexported fields
}

Manager represents the TmuxAI manager agent

func NewManager

func NewManager(cfg *config.Config) (*Manager, error)

NewManager creates a new manager agent

func (*Manager) Countdown

func (m *Manager) Countdown(seconds int)

func (*Manager) ExecWaitCapture

func (m *Manager) ExecWaitCapture(command string) (CommandExecHistory, error)

func (*Manager) FormatConfig

func (m *Manager) FormatConfig() string

FormatConfig returns a nicely formatted string of all config values with session overrides applied

func (*Manager) GetAvailablePane

func (m *Manager) GetAvailablePane() system.TmuxPaneDetails

GetAvailablePane finds an available pane or creates a new one if none are available

func (*Manager) GetAzureOpenAIAPIKey added in v1.1.3

func (m *Manager) GetAzureOpenAIAPIKey() string

GetAzureOpenAIAPIKey returns the Azure OpenAI API key value with session override if present

func (*Manager) GetAzureOpenAIDeploymentName added in v1.1.3

func (m *Manager) GetAzureOpenAIDeploymentName() string

GetAzureOpenAIDeploymentName returns the Azure OpenAI deployment name value with session override if present

func (*Manager) GetConfig

func (m *Manager) GetConfig() *config.Config

func (*Manager) GetExecConfirm

func (m *Manager) GetExecConfirm() bool

func (*Manager) GetMaxCaptureLines

func (m *Manager) GetMaxCaptureLines() int

GetMaxCaptureLines returns the max capture lines value with session override if present

func (*Manager) GetMaxContextSize

func (m *Manager) GetMaxContextSize() int

GetMaxContextSize returns the max context size value with session override if present

func (*Manager) GetModel added in v1.1.3

func (m *Manager) GetModel() string

GetModel returns the appropriate model based on configuration priority Priority: OpenAI > Azure > OpenRouter

func (*Manager) GetOpenAIAPIKey added in v1.1.3

func (m *Manager) GetOpenAIAPIKey() string

GetOpenAIAPIKey returns the OpenAI API key value with session override if present

func (*Manager) GetOpenAIBaseURL added in v1.1.3

func (m *Manager) GetOpenAIBaseURL() string

GetOpenAIBaseURL returns the OpenAI base URL value with session override if present

func (*Manager) GetOpenAIModel added in v1.1.3

func (m *Manager) GetOpenAIModel() string

GetOpenAIModel returns the OpenAI model value with session override if present

func (*Manager) GetOpenRouterModel

func (m *Manager) GetOpenRouterModel() string

func (*Manager) GetPasteMultilineConfirm

func (m *Manager) GetPasteMultilineConfirm() bool

func (*Manager) GetPrompt

func (m *Manager) GetPrompt() string

getPrompt returns the prompt string with color

func (*Manager) GetSendKeysConfirm

func (m *Manager) GetSendKeysConfirm() bool

func (*Manager) GetTmuxPanes

func (m *Manager) GetTmuxPanes() ([]system.TmuxPaneDetails, error)

func (*Manager) GetWaitInterval

func (m *Manager) GetWaitInterval() int

GetWaitInterval returns the wait interval value with session override if present

func (*Manager) InitExecPane

func (m *Manager) InitExecPane()

func (*Manager) IsMessageSubcommand

func (m *Manager) IsMessageSubcommand(content string) bool

checks if the given content is a command

func (*Manager) PrepareExecPane

func (m *Manager) PrepareExecPane()

func (*Manager) PrepareExecPaneWithShell added in v1.1.1

func (m *Manager) PrepareExecPaneWithShell(shell string)

func (*Manager) Println

func (m *Manager) Println(msg string)

func (*Manager) ProcessSubCommand

func (m *Manager) ProcessSubCommand(command string)

processes a command and returns a response

func (*Manager) ProcessUserMessage

func (m *Manager) ProcessUserMessage(ctx context.Context, message string) bool

Main function to process regular user messages Returns true if the request was accomplished and no further processing should happen

func (*Manager) Start

func (m *Manager) Start(initMessage string) error

Start starts the manager agent

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message

type Response added in v1.1.3

type Response struct {
	ID         string               `json:"id"`
	Object     string               `json:"object"`
	CreatedAt  int64                `json:"created_at"`
	Model      string               `json:"model"`
	Output     []ResponseOutputItem `json:"output"`
	OutputText string               `json:"output_text,omitempty"`
	Error      *ResponseError       `json:"error,omitempty"`
	Usage      *ResponseUsage       `json:"usage,omitempty"`
}

Response represents a response from the Responses API

type ResponseContent added in v1.1.3

type ResponseContent struct {
	Type        string        `json:"type"`
	Text        string        `json:"text,omitempty"`
	Annotations []interface{} `json:"annotations,omitempty"`
}

ResponseContent represents content in the Responses API

type ResponseError added in v1.1.3

type ResponseError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Code    string `json:"code,omitempty"`
}

ResponseError represents an error in the Responses API

type ResponseInput added in v1.1.3

type ResponseInput interface{}

ResponseInput represents the input for the Responses API

type ResponseOutputItem added in v1.1.3

type ResponseOutputItem struct {
	ID      string            `json:"id"`
	Type    string            `json:"type"`             // "message", "reasoning", "function_call", etc.
	Status  string            `json:"status,omitempty"` // "completed", "in_progress", etc.
	Content []ResponseContent `json:"content,omitempty"`
	Role    string            `json:"role,omitempty"` // "assistant", "user", etc.
	Summary []interface{}     `json:"summary,omitempty"`
}

ResponseOutputItem represents an output item in the Responses API

type ResponseRequest added in v1.1.3

type ResponseRequest struct {
	Model              string                 `json:"model"`
	Input              ResponseInput          `json:"input"`
	Instructions       string                 `json:"instructions,omitempty"`
	Tools              []interface{}          `json:"tools,omitempty"`
	PreviousResponseID string                 `json:"previous_response_id,omitempty"`
	Store              bool                   `json:"store,omitempty"`
	Include            []string               `json:"include,omitempty"`
	Text               map[string]interface{} `json:"text,omitempty"` // for structured outputs
}

ResponseRequest represents a request to the Responses API

type ResponseUsage added in v1.1.3

type ResponseUsage struct {
	InputTokens     int `json:"input_tokens"`
	OutputTokens    int `json:"output_tokens"`
	ReasoningTokens int `json:"reasoning_tokens,omitempty"`
	TotalTokens     int `json:"total_tokens"`
}

ResponseUsage represents token usage in the Responses API

Jump to

Keyboard shortcuts

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