ui

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 54 Imported by: 0

Documentation

Overview

Package ui implements the bubbletea TUI, SSH helpers, and CUE recipe execution for honey.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLocalFilesRoot added in v0.2.8

func DefaultLocalFilesRoot() string

DefaultLocalFilesRoot returns the configured or home-directory root for local file browser paths.

func DialSSHLeafForRecord added in v0.2.7

func DialSSHLeafForRecord(user string, r hosts.Record) (*ssh.Client, func(), error)

DialSSHLeafForRecord returns a leaf *ssh.Client for SSH to hosts.Record.PrimaryIP (same transport as the TUI). Kubernetes pod records are not supported for raw SSH in this helper.

func LoadAISystemPromptFromConfigPath added in v0.2.8

func LoadAISystemPromptFromConfigPath(configPath string) string

LoadAISystemPromptFromConfigPath returns defaults.ai_system_prompt from the honey YAML at path, if loadable.

func RemoteCopyLocalToRemote added in v0.2.8

func RemoteCopyLocalToRemote(user string, record hosts.Record, localPath, remotePath string, cache *engine.ClientCache) error

RemoteCopyLocalToRemote uploads a local file to the remote path.

func RemoteCopyRemoteToLocal added in v0.2.8

func RemoteCopyRemoteToLocal(user string, record hosts.Record, remotePath, localPath string, cache *engine.ClientCache) error

RemoteCopyRemoteToLocal downloads a remote file to a local path.

func RemoteListDir added in v0.2.8

func RemoteListDir(user string, record hosts.Record, remotePath string, cache *engine.ClientCache) ([]engine.RemoteFileEntry, error)

RemoteListDir lists a directory on the remote host using a cached SSH/k8s client.

func RemoteMkdirAll added in v0.3.6

func RemoteMkdirAll(user string, record hosts.Record, remotePath string, cache *engine.ClientCache) error

RemoteMkdirAll creates a directory on the remote host using a cached client.

func RemoteRemove added in v0.3.6

func RemoteRemove(user string, record hosts.Record, remotePath string, recursive bool, cache *engine.ClientCache) error

RemoteRemove deletes a file or directory on the remote host using a cached client.

func RemoteStat added in v0.3.6

func RemoteStat(user string, record hosts.Record, remotePath string, cache *engine.ClientCache) (hostexec.RemoteFileEntry, error)

RemoteStat queries a file stat on the remote host using a cached client.

func ResolveLocalAbsUnderRoot added in v0.3.6

func ResolveLocalAbsUnderRoot(root, requested string) (string, error)

ResolveLocalAbsUnderRoot resolves requested against root and ensures the result stays under root.

func RunLogTUI added in v0.3.1

func RunLogTUI(ctx context.Context, user string, records []hosts.Record, opts LogOptions, cache *engine.ClientCache) error

RunLogTUI starts the interactive log viewer.

func RunRecordingReplay added in v0.2.8

func RunRecordingReplay(recordDir, baseName string) error

RunRecordingReplay plays one .hrec.jsonl in a nested full-screen Bubble Tea view.

func RunSSHInteractiveStreams added in v0.3.7

func RunSSHInteractiveStreams(ctx context.Context, user string, r hosts.Record, stdin io.Reader, stdout io.Writer, cols, rows int, resize <-chan [2]int) error

RunSSHInteractiveStreams runs an interactive SSH PTY shell for r over the caller's streams (a web terminal's WebSocket pipes, or a recorded session) instead of os.Stdin/os.Stdout. It is the universal SSH terminal path: it dials the leaf directly via DialSSHLeafForRecord (independent of any executor registry), so a plain SSH host always gets a shell. Under a PTY the remote merges stderr into stdout, so both route to stdout. resize carries [cols, rows] pairs, forwarded to the session as WindowChange; the forwarding goroutine stops on session end or ctx cancellation.

It backs both the cli sshFallbackExecutor's InteractiveStreamer seam and the webserver's fallback when the resolved executor is not itself interactive, so the SSH PTY plumbing lives in exactly one place.

func RunTable

func RunTable(records []hosts.Record, sshUser string, opts RunTableOptions) error

RunTable shows an interactive table and optionally execs ssh. After SSH/Tunnel disconnects, it returns to the UI.

