package main import ( "encoding/json" "net/http" ) type workerStatusResponse struct { Runtime string `json:"runtime"` ExecutorConfigured bool `json:"executor_configured"` Mode string `json:"mode"` Ready bool `json:"ready"` Reason string `json:"reason"` } func workerStatusHandler(executorConfigured bool) http.Handler { status := workerStatusResponse{ Runtime: "agent-worker", ExecutorConfigured: executorConfigured, Mode: "recovery-only", Ready: false, Reason: "AGENT_EXECUTION_BRIDGE_URL is not configured", } if executorConfigured { status.Mode = "execution" status.Ready = true status.Reason = "typed agent execution bridge configured" } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet || (r.URL.Path != "/healthz" && r.URL.Path != "/readyz" && r.URL.Path != "/status") { http.NotFound(w, r) return } w.Header().Set("Content-Type", "application/json") if r.URL.Path == "/readyz" && !status.Ready { w.WriteHeader(http.StatusServiceUnavailable) } _ = json.NewEncoder(w).Encode(status) }) }