mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-07 04:50:57 +08:00
SSE Streaming: - Add POST /api/agent/chat/stream endpoint with real SSE streaming - Agent.HandleMessageStream() streams final LLM response via onEvent callback - Tool-calling rounds use non-streaming; tool status sent as 'tool' events - Frontend uses ReadableStream API instead of fake word-by-word setTimeout - SSE events: tool (tool execution), delta (text chunk), done (complete), error Data Maintenance: - Add cleanupOldData() on server startup (decisions >90d, equity >180d) - Add CleanOldRecords to DecisionStore and EquityStore - Add store-level logger for cleanup operations Exchange Traders: - Add GetAccountInfo() to Bitget, Bybit, Indodax, KuCoin, Lighter, OKX traders - Remove unused imports in Aster/Lighter traders
20 lines
758 B
Go
20 lines
758 B
Go
package api
|
|
|
|
import (
|
|
"nofx/agent"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// RegisterAgentHandler registers NOFXi agent API routes on the main router.
|
|
// Chat endpoint requires authentication; market data endpoints are public.
|
|
func (s *Server) RegisterAgentHandler(h *agent.WebHandler) {
|
|
// Chat requires auth — can trigger trades and access account data
|
|
s.router.POST("/api/agent/chat", s.authMiddleware(), gin.WrapF(h.HandleChat))
|
|
s.router.POST("/api/agent/chat/stream", s.authMiddleware(), gin.WrapF(h.HandleChatStream))
|
|
// Public endpoints — read-only market data
|
|
s.router.GET("/api/agent/health", gin.WrapF(h.HandleHealth))
|
|
s.router.GET("/api/agent/klines", gin.WrapF(h.HandleKlines))
|
|
s.router.GET("/api/agent/ticker", gin.WrapF(h.HandleTicker))
|
|
}
|