+
    lHàj0&  ã                   ó^  € R t ^ RIt^ RIHtHtHtHt ^t^tRt	Rt
RtRtR R ltR	 R
 ltR R ltR R ltR R ltR R ltR1R R lltR R ltRRRR] R] R2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!.//t^ R-IHtHt ]P2                  ! RR]R. ]R/R07       R# )2zÊClarify tool: structured multiple-choice / open-ended questions to the user.
Schema, validation and a thin dispatcher; the UI lives in a platform-provided
callback (cli.py, gateway/run.py, tui_gateway).N)ÚCallableÚDictÚListÚOptionali@  z(Recommended)z8Clarify tool is not available in this execution context.z]Pass questions=[{question, choices?, multi_select?}]; a single question is a one-entry array.c                ó\   € V ^8„  d   QhR\         \        ,          R\         \        ,          /# )é   ÚchoicesÚreturn)ÚlistÚstr)Úformats   "Ú7/home/ubuntu/.hermes/hermes-agent/tools/clarify_tool.pyÚ__annotate__r      s&   € ÷ @ñ @œd¤3�ið @¬D´­Iñ @ó    c                óà   € V '       d!   \        V ^ ,          4      P                  4       MRp\        V 4      ^8  g   V\        V4      8w  d   V # V R\         2.\        V R,          4      ,           # )z•Suffix the first choice (schema says best-first) with RECOMMENDED_LABEL; idempotent,
and a lone choice is left untouched (nothing to prefer it over).Ú Ú :é   NN)r   ÚstripÚlenÚstrip_recommendedÚRECOMMENDED_LABELr
   )r   Úfirsts   & r   Úmark_recommendedr      s`   € ÷ (/ŒC�˜•
‹O×!Ñ!Ô#°B€EÜ
ˆ7ƒ|�aÔ˜5Ô$5°eÓ$<Ô<ØˆØˆg�QÔ(Ð)Ð*Ð+¬d°7¸2µ;Ó.?Õ?Ð?r   c                ó0   € V ^8„  d   QhR\         R\         /# )r   Útextr	   )r   )r   s   "r   r   r      s   € ÷ ñ œCð ¤Cñ r   c                óè   € \        V 4      P                  4       pVP                  4       P                  \        P                  4       4      '       d"   VR\        \        4      )  P                  4       # V# )zSRemove the recommendation label so presentation never leaks into ``user_response``.N)r   r   ÚcasefoldÚendswithr   r   )r   Ústrippeds   & r   r   r      s[   € ä�4‹y�‰Ó €HØ×ÑÓ×#Ñ#Ô$5×$>Ñ$>Ó$@×AÒAØÐ1œ3Ô0Ó1Ð1Ð2×8Ñ8Ó:Ð:Ø€Or   c                ó$   € V ^8„  d   QhR\         /# )r   Úmulti©Úbool)r   s   "r   r   r   $   s   € ÷ Jñ Jœdñ Jr   c                ót  € V'       g   \        V 4      # \        V \        4      '       d3    \        P                  ! V 4      p\        V\        4      '       d   TMV .p V  Uu. uF/  p\        V4      P                  4       '       g   K$  \        V4      NK1  	  up#   \        P
                   d    Rp Lpi ; iu upi )zœStrip presentation (the label, multi-select JSON) from a locked answer: a multi-select
answer is a list, a JSON array string, or one typed ("Other") answer.N)r   Ú
isinstancer   ÚjsonÚloadsÚJSONDecodeErrorr
   r   )Úrawr!   ÚparsedÚitems   &&  r   Ú_clean_answerr,   $   s”   € ÷ Ü  Ó%Ð%Ü�#”s×Òð	Ü—Z’Z “_ˆFô # 6¬4×0Ò0‰f°s°eˆÙ03ÓI±¨´s¸4³y·±×7HÔ#Ô˜dÖ#±ÑIÐIøô ×#Ñ#ô 	ØŠFð	üò Js   «B Á !B5ÂB5ÂB2Â1B2c                ó$   € V ^8„  d   QhR\         /# ©r   r	   )Útuple)r   s   "r   r   r   2   s   € ÷ "ñ "¤uñ "r   c                ó&  € \        V \        4      '       d	   V '       g   RR\         23# \        V 4      \        8”  d   RR\         R23# . p\        V 4       EF.  w  r#\        V\        4      '       g   RRV R\         23u # \        VP                  R4      ;'       g    R4      P                  4       pV'       g   RRV R	23u # VP                  R
4      pVEe1   \        V\        4      '       d;   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   RRV R23u # \        V4       FW  w  rg\        VP                  4       4      \        8”  g   K)  RRV RV R\        VP                  4       4       R\         R2	3u u # 	  V Uu. uF*  qˆP                  4       '       g   K  VP                  4       NK,  	  upR\         p	V'       d   V	'       g   RRV R\        V4       R23u # T	;'       g    RpTP                  RRV 2RTR
V'       d   \        \        V4      4      MRRV'       d   \        V4      MRR\        VP                  R4      4      ;'       d    \        V4      /4       EK1  	  VR3# u upi )zÓValidate ``questions`` -> ``(normalized, error)``. Entries carry ``qid`` (stable wire id
``q<index>`` surfaces key answers by), ``question``, decorated ``choices``, bare
``choices_offered`` and ``multi_select``.Nz%questions must be a non-empty array. zquestions supports at most z items.z
questions[z] must be an object. Úquestionr   z"].question must be non-empty text.r   c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5i©N)r%   r   )Ú.0Úcs   & r   Ú	<genexpr>Ú'_normalize_questions.<locals>.<genexpr>C   s   é € Ð7\ÑT[Èq¼
À1Äc×8JÐ8JÓT[ùs   ‚FTz$].choices must be a list of strings.z
].choices[z] is z characters; the limit is z0. Move detail into the question text and resend.z].choices has zP entries but all are blank. Send real labels, or omit choices to ask open-ended.ÚqidÚqÚchoices_offeredÚmulti_select)r%   r
   Ú_SHAPEr   ÚMAX_QUESTIONSÚ	enumerateÚdictr   Úgetr   ÚallÚMAX_CHOICE_CHARSÚMAX_CHOICESÚappendr   r#   )
Ú	questionsÚ
normalizedÚindexr+   r   r   ÚposÚchoicer5   Úcleaneds
   &         r   Ú_normalize_questionsrK   2   sX  € ô �i¤×&Ò&¯iØÐ<¼V¸HÐEÐEÐEÜ
ˆ9ƒ~œÔ%ØÐ2´=°/ÀÐIÐIÐIØ€JÜ  ×+‰ˆÜ˜$¤×%Ò%Ø˜: e WÐ,AÄ&ÀÐJÐJÒJÜ�4—8‘8˜JÓ'×-Ð-¨2Ó.×4Ñ4Ó6ˆßØ˜: e WÐ,NÐOÐOÒOØ—(‘(˜9Ó%ˆØÓÜ˜g¤t×,Ò,·C³CÑ7\ÑT[Ó7\·C·C²CÑ7\ÑT[Ó7\×4\Ò4\Ø˜z¨%¨Ð0TÐUÐUÒUÜ(¨Ö1‘�Ü�v—|‘|“~Ó&Ô)9Ö9Ø J¨u¨g°ZÀ¸uÀEÌ#ÈfÏlÉlËnÓJ]ÐI^Ð^xÜ%5Ð$6Ð6fð#hð iô iñ  2ñ +2Ó?©' Q·W±W·Y”y�q—w‘w–y©'Ñ?ÀÄÐMˆGßŸwà 
¨5¨'°ÄÀGÃ¸~ð NUð Uð Vò Và—o�o ˆGØ×ÑØ�Q�u�g�; 
¨DØ¿'Ô'¬¨W«Ô6ÀtØ·œt Gœ}¸TØœD §¡¨.Ó!9Ó:×LÐL¼tÀG»}ð	N÷ 	Oñ) ,ð2 �tÐÐùò @s   Æ!JÆ=Jc                óH   € V ^8„  d   QhR\         R\        R\        R\        /# )r   r8   Úanswersr!   r	   )r   r?   r#   r/   )r   s   "r   r   r   W   s.   € ÷ Añ Aœ#ð A¬ð A´Tð A¼eñ Ar   c                 ó|   € VP                  V 4      pVR9  d   \        W24      MR pV'       d   RV3# W9   d   R# RR 3# )NÚansweredÚ
unanswered)Nr   )ÚskippedN)r@   r,   )r8   rM   r!   r)   rJ   s   &&&  r   Ú_response_statusrR   W   sF   € Ø
�+‰+�cÓ
€CØ+.°jÔ+@Œm˜CÔ'Àd€GßØ˜7Ð"Ð"ØœÐ@Ð@¨\¸DÐ@Ð@r   c                óR   € V ^8„  d   QhR\         \        ,          R\        R\        /# )r   rF   Úreplyr	   )r
   r?   r   )r   s   "r   r   r   _   s%   € ÷ 2ñ 2œœT�
ð 2¬4ð 2´Cñ 2r   c                óv  € VP                  R4      ;'       g    / p. pV  FF  p\        VR,          W$R,          4      w  rVVP                  RVR,          RVR,          RVRV/4       KH  	  RVR	VR	,          /pVP                  R
4      '       d   \        VR
,          4      VR
&   \        P
                  ! VRR7      # )zûResult JSON from a callback reply ``{"answers": {qid: raw | None}, "outcome", "notice"?}``:
every response carries ``status`` and ``user_response`` (null unless answered); ``outcome``
says how the wait ended and ``notice`` (surface-supplied) says why.rM   r8   r;   r1   r:   ÚstatusÚuser_responseÚ	responsesÚoutcomeÚnoticeF)Úensure_ascii)r@   rR   rD   r   r&   Údumps)rF   rT   rM   rX   ÚentryrV   ÚvalueÚresults   &&      r   Ú_resultr`   _   sº   € ð �i‰i˜	Ó"×(Ð( b€GØ€IÛˆÜ(¨¨u­°wÀnÕ@UÓV‰ˆØ×Ñ˜* e¨JÕ&7Ð9JÈEÐRcÕLdØ" F¨O¸UðDö 	Eñ ð "-¨i¸ÀEÈ)ÕDTÐ U€FØ‡y�y�×ÒÜ˜u X�Ó/ˆˆxÑÜ�:Š:�f¨5Ô1Ð1r   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# )r   Úcallbackr	   )r   r   r   )r   s   "r   r   r   o   s#   € ÷ Bñ B¤h¬xÕ&8ð BÄCñ Br   c                óê  € \        V 4      w  r#V'       d   \        V4      # Vf   \        \        4      # ^ RIHp V! RRP                  R V 4       4      R7      ;_uu_ 4       p V! V4      p\        VP                  R4      ;'       g    R4      Vn        \        W&4      uuRRR4       #   \         d*   pR	Tn        \        R
T 24      u Rp?uuRRR4       # Rp?ii ; i  + '       g   i     R# ; i)z³Ask 1-5 questions in one call. ``callback(questions) -> {"answers", "outcome", "notice"?}``
is platform injected (cli.py / gateway / tui_gateway) and receives the normalized list.N)Úhuman_input_requestÚclarifyÚ
c              3   ó2   "  € T F  qR ,          x € K  	  R# 5i)r1   N© )r4   r9   s   & r   r6   Úclarify_tool.<locals>.<genexpr>y   s   é € Ð8[ÑPZÈ1¸:¿ºÓPZùs   ‚)ÚpromptrY   r   ÚerrorzFailed to get user input: )rK   Ú
tool_errorÚ_UNAVAILABLEÚtools.human_input_hooksrd   Újoinr   r@   rY   r`   Ú	Exception)rE   rb   rF   rk   rd   ÚhumanrT   Úexcs   &&      r   Úclarify_toolrs   o   sÕ   € ô -¨YÓ7Ñ€JßÜ˜%Ó Ð ØÒÜœ,Ó'Ð'Ý;á	˜Y¨t¯y©yÑ8[ÑPZÓ8[Ó/[×	\Õ	\Ð`eð	BÙ˜ZÓ(ˆEÜ §	¡	¨)Ó 4× :Ð :¸Ó;ˆEŒMÜ˜:Ó-÷	 
]Ò	\øô
 ô 	BØ#ˆEŒMÜÐ :¸3¸%Ð@ÓAÔA÷ 
]Ò	\ûð
	Bú÷ 
]×	\Ð	\ús6   Á"C!Á$;B*Â*CÂ5CÃ	CÃ
C!ÃCÃC!Ã!C2	c                ó$   € V ^8„  d   QhR\         /# r.   r"   )r   s   "r   r   r   ƒ   s   € ÷ ñ ¤Dñ r   c                 ó   € R# )z>Clarify tool has no external requirements -- always available.Trh   rh   r   r   Úcheck_clarify_requirementsrv   ƒ   s   € ár   Únamere   Údescriptionz‘Ask the user one or more questions when you need a decision, clarification, or feedback before proceeding. Pass every question in `questions` (1-uö    entries) â€” a single question is a one-entry array, and several INDEPENDENT questions belong in ONE call (one form beats a chain of clarify calls; if one answer would change another question, ask separately). Per question: single-select (up to u   choices â€” put your recommended option FIRST, the UI marks it '(Recommended)' and auto-appends an 'Other' free-text row), multi-select (multi_select=true), or open-ended (omit choices). Options go ONLY in `choices`, never enumerated inside the question text (choices render as pickable rows; options written into the question are dead prose the user can't click). Result: {responses: [...], outcome} in question order. Each response has status answered, skipped or unanswered (user_response is null unless answered); outcome is submitted, cancelled, timed_out or undelivered, with a notice saying why when the wait ended without a submit. Prefer deciding low-stakes questions yourself; don't use this for dangerous-command confirmation (the terminal tool handles that).Ú
parametersÚtypeÚobjectÚ
propertiesrE   ÚarrayÚminItemsÚmaxItemszÎThe question(s). Each: question text (options excluded), optional choices (recommended first; omit for free-text), optional multi_select. Responses come back in question order with the question text echoed.Úitemsr1   Ústringr   r;   ÚbooleanÚrequired)Úregistryrl   c                 óX   € \        V P                  R 4      VP                  R4      R7      # )rE   rb   )rb   )rs   r@   )ÚargsÚkws   &,r   Ú<lambda>rˆ   Æ   s   € œ|¨D¯H©H°[Ó,AÈBÏFÉFÐS]ÓL^Õ_r   u   â�“)rw   ÚtoolsetÚschemaÚhandlerÚcheck_fnÚemojir3   )Ú__doc__r&   Útypingr   r   r   r   rC   r=   rB   r   rm   r<   r   r   r,   rK   rR   r`   rs   rv   ÚCLARIFY_SCHEMAÚtools.registryr„   rl   Úregisterrh   r   r   Ú<module>r“      sL  ðñ3ó ß 1Ó 1à€Ø€ð Ð à#Ð ØI€Ø	h€õ@õõJõ"õJAõ2÷ Bõ(ð ˆIØð	à*˜Oð , ð !,˜}ð -9ð	9ð( Ø�ØØØ˜Ø˜AØ˜MØð;ð
 Ø˜HØ Ø" V¨XÐ$6Ø!Ø" GØ# f¨hÐ%7Ø&¨ð$ð
 '¨°Ð(;ð#ð   ððð
ð4 	�[�Mð9ð/5€÷p 0à × Ò Ø	ØØÙ_Ø'Ø
÷r   