+
    lHàj}  ã                  óþ   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^g]! R4      ,
          ^@,
          t^k]! R4      ,
          ^@,
          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 ltR# )a'  Per-profile runtime and tmp dirs for browser-harness daemons (Browser Use mode).

A multiplexed gateway serves every profile from one process. The harness names a daemon by
``BU_NAME`` alone and reuses any live one, so each served profile gets its own runtime dir (daemon
sockets) and tmp dir (screenshots, debug overlays, logs). A runtime dir too long for a 64-character
session's AF_UNIX socket moves to a private short dir under the socket temp root.

``browser_use_cli._base_subprocess_env`` applies the result through ``namespace_harness_dirs``.
)ÚannotationsN)ÚPath)ÚOptionalz	/bu-.sockc               ó    € V ^8„  d   QhRRRR/# )é   ÚenvÚdictÚreturnútuple[str, ...]© )Úformats   "Ú?/home/ubuntu/.hermes/hermes-agent/tools/browser_harness_dirs.pyÚ__annotate__r      s   € ÷ Xñ X˜ð X /ñ Xó    c                óN   a € . V 3R l\          4       OS P                  RR4      N5# )zQ``(*HARNESS_DIR_KEYS values, BU_NAME)`` of the daemon a call with ``env`` drives.c              3  óH   <"  € T F  pSP                  VR 4      x € K  	  R# 5i)Ú N)Úget)Ú.0Úkr   s   & €r   Ú	<genexpr>Ú"daemon_identity.<locals>.<genexpr>    s   øé € Ð7Ñ&6 ˆc�g‰g�a˜�nˆnÓ&6ùs   ƒ"ÚBU_NAMEÚdefault)ÚHARNESS_DIR_KEYSr   )r   s   fr   Údaemon_identityr      s%   ø€ àWÔ7Õ&6Ó7ÐW¸¿¹ÀÈIÓ9VÑWÐWr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Úidentityr
   r	   r   )r   s   "r   r   r   #   s!   € ÷ 'ñ '�Dð ' Oð '¸ñ 'r   c                óÒ   € VEv r#V P                  4        UUu/ uF  w  rEV\        9  g   K  WEbK  	  pppVP                  R \        \        V4       4       4       / VCRV/C# u uppi )zO``env`` re-pointed at the daemon ``identity`` names (its own dirs and BU_NAME).c              3  ó@   "  € T F  w  rV'       g   K  W3x € K  	  R # 5i©Nr   )r   r   Úvs   &  r   r   Údaemon_env.<locals>.<genexpr>'   s   é € ÐFÑ%@™T˜QÄA”&�1•&Ó%@ùs   ‚“r   )Úitemsr   ÚupdateÚzip)r   r   ÚdirsÚnamer   r!   Útargets   &&     r   Ú
daemon_envr)   #   sc   € à�K€TØ"Ÿy™yœ{ÔH™{‘t�q¨aÔ7GÑ.GŒdˆaŠd™{€FÑHØ
‡M�MÑF¤SÔ)9¸4Ô%@ÓFÔFØ&ˆfÐ&�i Ñ&Ð&ùó Is
   ˜A#¬A#c               ó    € V ^8„  d   QhRRRR/# )r   ÚplatformÚstrr	   úOptional[int]r   )r   s   "r   r   r   +   s   € ÷ ñ  ð ¨ñ r   c                óZ   € V R8X  d   \         # V P                  R4      '       d   \        # R# )zzThe runtime-dir byte budget on ``platform`` (a ``sys.platform`` value) where the harness binds
