+
    jHàjó!  ã                   ó€   € R t ^ RIt^ RIHt ]P                  ! ]4      tR tR tR t	R t
R t^tR tR	 tR
 tRR ltR# )a®  The messaging setting handlers (``/reasoning`` ``/busy`` ``/verbose`` ``/fast`` ...) on a LOCAL session.

``slash.exec`` runs the same ``_handle_<name>_command`` a messaging chat runs. A local session's
next turn reads its settings from its live session and frozen policy, not from the runner's
per-platform snapshot, so a handler that changes a setting also applies it here: one behaviour
for every surface, held by the gateway.
N)ÚSimpleNamespacec                ó&   € \        W4      ^,          # )z\The ``LiveSession`` of the local session ``source`` belongs to, else None (messaging chats).)Úlocal_authority_live)ÚrunnerÚsources   &&ÚE/home/ubuntu/.hermes/hermes-agent/gateway/session_setting_commands.pyÚ
local_liver      s   € ä Ó/°Õ2Ð2ó    c                ó<   € \        W4      f   R# ^ RIHp V! W4      # )z0The frozen policy of a local session, else None.N©Úpolicy_for_source)r   Úgateway.session_policyr   )r   r   r   s   && r   Úlocal_policyr      s   € ä�&Ó!Ò)ÙÝ8Ù˜VÓ,Ð,r	   c                ój  € \        VRR4      pVR	9   d   V# ^ RIHp V! WP                  4      pVe   \        VRR4      R8X  d   RMRpVf   V P	                  VP                  4      # VP                  4       P                  R4      ;'       g    / P                  R4      ;'       g    TpVR	9   d   V# T# )
zYThe busy mode a local session's next input runs under (what ``config.get busy`` reports).Úbusy_input_modeNÚ	interruptÚqueuer   r   ÚtuiÚdisplay)r   Ústeerr   )Úgetattrr   r   r   Ú_effective_busy_input_modeÚconfigÚget)r   ÚliveÚvaluer   ÚpolicyÚfallbacks   &&    r   Úsession_busy_moder      s¯   € ä�DÐ+¨TÓ2€EØÐ/Ô/ØˆÝ8Ù˜v§{¡{Ó3€Fð
 !Ò,´¸ÀÈ4Ó1PÐTYÔ1Y‰wÐ_j€HØ‚~Ø×0Ñ0°·±Ó=Ð=Ø�]‰]‹_× Ñ  Ó+×1Ð1¨r×6Ñ6Ð7HÓI×UÐUÈX€EØÐ<Ô<ˆ5ÐJÀ(ÐJr	   c                ó"  € V'       g   R# ^ RI Hp ^ RIHp V! V 4       Fl  p\	        \        VR/ 4      P                  4       4       FA  pVP                  V8X  g   K  VP                  P                  VP                  8X  g   K=  Vu u # 	  Kn  	  R# )zDThe local ``LiveSession`` whose route is ``session_key``, else None.N©ÚPlatform©Úall_authoritiesÚsessions)Úgateway.configr!   Úgateway.session_authoritiesr#   Úlistr   ÚvaluesÚrouter   ÚplatformÚLOCAL)r   Úsession_keyr!   r#   Ú	authorityr   s   &&    r   Úlocal_live_for_router.   -   sj   € çÙÝ'Ý;Ù$ VÖ,ˆ	Üœ ¨J¸Ó;×BÑBÓDÖEˆDØ�z‰z˜[Ö(¨T¯[©[×-AÑ-AÀXÇ^Á^Ö-SØ”ó Fñ -ñ r	   c                ó,  € ^ RI Hp Ve   \        VRR4      VP                  8w  d   R# ^ RIHp V! V 4       FY  p\        VR/ 4      P                  VP                  4      pVf   K/  VP                  P                  VP                  8X  g   KV  WE3u # 	  R# )z\``(authority, live)`` owning the local session ``source`` belongs to, else ``(None, None)``.r    Nr*   r"   r$   )NN)
