Documentation
¶
Overview ¶
Package browserctl talks to a running kitty-browse over its owner-only Unix-domain control socket. It is the typed client the browser tool uses: /v1/info for discovery, /v1/actions for one action, /v1/screenshot for a picture.
The socket file's mode is the access control. A socket another user can write is refused rather than used, because an action puts input into a real browser session.
Index ¶
Constants ¶
const ( // EnvSocket is the control socket path a kitty-browse pane exposes. EnvSocket = "KITTY_BROWSE_SOCKET" // APIVersion is the only contract this client speaks. APIVersion = "v1" )
Variables ¶
This section is empty.
Functions ¶
func IsConnectionRefused ¶
IsConnectionRefused reports whether err means the browser is gone, so a tool can say that instead of printing a socket error.
func SocketFromEnv ¶
func SocketFromEnv() string
SocketFromEnv returns the configured control socket, or "".
Types ¶
type Capability ¶
type Capability struct {
Name string `json:"name"`
Description string `json:"description"`
ReadOnly bool `json:"readOnly"`
InputSchema json.RawMessage `json:"inputSchema"`
}
Capability is one action the browser implements, with its input schema.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is one browser's control socket.
func Dial ¶
Dial validates the socket and returns a client. It does not call the browser: a caller that wants to prove it is alive calls Info.
func NewWithTransport ¶
func NewWithTransport(socket string, rt http.RoundTripper) *Client
NewWithTransport builds a client for an already-trusted connection: a nil transport dials the Unix socket, and a test or embedder may supply its own. It skips the socket-permission check, which only Dial can make.
func (*Client) Action ¶
func (c *Client) Action(ctx context.Context, action string, params any, target Target, timeout time.Duration) (json.RawMessage, Meta, error)
Action runs one typed action against one target tab.
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Retryable bool `json:"retryable"`
Details json.RawMessage `json:"details,omitempty"`
}
Error is the action-level failure. OK false with a code is the branch to read; HTTP status alone is not enough.
type Info ¶
type Info struct {
APIVersion string `json:"apiVersion"`
BrowserID string `json:"browserId"`
ActiveTabID string `json:"activeTabId"`
Backend string `json:"backend"`
Tabs []Tab `json:"tabs"`
Capabilities []Capability `json:"capabilities"`
}
Info is /v1/info.
type Meta ¶
type Meta struct {
BrowserID string `json:"browserId"`
TabID string `json:"tabId"`
TargetID string `json:"targetId"`
URL string `json:"url"`
Title string `json:"title"`
Backend string `json:"backend"`
}
Meta is what the browser reports about where the action ran.