+
    i                         R t ^ RIt^ RIHtHtHt ^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.//t	^ RI
Ht ]P                  ! RR]	R ]RR7       R# )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Callablec                    V ^8  d   QhR\         R\        \        \         ,          ,          R\        \        ,          R\         /# )   questionchoicescallbackreturn)strr   r   r   )formats   "//home/ubuntu/hermes-agent/tools/clarify_tool.py__annotate__r      s>     4 44d3i 4 x 4 		4    c           
        V '       d   V P                  4       '       g   \        P                  ! RR/RR7      # V P                  4       p Ve   \        V\        4      '       g   \        P                  ! RR/RR7      # V Uu. uF=  p\        V4      P                  4       '       g   K$  \        V4      P                  4       NK?  	  pp\        V4      \        8  d
   VR\         pV'       g   RpVf   \        P                  ! RR/RR7      #  V! W4      p\        P                  ! R	T R
TR\        T4      P                  4       /RR7      # u upi   \         d(   p\        P                  ! RRT 2/RR7      u Rp?# Rp?ii ; i)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.
errorzQuestion text is required.F)ensure_asciiNz"choices must be a list of strings.z8Clarify tool is not available in this execution context.zFailed to get user input: r   choices_offereduser_response)	stripjsondumps
isinstancelistr   lenMAX_CHOICES	Exception)r   r   r	   cr   excs   &&&   r   clarify_toolr      sX   & 8>>++zz7$@APUVV~~H '4((::w(LM\abb+2E7ac!flln>3q6<<>7Ew<+%l{+GGzzPQ
 	


 3 ::H7]+113 	 ) F  
zz23%89
 	

s*   !E	'E	E F E;5F ;F c                $    V ^8  d   QhR\         /# )r   r
   )bool)r   s   "r   r   r   N   s      D r   c                     R# )z>Clarify tool has no external requirements -- always available.T r#   r   r   check_clarify_requirementsr$   N   s    r   nameclarifydescriptionu  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.
parameterstypeobject
propertiesr   stringz$The question to present to the user.r   arrayitemsmaxItemszUp 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.required)registryc                 z    \        V P                  R R4      V P                  R4      VP                  R4      R7      # )r    r   r	   )r   r   r	   )r   get)argskws   &,r   <lambda>r7      s/    |*b)#
# %r   u   ❓)r%   toolsetschemahandlercheck_fnemoji)NN)__doc__r   typingr   r   r   r   r   r$   CLARIFY_SCHEMAtools.registryr1   registerr#   r   r   <module>rB      s   
  + +
 4n I	C E &(+KR	
  	ZL%%&T $   	% (

r   