Ë
    âß²j«  ã                  óÒ   — U d Z ddlmZ ddlZddlmZmZmZmZ  e	h d£«      Z
dddd	d
ddddddddddœZded<   ddœd"d„Zd#d„Zd#d„Zd$d%d„Zd#d„Zd&d'd„Zd&d(d„Zd)d„Zd)d „Zd*d!„Zy)+aÓ  Single owner for personality overlays.

* ``display.personality`` holds the selected NAME (empty = no overlay).
* ``agent.system_prompt`` is the user-owned manual overlay; personality code never writes it.
* ``agent.personalities`` holds user-defined/overridden personalities, overlaying built-ins by name.
  The schema also exposes a top-level ``personalities:`` block (the original #643 shape); both are
  honoured, ``agent.personalities`` winning on a name clash.
é    )ÚannotationsN)ÚAnyÚDictÚOptionalÚTuple>   Ú ÚnoneÚdefaultÚneutralz)You are a helpful, friendly AI assistant.zCYou are a concise assistant. Keep responses brief and to the point.zMYou are a technical expert. Provide detailed, accurate technical information.zSYou are a creative assistant. Think outside the box and offer innovative solutions.zBYou are a patient teacher. Explain concepts clearly with examples.uÑ   You are a kawaii assistant! Use cute expressions like (â—•â€¿â—•), â˜…, â™ª, and ~! Add sparkles and be super enthusiastic about everything! Every response should feel warm and adorable desu~! ãƒ½(>âˆ€<â˜†)ãƒŽuÊ   You are Neko-chan, an anime catgirl AI assistant, nya~! Add 'nya' and cat-like expressions to your speech. Use kaomoji like (=^ï½¥Ï‰ï½¥^=) and à¸…^â€¢ï»Œâ€¢^à¸…. Be playful and curious like a cat, nya~!zÞArrr! Ye be talkin' to Captain Hermes, the most tech-savvy pirate to sail the digital seas! Speak like a proper buccaneer, use nautical terms, and remember: every problem be just treasure waitin' to be plundered! Yo ho ho!zóHark! Thou speakest with an assistant most versed in the bardic arts. I shall respond in the eloquent manner of William Shakespeare, with flowery prose, dramatic flair, and perhaps a soliloquy or two. What light through yonder terminal breaks?z¿Duuude! You're chatting with the chillest AI on the web, bro! Everything's gonna be totally rad. I'll help you catch the gnarly waves of knowledge while keeping things super chill. Cowabunga!a  The rain hammered against the terminal like regrets on a guilty conscience. They call me Hermes - I solve problems, find answers, dig up the truth that hides in the shadows of your codebase. In this city of silicon and secrets, everyone's got something to hide. What's your story, pal?z¡hewwo! i'm your fwiendwy assistant uwu~ i wiww twy my best to hewp you! *nuzzles your code* OwO what's this? wet me take a wook! i pwomise to be vewy hewpful >w<a  Greetings, seeker of wisdom. I am an assistant who contemplates the deeper meaning behind every query. Let us examine not just the 'how' but the 'why' of your questions. Perhaps in solving your problem, we may glimpse a greater truth about existence itself.z­YOOO LET'S GOOOO!!! I am SO PUMPED to help you today! Every question is AMAZING and we're gonna CRUSH IT together! This is gonna be LEGENDARY! ARE YOU READY?! LET'S DO THIS!)ÚhelpfulÚconciseÚ	technicalÚcreativeÚteacherÚkawaiiÚcatgirlÚpirateÚshakespeareÚsurferÚnoirÚuwuÚphilosopherÚhypezDict[str, str]ÚBUILTIN_PERSONALITIES©r
   c               óR   — | }|D ]  }t        |t        «      r||vr|c S ||   }Œ! |S )z@Nested dict lookup tolerant of None/non-dict intermediate nodes.)Ú
isinstanceÚdict)Úcfgr
   ÚkeysÚnodeÚkeys        ú;/home/ubuntu/.hermes/hermes-agent/hermes_cli/personality.pyÚ_getr$   %   s;   € à€DØò ˆÜ˜$¤Ô%¨°D©ØŠNØ�C‰y‰ðð €Kó    c                óÊ   — | €yt        | t        «      r| j                  «       S t        | t        «      rdj	                  d„ | D «       «      S t        | «      j                  «       S )zENormalize config prompt values from YAML (str | list | None) to text.r   ú
