+
    iHàjà[  ã                  ó4  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIt^ RIt^ RIt^ RIHt ]	P$                  ! ]4      tRsR tR t ! R	 R
]4      tRR ltR t ! R R4      t ! R R4      t^ RIHt ^ RI H!t!  ! R R]]!4      t"R# )zòExplicit worker persistence facade; never opens the canonical SQLite store.

This first operation family is deliberately NOT a complete SessionDB substitute.
No existing cron/child/compute consumer is switched until its inventory is covered.
)ÚannotationsN)ÚThreadPoolExecutor)ÚPath)Úmake_user_dirFc                 ó   € \         # )a  A successful self-registration makes this interpreter compute-only.

Process-scoped (not ContextVar): import-time recovery and fresh helper threads
must not regain owner-ledger access. This is cooperative runtime ownership,
not OS confinement or an authorization credential.
)Ú_worker_process© ó    Ú@/home/ubuntu/.hermes/hermes-agent/agent/runtime_session_store.pyÚis_worker_processr      s
   € ô Ðr	   c                óœ   € \        WRR7       F:  w  r#VP                  4        F!  w  rEVf   VP                  VR4       K  WRV&   K#  	  K<  	  R# )z\Mirror the owner's in-place row stamps onto the worker's dicts (None = the owner popped it).T)ÚstrictN)ÚzipÚitemsÚpop)Úmessagesr   ÚmessageÚ
annotationÚkeyÚvalues   &&    r
   Úapply_row_annotationsr   %   sF   € ä" 8À×FÑˆØ$×*Ñ*Ö,‰JˆCØŠ}Ø—‘˜C Ö&à$˜“ó	 -ó  Gr	   c                  ó   € ] tR t^.tRtR# )ÚWorkerPersistenceErrorr   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   r	   r
   r   r   .   s   † Ûr	   r   c                ój  € \         P                  ! ^4      . r!Ve‰   \        V4      V 8  dy   VP                  P	                  RR4      pVP                  R4      '       g8   VP                  V RVP                  P                   RVP                   24       VP                  pKŒ  RP                  V4      # )z§module:function:line of the frames above this store (its own frames skipped), never
locals or argument values: best-effort callers swallow the guard's raise (#139029).r   Ú?zagent.runtime_session_Ú:z <- )ÚsysÚ	_getframeÚlenÚ	f_globalsÚgetÚ
startswithÚappendÚf_codeÚco_nameÚf_linenoÚf_backÚjoin)ÚlimitÚframeÚframesÚmodules   &   r
   Ú_caller_summaryr1   2   s’   € ô —M’M !Ó$ bˆ6Ø
Ò
¤ F£¨eÔ 3Ø—‘×$Ñ$ Z°Ó5ˆØ× Ñ Ð!9×:Ò:Ø�M‰M˜V˜H A e§l¡l×&:Ñ&:Ð%;¸1¸U¿^¹^Ð<LÐMÔNØ—‘ŠØ�;‰;�vÓÐr	   c                óP  €  \         P                  ! 4        \        P                  ! 4       p\        ^RR7      ;_uu_ 4       pTP                  ! TP                  T .TO5/ TB P                  4       uuRRR4       #   \         d    T ! T/ TB u # i ; i  + '       g   i     R# ; i)a%  Call ``fn`` here, or on a worker thread when this thread is running an event loop.

For synchronous best-effort writers that can run inside a callback Relay drives on its private
loop (provider/tool callbacks): there ``WorkerRPC`` refuses the call (``synchronous_rpc_on_event_loop``,
sticky for the rest of the turn; #139029). The callback already blocks that loop, so waiting for the
thread costs it nothing; the context is copied so session-scoped state survives the hop, and errors
re-raise here. Async code awaits ``asyncio.to_thread`` instead.
zworker-persist-off-loop)Úmax_workersÚthread_name_prefixN)	ÚasyncioÚget_running_loopÚRuntimeErrorÚcontextvarsÚcopy_contextr   ÚsubmitÚrunÚresult)ÚfnÚargsÚkwargsÚcontextÚpools   &*,  r
   Úcall_off_event_looprB   >   s�   € ð#Ü× Ò Ô"ô ×&Ò&Ó(€GÜ	¨Ð>W×	XÕ	XÐ\`Ø�{Š{˜7Ÿ;™;¨Ð<¨TÒ<°VÑ<×CÑCÓE÷ 
YÒ	Xøô ô #Ù�4Ð"˜6Ñ"Ò"ð#ú÷ 
Y×	XÐ	Xús   ‚A; Á/BÁ;BÂBÂB%	c                  ó2   € ] tR t^PtRtR tR tR tR tRt	R# )Ú
_OwnerLinkaw  One owner WebSocket and the only thread that reads it. Events the owner broadcasts to every
transport are discarded as they arrive, idle or not: left queued, websockets' bounded receive
buffer pauses socket reads, which also stalls pongs and the close handshake. The reply to the
one outstanding request id goes to its caller; a closed connection goes to it as the exception.c                	óØ   € Wn         R V n        \        P                  ! 4       V n        \
        P                  ! V P                  RRR7      V n        V P                  P                  4        R # )Nzworker-rpc-readerT)ÚtargetÚnameÚdaemon)
