Ë
    ÛJêj%  ã                  óª   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	  G d„ de
e«      Z G d„ d	e
e«      Z G d
„ de
e«      Ze G d„ d«      «       Zg d¢Zy)um  Agent Identity â€” identity layer for CyberBrain26 agents.

Every agent in the system MUST have an AgentIdentity. Identity enables:
- unique agent identification
- role determination
- tool permission scoping
- auditability of agent actions
- downstream credential scoping
- separation of agent from user

Agent MUST NOT automatically inherit all user permissions.
é    )Úannotations)Ú	dataclassÚfield)ÚEnum)ÚAnyc                  ó    — e Zd ZdZdZdZdZdZy)Ú
TrustLevelz!Trust level of an agent identity.Ú	untrustedÚverifiedÚtrustedÚofficialN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	UNTRUSTEDÚVERIFIEDÚTRUSTEDÚOFFICIAL© ó    úS/home/oem/CyberBrain26-unified/src/cyberbrain26/security_plane/identity/__init__.pyr	   r	      s   „ Ù+à€IØ€HØ€GØ�Hr   r	   c                  ó8   — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZy)Ú	AgentRolezBBuilt-in agent roles. Custom roles can be added via string values.ÚplannerÚcoderÚ	evaluatorÚsecurityÚresearchÚ
supervisorÚrouterÚbrowserÚ
complianceÚcustomN)r   r   r   r   ÚPLANNERÚCODERÚ	EVALUATORÚSECURITYÚRESEARCHÚ
SUPERVISORÚROUTERÚBROWSERÚ
COMPLIANCEÚCUSTOMr   r   r   r   r      s7   „ ÙLà€GØ€EØ€IØ€HØ€HØ€JØ€FØ€GØ€JØ�Fr   r   c                  ó@   — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZy)ÚPermissionScopez/Standard permission scopes granted to an agent.Ú	read_fileÚ
write_fileÚdelete_fileÚnetworkr"   ÚshellÚpythonÚgitÚdockerÚsecretsÚmcpÚauditN)r   r   r   r   Ú	READ_FILEÚ
WRITE_FILEÚDELETE_FILEÚNETWORKr,   ÚSHELLÚPYTHONÚGITÚDOCKERÚSECRETSÚMCPÚAUDITr   r   r   r0   r0   -   sA   „ Ù9à€IØ€JØ€KØ€GØ€GØ€EØ€FØ
€CØ€FØ€GØ
€CØ�Er   r0   c                  óÖ   — e Zd ZU dZded<   ded<   ej                  Zded<    ee	¬«      Z
ded	<   d
Zded<    ee¬«      Zded<   dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zy
)ÚAgentIdentitya¶  Identity of an agent within the CyberBrain26 system.

    Attributes:
        agent_id: Unique identifier for the agent instance.
        role: The agent's role (planner, coder, etc.).
        trust_level: Trust classification of the agent.
        scopes: Set of permission scopes granted to this identity.
        owner: User or system that owns this agent.
        metadata: Additional identity metadata (provider, version, etc.).
    ÚstrÚagent_idÚroler	   Útrust_level)Údefault_factoryúset[str]ÚscopesNz
str | NoneÚownerzdict[str, Any]Úmetadatac                ó`   — | j                   st        d«      ‚| j                  st        d«      ‚y )Nzagent_id must not be emptyzrole must not be empty)rJ   Ú
ValueErrorrK   ©Úselfs    r   Ú__post_init__zAgentIdentity.__post_init__R   s-   € Ø�}Š}ÜÐ9Ó:Ð:Ø�yŠyÜÐ5Ó6Ð6ð r   c                ó   — || j                   v S )z<Check whether this identity has a specific permission scope.)rO   )rU   Úscopes     r   Ú	has_scopezAgentIdentity.has_scopeX   s   € à˜Ÿ™Ð#Ð#r   c                ó2   — t        || j                  z  «      S )z8Check whether this identity has any of the given scopes.)ÚboolrO   )rU   rO   s     r   Úhas_any_scopezAgentIdentity.has_any_scope\   s   € ä�F˜TŸ[™[Ñ(Ó)Ð)r   c                óT   — | j                  t        j                  j                  «      S ©N)rY   r0   r<   ÚvaluerT   s    r   Úcan_read_filezAgentIdentity.can_read_file`   s   € Ø�~‰~œo×7Ñ7×=Ñ=Ó>Ð>r   c                óT   — | j                  t        j                  j                  «      S r^   )rY   r0   r=   r_   rT   s    r   Úcan_write_filezAgentIdentity.can_write_filec   s   € Ø�~‰~œo×8Ñ8×>Ñ>Ó?Ð?r   c                óT   — | j                  t        j                  j                  «      S r^   )rY   r0   r@   r_   rT   s    r   Úcan_execute_shellzAgentIdentity.can_execute_shellf   s   € Ø�~‰~œo×3Ñ3×9Ñ9Ó:Ð:r   c                óT   — | j                  t        j                  j                  «      S r^   )rY   r0   r?   r_   rT   s    r   Úcan_access_networkz AgentIdentity.can_access_networki   ó   € Ø�~‰~œo×5Ñ5×;Ñ;Ó<Ð<r   c                óT   — | j                  t        j                  j                  «      S r^   )rY   r0   rD   r_   rT   s    r   Úcan_access_secretsz AgentIdentity.can_access_secretsl   rg   r   c                óZ   — | j                   t        j                  t        j                  fv S r^   )rL   r	   r   r   rT   s    r   Ú
is_trustedzAgentIdentity.is_trustedo   s$   € Ø×Ñ¤J×$6Ñ$6¼
×8KÑ8KÐ#LÐLÐLr   )ÚreturnÚNone)rX   rI   rl   r[   )rO   rN   rl   r[   )rl   r[   )r   r   r   r   Ú__annotations__r	   r   rL   r   ÚsetrO   rP   ÚdictrQ   rV   rY   r\   r`   rb   rd   rf   ri   rk   r   r   r   rH   rH   >   sz   … ñ	ð ƒMØ
ƒIØ(×1Ñ1€K�Ó1Ù¨SÔ1€FˆHÓ1Ø€Eˆ:ÓÙ$°TÔ:€HˆnÓ:ó7ó$ó*ó?ó@ó;ó=ó=ôMr   rH   )rH   r   r0   r	   N)r   Ú
__future__r   Údataclassesr   r   Úenumr   Útypingr   rI   r	   r   r0   rH   Ú__all__r   r   r   ú<module>rv      sf   ðñõ #ç (Ý Ý ô��dô ô��Tô ô�c˜4ô ð" ÷1Mð 1Mó ð1Mòh�r   