AF_UNIX sockets, else None.ÚdarwinÚlinuxN)Ú_MACOS_SOCKET_DIR_BUDGETÚ
startswithÚ_LINUX_SOCKET_DIR_BUDGET)r+   s   &r   Úsocket_dir_budgetr4   +   s,   € ð �8ÔÜ'Ð'Ø×Ñ˜7×#Ò#Ü'Ð'Ùr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úresolved_dirr,   Úbudgetr-   r	   Úboolr   )r   s   "r   r   r   5   s&   € ÷ Bñ B Sð B°-ð BÀDñ Br   c                óR   € VRJ ;'       g    \        V P                  4       4      V8*  # )zªWhether a 64-character session's socket under ``resolved_dir`` (the absolute, symlink-resolved
path the harness binds) fits ``budget``; no budget means no sun_path limit.N)ÚlenÚencode)r6   r7   s   &&r   Úfits_socket_budgetr<   5   s)   € ð �Tˆ>×AÐAœS ×!4Ñ!4Ó!6Ó7¸6ÑAÐAr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Útagr,   r	   ÚNoner   )r   s   "r   r   r   ;   s!   € ÷ #ñ # ð #¨3ð #°4ñ #r   c           	     óà  € V'       g   R# V P                  R4      ;'       g    V P                  R4      pV'       gƒ   V P                  R4      pV'       d   \        \        V4      R,          4      MM\        \        V P                  R4      ;'       g    \        P                  ! 4       4      R,          R,          4      p\        \        V4      P	                  4       4      pR\
        P                  ! VP                  4       4      P                  4       R	,           2pV P                  R
4      ;'       g5    V P                  R4      ;'       g    \        \        V4      R,          4      p\        \        V4      V,          4      p\        WeV4      V R
&   RV R&   \        \        V P                  R4      ;'       g    \        \        V4      R,          4      4      V,          4      V R&   RV R&   R# )z¢Give served profile ``tag`` its own harness runtime and tmp dirs in the child ``env``. An empty
``tag`` (outside a served-profile scope) leaves ``env`` unchanged.NÚBH_HOMEÚBROWSER_HARNESS_HOMEÚXDG_CONFIG_HOMEzbrowser-harnessÚHOMEz.configzp-ºNé   NÚBH_RUNTIME_DIRÚ
BH_TMP_DIRÚruntimeÚ1ÚBH_RUNTIME_DIR_SHAREDÚtmpÚBH_TMP_DIR_SHARED)
r   r,   r   ÚhomeÚ
expanduserÚhashlibÚsha256r;   Ú	hexdigestÚsocket_fit_runtime_dir)r   r>   ÚrootÚxdgÚleafÚbaserI   s   &&     r   Únamespace_harness_dirsrX   ;   so  € ÷ ÙØ�7‰7�9Ó×@Ð@ §¡Ð)?Ó!@€DßØ�g‰gÐ'Ó(ˆß58Œs”4˜“9Ð0Õ0Ô1¼cÜ�—‘˜“×/Ð/¤D§I¢I£KÓ0°9Õ<Ð?PÕPó?RˆäŒt�D‹z×$Ñ$Ó&Ó'€DØ”—’˜sŸz™z›|Ó,×6Ñ6Ó8¸Õ=Ð>Ð?€DØ�7‰7Ð#Ó$×\Ð\¨¯©°Ó(=×\Ð\ÄÄTÈ$ÃZÐR[ÕE[ÓA\€DÜ”$�t“*˜tÕ#Ó$€GÜ2°7À#ÓF€CÐÑØ#&€CÐÑ äœD §¡¨Ó!6×!QÐ!Q¼#¼dÀ4»jÈ5Õ>PÓ:QÓRÐUYÕYÓZ€CˆÑØ"€CÐÓr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rI   r,   rW   r>   r	   r   )r   s   "r   r   r   P   s(   € ÷ ñ  Cð ¨sð ¸ð Àñ r   c                óf  € \        \        P                  4      p\        \	        \        V 4      P                  4       P                  4       4      V4      '       d   V # ^ RIH	p \        \        RR 4      p\        P                  ! V! 4        RV RV 2P                  4       4      P                  4       R,          p\         P#                  R V! 4       R3 4       4      pV FN  p\        P$                  P'                  VRV 24      p	\        W“4      '       g   K9  \)        V	4      '       g   KL  V	u # 	  V # )	a
  ``runtime`` unless the socket the harness binds under it would be too long for a 64-character
