+
    .pÐjs ã                  ón  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
Ht ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHtHtHt ^ R
IHt ^ RIHtHtH t H!t!H"t" ^ RI#H$t$ ]PJ                  ! R4      t&Rt'0 Rm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/ ! R R4      t0R# )aj  Gateway slash commands that rotate, switch, fork or rewrite the session transcript:
/new, /resume, /sessions, /branch, /title, /save, /undo, /retry, /topic, /compress.
Split out of ``gateway/slash_commands.py``; bound onto ``GatewayRunner`` through
``GatewaySlashCommandsMixin``.  Origin internals are imported lazily inside the bodies to avoid
the import cycle.)ÚannotationsN)ÚOptionalÚUnion)Út)Úextract_api_content_sidecar)ÚPlatform)ÚEphemeralReply)ÚMessageEventÚMessageType)ÚSessionSourceÚbuild_session_keyÚis_shared_multi_user_session)ÚTranscriptReadError)ÚBRANCH_THREAD_PLATFORMSÚbranch_dest_sourceÚbranch_thread_parentÚformat_thread_refÚparse_branch_args)Úhistory_unreadablezgateway.rung      >@c               ó    € V ^8„  d   QhRRRR/# )é   ÚnameÚstrÚreturn© )Úformats   "Ú-/opt/hermes/gateway/slash_commands_session.pyÚ__annotate__r   *   s   € ÷ -ñ -�cð -˜cñ -ó    c                ó@   € \        \        WR4      ;'       g    R4      # )uW   ``str(getattr(obj, name) or "")`` â€” normalized identity field for origin comparisons.Ú )r   Úgetattr)Úobjr   s   &&r   Ú_sattrr#   *   s   € äŒw�s "Ó%×+Ð+¨Ó,Ð,r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚsummaryÚdictr   ú	list[str]r   )r   s   "r   r   r   /   s   € ÷ ñ ¨Tð Èyñ r   c                óZ  € RV R,           2.pV'       d   VP                  \        RVR7      4       VP                  V R,          4       V R,          '       d   VP                  V R,          4       \        VRR4      pV'       d   ^ R	IHp V! VR
R7      p\        VRR4      p\        VRR4      '       d2   TP                  \        RT;'       g    \        R4      R7      4       V# V'       d=   \        VRR4      ;'       g    \        R4      pVP                  \        RWgR7      4       V# )aE  Manual /compress confirmation lines, surfacing summariser/aux-model failures.
``_last_compress_aborted`` = no usable summary, messages unchanged.  Provider exception text is
force-redacted at this UI boundary even when global redaction is off; an aux model recovered
via main is an info note so the user can fix their config.õ   ðŸ—œï¸� Úheadlinezgateway.compress.focus_line)ÚtopicÚ
token_lineÚnoteÚ_last_summary_errorN)Úredact_sensitive_textT)ÚforceÚ_last_aux_model_failure_modelÚ_last_compress_abortedFzgateway.compress.abortedzgateway.shared.unknown_error©ÚerrorÚ_last_aux_model_failure_errorzgateway.compress.aux_failed)Úmodelr4   )Úappendr   r!   Úagent.redactr/   )r%   Ú
compressorÚfocus_topicÚlinesÚsummary_errr/   Úaux_fail_modelÚaux_errs   &&&     r   Ú_manual_compression_reply_linesr?   /   sÿ   € ð
 ˜ 
Õ+Ð,Ð-Ð.€EßØ�‰”QÐ4¸KÔHÔIØ	‡L�L�˜Õ&Ô'Øˆv‡„Ø�‰�W˜V•_Ô%Ü˜*Ð&;¸TÓB€KßÝ6Ù+¨K¸tÔDˆÜ˜ZÐ)HÈ$ÓO€NÜˆzÐ3°U×;Ò;Ø�‰”QÐ1¸+×:jÐ:jÌÐKiÓIjÔlÔmð €L÷ 
Ü˜*Ð&EÀtÓL×qÐqÔPQÐRpÓPqˆØ�‰”QÐ4¸NÔZÔ[Ø€Lr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   ÚpartialÚboolÚagg_noter   r   r   )r   s   "r   r   r   G   s#   € ÷ ñ ¨dð ÐVYð Ð^añ r   c           	     ó   € ^ RI Hp ^ RIHp V  Uu. uFX  pVP	                  R4      R9   g   K  VP	                  R4      '       g   K4  RVP	                  R4      RVP	                  R4      /NKZ  	  ppV! W�W#V! V4      4      p	V	R,           U
u. uF  p
RV
 2NK
  	  pp
V'       d   VP                  V4       RP                  V4      # u upi u up
i )	uQ   ``/compress --preview``: report what WOULD be compressed â€” no agent, no writes.)Úestimate_request_tokens_rough)Úsummarize_compress_previewÚroleÚcontentr;   r)   Ú
>   ÚuserÚ	assistant)Úagent.model_metadatarE   Úhermes_cli.partial_compressrF   Úgetr7   Újoin)ÚhistoryrA   Ú	keep_lastr:   rC   rE   rF   ÚmÚpv_msgsÚreportÚliner;   s   &&&&&       r   Ú_compress_preview_replyrV   G   sÄ   € åBÝFáMTó OÉWÈØ—%‘%˜“-Ð#8Ñ8ô DØ=>¿U¹UÀ9×=Mô D�˜Ÿ™˜f› y°!·%±%¸	Ó2BÓCÉW€Gð Oá'¨¸)Ù(EÀgÓ(NóP€Fà+1°'®?Ó;©? 4ˆx˜�vÓ©?€EÐ;ßØ�‰�XÔØ�9‰9�UÓÐùòOùò <s   ‘C®CÁ(CÂCc               ó   € V ^8„  d   QhRR/# ©r   r   ÚNoner   )r   s   "r   r   r   V   s   € ÷ !ñ !¨$ñ !r   c                 ó4  € \         P                  ! \        4      ;_uu_ 4        ^ RIHp  V ! 4        RRR4       \         P                  ! \        4      ;_uu_ 4        ^ RIHp V! 4        RRR4       R#   + '       g   i     LJ; i  + '       g   i     R# ; i)zXDrop env-passthrough and credential-file state at a conversation boundary (best-effort).)Úclear_env_passthroughN)Úclear_credential_files)Ú
contextlibÚsuppressÚ	ExceptionÚtools.env_passthroughr[   Útools.credential_filesr\   )r[   r\   s     r   Ú _reset_process_scoped_tool_staterb   V   sZ   € ä	×	Ò	œY×	'Õ	'Ý?ÙÔ÷ 
(ô 
×	Ò	œY×	'Õ	'ÝAÙÔ ÷ 
(Ñ	'÷ 
(×	'ú÷ 
(×	'Ð	'ús   £A3ÁBÁ3B	ÂB	c               ó    € V ^8„  d   QhRRRR/# )r   Úmsgr&   r   r   )r   s   "r   r   r   `   s   € ÷ ñ �Tð ˜dñ r   c                óø   € \          Uu/ uF  qV P                  V4      bK  	  ppV P                  RR4      VR&   V P                  R4      ;'       g    V P                  R4      VR&   \        V 4      VR&   V# u upi )z©/branch child row; keeps the api_content sidecar so the branch's first turn replays the
parent's exact wire bytes (warm provider prompt cache) instead of a cold prefill.rG   rJ   Ú	tool_namer   Úapi_content)Ú_BRANCH_COPIED_FIELDSrN   r   )rd   ÚkÚrows   &  r   Ú_branch_rowrk   `   st   € õ #8Ó
8Ñ"7˜Qˆc�g‰g�a‹jŠ=Ñ"7€CÐ
8Ø—'‘'˜& &Ó)€Cˆ�KØ—w‘w˜{Ó+×>Ð>¨s¯w©w°v«€CˆÑÜ4°SÓ9€CˆÑØ€Jùò	 9s   ‰A7c               ó    € V ^8„  d   QhRRRR/# )r   Úpartsr'   r   r   r   )r   s   "r   r   r   j   s   € ÷ ñ ˜ið ¨Cñ r   c                óÆ   € RP                  R V  4       4      P                  4       p\        V4      ^8¼  d+   V^ ,          VR,          3R9   d   V^R P                  4       pV# )zwJoin the non-flag /resume tokens; strip literal ``<...>``/``[...]``/quotes typed from the
usage hint (mirrors the CLI).Ú c              3  ó6   "  € T F  qR9  g   K  Vx € K  	  R# 5i)ú--allN>   rq   ú--cross-roomr   )Ú.0Úps   & r   Ú	<genexpr>Ú%_strip_resume_name.<locals>.<genexpr>m   s   é € ÐK™u˜!Ð1JÑ(J—A’A›uùs   ‚�
éÿÿÿÿ>   ©Ú"ry   ©Ú'r{   ©Ú<Ú>©Ú[Ú])rO   ÚstripÚlen)rm   r   s   & r   Ú_strip_resume_namer„   j   sZ   € ð �8‰8ÑK™uÓKÓK×QÑQÓS€DÜ
ˆ4ƒy�A„~˜4 �7 D¨¥HÐ-Ð1aÔaØ�A�bˆz×ÑÓ!ˆØ€Kr   c                  ó°  € ] tR t^st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4       tR R ltR R ltR R ltR R ltRDR R lltR R ltR R ltRER R ll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R* R+ ltRFR, R- lltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6 R7 lt R8 R9 lt!R: R; lt"R< R= lt#R> R? lt$R@ RA lt%RBt&RC# )GÚGatewaySessionCommandsMixinzwSession-transcript slash commands (/new, /resume, /sessions, /branch, /title, /save, /undo, /retry, /topic, /compress).c               ó    € V ^8„  d   QhRRRR/# )r   Úsession_keyr   r   rY   r   )r   s   "r   r   Ú(GatewaySessionCommandsMixin.__annotate__x   s   € ÷ *ñ *¸cð *Àdñ *r   c              ƒ  ól  "  € V P                  V4      pVf   R#  \        P                  ! V P                  V P                  V4      \
        R7      G Rj  x€L
  R#  L  \         d     \        P                  RT\
        4        R# \         d"   p\        P                  RY4        Rp?R# Rp?ii ; i5i)u4  Close the old agent's tool resources (sandboxes, browsers, subprocesses) before eviction.
Blocking work on the event loop (confirm-button click) â†’ offloaded with a bounded timeout.
wait_for cancels the await, not the worker thread: a wedged teardown keeps running (or
leaks); the reset proceeds either way.N)Útimeoutz–Agent resource cleanup for session %s exceeded %ss during /new reset; proceeding with reset (the worker thread is left to finish on its own). (#35994)zKAgent resource cleanup for session %s failed during /new reset: %s (#35994))
Ú_cached_agent_forÚasyncioÚwait_forÚ_run_housekeeping_in_executorÚ_cleanup_agent_resourcesÚ_RESET_CLEANUP_TIMEOUT_SÚTimeoutErrorÚloggerÚwarningr_   )Úselfrˆ   Ú
_old_agentÚcleanup_excs   &&  r   Ú_cleanup_old_agent_for_resetÚ8GatewaySessionCommandsMixin._cleanup_old_agent_for_resetx   s¡   é € ð
 ×+Ñ+¨KÓ8ˆ
ØÒÙð	*Ü×"Ò"Ø×2Ñ2°4×3PÑ3PÐR\Ó]Ü0ô2÷ 2ô 2øô ô 	7Ü�N‰NðSàÔ5÷7ô ô 	*Ü�N‰NØ]Ø÷*ò *ûð	*üsR   ‚B4›9A ÁAÁA ÁB4ÁA Á&B1ÂB4ÂB1ÂB1ÂB,Â&B4Â,B1Â1B4c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úsourcer   rˆ   r   r   rY   r   )r   s   "r   r   r‰   Ž   s(   € ÷ Cñ C°mð CÐRUð CØ48ñCr   c           
   ƒ  ó4  "  € VP                   '       d   VP                   P                  MRp\        P                  ! \        4      ;_uu_ 4        V P                  W5RW4R7      G Rj  x€L
 pV P                  WaVR7      G Rj  x€L
  RRR4       RVRVP                  RV/pV P                  P                  R	\        V4      4      G Rj  x€L
  V P                  P                  R
\        V4      4      G Rj  x€L
  R#  L• L|  + '       g   i     L‚; i LJ L5i)u‰   Session-boundary hooks: plugin finalize (off-loop + bounded â€” trace exports can block
arbitrarily), then session:end and session:reset.r    Únew_session)Ú
session_idÚplatformÚreasonÚold_session_idÚnew_session_idN©r›   rˆ   rŸ   Úuser_idrˆ   zsession:endzsession:reset)rŸ   Úvaluer]   r^   r_   Ú_finalize_session_off_loopÚ_deliver_session_end_messagesr¤   ÚhooksÚemitr&   )r•   r›   rˆ   Úold_sidÚnew_sidÚplatform_valueÚmessagesÚhook_payloads   &&&&&   r   Ú_fire_session_reset_hooksÚ5GatewaySessionCommandsMixin._fire_session_reset_hooksŽ   sç   é € ð 39·/·/°/˜Ÿ™×.Ò.ÀrˆÜ× Ò ¤×+Õ+Ø!×<Ñ<Ø"ÀMØ&ð =ó @÷ @ˆHð ×4Ñ4°XÐZeÐ4Óf×fÐf÷	 ,ð
 # N°I¸v¿~¹~È}Ð^iÐjˆØ�j‰j�o‰o˜m¬T°,Ó-?Ó@×@Ð@Ø�j‰j�o‰o˜o¬t°LÓ/AÓB×BÒBñ@ñ g÷	 ,×+úñ 	AÙBùsa   ‚ADÁDÁ'C=Á(DÂC?ÂDÂADÃ	DÃ
