9p: add /agents file listing available agent configs
This commit is contained in:
parent
b13f42778a
commit
81ad172aa3
16
main.go
16
main.go
|
|
@ -315,6 +315,22 @@ func NewRootStore() *fs.Tree {
|
|||
"help": func() ([]byte, error) {
|
||||
return os.ReadFile(helpPath)
|
||||
},
|
||||
"agents": func() ([]byte, error) {
|
||||
var sb strings.Builder
|
||||
for _, dir := range agent.AgentsDirs() {
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
for _, e := range entries {
|
||||
if !e.IsDir() && strings.HasSuffix(e.Name(), ".json") {
|
||||
sb.WriteString(strings.TrimSuffix(e.Name(), ".json"))
|
||||
sb.WriteByte('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
return []byte(sb.String()), nil
|
||||
},
|
||||
}
|
||||
notBlocking := func(context.Context, string) ([]byte, string, error) {
|
||||
return nil, "", fmt.Errorf("blocking read not supported")
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,7 @@ func (s *Server) buildDirData(path string) []byte {
|
|||
var dirs []plan9.Dir
|
||||
|
||||
if path == "/" {
|
||||
rootEntries := []string{"backends", "ctl", "help", "models", "s"}
|
||||
rootEntries := []string{"agents", "backends", "ctl", "help", "models", "s"}
|
||||
for _, name := range rootEntries {
|
||||
fpath := "/" + name
|
||||
st := s.makeStat(fpath)
|
||||
|
|
|
|||
Reference in New Issue