Ë
    ãß²jçS  ã                   ó8  — U d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZmZ ddlmZ ddlmZ dZ	 ddlZ ej.                  e«      Z ed	d¬
«      Zeeeeef         ed<   defd„ZddlmZm Z m!Z!m"Z" dSd„Z#de$de$dee$ef   dee$   fd„Z%d„ d„ fd„ d„ fd„ d„ fdœZ&dee$ef   de$fd„Z'	 dTde$de$d ee$   d!ee$   d"eeee$ef         dee$   fd#„Z(dee$   fd$„Z)d%Z*dUdee$   fd'„Z+	 	 	 dVde$de$d e$d!e$d(e$d"eeee$ef         d)ee!   de$fd*„Z,dTd+eee$ef      dee$ef   fd,„Z-dTd+eee$ef      deeef   fd-„Z.edefd.„«       Z/d)dde$deee$ef      fd/„Z0dee$ef   d)ddee$ef   fd0„Z1d&d1d2d3g d¢d4d5œd3d&d6gd7d5œd3d8d9œd3d:d9œd3d;d9œd<d=d2d3g d¢d>œd3d?d9œd3d@d9œd3dAd9œdBœdgdCœdDœdEœdgdCœdFœZ2dGdHdIœZ3dee$ef   fdJ„Z4ddKlm5Z5m6Z6  e5jn                  d&d&e2dL„ e/dMe4¬N«       ddOl8m9Z9 ddl:Z:dPdQiZ;dR„ Z<y# e$ r dZ	 ddlZn# e$ r Y nw xY wY �ŒÕw xY w)Wa4  Memory Tool - persistent curated memory (MEMORY.md = agent notes, USER.md = user
profile). Both enter the system prompt as a FROZEN snapshot at session start;
mid-session writes hit disk but never change the prompt (prefix cache intact).
Single `memory` tool: add/replace/remove or a batch `operations` list.é    N)Ú
ContextVar)ÚPath©Úget_hermes_home)ÚDictÚAnyÚListÚOptionalÚTuple)Úis_truthy_value)Úno_cache_check_fnÚmemory_surface_flags©ÚdefaultÚ_memory_surface_flagsÚreturnc                  ó   — t        «       dz  S )zUProfile-scoped memories dir, resolved per call (HERMES_HOME may switch after import).Úmemoriesr   © ó    ú6/home/ubuntu/.hermes/hermes-agent/tools/memory_tool.pyÚget_memory_dirr   &   s   € äÓ˜zÑ)Ð)r   )ÚENTRY_DELIMITERÚMEMORY_BLOCK_HEADERSÚMemoryStoreÚ_scan_memory_contentr   c            	      ó0  — 	 ddl m}   | «       xs i }t        |«      }t        |«      \  }}t	        t        |j                  dd«      «      t        |j                  dd«      «      ||¬«      }|j                  «        |S # t        $ r t	        «       }Y Œ'w xY w)zïFresh on-disk MemoryStore with configured limits/flags for contexts with no live
    agent (gateway, Desktop, ``/memory``) so approvals enforce the SAME caps as
    ``agent_init``. Falls back to defaults if config can't load; never raises.r   )Úload_configÚmemory_char_limiti˜  Úuser_char_limiti_  ©Úmemory_enabledÚuser_profile_enabled)	Úhermes_cli.configr   Úget_builtin_memory_configÚget_builtin_memory_store_flagsr   ÚintÚgetÚ	ExceptionÚload_from_disk)r   ÚconfigÚmem_cfgr"   r#   Ústores         r   Úload_on_disk_storer.   /   s“   € ðÝ1Ù“Ò$ "ˆÜ+¨FÓ3ˆÜ/MÈfÓ/UÑ,ˆÐ,ÜœC §¡Ð,?ÀÓ FÓGÌÈWÏ[É[ÐYjÐlpÓMqÓIrØ+9ÐPdôfˆð 
×ÑÔØ€Løô ò Ü“Šðús   ‚A+A? Á?BÂBÚsummaryÚdetailÚpayloadc           	      ó†  — 	 ddl m} |j                  |j                  | |¬«      }|j
                  ry|j                  rt        |j                  d¬«      S |j                  |j                  || › d|dd › �|j                  «       ¬	«      }t        j                  d
d
|d   |j                  dœd¬«      S # t        $ r Y yw xY w)z˜JSON tool-result string when the write must NOT proceed (blocked or staged
    for approval), None to proceed. Fails open if the gate module can't load.r   ©Úwrite_approvalN)Úinline_summaryÚinline_detailF©Úsuccessú: éx   ©r/   ÚoriginTÚid)r8   ÚstagedÚ
pending_idÚmessage©Úensure_ascii)Útoolsr4   r)   Úevaluate_gateÚMEMORYÚallowÚblockedÚ
tool_errorr@   Ústage_writeÚcurrent_originÚjsonÚdumps)r/   r0   r1   ÚwaÚdecisionÚrecords         r   Ú_gate_or_stagerP   @   sÁ   € ðÝ.ð ×Ñ §	¡	¸'ÐQWÐÓX€HØ‡~‚~ØØ×ÒÜ˜(×*Ñ*°EÔ:Ð:Ø�^‰^˜BŸI™I w¸7¸)À2ÀfÈTÈcÀlÀ^Ð8TÐ]_×]nÑ]nÓ]pˆ^Óq€FÜ�:‰: $°$ÀfÈTÁlÐ_g×_oÑ_oÑpØ#(ô*ð *øô ò Ùðús   ‚B4 Â4	C Â?C c                 ó&   — | j                  ||«      S ©N)Úadd©r-   ÚtargetÚcontentÚold_texts       r   ú<lambda>rX   S   s   € °U·Y±Y¸vÀwÓ5O€ r   c                 ó   — d| › �|xs dfS )Nzadd to Ú r   ©ÚlabelrV   rW   s      r   rX   rX   T   s   € °¸°wÐ.?ÀÂÈBÐ-O€ r   c                 ó(   — | j                  |||«      S rR   )ÚreplacerT   s       r   rX   rX   U   s   € ¸¿¹ÀvÈxÐY`Ó9a€ r   c                 ó   — d| › �d|› d|› �fS )Nzreplace in zentry matching: z
whole entry becomes: r   r[   s      r   rX   rX   V   s&   € °KÀ¸wÐ2GØ4DÀXÀJÐNeÐfmÐenÐ2oð2q€ r   c                 ó&   — | j                  ||«      S rR   )ÚremoverT   s       r   rX   rX   X   s   € ¸¿¹ÀVÈXÓ8V€ r   c                 ó   — d| › �|xs dfS )Nzremove from rZ   r   r[   s      r   rX   rX   Y   s   € °<À¸wÐ1GÈÊÐUWÐ0X€ r   )rS   r^   ra   Úopc                 óä   — | xs i } | j                  dd«      | j                  d«      xs | j                  d«      xs d| j                  dd«      }}}|dk(  rd|› �S |d	k(  rd
|› d|› �S d|› d|› �S )NÚactionú?rV   Únew_textrZ   rW   ra   z
- remove: r^   z- replace entry matching 'z' -> whole entry becomes: z- r9   )r(   )rc   ÚactrV   Úolds       r   Ú_batch_op_linerj   \   s˜   € Ø	Šˆr€BØŸ™˜x¨Ó-¨r¯v©v°iÓ/@Ò/\ÀBÇFÁFÈ:ÓDVÒ/\ÐZ\Ð^`×^dÑ^dÐeoÐqsÓ^t�#ˆ€CØ
ˆh‚Ø˜C˜5Ð!Ð!àUXÐ\eÒUeÐ(¨¨Ð-GÈÀyÐQð (Ø�c�U˜"˜W˜IÐ&ð(r   re   rU   rV   rW   Ú
operationsc                 óÊ   — |dk(  rdnd}|�6t        dt        |«      › d|› �dj                  d„ |D «       «      d||d	œ«      S t        g t        |    d
   |||«      ¢| |||dœ‘­Ž S )zMGate one mutating op, or (``operations`` set) a whole batch as a single unit.Úuserzuser profileÚmemoryzapply z
 op(s) to Ú
c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrR   ©rj   ©Ú.0rc   s     r   ú	<genexpr>z$_apply_write_gate.<locals>.<genexpr>l   s   è ø€ Ò'P¸r¬°r×(:Ñ'Pùó   ‚Úbatch©re   rU   rk   é   ©re   rU   rV   rW   )rP   ÚlenÚjoinÚ_STORE_ACTIONS)re   rU   rV   rW   rk   r\   s         r   Ú_apply_write_gater}   f   s—   € ð %¨Ò.‰N°H€EØÐÜ ¤s¨:£Ð&7°zÀ%ÀÐIØ"Ÿi™iÑ'PÀZÔ'PÓPØ)0¸FÐR\Ñ]ó_ð 	_ô ð jœ>¨&Ñ1°!Ñ4°U¸GÀXÓNð jØ%+°vÈ'Ð_gÑhòjð jr   c                 óþ   — |dk(  r|st        dd¬«      S |dv rQ|sO|dk(  rdnd}t        j                  dd	|› d
|› d|› d|› �| j                  |«      | j	                  |«      dœd¬«      S |dk(  r|st        dd¬«      S y)uý   Validate BEFORE the gate so an invalid write is rejected now, not at approve time.
    Missing ``old_text`` is recoverable (it can't be schema-required â€” needs a combinator
    the Codex backend rejects): return the inventory plus a retry instruction.rS   z%Content is required for 'add' action.Fr7   ©r^   ra   r^   zx For 'replace', content is the COMPLETE new entry -- the whole matched entry is overwritten, not just the old_text span.rZ   ú'z=' needs old_text -- a short unique substring of the entry to z!. None was provided. Reissue the z? with old_text set to part of one of the current_entries below.)r8   ÚerrorÚcurrent_entriesÚusagerA   z)content is required for 'replace' action.N)rH   rK   rL   Ú_entries_forÚ_usage)r-   re   rU   rV   rW   Úreplace_hints         r   Ú_validate_single_opr‡   r   sÆ   € ð �‚™wÜÐAÈ5ÔQÐQØÐ&Ñ&©xð " YÒ.ñTà46ð 	ô �z‰zØØ˜&˜ð "Ø"˜8Ð#DÀVÀHð MIØIUÈðXð  %×1Ñ1°&Ó9ÀEÇLÁLÐQWÓDXñZð
 inôoð 	oð �Ò¡7ÜÐEÈuÔUÐUØr   r   rn   c           
      ó  — ddl m}  |«       sy| t        v xs t        d„ |xs g D «       «      }|sy|�d||dœn| |||dœ}|�dj	                  d	„ |D «       «      nt        | ||d
œ«      }	 ddlm}	 |	j                  |	j                  |d|�dn| › d|› d|› �dd |	j                  «       ¬«      }
t        j                  ddd|
d   d|�dn| › d�dœd¬«      S # t        $ r' t        j                  dd¬«       t!        dd¬«      cY S w xY w)uû  Fail-closed operation gate for unattended background-review forks (#105921): ``add``
    stays available (it is all any review prompt asks for), while ``replace``/``remove`` â€”
    single or inside a batch â€” are never applied unattended. The op is staged in the pending
    store instead of merely denied: the fork's own review summary is never published back, so
    a plain denial would drop the consolidation request with no surfacing path at all. A
    staging failure fails closed to a plain denial.r   )Úis_unattended_reviewNc              3   ón   K  — | ]-  }t        |t        «      xr |j                  d «      t        v –— Œ/ y­w)re   N)Ú
isinstanceÚdictr(   Ú_BG_DELETE_ACTIONSrr   s     r   rt   z*_background_delete_gate.<locals>.<genexpr>•   s5   è ø€ ò .fØLNŒ
�2”tÓÒG §¡¨Ó!1Ô5GÐ!GÓGñ.fùs   ‚35rv   rw   ry   z; c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrR   rq   rr   s     r   rt   z*_background_delete_gate.<locals>.<genexpr>œ   s   è ø€ Ò@¨rœ r×*Ñ@ùru   )re   rV   rW   r3   z!background review consolidation (z on z): éÈ   r;   Tr=   zIBackground review may not delete memory entries unattended. The proposed ue    was staged for your approval â€” review it with /memory pending (approve to apply, discard to drop).)r8   r>   Úproposal_stagedr?   r@   FrA   z8Failed to stage background-review consolidation; denying©Úexc_infozuBackground review may not delete memory entries ('replace'/'remove', including in a batch); 'add' is still available.r7   )Útools.skill_provenancer‰   r�   Úanyr{   rj   rC   r4   rI   rE   rJ   rK   rL   r)   ÚloggerÚwarningrH   )re   rk   rU   rV   rW   r‰   Úhitr1   r0   rM   rO   s              r   Ú_background_delete_gater˜   Š   s  € õ <áÔ!ØØ
Ô&Ð
&ò f¬#ñ .fØS]ÒScÐacô.fó +f€CáØàÐ(ð "¨VÀ:ÒNà ¨F¸wÐT\Ñ]ð ð EOÐDZˆd�i‰iÑ@°ZÔ@Ô@Ü!¨VÀÐU]Ñ"^Ó_ð ð@Ý.Ø—‘Ø�I‰I�wØ8ÀJÐDZ¹Ð`fÐ8gð hØ!˜( # f Xð/Ø04°ð6à×$Ñ$Ó&ð	  ó (ˆô
 �z‰zØ tÀÐTZÐ[_ÑT`ØcØ&0Ð&<™7À&ÐIð J^ð^ñ
ð
 ôð 	øô ò @Ü�‰ÐQÐ\`ˆÔaÜð0Ø9>ô@ò 	@ð@ús   Á+A*C Ã-DÄDrg   r-   c                 ó>  — |€t        dd¬«      S |€|�|}|€dn|}t        ||«      }|�t        j                  |«      S |rht	        |t
        «      st        dd¬«      S t        | ||«      }|�|S t        d|dd|«      }	|	�|	S t        j                  |j                  ||«      d¬«      S | t        vrt        d	| › d
�d¬«      S t        || |||«      xs t        | d|||«      xs t        | |||«      }
|
�|
S t        j                  t        |    d   ||||«      d¬«      S )a-  Tool entry point; returns a JSON string. Single op (action + content/old_text)
    or batch (``operations``, atomic against the final budget). ``new_text``
    aliases ``content`` -- for 'replace' both mean the COMPLETE new entry (the
    whole matched entry is overwritten; old_text only locates it).NzJMemory is not available. It may be disabled in config or this environment.Fr7   rn   zCoperations must be a list of {action, content?, old_text?} objects.rv   rA   zUnknown action 'z'. Use: add, replace, remover   )rH   Ú_memory_target_errorrK   rL   r‹   Úlistr˜   r}   Úapply_batchr|   r‡   )re   rU   rV   rW   rg   rk   r-   Útarget_errorÚdeniedÚgate_resultÚinvalids              r   Úmemory_toolr¡   ²   sX  € ð €}ÜÐfÐpuÔvÐvØ€˜8Ð/Øˆà˜‰X¨V€FÜ'¨¨vÓ6€LØÐÜ�z‰z˜,Ó'Ð'ÙÜ˜*¤dÔ+ÜÐcÐmrÔsÐsÜ(¨°¸VÓDˆØÐØˆMä'¨°¸¸tÀZÓPˆØÐ"ØÐÜ�z‰z˜%×+Ñ+¨F°JÓ?ÈeÔTÐTØ”^Ñ#ÜÐ,¨V¨HÐ4PÐQÐ[`ÔaÐaÜ" 5¨&°&¸'À8ÓLò GÜ)¨&°$¸ÀÈÓRòGä# F¨F°G¸XÓFð ð ÐØˆÜ�:‰:”n VÑ,¨QÑ/°°v¸wÈÓQÐ`eÔfÐfr   r+   c                 óà   — | €	 ddl m}  |«       } t        | t        «      r| j                  d«      nd}t        |t        «      r|S i S # t        $ r t        j	                  dd¬«       i cY S w xY w)u²   Normalized ``memory`` config section ({} when missing/malformed â†’ flags default to
    enabled). ``agent_init`` reads the same section so availability and store cannot diverge.Nr   )Úload_config_readonlyz-Could not read memory config for availabilityTr‘   rn   )r$   r£   r)   r•   Údebugr‹   rŒ   r(   )r+   r£   Úsections      r   r%   r%   ×   sp   € ð €~ð	Ý>Ù)Ó+ˆFô '1°¼Ô&>ˆf�j‰j˜Ô"ÀD€GÜ  ¬$Ô/ˆ7Ð7°RÐ7øô	 ò 	Ü�L‰LÐHÐSWˆLÔXØŠIð	ús   „A Á"A-Á,A-c                 óB   ‡— t        | «      Št        ˆfd„dD «       «      S )zGReturn ``(memory_enabled, user_profile_enabled)`` from resolved config.c              3   óV   •K  — | ]   }t        ‰j                  |«      d ¬«      –— Œ" y­w)Tr   N)r   r(   )rs   Úkr¥   s     €r   rt   z1get_builtin_memory_store_flags.<locals>.<genexpr>è   s#   øè ø€ ÒsÀ1” §¡¨Q£¸×>Ð>Ñsùs   ƒ&)r!   )r%   Útuple)r+   r¥   s    @r   r&   r&   å   s   ø€ ä'¨Ó/€GÜÓsÐHrÔsÓsÐsr   c                  ó‚   — t         j                  d«       t        «       } t         j                  | «       | d   xs | d   S )zGSnapshot store flags and report whether the built-in tool is available.Nr   rx   )r   Úsetr&   )Úflagss    r   Úcheck_memory_requirementsr­   ë   s;   € ô ×Ñ˜dÔ#Ü*Ó,€EÜ×Ñ˜eÔ$Ø�‰8Ò�u˜Q‘xÐr   c                 ó~   — |dvrddl m} d |d|› d�«      dœS | j                  |«      ry|d	k(  rd