,DÃ6DÃ7DÃ=DÃ?DÄD	Ä	DÄDc               ó    € V ^8„  d   QhRRRR/# )r   Úeventr	   r   zstr | EphemeralReplyr   )r   s   "r   r   r‰   œ   s   € ÷ E4ñ E4°ð E4ÐBVñ E4r   c              ƒ  óÞ  "  € VP                   pV P                  V4      pV P                  VRR7       V P                  V4       V P                  P
                  P                  V4      pV P                  V4      G Rj  x€L
  V P                  V4       V P                  VRR7       \        P                  ! \        4      ;_uu_ 4        ^ RIHp T! TR\        \!        VRR4      ;'       g    R4      R7       RRR4       \#        4        V P$                  P'                  V4      G Rj  x€L
 pV'       d   VP(                  MRpT P+                  Y#TV'       d   VP(                  MR4      G Rj  x€L
   \,        P.                  ! V P0                  V4      G Rj  x€L
 pV'       d   \3        R4      p	M0V P$                  P5                  VR	R
7      G Rj  x€L
 p\3        R4      p	\,        P.                  ! V P6                  V4      G Rj  x€L
 ;'       g    T	p
VP9                  4       P;                  4       pV'       d?   V P<                  '       d-   V'       d%   V P?                  W¦P(                  V4      G Rj  x€L
 p
\,        P.                  ! V P@                  V4      G Rj  x€L
 '       d/   Ve+    \,        P.                  ! V PB                  W&4      G Rj  x€L
  V'       d   VP(                  MRp ^ RI$H%p T! RTRVPL                  '       d   VPL                  PN                  MRW|R7        ^ RI(H)p \3        RV! 4       R7      pV'       d   V
 RV 2MT
p\U        V V 24      #  ELâ  + '       g   i     ELs; i ELN EL ELå  \         d    Rp ELói ; i ELÃ EL’ EL' EL LÏ  \         d    \D        PG                  RR	R7        Lñi ; i  \         d     L°i ; i  \         d    Rp Lªi ; i5i)zHandle /new or /reset command.Úsession_reset©r    N)Úinterrupt_for_sessionrž   r    )rˆ   r    Úparent_session_idzgateway.reset.header_defaultT)Ú	force_newzgateway.reset.header_newz*Failed to rebind Telegram topic after /new©Úexc_info)Úinvoke_hookÚon_session_resetr�   )rž   r    rŸ   r¡   r¢   )Úget_random_tipzgateway.reset.tip)Útipú

)+r›   Ú_session_key_for_sourceÚ"_invalidate_session_run_generationÚ_release_running_agent_stateÚsession_storeÚ_entriesrN   r˜   Ú_evict_cached_agentÚ_clear_conversation_scoper]   r^   r_   Útools.async_delegationr¶   r   r!   rb   Úasync_session_storeÚreset_sessionrž   r¯   r�   Ú	to_threadÚ_reset_notice_session_infor   Úget_or_create_sessionÚ_telegram_topic_new_headerÚget_command_argsr‚   Ú_session_dbÚ_reset_titled_headerÚ_is_telegram_topic_laneÚ_record_telegram_topic_bindingr“   ÚdebugÚhermes_cli.lifecycler»   rŸ   r¥   Úhermes_cli.tipsr½   r   )r•   r²   r›   rˆ   Ú	old_entryr¶   Ú	new_entryÚ_old_sidÚsession_infoÚdefault_headerÚheaderÚ
_title_argÚ_new_sidÚ_invoke_hookr½   Ú	_tip_lineÚbodys   &&               r   Ú_handle_reset_commandÚ1GatewaySessionCommandsMixin._handle_reset_commandœ   s]  é € à—‘ˆØ×2Ñ2°6Ó:ˆØ×/Ñ/°ÀOÐ/ÔTð 	×)Ñ)¨+Ô6ð ×&Ñ&×/Ñ/×3Ñ3°KÓ@ˆ	Ø×/Ñ/°Ó<×<Ð<Ø× Ñ  Ô-ð 	×&Ñ& {¸?Ð&ÔKô × Ò ¤×+Õ+ÝDÙ!¨kÀ/Ü47¼À	È<ÐY[Ó8\×8bÐ8bÐ`bÓ4cõe÷ ,ô 	)Ô*à×2Ñ2×@Ñ@ÀÓM×Mˆ	ß+4�9×'Ò'¸$ˆØ×,Ñ,¨VÀ(ßEN¨Y×-AÒ-AÐTXóZ÷ 	Zð 	Zð	Ü!(×!2Ò!2°4×3RÑ3RÐTZÓ![×[ˆL÷ ÜÐ=Ó>‰Nà"×6Ñ6×LÑLÈVÐ_cÐLÓd×dˆIÜÐ9Ó:ˆNÜ×(Ò(¨×)HÑ)HÈ&ÓQ×Q×cÐcÐUcˆØ×+Ñ+Ó-×3Ñ3Ó5ˆ
ß˜$×*×*Ð*¯yØ×4Ñ4°V×=QÑ=QÐS]Ó^×^ˆFô ×"Ò" 4×#?Ñ#?ÀÓH×HÖHÈYÒMbðZÜ×'Ò'¨×(KÑ(KÈVÓ_×_Ð_÷ ,5�9×'Ò'¸$ˆð	ÝHÙÐ+¸ÈØ;A¿?¿?¸? &§/¡/×"7Ò"7ÐPRØ(0õKð
	Ý6ÜÐ-±>Ó3CÔDˆI÷ 1=�&�˜˜l˜^Ñ,À&ˆÜ   y kÐ2Ó3Ð3òm 	=÷ ,×+Ð+úò Nò	Zò
 \øÜô 	Ø‹Lð	úò
 eâQò _ò Iá_øÜô ZÜ—‘ÐIÐTX�ÖYðZûô ô 	Ùð	ûô
 ô 	ØŠIð	üsu  ‚A;O-Á=MÁ>A
O-Ã0M"Ã80O-Ä(M6Ä)O-Ä58O-Å-M9Å.O-Å3$M? ÆM<ÆM? ÆO-Æ$,O-ÇNÇ3O-ÈNÈ
O-È(O-È9O-ÉO-ÉO-É2NÉ3(O-ÊNÊ	O-Ê&O-Ê+$N! ËNËN! ËO-ËO-Ë+O	 ÌO	 Ì'O Ì?O-ÍO-Í"M3	Í-
O-Í9O-Í<M? Í?NÎO-ÎNÎO-ÎO-ÎO-ÎO-ÎN! Î!"OÏO-ÏOÏO-Ï	OÏO-ÏOÏO-ÏO*Ï'O-Ï)O*Ï*O-c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rÛ   r   rž   Ú	title_argr   r   )r   s   "r   r   r‰   ã   s*   € ÷ ñ °ð À#ð ÐRUð ÐZ]ñ r   c              ƒ  óê  "  € ^ RI Hp Rp VP                  V4      pV'       d:    V P                  P                  W&4      G Rj  x€L
  \	        RVR7      pW,           # V'       g   \	        R	4      pW,           #   \         d#   pRp\	        R\        T4      R7      p Rp?L„Rp?ii ; i Ld  \         d(   p\	        R\        T4      R7      p Rp?Y,           # Rp?i\         d     Y,           # i ; i5i)
zR``/new <title>``: titled header on success, else the header plus a rejection note.©Ú	SessionDBr    Nzgateway.reset.title_rejectedr3   zgateway.reset.header_titled©Útitlez"gateway.reset.title_error_untitledz"gateway.reset.title_empty_untitled)	Úhermes_staterç   Úsanitize_titleÚ
ValueErrorr   r   rÏ   Úset_session_titler_   )r•   rÛ   rž   rä   rç   r-   Ú	sanitizedÚes   &&&&    r   rÐ   Ú0GatewaySessionCommandsMixin._reset_titled_headerã   sè   é € å*Øˆð	CØ!×0Ñ0°Ó;ˆI÷ ðØ×&Ñ&×8Ñ8¸ÓO×OÐOÜÐ8À	ÔJ�ð �}Ð÷ ÜÐ9Ó:ˆDØ�}Ðøô ô 	CØˆIÜÐ3¼3¸q»6ÔB�Dûð	Cúñ
 Pøäô MÜÐ=ÄSÈÃVÔL”ð
 �}Ðûô	 ô Øð �}Ðð	üs€   ‚	C3ŒA9 �C3¦B+ ÁB)ÁB+ ÁC3Á&C3Á9B&ÂB!ÂC3Â!B&Â&C3Â)B+ Â+C0Â6CÃC3ÃC0Ã%C0Ã&	C3Ã/C0Ã0C3c               ó    € V ^8„  d   QhRRRR/# )r   rž   r   r   úOptional[SessionSource]r   )r   s   "r   r   r‰   ú   s   € ÷ 	Mñ 	M¸ð 	MÐAXñ 	Mr   c                ó<  a€ \        \        V P                  4      RR4      p\        V4      '       d'   V! V P                  S4      pVe   \        VRR4      # R# \        V P                  R/ 4      ;'       g    / p\	        V3R lVP                  4        4       R4      # )z2Best-effort origin lookup for gateway session IDs.Úlookup_by_session_idNÚoriginrÄ   c              3  óf   <"  € T F&  p\        VR R4      S8X  g   K  \        VRR4      x € K(  	  R# 5i)rž   Nrõ   )r!   )rs   rï   rž   s   & €r   ru   ÚMGatewaySessionCommandsMixin._gateway_session_origin_for_id.<locals>.<genexpr>  s8   øé € ð FÑ9I°AÜ  <°Ó6¸*ÑDô 0”W˜Q ¨$×/Ð/Ó9Iùs   ƒ1œ1)r!   ÚtyperÃ   ÚcallableÚnextÚvalues)r•   rž   ÚlookupÚentryÚentriess   &f   r   Ú_gateway_session_origin_for_idÚ:GatewaySessionCommandsMixin._gateway_session_origin_for_idú   s–   ø€ äœ˜d×0Ñ0Ó1Ð3IÈ4ÓPˆÜ�F×ÒÙ˜4×-Ñ-¨zÓ:ˆEØ5:Ò5F”7˜5 (¨DÓ1ÐPÈDÐPä˜$×,Ñ,¨j¸"Ó=×CÐCÀˆÜô F¸¿¹Ô9Ió FØGKóMð 	Mr   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   Úcurrentr   rõ   rò   r   rB   r   )r   s   "r   r   r‰     s(   € ÷ Qñ Q =ð QÐ:Qð QÐVZñ Qr   c                	ó"  € VR J;'       d…    VP                   \        P                  8H  ;'       d`    V P                   \        P                  8H  ;'       d;    VP                  V P                  8H  ;'       d    \	        V R4      \	        VR4      8H  # )NÚ	thread_id)rŸ   r   ÚMATRIXÚchat_idr#   )r  rõ   s   &&r   Ú_same_matrix_roomÚ-GatewaySessionCommandsMixin._same_matrix_room  s‰   € ð ˜dÐ"÷ Pð P v§¡¼(¿/¹/Ñ'I÷ Pð PØ×$Ñ$¬¯©Ñ7÷Pð PØ<B¿N¹NÈgÏoÉoÑ<]÷Pð Pä˜7 KÓ0´F¸6À;Ó4OÑOð	Qr   c               ó$   € V ^8„  d   QhRRRRRR/# r  r   )r   s   "r   r   r‰     s(   € ÷ @ñ @¨ð @Ð@Wð @Ð\`ñ @r   c                ó  € Ve   Vf   R# VP                   VP                   8w  g   VP                  VP                  8w  d   R# \        VR4      \        VR4      8w  d   R# \        VR4      P                  4       \        9   d’   \        VR4      '       d   R# \        VP                  ;'       g    VP                  ;'       g    R4      p\        VP                  ;'       g    VP                  ;'       g    R4      p\        V4      ;'       d    W48H  # V P                  V4      '       d   R# VP                  ;'       g    VP                  pVP                  ;'       g    VP                  p\        T;'       d    T4      ;'       d    W48H  # )zéPlatform-agnostic counterpart to ``_same_matrix_room``.  Per-participant sessions must be
participant-scoped here too, else a co-member could resume another member's live session
(IDOR); only an explicitly shared group/thread shares.Fr  Ú	chat_typer  Tr    )
rŸ   r  r#   ÚlowerÚ_DM_CHAT_TYPESr   Úuser_id_altr¤   rB   Ú_is_shared_session_source)r•   r  rõ   Úcur_pidÚorg_pids   &&&  r   Ú_same_origin_chatÚ-GatewaySessionCommandsMixin._same_origin_chat  s6  € ð Š>˜Wš_ÙØ�?‰?˜g×.Ñ.Ô.°&·.±.ÀGÇOÁOÔ2SÙä�'˜;Ó'¬6°&¸+Ó+FÔFÙÜ�'˜;Ó'×-Ñ-Ó/´>ÔAô �g˜y×)Ò)ÙÜ˜'×-Ñ-×FÐF°·±×FÐFÀBÓGˆGÜ˜&×,Ñ,×DÐD°·±×DÐDÀ"ÓEˆGÜ˜“=×7Ð7 WÑ%7Ð7ð ×)Ñ)¨'×2Ò2ÙØ×%Ñ%×8Ð8¨¯©ˆØ×$Ñ$×6Ð6¨¯©ˆÜ�G×'Ð' Ó(×?Ð?¨WÑ-?Ð?r   c               ó    € V ^8„  d   QhRRRR/# ©r   r›   r   r   rB   r   )r   s   "r   r   r‰   )  s   € ÷ ^ñ ^°ð ^À$ñ ^r   c           	     ór   € \        V\        V P                  RR4      \        V P                  RR4      R7      # )z§Whether *source*'s session key is shared by every participant (not per-user); mirrors
build_session_key's isolation rules so the guards stay in lock-step with the key.Úgroup_sessions_per_userTÚthread_sessions_per_userF)r  r  )r   r!   Úconfig)r•   r›   s   &&r   r  Ú5GatewaySessionCommandsMixin._is_shared_session_source)  s9   € ô ,Ø¬G°D·K±KÐAZÐ\`Ó,aÜ%,¨T¯[©[Ð:TÐV[Ó%\ô^ð 	^r   c               ó    € V ^8„  d   QhRRRR/# r  r   )r   s   "r   r   r‰   0  s   € ÷ 
ñ 
¨mð 
Àñ 
r   c                óÎ   €  ^ RI Hp V! W4      p\        VRR4      p\        VP                  ;'       d    T;'       d    VP                  V4      4      #   \         d     R# i ; i)u
  Whether *source* is an EXPLICITLY-configured admin (cross-origin /resume, /sessions).
Stricter than ``SlashAccessPolicy.is_admin()``, which is True for every caller when slash
gating is DISABLED â€” the default config would make everyone cross-origin-capable (IDOR).)Úpolicy_for_runner_sourcer¤   NF)Úgateway.slash_accessr  r!   rB   ÚenabledÚis_adminr_   )r•   r›   r  ÚpolicyÚuids   &&   r   Ú_resume_caller_is_adminÚ3GatewaySessionCommandsMixin._resume_caller_is_admin0  s\   € ð	ÝEÙ-¨dÓ;ˆFÜ˜& )¨TÓ2ˆCÜ˜Ÿ™×GÐG¨3×GÐG°6·?±?À3Ó3GÓHÐHøÜô 	Úð	ús   ‚<A ¿A ÁA$Á#A$c               ó$   € V ^8„  d   QhRRRRRR/# )r   r›   r   rj   r&   r   rB   r   )r   s   "r   r   r‰   <  s!   € ÷  7ñ  7°-ð  7Àdð  7Ètñ  7r   c                óš  € VP                   '       d   VP                   P                  MRpVP                  R4      p\        VR4      pV'       g   R# \	        VP                  R4      ;'       g    R4      pV'       d3   V'       d+   \	        V4      \	        V4      8X  d   V\        VR4      8X  g   R# \	        VP                  R4      ;'       g    R4      p\	        VP                  R4      ;'       g    R4      p\        VR4      p	\        \        VR4      4      p
\        VR	4      P                  4       \        9   d>   V
'       d   V'       d	   V	'       g   R# \        V4      ;'       d    Wu8H  ;'       d    W‰8H  # V'       d   V	'       d   W‰8X  g   R# V P                  V4      '       d   R
# V
'       d   R# \        V4      ;'       d    Wu8H  # )aO  Whether a persisted (inactive) session *row* provably belongs to *source*'s session key.
Rows once stored only source + user_id, so the persisted chat/thread origin is compared too
and legacy NULL rows fail closed.  The table has no user_id_alt column, so an alt-keyed
(Signal/Feishu) caller is never proven by user_id alone (CWE-639).Nr›   r¤   Fr  r    r  r  r  T)	rŸ   r¥   rN   r#   r   rB   r  r  r  )r•   r›   rj   Ú
caller_srcÚrow_srcÚ
caller_uidÚ
row_threadÚrow_uidÚrow_chatÚcaller_chatÚcaller_keys_on_alts   &&&        r   Ú_persisted_row_proves_ownerÚ7GatewaySessionCommandsMixin._persisted_row_proves_owner<  sR  € ð
 /5¯o¯o¨o�V—_‘_×*Ò*À4ˆ
