+
    „WÝjSä  ã                  ó^  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt	 ^ RI
Ht ^ RIHt ^ RIHt ]P                   ! ]4      tR(tR R ltR	 R
 ltR tR tR R ltR R ltR tR R ltR tR R ltR)t^$tR R lt R R lt!RR/R R llt"RRRRR R!/R" R# llt#R$ R% lt$ ! R& R'4      t%R# )*u  Model picker, /model switch application, runtime snapshot/restore, and codex runtime handling for the interactive CLI

Mixin split out of ``cli.py``; bound onto ``HermesCLI`` via the MRO. cli.py-internal
symbols are imported LAZILY inside each method (``from cli import ...``) â€” the mixin
never imports ``cli`` at module load time (import cycle).

Tests drive the switch paths with bare stubs lacking most mixin methods, so shared steps are
module-level functions taking ``cli`` and siblings are called as ``HermesCLI.<name>(self, ...)``.
)ÚannotationsN)Úescape©Út)Úbase_url_host_matches)Ú_retire_agentc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚdict© )Úformats   "ÚUC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\cli_model_switch_mixin.pyÚ__annotate__r   "   s   € ÷ Eñ E˜Dñ Eó    c           	     óL   € \          Uu/ uF  q\        WR 4      bK  	  up# u upi ©N)Ú_RUNTIME_FIELDSÚgetattr)ÚcliÚkeys   & r   Ú_runtime_fieldsr   "   s$   € Ý4CÓD±O¨S”˜ 4Ó(Ò(±OÑDÐDùÒDs   ‰!c               ó   € V ^8„  d   QhRR/# ©r
   r   ÚNoner   )r   s   "r   r   r   &   s   € ÷ $ñ $ 4ñ $r   c                ór   € ^ RI Hp ^ RIHp T! T\	        V RR4      ;'       g    R4      V n        RV n        R# )u  Re-resolve the CLI-level ``reasoning_config`` for ``cli.model`` through the shared chokepoint
(per-model ``reasoning_overrides`` > global ``agent.reasoning_effort``). Startup resolves it once
for the launch model; every path that moves ``cli.model`` must call this BEFORE the agent branch,
because a lazily built agent inherits this field â€” an always-thinking model then goes out with
the launch model's effort and 400s (#112921, #96012). ``agent.switch_model`` re-resolves its own
copy for the live-agent path.)Ú
CLI_CONFIG)Úresolve_reasoning_configÚmodelNÚ F)r   r   Úhermes_constantsr   r   Úreasoning_configÚ_reasoning_user_set)r   r   r   s   &  r   Ú_resolve_cli_reasoningr$   &   s4   € õ Ý9á3°JÄÈÈWÐVZÓ@[×@aÐ@aÐ_aÓb€CÔØ#€CÖr   c               óŠ  € \        T ;'       g    / P                  R4      ;'       g    R4      P                  4       pV'       g   R# ^ RIHp VP                  V 4      pVP                  R4      ;'       g    RpVP                  R4      ;'       g    RpVP                  R4      ;'       g    Rp\        W†VR7      p	W˜8w  d	   RpV	f   Rp\        V	4      ;'       d    W’8g  p
W18X  d   V
'       g   R# ^ R	IH	p V! W–4      '       d   R;rg^ R
I
Hp T! T	;'       g    RV4      pVe   ^ RIHp TpV! W—V4      ;'       g    RpW9WgV
3# )a­  The route a resumed session should run on, or ``None`` when the stored one is absent or
already current. Returns ``(model, provider, base_url, api_mode, provider_changed)``; the
canonical row reader is ``SessionDB.session_gateway_runtime`` (``model_config.gateway_runtime``,
else the TUI's top-level keys). Bare ``custom`` is healed because the CLI resolve path
hard-fails on it (the TUI gateway keeps it when a base_url exists).r   r    N)Ú	SessionDBÚbase_urlÚapi_modeÚprovider©r'   r   )Úis_foreign_provider_endpoint)Úmodel_derived_api_mode)Únormalize_opencode_base_url)ÚstrÚgetÚstripÚhermes_stater&   Úsession_gateway_runtimeÚ_heal_bare_custom_providerÚboolÚhermes_cli.runtime_providerr+   Úhermes_cli.model_switchr,   Úhermes_cli.modelsr-   )Úsession_metaÚcurrent_modelÚcurrent_providerÚstored_modelÚ
_SessionDBÚruntimer'   r(   Ústored_providerr)   Úprovider_changedr+   r,   Úderivedr-   s   &$$            r   Ústored_session_routerA   4   s1  € ô ˜×*Ð*¨×/Ñ/°Ó8×>Ð>¸BÓ?×EÑEÓG€LßÙÝ4Ø×0Ñ0°Ó>€GØ�{‰{˜:Ó&×.Ð.¨$€HØ�{‰{˜:Ó&×.Ð.¨$€HØ—k‘k *Ó-×5Ð5°€OÜ)¨/ÐT`Ôa€HØÔ"ð ˆØÒØˆHÜ˜H“~×FÐF¨(Ñ*FÐØÔ$×-=ÙÝHÙ# H×7Ò7à"Ð"ˆõ
 ?Ù$ X§^ ^°°\ÓB€GØÒÝAØˆÙ.¨xÀ8ÓL×TÐTÐPTˆØ 8Ð7GÐGÐGr   c               óô   € \        T ;'       g    R4      P                  4       P                  4       R8w  d   V #  ^ RIHp T! T;'       g    RT;'       g    RR7      ;'       g    R#   \
         d     R# i ; i)a  Bare ``custom`` is a billing class, not a routable identity: persisting/restoring it makes a
later resume hard-fail once the config default leaves the custom endpoint. Recover the durable
``custom:<name>`` menu key from the endpoint, else drop the provider (None).r    Úcustom)Úcanonical_custom_identityNr*   )r.   r0   Úlowerr5   rD   Ú	Exception)r)   r'   r   rD   s   &$$ r   r3   r3   ]   sp   € ô ˆ8�>ˆ>�rÓ× Ñ Ó"×(Ñ(Ó*¨hÔ6Øˆðõ 	JÙ(°(×2BÐ2B¸dÈ%Ï-È-ÐSWÔX×`Ð`Ð\`Ð`øÜô Úðús#   ºA( Á
A( ÁA( Á%A( Á(A7Á6A7c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   m   s   € ÷ Mñ M¸tñ Mr   c                ó^  € ^ RI Hp V P                  f   R#  ^ RIHp T! TV P                  \        V P                  ;'       g    . 4      Ve   TM\        V P                  RR4      \        V P                  RR4      R7       R#   \         d   pTP                  RT4        Rp?R# Rp?ii ; i)zKFold the context-compression preflight warning into ``result`` (fail-soft).©ÚloggerN)Ú#merge_preflight_compression_warningÚ_custom_providersÚ_config_context_length)ÚagentÚmessagesÚcustom_providersÚconfig_context_lengthz/preflight-compression switch warning failed: %s)
r   rJ   rN   Úhermes_cli.context_switch_guardrK   ÚlistÚconversation_historyr   rF   Údebug)r   ÚresultrP   rJ   rK   Úexcs   &&&   r   Ú_merge_preflight_warningrX   m   s—   € åØ
‡y�yÒÙðMÝWñ 	,ØØ—)‘)Ü˜#×2Ñ2×8Ð8°bÓ9Ø1AÒ1MÑ-Ü˜Ÿ™Ð$7¸Ó>Ü")¨#¯)©)Ð5MÈtÓ"T÷	Vøô ô MØ�‰ÐFÈ×LÒLûðMús   ˜+B Á>B ÂB,ÂB'Â'B,c               ó$   € V ^8„  d   QhRRRRRR/# )r
   Úone_turnr4   Ústrict_contextr   r   r   )r   s   "r   r   r   �   s#   € ÷ :2ñ :2¸tð :2ÐUYð :2Ð^bñ :2r   c               ó”  € ^ RI Hp ^ RIHpHp V! V4      pV! VP
                  4      p	RT RT	 RVP                  ;'       g    VP                   RV'       d   RMR R	2	V n        V! R
\        RV	R7       24       T! R\        RVP                  ;'       g    VP                  R7       24       VP                  R8X  dÉ   ^ RI
Hp
 \        V P                  \        4      '       d   V P                  P                  R4      M/ pV
