+
    jHàjVh  ã                   ó¶  a € R5 t&0 t R t^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHtHt ]P                  ! R4      tR]! RR	4       R
]! RR4       R]P"                  ! RR7       R2tRtR R ltR t]R 4       tR tR tRRRRRRRRRRR R/tR!R/R" ltR# tR$ R% ltR& R' ltR( R) ltR* R+ ltR,t / t!] ^ k R- R. lt"R/ R0 lt#R1 R2 lt$R6R3 R4 llt%R# )7zLRead-only session browsing, latest-descendant lookup and owner maintenance.
N)Úcontextmanager)ÚPath)ÚDictÚOptional)Ú_RESET_CHILD_SQLÚ_sql_json_extractzhermes_cli.web_servera«  
            WITH RECURSIVE descendants(id, parent_session_id, started_at) AS (
                SELECT id, parent_session_id, started_at FROM sessions WHERE id = ?
                UNION
                SELECT s.id, s.parent_session_id, s.started_at
                FROM sessions s
                JOIN descendants d ON s.parent_session_id = d.id
                -- Continuation edges only (same predicate as the session list's chain CTE): a subagent run,
                -- a /branch fork, a /new reset child or a tool-owned row is its own conversation, and resuming
                -- INTO one parks the user's chat in a row the sidebar never lists (#115092).
                WHERE zs.model_configz$._delegate_fromz IS NULL
                  AND z$._branched_fromz$ IS NULL
                  AND NOT (Ús)Úaz™)
                  AND COALESCE(s.source, '') != 'tool'
            )
            SELECT id, parent_session_id, started_at FROM descendants
            z~client_upgrade_required: this app is out of sync (different versions) with the Hermes backend; update the app to edit sessionsc                ó$   € V ^8„  d   QhR\         /# )é   Ú
session_id)Ústr)Úformats   "ÚC/home/ubuntu/.hermes/hermes-agent/hermes_cli/web_server_sessions.pyÚ__annotate__r   )   s   € ÷ )ñ )¬3ñ )ó    c           	     ój  € VP                  V 4      pV'       d   VP                  V4      '       g   R. 3# \        VRR4      pVeJ   R
pVP                  \        V34      P                  4        Uu. uF  p\        \        WE4      4      NK  	  ppMVP                  R^ RR7      p/ pV FZ  pVP                  R4      pVP                  R4      p	V'       g   K/  V	'       g   K9  VP                  V	. 4      P                  V4       K\  	  R p
TpV.pV0pVP                  V4      '       d‚   W{,           Uu. uF  qîP                  R4      V9  g   K  VNK  	  ppV'       g    W¼3# VP                  V
RR	7       V^ ,          R,          pVP                  V4       VP                  V4       K˜  W¼3# u upi u upi )zÎResolve a session id to the newest child leaf session.

/model may create child sessions; a dashboard refresh should continue the
newest child instead of reopening the old parent. Returns ``(leaf, path)``.
NÚ_connÚidÚparent_session_idi'  T)ÚlimitÚoffsetÚcompact_rowsc                 óp   €  \        V P                  R 4      ;'       g    ^ 4      #   \         d     R# i ; i)Ú
started_atç        )ÚfloatÚgetÚ	Exception)Úrows   &r   ÚstartedÚ+_session_latest_descendant.<locals>.startedA   s5   € ð	Ü˜Ÿ™ Ó.×3Ð3°!Ó4Ð4øÜô 	Úð	ús   ‚& Ÿ& ¦5´5)ÚkeyÚreverse)r   r   r   )Úresolve_session_idÚget_sessionÚgetattrÚexecuteÚ_DESCENDANTS_SQLÚfetchallÚdictÚzipÚlist_sessions_richr   Ú
setdefaultÚappendÚsortÚadd)r   ÚdbÚsidÚconnÚkeysr   ÚrowsÚchildrenÚridÚparentr    ÚcurrentÚpathÚseenÚrÚ
candidatess   &&              r   Ú_session_latest_descendantr>   )   s“  € ð ×
Ñ
 
Ó
+€Cß�b—n‘n S×)Ò)Ø�Rˆxˆä�2�w Ó%€DØÒØ8ˆØ04·±Ô=MÐPSÈvÓ0V×0_Ñ0_Ô0aÓbÑ0a¨””S˜“^Ö$Ñ0aˆÐbˆà×$Ñ$¨5¸ÈÐ$ÓNˆà€HÛˆØ�g‰g�d‹mˆØ—‘Ð,Ó-ˆß‰3—6‘6Ø×Ñ ¨Ó+×2Ñ2°3Ö7ñ	 òð €GØˆ5€DØˆ5€DØ
�,‰,�w×
Ò
Ø!)Ö!2ÓNÑ!2˜A·e±e¸D³kÈÑ6M—a�aÑ!2ˆ
ÐNßØð
 ˆ=Ðð	 	�‰˜G¨TˆÔ2Ø˜Q•- Õ%ˆØ�‰�GÔØ�‰�ÖØˆ=Ðùò9 cùò* Os   Á/F+Ä1F0ÅF0c           	     óZ  € ^ RI Hp ^ RIHp ^ RIHp ^ RIHp ^ RIH	p \        V P                  RR4      p\        V P                  RR4      pVe   VR	,          p	M‰Ve4   ^ R