Ø—'‘'˜(Ó#ˆÜ˜F IÓ.ˆ
ßÙÜ˜Ÿ™ Ó-×3Ð3°Ó4ˆ
ßŸJ¬3¨w«<¼3¸z»?Ô+JØ¤&¨°Ó"=Ô=ÙÜ�c—g‘g˜iÓ(×.Ð.¨BÓ/ˆÜ�s—w‘w˜yÓ)×/Ð/¨RÓ0ˆÜ˜V YÓ/ˆÜ!¤&¨°Ó"?Ó@ÐÜ�&˜+Ó&×,Ñ,Ó.´.Ô@ç!¯8¿ÙÜ˜“=×VÐV WÑ%:×VÐV¸xÑ?VÐVçŸ[¨XÔ-DÙð ×)Ñ)¨&×1Ò1ÙßÙÜ�G‹}×6Ð6 Ñ!6Ð6r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r›   r   Ú	target_idr   Úallow_overriderB   r   r   )r   s   "r   r   r‰   ^  s*   € ÷ =ñ =°=ð =ÈSð =Ø59ð=ØFJñ=r   c              ƒ  óŠ  "  € V'       d   V P                  V4      '       d   R#  V P                  V4      p\        V\        4      '       d   V P                  W4      #  V P                  P                  V4      G Rj  x€L
 ;'       g    / pT P                  Y4      #   \         d    Rp Lui ; i L2  \         d     R# i ; i5i)zØWhether *source* may resume session *target_id* (IDOR guard for every adapter).  The live
origin decides when the target is active; otherwise the DB row must PROVE ownership or fail
closed.  Admin ``--all`` bypasses.TNF)	r$  rÿ   r_   Ú
isinstancer   r  rÏ   Úget_sessionr0  )r•   r›   r3  r4  rõ   rj   s   &&&&  r   Ú_resume_target_allowedÚ2GatewaySessionCommandsMixin._resume_target_allowed^  s¸   é € ÷
 ˜d×:Ñ:¸6×BÒBÙð	Ø×8Ñ8¸ÓCˆFô �fœm×,Ò,Ø×)Ñ)¨&Ó9Ð9ð	Ø×(Ñ(×4Ñ4°YÓ?×?×EÐEÀ2ˆCð ×/Ñ/°Ó<Ð<øô ô 	ØŠFð	úñ
 @øÜô 	Úð	üsh   ‚C¢C¥B ¶'CÁB1 Á<B/Á=
B1 ÂB1 ÂCÂB,Â)CÂ+B,Â,CÂ/B1 Â1C Â<CÂ?C Ã Cc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r›   r   rj   r&   Ú	allow_allrB   r   r   )r   s   "r   r   r‰   r  s0   € ÷ Tñ T°ð TÀDð TÐUYð TÐ^bñ Tr   c              ƒ  óL  "  € V'       d   V P                  V4      '       d   R# \        VP                  R4      ;'       g    R4      pVP                  \        P
                  8X  d!   V P                  WP                  V4      4      # V P                  WRR7      G Rj  x€L
 #  L5i)z¯Whether a listing *row* belongs to the caller's origin (blocks cross-origin enumeration of
ids/previews); Matrix is room-scoped, ``--all`` needs a configured admin everywhere.TÚidr    F©r4  N)	r$  r   rN   rŸ   r   r  r  rÿ   r8  )r•   r›   rj   r;  Úsids   &&&& r   Ú_resume_row_visibleÚ/GatewaySessionCommandsMixin._resume_row_visibler  s€   é € ÷ ˜×5Ñ5°f×=Ò=ÙÜ�#—'‘'˜$“-×%Ð% 2Ó&ˆØ�?‰?œhŸo™oÔ-Ø×)Ñ)¨&×2UÑ2UÐVYÓ2ZÓ[Ð[Ø×0Ñ0°ÈUÐ0ÓS×SÐSÑSùs   ‚B$¢B$ÁAB$ÂB"ÂB$c               ó    € V ^8„  d   QhRRRR/# ©r   r²   r	   r   r   r   )r   s   "r   r   r‰   ~  s   € ÷ 1Qñ 1Q°ð 1QÀ#ñ 1Qr   c           
   ƒ  ó¦  aa"  € ^ RI HpHpHpHo VP
                  pV P                  P                  V4      G Rj  x€L
 p V P                  P                  VP                  4      G Rj  x€L
 o\        TT3R l\        \        S4      ^,
          RR4       4       R4      pTf   \        R4      #  T! ST4      w  r‰T! T	P!                  R4      4      p
T! ST,          4      w  r¼TeK    T P                  P%                  TP                  ^RR	7      G Rj  x€L
 pTf   \        R
4      # TR,          p
MBT P                  P'                  TP                  TRRR7      G Rj  x€L
 '       g   \        R
4      # ^ Tn        T P+                  RYVP                  4       T P-                  \/        T
\0        P2                  TTP4                  TP6                  R7      4      G Rj  x€L
 #  EL¤ ELy  \         d    \        4       u # i ; i  \"         d   p\        RTR7      u Rp?# Rp?ii ; i EL  \"         d   p\        RTR7      u Rp?# Rp?ii ; i Lï Lt5i)z6Handle /retry command - re-send the last user message.)Ú#history_before_user_originated_turnÚretryable_user_textÚsplit_user_originated_turnÚuser_originated_turn_viewNc              3  óN   <"  € T F  pS! SV,          4      f   K  Vx € K  	  R # 5i©Nr   )rs   ÚirP   rH  s   & €€r   ru   ÚDGatewaySessionCommandsMixin._handle_retry_command.<locals>.<genexpr>Œ  s'   øé € ð TÑ)H AÙ!:¸7À1½:Ó!F÷  šaÓ)Hùs   ƒ%›
%zgateway.retry.no_previousrH   zgateway.retry.unsafer3   T)Úrequire_retryable_compositezgateway.retry.failed_unchangedÚtarget_text)Úactive_onlyÚreject_active_turn_leaseÚretry)ÚtextÚmessage_typer›   Úraw_messageÚchannel_promptrw   )Úagent.context_compressorrE  rF  rG  rH  r›   rÈ   rÌ   Úload_transcriptrž   r   r   rú   Úrangerƒ   r   rN   rì   Úrewind_sessionÚrewrite_transcriptÚlast_prompt_tokensÚ_record_model_frictionÚ_handle_messager	   r
   ÚTEXTrT  rU  )r•   r²   rE  rF  rG  r›   Úsession_entryÚlast_user_idxÚ	truncatedÚ	live_viewÚlast_user_msgÚhandoffÚ_ÚexcÚrewind_resultrP   rH  s   &&             @@r   Ú_handle_retry_commandÚ1GatewaySessionCommandsMixin._handle_retry_command~  sC  ùé € ÷	'ó 	'ð —‘ˆØ"×6Ñ6×LÑLÈVÓT×Tˆð	(Ø ×4Ñ4×DÑDÀ]×E]ÑE]Ó^×^ˆGô õ T¬¬s°7«|¸aÕ/?ÀÀRÔ)Hó TØUYó[ˆàÒ ÜÐ0Ó1Ð1ð	8Ù#FÀwÐP]Ó#^Ñ ˆIÙ/°	·±¸iÓ0HÓIˆMÙ3°G¸MÕ4JÓK‰JˆGð Òð<ð '+×&>Ñ&>×&MÑ&MØ!×,Ñ,¨aÈTð 'Nó 'S÷ !S�ð Ò$ÜÐ9Ó:Ð:Ø)¨-Õ8‰Mà×/Ñ/×BÑBØ×$Ñ$ i¸TÐ\`ð Có b÷ bö bäÐ5Ó6Ð6Ø+,ˆÔ(Ø×#Ñ# G¨V×5MÑ5MÔNØ×)Ñ)¬,Ø¬[×-=Ñ-=ÀfØ×)Ñ)¸%×:NÑ:Nô+Pó Q÷ Qð 	QòM Uâ^øÜ"ô 	(Ü%Ó'Ò'ð	(ûô ô 	8ÜÐ+°3Ô7Õ7ûð	8úò!Søäô <ÜÐ/°sÔ;Õ;ûð<úñbñ
QùsÞ   „7I»G¼IÁ(G% Á)G"Á*G% Á.AIÂ03H  Ã#IÃ(+H( ÄH%ÄH( ÄAIÅIÅ	IÅ(A2IÇIÇIÇ"G% Ç%G=Ç:IÇ<G=Ç=IÈ H"ÈHÈH"ÈIÈH"È"IÈ%H( È(I
È3IÈ?I
É IÉI
É
IÉIc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úsignalr   rž   ÚturnsÚintr   rY   r   )r   s   "r   r   r‰   ±  s0   € ÷ \ñ \¨Sð \Àcð \ÐRUð \Ð^bñ \r   c                ó  € ^ RI Hp Rp\        \        V RR4      RR4      '       d=   \        P                  ! \
        4      ;_uu_ 4        V P                  V4      pRRR4       V! WWdR7       R#   + '       g   i     L; i)zuSlash dispatch does not install the routed profile's scope, so a multiplexed runner
names the owning home explicitly.)Úrecord_model_frictionNr  Úmultiplex_profilesF)rž   Úhermes_homerl  )Ú-hermes_cli.observability.shared_metrics_modelro  r!   r]   r^   r_   Ú _resolve_profile_home_for_source)r•   rk  r›   rž   rl  ro  Úhomes   &&&&&  r   r\  Ú2GatewaySessionCommandsMixin._record_model_friction±  s_   € õ 	XØˆÜ”7˜4 ¨4Ó0Ð2FÈ×NÒNÜ×$Ò$¤Y×/Õ/Ø×<Ñ<¸VÓD�÷ 0á˜fÈ×[÷ 0×/ús   Á	A/Á/A?	c               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   »  s   € ÷ Añ A°ð AÀñ Ar   c              ƒ  ó   "  € VP                   p^pVP                  4       P                  4       pV'       d,    \        ^\	        VP                  4       ^ ,          4      4      pV P                  P                  V4      G Rj  x€L
 pV P                  P                  VP                  V4      G Rj  x€L
 pVf   \        R4      # ^ Vn        T P                  RY%P                  VP                  R4      ;'       g    ^4        V P                  V P!                  V4      4       VR,          p\)        V4      ^È8”  d   VR	,          R
,           MTp	\        RVR,          VR,          V	R7      #   \         d&    \        RTP                  4       ^ ,          R7      u # i ; i EL Lï  \"         d!   p\$        P'                  RT4        Rp?L¦Rp?ii ; i5i)uÊ   Handle /undo [N] â€” back up N user turns (default 1), soft-deleting the truncated rows and
echoing the backed-up text; evicts the cached agent so the next turn rebuilds from the
active-only transcript.zgateway.undo.invalid_count)ÚargNzgateway.undo.nothingÚundoÚturns_undonez'undo: cached-agent eviction skipped: %srN  :NéÈ   Nz...zgateway.undo.removedÚrewound_count)rl  ÚcountÚpreview)r›   rÎ   r‚   Úmaxrm  Úsplitrì   r   rÈ   rÌ   rY  rž   r[  r\  rN   rÅ   rÀ   r_   r“   rÓ   rƒ   )
r•   r²   r›   ÚnÚraw_argsr_  Úresultrï   rN  r~  s
   &&        r   Ú_handle_undo_commandÚ0GatewaySessionCommandsMixin._handle_undo_command»  s˜  é € ð —‘ˆØˆØ×)Ñ)Ó+×1Ñ1Ó3ˆßðPÜ˜œ3˜xŸ~™~Ó/°Õ2Ó3Ó4�ð #×6Ñ6×LÑLÈVÓT×TˆØ×/Ñ/×>Ñ>¸}×?WÑ?WÐYZÓ[×[ˆØŠ>ÜÐ+Ó,Ð,Ø+,ˆÔ(Ø×#Ñ# F¨F×4LÑ4LÈfÏjÉjÐYgÓNh×NmÐNmÐlmÔnð	Gð ×$Ñ$ T×%AÑ%AÀ&Ó%IÔJð ˜]Õ+ˆÜ/2°;Ó/?À#Ô/E�+˜dÕ# eÖ+È;ˆÜÐ'¨v°nÕ/EØ˜oÕ.¸ôAð 	Aøô! ô PÜÐ5¸8¿>¹>Ó;KÈAÕ;NÔOÒOðPúâTÙ[øô ô 	GÜ�L‰LÐBÀA×FÑFûð	Güsx   ‚5G¸*E( Á"GÂ FÂ-GÂ.FÂ/AGÃ8GÄ  F  Ä AGÅ(-FÆGÆFÆGÆGÆ GÆ+GÇGÇGÇGc               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   Ú  s   € ÷ Dñ D°Lð DÀSñ Dr   c              ƒ  óN  "  € \        \        V RR4      RR4      '       g   V P                  V4      G Rj  x€L
 # ^ RIHp V! V P	                  VP
                  4      4      ;_uu_ 4        V P                  V4      G Rj  x€L
 uuRRR4       #  LW L  + '       g   i     R# ; i5i)u  Profile-scoping wrapper around manual /compress: multiplexed gateways resolve credentials