! V4      R,          P                  VP
                  / 4      P                  R4      ;'       g    / pV'       d<   VP                  R4       RVP                  R4       2pV! R\        RVR7       24       VP                   pV P"                  p T! VP
                  VP                  VP$                  ;'       g    V P$                  ;'       g    RVP&                  ;'       g    V P&                  ;'       g    RTV'       d   \)        VRR4      MRV'       d   \)        VRR4      MRR7      pV'       d=   ^ RIHp T! R\        RVR R7       T! TV'       d   \)        VRR4      MR4       24       V'       dY   VP0                  '       d#   V! R\        R VP0                  R R7       24       V! R\        R!VP3                  4       R"7       24       \5        VP$                  ;'       g    RR#4      ;'       d&    R$VP
                  P7                  4       9   ;'       g    VP8                  R%8H  pV'       d   V! R\        R&4       24       VP:                  '       d   V! R'VP:                   24       \)        VR(R4      '       d   V! R'VP<                   24       R# R#   \*         d    T'       d   h Rp ELˆi ; i))a3  Record the next-turn switch note and print the "Model switched" block.

The note is prepended to the next user message (a mid-history system message would break
providers and prompt caching). ``strict_context``: the typed /model path lets
context-resolution errors propagate; the picker path swallows them.
©Ú_cprint)Úformat_model_for_displayÚresolve_display_context_lengthz$[Note: model was just switched from z to z via z. z-This override applies to the next turn only. r    z-Adjust your self-identification accordingly.]ú  zcli.model.switched©r   ú    zgateway.model.provider_label)r)   Úmoa)Únormalize_moa_configÚpresetsÚ
aggregatorr)   Ú:r   zcli.model.acting_modelrM   NrL   )r'   Úapi_keyÚ
model_inforQ   rP   )Úcontext_pin_suffixzgateway.model.context_labelÚ,)Útokenszgateway.model.max_output_labelz gateway.model.capabilities_label)Úcapabilitieszopenrouter.aiÚclaudeÚanthropic_messagesz$gateway.model.prompt_caching_enabledu       âš  Úusage_notice)r   r^   r6   r_   r`   Ú	new_modelÚprovider_labelÚtarget_providerÚ_pending_model_switch_noter   Úhermes_cli.moa_configre   Ú
isinstanceÚconfigr   r/   rj   rN   r'   ri   r   rF   Úagent.context_pinrk   Ú
max_outputÚformat_capabilitiesr   rE   r(   Úwarning_messagerq   )r   rV   Ú	old_modelrZ   r[   r^   r_   r`   Ú_display_oldÚ_display_newre   Úmoa_cfgÚaggÚ_actingÚmirN   Úctxrk   Úcache_enableds   &&&$$              r   Ú_print_switch_summaryr†   �   s\  € õ ß`Ù+¨IÓ6€LÙ+¨F×,<Ñ,<Ó=€Là
.¨|¨n¸DÀÀð OØ×$Ñ$×>Ð>¨×(>Ñ(>Ð?¸rß>FÑ:ÈBÐ
OØ
7ð	9ð Ô"ñ
 ˆb”Ð'¨|Ô<Ð=Ð>Ô?Ùˆd”1Ð3¸f×>SÑ>S×>mÐ>mÐW]×WmÑWmÔnÐoÐpÔqØ×Ñ Ô&å>Ü+5°c·j±jÄ$×+GÒ+G�#—*‘*—.‘. Ô'ÈRˆÙ" 7Ó+¨IÕ6×:Ñ:¸6×;KÑ;KÈRÓP×TÑTÐUaÓb×hÐhÐfhˆßØŸ™ Ó,Ð-¨Q¨s¯w©w°wÓ/?Ð.@ÐAˆGÙ�dœ1Ð5¸WÔEÐFÐGÔHð 
×	Ñ	€BØ�I‰I€Eð
Ù,Ø×Ñ˜f×4Ñ4Ø—_‘_×:Ð:¨¯©×:Ð:¸Ø—N‘N×7Ð7 c§k¡k×7Ð7°RÀBßTY¤'¨%Ð1IÈ4Ô"PÐ_cßJOœW UÐ,?ÀÔFÐUYô[ˆ÷ Ý8Ù�$”qÐ6À#ÀaÀÔJÐKÙ% c×]b¬7°5Ð:RÐTXÔ+YÐhlÓmÐnðpô 	qç	Ø�=�=ˆ=Ù�dœ1Ð=ÈÏÉÐWXÐHYÔ[Ð\Ð]Ô^Ù�$”qÐ;È"×J`ÑJ`ÓJbÔcÐdÐeÔfä	˜vŸ™×4Ð4°"°oÓ	F×	oÐ	oÈ8ÐW]×WgÑWg×WmÑWmÓWoÑKo÷ 	3ð 	3Ø�?‰?Ð2Ñ2ð ÷ Ù�$”qÐ?Ó@ÐAÐBÔCØ××ÐÙ�(˜6×1Ñ1Ð2Ð3Ô4Üˆv�~ r×*Ò*Ù�(˜6×.Ñ.Ð/Ð0Ö1ñ +øô' ô ßØØ‹ðús<   Æ!*N- ÇN- Ç N- Ç5N- È	
N- ÈN- È*N- Î-OÏ OÏOc               óÌ   € ^ RI Hp T! YP                  ;'       g    RV P                  ;'       g    RV P                  ;'       g    RV P
                  ;'       g    RVW4VR7	      # )z3``switch_model`` seeded with this CLI's live route.)Úswitch_modelr    )	Ú	raw_inputr:   r9   Úcurrent_base_urlÚcurrent_api_keyÚ	is_globalÚexplicit_providerÚuser_providersrP   )r6   rˆ   r)   r   r'   ri   )r   r‰   rŒ   r�   rŽ   rP   rˆ   s   &&$$$$ r   Ú_switch_model_fromr�   ¾   s[   € õ 5ÙØ¯l©l×.@Ð.@¸bÐPS×PYÑPY×P_ÐP_Ð]_ØŸ™×+Ð+¨¸S¿[¹[×=NÐ=NÈBÐZcØ+Ø)ô	+ð +r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   É   s   € ÷ 
ñ 
°$ñ 
r   c                óˆ   € \        V RR4      '       d)   \        P                  ! WRR7      P                  4        R# V! V!   R# )a/  Run a confirm+apply sequence off the UI thread when the TUI is live.

The expensive-model modal blocks its thread on a response queue (_prompt_text_input_modal);
on the prompt_toolkit main thread that freezes rendering, so the modal never appears and the
switch silently cancels after the 120s timeout.
Ú_appNT)ÚtargetÚargsÚdaemon)r   Ú	threadingÚThreadÚstart)r   r“   r”   s   &&*r   Ú_run_confirm_and_applyr™   É   s3   € ô ˆs�F˜D×!Ò!Ü×Ò ¸$Ô?×EÑEÖGá�Œr   c                ó  € ^ RI HpHp \        V RR4      pVe#   \	        VR4      '       d   VP                  4        V! V4      pVe   V# ^ RIHp \        V RR4      p\        V RR4      pVe%   V'       d   \        \        VRR4      4      '       g   R#  VP                  V4      pT! YgT4      p	T	'       g   R# T! T	\        T RR4      ;'       g    RR7      #   \         d    \        P                  R	R
R7        R# i ; i)a	  Context the owner's large-context guard would see, for a ``/model --once`` that does not mutate.

A live compressor measurement wins. Otherwise refresh ``session.stats``, then the session row's
persisted usage anchor (a resume, before this process has run a turn).
)ÚSelectionContextÚselection_context_for_agentrN   NÚ_refresh_stats)Úpersisted_anchor_tokensÚ_session_dbÚ
session_idÚget_messages_as_conversationz&one-turn selection context unavailableT©Úexc_infor   )Úcontext_tokensr9   )Ú!hermes_cli.model_selection_guardsr›   rœ   r   Úhasattrr�   Úagent.usage_anchorrž   Úcallabler¡   rF   rJ   rU   )
r   r›   rœ   rN   Úliverž   ÚdbÚsidrO   rm   s
   &         r   Ú_one_turn_selection_contextr¬   Ö   sö   € ÷ `Ü�C˜ $Ó'€EØÒœW UÐ,<×=Ò=Ø×ÑÔÙ& uÓ-€DØÒØˆÝ:Ü	��m TÓ	*€BÜ
