Documentation
¶
Index ¶
- func ProcessStartTime(pid int) (int64, error)
- func TailFile(path string, lines int) ([]byte, error)
- type AdoptOpts
- type ScreenCapture
- type Scrollback
- func (s *Scrollback) Close() error
- func (s *Scrollback) Remove() error
- func (s *Scrollback) Stats() (written, maxSize int64, saturated bool)
- func (s *Scrollback) Tail(lines int) ([]byte, error)
- func (s *Scrollback) TailBytes(maxBytes int64) ([]byte, error)
- func (s *Scrollback) Write(data []byte) (int, error)
- type Session
- func (s *Session) Attach(w io.Writer)
- func (s *Session) Close()
- func (s *Session) Detach()
- func (s *Session) DetachWriter(w io.Writer)
- func (s *Session) Done() <-chan struct{}
- func (s *Session) ExitCode() int
- func (s *Session) ExitSignal() syscall.Signal
- func (s *Session) Exited() bool
- func (s *Session) Fd() uintptr
- func (s *Session) ForceKill() error
- func (s *Session) Interrupt(count int, delay time.Duration) error
- func (s *Session) Kill() error
- func (s *Session) LastOutputAt() time.Time
- func (s *Session) NotifyUserInput()
- func (s *Session) PeakRSSBytes() int64
- func (s *Session) Poke()
- func (s *Session) ProcessPID() int
- func (s *Session) RecentlyAdopted(grace time.Duration) bool
- func (s *Session) Resize(rows, cols uint16) error
- func (s *Session) ScreenPreview() string
- func (s *Session) ScreenSnapshot() ScreenCapture
- func (s *Session) WaitForUserIdle(idleTimeout, maxWait time.Duration) bool
- func (s *Session) WriteInput(data []byte) error
- func (s *Session) WriteInputAndSubmit(data []byte) error
- type SessionOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessStartTime ¶ added in v0.48.0
ProcessStartTime returns a value that uniquely identifies the process with the given PID (clock ticks since boot from /proc/[pid]/stat field 22). If the PID is recycled, the new process will have a different start time.
func TailFile ¶ added in v0.64.5
TailFile returns the last `lines` lines from a scrollback file on disk without a live Scrollback. It is used to read logs for stopped sessions whose live PTY has already been torn down. A missing file is returned as an error; an existing but empty file returns (nil, nil).
Types ¶
type ScreenCapture ¶ added in v0.2.0
type Scrollback ¶
type Scrollback struct {
// contains filtered or unexported fields
}
Scrollback is an append-only log file. path is immutable after construction, so Tail/TailBytes read it lock-free via independent file descriptors.
func NewScrollback ¶
func NewScrollback(path string, maxSize int64) (*Scrollback, error)
func (*Scrollback) Close ¶
func (s *Scrollback) Close() error
func (*Scrollback) Remove ¶
func (s *Scrollback) Remove() error
func (*Scrollback) Stats ¶ added in v0.28.0
func (s *Scrollback) Stats() (written, maxSize int64, saturated bool)
type Session ¶
type Session struct {
ID string
Cmd *exec.Cmd
Ptmx *os.File
Scrollback *Scrollback
// contains filtered or unexported fields
}
func AdoptSession ¶
func NewSession ¶
func NewSession(opts SessionOpts) (*Session, error)
func (*Session) DetachWriter ¶
func (*Session) ExitSignal ¶ added in v0.51.0
func (*Session) Interrupt ¶ added in v0.66.2
Interrupt sends the interrupt byte (Ctrl-C, 0x03) to the PTY count times, pausing delay between successive sends. Some agent TUIs (notably Claude) ignore a single Ctrl-C and need two rapid presses to actually interrupt, so the count and delay are configurable per agent (see issue #620). A count below 1 sends once. The whole operation holds writeMu so the presses aren't interleaved with other input.
func (*Session) LastOutputAt ¶ added in v0.3.0
func (*Session) NotifyUserInput ¶ added in v0.52.0
func (s *Session) NotifyUserInput()
NotifyUserInput records that the attached user just typed something. Call this from the passthrough data path, not from gr type.
func (*Session) PeakRSSBytes ¶ added in v0.51.0
func (*Session) Poke ¶ added in v0.16.5
func (s *Session) Poke()
Poke sends SIGWINCH to the session's process group. This interrupts blocked reads and forces TUI frameworks to re-check stdin, ensuring recently written input is consumed. The child process was started with Setsid, so its PID equals its process group ID.
func (*Session) ProcessPID ¶
func (*Session) RecentlyAdopted ¶ added in v0.6.1
RecentlyAdopted returns true if the session was adopted (daemon restart) within the last duration and has not yet received fresh PTY output.
func (*Session) ScreenPreview ¶ added in v0.2.0
func (*Session) ScreenSnapshot ¶ added in v0.2.0
func (s *Session) ScreenSnapshot() ScreenCapture
func (*Session) WaitForUserIdle ¶ added in v0.52.0
WaitForUserIdle blocks until at least idleTimeout has elapsed since the last user keystroke, or until maxWait has elapsed (whichever comes first). Returns true if the idle condition was met, false if maxWait expired.
func (*Session) WriteInput ¶
func (*Session) WriteInputAndSubmit ¶ added in v0.29.0
WriteInputAndSubmit writes text followed by a carriage return, with a brief pause between the two so that TUI frameworks treat them as separate events. The entire operation holds writeMu to prevent interleaving from other sources.