Documentation
¶
Overview ¶
Package tmux scrapes tmux sessions to detect running AI agent processes and their usage.
Index ¶
- Variables
- func StripANSI(input string) string
- type CommandRunner
- type ExecRunner
- type Session
- func (s *Session) CapturePane(ctx context.Context, captureArgs ...string) (string, error)
- func (s *Session) Kill(ctx context.Context) error
- func (s *Session) Resize(ctx context.Context, width, height int) error
- func (s *Session) SendKeys(ctx context.Context, keys ...string) error
- func (s *Session) Start(ctx context.Context) error
- func (s *Session) WaitForPattern(ctx context.Context, pattern *regexp.Regexp, ...) (string, error)
- type SessionOption
- type UsageResult
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrTmuxNotFound indicates tmux is not installed. ErrTmuxNotFound = errors.New("tmux not found") )
Functions ¶
Types ¶
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, name string, args ...string) ([]byte, error)
}
CommandRunner executes commands for tmux interactions.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session wraps a tmux session.
func NewSession ¶
func NewSession(name string, opts ...SessionOption) *Session
NewSession constructs a tmux session wrapper.
func (*Session) CapturePane ¶
CapturePane captures the current pane contents.
type SessionOption ¶
type SessionOption func(*Session)
SessionOption configures a tmux Session.
func WithRunner ¶
func WithRunner(runner CommandRunner) SessionOption
WithRunner sets the command runner.
func WithWorkDir ¶
func WithWorkDir(dir string) SessionOption
WithWorkDir sets the session working directory.
type UsageResult ¶
type UsageResult struct {
Provider string
WeeklyPct float64
SessionResetTime string // e.g. "9pm (America/Los_Angeles)" or "01:18 on 5 Feb"
WeeklyResetTime string // e.g. "Feb 8 at 10am (America/Los_Angeles)" or "20:08 on 9 Feb"
ScrapedAt time.Time
RawOutput string
}
UsageResult captures scraped usage metadata.
func ScrapeClaudeUsage ¶
func ScrapeClaudeUsage(ctx context.Context) (UsageResult, error)
ScrapeClaudeUsage starts Claude in tmux, runs /usage, and parses weekly usage percent.
func ScrapeCodexUsage ¶
func ScrapeCodexUsage(ctx context.Context) (UsageResult, error)
ScrapeCodexUsage starts Codex in tmux, runs /status, and parses weekly usage percent.
Click to show internal directories.
Click to hide internal directories.