Documentation
¶
Index ¶
Constants ¶
const MaxMessageSize = 1024 * 1024
MaxMessageSize is Chrome's native messaging limit (1 MB).
Variables ¶
This section is empty.
Functions ¶
func ReadMessage ¶
ReadMessage reads a Chrome native messaging frame: 4-byte LE length + JSON payload.
Types ¶
type Bridge ¶
type Bridge struct {
Dialer Dialer
Addr string // HUMAN_CHROME_ADDR (TCP address of daemon's chrome proxy)
Token string
Version string
Logger zerolog.Logger
}
Bridge creates a fake Unix socket inside a container and tunnels traffic over TCP to the daemon on the host, which connects to the real Chrome native messaging socket.
type DefaultDialer ¶
type DefaultDialer struct{}
DefaultDialer uses the standard net.Dialer.
func (DefaultDialer) DialContext ¶
DialContext dials using the standard library.
type McpTranslator ¶ added in v0.11.0
type McpTranslator struct {
// ClaudePath is the absolute path to the claude binary.
ClaudePath string
Logger zerolog.Logger
}
McpTranslator bridges a net.Conn speaking the native host socket protocol (4-byte LE framing) to a claude --claude-in-chrome-mcp subprocess speaking JSON-RPC over stdio. It translates only the envelope — payloads are opaque.
type Server ¶
type Server struct {
Addr string
Token string
Translator *McpTranslator
Logger zerolog.Logger
}
Server listens for chrome-proxy connections on its own TCP port.
type SocketConnector ¶
SocketConnector implements ProcessSpawner by connecting to a Unix socket in the socket directory. It is used by the daemon to connect to the Chrome native messaging bridge socket created by the bridge command.
func (*SocketConnector) Spawn ¶
func (sc *SocketConnector) Spawn(_ context.Context) (io.WriteCloser, io.ReadCloser, func() error, error)
Spawn connects to the first reachable .sock file in SocketDir.
type SocketRelay ¶
type SocketRelay struct {
SocketDir string
Logger zerolog.Logger
// contains filtered or unexported fields
}
SocketRelay implements ProcessSpawner by creating a Unix socket and accepting connections from Chrome's native messaging host. When Spawn is called (by ForwardProxy via chrome.Server), it dequeues a waiting Chrome connection and returns it as stdin/stdout, pairing it with the bridge connection.
func NewSocketRelay ¶
func NewSocketRelay(socketDir string, logger zerolog.Logger) *SocketRelay
NewSocketRelay creates a SocketRelay with a buffered pending channel.
func (*SocketRelay) ListenAndServe ¶
func (r *SocketRelay) ListenAndServe(ctx context.Context) error
ListenAndServe creates a Unix socket in SocketDir and accepts connections, queuing them in the pending channel. It blocks until ctx is cancelled.
func (*SocketRelay) Spawn ¶
func (r *SocketRelay) Spawn(ctx context.Context) (io.WriteCloser, io.ReadCloser, func() error, error)
Spawn implements ProcessSpawner. It blocks until a Chrome native messaging connection is available (or ctx is cancelled) and returns it as stdin/stdout.