+
    ~jt                      a  0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t
^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHtHtHtHt ^ RIHt ^ RIt^ R	IH t H!t! ^ R
I"H#t# ^ RI$H%t%H&t& ^RI'H(t( ^RI)H*t* ^RI+H,t,H-t- ^RI.H/t/H0t0H1t1 ^RI2H3t3 ^RI4H5t5H6t6H7t7 ^RI8H9t9 ^RI:H;t; ]Px                  R,          ! R4      t=R R lt>]'       d   ^RI?H@t@ ^RIAHBtBHCtC ^RIDHEtE ]RR/R R ll4       tF]R R  l4       tFRR/R! R" lltF]FtG] ! R# R$]4      4       tH ! R% R&]I]4      tJ] ! R' R(4      4       tK] ! R) R*4      4       tL]!P                  P                  ]!P                  P                  ]!P                  P                  .tQR+]RR,&    ! R- R.]P                  4      tT ! R/ R4      tUR0 R1 ltV ! R2 R34      tW ! R4 R54      tX] ! R6 R74      4       tYR# )8    )annotationsN)Callable	Coroutine)	dataclass)Enumunique)Path)TYPE_CHECKINGAnyLiteraloverload)urlparse)apirtc)Claims)agentmodels)logger)Tagger)_upload_session_reportotel_metrics)_BufferingHandler_setup_cloud_tracer_shutdown_telemetry)
NotGivenOr)http_contextis_givenwait_for_participant)deprecate_params)is_cloud
JobContextagents_job_contextc                    V ^8  d   QhRRRR/# )   livekit_urlstrreturn
str | None )formats   "g/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/agents/job.py__annotate__r,   3   s      C J     c                    \         P                  P                  R4      pV'       d   V# \        V 4      P                  pV'       d   \        V 4      '       d   RV 2# R# )zKReturn the observability endpoint, or None if observability is unavailable.LIVEKIT_OBSERVABILITY_URLzhttps://N)osenvirongetr   hostnamer    )r%   urlr3   s   &  r+   _observability_urlr5   3   sJ    
**..4
5C

$--HH[))($$r-   )InferenceExecutor)AgentSessionRecordingOptionsSessionReportrequiredTc                    V ^8  d   QhRRRR/# )r$   r;   zLiteral[True]r'   r!   r)   )r*   s   "r+   r,   r,   E   s     I I I* Ir-   c                    R # Nr)   r;   s   $r+   get_job_contextr@   D   s    FIr-   c                    V ^8  d   QhRRRR/# )r$   r;   zLiteral[False]r'   JobContext | Noner)   )r*   s   "r+   r,   r,   I   s     J J J4E Jr-   c                    R # r>   r)   r?   s   $r+   r@   r@   H   s    GJr-   c                    V ^8  d   QhRRRR/# )r$   r;   boolr'   rB   r)   )r*   s   "r+   r,   r,   L   s       1B r-   c                ^    \         P                  R 4      pVf   V '       d   \        R4      hV# )NzHno job context found, are you running this code inside a job entrypoint?)_JobContextVarr2   RuntimeError)r;   ctxs   $ r+   r@   r@   L   s0    


T
"C
{xV
 	
 Jr-   c                      ] tR t^YtRtRtRtR# )JobExecutorTypeprocessthreadr)   N)__name__
