§
    øžyj  ã                   ó,  — 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(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 ej        dddddi dœdœd„ ¬¦  «          ej        ddddddddœdd dœd!œdgd"œdœd#„ ¬¦  «          ej        d$dd$d%dddd&dœidgd"œdœd'„ ¬¦  «         dS )*u¸  Project tools â€” the agent's INTENTIONAL handle on first-class Projects.

Projects (per-profile ``projects.db``) are the named workspaces the desktop
sidebar groups sessions into. Creating / switching a project is a deliberate act
expressed as explicit tools â€” never a side effect of a terminal ``cd``.

Exposed only on GUI sessions: the tools live in the `project` toolset (kept off
``_HERMES_CORE_TOOLS``) which the desktop/TUI gateway folds into its resolved
toolsets, so no CLI/messaging/cron schema carries them. The GUI also wires
``set_project_workspace_callback`` so a create/switch re-anchors the live
session's cwd and the sidebar follows the move; the DB write is the durable part.
é    N)ÚCallableÚOptional)ÚregistryÚ_workspace_callbackÚfnÚreturnc                 ó
   — | a d S ©N)r   )r   s    ú9/home/ragecks/.hermes/hermes-agent/tools/project_tools.pyÚset_project_workspace_callbackr      s   € àÐÐÐó    c                 óœ   — t          | dd ¦  «        r| j        S | j        D ]}|j        r	|j        c S Œ| j        r| j        d         j        nd S )NÚprimary_pathr   )Úgetattrr   ÚfoldersÚ
is_primaryÚpath)ÚprojÚfolders     r   Ú_primary_pathr   !   si   € Ýˆt�^ TÑ*Ô*ð !ØÔ Ð Ø”,ð ð ˆØÔð 	Ø”;ÐÐÐð	à#'¤<Ð9ˆ4Œ<˜Œ?ÔÐ°TÐ9r   Útask_idr   Únamec                 ój   — t           }|r%| r%|r%	  || ||¦  «         d S # t          $ r Y d S w xY wd S d S d S r
   )r   Ú	Exception)r   r   r   Úcbs       r   Ú_apply_workspacer   *   s|   € Ý	€BØ	ð ˆgð ˜$ð ð	ØˆBˆw˜˜dÑ#Ô#Ð#Ð#Ð#øÝð 	ð 	ð 	ØˆDˆDð	øøøðð ð ð ð ð s   � ž
,«,Útokenc                 ój  — ddl m} |pd                     ¦   «         }|sd S |                     | d¬¦  «        }|D ]!}||j        |j        fv s|j        |k    r|c S Œ"|                     ¦   «         }|D ]@}|j                             ¦   «         |k    s|j                             ¦   «         |k    r|c S ŒAd S )Nr   ©Úprojects_dbÚ T)Úinclude_archived)Ú
hermes_clir    ÚstripÚlist_projectsÚidÚslugr   Úlower)Úconnr   ÚpdbÚprojectsr   Úlows         r   Ú_resolver-   3   sè   € Ø-Ð-Ð-Ð-Ð-Ð-àˆ[�b×ÒÑ!Ô!€EØð ØˆtØ× Ò  ¸Ð Ñ=Ô=€Hàð ð ˆØ�T”W˜dœiÐ(Ð(Ð(¨D¬I¸Ò,>Ð,>ØˆKˆKˆKð -?à
�+Š+‰-Œ-€CØð ð ˆØŒ9�?Š?ÑÔ Ò#Ð# t¤y§¢Ñ'8Ô'8¸CÒ'?Ð'?ØˆKˆKˆKð (@àˆ4r   c                 ó  ‡— ddl m} |                     ¦   «         5 }|                     |¦  «        Š|                     |¦  «        }d d d ¦  «         n# 1 swxY w Y   t          j        ‰ˆfd„|D ¦   «         dœ¦  «        S )Nr   r   c                 ój   •— g | ]/}|j         |j        |j        t          |¦  «        |j         ‰k    d œ‘Œ0S ))r&   r'   r   r   Úactive)r&   r'   r   r   )Ú.0Úpr0   s     €r   ú
<listcomp>z project_list.<locals>.<listcomp>N   sU   ø€ ð 	
ð 	
ð 	
ð ð ”dØœØœÝ -¨aÑ 0Ô 0Øœ$ &š.ðð ð	
ð 	
ð 	
r   )Ú	active_idr+   )r#   r    Úconnect_closingÚget_active_idr%   ÚjsonÚdumps)r   r*   r)   r+   r0   s       @r   Úproject_listr9   E   sê   ø€ Ø-Ð-Ð-Ð-Ð-Ð-à	×	Ò	Ñ	Ô	ð + $Ø×"Ò" 4Ñ(Ô(ˆØ×$Ò$ TÑ*Ô*ˆð+ð +ð +ñ +ô +ð +ð +ð +ð +ð +ð +øøøð +ð +ð +ð +õ Œ:Øð	
ð 	
ð 	
ð 	
ð ð	
ñ 	
ô 	
ðð ñ ô ð s   œ+AÁAÁAc                 óL  — | pd                      ¦   «         } | st          j        dddœ¦  «        S ddlm} |pd                      ¦   «         }|r<t
          j                             t
          j                             |¦  «        ¦  «        }	 | 	                    ¦   «         5 }| 
                    || |r|gng |pd ¬¦  «        }|                     ||¦  «         |                     ||¦  «        }d d d ¦  «         n# 1 swxY w Y   n;# t          $ r.}t          j        dt          |¦  «        dœ¦  «        cY d }~S d }~ww xY w|€t          j        dddœ¦  «        S t          |¦  «        }	t!          ||	|j        ¦  «         t          j        d	|j        |j        |j        |	d
