fix: allow access to agent/new on empty sessions

pathType in server.go blocked walks to agent/new when Core is nil.
Added early return for parts[2]=="new" before the nil-guard so the
agent creation file is always accessible.

Also made agent/new rdwr return the agent name instead of just "ok".
This commit is contained in:
Ollie Agent 2026-08-01 19:56:14 +02:00
parent a01338b850
commit 8b795ad7e6
2 changed files with 8 additions and 1 deletions

View File

@ -573,6 +573,13 @@ func (s *Server) pathType(path string) string {
if len(parts) == 2 {
return "dir"
}
// agent/new is always accessible — it creates the agent
if len(parts) >= 3 && parts[2] == "new" {
if len(parts) == 3 {
return "file"
}
return ""
}
// No agent in empty session.
if sess.Core == nil {
return ""

View File

@ -486,7 +486,7 @@ func rootOpen(rs *rootState, name string) (File, error) {
if err := CreateAgent(rs, sessID, strings.Fields(strings.TrimSpace(string(data)))); err != nil {
return err
}
agentResult = "ok"
agentResult = sess.Core.Agent().Name()
return nil
},
BlockingReadFn: notBlocking,