Documentation
¶
Overview ¶
Package gateway provides an HTTP API gateway for DevClaw.
Package gateway provides an HTTP API gateway for DevClaw.
Package gateway – websocket.go implements a bidirectional JSON-RPC WebSocket endpoint for real-time communication with the DevClaw agent.
Protocol:
Client → Server (requests):
{"type":"req","id":"1","method":"chat.send","params":{"sessionId":"...","content":"..."}}
{"type":"req","id":"2","method":"chat.abort","params":{"sessionId":"..."}}
{"type":"req","id":"3","method":"chat.history","params":{"sessionId":"..."}}
Server → Client (responses):
{"type":"res","id":"1","ok":true,"payload":{"runId":"..."}}
Server → Client (events — unsolicited):
{"type":"event","event":"delta","payload":{"content":"..."}}
{"type":"event","event":"tool_use","payload":{"tool":"...","input":{...}}}
{"type":"event","event":"done","payload":{"usage":{...}}}
Index ¶
- Variables
- type Gateway
- func (g *Gateway) AddWebhook(webhookURL string, events []string) (WebhookEntry, error)
- func (g *Gateway) DeleteWebhook(id string) bool
- func (g *Gateway) ListWebhooks() []WebhookEntry
- func (g *Gateway) Start(ctx context.Context) error
- func (g *Gateway) Stop(ctx context.Context) error
- func (g *Gateway) ToggleWebhook(id string, active bool) bool
- type WebSocketHandler
- type WebhookEntry
Constants ¶
This section is empty.
Variables ¶
var ValidWebhookEvents = []string{
"message.received",
"message.sent",
"agent.started",
"agent.completed",
"agent.error",
"tool.called",
"tool.completed",
"session.created",
"session.deleted",
}
ValidWebhookEvents lists all supported webhook event types.
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the HTTP API gateway.
func (*Gateway) AddWebhook ¶
func (g *Gateway) AddWebhook(webhookURL string, events []string) (WebhookEntry, error)
AddWebhook registers a new webhook and returns the entry or an error. Returns an error if the URL targets a private/loopback address (SSRF guard).
func (*Gateway) DeleteWebhook ¶
DeleteWebhook removes a webhook by ID.
func (*Gateway) ListWebhooks ¶
func (g *Gateway) ListWebhooks() []WebhookEntry
ListWebhooks returns all registered webhooks.
type WebSocketHandler ¶
type WebSocketHandler struct {
// contains filtered or unexported fields
}
WebSocketHandler upgrades HTTP connections to WebSocket and handles bidirectional JSON-RPC communication.
func NewWebSocketHandler ¶
func NewWebSocketHandler(api webui.AssistantAPI, logger *slog.Logger) *WebSocketHandler
NewWebSocketHandler creates a new WebSocket handler.
func (*WebSocketHandler) ServeHTTP ¶
func (h *WebSocketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP upgrades the connection and starts the message loop.