œ¦  «        S )Nr!   Fzname is required©ÚsuccessÚerrorr   r   )r   r   r   zproject vanished after createT©r<   r&   r'   r   r   )r$   r7   r8   r#   r    Úosr   ÚabspathÚ
expanduserr5   Úcreate_projectÚ
set_activeÚget_projectÚ
ValueErrorÚstrr   r   r   r&   r'   )
r   r   r   r*   r   r)   Úpidr   ÚexcÚprimarys
             r   Úproject_createrJ   [   s  € ØˆJ�B×ÒÑÔ€DØð KÝŒz eÐ6HÐIÐIÑJÔJÐJà-Ð-Ð-Ð-Ð-Ð-àˆj�b×ÒÑ!Ô!€FØð =Ý”—’¥¤×!3Ò!3°FÑ!;Ô!;Ñ<Ô<ˆðAØ× Ò Ñ"Ô"ð 	. dØ×$Ò$ T°È&Ð>X¸v¸h¸hÐVXÐgmÐguÐquÐ$ÑvÔvˆCØ�NŠN˜4 Ñ%Ô%Ð%Ø—?’? 4¨Ñ-Ô-ˆDð	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.øøõ ð Að Að AÝŒz eµc¸#±h´hÐ?Ð?Ñ@Ô@Ð@Ð@Ð@Ð@Ð@Ð@øøøøðAøøøð €|ÝŒz eÐ6UÐVÐVÑWÔWÐWå˜DÑ!Ô!€GÝ�W˜g t¤yÑ1Ô1Ð1åŒ: $¨d¬g¸t¼yÐRVÔR[ÐmtÐuÐuÑvÔvÐvsC   ÂD ÂAC8Ã,D Ã8C<Ã<D Ã?C<Ä D Ä
D<Ä#D7Ä1D<Ä7D<Úprojectc                 óª  — ddl m} |                     ¦   «         5 }t          || ¦  «        }|€'t	          j        dd| › d�dœ¦  «        cd d d ¦  «         S |                     ||j        ¦  «         d d d ¦  «         n# 1 swxY w Y   t          |¦  «        }t          |||j
        ¦  «         t	          j        d|j        |j        |j
        |dœ¦  «        S )	Nr   r   Fzno project matching 'ú'r;   Tr>   )r#   r    r5   r-   r7   r8   rC   r&   r   r   r   r'   )rK   r   r*   r)   r   rI   s         r   Úproject_switchrN   w   s8  € Ø-Ð-Ð-Ð-Ð-Ð-à	×	Ò	Ñ	Ô	ð & $Ý˜˜gÑ&Ô&ˆØˆ<Ý”:¨%Ð:\ÐRYÐ:\Ð:\Ð:\Ð]Ð]Ñ^Ô^ð&ð &ð &ð &ñ &ô &ð &ð &ð 	�Š�t˜TœWÑ%Ô%Ð%ð	&ð &ð &ñ &ô &ð &ð &ð &ð &ð &ð &øøøð &ð &ð &ð &õ ˜DÑ!Ô!€GÝ�W˜g t¤yÑ1Ô1Ð1åŒ: $¨d¬g¸t¼yÐRVÔR[ÐmtÐuÐuÑvÔvÐvs   ›-A<ÁA<Á<B ÂB r9   zEList the desktop Projects (named workspaces) and which one is active.Úobject)ÚtypeÚ
