Documentation
¶
Overview ¶
Package attachclient is the shared client for attach-mode endpoints, used by both `core-agent attach`/`ls` (in cmd/core-agent) and `core-agent-tui` (in cmd/core-agent-tui). The package is internal/ so the surface isn't part of the public API stability promise — it's a coordination point between two of our own binaries, not a SDK consumers should reach for.
Index ¶
- type Client
- func (c *Client) Agents(ctx context.Context, sessionPath string) ([]attach.AgentInfo, error)
- func (c *Client) Inject(ctx context.Context, sessionPath, message string) error
- func (c *Client) ListPeers(ctx context.Context) ([]PeerDescriptor, error)
- func (c *Client) ListSessions(ctx context.Context) ([]SessionDescriptor, error)
- func (c *Client) Status(ctx context.Context, sessionPath string) (attach.StatusInfo, error)
- func (c *Client) Stream(ctx context.Context, sessionPath string, since int64) (<-chan attach.Frame, error)
- func (c *Client) Tools(ctx context.Context, sessionPath string) ([]attach.ToolInfo, error)
- func (c *Client) Wake(ctx context.Context, sessionPath string) error
- type ParsedURL
- type PeerDescriptor
- type SessionDescriptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a thin HTTP client for one attach-mode endpoint. Holds the parsed URL, bearer token (empty for no auth), and a configured http.Client (Unix-socket-aware when the URL scheme is unix://). Safe for concurrent use.
func New ¶
New builds a Client. ParseURL the rawURL first; Token may be empty. timeout governs all HTTP calls except Stream (which uses ctx cancel instead). Zero timeout falls back to 30 s.
func (*Client) Inject ¶
Inject calls POST <base>/sessions/<sid>/inject with the given message. sessionPath is the /sessions/<sid> prefix (relative to BaseURL).
func (*Client) ListPeers ¶
func (c *Client) ListPeers(ctx context.Context) ([]PeerDescriptor, error)
ListPeers calls GET <base>/peers. Returns nil (not an error) when the listener doesn't have peer-registration enabled (HTTP 404).
func (*Client) ListSessions ¶
func (c *Client) ListSessions(ctx context.Context) ([]SessionDescriptor, error)
ListSessions calls GET <base>/sessions.
func (*Client) Stream ¶
func (c *Client) Stream(ctx context.Context, sessionPath string, since int64) (<-chan attach.Frame, error)
Stream connects to <base><sessionPath>/events?since=<since> and returns a channel of decoded frames. Closes the channel on ctx cancel, stream error, or upstream EOF. Errors that prevented the initial GET (network failure, non-200 status) are returned synchronously; downstream errors land in the returned channel's error field via the second return value being closed.
The lossless-replay property of the protocol means that passing a non-zero since value asks the server to replay any frames since that sequence before resuming live tail.
type ParsedURL ¶
type ParsedURL struct {
Scheme string // http | https | unix
Host string // host:port (empty for unix)
SocketPath string // for unix scheme
BaseURL string // ready-to-use for HTTP client: http(s)://host OR http://unix placeholder
Session string // /sessions/<...> path; empty for list endpoints
}
ParsedURL holds the components of an attach-mode URL. Three schemes are accepted: http://, https://, unix:// (the last for Unix-socket listeners — convention is unix:///path/to/socket/sessions/<sid>).
Session is non-empty when the URL targets a specific session (e.g. /sessions/<sid> or /sessions/<app>/<sid>). For listing endpoints (GET /sessions) Session is empty.