daemon

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 49 Imported by: 0

Documentation

Overview

Package daemon is devbox-daemon, PID 1 in every DevBox sandbox (section 4.2). It wires the subsystems together and serves the devbox.v1.Daemon gRPC service and the HTTP endpoints (/readyz, /terminals/<id>/ws, /browser/vnc, /preview/<port>/*) on one h2c port.

Index

Constants

View Source
const (
	StatusBooting   = "booting"
	StatusHydrating = "hydrating"
	StatusReady     = "ready"
	StatusDegraded  = "degraded"
)

Health statuses.

View Source
const BundlePath = "/workspace/bundles/"

BundlePath is the daemon-local extension for git bundle uploads (DBX-72 push). The contract has no RPC for it.

Variables

View Source
var GitAuthPlaceholder = "Authorization: Basic " + base64.StdEncoding.EncodeToString([]byte("x-access-token:"+harness.PlaceholderKey))

GitAuthPlaceholder is the Authorization header git sends to SCM hosts. atenet-egress only replaces headers that are present, so git must send one; the real token never enters the sandbox.

Functions

func ImageProbeSpecs

func ImageProbeSpecs(img *harness.ImageInfo, def string) []*devboxv1.AgentProbeSpec

ImageProbeSpecs are probe specs for every agent the image ships (`devbox-daemon probe`), the first listed as default unless def names one.

func Probe

Probe runs the section 4.2a probe outside a running daemon (image builds, `devbox-daemon probe --json`).

Types

type Config

type Config struct {
	// ListenAddr serves gRPC (h2c) and HTTP on one port (":80").
	ListenAddr string
	// Home is the dev user's home on the workspace volume (/home/dev).
	Home string
	// StateDir holds the daemon's durable state, event log included (~/.plural).
	StateDir string
	// SkelDir is copied into Home on first boot without overwriting (/etc/devbox/skel).
	SkelDir string
	// TrustDir is the writable trust store; TrustBundle() is what the CA env vars point at.
	TrustDir string
	// SystemCABundle is merged with the egress interception CA(s) matched by EgressCAGlobs.
	SystemCABundle string
	EgressCAGlobs  []string
	// IdentityDir holds federated token files and SDK config (/run/plural/identity).
	IdentityDir string
	// AgentAuthDir is the subscription-credential tmpfs (/run/plural/agent-auth).
	AgentAuthDir string
	// ImageInfo is /etc/devbox/image.json.
	ImageInfo string
	// Contract overrides the image contract version (DEVBOX_CONTRACT).
	Contract string
	// Shell is the terminals' login shell.
	Shell string

	Chromium    string
	Xvfb        string
	X11VNC      string
	Display     string
	CDPPort     int
	VNCPort     int
	BrowserIdle time.Duration
	// PlaywrightMCP is the Playwright MCP command added to every session (empty: image.json's playwrightMcp).
	PlaywrightMCP string

	// MaxRunningThreads is the default concurrency limit before Initialize sets one.
	MaxRunningThreads int
	// AgentOverrides replace an agent's ACP command (DEVBOX_AGENT_<NAME>_COMMAND; local development and tests).
	AgentOverrides map[devboxv1.AgentType]harness.Command
	// InsecureNoAuth accepts calls without a request token even after Initialize delivered keys (local only).
	InsecureNoAuth bool

	Version string
	Clock   clock.Clock
	Log     *slog.Logger
}

Config holds every path and port the daemon uses. cmd/devbox-daemon fills it from flags and DEVBOX_* env.

func (*Config) JavaTrustStore

func (c *Config) JavaTrustStore() string

JavaTrustStore is the image's writable JDK truststore; the JDK's cacerts is a symlink to it.

func (*Config) TrustBundle

func (c *Config) TrustBundle() string

TrustBundle is the CA bundle path every child process is pointed at.

type Daemon

type Daemon struct {
	devboxv1.UnimplementedDaemonServer
	// contains filtered or unexported fields
}

Daemon is the running daemon.

func New

func New(cfg Config) (*Daemon, error)

New builds the daemon and restores its persisted state. Nothing runs until Run.

func (*Daemon) AckEvents

func (*Daemon) AddRepository

func (*Daemon) CancelPrompt

func (*Daemon) CloseTerminal

func (*Daemon) CloseThread

func (*Daemon) CreateTerminal

func (*Daemon) CreateThread

func (*Daemon) DeleteThread

func (*Daemon) ForkThread

func (*Daemon) Forward

func (d *Daemon) Forward(sig syscall.Signal)

Forward relays a signal to every supervised child (PID 1 duty).

func (*Daemon) GetBranchDiffStat

func (*Daemon) GetBrowser

func (*Daemon) GetChanges

func (*Daemon) GetIdleState

func (*Daemon) GetInfo

func (*Daemon) GetTimeline

func (*Daemon) Handler

func (d *Daemon) Handler() http.Handler

Handler serves gRPC (HTTP/2 with content-type application/grpc) and the HTTP endpoints on one port.

func (*Daemon) ImportThread

func (*Daemon) Initialize

func (*Daemon) ListFiles

func (*Daemon) ListThreads

func (*Daemon) ProbeAgents

func (*Daemon) Prompt

func (*Daemon) ReadFile

func (*Daemon) ResizeTerminal

func (*Daemon) ResumeThread

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

Run serves until ctx ends, then shuts every subsystem down.

func (*Daemon) Serve

func (d *Daemon) Serve(ctx context.Context, ln net.Listener) error

Serve is Run on an existing listener.

func (*Daemon) StartBrowser

func (*Daemon) StatFile

func (*Daemon) WatchFiles

func (*Daemon) WriteFile

Directories

Path Synopsis
Package acp is the daemon's ACP client layer: a raw JSON-RPC connection to a harness over stdio, converters between ACP JSON and the devbox.v1 protos, the v1 -> v2 entity normalizer, subagent lineage extraction and the live entity store.
Package acp is the daemon's ACP client layer: a raw JSON-RPC connection to a harness over stdio, converters between ACP JSON and the devbox.v1 protos, the v1 -> v2 entity normalizer, subagent lineage extraction and the live entity store.
Package agents is the daemon's ACP session service (DBX-41, DBX-48): one ACP connection per agent type, shared by that agent's threads; threads mapped onto ACP's session built-ins; the prompt lifecycle with the per-instance running-thread limit; permission and elicitation interactions; config options (models included); slash commands; subagent lineage; and the live entity store whose normalized, v2-shaped changes are appended to the daemon's event log, with settled entities written to the box's transcript.
Package agents is the daemon's ACP session service (DBX-41, DBX-48): one ACP connection per agent type, shared by that agent's threads; threads mapped onto ACP's session built-ins; the prompt lifecycle with the per-instance running-thread limit; permission and elicitation interactions; config options (models included); slash commands; subagent lineage; and the live entity store whose normalized, v2-shaped changes are appended to the daemon's event log, with settled entities written to the box's transcript.
Package authn validates `devbox-request-token`, the JWT the gateway attaches to every Daemon call, against the JWKS delivered in Initialize.
Package authn validates `devbox-request-token`, the JWT the gateway attaches to every Daemon call, against the JWKS delivered in Initialize.
Package browser runs the sandbox's visible Chromium (DBX-45): Xvfb, Chromium with a CDP port the agent's Playwright MCP drives, x11vnc on localhost bridged to the /browser/vnc WebSocket, and the /preview/:port/* reverse proxy.
Package browser runs the sandbox's visible Chromium (DBX-45): Xvfb, Chromium with a CDP port the agent's Playwright MCP drives, x11vnc on localhost bridged to the /browser/vnc WebSocket, and the /preview/:port/* reverse proxy.
Package creds manages the credentials that must live in the sandbox (sections 4.9 and 4.11): cloud OIDC token files with SDK configuration, and the Codex subscription bundle on tmpfs with compare-and-swap write-back.
Package creds manages the credentials that must live in the sandbox (sections 4.9 and 4.11): cloud OIDC token files with SDK configuration, and the Codex subscription bundle on tmpfs with compare-and-swap write-back.
Package derr builds gRPC errors carrying a devbox.v1.ErrorDetail, so callers can branch on the reason.
Package derr builds gRPC errors carrying a devbox.v1.ErrorDetail, so callers can branch on the reason.
Package eventlog is the daemon's offset-addressed event log (section 4.6).
Package eventlog is the daemon's offset-addressed event log (section 4.6).
Package fakeacp is a scripted ACP v1 agent for tests.
Package fakeacp is a scripted ACP v1 agent for tests.
Package files serves the filesystem and changes RPCs (DBX-43): listing, stat, reads with a content hash, compare-and-swap writes, recursive watches, and git changes grouped by checkout.
Package files serves the filesystem and changes RPCs (DBX-43): listing, stat, reads with a content hash, compare-and-swap writes, recursive watches, and git changes grouped by checkout.
Package gitutil wraps the git CLI for checkout inspection, status and diffs (DBX-43).
Package gitutil wraps the git CLI for checkout inspection, status and diffs (DBX-43).
Package harness builds the launch configuration for each agent harness (DBX-46, DBX-57): the ACP command, environment pointing model traffic at the console AI proxy with a placeholder key (or at the owner's plan), CA trust, home instruction files and the per-harness model boot flags used when an adapter has no ACP model control.
Package harness builds the launch configuration for each agent harness (DBX-46, DBX-57): the ACP command, environment pointing model traffic at the console AI proxy with a placeholder key (or at the owner's plan), CA trust, home instruction files and the per-harness model boot flags used when an adapter has no ACP model control.
Package idle is the daemon's suspend detector (DBX-47, section 4.3a).
Package idle is the daemon's suspend detector (DBX-47, section 4.3a).
internal
clock
Package clock abstracts time so the daemon's timers (idle detection, settling, credential rotation) can be driven by a fake clock in tests.
Package clock abstracts time so the daemon's timers (idle detection, settling, credential rotation) can be driven by a fake clock in tests.
fsutil
Package fsutil holds small filesystem helpers shared by the daemon's packages.
Package fsutil holds small filesystem helpers shared by the daemon's packages.
gittest
Package gittest creates throwaway git repositories for tests.
Package gittest creates throwaway git repositories for tests.
Package proc runs and supervises the daemon's child processes and, when the daemon is PID 1, reaps orphaned zombies without racing exec.Cmd.Wait for the children the daemon started itself.
Package proc runs and supervises the daemon's child processes and, when the daemon is PID 1, reaps orphaned zombies without racing exec.Cmd.Wait for the children the daemon started itself.
Package prs readies a checkout for a pull request: it writes the title, body and commit message from the changes the box holds, branches off the default branch if needed, commits and pushes.
Package prs readies a checkout for a pull request: it writes the title, body and commit message from the changes the box holds, branches off the default branch if needed, commits and pushes.
Package terminal runs PTY sessions for the workbench terminal pane and `plural devbox ssh` (DBX-42).
Package terminal runs PTY sessions for the workbench terminal pane and `plural devbox ssh` (DBX-42).
Package transcript is the box's durable transcript: every settled entity revision, kept on the workspace volume (~/.plural/transcripts) so it survives suspends, snapshots and daemon restarts, and served to the gateway by Daemon.GetTimeline.
Package transcript is the box's durable transcript: every settled entity revision, kept on the workspace volume (~/.plural/transcripts) so it survives suspends, snapshots and daemon restarts, and served to the gateway by Daemon.GetTimeline.
Package trust builds the sandbox's CA bundle: the system roots plus the egress gateway's interception CA, written to the writable trust store that SSL_CERT_FILE, NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE and GIT_SSL_CAINFO point at.
Package trust builds the sandbox's CA bundle: the system roots plus the egress gateway's interception CA, written to the writable trust store that SSL_CERT_FILE, NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE and GIT_SSL_CAINFO point at.
Package workspace hydrates and maintains the multi-repo home directory (DBX-44, section 4.2b): skeleton files, repository clones with the naming rule, the home instruction file, Project.md's managed table and stubs, AddRepository, per-thread worktrees, and uploaded git bundles.
Package workspace hydrates and maintains the multi-repo home directory (DBX-44, section 4.2b): skeleton files, repository clones with the naming rule, the home instruction file, Project.md's managed table and stubs, AddRepository, per-thread worktrees, and uploaded git bundles.

Jump to

Keyboard shortcuts

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