server: add non-blocking state file separate from statewait

- state: immediate read of current agent state
- statewait: blocks until state changes

Clearer semantics than overloading statewait with both behaviors.
This commit is contained in:
Levi Neely 2026-10-06 12:17:19 +02:00
parent 021436bfbf
commit 6ea2bc052e
1 changed files with 5 additions and 1 deletions

View File

@ -877,10 +877,14 @@ func buildAgentChildren(a *agent.Agent, s *session.Session) []virtfs.FsNodeDecl
}), }),
virtfs.Stream(a.ChatRead, a.ChatSignal), virtfs.Stream(a.ChatRead, a.ChatSignal),
), ),
virtfs.FileNode("statewait", 0444, virtfs.FileNode("state", 0444,
virtfs.Doc("Current agent state (idle, calling, thinking, paused)"),
virtfs.Read(func() ([]byte, error) { virtfs.Read(func() ([]byte, error) {
return []byte(a.State() + "\n"), nil return []byte(a.State() + "\n"), nil
}), }),
),
virtfs.FileNode("statewait", 0444,
virtfs.Doc("Blocks until state changes; returns new value"),
virtfs.BlockOnce(func() ([]byte, string, error) { virtfs.BlockOnce(func() ([]byte, string, error) {
st := a.State() st := a.State()
return []byte(st + "\n"), st, nil return []byte(st + "\n"), st, nil