daemon

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package daemon wires every component into the running `caprock up` process: store, pricing, recorder, hookd, ingest, loop detector, API/WS server, the idle sweeper, and the runtime.json lifecycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opt Options) error

Run starts the daemon and blocks until ctx is cancelled or a fatal error occurs.

Types

type Daemon

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

Daemon is a running instance.

func (*Daemon) URL

func (d *Daemon) URL() string

URL returns the bound base URL (after start).

type Options

type Options struct {
	DataDir        string
	Config         config.Config
	Version        string
	Log            *slog.Logger
	TranscriptRoot string // "" ⇒ ~/.claude/projects
	// Listener overrides the port (tests pass a pre-bound 127.0.0.1:0 listener).
	Listener net.Listener
	// DisableIngest turns transcript tailing off (tests, or hooks-only mode).
	DisableIngest bool
	// OpenCodeURL overrides where OpenCode's headless server is expected.
	// Empty means the documented default; tests point it at a stub.
	OpenCodeURL string
	// OpenCodeDB overrides where OpenCode's database is looked for. Empty means
	// discover it; "off" disables the reader entirely. Tests must set one or
	// the other, or a developer's own OpenCode sessions leak into a temporary
	// store and make assertions about session counts fail on their machine and
	// pass in CI.
	OpenCodeDB string
	// IdleAfter is the silence threshold before a session is marked idle.
	IdleAfter time.Duration
	// EndAfter is the silence threshold before a session is marked ended (default 12h).
	EndAfter time.Duration
	// HiveDir enables Phase 2 orchestration (tasks board + Stop-loop) at this path.
	// Empty ⇒ orchestration off (task endpoints return 501).
	HiveDir string
	// RepoCwd is the repo the orchestrator + workers operate on (default: cwd).
	RepoCwd string
	// OnReady is called once the server is listening (with the bound URL).
	OnReady func(url string)
}

Options configure a daemon run.

type PricingStatus

type PricingStatus struct {
	Version      string `json:"version"`
	Source       string `json:"source"`
	FetchedAt    string `json:"fetched_at"`
	UserOverride bool   `json:"user_override"`
	Models       int    `json:"models"`
}

PricingStatus summarizes the table in force.

type Status

type Status struct {
	Version string `json:"version"`
	// Platform is GOOS/GOARCH — the first thing a bug report needs and the
	// last thing anyone remembers to include.
	Platform  string        `json:"platform"`
	PID       int           `json:"pid"`
	StartedAt int64         `json:"started_at"`
	UptimeS   int64         `json:"uptime_s"`
	URL       string        `json:"url"`
	DataDir   string        `json:"data_dir"`
	Pricing   PricingStatus `json:"pricing"`
	Ingest    *ingest.Stats `json:"ingest,omitempty"`
	// IngestError is the terminal error that stopped transcript ingest, when
	// one happened (a read-only ~/.claude, a vanished transcript root). Empty
	// while ingest is running. Without it the daemon looked healthy while
	// capturing nothing, and the dashboard told the user to start `claude` and
	// wait for sessions that could never arrive.
	IngestError     string        `json:"ingest_error,omitempty"`
	Hooks           *hooks.Status `json:"hooks,omitempty"`
	UIBuilt         bool          `json:"ui_built"`
	ClaudeAvailable bool          `json:"claude_available"`
	// OpenCode reports what the second agent's reader is doing, or is absent
	// when OpenCode is not installed. Without it there was no way to tell
	// whether a machine that runs OpenCode was having those sessions read:
	// the dashboard shows them mixed in with Claude Code's, so their absence
	// looks the same as having none.
	OpenCode      *opencode.Stats `json:"opencode,omitempty"`
	OwnedActive   int             `json:"owned_active"`
	Orchestration bool            `json:"orchestration"`
	// Hive is the orchestration directory in force, and Repo the checkout its
	// workers operate on. Both empty when orchestration is off. Without them
	// there was no way — CLI, API or log — to ask which hive a running daemon
	// had been started with.
	Hive string `json:"hive,omitempty"`
	Repo string `json:"repo,omitempty"`
	// SuggestedHive and SuggestedRepo are what POST /v1/hive would use if it were
	// called with no body — the defaults the dashboard shows for confirmation
	// before turning the runner on. Present only while orchestration is off.
	SuggestedHive string `json:"suggested_hive,omitempty"`
	SuggestedRepo string `json:"suggested_repo,omitempty"`
	LoopK         int    `json:"loop_k"`
	LoopTMin      int    `json:"loop_t_minutes"`
	ActiveLoops   int    `json:"active_loops"`
	Events        int64  `json:"events"`
	RetentionDays int    `json:"retention_days"`
	// Desktop is the Claude desktop app's own plan usage, when it has any on
	// this machine. Omitted entirely otherwise — most people do not use it.
	Desktop *desktop.Reading `json:"desktop,omitempty"`
}

Status is /v1/status.

Jump to

Keyboard shortcuts

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