session. The harness binds ``Path(BH_RUNTIME_DIR).expanduser().resolve()``, so the length is
judged on that path (a short relative or symlinked spelling can still resolve deep); a dir that
fits is returned as given. Otherwise the served profile gets a private dir under the short socket
temp root (``hbh-<12 hex>``), keyed by uid, base and profile; if none fits or can be claimed safely
the long path stays (shorter names only).)Úsocket_safe_tmpdirÚgetuidc                 ó   € ^ # )é    r   r   r   r   Ú<lambda>Ú(socket_fit_runtime_dir.<locals>.<lambda>[   s   € ©1r   Ú rE   c              3  ó`   "  € T F$  p\         P                  P                  V4      x € K&  	  R # 5ir    )ÚosÚpathÚrealpath)r   Úrs   & r   r   Ú)socket_fit_runtime_dir.<locals>.<genexpr>_   s$   é € ÐVÑ7U°!œ"Ÿ'™'×*Ñ*¨1×-Ð-Ó7Uùs   ‚,.z/tmpzhbh-)r4   Úsysr+   r<   r,   r   rO   ÚresolveÚhermes_constantsr[   Úgetattrrc   rP   rQ   r;   rR   r   Úfromkeysrd   ÚjoinÚclaim_private_dir)
rI   rW   r>   r7   r[   r\   ÚdigestÚrootsrT   Úshorts
   &&&       r   rS   rS   P   sí   € ô œsŸ|™|Ó,€FÜœ#œd 7›m×6Ñ6Ó8×@Ñ@ÓBÓCÀV×LÒLØˆÝ3Ü”R˜¡9Ó-€FÜ�^Š^™v›x˜j¨¨4¨&°°3°%Ð8×?Ñ?ÓAÓB×LÑLÓNÈsÕS€Fô �M‰MÑVÑ8JÓ8LÈfÑ7UÓVÓV€EÛˆÜ—‘—‘˜T T¨&¨ ?Ó3ˆÜ˜e×,Ô,Ô1BÀ5×1IÔ1IØŠLñ ð €Nr   c               ó    € V ^8„  d   QhRRRR/# )r   rd   r,   r	   r8   r   )r   s   "r   r   r   g   s   € ÷ (ñ (˜Cð ( Dñ (r   c                óž  €  \         P                  ! V R4       R#   \         d     M\         d     R# i ; i \         P                  ! T 4      pM  \         d     R# i ; i\
        P                  ! TP                  4      ;'       dE    TP                  \        \         RR 4      ! 4       8H  ;'       d    TP                  ^?,          '       * # )zùCreate ``path`` 0700, or accept an existing one only when it is a real directory (not a
symlink) owned by this uid and closed to group/other: the temp root is world-writable, and the
harness resolves symlinks and only chmods a dir it created itself.iÀ  TFr\   c                 ó   € R# )é   éÿÿÿÿr   r   r   r   r_   Ú#claim_private_dir.<locals>.<lambda>v   s   € ÑTVr   )
rc   ÚmkdirÚFileExistsErrorÚOSErrorÚlstatÚstatÚS_ISDIRÚst_modeÚst_uidrk   )rd   Ústs   & r   rn   rn   g   s¨   € ðÜ
�Š��uÔÙøÜô ÙÜô ÚðúðÜ�XŠX�d‹^‰øÜô Úðúä�LŠL˜Ÿ™Ó$÷ 'ð '¨¯©´g¼bÀ(ÉJÔ6WÓ6YÑ)Y÷ 'ð 'Ø—J‘J Õ&Ô&ð(s%   ‚ ›6¨6±6µ6ºA ÁA ÁA )rG   rK   rH   rM   )Ú__doc__Ú
__future__r   rP   rc   r|   rh   Úpathlibr   Útypingr   r:   r1   r3   r   r   r)   r4   r<   rX   rS   rn   r   r   r   Ú<module>r…      s{   ðñõ #ã Û 	Û Û 
Ý Ý ð
 ¡ [Ó!1Õ1°BÕ6Ð Ø¡ [Ó!1Õ1°BÕ6Ð ð bÐ õXõ
'õõBõ#õ*÷.(r   