Skip to main content

Crate zeroclaw_gateway

Crate zeroclaw_gateway 

Source
Expand description

Axum-based HTTP gateway with proper HTTP/1.1 compliance, body limits, and timeouts.

This module replaces the raw TCP implementation with axum for:

  • Proper HTTP/1.1 parsing and compliance
  • Content-Length validation (handled by hyper)
  • Request body size limits (64KB max)
  • Request timeouts (30s) to prevent slow-loris attacks
  • Header sanitization (handled by axum/hyper)

Modules§

acp
ACP-over-WebSocket gateway endpoint.
api
REST API handlers for the web dashboard.
api_browse
HTTP adapter over zeroclaw_runtime::browse::list_directory.
api_config
Per-property CRUD endpoints for /api/config/*.
api_logs
GET /api/logs — paginated query over the persisted JSONL log.
api_pairing
Device management and pairing API handlers.
api_personality
Read/write endpoints for per-agent personality markdown files (SOUL.md, IDENTITY.md, USER.md, AGENTS.md, TOOLS.md, HEARTBEAT.md, BOOTSTRAP.md, MEMORY.md).
api_quickstart
HTTP routes for the Quickstart flow.
api_sections
Curated config-section endpoints. Used by the /config page in the web dashboard to navigate the schema by curated section rather than raw prop paths. OpenAPI is authoritative for the exact route set.
api_skills
HTTP adapter over zeroclaw_runtime::skills::SkillsService.
auth_rate_limit
Sliding-window rate limiter for authentication attempts.
canvas
Live Canvas gateway routes — REST + WebSocket for real-time canvas updates.
hardware_context
Hardware context management endpoints.
node_tool
Wraps a node capability as a zeroclaw Tool so it can be dispatched through the existing tool registry and agent loop.
nodes
WebSocket endpoint for dynamic node discovery and capability advertisement.
openapi
Runtime-generated OpenAPI 3.1 document for the new /api/config/* surface.
session_queue
Re-export from zeroclaw-infra so existing gateway imports keep working.
sse
Server-Sent Events (SSE) stream for real-time event delivery.
static_files
Static file serving for the web dashboard.
tls
TLS and mutual TLS (mTLS) support for the gateway server.
ws
WebSocket agent chat handler.
ws_approval
WebSocket-backed Channel implementation that surfaces tool approval prompts to the gateway client and waits for the operator’s decision.

Structs§

AdminPaircodeQuery
Query parameters for POST /admin/paircode/new.
AppState
Shared state for all axum handlers
GatewayRateLimiter
IdempotencyStore
WatiVerifyQuery
WebhookBody
Webhook request body
WebhookQuery
Webhook query parameters
WhatsAppVerifyQuery
WhatsApp verification query params

Constants§

IDEMPOTENCY_MAX_KEYS_DEFAULT
Fallback max distinct idempotency keys retained in gateway memory.
LONG_RUNNING_REQUEST_TIMEOUT_SECS
Default request timeout for POST /api/cron/{id}/run (10 minutes).
MAX_BODY_SIZE
Maximum request body size (64KB) — prevents memory exhaustion
RATE_LIMIT_MAX_KEYS_DEFAULT
Fallback max distinct client keys tracked in gateway rate limiter.
RATE_LIMIT_WINDOW_SECS
Sliding window used by gateway rate limiting.
REQUEST_TIMEOUT_SECS
Default request timeout (30s) — prevents slow-loris attacks.

Functions§

gateway_long_running_request_timeout_secs
Manual cron-trigger request timeout (seconds), exempt from the gateway-wide gateway_request_timeout_secs limit so synchronous agent jobs can run to completion. Reads from typed config.
gateway_request_timeout_secs
Gateway request timeout (seconds) for routes other than the long-running cron-trigger endpoint. Reads from typed config.
run_gateway
Run the HTTP gateway using axum with proper HTTP/1.1 compliance.
verify_whatsapp_signature
Verify WhatsApp webhook signature (X-Hub-Signature-256). Returns true if the signature is valid, false otherwise. See: https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests