Honeycomb und Control-Patch
This commit is contained in:
@@ -31,6 +31,9 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("GET /api/status", s.handleStatus)
|
||||
mux.HandleFunc("GET /api/graph", s.handleGraph)
|
||||
mux.HandleFunc("GET /api/analysis", s.handleAnalysis)
|
||||
mux.HandleFunc("GET /api/runtime-settings", s.handleGetRuntimeSettings)
|
||||
mux.HandleFunc("PUT /api/runtime-settings", s.handleSetRuntimeSettings)
|
||||
mux.HandleFunc("GET /api/categories", s.handleCategories)
|
||||
mux.HandleFunc("GET /api/stream", s.Broker.ServeSSE)
|
||||
mux.HandleFunc("POST /api/query", s.handleQuery)
|
||||
mux.HandleFunc("POST /api/events", s.handleEvent)
|
||||
@@ -60,6 +63,33 @@ func (s *Server) handleGraph(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleAnalysis(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, 200, s.Graph.Analyze())
|
||||
}
|
||||
|
||||
func (s *Server) handleGetRuntimeSettings(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, s.Engine.RuntimeSettings())
|
||||
}
|
||||
|
||||
func (s *Server) handleSetRuntimeSettings(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.authorized(r) {
|
||||
writeJSON(w, http.StatusUnauthorized, map[string]string{"error": "unauthorized"})
|
||||
return
|
||||
}
|
||||
var settings engine.RuntimeSettings
|
||||
if err := decode(r, &settings); err != nil {
|
||||
writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
updated, err := s.Engine.SetRuntimeSettings(settings)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, updated)
|
||||
}
|
||||
|
||||
func (s *Server) handleCategories(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{"categories": s.Engine.Categories()})
|
||||
}
|
||||
|
||||
func (s *Server) handleQuery(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.authorized(r) {
|
||||
writeJSON(w, 401, map[string]string{"error": "unauthorized"})
|
||||
@@ -145,6 +175,10 @@ func (s *Server) handleEnrich(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if r.URL.Query().Get("async") == "1" {
|
||||
if !s.Engine.ThinkingEnabled() {
|
||||
writeJSON(w, http.StatusConflict, map[string]any{"error": "AI-THINK is disabled by runtime settings", "status": s.Engine.Status()})
|
||||
return
|
||||
}
|
||||
if !s.Engine.RequestEnrich("manual") {
|
||||
writeJSON(w, http.StatusConflict, map[string]any{"error": "AI-THINK is already running or queued", "status": s.Engine.Status()})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user