getSessionStatus returns the session's current runtime state. With ?wait= it blocks until the session's runtime is attached (ready to accept follow-ups and produce events) before responding, so a client that just launched a run can wait for that exact session instead of polling.
(c echo.Context)
| 298 | // to accept follow-ups and produce events) before responding, so a client |
| 299 | // that just launched a run can wait for that exact session instead of polling. |
| 300 | func (s *Server) getSessionStatus(c echo.Context) error { |
| 301 | if v := c.QueryParam("wait"); v != "" { |
| 302 | d, err := time.ParseDuration(v) |
| 303 | if err != nil { |
| 304 | return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid wait: %v", err)) |
| 305 | } |
| 306 | if !s.sm.WaitSessionAttached(c.Request().Context(), c.Param("id"), min(d, maxAPITimeout)) { |
| 307 | return echo.NewHTTPError(http.StatusServiceUnavailable, "session not ready within timeout") |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | status, err := s.sm.GetSessionStatus(c.Request().Context(), c.Param("id")) |
| 312 | if err != nil { |
| 313 | return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("session not found: %v", err)) |
| 314 | } |
| 315 | return c.JSON(http.StatusOK, status) |
| 316 | } |
| 317 | |
| 318 | // getSessionSnapshot returns the full state of a session in one response |
| 319 | // (stored fields + live runtime state + last event sequence number) so a |
nothing calls this directly
no test coverage detected