__module____qualname____firstlineno__PROCESSTHREAD__static_attributes__r)   r-   r+   rK   rK   Y   s    GFr-   rK   c                  &    ] tR t^_tRtRtRtRtRtR# )AutoSubscribesubscribe_allsubscribe_none
audio_only
video_onlyr)   N)	rN   rO   rP   rQ   SUBSCRIBE_ALLSUBSCRIBE_NONE
AUDIO_ONLY
VIDEO_ONLYrT   r)   r-   r+   rV   rV   _   s    #M%NJJr-   rV   c                  D    ] tR t^ft$ R]R&   R]R&   R]R&   RtR]R&   RtR# )	JobAcceptArgumentsr&   nameidentitymetadataNdict[str, str] | None
attributesr)   )rN   rO   rP   rQ   __annotations__re   rT   r)   r-   r+   r`   r`   f   s    
IMM(,J%,r-   r`   c                  T    ] tR t^nt$ R]R&   R]R&   R]R&   R]R&   R]R&   R	]R
&   RtR# )RunningJobInfor`   accept_arguments	agent.Jobjobr&   r4   token	worker_idrE   fake_jobr)   NrN   rO   rP   rQ   rf   rT   r)   r-   r+   rh   rh   n   s!    ((	N	HJNNr-   rh   z#list[rtc.ParticipantKind.ValueType]DEFAULT_PARTICIPANT_KINDSc                  >   a  ] tR t^tRtR V 3R lltR R ltRtV ;t# )_ContextLogFieldsFilterzGFilter that adds job context fields to log records without overwriting.c                    V ^8  d   QhRRRR/# )r$   job_ctxr!   r'   Noner)   )r*   s   "r+   r,   $_ContextLogFieldsFilter.__annotate__   s      
 t r-   c                	0   < \         SV `  4        Wn        R # r>   )super__init__rt   )selfrt   	__class__s   &&r+   ry    _ContextLogFieldsFilter.__init__   s    r-   c                    V ^8  d   QhRRRR/# )r$   recordzlogging.LogRecordr'   rE   r)   )r*   s   "r+   r,   rv      s      . 4 r-   c                	d   V P                   P                  P                  \        P                  8w  d    \        4       pW P                   8w  d   R #  V P                   P                  P                  4        F$  w  r4\        W4      '       d   K  \        WV4       K&  	  R #   \         d     R # i ; i)T)rt   procexecutor_typerK   rR   r@   rH   _log_fieldsitemshasattrsetattr)rz   r~   rI   keyvalues   &&   r+   filter_ContextLogFieldsFilter.filter   s    <<**o.E.EE %' ,,& ' ,,2288:JC6''U+ ;    s   
B   B/.B/)rt   )	rN   rO   rP   rQ   __doc__ry   r   rT   __classcell__)r{   s   @r+   rr   rr      s    Q  r-   rr   c            	         ] tR t^t]R ]P                  .]RN,          3,          tR R lt	R R lt
R R ltR R	 ltR
 R ltR R ltR R ltR R lt]R R l4       t]R R l4       t]R R l4       tROR R llt]P.                  R R l4       t]R R l4       t]R R l4       t]R  R! l4       t]R" R# l4       t]R$ R% l4       t]R& R' l4       t]R( R) l4       t]R* R+ l4       t ] PB                  R, R- l4       t R. R/ lt"R0RR1]#/R2 R3 llt$]%! R4R5/4      R6RR7]&PN                  R8RR4R/R9 R: ll4       t(ROR; R< llt)R=R>/R? R@ llt*RPRA RB llt+RQRC RD llt,R1]#/RE RF llt-RG RH lt.RI RJ lt/RK RL lt0RMt1R# )Rr!   Nc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r$   r   
JobProcessinforh   roomrtc.Room
on_connectzCallable[[], None]on_shutdownzCallable[[str], None]inference_executorr6   r'   ru   r)   )r*   s   "r+   r,   JobContext.__annotate__   s[     1A 1A 1A 	1A
 1A '1A +1A .1A 
1Ar-   c               	f   Wn         W n        W0n        W@n        WPn        . V n        . V n        \        \        \        \        P                  3,          \        P                  R ,          3,          ! 4       V n        \        \        P                  \         ,          ,          ! 4       V n        V P                  P%                  RV P&                  4       W`n        / V n        \-        V 4      V n        . V n        R V n        \4        P6                  ! 4       V n        ^RIHp VP?                  4       pVP@                  '       d   VPB                  V n"        M$\G        V P8                  PH                  4      V n"        RV n%        \        PL                  ! 4       V n'        \Q        4       V n)        RV n*        R V n+        R # )Nparticipant_connectedAgentsConsoleF),_proc_info_room_on_connect_on_shutdown_shutdown_callbacks_participant_entrypointsdicttupler&   r!    _PARTICIPANT_ENTRYPOINT_CALLBACKasyncioTask_participant_taskslistr   _pending_taskson_participant_available_inf_executorr   rr   _log_filter_handlers_with_filter_primary_agent_sessiontempfileTemporaryDirectory_tempdirclir   get_instanceenabledsession_directory_session_directoryr	   ra   
_connectedLock_lockr   _tagger_recording_initialized_early_log_handler)	rz   r   r   r   r   r   r   r   cs	   &$$$$$$  r+   ry   JobContext.__init__   sE    


%'WY   	% #'#zBBBCW\\RVEWW#
 # #7<<#457

-t/J/JK/+-248<>";?# 335&&&(999&'&9&9D#&*4==+=+=&>D#\\^
x&+#<@r-   c                   V ^8  d   QhRR/# r$   r'   ru   r)   )r*   s   "r+   r,   r      s     7 74 7r-   c                	    \         P                  ! 4       pVP                   F9  pVP                  V P                  4       V P
                  P                  V4       K;  	  R # r>   )logging	getLoggerhandlers	addFilterr   r   append)rz   root_loggerhandlers   &  r+   	_on_setupJobContext._on_setup   sH    '')"++Gd../&&--g6 ,r-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   r      s     @ @d @r-   c                V   V P                   P                  '       g'   V P                   P                  P                  '       g   R# \	        V P                   P
                  4      '       g   R# \        4       V n        \        P                  ! 4       P                  V P                  4       R# )z9Start buffering logs early so crash logs can be uploaded.N)r   rn   rk   enable_recordingr5   r4   r   r   r   r   
