o
    i                     @  sP  d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 ddl
mZmZ dd	lmZ eG d
d dZeG dd dZeG dd dZeG dd dZeG dd dZeG dd dZeG dd dZeG dd dZeG dd dZeG dd dZejeejeejeejeejeejeejeejeejeejei
ZdS )    )annotationsN)	dataclassfield)ClassVar)agent   )JobAcceptArgumentsRunningJobInfo   )channelc                   @  sn   e Zd ZU dZdZded< dZded< dZded	< dZded
< dZ	ded< dZ
ded< dddZdddZdS )InitializeRequestzisent by the main process to the subprocess to initialize it. this is going to call initialize_process_fncr   ClassVar[int]MSG_IDFboolasyncio_debugfloatping_intervalping_timeouthigh_ping_threshold str
http_proxyb
io.BytesIOreturnNonec                 C  sJ   t || j t || j t || j t || j t || j d S N)	r   
write_boolr   write_floatr   r   r   write_stringr   selfr    r"   Z/var/www/html/livekit_bhavya/venv/lib/python3.10/site-packages/livekit/agents/ipc/proto.pywrite   s
   zInitializeRequest.writec                 C  s@   t || _t || _t || _t || _t || _d S r   )	r   	read_boolr   
read_floatr   r   r   read_stringr   r    r"   r"   r#   read!   s
   zInitializeRequest.readNr   r   r   r   )__name__
__module____qualname____doc__r   __annotations__r   r   r   r   r   r$   r(   r"   r"   r"   r#   r      s   
 
r   c                   @  >   e Zd ZU dZdZded< dZded< dddZdddZdS )InitializeResponsezmark the process as initializedr
   r   r   r   r   errorr   r   r   r   c                 C     t || j d S r   )r   r   r1   r    r"   r"   r#   r$   0      zInitializeResponse.writec                 C     t || _d S r   )r   r'   r1   r    r"   r"   r#   r(   3      zInitializeResponse.readNr)   )	r*   r+   r,   r-   r   r.   r1   r$   r(   r"   r"   r"   r#   r0   )      
 
r0   c                   @  r/   )PingRequestzHsent by the main process to the subprocess to check if it is still aliver   r   r   r   int	timestampr   r   r   r   c                 C  r2   r   )r   
write_longr9   r    r"   r"   r#   r$   >   r3   zPingRequest.writec                 C  r4   r   )r   	read_longr9   r    r"   r"   r#   r(   A   r5   zPingRequest.readNr)   )	r*   r+   r,   r-   r   r.   r9   r$   r(   r"   r"   r"   r#   r7   7   r6   r7   c                   @  sJ   e Zd ZU dZdZded< dZded< dZded< dddZdddZ	dS )PongResponsezresponse to a PingRequest   r   r   r   r8   last_timestampr9   r   r   r   r   c                 C  s    t || j t || j d S r   )r   r:   r>   r9   r    r"   r"   r#   r$   M   s   zPongResponse.writec                 C  s   t || _t || _d S r   )r   r;   r>   r9   r    r"   r"   r#   r(   Q   s   zPongResponse.readNr)   )
r*   r+   r,   r-   r   r.   r>   r9   r$   r(   r"   r"   r"   r#   r<   E   s   
 
r<   c                   @  sD   e Zd ZU dZdZded< eddZded< dddZdddZ	dS )StartJobRequestzsent by the main process to the subprocess to start a job, the subprocess will only
    receive this message if the process is fully initialized (after sending a InitializeResponse).   r   r   F)initr	   running_jobr   r   r   r   c                 C  s   | j j}t|| j j  t||j t||j t||j	 t|| j j
 t|| j j t|| j j t|| j j d S r   )rB   accept_argumentsr   write_bytesjobSerializeToStringr   nameidentitymetadataurltoken	worker_idr   fake_job)r!   r   accept_argsr"   r"   r#   r$   ^   s   zStartJobRequest.writec              	   C  sf   t  }|t| ttt|t|t|d|t|t|t|t|d| _	d S )N)rG   rH   rI   )rC   rE   rJ   rK   rL   rM   )
