Documentation
¶
Overview ¶
Package daemon provides the background daemon for persistent state management.
Package daemon provides the background daemon for persistent state management.
Package daemon provides the background daemon for persistent state management.
Package daemon provides the stateful daemon process that manages processes, proxies, and traffic logs across client connections.
Index ¶
- Constants
- Variables
- func CleanupZombieDaemons(socketPath string) int
- func CompareVersions(a, b string) (int, error)
- func Connect(path string) (net.Conn, error)
- func DefaultSocketPath() string
- func DefaultStatePath() string
- func FormatVersion(major, minor, patch int) string
- func IsDaemonRunning(socketPath string) bool
- func IsRunning(path string) bool
- func ParseVersion(v string) (major, minor, patch int, err error)
- func StopDaemon(socketPath string) error
- func UpgradeDaemon(ctx context.Context, config UpgradeConfig) error
- func ValidateVersion(v string) error
- func VersionsMatch(a, b string) bool
- type AutoStartClient
- type AutoStartConfig
- type BufferedWriter
- type Client
- func (c *Client) BroadcastActivity(active bool, proxyIDs ...string) error
- func (c *Client) ChaosAddRule(proxyID string, rule protocol.ChaosRuleConfig) (map[string]interface{}, error)
- func (c *Client) ChaosClear(proxyID string) (map[string]interface{}, error)
- func (c *Client) ChaosDisable(proxyID string) (map[string]interface{}, error)
- func (c *Client) ChaosEnable(proxyID string) (map[string]interface{}, error)
- func (c *Client) ChaosListPresets() (map[string]interface{}, error)
- func (c *Client) ChaosListRules(proxyID string) (map[string]interface{}, error)
- func (c *Client) ChaosPreset(proxyID, preset string) (map[string]interface{}, error)
- func (c *Client) ChaosRemoveRule(proxyID, ruleID string) (map[string]interface{}, error)
- func (c *Client) ChaosSet(proxyID string, config protocol.ChaosConfigPayload) (map[string]interface{}, error)
- func (c *Client) ChaosStats(proxyID string) (map[string]interface{}, error)
- func (c *Client) ChaosStatus(proxyID string) (map[string]interface{}, error)
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) CurrentPageClear(proxyID string) error
- func (c *Client) CurrentPageGet(proxyID, sessionID string) (map[string]interface{}, error)
- func (c *Client) CurrentPageList(proxyID string) (map[string]interface{}, error)
- func (c *Client) Detect(path string) (map[string]interface{}, error)
- func (c *Client) Info() (*DaemonInfo, error)
- func (c *Client) IsConnected() bool
- func (c *Client) OverlayClear() error
- func (c *Client) OverlayGet() (map[string]interface{}, error)
- func (c *Client) OverlaySet(endpoint string) (map[string]interface{}, error)
- func (c *Client) Ping() error
- func (c *Client) ProcCleanupPort(port int) (map[string]interface{}, error)
- func (c *Client) ProcList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (c *Client) ProcOutput(processID string, filter protocol.OutputFilter) (string, error)
- func (c *Client) ProcStatus(processID string) (map[string]interface{}, error)
- func (c *Client) ProcStop(processID string, force bool) (map[string]interface{}, error)
- func (c *Client) ProxyExec(id, code string) (map[string]interface{}, error)
- func (c *Client) ProxyList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (c *Client) ProxyLogClear(proxyID string) error
- func (c *Client) ProxyLogQuery(proxyID string, filter protocol.LogQueryFilter) (map[string]interface{}, error)
- func (c *Client) ProxyLogStats(proxyID string) (map[string]interface{}, error)
- func (c *Client) ProxyStart(id, targetURL string, port, maxLogSize int, path string) (map[string]interface{}, error)
- func (c *Client) ProxyStartWithConfig(id, targetURL string, port, maxLogSize int, config ProxyStartConfig) (map[string]interface{}, error)
- func (c *Client) ProxyStatus(id string) (map[string]interface{}, error)
- func (c *Client) ProxyStop(id string) error
- func (c *Client) ProxyToast(id string, toast protocol.ToastConfig) (map[string]interface{}, error)
- func (c *Client) Run(config protocol.RunConfig) (map[string]interface{}, error)
- func (c *Client) SessionCancel(taskID string) error
- func (c *Client) SessionGenerateCode(command string) (string, error)
- func (c *Client) SessionGet(code string) (map[string]interface{}, error)
- func (c *Client) SessionHeartbeat(code string) error
- func (c *Client) SessionList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (c *Client) SessionRegister(code string, overlayPath string, projectPath string, command string, ...) (map[string]interface{}, error)
- func (c *Client) SessionSchedule(code string, duration string, message string) (map[string]interface{}, error)
- func (c *Client) SessionSend(code string, message string) (map[string]interface{}, error)
- func (c *Client) SessionTasks(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (c *Client) SessionUnregister(code string) error
- func (c *Client) Shutdown() error
- func (c *Client) TunnelList() (map[string]interface{}, error)
- func (c *Client) TunnelStart(config protocol.TunnelStartConfig) (map[string]interface{}, error)
- func (c *Client) TunnelStatus(id string) (map[string]interface{}, error)
- func (c *Client) TunnelStop(id string) error
- type ClientOption
- type Connection
- type Daemon
- func (d *Daemon) GetSession(code string) (*Session, bool)
- func (d *Daemon) Info() DaemonInfo
- func (d *Daemon) OverlayEndpoint() string
- func (d *Daemon) ProcessManager() *process.ProcessManager
- func (d *Daemon) ProxyManager() *proxy.ProxyManager
- func (d *Daemon) Scheduler() *Scheduler
- func (d *Daemon) SessionRegistry() *SessionRegistry
- func (d *Daemon) SetOverlayEndpoint(endpoint string)
- func (d *Daemon) Start() error
- func (d *Daemon) StateManager() *StateManager
- func (d *Daemon) Stop(ctx context.Context) error
- func (d *Daemon) TunnelManager() *tunnel.Manager
- func (d *Daemon) Wait()
- type DaemonConfig
- type DaemonInfo
- type DaemonUpgrader
- type PersistedTaskState
- type PersistentProxyConfig
- type PersistentState
- type ProcessInfo
- type ProxyInfo
- type ProxyStartConfig
- type ReconnectCallback
- type ResilientClient
- func (rc *ResilientClient) BroadcastActivity(active bool, proxyIDs ...string) error
- func (rc *ResilientClient) ChaosAddRule(proxyID string, rule protocol.ChaosRuleConfig) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosClear(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosDisable(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosEnable(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosListPresets() (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosListRules(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosPreset(proxyID, preset string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosRemoveRule(proxyID, ruleID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosSet(proxyID string, config protocol.ChaosConfigPayload) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosStats(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ChaosStatus(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) Client() *Client
- func (rc *ResilientClient) Close() error
- func (rc *ResilientClient) Connect() error
- func (rc *ResilientClient) CurrentPageClear(proxyID string) error
- func (rc *ResilientClient) CurrentPageGet(proxyID, sessionID string) (map[string]interface{}, error)
- func (rc *ResilientClient) CurrentPageList(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) Detect(path string) (map[string]interface{}, error)
- func (rc *ResilientClient) Info() (*DaemonInfo, error)
- func (rc *ResilientClient) IsConnected() bool
- func (rc *ResilientClient) IsReconnecting() bool
- func (rc *ResilientClient) OverlaySet(endpoint string) (map[string]interface{}, error)
- func (rc *ResilientClient) Ping() error
- func (rc *ResilientClient) ProcCleanupPort(port int) (map[string]interface{}, error)
- func (rc *ResilientClient) ProcList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (rc *ResilientClient) ProcOutput(processID string, filter protocol.OutputFilter) (string, error)
- func (rc *ResilientClient) ProcStatus(processID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ProcStop(processID string, force bool) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyExec(id, code string) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyLogClear(proxyID string) error
- func (rc *ResilientClient) ProxyLogQuery(proxyID string, filter protocol.LogQueryFilter) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyLogStats(proxyID string) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyStart(id, targetURL string, port, maxLogSize int, path string) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyStartWithConfig(id, targetURL string, port, maxLogSize int, config ProxyStartConfig) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyStatus(id string) (map[string]interface{}, error)
- func (rc *ResilientClient) ProxyStop(id string) error
- func (rc *ResilientClient) ProxyToast(id string, toast protocol.ToastConfig) (map[string]interface{}, error)
- func (rc *ResilientClient) Run(config protocol.RunConfig) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionCancel(taskID string) error
- func (rc *ResilientClient) SessionGenerateCode(command string) (string, error)
- func (rc *ResilientClient) SessionGet(code string) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionHeartbeat(code string) error
- func (rc *ResilientClient) SessionList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionRegister(code, overlayPath, projectPath, command string, args []string) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionSchedule(code, duration, message string) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionSend(code, message string) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionTasks(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
- func (rc *ResilientClient) SessionUnregister(code string) error
- func (rc *ResilientClient) Stats() map[string]interface{}
- func (rc *ResilientClient) TunnelList() (map[string]interface{}, error)
- func (rc *ResilientClient) TunnelStart(config protocol.TunnelStartConfig) (map[string]interface{}, error)
- func (rc *ResilientClient) TunnelStatus(id string) (map[string]interface{}, error)
- func (rc *ResilientClient) TunnelStop(id string) error
- func (rc *ResilientClient) WithClient(fn func(*Client) error) error
- type ResilientClientConfig
- type ScheduledTask
- type Scheduler
- func (s *Scheduler) Cancel(taskID string) error
- func (s *Scheduler) GetTask(taskID string) (*ScheduledTask, bool)
- func (s *Scheduler) Info() SchedulerInfo
- func (s *Scheduler) ListPendingTasks(projectPath string, global bool) []*ScheduledTask
- func (s *Scheduler) ListTasks(projectPath string, global bool) []*ScheduledTask
- func (s *Scheduler) Schedule(sessionCode string, duration time.Duration, message string, projectPath string) (*ScheduledTask, error)
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Stop()
- type SchedulerConfig
- type SchedulerInfo
- type SchedulerStateManager
- func (m *SchedulerStateManager) ClearProject(projectPath string) error
- func (m *SchedulerStateManager) ListProjectsWithTasks() []string
- func (m *SchedulerStateManager) LoadAllTasks() []*ScheduledTask
- func (m *SchedulerStateManager) LoadTasks(projectPath string) ([]*ScheduledTask, error)
- func (m *SchedulerStateManager) RegisterProject(projectPath string)
- func (m *SchedulerStateManager) RemoveTask(taskID string, projectPath string) error
- func (m *SchedulerStateManager) SaveTask(task *ScheduledTask) error
- func (m *SchedulerStateManager) ScanForProjects(basePaths []string)
- type Session
- type SessionInfo
- type SessionRegistry
- func (r *SessionRegistry) ActiveCount() int64
- func (r *SessionRegistry) CheckHeartbeats()
- func (r *SessionRegistry) GenerateSessionCode(command string) string
- func (r *SessionRegistry) Get(code string) (*Session, bool)
- func (r *SessionRegistry) Heartbeat(code string) error
- func (r *SessionRegistry) Info() SessionInfo
- func (r *SessionRegistry) List(projectPath string, global bool) []*Session
- func (r *SessionRegistry) ListActive(projectPath string, global bool) []*Session
- func (r *SessionRegistry) Register(session *Session) error
- func (r *SessionRegistry) TotalRegistered() int64
- func (r *SessionRegistry) TotalUnregistered() int64
- func (r *SessionRegistry) Unregister(code string) error
- type SessionStatus
- type SocketConfig
- type SocketManager
- type StateManager
- func (sm *StateManager) AddProxy(config PersistentProxyConfig)
- func (sm *StateManager) Clear() error
- func (sm *StateManager) Flush() error
- func (sm *StateManager) GetOverlayEndpoint() string
- func (sm *StateManager) GetProxies() []PersistentProxyConfig
- func (sm *StateManager) GetProxy(id string) (PersistentProxyConfig, bool)
- func (sm *StateManager) Load() error
- func (sm *StateManager) RemoveProxy(id string)
- func (sm *StateManager) Save() error
- func (sm *StateManager) SaveDebounced()
- func (sm *StateManager) SetOverlayEndpoint(endpoint string)
- func (sm *StateManager) State() PersistentState
- type StateManagerConfig
- type TaskStatus
- type TunnelInfo
- type UpgradeConfig
Constants ¶
const SchedulerStateDir = ".agnt"
SchedulerStateDir is the directory within each project for agnt state.
const SchedulerStateFile = "scheduled-tasks.json"
SchedulerStateFile is the name of the per-project task state file.
Variables ¶
var ( // ErrNotConnected is returned when trying to use a closed client. ErrNotConnected = errors.New("not connected to daemon") // ErrServerError is returned when the daemon returns an error response. ErrServerError = errors.New("daemon error") )
var ( // ErrReconnecting is returned when an operation is attempted during reconnection. ErrReconnecting = errors.New("client is reconnecting") // ErrShutdown is returned when an operation is attempted after shutdown. ErrShutdown = errors.New("client has been shut down") )
var ( // ErrSocketInUse is returned when the socket is already in use. ErrSocketInUse = errors.New("socket already in use") // ErrSocketNotFound is returned when the socket doesn't exist. ErrSocketNotFound = errors.New("socket not found") // ErrDaemonRunning is returned when another daemon is already running. ErrDaemonRunning = errors.New("daemon already running") )
var BuildTime = ""
BuildTime is the build timestamp (RFC3339 format). Set at build time with: -ldflags "-X github.com/standardbeagle/agnt/internal/daemon.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
var GitCommit = ""
GitCommit is the git commit hash. Set at build time with: -ldflags "-X github.com/standardbeagle/agnt/internal/daemon.GitCommit=$(git rev-parse HEAD)"
var Version = "0.7.1"
Version is the daemon version. Can be overridden at build time with: -ldflags "-X github.com/standardbeagle/agnt/internal/daemon.Version=x.y.z"
Functions ¶
func CleanupZombieDaemons ¶
CleanupZombieDaemons finds and kills any zombie daemon processes that aren't responding on their socket. This is called during startup to clean up any leftover processes from previous runs.
func CompareVersions ¶ added in v0.6.6
CompareVersions compares two semantic version strings. Returns:
- -1 if a < b
- 0 if a == b
- 1 if a > b
- error if either version is invalid
func DefaultSocketPath ¶
func DefaultSocketPath() string
DefaultSocketPath returns the default socket path for the current platform.
func DefaultStatePath ¶
func DefaultStatePath() string
DefaultStatePath returns the default state file path.
func FormatVersion ¶ added in v0.6.6
FormatVersion formats a version with the "v" prefix. Example: "0.6.5" → "v0.6.5"
func IsDaemonRunning ¶
IsDaemonRunning checks if the daemon is running at the given socket path.
func ParseVersion ¶ added in v0.6.6
ParseVersion parses a semantic version string (e.g., "0.6.5" or "v0.6.5") and returns the major, minor, and patch numbers. Returns an error if the version format is invalid.
func StopDaemon ¶
StopDaemon connects to a running daemon and requests shutdown.
func UpgradeDaemon ¶ added in v0.6.6
func UpgradeDaemon(ctx context.Context, config UpgradeConfig) error
UpgradeDaemon is a convenience function for upgrading the daemon. It creates a DaemonUpgrader with the given config and runs the upgrade.
func ValidateVersion ¶ added in v0.6.6
ValidateVersion checks if a version string is valid. Returns nil if valid, error otherwise.
func VersionsMatch ¶ added in v0.6.6
VersionsMatch checks if two versions are exactly equal. Returns true if versions match, false otherwise. Handles "v" prefix gracefully (v0.6.5 == 0.6.5).
Types ¶
type AutoStartClient ¶
type AutoStartClient struct {
*Client
// contains filtered or unexported fields
}
AutoStartClient creates a client that auto-starts the daemon if needed.
func NewAutoStartClient ¶
func NewAutoStartClient(config AutoStartConfig) *AutoStartClient
NewAutoStartClient creates a new auto-start client.
func (*AutoStartClient) Connect ¶
func (c *AutoStartClient) Connect() error
Connect connects to the daemon, starting it if necessary.
type AutoStartConfig ¶
type AutoStartConfig struct {
// SocketPath is the socket path to connect to.
SocketPath string
// DaemonPath is the path to the daemon executable.
DaemonPath string
// StartTimeout is how long to wait for the daemon to start.
StartTimeout time.Duration
// RetryInterval is how long to wait between connection attempts.
RetryInterval time.Duration
// MaxRetries is the maximum number of connection attempts.
MaxRetries int
}
AutoStartConfig holds configuration for auto-starting the daemon.
func DefaultAutoStartConfig ¶
func DefaultAutoStartConfig() AutoStartConfig
DefaultAutoStartConfig returns sensible defaults.
type BufferedWriter ¶
type BufferedWriter struct {
// contains filtered or unexported fields
}
BufferedWriter wraps a connection with buffered writing.
func NewBufferedWriter ¶
func NewBufferedWriter(conn net.Conn) *BufferedWriter
NewBufferedWriter creates a buffered writer for a connection.
func (*BufferedWriter) Flush ¶
func (w *BufferedWriter) Flush() error
Flush flushes the buffer to the connection.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for communicating with the daemon over the socket.
func EnsureDaemonRunning ¶
func EnsureDaemonRunning(config AutoStartConfig) (*Client, error)
EnsureDaemonRunning ensures the daemon is running, starting it if needed. Returns a connected client.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new daemon client.
func (*Client) BroadcastActivity ¶
BroadcastActivity broadcasts an activity state update to connected browsers via specified proxies. If proxyIDs is empty, broadcasts to all proxies (backward compatibility).
func (*Client) ChaosAddRule ¶
func (c *Client) ChaosAddRule(proxyID string, rule protocol.ChaosRuleConfig) (map[string]interface{}, error)
ChaosAddRule adds a single rule to a proxy's chaos engine.
func (*Client) ChaosClear ¶
ChaosClear clears all chaos rules and resets stats for a proxy.
func (*Client) ChaosDisable ¶
ChaosDisable disables chaos injection on a proxy.
func (*Client) ChaosEnable ¶
ChaosEnable enables chaos injection on a proxy.
func (*Client) ChaosListPresets ¶
ChaosListPresets returns the list of available chaos presets.
func (*Client) ChaosListRules ¶
ChaosListRules lists all chaos rules for a proxy.
func (*Client) ChaosPreset ¶
ChaosPreset applies a preset chaos configuration to a proxy.
func (*Client) ChaosRemoveRule ¶
ChaosRemoveRule removes a rule from a proxy's chaos engine.
func (*Client) ChaosSet ¶
func (c *Client) ChaosSet(proxyID string, config protocol.ChaosConfigPayload) (map[string]interface{}, error)
ChaosSet sets the full chaos configuration on a proxy.
func (*Client) ChaosStats ¶
ChaosStats gets chaos statistics for a proxy.
func (*Client) ChaosStatus ¶
ChaosStatus gets the chaos status of a proxy.
func (*Client) CurrentPageClear ¶
CurrentPageClear clears page sessions.
func (*Client) CurrentPageGet ¶
CurrentPageGet gets details for a specific page session.
func (*Client) CurrentPageList ¶
CurrentPageList lists active page sessions.
func (*Client) Info ¶
func (c *Client) Info() (*DaemonInfo, error)
Info retrieves daemon information.
func (*Client) IsConnected ¶
IsConnected returns whether the client is connected.
func (*Client) OverlayClear ¶
OverlayClear clears the overlay endpoint configuration.
func (*Client) OverlayGet ¶
OverlayGet gets the current overlay endpoint configuration.
func (*Client) OverlaySet ¶
OverlaySet sets the overlay endpoint URL. The endpoint should be the full URL, e.g., "http://127.0.0.1:19191".
func (*Client) ProcCleanupPort ¶
ProcCleanupPort kills processes on a specific port.
func (*Client) ProcList ¶
func (c *Client) ProcList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
ProcList lists all processes.
func (*Client) ProcOutput ¶
ProcOutput gets the output of a process.
func (*Client) ProcStatus ¶
ProcStatus gets the status of a process.
func (*Client) ProxyList ¶
func (c *Client) ProxyList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
ProxyList lists all proxies.
func (*Client) ProxyLogClear ¶
ProxyLogClear clears proxy logs.
func (*Client) ProxyLogQuery ¶
func (c *Client) ProxyLogQuery(proxyID string, filter protocol.LogQueryFilter) (map[string]interface{}, error)
ProxyLogQuery queries proxy logs.
func (*Client) ProxyLogStats ¶
ProxyLogStats gets proxy log statistics.
func (*Client) ProxyStart ¶
func (c *Client) ProxyStart(id, targetURL string, port, maxLogSize int, path string) (map[string]interface{}, error)
ProxyStart starts a reverse proxy.
func (*Client) ProxyStartWithConfig ¶
func (c *Client) ProxyStartWithConfig(id, targetURL string, port, maxLogSize int, config ProxyStartConfig) (map[string]interface{}, error)
ProxyStartWithConfig starts a reverse proxy with extended configuration.
func (*Client) ProxyStatus ¶
ProxyStatus gets the status of a proxy.
func (*Client) ProxyToast ¶
ProxyToast sends a toast notification to connected browsers.
func (*Client) SessionCancel ¶ added in v0.7.0
SessionCancel cancels a scheduled task.
func (*Client) SessionGenerateCode ¶ added in v0.7.0
SessionGenerateCode requests a new session code from the daemon. This is used when auto-generating session codes based on command name.
func (*Client) SessionGet ¶ added in v0.7.0
SessionGet retrieves a specific session.
func (*Client) SessionHeartbeat ¶ added in v0.7.0
SessionHeartbeat sends a heartbeat for a session.
func (*Client) SessionList ¶ added in v0.7.0
func (c *Client) SessionList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
SessionList lists active sessions.
func (*Client) SessionRegister ¶ added in v0.7.0
func (c *Client) SessionRegister(code string, overlayPath string, projectPath string, command string, args []string) (map[string]interface{}, error)
SessionRegister registers a new session with the daemon.
func (*Client) SessionSchedule ¶ added in v0.7.0
func (c *Client) SessionSchedule(code string, duration string, message string) (map[string]interface{}, error)
SessionSchedule schedules a message for future delivery.
func (*Client) SessionSend ¶ added in v0.7.0
SessionSend sends an immediate message to a session.
func (*Client) SessionTasks ¶ added in v0.7.0
func (c *Client) SessionTasks(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
SessionTasks lists scheduled tasks.
func (*Client) SessionUnregister ¶ added in v0.7.0
SessionUnregister unregisters a session from the daemon.
func (*Client) TunnelList ¶
TunnelList lists all active tunnels.
func (*Client) TunnelStart ¶
func (c *Client) TunnelStart(config protocol.TunnelStartConfig) (map[string]interface{}, error)
TunnelStart starts a tunnel for a local port.
func (*Client) TunnelStatus ¶
TunnelStatus gets the status of a tunnel.
func (*Client) TunnelStop ¶
TunnelStop stops a running tunnel.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithSocketPath ¶
func WithSocketPath(path string) ClientOption
WithSocketPath sets the socket path for the client.
func WithTimeout ¶
func WithTimeout(d time.Duration) ClientOption
WithTimeout sets the default timeout for operations.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a client connection to the daemon.
func (*Connection) Handle ¶
func (c *Connection) Handle(ctx context.Context)
Handle processes commands from the client until disconnect or error.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the main daemon process that manages state across client connections.
func (*Daemon) GetSession ¶ added in v0.7.0
GetSession retrieves a session by code.
func (*Daemon) OverlayEndpoint ¶
OverlayEndpoint returns the current overlay endpoint URL, or empty string if not set.
func (*Daemon) ProcessManager ¶
func (d *Daemon) ProcessManager() *process.ProcessManager
ProcessManager returns the process manager.
func (*Daemon) ProxyManager ¶
func (d *Daemon) ProxyManager() *proxy.ProxyManager
ProxyManager returns the proxy manager.
func (*Daemon) SessionRegistry ¶ added in v0.7.0
func (d *Daemon) SessionRegistry() *SessionRegistry
SessionRegistry returns the session registry.
func (*Daemon) SetOverlayEndpoint ¶
SetOverlayEndpoint sets the overlay endpoint URL and updates all existing proxies. The endpoint should be the full URL, e.g., "http://127.0.0.1:19191". Pass an empty string to disable overlay forwarding.
func (*Daemon) StateManager ¶
func (d *Daemon) StateManager() *StateManager
StateManager returns the state manager (may be nil if persistence is disabled).
func (*Daemon) TunnelManager ¶
TunnelManager returns the tunnel manager.
type DaemonConfig ¶
type DaemonConfig struct {
// Socket configuration
SocketPath string
// Process manager configuration
ProcessConfig process.ManagerConfig
// Max concurrent clients (0 = unlimited)
MaxClients int
// Connection read timeout (0 = no timeout)
ReadTimeout time.Duration
// Connection write timeout (0 = no timeout)
WriteTimeout time.Duration
// OverlayEndpoint is the URL of the agnt overlay server for forwarding events.
// Example: "http://127.0.0.1:19191"
// When set, proxies will forward panel messages, sketches, etc. to the overlay.
OverlayEndpoint string
// EnableStatePersistence enables persisting proxy configs for recovery.
EnableStatePersistence bool
// StatePath is the path to the state file.
// If empty, uses default location.
StatePath string
// EnableUpdateCheck enables periodic update checking.
// Default: true
EnableUpdateCheck bool
// UpdateCheckInterval is the interval between update checks.
// Default: 24 hours
UpdateCheckInterval time.Duration
}
DaemonConfig holds configuration for the daemon.
func DefaultDaemonConfig ¶
func DefaultDaemonConfig() DaemonConfig
DefaultDaemonConfig returns sensible defaults.
type DaemonInfo ¶
type DaemonInfo struct {
Version string `json:"version"`
BuildTime string `json:"build_time,omitempty"` // Build timestamp (RFC3339)
GitCommit string `json:"git_commit,omitempty"` // Git commit hash
SocketPath string `json:"socket_path"`
Uptime time.Duration `json:"uptime"`
ClientCount int64 `json:"client_count"`
ProcessInfo ProcessInfo `json:"process_info"`
ProxyInfo ProxyInfo `json:"proxy_info"`
TunnelInfo TunnelInfo `json:"tunnel_info"`
SessionInfo SessionInfo `json:"session_info"`
SchedulerInfo SchedulerInfo `json:"scheduler_info"`
UpdateInfo *updater.UpdateInfo `json:"update_info,omitempty"` // Update availability info
}
DaemonInfo holds daemon status information.
type DaemonUpgrader ¶ added in v0.6.6
type DaemonUpgrader struct {
// contains filtered or unexported fields
}
DaemonUpgrader handles atomic daemon upgrades with locking.
func NewDaemonUpgrader ¶ added in v0.6.6
func NewDaemonUpgrader(config UpgradeConfig) *DaemonUpgrader
NewDaemonUpgrader creates a new daemon upgrader.
func (*DaemonUpgrader) Upgrade ¶ added in v0.6.6
func (u *DaemonUpgrader) Upgrade(ctx context.Context) error
Upgrade performs an atomic daemon upgrade with the following steps:
- Acquire upgrade lock (prevents concurrent upgrades)
- Connect to running daemon and get current version
- Request graceful shutdown (stops all processes)
- Wait for daemon to exit
- Clean up stale socket/PID files
- Start new daemon binary
- Wait for new daemon to be ready
- Verify new daemon version
- Release upgrade lock
type PersistedTaskState ¶ added in v0.7.0
type PersistedTaskState struct {
Version int `json:"version"`
Tasks []*ScheduledTask `json:"tasks"`
UpdatedAt string `json:"updated_at"`
}
PersistedTaskState represents the structure of the task state file.
type PersistentProxyConfig ¶
type PersistentProxyConfig struct {
ID string `json:"id"`
TargetURL string `json:"target_url"`
Port int `json:"port"`
MaxLogSize int `json:"max_log_size"`
Path string `json:"path"`
CreatedAt string `json:"created_at"`
}
PersistentProxyConfig stores the configuration needed to recreate a proxy.
type PersistentState ¶
type PersistentState struct {
Version int `json:"version"`
OverlayEndpoint string `json:"overlay_endpoint,omitempty"`
Proxies []PersistentProxyConfig `json:"proxies,omitempty"`
UpdatedAt string `json:"updated_at"`
}
PersistentState stores daemon state that should survive restarts.
type ProcessInfo ¶
type ProcessInfo struct {
Active int64 `json:"active"`
TotalStarted int64 `json:"total_started"`
TotalFailed int64 `json:"total_failed"`
}
ProcessInfo holds process manager statistics.
type ProxyStartConfig ¶
type ProxyStartConfig struct {
Path string `json:"path,omitempty"`
BindAddress string `json:"bind_address,omitempty"`
PublicURL string `json:"public_url,omitempty"`
VerifyTLS bool `json:"verify_tls,omitempty"`
Tunnel *protocol.TunnelConfig `json:"tunnel,omitempty"`
}
ProxyStartConfig holds configuration for starting a proxy.
type ReconnectCallback ¶
ReconnectCallback is called after successful reconnection. It should restore any state that needs to be re-registered with the daemon.
type ResilientClient ¶
type ResilientClient struct {
// contains filtered or unexported fields
}
ResilientClient wraps Client with automatic reconnection and health monitoring.
func NewResilientClient ¶
func NewResilientClient(config ResilientClientConfig) *ResilientClient
NewResilientClient creates a new resilient client.
func (*ResilientClient) BroadcastActivity ¶
func (rc *ResilientClient) BroadcastActivity(active bool, proxyIDs ...string) error
BroadcastActivity sends an activity state update to connected browsers via specified proxies. If proxyIDs is empty, broadcasts to all proxies (backward compatibility).
func (*ResilientClient) ChaosAddRule ¶ added in v0.6.6
func (rc *ResilientClient) ChaosAddRule(proxyID string, rule protocol.ChaosRuleConfig) (map[string]interface{}, error)
ChaosAddRule adds a single rule to a proxy's chaos engine.
func (*ResilientClient) ChaosClear ¶ added in v0.6.6
func (rc *ResilientClient) ChaosClear(proxyID string) (map[string]interface{}, error)
ChaosClear clears all chaos rules and resets stats for a proxy.
func (*ResilientClient) ChaosDisable ¶ added in v0.6.6
func (rc *ResilientClient) ChaosDisable(proxyID string) (map[string]interface{}, error)
ChaosDisable disables chaos injection on a proxy.
func (*ResilientClient) ChaosEnable ¶ added in v0.6.6
func (rc *ResilientClient) ChaosEnable(proxyID string) (map[string]interface{}, error)
ChaosEnable enables chaos injection on a proxy.
func (*ResilientClient) ChaosListPresets ¶ added in v0.6.6
func (rc *ResilientClient) ChaosListPresets() (map[string]interface{}, error)
ChaosListPresets returns the list of available chaos presets.
func (*ResilientClient) ChaosListRules ¶ added in v0.6.6
func (rc *ResilientClient) ChaosListRules(proxyID string) (map[string]interface{}, error)
ChaosListRules lists all chaos rules for a proxy.
func (*ResilientClient) ChaosPreset ¶ added in v0.6.6
func (rc *ResilientClient) ChaosPreset(proxyID, preset string) (map[string]interface{}, error)
ChaosPreset applies a preset chaos configuration to a proxy.
func (*ResilientClient) ChaosRemoveRule ¶ added in v0.6.6
func (rc *ResilientClient) ChaosRemoveRule(proxyID, ruleID string) (map[string]interface{}, error)
ChaosRemoveRule removes a rule from a proxy's chaos engine.
func (*ResilientClient) ChaosSet ¶ added in v0.6.6
func (rc *ResilientClient) ChaosSet(proxyID string, config protocol.ChaosConfigPayload) (map[string]interface{}, error)
ChaosSet sets the full chaos configuration on a proxy.
func (*ResilientClient) ChaosStats ¶ added in v0.6.6
func (rc *ResilientClient) ChaosStats(proxyID string) (map[string]interface{}, error)
ChaosStats gets chaos statistics for a proxy.
func (*ResilientClient) ChaosStatus ¶ added in v0.6.6
func (rc *ResilientClient) ChaosStatus(proxyID string) (map[string]interface{}, error)
ChaosStatus gets the chaos status of a proxy.
func (*ResilientClient) Client ¶
func (rc *ResilientClient) Client() *Client
Client returns the underlying client for direct access. Returns nil if not connected.
func (*ResilientClient) Close ¶
func (rc *ResilientClient) Close() error
Close shuts down the resilient client.
func (*ResilientClient) Connect ¶
func (rc *ResilientClient) Connect() error
Connect establishes the initial connection to the daemon.
func (*ResilientClient) CurrentPageClear ¶ added in v0.6.6
func (rc *ResilientClient) CurrentPageClear(proxyID string) error
CurrentPageClear clears page sessions.
func (*ResilientClient) CurrentPageGet ¶ added in v0.6.6
func (rc *ResilientClient) CurrentPageGet(proxyID, sessionID string) (map[string]interface{}, error)
CurrentPageGet gets details for a specific page session.
func (*ResilientClient) CurrentPageList ¶ added in v0.6.6
func (rc *ResilientClient) CurrentPageList(proxyID string) (map[string]interface{}, error)
CurrentPageList lists active page sessions.
func (*ResilientClient) Detect ¶ added in v0.6.6
func (rc *ResilientClient) Detect(path string) (map[string]interface{}, error)
Detect detects the project type at the given path.
func (*ResilientClient) Info ¶
func (rc *ResilientClient) Info() (*DaemonInfo, error)
Info retrieves daemon information.
func (*ResilientClient) IsConnected ¶
func (rc *ResilientClient) IsConnected() bool
IsConnected returns whether the client is currently connected.
func (*ResilientClient) IsReconnecting ¶
func (rc *ResilientClient) IsReconnecting() bool
IsReconnecting returns whether the client is currently reconnecting.
func (*ResilientClient) OverlaySet ¶
func (rc *ResilientClient) OverlaySet(endpoint string) (map[string]interface{}, error)
OverlaySet sets the overlay endpoint.
func (*ResilientClient) Ping ¶
func (rc *ResilientClient) Ping() error
Ping sends a ping to the daemon.
func (*ResilientClient) ProcCleanupPort ¶ added in v0.6.6
func (rc *ResilientClient) ProcCleanupPort(port int) (map[string]interface{}, error)
ProcCleanupPort kills processes on a specific port.
func (*ResilientClient) ProcList ¶ added in v0.6.6
func (rc *ResilientClient) ProcList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
ProcList lists all processes.
func (*ResilientClient) ProcOutput ¶ added in v0.6.6
func (rc *ResilientClient) ProcOutput(processID string, filter protocol.OutputFilter) (string, error)
ProcOutput gets the output of a process.
func (*ResilientClient) ProcStatus ¶ added in v0.6.6
func (rc *ResilientClient) ProcStatus(processID string) (map[string]interface{}, error)
ProcStatus gets the status of a process.
func (*ResilientClient) ProcStop ¶ added in v0.6.6
func (rc *ResilientClient) ProcStop(processID string, force bool) (map[string]interface{}, error)
ProcStop stops a process.
func (*ResilientClient) ProxyExec ¶ added in v0.6.6
func (rc *ResilientClient) ProxyExec(id, code string) (map[string]interface{}, error)
ProxyExec executes JavaScript in connected browsers.
func (*ResilientClient) ProxyList ¶
func (rc *ResilientClient) ProxyList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
ProxyList lists all proxies.
func (*ResilientClient) ProxyLogClear ¶ added in v0.6.6
func (rc *ResilientClient) ProxyLogClear(proxyID string) error
ProxyLogClear clears proxy logs.
func (*ResilientClient) ProxyLogQuery ¶ added in v0.6.6
func (rc *ResilientClient) ProxyLogQuery(proxyID string, filter protocol.LogQueryFilter) (map[string]interface{}, error)
ProxyLogQuery queries proxy logs.
func (*ResilientClient) ProxyLogStats ¶ added in v0.6.6
func (rc *ResilientClient) ProxyLogStats(proxyID string) (map[string]interface{}, error)
ProxyLogStats gets proxy log statistics.
func (*ResilientClient) ProxyStart ¶
func (rc *ResilientClient) ProxyStart(id, targetURL string, port, maxLogSize int, path string) (map[string]interface{}, error)
ProxyStart starts a reverse proxy.
func (*ResilientClient) ProxyStartWithConfig ¶ added in v0.6.6
func (rc *ResilientClient) ProxyStartWithConfig(id, targetURL string, port, maxLogSize int, config ProxyStartConfig) (map[string]interface{}, error)
ProxyStartWithConfig starts a reverse proxy with extended configuration.
func (*ResilientClient) ProxyStatus ¶ added in v0.6.6
func (rc *ResilientClient) ProxyStatus(id string) (map[string]interface{}, error)
ProxyStatus gets the status of a proxy.
func (*ResilientClient) ProxyStop ¶
func (rc *ResilientClient) ProxyStop(id string) error
ProxyStop stops a reverse proxy.
func (*ResilientClient) ProxyToast ¶ added in v0.6.6
func (rc *ResilientClient) ProxyToast(id string, toast protocol.ToastConfig) (map[string]interface{}, error)
ProxyToast sends a toast notification to connected browsers.
func (*ResilientClient) Run ¶ added in v0.6.6
func (rc *ResilientClient) Run(config protocol.RunConfig) (map[string]interface{}, error)
Run starts a process on the daemon.
func (*ResilientClient) SessionCancel ¶ added in v0.7.0
func (rc *ResilientClient) SessionCancel(taskID string) error
SessionCancel cancels a scheduled task.
func (*ResilientClient) SessionGenerateCode ¶ added in v0.7.0
func (rc *ResilientClient) SessionGenerateCode(command string) (string, error)
SessionGenerateCode generates a unique session code for a command.
func (*ResilientClient) SessionGet ¶ added in v0.7.0
func (rc *ResilientClient) SessionGet(code string) (map[string]interface{}, error)
SessionGet retrieves details for a specific session.
func (*ResilientClient) SessionHeartbeat ¶ added in v0.7.0
func (rc *ResilientClient) SessionHeartbeat(code string) error
SessionHeartbeat sends a heartbeat for a session.
func (*ResilientClient) SessionList ¶ added in v0.7.0
func (rc *ResilientClient) SessionList(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
SessionList lists sessions, optionally filtered by directory.
func (*ResilientClient) SessionRegister ¶ added in v0.7.0
func (rc *ResilientClient) SessionRegister(code, overlayPath, projectPath, command string, args []string) (map[string]interface{}, error)
SessionRegister registers a new session with the daemon.
func (*ResilientClient) SessionSchedule ¶ added in v0.7.0
func (rc *ResilientClient) SessionSchedule(code, duration, message string) (map[string]interface{}, error)
SessionSchedule schedules a message for future delivery.
func (*ResilientClient) SessionSend ¶ added in v0.7.0
func (rc *ResilientClient) SessionSend(code, message string) (map[string]interface{}, error)
SessionSend sends a message to a session immediately.
func (*ResilientClient) SessionTasks ¶ added in v0.7.0
func (rc *ResilientClient) SessionTasks(dirFilter protocol.DirectoryFilter) (map[string]interface{}, error)
SessionTasks lists scheduled tasks, optionally filtered by directory.
func (*ResilientClient) SessionUnregister ¶ added in v0.7.0
func (rc *ResilientClient) SessionUnregister(code string) error
SessionUnregister unregisters a session.
func (*ResilientClient) Stats ¶
func (rc *ResilientClient) Stats() map[string]interface{}
Stats returns connection statistics.
func (*ResilientClient) TunnelList ¶ added in v0.6.6
func (rc *ResilientClient) TunnelList() (map[string]interface{}, error)
TunnelList lists all active tunnels.
func (*ResilientClient) TunnelStart ¶ added in v0.6.6
func (rc *ResilientClient) TunnelStart(config protocol.TunnelStartConfig) (map[string]interface{}, error)
TunnelStart starts a tunnel for a local port.
func (*ResilientClient) TunnelStatus ¶ added in v0.6.6
func (rc *ResilientClient) TunnelStatus(id string) (map[string]interface{}, error)
TunnelStatus gets the status of a tunnel.
func (*ResilientClient) TunnelStop ¶ added in v0.6.6
func (rc *ResilientClient) TunnelStop(id string) error
TunnelStop stops a running tunnel.
func (*ResilientClient) WithClient ¶
func (rc *ResilientClient) WithClient(fn func(*Client) error) error
WithClient executes a function with the client, handling reconnection.
type ResilientClientConfig ¶
type ResilientClientConfig struct {
// AutoStartConfig for daemon auto-start
AutoStartConfig AutoStartConfig
// HeartbeatInterval is how often to send heartbeats (0 disables)
HeartbeatInterval time.Duration
// HeartbeatTimeout is how long to wait for heartbeat response
HeartbeatTimeout time.Duration
// ReconnectBackoffMin is the minimum backoff between reconnection attempts
ReconnectBackoffMin time.Duration
// ReconnectBackoffMax is the maximum backoff between reconnection attempts
ReconnectBackoffMax time.Duration
// MaxReconnectAttempts limits reconnection attempts (0 = unlimited)
MaxReconnectAttempts int
// OnReconnect is called after successful reconnection
OnReconnect ReconnectCallback
// OnDisconnect is called when connection is lost
OnDisconnect func(err error)
// OnReconnectFailed is called when reconnection fails permanently
OnReconnectFailed func(err error)
// ClientVersion is the expected daemon version (strict matching).
// If empty, version checking is skipped.
ClientVersion string
// OnVersionMismatch is called when client and daemon versions don't match.
// If nil and versions mismatch, Connect() returns an error.
// If non-nil, the callback can handle the mismatch (e.g., trigger upgrade).
// Return nil to proceed with mismatched versions, or error to fail connection.
OnVersionMismatch func(clientVer, daemonVer string) error
}
ResilientClientConfig configures a ResilientClient.
func DefaultResilientClientConfig ¶
func DefaultResilientClientConfig() ResilientClientConfig
DefaultResilientClientConfig returns sensible defaults.
type ScheduledTask ¶ added in v0.7.0
type ScheduledTask struct {
ID string `json:"id"` // Unique task ID (e.g., "task-abc123")
SessionCode string `json:"session_code"` // Target session
Message string `json:"message"` // Message to deliver
DeliverAt time.Time `json:"deliver_at"` // Scheduled delivery time
CreatedAt time.Time `json:"created_at"` // When task was created
ProjectPath string `json:"project_path"` // For project-scoped filtering
Status TaskStatus `json:"status"` // Current status
Attempts int `json:"attempts"` // Delivery attempts
LastError string `json:"last_error,omitempty"` // Last delivery error
}
ScheduledTask represents a message scheduled for future delivery.
func (*ScheduledTask) ToJSON ¶ added in v0.7.0
func (t *ScheduledTask) ToJSON() map[string]interface{}
ToJSON returns the task as a JSON-serializable map.
type Scheduler ¶ added in v0.7.0
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages scheduled message delivery.
func NewScheduler ¶ added in v0.7.0
func NewScheduler(config SchedulerConfig, registry *SessionRegistry, stateMgr *SchedulerStateManager) *Scheduler
NewScheduler creates a new scheduler.
func (*Scheduler) GetTask ¶ added in v0.7.0
func (s *Scheduler) GetTask(taskID string) (*ScheduledTask, bool)
GetTask retrieves a task by ID.
func (*Scheduler) Info ¶ added in v0.7.0
func (s *Scheduler) Info() SchedulerInfo
Info returns statistics about the scheduler.
func (*Scheduler) ListPendingTasks ¶ added in v0.7.0
func (s *Scheduler) ListPendingTasks(projectPath string, global bool) []*ScheduledTask
ListPendingTasks returns only pending tasks.
func (*Scheduler) ListTasks ¶ added in v0.7.0
func (s *Scheduler) ListTasks(projectPath string, global bool) []*ScheduledTask
ListTasks returns all tasks, optionally filtered by project path.
func (*Scheduler) Schedule ¶ added in v0.7.0
func (s *Scheduler) Schedule(sessionCode string, duration time.Duration, message string, projectPath string) (*ScheduledTask, error)
Schedule adds a new task to the scheduler.
type SchedulerConfig ¶ added in v0.7.0
type SchedulerConfig struct {
// TickInterval is how often the scheduler checks for due tasks.
TickInterval time.Duration
// MaxRetries is the maximum number of delivery attempts.
MaxRetries int
// RetryDelay is the base delay between retries (exponential backoff).
RetryDelay time.Duration
// DeliveryTimeout is the timeout for each delivery attempt.
DeliveryTimeout time.Duration
}
SchedulerConfig configures the scheduler.
func DefaultSchedulerConfig ¶ added in v0.7.0
func DefaultSchedulerConfig() SchedulerConfig
DefaultSchedulerConfig returns sensible defaults.
type SchedulerInfo ¶ added in v0.7.0
type SchedulerInfo struct {
TotalScheduled int64 `json:"total_scheduled"`
TotalDelivered int64 `json:"total_delivered"`
TotalFailed int64 `json:"total_failed"`
TotalCancelled int64 `json:"total_cancelled"`
PendingCount int64 `json:"pending_count"`
}
SchedulerInfo contains statistics about the scheduler.
type SchedulerStateManager ¶ added in v0.7.0
type SchedulerStateManager struct {
// contains filtered or unexported fields
}
SchedulerStateManager handles persisting scheduled tasks per-project.
func NewSchedulerStateManager ¶ added in v0.7.0
func NewSchedulerStateManager() *SchedulerStateManager
NewSchedulerStateManager creates a new scheduler state manager.
func (*SchedulerStateManager) ClearProject ¶ added in v0.7.0
func (m *SchedulerStateManager) ClearProject(projectPath string) error
ClearProject removes all tasks for a project.
func (*SchedulerStateManager) ListProjectsWithTasks ¶ added in v0.7.0
func (m *SchedulerStateManager) ListProjectsWithTasks() []string
ListProjectsWithTasks returns all known project directories with tasks.
func (*SchedulerStateManager) LoadAllTasks ¶ added in v0.7.0
func (m *SchedulerStateManager) LoadAllTasks() []*ScheduledTask
LoadAllTasks loads all tasks from all known project directories.
func (*SchedulerStateManager) LoadTasks ¶ added in v0.7.0
func (m *SchedulerStateManager) LoadTasks(projectPath string) ([]*ScheduledTask, error)
LoadTasks loads all tasks for a specific project.
func (*SchedulerStateManager) RegisterProject ¶ added in v0.7.0
func (m *SchedulerStateManager) RegisterProject(projectPath string)
RegisterProject registers a project directory for task tracking.
func (*SchedulerStateManager) RemoveTask ¶ added in v0.7.0
func (m *SchedulerStateManager) RemoveTask(taskID string, projectPath string) error
RemoveTask removes a task from the project's state file.
func (*SchedulerStateManager) SaveTask ¶ added in v0.7.0
func (m *SchedulerStateManager) SaveTask(task *ScheduledTask) error
SaveTask saves or updates a task in the project's state file.
func (*SchedulerStateManager) ScanForProjects ¶ added in v0.7.0
func (m *SchedulerStateManager) ScanForProjects(basePaths []string)
ScanForProjects scans directories for existing task state files. This is called at daemon startup to discover persisted tasks.
type Session ¶ added in v0.7.0
type Session struct {
Code string `json:"code"` // Unique session identifier (e.g., "claude-1", "dev")
OverlayPath string `json:"overlay_path"` // Unix socket path for overlay
ProjectPath string `json:"project_path"` // Directory where session was started
Command string `json:"command"` // Command being run (e.g., "claude")
Args []string `json:"args"` // Command arguments
StartedAt time.Time `json:"started_at"` // When session started
Status SessionStatus `json:"status"` // Current status
LastSeen time.Time `json:"last_seen"` // Last heartbeat timestamp
// contains filtered or unexported fields
}
Session represents an active agnt run instance.
func (*Session) GetStatus ¶ added in v0.7.0
func (s *Session) GetStatus() SessionStatus
GetStatus returns the current session status.
func (*Session) IsActive ¶ added in v0.7.0
IsActive returns true if the session is currently active.
func (*Session) MarshalJSON ¶ added in v0.7.0
MarshalJSON implements json.Marshaler for Session.
func (*Session) SetStatus ¶ added in v0.7.0
func (s *Session) SetStatus(status SessionStatus)
SetStatus updates the session status.
func (*Session) UpdateLastSeen ¶ added in v0.7.0
func (s *Session) UpdateLastSeen()
UpdateLastSeen updates the last seen timestamp and sets status to active.
type SessionInfo ¶ added in v0.7.0
type SessionInfo struct {
ActiveCount int64 `json:"active_count"`
TotalRegistered int64 `json:"total_registered"`
TotalUnregistered int64 `json:"total_unregistered"`
}
SessionInfo contains statistics about the session registry.
type SessionRegistry ¶ added in v0.7.0
type SessionRegistry struct {
// contains filtered or unexported fields
}
SessionRegistry manages active sessions with lock-free operations.
func NewSessionRegistry ¶ added in v0.7.0
func NewSessionRegistry(heartbeatTimeout time.Duration) *SessionRegistry
NewSessionRegistry creates a new session registry.
func (*SessionRegistry) ActiveCount ¶ added in v0.7.0
func (r *SessionRegistry) ActiveCount() int64
ActiveCount returns the number of active sessions.
func (*SessionRegistry) CheckHeartbeats ¶ added in v0.7.0
func (r *SessionRegistry) CheckHeartbeats()
CheckHeartbeats marks sessions as disconnected if they haven't sent a heartbeat recently.
func (*SessionRegistry) GenerateSessionCode ¶ added in v0.7.0
func (r *SessionRegistry) GenerateSessionCode(command string) string
GenerateSessionCode generates a unique session code based on command name. Returns codes like "claude-1", "claude-2", etc.
func (*SessionRegistry) Get ¶ added in v0.7.0
func (r *SessionRegistry) Get(code string) (*Session, bool)
Get retrieves a session by code.
func (*SessionRegistry) Heartbeat ¶ added in v0.7.0
func (r *SessionRegistry) Heartbeat(code string) error
Heartbeat updates the last seen time for a session.
func (*SessionRegistry) Info ¶ added in v0.7.0
func (r *SessionRegistry) Info() SessionInfo
Info returns statistics about the session registry.
func (*SessionRegistry) List ¶ added in v0.7.0
func (r *SessionRegistry) List(projectPath string, global bool) []*Session
List returns all sessions, optionally filtered by project path.
func (*SessionRegistry) ListActive ¶ added in v0.7.0
func (r *SessionRegistry) ListActive(projectPath string, global bool) []*Session
ListActive returns only active sessions.
func (*SessionRegistry) Register ¶ added in v0.7.0
func (r *SessionRegistry) Register(session *Session) error
Register adds a new session to the registry.
func (*SessionRegistry) TotalRegistered ¶ added in v0.7.0
func (r *SessionRegistry) TotalRegistered() int64
TotalRegistered returns the total number of sessions registered.
func (*SessionRegistry) TotalUnregistered ¶ added in v0.7.0
func (r *SessionRegistry) TotalUnregistered() int64
TotalUnregistered returns the total number of sessions unregistered.
func (*SessionRegistry) Unregister ¶ added in v0.7.0
func (r *SessionRegistry) Unregister(code string) error
Unregister removes a session from the registry.
type SessionStatus ¶ added in v0.7.0
type SessionStatus string
SessionStatus represents the current state of a session.
const ( // SessionStatusActive indicates the session is running and responsive. SessionStatusActive SessionStatus = "active" // SessionStatusDisconnected indicates the session has not sent a heartbeat recently. SessionStatusDisconnected SessionStatus = "disconnected" )
type SocketConfig ¶
type SocketConfig struct {
// Path is the socket file path. If empty, uses default path.
Path string
// Mode is the socket file permissions (default 0600).
Mode os.FileMode
}
SocketConfig holds configuration for socket management.
func DefaultSocketConfig ¶
func DefaultSocketConfig() SocketConfig
DefaultSocketConfig returns the default socket configuration.
type SocketManager ¶
type SocketManager struct {
// contains filtered or unexported fields
}
SocketManager handles Unix socket lifecycle.
func NewSocketManager ¶
func NewSocketManager(config SocketConfig) *SocketManager
NewSocketManager creates a new socket manager.
func (*SocketManager) Close ¶
func (sm *SocketManager) Close() error
Close closes the socket and removes the socket and PID files.
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager handles persisting and restoring daemon state.
func NewStateManager ¶
func NewStateManager(config StateManagerConfig) *StateManager
NewStateManager creates a new state manager.
func (*StateManager) AddProxy ¶
func (sm *StateManager) AddProxy(config PersistentProxyConfig)
AddProxy adds a proxy configuration to state.
func (*StateManager) Flush ¶
func (sm *StateManager) Flush() error
Flush ensures any pending saves are written immediately.
func (*StateManager) GetOverlayEndpoint ¶
func (sm *StateManager) GetOverlayEndpoint() string
GetOverlayEndpoint returns the persisted overlay endpoint.
func (*StateManager) GetProxies ¶
func (sm *StateManager) GetProxies() []PersistentProxyConfig
GetProxies returns all persisted proxy configurations.
func (*StateManager) GetProxy ¶
func (sm *StateManager) GetProxy(id string) (PersistentProxyConfig, bool)
GetProxy returns a specific proxy configuration.
func (*StateManager) RemoveProxy ¶
func (sm *StateManager) RemoveProxy(id string)
RemoveProxy removes a proxy configuration from state.
func (*StateManager) SaveDebounced ¶
func (sm *StateManager) SaveDebounced()
SaveDebounced saves state with debouncing to avoid excessive writes.
func (*StateManager) SetOverlayEndpoint ¶
func (sm *StateManager) SetOverlayEndpoint(endpoint string)
SetOverlayEndpoint updates the overlay endpoint in state.
func (*StateManager) State ¶
func (sm *StateManager) State() PersistentState
State returns a copy of the current state.
type StateManagerConfig ¶
type StateManagerConfig struct {
// StatePath is the path to the state file.
// If empty, uses default location.
StatePath string
// SaveInterval is the minimum time between saves (debouncing).
SaveInterval time.Duration
// AutoLoad loads state on creation if true.
AutoLoad bool
}
StateManagerConfig configures the state manager.
func DefaultStateManagerConfig ¶
func DefaultStateManagerConfig() StateManagerConfig
DefaultStateManagerConfig returns sensible defaults.
type TaskStatus ¶ added in v0.7.0
type TaskStatus string
TaskStatus represents the current state of a scheduled task.
const ( // TaskStatusPending indicates the task is waiting to be delivered. TaskStatusPending TaskStatus = "pending" // TaskStatusDelivered indicates the task was successfully delivered. TaskStatusDelivered TaskStatus = "delivered" // TaskStatusFailed indicates the task failed after max retries. TaskStatusFailed TaskStatus = "failed" // TaskStatusCancelled indicates the task was cancelled. TaskStatusCancelled TaskStatus = "cancelled" )
type TunnelInfo ¶
type TunnelInfo struct {
Active int64 `json:"active"`
}
TunnelInfo holds tunnel manager statistics.
type UpgradeConfig ¶ added in v0.6.6
type UpgradeConfig struct {
// SocketPath is the socket path to connect to the daemon.
// If empty, uses DefaultSocketPath().
SocketPath string
// NewBinaryPath is the path to the new daemon binary.
// If empty, uses the current executable.
NewBinaryPath string
// Timeout is the maximum time for the entire upgrade process.
// Default: 30 seconds.
Timeout time.Duration
// GracefulTimeout is the timeout for graceful daemon shutdown.
// Default: 5 seconds.
GracefulTimeout time.Duration
// Force bypasses version checks and performs upgrade even if versions match.
Force bool
// Verbose enables detailed logging during upgrade.
Verbose bool
}
UpgradeConfig holds configuration for daemon upgrades.
func DefaultUpgradeConfig ¶ added in v0.6.6
func DefaultUpgradeConfig() UpgradeConfig
DefaultUpgradeConfig returns sensible defaults.