+
    jHàjâ  ã                   óV   € R t ^ RIt^ RIHt ]! RR04      tR tR tR tR t	R	 t
R
 tR# )a“  A viewer's model and reasoning picks on a messaging chat (Telegram, Discord, ...), #141152.

Desktop and the TUI send ``session.mutate`` ``model`` / ``reasoning`` for whatever session they show.
A LOCAL session commits the pick into its frozen policy; a messaging chat has no frozen policy, so
that path refused it with ``runtime_coordination_required`` and the reasoning pill waited forever for
a level. The chat's own ``/model`` and ``/reasoning`` set a per-chat override that its next turn
resolves (``_record_model_switch``, ``_apply_reasoning_selection``). A viewer's pick sets that same
override, so the chat and every viewer see one setting.

The mutation names the session a viewer resumed, which for a compressed chat is its lineage root
(``messaging_owner_ref``): the fences are checked on that row and the override is keyed by the lane's
route, so it applies to the compression tip the next turn writes.
N)ÚRuntimeStoreErrorÚmodelÚ	reasoningc                 óŽ   € ^ RI Hp V\        9   ;'       d0    V RJ;'       d$    V P                  P                  VP
                  8g  # )é    )ÚPlatformN)Úgateway.configr   Ú
CHAT_PICKSÚsourceÚplatformÚLOCAL)ÚliveÚ	operationr   s   && ÚD/home/ubuntu/.hermes/hermes-agent/gateway/session_messaging_picks.pyÚis_chat_pickr      s;   € Ý'Øœ
Ñ"×bÐb t°4Ð'7×bÐb¸D¿K¹K×<PÑ<PÐT\×TbÑTbÑ<bÐbó    c                 óF   € ^ RI Hp V! V P                  P                  4      # )r   )Ú_platform_config_key)Úgateway.runr   r
   r   )r   r   s   & r   Ú_platform_keyr      s   € Ý0Ù §¡× 4Ñ 4Ó5Ð5r   c                ób   € T P                  VP                  \        V4      Vf   R4      # T4      # )zQ``/reasoning <level>`` (``None``: ``/reasoning reset``) as the chat would run it.Úreset)Ú_apply_reasoning_selectionÚrouter   )Úrunnerr   Úefforts   &&&r   Ú_apply_reasoningr      s/   € à×,Ñ,¨T¯Z©Z¼ÀtÓ9LÐY_ÒYgÈgÓtÐtÐmsÓtÐtr   c              ƒ  ó   "  € ^ RI HpHp ^ RIHp ^ RIHp V P                  p	V! VP                  VP                  V! 4       R,          RR7      p
V
P                  4        V	P                  VP                  4       T
P                  V	P                  VP                  4      ;'       g    / 4       V	P                  W£R,          VP                  RR	4      VP                  4      G R
j  x€L
 w  r¼Ve   \!        RVR7      hRVP"                  RVR,          /pV! V
P$                  V
P&                  V
P(                  V
P*                  4      pV! WW=Wë4      G R
j  x€L
 pVe   V# V	P-                  WºVP                  RRR7      G R
j  x€L
  RVP.                  RVP0                  /pRV9   d    \3        W’VR,          4       VR,          VR&   V#  Lâ Lu LJ5i)z»The chat's ``/model <name> [--provider p]`` resolution, guarded like a LOCAL pick, then committed
as its session override. Returns the receipt fields, or the guard's confirmation request.)Ú_RouteÚ_selection_guard_refusal)Ú_ModelSwitchContext)Úget_hermes_homezconfig.yamlF)Úsession_keyr
   Úconfig_pathÚpersist_globalr   ÚproviderÚ NÚmodel_resolution_failed)ÚdetailÚtargetÚtarget_revisionÚruntime_revisionT)r
   Úone_turnÚpickerr   r   )Úgateway.session_mutation_modelr   r   Úgateway.slash_commands_modelr    Úhermes_constantsr!   r   r   r
   Úread_configÚ!_rehydrate_session_model_overrideÚapply_overrideÚ_session_model_overrideÚ_perform_model_switchÚgetr   Ú
