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"` LocalFallback bool `json:"local_fallback"` LocalExecutor bool `json:"local_executor"` Capabilities []string `json:"capabilities,omitempty"` } func workerStatusHandler(executorConfigured bool, localFallback ...bool) http.Handler { local := len(localFallback) > 0 && localFallback[0] status := workerStatusResponse{ Runtime: "agent-worker", ExecutorConfigured: executorConfigured, Mode: "recovery-only", Ready: false, Reason: "protected agent execution bridge URL is not configured", LocalFallback: local, LocalExecutor: local, } if local { status.Mode = "local-executor" status.Reason = "bounded local task-evaluation executor is active; unsupported work remains durably waiting" status.Capabilities = []string{"task-evaluation"} } 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) }) }