addHandlerrz   s   &r+   _start_log_bufferingJobContext._start_log_buffering   sf    ::djjnn&E&E&E!$**..11"3"5&&t'>'>?r-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   r      s     ' 'T 'r-   c                    V P                   pVf   R# \        P                  ! 4       P                  V4       RV n         R# )z/Remove the buffering handler without replaying.N)r   r   r   removeHandler)rz   r   s   & r+   _stop_log_bufferingJobContext._stop_log_buffering   s4    ))?))'2"&r-   c                    V ^8  d   QhRRRR/# )r$   replayrE   r'   ru   r)   )r*   s   "r+   r,   r      s       $ r-   c               \   V P                   pVf   R# \        P                  ! 4       P                  V4       RV n         V'       g   R# ^ RIHp \        P                  ! 4       P                   F;  p\        WC4      '       g   K  VP                   F  pVP                  V4       K  	   R# 	  R# )zDRemove buffering handler and optionally replay records through OTLP.N)LoggingHandler)
r   r   r   r   opentelemetry.sdk._logsr   r   
isinstancebufferemit)rz   r   r   r   hr~   s   &$    r+   _flush_early_log_buffer"JobContext._flush_early_log_buffer   s    ))?))'2"& 	;""$--A!,,%nnFFF6N -	 .r-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   r      s     (Y (Yt (Yr-   c                	V  "   ^RI Hp V P                  ;p'       g   R# \        P                  ! VP
                  4       VP                  4       pV P                  V4      pVP                  '       d   VP                  '       d    \        P                  ! VP                  4       ^R7      p^ RIp^ RIpVP                  P!                  V P"                  RR7      G Rj  xL
  VP%                  V P"                  R,          RR7      ;_uu_4       GRj  xL
 pVP'                  V4      G Rj  xL
  RRR4      GRj  xL
  \/        V P0                  P2                  ;'       g    V P0                  P4                  4      p\7        V P8                  P:                  4      p	\=        VP>                  PA                  4       4      '       g	   V'       da   V	'       dW    \C        V P8                  PD                  PF                  V	VV P0                  \H        PJ                  ! 4       R
7      G Rj  xL
  R# R# R#  ELR EL  EL
 L  + GRj  xL 
 '       g   i     EL; i  \(         d    \*        P,                  ! R	4        EL;i ; i LZ  \(         d    \*        P,                  ! R4        R# i ; i5i)   r   N)indentT)exist_okzsession_report.jsonw)modezfailed to save session report)
agent_nameobservability_urlreporttaggerhttp_sessionz4failed to upload the session report to LiveKit Cloud)&r   r   r   r   flush_turn_metricshistoryr   make_session_reportr   r~   jsondumpsto_dictaiofilesaiofiles.osr0   makedirsr   openwrite	Exceptionr   	exceptionrE   r   evaluationsoutcomer5   r   r4   anyrecording_optionsvaluesr   rk   r   r   r   )
rz   r   sessionr   r   report_jsonr   f	has_evalsobs_urls
   &         r+   _on_session_endJobContext._on_session_end   s    &6666''8&&())'2 999B"jj)9!D"kk**4+B+BT*RRR#==++.CC# )   ''+...  11IIT\\5I5IJ	$TZZ^^4((//122iW	Y,#zz~~88&-!<<!-!:!:!<   FMi S /   
  B  !@AB  Y  !WXYs   A/J)2J)AI H/4I H2I H:+H5,H:0I ;H8<I  !J)"A*J)J)AJ $I?%J )J)/I 2I 5H:8I :I	 I
I	I	I J)I !I<8J);I<<J)?J !J&"J)%J&&J)c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   r   )  s     + +T +r-   c           	     	   V P                   e5   V P                  '       g#    ^RIHp V P	                  V! RRRRR7      4       V P                  P                  4        \        4        V P                   F  pVP                  V P                  4       K   	  V P                  P                  4        R #   \
         d*    \        P                  ! R4       T P                  4         Li ; i)N)r8   FT)audiotraceslogs
transcriptz%failed to initialize crash log upload)r   r   voice.agent_sessionr8   init_recordingr   r   r   r   r   cleanupr   r   removeFilterr   clear)rz   r8   r   s   &  r+   _on_cleanupJobContext._on_cleanup)  s     "".t7R7R7R+A##$5TV[\ 	11G  !1!12 2""((*  +  !HI((*+s   !B1 11C%$C%c                   V ^8  d   QhRR/# )r$   r'   rE   r)   )r*   s   "r+   r,   r   >  s     # #T #r-   c                	.    V P                   P                  # r>   )r   rn   r   s   &r+   is_fake_jobJobContext.is_fake_job>  s    zz"""r-   c                   V ^8  d   QhRR/# )r$   r'   r	   r)   )r*   s   "r+   r,   r   B  s     - -4 -r-   c                	,    \        V P                  4      # r>   )r	   r   r   s   &r+   r   JobContext.session_directoryA  s    D++,,r-   c                   V ^8  d   QhRR/# )r$   r'   r6   r)   )r*   s   "r+   r,   r   F  s     " "$5 "r-   c                	    V P                   # r>   )r   r   s   &r+   r   JobContext.inference_executorE  s    !!!r-   c                   V ^8  d   QhRR/# )r$   r'   r   r)   )r*   s   "r+   r,   r   J  s       r-   c                    V P                   # )a3  Returns the Tagger for adding tags and outcomes to the session.

Tags are uploaded to LiveKit Cloud at session end.

Example:
    ```python
    ctx.tagger.success(reason="Task completed successfully")
    ctx.tagger.fail(reason="User hung up before completing")
    ctx.tagger.add("voicemail:true")
    ```
)r   r   s   &r+   r   JobContext.taggerI  s     ||r-   c                    V ^8  d   QhRRRR/# )r$   r   zAgentSession | Noner'   r:   r)   )r*   s   "r+   r,   r   X  s     $ $+> $- $r-   c                	d   ^RI Hp T;'       g    V P                  pV'       g   \        R4      hVP                  pV'       d   VP
                  '       d   \        R4      hT! VP                  V P                  P                  V P                  P                  P                  V P                  P                  P                  VP                  V'       d   VP                  MRV'       d   VP                  MRVP                  VP                   VP"                  P%                  4       VP&                  P(                  R7      pV'       di   VP                  '       d   VP                  Vn        VP                  '       d4   VP                  Vn        VP.                  VP,                  ,
          Vn        V# )r   r9   z0Cannot prepare report, no AgentSession was foundzHCannot create the AgentSession report, the RecorderIO is still recordingN)r   job_idroom_idr   optionsaudio_recording_pathaudio_recording_started_at