�#�| TÓ
*€CØ	‚zŸ¤H¬W°RÐ9WÐY]Ó-^×$_Ò$_ÙðØ×2Ñ2°3Ó7ˆñ % R¨hÓ7€FßÙÙ¨6ÄÈÈgÐW[ÓA\×AdÐAdÐ`dÔeÐeøô ô Ü�‰Ð=ÈˆÔMÚðús   ÂC Ã"C>Ã=C>c               ó$   € V ^8„  d   QhRRRRRR/# )r
   Útitler.   Údetailr   r4   r   )r   s   "r   r   r   ó   s&   € ÷ Gñ G 3ð G°ð G¸ñ Gr   c                ó¶   € R\        R4      \        R4      3R\        R4      \        R4      3.pV P                  RV R2W#^xR	7      pV P                  WC4      R8H  # )
zUThe model-guard prompt (switch anyway once, or cancel): True only on an explicit yes.Úoncezcli.model.choice_switch_anywayzcli.model.desc_switch_anywayÚcancelzcli.model.choice_cancelz!cli.model.desc_keep_current_modelz!!! z !!!)r®   r¯   ÚchoicesÚtimeout)r   Ú_prompt_text_input_modalÚ_normalize_slash_confirm_choice)r   r®   r¯   r³   Úraws   &&&  r   Ú_ask_switch_anywayr¸   ó   sq   € ð 
”Ð3Ó4´aÐ8VÓ6WÐXØ	”1Ð.Ó/´Ð3VÓ1WÐXðZ€Gð ×
&Ñ
&¨t°E°7¸$Ð-?ÈÐilÐ
&Ó
m€CØ×.Ñ.¨sÓ<ÀÑFÐFr   c               ó   € V ^8„  d   QhRR/# )r
   r   zlist[tuple[str, str]]r   )r   s   "r   r   r   
  s   € ÷ ñ Ð 5ñ r   c                 ó°   € ^ RI Hp  V  Uu. uF  qV3NK  	  ppVP                  R\        R4      34       VP                  R\        R4      34       V# u upi )zš``(value, label)`` rows for the picker's effort step: the canonical ladder, the off state,
then a keep-current row (empty value = leave the effort alone).)ÚVALID_REASONING_EFFORTSÚnonezcli.model.effort_noner    zcli.model.effort_keep_current)r!   r»   Úappendr   )r»   ÚlvlÚrowss      r   Ú_picker_reasoning_rowsrÀ   
  sW   € õ 9Ù"9Ó:Ñ"9˜3�#‹JÑ"9€DÐ:Ø‡K�K�œÐ2Ó3Ð4Ô5Ø‡K�K�”QÐ6Ó7Ð8Ô9Ø€Kùò ;s   ‹Ac               ó$   € V ^8„  d   QhRRRRRR/# )r
   Úprovider_datar   r   r.   r   r4   r   )r   s   "r   r   r     s&   € ÷ Mñ M¨Dð M¸ð MÀñ Mr   c                óê   € T ;'       g    / P                  R4      p\        V\        4      '       d   VP                  V4      MRp\        V\        4      ;'       d    VP                  R4      RJ '       * # )z©False only when the inventory's capability map says the picked model has no reasoning
control; unknown capabilities keep the step (a no-op dial beats hiding a real one).rn   NÚ	reasoningF)r/   rw   r   )rÂ   r   ÚcapsÚentrys   &&  r   Ú_picker_offers_reasoningrÇ     s]   € ð ×Ð˜R×$Ñ$ ^Ó4€DÜ)¨$´×5Ò5ˆD�H‰H�UŒO¸4€EÜ˜5¤$Ó'×KÐK¨E¯I©I°kÓ,BÀeÐ,KÔLÐLr   rZ   Fc               ó(   € V ^8„  d   QhRRRRRRRR/# )r
   Úeffortr.   Úpersist_globalr4   rZ   r   r   r   )r   s   "r   r   r     s0   € ÷ "vñ "v¨sð "vÀtð "vÐW[ð "vÐhlñ "vr   c               ó¼  € ^ RI HpHpHpHp V! V4      pVf   R# W€n        V'       dœ   ^ RIHp	 \        V RR4      p
\        V
\        4      '       d   WR&   \        V P                  V	4      '       d   V P                  P                  V4       MV P                  e   W€P                  n        V! R\        RVR7       24       R# R	V n        V P                  e5   \        V P                  R
R4      pVe
   V! V4       MW€P                  n        T;'       d
    V! RV4      pV'       d   WP                  R/ 4      R&   T! R\        V'       d   RMRVR7       24       R# )aÃ  Apply a ``--reasoning <level>`` that rode along with a model pick. Runs AFTER the swap: the
agent's ``switch_model`` re-resolves ``reasoning_config`` from config.yaml, so an earlier write
would be clobbered. Session-scoped unless the pick itself persists (``--global``).

``one_turn`` (``--once``): the level rides the one-turn admission (``model_override.reasoning``)
and the restore snapshot puts the CLI's own level back. It is never a session pin.)r   r^   Ú_parse_reasoning_configÚsave_config_valueN©ÚGatewayAgentÚ_pending_one_turn_model_restoreÚone_turn_reasoningrc   zcli.model.reasoning_effort)rÉ   TÚpin_reasoningzagent.reasoning_effortrN   Úreasoning_effortz cli.model.reasoning_effort_saved)r   r   r^   rÌ   rÍ   r"   Úhermes_cli.gateway_agentrÏ   r   rw   r   rN   Ústage_turn_reasoningr   r#   Ú
setdefault)r   rÉ   rÊ   rZ   r   r^   rÌ   rÍ   ÚparsedrÏ   ÚpendingÚpinÚsaveds   &&$$         r   Ú_apply_reasoning_after_switchrÛ     s'  € ÷ TÓSÙ$ VÓ,€FØ‚~ÙØ!ÔßÝ9Ü˜#Ð@À$ÓGˆÜ�gœt×$Ò$Ø,2Ð(Ñ)Ü�c—i‘i ×.Ò.Ø�I‰I×*Ñ*¨6Õ2Ø�Y‰YÒ"Ø)/�I‰IÔ&Ù�$”qÐ5¸fÔEÐFÐGÔHÙØ"€CÔØ
‡y�yÒä�c—i‘i °$Ó7ˆØŠ?Ù��Kà)/�I‰IÔ&Ø×RÐRÑ0Ð1IÈ6ÓR€EßØAG×Ñ˜g rÓ*Ð+=Ñ>Ùˆd”1¿5Ñ7ÐFbÐkqÔrÐsÐtÖur   ÚpickerrÓ   r    c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r
   rÊ   r4   rZ   rÜ   rÓ   r.   r   r   r   )r   s   "r   r   r   A  s;   € ÷ 2@ñ 2@Ø$(ð2@Ø48ð2@ØJNð2@àð2@à#'ñ2@r   c               ó  € ^ RI HpHp V P                  \	        V RR4      r˜V'       d&   \	        V RR4      ;'       g    V P                  4       MRp
V
e-   V
P                  4        UUu/ uF  w  r¼VR9  g   K  W¼bK  	  p
pp\        V4      V n         V P                  W4      pRV n        V'       g   R# \	        V RR4      '       gH   ^ RI
Hp T! Y‘P                  R	T\	        \	        V R
R4      RR4      ;'       g    \	        V RR4      R7       V'       g-   W n        V
e#   \	        VRR4      '       d   VP                  V
R&   \        WWƒV'       * R7       V'       d   \!        YT;'       d    V'       * VR7       V'       d.   ^ RIHp V! V4       T! R\'        V'       d   RMR4       24       M1V'       d   V! R\'        R4       24       MV! R\'        R4       24       V'       g   VP)                  W4       R# R# u uppi   RT n        i ; i)aW  Stage + swap, print the summary, persist (session row unless --once; config on --global).
``picker``: tolerate context-resolution errors and label the config write "(--global)"; the
typed path additionally records the one-turn restore snapshot. ``reasoning_effort`` (from
``--reasoning`` or the picker's effort step) is applied after the swap.)Ú	HermesCLIr^   r)   NrÐ   Úone_turn_aliasFÚis_slash_worker)Úrecord_model_switchr   rN   r    )Úfrom_providerÚto_providerÚsurfaceÚ
from_modelr    Úresolved_via_aliasr    )rZ   r[   )rÊ   rZ   )Úpersist_model_selectionrc   zcli.model.saved_globalzcli.model.savedzcli.model.next_turn_onlyzcli.model.session_only)rÑ   rà   )r   rß   r^   r   r   Ú_snapshot_model_runtimeÚitemsr4   Ú_model_switch_one_turnÚ_stage_and_swap_modelÚ.hermes_cli.observability.shared_metrics_eventsrâ   rt   rÐ   rç   r†   rÛ   r6   rè   r   Ú _persist_model_switch_to_session)r   rV   rÊ   rZ   rÜ   rÓ   rß   r^   r}   Úold_providerÚsnapshotr   ÚvalueÚstagedrâ   rè   s   &&$$$$          r   Ú_commit_model_switchró   A  sò  € ÷ 'Ø!Ÿi™i¬°°jÀ$Ó)Gˆ|÷ 6>ô ˜Ð>ÀÓE÷ 1ð 1Ø×.Ñ.Ó0øÀ4ð àÒð 2:·±Ô1Aô LÑ1A¡: 3ØÐ"JÑJô �C’JÑ1Aˆñ Lô "& h£€CÔð+Ø×*Ñ*¨6Ó=ˆà%*ˆÔ"ßÙä�3Ð)¨5×1Ò1ÝVÙØ&×4JÑ4JÐTYÐfoÜœw s¨G°TÓ:¸LÈ$ÓO×sÐsÔSZÐ[^Ð`lÐnrÓSsõ	u÷ Ø.6Ô+ØÒ¤G¨FÐ4HÈ"×$MÒ$MØ)/×)BÑ)BˆHÐ%Ñ&Ü˜# yÐX^ÔT^Õ_ßÜ% cÈN×LkÐLkÐckÔ_kØ/7õ	9çÝCÙ Ô'Ù�$”q·VÑ1ÐARÓSÐTÐUÕVß	Ù�$”qÐ3Ó4Ð5Ð6Õ7á�$”qÐ1Ó2Ð3Ð4Ô5÷ Ø×2Ñ2°3Ö?ñ ùóELøð &+ˆÕ"ús   Á'G<Á7G<ÂH È	Hc               ó    € V ^8„  d   QhRRRR/# )r
   Úforce_refreshr4   r   r   r   )r   s   "r   r   r   v  s   € ÷ Hñ H°ð H¸ñ Hr   c           	     ó:  € ^ RI Hp ^ RIHp ^ RIHp  Vf   \        R4      hV! WV'       * RRRR7      R	,          pV'       gX   V! R
\        R4       24       V! R4       \         F/  w  rxV! R
VP                  \        4       R\        V4       24       K1  	  R# T P                  Y`P                  ;'       g    RV P                  '       d   V! V P                  4      MRVe   VP                  MRVe   VP                   MRR7       R#   \         d    . p LÝi ; i)zP``/model`` with no args: open the picker, or print usage when nothing is authed.r]   )Úbuild_models_payload)Ú	get_labelNzinventory context unavailableTF)Úprobe_custom_providersÚprobe_current_custom_providerrn   Ú
for_pickerÚfast_custom_probeÚ	providersra   z$cli.model.no_authenticated_providersr    Ú Úunknown)Ú
user_provsÚcustom_provs)r   r^   Úhermes_cli.inventoryr÷   Úhermes_cli.providersrø   ÚRuntimeErrorrF   r   Ú_MODEL_USAGE_ROWSÚljustÚ_MODEL_USAGE_COLÚ_open_model_pickerr   r)   rŽ   rP   )	r   r„   rõ   r^   r÷   rø   rý   ÚformÚdesc_keys	   &&&      r   Ú_show_model_pickerr  v  s  € åÝ9Ý.ðØŠ;ÜÐ>Ó?Ð?Ù(ØØ.;Ô*;Øð ð $ô
ð õˆ	÷ Ù�"”QÐ=Ó>Ð?Ð@ÔAÙ�Œß/‰NˆDÙ�b˜Ÿ™Ô$4Ó5Ð6°a¼¸(»°}ÐEÖFñ 0áØ×ÑØ—9‘9×)Ð) 	ÀcÇlÇlÀl©9°S·\±\Ô+BÐXaØ),ª�3×%Ò%¸dØ-0ª_�S×)Ò)À$ð ö Høô ô ØŠ	ðús   ”(D
 Ä
DÄDc                  óR  € ] tR tRtRtR R ltR R ltRR/R	 R
 lltR1R R lltR R lt	R R lt
R2R R lltR R ltR R ltR R lt]R R l4       t]R3R R ll4       tR R ltR2R  R! lltR4R" R# lltR5R$ R% lltR& R' ltR2R( R) lltR* R+ ltR4R, R- lltR. R/ ltR0tR# )6ÚCLIModelSwitchMixini˜  zuModel picker, /model switch application, runtime snapshot/restore, and codex runtime handling for the interactive CLIc               ó    € V ^8„  d   QhRRRR/# )r
   Úresolved_providerr.   r   r4   r   )r   s   "r   r   Ú CLIModelSwitchMixin.__annotate__›  s   € ÷ Uñ U¸sð UÀtñ Ur   c                óR  a aaaaaaaa€ ^ RI Hp \        S P                  ;'       g    R4      P	                  4       o\        S P                  \        4      '       d   V! S P                  4      w  opRoR VVV 3R lloR VVVV 3R llp ^ RIHpH	p SV9  d   S! V! SS4      VV3R	 l4       SR
8X  d!   ^ RIHoHo T! TT 3R lTT 3R lT3R l4      # ^ RIHp T! S4      e"   ^ RIHoHo T! TT3R lTT3R lTT3R l4      # SR8w  d   S# RS9   dl   SP#                  R^4      ^,          pS P$                  '       g6   S P'                  R\)        \+        RSTRR7      4      ,           R,           4       TS n        ToRoS P$                  '       dp   ^ RIHp	Hp
 T	^ ,          p T
! S P2                  '       d   S P2                  MRS P4                  ;'       g    RR7      pT'       d
   T^ ,          pST8w  d
   TS n        RoS#   \         d     ELdi ; i  \         d     L1i ; i)z2Normalize provider-specific model IDs and routing.)Ú_split_model_config_defaultr    Fc               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   ÚGCLIModelSwitchMixin._normalize_model_for_provider.<locals>.__annotate__£  s   € ÷ 	ñ 	¨ñ 	r   c                óž   <€ V '       dD   V S8w  d;   SP                   '       g   SP                  RV! V 4       R24       V Sn        V oRoR# R# R# )zMAdopt ``canonical`` when it differs; ``notice(new)`` builds the warning text.õ   [yellow]âš ï¸�  ú[/]TN)Ú_model_is_defaultÚ_console_printr   )Ú	canonicalÚnoticeÚchangedr9   Úselfs   &&€€€r   Ú_adoptÚACLIModelSwitchMixin._normalize_model_for_provider.<locals>._adopt£  sQ   ø€ ÷ ˜Y¨-Ô7Ø×-×-Ð-Ø×'Ñ'Ð*:¹6À)Ó;LÐ:MÈSÐ(QÔRØ&�”