through the fail-closed per-profile secret scope, which slash dispatch (unlike ``_run_agent``)
does not install â€” unscoped, /compress would raise ``UnscopedSecretError``.r  Nrp  F)Ú_profile_runtime_scope)r!   Ú_handle_compress_command_innerÚgateway.runrˆ  rs  r›   )r•   r²   rˆ  s   && r   Ú_handle_compress_commandÚ4GatewaySessionCommandsMixin._handle_compress_commandÚ  sƒ   é € ô ”w˜t X¨tÓ4Ð6JÈE×RÒRØ×<Ñ<¸UÓC×CÐCÝ6Ù# D×$IÑ$IÈ%Ï,É,Ó$W×XÕXØ×<Ñ<¸UÓC×C÷ YÒXñ Dñ D÷ Y×XÐXüs9   ‚3B%µB¶3B%Á)BÁ>BÁ?BÂB%ÂBÂB"	Â	B%c               ó$   € V ^8„  d   QhRRRRRR/# )r   rˆ   r   rž   r   r   )r   s   "r   r   r‰   ä  s#   € ÷ 6ñ 6ÀCð 6ÐUXð 6Ð]`ñ 6r   c              ƒ  ó˜  aa"  € ^ RI Hp V P                  VRR7      oSe   SVJ g   \        SRR4      f   \	        R4      # \        SRR4      p\        VR^ 4      p V P                  VV3R	 l4      G Rj  x€L
  \        TR^ 4      T8”  d   \	        R4      # \	        R4      #  L,  \         d   p\	        R
TR7      u Rp?# Rp?ii ; i5i)a  Manual /compress for codex_app_server sessions: compacts the LIVE cached agent's
app-server thread (``force=True`` bypasses the ``codex_app_server_auto`` gate) and keeps it
cached. A temporary agent or a mirror rewrite cannot shrink the server-side thread.

See #73503.
)Ú_AGENT_PENDING_SENTINELT)Úlockless_fallbackNÚ_codex_sessionzgateway.compress.codex_nothingÚcontext_compressorÚcompression_countc                 óB   <€ S P                  . R RS;'       g    RR7      # )r    TÚdefault)r0   Útask_id)Ú_compress_context)Úagentrž   s   €€r   Ú<lambda>ÚPGatewaySessionCommandsMixin._compress_codex_app_server_session.<locals>.<lambda>ô  s"   ø€ ˜×/Ñ/°°B¸dÈJ×LcÐLcÐZcÐ/Ôdr   úgateway.compress.failedr3   z gateway.compress.codex_compactedz!gateway.compress.codex_incomplete)rŠ  r�  rŒ   r!   r   Ú_run_in_executor_with_contextr_   )r•   rˆ   rž   r�  r9   Úcount_beforerf  r˜  s   &&f    @r   Ú"_compress_codex_app_server_sessionÚ>GatewaySessionCommandsMixin._compress_codex_app_server_sessionä  sÙ   ùé € õ 	8à×&Ñ& {ÀdÐ&ÓKˆØŠ=˜EÐ%<Ó<ÄÈÐO_ÐaeÓ@fÒ@nÜÐ5Ó6Ð6Ü˜UÐ$8¸$Ó?ˆ
Ü˜zÐ+>ÀÓBˆð	;Ø×4Ñ4Ýdóf÷ fð fô �:Ð2°AÓ6¸ÔEÜÐ7Ó8Ð8ÜÐ4Ó5Ð5ñføäô 	;ÜÐ.°cÔ:Õ:ûð	;üsH   „AC
ÁB% Á6B#Á7B% Á;(C
Â#B% Â%CÂ0CÂ<CÂ=C
ÃCÃC
c               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   û  s   € ÷ 9ñ 9¸,ð 9È3ñ 9r   c              ƒ  óP  "  € ^ RI HpHp VP                  pV P                  P                  V4      G Rj  x€L
 p V P                  P                  VP                  4      G Rj  x€L
 pT'       d   \        T4      T8  d   \        R4      # T! TP                  4       ;'       g    R4      pTP                  '       d   \        R4      MRpTP                  '       d   TP                  '       g   T# TP                  '       d-   \        YgP                   TP"                  TP$                  T4      #  T P'                  YEYg4      G Rj  x€L
 #  EL Lè  \         d    \        4       u # i ; i L$  \(         d.   p	\*        P-                  RT	4       \        RT	R7      u Rp	?	# Rp	?	ii ; i5i)	z®Handle /compress -- manually compress conversation context; ``/compress <focus>`` tells
the summariser what to preserve. Flags/positional forms are parsed by the shared core.)ÚMIN_MESSAGESÚparse_compress_argsNzgateway.compress.not_enoughr    z'gateway.compress.aggressive_unsupportedzManual compress failed: %sr›  r3   )Ú%agent.conversation_compression_manualr¢  r£  r›   rÈ   rÌ   rW  rž   r   r   rƒ   r   rÎ   Ú
aggressiver~  rV   rA   rQ   r:   Ú_run_manual_compressionr_   r“   r”   )
r•   r²   r¢  r£  r›   r_  rP   ÚrequestÚ	_agg_noterï   s
   &&        r   r‰  Ú:GatewaySessionCommandsMixin._handle_compress_command_innerû  sU  é € ÷ 	\à—‘ˆØ"×6Ñ6×LÑLÈVÓT×Tˆð	(Ø ×4Ñ4×DÑDÀ]×E]ÑE]Ó^×^ˆG÷ œ#˜g›,¨Ô5ÜÐ2Ó3Ð3Ù% e×&<Ñ&<Ó&>×&DÐ&DÀ"ÓEˆØDK×DV×DVÐDV”AÐ?Ô@Ð\^ˆ	Ø××Ð g§o§o oØÐØ�?�?ˆ?Ü*¨7·O±OÀW×EVÑEVÐX_×XkÑXkÐmvÓwÐwð	9Ø×5Ñ5°fÈWÓ^×^Ð^ò Uá^øÜ"ô 	(Ü%Ó'Ò'ð	(úñ _øÜô 	9Ü�N‰NÐ7¸Ô;ÜÐ.°aÔ8Õ8ûð	9üsª   ‚3F&µE	¶F&»(E Á#EÁ$E Á(F&Á03F&Â$F&Â=F&ÃF&Ã.F&Ä,F&Ä/E+ ÅE)ÅE+ ÅF&ÅE ÅE&Å#F&Å%E&Å&F&Å)E+ Å+F#Å6"FÆF#ÆF&ÆF#Æ#F&c               ó    € V ^8„  d   QhRRRR/# )r   rP   Úlistr   r   r   )r   s   "r   r   r‰     s   € ÷ 1dñ 1dÈDð 1dÐ^añ 1dr   c              ƒ  ó6  aaaaa"  € ^ RI Hp ^ RIHoHp ^ RIHp V P                  V4      pVP                  '       d   V! VP                  4      MRp	V P                  WR7      w  r«\        VP                  R4      ;'       g    R4      P                  4       R8X  d%   V P                  VSP                  4      G Rj  x€L
 # VP                  R	4      '       g   \        R
4      # V Uu. uF  qÌP                  R4      R9   g   K  VNK  	  upoV	e   W›R&   W‹R&   V P!                  WR7      VR&   V P#                  SP                  W«4      G Rj  x€L
 o V P%                  VVVVV3R l4      G Rj  x€L
 pVP&                  R8X  dB   \        R4      V! SRR7       V P)                  V4       V P+                  SRR7      G Rj  x€L
  # VP&                  R8w  dN   RP-                  V! V4      4      V! SRR7       V P)                  V4       V P+                  SRR7      G Rj  x€L
  # V P/                  SSWP0                  4      G Rj  x€L
  V! SRR7       SP2                  pVP4                  pV! SRR7       V P)                  V4       V P+                  SRR7      G Rj  x€L
  RP-                  \7        WþSP8                  4      4      #  EL	u upi  EL� ELb EL L¸ L” L>  T! SRR7       T P)                  T4       T P+                  SRR7      G Rj  x€L 
  i ; i5i)zYBuild a temporary agent, run the shared compress core, persist, and describe the outcome.)Ú0finalize_context_engine_compression_notification)Úcompress_nowÚrender_compress_result)Ú_platform_config_keyNr£   Úapi_moder    Úcodex_app_serverÚapi_keyzgateway.compress.no_providerrG   rŸ   Úgateway_session_key)r›   r6   Úreasoning_configc            	     óH   <€ S ! SSSR RSP                   ;'       g    RR7      # )r    Tr•  )Úsystem_messageÚskip_without_windowr–  ©rž   )r®  Úmsgsr§  r_  Ú	tmp_agents   €€€€€r   r™  ÚEGatewaySessionCommandsMixin._run_manual_compression.<locals>.<lambda>6  s'   ø€ ™ Y°°gÈbÐfjØ-:×-EÑ-E×-RÐ-RÈõTr   Únothing_to_dozgateway.compress.nothing_to_doF)Ú	committedzmanual compression)ÚcontextÚ