IHp
 V
! RVP                  RVP                  RVP                   /4      p	MR\        V P"                  P                  RR4      '       g"   V! V 4      '       d   ^ R
IHp
 V
! RRRR/4      p	M
V! RRR7      h\        V P"                  P                  RR4      pV'       d   \%        V! V4      ^,          4      M\%        V! 4       4      P&                  p\)        0 Rm4      pVfR   \        V P"                  P                  RR4      e   V! RRR7      hRV! V	\+        VP-                  4       4      VR4      3# ^ RIHp \        V P"                  P                  RR4      pVe	   V! Wü4      MRpVfM   VP-                  4       \%        VP2                  P4                  4      P&                  P-                  4       8X  d   TpVf   V! RRR7      hTpVe#   VR,          VP6                  8w  d   V! RRR7      hVe9   ^ RIpW³! W›P6                  VRVP;                  4       P<                  ,           4      3# W³! W›P6                  VR4      3# ) zBUse the same principal and profile boundary for prepare and apply.©ÚHTTPException)Ú	Principal)Ú_has_valid_session_token©Ú_cron_profile_home©Ú_default_db_pathÚnative_http_principalNÚsessionÚsubject)Úauthenticated_subjectÚuser_idÚproviderÚissuerÚauth_requiredFzlegacy-token-ownerzsession-tokeni‘  ÚUnauthorized©Ústatus_codeÚdetailÚsession_authorityÚgateway_runneré÷  Úsession_authority_unavailableÚhttp)Úauthority_for_homeé“  Úprofile_mismatchÚ
profile_idúnative-http:>   úsession:readúsession:createúsession:controlúsession:operator)ÚfastapirA   Úgateway.session_contractrB   Úhermes_cli.web_serverrC   Úhermes_cli.web_server_cronrE   Úhermes_staterG   r&   ÚstateÚgateway.session_identityrK   rL   rM   rN   Úappr   r8   Ú	frozensetr   ÚresolveÚgateway.session_authoritiesrY   r1   Údb_pathr\   ÚuuidÚuuid4Úhex)ÚrequestÚprofilerA   rB   rC   rE   rG   ÚnativerI   rJ   rK   Ú	authorityÚhomeÚcapabilitiesrY   ÚrunnerÚownerrn   s   &&                r   Ú_session_mutation_contextry   U   sX  € å%Ý2Ý>Ý=Ý-ä�W—]‘]Ð$;¸TÓB€FÜ�g—m‘m Y°Ó5€GØÒØ˜Õ#‰Ø	Ò	ÝBÙ'¨°G·O±OØ˜×(Ñ(¨(°G·N±Nð)Dó E‰ä�W—[‘[×&Ñ&¨¸×?Ò?ÑD\Ð]d×DeÒDeÝBÙ'¨Ð4HÈ*ÐVeÐ(fÓg‰á¨°NÔCÐCÜ˜Ÿ™×)Ñ)Ð+>ÀÓE€Iß3:Œ4Ñ" 7Ó+¨AÕ.Ô/ÄÑEUÓEWÓ@X×@_Ñ@_€DÜÒfÓg€LØÒÜ�7—;‘;×$Ñ$Ð&6¸Ó=ÒIÙ¨CÐ8WÔXÐXð ‘Y˜w¬¨D¯L©L«NÓ(;¸\È6ÓRÐRÐRå>Ü�W—[‘[×&Ñ&Ð(8¸$Ó?€FØ06Ò0BÑ˜vÔ,È€EØ‚}˜Ÿ™›¬4°	·±×0DÑ0DÓ+E×+LÑ+L×+TÑ+TÓ+VÔVØˆØ‚}Ù¨Ð4FÔGÐGØ€IØÒ˜f \Õ2°i×6JÑ6JÔJÙ¨Ð4FÔGÐGØÒó 	Ø˜) G×-AÑ-AÀ<ÐQ_Ðbf×blÑblÓbn×brÑbrÕQrÓsÐsÐsØ�i ×)=Ñ)=¸|ÈVÓTÐTÐTr   c              #  ó6  "  € RpVeC   \        \        VRR4      4      P                  R4      '       d   \        V P                  RR4      pVf   Rx € R# ^ RIHpHp V! WRRR	VP                  R
VR
,          /4        Rx € V! W4       R#   T! Y4       i ; i5i)zPBind a verified native HTTP actor as a native legacy transport for one mutation.NÚtransport_idÚ r]   rH   )Úbind_native_transportÚunbind_native_transportrM   Úlocalr\   Úinstance_id)r   r&   Ú
startswithrg   Úgateway.session_local_migrationr}   r~   r\   )rq   rt   Úactorrs   r}   r~   s   &&&   r   Ú_native_history_transportr„   ˆ   s•   é € ð €FØÒ¤¤W¨U°NÀBÓ%GÓ!H×!SÑ!SÐTb×!cÒ!cÜ˜Ÿ™Ð(?ÀÓFˆØ‚~ÛÙß^Ù˜)¨Z¸À,ÐPY×PdÑPdØ-:¸FÀ=Õ<Qð-Sô Tð2Ûá 	Ö1øÑ 	Õ1üs   ‚A;BÁ>B Â
BÂ
BÂBc                óX   a aaaaa€ ^ RI Ho ^ RIHoHo VVVVVV 3R lp\        S V4      # )zòStandalone edit: the receipt transaction on this process's single shared writer.