r%   r!   r   r+   r&   r#   r   Úchat_idr   r*   )r   r   r!   r#   r-   r   s   &&    r   r   r   :   s~   € å'Ø‚~œ ¨°TÓ:¸h¿n¹nÔLØÐÝ;Ù$ VÖ,ˆ	Ü�y *¨bÓ1×5Ñ5°f·n±nÓEˆØÔ §¡× 4Ñ 4¸¿¹Ö FØ�?Ò"ñ -ð Ðr	   c                ó˜   € ^ RI pRV P                  RRVP                  4       P                  ,           RVR,          RVR,          R	R
RRV//# )zaThe owner's fenced ``reasoning`` mutation of a ``/reasoning`` command, on *row*'s current fences.NÚ
session_idÚ
request_idzreasoning-command:Úexpected_revisionÚruntime_revisionÚexpected_generationÚruntime_generationÚ	operationÚ	reasoningÚpayloadÚeffort)Úuuidr2   Úuuid4Úhex)ÚrefÚrowr;   r<   s   &&& r   Ú_reasoning_mutationrA   J   sU   € ãØ˜#Ÿ.™.¨,Ð8LÈtÏzÉzË|×O_ÑO_Õ8_Ø Ð%7Õ!8Ð:OÐQTÐUiÕQjØ˜ i°(¸FÐ1CðEð Er	   c              ƒ  óÀ  "  € ^ RI p^ RIHp ^ RIHp ^ RIHp ^ RIHp	 ^ RI	H
p
 VR8X  d   V'       g   RpMVR8w  d   V! V4      e   TpMR# V P                  VP                  ,          pVP                  P                  VP                  8w  d   R# \!        \"        4       Fe  pVP%                  V P&                  P(                  VP                  4      G Rj  x€L
 pVf	   V
! R4      h V! WV\+        W.V4      4      G Rj  x€L
   R# 	  VP.                  V3Vn        R#  LG L   T
.T	O5 d/   p\-        TR	R
4      pTR8X  d    Rp?K§  TR9  d   h  Rp? KM  Rp?ii ; i5i)aR  ``/reasoning <level>`` in either scope, or ``reset``, on a LOCAL session (``config.set`` and
``slash.exec``): the owner's fenced ``reasoning`` mutation, before the handler replies or writes
config.yaml (``--global``). The level is the session's durable choice and a reset gives it back to the
profile, whatever an older pick said, after an owner restart too. Display words and reads commit nothing,
and so does a messaging chat (no session policy). While a turn runs, the handler applies it for the next
turn as on main and the drain commits it at that turn's end (``apply_pending_reasoning``).Nr    )Úmutate_session)Úparse_reasoning_effort©ÚMUTATION_GUARD_REFUSALS©ÚRuntimeStoreErrorÚresetÚ	not_foundÚreasonÚsession_busyÚrevision_conflict©rL   Úunknown_execution)Úasyncior%   r!   Úgateway.session_mutationsrC   Úhermes_constantsrD   Úhermes_state_mutation_guardsrF   Úhermes_state_runtimerH   r$   r2   r   r*   r+   ÚrangeÚ_FENCE_ATTEMPTSÚ	to_threadÚdbÚget_sessionrA   r   ÚsubjectÚpending_reasoning)r-   Úactorr?   r   Úpersist_globalrP   r!   rC   rD   rF   rH   r;   r   Ú_attemptr@   ÚexcrK   s   &&&&&            r   Úcommit_reasoning_commandr`   R   s7  é € ó Ý'Ý8Ý7ÝDÝ6Ø�Ô§Ø‰Ø	�'Ô	Ñ4°UÓ;ÒGØ‰áØ×Ñ˜cŸn™nÕ-€DØ‡{�{×Ñ˜xŸ~™~Ô-Ùô œ/Ö*ˆØ×%Ñ% i§l¡l×&>Ñ&>ÀÇÁÓO×OˆØŠ;Ù# KÓ0Ð0ð		Ù  °3Ô8KÈCÐV\Ó8]Ó^×^Ð^Úñ +ð $Ÿm™m¨VÐ4€DÖñ Pñ _øà!Ð<Ð$;Ñ<ô 	Ü˜S (¨NÓ;ˆFØÐ,Ô,ÝØÐBÔBØÞûð	üs_   ‚1E´B"EÃDÃEÃ(D"Ã?D Ä D"ÄEÄ D"Ä"EÄ-EÅEÅEÅEÅEÅEc           
   ƒ  ó†  "  € ^ RI p^ RIHp ^ RIHp ^ RIHp VP                  Ruqrn        Vf   R#  VP                  V P                  P                  VP                  4      G Rj  x€L
 pV! W\        WV^,          4      RV^ ,          R7      G Rj  x€L
  R#  L2 L  T.TO5 dj   p	\        T	RR4      R
