Documentation
¶
Overview ¶
Package daemon runs a background process that holds one CDP connection and serves Browser calls over a Unix socket. Keeping a single long-lived connection means Chrome's "Allow debugging?" prompt fires once per session (not once per command) and each command is a fast socket round-trip.
Protocol: one JSON request/response per connection (NDJSON), where a request names a Browser method and carries its positional args as JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunDaemon ¶
RunDaemon connects Chrome and serves sockPath until idle or stopped. Used by the hidden `__daemon` invocation.
func Serve ¶
Serve accepts connections on ln and dispatches each to b until an idle period of `idle` elapses or a stop request arrives.
func SocketPath ¶
SocketPath returns the daemon socket path for an endpoint key, under the XDG runtime/state dir. Liveness is discovered by connecting (no PID file).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a running daemon over its Unix socket (one connection per call).
func Ensure ¶
Ensure connects to a running daemon, or spawns one (detached) and waits for it to come up. env carries the connection options (CHROME_CDP_*) for the daemon.
func TryConnect ¶
TryConnect returns a Client if a daemon is already listening on sockPath.
func (*Client) StatusInfo ¶
StatusInfo returns the daemon's status payload: {connected, targets}.
type Request ¶
type Request struct {
Method string `json:"method"`
Args []json.RawMessage `json:"args,omitempty"`
TimeoutMs int64 `json:"timeout_ms,omitempty"`
}
Request is a Browser method call. Args are the positional arguments (after ctx) as JSON. TimeoutMs carries the client's remaining deadline so the daemon bounds the action instead of running (and blocking the client) forever.
type Response ¶
type Response struct {
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
Response is the method result (or an error string).