|
1 | 1 | # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | | -"""Durable metadata for interactive coding-agent sessions.""" |
| 3 | +"""Durable metadata and transient lifecycle events for coding-agent sessions.""" |
4 | 4 |
|
5 | | -from typing import ClassVar |
| 5 | +from typing import Annotated, ClassVar |
6 | 6 |
|
7 | | -from nooa.context_blocks import Metadata |
| 7 | +from pydantic import Field |
| 8 | + |
| 9 | +from nooa.context_blocks import EventBase, Metadata |
8 | 10 | from nooa.context_blocks.roles import Role |
9 | 11 |
|
10 | 12 |
|
@@ -36,6 +38,33 @@ class SessionUserMessage(Metadata): |
36 | 38 | content: str = "" |
37 | 39 |
|
38 | 40 |
|
| 41 | +class SessionResumed(EventBase): # type: ignore[misc] |
| 42 | + """An interactive agent has been restored or initialized for a session.""" |
| 43 | + |
| 44 | + _role: ClassVar[Role] = Role.RUNTIME_EVENT |
| 45 | + handler_aliases: ClassVar[tuple[str, ...]] = ("TuiSessionResumed",) |
| 46 | + |
| 47 | + session_id: Annotated[str, Field(description="The resumed or started session ID")] |
| 48 | + restored: Annotated[ |
| 49 | + bool, |
| 50 | + Field(description="Whether a snapshot was restored into the agent"), |
| 51 | + ] |
| 52 | + |
| 53 | + |
| 54 | +class SessionCleared(EventBase): # type: ignore[misc] |
| 55 | + """An interactive agent's working state has been reset.""" |
| 56 | + |
| 57 | + _role: ClassVar[Role] = Role.RUNTIME_EVENT |
| 58 | + handler_aliases: ClassVar[tuple[str, ...]] = ("TuiSessionCleared",) |
| 59 | + |
| 60 | + session_id: Annotated[ |
| 61 | + str | None, |
| 62 | + Field(default=None, description="The new post-clear session ID, when known"), |
| 63 | + ] |
| 64 | + |
| 65 | + |
| 66 | +# Transient lifecycle events are deliberately absent here: this tuple is the |
| 67 | +# set persisted with the session, and those two are runtime-only. |
39 | 68 | SESSION_EVENT_TYPES: tuple[type[Metadata], ...] = ( |
40 | 69 | SessionStarted, |
41 | 70 | SessionTitleUpdated, |
|
0 commit comments