c              3  ó‚   K  — | ]7  }t        |«      j                  «       sŒt        |«      j                  «       –— Œ9 y ­w©N©ÚstrÚstrip)Ú.0Úitems     r#   ú	<genexpr>zprompt_text.<locals>.<genexpr>6   ó(   è ø€ ÒR¨tÄÀDÃ	ÇÁÕ@Qœ˜T›Ÿ™×*ÑRùó   ‚?¡?)r   r+   r,   ÚlistÚjoin)Úvalues    r#   Úprompt_textr5   /   sR   € à€}ØÜ�%œÔØ�{‰{‹}ÐÜ�%œÔØ�y‰yÑR°uÔRÓRÐRÜˆu‹:×ÑÓÐr%   c                ó.  — t        | t        «      r{| j                  dd«      g}| j                  d«      r|j                  d| d   › �«       | j                  d«      r|j                  d| d   › �«       dj	                  d„ |D «       «      S t        | «      S )	zDRender a string or structured personality definition to prompt text.Úsystem_promptr   ÚtonezTone: ÚstylezStyle: r'   c              3  ó‚   K  — | ]7  }t        |«      j                  «       sŒt        |«      j                  «       –— Œ9 y ­wr)   r*   )r-   Úparts     r#   r/   z,render_personality_prompt.<locals>.<genexpr>B   r0   r1   )r   r   ÚgetÚappendr3   r5   )r4   Úpartss     r#   Úrender_personality_promptr?   :   s†   € ä�%œÔØ—‘˜?¨BÓ/Ð0ˆØ�9‰9�VÔØ�L‰L˜6 %¨¡- Ð1Ô2Ø�9‰9�WÔØ�L‰L˜7 5¨¡>Ð"2Ð3Ô4Ø�y‰yÑR°uÔRÓRÐRÜ�uÓÐr%   c                ó
  — t        | t        «      r/| j                  d«      xs t        | j                  dd«      «      }nt        | «      }|j	                  «       j                  dd«      }|d| t        |«      |kD  rdz   S dz   S )zGShort preview line for list UIs (CLI table, gateway /personality list).Údescriptionr7   r   r'   ú Nz...)r   r   r<   r+   r,   ÚreplaceÚlen)r4   ÚwidthÚpreviews      r#   Údescribe_personalityrG   F   st   € ä�%œÔØ—)‘)˜MÓ*ÒQ¬c°%·)±)¸OÈRÓ2PÓ.Q‰ä�e“*ˆØ�m‰m‹o×%Ñ% d¨CÓ0€GØ�6�Eˆ?¤s¨7£|°eÒ';˜eÑDÐDÀÑDÐDr%   c                óp   — t        | xs d«      j                  «       j                  «       }|t        v rdS |S )zCCanonical form of a personality name ('' for any neutral spelling).r   )r+   r,   ÚlowerÚNEUTRAL_PERSONALITY_NAMES)r4   Únames     r#   Únormalize_personality_namerL   P   s5   € äˆuŠ{˜Ó×!Ñ!Ó#×)Ñ)Ó+€DØÔ2Ñ2ˆ2Ð<¸Ð<r%   c                ó*  — t        t        «      }t        | di ¬«      t        | ddi ¬«      fD ]c  }t        |t         «      sŒ|j	                  «       D ]=  \  }}t        |«      j                  «       j                  «       }|sŒ0|t        vsŒ9|||<   Œ? Œe |S )z¡Built-ins overlaid by the user's personalities: root ``personalities`` then
    ``agent.personalities`` (later wins). Root entries were silently ignored (#9636).Úpersonalitiesr   Úagent)	r   r   r$   r   Úitemsr+   r,   rI   rJ   )r   ÚmergedÚuserrK   Ú
definitionr"   s         r#   Úavailable_personalitiesrT   V   s“   € ô "Ô"7Ó8€FÜ�c˜?°BÔ7¼¸cÀ7ÈOÐegÔ9hÐiò )ˆÜ˜$¤Ô%ØØ $§
¡
£ò 	)ÑˆD�*Ü�d“)—/‘/Ó#×)Ñ)Ó+ˆCÚ�sÔ";Ò;Ø(��s’ñ	)ð)ð €Mr%   c                óî   — t        | «      }|syt        |«      }||vrIdj                  d„ t        |«      D «       «      }t	        dt        | «      j                  «       › d|› �«      ‚|t        ||   «      fS )zEResolve a requested personality to ``(canonical_name, prompt_text)``.)r   r   z, c              3  ó(   K  — | ]
  }d |› d �–— Œ y­w)ú`N© )r-   Úns     r#   r/   z&resolve_personality.<locals>.<genexpr>k   s   è ø€ ÒB q˜A˜a˜S œ(ÑBùs   ‚zUnknown personality: `z`.

Available: `none`, )rL   rT   r3   ÚsortedÚ
ValueErrorr+   r,   r?   )r4   r   rK   rN   Únamess        r#   Úresolve_personalityr]   d   s}   € ä% eÓ,€DÙØÜ+¨CÓ0€MØ�=Ñ Ø—	‘	ÑB¬F°=Ó,AÔBÓBˆÜÐ1´#°e³*×2BÑ2BÓ2DÐ1EÐE^Ð_dÐ^eÐfÓgÐgØÔ*¨=¸Ñ+>Ó?Ð?Ð?r%   c                óX   — t        t        | ddd¬«      «      }|r|t        | «      v r|S dS )zAThe currently selected personality name ('' when none is active).ÚdisplayÚpersonalityr   r   )rL   r$   rT   ©r   rK   s     r#   Úactive_personality_namerb   p   s2   € ä%¤d¨3°	¸=ÐRTÔ&UÓV€DÙ˜DÔ$;¸CÓ$@Ñ@ˆ4ÐHÀbÐHr%   c                óz   — t        | «      }|rt        t        | «      |   «      S t        t	        | ddd¬«      «      S )zµSession overlay: ``display.personality`` when it names a known personality, else the
    user-owned ``agent.system_prompt``. Callers still prefer ``HERMES_EPHEMERAL_SYSTEM_PROMPT``.rO   r7   r   r   )rb   r?   rT   r5   r$   ra   s     r#   Úresolve_ephemeral_system_promptrd   v   s=   € ô # 3Ó'€DÙÜ(Ô)@ÀÓ)EÀdÑ)KÓLÐLÜ”t˜C ¨/À2ÔFÓGÐGr%   c                ó  — t        | «      }	 ddlm} ddlm}  |«       dz  }ddlm}  ||j                  «        ||d|«       	 t        j                  |d«       y# t        t        f$ r Y yw xY w# t        $ r Y y	w xY w)
uè   Persist the selection â€” the ONLY sanctioned write path. Writes the canonical name (or '')
    to ``display.personality`` atomically (comments/ordering preserved); never touches
    ``agent.system_prompt``. Returns True on success.r   )Úget_hermes_home)Úatomic_roundtrip_yaml_updatezconfig.yaml)Úmkdir_under_hermes_homezdisplay.personalityi€  TF)rL   Úhermes_constantsrf   Úutilsrg   rh   ÚparentÚosÚchmodÚOSErrorÚNotImplementedErrorÚ	Exception)r4   rK   rf   rg   Úconfig_pathrh   s         r#   Úpersist_personalityrr      sŒ   € ô & eÓ,€DðÝ4Ý6á%Ó'¨-Ñ7ˆÝ<Ù × 2Ñ 2Ô3Ù$ [Ð2GÈÔNð	Ü�H‰H�[ %Ô(ð øô Ô,Ð-ò 	ØØð	ûô ò Ùðús/   �8A2 ÁA ÁA/Á,A2 Á.A/Á/A2 Á2	A>Á=A>)r   úOptional[Dict[str, Any]]r    r+   r
   r   Úreturnr   )r4   r   rt   r+   )é2   )r4   r   rE   Úintrt   r+   r)   )r   rs   rt   zDict[str, Any])r4   r   r   rs   rt   zTuple[str, str])r   rs   rt   r+   )r4   r   rt   Úbool)Ú__doc__Ú
__future__r   rl   Útypingr   r   r   r   Ú	frozensetrJ   r   Ú__annotations__r$   r5   r?   rG   rL   rT   r]   rb   rd   rr   rX   r%   r#   ú<module>r}      s¹   ðòõ #ã 	ß -Ó -ñ &Ò&HÓIÐ ð ;ØTØ`ØeØSð bð \ð oð Ið Pð lð oð Wð |ñ)Ð �~ó ð$ DHõ óó	ôEó=ôô	@óIóHôr%   