ÚwsÚawaitingÚqueueÚSimpleQueueÚrepliesÚ	threadingÚThreadÚ_readÚreaderÚstart)ÚselfrI   s   &&r
   Ú__init__Ú_OwnerLink.__init__U   sJ   € ØŒØˆŒÜ×(Ò(Ó*ˆŒÜ×&Ò&¨d¯j©jÐ?RÐ[_Ô`ˆŒØ�‰×ÑÖr	   c                	ó¾  €    \         P                  ! V P                  P                  4       4      p\        T\        4      '       g   KH  T P                  f   KX  TP                  R4      T P                  8X  g   Kz  T P                  P                  T4       K—    \         d     K¥  i ; i  \         d'   pT P                  P                  T4        Rp?R# Rp?ii ; i)TNÚid)ÚjsonÚloadsrI   ÚrecvÚ
ValueErrorÚ
isinstanceÚdictrJ   r%   rM   ÚputÚ	Exception)rS   r.   Úexcs   &  r
   rP   Ú_OwnerLink._read\   s¢   € ð		"ØðÜ ŸJšJ t§w¡w§|¡|£~Ó6�Eô ˜e¤T×*Ô*¨t¯}©}Ô/HÈUÏYÉYÐW[Ë_Ð`d×`mÑ`mÖMmØ—L‘L×$Ñ$ UÖ+øô "ô Úðûô ô 	"Ø�L‰L×Ñ˜S×!Ò!ûð	"úsK   ‚B+ „.B ²B+ Á
B+ ÁB+ Á<B+ ÂB(Â$B+ Â'B(Â(B+ Â+CÂ6CÃCc                	óH   € Wn         V P                  P                  V4       R # ©N)rJ   rI   Úsend)rS   Ú
request_idr   s   &&&r
   rd   Ú_OwnerLink.sendh   s   € Ø"ŒØ�‰�‰�WÖr	   c                	óº   €  V P                   P                  VR 7      p\        T\        4      '       d   ThT#   \        P                   d    \	        R4      Rhi ; i)©ÚtimeoutÚworker_receipt_timeoutN)rM   r%   rK   ÚEmptyÚTimeoutErrorr\   ÚBaseException)rS   ri   Úreplys   && r
   ÚreceiveÚ_OwnerLink.receivel   s]   € ð	CØ—L‘L×$Ñ$¨WÐ$Ó5ˆEô �eœ]×+Ò+ØˆKØˆøô	 �{‰{ô 	CÜÐ7Ó8¸dÐBð	Cús	   ‚8 ¸"A)rJ   rQ   rM   rI   N)
r   r   r   r   Ú__doc__rT   rP   rd   ro   r   r   r	   r
   rD   rD   P   s   † ñgòò
"òör	   rD   c                  ó8   € ] tR t^vtRtR tR tR tR tR t	Rt
R# )	Ú	WorkerRPCa/  Bounded authenticated calls to an existing owner; never starts a daemon.

No owner-loop synchronous self-RPC or SQLite fallback is permitted.
One connection serves every call (serialized by ``lock``, correlated by id); it is
discovered, identified and ticketed on connect exactly as each call once was.
c                	ó    € \        V4      P                  4       V n        \        P                  ! 4       V n        R V n        R V n        ^ V n        R # rc   )	r   ÚresolveÚhomerN   ÚLockÚlockÚendpointÚlinkre   )rS   rv   s   &&r
   rT   ÚWorkerRPC.__init__}   s9   € Ü˜“J×&Ñ&Ó(ˆŒ	Ü—N’NÓ$ˆŒ	ØˆŒØˆŒ	ØˆŽr	   c                	ó  € V P                   eG   V P                   P                  P                  4       '       d   V P                   # V P                  4        ^ RIHpHp ^ RIHp ^ RI	H
p ^ RIHp V! V P                  ^R7      pVP                  R8X  d!   VP                  e   VP                  V n        M*VP                  R8w  g   V P                  f   \!        R4      h^ R	IHp V P                  pV! V! V P                  V4      ^R7      p	V	P%                  R
4      \&        P(                  ! 4       8X  d   \!        R4      hV! V P                  VRR7      p
V! WŠ4      w  r¼\+        V! W¼^^RR R R7      4      V n         V P                   # )N)Ú_session_ticketÚgateway_ws_target)Úquery_identify)Úconnect)Údiscover_gateway_endpointrh   ÚreadyÚdrainingÚowner_unavailable)Úcontrol_home_forÚpidÚsynchronous_self_rpczworker-adoption)Úpurpose)ÚsubprotocolsÚopen_timeoutÚclose_timeoutÚmax_sizeÚproxyÚping_intervali  € )rz   rQ   Úis_aliveÚ_dropÚhermes_cli.gateway_clientr}   r~   Ú$hermes_cli.gateway_runtime_discoveryr   Úwebsockets.sync.clientr€   Úhermes_cli.gateway_runtimer�   rv   Ústatery   r   r…   r%   ÚosÚgetpidrD   )rS   r}   r~   r   r€   r�   Ú	discoveryr…   ry   Ú
descriptorÚticketÚurlÚ	protocolss   &            r
   Ú_connectionÚWorkerRPC._connection„   s1  € Ø�9‰9Ò Ø�y‰y×Ñ×(Ñ(×*Ò*Ø—y‘yÐ à�J‰JŒLßPÝGÝ2åHÙ-¨d¯i©iÀÔCˆ	Ø�?‰?˜gÔ%¨)×*<Ñ*<Ò*HØ%×.Ñ.ˆD�MØ�_‰_ 
Ô*¨d¯m©mÒ.CÜ(Ð)<Ó=Ð=Ý?Ø—=‘=ˆÙ#Ñ$4°T·Y±YÀÓ$IÐSTÔUˆ
Ø�>‰>˜%Ó ¤B§I¢I£KÔ/Ü(Ð)?Ó@Ð@Ù  §¡¨HÐ>OÔPˆÙ*¨8Ó<‰ˆô ™w sÐQRÐbcØ0?ÀtÐ[_ô aó bˆŒ	à�y‰yÐr	   c                	óê   € V P                   R uqn         VeH   \        P                  ! \        4      ;_uu_ 4        VP                  P                  4        R R R 4       R # R #   + '       g   i     R # ; irc   )rz   Ú
contextlibÚsuppressÚOSErrorrI   Úclose)rS   rz   s   & r
   r�   ÚWorkerRPC._drop¢   sL   € ØŸ)™) TˆˆŒiØÒÜ×$Ò$¤W×-Õ-Ø—‘—‘”÷ .Ñ-ñ ß-×-Ð-ús   ºA!Á!A2	c                	óˆ   € V P                   ;_uu_ 4        V P                  4        R R R 4       R #   + '       g   i     R # ; irc   )rx   r�   ©rS   s   &r
   r£   ÚWorkerRPC.close¨   s    € Ø�Y�Y‹YØ�J‰JŒL÷ �Y�YŠYús	   •0°A	c                	óÈ  €  \         P                  ! 4        \        P                  R V\        P
                  ! 4       P                  \        4       4       \        R4      h  \         d     Mi ; i^ RI
Hp T P                  ;_uu_ 4        T ;P                  ^,          un        T P                  p\        P                  ! RRRTRTRT/4      p T P!                  4       p TP#                  YE4       M>  T d5    T P%                  4        T P!                  4       pTP#                  YE4        Mi ; iTP'                  ^4      pM   \(         d    T P%                  4        h i ; iRT9   d#   \        TR,          P+                  R	R
4      4      hTR9   d,   TP+                  R4      \,        P.                  ! 4       8X  d   RsTR,          uuRRR4       #   + '       g   i     R# ; i)z:synchronous_rpc_on_event_loop: %s on thread %s; caller: %sÚsynchronous_rpc_on_event_loop)ÚConnectionClosedÚjsonrpcz2.0rW   ÚmethodÚparamsÚerrorr   Úpersistence_failedr†   Tr<   N)zworker.registerzworker.adopt)r5   r6   ÚloggerÚwarningrN   Úcurrent_threadrG   r1   r   r7   Úwebsockets.exceptionsrª   rx   re   rX   Údumpsr�   rd   r�   ro   rm   r%   r–   r—   r   )rS   r¬   r­   rª   re   r   rz   Úresponses   &&,     r
   Ú__call__ÚWorkerRPC.__call__¬   s�  € ð	JÜ×$Ò$Ô&ô �N‰NÐWØ!¤9×#;Ò#;Ó#=×#BÑ#BÄOÓDUôWä(Ð)HÓIÐIøô ô 	Ùð	úõ 	;Ø�Y�Y‹YØ�OŠO˜qÕ �OØŸ™ˆJÜ—j’j )¨U°D¸*ÀhÐPVÐX`ÐbhÐ!iÓjˆGðØ×'Ñ'Ó)�ð3Ø—I‘I˜jÕ2øØ'ô 3ð —J‘J”LØ×+Ñ+Ó-�DØ—I‘I˜jÖ2ð3úð  Ÿ<™<¨Ó+‘øÜ ô à—
‘
”Øðúð ˜(Ô"Ü,¨X°gÕ->×-BÑ-BÀ9ÐNbÓ-cÓdÐdØÐ<Ô<ÀÇÁÈEÓARÔVX×V_ÒV_ÓVaÔAaà"&�Ø˜HÕ%÷3 �Y�Y‹Yús[   ‚A ÁA-Á,A-Â
AGÃEÃ C2Ã1EÃ28D-Ä*EÄ,D-Ä-EÅGÅEÅA&GÇG!	)ry   rv   rz   rx   re   N)r   r   r   r   rq   rT   r�   r�   r£   r¶   r   r   r	   r
   rs   rs   v   s    † ñòòò< òö#&r	   rs   )ÚRuntimeSessionCompressionMixin)ÚRuntimeSessionLifecycleMixinc                  ó2  € ] tR t^ØtRtRtR4RR5/R lltR tR tR t	R	 t
R
 tR tR6R ltRRRR/R ltRRRRRRRRRRRRRRRR/R ltRRRR/R ltR tR tR  tR7R! ltR" tR# tR$ tR% tR& tR' tR( tR) tR* tR4R+ ltR, tR- t R. t!R/ t"R0 t#R1 t$R2 t%R3t&R# )8ÚRuntimeSessionStorea  Synchronous durable results with a private byte-bounded retry journal.

A failed write remains pending, and failure is sticky until explicit retry or
adoption. Local queue acceptance is never returned as canonical commit.
Pending journals live outside age-pruned cache trees.
TNÚ	max_bytesc               	ó¬  € Wn         \        V4      V n        WPn        \        P
                  ! 4       V n        R V n        \        V4      R,          V n	        \        V P                  P                  RRRR7       V P                  P                  P                  4       '       g!   V P                  P                  4       '       d   \        R4      h\        P                  ! V P                  P                  R4       ^ RIHp V P                  P                  R,          pVP                  4       '       d   \        R4      hVP%                  RR	R
7      V n        \        P                  ! VR4       V! V P&                  4      '       g&   V P&                  P)                  4        \        R4      h V P                  P+                  4       '       d¤   V P                  P-                  4       P.                  V8”  d   \        R4      h\0        P2                  ! V P                  P5                  RR
7      4      V n        V P6                  R,          V P                  8g  pV'       d   V P9                  V4       M4RpRV P                  R^R. /V n        V P;                  V P6                  4       V P6                  R,          '       d   V P=                  4        V'       d&   V P                  \        V4      8w  d   \        R4      h\?        4       '       d%   V P@                  '       d   ^ RI!H"p	 V	! V 4       R # R # R #   \F         d    T P&                  P)                  4        h i ; i)Nzpending.jsoniÀ  T)ÚmodeÚparentsÚexist_okÚunsafe_outbox)Ú_try_acquire_file_lockz
owner.lockza+zutf-8)Úencodingé€  Úoutbox_in_useÚoutbox_fullz	utf-8-sigÚscopeFÚnext_sequenceÚpendingÚoutbox_scope_mismatch)Úbind_worker_delegation_store)$Úrpcr]   rÇ   r¼   rN   ÚRLockrx   Úfailurer   Úpathr   ÚparentÚ
is_symlinkr   r–   ÚchmodÚgateway.statusrÂ   ÚopenÚ_outbox_ownerr£   ÚexistsÚstatÚst_sizerX   rY   Ú	read_textÚjournalÚ_reconcile_adoptedÚ_saveÚretry_pendingr   Úbinds_delegation_ledgerÚtools.async_delegation_workerrË   r_   )
rS   rÌ   rÇ   Ú
outbox_dirÚadoptedr¼   rÂ   Ú	lock_pathÚ
reconciledrË   s
   &&&&&$    r
   rT   ÚRuntimeSessionStore.__init__â   sc  € ØŒÜ˜%“[ˆŒ
Ø"ŒÜ—O’OÓ%ˆŒ	ØˆŒÜ˜Ó$ ~Õ5ˆŒ	Ü�d—i‘i×&Ñ&¨U¸DÈ4ÕPØ�9‰9×Ñ×&Ñ&×(Ò(¨D¯I©I×,@Ñ,@×,BÒ,BÜ(¨Ó9Ð9Ü
�Š�—‘×!Ñ! 5Ô)Ý9Ø—I‘I×$Ñ$ |Õ3ˆ	Ø×Ñ×!Ò!Ü(¨Ó9Ð9Ø&Ÿ^™^¨D¸7˜^ÓCˆÔÜ
�Š�˜EÔ"Ù% d×&8Ñ&8×9Ò9Ø×Ñ×$Ñ$Ô&Ü(¨Ó9Ð9ð	Ø�y‰y×Ñ×!Ò!Ø—9‘9—>‘>Ó#×+Ñ+¨iÔ7Ü0°Ó?Ð?Ü#Ÿzšz¨$¯)©)×*=Ñ*=À{Ð*=Ó*SÓT�”Ø!Ÿ\™\¨'Õ2°d·j±jÑ@�
ßØ×+Ñ+¨GÔ4øà"�
Ø '¨¯©°_ÀaÈÐTVÐW�”Ø—
‘
˜4Ÿ<™<Ô(Ø�|‰|˜I×&Ô&Ø×"Ñ"Ô$ß˜dŸj™j¬D°«KÔ7ô -Ð-DÓEÐEÜ ×"Ò" t×'C×'CÐ'CÝVÙ,¨TÖ2ñ (DÑ"øô ô 	Ø×Ñ×$Ñ$Ô&Øð	ús-   Æ)L, Ç	BL, ÉAL, Ê9L, ËAL, ÌL, Ì,'Mc                óú  aa€ V P                   R,          V P                  uoo\        S4      RR0,
          p\        V\        4      '       EdÕ   \        S4      \        S4      8w  Eg»   \
        ;QJ d     VV3R lV 4       F  '       g   K   RM	  RM! VV3R lV 4       4      '       Egx   VP                  R4      SP                  R4      8w  EgR   VP                  R4      SP                  R4      8w  Eg,   VP                  R4      SP                  R4      8w  Eg   VP                  R	4      SP                  R4      8w  gá   VP                  R
4      R8w  gË   \        SP                  R4      4      \        Jg©   \        SP                  R4      4      \        Jg‡   SR,          SR,          8”  gr   SR,          SR,          8w  dh   \
        ;QJ d-    R V P                   R,           4       F  '       g   K   RM"	  RM! R V P                   R,           4       4      '       g   \        R4      h\	        V P                   \	        SSR,          R7      R7      pV P                  V4       VR,          V n        W0n         R# )a,  Carry a retained outbox across verified owner replacement.

``adopted`` is the separately authenticated ``worker.adopt`` result for the requested
scope; never self-adopt. Only the owner epoch (forward) and the physical target may
differ from the journal (a same-epoch restart can still find the target rotated).
Pending entries replay under the journal's own target with the adopted epoch, so an
exact lost-ACK retry resolves its original receipt instead of creating a second one;
the constructor then requires the replayed scope to equal the adopted one.
rÇ   ÚepochÚ
session_idc              3  óJ   <"  € T F  pSV,          SV,          8g  x € K  	  R # 5irc   r   )Ú.0r   ÚnewÚolds   & €€r
   Ú	<genexpr>Ú9RuntimeSessionStore._reconcile_adopted.<locals>.<genexpr>  s   øé € Ð=±u°�s˜3•x 3 s¥8Ö+³uùs   ƒ #TFÚexecution_idÚ
generationÚowner_epochÚstatusÚrunningc              3  ó8   "  € T F  qR ,          R8H  x € K  	  R# 5i)Ú	operationzcompression.publishNr   )ré   Úentrys   & r
   rì   rí   $  s   é € ð GfÙMdÀE˜+Õ&Ð*?Ö?ÓMdùs   ‚rÉ   rÊ   ©ræ   ©rÇ   N)rÚ   rÇ   Úsetr\   r]   Úanyr%   ÚtypeÚintr   rÜ   )rS   rá   ÚfixedÚ	candidaterê   rë   s   &&  @@r
   rÛ   Ú&RuntimeSessionStore._reconcile_adopted  sÇ  ù€ ð —<‘< Õ(¨$¯*©*ˆˆˆSÜ�C“˜G \Ð2Õ2ˆÜ˜7¤D×)Ó)¬S°«X¼¸S»Õ-Aß“3Õ=±uÓ=—3—3’3Õ=±uÓ=×=Ó=Ø—;‘;˜~Ó.°#·'±'¸.Ó2IÕIØ—;‘;˜|Ó,°·±¸Ó0EÕEØ—;‘;˜|Ó,°·±¸Ó0EÕEØ—;‘;˜}Ó-°·±¸Ó1AÔAÀWÇ[Á[ÐQYÓEZÐ^gÔEgÜ˜Ÿ™ Ó(Ó)´Ó4¼¸S¿W¹WÀWÓ=MÓ8NÔVYÓ8YØ�w•< # g¥,Ô.à˜Õ%¨¨\Õ):Ô:Ç3Ã3ñ GfØMQÏ\É\ÐZcÖMdóGfÇ3Ç3Â3ñ GfØMQÏ\É\ÐZcÖMdóGf÷ Dfò Dfä(Ð)@ÓAÐAÜ˜Ÿ™¬T°#¸SÀ½\Ô-JÔKˆ	Ø�
