daemon

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CheckInterval      time.Duration
	TokenThreshold     time.Duration
	NotificationsOn    bool
	AttentionThreshold time.Duration
	NotifyOn           []string
	QuietHoursStart    string
	QuietHoursEnd      string
	ContainerPrefix    string
	CreateContainer    func(task, parentContainer, branch string) (string, error) // Callback for IPC child creation
}

Config holds daemon configuration

type ContainerState

type ContainerState struct {
	Name                   string
	AttentionStarted       *time.Time
	LastNotified           *time.Time
	LastActivity           time.Time
	LastTokenCheck         time.Time
	NotificationSent       bool
	LastTaskCheck          time.Time
	HadOpenTasks           bool   // Whether container had incomplete tasks last check
	LastTaskProgress       string // Last seen task progress (e.g., "2/5")
	TaskCompletionNotified bool   // Whether we've notified about task completion
	LastIPCCheck           time.Time
	// contains filtered or unexported fields
}

ContainerState tracks container monitoring state

type Credentials

type Credentials struct {
	ClaudeAiOauth struct {
		AccessToken      string   `json:"accessToken"`
		RefreshToken     string   `json:"refreshToken"`
		ExpiresAt        int64    `json:"expiresAt"`
		Scopes           []string `json:"scopes"`
		SubscriptionType string   `json:"subscriptionType"`
	} `json:"claudeAiOauth"`
}

Credentials represents OAuth credentials

type Daemon

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

Daemon manages background monitoring and auto-refresh

func New

func New(config Config, configDir string, iconData []byte) (*Daemon, error)

New creates a new daemon instance

func (*Daemon) Start

func (d *Daemon) Start() error

Start begins the daemon monitoring loop

func (*Daemon) Stop

func (d *Daemon) Stop()

Stop signals the daemon to stop (safe to call multiple times)

type DaemonIPCInfo added in v0.9.4

type DaemonIPCInfo struct {
	Port       int    `json:"port"`
	BridgePort int    `json:"bridge_port,omitempty"`
	Token      string `json:"token"`
	PID        int    `json:"pid"`
}

DaemonIPCInfo is the JSON structure written to daemon-ipc.json

type IPCAction added in v0.9.4

type IPCAction string

IPCAction represents the type of IPC request

const (
	IPCActionNew          IPCAction = "new"
	IPCActionNotify       IPCAction = "notify"
	IPCActionExit         IPCAction = "exit"
	IPCActionReadMessages IPCAction = "read_messages"
	IPCActionSendMessage  IPCAction = "send_message"
	IPCActionWaitIdle     IPCAction = "wait_idle"
)

type IPCMessage added in v0.9.4

type IPCMessage struct {
	Role      string `json:"role"`      // "user" or "assistant"
	Content   string `json:"content"`   // Text content (truncated at 10KB)
	Timestamp string `json:"timestamp"` // ISO 8601
}

IPCMessage represents a message from a Claude session

type IPCRequest added in v0.9.4

type IPCRequest struct {
	ID              string    `json:"id"`
	Action          IPCAction `json:"action"`
	Task            string    `json:"task,omitempty"`              // For "new" action
	Title           string    `json:"title,omitempty"`             // For "notify" action
	Message         string    `json:"message,omitempty"`           // For "notify" and "send_message" actions
	Parent          string    `json:"parent"`                      // Container hostname (verified)
	Branch          string    `json:"branch,omitempty"`            // Optional branch for "new" action
	TargetRequestID string    `json:"target_request_id,omitempty"` // For child-targeting actions
	Count           int       `json:"count,omitempty"`             // read_messages: how many (default 10, max 50)
	Timeout         int       `json:"timeout,omitempty"`           // wait_idle: seconds (default 300)
}

IPCRequest is the wire format for IPC requests from containers

type IPCRequestFile added in v0.9.4

type IPCRequestFile struct {
	ID              string           `json:"id"`
	Action          IPCAction        `json:"action"`
	Task            string           `json:"task,omitempty"`
	Title           string           `json:"title,omitempty"`
	Message         string           `json:"message,omitempty"`
	Parent          string           `json:"parent"`
	Branch          string           `json:"branch,omitempty"`
	Status          IPCRequestStatus `json:"status"`
	RequestedAt     time.Time        `json:"requested_at"`
	ChildContainer  *string          `json:"child_container,omitempty"`
	FulfilledAt     *time.Time       `json:"fulfilled_at,omitempty"`
	ChildExitedAt   *time.Time       `json:"child_exited_at,omitempty"`
	Error           *string          `json:"error,omitempty"`
	TargetRequestID string           `json:"target_request_id,omitempty"`
	Messages        []IPCMessage     `json:"messages,omitempty"`
	Count           int              `json:"count,omitempty"`
	Timeout         int              `json:"timeout,omitempty"`
}

IPCRequestFile is the persistence format stored in the container filesystem

type IPCRequestStatus added in v0.9.4

type IPCRequestStatus string

IPCRequestStatus represents the status of a persisted IPC request

const (
	IPCRequestStatusPending     IPCRequestStatus = "pending"
	IPCRequestStatusFulfilled   IPCRequestStatus = "fulfilled"
	IPCRequestStatusFailed      IPCRequestStatus = "failed"
	IPCRequestStatusChildExited IPCRequestStatus = "child_exited"
)

type IPCResponse added in v0.9.4

type IPCResponse struct {
	Status    string `json:"status"`              // "ok", "accepted", "error"
	Container string `json:"container,omitempty"` // For "new" action (immediate only)
	Error     string `json:"error,omitempty"`
}

IPCResponse is the wire format for IPC responses to containers

type IPCServer added in v0.9.4

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

IPCServer handles HTTP requests from containers and CLI over TCP

func NewIPCServer added in v0.9.4

func NewIPCServer(d *Daemon, token string) (*IPCServer, error)

NewIPCServer creates a new IPC server with a loopback listener (and optionally a Docker bridge listener)

func (*IPCServer) BridgePort added in v0.9.4

func (s *IPCServer) BridgePort() int

BridgePort returns the TCP port on the Docker bridge interface, or 0 if not bound

func (*IPCServer) LoopbackPort added in v0.9.4

func (s *IPCServer) LoopbackPort() int

LoopbackPort returns the TCP port on 127.0.0.1 (for CLI / daemon-ipc.json)

func (*IPCServer) Start added in v0.9.4

func (s *IPCServer) Start()

Start begins serving requests — one goroutine per listener

func (*IPCServer) Stop added in v0.9.4

func (s *IPCServer) Stop()

Stop gracefully shuts down the IPC server (closes all listeners)

type IPCStatusResponse added in v0.9.4

type IPCStatusResponse struct {
	Running    bool     `json:"running"`
	PID        int      `json:"pid"`
	Containers []string `json:"containers"`
	Uptime     string   `json:"uptime"`
}

IPCStatusResponse is returned by the /status endpoint

Jump to

Keyboard shortcuts

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