Ë
    ãß²ja  ã                   óp   — d Z ddlZddlmZ dZ G d„ d«      Zdefd„Zdd	efd
„Z	 G d„ d«      Z
 e
«       Zy)uG  Origin-module lookup shared by the ``tools.browser_tool_*`` extraction modules.

Extracted code reads facade-owned state (caches, locks, session tables, facade-defined
helpers) *through* ``tools.browser_tool`` and must not import it at import time (cycle) â€”
hence the lazy :func:`origin_module` and the :data:`origin` proxy.
é    N)Ú
ModuleTypeztools.browser_toolc                   ó&   — e Zd ZdZdZd„ Zd„ Zd„ Zy)Ú_NamespaceViewz Live view over a module namespace whose module object is gone (a test purged
    ``sys.modules``): the old code still runs with its own globals, so hit *those*.©Ú_gc                 ó2   — t         j                  | d|«       y )Nr   )ÚobjectÚ__setattr__)ÚselfÚgs     ú>/home/ubuntu/.hermes/hermes-agent/tools/browser_tool_origin.pyÚ__init__z_NamespaceView.__init__   s   € Ü×Ñ˜4  qÕ)ó    c                 óT   — 	 | j                   |   S # t        $ r t        |«      d ‚w xY w©N)r   ÚKeyErrorÚAttributeError©r   Únames     r   Ú__getattr__z_NamespaceView.__getattr__   s1   € ð	1Ø—7‘7˜4‘=Ð øÜò 	1Ü  Ó&¨DÐ0ð	1ús   ‚ ‘'c                 ó"   — || j                   |<   y r   r   ©r   r   Úvalues      r   r
   z_NamespaceView.__setattr__   s   € Øˆ�‰�Šr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r
   © r   r   r   r      s   „ ñWð €Iò*ò1ór   r   r   c                 ó´   — ddl }t        j                  j                  t        «      t        |dd«      fD ]  }|€Œ|j                  | u sŒ|c S  t        | «      S )zDThe module object whose namespace is ``g`` (or a live view over it).r   NÚbrowser_tool)ÚtoolsÚsysÚmodulesÚgetÚ_ORIGIN_NAMEÚgetattrÚ__dict__r   )r   r"   Úmods      r   Ú_module_for_globalsr*   !   sQ   € ãä—‘—‘¤Ó-¬w°u¸nÈdÓ/SÐTò ˆØ‰?˜sŸ|™|¨qÒ0ØŠJðô ˜!ÓÐr   Ú_depthc                 ó,  — 	 t        j                  | «      }|}|�F|j                  j	                  d«      t
        k(  rt        |j                  «      S |j                  }|�ŒF|}|�`t        |j                  j                  «       «      D ]+  }t        |t        «      sŒt        |dd«      t
        k(  sŒ)|c S  |j                  }|�Œ`t         j                  j	                  t
        «      }|€ddl}t        |dd«      }|€ddlm} |S # t        $ r d}Y Œûw xY w)a¿  The ``tools.browser_tool`` instance the *calling* moved function belongs to, mirroring
    what in-file code would see: (1) the nearest enclosing frame executing origin code (the
    exact module copy, even after a test purged/reloaded ``sys.modules``); (2) an origin
    module referenced from a calling frame's globals; (3) ``sys.modules`` / ``tools``
    package attribute / fresh import. ``_depth`` is the frame of the moved function's caller.Nr   r   r!   )r#   Ú	_getframeÚ
ValueErrorÚ	f_globalsr%   r&   r*   Úf_backÚlistÚvaluesÚ
isinstancer   r'   r$   r"   Útools.browser_toolr!   )r+   ÚstartÚframer   r)   r"   s         r   Úorigin_moduler7   +   s  € ðÜ—‘˜fÓ%ˆð €EØ
Ð
Ø�?‰?×Ñ˜zÓ*¬lÒ:Ü& u§¡Ó7Ð7Ø—‘ˆð Ñ
ð €EØ
Ð
Ü˜%Ÿ/™/×0Ñ0Ó2Ó3ò 	ˆEÜ˜%¤Õ,´¸À
ÈDÓ1QÔUaÓ1aØ’ð	ð —‘ˆð	 Ñ
ô
 �+‰+�/‰/œ,Ó
'€CØ
€{Ûä�e˜^¨TÓ2ˆØ
€{Ý(Ø€Jøô) ò ØŠðús   ‚D ÄDÄDc                   ó    — e Zd ZdZdZd„ Zd„ Zy)Ú_OriginProxyztModule-level ``_bt`` stand-in: every attribute read/write forwards to the origin
    module resolved at that moment.r   c                 ó,   — t        t        d«      |«      S ©Né   )r'   r7   r   s     r   r   z_OriginProxy.__getattr__P   s   € Ü”} QÓ'¨Ó.Ð.r   c                 ó0   — t        t        d«      ||«       y r;   )Úsetattrr7   r   s      r   r
   z_OriginProxy.__setattr__S   s   € Ü”˜aÓ  $¨Õ.r   N)r   r   r   r   r   r   r
   r   r   r   r9   r9   J   s   „ ñ'ð €Iò/ó/r   r9   )é   )r   r#   Útypesr   r&   r   Údictr*   Úintr7   r9   Úoriginr   r   r   ú<module>rD      sL   ðñó Ý à#€÷ñ ð&˜4ó ñ˜#ó ÷>
/ñ 
/ñ 
‹�r   