+
    i%                        R t ^ RIt^ RIHtHtHtHt 0 R'mt ! R R4      tR(R R llt	R R	 lt
R
RRRRRRRRRRRRRRRRRRRRR/RRRRR/RRRR. R)ORR//R. R*O//RRR RR!R"R//R. //t^ R#IHt ]P                  ! RR]R$ ]
R%R&7       R# )+a4  
Todo Tool Module - Planning & Task Management

Provides an in-memory task list the agent uses to decompose complex tasks,
track progress, and maintain focus across long conversations. The state
lives on the AIAgent instance (one per session) and is re-injected into
the conversation after context compression events.

Design:
- Single `todo` tool: provide `todos` param to write, omit to read
- Every call returns the full current list
- No system prompt mutation, no tool response modification
- Behavioral guidance lives entirely in the tool schema description
N)DictAnyListOptionalc                      a  ] tR t^t o RtR tRV 3R lR lltV 3R lR ltV 3R lR ltV 3R	 lR
 lt	]
V 3R lR l4       tRtV tR# )	TodoStorea
  
In-memory todo list. One instance per AIAgent (one per session).

Items are ordered -- list position is priority. Each item has:
  - id: unique string identifier (agent-chosen)
  - content: task description
  - status: pending | in_progress | completed | cancelled
c                    . V n         R # )N_itemsselfs   &,/home/ubuntu/hermes-agent/tools/todo_tool.py__init__TodoStore.__init__#   s	    ,.    c          	      x   < V ^8  d   QhRS[ S[S[S[3,          ,          RS[RS[ S[S[S[3,          ,          /# )   todosmergereturn)r   r   strr   bool)format__classdict__s   "r   __annotate__TodoStore.__annotate__&   s?     * *4S#X/ * *dSVX[S[nI] *r   c                   V'       g6   V Uu. uF  q0P                  V4      NK  	  upV n        V P                  4       # V P                   Uu/ uF  qDR,          VbK  	  ppV EF  p\        VP                  RR4      4      P	                  4       pV'       g   K7  We9   d   RV9   d9   VR,          '       d*   \        VR,          4      P	                  4       WV,          R&   RV9   dZ   VR,          '       dI   \        VR,          4      P	                  4       P                  4       pV\        9   d   WuV,          R&   K  K  K  K  V P                  V4      pWVR,          &   V P                  P                  V4       EK  	  \        4       p	. p
V P                   FU  pVP                  VR,          V4      pVR,          V	9  g   K,  V
P                  V4       V	P                  VR,          4       KW  	  Wn        V P                  4       # u upi u upi )z
Write todos. Returns the full current list after writing.

Args:
    todos: list of {id, content, status} dicts
    merge: if False, replace the entire list. If True, update
           existing items by id and append new ones.