compressedrI   T>   ÚtoolrJ   rK   )Úagent.conversation_compressionr­  r¤  r®  r¯  rŠ  r°  rÀ   rŸ   Ú_resolve_session_agent_runtimer   rN   r  rž  rž   r   Ú!_resolve_session_reasoning_configÚ_build_manual_compression_agentrœ  ÚstatusrÅ   Ú!_cleanup_agent_resources_off_looprO   Ú_persist_manual_compressionÚafter_messagesr’  r%   r?   r:   )r•   r›   r_  rP   r§  r­  r¯  r°  rˆ   Úplatform_keyr6   Úruntime_kwargsrR   rƒ  r9   r%   r®  rº  r»  s   &&f&f           @@@r   r¦  Ú3GatewaySessionCommandsMixin._run_manual_compression  së  üé € åcß^Ý4à×2Ñ2°6Ó:ˆð AGÇÇÀÑ+¨F¯O©OÔ<ÐUYˆØ $× CÑ CÈ6Ð CÓ kÑˆÜˆ~×!Ñ! *Ó-×3Ð3°Ó4×:Ñ:Ó<Ð@RÔRð ×@Ñ@ÀÈm×NfÑNfÓg×gÐgØ×!Ñ! )×,Ò,ÜÐ3Ó4Ð4ñ #ÓU™7�a§e¡e¨F£mÐ7TÑ&T—�™7ÑUˆð Ò#Ø)5˜:Ñ&Ø0;Ð,Ñ-ð .2×-SÑ-SÐ[aÐ-SÓ-oˆÐ)Ñ*à×>Ñ>¸}×?WÑ?WÐY^Óo×oˆ	ð	bð  ×=Ñ=÷Tð TóU÷ UˆFð �}‰} Ô/ÜÐ9Ó:ñ =¸YÐRWÕXØ×$Ñ$ [Ô1à×8Ñ8¸ÐL`Ð8Óa×aÑað �}‰} Ô,Ø—y‘yÑ!7¸Ó!?Ó@ñ =¸YÐRWÕXØ×$Ñ$ [Ô1à×8Ñ8¸ÐL`Ð8Óa×aÑað ×2Ñ2°9¸mÈV×UjÑUjÓk×kÐkÙ<¸YÐRVÕWØ"×5Ñ5ˆJØ—n‘nˆGá<¸YÐRWÕXØ×$Ñ$ [Ô1à×8Ñ8¸ÐL`Ð8Óa×aÐaØ�y‰yÔ8¸Èg×NaÑNaÓbÓcÐcòG hùò
 Vò pòUô bñ lñ bøñ =¸YÐRWÕXØ×$Ñ$ [Ô1à×8Ñ8¸ÐL`Ð8Óa×aÒaüsÓ   ‡B6LÂ=KÂ>LÃLÃ(K	ÄK	Ä
ALÅKÅLÅK Å/KÅ0K Æ1LÇ KÇLÇ'K Ç-1LÈKÈLÈ$ K ÉKÉ&K É+1LÊKÊ*LË	LËK ËLËLËK ËLË2LÌLÌLÌLc               ó    € V ^8„  d   QhRRRR/# )r   rž   r   rË  r&   r   )r   s   "r   r   r‰   G  s   € ÷ &ñ &Àð &Ð\`ñ &r   c              ƒ  óR  "  € ^ RI Hp ^ RIHpHp ^ RIHp ^ RIHp Rp	\        V P                  RR4      p
\        V
4      '       d    V
! V4      G Rj  x€L
 p	T! V! 4       ;'       g    / P                  R
4      ;'       g    / P                  R4      RR7      pV! R/ VBRVR^RRRV'       * RR.RVR\        V P                  RV P                  4      /B pV! WÙ4       W]n        R Vn        RVn        V#  L¡  \         d#   p\        P                  RYRR	7        Rp?LÇRp?ii ; i5i)zUBuild the throwaway AIAgent that performs a manual /compress rewrite of *session_id*.)ÚAIAgent)Ú_GATEWAY_HYGIENE_PLATFORMÚ_seed_hygiene_system_prompt)Úload_config)Úis_truthy_valueNr7  z¡Manual compression could not restore the system prompt for session %s: %s. Preserving an empty prompt so the live turn rebuilds it with its configured providers.Tr¹   ÚcompressionÚcheckpoint_requiredF)r•  r6   Úmax_iterationsÚ
quiet_modeÚskip_memoryÚenabled_toolsetsÚmemoryrž   Ú
session_dbÚ_dbc                 ó   € R # rJ  r   )ÚaÚkws   *,r   r™  ÚMGatewaySessionCommandsMixin._build_manual_compression_agent.<locals>.<lambda>j  s   € ©tr   r   )Ú	run_agentrÏ  rŠ  rÐ  rÑ  Úhermes_cli.configrÒ  ÚutilsrÓ  r!   rÏ   rù   r_   r“   r”   rN   rŸ   Ú	_print_fnÚ_end_session_on_close)r•   rž   r6   rË  rÏ  rÐ  rÑ  Ú	_load_cfgÚ
_is_truthyÚsession_rowr7  rf  Ú_checkpoint_requiredr»  s   &&&&          r   rÅ  Ú;GatewaySessionCommandsMixin._build_manual_compression_agentG  sU  é € å%ßVÝ>Ý7ð ˆÜ˜d×.Ñ.°¸tÓDˆÜ�K× Ò ðBÙ$/°
Ó$;×;�ñ  *Ù‹k×Ð˜R×$Ñ$ ]Ó3×9Ð9°r×>Ñ>Ð?TÓUØô Ðñ ñ [˜nñ [°Eð [È!ð [ÐX\ð [Ø,@Ô(@ð[ØT\ÐS]ð[à'1ð[ô (/¨t×/?Ñ/?ÀÈ×HXÑHXÓ'Yò[ˆ	ñ 	$ IÔ;ð
 7ÔÙ3ˆ	Ôà*/ˆ	Ô'ØÐñ3 <øÜô BÜ—‘ð!à",¸Dð ÷ Bñ BûðBüsO   ‚AD'ÁC7 ÁC5ÁC7 ÁD'Á(D'ÂA4D'Ã5C7 Ã7D$ÄDÄD'ÄD$Ä$D'c               ó   € V ^8„  d   QhRR/# rX   r   )r   s   "r   r   r‰   o  s   € ÷ gñ gÐaeñ gr   c              ƒ  ó0  "  € VP                   pWRP                   8w  d—   V P                  P                  VP                   WT4      G Rj  x€L
 '       g   \        RV 24      hWRn         V P                  P	                  4       G Rj  x€L
  \
        P                  ! V P                  W2RR7      G Rj  x€L
  M(\        VRR4      '       g   \        P                  R4       V P                  P                  VP                  ^ R7      G Rj  x€L
  R#  LÅ L‹ Lb L5i)	a¦  Commit a manual /compress result to the session store.  Rotation (new continuation id)
makes the NEW session durable (already published, else rewritten) so the original stays searchable;
persist BEFORE repointing so a failed write is fatal and old history stays reachable.
In-place compaction already archived + inserted rows, and a rewrite would DELETE the
archive; an unchanged id without in-place means rotation FAILED.Nz4failed to persist compressed transcript for session zcompress-commandrµ   Ú_last_compaction_in_placeFu§   Manual /compress: session rotation did not occur (session_id unchanged) and in-place mode is off â€” preserving original transcript instead of overwriting it (#44794).)r[  )rž   rÈ   Ú!persist_rotated_compression_childÚRuntimeErrorÚ_saver�   rÊ   Ú_sync_telegram_topic_bindingr!   r“   r”   Úupdate_sessionrˆ   )r•   r»  r_  r›   rÀ  r¢   s   &&&&& r   rÈ  Ú7GatewaySessionCommandsMixin._persist_manual_compressiono  s  é € ð #×-Ñ-ˆØ×5Ñ5Ô5à×1Ñ1×SÑSØ!×,Ñ,¨nóJ÷ Jö Jä"Ð%YÐZhÐYiÐ#jÓkÐkØ'5Ô$Ø×*Ñ*×0Ñ0Ó2×2Ð2Ü×#Ò# D×$EÑ$EÀvØ+=ô?÷ ?ñ ?ä˜Ð$?À×GÒGÜ�N‰Nðeôfð ×&Ñ&×5Ñ5°m×6OÑ6OÐdeÐ5Óf×fÒfñJñ 3ñ?ñ 	gùsO   ‚ADÁDÁ		DÁ1DÂDÂ*DÂ/DÂ0ADÄDÄDÄDÄDÄDc               ó$   € V ^8„  d   QhRRRRRR/# )r   r²   r	   Úargsr   r   r   )r   s   "r   r   r‰   ‡  s'   € ÷ A(ñ A(°ð A(ÀSð A(ÐRUñ A(r   c           	   ƒ  óT  "  € VP                   pVP                  \        P                  8w  g   VP                  R8w  d   \        R4      # V P                  '       g   V P                  4       #  V P                  V4      '       g   \        R4      #  VP                  4       P                  4       pVP                  4       R9   d   V P                  4       # VP                  4       R9   d   V P!                  V4      G Rj  x€L
 # V'       d7   VP"                  '       g   \        R4      # V P%                  W4      G Rj  x€L
 # V P'                  V4      G Rj  x€L
 pVP)                  R	4      '       du   RpVP)                  R
4      RJ d   RpMVP)                  R4      RJ d   RpV'       d<   V P+                  V4      '       d   V P-                  V4      G Rj  x€L
  \        V4      # V P/                  V4      p V P                  P1                  \3        VP4                  4      \3        VP6                  4      VVP)                  R
4      VP)                  R4      R7      G Rj  x€L
  TP"                  '       g3   T P;                  T4      G Rj  x€L
  T P=                  T4      G Rj  x€L
 #  T P                  P?                  \3        TP4                  4      \3        TP"                  4      TR7      G Rj  x€L
 pT'       g   \        R4      # \3        TP)                  R4      ;'       g    R4      p	 T P                  PA                  T	4      G Rj  x€L
 p
\        RT
;'       g    \        R4      T	R7      #   \         d    \        P                  RRR7        ELi ; i EL› EL` ELJ ELÍ ELG  \         d-   p\        P9                  R4       \        RTR7      u Rp?# Rp?ii ; i ELY ELC Lø  \         d    \        P                  RRR7       Rp ELi ; i LÊ  \         d    Rp
 L×i ; i5i)z:Handle /topic for Telegram DM user-managed topic sessions.Údmzgateway.topic.not_telegram_dmzgateway.topic.unauthorizedzTopic auth check failedTr¹   Nz!gateway.topic.restore_needs_topicÚcheckedÚhas_topics_enabledFzgateway.topic.topics_disabledÚallows_users_to_create_topicsz$gateway.topic.topics_user_disallowed)r  r¤   Úprofile_namerù  rú  z$Failed to enable Telegram topic modezgateway.topic.enable_failedr3   )r  r  rû  z%Failed to read Telegram topic bindingzgateway.topic.thread_readyrž   r    zgateway.topic.bound_statuszgateway.topic.untitled_session)Úlabelrž   >   Ú?Úhelpú-hú--help>   ÚoffÚstopÚdisable)!r›   rŸ   r   ÚTELEGRAMr  r   rÏ   Ú_session_db_unavailable_replyÚ_is_user_authorized_for_sourcer_   r“   rÓ   rÎ   r‚   r  Ú_telegram_topic_help_textÚ%_disable_telegram_topic_mode_for_chatr  Ú_restore_telegram_topic_sessionÚ _get_telegram_topic_capabilitiesrN   Ú%_should_send_telegram_capability_hintÚ _send_telegram_topic_setup_imageÚ_telegram_topic_profile_nameÚenable_telegram_topic_moder   r  r¤   Ú	exceptionÚ_ensure_telegram_system_topicÚ#_telegram_topic_root_status_messageÚget_telegram_topic_bindingÚget_session_title)r•   r²   rõ  r›   ÚcapabilitiesÚblocked_keyrû  rf  Úbindingrž   ré   s   &&&        r   Ú_handle_topic_commandÚ1GatewaySessionCommandsMixin._handle_topic_command‡  s¨  é € à—‘ˆØ�?‰?œh×/Ñ/Ô/°6×3CÑ3CÀtÔ3KÜÐ4Ó5Ð5Ø××ÐØ×5Ñ5Ó7Ð7ð	CØ×6Ñ6°v×>Ò>ÜÐ5Ó6Ð6ð ?ð
 ×%Ñ%Ó'×-Ñ-Ó/ˆØ�:‰:‹<Ð8Ô8Ø×1Ñ1Ó3Ð3Ø�:‰:‹<Ð5Ô5Ø×CÑCÀFÓK×KÐKßØ×#×#Ð#ÜÐ<Ó=Ð=Ø×=Ñ=¸eÓJ×JÐJà!×BÑBÀ6ÓJ×JˆØ×Ñ˜I×&Ò&ØˆKØ×ÑÐ 4Ó5¸Ó>Ø=‘Ø×!Ñ!Ð"AÓBÀeÓKØD�ßØ×=Ñ=¸f×EÒEØ×?Ñ?ÀÓG×GÐGÜ˜“~Ð%à×8Ñ8¸Ó@ˆð	?Ø×"Ñ"×=Ñ=Ü˜FŸN™NÓ+´S¸¿¹Ó5HÐWcØ#/×#3Ñ#3Ð4HÓ#IØ.:×.>Ñ.>Ð?^Ó._ð >ó a÷ að að ××ÐØ×4Ñ4°VÓ<×<Ð<Ø×AÑAÀ&ÓI×IÐIð	Ø ×,Ñ,×GÑGÜ˜FŸN™NÓ+´s¸6×;KÑ;KÓ7LØ)ð Hó +÷ +ˆG÷ ÜÐ1Ó2Ð2Ü˜Ÿ™ \Ó2×8Ð8°bÓ9ˆ
