Files
Agent-System/internal/server/chat_recategorize_api.go
T
weichenandCursor f6813cc272 feat(api): add additive HTTP/SSE error envelopes
Public errors now emit code, safe message, and request_id while keeping the legacy error field. Raw SQL, paths, tokens, and XSS payloads are stripped; the frontend branches on code instead of substring matching.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 14:40:56 +00:00

40 lines
906 B
Go

package server
// chat_recategorize_api.go — 管理端点 POST /api/v1/chat/recategorize (Spec §3.4 A4)
import (
"encoding/json"
"net/http"
)
type recategorizeReq struct {
SessionID string `json:"session_id"`
}
func (s *Server) handleChatRecategorize(w http.ResponseWriter, r *http.Request) {
if s.ctxMgr == nil {
writeSafeError(w, r, http.StatusServiceUnavailable, "context manager unavailable")
return
}
var req recategorizeReq
if r.Body != nil {
_ = json.NewDecoder(r.Body).Decode(&req)
}
res, err := s.ctxMgr.RecategorizeMessages(r.Context(), req.SessionID)
if err != nil {
writeJSONResponse(w, http.StatusInternalServerError, map[string]any{
"success": false,
"error": err.Error(),
})
return
}
writeJSONResponse(w, http.StatusOK, map[string]any{
"success": true,
"total_processed": res.TotalProcessed,
"total_updated": res.TotalUpdated,
})
}