nd}dd|› d�|dœS )zCReturn a shared validation error for an invalid or disabled target.>   rm   rn   r   )Ú_bound_error_textFzInvalid memory target 'z'. Use 'memory' or 'user'.©r8   r�   Nrm   zUSER.mdz	MEMORY.mdz	Built-in z& writes are disabled in memory config.)r8   r�   rU   )Útools.registryr¯   Útarget_enabled)r-   rU   r¯   r\   s       r   rš   rš   ô   sg   € àÐ'Ñ'Ý4Ø Ù*Ð-DÀVÀHÐLfÐ+gÓhñjð 	jà×Ñ˜FÔ#ØØ 6Ò)‰I¨{€EØ¨°5°'Ð9_Ð'`ÐlrÑsÐsr   c                 óR  — | j                  d«      | j                  dd«      }}t        ||«      }|�|S |dk(  r%|j                  || j                  d«      xs g «      S |t        vr	dd|› d�d	œS t        |   d
   ||| j                  d«      xs d| j                  d«      xs d«      S )zNReplay a staged write against the store, bypassing the gate (/memory approve).re   rU   rn   rv   rk   FzUnknown staged action 'z'.r°   r   rV   rZ   rW   )r(   rš   rœ   r|   )r1   r-   re   rU   r�   s        r   Úapply_memory_pendingr´      s¹   € à—[‘[ Ó*¨G¯K©K¸À(Ó,KˆF€FÜ'¨¨vÓ6€LØÐØÐØ�ÒØ× Ñ  ¨¯©°\Ó)BÒ)HÀbÓIÐIØ”^Ñ#Ø Ð-DÀVÀHÈBÐ+OÑPÐPÜ˜&Ñ! !Ñ$ U¨F°G·K±KÀ	Ó4JÒ4PÈbÐRY×R]ÑR]Ð^hÓRiÒRoÐmoÓpÐpr   u<  Save durable facts to persistent memory that survive across sessions. Memory is injected into every future turn, so keep entries compact and high-signal.

HOW: make ALL your changes in ONE call via an 'operations' array (each item: {action, content?, old_text?}). The batch applies atomically and the char limit is checked only on the FINAL result â€” so a single call can remove/replace stale entries to free room AND add new ones, even when an add alone would overflow. The response reports current/limit chars and confirms completion; one batch call finishes the update, so don't repeat it. Use the bare action/content/old_text fields only for a single lone change.

WHEN: only for facts that apply to EVERY session regardless of task: who the user is, stable environment facts, standing conventions with no task home. Anything learned while doing a task (procedures, pitfalls, and the user's preferences and corrections for that kind of work) belongs in the task's skill via skill_manage, where it loads only when relevant; memory is injected into every turn and must stay small.

IF FULL: an add is rejected with the current entries shown. Reissue as ONE batch that removes or shortens enough stale entries and adds the new one together.

TARGETS: 'user' = who the user is (name, role, preferences, style). 'memory' = your notes (environment, conventions, tool quirks, lessons).

SKIP: trivial/obvious info, easily re-discovered facts, raw data dumps, task progress, completed-work logs, temporary TODO state (use session_search for those). Reusable procedures belong in a skill, not memory.ÚobjectÚstringzFThe action to perform (single-op shape). Omit when using 'operations'.)ÚtypeÚenumÚdescriptionrm   zIWhich memory store: 'memory' for personal notes, 'user' for user profile.zóThe entry content. Required for 'add' and 'replace'. For 'replace' it is the COMPLETE new entry text: the whole matched entry is overwritten, so include everything you want to keep. Alias: 'new_text' is also accepted (same full-entry meaning).)r·   r¹   z½REQUIRED for 'replace' and 'remove' (single-op shape): a short unique substring IDENTIFYING the existing entry to modify -- it locates the entry, it is not spliced out. Omit only for 'add'.z†Alias for 'content' (single-op shape): the COMPLETE new entry for 'replace', not a patch of old_text. If both are set, 'content' wins.ÚarrayzÑBatch shape: a list of operations applied atomically in one call against the final char budget. Preferred when making multiple changes or consolidating to make room. Each item is {action, content?, old_text?}.)r·   r¸   zsEntry content for add/replace. For replace, the COMPLETE new entry (whole entry is overwritten). Alias: 'new_text'.z"Alias for 'content' in a batch op.z3Substring identifying the entry for replace/remove.)re   rV   rg   rW   )r·   Ú
propertiesÚrequired)r·   r¹   Úitems)re   rU   rV   rW   rg   rk   )Únamer¹   Ú
parameters)z8The enabled built-in store: 'memory' for personal notes.zeTARGET: only 'memory' is enabled for personal notes (environment, conventions, tool quirks, lessons).)z4The enabled built-in store: 'user' for user profile.zWTARGET: only 'user' is enabled for user profile facts (name, role, preferences, style).))rn   )rm   c                  óœ  — t         j                  «       xs
 t        «       } t         j                  d«       t	        d| «      D ��cg c]
  \  }}|sŒ	|‘Œ }}}t        j                  t        d   «      }|d   d   t        d   }}||d<   t        j                  t        |«      «      x}r|\  |d<   }|j                  d|«      }||d	œS c c}}w )
