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:
parent
021436bfbf
commit
6ea2bc052e
|
|
@ -877,10 +877,14 @@ func buildAgentChildren(a *agent.Agent, s *session.Session) []virtfs.FsNodeDecl
|
|||
}),
|
||||
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) {
|
||||
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) {
|
||||
st := a.State()
|
||||
return []byte(st + "\n"), st, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue