daemon

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the canonical config location.

Types

type Buttons

type Buttons struct {
	Custom1 string `toml:"custom_1"`
	Custom2 string `toml:"custom_2"`
}

Buttons holds the two user-customizable pad buttons. Each is a single value: a recognized key name / combo ("Ctrl+O", "Shift+Tab") or a literal string sent as-is ("/compact") — see encodeKey. All other intent buttons (accept/reject/up/down/mode_switch/interrupt/rewind) are hardcoded per agent — see keysForCommand — and cannot be overridden from config.

type Config

type Config struct {
	Presets map[string]Preset `toml:"preset"`
}

func LoadConfig

func LoadConfig(path string) (Config, error)

type Daemon

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

func New

func New(cfg Config, socketPath string) *Daemon

func (*Daemon) Serve

func (d *Daemon) Serve(ln net.Listener) error

func (*Daemon) Shutdown

func (d *Daemon) Shutdown()

type Preset

type Preset struct {
	Agent   string            `toml:"agent"`
	Cwd     string            `toml:"cwd"`
	Command string            `toml:"command"`
	Args    []string          `toml:"args"`
	Env     map[string]string `toml:"env"`
	Buttons Buttons           `toml:"buttons"`
}

type Session

type Session struct {
	ID           uint32
	Name         string
	Agent        string
	Cwd          string
	Repo         string // short display label: git repo name or cwd folder name
	Status       string
	LastActivity int64
	// contains filtered or unexported fields
}

func NewSession

func NewSession(id uint32, name string, preset Preset) *Session

func (*Session) CommandLine

func (s *Session) CommandLine() string

CommandLine returns the full launch command as typed ("ollama run glm"), so clients can offer "start another one like this".

func (*Session) DoAction

func (s *Session) DoAction(action string) error

DoAction maps an action name to the session's configured key sequence and writes it. Keys in a multi-key sequence are written with a short gap so ESC-prefixed sequences register as separate key presses (two ESC bytes in one write would otherwise be swallowed as one escape-sequence prefix).

func (*Session) Kill

func (s *Session) Kill()

func (*Session) Resize

func (s *Session) Resize(cols, rows int) error

Resize updates the PTY window size so the child process reflows its TUI to match the attached client's terminal dimensions. Safe to call before or after Start; a no-op for not-yet-started sessions.

func (*Session) SetCustom

func (s *Session) SetCustom(action, value string) error

SetCustom rebinds a custom button at runtime (from the TUI). The value is a single key name / combo or a literal string — the same grammar as the config file. Session-scoped: config.toml is untouched.

func (*Session) Size

func (s *Session) Size() (cols, rows int)

Size returns the PTY size last applied via Resize (0,0 before the first).

func (*Session) Start

func (s *Session) Start() error

func (*Session) SubscribeWithScrollback

func (s *Session) SubscribeWithScrollback(cw *connWriter) (chan []byte, [][]byte)

SubscribeWithScrollback atomically registers a subscription and snapshots the scrollback under the same lock, so a client replaying scrollback then reading the channel sees every byte exactly once, with no gap or duplicate.

func (*Session) Unsubscribe

func (s *Session) Unsubscribe(ch chan []byte)

func (*Session) WriteInput

func (s *Session) WriteInput(b []byte) error

func (*Session) WriteText

func (s *Session) WriteText(text string) error

WriteText writes user-typed text. A trailing CR is written as its own delayed write: agents distinguish a typed Enter from a pasted newline by read-chunk boundaries, so "text\r" in one write lands as a soft newline in the agent's input box instead of submitting it.

Jump to

Keyboard shortcuts

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