started_ateventschat_historymodel_usage)voice.reportr:   r   rH   _recorder_io	recording_recording_optionsrk   idr   sidra   r%  output_pathrecording_started_at_started_at_recorded_eventsr   copyusager+  r&  r'  	timestampduration)rz   r   r:   recorder_iosrs   &&   r+   r   JobContext.make_session_reportX  s7   /88T88QRR**;000Z  %8888;;HHMM%%##OO<G!8!8TKV{'G'G\`**++ --/11
 &&&*5*A*A'///0;0P0P- llR-J-JJ	r-   c                   V ^8  d   QhRR/# )r$   r'   zapi.LiveKitAPIr)   )r*   s   "r+   r,   r     s     C C^ Cr-   c                V    \         P                  ! \        P                  ! 4       R7      # )a@  Returns an LiveKitAPI for making API calls to LiveKit.

Credentials are sourced from environment variables if not provided explicitly.
When starting via the worker, values passed in `WorkerOptions` are exported to
LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET so this API is always
usable inside job entrypoints.
)r   )r   
LiveKitAPIr   r   r   s   &r+   r   JobContext.api~  s     ~~l&?&?&ABBr-   c                   V ^8  d   QhRR/# )r$   r'   r   r)   )r*   s   "r+   r,   r     s      j r-   c                    V P                   # )zOReturns the process running the job. Useful for storing process-specific state.)r   r   s   &r+   r   JobContext.proc  s     zzr-   c                   V ^8  d   QhRR/# r$   r'   rj   r)   )r*   s   "r+   r,   r     s      Y r-   c                .    V P                   P                  # )z5Returns the current job that the worker is executing.)r   rk   r   s   &r+   rk   JobContext.job  s     zz~~r-   c                   V ^8  d   QhRR/# r$   r'   r&   r)   )r*   s   "r+   r,   r     s     $ $3 $r-   c                .    V P                   P                  # )zReturns the id of the worker.)r   rm   r   s   &r+   rm   JobContext.worker_id  s     zz###r-   c                   V ^8  d   QhRR/# )r$   r'   r   r)   )r*   s   "r+   r,   r     s      h r-   c                    V P                   # )zThe Room object is the main interface that the worker should interact with.

When the entrypoint is called, the worker has not connected to the Room yet.
Certain properties of Room would not be available before calling JobContext.connect()
)r   r   s   &r+   r   JobContext.room  s     zzr-   c                   V ^8  d   QhRR/# )r$   r'   zrtc.LocalParticipantr)   )r*   s   "r+   r,   r     s     , ,+ ,r-   c                	.    V P                   P                  # r>   )r   local_participantr   s   &r+   r   JobContext.agent  s    zz+++r-   c                   V ^8  d   QhRR/# )r$   r'   r7   r)   )r*   s   "r+   r,   r     s     + + +r-   c                T    V P                   '       g   \        R4      hV P                   # )z.Returns the primary AgentSession for this job.z(No AgentSession was started for this job)r   rH   r   s   &r+   primary_sessionJobContext.primary_session  s(     ***IJJ***r-   c                   V ^8  d   QhRR/# rI  r)   )r*   s   "r+   r,   r     s     5 5C 5r-   c                	    V P                  4       P                  ;p'       d   V# V P                  P                  P                  # r>   )token_claimsrb   r   rQ  )rz   rb   s   & r+   local_participant_identity%JobContext.local_participant_identity  s7    ((*33383Ozz++444r-   c                   V ^8  d   QhRR/# )r$   r'   dict[str, Any]r)   )r*   s   "r+   r,   r     s     
  
 N 
 r-   c                    V P                   # )a^  
Returns the current dictionary of log fields that will be injected into log records.

These fields enable enriched structured logging and can include job metadata,
worker ID, trace IDs, or other diagnostic context.

The returned dictionary can be directly edited, or entirely replaced via assignment
(e.g., `job_context.log_context_fields = {...}`)
r   r   s   &r+   log_context_fieldsJobContext.log_context_fields  s     r-   c                    V ^8  d   QhRRRR/# )r$   fieldsr]  r'   ru   r)   )r*   s   "r+   r,   r     s     	" 	" 	"D 	"r-   c                    Wn         R# )a)  
Sets the log fields to be injected into future log records.

Args:
    fields (dict[str, Any]): A dictionary of key-value pairs representing
        structured data to attach to each log entry. Typically includes contextual
        information like job ID, trace information, or worker metadata.