session_idÚcurrent_providerÚcurrent_modelÚcurrent_base_urlÚcurrent_api_keyÚ_record_model_switchÚ	new_modelÚtarget_providerr   )Ú	authorityÚownerr   ÚpayloadÚrowr   r   r    r!   r   ÚctxÚresultÚerrorÚsnapshotÚcurrentÚrefusalÚfieldss   &&&&&            r   Ú_pick_modelrJ   $   s§  é € ÷ PÝ@Ý0Ø×Ñ€FÙ
¨$¯*©*¸T¿[¹[Ù*9Ó*;¸mÕ*KÐ\aôc€Cà‡O�OÔð ×,Ñ,¨T¯Z©ZÔ8Ø×Ñ�v×5Ñ5°d·j±jÓA×GÐGÀRÔHØ ×6Ñ6°sÀGÕ<LÈgÏkÉkÐZdÐfhÓNiÐko×kvÑkvÓw×w�M€FØÒÜÐ 9À%ÔHÐHØ˜%×*Ñ*Ð,=¸sÐCUÕ?VÐW€HÙ�S×)Ñ)¨3×+<Ñ+<¸c×>RÑ>RÐTW×TgÑTgÓh€GÙ,¨Y¸gÐQXÓa×a€GØÒØˆð ×
%Ñ
% f¸$¿+¹+ÐPUÐ^bÐ
%Ó
c×cÐcØ�v×'Ñ'¨°V×5KÑ5KÐL€FØ�gÔÜ˜ w¨{Õ';Ô<Ø" ;Õ/ˆˆxÑØ€Mñ xñ
 bñ
 dùs8   ‚C#GÃ%GÃ&A.GÅG
Å,GÆGÆAGÇ
GÇGc          	   ƒ  ó"  "  € ^ RI HpHpHp ^ RIHp	 VR,          VR,          rºV	! W«4       V! WRP                  V4      w  rÍ\        V P                  WÍVP                  VR7      p\        P                  ! W€P                  3/ VB G Rj  x€L
 pRV9   d
   VR,          # VR,          pV P                  pV
R	8X  d8   \        P                  ! \        VW;R
,          4      G Rj  x€L
  R
VR
,          /pMFVP                  4       ;_uu_4       GRj  x€L
  \        WW;V4      G Rj  x€L
 pRRR4      GRj  x€L
  XP!                  R4      R8X  d   RVP                  RV
/VC# RVP                  RV
RVR,          RVR,          /VCp\        P                  ! WpP                  3/ VBRV/B G Rj  x€L
 p^ RIHp VP&                  P)                  VP                  V! W4      RR7       V#  EL] EL	 LÞ LË L½  + GRj  x€L 
 '       g   i     LÔ; i Lb5i)a+  Apply a ``model`` / ``reasoning`` mutation to the messaging chat *live* mounted on *owner* (the
caller authorized control and holds its mutation lock). The fences are the mount's, the ones
``session.resume`` handed the viewer; comparing them with a compression segment's row refused a
pick on a compressed chat with ``stale_generation``. The receipt is keyed on that mount too: an
exact retry answers its stored receipt without re-applying the override, and the commit bumps the
mount's revision, so a retry of an older pick refuses ``revision_conflict``.)Úchat_pick_keyÚcommit_chat_pickÚprepare_chat_pick)Úvalidate_actionr   rA   )ÚepochÚkeyÚdigestr7   ÚparamsNÚreceiptrB   r   r   ÚstatusÚconfirmation_requiredr7   Úrevisionr+   Úexecution_generationÚruntime_generationrD   )Úlocal_session_infozsession.info)Ú
event_type)Úhermes_state_mutation_chat_pickrL   rM   rN   Úhermes_state_mutationsrO   r7   ÚdictrP   ÚasyncioÚ	to_threadÚdbr   r   Ú_model_switch_lockrJ   r6   Úgateway.session_localrZ   Úevent_streamÚpublish)r?   Úrefr@   r   rS   Úprincipal_idrL   rM   rN   rO   r   rA   rQ   rR   ÚfencedÚpreparedrB   r   rI   rD   rZ   s   &&&&&$               r   Úapply_chat_pickrj   D   s×  é € ÷ cÑbÝ6Ø Õ,¨f°YÕ.?ˆwÙ�IÔ'Ù ×.>Ñ.>ÀÓG�K€CÜ˜	Ÿ™¨SÈE×L\ÑL\ÐekÔl€FÜ×&Ò&Ð'8¿,¹,ÑQÈ&ÑQ×Q€HØ�HÔØ˜	Õ"Ð"Ø
�5�/€CØ×Ñ€FØ�KÔÜ×ÒÔ 0°&¸$ÈÕ@QÓR×RÐRØ˜G HÕ-Ð.‰à×,Ñ,×.×.Õ.Ü& y¸ÈÓL×LˆF÷ /×.à‡z�z�(ÓÐ6Ô6Ø˜cŸn™n¨k¸9ÐOÈÐOÐOØ˜CŸN™N¨K¸ÀJÐPSÐTfÕPgØ$ cÐ*>Õ&?ðKØCIðK€Fä×$Ò$Ð%5·|±|Ñ]ÀvÑ]ÐV\Ò]×]€FÝ8à×Ñ×Ñ˜e×.Ñ.Ñ0BÀ9Ó0TÐaoÐÔpØ€Mò' Rò 	Sñ /ÙL÷ /×.×.Ò.úñ ^ùs’   ‚BHÂG%Â	AHÃG(Ã ,HÄG+ÄHÄG1Ä!G-Ä"G1Ä&HÄ1G/Ä2A8HÆ*HÆ+;HÇ(HÇ+HÇ-G1Ç/HÇ1H
	Ç7G:Ç8