properties)r   ÚdescriptionÚ
parametersc                 óH   — t          |                     d¦  «        ¬¦  «        S )Nr   )r   )r9   Úget©ÚargsÚkws     r   ú<lambda>rY   Ž   s   € �|°B·F²F¸9Ñ4EÔ4EÐFÑFÔF€ r   )r   ÚtoolsetÚschemaÚhandlerrJ   u  Create a desktop Project (a named workspace) and switch this chat into it. Pass `path` to anchor it to a repo/folder â€” this chat's workspace moves there and the sidebar follows. Use when starting work in a new repo/folder; this is the intentional way to move the session, not `cd`.ÚstringzHuman name, e.g. 'Aurora Demo')rP   rR   z,Primary repo/folder to anchor the project to)r   r   )rP   rQ   Úrequiredc                 óš   — t          |                      dd¦  «        |                      d¦  «        |                     d¦  «        ¬¦  «        S )Nr   r!   r   r   )r   r   r   )rJ   rU   rV   s     r   rY   rY   ¥   sB   € �~Ø�XŠX�f˜bÑ!Ô!¨¯ª°Ñ(8Ô(8À"Ç&Â&ÈÑBSÔBSð ñ  ô  € r   rN   zØSwitch this chat into an existing desktop Project (by name, slug, or id). Moves the session's workspace to the project's primary folder and the sidebar follows. The intentional way to move between projects, not `cd`.zProject name, slug, or idc                 ór   — t          |                      dd¦  «        |                     d¦  «        ¬¦  «        S )NrK   r!   r   )rK   r   )rN   rU   rV   s     r   rY   rY   ¼   s1   € �~°d·h²h¸yÈ"Ñ6MÔ6MÐWY×W]ÒW]Ð^gÑWhÔWhÐiÑiÔi€ r   r
   )NN)Ú__doc__r7   r?   Útypingr   r   Útools.registryr   r   rF   Ú__annotations__r   r   r   r-   r9   rJ   rN   Úregister© r   r   ú<module>rg      s  ððð ð ð €€€Ø 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à #Ð #Ð #Ð #Ð #Ð #ð BFÐ �X˜h¨¨S°# ¸Ð'<Ô=Ô>Ð EÐ EÑ Eð x°¸#¸sÀC¸È$Ð9NÔ0OÔ'Pð ÐUYð ð ð ð ð
:˜8 Cœ=ð :ð :ð :ð :ð˜h sœmð °8¸C´=ð Èð ÐPTð ð ð ð ð˜#ð ð ð ð ð$ð ˜( 3œ-ð °3ð ð ð ð ð,wð w˜ð w H¨S¤Mð wÀ8ÈCÄ=ð wÐ\_ð wð wð wð wð8wð w˜Cð w¨(°3¬-ð wÀ3ð wð wð wð wð €Ô Ø	ØàØ^Ø'°rÐ:Ð:ðð ð
 GÐFð	ñ 	ô 	ð 	ð €Ô Ø	Øà ðAð à!)Ð:ZÐ[Ð[Ø!)Ð:hÐiÐiðð ð  ˜ð
ð 
ðð ð"ð ð)ñ ô ð ð2 €Ô Ø	Øà ðOð
 à HÐ=XÐYÐYðð #˜ð
ð 
ðð ð jÐið%ñ ô ð ð ð r   