Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Envelope ¶
type Envelope struct {
ID string `json:"id"`
Source string `json:"source"`
Destination string `json:"destination"`
Protocol protocol.Protocol `json:"protocol"`
MessageType MessageType `json:"message_type"`
ContentType string `json:"content_type"`
Payload []byte `json:"payload"`
Metadata map[string]string `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
TTL int `json:"ttl,omitempty"`
TraceID string `json:"trace_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
Signature string `json:"signature,omitempty"`
Nonce string `json:"nonce,omitempty"`
Encrypted bool `json:"encrypted,omitempty"`
SenderX25519 string `json:"sender_x25519,omitempty"`
}
Envelope is the universal message wrapper that bridges different AI agent protocols. Every message flowing through PeerClaw is wrapped in an Envelope regardless of the originating protocol.
func NewResponse ¶ added in v0.3.0
NewResponse creates a response envelope from a request envelope. It generates a new ID, copies TraceID and SessionID from the request, swaps Source and Destination, and sets MessageType to response.
func (*Envelope) GetSignature ¶ added in v0.4.0
GetSignature returns the envelope's signature field.
func (*Envelope) SetSignature ¶ added in v0.4.0
SetSignature sets the envelope's signature field.
func (*Envelope) SigningPayload ¶ added in v0.4.0
SigningPayload returns a canonical byte representation of the envelope's security-critical fields for signing. This covers Source, Destination, Protocol, MessageType, Nonce, Timestamp, and Payload — preventing an attacker from modifying routing or replay-protection fields without invalidating the signature.
This implements the identity.SignableEnvelope interface.
func (*Envelope) WithMetadata ¶
WithMetadata adds a metadata key-value pair and returns the envelope for chaining.
func (*Envelope) WithSessionID ¶ added in v0.2.0
WithSessionID sets the session ID for multi-turn conversations and returns the envelope for chaining.
type MessageType ¶
type MessageType string
MessageType categorizes the purpose of a message.
const ( MessageTypeRequest MessageType = "request" MessageTypeResponse MessageType = "response" MessageTypeEvent MessageType = "event" MessageTypeError MessageType = "error" )