Ë
    ãß²j2  ã                   ó¦  — U d Z ddlZddlZddlmZmZ ddlmZ daeee	e	e	gdf      e
d<   deee	e	e	gdf      ddfd„Zdee	   fd	„Zd
ee	   dee	   de	ddfd„Zde	fd„Zd
ee	   de	fd„Zd(d
ee	   de	fd„Zd)de	dee	   d
ee	   de	fd„Zd(de	d
ee	   de	fd„Zd„ d„ d„ dœZd„ Z ej*                  ddddddg d¢dœdd d!œdd"d!œd#œd$gd%œd&œe¬'«       y)*uœ  Project tools â€” the agent's INTENTIONAL handle on first-class Projects (per-profile
``projects.db``, the desktop sidebar's named workspaces). Creating/switching is an explicit
tool call, never a side effect of ``cd``. GUI-only: the `project` toolset stays off
``_HERMES_CORE_TOOLS``; the desktop/TUI gateway folds it in and wires
``set_project_workspace_callback`` so the live session's cwd and sidebar follow.é    N)ÚCallableÚOptional)ÚregistryÚ_workspace_callbackÚfnÚreturnc                 ó   — | a y ©N)r   )r   s    ú8/home/ubuntu/.hermes/hermes-agent/tools/project_tools.pyÚset_project_workspace_callbackr      s   € àÑó    c                 óØ   — t        | dd «      r| j                  S | j                  D ]  }|j                  sŒ|j                  c S  | j                  r| j                  d   j                  S d S )NÚprimary_pathr   )Úgetattrr   ÚfoldersÚ
is_primaryÚpath)ÚprojÚfolders     r   Ú_primary_pathr      sa   € Üˆt�^ TÔ*Ø× Ñ Ð Ø—,‘,ò ˆØ×ÓØ—;‘;Òðð $(§<¢<ˆ4�<‰<˜‰?×ÑÐ9°TÐ9r   Útask_idr   Únamec                 óV   — t         }|r| r|r	  || ||«       y y y y # t        $ r Y y w xY wr
   )r   Ú	Exception)r   r   r   Úcbs       r   Ú_apply_workspacer   !   s<   € Ü	€BÙ	‰g™$ð	Ùˆw˜˜dÕ#ð ˆg€røô ò 	Ùð	ús   Ž
 œ	(§(Útokenc                 óv  — ddl m} |xs dj                  «       }|sy |j                  | d¬«      }|D ]/  }||j                  |j
                  fv s|j                  |k(  sŒ-|c S  |j                  «       }|D ]@  }|j
                  j                  «       |k(  s|j                  j                  «       |k(  sŒ>|c S  y )Nr   ©Úprojects_dbÚ T)Úinclude_archived)Ú
hermes_clir    ÚstripÚlist_projectsÚidÚslugr   Úlower)Úconnr   ÚpdbÚprojectsr   Úlows         r   Ú_resolver-   *   s±   € Ý-ØŠ[�b×ÑÓ!€EÙØØ× Ñ  ¸Ð Ó=€Hàò ˆØ�T—W‘W˜dŸi™iÐ(Ñ(¨D¯I©I¸Ó,>ØŠKðð �+‰+‹-€CØò ˆØ�9‰9�?‰?Ó Ò# t§y¡y§¡Ó'8¸CÓ'?ØŠKðð r   c                 ó¸   — t        | «      }t        ||| j                  «       t        j                  d| j
                  | j                  | j                  |dœ«      S )NT)Úsuccessr&   r'   r   r   )r   r   r   ÚjsonÚdumpsr&   r'   )r   r   Úprimarys      r   Ú
_activatedr3   ;   sJ   € Ü˜DÓ!€GÜ�W˜g t§y¡yÔ1Ü�:‰:Ø˜tŸw™w°·	±	À4Ç9Á9Øñ!ó "ð "r   c                 óf  — ddl m} |j                  «       5 }|j                  |«      }|j	                  |«      }d d d «       t        j                  D �cg c]>  }|j                  |j                  |j                  t        |«      |j                  |k(  dœ‘Œ@ c}dœ«      S # 1 sw Y   ŒixY wc c}w )Nr   r   )r&   r'   r   r   Úactive)Ú	active_idr+   )r#   r    Úconnect_closingÚget_active_idr%   r0   r1   r&   r'   r   r   )r   r*   r)   r5   r+   Úps         r   Úproject_listr:   C   s©   € Ý-Ø	×	Ñ	Ó	ð + $Ø×"Ñ" 4Ó(ˆØ×$Ñ$ TÓ*ˆ÷+ô �:‰:Øð
 ö	ð ð —d‘d A§F¡F°A·F±FÜ -¨aÓ 0¸A¿D¹DÀF¹NóLòñ ó !ð !÷+ð +üò
s   —#B"ÁAB.
Â"B+c                 ó  — | xs dj                  «       } | st        j                  dddœ«      S ddlm} |xs dj                  «       }|r<t
        j                  j                  t
        j                  j                  |«      «      }	 |j                  «       5 }|r|j                  ||«      nd }|�|j                  ||j                  «       |}nB|j                  || |r|gng |xs d ¬«      }|j                  ||«       |j                  ||«      }d d d «       €t        j                  dddœ«      S t#        ||«      S # 1 sw Y   Œ/xY w# t        $ r+}	t        j                  dt!        |	«      dœ«      cY d }	~	S d }	~	ww xY w)	Nr!   Fzname is required©r/   Úerrorr   r   )r   r   r   zproject vanished after create)r$   r0   r1   r#   r    Úosr   ÚabspathÚ
