daemonclient

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 9 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 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

func Drain(sock string, req map[string]any) (*protocol.Response, error)

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

func Roundtrip(sock string, req map[string]any) (*protocol.Response, error)

Roundtrip sends one request and reads exactly one frame back. Use this for non-streaming ops (everything except `exec`).

func SocketPath

func SocketPath(override string) string

SocketPath resolves the daemon socket path, in order of precedence:

  1. explicit override (--socket flag value; pass "" to skip)
  2. AGENTENV_SOCKET env var
  3. 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().

func Dial

func Dial(sock string, req map[string]any) (*Conn, error)

Dial connects to the daemon's unix socket and sends one JSON request line. The returned Conn is ready for Recv(); the caller closes it.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the underlying socket.

func (*Conn) Recv

func (c *Conn) Recv() (*protocol.Response, error)

Recv decodes the next response frame.

Jump to

Keyboard shortcuts

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