Documentation
¶
Index ¶
- Constants
- func IsStdinTTY() bool
- type Config
- type Daemon
- type REPL
- type RingBuffer
- type SessionManager
- func (m *SessionManager) Active() *ipc.PageSession
- func (m *SessionManager) ActiveID() string
- func (m *SessionManager) Add(sessionID, targetID, url, title string)
- func (m *SessionManager) All() []ipc.PageSession
- func (m *SessionManager) Clear()
- func (m *SessionManager) Count() int
- func (m *SessionManager) FindByQuery(query string) []ipc.PageSession
- func (m *SessionManager) Get(sessionID string) *ipc.PageSession
- func (m *SessionManager) GetByTargetID(targetID string) *ipc.PageSession
- func (m *SessionManager) Remove(sessionID string) (newActiveID string, activeChanged bool)
- func (m *SessionManager) SetActive(sessionID string) bool
- func (m *SessionManager) TargetID(sessionID string) string
- func (m *SessionManager) Update(sessionID, url, title string)
- func (m *SessionManager) UpdateByTargetID(targetID, url, title string)
- type SessionProvider
Constants ¶
const DefaultBufferSize = 10000
DefaultBufferSize is the default capacity for event buffers.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Headless bool
Port int
SocketPath string
PIDPath string
BufferSize int
Debug bool
// CommandExecutor is called by REPL for CLI command execution with flags.
// If nil, REPL falls back to basic IPC-only execution.
CommandExecutor ipc.CommandExecutor
}
Config holds daemon configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default daemon configuration.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the persistent webctl daemon process.
type REPL ¶
type REPL struct {
// contains filtered or unexported fields
}
REPL provides an interactive command interface for the daemon.
func NewREPL ¶
func NewREPL(handler ipc.Handler, cmdExec ipc.CommandExecutor, shutdown func()) *REPL
NewREPL creates a new REPL with the given handler, command executor, and shutdown callback. The cmdExec function executes CLI commands with full flag support. If cmdExec is nil, REPL falls back to basic IPC-only command execution.
func (*REPL) Close ¶
Close closes the readline instance if it exists. Safe to call multiple times (idempotent). Returns the error from the first close attempt on all subsequent calls.
func (*REPL) SetSessionProvider ¶
func (r *REPL) SetSessionProvider(sp SessionProvider)
SetSessionProvider sets the session provider for dynamic prompt generation.
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
RingBuffer is a thread-safe circular buffer with fixed capacity. When the buffer is full, new items overwrite the oldest items.
func NewRingBuffer ¶
func NewRingBuffer[T any](capacity int) *RingBuffer[T]
NewRingBuffer creates a new ring buffer with the specified capacity.
func (*RingBuffer[T]) All ¶
func (b *RingBuffer[T]) All() []T
All returns all items in the buffer, oldest first. Allocates a new slice on each call. This is acceptable for the current request-response IPC pattern where each query is a discrete operation.
func (*RingBuffer[T]) Clear ¶
func (b *RingBuffer[T]) Clear()
Clear removes all items from the buffer.
func (*RingBuffer[T]) Len ¶
func (b *RingBuffer[T]) Len() int
Len returns the current number of items in the buffer.
func (*RingBuffer[T]) Push ¶
func (b *RingBuffer[T]) Push(item T)
Push adds an item to the buffer. If the buffer is full, the oldest item is overwritten.
func (*RingBuffer[T]) RemoveIf ¶
func (b *RingBuffer[T]) RemoveIf(fn func(*T) bool)
RemoveIf removes all items for which fn returns true. Items are compacted in-place, maintaining order.
func (*RingBuffer[T]) Update ¶
func (b *RingBuffer[T]) Update(fn func(*T) bool)
Update iterates through buffer items from newest to oldest, calling fn with a pointer to each item. Iteration stops when fn returns true. This allows in-place modification of buffer entries.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager tracks CDP page sessions.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a new session manager.
func (*SessionManager) Active ¶
func (m *SessionManager) Active() *ipc.PageSession
Active returns the active session info, or nil if none.
func (*SessionManager) ActiveID ¶
func (m *SessionManager) ActiveID() string
ActiveID returns the current active session ID (empty if none).
func (*SessionManager) Add ¶
func (m *SessionManager) Add(sessionID, targetID, url, title string)
Add adds a new session. If it's the first session, it becomes active.
func (*SessionManager) All ¶
func (m *SessionManager) All() []ipc.PageSession
All returns all sessions as IPC PageSession list.
func (*SessionManager) Clear ¶
func (m *SessionManager) Clear()
Clear removes all sessions and resets the manager state. Used when browser connection is lost.
func (*SessionManager) Count ¶
func (m *SessionManager) Count() int
Count returns the number of sessions.
func (*SessionManager) FindByQuery ¶
func (m *SessionManager) FindByQuery(query string) []ipc.PageSession
FindByQuery searches for sessions matching the query. Query is matched against session ID prefix (case-sensitive) or title substring (case-insensitive). Returns matching sessions.
func (*SessionManager) Get ¶
func (m *SessionManager) Get(sessionID string) *ipc.PageSession
Get returns a session by ID, or nil if not found.
func (*SessionManager) GetByTargetID ¶ added in v0.1.0
func (m *SessionManager) GetByTargetID(targetID string) *ipc.PageSession
GetByTargetID returns the session matching the given targetID, or nil if not found.
func (*SessionManager) Remove ¶
func (m *SessionManager) Remove(sessionID string) (newActiveID string, activeChanged bool)
Remove removes a session. If it was active, switches to most recent remaining. Returns the new active session ID (empty if none remain) and true if active changed.
func (*SessionManager) SetActive ¶
func (m *SessionManager) SetActive(sessionID string) bool
SetActive sets the active session by ID. Returns false if the session doesn't exist.
func (*SessionManager) TargetID ¶ added in v0.1.0
func (m *SessionManager) TargetID(sessionID string) string
TargetID returns the targetID for the given sessionID, or empty string if not found.
func (*SessionManager) Update ¶
func (m *SessionManager) Update(sessionID, url, title string)
Update updates a session's URL and title by session ID.
func (*SessionManager) UpdateByTargetID ¶
func (m *SessionManager) UpdateByTargetID(targetID, url, title string)
UpdateByTargetID updates a session's URL and title by target ID.
type SessionProvider ¶
type SessionProvider func() (active *ipc.PageSession, count int)
SessionProvider returns the active session info and total count.