X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/f59bb67ae1bc2c899ef4f6be9ce2ff6296c7ffcc..697c662a48c87ee9be136358129c1f79f4f5a72f:/turn.go?ds=sidebyside diff --git a/turn.go b/turn.go index 75cbfb6..f8faad8 100644 --- a/turn.go +++ b/turn.go @@ -17,8 +17,8 @@ type modelClient interface { } // Event tells the clients what the agent does as it happens. Kind is the kind -// of a logged message (user, reply, tool, echo), or one of busy, idle, and -// error. ID is the ID of a logged message. +// of a logged message (user, reply, tool, echo), or one of ready, busy, idle, +// and error. ID is the ID of a logged message. type Event struct { Kind string `json:"kind"` ID int `json:"id,omitempty"` @@ -133,6 +133,14 @@ func (l *loop) Interrupt() bool { return true } +// Busy tells if a turn runs. +func (l *loop) Busy() bool { + l.mutex.Lock() + defer l.mutex.Unlock() + + return l.cancel != nil +} + // Append logs a message and tells the clients. The toolbox logs its calls and // results through it. func (l *loop) Append(kind, text string) (Message, error) {