1111import threading
1212import time
1313from collections .abc import Callable
14+ from dataclasses import dataclass
1415from functools import partial
1516from pathlib import Path
1617from typing import Any
@@ -221,20 +222,13 @@ def _format_run_info(
221222# lavender=web, violet=delegate, purple=meta.
222223
223224
225+ @dataclass (slots = True )
224226class _ToolConfig :
225227 """Visual and extraction config for a known tool."""
226228
227- __slots__ = ("color" , "category" , "extract_arg" )
228-
229- def __init__ (
230- self ,
231- color : str ,
232- category : str ,
233- extract_arg : Callable [[dict [str , Any ]], str ] | None = None ,
234- ) -> None :
235- self .color = color
236- self .category = category
237- self .extract_arg = extract_arg
229+ color : str
230+ category : str
231+ extract_arg : Callable [[dict [str , Any ]], str ] | None = None
238232
239233
240234_TOOL_REGISTRY : dict [str , _ToolConfig ] = {
@@ -248,10 +242,18 @@ def __init__(
248242 "BashOutput" : _ToolConfig (_brand .GREEN , "bash" ),
249243 "WebFetch" : _ToolConfig (_brand .LAVENDER , "web" , lambda i : i .get ("url" , "" )),
250244 "WebSearch" : _ToolConfig (_brand .LAVENDER , "web" , lambda i : i .get ("query" , "" )),
251- "Task" : _ToolConfig (_brand .VIOLET , "task" , lambda i : _format_params (i , ["description" , "prompt" ])),
252- "Agent" : _ToolConfig (_brand .VIOLET , "agent" , lambda i : _format_params (i , ["description" , "prompt" ])),
253- "ToolSearch" : _ToolConfig (_brand .BLUE , "other" , lambda i : _format_params (i , ["query" , "max_results" ])),
254- "TodoWrite" : _ToolConfig (_brand .PURPLE , "todo" , lambda i : f"{ len (i .get ('todos' , []))} todos" ),
245+ "Task" : _ToolConfig (
246+ _brand .VIOLET , "task" , lambda i : _format_params (i , ["description" , "prompt" ])
247+ ),
248+ "Agent" : _ToolConfig (
249+ _brand .VIOLET , "agent" , lambda i : _format_params (i , ["description" , "prompt" ])
250+ ),
251+ "ToolSearch" : _ToolConfig (
252+ _brand .BLUE , "other" , lambda i : _format_params (i , ["query" , "max_results" ])
253+ ),
254+ "TodoWrite" : _ToolConfig (
255+ _brand .PURPLE , "todo" , lambda i : f"{ len (i .get ('todos' , []))} todos"
256+ ),
255257}
256258
257259_DEFAULT_TOOL_STYLE : tuple [str , str ] = ("white" , "other" )
@@ -582,6 +584,7 @@ def _build_footer(self) -> Table:
582584_FULLSCREEN_MIN_VISIBLE = 5
583585
584586
587+ @dataclass (slots = True )
585588class _ScrollbarMetrics :
586589 """Pure-data result of scrollbar geometry calculation.
587590
@@ -591,12 +594,9 @@ class _ScrollbarMetrics:
591594 ``True``.
592595 """
593596
594- __slots__ = ("show" , "thumb_start" , "thumb_size" )
595-
596- def __init__ (self , show : bool , thumb_start : int , thumb_size : int ) -> None :
597- self .show = show
598- self .thumb_start = thumb_start
599- self .thumb_size = thumb_size
597+ show : bool
598+ thumb_start : int
599+ thumb_size : int
600600
601601
602602def _scrollbar_metrics (total : int , visible : int , offset : int ) -> _ScrollbarMetrics :
0 commit comments