func StreamLogs added in v0.3.1

func StreamLogs(ctx context.Context, user string, records []hosts.Record, opts LogOptions, cache *engine.ClientCache, out io.Writer) error

StreamLogs streams logs for records to out with stable per-record prefixes.

Types

type LocalFileEntry added in v0.2.8

type LocalFileEntry struct {
	Name       string    `json:"name"`
	Path       string    `json:"path"`
	IsDir      bool      `json:"is_dir"`
	Size       int64     `json:"size"`
	Mode       string    `json:"mode"`
	ModifiedAt time.Time `json:"modified_at"`
}

LocalFileEntry mirrors engine.RemoteFileEntry for local directories.

func ListLocalDirUnderRoot added in v0.2.8

func ListLocalDirUnderRoot(root, requested string) (string, []LocalFileEntry, error)

ListLocalDirUnderRoot lists a directory under the resolved root path.

type LogOptions added in v0.3.1

type LogOptions struct {
	Target                 string
	Source                 string
	Follow                 bool
	Tail                   int64
	Since                  time.Duration
	Timestamps             bool
	Container              string
	Unit                   string
	Command                string
	RunAs                  string
	MaxConcurrency         int
	Grep                   string
	Labels                 []string
	Highlight              bool
	Anomaly                bool
	AnomalyModel           string
	AnomalyThresh          float64
	AnomalyWindow          int
	AnomalyOnly            bool
	AnomalyStrict          bool
	AnomalyTokPath         string
	AnomalyEndpoint        string
	AnomalyLLMModel        string
	AnomalyContextLines    int
	AnomalyFilterThreshold float64
	AnomalyFreqWindow      int
	AnomalyFreqRatio       float64
	AnomalyFeedbackFile    string
	AnomalyPreprocessor    string
	AlertEnabled           bool
	AlertSuppressDuration  time.Duration
}

LogOptions controls distributed log streaming.

type LogViewModel added in v0.3.1

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

LogViewModel is the Bubble Tea model for the log viewer.

func NewLogViewModel added in v0.3.1

func NewLogViewModel(opts LogOptions) *LogViewModel

NewLogViewModel creates a new log view model.

func (*LogViewModel) Init added in v0.3.1

func (m *LogViewModel) Init() tea.Cmd

Init initializes the log view model.

func (*LogViewModel) Update added in v0.3.1

func (m *LogViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the log view model.

func (*LogViewModel) View added in v0.3.1

func (m *LogViewModel) View() tea.View

View renders the log viewer UI.

type RunTableOptions added in v0.2.8

type RunTableOptions struct {
	RecordDir     string
	RecordEnabled bool
	// Config is the honey YAML already loaded for this session (optional; nil if none / load failed).
	Config *config.File
	// ConfigPath is the resolved honey YAML path (may be empty); CUE agent_transfer steps with cloud_backend_ref need it.
	ConfigPath string
	// engine.ClientCache is an optional shared SSH client cache. If nil, one is created.
	ClientCache *engine.ClientCache
	// ExecRegistry is the host execution registry.
	ExecRegistry hostexec.Registry
	// AlertBanner is an optional one-line banner shown above the table (e.g. from `honey alert investigate`).
	AlertBanner string
}

RunTableOptions configures optional session recording for the TUI table.

type TunnelModel added in v0.3.6

type TunnelModel struct {
	Record hosts.Record
	Width  int
	Height int
	// contains filtered or unexported fields
}

TunnelModel is the BubbleTea sub-model for the tunnel popup.

func NewTunnelModel added in v0.3.6

func NewTunnelModel(r hosts.Record, isK8s bool, width, height int) *TunnelModel

NewTunnelModel initializes the tunnel sub-model.

func (*TunnelModel) Init added in v0.3.6

func (m *TunnelModel) Init() tea.Cmd

Init satisfies tea.Model.

func (*TunnelModel) Update added in v0.3.6

func (m *TunnelModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update satisfies tea.Model.

func (*TunnelModel) View added in v0.3.6

func (m *TunnelModel) View() tea.View

View satisfies tea.Model.

type TunnelResult added in v0.3.6

type TunnelResult struct {
	Arg      string
	Canceled bool
}

TunnelResult wraps the tunnel creation outcome.

Jump to

Keyboard shortcuts

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