ð	Ø×*Ñ*×<Ñ<¸ZÓH×HˆEô Ð-°U×5aÐ5a¼aÐ@`Ó>aØ&ô(ð 	(øôi ô 	CÜ�L‰LÐ2¸TˆL×Bð	Cúò Lò KâJò Hò
aøô ô 	?Ü×ÑÐCÔDÜÐ2¸#Ô>Õ>ûð	?úò
 =ÚIñ+øô ô 	Ü�L‰LÐ@È4ˆLÔPØ‹Gð	úñ IøÜô 	ØŠEð	üs}  ‚AP(ÁP(Á-M. Â
M. ÂA.P(Ã<NÃ=P(Ä	P(ÄP(Ä:NÄ;P(ÅNÅP(Å/8P(Æ(P(Æ?P(ÇN Ç P(Ç5A'N& ÉN#ÉN& É!P(É3P(ÊO ÊP(Ê O#Ê!P(Ê&AO( Ë-O&Ë.O( Ë2P(Ë:'P(Ì"P(Ì*P ÍPÍ	P ÍP(ÍP(Í."NÎP(ÎNÎP(ÎP(ÎP(Î P(Î#N& Î&OÎ1!OÏOÏP(ÏOÏP(Ï#P(Ï&O( Ï($PÐP(ÐPÐP(ÐP ÐP%Ð"P(Ð$P%Ð%P(c               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   Ì  s   € ÷ ;#ñ ;#°ð ;#Àñ ;#r   c           	   ƒ  ó	  aaaa"  € ^ RI p^ RIHpHpHpHpHo VP                  4       P                  4       p\        V4      ;'       d    VR,          P                  4       R9   pV'       d   VRR pV'       g   V#  V! V^ ,          4      oTP                  p
T P                  P                  T
4      G Rj  x€L
 pTP                  pT P                   '       g   \#        R4      # \%        T4      ^8”  d
   T^,          MT! TS4      p\&        P(                  P+                  T4      ;'       g
    T! TS4      p^ RIHp  \0        P2                  ! YPP                   P4                  TS4      G Rj  x€L
 oS'       g   \#        RTR7      # T'       d   ^ RIHp T! S4      oTP=                  R	R
7      p\&        P(                  P?                  TT4      o R TTTT3R llp\0        P2                  ! T4      G Rj  x€L
  T PA                  T
4      pT'       gc   \#        R4      \B        PD                  ! \F        4      ;_uu_ 4        \&        PH                  ! S4       \&        PJ                  ! T4       RRR4       # TPM                  T
PN                  S\#        RTR7      TR7      G Rj  x€L
  \#        R4      \B        PD                  ! \F        4      ;_uu_ 4        \&        PH                  ! S4       \&        PJ                  ! T4       RRR4       #   \         d   p	T	 RT 2u Rp	?	# Rp	?	ii ; i ELq EL¾  T d   p	\7        T	4      u Rp	?	# Rp	?	ii ; i ELX  + '       g   i     # ; i LÀ  + '       g   i     # ; i  \F         d˜   p	\P        PS                  RT	4       \#        RT	R7      u Rp	?	\B        PD                  ! \F        4      ;_uu_ 4        \&        PH                  ! S4       \&        PJ                  ! T4       RRR4       #   + '       g   i     # ; iRp	?	ii ; i  \B        PD                  ! \F        4      ;_uu_ 4        \&        PH                  ! S4       \&        PJ                  ! T4       RRR4       i   + '       g   i     i ; i; i5i)uF   Handle /save â€” export the current session and send it as a document.N)Ú
SAVE_USAGEÚdefault_save_filenameÚload_save_snapshotÚnormalize_save_formatÚrender_session_for_saver¿   z%gateway.shared.session_db_unavailable)ÚSessionExportTooLargeErrorzgateway.save.no_messagesr¹  )Úredact_session_dataÚhermes_save_)Úprefixc               ó   € V ^8„  d   QhRR/# rX   r   )r   s   "r   r   ÚFGatewaySessionCommandsMixin._handle_save_command.<locals>.__annotate__ô  s   € ÷ &ñ & tñ &r   c                 ó¢   <€ S! SS4      p \        SR RR7      ;_uu_ 4       pVP                  V 4       RRR4       R#   + '       g   i     R# ; i)Úwzutf-8)ÚencodingN)ÚopenÚwrite)ÚrenderedÚfÚexport_dataÚfmtr  Ú	temp_paths     €€€€r   Ú_render_and_writeÚKGatewaySessionCommandsMixin._handle_save_command.<locals>._render_and_writeô  s;   ø€ Ù2°;ÀÓD�Ü˜) S°7×;Õ;¸qØ—G‘G˜HÔ%÷ <×;×;Ò;ús	   ¡=½A	zgateway.save.no_adapterzgateway.save.caption)Úfilename)r  Ú	file_pathÚcaptionÚ	file_namezgateway.save.completezSession /save failed: %szgateway.save.failedr3   rw   )Úredactz--redact)*ÚtempfileÚhermes_cli.session_exportr  r  r  r  r  rÎ   r€  rB   r  rì   r›   rÈ   rÌ   rž   rÏ   r   rƒ   ÚosÚpathÚbasenamerê   r   r�   rÊ   rÜ  r   Úhermes_cli.session_export_mdr!  ÚmkdtemprO   Ú_delivery_adapter_forr]   r^   r_   ÚremoveÚrmdirÚsend_documentr  r“   r”   )r•   r²   r7  r  r  r  r  rm   r6  rï   r›   r_  rž   r2  r   r!  Útemp_dirr0  Úadapterr-  r.  r  r/  s   &&                 @@@@r   Ú_handle_save_commandÚ0GatewaySessionCommandsMixin._handle_save_commandÌ  sj  ûé € ã÷	sõ 	sð ×&Ñ&Ó(×.Ñ.Ó0ˆÜ�e“×LÐL  r¥§¡Ó!2Ð6LÑ!LˆßØ˜#˜2�JˆEßØÐð	*Ù'¨¨a­Ó1ˆCð —‘ˆØ"×6Ñ6×LÑLÈVÓT×TˆØ"×-Ñ-ˆ
Ø××ÐÜÐ<Ó=Ð=ä" 5›z¨Aœ~�5˜–8Ñ3HÈÐUXÓ3YˆÜ—7‘7×#Ñ# HÓ-×WÐWÑ1FÀzÐSVÓ1WˆÝ;ð	ä '× 1Ò 1Ð2D×FVÑFV×FZÑFZÐ\fÐhkÓ l×lˆK÷ ÜÐ/¸JÔGÐGßÝHÙ-¨kÓ:ˆKØ×#Ñ#¨>Ð#Ó:ˆÜ—G‘G—L‘L ¨8Ó4ˆ	ð	#÷&ó &ô
 ×#Ò#Ð$5Ó6×6Ð6à×0Ñ0°Ó8ˆGßÜÐ2Ó3ô ×$Ò$¤Y×/Õ/Ü—	’	˜)Ô$Ü—’˜Ô"÷ 0Ð/ð ×'Ñ'°·±È)Ü01Ð2HÐS[Ô0\Ðhpð (ó r÷ rð räÐ,Ó-ô
 ×$Ò$¤Y×/Õ/Ü—	’	˜)Ô$Ü—’˜Ô"÷ 0Ð/øôW ô 	*Ø�S˜˜Z˜LÐ)Õ)ûð	*úò Uò møØ)ô 	Ü�q“6�Mûð	úò  7÷ 0×/úñr÷ 0×/ûô	 ô 	5Ü�N‰NÐ5°qÔ9ÜÐ*°!Ô4Ô4ä×$Ò$¤Y×/Õ/Ü—	’	˜)Ô$Ü—’˜Ô"÷ 0×/×/Ð/þð		5ûô ×$Ò$¤Y×/Õ/Ü—	’	˜)Ô$Ü—’˜Ô"÷ 0×/×/Ð/ÿs‚  †A%R
Á,R
Á9R
Á<L Â*R
Â5L&Â6!R
ÃAR
Ä+R
Ä</L, Å+L)Å,L, Å0R
Å8R
ÆA R
Ç%M6 Ç3MÇ4M6 È
M6 È"R
È=-MÉ*	R
É3-M6 Ê M!Ê!M6 Ê/"R
Ë-M#Ë>	R
ÌL#ÌLÌL#ÌR
ÌL#Ì#R
Ì)L, Ì,MÌ3
MÌ=MÌ>R
ÍMÍR
ÍM6 ÍMÍR
Í!M6 Í#M3Í.R
Í6PÎ"PÎ#PÎ$P Î("R
Ï
-P Ï7	R
Ð PÐR
ÐPÐP Ð#RÐ>-Q4	Ñ+	RÑ4RÑ?RÒR
c               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   	  s   € ÷ ):ñ ):°ð ):À#ñ ):r   c              ƒ  óˆ  "  € VP                   pV P                  P                  V4      G Rj  x€L
 pVP                  pV P                  '       g   V P                  4       # V P                  P                  V4      G Rj  x€L
 f¥   \        P                  ! \        4      ;_uu_ 4        V P                  P                  TVP                  '       d   VP                  P                  MRVP                  VP                  VP                  VP                   R7      G Rj  x€L
  RRR4       VP#                  4       P%                  4       pV'       gF   V P                  P                  V4      G Rj  x€L
 pV'       d   \'        RWFR7      # \'        RVR7      #  ^ RIHp VP-                  V4      pT'       g   \'        R4      #  T P                  P1                  YH4      G Rj  x€L
 '       g   \'        R4      #   \2        P4                  ! T P6                  Y$T4      G Rj  x€L
  \'        RTR7      #  EL  EL² EL  + '       g   i     EL; i LÜ  \.         d   p	\'        R	T	R
7      u Rp	?	# Rp	?	ii ; i L’  \.         d   p	\'        R	T	R
7      u Rp	?	# Rp	?	ii ; i L|  \         d    \8        P;                  RRR7        Lži ; i5i)uB   Handle /title command â€” set or show the current session's title.NÚunknown)rž   r›   r¤   r  r  r  z gateway.title.current_with_title)rž   ré   zgateway.title.current_no_titler¹  ræ   zgateway.shared.warn_passthroughr3   zgateway.title.empty_after_cleanzgateway.title.not_foundz+Failed to rename Telegram topic from /titleTr¹   zgateway.title.set_torè   )r›   rÈ   rÌ   rž   rÏ   r  r  r]   r^   r_   Úcreate_sessionrŸ   r¥   r¤   r  r  r  rÎ   r‚   r   rê   rç   rë   rì   rí   r�   rÊ   Ú%_schedule_telegram_topic_title_renamer“   rÓ   )
r•   r²   r›   r_  rž   rä   ré   rç   rî   rï   s
   &&        r   Ú_handle_title_commandÚ1GatewaySessionCommandsMixin._handle_title_command	  sT  é € à—‘ˆØ"×6Ñ6×LÑLÈVÓT×TˆØ"×-Ñ-ˆ
Ø××ÐØ×5Ñ5Ó7Ð7ð
 ×!Ñ!×3Ñ3°JÓ?×?ÒGÜ×$Ò$¤Y×/Õ/Ø×&Ñ&×5Ñ5Ø)Ø4:·O·O°O˜6Ÿ?™?×0Ò0ÈØ"ŸN™N°F·N±NÈf×N^ÑN^Ø$×.Ñ.ð	 6ó 0÷ 0ð 0÷ 0ð ×*Ñ*Ó,×2Ñ2Ó4ˆ	ßØ×*Ñ*×<Ñ<¸ZÓH×HˆEßÜÐ;È
Ô`Ð`ÜÐ5À*ÔMÐMð	AÝ.Ø!×0Ñ0°Ó;ˆI÷ ÜÐ6Ó7Ð7ð	AØ×)Ñ)×;Ñ;¸JÓR×RÖRÜÐ2Ó3Ð3ð Sð
	WÜ×#Ò# D×$NÑ$NÐPVÐdmÓn×nÐnô Ð'¨yÔ9Ð9òM Uò @ò0÷ 0×/Ð/úñ Iøô ô 	AÜÐ6¸aÔ@Õ@ûð	Aúñ
 Søäô 	AÜÐ6¸aÔ@Õ@ûð	Aúñ oøÜô 	WÜ�L‰LÐFÐQUˆLÖVð	Wüs  ‚+K­H-®!KÁ.KÁ>H0Á?(KÂ'A5H6ÄH3ÄH6Ä!-KÅKÅ-I
Å.KÅ:KÆI Æ,KÆ4KÇ I3 ÇI1Ç	I3 Ç)
I3 Ç3KÇ6%J ÈJÈJ È KÈ0KÈ3H6È6I	É
KÉI.ÉI)É#I.É$KÉ)I.É.KÉ1I3 É3JÉ>JÊ
JÊKÊJÊKÊJ Ê"J?Ê<KÊ>J?Ê?Kc               ó$   € V ^8„  d   QhRRRRRR/# )r   rˆ   r   r;  rB   r   ú
list[dict]r   )r   s   "r   r   r‰   6  s'   € ÷ 	[ñ 	[¸sð 	[Ètð 	[ÐXbñ 	[r   c              ƒ  óÖ  "  € T;'       d    V P                  V4      pV P                  P                  VP                  '       d   VP                  P                  MRV'       d   RMT^
RR7      G Rj  x€L
 pV Uu. uF  qfP                  R4      '       g   K  VNK  	  upR,          pV Uu. uF&  q`P                  WV4      G Rj  x€L
 '       g   K$  VNK(  	  up#  Lhu upi  Lu upi 5i)zMTitled sessions visible to the caller (origin-scoped unless admin ``--all``).NT)r›   rˆ   ÚlimitÚorder_by_last_activeré   ºNé
   N)r$  rÏ   Úlist_sessions_richrŸ   r¥   rN   r@  )r•   r›   rˆ   r;  ÚwidenÚsessionsÚsÚtitleds   &&&&    r   Ú_list_titled_sessionsÚ1GatewaySessionCommandsMixin._list_titled_sessions6  sÄ   é € à×BÐB˜d×:Ñ:¸6ÓBˆð ×)Ñ)×<Ñ<Ø,2¯O¯O¨O�6—?‘?×(Ò(Àß %™¨;¸bÐW[ð =ó ]÷ ]ˆñ &Ó8™X˜¯©¨w¯—!�!™XÑ8¸Õ=ˆÙ!ÓZ™6�a×+CÑ+CÀFÈyÓ+Y×%YÓ%Y—�™6ÑZÐZñ	]ùò 9Ù%YùÒZùs`   ‚AC)ÁC)Á$C)Á2CÁ3C)Á;CÂCÂC)Â,C$ÃC"
ÃC$ÃC$ÃC)ÃC)Ã"C$Ã$C)c               ó$   € V ^8„  d   QhRRRRRR/# )r   rˆ   r   r   r;  rB   r   )r   s   "r   r   r‰   A  s"   € ÷ ñ Àð È3ð Ð[_ñ r   c              ƒ  óN  "  € VP                  4       '       d†    V P                  WV4      G Rj  x€L
 p\        T4      pT^8  g   T\        T4      8”  d   \        RTR7      # YW^,
          ,          pTP                  R4      TP                  R4      ;'       g    Tr9MWV P                  P                  V4      G Rj  x€L
 p
V
'       d
   V
R,          M"V P                  P                  V4      G Rj  x€L
 p	V	'       g   \        R	VR
7      #  V P                  P                  V	4      G Rj  x€L
 p	W“3#  EL  \         d.   p\        P	                  RT4       \        RTR7      u Rp?# Rp?ii ; i L² L€ LI  \         d#   p\        P	                  RY–4        Rp?Y“3# Rp?ii ; i5i)zW``(target_id, name)`` for a numbered choice, session id or title; else the error reply.Nz5Failed to list titled sessions for numeric resume: %súgateway.resume.list_failedr3   zgateway.resume.out_of_range)Úindexr=  ré   zgateway.resume.not_found©r   z0Failed to resolve resume continuation for %s: %s)ÚisdigitrY  r_   r“   rÓ   r   rm  rƒ   rN   rÏ   r7  Úresolve_session_by_titleÚresolve_resume_session_id)r•   r›   rˆ   r   r;  rX  rï   r^  Útargetr3  Úsessions   &&&&&      r   Ú_resolve_resume_targetÚ2GatewaySessionCommandsMixin._resolve_resume_targetA  sg  é € à�<‰<�>Š>ð@Ø#×9Ñ9¸&ÈyÓY×Y�ô ˜“IˆEØ�qŒy˜E¤C¨£KÔ/ÜÐ6¸eÔDÐDØ A�IÕ&ˆFØ$Ÿj™j¨Ó.°·
±
¸7Ó0C×0KÐ0KÀt‘tà ×,Ñ,×8Ñ8¸Ó>×>ˆGß)0˜ ž¸D×<LÑ<L×<eÑ<eÐfjÓ<k×6kˆIßÜÐ/°dÔ;Ð;ð	[à"×.Ñ.×HÑHÈÓS×SˆIð ˆÐò) ZøÜô @Ü—‘ÐTÐVWÔXÜÐ5¸QÔ?Õ?ûð@úñ ?Ù6kñ TøÜô 	[Ü�L‰LÐKÈY×ZÐZØˆÐûð	[üs°   ‚F%šD4 ¯D1°D4 ´A%F%Â"F%Â<E/Â=F%Ã	'F%Ã0E1Ã1F%Ã=F%ÄE5 Ä)E3Ä*E5 Ä.F%Ä1D4 Ä4E,Ä?"E'Å!E,Å"F%Å'E,Å,F%Å1F%Å3E5 Å5F"Æ FÆF%ÆF"Æ"F%c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r3  r   r   r;  rB   Úallow_cross_roomr   zOptional[str]r   )r   s   "r   r   r‰   [  s9   € ÷ @ñ @À3ð @Ècð @Ð^bð @Ø<@ð@ØERñ@r   c              ƒ  óž  "  € VP                   \        P                  8X  dp   V P                  V4      pV P	                  W4      '       g	   V'       d   R# Vf   \        RVR7      # \        RTVP                  ;'       g    VP                  R7      # T P                  YT;'       g    TR7      G Rj  x€L
 '       d   R# \        RVR7      #  L5i)uœ   IDOR guard: a session id/title is a routing handle, not authority â€” bind /resume to the
caller's own room (Matrix) or platform/user/chat (other adapters).Nz'gateway.resume.matrix_blocked_no_originr_  z(gateway.resume.matrix_blocked_other_room)r   Úroomr>  z gateway.resume.blocked_not_owner)	rŸ   r   r  rÿ   r  r   Ú	chat_namer  r8  )r•   r›   r3  r   r;  rh  Útarget_origins   &&&&&& r   Ú_resume_access_denied_replyÚ7GatewaySessionCommandsMixin._resume_access_denied_reply[  s·   é € ð �?‰?œhŸo™oÔ-Ø ×?Ñ?À	ÓJˆMØ×%Ñ% f×<Ò<×@PÙØÒ$ÜÐBÈÔNÐNÜÐ?ÀdØ'×1Ñ1×JÐJ°]×5JÑ5JôLð Là×,Ñ,¨VÐPY×PmÐPmÐ]mÐ,Óo×oÖoÙÜÐ3¸$Ô?Ð?ñ pùs*   ‚ACÁ,CÁ?&CÂ&CÂ1CÂ2	CÂ<Cc               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   k  s"   € ÷ ANñ AN°,ð ANÀ3ñ ANr   c              ƒ  óþ  "  € V P                   '       g   V P                  4       # \        P                  ! V P                  VP
                  4      G Rj  x€L
 pV P                  V4      p \        P                  ! VP                  4       P                  4       4      pRT9   pRT9   p\        T4      pT'       g.    T P                  Y#T4      G Rj  x€L
 p	T P                  Y)T4      # T P'                  Y#Y†4      G Rj  x€L
 p\)        T\*        4      '       d   T# Tw  rÈT P-                  Y,Y†T4      G Rj  x€L
 pTe   T# T P.                  P1                  T4      G Rj  x€L
 pTP2                  T8X  d   \        RTR	7      # T P5                  T4       T P.                  P7                  Y<R
R7      G Rj  x€L
 pT'       g   \        R4      # T P9                  TRR7       T P.                  P;                  TR4      G Rj  x€L
  T P=                  T4       T P                   P?                  T4      G Rj  x€L
 ;'       g    Tp T P.                  PA                  T4      G Rj  x€L
 pT'       d4   \G        T Uu. uF  pTPI                  R4      R8X  g   K  TNK  	  up4      M^ pTPJ                  \L        PN                  8X  dV   T'       dN   T'       d   \        T^8X  d   RMRTR7      MRp\        RTTPP                  ;'       g    TPR                  TR7      # T'       g   \        RTR7      # T^8X  d   \        RTTR7      # \        RTTR7      #  ELö  \         d   p\        RTR7      u Rp?# Rp?ii ; i EL¢  \          d.   p
\"        P%                  RT
4       \        RT
R7      u Rp
?
# Rp
?
ii ; i EL´ EL€ ELZ EL	 ELÂ EL‘ ELf  \B         d'    \        RTR7      R,           \E        4       ,           u # i ; iu upi 5i)u@   Handle /resume command â€” list or switch to a previous session.Núgateway.resume.parse_errorr3   rq   rr   z"Failed to list titled sessions: %sr]  zgateway.resume.already_onr_  F)Úpreserve_prompt_pinzgateway.resume.switch_failedÚresumerµ   zgateway.resume.resumed_no_countrè   rI   rG   rJ   zgateway.resume.msg_count_onezgateway.resume.msg_count_other)r}  r    z(gateway.resume.matrix_cross_room_success)ré   rj  Úmsg_partzgateway.resume.resumed_one)ré   r}  zgateway.resume.resumed_many)*rÏ   r  r�   rÊ   Ú!_normalize_source_for_session_keyr›   rÀ   Úshlexr€  rÎ   r‚   rì   r   r„   rY  Ú_resume_listing_replyr_   r“   rÓ   re  r6  r   rm  rÈ   rÌ   rž   rÂ   Úswitch_sessionrÆ   Úset_model_overriderÅ   r  rW  r   r   rƒ   rN   rŸ   r   r  rk  r  )r•   r²   r›   rˆ   rm   rf  r;  rh  r   rX  rï   Úresolvedr3  ÚdeniedÚcurrent_entryr×   ré   rP   rR   Ú	msg_countrt  s   &&                   r   Ú_handle_resume_commandÚ2GatewaySessionCommandsMixin._handle_resume_commandk  sš  é € à××ÐØ×5Ñ5Ó7Ð7Ü×(Ò(¨×)OÑ)OÐQV×Q]ÑQ]Ó^×^ˆØ×2Ñ2°6Ó:ˆð	>Ü—K’K × 6Ñ 6Ó 8× >Ñ >Ó @ÓAˆEð ˜uÑ$ˆ	Ø)¨UÑ2ÐÜ! %Ó(ˆßð@Ø#×9Ñ9¸&ÈyÓY×Y�Ø×1Ñ1°&À)ÓLÐLð
 ×4Ñ4°VÈ$ÓZ×ZˆÜ�h¤×$Ò$ØˆOØ"‰ˆ	Ø×7Ñ7¸È4Ð\lÓm×mˆØÒØˆMØ"×6Ñ6×LÑLÈVÓT×TˆØ×#Ñ# yÔ0ÜÐ0°tÔ<Ð<Ø×)Ñ)¨+Ô6Ø×2Ñ2×AÑAØ¸ð Bó 
÷ 
ˆ	÷ ÜÐ3Ó4Ð4ð
 	×&Ñ& {¸8Ð&ÔDð ×&Ñ&×9Ñ9¸+ÀtÓL×LÐLð 	× Ñ  Ô-Ø×&Ñ&×8Ñ8¸ÓC×C×KÐKÀtˆð	cØ ×4Ñ4×DÑDÀYÓO×OˆG÷ MT”C¡GÓG¡G˜q¨q¯u©u°V«}ÀÑ/FŸ˜¡GÑGÔHÐYZˆ	Ø�?‰?œhŸo™oÔ-×2Bç-6ô ¸9È¼>Ñ7ÐOoØ(õ*Ø<>ð äÐ?ÀuØ ×*Ñ*×<Ð<¨f¯n©nÀxôQð QçÜÐ6¸eÔDÐDØ˜Œ>ÜÐ1¸ÀiÔPÐPÜÐ.°eÀ9ÔMÐMò{ _øô ô 	>ÜÐ1¸Ô=Õ=ûð	>úò Zøäô @Ü—‘ÐAÀ1ÔEÜÐ5¸QÔ?Õ?ûð@úò [ò nò Uò
ò 	Mò DâOøÜ"ô 	cäÐ6¸eÔDÀtÕKÔN`ÓNbÕbÒbð	cüò Hùs]  ‚AO=ÁM	ÁO=Á*2M ÂO=Â:M4 ÃM1ÃM4 Ã%O=Ã;N/Ã<6O=Ä2N2Ä3(O=ÅN5ÅAO=Æ/N8Æ0O=Æ<=O=Ç9N;Ç:3O=È-N>È.
O=È9O=È=O ÉOÉO É O=É(	O=É1O8ÊO8Ê/O=ËO=Ë1O=Ë>O=Ì1O=ÍM.ÍM)Í#M.Í$O=Í)M.Í.O=Í1M4 Í4N,Í?"N'Î!N,Î"O=Î'N,Î,O=Î2O=Î5O=Î8O=Î;O=Î>O=ÏO Ï.O5Ï2O=Ï4O5Ï5O=c               ó$   € V ^8„  d   QhRRRRRR/# )r   rX  rN  r;  rB   r   r   r   )r   s   "r   r   r‰   ®  s"   € ÷  ñ  °Jð  È4ð  ÐTWñ  r   c           
     óš  € RpV'       d#   V P                  V4      '       g   \        R4      pV'       gO   VP                  \        P                  8X  d   V'       g   \        R4      # \        R4      pV'       d   V RV 2# T# \        R4      .p\        VR,          ^R7       Fâ  w  rxVR	,          p	VP                  \        P                  8X  di   V'       da   T P                  \        VP                  R
4      ;'       g    R4      4      p
V
'       d&   T	 RV
P                  ;'       g    V
P                   2p	VP                  RR4      R,          pV'       d   \        RVR7      MRpVP                  \        RWyVR7      4       Kä  	  V'       d   VP                  V4       VP                  \        R4      4       RP                  V4      # )z}Numbered /resume list; a non-admin ``--all`` falls back to same-origin scoping and says so
(sibling of the /sessions notice).Nz!gateway.resume.all_requires_adminz'gateway.resume.matrix_no_named_sessionsz gateway.resume.no_named_sessionsrI   zgateway.resume.list_headerrR  )Ústartré   r=  r    u    â€” r~  :Né(   Nz"gateway.resume.list_preview_suffix)r~  z!gateway.resume.list_item_numbered)r^  ré   Úpreview_partz#gateway.resume.list_footer_numbered)r$  r   rŸ   r   r  Ú	enumeraterÿ   r   rN   rk  r  r7   rO   )r•   r›   rX  r;  Ú
scope_noteÚbaser;   ÚidxrW  ré   rõ   r~  r„  s   &&&&         r   rw  Ú1GatewaySessionCommandsMixin._resume_listing_reply®  sg  € ð ˆ
ß˜T×9Ñ9¸&×AÒAÜÐ>Ó?ˆJßØ�‰¤(§/¡/Ô1¿)ÜÐBÓCÐCÜÐ7Ó8ˆDß.8�d�V˜2˜j˜\Ð*ÐB¸dÐBÜÐ/Ó0Ð1ˆÜ  s¥°1×5‰FˆCØ�g•JˆEØ�‰¤(§/¡/Ô1·iØ×<Ñ<¼SÀÇÁÀtÃ×ARÐARÐPRÓ=SÓT�ßØ$˜g U¨6×+;Ñ+;×+MÐ+M¸v¿~¹~Ð*NÐO�EØ—e‘e˜I rÓ*¨3Õ/ˆGßW^œ1ÐAÈ7ÕSÐdfˆLØ�L‰LœÐ>ÀcÐeqÔrÖsñ 6÷ Ø�L‰L˜Ô$Ø�‰”QÐ<Ó=Ô>Ø�y‰y˜ÓÐr   c               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   È  s   € ÷ )Cñ )C°Lð )CÀSñ )Cr   c              ƒ  ó
  "  € V P                   '       g   V P                  4       # ^ RIHpHpHp  V! VP                  4       P                  4       4      w  rVrxTR8X  d   \        R4      # T'       d3   T P                  \        P                  ! TRT 2R7      4      G Rj  x€L
 # \        P                  ! T P                  TP                   4      G Rj  x€L
 p