zENarrow the advertised target surface using the availability snapshot.N)rn   rm   r¿   r»   rU   r¹   r¸   z‹TARGETS: 'user' = who the user is (name, role, preferences, style). 'memory' = your notes (environment, conventions, tool quirks, lessons).)r¹   r¿   )r   r(   r&   r«   ÚzipÚcopyÚdeepcopyÚMEMORY_SCHEMAÚ_SINGLE_TARGET_TEXTr©   r^   )	r¬   ÚtÚonÚtargetsr¿   Útarget_schemar¹   ÚnarrowedÚreplacements	            r   Ú_build_memory_schema_overridesrÌ   a  sÔ   € ä!×%Ñ%Ó'ÒKÔ+IÓ+K€EÜ×Ñ˜dÔ#Ü!Ð"4°eÓ<×C‘U�Q˜ÂŠqÐC€GÑCÜ—‘œ}¨\Ñ:Ó;€JØ!+¨LÑ!9¸(Ñ!CÄ]ÐS`ÑEa�;€MØ#€M�&ÑÜ&×*Ñ*¬5°«>Ó:Ð:€xÐ:Ø4<Ñ1ˆ�mÑ$ kØ!×)Ñ)ðFØGRóTˆð '°jÑAÐAùó Ds   Á
CÁC)ÚregistryrH   c                 óÄ   — t        d| j                  dd«      | j                  dd«      |j                  d«      dœdD �ci c]  }|| j                  |«      “Œ c}¤ŽS c c}w )	Nre   rZ   rU   rn   r-   )re   rU   r-   )rV   rW   rg   rk   r   )r¡   r(   )ÚargsÚkwr¨   s      r   rX   rX   w  s_   € œ{ð  WØ�x‰x˜ "Ó%¨d¯h©h°xÀÓ.JÐRT×RXÑRXÐY`ÓRañ Wà#TÖ
U˜aˆ1ˆd�h‰h�q‹k‰>Ò
Uñ W€ ùâ
Us   ¿Au   ðŸ§ )r¾   ÚtoolsetÚschemaÚhandlerÚcheck_fnÚemojiÚdynamic_schema_overrides)ÚcontextmanagerÚatomic_write_text)ÚutilsrØ   c                 óÌ   — t         j                  | «      }|€t        dt        ›d| ›�«      ‚dd l}ddlm}  |t        | g|¢­Ž  t        |j                  |d   «      |d   «      S )Nzmodule z has no attribute r   )Ú	warn_oncerx   )	Ú_PLUGIN_COMPAT_LAZYr(   ÚAttributeErrorÚ__name__Ú	importlibÚhermes_cli.plugin_compatrÛ   ÚgetattrÚimport_module)r¾   rU   rß   rÛ   s       r   Ú__getattr__rã   Œ  se   € Ü ×$Ñ$ TÓ*€FØ€~Ü˜w¤x lÐ2DÀTÀHÐMÓNÐNÛÝ2ÙŒh˜Ð&˜vÓ&Ü�9×*Ñ*¨6°!©9Ó5°v¸a±yÓAÐAr   )r   r   rR   )rn   NN)Nrn   NNNNN)=Ú__doc__rÂ   rK   ÚloggingÚcontextvarsr   Úpathlibr   Úhermes_constantsr   Útypingr   r   r	   r
   r   rÙ   r   r±   r   ÚmsvcrtÚfcntlÚImportErrorÚ	getLoggerrÞ   r•   r   ÚboolÚ__annotations__r   Útools.memory_tool_storer   r   r   r   r.   ÚstrrP   r|   rj   r}   r‡   r�   r˜   r¡   r%   r&   r­   rš   r´   rÄ   rÅ   rÌ   rÍ   rH   ÚregisterÚ
