X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/153f3f9b4b09d521412eacca30eddeed395c3f41..0b97bb2cc4bc0b8f8fe27cc7aa3f9d1d89ed28c8:/stop.go?ds=sidebyside diff --git a/stop.go b/stop.go index 640464f..6df8dd3 100644 --- a/stop.go +++ b/stop.go @@ -1,4 +1,21 @@ package main -// stopCommand is the input line that interrupts the running turn. +import ( + "strings" +) + +// stopCommand is the input line that interrupts the running turn. The line +// "/stop NAME" stops the subagent NAME. const stopCommand = "/stop" + +// stopSubagentName returns NAME of a line "/stop NAME", or false for any other +// line. +func stopSubagentName(line string) (string, bool) { + name, found := strings.CutPrefix(strings.TrimSpace(line), stopCommand+" ") + name = strings.TrimSpace(name) + if !found || name == "" { + return "", false + } + + return name, true +}