§
    ‰eîi[  ã            	       óæ   — d Z ddlZddlmZmZmZ dZ	 	 ddedeee                  dee         defd	„Zde	fd
„Z
ddddddœdddieddœdœdgdœdœZddlmZmZ  ej        dded„ e
d¬¦  «         dS )aó  
Clarify Tool Module - Interactive Clarifying Questions

Allows the agent to present structured multiple-choice questions or open-ended
prompts to the user. In CLI mode, choices are navigable with arrow keys. On
messaging platforms, choices are rendered as a numbered list.

The actual user-interaction logic lives in the platform layer (cli.py for CLI,
gateway/run.py for messaging). This module defines the schema, validation, and
a thin dispatcher that delegates to a platform-provided callback.
é    N)ÚListÚOptionalÚCallableé   ÚquestionÚchoicesÚcallbackÚreturnc                 óT  — | r|                       ¦   «         st          d¦  «        S |                       ¦   «         } |�[t          |t          ¦  «        st          d¦  «        S d„ |D ¦   «         }t	          |¦  «        t
          k    r|dt
          …         }|sd}|€t          j        ddid¬¦  «        S 	  || |¦  «        }n2# t          $ r%}t          j        dd	|› �id¬¦  «        cY d}~S d}~ww xY wt          j        | |t          |¦  «                              ¦   «         d
œd¬¦  «        S )a  
    Ask the user a question, optionally with multiple-choice options.

    Args:
        question: The question text to present.
        choices:  Up to 4 predefined answer choices. When omitted the
                  question is purely open-ended.
        callback: Platform-provided function that handles the actual UI
                  interaction. Signature: callback(question, choices) -> str.
                  Injected by the agent runner (cli.py / gateway).

    Returns:
        JSON string with the user's response.
    zQuestion text is required.Nz"choices must be a list of strings.c                 ó’   — g | ]D}t          |¦  «                             ¦   «         ¯#t          |¦  «                             ¦   «         ‘ŒES © )ÚstrÚstrip)Ú.0Úcs     ú4/home/div/.hermes/hermes-agent/tools/clarify_tool.pyú
<listcomp>z clarify_tool.<locals>.<listcomp>3   s9   € ÐEÐEÐE aµc¸!±f´f·l²l±n´nÐE•3�q‘6”6—<’<‘>”>ÐEÐEÐEó    Úerrorz8Clarify tool is not available in this execution context.F)Úensure_asciizFailed to get user input: )r   Úchoices_offeredÚuser_response)
r   Ú
tool_errorÚ
isinstanceÚlistÚlenÚMAX_CHOICESÚjsonÚdumpsÚ	Exceptionr   )r   r   r	   r   Úexcs        r   Úclarify_toolr"      s“  € ð& ð 8˜8Ÿ>š>Ñ+Ô+ð 8ÝÐ6Ñ7Ô7Ð7à�~Š~ÑÔ€Hð ÐÝ˜'¥4Ñ(Ô(ð 	DÝÐBÑCÔCÐCØEÐE¨7ÐEÑEÔEˆÝˆw‰<Œ<�+Ò%Ð%Ø˜l�{˜lÔ+ˆGØð 	ØˆGàÐÝŒzØÐPÐQØð
ñ 
ô 
ð 	
ð

Ø ˜ ¨7Ñ3Ô3ˆˆøÝð 
ð 
ð 
ÝŒzØÐ8°3Ð8Ð8Ð9Øð
ñ 
ô 
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
øøøøð
øøøõ Œ:ØØ"Ý˜]Ñ+Ô+×1Ò1Ñ3Ô3ðð ð ð	ñ ô ð s   Â2B? Â?
C.Ã	C)Ã#C.Ã)C.c                  ó   — dS )z>Clarify tool has no external requirements -- always available.Tr   r   r   r   Úcheck_clarify_requirementsr$   N   s   € àˆ4r   Úclarifyu  Ask the user a question when you need clarification, feedback, or a decision before proceeding. Supports two modes:

1. **Multiple choice** â€” provide up to 4 choices. The user picks one or types their own answer via a 5th 'Other' option.
2. **Open-ended** â€” omit choices entirely. The user types a free-form response.

Use this tool when:
- The task is ambiguous and you need the user to choose an approach
- You want post-task feedback ('How did that work out?')
- You want to offer to save a skill or update memory
- A decision has meaningful trade-offs the user should weigh in on

Do NOT use this tool for simple yes/no confirmation of dangerous commands (the terminal tool handles that). Prefer making a reasonable default choice yourself when the decision is low-stakes.ÚobjectÚstringz$The question to present to the user.)ÚtypeÚdescriptionÚarrayr(   z¥Up to 4 answer choices. Omit this parameter entirely to ask an open-ended question. When provided, the UI automatically appends an 'Other (type your answer)' option.)r(   ÚitemsÚmaxItemsr)   )r   r   )r(   Ú
propertiesÚrequired)Únamer)   Ú
parameters)Úregistryr   c                 óš   — t          |                      dd¦  «        |                      d¦  «        |                     d¦  «        ¬¦  «        S )Nr   Ú r   r	   )r   r   r	   )r"   Úget)ÚargsÚkws     r   ú<lambda>r7   ‡   sD   € �|Ø—’˜* bÑ)Ô)Ø—’˜Ñ#Ô#Ø—’˜
Ñ#Ô#ð %ñ  %ô  %€ r   u   â�“)r/   ÚtoolsetÚschemaÚhandlerÚcheck_fnÚemoji)NN)Ú__doc__r   Útypingr   r   r   r   r   r"   Úboolr$   ÚCLARIFY_SCHEMAÚtools.registryr1   r   Úregisterr   r   r   ú<module>rC      ss  ðð
ð 
ð €€€Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +ð
 €ð
 $(Ø#'ð4ð 4Øð4à�d˜3”iÔ ð4ð �xÔ ð4ð 	ð	4ð 4ð 4ð 4ðn Dð ð ð ð ð ð	Cð  ð !ØEðð ð
  Ø  (Ð+Ø'ðRð	ð 	ð
ð 
ð   �Lð%ð ð%&ð &€ðT 0Ð /Ð /Ð /Ð /Ð /Ð /Ð /à €Ô Ø	ØØð%ð %ð (Ø
ð
ñ 
ô 
ð 
ð 
ð 
r   