r   JobParseFromStringr   
read_bytesr	   r   r'   r%   rB   )r!   r   rE   r"   r"   r#   r(   i   s   zStartJobRequest.readNr)   )
r*   r+   r,   r-   r   r.   r   rB   r$   r(   r"   r"   r"   r#   r?   V   s   
 
r?   c                   @  r/   )ShutdownRequestzsent by the main process to the subprocess to indicate that it should shut down
    gracefully. the subprocess will follow with a ExitInfo message   r   r   r   r   reasonr   r   r   r   c                 C  r2   r   r   r   rT   r    r"   r"   r#   r$      r3   zShutdownRequest.writec                 C  r4   r   r   r'   rT   r    r"   r"   r#   r(      r5   zShutdownRequest.readNr)   	r*   r+   r,   r-   r   r.   rT   r$   r(   r"   r"   r"   r#   rR   z   s   
 
rR   c                   @  r/   )ExitingzIsent by the subprocess to the main process to indicate that it is exiting   r   r   r   r   rT   r   r   r   r   c                 C  r2   r   rU   r    r"   r"   r#   r$      r3   zExiting.writec                 C  r4   r   rV   r    r"   r"   r#   r(      r5   zExiting.readNr)   rW   r"   r"   r"   r#   rX      r6   rX   c                   @  sV   e Zd ZU dZdZded< dZded< dZded< d	Zd
ed< dddZ	dddZ
dS )InferenceRequestz=sent by a subprocess to the main process to request inference   r   r   r   r   method
request_id    bytesdatar   r   r   r   c                 C  s.   t || j t || j t || j d S r   )r   r   r\   r]   rD   r`   r    r"   r"   r#   r$      s   zInferenceRequest.writec                 C  s(   t || _t || _t || _d S r   )r   r'   r\   r]   rQ   r`   r    r"   r"   r#   r(      s   zInferenceRequest.readNr)   )r*   r+   r,   r-   r   r.   r\   r]   r`   r$   r(   r"   r"   r"   r#   rZ      s   
 
rZ   c                   @  sV   e Zd ZU dZdZded< dZded< dZd	ed
< dZded< dddZ	dddZ
dS )InferenceResponsezresponse to an InferenceRequest   r   r   r   r   r]   Nzbytes | Noner`   r1   r   r   r   r   c                 C  sJ   t || j t || jd u | jd urt || j t || j d S r   )r   r   r]   r   r`   rD   r1   r    r"   r"   r#   r$      s
   
zInferenceResponse.writec                 C  s6   t || _t |}|rt || _t || _d S r   )r   r'   r]   r%   rQ   r`   r1   )r!   r   has_datar"   r"   r#   r(      s
   
zInferenceResponse.readr)   )r*   r+   r,   r-   r   r.   r]   r`   r1   r$   r(   r"   r"   r"   r#   ra      s   
 
ra   c                   @  s2   e Zd ZU dZdZded< dd	d
ZdddZdS )DumpStackTraceRequestzEsent by the main process to request a stack trace dump before killing	   r   r   r   r   r   r   c                 C     d S r   r"   r    r"   r"   r#   r$         zDumpStackTraceRequest.writec                 C  rf   r   r"   r    r"   r"   r#   r(      rg   zDumpStackTraceRequest.readNr)   )r*   r+   r,   r-   r   r.   r$   r(   r"   r"   r"   r#   rd      s
   
 
rd   )
__future__r   iodataclassesr   r   typingr   livekit.protocolr   rE   r   r	   r   r   r   r0   r7   r<   r?   rR   rX   rZ   ra   rd   r   IPC_MESSAGESr"   r"   r"   r#   <module>   sL    #