‰
�9ÔØ˜wÕ'ˆŒ
Ø Žr	   c                	óJ  € V P                   P                  '       d   \        R 4      h\        P                  ! VRRR
R7      P                  4       p\        V4      V P                  8”  d   RV n        \        V P                  4      h^ RI	H
p V! V P                  VRRRR7       R	# )Úoutbox_closedTF)Úensure_asciiÚ	allow_nanÚ
separatorsrÆ   )Úatomic_write_bytesz	.pending-rÄ   )Ú
tmp_prefixr¾   Ú	fsync_dirN)Ú,r    )rÕ   Úclosedr   rX   r´   Úencoder#   r¼   rÎ   Úutilsr  rÏ   )rS   rÚ   Úencodedr  s   &&  r
   rÜ   ÚRuntimeSessionStore._save,  s{   € Ø×Ñ×$×$Ð$Ü(¨Ó9Ð9Ü—*’*˜W°4À5ÐU_Ô`×gÑgÓiˆÜˆw‹<˜$Ÿ.™.Ô(Ø(ˆDŒLÜ(¨¯©Ó6Ð6Ý,á˜4Ÿ9™9 g¸+ÈEÐ]a×br	   c                	óJ   € WP                   R ,          8w  d   \        R4      hR# )rç   Úpermission_deniedN)rÇ   r   ©rS   rç   s   &&r
   Ú_sessionÚRuntimeSessionStore._session7  s"   € ØŸ™ LÕ1Ô1Ü(Ð)<Ó=Ð=ñ 2r	   c                	óì  € V P                   ;_uu_ 4        V P                  '       d   \        V P                  4      hV P                  R ,          '       d   \        R4      hRV P                  R,          RVRV/p\        P
                  ! \        P                  ! V P                  4      4      pVR ,          P                  \        P
                  ! \        P                  ! VRR7      4      4       VR;;,          ^,          uu&    V P                  V4       Y@n        T P                  4       ^ ,          uuRRR4       #   \         d   p\        T4      T n        h Rp?ii ; i  + '       g   i     R# ; i)	rÉ   Úpending_receiptÚsequencerÈ   rô   ÚpayloadF)r  N)rx   rÎ   r   rÚ   rX   rY   r´   r'   rÜ   r_   ÚstrrÝ   )rS   rô   r  rõ   rý   r`   s   &&&   r
   Ú_applyÚRuntimeSessionStore._apply;  s  € Ø�Y�Y‹YØ�|�|ˆ|Ü,¨T¯\©\Ó:Ð:Ø�|‰|˜I×&Ô&Ü,Ð->Ó?Ð?Ø §¡¨oÕ!>ÀÈYÐXaÐcjÐkˆEÜŸ
š
¤4§:¢:¨d¯l©lÓ#;Ó<ˆIØ�iÕ ×'Ñ'¬¯
ª
´4·:²:¸eÈuÔ3UÓ(VÔWØ�o×&¨!Õ+Ó&ðØ—
‘
˜9Ô%ð %ŒLØ×%Ñ%Ó'¨Õ*÷ ŠYøô ô Ü" 3›x�”Øûðú÷ �YˆYús7   •A E"ÁB/E"ÄD>ÄE"Ä>EÅ	EÅEÅE"Å"E3	c                	ó\  € V P                   ;_uu_ 4        . p V P                  R ,          '       d±   V P                  R ,          ^ ,          pV P                  ! R/ V P                  BVB p\	        V P                  V P                  R ,          R,          R7      pV P                  WC4      pV P                  V4       VR,          V n        W@n        VP                  V4       KÉ   RT n
        TuuRRR4       #   \         d   p\        T4      T n
        h Rp?ii ; i  + '       g   i     R# ; i)rÉ   :é   NN)rÉ   rÇ   N)zworker.persist)rx   rÚ   rÌ   rÇ   r]   Ú_compression_receipt_journalrÜ   r'   r_   r  rÎ   )rS   Úresultsrõ   r<   rý   r`   s   &     r
   rÝ   Ú!RuntimeSessionStore.retry_pendingM  së   € Ø�Y�Y‹YØˆGðØ—l‘l 9×-Ô-Ø ŸL™L¨Õ3°AÕ6�EØ!ŸXšXÑN¸$¿*¹*ÐNÈÑN�FÜ $ T§\¡\¸4¿<¹<È	Õ;RÐSUÕ;VÔ W�IØ $× AÑ AÀ)Ó T�IØ—J‘J˜yÔ)Ø!*¨7Õ!3�D”JØ#,”LØ—N‘N 6Ö*ð .ð  ˆDŒLØ÷! ŠYøô ô Ü" 3›x�”Øûðú÷ �YˆYús4   •D™C6²B0C6Ã"	DÃ6DÄDÄDÄDÄD+	c           
     ó  € V P                   ;_uu_ 4        \        V P                  \        V P                  VR7      R7      pV P	                  V4       VR,          V n        W n        RV n        RRR4       R#   + '       g   i     R# ; i)zIInstall only a separately verified worker.adopt result; never self-adopt.rö   r÷   rÇ   N)rx   r]   rÚ   rÇ   rÜ   rÎ   )rS   ræ   rý   s   && r
   ÚadoptÚRuntimeSessionStore.adopt`  sV   € à�Y�Y‹YÜ˜TŸ\™\´°d·j±jÈÔ1NÔOˆIØ�J‰J�yÔ!Ø" 7Õ+ˆDŒJØ$ŒLØˆDŒL÷ �Y�YŠYús   •AA8Á8B		ç     Àr@c                	óà   € V P                  V4       Ve   \        R4      hVf   VR8w  d   V P                  WVWF4      # V P                  RRVRV/4      p\	        W'R,          4       VR,          # )NÚunsupported_operationr!  ztranscript.appendr   Úturn_lease_holderr   Úcount)r  r   Ú_append_compression_messagesr  r   )rS   rç   r   Úcompression_lock_holderr$  Ú
chunk_rowsÚturn_lease_ttl_secondsr<   s   &&&&&&& r
   Úappend_messages_batchÚ)RuntimeSessionStore.append_messages_batchi  s|   € à�‰�jÔ!ØÒ!Ü(Ð)@ÓAÐAØ"Ò.Ð2HÈEÔ2QØ×4Ñ4°ZÐKbØ!ó;ð ;à—‘Ð0°:¸xÐI\Ð^oÐ2pÓqˆÜ˜h¨}Õ(=Ô>Ø�g�Ðr	   Úttl_secondsÚ
patience_sc               	ó^   € V P                  V4       V P                  R RVRV/4      R,          # )zturn.acquireÚholderr,  r   ©r  r  ©rS   rç   r/  r,  r-  s   &&&$$r
   Útry_acquire_session_turn_leaseÚ2RuntimeSessionStore.try_acquire_session_turn_leaseu  s.   € Ø�‰�jÔ!Ø�{‰{˜>¨H°f¸mÈ[Ð+YÓZÐ[bÕcÐcr	   Úwait_secondsg      œ@Úpoll_interval_secondsg      ð?Úon_waitÚwait_notice_interval_secondsg      .@Úshould_abortÚacquire_patience_sg      à?Úon_contendedc               	ó>   € ^ RI Hp VP                  WVW4WVVW‰V
R7      # )é    )ÚSessionCompressionMixin)r,  r4  r5  r6  r7  r8  r9  r:  )Úhermes_state_compressionr=  Úacquire_session_turn_lease)rS   rç   r/  r,  r4  r5  r6  r7  r8  r9  r:  r=  s   &&&$$$$$$$$ r
   r?  Ú.RuntimeSessionStore.acquire_session_turn_leasey  s5   € õ 	EØ&×AÑAÀ$ÐTZØ#Ø"7Ø)EØ%Ø%ð Bó 'ð 	'r	   c               	ó^   € V P                  V4       V P                  R RVRV/4      R,          # )z
turn.renewr/  r,  r   r0  r1  s   &&&$$r
   Úrefresh_session_turn_leaseÚ.RuntimeSessionStore.refresh_session_turn_lease‡  s.   € Ø�‰�jÔ!Ø�{‰{˜<¨(°F¸MÈ;Ð)WÓXÐY`ÕaÐar	   c                	ó2   € V P                  R RVRV/4       R# )zturn.cleanuprF   r/  N©r  )rS   rç   r/  s   &&&r
   Úrelease_session_turn_leaseÚ.RuntimeSessionStore.release_session_turn_lease‹  s   € à�‰�N X¨z¸8ÀVÐ$LÖMr	   c                	óL   € V P                  V4       V P                  R V4       R# )z
usage.mainNr0  )rS   rç   Úusages   &&,r
   Úqueue_token_countsÚ&RuntimeSessionStore.queue_token_counts�  s   € Ø�‰�jÔ!Ø�‰�L %Ö(r	   c                	ó`   € V P                  V4       V P                  R \        W2R7      4       R# )zusage.auxiliary)ÚtaskN)r  r  r]   )rS   rç   rM  rI  s   &&&,r
   Úrecord_auxiliary_usageÚ*RuntimeSessionStore.record_auxiliary_usage“  s"   € Ø�‰�jÔ!Ø�‰Ð%¤t¨EÔ'=Ö>r	   c                	ó   € V P                   ;_uu_ 4        V P                  '       d   \        V P                  4      hV P                  R ,          '       d   \        R4      h RRR4       R#   + '       g   i     R# ; i)rÉ   r  NT)rx   rÎ   r   rÚ   )rS   ri   s   &&r
   Úflush_token_countsÚ&RuntimeSessionStore.flush_token_counts—  sM   € Ø�Y�Y‹YØ�|�|ˆ|Ü,¨T¯\©\Ó:Ð:Ø�|‰|˜I×&Ô&Ü,Ð->Ó?Ð?Ø÷ �Y�YŠYús   •A A,ÁA,Á,A=	c                	óB   € V P                  V4      P                  R 4      # )Útitle©Úget_sessionr%   r  s   &&r
   Úget_session_titleÚ%RuntimeSessionStore.get_session_titleŸ  s   € Ø×Ñ 
Ó+×/Ñ/°Ó8Ð8r	   c                	óV   € V P                  V4       V P                  R / 4      R,          # )zsession.tail_roler   r0  r  s   &&r
   Úlatest_conversation_roleÚ,RuntimeSessionStore.latest_conversation_role¤  s%   € Ø�‰�jÔ!Ø�{‰{Ð.°Ó3°GÕ<Ð<r	   c                	ól   € V P                  V4       V P                  R R\        V4      /4      R,          # )zsession.row_roleÚrow_idr   )r  r  rû   )rS   rç   r]  s   &&&r
   Úget_message_roleÚ$RuntimeSessionStore.get_message_role¨  s.   € Ø�‰�jÔ!Ø�{‰{Ð-°¼#¸f»+Ð/FÓGÈÕPÐPr	   c                	óp   € V P                  V4      pR RRVP                  R4      RVP                  R4      /# )Úsession_existsTÚcooldown_untilÚ"compression_failure_cooldown_untilr®   Úcompression_failure_errorrU  )rS   rç   Úrows   && r
   Ú$get_compression_failure_cooldown_rowÚ8RuntimeSessionStore.get_compression_failure_cooldown_row¬  s?   € Ø×Ñ˜zÓ*ˆØ  $Ð(8¸#¿'¹'ÐBfÓ:gØ˜Ÿ™Ð!<Ó=ð?ð 	?r	   c                	óÚ   € ^ RI pVP                  4       pV P                  V4      pVR,          pVe   \        V4      V8:  d   R# R\        V4      R\        V4      V,
          RVR,          /# )r<  Nrb  Úremaining_secondsr®   )Útimerf  Úfloat)rS   rç   rj  Únowre  Údeadlines   &&    r
   Ú get_compression_failure_cooldownÚ4RuntimeSessionStore.get_compression_failure_cooldown±  sj   € ÛØ�i‰i‹kˆØ×7Ñ7¸
ÓCˆØÐ'Õ(ˆØÒœu X›°#Ô5ÙØ ¤%¨£/Ð3FÌÈhËÐZ]ÕH]Ø˜˜W�ð'ð 	'r	   c                	ó¬   € V P                  V4      p \        YC! VP                  V4      ;'       g    T4      4      #   \        \        3 d    Tu # i ; irc   )rV  Úmaxr%   Ú	TypeErrorr[   )rS   rç   ÚcolumnÚcastÚzerore  s   &&&&& r
   Ú_session_numberÚ#RuntimeSessionStore._session_number»  sR   € Ø×Ñ˜zÓ*ˆð	Ü�t˜T #§'¡'¨&£/×"9Ð"9°TÓ:Ó;Ð;øÜœ:Ð&ô 	ØŠKð	ús   “= ²
= ½AÁAc                	ó2   € V P                  VR \        ^ 4      # )Úcompression_fallback_streak©rv  rû   r  s   &&r
   Úget_compression_fallback_streakÚ3RuntimeSessionStore.get_compression_fallback_streakÂ  s   € Ø×#Ñ# JÐ0MÌsÐTUÓVÐVr	   c                	ó2   € V P                  VR \        ^ 4      # )Úcompression_ineffective_countrz  r  s   &&r
   Ú!get_compression_ineffective_countÚ5RuntimeSessionStore.get_compression_ineffective_countÅ  s   € Ø×#Ñ# JÐ0OÔQTÐVWÓXÐXr	   c                	ó2   € V P                  VR \        R4      # )Úcompression_recovery_deadlineg        )rv  rk  r  s   &&r
   Ú!get_compression_recovery_deadlineÚ5RuntimeSessionStore.get_compression_recovery_deadlineÈ  s   € Ø×#Ñ# JÐ0OÔQVÐX[Ó\Ð\r	   c                	óx   € ^ RI Hp V! V P                  V4      P                  R4      4      P                  W#4      # )r<  )Ú_parse_model_configÚmodel_config)Úhermes_state_sessionsr†  rV  r%   )rS   rç   r   Údefaultr†  s   &&&& r
   Úget_session_model_config_valueÚ2RuntimeSessionStore.get_session_model_config_valueË  s2   € Ý=Ù" 4×#3Ñ#3°JÓ#?×#CÑ#CÀNÓ#SÓT×XÑXÐY\ÓfÐfr	   c           
     	óx   € V P                  V4       V P                  WV! V P                  W4      4      /4       V# rc   )r  Úpatch_session_model_configrŠ  )rS   rç   r   Úupdates   &&&&r
   Ú&update_conversation_model_config_valueÚ:RuntimeSessionStore.update_conversation_model_config_valueÏ  s:   € ð 	�‰�jÔ!Ø×'Ñ'¨
¹&À×AdÑAdÐeoÓAuÓ:vÐ4wÔxØÐr	   c                	óX   € V P                   R ,          pV P                  W!4      e   V.# . # )rç   )rÇ   rŠ  )rS   r   Úsids   && r
   Ú!session_ids_with_model_config_keyÚ5RuntimeSessionStore.session_ids_with_model_config_keyÖ  s.   € à�j‰j˜Õ&ˆØ×;Ñ;¸CÓEÒQ�ˆuÐYÐWYÐYr	   c                	óP   € V P                  V4       V P                  R RV/4       R# )zsession.promptÚsystem_promptNr0  )rS   rç   r–  s   &&&r
   Úupdate_system_promptÚ(RuntimeSessionStore.update_system_promptÛ  s"   € Ø�‰�jÔ!Ø�‰Ð$ ¸Ð&FÖGr	   c                	óP   € V P                  V4       V P                  R RV/4       R# )zsession.sidecarsÚpatchNr0  )rS   rç   rš  s   &&&r
   r�  Ú.RuntimeSessionStore.patch_session_model_configß  s"   € Ø�‰�jÔ!Ø�‰Ð&¨°%Ð(8Ö9r	   c                	óP   € V P                  V4       V P                  R RV/4       R# )zsession.toolsÚ
tool_namesNr0  )rS   rç   Úpins   &&&r
   Úupdate_session_tool_namesÚ-RuntimeSessionStore.update_session_tool_namesã  s#   € ð 	�‰�jÔ!Ø�‰�O l°CÐ%8Ö9r	   c                	ó&   € V P                  R / 4      # )zexecution.finishrE  r¦   s   &r
   ÚfinishÚRuntimeSessionStore.finishé  s   € Ø�{‰{Ð-¨rÓ2Ð2r	   c                	óþ   € V P                   ;_uu_ 4         V P                  4        V P                  P                  4         R R R 4       R #   T P                  P                  4        i ; i  + '       g   i     R # ; irc   )rx   rQ  rÕ   r£   r¦   s   &r
   r£   ÚRuntimeSessionStore.closeì  sU   € Ø�Y�Y‹Yð+Ø×'Ñ'Ô)à×"Ñ"×(Ñ(Õ*÷	 ‰Yøð ×"Ñ"×(Ñ(Õ*ú÷	 �YˆYús!   •A+—A§A+ÁA(Á(A+Á+A<	)rÕ   rÎ   rÚ   rx   r¼   rÏ   rÌ   rÇ   rc   i  @ )NNNr!  )g      @)'r   r   r   r   rq   rÞ   rT   rÛ   rÜ   r  r  rÝ   r  r*  r2  r?  rB  rF  rJ  rN  rQ  rW  rZ  r^  rf  rn  rv  r{  r  rƒ  rŠ  r�  r“  r—  r�  rŸ  r¢  r£   r   r   r	   r
   r»   r»   Ø   s&  † ñð #Ðñ+È/õ +òZ!ò:	cò>ò+ò$ò& ô
ðdÐPUð dÐbfô dð'ÈEð 'Øð'Ø7:ð'ØDHð'à)-ð'à<@ð'àUXð'ð ô'ðbÈEð bÐ^bô bòNò)ò?ôò9ò
=òQò?ò
'òòWòYò]ôgòòZò
Hò:ò:ò3ö+r	   r»   )é   )#rq   Ú
__future__r   r5   r    r8   Úconcurrent.futuresr   rX   Úloggingr–   Úpathlibr   rK   r!   rN   Úhermes_dir_aclr   Ú	getLoggerr   r°   r   r   r   r7   r   r1   rB   rD   rs   Ú!agent.runtime_session_compressionr¸   Úagent.runtime_session_lifecycler¹   r»   r   r	   r
   Ú<module>r¯     sŸ   ðñõ
 #ã Û Û Ý 1Û Û Û 	Ý Û Û 
Û Ý (à	×	Ò	˜8Ó	$€à€òò%ô	˜\ô 	ô	òF÷$#ñ #÷LY&ñ Y&õx Mõ IôY+Ð8Ð:Vö Y+r	   