X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/ddd0a50f7b801112376d7fb27bfd05d2fc26c2fd..59e1537e1969f7c109084497287d729edbedba04:/subagent.go?ds=sidebyside diff --git a/subagent.go b/subagent.go index 596c038..132ca47 100644 --- a/subagent.go +++ b/subagent.go @@ -130,8 +130,10 @@ func (s *Subagents) Close() error { defer s.mutex.Unlock() var err error + for name, subagent := range s.open { err = errors.Join(err, subagent.close()) + delete(s.open, name) } @@ -169,6 +171,14 @@ func (a *Subagent) Flush(ctx context.Context) error { return a.syncer.Flush(ctx) } +// First returns the first message of the log. +func (a *Subagent) First() (Message, error) { + a.mutex.Lock() + defer a.mutex.Unlock() + + return a.log.Message(0) +} + // Show returns the whole log, each message as "i|kind: text", with a blank line // between messages. func (a *Subagent) Show() (string, error) {