T P#                  T
4      pT;'       d    T P%                  T
4      pRpT'       d   T'       g   \        R	4      pT P&                  P)                  T
4      G Rj  x€L
 p\        P                  ! T\+        T P                   R
T P                   4      T
P,                  '       d   T
P,                  P.                  MRT'       d   RMTTP0                  RYÆTT'       d   ^2M^
R.R7      G Rj  x€L
 pT'       g6   T Uu. uF)  pT P3                  T
TRR7      G Rj  x€L
 '       g   K'  TNK+  	  ppTR,          pT'       d   \        RTR7      pM\        T'       d   RMR4      pT! YüTTR7      #   \         d   p	\        RT	R7      u Rp	?	# Rp	?	ii ; i ELÓ EL£ EL: L® Lƒu upi 5i)u>   Handle /sessions â€” list previous sessions for gateway chats.)Úformat_gateway_session_listingÚparse_session_listing_argsÚquery_session_listingrq  r3   Nr    zgateway.sessions.usage_searchz/resume )rR  z#gateway.sessions.all_requires_adminrÜ  TrÁ  )	r›   rˆ   Úcurrent_session_idÚinclude_current_sessionÚinclude_all_sourcesÚinclude_unnamedÚsearch_queryrP  Úexclude_sourcesF)r;  rR  zgateway.sessions.title_matching)Úqueryzgateway.sessions.title_allzgateway.sessions.title_named)Úinclude_sourceré   Únotice)rÏ   r  Úhermes_cli.session_listingrŒ  r�  rŽ  rÎ   r‚   rì   r   r~  ÚdataclassesÚreplacer�   rÊ   ru  r›   rÀ   r$  rÈ   rÌ   r!   rŸ   r¥   rž   r@  )r•   r²   rŒ  r�  rŽ  Úinclude_allr’  rc  r“  rf  r›   rˆ   Úcross_originÚscope_noticer|  Úrowsrj   ré   s   &&                r   Ú_handle_sessions_commandÚ4GatewaySessionCommandsMixin._handle_sessions_commandÈ  s5  é € à××ÐØ×5Ñ5Ó7Ð7÷	_ñ 	_ð	>ÙA[Ø×&Ñ&Ó(×.Ñ.Ó0óB2Ñ>ˆK¨&ð ˜2ÔÜÐ4Ó5Ð5ßØ×4Ñ4´[×5HÒ5HÈÐW_Ð`fÐ_gÐUhÔ5iÓj×jÐjÜ×(Ò(¨×)OÑ)OÐQV×Q]ÑQ]Ó^×^ˆØ×2Ñ2°6Ó:ˆð #×KÐK t×'CÑ'CÀFÓ'KˆØˆßŸ|ÜÐBÓCˆLØ"×6Ñ6×LÑLÈVÓT×TˆÜ×&Ò&Ø!¤7¨4×+;Ñ+;¸UÀD×DTÑDTÓ#UØ,2¯O¯O¨O�6—?‘?×(Ò(Àß ,™°+Ø,×7Ñ7ÐQUØ ,Ø%ç$‘"¨"¸v¸hôH÷ Hˆ÷ Ù#'Óh¡4˜C°×1IÑ1IÈ&ÐRUÐafÐ1IÓ1g×+gÓ+g—C�C¡4ˆDÐhØ�C�yˆßÜÐ7¸|ÔL‰Eä·oÑ2ÐKiÓjˆEÙ-¨dÐW\Ø5AôCð 	Cøô? ô 	>ÜÐ1¸Ô=Õ=ûð	>úò
 kÚ^ò UñHñ ,hùÒhùsË   ‚-J°'I ÁJÁ1-JÂI1Â2JÃI4ÃJÃ0JÄJÄ)JÄ=I7Ä>A%JÆ$'JÇI:ÇJÇJÇI>Ç8I<
