chore: auto-commit (8 archivos)
- backend/handlers.go - data.cpp - data.h - main.cpp - panel_board.cpp - panel_filters.cpp - appicon.ico - backend/kanban_cpp_backend.exe Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+78
-4
@@ -1,8 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -11,6 +13,8 @@ import (
|
||||
"fn-registry/functions/infra"
|
||||
)
|
||||
|
||||
const agentRunnerBase = "http://127.0.0.1:8486"
|
||||
|
||||
func (s *Server) registerRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/api/health", s.handleHealth)
|
||||
mux.HandleFunc("/api/issues", s.handleIssues)
|
||||
@@ -19,6 +23,8 @@ func (s *Server) registerRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/api/flows/", s.handleFlowByID)
|
||||
mux.HandleFunc("/api/meta", s.handleMeta)
|
||||
mux.HandleFunc("/api/sse", s.handleSSE)
|
||||
mux.HandleFunc("/api/agent_status", s.handleAgentStatus)
|
||||
mux.HandleFunc("/api/agent_launch", s.handleAgentLaunch)
|
||||
}
|
||||
|
||||
func writeJSON(w http.ResponseWriter, status int, v any) {
|
||||
@@ -279,13 +285,81 @@ func (s *Server) handleFlowByID(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) handleMeta(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, 200, map[string]any{
|
||||
"statuses": []string{"pendiente", "in-progress", "bloqueado", "completado", "deferred", "descartado"},
|
||||
"priorities": []string{"critica", "alta", "media", "baja"},
|
||||
"scopes": []string{"registry-only", "app-scoped", "multi-app", "cross-stack"},
|
||||
"types": []string{"feature", "bugfix", "refactor", "docs", "chore", "research", "infra", "app", "spike", "epic", "planning"},
|
||||
"statuses": []string{"ideas", "pendiente", "in-progress", "bloqueado", "completado", "deferred", "descartado"},
|
||||
"board_columns": []string{"ideas", "pendiente", "in-progress", "completado"},
|
||||
"priorities": []string{"critica", "alta", "media", "baja"},
|
||||
"scopes": []string{"registry-only", "app-scoped", "multi-app", "cross-stack"},
|
||||
"types": []string{"feature", "bugfix", "refactor", "docs", "chore", "research", "infra", "app", "spike", "epic", "planning"},
|
||||
})
|
||||
}
|
||||
|
||||
// GET /api/agent_status — proxies agent_runner_api running runs, returns map issue_id -> run_id
|
||||
func (s *Server) handleAgentStatus(w http.ResponseWriter, r *http.Request) {
|
||||
resp, err := http.Get(agentRunnerBase + "/api/runs?status=running")
|
||||
if err != nil {
|
||||
writeJSON(w, 200, map[string]any{"available": false, "active": map[string]string{}})
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
var runs []map[string]any
|
||||
if err := json.Unmarshal(body, &runs); err != nil {
|
||||
writeJSON(w, 200, map[string]any{"available": false, "active": map[string]string{}})
|
||||
return
|
||||
}
|
||||
active := map[string]string{}
|
||||
for _, run := range runs {
|
||||
issueID, _ := run["issue_id"].(string)
|
||||
runID, _ := run["id"].(string)
|
||||
if issueID != "" && runID != "" {
|
||||
active[issueID] = runID
|
||||
}
|
||||
}
|
||||
writeJSON(w, 200, map[string]any{"available": true, "active": active})
|
||||
}
|
||||
|
||||
// POST /api/agent_launch {"issue_id":"NNNN"} — forwards to agent_runner_api
|
||||
func (s *Server) handleAgentLaunch(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
writeErr(w, 405, "method not allowed")
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
IssueID string `json:"issue_id"`
|
||||
Mode string `json:"mode"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeErr(w, 400, "bad json")
|
||||
return
|
||||
}
|
||||
if req.IssueID == "" {
|
||||
writeErr(w, 400, "issue_id required")
|
||||
return
|
||||
}
|
||||
if req.Mode == "" {
|
||||
req.Mode = "fix-issue"
|
||||
}
|
||||
payload, _ := json.Marshal(map[string]string{
|
||||
"issue_id": req.IssueID,
|
||||
"mode": req.Mode,
|
||||
"kanban_app": "kanban_cpp",
|
||||
})
|
||||
resp, err := http.Post(agentRunnerBase+"/api/runs", "application/json", bytes.NewReader(payload))
|
||||
if err != nil {
|
||||
writeErr(w, 502, fmt.Sprintf("agent_runner_api unreachable: %v", err))
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode >= 400 {
|
||||
writeErr(w, resp.StatusCode, string(body))
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(resp.StatusCode)
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
func (s *Server) handleSSE(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user