Documentation
¶
Overview ¶
Package ws provides a Phoenix Channel client over WebSocket for consuming real-time agent events from reef-core.
Index ¶
- Constants
- type Client
- type CompletePayload
- type CostPayload
- type ErrorPayload
- type LifecyclePayload
- type PhoenixMsg
- type StreamPayload
- type ToolCallPayload
- type WsAgentExited
- type WsAgentStarted
- type WsCompleteMsg
- type WsConnectedMsg
- type WsCostMsg
- type WsDisconnectedMsg
- type WsErrorMsg
- type WsPodCostMsg
- type WsStreamMsg
- type WsToolCallMsg
Constants ¶
const ( HeartbeatInterval = 30 * time.Second HeartbeatTimeout = 10 * time.Second ReconnectMin = 1 * time.Second ReconnectMax = 30 * time.Second )
Phoenix protocol constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a WebSocket connection to reef-core's Phoenix Channel endpoint. It joins channels, sends heartbeats, and dispatches incoming events as Bubble Tea messages via program.Send().
func (*Client) Connect ¶
Connect opens the WebSocket, starts heartbeat, joins pod:events, and begins reading messages. Handles reconnection internally with exponential backoff. Must be called from a goroutine.
func (*Client) JoinAgent ¶
JoinAgent joins the agent:<id> channel, leaving any previously joined agent channel. Safe to call from any goroutine.
func (*Client) LeaveAgent ¶
LeaveAgent leaves the current agent channel.
type CompletePayload ¶
type CompletePayload struct {
Result string `json:"result"`
}
CompletePayload carries a task completion event.
type CostPayload ¶
type CostPayload struct {
Sats int64 `json:"sats"`
}
CostPayload carries a spend event.
type ErrorPayload ¶
type ErrorPayload struct {
Message string `json:"message"`
}
ErrorPayload carries an agent error event.
type LifecyclePayload ¶
type LifecyclePayload struct {
AgentID string `json:"agent_id"`
Name string `json:"name,omitempty"`
Code int `json:"code,omitempty"`
}
LifecyclePayload carries agent started/exited events on pod:events.
type PhoenixMsg ¶
type PhoenixMsg struct {
JoinRef string `json:"join_ref"`
Ref string `json:"ref"`
Topic string `json:"topic"`
Event string `json:"event"`
Payload any `json:"payload"`
}
PhoenixMsg is the JSON envelope used by Phoenix Channels. Every message over the WebSocket uses this shape.
type StreamPayload ¶
type StreamPayload struct {
Data string `json:"data"`
}
StreamPayload carries agent text output.
type ToolCallPayload ¶
type ToolCallPayload struct {
Tool string `json:"tool"`
}
ToolCallPayload carries a tool invocation event.
type WsAgentExited ¶
WsAgentExited signals an agent left the pod.
type WsAgentStarted ¶
type WsAgentStarted struct{ AgentID, Name string }
WsAgentStarted signals a new agent joined the pod.
type WsCompleteMsg ¶
type WsCompleteMsg struct{ AgentID, Result string }
WsCompleteMsg signals task completion.
type WsConnectedMsg ¶
type WsConnectedMsg struct{}
WsConnectedMsg signals the WebSocket connected successfully.
type WsCostMsg ¶
WsCostMsg carries a per-agent spend event from the AgentChannel. It is only delivered while an agent:<id> topic is joined — typically when the Inspector is open on that agent.
type WsDisconnectedMsg ¶
type WsDisconnectedMsg struct{ Err error }
WsDisconnectedMsg signals the WebSocket disconnected.
type WsErrorMsg ¶
type WsErrorMsg struct{ AgentID, Message string }
WsErrorMsg carries an agent error.
type WsPodCostMsg ¶
WsPodCostMsg carries a pod-wide spend event from the PodEventsChannel. It is delivered for every agent_cost broadcast regardless of which (if any) agent channel is currently joined, so the Budget tab stays live even when no Inspector is open.
type WsStreamMsg ¶
type WsStreamMsg struct{ AgentID, Data string }
WsStreamMsg carries streaming text output from an agent.
type WsToolCallMsg ¶
type WsToolCallMsg struct{ AgentID, Tool string }
WsToolCallMsg carries a tool invocation event.