Nr_  )rz   rc  s   &&r+   r`  ra    s
     "r-   c                    V ^8  d   QhRRRR/# )r$   callbackzXCallable[[], Coroutine[None, None, None]] | Callable[[str], Coroutine[None, None, None]]r'   ru   r)   )r*   s   "r+   r,   r     s      5 575 
	5r-   c                   a \         P                  ! S4      '       d   ^M^pSP                  P                  V8  d   V P                  P                  S4       R# R V3R llpV P                  P                  V4       R# )z
Add a callback to be called when the job is shutting down.
Optionally the callback can take a single argument, the shutdown reason.
c                    V ^8  d   QhRRRR/# )r$   _r&   r'   ru   r)   )r*   s   "r+   r,   6JobContext.add_shutdown_callback.<locals>.__annotate__  s     ! ! ! !r-   c                2   <"   S! 4       G R j  xL
  R #  L5ir>   r)   )ri  rf  s   &r+   wrapper1JobContext.add_shutdown_callback.<locals>.wrapper  s     j  s   N)inspectismethod__code__co_argcountr   r   )rz   rf  min_args_numrl  s   &f  r+   add_shutdown_callback JobContext.add_shutdown_callback  sd     $,,X66qA((L8$$++H5! ! $$++G4r-   rb   kindc               $    V ^8  d   QhRRRRRR/# )r$   rb   r(   ru  Clist[rtc.ParticipantKind.ValueType] | rtc.ParticipantKind.ValueTyper'   rtc.RemoteParticipantr)   )r*   s   "r+   r,   r     s/     T T T(	T 
Tr-   c                  "   V P                   P                  4       '       g   V P                  4       G Rj  xL
  \        V P                   WR7      G Rj  xL
 #  L# L5i)z
Returns a participant that matches the given identity. If identity is None, the first
participant that joins the room will be returned.
If the participant has already joined, the function will return immediately.
N)rb   ru  )r   isconnectedconnectr   )rz   rb   ru  s   &$$r+   r   JobContext.wait_for_participant  sE      zz%%'',,.  )$**xSSS !Ss!   4AAAAAAe2eezUse `encryption` instead.
encryptionauto_subscribe
rtc_configc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r$   r~  zrtc.E2EEOptions | Noner  rV   r  zrtc.RtcConfiguration | Noner}  r'   ru   r)   )r*   s   "r+   r,   r     s>     !# !# +!# &	!#
 0!# %!# 
!#r-   c                 "   V P                   ;_uu_4       GRj  xL
  V P                  '       d    RRR4      GRj  xL
  R# T;'       g    Tp\        P                  ! VV\        P
                  8H  VR7      pV P                  P                  V P                  P                  V P                  P                  VR7      G Rj  xL
  V P                  4        V P                  P                  P                  4        F  pV P                  V4       K  	  \        V P                  V4       RV n        RRR4      GRj  xL
  R#  EL) EL	 L L  + GRj  xL 
 '       g   i     R# ; i5i)a  Connect to the room. This method should be called only once.

Args:
    encryption: End-to-end encryption options. If provided, the Agent will utilize end-to-end encryption. Note: clients will also need to handle E2EE.
    auto_subscribe: Whether to automatically subscribe to tracks. Default is AutoSubscribe.SUBSCRIBE_ALL.
    rtc_config: Custom RTC configuration to use when connecting to the room.
N)r~  r  r  )r%  T)r   r   r   RoomOptionsrV   r[   r   r{  r   r4   rl   r   remote_participantsr   r   _apply_auto_subscribe_opts)rz   r~  r  r  r}  room_optionsps   &$$$$  r+   r{  JobContext.connect  s     " :::: :: $++tJ??%-1L1LL%L **$$TZZ^^TZZ5E5E|$\\\ZZ33::<++A. = 'tzz>B"DO# :: ] :::s   E+EE+EE+EE+EA6EE
A-E2E+=E>E+E+
EE+E(	E
E(	 E(	"	E+c                    V ^8  d   QhRRRR/# )r$   	room_namer(   r'   z&asyncio.Future[api.DeleteRoomResponse]r)   )r*   s   "r+   r,   r     s      Z ;a r-   c                  a aa S P                  4       '       dg   \        P                  ! R4       \        P                  \
        P                  ,          ! 4       pVP                  \
        P                  ! 4       4       V# R VV 3R llp\        P                  ! V! 4       4      oS P                  P                  S4       SP                  V V3R l4       S# )z2Deletes the room and disconnects all participants.z;job_ctx.delete_room() is not executed while in console modec                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   ,JobContext.delete_room.<locals>.__annotate__  s     	F 	FD 	Fr-   c                 L  <"    SP                   P                  P                  \         P                  ! S;'       g    SP                  P
                  R 7      4      G Rj  xL
  R#  L  \        P                   d    \        P                  ! R4        R# \         P                   dT   p T P                  \         P                  P                  8w  d    \        P                  ! RT  24        Rp ? R#  Rp ? R# Rp ? i\         d    \        P                  ! R4        R# i ; i5i))r   Nz'server disconnected while deleting roomzerror while deleting room: z!unknown error while deleting room)r   r   delete_roomDeleteRoomRequestr   ra   aiohttpServerDisconnectedErrorr   warning
TwirpErrorcodeTwirpErrorCode	NOT_FOUNDr   r   )er  rz   s    r+   _delete_room,JobContext.delete_room.<locals>._delete_room  s     
Fhhmm//))y/K/KDJJOOL   22 JHI>> F66S//999NN%@#DEE : F  !DEFsf   D$AA)  A'!A) %D$'A) )+D!D$D!*D!+AC9-D$9D!D!D$ D!!D$c                :   < SP                   P                  S4      # r>   r   removeri  rz   tasks   &r+   <lambda>(JobContext.delete_room.<locals>.<lambda>-      )<)<)C)CD)Ir-   )r  r   r  r   Futurer   DeleteRoomResponse
set_resultcreate_taskr   r   add_done_callback)rz   r  futr  r  s   ff  @r+   r  JobContext.delete_room  s    NNXY..!7!78:CNN31134J	F 	F ""<>2""4(IJr-   participant_namezSIP-participantc          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r$   call_tor&   trunk_idparticipant_identityr  zNotGivenOr[str]r'   &asyncio.Future[api.SIPParticipantInfo]r)   )r*   s   "r+   r,   r   0  s>     ) ) ) 	)
 ") *) 
0)r-   c               V  a a S P                  4       '       dg   \        P                  ! R4       \        P                  \
        P                  ,          ! 4       pVP                  \
        P                  ! 4       4       V# \        P                  ! S P
                  P                  P                  \
        P                  ! S P                  P                  TTT\        V4      '       d   TMRR7      4      4      oS P                  P!                  S4       SP#                  V V3R l4       S# )a  
Add a SIP participant to the room.

Args:
    call_to: The number or SIP destination to transfer the participant to.
                 This can either be a number (+12345555555) or a
                 sip host (sip:<user>@<host>)
    trunk_id: The ID of the SIP trunk to use
    participant_identity: The identity of the participant to add
    participant_name: The name of the participant to add

Make sure you have an outbound SIP trunk created in LiveKit.
See https://docs.livekit.io/sip/trunk-outbound/ for more information.
zCjob_ctx.add_sip_participant() is not executed while in console modeN)r  r  sip_trunk_idsip_call_tor  c                :   < SP                   P                  S4      # r>   r  r  s   &r+   r  0JobContext.add_sip_participant.<locals>.<lambda>X  r  r-   )r  r   r  r   r  r   SIPParticipantInfor  r  sipcreate_sip_participantCreateSIPParticipantRequestr   ra   r   r   r   r  )rz   r  r  r  r  r  r  s   f$$$$ @r+   add_sip_participantJobContext.add_sip_participant0  s    , NN`a..!7!78:CNN31134J""HHLL////"jjoo)=!) '9ABR9S9S%5Y]

 	""4(IJr-   c               (    V ^8  d   QhRRRRRRRR/# )	r$   participantzrtc.RemoteParticipant | strtransfer_tor&   play_dialtonerE   r'   r  r)   )r*   s   "r+   r,   r   [  s2     2 202 2 	2
 
02r-   c                  a a S P                  4       '       dg   \        P                  ! R4       \        P                  \
        P                  ,          ! 4       pVP                  \
        P                  ! 4       4       V# \        V\        P                  4      '       d>   VP                  \        P                  P                  8X  g   Q R4       hVP                  pMTp\        P                  ! S P
                  P                   P#                  \
        P$                  ! S P&                  P(                  VVVR7      4      4      oS P*                  P-                  S4       SP/                  V V3R l4       S# )a?  Transfer a SIP participant to another number.

Args:
    participant: The participant to transfer
    transfer_to: The number or SIP destination to transfer the participant to.
                 This can either be a number (+12345555555) or a
                 sip host (sip:<user>@<host>)
    play_dialtone: Whether to play a dialtone during transfer. Defaults to True.


Returns:
    Future that completes when the transfer is complete

Make sure you have enabled call transfer on your provider SIP trunk.
See https://docs.livekit.io/sip/transfer-cold/ for more information.
zHjob_ctx.transfer_sip_participant() is not executed while in console modez%Participant must be a SIP participant)r  r  r  r  c                :   < SP                   P                  S4      # r>   r  r  s   &r+   r  5JobContext.transfer_sip_participant.<locals>.<lambda>  r  r-   )r  r   r  r   r  r   r  r  r   r   RemoteParticipantru  ParticipantKindPARTICIPANT_KIND_SIPrb   r  r  transfer_sip_participantTransferSIPParticipantRequestr   ra   r   r   r  )rz   r  r  r  r  r  r  s   f&&&  @r+   r  #JobContext.transfer_sip_participant[  s   , NNZ ..!7!78:CNN31134Jk3#8#899##s':':'O'OO 7O $/#7#7 #. ""HHLL1111"jjoo)= +"/		
 	""4(IJr-   c                    V ^8  d   QhRRRR/# )r$   reasonr&   r'   ru   r)   )r*   s   "r+   r,   r     s     " "s "D "r-   c                	(    V P                  V4       R # r>   )r   )rz   r  s   &&r+   shutdownJobContext.shutdown  s    &!r-   c               (    V ^8  d   QhRRRRRRRR/# )	r$   entrypoint_fnczJCallable[[JobContext, rtc.RemoteParticipant], Coroutine[None, None, None]]ri  r   ru  rw  r'   ru   r)   )r*   s   "r+   r,   r     s8     E EbE E(	E 
Er-   c                   YP                    UUu. uF  w  rCVNK	  	  upp9   d   \        R4      hV P                   P                  W34       R# u uppi )a	  Adds an entrypoint function to be run when a participant joins the room. In cases where
the participant has already joined, the entrypoint will be run immediately. Multiple unique entrypoints can be
added and they will each be run in parallel for each participant.
z*entrypoints cannot be added more than onceN)r   
ValueErrorr   )rz   r  ru  ri  r  s   &&$* r+   add_participant_entrypoint%JobContext.add_participant_entrypoint  sL     .K.KL.KFQa.KLLIJJ%%,,n-CD Ms   Ac                    V ^8  d   QhRRRR/# )r$   r%  r8   r'   ru   r)   )r*   s   "r+   r,   r     s     = =&6 =4 =r-   c                	   V P                   '       d   V P                  4        R # RV n         VP                  RR4      ;'       gG    VP                  RR4      ;'       g-    VP                  RR4      ;'       g    VP                  RR4      p\        V P                  P
                  4      pV'       d	   V'       g   V P                  4        R # \        P                  ! R4       \        V P                  P                  P                  V P                  P                  VVR,          VR,          R7       V P                  VR,          R7       R # )	NTr
  r  r	  r  zconfiguring session recording)r$  r#  r   enable_tracesenable_logs)r   )r   r   r2   r5   r   r4   r   debugr   rk   r   r1  r0  r   )rz   r%  needs_cloudr  s   &&  r+   r  JobContext.init_recording  s   &&&$$&&*# KK$' / /{{64(/ /{{7D)/ / {{<.	 	 %TZZ^^4$$&45HHMM%%88;;%!(+	
 	$$GFO$<r-   c                    V ^8  d   QhRRRR/# )r$   r  rx  r'   ru   r)   )r*   s   "r+   r,   r     s      (= $ r-   c                	  a a S P                    F  w  r#\        V\        4      '       d   SP                  V9  d   K.  MSP                  V8w  d   KB  SP                  V3S P
                  9   d%   \        P                  ! R SP                   R24       RSP                   RVP                   2p\        P                  ! V! S S4      VR7      pVS P
                  SP                  V3&   VP                  V3VV 3R ll4       K  	  R# )zca participant has joined before a prior participant task matching the same identity has finished: ''zpart-entry--)ra   c                R   < SP                   P                  SP                  V34      # r>   )r   poprb   )ri  coror  rz   s   &&r+   r  3JobContext._participant_available.<locals>.<lambda>  s    T%<%<%@%@!**dAS%Tr-   N)r   r   r   ru  rb   r   r   r  rN   r   r  r  )rz   r  r  ru  	task_namer  s   ff    r+   r   !JobContext._participant_available  s    77JD$%%66% & 66T>

