loops = append(loops, loop)
}
+ messages, err := openDaemonMessages(loops)
+ if err != nil {
+ return errors.Join(fmt.Errorf("open agent messages: %w", err), listener.Close())
+ }
+
hub.snapshot = func(ctx context.Context, snapshot func() error) error {
- return daemonSnapshot(ctx, loops, snapshot)
+ return messages.SnapshotAgents(ctx, snapshot)
+ }
+
+ runtime := &DaemonChildren{
+ ctx: ctx,
+ cancel: cancel,
+ root: l,
+ messages: messages,
}
+ l.tools.children = runtime
var workers sync.WaitGroup
hub.CloseAll()
workers.Wait()
- return errors.Join(err, whatsappErr, schedulesErr, botErr, errors.Join(childErrors...))
+ return errors.Join(err, whatsappErr, schedulesErr, botErr, errors.Join(childErrors...), runtime.Close())
}
// daemonRunChild runs a child's turn loop and its schedules until either stops.