package server import ( core "agent-system-core" "crypto/sha256" "encoding/hex" "net/http" ) func (s *Server) taskSource(w http.ResponseWriter, r *http.Request) { owner := s.owner(r) c, e := s.st.GetCard(owner, r.PathValue("id")) if e != nil || c.Task == nil { http.NotFound(w, r) return } if _, e = s.st.GetConversation(owner, c.ConversationID); e != nil { http.NotFound(w, r) return } var ref *core.TaskSourceRef for _, f := range c.Task.Findings { for _, src := range f.Sources { if src.ID == r.PathValue("sourceId") { copy := src ref = © break } } } if ref == nil { http.NotFound(w, r) return } art, e := s.st.GetArtifact(owner, ref.ArtifactID) if e != nil || art.ProjectID != c.ProjectID { http.NotFound(w, r) return } data, e := s.st.ArtifactContent(owner, ref.ArtifactID) if e != nil { http.NotFound(w, r) return } sum := sha256.Sum256(data) state := "current" if hex.EncodeToString(sum[:]) != ref.ContentHash { state = "changed" ref.Availability = "changed" } else { ref.Availability = "available" } writeJSONOr(w, map[string]any{"source": ref, "versionState": state, "artifact": art}, nil) }