
    i                       d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ  ej        d          Z G d de          Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )z.Pydantic models for the multi-agent framework.    )annotationsN)Any)	BaseModel
ConfigDictFieldValidationInfofield_validatormodel_validatorz^[A-Za-z0-9_-]+$c                  B   e Zd ZU dZ ed          Zded<   ded<   ded<   ded<   ded	<   ded
<    ee          Z	ded<    ee          Z
ded<    ee          Zded<    ed          edd                        Z ed          edd                        ZdS )AgentConfigz-Configuration for a loadable stateless agent.forbidextrastrnameroledescriptionsystem_promptinput_schema_descriptionoutput_schema_descriptiondefault_factoryzdict[str, Any]input_schemaoutput_schemametadatavaluereturnc                X    t                               |          st          d          |S )Nz<name must use only letters, numbers, underscores, or hyphens)SAFE_NAME_RE	fullmatch
ValueErrorclsr   s     2/root/projects/multi-agents-meeting/core/models.pyvalidate_namezAgentConfig.validate_name   s/     %%e,, 	][\\\    c                L    |                                 st          d          |S )Nzsystem_prompt must not be emptystripr!   r"   s     r$   validate_system_promptz"AgentConfig.validate_system_prompt$   s)     {{}} 	@>???r&   Nr   r   r   r   )__name__
__module____qualname____doc__r   model_config__annotations__r   dictr   r   r   r	   classmethodr%   r*    r&   r$   r   r      s2        77:H---LIIIIII!!!!""""#(5#>#>#>L>>>>$)E$$?$?$?M????$uT:::H::::_V   [ 
 __%%   [ &%  r&   r   c                      e Zd ZU dZ ed          ZdZded<   dZded<    e	e
          Zd	ed
<    e	e
          Zd	ed<    e	e
          Zd	ed<   dS )MeetingBriefz Shared background for a meeting.r   r    r   project_backgroundcurrent_stater   	list[str]constraintssuccess_criteria	non_goalsN)r,   r-   r.   r/   r   r0   r8   r1   r9   r   listr;   r<   r=   r4   r&   r$   r6   r6   ,   s         **:H---L     M"U4888K8888"'%"="="===== 5666I666666r&   r6   c                      e Zd ZU dZ ed          Zded<    ee          Z	ded<    ee          Z
ded	<    ee          Zded
<   dZded<   dZded<    ed          edd                        ZdS )DecisionPacketzDecision frame for a meeting.r   r   r   decision_to_maker   r:   optionsevaluation_dimensionsrequired_questionsr7   risk_tolerancetime_horizonr   r   c                L    |                                 st          d          |S )Nz"decision_to_make must not be emptyr(   r"   s     r$   validate_decision_to_makez(DecisionPacket.validate_decision_to_makeD   s)     {{}} 	CABBBr&   Nr+   )r,   r-   r.   r/   r   r0   r1   r   r>   rB   rC   rD   rE   rF   r	   r3   rH   r4   r&   r$   r@   r@   8   s         '':H---Lt444G4444',uT'B'B'BBBBB$)E$$?$?$?????NL_'((   [ )(  r&   r@   c                  \   e Zd ZU dZ ed          Zded<   ded<   ded<    ee          Z	d	ed
<    ee          Z
d	ed<   dZded<   dZded<    ed          edd                        Z edd          edd                        Z edd          edd                        ZdS )ContextSourcez&External context source for a meeting.r   r   r   typepathpurposer   r:   includeexclude   int	max_filesi  max_chars_per_filer   r   c                ,    |dvrt          d          |S )N>   file	directoryz"type must be 'file' or 'directory'r!   r"   s     r$   validate_typezContextSource.validate_typeY   s$     ---ABBBr&   infor   c                \    |                                 st          |j         d          |S )Nz must not be empty)r)   r!   
field_namer#   r   rY   s      r$   validate_non_empty_textz%ContextSource.validate_non_empty_text`   s3     {{}} 	ECCCDDDr&   c                @    |dk    rt          |j         d          |S )Nr   z must be greater than zero)r!   r[   r\   s      r$   validate_positive_limitsz&ContextSource.validate_positive_limitsg   s+     A::KKKLLLr&   Nr+   )r   r   rY   r   r   r   )r   rQ   rY   r   r   rQ   )r,   r-   r.   r/   r   r0   r1   r   r>   rN   rO   rR   rS   r	   r3   rX   r]   r_   r4   r&   r$   rJ   rJ   L   sJ        00:H---LIIIIIILLLt444G4444t444G4444I"""""_V   [ 
 _VY''   [ ('
 _["677   [ 87  r&   rJ   c                      e Zd ZU dZ ed          Zded<   ded<   ded	<    ee
          Z	ded<    e
d          edd                        ZdS )MeetingInputz#Structured input for a meeting run.r   r   r   topicr6   briefr@   decision_packetr   zlist[ContextSource]context_sourcesr   r   c                L    |                                 st          d          |S )Nztopic must not be emptyr(   r"   s     r$   validate_topiczMeetingInput.validate_topicy   s(     {{}} 	86777r&   Nr+   )r,   r-   r.   r/   r   r0   r1   r   r>   re   r	   r3   rg   r4   r&   r$   ra   ra   o   s         --:H---LJJJ####+05+F+F+FOFFFF_W   [   r&   ra   c                  h    e Zd ZU dZ ed          Zded<   ded<   ded<   ded<   ded	<   d
ed<   dS )ContextDocumentz0A context document included in a meeting bundle.r   r   r   document_idsource_pathsource_typerM   excerptrQ   
char_countN)r,   r-   r.   r/   r   r0   r1   r4   r&   r$   ri   ri      sg         :::H---LLLLLLLOOOOOr&   ri   c                  z    e Zd ZU dZ ed          Zded<    ee          Z	ded<    ee          Z
d	ed
<   dS )ContextBundlez Collected context for a meeting.r   r   r   summaryr   zlist[ContextDocument]	documentszlist[dict[str, str]]skipped_pathsN)r,   r-   r.   r/   r   r0   r1   r   r>   rr   rs   r4   r&   r$   rp   rp      so         **:H---LLLL',uT'B'B'BIBBBB*/%*E*E*EMEEEEEEr&   rp   c                  N    e Zd ZU dZ ed          Zded<   ded<   dZded<   d	S )
DocumentCitationz4A machine-verifiable citation to a context document.r   r   r   rj   rk   r7   quoteN)r,   r-   r.   r/   r   r0   r1   rv   r4   r&   r$   ru   ru      sM         >>:H---LEOOOOOOr&   ru   c                      e Zd ZU dZ ed          Zded<   ded<    ee          Z	ded	<    ee          Z
ded
<    ee          Zded<    ee          Zded<   dS )AgentTurnResultz5Normalized runtime output for a stateless agent turn.r   r   r   
agent_nameresponser   r:   
key_pointsrisksrecommendationszlist[DocumentCitation]	citationsN)r,   r-   r.   r/   r   r0   r1   r   r>   r{   r|   r}   r~   r4   r&   r$   rx   rx      s         ??:H---LOOOMMM!E$777J7777uT222E2222!&t!<!<!<O<<<<(-d(C(C(CICCCCCCr&   rx   c                      e Zd ZU dZ ed          Zded<   ded<   dZded	<   dZded
<   dZ	ded<    e
d          edd                        Z ed          dd            ZdS )
PMDecisionz5Constrained orchestration decision from the PM agent.r   r   r   analysisnext_actionNz
str | Nonetarget_agentprompt_for_agentfinal_reportr   r   c                ,    |dvrt          d          |S )N>   FINISH
CALL_AGENTz(next_action must be CALL_AGENT or FINISHrW   r"   s     r$   validate_next_actionzPMDecision.validate_next_action   s$     000GHHHr&   aftermode'PMDecision'c                    | j         dk    r| j        r| j        st          d          | j         dk    r| j        st          d          | S )Nr   z5CALL_AGENT requires target_agent and prompt_for_agentr   zFINISH requires final_report)r   r   r   r!   r   selfs    r$   validate_action_fieldsz!PMDecision.validate_action_fields   s`    |++$ ZD,A Z !XYYYx''0A';<<<r&   r+   )r   r   )r,   r-   r.   r/   r   r0   r1   r   r   r   r	   r3   r   r
   r   r4   r&   r$   r   r      s         ??:H---LMMM#L#####'''''#L####_]##   [ $#
 _'"""   #"  r&   r   c                     e Zd ZU dZ ed          Zded<   ded<   ded	<   ded
<   ded<   ded<    ee          Z	ded<    ee          Z
ded<    ee          Zded<    ee          Zded<    ee          Zded<   ded<   ded<    ed          ed!d                        Z ed          d"d            Zd S )#MeetingStatez&Shared whiteboard state for a meeting.r   r   r   rb   r:   participantsrQ   
loop_count	max_loopsstatusrq   r   r{   open_questions	decisionszdict[str, AgentTurnResult]latest_agent_outputszlist[dict[str, Any]]	event_logra   meeting_inputrp   context_bundler   r   c                4    h d}||vrt          d          |S )N>   failedrunningfinished	finishingforced_stopz.status must be a valid meeting lifecycle staterW   )r#   r   alloweds      r$   validate_statuszMeetingState.validate_status   s/     POOMNNNr&   r   r   'MeetingState'c                J    | j         | j        dz   k    rt          d          | S )N   z(loop_count must not exceed max_loops + 1)r   r   r!   r   s    r$   validate_loop_boundsz!MeetingState.validate_loop_bounds   s*    ?T^a///GHHHr&   Nr+   )r   r   )r,   r-   r.   r/   r   r0   r1   r   r>   r{   r   r   r2   r   r   r	   r3   r   r
   r   r4   r&   r$   r   r      sw        00:H---LJJJOOONNNKKKLLL!E$777J7777 %d ; ; ;N;;;; 5666I66667<uT7R7R7RRRRR&+eD&A&A&AIAAAA!!!!_X   [  _'"""   #"  r&   r   )r/   
__future__r   retypingr   pydanticr   r   r   r   r	   r
   compiler   r   r6   r@   rJ   ra   ri   rp   ru   rx   r   r   r4   r&   r$   <module>r      se   4 4 " " " " " " 				       c c c c c c c c c c c c c c c c rz-..    )   <	7 	7 	7 	7 	79 	7 	7 	7    Y   (         I      F    9   $
 
 
 
 
i 
 
 
F F F F FI F F F    y   
D 
D 
D 
D 
Di 
D 
D 
D       8    9     r&   