9   d"   TP                  ;'       g    TTn         Rp	?	R# \        P                  RTP                  T	P                   4        Rp	?	R# Rp	?	i\"         d%    \        P%                  R	TP                  4        R# i ; i5i)zÉCommit a reasoning command that arrived while a turn ran. The drain calls this at the turn boundary,
under the claim gate and mutation lock, before a deferred model pick (whose level wins, as on main).N)Úwrite_mutationrE   rG   )Úprincipal_idrK   rL   z)Reasoning command on %s not committed: %sz(Reasoning command on %s failed to commitrN   )rP   rQ   rb   rS   rF   rT   rH   r[   rW   rX   rY   r2   rA   r   ÚloggerÚwarningrK   Ú	ExceptionÚ	exception)
r-   r?   r   rP   rb   rF   rH   Úpendingr@   r_   s
   &&&       r   Úapply_pending_reasoningri   |   s  é € ó Ý8ÝDÝ6Ø&*×&<Ñ&<¸dÐ#€GÔ#Ø‚Ùð
UØ×%Ñ% i§l¡l×&>Ñ&>ÀÇÁÓO×OˆÙ˜YÔ-@ÀÈ7ÐSTÍ:Ó-VÐX\ÐkrÐstÕkuÔv×vÒvñ PÙvøØÐ8Ð 7Ñ8ô dÜ�3˜ .Ó1Ð5ZÔZØ%)×%;Ñ%;×%FÐ%F¸wˆD×"Ò"ä�N‰NÐFÈÏÉÐX[×XbÑXb×cÒcûÜô Uä×ÑÐCÀSÇ^Á^×TðUüsv   ‚0E³3B Á&BÁ'+B ÂBÂB ÂEÂB ÂB ÂD>Â($DÃDÃEÃ+DÄEÄD>Ä!D>Ä:EÄ=D>Ä>Ec           	     óÀ  € ^ RI p^ RIHp ^ RIHp ^ RIHp VP                  P                  p\        V! V P                  V4      R,          R7      p	RVP                  ;'       g    VP                  /p
VP                  '       d   VP                  V
R&   V'       d   W:R	&   V! W	V! V P                  V4      R
RVP                  4       P                   ,           RV
/4       R# )aU  A typed ``/model`` on a local session: the resolved target becomes the session's canonical
``model`` mutation, committed by the owner at the next turn boundary (the typed command is
itself the running admission). One writer, so the next request, ``sessions.model`` and
``session.info`` move together, or the commit is announced as a refusal.N)Ú
SessionRef)Ú
defer_pick)Úlocal_receiptrc   )rZ   ÚmodelÚproviderr9   r3   ztyped-model:r:   )r<   Úgateway.session_contractrk   Úgateway.session_deferred_pickrl   Úhermes_state_localrm   r   r0   r   rX   Úresolved_via_aliasÚ	new_modelÚtarget_providerÚ
profile_idr=   r>   )r-   r   Úresultr;   r<   rk   rl   rm   ÚsidÚownerr:   s   &&&&       r   Údefer_local_model_pickrz   “   s·   € ó
 Ý3Ý8Ý0Ø
�+‰+×
Ñ
€CÜ¡M°)·,±,ÀÓ$DÀ^Õ$TÔU€Eð ˜×1Ñ1×EÐE°V×5EÑ5EÐF€GØ××ÐØ$×4Ñ4ˆ�
ÑßØ%�ÑÙˆy¡¨I×,@Ñ,@À#Ó!FØ˜n¨t¯z©z«|×/?Ñ/?Õ?ÀÈGÐTöVr	   )Ú )Ú__doc__ÚloggingÚtypesr   Ú	getLoggerÚ__name__rd   r   r   r   r.   r   rV   rA   r`   ri   rz   © r	   r   Ú<module>r‚      s[   ðñó Ý !à	×	Ò	˜8Ó	$€ò3ò
-òKò$
ò
ð €òEò'5òTUö.Vr	   