{"modulePath":"github.com/css521/agentenv","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package daemonclient\n\nPackage 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.\n\nProtocol shape (recap of internal/protocol):\n\n  - 1 request line in → 1 or more Response frames out.\n  - Most ops emit exactly 1 frame; \\`exec\\` streams stdout/stderr frames and then a terminal frame (OK or Error).\n\nThree call shapes are exposed:\n\n  - Dial + Recv + Close — full control; use when you need to react to each frame (ctl's streaming exec prints stdout/stderr as it arrives).\n  - Roundtrip — read exactly one frame; correct for non-streaming ops.\n  - 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).\n\n## Functions\n\n```go\nfunc Drain(sock string, req map[string]any) (*protocol.Response, error)\n```\nDrain 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.\n\n```go\nfunc Roundtrip(sock string, req map[string]any) (*protocol.Response, error)\n```\nRoundtrip sends one request and reads exactly one frame back. Use this for non-streaming ops (everything except \\`exec\\`).\n\n```go\nfunc SocketPath(override string) string\n```\nSocketPath resolves the daemon socket path, in order of precedence:\n\n 1. explicit override (--socket flag value; pass \"\" to skip)\n 2. AGENTENV\\_SOCKET env var\n 3. AGENTENV\\_ROOT/agentenv.sock (root defaults to /agentfs)\n\nCentralizing this means \\`ctl\\`, the MCP server, and any future client all agree on where the daemon listens.\n\n## Types\n\n```go\ntype Conn struct {\n\t// contains filtered or unexported fields\n}\n```\nConn is one open daemon connection with the request already sent. Recv() repeatedly until you get a Terminal() frame (or an error), then Close().\n\n```go\nfunc Dial(sock string, req map[string]any) (*Conn, error)\n```\nDial connects to the daemon's unix socket and sends one JSON request line. The returned Conn is ready for Recv(); the caller closes it.\n\n```go\nfunc (c *Conn) Close() error\n```\nClose closes the underlying socket.\n\n```go\nfunc (c *Conn) Recv() (*protocol.Response, error)\n```\nRecv decodes the next response frame.\n\n","path":"github.com/css521/agentenv/internal/daemonclient","name":"daemonclient","synopsis":"Package daemonclient is the in-process client for the agentenv daemon's newline-delimited JSON API (see internal/protocol).","isRedistributable":true}
