action

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 16 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 action exposes kitty-browse's versioned, native Chromium automation API. Browser and tab lifetimes remain owned by the host application.

Index

Constants

View Source
const APIVersion = "v1"
View Source
const Backend = "native-cdp"

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, req Request, sess *browser.Session) (json.RawMessage, error)

Execute dispatches a request only to native Session/CDP implementations. Browser lifecycle operations are returned to the host rather than mutating Session state behind the UI's back.

func RequestTimeout

func RequestTimeout(req Request) (time.Duration, error)

RequestTimeout validates and converts the public millisecond timeout. A zero value means the stable 30-second default.

func ValidateRequest

func ValidateRequest(req Request) error

ValidateRequest checks the versioned request envelope. An omitted version is the v1 compatibility spelling; versions are otherwise matched exactly.

Types

type Capability

type Capability struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	ReadOnly    bool            `json:"readOnly"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

func Capabilities

func Capabilities() []Capability

Capabilities describes only the native surface. Host-managed entries are declarations: Execute returns host_action_required for those actions.

type Error

type Error struct {
	Code      string          `json:"code"`
	Message   string          `json:"message"`
	Retryable bool            `json:"retryable"`
	Details   json.RawMessage `json:"details"`
}

func (*Error) Error

func (e *Error) Error() string

type ExplicitSelection added in v0.2.9

type ExplicitSelection struct {
	Revision uint64 `json:"revision"`
	TabID    string `json:"tabId"`
	TargetID string `json:"targetId"`
}

ExplicitSelection is the latest successful control-API tab activation. Its revision is scoped to one browser instance and does not change on reads, popup reconciliation, or manual selection in a visible pane.

type Info

type Info struct {
	APIVersion        string             `json:"apiVersion"`
	BrowserID         string             `json:"browserId"`
	LoginProfile      string             `json:"loginProfile,omitempty"`
	ActiveTabID       string             `json:"activeTabId"`
	Backend           string             `json:"backend"`
	Tabs              []TabInfo          `json:"tabs"`
	Capabilities      []Capability       `json:"capabilities"`
	ExplicitSelection *ExplicitSelection `json:"explicitSelection,omitempty"`
}

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"`
}

type Request

type Request struct {
	APIVersion string          `json:"apiVersion,omitempty"`
	ID         string          `json:"id"`
	Action     string          `json:"action"`
	Params     json.RawMessage `json:"params"`
	Args       []string        `json:"args"`
	Target     Target          `json:"target"`
	TimeoutMS  int             `json:"timeoutMs"`
}

func ParseCommand

func ParseCommand(args []string) (Request, error)

ParseCommand converts the documented CLI vocabulary to the stable API request. It never provides a catch-all passthrough.

type Response

type Response struct {
	APIVersion string          `json:"apiVersion"`
	ID         string          `json:"id"`
	OK         bool            `json:"ok"`
	Result     json.RawMessage `json:"result"`
	Error      *Error          `json:"error"`
	Meta       Meta            `json:"meta"`
}

func Respond

func Respond(req Request, info Info, target TabInfo, result json.RawMessage, err error) Response

Respond builds the stable response envelope and maps implementation errors without exposing Go or CDP internals.

type TabInfo

type TabInfo struct {
	ID       string `json:"id"`
	TargetID string `json:"targetId"`
	URL      string `json:"url"`
	Title    string `json:"title"`
	Index    int    `json:"index"`
	Active   bool   `json:"active"`
}

func SelectTarget

func SelectTarget(info Info, target Target) (TabInfo, error)

SelectTarget resolves only targets advertised by the host. Tab IDs are opaque stable IDs; indices and other transient aliases are not accepted.

type Target

type Target struct {
	BrowserID string `json:"browserId"`
	TabID     string `json:"tabId"`
	TargetID  string `json:"targetId"`
}

Jump to

Keyboard shortcuts

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