agent

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default path for the agent config file.

func RunConnect added in v0.6.1

func RunConnect(opts ConnectOptions)

RunConnect executes the agent connect workflow.

func SaveConfig

func SaveConfig(path string, cfg *Config) error

SaveConfig writes the agent config to disk.

Types

type Client

type Client struct {
	ServerURL     string
	SandboxID     string
	TunnelToken   string
	OpencodeURL   string
	OpencodeToken string
	// contains filtered or unexported fields
}

Client is the cli-agent tunnel client that connects to the server and forwards HTTP requests to a local opencode instance.

func NewClient

func NewClient(serverURL, sandboxID, tunnelToken, opencodeURL, opencodeToken string) *Client

NewClient creates a new agent tunnel client.

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run connects to the server and enters the tunnel event loop. It automatically reconnects with exponential backoff on disconnection.

type Config

type Config struct {
	Server      string `json:"server"`
	SandboxID   string `json:"sandboxId"`
	TunnelToken string `json:"tunnelToken"`
	WorkspaceID string `json:"workspaceId"`
	Name        string `json:"name"`
}

Config holds the local agent's persistent configuration.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads the agent config from disk.

func Register

func Register(serverURL, code, name string) (*Config, error)

Register registers a new local agent with the server using a one-time code.

type ConnectOptions added in v0.6.1

type ConnectOptions struct {
	Server         string
	Code           string
	Name           string
	OpencodeURL    string
	OpencodeURLSet bool // true if --opencode-url was explicitly provided
	OpencodeToken  string
	ConfigPath     string
	AutoStart      bool
	OpencodeBin    string
	OpencodePort   int
}

ConnectOptions holds all flags for the connect command.

type OpencodeProcess

type OpencodeProcess struct {
	Port int
	// contains filtered or unexported fields
}

OpencodeProcess manages a local opencode serve subprocess.

func StartOpencode

func StartOpencode(bin string, port int) (*OpencodeProcess, error)

StartOpencode starts "opencode serve --hostname 127.0.0.1 --port {port}" as a child process. It returns immediately after starting the process.

func (*OpencodeProcess) Stop

func (p *OpencodeProcess) Stop()

Stop sends SIGTERM to the child process, waits briefly, then sends SIGKILL if needed.

func (*OpencodeProcess) WaitReady

func (p *OpencodeProcess) WaitReady(ctx context.Context, timeout time.Duration) error

WaitReady polls http://localhost:{port}/ every 500ms until a response is received or the timeout expires.

Jump to

Keyboard shortcuts

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