Ø )�Ø’ñ 8‰yr   c               ó   € V ^8„  d   QhRR/# ©r
   r   r4   r   )r   s   "r   r   r  ­  s   € ÷ 	ñ 	Àñ 	r   c                ó�   <€  S! V ! S4      V4       V! S4      pVSP                   8w  d
   VSn         RoS#   \         d     S# i ; i)zPProvider families that also own the wire protocol: adopt id, then sync api_mode.T)r(   rF   )Ú	normalizeÚapi_mode_ofr  Úresolved_moder  r  r9   r  s   &&& €€€€r   Ú_adopt_with_modeÚKCLIModelSwitchMixin._normalize_model_for_provider.<locals>._adopt_with_mode­  sY   ø€ ðÙ‘y Ó/°Ô8Ù +¨MÓ :�Ø  D§M¡MÔ1Ø$1�D”MØ"�Gð ˆNøô ô ØØˆNðús   ƒ'6 «	6 ¶AÁA)Ú_AGGREGATOR_PROVIDERSÚnormalize_model_for_providerc                ó"   <€ \        R SV SR7      # )zcli.model.normalized_model©ÚoldÚnewr)   r   ©r-  r9   r  s   &€€r   Ú<lambda>ÚCCLIModelSwitchMixin._normalize_model_for_provider.<locals>.<lambda>À  s   ø€ ¤Ð">ÀMÐWZÐevÕ wr   Úcopilot)Úcopilot_model_api_modeÚnormalize_copilot_model_idc                ó,   <€ S! V SP                   R 7      # ©©ri   r6  )Úmr3  r  s   &€€r   r/  r0  Ç  s   ø€ Ñ4°QÀÇÁÕMr   c                ó,   <€ S! V SP                   R 7      # r5  r6  )r7  r2  r  s   &€€r   r/  r0  È  s   ø€ Ñ0°¸D¿L¹LÕIr   c                ó    <€ \        R SV R7      # )z"cli.model.normalized_copilot_model)r,  r-  r   )r-  r9   s   &€r   r/  r0  É  s   ø€ œAÐBÈÐ[^Õ_r   )Úopencode_provider_familyN)Únormalize_opencode_model_idÚopencode_model_api_modec                ó   <€ S! SV 4      # r   r   )r7  r;  r  s   &€€r   r/  r0  Ï  s   ø€ Ñ5Ð6GÈÔKr   c                ó   <€ S! SV 4      # r   r   )r7  r<  r  s   &€€r   r/  r0  Ð  s   ø€ Ñ1Ð2CÀQÔGr   c                ó"   <€ \        R SV SR7      # )ú"cli.model.stripped_provider_prefixr+  r   r.  s   &€€r   r/  r0  Ñ  s   ø€ œAÐBÈÐ[^ÐizÕ{r   zopenai-codexÚ/r  r@  zOpenAI Codexr+  r  T)ÚDEFAULT_CODEX_MODELSÚget_codex_model_ids)Úaccess_tokenr'   )r   r  r.   r   r0   rw   r   Úhermes_cli.model_normalizer(  r)  rF   r7   r2  r3  r:  r;  r<  Úsplitr  r  Ú_escaper   Úhermes_cli.codex_modelsrB  rC  ri   r'   )r  r  r  Ú_r&  r(  r)  r:  ÚslugrB  rC  Úfallback_modelÚ	availabler  r  r2  r9   r3  r;  r<  s   ff           @@@@@@@r   Ú_normalize_model_for_providerÚ1CLIModelSwitchMixin._normalize_model_for_provider›  s  ÿø€ å3Ü˜DŸJ™J×,Ð,¨"Ó-×3Ñ3Ó5ˆÜ�d—j‘j¤$×'Ò'Ù:¸4¿:¹:ÓFÑˆM˜1Øˆ÷	ò 	÷	ó 	ð	÷Eà Ð(=Ô=ÙÙ0°Ð@QÓRÝwôyð  	Ô)ß\Ù#ÝMÝIÜ_óað aõ
 	?Ù#Ð$5Ó6ÒBß^Ù#ÝKÝGÝ{ó}ð }ð
  Ô.ØˆNð �-ÔØ ×&Ñ& s¨AÓ.¨qÕ1ˆDØ×)×)Ð)Ø×#Ñ#Ø&¬´Ð3WÐ]jÐptð  @Nô  2Oó  *Põ  Pð  SXõ  XôYàˆDŒJØ ˆMØˆGð ×!×!Ð!ßYà1°!Õ4ˆNðá/Ø15··° §¢À4ÐRV×R_ÑR_×RgÐRgÐcgôi�	çØ%.¨q¥\�Nð  Ô.Ø+�”
Ø�Øˆøô_ ô 	Úð	ûôT ô Ùðús6   Â$H Æ'H Æ;H ÇH Ç+	H ÈHÈHÈH&È%H&c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r  ò  s   € ÷ #Xñ #X¸$ñ #Xr   c                óà  € ^ RI Hp \        V RR4      p\        V RR4      pV'       d	   V'       g   R# R\        VP                  VP
                  VP                  R7      ;'       g    RRVP
                  ;'       g    RRVP                  ;'       g    R/p VP                  WAP                  4       VP                  VR	V/VC4       R#   \         d    TP                  R
RR7        R# i ; i)u   Persist a session-scoped /model switch to the session DB row.

Writes the model column plus the route in both shapes readers use â€” nested
``gateway_runtime`` (CLI --resume) and top-level keys (TUI session.resume) â€” from one
or-None dict so stale keys are DELETED (``_merge_model_config_json`` only deletes on
explicit None) and the shapes never diverge.

Writes the model column plus the runtime route so ``--resume`` (CLI, reads ``gateway_runtime``) and
``session.resume`` (TUI/desktop, reads top-level ``model_config`` keys via
``_stored_session_runtime_overrides``) both restore the switched provider instead of recombining the
model with the ambient default (#79536). Mirrors the gateway's ``update_session_model()`` call.
getattr: tests drive the switch paths with ``object.__new__`` stubs.
rI   rŸ   Nr    r)   r*   r'   r(   Úgateway_runtimez,Failed to persist model switch to session DBTr¢   )r   rJ   r   r3   rt   r'   rr   r(   Úupdate_session_modelÚpatch_session_model_configrF   rU   )r  rV   rJ   rª   r«   Úroutes   &&    r   rî   Ú4CLIModelSwitchMixin._persist_model_switch_to_sessionò  sÝ   € õ 	Ü�T˜=¨$Ó/ˆÜ�d˜L¨$Ó/ˆßŸÙàÔ2Ø×&Ñ&°·±È×HXÑHXô÷ ð àð ˜Ÿ™×/Ð/¨4Ø˜Ÿ™×/Ð/¨4ð1ˆð	XØ×#Ñ# C×)9Ñ)9Ô:Ø×)Ñ)¨#Ð0AÀ5Ð/RÈEÐ/RÖSøÜô 	XØ�L‰LÐGÐRVˆL×Wð	Xús   Â1C ÃC-Ã,C-ÚquietFc               ó$   € V ^8„  d   QhRRRRRR/# )r
   r8   r   rV  r4   r   r   r   )r   s   "r   r   r    s'   € ÷ U>ñ U>°4ð U>À4ð U>ÐTXñ U>r   c               ó  € ^ RI Hp T;'       g    / P                  R4      '       d   \        V RR4      '       d   R# \	        WP
                  V P                  R7      pVf   R# Tw  rVrxp	^ RIHp
 \        T;'       g    R4      P                  4       P                  4       V
9   pWPn        V'       d1   W`n        W`n        V'       d   V'       g   Wpn        V'       d   W€n        V'       dÜ   \        V R	R4      '       d	   V	'       dÁ   RV n        RV n         ^ R
IHp T! Y`P
                  ;'       g    RR7      pVP                  R4      '       d%   VR,          V n        VP                  R4      V n        VP                  R4      '       d   VR,          V n        V'       g&   VP                  R4      '       d   VR,          V n        MÎV	'       dÇ   RV n        Wpn         ^ R
IHp T! Y`P
                  ;'       g    RR7      pVP                  R4      '       d%   VR,          V n        VP                  R4      V n        V'       g&   VP                  R4      '       d   VR,          V n        V'       g&   VP                  R4      '       d   VR,          V n        \/        V 4       V P0                  er    V P0                  P3                  V P
                  V P                  V P&                  ;'       g    RV P                  ;'       g    RV P                  ;'       g    RR7       \5        RVR7      pV'       d   VRV R2,          pV'       d   \7        V\8        P:                  R7       R# V P=                  R\?        V4       R24       R#   \*         d'    T'       d   Ypn        TP-                  RTRR7        EL!i ; i  \*         d    TP-                  RTRR7        ELGi ; i  \*         d    TP-                  RRR7        Lái ; i)u’  Restore model/provider from the session DB row on every resume path.