H
	ÈH
	È	Hc           	     óè  € ^ RI HpHp ^ RIHp V! 4       pVP                  R4      p\        V\        4      '       d   TM/ pV! V4      VP                  R4      VP                  R4      r˜pV P                  VP                  4      p
V
e,   V
P                  ;'       g    TV
P                  ;'       g    Tr‡V P                  VP                  4      ;'       g0    V P                  P                  VP                  4      ;'       g    / pVP                  R4      ;'       g    TpVP                  R4      ;'       g    TVP                  R4      ;'       g    T	r˜VP                  R4      ;'       g)    W†P                  R4      8X  d   VP                  R4      MRpV P!                  VP                  VP                  VR7      pV P#                  VP                  VP                  R	7      pRV/V! WÞWxWœ4      C# )
a  ``model`` and the effort fields a messaging chat's next turn resolves, without building an agent
or resolving credentials: session ``/model`` > ``channel_overrides`` > config.yaml, and the session
``/reasoning`` > per-model > global level (``_resolve_session_reasoning_config``).)Ú_load_gateway_configÚ_resolve_gateway_model)Úeffort_fieldsr   r%   Úbase_urlNÚapi_mode)r
   r"   r   )r
   r"   )r   rl   rm   rc   rn   r6   Ú
isinstancer^   Ú_channel_override_forr
   r   r%   r4   r   Úsession_storeÚget_model_overrideÚ!_resolve_session_reasoning_configÚ_resolve_session_service_tier)r   r   rl   rm   rn   ÚconfigÚblockr   r%   ro   ÚchannelÚoverriderp   r   Útiers   &&             r   Úmessaging_route_infor|   g   s£  € ÷ IÝ3Ù!Ó#€FØ�J‰J�wÓ€EÜ ¤t×,Ò,‰E°"€EÙ 6°vÓ >ÀÇ	Á	È*Ó@UÐW\×W`ÑW`ÐakÓWl�X€EØ×*Ñ*¨4¯;©;Ó7€GØÒØ!Ÿ-™-×0Ð0¨5°'×2BÑ2B×2NÐ2NÀhˆxØ×-Ñ-¨d¯j©jÓ9×vÐv¸V×=QÑ=Q×=dÑ=dÐei×eoÑeoÓ=p×vÐvÐtv€HØ�L‰L˜Ó!×*Ð* U€EØ!Ÿ™ jÓ1×=Ð=°X¸x¿|¹|ÈJÓ?W×?cÐ?cÐ[cˆhð �|‰|˜JÓ'×qÐqÀX×QZÑQZÐ[eÓQfÔEf¨E¯I©I°jÔ,AÐlp€HØ×8Ñ8ÀÇÁÐY]×YcÑYcÐkpÐ8Óq€IØ×/Ñ/°t·{±{ÐPT×PZÑPZÐ/Ó[€DØ�UÐb™m¨I¸UÈhÓaÐbÐbr   )Ú__doc__r_   Úhermes_state_runtimer   Ú	frozensetr	   r   r   r   rJ   rj   r|   © r   r   Ú<module>r�      sD   ðñó å 2á˜ Ð-Ó.€
òcò
6ò
uò
ò@ ôFcr   