Skip to main content

Crate grapsus_agent_protocol

Crate grapsus_agent_protocol 

Source
Expand description

Agent protocol for Grapsus proxy

This crate defines the protocol for communication between the proxy dataplane and external processing agents (WAF, auth, rate limiting, custom logic).

The protocol is inspired by SPOE (Stream Processing Offload Engine) and Envoy’s ext_proc, designed for bounded, predictable behavior with strong failure isolation.

§Architecture

§Transports

Two transport options are supported:

§Unix Domain Sockets (Default)

Messages are length-prefixed with negotiated encoding (JSON or MessagePack):

  • 4-byte big-endian length prefix
  • Encoded payload (max 10MB)

§gRPC

Binary protocol using Protocol Buffers over HTTP/2:

  • Better performance for high-throughput scenarios
  • Native support for TLS/mTLS
  • Language-agnostic (agents can be written in any language with gRPC support)

Modules§

binary
Binary protocol for Unix Domain Socket transport.
buffer_pool
Buffer pooling for message serialization/deserialization.
grpc_v2
gRPC v2 protocol definitions generated from proto/agent_v2.proto
headers
Zero-copy header types for efficient header processing.
v2
Protocol v2 types with bidirectional streaming, capabilities, and flow control Protocol v2 types for Agent Protocol 2.0

Structs§

AgentResponse
Agent response message
AuditMetadata
Audit metadata from agent
BinaryRequestBodyChunkEvent
Binary request body chunk event.
BinaryResponseBodyChunkEvent
Binary response body chunk event.
BodyMutation
Body mutation from agent
GuardrailDetection
A single guardrail detection (prompt injection attempt, PII instance, etc.)
GuardrailInspectEvent
Guardrail inspection event
GuardrailResponse
Guardrail inspection response from agent
RequestBodyChunkEvent
Request body chunk event
RequestCompleteEvent
Request complete event (for logging/audit)
RequestHeadersEvent
Request headers event
RequestMetadata
Request metadata sent to agents
ResponseBodyChunkEvent
Response body chunk event
ResponseHeadersEvent
Response headers event
TextSpan
Text span indicating location in content
WebSocketFrameEvent
WebSocket frame event

Enums§

AgentProtocolError
Agent protocol errors
Decision
Agent decision
DetectionSeverity
Severity level for guardrail detections
EventType
Agent event type
GuardrailInspectionType
Type of guardrail inspection to perform
HeaderOp
Header modification operation
WebSocketDecision
WebSocket frame decision
WebSocketOpcode
WebSocket opcode

Constants§

MAX_MESSAGE_SIZE
Maximum message size for gRPC transport (10MB)