Skips when no model is recorded or the CLI got an explicit ``-m`` (user intent wins).
A different stored provider gets its credentials re-resolved â€” the ambient ``api_key``
must not be sent to the session's endpoint; on failure the ambient credentials are kept
so the session still opens (the first turn surfaces the auth error).
rI   r   Ú_explicit_model_overrideFN)r9   r:   )ÚLLAMACPP_ALIASESr    Ú_explicit_base_url)Úresolve_runtime_provider)Ú	requestedÚtarget_modelri   Úcredential_poolr'   r(   z\Credential re-resolution for resumed session provider %s failed; keeping ambient credentialsTr¢   )rr   Únew_providerri   r'   r(   z*In-place agent model swap on resume failedzcli.model.restored_from_sessionrb   z (Ú))Úfilez[dim]z[/dim]) r   rJ   r/   r   rA   r   r)   Ú!hermes_cli.local_runtime.endpointrZ  r.   r0   rE   Úrequested_providerr'   r(   Ú_explicit_api_keyr[  r5   r\  ri   Ú_credential_poolrF   rU   r$   rN   rˆ   r   ÚprintÚsysÚstderrr  rG  )r  r8   rV  rJ   rT  r;   r>   Ústored_base_urlÚstored_api_moder?   rZ  Úmanagedr\  ÚresolvedÚmsgs   &&$            r   Ú_restore_session_modelÚ*CLIModelSwitchMixin._restore_session_model  s?  € õ 	Ø×"Ð" ×'Ñ'¨×0Ò0´G¸DÐB\Ð^c×4dÒ4dÙÜ$ \ÇÁÐ^b×^kÑ^kÔlˆØŠ=ÙØ\aÑYˆ ÐIYÝFÜ�o×+Ð+¨Ó,×2Ñ2Ó4×:Ñ:Ó<Ð@PÑPˆØ!Œ
ßØ+ŒMØ&5Ô#ß§wØ /”ßØ /”ßœG DÐ*>À×EÒE×N^ð &*ˆDÔ"Ø&*ˆDÔ#ð4ÝPÙ3¸o×\fÑ\f×\nÐ\nÐjnÔo�Ø—<‘< 	×*Ò*Ø#+¨IÕ#6�D”LØ,4¯L©LÐ9JÓ,K�DÔ)Ø—<‘< 
×+Ò+Ø$,¨ZÕ$8�D”Mß&¨8¯<©<¸
×+CÒ+CØ$,¨ZÕ$8�D”Mø÷ ð &*ˆDÔ"Ø&5Ô#ð4ÝPÙ3¸o×\fÑ\f×\nÐ\nÐjnÔo�Ø—<‘< 	×*Ò*Ø#+¨IÕ#6�D”LØ,4¯L©LÐ9JÓ,K�DÔ)ß&¨8¯<©<¸
×+CÒ+CØ$,¨ZÕ$8�D”Mß&¨8¯<©<¸
×+CÒ+CØ$,¨ZÕ$8�D”Mô 	˜tÔ$ð �:‰:Ò!ðZØ—
‘
×'Ñ'Ø"Ÿj™j°t·}±}ÈdÏlÉl×N`ÐN`Ð^`Ø!Ÿ]™]×0Ð0¨b¸4¿=¹=×;NÐ;NÈBð (ô Pô
 Ð1¸ÔFˆßØ�R˜Ð(¨Ð*Õ*ˆCßÜ�#œCŸJ™J×'à×Ñ %¬°« ~°VÐ <Ö=øôY ô 4ß"Ø$3”MØ—‘ð=à#¨dð ÷ 4ð4ûô. ô 4Ø—‘ð=à#¨dð ÷ 4ð4ûô ô ZØ—‘ÐIÐTX�ÖYðZús�   ÄN Ä/N Å:N Æ	N ÆN Æ6N ÇN8 Ç6N8 È+N8 ÉN8 ÉN8 É.N8 ÊN8 Ê-=O Ë+O Ì O ÌO ÎN5ÎN5Î4N5Î8OÏOÏO?Ï>O?Nc               ó(   € V ^8„  d   QhRRRRRRRR/# )r
   rý   rS   r9   r.   r:   r   r   r   )r   s   "r   r   r  n  s.   € ÷ +ñ +¨Dð +Àð +ÐX[ð +ð  EIñ +r   c                ó¬   € V P                  4        RRRVR\        R \        V4       4       ^ 4      RVRVRVR	VR
R/V n        V P	                  RR7       R# )z/Open prompt_toolkit-native /model picker modal.Ústager)   rý   Úselectedc              3  ó\   "  € T F"  w  rVP                  R 4      '       g   K  Vx € K$  	  R# 5i)Ú
is_currentN©r/   )Ú.0ÚiÚps   &  r   Ú	<genexpr>Ú9CLIModelSwitchMixin._open_model_picker.<locals>.<genexpr>t  s!   é € ÐXÑ,@¡D AÀAÇEÁEÈ,×DWŸašaÓ,@ùs   ‚,¢
,r9   r:   r   r  Úfilterr    ç        ©Úmin_intervalN)Ú_capture_modal_input_snapshotÚnextÚ	enumerateÚ_model_picker_stateÚ_invalidate)r  rý   r9   r:   r   r  s   &&&&&&r   r  Ú&CLIModelSwitchMixin._open_model_pickern  sg   € à×*Ñ*Ô,à�ZØ˜ØœÑX¬I°iÔ,@ÓXÐZ[Ó\Ø˜]ØÐ 0Ø˜*Ø˜LØ�bð$ˆÔ ð 	×Ñ cÐÖ*r   c               ó   € V ^8„  d   QhRR/# r!  r   )r   s   "r   r   r  |  s   € ÷ ñ ¸ñ r   c                ó4  € RV n         \        VRR4      '       g   R#  ^ RIHpHp \        V RR4      pT! VP
                  VP                  VP                  ;'       g    V P                  ;'       g    RVP                  ;'       g    V P                  ;'       g    RVP                  Ve   TMV! \        V RR4      4      R	7      pVf   R# \        WP                  VP                  4      '       g   R# VP                  V n         R#   \         d    Rp LPi ; i)
zDAsk for explicit confirmation before applying costly model switches.NÚsuccessFT)Úcombined_selection_warningrœ   r¬   r    rN   )r)   r'   ri   rj   Úselection_context)Ú_confirmed_switch_warningr   r¥   rŠ  rœ   rr   rt   r'   ri   rj   rF   r¸   r®   Úmessage)r  rV   rŠ  rœ   ÚprimedÚwarnings   &&    r   Ú_confirm_expensive_model_switchÚ3CLIModelSwitchMixin._confirm_expensive_model_switch|  só   € à)-ˆÔ&Ü�v˜y¨%×0Ò0Ùð	÷Iä˜TÐ#@À$ÓGˆFÙ0Ø× Ñ ¨6×+AÑ+AØŸ™×?Ð?¨D¯M©M×?Ð?¸RØŸ™×<Ð<¨$¯,©,×<Ð<¸"È×IZÑIZØ,2Ò,>¡&ÑD_Ü˜D '¨4Ó0óE2ô	3ˆGð Š?ÙÜ! $¯©°w·±×GÒGÙØ)0¯©ˆÔ&Ùøô ô 	ØŠGð	ús)   ž?D ÁD Á2D ÂD Â+D ÄDÄDc               ó   € V ^8„  d   QhRR/# r!  r   )r   s   "r   r   r  ”  s   € ÷ 
Nñ 
N°dñ 
Nr   c                ó°   € ^ RI Hp VP                  R4      ;'       g    Rp\        V RR4      Ruq@n        V'       d	   W48X  d   R# \        W! V4      V4      # )aY  The gateway owner refused a guarded target (``confirmation_required``: cost, data policy,
large context; Ink/Desktop/ACP show the same ``confirm_message``): ask in the same prompt as
``_confirm_expensive_model_switch``. Only a yes re-sends with the owner's token. The identical
warning the user just confirmed for this switch is not asked twice.)Úconfirmation_titleÚconfirm_messager    rŒ  NT)Úhermes_cli.gateway_mutationsr”  r/   r   rŒ  r¸   )r  Úrefusalr”  r�  Ú	confirmeds   &&   r   Ú_confirm_owner_model_switchÚ/CLIModelSwitchMixin._confirm_owner_model_switch”  sX   € õ
 	DØ—+‘+Ð/Ó0×6Ð6°BˆÜ4;¸DÐB]Ð_cÓ4dÐfjÐ1ˆ	Ô1ß�wÔ+ÙÜ! $Ð(:¸7Ó(CÀWÓMÐMr   c               ó$   € V ^8„  d   QhRRRRRR/# ©r
   rÊ   r4   rÓ   r.   r   r   r   )r   s   "r   r   r     s)   € ÷ 
Gñ 
GØ&*ð
GØUXð
GØbfñ
Gr   c           	     	ó  € ^ RI Hp  VP                  '       d.   V P                  V4      '       g   V! R\	        R4       24       R# V P                  WW4R7       R#   \         d"   pT! R\	        RTR7       24        Rp?R# Rp?ii ; i)é    r]   ra   úcli.model.switch_cancelledN)rP   rÓ   zcli.model.selection_failed©Úerror)r   r^   r‰  r�  r   Ú_apply_model_switch_resultrF   )r  rV   rÊ   rP   rÓ   r^   rW   s   &&&&&  r   Ú&_confirm_and_apply_model_switch_resultÚ:CLIModelSwitchMixin._confirm_and_apply_model_switch_result   s„   € åð	GØ�~�~ˆ~ d×&JÑ&JÈ6×&RÒ&RÙ˜"œQÐ;Ó<Ð=Ð>Ô?ÙØ×+Ñ+ØÐ9Ið ,ö nøäô 	GÙ�bœÐ7¸sÔCÐDÐE×FÒFûð	Gús'   ˆA šA ±A ÁA ÁBÁ'BÂBc               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r  ¬  s   € ÷ +ñ + Tñ +r   c                	óX   € R V n         V P                  4        V P                  RR7       R # )Nr~  r  )r„  Ú_restore_modal_input_snapshotr…  )r  s   &r   Ú_close_model_pickerÚ'CLIModelSwitchMixin._close_model_picker¬  s'   € Ø#'ˆÔ Ø×*Ñ*Ô,Ø×Ñ cÐÖ*r   c               ó   € V ^8„  d   QhRR/# r	   r   )r   s   "r   r   r  ±  s   € ÷ 	.ñ 	.¨ñ 	.r   c                óÎ   € \        V RR4      p/ \        V 4      CR\        P                  ! \        V RR4      4      RVe$   \        P                  ! \        VRR4      4      /C# R/C# )zACapture current CLI and agent model runtime for one-turn restore.rN   Nr"   Úagent_primary_runtimeÚ_primary_runtime)r   r   ÚcopyÚdeepcopy)r  rN   s   & r   ré   Ú+CLIModelSwitchMixin._snapshot_model_runtime±  sx   € ä˜˜g tÓ,ˆð.Ü˜dÓ#ð.à¤§¢¬g°dÐ<NÐPTÓ.UÓ VØ#àÒ"ô &*§]¢]Ü˜Ð1°4Ó8ó&ñ.ð 	.ð
 )-ñ.ð 	.r   c               ó    € V ^8„  d   QhRRRR/# )r
   rð   zdict | Noner   r   r   )r   s   "r   r   r  ¼  s   € ÷ 3@ñ 3@¸ð 3@Èñ 3@r   c                ó"  a€ ^ RI HpHp V'       g   R# \        V 4      p\         F&  pWQ9   g   K  \        WVP                  V4      4       K(  	  \        V RR4      oSf   R# ^ RIH	p \        SV4      '       d   SP                  MV3R lpRV9   d   V! VR,          4       VP                  R4      pV'       dV   \        SR4      '       dD    \        P                  ! V4      Sn        R	Sn        ^ Sn        SP%                  4       '       d   R#  \        SR4      '       Ed    SP+                  VP                  RR4      VP                  RR4      VP                  RR4      VP                  RR4      VP                  RR4      VP                  R4      R	R	R7      p	V	RJ g   \        V	\&        4      '       dm   VP/                  4        F  w  r[\        WV4       K  	  V	RJ d   \1        R4      M(\1        RVP                  RR4      V	SP2                  R7      pV! RV 24       R# RV9   d   V! VR,          4       R# R# R#   \&         d    TP)                  R