Ç9I>ÈI>ÈJÈ.JÉI.ÉI)É#I.É$JÉ)I.É.JÉ4JÉ7JÉ:JÉ<I>É>Jc               ó    € V ^8„  d   QhRRRR/# rC  r   )r   s   "r   r   r‰   õ  s"   € ÷ ZSñ ZS°,ð ZSÀ3ñ ZSr   c              ƒ  ó>  "  € ^ RI p^ RIp^ RIHp V P                  '       g   V P	                  4       # VP
                  pV P                  V4      pV P                  P                  V4      G Rj  x€L
 p V P                  P                  VP                  4      G Rj  x€L
 pT'       g   \        R4      # TP                  4       P                  R4       RTP!                  4       P"                  R,           2p	\%        TP'                  4       4      w  r«T'       g[   T P                  P)                  TP                  4      G Rj  x€L
 pT P                  P+                  T;'       g    R4      G Rj  x€L
 pTP                  pT
'       d   RMT P-                  Y[4      G Rj  x€L
 pTRJ pT'       d   TpT'       d   TMT P                  T4      pRp\.        P0                  ! \2        4      ;_uu_ 4        T'       d   TP4                  ;'       g    TMTpTP7                  TP9                  4       4      pRRR4        T P                  P;                  T4      G Rj  x€L
 pT P                  P=                  T	TP>                  '       d   TP>                  P@                  MR\C        T PD                  \F        4      '       d6   T PD                  PI                  R	/ 4      ;'       g    / PI                  R
4      MRRT/YÞPJ                  TTPL                  TPN                  TPP                  TTPR                  T;'       g    / PI                  R4      ;'       g    RR7      G Rj  x€L
  \.        P0                  ! \2        4      ;_uu_ 4        T P                  PY                  Y˜ Uu. uF  p\[        T4      NK  	  upRR7      G Rj  x€L
  RRR4       \.        P0                  ! \2        4      ;_uu_ 4        T P                  P]                  Y›4      G Rj  x€L
  RRR4       T'       g$   T P                  P                  T4      G Rj  x€L
  T P                  P_                  TT	4      G Rj  x€L
 pT'       g   \        R4      # T Pa                  T4       T Pc                  T4       \e        T Uu. uF  pTPI                  R4      R8X  g   K  TNK  	  up4      pT'       dS   T^8X  d   RMRp\        TTTYÙR7      pT
'       g/   TP>                  \f        9   d   TR\        R4      ,           ,          pT# T^8X  d   RMRp\        TTTYÙ\i        TP>                  TPP                  4      R7      #  ELò ELÇ  \         d    \        4       u # i ; i EL? EL ELé  + '       g   i     ELc; i ELG ELG  \2         d.   p\T        PW                  RT4       \        RTR7      u Rp?# Rp?ii ; iu upi  EL)  + '       g   i     EL0; i ELò  + '       g   i     ELù; i ELÖ ELµu upi 5i)uU  Handle /branch [--here] [name] â€” fork the current session into an independent copy.

Thread-capable platforms (Discord/Telegram/Slack/Matrix) open a NEW sibling thread bound
to the clone and leave this chat on the original session; ``--here`` (and every platform
without threads) switches the current chat onto the clone instead (#66023).
N)Údatetimezgateway.branch.no_conversationz%Y%m%d_%H%M%Sre  :Né   NÚbranchÚgatewayr6   r•  Ú_branched_fromÚsystem_prompt)rž   r›   r6   Úmodel_configr·   r¤   rˆ   r  r  r  Úorigin_jsonÚdisplay_namer¨  z#Failed to create branch session: %szgateway.branch.create_failedr3   iô  )Ú
chunk_rowszgateway.branch.switch_failedrG   rJ   zgateway.branch.branched_onezgateway.branch.branched_many)ré   r}  ÚparentÚnewrI   zgateway.branch.thread_fallbackz"gateway.branch.branched_thread_onez#gateway.branch.branched_thread_many)ré   r}  r­  r®  Úthread)5ÚjsonÚuuidr£  rÏ   r  r›   rÀ   rÈ   rÌ   rW  rž   r   r   r   ÚnowÚstrftimeÚuuid4Úhexr   rÎ   r  Úget_next_title_in_lineageÚ_branch_open_threadr]   r^   r_   rõ   ÚdumpsÚto_dictr7  rI  rŸ   r¥   r6  r  r&   rN   r¤   r  r  r  r«  r“   r4   Úappend_messages_batchrk   rí   rx  Ú&_clear_session_boundary_security_staterÅ   rƒ   r   r   )r•   r²   Ú_jsonÚ_uuidÚ_dtr›   rˆ   r|  rP   r¢   Ú	stay_hereÚbranch_titleÚcurrent_titler·   Údest_sourceÚin_placeÚdest_keyÚ_branch_origin_jsonÚ_originr­  rï   rd   r×   rR   r}  ÚkeyÚreplys   &&                         r   Ú_handle_branch_commandÚ2GatewaySessionCommandsMixin._handle_branch_commandõ  sÿ  é € ó 	ÛÝ,à××ÐØ×5Ñ5Ó7Ð7Ø—‘ˆØ×2Ñ2°6Ó:ˆØ"×6Ñ6×LÑLÈVÓT×Tˆð	(Ø ×4Ñ4×DÑDÀ]×E]ÑE]Ó^×^ˆG÷ ÜÐ5Ó6Ð6ØŸG™G›I×.Ñ.¨Ó?Ð@ÀÀ%Ç+Á+Ã-×BSÑBSÐTVÕBWÐAXÐYˆÜ"3°E×4JÑ4JÓ4LÓ"MÑˆ	ßØ"&×"2Ñ"2×"DÑ"DÀ]×E]ÑE]Ó"^×^ˆMØ!%×!1Ñ!1×!KÑ!KÈM×LeÐLeÐ]eÓ!f×fˆLØ)×4Ñ4Ð÷ (‘d°4×3KÑ3KÈFÓ3a×-aˆØ $Ð&ˆßØ ˆKß"*‘;°×0LÑ0LÈ[Ó0Yˆð #ÐÜ× Ò ¤×+Õ+ß:B�}×+Ñ+×5Ð5¨vøÈˆGØ"'§+¡+¨g¯o©oÓ.?Ó"@Ð÷ ,ð	>Ø×+Ñ+×7Ñ7Ð8IÓJ×JˆFØ×"Ñ"×1Ñ1Ø)Ø06··°�v—‘×,Ò,ÀYÜMWÐX\×XcÑXcÔei×MjÒMj�t—{‘{—‘ w°Ó3×9Ð9°r×>Ñ>¸yÔIÐptØ.Ð0AÐBØ"3×=PÑ=PØ$¨k×.AÑ.AÈ[×MbÑMbØ%×/Ñ/Ð=PØ*×7Ñ7ÈÏÈÐRT×GYÑGYÐZiÓGj×GrÐGrÐnrð 2ó t÷ tð tô × Ò ¤×+Õ+ð ×"Ñ"×8Ñ8Ø¸WÓ E¹W°c¤¨SÖ!1¹WÑ EÐRUð 9ó W÷ Wð W÷	 ,ô × Ò ¤×+Õ+Ø×"Ñ"×4Ñ4°^ÓR×RÐR÷ ,çð ×*Ñ*×@Ñ@ÀÓM×MÐMØ×2Ñ2×AÑAÀ(ÈNÓ[×[ˆ	ßÜÐ3Ó4Ð4Ø×3Ñ3°HÔ=Ø× Ñ  Ô*Ü¡GÓG¡G˜q¨q¯u©u°V«}ÀÑ/FŸ˜¡GÑGÓHˆ	ßØ3<À´>Ñ/ÐGeˆCÜ�c °YÐGXÔmˆEß §¡Ô4KÔ!KØ˜¤Ð"BÓ CÕCÕC�ØˆLØ6?À1´nÑ2ÐJoˆÜ�˜L°	ÐBSÜ)¨&¯/©/¸;×;PÑ;PÓQôSð 	SòU Uâ^øÜ"ô 	(Ü%Ó'Ò'ð	(úò _Úfò .b÷ ,×+Ð+úò Kòtøô ô 	>Ü�L‰LÐ>ÀÔBÜÐ3¸1Ô=Õ=ûð	>üò !FòW÷	 ,×+Ð+úò S÷ ,×+Ð+úò
 NÚ[ùò
 HùsÌ  ‚A,XÁ.U Á/XÁ4(U& ÂU#ÂU& Â!XÂ)BXÅVÅ!XÅ%
XÅ/VÅ0XÆXÆVÆXÆ/	XÆ97XÇ0V
È$V
È0XÈ9V$ ÉVÉ+V$ ÊAV$ ËAV$ Ì6V$ ÍV$ ÍV!ÍV$ Í"XÎW'ÎWÎ/W'Î;W$Î<W'Ï *XÏ*W>Ð	W;Ð
W>ÐXÐXÐ<XÐ=#XÑ XÑ!XÑ-6XÒ#XÓ XÓXÓBXÕ#U& Õ&U>Õ;XÕ=U>Õ>XÖXÖXÖ
V	Ö	XÖV$ Ö!V$ Ö$WÖ/"W×W×X×W×X×W'×'W8	×2	X×;W>×>X	Ø	
XØXØXc               ó$   € V ^8„  d   QhRRRRRR/# )r   r›   r   ré   r   r   rò   r   )r   s   "r   r   r‰   Q  s'   € ÷ fñ f°ð fÀcð fÐNeñ fr   c              ƒ  óÂ  "  € \        V4      pV'       d   V P                  V4      MRpVf   R#  VP                  W24      G Rj  x€L
 pT'       g   R# \        TRR4      pTe#   TP                  \        T4      4      G Rj  x€L
  \        Y\        T4      TR7      #  LX  \         d1    \        P                  RTP                  P                  RR7        R# i ; i L[5i)zŒOpen the sibling thread a plain ``/branch`` clones into; the destination source, or
None when this chat cannot host one (in-place fallback).Nz>Branch: create_handoff_thread failed on %s; branching in placeTr¹   Ú_threads)Ú	parent_idr  ré   )r   r>  Úcreate_handoff_threadr_   r“   r”   rŸ   r¥   r!   Ú
mark_asyncr   r   )r•   r›   ré   rÎ  rC  r  Úthreadss   &&&    r   r·  Ú/GatewaySessionCommandsMixin._branch_open_threadQ  sÎ   é € ô )¨Ó0ˆ	ß8A�$×,Ñ,¨VÔ4ÀtˆØŠ?Ùð	Ø%×;Ñ;¸IÓM×MˆI÷
 Ùä˜' :¨tÓ4ˆØÒØ×$Ñ$¤S¨£^Ó4×4Ð4Ü! &ÌÈYËÐ_dÔeÐeñ NøÜô 	Ü�N‰NÐ[Ø!Ÿ?™?×0Ñ0¸4ð ô Aâð	úñ 5ùsL   ‚-C°B ÁBÁB Á	CÁ0CÂCÂCÂB Â7CÃCÃCÃCr   N)F)é   )r    )'Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r˜   r¯   rá   rÐ   rÿ   Ústaticmethodr  r  r  r$  r0  r8  r@  rh  r\  r„  r‹  rž  r‰  r¦  rÅ  rÈ  r  rD  rK  rY  re  rm  r~  rw  rŸ  rÉ  r·  Ú__static_attributes__r   r   r   r†   r†   s   sß   † ñ Bõ*õ,CõE4õNõ.	Mð ôQó ðQõ@õ8^õ
õ 7÷D=õ(Tõ1Q÷f\õAõ>Dõ6õ.9õ21dõf&õPg÷0A(õJ;#õz):õZ	[õõ4@õ ANõF õ4)CõZZS÷xfñ fr   r†   >   r    r÷  ÚdirectÚprivate)
rH   Ú
tool_callsÚtool_call_idÚfinish_reasonÚ	reasoningÚreasoning_contentÚreasoning_detailsÚcodex_reasoning_itemsÚcodex_message_itemsÚ	timestamp)1rØ  Ú
__future__r   r�   r]   r™  Úloggingr9  rv  Útypingr   r   Ú
agent.i18nr   Úagent.turn_contextr   Úgateway.configr   Úgateway.platforms.baser   Úgateway.platforms.eventr	   r
   Úgateway.sessionr   r   r   Úgateway.session_transcriptr   Ú$gateway.slash_commands_branch_threadr   r   r   r   r   Úgateway.slash_commands_statusr   Ú	getLoggerr“   r‘   r  rh   r#   r?   rV   rb   rk   r„   r†   r   r   r   Ú<module>ró     sœ   ðñõ #ã Û Û Û Û 	Û ß "å Ý :Ý #Ý 1ß =ß ZÑ ZÝ :÷õ õ =à	×	Ò	˜=Ó	)€ð  Ð â0€ð=Ð õ
-õ
õ0õ!õõ÷qfó qfr   