Gleipnir is a Bun + Hono prototype for AI traffic observation, evidence retrieval, and safety control loops. The repository currently brings four capabilities together in one service:
- ReAct-style agent endpoints
- AgentSight event inspection and stream analysis tools
- Local SQLite/FTS-based Log RAG for evidence retrieval
- An OpenClaw security audit loop demo
The project is best understood as a backend capability prototype rather than a finished product. It already covers observation, retrieval, auditing, and part of the control plane, but it does not yet include production-grade rule staging, approval gates, rollback, or incident state management.
POST /chat- General-purpose agent for Q&A, operational checks, and AgentGuardian / Log RAG tool usage
POST /agents/packet-analyzer/chat- Packet-analysis agent focused on AgentSight request/response evidence and streaming diagnostics
DELETE /memory/:sessionId- Clear session history
Implementation:
The agent can currently call:
getAgentSightAiEvents- Read AgentSight snapshot events and filter AI request/response traffic
getAgentSightAiEventsStream- Read AgentSight SSE streams and filter AI request/response traffic
getAgentGuardianStatus- Query AgentGuardian
permanentandruntimestate
- Query AgentGuardian
validateAgentGuardianRules- Validate AgentGuardian rules
reloadAgentGuardianRules- Reload
permanentrules intoruntime
- Reload
retrieveLogEvidence- Search historical evidence in the local log evidence store
Implementation:
The current Log RAG implementation already supports:
- parsing AgentSight and decoded NDJSON
- extracting AI-related events into compact evidence documents
- storing evidence in local SQLite
- indexing evidence with SQLite FTS5
- exposing retrieval through CLI, HTTP APIs, and the tool layer
Entrypoints:
POST /rag/logs/ingestPOST /rag/logs/searchbun run log-rag:ingestbun run log-rag:search
Implementation:
The repository also includes an OpenClaw security loop demo that can:
- audit AI request/response summaries
- detect secret leaks and prompt injection patterns
- generate a simulated Guardian proposal
- simulate post-enforcement re-audit results
Entrypoint:
POST /demo/security-loop/run
Implementation:
What is already in place:
- HTTP service and core routes
- two agent modes:
generalandpacket-analysis - session memory backed by SQLite
- AgentSight snapshot and SSE stream readers
- AgentGuardian control-plane actions:
status,validate,reload - log evidence ingestion and retrieval
- security loop demo plus baseline tests
What is still missing:
- Guardian rule staging or writing tools
- a proposal-to-policy conversion layer
- rollback support
- incident lifecycle and audit trail management
- approval gates, dry-run flow, and dual control
- a unified UI for operators or product integration
bun installmkdir -p config
cp config/llm.example.json config/llm.jsonEdit config/llm.json and provide a real apiKey.
Two configuration styles are supported:
- provide
baseURLdirectly - or provide
host + apiPath
By default the app reads config/llm.json. You can override the path with LLM_CONFIG_FILE.
bun run devor:
bun run startThe server tries 3001, 3002, and 8787 by default. You can also set PORT explicitly.
bun run test
bun run typecheckpython3 script/decode.py --input logs/oc.log --output logs/oc.decoded.ndjson
bun run log-rag:ingest -- --input logs/oc.decoded.ndjson
bun run log-rag:search -- --query "chat completions"curl http://localhost:3001/curl -X POST http://localhost:3001/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Check the current AgentGuardian rule status"
}'curl -X POST http://localhost:3001/agents/packet-analyzer/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Analyze recent AI responses and look for anomalies or secret leak signals"
}'curl -X POST http://localhost:3001/rag/logs/ingest \
-H "Content-Type: application/json" \
-d '{
"inputPath": "logs/oc.decoded.ndjson",
"aiOnly": true
}'curl -X POST http://localhost:3001/rag/logs/search \
-H "Content-Type: application/json" \
-d '{
"query": "secret leak",
"limit": 5,
"requestResponseType": "both"
}'curl -X POST http://localhost:3001/demo/security-loop/run \
-H "Content-Type: application/json" \
-d '{
"scenario": "openclaw-secret-leak"
}'.
├── src/
│ ├── index.ts # HTTP API entrypoint
│ ├── agent.ts # agent runtime and profiles
│ ├── tools.ts # AgentSight / AgentGuardian / Log RAG tools
│ ├── memory.ts # SQLite-backed session memory
│ ├── log-rag.ts # log evidence ingest and retrieval
│ └── demo.ts # security audit loop demo
├── script/
│ ├── decode.py # OpenClaw/AgentSight log decoder
│ └── log-rag.ts # Log RAG CLI
├── config/
│ └── llm.example.json
└── doc/
└── README.md # documentation index
- doc/README.md
- doc/react-agent-architecture.md
- doc/tool-api.md
- doc/log-rag.md
- doc/security-audit-control-loop.md
- doc/sse-processor.md
-
Add Guardian rule staging. Introduce
stageGuardianRuleso proposals can be written into a validateable permanent ruleset and turned into a realproposal -> validate -> reloadflow. -
Introduce an incident state machine. Connect observation, audit, proposal, enforcement, and verification under one consistent lifecycle model.
-
Extract the demo audit logic into a reusable audit layer. Turn the current regex-based checks into configurable policies with scoring, false-positive handling, and versioning.
-
Strengthen the AgentSight evidence model. Unify snapshot and stream evidence shapes and make request/response/SSE-merged correlation keys explicit.
-
Stabilize external contracts. Lock down HTTP API shapes, tool schemas, and integration-facing documentation before building UI or broader automation on top.