1010
1111
1212from dataclasses import dataclass
13- from typing import Any , Optional , List , Dict , TypeVar , Type , cast , Callable
13+ from typing import Any , TypeVar , cast
14+ from collections .abc import Callable
1415from enum import Enum
1516
1617
@@ -52,22 +53,22 @@ def from_bool(x: Any) -> bool:
5253 return x
5354
5455
55- def to_class (c : Type [T ], x : Any ) -> dict :
56+ def to_class (c : type [T ], x : Any ) -> dict :
5657 assert isinstance (x , c )
5758 return cast (Any , x ).to_dict ()
5859
5960
60- def from_list (f : Callable [[Any ], T ], x : Any ) -> List [T ]:
61+ def from_list (f : Callable [[Any ], T ], x : Any ) -> list [T ]:
6162 assert isinstance (x , list )
6263 return [f (y ) for y in x ]
6364
6465
65- def from_dict (f : Callable [[Any ], T ], x : Any ) -> Dict [str , T ]:
66+ def from_dict (f : Callable [[Any ], T ], x : Any ) -> dict [str , T ]:
6667 assert isinstance (x , dict )
6768 return { k : f (v ) for (k , v ) in x .items () }
6869
6970
70- def to_enum (c : Type [EnumT ], x : Any ) -> EnumT :
71+ def to_enum (c : type [EnumT ], x : Any ) -> EnumT :
7172 assert isinstance (x , c )
7273 return x .value
7374
@@ -101,7 +102,7 @@ def to_dict(self) -> dict:
101102
102103@dataclass
103104class PingParams :
104- message : Optional [ str ] = None
105+ message : str | None = None
105106 """Optional message to echo back"""
106107
107108 @staticmethod
@@ -138,8 +139,8 @@ def to_dict(self) -> dict:
138139@dataclass
139140class Limits :
140141 max_context_window_tokens : float
141- max_output_tokens : Optional [ float ] = None
142- max_prompt_tokens : Optional [ float ] = None
142+ max_output_tokens : float | None = None
143+ max_prompt_tokens : float | None = None
143144
144145 @staticmethod
145146 def from_dict (obj : Any ) -> 'Limits' :
@@ -233,16 +234,16 @@ class Model:
233234 name : str
234235 """Display name"""
235236
236- billing : Optional [ Billing ] = None
237+ billing : Billing | None = None
237238 """Billing information"""
238239
239- default_reasoning_effort : Optional [ str ] = None
240+ default_reasoning_effort : str | None = None
240241 """Default reasoning effort level (only present if model supports reasoning effort)"""
241242
242- policy : Optional [ Policy ] = None
243+ policy : Policy | None = None
243244 """Policy state (if applicable)"""
244245
245- supported_reasoning_efforts : Optional [ List [ str ]] = None
246+ supported_reasoning_efforts : list [ str ] | None = None
246247 """Supported reasoning effort levels (only present if model supports reasoning effort)"""
247248
248249 @staticmethod
@@ -275,7 +276,7 @@ def to_dict(self) -> dict:
275276
276277@dataclass
277278class ModelsListResult :
278- models : List [Model ]
279+ models : list [Model ]
279280 """List of available models with full metadata"""
280281
281282 @staticmethod
@@ -298,14 +299,14 @@ class Tool:
298299 name : str
299300 """Tool identifier (e.g., "bash", "grep", "str_replace_editor")"""
300301
301- instructions : Optional [ str ] = None
302+ instructions : str | None = None
302303 """Optional instructions for how to use this tool effectively"""
303304
304- namespaced_name : Optional [ str ] = None
305+ namespaced_name : str | None = None
305306 """Optional namespaced name for declarative filtering (e.g., "playwright/navigate" for MCP
306307 tools)
307308 """
308- parameters : Optional [ Dict [ str , Any ]] = None
309+ parameters : dict [ str , Any ] | None = None
309310 """JSON Schema for the tool's input parameters"""
310311
311312 @staticmethod
@@ -333,7 +334,7 @@ def to_dict(self) -> dict:
333334
334335@dataclass
335336class ToolsListResult :
336- tools : List [Tool ]
337+ tools : list [Tool ]
337338 """List of available built-in tools with metadata"""
338339
339340 @staticmethod
@@ -350,7 +351,7 @@ def to_dict(self) -> dict:
350351
351352@dataclass
352353class ToolsListParams :
353- model : Optional [ str ] = None
354+ model : str | None = None
354355 """Optional model ID — when provided, the returned tool list reflects model-specific
355356 overrides
356357 """
@@ -385,7 +386,7 @@ class QuotaSnapshot:
385386 used_requests : float
386387 """Number of requests used so far this period"""
387388
388- reset_date : Optional [ str ] = None
389+ reset_date : str | None = None
389390 """Date when the quota resets (ISO 8601)"""
390391
391392 @staticmethod
@@ -413,7 +414,7 @@ def to_dict(self) -> dict:
413414
414415@dataclass
415416class AccountGetQuotaResult :
416- quota_snapshots : Dict [str , QuotaSnapshot ]
417+ quota_snapshots : dict [str , QuotaSnapshot ]
417418 """Quota snapshots keyed by type (e.g., chat, completions, premium_interactions)"""
418419
419420 @staticmethod
@@ -430,7 +431,7 @@ def to_dict(self) -> dict:
430431
431432@dataclass
432433class SessionModelGetCurrentResult :
433- model_id : Optional [ str ] = None
434+ model_id : str | None = None
434435
435436 @staticmethod
436437 def from_dict (obj : Any ) -> 'SessionModelGetCurrentResult' :
@@ -447,7 +448,7 @@ def to_dict(self) -> dict:
447448
448449@dataclass
449450class SessionModelSwitchToResult :
450- model_id : Optional [ str ] = None
451+ model_id : str | None = None
451452
452453 @staticmethod
453454 def from_dict (obj : Any ) -> 'SessionModelSwitchToResult' :
@@ -546,7 +547,7 @@ class SessionPlanReadResult:
546547 exists : bool
547548 """Whether plan.md exists in the workspace"""
548549
549- content : Optional [ str ] = None
550+ content : str | None = None
550551 """The content of plan.md, or null if it does not exist"""
551552
552553 @staticmethod
@@ -606,7 +607,7 @@ def to_dict(self) -> dict:
606607
607608@dataclass
608609class SessionWorkspaceListFilesResult :
609- files : List [str ]
610+ files : list [str ]
610611 """Relative file paths in the workspace files directory"""
611612
612613 @staticmethod
@@ -708,7 +709,7 @@ def to_dict(self) -> dict:
708709
709710@dataclass
710711class SessionFleetStartParams :
711- prompt : Optional [ str ] = None
712+ prompt : str | None = None
712713 """Optional user prompt to combine with fleet instructions"""
713714
714715 @staticmethod
@@ -753,7 +754,7 @@ def to_dict(self) -> dict:
753754
754755@dataclass
755756class SessionAgentListResult :
756- agents : List [AgentElement ]
757+ agents : list [AgentElement ]
757758 """Available custom agents"""
758759
759760 @staticmethod
@@ -797,7 +798,7 @@ def to_dict(self) -> dict:
797798
798799@dataclass
799800class SessionAgentGetCurrentResult :
800- agent : Optional [ SessionAgentGetCurrentResultAgent ] = None
801+ agent : SessionAgentGetCurrentResultAgent | None = None
801802 """Currently selected custom agent, or null if using the default agent"""
802803
803804 @staticmethod
0 commit comments