id contentstatus)	_validater
   r   getstriplowerVALID_STATUSESappendsetaddread)r   r   r   titemexistingitem_idr    	validatedseenrebuiltcurrents   &&&         r   writeTodoStore.write&   s    6;<e>>!,e<DK> yy{9 6:[[A[TT
D([HAaeeD"o.446& A~!I,,7:1Y<7H7N7N7P))41}8!$Qx[!1!7!7!9!?!?!A!^3:@W-h7 4 *5} !%q 1I09Yt_-KK&&y1# & 5DG",,tDz484=,NN7+HHWT]+	 $
 "Kyy{? = Bs   HHc                F   < V ^8  d   QhRS[ S[S[S[3,          ,          /# r   r   )r   r   r   )r   r   s   "r   r   r   R   s!     5 5d4S>* 5r   c                ^    V P                    Uu. uF  qP                  4       NK  	  up# u upi )z"Return a copy of the current list.)r
   copy)r   r+   s   & r   r)   TodoStore.readR   s"    (,4		444s   *c                    < V ^8  d   QhRS[ /# r5   r   )r   r   s   "r   r   r   V   s     $ $4 $r   c                2    \        V P                  4      ^ 8  # )z)Check if there are any items in the list.)lenr
   r   s   &r   	has_itemsTodoStore.has_itemsV   s    4;;!##r   c                0   < V ^8  d   QhRS[ S[,          /# r5   )r   r   )r   r   s   "r   r   r   Z   s          hsm   r   c                   V P                   '       g   R# RRRRRRRR	/pV P                    Uu. uF  pVR
,          R9   g   K  VNK  	  ppV'       g   R# R.pV FO  pVP                  VR
,          R4      pVP                  RV RVR,           RVR,           RVR
,           R2	4       KQ  	  RP                  V4      # u upi )z
Render the todo list for post-compression injection.

Returns a human-readable string to append to the compressed
message history, or None if the list is empty.
N	completedz[x]in_progressz[>]pendingz[ ]	cancelledz[~]r    z@[Your active task list was preserved across context compression]z[?]z-  r   z. r   z ()
)rC   rB   )r
   r"   r&   join)r   markersr+   active_itemslinesmarkers   &     r   format_for_injectionTodoStore.format_for_injectionZ   s     {{{ 5u	
 "[[
(TH~!;; D[ 	 
 ST D[[h7FLL2fXQtDzl"T)_4ERXGWWXYZ ! yy
s   B=B=c                R   < V ^8  d   QhRS[ S[S[3,          RS[ S[S[3,          /# )r   r+   r   )r   r   r   )r   r   s   "r   r   r   }   s/     E ES#X E4S> Er   c                f   \        V P                  RR4      4      P                  4       pV'       g   Rp\        V P                  RR4      4      P                  4       pV'       g   Rp\        V P                  RR4      4      P                  4       P                  4       pV\        9  d   RpRVRVRV/# )z
Validate and normalize a todo item.

Ensures required fields exist and status is valid.
Returns a clean dict with only {id, content, status}.
r   r   ?r   z(no description)r    rC   )r   r"   r#   r$   r%   )r+   r-   r   r    s   &   r   r!   TodoStore._validate|   s     dhhtR()//1Gdhhy"-.446(GTXXh	2399;AAC'Fgy'8VDDr   r	   N)F)__name__
__module____qualname____firstlineno____doc__r   r2   r)   r=   rM   staticmethodr!   __static_attributes____classdictcell__)r   s   @r   r   r      sO     /* *X5 5$ $     D E Er   r   Fc                    V ^8  d   QhR\         \        \        \        \        3,          ,          ,          R\
        R\         \        ,          R\        /# )r   r   r   storer   )r   r   r   r   r   r   r   )r   s   "r   r   r      sG     ' 'Dc3h()'' I' 		'r   c                x   Vf   \         P                  ! RR/RR7      # V e   VP                  W4      pMVP                  4       p\	        R V 4       4      p\	        R V 4       4      p\	        R V 4       4      p\	        R V 4       4      p\         P                  ! R	VR
R\        V4      RVRVRVRV//RR7      # )ad  
Single entry point for the todo tool. Reads or writes depending on params.

Args:
    todos: if provided, write these items. If None, read current list.
    merge: if True, update by id. If False (default), replace entire list.
    store: the TodoStore instance from the AIAgent.

Returns:
    JSON string with the full current list and summary metadata.
errorzTodoStore not initializedF)ensure_asciic              3   D   "   T F  qR ,          R8X  g   K  ^x  K  	  R# 5i)r    rC   N .0is   & r   	<genexpr>todo_tool.<locals>.<genexpr>   s     ?UkY&>!!U    
 c              3   D   "   T F  qR ,          R8X  g   K  ^x  K  	  R# 5i)r    rB   Nra   rb   s   & r   re   rf      s     GAH+*Faarg   c              3   D   "   T F  qR ,          R8X  g   K  ^x  K  	  R# 5i)r    rA   Nra   rb   s   & r   re   rf           Cu!({(BAAurg   c              3   D   "   T F  qR ,          R8X  g   K  ^x  K  	  R# 5i)r    rD   Nra   rb   s   & r   re   rf      rj   rg   r   summarytotalrC   rB   rA   rD   )jsondumpsr2   r)   sumr<   )r   r   r\   itemsrC   rB   rA   rD   s   &&&     r   	todo_toolrr      s      }zz7$?@uUUE)

 ?U??GGGGKCuCCICuCCI::SZw;
	 	 	r   c                $    V ^8  d   QhR\         /# r5   r:   )r   s   "r   r   r      s       r   c                     R# )z;Todo tool has no external requirements -- always available.Tra   ra   r   r   check_todo_requirementsru      s    r   nametododescriptiona  Manage your task list for the current session. Use for complex tasks with 3+ steps or when the user provides multiple tasks. Call with no parameters to read the current list.

Writing:
- Provide 'todos' array to create/update items
- merge=false (default): replace the entire list with a fresh plan
- merge=true: update existing items by id, add any new ones

Each item: {id: string, content: string, status: pending|in_progress|completed|cancelled}
List order is priority. Only ONE item in_progress at a time.
Mark items completed immediately when done. If something fails, cancel it and add a revised item.

Always returns the full current list.
parameterstypeobject
propertiesr   arrayz/Task items to write. Omit to read current list.rq   r   stringzUnique item identifierr   zTask descriptionr    enumzCurrent statusrequiredr   booleanzZtrue: update existing items by id, add new ones. false (default): replace the entire list.default)registryc                 z    \        V P                  R 4      V P                  RR4      VP                  R4      R7      # )r   r   Fr\   )r   r   r\   )rr   r"   )argskws   &,r   <lambda>r     s-    yhhwtxx'?rvvg Xr   u   📋)rv   toolsetschemahandlercheck_fnemoji>   rC   rD   rA   rB   )NFN)rC   rB   rA   rD   )r   r   r    )rW   rn   typingr   r   r   r   r%   r   rr   ru   TODO_SCHEMAtools.registryr   registerra   r   r   <module>r      s(    , , FwE wEt'T F	0 PH "H)+C ""H)+=$ !"H"$X)+;##  ;#. 	@ 51 
B 	BG$#6t $   	X$
r   