Runs under the exact owner lock (409 while any gateway owns the store, never a
second writer beside it); revision/generation/idle guards are the gateway's own.
r@   )Úbegin_runtime_epochÚmutate_runtime_sessionc                  óÞ  <€ \        SR R7      p  RpSR,          R8X  dw   V P                  SR,          R,          4      w  r#V'       d   S
! RRV/R	7      h^ R
IHp ^ RIHp T! TS\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      R7      pV P                  4       ;_uu_ 4       pVP                  R4      P                  4       pRRR4       X'       d
   V^ ,          M	S! V RR7      pS! V 3RVRSP                  RSP                  R4      RV/R U	u/ uF  q™SV	,          bK  	  up	B V P                  4        #   + '       g   i     L|; iu up	i   T P                  4        i ; i)F©Ú	read_onlyNÚ	operationÚimportÚpayloadÚsessionsé�  ÚerrorsrQ   )Úpartial)Úimport_history_controlc              3   ó@   "  € T F  qR ,          R,          x € K  	  R# 5i)rI   r   N© )Ú.0Úitems   & r   Ú	<genexpr>Ú5_mutate_offline_store.<locals>.run.<locals>.<genexpr>®   s   é € Ð7eÑZdÐRV¸Y½È×8MÒ8MÓZdùs   ‚)rƒ   Úsession_idsz1SELECT epoch FROM runtime_epoch WHERE singleton=1zdashboard-offline)r€   ÚepochÚprincipal_idÚexpected_generationÚ_authorize_write©r   Ú
request_idÚexpected_revisionr‹   r�   )Ú_open_session_db_for_profileÚ_validate_import_payloadÚ	functoolsr‘   Úhermes_state_mutation_bindingr’   ÚtupleÚ	_read_ctxr'   ÚfetchonerJ   r   Úclose)r1   Úwrite_guardÚ
normalizedr�   r‘   r’   r3   r   rš   r"   rA   rƒ   r†   r‡   Úparamsrr   s             €€€€€€r   ÚrunÚ"_mutate_offline_store.<locals>.run£   s_  ø€ Ü)¨'¸UÔCˆð	ØˆKØ�kÕ" hÔ.Ø%'×%@Ñ%@ÀÈ	ÕARÐS]ÕA^Ó%_Ñ"�
ßÙ'°CÀÈ6Ð@RÔSÐSÝ-ÝPÙ%Ð&<ÀEß27´%Ñ7eÑZdÓ7e·%±%Ñ7eÑZdÓ7eÓ2eôg�à—‘—” 4Ø—l‘lÐ#VÓW×`Ñ`Ób�÷  ÷ "�C˜–FÑ':¸2ÐK^Ô'_ˆEÙ)¨"ñ J°Eð JÈÏÉð JØ$*§J¡JÐ/DÓ$EðJØXcðJñ0Hó Iñ 0H¨˜˜s�Ò#ñ 0Hñ IñJð
 �H‰H�J÷  —üòIøð �H‰H�Jús<   �AE Á0>E Â. EÃE Ã=E ÄEÄ-E ÅE	ÅE ÅE,)rb   rA   Úhermes_state_runtimer†   r‡   Ú_with_session_maintenance)rr   rƒ   r«   r¬   rA   r†   r‡   s   fff @@@r   Ú_mutate_offline_storer°   š   s$   ý€ õ &ßP÷ò ô, % W¨cÓ2Ð2r   c              ƒ  ó�  "  € ^ RI Hp ^ RIHpHpHp ^ RIHp ^ RIH	p ^ RI
Hp	 ^ RIHp
 V '       d   \        V	! V 4      ^,          4      M\        V
! 4       4      P                  p\         P"                  ! W{RR7      G R	j  x€L
 p\%        VR
R	4      pVf   R	# \%        VRR4      '       g6   ^ RIHp V! V\+        VP-                  4       P/                  4       4      R7      pR Uu/ uF  pWò9   g   K  WòV,          bK  	  ppVP1                  R4      e   VR,          VR&    V! WÑP2                  R7      ;_uu_4       GR	j  x€L
 pVP4                  ! R/ VB G R	j  x€L
 uuR	R	R	4      GR	j  x€L
  #  Lïu upi  L7 L L  + GR	j  x€L 
 '       g   i     R	# ; i  T d    h YH\6        \8        3 d   pT! RRR7      ThR	p?ii ; i5i)at  Forward a standalone dashboard mutation to the live gateway owner.

