client

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 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 client connects agents to a sailwright-gateway on the same machine or through a mounted agent directory in a devcontainer. Explicit endpoint and token settings take precedence over discovery; mounted container credentials take precedence over the current user's local gateway.

Index

Constants

View Source
const (
	EnvURL   = "SAILWRIGHT_GATEWAY_URL"
	EnvToken = "SAILWRIGHT_GATEWAY_TOKEN"
	EnvDir   = "SAILWRIGHT_GATEWAY_DIR"

	DefaultDir    = "/run/sailwright-gateway"
	DefaultTCPURL = "http://host.docker.internal:7391/mcp"
	LocalTCPURL   = "http://127.0.0.1:7391/mcp"
	UserDirName   = ".sailwright-gateway"
)

Environment variables and defaults used for discovery.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, endpoint Endpoint, impl *mcp.Implementation) (*mcp.ClientSession, error)

Connect opens an MCP client session to the gateway.

func CopyTunnel added in v0.27.0

func CopyTunnel(ctx context.Context, tunnel net.Conn, input io.Reader, output io.Writer) error

CopyTunnel carries stdio or a local connection over a guest tunnel. It preserves half-close semantics so a client can finish writing while reading its response.

Types

type Bridge

type Bridge struct {
	Endpoint Endpoint
	Version  string
	// contains filtered or unexported fields
}

Bridge serves the gateway's tools over another MCP transport (usually stdio), so any agent harness that can start a command can use the gateway. Tool calls are forwarded unchanged; the gateway enforces its policy as usual.

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context, transport mcp.Transport) error

Run connects upstream, mirrors its tools and serves them on transport until the downstream client disconnects or ctx is cancelled.

type Endpoint

type Endpoint struct {
	// URL is the HTTP endpoint; for socket endpoints it is a placeholder host.
	URL string
	// Socket is the Unix socket path, if the gateway is reached over a socket.
	Socket string
	Token  string
	// Source explains how the endpoint was found.
	Source string
}

Endpoint is a resolved gateway address plus token.

func Discover

func Discover(getenv func(string) string) (Endpoint, error)

Discover resolves the gateway from explicit settings, the container mount, or the current user's agent directory. Credentials always belong to the selected directory, so discovering a local gateway cannot replace a mounted host token.

func (Endpoint) HTTPClient

func (e Endpoint) HTTPClient() *http.Client

HTTPClient returns an HTTP client that reaches the endpoint and sends the token.

func (Endpoint) OpenTunnel added in v0.27.0

func (e Endpoint) OpenTunnel(ctx context.Context, osName, typ, arch string, port int, names ...string) (net.Conn, error)

OpenTunnel upgrades an authenticated HTTP/1 connection to a raw guest stream.

func (Endpoint) String

func (e Endpoint) String() string

String describes the endpoint without the token.

Jump to

Keyboard shortcuts

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