R	R7        ELQi ; i  \&         d   p
TP-                  RT
4       T
p	 Rp
?
LíRp
?
ii ; i)z<Restore a model runtime captured before a one-turn override.)r^   rJ   NrN   rÎ   c                ó   <€ \        SR V 4      # )r"   )Úsetattr)rx   rN   s   &€r   r/  ÚECLIModelSwitchMixin._restore_model_runtime_snapshot.<locals>.<lambda>Ì  s   ø€ ´¸Ð@RÐTZÔ1[r   r"   r¬  Ú_restore_primary_runtimeTz5CLI one-turn model restore via primary runtime failedr¢   rˆ   r   r    r)   ri   r'   r(   rn   )rr   r`  ri   r'   r(   rn   r±   Úrestorez%CLI one-turn model restore failed: %sFrŸ  úcli.model.switch_failed©r   r¡  r}   ra   )r   r^   rJ   r   r   r´  r/   r   rÔ   rÏ   rw   Úrestore_reasoningr¦   r®  r¯  r­  Ú_fallback_activatedÚ_rate_limited_untilr¶  rF   rU   rˆ   r�  rê   r   r   )r  rð   r^   rJ   rZ   r   rÏ   rº  ÚprimaryÚrestoredrW   rñ   r  rN   s   &&           @r   Ú_restore_model_runtime_snapshotÚ3CLIModelSwitchMixin._restore_model_runtime_snapshot¼  sO  ø€ ç'ßÙÜ" 4Ó(ˆß"ˆCØŽÜ˜ 8§<¡<°Ó#4Ö5ñ #ô ˜˜g tÓ,ˆØŠ=ÙÝ9ä8BÀ5È,×8WÒ8W˜U×4Ò4Ü"[ð 	à Ô)Ù˜hÐ'9Õ:Ô;Ø—,‘,Ð6Ó7ˆß”w˜uÐ&@×AÒAðeÜ)-¯ª°wÓ)?�Ô&Ø,0�Ô)Ø,-�Ô)Ø×1Ñ1×3Ò3Ùð 4ô �5˜.×)Ó)ð
ð !×-Ñ-Ø&Ÿl™l¨7°BÓ7ÀhÇlÁlÐS]Ð_aÓFbØ$ŸL™L¨°BÓ7À(Ç,Á,ÈzÐ[]ÓB^Ø%Ÿ\™\¨*°bÓ9Ø!)§¡¨nÓ!=ÀDÐRVð	 .ó X�ð ˜5Ó ¤J¨x¼×$CÒ$Cð #+§.¡.Ö"2‘J�CÜ˜D uÖ-ñ #3à<DÈÓ<MœÐ7Ô8ÔSTØ-°X·\±\À'È2Ó5NÐV^Ðjo×juÑjuôTw�á˜"˜V˜H˜Ô&ÙØ! XÔ-Ù! (Ð+=Õ">Ö?ñ .ñ+ *øô ô eØ—‘ÐTÐ_c�×dðeûô ô Ø—‘ÐFÈÔLØ•ûðús+   Ã>I  Ä$A8I% É I"É!I"É%JÉ0J	Ê	Jc               ó$   € V ^8„  d   QhRRRRRR/# )r
   ÚentriesrS   Úqueryr.   r   r   )r   s   "r   r   r  ò  s&   € ÷ Jñ J¨dð J¸3ð JÀ4ñ Jr   c           
     ó$  € \        \        V 4      4      pT;'       g    RP                  4       P                  4       pV'       g   V# R R lpV UUu. uF0  w  rVV! V\	        V4      P                  4       4      '       g   K-  WV3NK2  	  upp# u uppi )uó   Return (original_index, label) pairs matching ``query`` (case-insensitive subsequence;
empty matches all). The ORIGINAL index keeps a filtered selection resolving to exactly one
concrete model â€” filtering never introduces fuzzy *resolution*.r    c               ó$   € V ^8„  d   QhRRRRRR/# )r
   Úneedler.   Úhayr   r4   r   )r   s   "r   r   ÚFCLIModelSwitchMixin._filter_model_picker_entries.<locals>.__annotate__û  s!   € ÷ 	2ñ 	2˜Cð 	2 cð 	2¨dñ 	2r   c                óŽ   a€ \        V4      o\        ;QJ d    V3R  lV  4       F  '       d   K   R# 	  R# ! V3R  lV  4       4      # )c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5ir   r   )rx  ÚchÚits   & €r   r{  ÚTCLIModelSwitchMixin._filter_model_picker_entries.<locals>._subseq.<locals>.<genexpr>ý  s   øé € Ð1©& B˜R–x«&ùs   ƒFT)ÚiterÚall)rÆ  rÇ  rÌ  s   &&@r   Ú_subseqÚACLIModelSwitchMixin._filter_model_picker_entries.<locals>._subseqû  s5   ø€ Ü�c“ˆBß“3Ô1©&Ó1—3”3Ð1’3Ð1�3Ô1©&Ó1Ó1Ð1r   )rS   rƒ  r0   rE   r.   )rÂ  rÃ  ÚpairsÚqrÐ  ry  Úes   &&     r   Ú_filter_model_picker_entriesÚ0CLIModelSwitchMixin._filter_model_picker_entriesñ  sp   € ô
 ”Y˜wÓ'Ó(ˆØ�[ˆ[�b×ÑÓ!×'Ñ'Ó)ˆßØˆLõ	2ñ &+ÔI¡U™6˜A©g°a¼¸Q»¿¹»×.H”�“¡UÒIÐIùÓIs   Á*BÂBc               ó8   € V ^8„  d   QhRRRRRRRRRRRRRRR	R
/# )r
   rt  ÚintÚscroll_offsetÚnÚ	term_rowsÚreserved_belowÚpanel_chromeÚmin_visibler   ztuple[int, int]r   )r   s   "r   r   r    sV   € ÷ @ñ @Øð@Ø&)ð@Ø.1ð@Ø>Að@ØSVð@àð@à,/ð@à8Gñ@r   c                óÒ   € \        WcV,
          V,
          4      pW'8:  d   ^ V3# TpW8  d   T pMWV,           8¼  d   W,
          ^,           p\        ^ \        WV,
          4      4      V3# )zûResolve (scroll_offset, visible) for the /model picker viewport. ``reserved_below``
matches the approval/clarify panels (input, status bar, separators); ``panel_chrome`` is
borders + blanks + hint row. The offset slides to keep ``selected`` on screen.)ÚmaxÚmin)	rt  rÙ  rÚ  rÛ  rÜ  rÝ  rÞ  Úmax_visibleÚvisibles	   &&&&&&&  r   Ú_compute_model_picker_viewportÚ2CLIModelSwitchMixin._compute_model_picker_viewport  sj   € ô ˜+°>Õ'AÀLÕ'PÓQˆØÔØ�a�4ˆKØˆØÔ#Ø$‰MØ¨Õ0Ô0Ø$Õ.°Õ2ˆMÜ�1”c˜-¨W­Ó5Ó6¸Ð?Ð?r   c               ó   € V ^8„  d   QhRR/# r!  r   )r   s   "r   r   r    s   € ÷ 8ñ 8¸$ñ 8r   c                ó(  € ^ RI Hp V P                  f3   \        V RR4      '       d    V P	                  4       '       g
   RV n        R# \        V 4      pVP                  V n        VP                  V n
        VP                  V n        VP                  V n        VP                  V n        VP                  '       d   VP                  V n        VP                  '       d   VP                  V n        VP                   '       d   VP                   V n        \#        V 4       V P                  eø    \%        VP                  VP                  VP                  VP                  VP                   \        VRR4      R7      p\        V RR4      '       d)   TP'                  R\        VR	R
4      ;'       g    R
R7       V P                  P(                  ! R/ VB RJ dD   VP+                  4        F  w  rg\-        WV4       K  	  V! R\/        R4       24        RV n        R#  RT n        R# R#   \0         dY   pTP+                  4        F  w  rg\-        YT4       K  	  T! R\/        RTP                  Y‚R7       24        Rp?RT n        R# Rp?ii ; i  RT n        i ; i)uI  Stage ``result`` onto the CLI fields, then swap the live agent in place.

CLI fields are snapshotted first so a failed agent swap rolls the whole CLI back â€”
otherwise the staged broken credentials leak into the next turn even though the agent
rolled back. Returns False after printing the failure (a failed switch is a no-op).
r]   NÚ_gateway_session_openFÚruntime_capabilities)rr   r`  ri   r'   r(   rn   rë   Trç   r    )r±   Úaliasra   rŸ  r¸  r¹  r   )r   r^   rN   r   Ú_init_agentrŒ  r   rr   r   rt   r)   rd  ri   re  r'   r[  r(   r$   r   Úupdaterˆ   rê   r´  r   rF   )	r  rV   r}   r^   Ú_cli_snapshotÚfieldsÚ_kÚ_vrW   s	   &&&      r   rì   Ú)CLIModelSwitchMixin._stage_and_swap_model  s%  € õ 	 Ø�:‰:Ò¤'¨$Ð0GÈ×"OÒ"OÐX\×XhÑXh×XjÒXjð .2ˆDÔ*ÙÜ'¨Ó-ˆØ×%Ñ%ˆŒ
Ø×.Ñ.ˆŒØ"(×"8Ñ"8ˆÔð "(§¡ˆÔØ"(§/¡/ˆÔØ�>�>ˆ>Ø!Ÿ>™>ˆDŒLØ�?�?ˆ?Ø"ŸO™OˆDŒMØ�?�?ˆ?Ø"ŸO™OˆDŒMÜ˜tÔ$à�:‰:Ò!ð6ÜØ$×.Ñ.¸V×=SÑ=SØ"ŸN™N°V·_±_ÈvÏÉÜ!(¨Ð1GÈÓ!NôP�ô ˜4Ð!9¸5×AÒAà—M‘M t´7¸6ÐCWÐY[Ó3\×3bÐ3bÐ`b�MÔcØ—:‘:×*Ò*Ñ4¨VÑ4¸Ó=à"/×"5Ñ"5Ö"7™˜Ü ¨"Ö-ñ #8á˜b¤Ð#?Ó!@Ð AÐBÔCØ ð 26�Ö.ð# >ð" 26�Ô.Ûøô ô 	ð ,×1Ñ1Ö3‘F�BÜ˜D bÖ)ñ 4á˜"œQÐ8À×@PÑ@PÐX[ÔqÐrÐsÔtÛà15�Ö.ûð	ûð 26�Õ.ús3   Ä*B H" Æ+A!H" È"JÈ-AJ É3J Ê JÊJ Ê	Jc               ó$   € V ^8„  d   QhRRRRRR/# rœ  r   )r   s   "r   r   r  L  s)   € ÷ 	@ñ 	@Ø&*ð	@ØUXð	@Øbfñ	@r   c                óš   € ^ RI Hp VP                  '       g   V! RVP                   24       R# \	        WV4       \        WVRVR7       R# )z.Picker-path commit (see _commit_model_switch).r]   õ     âœ— NT)rÊ   rÜ   rÓ   )r   r^   r‰  Úerror_messagerX   ró   )r  rV   rÊ   rP   rÓ   r^   s   &&&&& r   r¢  Ú.CLIModelSwitchMixin._apply_model_switch_resultL  sG   € õ 	 Ø�~�~ˆ~Ù�f˜V×1Ñ1Ð2Ð3Ô4ÙÜ  Ð/?Ô@Ü˜T¸.ÐQUØ.>÷	@r   c               ó    € V ^8„  d   QhRRRR/# )r
   rÊ   r4   r   r   r   )r   s   "r   r   r  W  s"   € ÷ Kcñ Kc¸Tð KcÈdñ Kcr   c                	óV  a€ V P                   pV'       g   R # VP                  R^ 4      pVP                  R4      pVR8X  dÙ   VP                  R4      ;'       g    . pV\        V4      8¼  d   V P                  4        R # WS,          oSP                  R. 4      pV'       g!    ^ RIHp V! SR,          4      ;'       g    Tp^ RIHp V! VSP                  R4      SP                  R	4      4      pVP                  R