D!T%<%<<yz{  {E  {E  zF  FG  H &ajj\4==/BI&&tD!}9ED:>D##QZZ$67""#T 8r-   c                   V ^8  d   QhRR/# )r$   r'   r   r)   )r*   s   "r+   r,   r     s     T Tf Tr-   c                	v    \         P                  ! 4       P                  V P                  P                  R R7      # )F)verify_signature)r   TokenVerifierverifyr   rl   r   s   &r+   rY  JobContext.token_claims  s+      "))$***:*:U)SSr-   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )NNNr>   )F) )2rN   rO   rP   rQ   r   r   r  r   r   ry   r   r   r   r   r  r  r  propertyr   r   r   r   	functoolscached_propertyr   r   rk   rm   r   r   rU  rZ  r`  setterrs  rp   r   r   rV   r[   r{  r  r  r  r  r  r  r   rY  rT   r)   r-   r+   r!   r!      s#   '/	s,,-y9I/JJ($
1Af7@'*(YT+*# - - " "  $L C C     $ $   , , + + 5 5 
  
  	" 	"5&T  $T
 +DT& v:;<!# .2!# )6(C(C	!#
 37!# (,!# =!#F4) ->)V2h"E
 +DE"=>(T Tr-   c               $    V ^8  d   QhRRRRRR/# )r$   r   r   r  rV   r'   ru   r)   )r*   s   "r+   r,   r,     s"     " "X "} "QU "r-   c                8  aa S\         P                  \         P                  39  d   R # R V3R lloV P                  P	                  4        F,  pVP
                  P	                  4        F  pS! V4       K  	  K.  	  V P                  R4      R V3R ll4       pR # )Nc                    V ^8  d   QhRRRR/# )r$   pubrtc.RemoteTrackPublicationr'   ru   r)   )r*   s   "r+   r,   0_apply_auto_subscribe_opts.<locals>.__annotate__  s     % %"< % %r-   c                *  < S\         P                  8X  d*   V P                  \        P                  P
                  8X  g?   S\         P                  8X  d?   V P                  \        P                  P                  8X  d   V P                  R 4       R# R# R# )TN)	rV   r]   ru  r   	TrackKind
KIND_AUDIOr^   
KIND_VIDEOset_subscribed)r  r  s   &r+   _subscribe_if_needed8_apply_auto_subscribe_opts.<locals>._subscribe_if_needed  s`    m666388s}}G_G_;_ 8 88SXXIaIa=at$ >b8r-   track_publishedc               $    V ^8  d   QhRRRRRR/# )r$   r  r  ri  rx  r'   ru   r)   )r*   s   "r+   r,   r    s$     " " : "?T "Y] "r-   c                   < S! V 4       R # r>   r)   )r  ri  r  s   &&r+   on_track_published6_apply_auto_subscribe_opts.<locals>.on_track_published  s    S!r-   )rV   r]   r^   r  r   track_publicationsr   )r   r  r  r  r  r  s   &f   @r+   r  r    s    m668P8PQQ% % %%,,.''..0C % 1 / 
WW"  "r-   c                      ] tR tRtR R lt]R R l4       t]R R l4       t]R R	 l4       t]R
 R l4       t	]R R l4       t
RtR# )r   i  c               (    V ^8  d   QhRRRRRRRR/# )	r$   r   rK   user_arguments
Any | None
http_proxyr(   r'   ru   r)   )r*   s   "r+   r,   JobProcess.__annotate__  s4     2 2 '2 #	2
 2 
2r-   c               	l    Wn         \        P                  ! 4       V n        / V n        W n        W0n        R # r>   )_executor_typempcurrent_process_mp_proc	_userdata_user_arguments_http_proxy)rz   r   r  r  s   &$$$r+   ry   JobProcess.__init__  s-     ,**,)+-'1r-   c                   V ^8  d   QhRR/# )r$   r'   rK   r)   )r*   s   "r+   r,   r    s     # # #r-   c                	    V P                   # r>   )r	  r   s   &r+   r   JobProcess.executor_type  s    """r-   c                   V ^8  d   QhRR/# )r$   r'   z
int | Noner)   )r*   s   "r+   r,   r     s     ! !Z !r-   c                	.    V P                   P                  # r>   )r  pidr   s   &r+   r  JobProcess.pid  s    }}   r-   c                   V ^8  d   QhRR/# )r$   r'   zdict[Any, Any]r)   )r*   s   "r+   r,   r    s      . r-   c                	    V P                   # r>   )r  r   s   &r+   userdataJobProcess.userdata  s    ~~r-   c                   V ^8  d   QhRR/# )r$   r'   r  r)   )r*   s   "r+   r,   r    s     $ $
 $r-   c                	    V P                   # r>   )r  r   s   &r+   r  JobProcess.user_arguments  s    ###r-   c                   V ^8  d   QhRR/# )r$   r'   r(   r)   )r*   s   "r+   r,   r    s        J  r-   c                	    V P                   # r>   )r  r   s   &r+   r  JobProcess.http_proxy  s    r-   )r	  r  r  r  r  N)rN   rO   rP   rQ   ry   r  r   r  r  r  r  rT   r)   r-   r+   r   r     sk    2 # # ! !   $ $    r-   r   c                      ] tR tRtR R lt]R R l4       t]R R l4       t]R R	 l4       t]R
 R l4       t	]R R l4       t
RR/R R lltRRRRRRRR/R R lltRtR# )
JobRequesti  c               (    V ^8  d   QhRRRRRRRR/# )	r$   rk   rj   	on_rejectz-Callable[[bool], Coroutine[None, None, None]]	on_acceptz;Callable[[JobAcceptArguments], Coroutine[None, None, None]]r'   ru   r)   )r*   s   "r+   r,   JobRequest.__annotate__  s6     
$ 
$ 
$ A	
$
 O
$ 

$r-   c               	^    Wn         \        P                  ! 4       V n        W n        W0n        R # r>   )_jobr   r   r   
_on_reject
_on_accept)rz   rk   r%  r&  s   &$$$r+   ry   JobRequest.__init__  s      	\\^
##r-   c                   V ^8  d   QhRR/# rI  r)   )r*   s   "r+   r,   r'    s      C r-   c                	.    V P                   P                  # r>   )r)  r0  r   s   &r+   r0  JobRequest.id  s    yy||r-   c                   V ^8  d   QhRR/# rE  r)   )r*   s   "r+   r,   r'  "  s      Y r-   c                	    V P                   # r>   )r)  r   s   &r+   rk   JobRequest.job!  s    yyr-   c                   V ^8  d   QhRR/# )r$   r'   zmodels.Roomr)   )r*   s   "r+   r,   r'  &  s      k r-   c                	.    V P                   P                  # r>   )r)  r   r   s   &r+   r   JobRequest.room%  s    yy~~r-   c                   V ^8  d   QhRR/# )r$   r'   zmodels.ParticipantInfo | Noner)   )r*   s   "r+   r,   r'  *  s     % %8 %r-   c                	.    V P                   P                  # r>   )r)  r  r   s   &r+   	publisherJobRequest.publisher)  s    yy$$$r-   c                   V ^8  d   QhRR/# rI  r)   )r*   s   "r+   r,   r'  .  s     $ $C $r-   c                	.    V P                   P                  # r>   )r)  r   r   s   &r+   r   JobRequest.agent_name-  s    yy###r-   	terminateTc                    V ^8  d   QhRRRR/# )r$   r=  rE   r'   ru   r)   )r*   s   "r+   r,   r'  1  s     ) ) ) )r-   c               D   "   V P                  V4      G Rj  xL
  R#  L5i)zFReject the job request. The job will not be assigned to another workerN)r*  )rz   r=  s   &$r+   rejectJobRequest.reject1  s     ooi(((s     ra   r  rb   rc   re   Nc          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r$   ra   r&   rb   rc   re   rd   r'   ru   r)   )r*   s   "r+   r,   r'  5  s>     0 0 0 	0
 0 *0 
0r-   c                  "   V'       g   RV P                   ,           p\        VVVVR7      pV P                  V4      G Rj  xL
  R#  L5i)z[Accept the job request, and start the job if the LiveKit SFU assigns the job to our worker.zagent-)ra   rb   rc   re   N)r0  r`   r+  )rz   ra   rb   rc   re   ri   s   &$$$$ r+   acceptJobRequest.accept5  sD      $'')H-!	
 oo.///s   ?A
