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 ¶
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is a running instance.
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 1h). It is a backstop, not the main path: SessionEnd ends a
// session the moment the user leaves it. What this catches is the session
// whose hook never fired — kill -9, a closed terminal, a crashed host.
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"`
// GeminiAvailable says the Gemini CLI is on PATH, so the new-session
// dialog offers an agent the machine actually has rather than a choice
// that fails on click.
GeminiAvailable bool `json:"gemini_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.