SV^ RR R7       V P                  RR7       R # VR
8X  EdÍ   VP                  R4      ;'       g    / oVP                  R4      ;'       g    . pVP                  R4      p	V	f   \        \        V4      4      p	V	 U
Uu. uF  w  r«VNK	  	  pp
p\        V4      pW=8X  d`   TP                  RRR \        V3R l\        VP                  R4      ;'       g    . 4       4       ^ 4      R7       V P                  RR7       R # W=8”  d   V P                  4        R # ^ Tu;8:  d   V8  d²   M M®\        WV,          VSP                  R4      VP                  R4      VP                  R4      R7      pVP                  '       dF   \!        SVP"                  4      '       d*   VP                  RV^ ^ R7       V P                  RR7       R # V P%                  Wá4       R # V P                  4        VR8X  d�   \'        4       pVP                  R4      pV\        V4      8X  d*   VP                  R
^ ^ R R7       V P                  RR7       R # V\        V4      8”  g   Vf   V P                  4        R # V P%                  WáWó,          ^ ,          R7       R # R #   \         d     ELài ; iu upp
i )Nrt  rs  r)   rý   Úmodels)Úcached_provider_model_idsrJ  )Úoffered_model_idsÚapi_urlr   r    )rs  rÂ   Ú
model_listrt  r}  Ú_filtered_pairsr~  r  rÂ   rý  rþ  c              3  óz   <"  € T F0  w  rVP                  R 4      SP                  R 4      8X  g   K,  Vx € K2  	  R# 5i)rJ  Nrw  )rx  ry  rz  rÂ   s   &  €r   r{  ÚECLIModelSwitchMixin._handle_model_picker_selection.<locals>.<genexpr>‚  s8   øé € ð #RÑ1X©¨Ø&'§e¡e¨F£m°}×7HÑ7HÈÓ7PÑ&P÷ $%¢1Ó1Xùs   ƒ);±
;)rs  r}  rþ  rt  r   r  ©rŒ   r�   rŽ   rP   rÄ   )rs  Úswitch_resultrt  Ú_scroll_offsetr  )rs  rt  r  r  )rÓ   )r„  r/   Úlenr¨  r7   rú  rF   Úhermes_cli.models_validaterû  rì  r…  rS   rƒ  r‚  r�   r‰  rÇ   rr   Ú_commit_picker_resultrÀ   )r  rÊ   Ústatert  rs  rý   rý  rú  rû  Úfiltered_pairsÚ_irÔ  Úvisible_labelsÚback_idxrV   r¿   rÂ   s   &&              @r   Ú_handle_model_picker_selectionÚ2CLIModelSwitchMixin._handle_model_picker_selectionW  s\  ø€ Ø×(Ñ(ˆßÙØ—9‘9˜Z¨Ó+ˆØ—	‘	˜'Ó"ˆØ�JÔØŸ	™	 +Ó.×4Ð4°"ˆIØœ3˜y›>Ô)Ø×(Ñ(Ô*ÙØ%Õ/ˆMð
 '×*Ñ*¨8°RÓ8ˆJßðÝKÙ!:¸=ÈÕ;PÓ!Q×!_Ð!_ÐU_�Jõ EÙ*Ø˜M×-Ñ-¨fÓ5°}×7HÑ7HÈÓ7SóUˆJà�L‰LØ¨]ÀzØ 2°tð ô =ð ×Ñ¨#ÐÔ.ÙØ�GÕØ!ŸI™I oÓ6×<Ð<¸"ˆMØŸ™ <Ó0×6Ð6°BˆJà"ŸY™YÐ'8Ó9ˆNØÒ%Ü!%¤i°
Ó&;Ó!<�Ù/=Ô>©~¡G R›a©~ˆNÑ>Ü˜>Ó*ˆHØÔ#Ø—‘Ø$¨RÀÜ!ô #R´¸5¿9¹9À[Ó;Q×;WÐ;WÐUWÔ1Xó #RØSTóVð ô Wð × Ñ ¨cÐ Ô2ÙØÔ"Ø×(Ñ(Ô*ÙØ�HÖ'˜x×'Ü+Ø¨Õ2¸nØ&3×&7Ñ&7¸Ó&?Ø#(§9¡9¨\Ó#:Ø%*§Y¡Y¨~Ó%>ô	@�ð
 —>—>�>Ô&>¸}Èf×N^ÑN^×&_Ò&_ð —L‘L {À&ÐSTÐef�LÔgØ×$Ñ$°#Ð$Ô6ÙØ×*Ñ*¨6ÔBÙØ×$Ñ$Ô&Ø�KÔÜ)Ó+ˆDØ—Y‘Y˜Ó/ˆFØœ3˜t›9Ô$Ø—‘ 7°QÀqÐX\�Ô]Ø× Ñ ¨cÐ Ô2ÙØœ#˜d›)Ô# v¢~Ø×(Ñ(Ô*ÙØ×&Ñ& vÐPTÕP^Ð_`ÕPaÐ&Öbñ  øôY !ô Úðüó" ?s   Â"N Â>N ÆN%ÎN"Î!N"c               ó$   € V ^8„  d   QhRRRRRR/# rœ  r   )r   s   "r   r   r  ¤  s(   € ÷ 
Bñ 
B¸Dð 
BÐTWð 
BÐaeñ 
Br   c                óÀ   € V P                   ;'       g    / pVP                  R4      pV P                  4        V'       d   V3MRp\        W P                  WV.VO5!   R# )zCClose the picker and run the confirm+apply sequence for ``result``.r  Nr   )r„  r/   r¨  r™   r£  )r  rV   rÊ   rÓ   r  Ú_picker_custom_provsÚextras   &&&&   r   r  Ú)CLIModelSwitchMixin._commit_picker_result¤  s^   € à×(Ñ(×.Ð.¨Bˆà$Ÿy™y¨Ó8ÐØ× Ñ Ô"ç'7Ð!Ñ#¸RˆÜØ×=Ñ=ØÐ$8ð	Bà;@ö	Br   c               ó   € V ^8„  d   QhRR/# ©r
   Úcmd_originalr.   r   )r   s   "r   r   r  °  s   € ÷ @Dñ @D°ñ @Dr   c           	     óÄ  € ^ RI Hp ^ RIHpHp VP                  R^4      pT! \        V4      ^8”  d   V^,          P                  4       MR4      pVP                  '       d#   V! RVP                  4       ^ ,           24       R# VP                  pV! VP                  VP                  VVP                  R7      pVP                  '       d#    ^ RIHp	 V	! 4        V! R\#        R	4       24       ^ R
IHp
  V
! 4       P+                  V P,                  ;'       g    RV P.                  ;'       g    RV P0                  ;'       g    RR7      pVe   VP2                  MRpVe   VP4                  MRpVP6                  '       g)   VP                  '       g   \9        WVP                  4      # \;        WP6                  VVP                  WÍR7      pVP<                  '       g   V! RVP>                   24       R# \A        WV4       VPB                  '       d   VPB                  3MRp\E        W PF                  WèW}.VO5!   R#   \$         d     EL\i ; i  \$         d    Rp ELi ; i)uð  Handle /model command â€” switch model.

Supports:
  /model                              â€” show current model + usage hints
  /model <name>                       â€” switch model (this session only)
  /model <name> --once                â€” switch for the next turn only
  /model <name> --session             â€” switch for this session only (explicit)
  /model <name> --global              â€” switch and persist to config.yaml
  /model <name> --provider <provider> â€” switch provider + model
  /model <name> --reasoning <level>   â€” switch and set reasoning effort in one step
  /model --provider <provider>        â€” switch to provider, auto-detect model

Switches are session-scoped unless ``model.persist_switch_by_default`` or ``--global``.
r]   )Úparse_model_switch_argsÚresolve_persist_behaviorNr    rô  )Úis_oncer�   )Úclear_provider_models_cachera   zcli.model.cleared_picker_cache)Úload_picker_context)r:   r9   rŠ   r  r   )$r   r^   r6   r  r  rF  r  r0   ÚerrorsÚerror_messagesr  rŒ   Ú
is_sessionr�   rõ   r7   r  r   rF   r  r  Úwith_overridesr)   r   r'   rŽ   rP   r“   r  r�   r‰  rõ  rX   rÓ   r™   Ú#_confirm_and_apply_cli_model_switch)r  r  r^   r  r  ÚpartsÚrequestrZ   rÊ   r  r  r„   r   r  rV   r  s   &&              r   Ú_handle_model_switchÚ(CLIModelSwitchMixin._handle_model_switch°  s  € õ 	 ß]à×"Ñ" 4¨Ó+ˆÙ)¼cÀ%»jÈ1¼n¨%°­(¯.©.Ô*:ÐRTÓUˆØ�>�>ˆ>á�f˜W×3Ñ3Ó5°aÕ8Ð9Ð:Ô;ÙØ—?‘?ˆÙ1Ø×Ñ˜w×1Ñ1¸8Ø%×7Ñ7ô9ˆð
 × × Ð ðÝIÙ+Ô-Ù˜"œQÐ?Ó@ÐAÐBÔCõ
 	=ð	Ù%Ó'×6Ñ6Ø!%§¡×!4Ð!4°"ÀDÇJÁJ×DTÐDTÐRTØ!%§¡×!4Ð!4°"ð 7ó 6ˆCð ,/ª?�S×'Ò'Àˆ
