gateway

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 New

func New(assistant *copilot.Assistant, cfg copilot.GatewayConfig, logger *slog.Logger) *Gateway

New creates a new 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

func (g *Gateway) DeleteWebhook(id string) bool

DeleteWebhook removes a webhook by ID.

func (*Gateway) ListWebhooks

func (g *Gateway) ListWebhooks() []WebhookEntry

ListWebhooks returns all registered webhooks.

func (*Gateway) Start

func (g *Gateway) Start(ctx context.Context) error

Start starts the HTTP server.

func (*Gateway) Stop

func (g *Gateway) Stop(ctx context.Context) error

Stop gracefully shuts down the HTTP server.

func (*Gateway) ToggleWebhook

func (g *Gateway) ToggleWebhook(id string, active bool) bool

ToggleWebhook enables or disables a webhook by ID.

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.

type WebhookEntry

type WebhookEntry struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	Events    []string  `json:"events"`
	CreatedAt time.Time `json:"created_at"`
	Active    bool      `json:"active"`
}

WebhookEntry represents a registered outgoing webhook.

Jump to

Keyboard shortcuts

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