contextlibr×   ÚtimerÜ   rã   r   r   r   ú<module>rõ      s\  ðòJó
 Û Û Ý "Ý Ý ,ß 3Õ 3å !Ý ,ð 
€ðÛð 
ˆ×	Ñ	˜8Ó	$€ñ
 BLÐLbÐlpÔAqÐ �z (¨5°°t°Ñ+<Ñ"=Ñ>Ó qð*˜ó *÷
Nó Nóð"*˜Cð *¨ð *°t¸CÀ¸H±~ð *È(ÐSVÉ-ó *ñ& PÙOðQáañqðrñ WÙXðZñ[€ð(�t˜C ˜H‘~ð (¨#ó (ð DHñ	j˜cð 	j¨3ð 	j¸À#¹ð 	jÐRZÐ[^ÑR_ð 	jØ"*¨4°°S¸#°X±Ñ+?Ñ"@ð	jØLTÐUXÉMó	jðÀXÈcÁ]ó ð* +Ð ñ%@ÐaiÐjmÑanó %@ðP bfØSWØ/3ñ"g˜ð "g¨Cð "gÀSð "gÐ[^ð "gØð"gØ2:¸4ÀÀSÈ#ÀXÁÑ;OÑ2Pð"gà Ñ,ð"gà8;ó"gñJ8 h¨t°C¸°H©~Ñ&>ð 8È$ÈsÐTWÈxÉ.ó 8ñt¨8°D¸¸c¸±NÑ+Cð tÈuÐUYÐ[_ÐU_ÑO`ó tð ð  4ò  ó ð ð	t ð 	t°sð 	t¸xÈÈSÐRUÈXÉÑ?Wó 	tð
q $ s¨C x¡.ð 
q¸ð 
qÈ4ÐPSÐUXÐPXÉ>ó 
qð ð	4ð0 ð !Ú4Øgñð !Ø! 6Ð*Øjñð !ð  Uñð
 !ð  _ñð
 !ð  hñð
  ðað
 %à+3Ò=YÑ"ZØ,4ð  F{ñ  $|Ø-5ÐFjÑ$kØ-5ÐF{Ñ$|ñ	#ð "* 
ñ	ññ/)
ðT �JñY-ñ5H€ðZ,ðkñ	lÐ ðB¨¨S°#¨X©ó B÷  0à €× Ñ Ø	ØØñWð 'Ø
Ø;õ	=õ  &Û ð Ð7ðÐ ó
Bøðk ò Ø€EðÜøØò Ùðýð	ús5   ¿G= Ç=HÈH
È	HÈ
HÈHÈHÈHÈH