Ø/2ª�s×+Ò+ÀDˆà�~�~ˆ~ g×&?×&?Ð&?Ü% d°×1FÑ1FÓGÐGä#Ø—.‘.¨NØ%×7Ñ7Ø%ôFˆð �~�~ˆ~Ù�f˜V×1Ñ1Ð2Ð3Ô4ÙÜ  ¨|Ô<Ø/6×/G×/GÐ/G�×)Ñ)Ñ+ÈRˆÜØ×:Ñ:Ø Hð	Dà=Bö	Døô7 ô Úðûô ô 	Ø‹Cð	ús6   Ã!H< Ã5"I ÄI Ä-I ÅI È<IÉ
IÉIÉIc               ó(   € V ^8„  d   QhRRRRRRRR/# )r
   rÊ   r4   rZ   rÓ   r.   r   r   r   )r   s   "r   r   r  ò  s,   € ÷ 4ñ 4Ø&*ð4Ø6:ð4Øadð4Ønrñ4r   c                óô   € ^ RI Hp V'       d   \        V 4      MRV n         V P                  V4      '       g   V! R\	        R4       24        RV n        R# \        WW#VR7       RV n        R#   RT n        i ; i)z¨Confirm an expensive model switch and apply it (typed /model path). Runs on a worker
thread when the TUI is active (see _run_confirm_and_apply) so the modal can render.r]   Nra   rŸ  )rÊ   rZ   rÓ   )r   r^   r¬   r�  r   ró   )r  rV   rÊ   rZ   r  rÓ   r^   s   &&&&&& r   r   Ú7CLIModelSwitchMixin._confirm_and_apply_cli_model_switchò  s|   € õ 	 ÷ QYÔ+FÀtÔ+LÐ^bˆÔ(ð	4Ø×7Ñ7¸×?Ò?Ù˜"œQÐ;Ó<Ð=Ð>Ô?Øð 04ˆDÖ,ô ! ¸nØ2BõDð 04ˆDÖ,ø¨tˆDÕ,ús   ¢A. ¹A. ÁA. Á.	A7c               ó    € V ^8„  d   QhRRRR/# )r
   r  r.   r   r   r   )r   s   "r   r   r    s   € ÷ Cñ C°#ð C¸$ñ Cr   c                óÔ  € ^ RI Hp ^ RIHp VP	                  R^4      pTP                  \        V4      ^8”  d   V^,          P                  4       MR4      w  rVV'       d   V F  pV! RV 24       K  	  R#  ^ RIH	pH
p	 TP                  T! 4       TTe   T	MRR	7      pTP                  '       d   R
MRpTP                  P!                  4        F-  pT! TP#                  R4      '       d	   RT RT 2MRT 24       K/  	  TP                  '       d+   TP$                  '       d   T! R\        R4       24       R# R# R#   \         d   p
T! \        RT
R7      4        Rp
?
R# Rp
?
ii ; i)um  Handle /codex-runtime â€” toggle the codex app-server runtime opt-in.

Usage:
    /codex-runtime                       â€” show current state
    /codex-runtime auto                  â€” Hermes default (chat_completions)
    /codex-runtime codex_app_server      â€” hand turns to codex subprocess
    /codex-runtime on / off              â€” synonyms for the above
r]   )Úcodex_runtime_switchNr    u   â�Œ )Úload_configÚsave_configzcli.model.could_not_load_configr   )Úpersist_callbacku   âœ“u   âœ—Úopenai_runtimera   rþ   rc   zcli.model.tip_reset_new_session)r   r^   Ú
hermes_clir*  rF  Ú
parse_argsr  r0   Úhermes_cli.configr+  r,  rF   r   Úapplyr‰  r�  Ú
splitlinesÚ
startswithÚrequires_new_session)r  r  r^   Úcrsr!  Ú	new_valuer  Úerrr+  r,  rW   rV   ÚprefixÚlines   &&            r   Ú_handle_codex_runtimeÚ)CLIModelSwitchMixin._handle_codex_runtime  s@  € õ 	 Ý:à×"Ñ" 4¨Ó+ˆØŸN™N¼sÀ5»zÈA¼~¨5°­8¯>©>Ô+;ÐSUÓVÑˆ	ßÛ�Ù˜$˜s˜e˜Ö%ñ áð	ßBð —‘Ù‹M˜9Ø-6Ò-B™kÈð ó Oˆð !Ÿ.Ÿ.˜.‘¨eˆØ—N‘N×-Ñ-Ö/ˆDÙ¨D¯O©OÐ<L×,MÒ,M�b˜˜  $ Ñ(ÐUYÐZ^ÐY_ÐS`Öañ 0à�>�>ˆ>˜f×9×9Ð9Ù�dœ1Ð>Ó?Ð@ÐAÖBñ :‰>øô ô 	Ù”AÐ7¸sÔCÔDÝûð	ús   Á8D> Ä>E'Å	E"Å"E'c               ó$   € V ^8„  d   QhRRRRRR/# )r
   Útextr.   Ú
has_imagesr4   r   r   )r   s   "r   r   r  #  s"   € ÷ 
ñ 
¸ð 
Èð 
ÐZ^ñ 
r   c                ó<  € ^ RI Hp V'       d   V'       g   V! V4      '       g   R#  ^ RIHp V! VP	                  R^4      ^ ,          P                  4       P                  R4      4      p\        T;'       d    VP                  R8H  4      #   \         d     R# i ; i)zGReturn True when /model should be handled immediately on the UI thread.)Ú_looks_like_slash_commandF)Úresolve_commandNrA  r   )
r   rA  Úhermes_cli.commandsrB  rF  rE   Úlstripr4   ÚnamerF   )r  r>  r?  rA  rB  Úcmds   &&&   r   Ú#_should_handle_model_command_inlineÚ7CLIModelSwitchMixin._should_handle_model_command_inline#  s|   € å1ß—zÑ)BÀ4×)HÒ)HÙð	Ý;Ù! $§*¡*¨T°1Ó"5°aÕ"8×">Ñ">Ó"@×"GÑ"GÈÓ"LÓMˆCÜ˜×3Ð3 §¡¨GÑ 3Ó4Ð4øÜô 	Úð	ús   ¨AB Á8B ÂBÂBc               ó   € V ^8„  d   QhRR/# r  r   )r   s   "r   r   r  /  s   € ÷ Jñ J Sñ Jr   c           	     óþ  € ^ RI HpHp ^ RIHpHp V! V4      pV'       g   V! RV! 4        24       R# \        V P                  \        4      '       d   V P                  P                  R4      M/ pV! V4      R,          pR U	u/ uF  p	V	\        W	R4      bK  	  up	V n        RV n        RV n        W€n        RV n        R	V n        R
V n        \%        V 4       RV n        W`n        V! R\+        RVR7       24       R# u up	i )z¦/moa one-shot: run one prompt through the default MoA preset, then restore the prior
model (a session-long MoA switch goes through the picker's virtual MoA provider).)r^   Ú_slash_args)Ú	moa_usagere   ra   Trd   Údefault_presetNzmoa-virtual-providerzmoa://localÚchat_completionszcli.model.moa_one_shot_queued)Úpreset)rd  r)   r   ri   r'   r(   )r   r^   rK  rv   rL  re   rw   rx   r   r/   r   Ú_pending_moa_restore_modelrd  r)   r   ri   r'   r(   r   Ú_pending_moa_disable_after_turnÚ_pending_agent_seedr   )
r  r  r^   rK  rL  re   Úpayloadr€   rO  r   s
   &&        r   Ú_cmd_moaÚCLIModelSwitchMixin._cmd_moa/  sõ   € ÷ 	-ßIá˜lÓ+ˆßÙ�b™›˜Ð&Ô'ÙÜ,6°t·{±{ÄD×,IÒ,I�$—+‘+—/‘/ %Ô(ÈrˆÙ% gÓ.Ð/?Õ@ˆñ^ó+_ñ^�ð ”˜ DÓ)Ò)ñ^ñ+_ˆÔ'ð #(ˆÔØˆŒØŒ
Ø-ˆŒØ%ˆŒØ*ˆŒÜ�dÔØ/3ˆÔ,Ø#*Ô Ù�"”QÐ6¸vÔFÐGÐHÖIùò+_s   ÂC:)rŒ  rf  re  r[  r„  r¬   rR  rQ  rP  ri   r(   r'   r   r)   rd  )NN)Nr    )é   rV  é   )F)r    )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rM  rî   ro  r  r�  r™  r£  r¨  ré   r¿  ÚstaticmethodrÕ  rä  rì   r¢  r  r  r#  r   r;  rG  rT  Ú__static_attributes__r   r   r   r  r  ˜  s´   † ÙõUõn#XðJU>È%÷ U>÷n+õõ0
N÷
Gõ+õ
	.õ3@ðj ôJó ðJð ö@ó ð@õ 8÷t	@÷Kc÷Z
Bõ@D÷D4õ"C÷@
÷Jñ Jr   r  )	r   r)   rd  re  r[  ri   r'   r(   r"   ))z/model <name>zcli.model.usage_switch)z/model <name> --globalzcli.model.usage_switch_global)z/model <name> --oncezcli.model.usage_switch_once)z/model <name> --sessionzcli.model.usage_switch_session)z/model <name> --provider <slug>z%cli.model.usage_switch_provider_model)z!/model <name> --reasoning <level>z cli.model.usage_switch_reasoning)z/model --provider <slug>zcli.model.usage_switch_provider)z/model --refreshzcli.model.usage_refresh)&r\  Ú
__future__r   r®  Úloggingrh  r–   Úrich.markupr   rG  Ú
agent.i18nr   Úutilsr   Ú hermes_cli.cli_agent_setup_mixinr   Ú	getLoggerrX  rJ   r   r   r$   rA   r3   rX   r†   r�   r™   r¬   r¸   r  r  rÀ   rÇ   rÛ   ró   r  r  r   r   r   Ú<module>rf     sÙ   ðñõ #ã Û Û 
Û å )Ý Ý 'Ý :à	×	Ò	˜8Ó	$€ð;€õ
Eõ$ò&HòRõ Mõ(:2òz+õ
òfõ:Gð5Ð ð Ð õõMð"vÐ^c÷ "vðJ2@Ø;@ð2@ØQVð2@à÷2@õjH÷Dp
Jó p
Jr   