o
    pjj  ã                   @  sT   d Z ddlmZ ddlmZ ddlmZmZ ddd„Zddd„Z	ddœddd„Z
dS )zLGenerate agent tool definitions without exposing app implementation details.é    )Úannotations)ÚAny)ÚActionContractÚAppManifestÚmanifestr   ÚactionÚstrÚcontractr   Úreturnúdict[str, Any]c              	   C  sN   |j }|d u s
|jstdƒ‚| j| j|j|j|jt|j	ƒ|j
|jdœ|jdœS )Nz#Capability is not exposed to agents)ÚcategoryÚlevel)Úapp_idÚapp_versionÚ
capabilityÚtitleÚsummaryÚdomainsÚriskÚconfirmation)ÚagentÚexposedÚ
ValueErrorr   r   r   r   r   Úlistr   Úrisk_categoryÚ
risk_levelr   )r   r   r	   r   © r   ú&bridge_platform/agents/tool_catalog.pyÚcompact_tool
   s   ør   c                 C  sx   t | ||ƒ}|j}| dt|jƒt|jƒ|jpdi dœ|jt|jƒt|j	ƒt|j
ƒ||j|j|j|j|jdœdœ	¡ |S )Nz1.0Úobject)ÚtypeÚ
properties)r   Útimeout_secondsÚside_effectsÚ
idempotentÚidempotency_key_requiredÚdata_classification)	Útool_schema_versionÚuse_whenÚdo_not_use_whenÚinput_schemaÚoutput_schemaÚerrorsÚrequired_permissionsÚallowed_rolesÚ	execution)r   r   Úupdater   r(   r)   r*   r+   r,   r-   r.   r"   r#   r$   r%   r&   )r   r   r	   Útoolr   r   r   r   Ú	full_tool   s(   ú÷r2   T)Úcompactr3   Úboolúlist[dict[str, Any]]c                  s&   |rt nt‰‡ ‡fdd„ˆ j ¡ D ƒS )Nc                   s.   g | ]\}}|j d ur|j jrˆˆ ||ƒ‘qS )N)r   r   )Ú.0r   r	   ©r   Úrenderr   r   Ú
<listcomp>4   s
    
þz"manifest_tools.<locals>.<listcomp>)r   r2   ÚactionsÚitems)r   r3   r   r7   r   Úmanifest_tools2   s   þr<   N)r   r   r   r   r	   r   r
   r   )r   r   r3   r4   r
   r5   )Ú__doc__Ú
__future__r   Útypingr   Úbridge_platform.apps.contractsr   r   r   r2   r<   r   r   r   r   Ú<module>   s    

