X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/153f3f9b4b09d521412eacca30eddeed395c3f41..871743f6ab20d68dcede1673a9764730fda38308:/stop.go 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 +}