Documentation
¶
Overview ¶
Package daemonclient is the in-process client for the agentenv daemon's newline-delimited JSON API (see internal/protocol). It owns all the "dial unix socket, write one request line, decode protocol.Response frames" plumbing so that callers — internal/cli's `ctl` subcommand AND the MCP server bridge (internal/mcp) — share one implementation.
Protocol shape (recap of internal/protocol):
- 1 request line in → 1 or more Response frames out.
- Most ops emit exactly 1 frame; `exec` streams stdout/stderr frames and then a terminal frame (OK or Error).
Three call shapes are exposed:
- Dial + Recv + Close — full control; use when you need to react to each frame (ctl's streaming exec prints stdout/stderr as it arrives).
- Roundtrip — read exactly one frame; correct for non-streaming ops.
- Drain — read until a Terminal() frame; correct when you want the final verdict but don't care about intermediate streaming frames (the MCP bridge uses this defensively in case someone routes `exec` through it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Drain ¶
Drain sends one request and reads frames until a Terminal() one arrives, discarding any streaming frames along the way. Use this when you only care about the final verdict.
func Roundtrip ¶
Roundtrip sends one request and reads exactly one frame back. Use this for non-streaming ops (everything except `exec`).
func SocketPath ¶
SocketPath resolves the daemon socket path, in order of precedence:
- explicit override (--socket flag value; pass "" to skip)
- AGENTENV_SOCKET env var
- AGENTENV_ROOT/agentenv.sock (root defaults to /agentfs)
Centralizing this means `ctl`, the MCP server, and any future client all agree on where the daemon listens.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one open daemon connection with the request already sent. Recv() repeatedly until you get a Terminal() frame (or an error), then Close().