rwagent

package
v0.115.0-nightly Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package rwagent provides a Go client for the RootWallet agent daemon.

The agent is a persistent daemon that holds vault keys in memory and serves operations to authorized apps over a Unix socket HTTP API. This SDK replaces all subprocess `rw` calls with direct HTTP communication.

Index

Constants

View Source
const (
	// DefaultSocketName is the socket file relative to ~/.rootwallet/.
	DefaultSocketName = "agent.sock"

	// DefaultTimeout for HTTP requests to the agent.
	// Set high enough to allow pending approval flow (2 min approval timeout).
	DefaultTimeout = 150 * time.Second
)

Variables

View Source
var ErrAgentNotRunning = fmt.Errorf("rootwallet agent is not running — start with: rw agent start && rw agent unlock")

ErrAgentNotRunning is returned when the agent socket is not reachable.

Functions

func IsApprovalDenied

func IsApprovalDenied(err error) bool

IsApprovalDenied returns true if the user denied the app's access request.

func IsLocked

func IsLocked(err error) bool

IsLocked returns true if the error indicates the agent is locked.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the vault entry was not found.

func IsNotRunning

func IsNotRunning(err error) bool

IsNotRunning returns true if the error indicates the agent is not reachable.

Types

type AgentError

type AgentError struct {
	Code       string // e.g., "AGENT_LOCKED", "NOT_FOUND"
	Message    string
	StatusCode int
}

AgentError represents an error returned by the rootwallet agent API.

func (*AgentError) Error

func (e *AgentError) Error() string

type AppPermission

type AppPermission struct {
	BinaryHash   string                `json:"binaryHash"`
	BinaryPath   string                `json:"binaryPath"`
	Name         string                `json:"name"`
	FirstSeen    string                `json:"firstSeen"`
	LastUsed     string                `json:"lastUsed"`
	Capabilities []PermittedCapability `json:"capabilities"`
}

AppPermission represents an approved app in the permission database.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the rootwallet agent daemon over a Unix socket.

func New

func New(socketPath string) *Client

New creates a client that connects to the agent's Unix socket. If socketPath is empty, defaults to ~/.rootwallet/agent.sock.

func (*Client) CreateSSHEntry

func (c *Client) CreateSSHEntry(ctx context.Context, host, username string) (*VaultSSHData, error)

CreateSSHEntry creates a new SSH key entry in the vault.

func (*Client) GetAddress

func (c *Client) GetAddress(ctx context.Context, chain string) (*WalletAddressData, error)

GetAddress returns the active wallet address.

func (*Client) GetPassword

func (c *Client) GetPassword(ctx context.Context, domain, username string) (*VaultPasswordData, error)

GetPassword retrieves a stored password from the vault.

func (*Client) GetSSHKey

func (c *Client) GetSSHKey(ctx context.Context, host, username, format string) (*VaultSSHData, error)

GetSSHKey retrieves an SSH key from the vault. format: "priv", "pub", or "both".

func (*Client) IsRunning

func (c *Client) IsRunning(ctx context.Context) bool

IsRunning returns true if the agent is reachable.

func (*Client) Lock

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

Lock locks the agent, zeroing all key material.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*StatusResponse, error)

Status returns the agent's current status.

func (*Client) Unlock

func (c *Client) Unlock(ctx context.Context, password string, ttlMinutes int) error

Unlock sends the password to unlock the agent.

type PermittedCapability

type PermittedCapability struct {
	Capability string `json:"capability"`
	GrantedAt  string `json:"grantedAt"`
}

PermittedCapability is a specific capability granted to an app.

type StatusResponse

type StatusResponse struct {
	Version       string `json:"version"`
	Locked        bool   `json:"locked"`
	Uptime        int    `json:"uptime"`
	PID           int    `json:"pid"`
	ConnectedApps int    `json:"connectedApps"`
}

StatusResponse from GET /v1/status.

type VaultPasswordData

type VaultPasswordData struct {
	Password string `json:"password"`
}

VaultPasswordData from GET /v1/vault/password/:domain/:user.

type VaultSSHData

type VaultSSHData struct {
	PrivateKey string `json:"privateKey,omitempty"`
	PublicKey  string `json:"publicKey,omitempty"`
}

VaultSSHData from GET /v1/vault/ssh/:host/:user.

type WalletAddressData

type WalletAddressData struct {
	Address string `json:"address"`
	Chain   string `json:"chain"`
}

WalletAddressData from GET /v1/wallet/address.

Jump to

Keyboard shortcuts

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