Documentation
¶
Overview ¶
Package backend obtains a reachable local CDP/VNC endpoint for a browser that runs in one of four places: a local docker container, a Kubernetes Deployment, docker on an ssh host, or a pre-exposed direct URL. Every CDP/VNC-facing operation runs against the Endpoint a backend yields, so the rest of cuttle is transport-agnostic.
Index ¶
- type Backend
- type Direct
- type Endpoint
- type ExecRunner
- type K8s
- type Local
- func (l *Local) Diagnostics(ctx context.Context) []string
- func (l *Local) Image(ctx context.Context) string
- func (l *Local) Reach(_ context.Context, _, _ int) (Endpoint, func(), error)
- func (l *Local) Start(ctx context.Context, opts StartOpts) error
- func (l *Local) State(ctx context.Context) (State, error)
- func (l *Local) Stop(ctx context.Context, purge bool) error
- type Process
- type Result
- type Runner
- type SSH
- type StartOpts
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
State(ctx context.Context) (State, error)
Start(ctx context.Context, opts StartOpts) error
Stop(ctx context.Context, purge bool) error
// Reach yields a local endpoint plus a release func that tears down any
// tunnel opened to reach it. release is always safe to call (no-op for
// direct/local). cdpPort/vncPort request specific local ports for a tunneled
// backend (k8s/ssh) so a held forward is deterministic and `cuttle mcp` can
// point a driver at it; 0 auto-picks a free port (used by the ephemeral
// status/login/up forwards, which never collide with a local container).
// local/direct ignore the requested ports and return their fixed endpoint.
Reach(ctx context.Context, cdpPort, vncPort int) (Endpoint, func(), error)
}
Backend manages one browser's lifecycle and reachability.
type Direct ¶
type Direct struct {
// contains filtered or unexported fields
}
Direct targets a pre-exposed CDP/VNC endpoint from config as-is. It is the escape hatch for any browser cuttle does not itself manage (e.g. reached over a tailnet), so Start/Stop are errors.
type Endpoint ¶
Endpoint is a reachable CDP (and optional VNC) address. For tunneled backends the host is loopback and the ports are auto-picked local forwards; for direct it is the configured host/port as-is.
type ExecRunner ¶
type ExecRunner struct{}
ExecRunner is the production Runner backed by os/exec.
type K8s ¶
type K8s struct {
// contains filtered or unexported fields
}
K8s runs the browser as a Helm-managed Deployment in a cluster, reached via kubectl port-forward. It shells out to kubectl/helm and inherits the user's kube context (and thus their routing) with zero cuttle-specific setup.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local runs the browser in a docker container on this host. It is a faithful port of the Python cuttle CLI's docker lifecycle, so existing behavior does not regress when no config file is present.
func (*Local) Diagnostics ¶
Diagnostics returns human-readable triage lines for an unhealthy container: the real host<-container port bindings and a log tail, so triage never needs a raw docker command. It is used by `status` via an optional interface.
func (*Local) Reach ¶
Reach for local is a direct loopback endpoint on the host-mapped ports; no tunnel, so release is a no-op.
type Process ¶
type Process interface {
Stop() error
}
Process is a running command that can be stopped.
type Runner ¶
type Runner interface {
// Output runs a command to completion and captures its output. A non-zero
// exit is reported in Result.Code with a nil error (mirroring the Python
// check=False); a nil error means only that the command ran.
Output(ctx context.Context, name string, args ...string) (Result, error)
// Start launches a long-running command (a tunnel) and returns a handle to
// stop it.
Start(ctx context.Context, name string, args ...string) (Process, error)
// LookPath reports the resolved path of an executable, or an error if absent.
LookPath(name string) (string, error)
}
Runner is the exec seam every backend goes through, so command construction is unit-testable without docker/kubectl/ssh installed.
type SSH ¶
type SSH struct {
// contains filtered or unexported fields
}
SSH runs the browser in docker on a remote host reached over ssh, tunneled to this machine with ssh -L. It inherits ~/.ssh/config (keys, jump hosts, and any routing the user provides), so cuttle needs no ssh setup of its own.
func (*SSH) Reach ¶
Reach opens an ssh -L tunnel from local ports to the remote container's published ports, establishing the ControlMaster the other calls reuse. cdpPort/vncPort pin the local ports (so a held `cuttle connect` forward is deterministic and mcp can target it); 0 auto-picks free ports for the ephemeral status/login forwards.
type StartOpts ¶
type StartOpts struct {
Image string
Recreate bool
KeepProfile *bool // nil = backend default (on)
NoVNC bool
Proxy string
IdleTimeout string // local only
Storage string // profile storage: "local" | "remote"
}
StartOpts carries the per-invocation choices for Start. Not every field applies to every backend (e.g. IdleTimeout is local-only, Recreate is docker- only); a backend ignores what it does not use.