package agent import ( "slices" llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1" ) // logsReply answers a request for one of this node's logs. func (a *Agent) logsReply(req *llmgwv1.LogsRequest) *llmgwv1.LogsReply { n := int(req.GetLines()) if n <= 0 { n = 200 } n = min(n, agentLogLines) shards := a.sup.IDs() slices.Sort(shards) out := &llmgwv1.LogsReply{ RequestId: req.GetRequestId(), Sources: append([]string{"agent"}, shards...), } switch src := req.GetSource(); src { case "", "agent": out.Lines = a.logRing.tail(n) default: sh, err := a.sup.Get(src) if err != nil { out.Error = "no engine " + src + " runs on this node" return out } out.Lines = sh.Logs(n) } return out }