admin / Syanpse-Vanguard
public
Syanpse-Vanguard / synapse-vanguard-v3 / sv / models / agent.py
1396 B · main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | """API contracts for agent enrollment and log streaming.""" from __future__ import annotations from datetime import datetime from uuid import UUID from pydantic import BaseModel, Field class AgentRegisterRequest(BaseModel): hostname: str platform: str = Field(pattern="^(windows|linux)$") agent_version: str channels: list[str] = Field(default_factory=list) # In full mTLS mode the agent submits a CSR the server-CA signs. In dev # (SV_MTLS_ENABLED=false) this may be omitted and the agent authenticates # subsequent calls with the returned bearer token. csr_pem: str | None = None class AgentRegisterResponse(BaseModel): agent_id: UUID # One of these is populated depending on mTLS mode: client_cert_pem: str | None = None ca_chain_pem: str | None = None ingest_token: str | None = None # dev-mode bearer fallback heartbeat_seconds: int = 60 class EventBundle(BaseModel): """Metadata envelope (sent as the X-SV-Bundle header). The compressed NDJSON body is the HTTP request body.""" agent_id: UUID seq: int # monotonic per-agent; enables idempotent replay codec: str = Field(pattern="^(zstd|gzip|none)$") event_count: int sent_at: datetime class IngestAck(BaseModel): accepted: int last_seq: int # agent trims its disk buffer up to here |