webagent

package
v0.0.0-nightly.20260802 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWSPath = "/api/agent/ws"

DefaultWSPath is the default WebSocket endpoint for agent connections.

Variables

This section is empty.

Functions

func BroadcastPTYSessions

func BroadcastPTYSessions(mgr *tmux.Manager, router *pty.Router, send func(webproto.Message))

BroadcastPTYSessions sends the current PTY session list to all active streams.

func DefaultRuntime

func DefaultRuntime() webproto.AgentRuntime

DefaultRuntime returns OS process metadata without introducing another identity beside the IOA NodeRef.

func HTTPToWS

func HTTPToWS(rawURL string) string

HTTPToWS converts an HTTP(S) URL to a WS(S) URL.

func HandleExec

func HandleExec(ctx context.Context, msg webproto.Message, baseDir string, send func(webproto.Message))

HandleExec runs Cairn's native shell RPC and returns output using the same correlated output/complete envelope as the file RPCs.

func HandleFileList

func HandleFileList(msg webproto.Message, baseDir string, send func(webproto.Message))

HandleFileList returns a directory listing as structured JSON. It does not invoke BashTool or parse terminal output.

func HandleFileMkdir

func HandleFileMkdir(msg webproto.Message, baseDir string, send func(webproto.Message))

HandleFileMkdir creates a directory using the host filesystem API.

func HandleFileRead

func HandleFileRead(msg webproto.Message, baseDir string, send func(webproto.Message))

HandleFileRead reads a file from disk and sends its base64-encoded content.

func HandleFileWrite

func HandleFileWrite(msg webproto.Message, baseDir string, send func(webproto.Message))

HandleFileWrite writes base64-encoded data from a message to a file on disk.

func HandleToolCallEvent

func HandleToolCallEvent(ctx context.Context, msg webproto.Message, event aop.Event, executor aopToolExecutor, dataBus *eventbus.Bus[output.ToolDataEvent], send func(webproto.Message))

HandleToolCallEvent executes one direct AOP tool.call and returns its terminal tool.result through the same AOP envelope.

func NewPTYRouter

func NewPTYRouter(reg *commands.CommandRegistry) *pty.Router

NewPTYRouter creates the tool-node fallback router. Agent transports receive their router directly from AgentRuntime and do not inspect the bash tool.

func RegisterPayload

func RegisterPayload(name string, reg *commands.CommandRegistry, ref protocols.NodeRef, runtimeInfo webproto.AgentRuntime, statusFn func() webproto.AgentStatus, menuFn func() []webproto.CommandSpec, stats webproto.AgentStats) (webproto.RegisterPayload, error)

RegisterPayload builds the WebSocket registration payload.

func RegistryPTYManager

func RegistryPTYManager(reg *commands.CommandRegistry) *tmux.Manager

RegistryPTYManager extracts the tmux Manager from the "bash" tool in the command registry, if available.

func RunToolNode

func RunToolNode(ctx context.Context, cfg ToolNodeConfig) error

RunToolNode connects to the hub as a tool-only node and serves until ctx is done, reconnecting with backoff on connection loss.

func RunWebSocket

func RunWebSocket(ctx context.Context, option *cfg.Option, logger telemetry.Logger) error

func SplitAccessKey

func SplitAccessKey(rawURL string) (dialURL, token string)

SplitAccessKey lifts the access token out of a URL's userinfo (http://<token>@host...), returning a userinfo-free URL plus the token. A URL without userinfo (or an unparseable one) comes back unchanged with an empty token.

func SubscribePTYSessions

func SubscribePTYSessions(ctx context.Context, mgr *tmux.Manager, router *pty.Router, send func(webproto.Message)) func()

SubscribePTYSessions subscribes to PTY session changes and broadcasts session state to all active PTY streams.

Types

type AgentStatsTracker

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

AgentStatsTracker tracks agent event statistics for the WebSocket connection.

func NewAgentStatsTracker

func NewAgentStatsTracker() *AgentStatsTracker

NewAgentStatsTracker creates a new stats tracker.

func (*AgentStatsTracker) Observe

Observe records an AOP event and returns updated stats if the stats changed.

func (*AgentStatsTracker) Snapshot

func (t *AgentStatsTracker) Snapshot() webproto.AgentStats

Snapshot returns the current stats snapshot.

type ToolNodeConfig

type ToolNodeConfig struct {
	ServerURL string
	WSPath    string
	// ID is the stable node identity used by Cairn as the runner primary key.
	ID       string
	Token    string
	Registry *commands.CommandRegistry
	DataBus  *eventbus.Bus[output.ToolDataEvent]
	SCO      *output.SCOSidecar
	Logger   telemetry.Logger
	Version  string
}

ToolNodeConfig configures a tool-only runner: an outbound WebSocket connection exposing Command, native file RPCs, PTY, tool.data and tool.sco, with no LLM provider, agent loop, or IOA dependency.

Jump to

Keyboard shortcuts

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