AA
)r)  r   r+  r*  )rN   rO   rP   rQ   ry   r  r0  rk   r   r8  r   r@  rD  rT   r)   r-   r+   r#  r#    s    
$       % % $ $) )0 0 	0
 0 -10 0r-   r#  c                  ,    ] tR tRt$ R]R&   R]R&   RtR# )_JobShutdownInfoiK  rE   user_initiatedr&   r  r)   Nro   r)   r-   r+   rG  rG  K  s    Kr-   rG  )Z__conditional_annotations__
__future__r   r   contextvarsr  rn  r   r   multiprocessingr
  r0   r   collections.abcr   r   dataclassesr   enumr   r   pathlibr	   typingr
   r   r   r   urllib.parser   r  livekitr   r   livekit.api.access_tokenr   livekit.protocolr   r   logr   observabilityr   	telemetryr   r   telemetry.tracesr   r   r   typesr   utilsr   r   r   utils.deprecationr   
utils.miscr    
ContextVarrG   r5   ipc.inference_executorr6   r  r7   r8   r,  r:   r@   get_current_job_contextrK   r&   rV   r`   rh   r  PARTICIPANT_KIND_CONNECTORr  PARTICIPANT_KIND_STANDARDrp   rf   Filterrr   r!   r  r   r#  rG  )rI  s   @r+   <module>rd     s   # "        	  / !   8 8 !   + *  ! ; Y Y  ? ? /  ''56JK 9C+ 
 I I 
 I 
 J 
 J  *  d  
C  - - -    22,,11B > gnn 4~T ~TB"&     F80 80v   r-   