Create a signed JWT used by the SSE stream for resuming agent runs. The token embeds the provided payload and standard claims (iat/exp).
(payload: dict[str, Any])
| 13 | |
| 14 | |
| 15 | def make_stream_token(payload: dict[str, Any]) -> str: |
| 16 | """Create a signed JWT used by the SSE stream for resuming agent runs. |
| 17 | |
| 18 | The token embeds the provided payload and standard claims (iat/exp). |
| 19 | """ |
| 20 | now = datetime.now(timezone.utc) |
| 21 | to_encode = { |
| 22 | **payload, |
| 23 | "iat": int(now.timestamp()), |
| 24 | "exp": int((now + timedelta(seconds=JWT_TTL_SECONDS)).timestamp()), |
| 25 | } |
| 26 | return jwt.encode(to_encode, JWT_SECRET, algorithm=JWT_ALG) |
| 27 | |
| 28 | |
| 29 | def read_stream_token(token: str) -> dict[str, Any]: |
no outgoing calls
no test coverage detected