While a gateway serves the same home, a separately launched ``hermes
dashboard`` is not the store owner, so the offline path's
exclusive-maintenance reservation can never win and every write action
dies on a bare 409 (#138915). The owner exposes the same revision-fenced
verb over the control socket; with no discoverable owner return None so the
caller falls back to the offline store.

A dial, mint or RPC that dies on an endpoint discovery just identified is
not owner-less (a slow first dial, or an owner restart between discovery
and mint): the offline reservation would only lose to that same owner and
answer with the bare 409 this forward exists to remove, so every transport
failure surfaces a retryable 503. Only the owner's refusal frame
(``GatewayRPCError``) is passed on as a verdict.

The ticket is minted for the dashboard's authenticated principal, not the
socket UID: ``authorize_history`` compares the actor subject against the
row's stored owner, so a cold row owned by a dashboard account only takes
the mutation when the forward acts as that account.
r@   )ÚGatewayClientErrorÚGatewayRPCErrorÚconnect_gateway)Údiscover_gateway_endpoint)ÚDiscoveryErrorrD   rF   g      ø?)ÚtimeoutNÚendpointÚcontrol_homeT)Úreplace)r¹   rœ   )r¸   rJ   rV   Úowner_unreachablerQ   rž   )zsession.mutate)rb   rA   Úhermes_cli.gateway_clientr²   r³   r´   Úhermes_cli.gateway_runtimerµ   Ú$hermes_cli.gateway_runtime_discoveryr¶   re   rE   rf   rG   r   r8   ÚasyncioÚ	to_threadr&   Údataclassesrº   r   Ú
expanduserrk   r   rJ   ÚrpcÚOSErrorÚTimeoutError)rr   rƒ   r«   rA   r²   r³   r´   rµ   r¶   rE   rG   ru   Ú	discoveryr¸   rº   r"   ÚcallÚclientÚexcs   &&&                r   Ú_mutate_via_gateway_ownerrÊ   ¼   sŽ  é € õ, &ß^Ñ^ÝDÝCÝ=Ý-ç3:Œ4Ñ" 7Ó+¨AÕ.Ô/ÄÑEUÓEWÓ@X×@_Ñ@_€Dä×'Ò'Ð(AÐQTÔU×U€IÜ�y *¨dÓ3€HØÒÙÜ�8˜^¨T×2Ò2õ 	(Ù˜8´#°d·o±oÓ6G×6OÑ6OÓ6QÓ2RÔSˆáUóhÙUð "%ØY\ÑYfô ˆC˜•ÒÙUð 	ð hà‡z�zÐ'Ó(Ò4Ø&,Ð-BÕ&CˆÐ"Ñ#ð
RÙ"¨H¿m¹m×L×LÕLÐPVØŸšÑ=¸Ñ=×=÷ M×LÒLñ Vùòhñ
 MÙ=÷ M×L×LÓLûàô àØ´¼ÐFô Rñ ¨Ð4GÔHÈcÐQûð	Rüs»   ‚A>GÂ E0ÂA#GÃ$E2Ã1E2Ã>!GÄ F Ä?E7Å F ÅE=ÅE9ÅE=ÅF Å*E;Å+F Å/GÅ2GÅ7F Å9E=Å;F Å=F	ÆFÆ
F	ÆF	ÆF ÆGÆF ÆGÆ3F>Æ>GÇGÚpermission_deniedrZ   r[   Ú	not_foundi”  Úinvalid_paramsr�   Úruntime_drainingrV   Ústorage_unavailablerœ   c          
   ƒ  ór  "  € ^ RI p^ RIHp	 ^ RIHp
 ^ RIHp ^ RIHp ^ RI	H
p ^ RIHp \        W4      w  ppVR8X  d>   Ve:   VP                  P                  VR	,          4      w  ppV'       d   V	! R
RV/R7      hVf   Vf   Vf   V	! R\         R7      hVe   Vf   V	! RRR7      h\#        W#VWVR7      pVe   VVR&    Vf@   \%        VVV4      G Rj  x€L
 pVf&   \&        P(                  ! \*        VVV4      G Rj  x€L
 pMA\-        WV4      ;_uu_ 4        V! VVV
! VP.                  V4      V4      G Rj  x€L
 pRRR4       RR/XC#  Lu LN L  + '       g   i     L; i  T d9   pT	! \0        P3                  TP4                  R4      TP4                  R7      ThRp?iT d7   pT	! \0        P3                  \7        T4      R4      \7        T4      R7      ThRp?iT d   pT	! RRR7      ThRp?i\8         d   pT	! R
\7        T4      R7      ThRp?iTP:                   d   pT	! RRR7      ThRp?ii ; i5i)zJResolve the authenticated principal and owner; never open a second writer.Nr@   )Ú
SessionRef)Úmutate_session)r²   )ÚMUTATION_GUARD_REFUSALS)ÚRuntimeStoreErrorrŒ   rŽ   r�   r�   rQ   é™  Úmutation_identity_requiredrž   rœ   ÚokTÚsession_busyrV   rÏ   )Úsqlite3rb   rA   rc   rÑ   Úgateway.session_mutationsrÒ   r¼   r²   Úhermes_state_mutation_guardsrÓ   r®   rÔ   ry   r1   r¢   ÚCLIENT_UPGRADE_REQUIREDr*   rÊ   r¿   rÀ   r°   r„   r\   Ú_MUTATION_REFUSAL_STATUSr   Úreasonr   Ú
ValueErrorÚError)rq   rr   r   rŸ   r    r‹   r�   rœ   rÙ   rA   rÑ   rÒ   r²   rÓ   rÔ   rt   rƒ   Ú_r�   r«   ÚresultrÉ   s   &&&$$$$$              r   Ú_mutate_session_requestrã   ý   s.  é € ó Ý%Ý3Ý8Ý<ÝDÝ6ä0°ÓBÑ€IˆuØ�HÔ Ò!6Ø—L‘L×9Ñ9¸'À*Õ:MÓN‰	ˆˆ6ßÙ¨C¸À6Ð8JÔKÐKØÒÐ/Ò7Ð<OÒ<Wñ ¨Ô4KÔLÐLØÒÐ.Ò6Ù¨Ð4PÔQÐQÜ˜ZÐRcØô.€FàÒ&Ø(;ˆÐ$Ñ%ðTØÒô 5°W¸eÀVÓL×LˆFØŠ~Ü&×0Ò0Ô1FÈÐQVÐX^Ó_×_�øä*¨7¸u×EÕEÙ-¨i¸Á
È9×K_ÑK_ÐakÓ@lÐntÓu×u�÷ Fà�dÐ%˜fÐ%Ð%ñ Má_ñ v÷ F×Eûð ô sÙÔ(@×(DÑ(DÀSÇZÁZÐQTÓ(UÐ^a×^hÑ^hÔiÐorÐrûØô oñ Ô(@×(DÑ(DÄSÈÃXÈsÓ(SÔ\_Ð`cÓ\dÔeÐknÐnûØ"ô MÙ¨°NÔCÈÐLûÜô GÙ¨´C¸³HÔ=À3ÐFûØ�=‰=ô TÙ¨Ð4IÔJÐPSÐSûðTüsÇ   ‚A.H7Á1AH7ÃE$ ÃEÃ(E$ Ã>EÃ?E$ Ä EÄ8EÄ9EÄ=E$ Å
H7ÅE$ ÅE$ ÅEÅE!	ÅE$ Å$H4Å+3FÆH4Æ'H4Æ(1GÇH4Ç"H4Ç#G.Ç.H4Ç;H4Ç<HÈH4È#H4È$H/È/H4È4H7c                óŠ  € ^ RI Hp ^ RIHpHp ^ RIHp ^ RIHp V '       d   \        V! V 4      ^,          4      M\        V! 4       4      P                  p V! V.4      ;_uu_ 4        V! V!  uuRRR4       #   + '       g   i     R# ; i  T d0   p	\        P                  RY‰4       T! R\        T	4      R7      T	hRp	?	ii ; i)	zIOffline bulk actions reserve the exact owner lock through final DB close.r@   )ÚOwnershipConflictÚexclusive_maintenancerD   rF   Nz session write refused for %s: %srÕ   rQ   )rb   rA   Úgateway.runtime_ownershiprå   ræ   re   rE   rf   rG   r   r8   Ú_logÚwarningr   )
rr   r‹   ÚargsrA   rå   ræ   rE   rG   ru   rÉ   s
   &&*       r   r¯   r¯   1  s•   € å%ßRÝ=Ý-ç3:Œ4Ñ" 7Ó+¨AÕ.Ô/ÄÑEUÓEWÓ@X×@_Ñ@_€DðGÙ" D 6×*Õ*Ù˜dÑ#÷ +×*×*Ó*ûàô Gô 	�‰Ð7¸ÔCÙ¨´C¸³HÔ=À3ÐFûð	Gús6   ÁB Á'A8Á-
B Á8B		ÂB Â	B ÂCÂ*B=Â=Cc                ó$   € V ^8„  d   QhR\         /# )r   Úreturn)r¥   )r   s   "r   r   r   C  s   € ÷ *ñ *¬5ñ *r   c                 ó   € ^ RI Hp  V ! 4       # )zGProbe the declared schema without reconciling it on a browsing request.©Úschema_read_probe_statements)Úhermes_state_schemarï   rî   s    r   Ú!_session_db_read_probe_statementsrñ   C  s   € å@á'Ó)Ð)r   c                ó0   € V ^8„  d   QhR\         R\        /# )r   rm   rŠ   )r   Úbool)r   s   "r   r   r   J  s"   € ÷ IEñ IE¤dð IE¼$ñ IEr   c               ó6  a a€ ^ RI p^ RIHp ^ RIHo ^ RIHp ^ RIHp V'       g	   V! S 4      #  S P                  4       P                  ^ 8„  pV'       g   V! RRR	7      h^ R
IHpHpHp	 VV 3R lp
  V
! 4       #   \         d    Rp L;i ; i  TP                    de   pT! T4      '       g   h  T	! S 4       M:  T d1   p\"        P%                  RS T4       T! R\'        T4      R	7      ThRp?ii ; iT
! 4       u Rp?# Rp?ii ; i  TP(                  \*        3 d~   p^ RIHp \/        Y²P(                  4      '       d   T! T4      '       d   ^ RIHp T! S T4      Th\/        Y²P                   4      '       d   T! T4      '       d   RpMRpT! RTR	7      ThRp?ii ; i)aÈ  Browsing never initializes or repairs the owner's session store.

Owner startup reconciles schema. The one write a browse may do: a store that lags
SCHEMA_SQL (missing table/column, not corruption) with NO gateway owning it gets the
missing declared tables/columns once, in one short locked transaction (#140315); an
owned store is refused by name instead. Explicit mutation APIs retain their writable
acquisition until their separate owner-RPC migration.
Nr@   )Ú	SessionDB)Úis_transient_sqlite_error)ÚacquireFrV   zPSession store is not initialized. Start this profile's gateway to initialize it.rQ   )ÚDeclarativeDriftErrorÚis_declarative_drift_errorÚreconcile_drift_for_browsec                  óà   <€ S! SR R7      p  \        V RR4      pVe1   \        4        F"  pVP                  V4      P                  4        K$  	  V #   \         d    T P                  4        h i ; i)T)rm   rŠ   r   N)r&   rñ   r'   r§   ÚBaseExceptionr¨   )r1   r3   Ú	statementrõ   rm   s      €€r   Ú_open_probedÚ._open_session_db_at_path.<locals>._open_probedj  sk   ø€ Ù˜w°$Ô7ˆð	Ü˜2˜w¨Ó-ˆDØÒÜ!BÖ!D�IØ—L‘L Ó+×4Ñ4Ö6ñ "EàˆIøÜô 	Ø�H‰HŒJØð	ús   �AA ÁA-z,session store at %s is behind SCHEMA_SQL: %s)Úis_malformed_db_error)Úcorrupt_store_statuszJSession store is busy (disk I/O or lock). Retry; the list was not cleared.z¿Session store schema is unavailable or corrupt. Start or restart this profile's gateway to reconcile it; if it persists, run `hermes doctor` for diagnosis. Browsing does not repair the store.)rÙ   rb   rA   rf   rõ   Úhermes_state_errorsrö   Úhermes_state_registryr÷   ÚstatÚst_sizeÚFileNotFoundErrorÚhermes_state_reconcilerø   rù   rú   ÚOperationalErrorrè   ré   r   ÚDatabaseErrorÚUnicodeDecodeErrorr   Ú
isinstanceÚhermes_cli.web_routers._commonr  )rm   rŠ   rÙ   rA   rö   r÷   Úinitializedrø   rù   rú   rþ   rÉ   Údriftr   r  rS   rõ   s   f$              @r   Ú_open_session_db_at_pathr  J  s•  ù€ ó å%Ý&Ý=Ý-çÙ�wÓÐðØ—l‘l“n×,Ñ,¨qÑ0ˆ÷ ÙØØeôgð 	g÷ñ ö
ðEð	"Ù“>Ð!øô3 ô ØŠðûð4 ×'Ñ'ô 	"ñ .¨c×2Ò2ØðQÙ*¨7Õ3øØ(ô QÜ—‘ÐKÈWÐV[Ô\Ù#°¼CÀ»JÔGÈSÐPûðQúñ  “>Õ!ûð	"ûð ×!Ñ!Ô#5Ð6ô EÝ=Ü�c×0Ñ0×1Ò1Ñ6KÈC×6PÒ6Põ LÙ& w°Ó4¸#Ð=Ü�c×3Ñ3×4Ò4Ñ9RÐSV×9WÒ9WØa‰Fð6ð ñ ¨°FÔ;ÀÐDûðEús}   °A9 Á2B Á9B	ÂB	ÂDÂC<Â-B6Â5C<Â6C-Â=+C(Ã(C-Ã-	C<Ã6DÃ7D Ã<DÄD ÄFÄ.FÅ
8FÆFÆFc                óF   € V ^8„  d   QhR\         \        ,          R\        /# )r   rr   rì   )r   r   r   )r   s   "r   r   r   –  s   € ÷ $ñ $¬(´3­-ð $¼Dñ $r   c                ó‚   € ^ RI Hp ^ RIHp V '       d   V! V 4      w  r4\	        V4      R,          # \	        V! 4       4      # )z@state.db path for ``profile`` (None/empty = this process's own).rD   rF   zstate.db)re   rE   rf   rG   r   )rr   rE   rG   Ú_nameru   s   &    r   Ú_session_db_path_for_profiler  –  s5   € å=Ý-çÙ(¨Ó1‰ˆÜ�D‹z˜JÕ&Ð&ÜÑ Ó"Ó#Ð#r   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# )r   rr   rŠ   )r   r   ró   )r   s   "r   r   r   ¡  s"   € ÷ `ñ `¬(´3­-ð `Ätñ `r   c               ó.   € \        \        V 4      VR7      # )z‹Open a SessionDB for ``profile`` (None/empty = this process's own state.db).

Access-mode semantics: see :func:`_open_session_db_at_path`.
r‰   )r  r  )rr   rŠ   s   &$r   r¡   r¡   ¡  s   € ô
 $Ô$@ÀÓ$IÐU^Ô_Ð_r   g     Àr@c                ó>   € V ^8„  d   QhR\         \        ,          RR/# )r   rr   rì   N)r   r   )r   s   "r   r   r   °  s"   € ÷ 1Bñ 1B¬X´c­]ð 1B¸tñ 1Br   c           	     ó6  €  T ;'       g    Rp\         P                  ! 4       p\        P                  V4      pVe   W#,
          \        8  d   R# T\        V&   ^ RIHp ^ RIHpH	p \        V 4      P                  pV! \        V4      4      p V! 4       P                  R4      ;'       g    / p	V! V4       V	P                  RR4      '       g   R# ^ RIHp
 V
! V4      '       d   R# \        V RR	7      p VP!                  \#        V	P                  R
^4      4      \%        V	P                  R^4      4      R7       VP'                  4        R#   T! T4       i ; i  TP'                  4        i ; i  \(         d"   p\*        P-                  RT4        Rp?R# Rp?ii ; i)zÓConfig-gated owner-lifetime maintenance, never invoked by browsing.

The standalone serve ticker maintains its own profile; a composed HTTP
listener relies on its gateway owner's startup and housekeeping hooks.
r|   N)Úload_config)Úreset_hermes_home_overrideÚset_hermes_home_overriderŽ   Úauto_archiveF©Ú_check_gateway_runningr‰   Úauto_archive_daysÚmin_interval_hours)Ú	idle_daysr  z&opportunistic auto-archive skipped: %s)ÚtimeÚ	monotonicÚ_last_auto_archive_checkr   Ú_AUTO_ARCHIVE_CHECK_INTERVAL_SÚhermes_cli.configr  Úhermes_constantsr  r  r  r8   r   Úhermes_cli.profilesr  r¡   Úmaybe_auto_archiver   Úintr¨   r   rè   Údebug)rr   r"   ÚnowÚlastÚ_load_full_configr  r  Úprofile_homeÚ_home_tokenÚcfgr  r1   rÉ   s   &            r   Ú_maybe_auto_archive_for_profiler1  °  sV  € ð+BØ�mˆm˜ˆÜ�nŠnÓˆÜ'×+Ñ+¨CÓ0ˆØÒ ¥
Ô-KÔ KÙØ(+Ô  Ñ%åFßYô 4°GÓ<×CÑCˆÙ.¬s°<Ó/@ÓAˆð	4Ù$Ó&×*Ñ*¨:Ó6×<Ð<¸"ˆCá& {Ô3Ø�w‰w�~ u×-Ò-ÙÝ>ñ " ,×/Ò/ÙÜ)¨'¸UÔCˆð	Ø×!Ñ!Ü §¡Ð(;¸QÓ ?Ó@Ü#& s§w¡wÐ/CÀRÓ'HÓ#Ið "ô Kð �H‰HŽJøñ+ ' {Õ3ûð* �H‰H�JûÜô BÜ�
‰
Ð;¸S×AÒAûðBúsf   ‚E, ‹AE, Á=E, ÂE
 Â*E
 Â-E, ÃE, Ã%E, Ã3AE Ä8E, Å

EÅE, ÅE)Å)E, Å,FÅ7FÆFc                óF   € V ^8„  d   QhR\         R\        \         ,          /# )r   r   rì   )r   r   )r   s   "r   r   r   ä  s   € ÷ /ñ /¬Eð /´h¼uµoñ /r   c                ó"  € ^ RI Hp ^ RIHp V! 4       P	                  4       pVP
                  ;_uu_ 4        VP                  P                  4        Uu. uF>  p\        VP                  R4      ;'       g    T4      P	                  4       V8X  g   K<  VNK@  	  pp\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d    RRR4       R# \        WP                  P                  \        V4      ^ 4      .V Uu. uF'  p\        VP                  R4      ;'       g    T 4      NK)  	  up,           4      pRRR4       \        R\        P                  ! 4       X,
          4      # u upi u upi   + '       g   i     L@; i)	zIMeasure chat inactivity, not socket inactivity (Desktop stays connected).N©Úget_hermes_homer.  c              3   óB   "  € T F  qP                  R 4      x € K  	  R# 5i)ÚrunningN)r   )r•   rI   s   & r   r—   Ú._skill_maintenance_idle_for.<locals>.<genexpr>î  s   é € Ð>±X¨'�{‰{˜9×%Ð%³Xùs   ‚TFÚlast_activer   )Útui_gateway.serverÚserverr&  r5  rk   Ú_sessions_lockÚ	_sessionsÚvaluesr   r   ÚanyÚmaxÚ_closed_session_activityr   r   r!  )r   Úgatewayr5  ru   rI   rŽ   r9  s   &      r   Ú_skill_maintenance_idle_forrC  ä  s4  € å(å0áÓ×$Ñ$Ó&€DØ	×	×	Ó	Ø+2×+<Ñ+<×+CÑ+CÔ+Eó TÑ+E Ü˜GŸK™K¨Ó7×?Ð?¸4Ó@×HÑHÓJÈdÑR÷ �GÑ+Eˆð Tç‹3Ñ>±XÓ>�3�3Š3Ñ>±XÓ>×>Ò>Ø÷	 
 Ñ	ô
 Ø×9Ñ9×=Ñ=¼cÀ$»iÈÓKÐLÙNVÓWÉhÀ7Œu�W—[‘[ Ó/×=Ð=°:Ö>ÉhÑWõXóYˆ÷ 
 ô ˆs”D—I’I“K +Õ-Ó.Ð.ùòTùò X÷ 
 ×	úsM   ¶E>Á!E4Á5E4ÂE4ÂE>Â8E>ÃE>Ã.E>Ä!E9Ä.E9Ä9E>Å4
E>Å>F	c                ó(   € V ^8„  d   QhR\         RR/# )r   r   rì   N©r   )r   s   "r   r   r   ö  s   € ÷ :ñ :¬Uð :°tñ :r   c                 óè   € ^ RI Hp ^ RIHp V! V! 4       4      '       d   R# ^ RIHp  \        V 4      pVe   V! VR7       R# R#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)é    r4  r  N)Úmaybe_run_curator)Úidle_for_secondszserve curator tick skipped: %s)
r&  r5  r'  r  Úagent.curatorrH  rC  r   rè   r*  )r   r5  r  rH  Úidle_forrÉ   s   &     r   Ú_maybe_run_skill_maintenancerL  ö  sb   € Ý0Ý:ñ ™oÓ/×0Ò0Ùå/ð:Ü.¨zÓ:ˆØÒÙ¨x×8ñ  øäô :Ü�
‰
Ð3°S×9Ò9ûð:ús   ©A ÁA1ÁA,Á,A1c                ó4   € V ^8„  d   QhR\         R\         RR/# )r   Ú
interval_sÚinitial_delay_srì   NrE  )r   s   "r   r   r     s$   € ÷ (ñ (Üð(Ü16ð(ØBFñ(r   c              ƒ  ól  a"  € \         P                   ! 4       oR V3R llp\        P                  ! V4      G Rj  x€L
    \        P                  ! V4      G Rj  x€L
  \        P                  ! V 4      G Rj  x€L
  K@   LD L&  \         d!   p\
        P                  RT4        Rp?LJRp?ii ; i L85i)zçPoll maintenance for this serve profile, including Desktop-only installs.

Individual chores own their config/interval gates. Curator additionally uses
real chat inactivity; merely keeping a Desktop WebSocket open is not activity.
c                ó   € V ^8„  d   QhRR/# )r   rì   Nr”   )r   s   "r   r   Ú/_auto_archive_ticker_loop.<locals>.__annotate__  s   € ÷ 1ñ 1�Dñ 1r   c                  ó4   <€ \        R 4       \        S 4       R # )N)r1  rL  )r   s   €r   Ú_sweepÚ)_auto_archive_ticker_loop.<locals>._sweep  s   ø€ Ü'¨Ô-Ü$ ZÖ0r   Nzauto-archive tick skipped: %s)r!  r¿   ÚsleeprÀ   r   rè   r*  )rN  rO  rT  rÉ   r   s   &&  @r   Ú_auto_archive_ticker_looprW    s�   øé € ô —’“€J÷1ð 1ô �-Š-˜Ó
(×(Ð(Ø
ð	=Ü×#Ò# FÓ+×+Ð+ô �mŠm˜JÓ'×'Ò'ñ )ñ ,øÜô 	=Ü�J‰JÐ6¸×<Ñ<ûð	=úá'ùsW   ƒ8B4»B ¼B4ÁB ÁBÁB Á B4Á9B2Á:B4ÂB ÂB/ÂB*Â%B4Â*B/Â/B4c                ób   € V ^8„  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r   r#  )Ú__conditional_annotations__r*   r   r   )r   s   "r   r   r      s)   € ÷ ñ ÷X 0Ò /œ$œs¤E˜zÕ*Ñ /òYr   )g      ¬@g     €V@)'rY  Ú__doc__Úloggingr¿   r!  Ú
contextlibr   Úpathlibr   Útypingr   r   Úhermes_state_commonr   r   Ú	getLoggerrè   r   r(   rÜ   r>   ry   r„   r°   rÊ   rÝ   rã   r¯   rñ   r  r  r¡   r$  r#  r1  rC  rL  rW  r   )rY  s   @r   Ú<module>ra     s?  øðöó Û Û Ý %Ý ß !ç Cð ×ÒÐ0Ó1€ð
ñ )Ð)9Ð;MÓNÐOð PÙ(Ð)9Ð;MÓNÐOð PØ,×3Ò3°cÔ:Ð;ð <ðÐ ð*VÐ õ)òX0Uðf ñ2ó ð2ò"3òD7Rðz 0°Ð6HÈ#È{Ð\_Ø,¨cÐ3EÀsÐLaÐcfðhÐ ð1TØ]aô1TòhGõ$*õIEõX$õ`ð "'Ð Ø-/Ð Ó /õ1Bõh/õ$:÷$(ñ (r   