expanduserr7   Úfind_by_primary_pathÚ
set_activer&   Úcreate_projectÚget_projectÚ
ValueErrorÚstrr3   )
r   r   r   r*   r   r)   Úexistingr   ÚpidÚexcs
             r   Úproject_createrJ   Q   s\  € ØŠJ�B×ÑÓ€DÙÜ�z‰z eÐ6HÑIÓJÐJÝ-ØŠj�b×ÑÓ!€FÙÜ—‘—‘¤§¡×!3Ñ!3°FÓ!;Ó<ˆðAØ× Ñ Ó"ð 	2 dÙAG�s×/Ñ/°°fÔ=ÈTˆHØÐ#ð —‘˜t X§[¡[Ô1Ø‘à×(Ñ(¨°DÉfÀ6Á(ÐZ\ÐkqÒkyÐuyÐ(Óz�Ø—‘˜t SÔ)Ø—‘ t¨SÓ1�÷	2ð €|Ü�z‰z eÐ6UÑVÓWÐWÜ�d˜GÓ$Ð$÷!	2ð 	2ûô ò AÜ�z‰z e´c¸#³hÑ?Ó@Õ@ûðAús7   ÂE ÂA:E ÄE Å E	ÅE Å	F Å E;Å5F Å;F Úprojectc                 ó  — ddl m} |j                  «       5 }t        || «      }|€%t	        j
                  dd| › d�dœ«      cd d d «       S |j                  ||j                  «       d d d «       t        |«      S # 1 sw Y   ŒxY w)Nr   r   Fzno project matching 'ú'r<   )	r#   r    r7   r-   r0   r1   rB   r&   r3   )rK   r   r*   r)   r   s        r   Úproject_switchrN   m   s„   € Ý-Ø	×	Ñ	Ó	ð & $Ü˜˜gÓ&ˆØˆ<Ü—:‘:¨%Ð<QÐRYÐQZÐZ[Ð:\Ñ]Ó^÷&ñ &ð 	�‰�t˜TŸW™WÔ%÷	&ô
 �d˜GÓ$Ð$÷&ð &ús   —*A;ÁA;Á;Bc                 ó   — t        |¬«      S )N)r   )r:   ©ÚargsÚtids     r   ú<lambda>rS   x   s   € œl°3Ô7€ r   c                 ó\   — t        | j                  dd«      | j                  d«      |¬«      S )Nr   r!   r   )r   r   r   )rJ   ÚgetrP   s     r   rS   rS   y   s'   € ¤Ø�X‰X�f˜bÓ!¨¯©°Ó(8À#ô!G€ r   c                 ó<   — t        | j                  dd«      |¬«      S )Nr   r!   )rK   r   )rN   rU   rP   s     r   rS   rS   {   s   € ¤°t·x±xÀÈÓ7KÐUXÔ Y€ r   )ÚlistÚcreateÚswitchc                 óÒ   — t         j                  | j                  d«      xs dj                  «       «      }|€t        j                  dddœ«      S  || |j                  d«      «      S )NÚactionr!   Fz,action must be one of: create, switch, list.r<   r   )Ú_ACTIONSrU   r$   r0   r1   )rQ   Úkwr[   s      r   Ú_handle_projectr^   ~   sW   € Ü�\‰\˜4Ÿ8™8 HÓ-Ò3°×:Ñ:Ó<Ó=€FØ€~Ü�z‰z eÐ6dÑeÓfÐfÙ�$˜Ÿ™˜yÓ)Ó*Ð*r   Údesktop_projectu`  Create or switch desktop Projects (named workspaces). create: one and switch this chat into it â€” pass path to anchor it to a repo/folder (the chat's workspace moves there, the sidebar follows). switch: move this chat into an existing project by name/slug/id â€” the intentional way to move the session, not `cd`. list: all projects + which is active.ÚobjectÚstring)rX   rY   rW   )ÚtypeÚenumz.create: human name. switch: name, slug, or id.)rb   Údescriptionz!create: repo/folder to anchor to.)r[   r   r   r[   )rb   Ú
propertiesÚrequired)r   rd   Ú
parameters)r   ÚtoolsetÚschemaÚhandlerr
   )NN)Ú__doc__r0   r>   Útypingr   r   Útools.registryr   r   rF   Ú__annotations__r   r   r   r-   r3   r:   rJ   rN   r\   r^   Úregister© r   r   ú<module>rq      s™  ðòTó Û 	ß %å #ð BFÐ �X˜h¨¨S°# ¸Ð'<Ñ=Ñ>Ó Eð x°¸#¸sÀC¸È$Ð9NÑ0OÑ'Pð ÐUYó ð
:˜8 C™=ó :ð˜h s™mð °8¸C±=ð Èð ÐPTó ð˜#ó ð""˜h s™mð "°ó "ñ!˜( 3™-ð !°3ó !ñ%˜ð % H¨S¡Mð %À8ÈCÁ=ð %Ð\_ó %ñ8%˜Cð %¨(°3©-ð %À3ó %ñ 8ñGáYñ	[€ò+ð €× Ñ Ø	Øà!ðcð à#+Ò5QÑRØ!)Ð:jÑkØ!)Ð:]Ñ^ñð
 "˜
ñ
ñð& ö-r   