9p: add /agents file listing available agent configs

This commit is contained in:
Levi Neely 2026-07-18 15:27:05 +02:00
parent b13f42778a
commit 81ad172aa3
2 changed files with 17 additions and 1 deletions

16
main.go
View File

@ -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")

View File

@ -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)