+
    ~j                     a  0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHtH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHtHt ^ R	IHtHt ^ R
IH t  ^ RI!H"t" ^RI#H$t$H%t%H&t&H't'H(t(H)t)H*t* ^RI+H,t, ^RI-H.t. ^RI&H/t/H0t0H1t1 ^RI2H3t3 ^RI4H5t5 ^RI6H7t7H8t8 ^RI9H:t:H;t; ^RIH<t<H=t=H>t>H?t? ^RI@HAtA ^RIBHCtC ^RI#HDtDHEtE ^RIFHGtG ^RIHHItIHJtJ ^RIKHLtLHMtM ^RINHOtO ^RIPHQtQHRtRHStSHTtTHUtUHVtVHWtWHXtXHYtYHZtZ ^RI[H\t\ ^RI]H^t^ ^RI_H`t`Hata ^R IbHctc ^R!IdHeteHftf ^R"IgHhthHitiHjtjHktkHltlHmtmHntnHotoHptpHqtq ]'       d   ^R#I%HrtrHstsHttt ^R$I&Hutu ^R%IvHwtw  ! R& R'] R(R)7      txR*R+R,R+R-R+R.R+/tyR']zR/&   R*R(R,R(R-R(R.R(/t{R']zR0&   R1 R2 lt|] ! R3 R44      4       t}] ! R5 R64      4       t~]! R74      t]! R84      t] ! R9 R:]4      4       t ! R; R<4      tR=R>.tR?]zR@&    ! RA RB]"EP                  ]W,          ]],          4      tR# )C    )annotationsN)AsyncIterableCallableSequence)AbstractContextManagernullcontext)Token)	dataclass)TracebackType)TYPE_CHECKINGGenericLiteralProtocolTypeVaroverloadruntime_checkable)contexttrace)	TypedDict)rtc)cli	inferencellmsttttsutilsvad)APIError)get_job_context)AgentHandoffChatContextMetricsReport)Instructionslogger)AgentSessionUsageModelUsageCollector)trace_typestracer)DEFAULT_API_CONNECT_OPTIONS	NOT_GIVENAPIConnectOptions
NotGivenOr)deprecate_params)is_given)ioroom_io)_set_participant_attributes)Agent	AgentTask)AgentActivity_ReusableResources)AMD)

AgentEvent
AgentStateAgentStateChangedEvent
CloseEventCloseReasonConversationItemAddedEvent
EventTypesUserInputTranscribedEvent	UserStateUserStateChangedEvent)IVRActivity)
RecorderIO)RoomSessionTransportSessionHost)	RunResult)InputDetailsSpeechHandle)
EndpointingOptionsInterruptionOptionsPreemptiveGenerationOptionsTurnDetectionModeTurnHandlingOptions_migrate_turn_handling_resolve_endpointing_resolve_interruption_resolve_preemptive_generation_resolve_user_turn_limit)	LLMModels	STTModels	TTSModels)mcp)TextTransformsc                  J    ] tR t^St$ RtR]R&    R]R&    R]R&    R]R&   RtR# )	RecordingOptionsu  Granular control over which recording features are active.

All keys default to ``True`` when not specified, so ``{"logs": False}``
means "record everything except logs."

Can be passed directly to :pymethod:`AgentSession.start(record=...)`:

* ``record=True``  → all on (backward compatible)
* ``record=False`` → all off (backward compatible)
* ``record={"audio": True, "traces": False}`` → granular
boolaudiotraceslogs
transcript N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r_       w/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/agents/voice/agent_session.pyrY   rY   S   s*    
 K5LA
J:Rrg   rY   F)totalr[   Tr\   r]   r^   _RECORDING_ALL_ON_RECORDING_ALL_OFFc                    V ^8  d   QhRRRR/# )   recordbool | RecordingOptionsreturnrY   r_   )formats   "rh   __annotate__rr   x   s     ? ?'> ?CS ?rg   c                    \        V \        4      '       d    V '       d   \        M\        p\	        R/ VB # \	        R/ / \        CV CB # )Nr_   )
isinstancerZ   rj   rk   rY   )rn   defaultss   & rh   _resolve_recording_optionsrv   x   sB    &$(.$4F+(++>=!2=f=>>rg   c                  P    ] tR t^t$ ]tR]R&   ]tR]R&   ]tR]R&   ^t	R]R&   Rt
R# )	SessionConnectOptionsr,   stt_conn_optionsllm_conn_optionstts_conn_optionsintmax_unrecoverable_errorsr_   N)r`   ra   rb   rc   r*   ry   re   rz   r{   r}   rf   r_   rg   rh   rx   rx      s4    *E'E*E'E*E'E$%c%Mrg   rx   c                      ] tR t^t$ R]R&   R]R&   R]R&   R]R&   R	]R
&   R]R&   R]R&   R]R&   R]R&   ]R R l4       t]R R l4       t]R R l4       tRt	R# )AgentSessionOptionsrM   turn_handlingr|   max_tool_stepsfloat | Noneuser_away_timeoutfloatmin_consecutive_speech_delayzbool | Noneuse_tts_aligned_transcriptzSequence[TextTransforms] | Nonetts_text_transformsrZ   ivr_detectionaec_warmup_duration session_close_transcript_timeoutc                   V ^8  d   QhRR/# )rm   rp   rI   r_   )rq   s   "rh   rr    AgentSessionOptions.__annotate__   s     1 1/ 1rg   c                	(    V P                   R ,          # )endpointingr   selfs   &rh   r   AgentSessionOptions.endpointing   s    !!-00rg   c                   V ^8  d   QhRR/# )rm   rp   rJ   r_   )rq   s   "rh   rr   r      s     2 21 2rg   c                	(    V P                   R ,          # )interruptionr   r   s   &rh   r    AgentSessionOptions.interruption   s    !!.11rg   c                   V ^8  d   QhRR/# )rm   rp   rK   r_   )rq   s   "rh   rr   r      s     ; ;'B ;rg   c                	(    V P                   R ,          # )preemptive_generationr   r   s   &rh   r   )AgentSessionOptions.preemptive_generation   s    !!"9::rg   r_   N)
r`   ra   rb   rc   re   propertyr   r   r   rf   r_   rg   rh   r   r      sr    &&##"'' ++88%%&++1 1 2 2 ; ;rg   r   
Userdata_TRun_Tc                  "    ] tR t^tR R ltRtR# )_VideoSamplerc               $    V ^8  d   QhRRRRRR/# rm   framezrtc.VideoFramesessionAgentSessionrp   rZ   r_   )rq   s   "rh   rr   _VideoSampler.__annotate__   s    QQnQ|QQrg   c                	    R # Nr_   )r   r   r   s   &&&rh   __call___VideoSampler.__call__   s    crg   r_   N)r`   ra   rb   rc   r   rf   r_   rg   rh   r   r      s    QQrg   r   c                  :    ] tR t^tRRRR/R R lltR R ltR	tR
# )VoiceActivityVideoSamplerspeaking_fps      ?
silent_fps333333?c                    V ^8  d   QhRRRR/# )rm   r   r   r   r_   )rq   s   "rh   rr   &VoiceActivityVideoSampler.__annotate__   s     5 5 5 5rg   c               	,    Wn         W n        R V n        R # r   )r   r   _last_sampled_time)r   r   r   s   &$$rh   __init__"VoiceActivityVideoSampler.__init__   s    ($04rg   c               $    V ^8  d   QhRRRRRR/# r   r_   )rq   s   "rh   rr   r      s!      n |  rg   c                	   \         P                   ! 4       pVP                  R 8H  pV'       d   V P                  MV P                  pV^ 8X  d   R# RV,          pV P                  f	   W0n        R# W0P                  ,
          V8  d	   W0n        R# R# )speakingFr   T)time
user_stater   r   r   )r   r   r   nowis_speaking
target_fpsmin_frame_intervals   &&&    rh   r   "VoiceActivityVideoSampler.__call__   sx    iik((J6*5T&&4??
? :-""*&)#))).@@&)#rg   )r   r   r   N)r`   ra   rb   rc   r   r   rf   r_   rg   rh   r   r      s    5 5 5
 rg   r   filter_markdownfilter_emojizlist[TextTransforms]DEFAULT_TTS_TEXT_TRANSFORMSc            =        a  ] tR t^t]! RRRRRRRRRRRRRRR	RR
RRRRR/RR7      R]R]R]R]R]R]R^R]R]RRR]R]RRRRR R!R"R#R$]R%R&R	]R]R]R]R]R]R]R
]R]R]R]R']/R( V 3R) lll4       t]R* R+ l4       tRR, V 3R- lllt	R. V 3R/ llt
]R0 R1 l4       t]P                  R2 R3 l4       t]R4 R5 l4       t]R6 R7 l4       t]R8 R9 l4       t]R: R; l4       t]R< R= l4       t]R> R? l4       t]R@ RA l4       t]RB RC l4       t]RD RE l4       t]RF RG l4       t]RH RI l4       t]RJ RK l4       t]RL RM l4       tRNRORPR&/RQ RR llt]RS]RT]RURVRW]RX]/RY RZ ll4       t]R[RRS]RT]RURVRW]RX]/R\ R] ll4       tR[RRS]RT]RU]RW]RX]/R^ R_ lltR` Ra lt]Rb Rc l4       tRdRReR&/Rf Rg lltRdRV/Rh Ri llt ]!PD                  ! ]#Rj7      RdRReR&/Rk Rl ll4       t$Rm Rn lt%Ro]R]R]R]/Rp Rq llt&RRr Rs llt'Rt]R]RuRV/Rv Rw llt(Rx]Ry]Rz]R]R]R{]RNRO/R| R} llt)R~R/R R llt*R R lt+RR#RR#RR/R R llt,R R lt-R R lt.RRRRRR&RRV/R R llt/]!PD                  ! ]#Rj7      R R l4       t0R R lt1]!PD                  ! ]#Rj7      R R l4       t2]!PD                  ! ]#Rj7      R R l4       t3R R lt4R R lt5R R lt6RR&RR&/R R llt7RR&/R R llt8R R lt9R 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?]R R l4       t@]R R l4       tAR R ltBR R ltCR R ltDR R ltER R ltFR R ltGR R ltHRtIV ;tJ# )r   min_endpointing_delayz2Use turn_handling=TurnHandlingOptions(...) insteadmax_endpointing_delayfalse_interruption_timeoutresume_false_interruptionallow_interruptions discard_audio_if_uninterruptiblemin_interruption_durationr   min_interruption_wordsturn_detection agent_false_interruption_timeoutzv2.0)target_versionr   r   r   r   r   toolsr   r   r   r           userdatavideo_samplerr         @r   Fr   g      .@r   g       @conn_optionsloopNmcp_serversc          >         V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRRRRRRRRRRRR R!R"R#RR$R%R&R%R'R(R)R*R+RR,R%R-R.R/RR0RR1R(R2R3R4R5/# )6rm   r   z%NotGivenOr[stt.STT | STTModels | str]r   zNotGivenOr[vad.VAD]r   z9NotGivenOr[llm.LLM | llm.RealtimeModel | LLMModels | str]r   z%NotGivenOr[tts.TTS | TTSModels | str]r   zNotGivenOr[TurnHandlingOptions]r   z(NotGivenOr[list[llm.Tool | llm.Toolset]]r   r|   r   NotGivenOr[bool]r   z+NotGivenOr[Sequence[TextTransforms] | None]r   r   r   zNotGivenOr[Userdata_T]r   z NotGivenOr[_VideoSampler | None]r   r   r   rZ   r   r   r   z!NotGivenOr[SessionConnectOptions]r   z asyncio.AbstractEventLoop | Noner   r   NotGivenOr[float]r   r   zNotGivenOr[float | None]r   zNotGivenOr[TurnDetectionMode]r   r   r   zNotGivenOr[int]r   r   r   r   zNotGivenOr[list[mcp.MCPServer]]rp   Noner_   )rq   s   "rh   rr   AgentSession.__annotate__   st    % % 3% !	%
 G% 3% 7% 8% % %5% I% ',%  )!%" 8#%$ *%%& '%( ()%* +0+%. 8/%0 /1%4  05%6  17%8  19%: %=;%< 6=%> +;?%@ $5A%B !0C%D .E%F $4G%H +CI%J 5K%L 
M%rg   c               	  < \         S$V `  4        T;'       g    \        P                  ! 4       V n        \        V4      '       d   TM\        RRR7      V n        \        V4      '       g=   \        \        V4      '       d   TMR\        V4      '       d   TMRVVVVVVVVVR7      MTp\        VP                  R4      4      p\        VP                  R4      4      p \        VP                  R	4      4      p!\        VP                  R
4      4      p"VP                  RR4      p#\        P                  ! 4       V n        \#        \%        VV V#V!V"R7      TTT
\        V	4      '       d   T	M\&        T\        V4      '       d   TMRVVR7	      V n        T;'       g    \+        4       V n        RV n        \1        V\2        4      '       d    \4        P6                  P9                  V4      p\1        V\2        4      '       d    \4        P:                  P9                  V4      p\1        V\2        4      '       d    \4        P<                  P9                  V4      pT;'       g    RV n        T;'       g    RV n         T;'       g    RV n!        T;'       g    RV n"        V#V n#        V P                  R\H        4      V n%        T;'       g    RV n&        V PL                  '       d   \N        PP                  ! R4       \        V4      '       d   TM. V n)        ^ V n*        ^ V n+        T;'       g    RV n,        RV n-        \\        P^                  ! V P`                  V Pb                  V Pd                  R7      V n3        \\        Ph                  ! V Pj                  V Pl                  V Pn                  4      V n8        RV n9        RV n:        RV n;        \        Px                  ! 4       V n=        \        Px                  ! 4       V n>        RV n?        RV n@        RV nA        RV nB        RV nC        RV nD        RV nE        RV nF        RV nG        \        V4      '       d   TMRV nH        RV nI        RV nJ        RV nK        RV nL        RV nM        RV nN        RV nO        RV nP        RV nQ        RV nR        . V nS        \        P                  4       V nV        RV nW        \        4       V nY        RV nZ        RV n[        R# )aX  `AgentSession` is the LiveKit Agents runtime that glues together
media streams, speech/LLM components, and tool orchestration into a
single real-time voice agent.

It links audio, video, and text I/O with STT, VAD, TTS, and the LLM;
handles turn detection, endpointing, interruptions, and multi-step
tool calls; and exposes everything through event callbacks so you can
focus on writing function tools and simple hand-offs rather than
low-level streaming logic.

Args:
    stt (stt.STT | str, optional): Speech-to-text backend.
    vad (vad.VAD, optional): Voice-activity detector
    llm (llm.LLM | llm.RealtimeModel | str, optional): LLM or RealtimeModel
    tts (tts.TTS | str, optional): Text-to-speech engine.
    tools (list[llm.FunctionTool | llm.RawFunctionTool], optional): List of
        tools shared by every agent in the agent session.
    mcp_servers (list[mcp.MCPServer], optional): List of MCP servers
        providing external tools for the agent to use.
    userdata (Userdata_T, optional): Arbitrary per-session user data.
    turn_handling (TurnHandlingOptions, optional): Configuration for turn handling.
    max_endpointing_delay (float): Maximum time-in-seconds the agent
        will wait before terminating the turn. Default ``3.0`` s.
    max_tool_steps (int): Maximum consecutive tool calls per LLM turn.
        Default ``3``.
    video_sampler (_VideoSampler, optional): Uses
        :class:`VoiceActivityVideoSampler` when *NOT_GIVEN*; that sampler
        captures video at ~1 fps while the user is speaking and ~0.3 fps
        when silent by default.
    min_consecutive_speech_delay (float, optional): The minimum delay between
        consecutive speech. Default ``0.0`` s.
    use_tts_aligned_transcript (bool, optional): Whether to use TTS-aligned
        transcript as the input of the ``transcription_node``. Only applies
        if ``TTS.capabilities.aligned_transcript`` is ``True`` or ``streaming``
        is ``False``. When NOT_GIVEN, it's disabled.
    tts_text_transforms (Sequence[TextTransforms], optional): The transforms to apply
        to the tts input text, available built-in transforms: ``"filter_markdown"``, ``"filter_emoji"``.
        Set to ``None`` to disable. When NOT_GIVEN, all filters will be applied.
    ivr_detection (bool): Whether to detect if the agent is interacting with an IVR system.
        Default ``False``.
    conn_options (SessionConnectOptions, optional): Connection options for
        stt, llm, and tts.
    loop (asyncio.AbstractEventLoop, optional): Event loop to bind the
        session to. Falls back to :pyfunc:`asyncio.get_event_loop()`.
    user_away_timeout (float, optional): If set, set the user state as
        "away" after this amount of time after user and agent are silent.
        Defaults to ``15.0`` s, set to ``None`` to disable.
    aec_warmup_duration (float, optional): The duration in seconds that the agent
        will ignore user's audio interruptions after the agent starts speaking.
        This is useful to prevent the agent from being interrupted by echo before AEC is ready.
        Set to ``None`` to disable. Default ``3.0`` s.
    session_close_transcript_timeout (float, optional): Seconds to wait for the
        final STT transcript when closing the session (after audio is detached).
        Default ``2.0`` s (independent of ``commit_user_turn``'s ``transcript_timeout``).
    preemptive_generation (NotGivenOr[bool | PreemptiveGenerationOptions]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    min_endpointing_delay (NotGivenOr[float]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    max_endpointing_delay (NotGivenOr[float]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    false_interruption_timeout (NotGivenOr[float | None]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    turn_detection (NotGivenOr[TurnDetectionMode]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    discard_audio_if_uninterruptible (NotGivenOr[bool]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    min_interruption_duration (NotGivenOr[float]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    min_interruption_words (NotGivenOr[int]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    allow_interruptions (NotGivenOr[bool]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    resume_false_interruption (NotGivenOr[bool]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
    agent_false_interruption_timeout (NotGivenOr[float | None]): Deprecated, use turn_handling=TurnHandlingOptions(...) instead.
r   r   )r   r   g      ?r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   user_turn_limitr   N)r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   Fmodez}passing MCP servers to AgentSession or Agent is deprecated and will be removed in a future version. Use `MCPToolset` instead.r   )audio_enabled_cb	listeninginitializing)\superr   asyncioget_event_loop_loopr/   r   _video_samplerrN   rO   getrP   rQ   rR   r!   empty	_chat_ctxr   rM   r   _optsrx   _conn_options_startedrt   strr   STTfrom_model_stringLLMTTS_stt_vad_llm_tts_turn_detectionr+   _interruption_detection_mcp_serversr%   warning_tools_llm_error_counts_tts_error_counts_aec_warmup_remaining_aec_warmup_timerr0   
AgentInput_on_video_input_changed_on_audio_input_changed_on_audio_enabled_changed_inputAgentOutput_on_video_output_changed_on_audio_output_changed_on_text_output_changed_output_forward_audio_atask_forward_video_atask_update_activity_ataskLock_activity_lock_lock_room_io_recorder_io_session_host_agent	_activity_next_activity_user_state_agent_state_user_away_timer	_userdata_closing_task_closing_job_context_cb_registered_global_run_state_early_assistant_metrics_user_speaking_span_agent_speaking_span_session_span_root_span_context_session_ctx_token_recorded_eventsrk   copy_recording_options_started_atr'   _usage_collector_ivr_activity_amd)%r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   preemptive_genr   raw_turn_detection	__class__s%   &$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$     rh   r   AgentSession.__init__   sI   r 	55W335
 && *L 	2 M**% # .66K-L-L)RU .66K-L-L)RU+E-1Q*C'=$7*C1Q&;!& ) 	. +=+<+<]+KL,]->->~-NO78I8IJa8bc2=3D3DEV3WX*../?F %**,(-')1&4 / */)E /00 $0'233 (B 3-M+

. *DD-B-Dc3--11#6Cc3--11#6Cc3--11#6CKK4	KK4	KK4	KK4	1'3'7'7	'J$'//4NNU  (eB "#!" &9%?%?C"=A mm((((!;;

 ~~))))((
 @D!?C!AE#%lln\\^
 04/315$(/348&1(6<@8@8J8JHPT8<#05'37>B% 7; 7;!04?CFJ244F4K4K4M)- 3 5 26 $	rg   c                   V ^8  d   QhRR/# )rm   rp   z
AMD | Noner_   )rq   s   "rh   rr   r     s      Z rg   c                    V P                   # )zOThe Answering Machine Detection (AMD) instance, or ``None`` if AMD is disabled.)r)  r   s   &rh   amdAgentSession.amd  s     yyrg   c               $    V ^8  d   QhRRRRRR/# )rm   eventr>   callbackzCallable | Nonerp   r   r_   )rq   s   "rh   rr   r     s!     + +
 +o + +rg   c                	d   < VR 8X  d   Ve   \         P                  ! R4       \        SV `  W4      # )metrics_collectedz{metrics_collected is deprecated. Use session_usage_updated for usage tracking and ChatMessage.metrics for per-turn latency.)r%   r   r   on)r   r3  r4  r,  s   &&&rh   r7  AgentSession.on  s4    ''H,@NN@
 wz%**rg   c               $    V ^8  d   QhRRRRRR/# )rm   r3  r>   argr8   rp   r   r_   )rq   s   "rh   rr   r     s!     ! !* !: !$ !rg   c                	\   < V P                   P                  V4       \        SV `  W4       R # r   )r#  appendr   emit)r   r3  r:  r,  s   &&&rh   r=  AgentSession.emit  s#    $$S)U rg   c                   V ^8  d   QhRR/# )rm   rp   r   r_   )rq   s   "rh   rr   r     s      * rg   c                	L    V P                   f   \        R4      hV P                   # )Nz AgentSession userdata is not set)r  
ValueErrorr   s   &rh   r   AgentSession.userdata  s"    >>!?@@~~rg   c                    V ^8  d   QhRRRR/# )rm   valuer   rp   r   r_   )rq   s   "rh   rr   r     s      j T rg   c                	    Wn         R # r   )r  )r   rD  s   &&rh   r   rB    s    rg   c                   V ^8  d   QhRR/# )rm   rp   zTurnDetectionMode | Noner_   )rq   s   "rh   rr   r     s     $ $ 8 $rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.turn_detection  s    ###rg   c                   V ^8  d   QhRR/# )rm   rp   zlist[mcp.MCPServer] | Noner_   )rq   s   "rh   rr   r     s     ! !7 !rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.mcp_servers         rg   c                   V ^8  d   QhRR/# )rm   rp   zio.AgentInputr_   )rq   s   "rh   rr   r     s      } rg   c                	    V P                   # r   )r  r   s   &rh   inputAgentSession.input       {{rg   c                   V ^8  d   QhRR/# )rm   rp   zio.AgentOutputr_   )rq   s   "rh   rr   r     s       rg   c                	    V P                   # r   )r  r   s   &rh   outputAgentSession.output  s    ||rg   c                   V ^8  d   QhRR/# )rm   rp   r   r_   )rq   s   "rh   rr   r   	  s      , rg   c                	    V P                   # r   )r   r   s   &rh   optionsAgentSession.options  s    zzrg   c                   V ^8  d   QhRR/# )rm   rp   rx   r_   )rq   s   "rh   rr   r     s     " "3 "rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.conn_options  s    !!!rg   c                   V ^8  d   QhRR/# )rm   rp   zllm.ChatContextr_   )rq   s   "rh   rr   r     s       rg   c                	    V P                   # r   )r   r   s   &rh   historyAgentSession.history  s    ~~rg   c                   V ^8  d   QhRR/# )rm   rp   zSpeechHandle | Noner_   )rq   s   "rh   rr   r     s     U U 3 Urg   c                	N    V P                   e   V P                   P                  # R # r   )r  current_speechr   s   &rh   rc  AgentSession.current_speech  s!    040Jt~~,,TPTTrg   c                   V ^8  d   QhRR/# )rm   rp   r@   r_   )rq   s   "rh   rr   r     s        I  rg   c                	    V P                   # r   )r  r   s   &rh   r   AgentSession.user_state  s    rg   c                   V ^8  d   QhRR/# )rm   rp   r9   r_   )rq   s   "rh   rr   r     s     ! !Z !rg   c                	    V P                   # r   )r  r   s   &rh   agent_stateAgentSession.agent_state  rL  rg   c                   V ^8  d   QhRR/# )rm   rp   r3   r_   )rq   s   "rh   rr   r   !  s      u rg   c                	L    V P                   f   \        R4      hV P                   # )NzVoiceAgent isn't running)r  RuntimeErrorr   s   &rh   current_agentAgentSession.current_agent   s"    ;;9::{{rg   c                   V ^8  d   QhRR/# )rm   rp   zlist[llm.Tool | llm.Toolset]r_   )rq   s   "rh   rr   r   (  s      3 rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.tools'  rQ  rg   c                   V ^8  d   QhRR/# )rm   rp   r&   r_   )rq   s   "rh   rr   r   ,  s     N N( Nrg   c                J    \        V P                  P                  4       R7      # )zMReturns usage summaries for this session, one per model/provider combination.)model_usage)r&   r'  flattenr   s   &rh   usageAgentSession.usage+  s     !T-B-B-J-J-LMMrg   input_modalitytextoutput_typec               (    V ^8  d   QhRRRRRRRR/# )	rm   
user_inputr   rz  Literal['text', 'audio']r|  ztype[Run_T] | Nonerp   zRunResult[Run_T]r_   )rq   s   "rh   rr   r   0  s4        1	
 ( 
rg   c               	    V P                   e,   V P                   P                  4       '       g   \        R4      h\        WR7      pW@n         V P	                  WR7       V# )Nnested runs are not supported)r~  r|  )r~  rz  )r  donern  rF   generate_reply)r   r~  rz  r|  	run_states   &$$$ rh   runAgentSession.run0  sW     !!-d6L6L6Q6Q6S6S>??M	!*zQrg   roomroom_optionsrn   Troom_input_optionsroom_output_optionsc               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )rm   agentr3   capture_runzLiteral[True]r  NotGivenOr[rtc.Room]r  NotGivenOr[room_io.RoomOptions]rn   ro   r  $NotGivenOr[room_io.RoomInputOptions]r  %NotGivenOr[room_io.RoomOutputOptions]rp   rF   r_   )rq   s   "rh   rr   r   @  s\       #	
 # 6 ( A C 
rg   c               	   "   R # 5ir   r_   r   r  r  r  r  rn   r  r  s   &&$$$$$$rh   startAgentSession.start?  s
         r  c               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )rm   r  r3   r  zLiteral[False]r  r  r  r  rn   ro   r  r  r  r  rp   r   r_   )rq   s   "rh   rr   r   N  s\       $	
 # 6 ( A C 
rg   c               	   "   R # 5ir   r_   r  s   &&$$$$$$rh   r  r  M  s
      r  c               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )rm   r  r3   r  rZ   r  r  r  r  rn   z#NotGivenOr[bool | RecordingOptions]r  r  r  r  rp   zRunResult | Noner_   )rq   s   "rh   rr   r   [  sf     G GG 	G
 #G 6G 4G AG CG 
Grg   c               .  a aa"   S P                   ;_uu_4       GRj  xL
  S P                  '       d    RRR4      GRj  xL
  R# \        P                  ! 4       S n        \	        V4      p\        RR7      p	\	        V4      '       g!   V	'       d   V	P                  P                  MRp\        V4      S n	        Rp
V	'       d   V	P                  e   V	P                  S J d	   S V	n
        MNRp
\        S P                  P                  4       4      '       d$   V'       d   \        R4      h\        R4      S n	        V	P                  S P                  4       \        P                   ! R4      ;S n        pS P$                  e(   \&        P(                  ! S P$                  4       RS n        \*        P,                  ! V4      p\&        P.                  ! V4      S n        . S n        \3        4       S n        RS n        RS n        RS n        RS n        \&        P>                  ! 4       S n         \*        PB                  ! 4       pVPE                  \F        PH                  VPJ                  4       VS n&        S PO                  R4       . p\P        PR                  PU                  4       pVPV                  '       dx   VPX                  '       gf   S PZ                  P\                  f   S P^                  P\                  e   \`        Pb                  ! R4       VPe                  S Pf                  S R	7       EM \	        V4      '       Ed   S P6                  '       Eg   \h        Pj                  Pm                  VVVR
7      p\n        Pn                  ! V4      pS PZ                  P\                  e0   VPp                  '       d   \`        Pb                  ! R4       RVn8        S P^                  P\                  e0   VPr                  '       d   \`        Pb                  ! R4       RVn9        S P^                  Pt                  e0   VPv                  '       d   \`        Pb                  ! R4       RVn;        \h        Px                  ! VS VR7      S n        S P6                  P{                  4       G Rj  xL
  V
'       d7   \}        V4      p\        V4      S n        S P:                  P                  S 4       VP                  4       pV'       dY   S P6                  P                  VP                  4       S P:                  e&   S P:                  P                  VP                  4       V	'       Ed   S PZ                  P\                  '       Edr   S P^                  P\                  '       EdU   S P                  R,          '       g'   VPV                  '       Ed)   VP                  '       Ed   \        S R7      S n        S P8                  P                  S PZ                  P\                  4      S PZ                  n.        S P8                  P                  S P^                  P\                  4      S P^                  n.        VPV                  '       d   VP                  '       g   VPV                  '       gS   \        P                  ! S P8                  P{                  V	P                  R,          R7      4      pVP                  V4       S P                  P                  '       d6   VP                  \        P                  ! S P                  4       RR7      4       VPE                  \F        P                  V	P                  P                  4       VPE                  \F        P                  V	P                  P                  4       VPE                  \F        P                  V	P                  P                  4       S P6                  '       d6   VP                  \        P                  ! V	P                  4       RR7      4       S P                  '       g   V	P                  V 3R l4       RS nW        RpV'       dM   S P                  e,   S P                  P                  4       '       g   \        R4      h\        RR7      pVS nY        VP                  \        P                  ! S P                  S PL                  RR7      4      4        \        P                  ! V!  G Rj  xL
  \        P                  P                  ! V!  G Rj  xL
  S P:                  e#   S P:                  P{                  4       G Rj  xL
  S PZ                  P\                  e,   \        P                  ! S P                  4       RR7      S nb        S PZ                  P                  e,   \        P                  ! S P                  4       RR7      S ne        RS n        S PO                  R4       S P6                  '       dK   S P6                  P                  '       d/   R V 3R llpS P6                  P                  P                  V4       R V3R  lloR! V3R" lloS! S PZ                  P\                  4      RRR-1,          pS! S PZ                  P                  4      RRR-1,          pS! S P^                  P\                  4      pS! S P^                  P                  4      pS! S P^                  Pt                  4      p\`        P                  ! R#R$P                  V Uu. uF  pR%VPJ                   R%2NK  	  up4      ;'       g    R&R$P                  V Uu. uF  pR%VPJ                   R%2NK  	  up4      ;'       g    R&4       S P                  P                  R',          '       d{   S P^                  P\                  '       d_   S P^                  P\                  P                  '       g9   \`        Pb                  ! R(R)S P^                  P\                  PJ                  /R*7       \`        P                  ! R+R$P                  V Uu. uF  pR%VPJ                   R%2NK  	  up4      ;'       g    R&4       V'       g	   V'       d   \`        P                  ! R,R$P                  V Uu. uF  pR%VPJ                   R%2NK  	  up4      ;'       g    R&R$P                  V Uu. uF  pR%VPJ                   R%2NK  	  up4      ;'       g    R&4       V'       d   VG Rj  xL
  TuuRRR4      GRj  xL
  #  EL EL EL EL= EL  \        P                  P                  ! T!  G Rj  xL 
  i ; i ELu upi u upi u upi u upi u upi  Lo L^  + GRj  xL 
 '       g   i     R# ; i5i).a  Start the voice agent.

Create a default RoomIO if the input or output audio is not already set.
If the console flag is provided, start a ChatCLI.

Args:
    capture_run: Whether to return a RunResult and capture the run result during session start.
    room: The room to use for input and output
    room_input_options: Options for the room input
    room_output_options: Options for the room output
    record: Whether to record the audio, transcripts, traces, or logs
NF)requiredTzOnly one `AgentSession` can be the primary at a time. If you want to ignore primary designation, use session.start(record=False).agent_sessionr   zeagent started with the console subcommand, but input.audio/output.audio is already set, overriding...)r   r   )r  r  zHRoomIO audio input is enabled but input.audio is already set, ignoring..zJRoomIO audio output is enabled but output.audio is already set, ignoring..zZRoomIO transcription output is enabled but output.transcription is already set, ignoring..)r  r  rX  r[   )r  z	audio.ogg)output_path_ivr_activity_startname_job_ctx_connectc                 D   < S P                  \        P                  R 7      # )reason)_aclose_implr<   JOB_SHUTDOWNr   s   rh   <lambda>$AgentSession.start.<locals>.<lambda>  s     1 19Q9Q 1 Rrg   r  )r|  )wait_on_enter_forward_audio_task_forward_video_taskr   c                    V ^8  d   QhRRRR/# )rm   _asyncio.Future[None]rp   r   r_   )rq   s   "rh   rr   (AgentSession.start.<locals>.__annotate__,  s     4 4-A 4d 4rg   c                t   < SP                   R 8X  d&   SP                  R 8X  d   SP                  4        R# R# R# )r   N)r  r  _set_user_away_timerr  r   s   &rh   on_room_io_subscribed1AgentSession.start.<locals>.on_room_io_subscribed,  s4    '';64;L;LP[;[113 <\6rg   c                    V ^8  d   QhRRRR/# )rm   inpz$io.AudioInput | io.VideoInput | Nonerp   z#list[io.AudioInput | io.VideoInput]r_   )rq   s   "rh   rr   r  3  s      R R9R4Rrg   c                D   < V f   . # V .S! V P                   4      ,           # r   )source)r  _collect_sources   &rh   r  +AgentSession.start.<locals>._collect_source3  s$     ![rQseocjj6Q.QQrg   c                    V ^8  d   QhRRRR/# )rm   outz6io.TextOutput | io.VideoOutput | io.AudioOutput | Nonerp   z5list[io.VideoOutput | io.AudioOutput | io.TextOutput]r_   )rq   s   "rh   rr   r  8  s      X XKXFXrg   c                D   < V f   . # V .S! V P                   4      ,           # r   )next_in_chain)r  _collect_chains   &rh   r  *AgentSession.start.<locals>._collect_chain8  s&     ![rWsenSEVEV6W.WWrg   z*using audio io: %s -> `AgentSession` -> %sz -> `z(none)r   z`resume_false_interruption is enabled but audio output does not support pause, it will be ignoredaudio_outputextraz)using transcript io: `AgentSession` -> %sz(using video io: %s > `AgentSession` > %s)mr  r   r   r&  r/   r   jobenable_recordingrv   r%  _primary_agent_sessionanyvaluesrn  init_recordingr)   
start_spanr   r"  otel_contextdetachr   set_span_in_contextattachr#  r'   r'  r  r  r  r  get_currentr!  get_current_spanset_attributer(   ATTR_AGENT_LABELlabelr  _update_agent_stater   AgentsConsoleget_instanceenabledio_acquiredrO  r[   rT  r%   r   
acquire_ior   r1   RoomOptions_ensure_optionsr$  audio_inputr  transcriptiontext_outputRoomIOr  rD   rE   register_sessionget_text_input_optionsregister_text_inputtext_input_cbrn   rC   record_inputrecord_outputr   create_tasksession_directoryr<  rX  r   _start_ivr_detectionATTR_ROOM_NAMEr  r  ATTR_JOB_IDidATTR_AGENT_NAME
agent_nameconnectr  add_shutdown_callbackr  r  rF   _update_activitygatherr   aiocancel_and_waitr  r	  videor  r
  subscribed_futadd_done_callbackdebugjoinr   r   	can_pause)r   r  r  r  r  rn   r  r  record_is_givenjob_ctx
is_primarycurrent_spanctxtasksc	transporttext_input_optstaskr  r  r  video_inputr  video_outputtranscript_outputr  r  r  s   f&$$$$$$                  @@rh   r  r  [  s	    0 ::::}}} ::  $yy{D 'v.O%u5GF##9@55e&@&HD#J119W=[=[_c=c59G2!&J42299;<<*".!C#  7QQV6WD3&&t'>'>?060A0A/0RRD &&2##D$;$;<*.'++L9C&2&9&9#&>D#$&D!$7$9D! DM $D!%D!DM&2&>&>&@D# 113L&&{'C'CU[[QDK$$^4.0E!!..0Ayyy::##/4;;3D3D3PNN8
 $**d;$&22BB '9(;  C  
  $yy6::##/#///f 05L,;;$$0#000h 16L-;;,,8#///x 05L, 'DVb cmm))+++ 4T :I)4Y)?D&&&77="."E"E"G"MM55o6S6ST))5**>>?\?\]w::###(9(9(9..w77AIII!(((,6T,J)+/+<+<+I+I$**JZJZ+[

(,0,=,=,K,KDKKL]L],^)III!(((1999#*#6#6 $ 1 1 7 7070I0IK0W !8 !"$D
 "LL.<<---LL++D,E,E,GNcd **;+E+Ew||GXGXY**;+B+BGKKNNS**;+F+FH^H^_===LL!4!4W__5FM_!`a 66611R 7;D3*.I))5d>T>T>Y>Y>[>[&'FGG%$7	)2& LL##D$9$9$++UZ$9$[\8nne,,,ii//777!!-((..000 zz+,3,?,?,,.5J-) zz+,3,?,?,,.5J-) !DM$$[1}}}!=!=!=4 4 ,,>>?TUR R
X X
 *$***:*:;DbDAK)$***:*:;DbDAK)$++*;*;<L)$++*;*;<L .t{{/H/H ILL<E#q1-EFRR(F#q1-FGSS8 

''(CDDKK%%%))333v)4;;+<+<+B+BC
 LL;9JK9J#q1-9JKLXXPX
 l>KK[ I[c1SYYKq!1[ IJVVhKK\ J\c1SYYKq!1\ JKWWx _ :::F ,~ -7eii//777 1X FF L !J J  [ :::s  vtvu8vt vA	u8B
u8Fu8=B	u8A!u8)Au80Au87Au8t#u8Au8*A u8u8(u8u8u81u8B0u85u8A-u85C"u8Au8%u8-u83Au8t,)t&*t,.!u8t)/u8?u B3u84u8D u8u)u87u8u !u8/)u8u85%u8Au83u%u8u8)u81 u8u**u88u8	u/"u80u8?u8u4u8
vu6v v#u8&t,)u8,"uuuu8u86v8v	>v?
v	
v		vc                   V ^8  d   QhRR/# rm   rp   r   r_   )rq   s   "rh   rr   r   d  s     % %T %rg   c                	   "   V P                   f   \        R4      hV P                   P                  4       G R j  xL
  R #  L5iNAgentSession isn't running)r  rn  drainr   s   &rh   r  AgentSession.draind  s1     >>!;<<nn""$$$s   7AA Ac                   V ^8  d   QhRR/# )rm   rp   zroom_io.RoomIOr_   )rq   s   "rh   rr   r   k  s       rg   c                	T    V P                   '       g   \        R 4      hV P                   # )zDCannot access room_io: the AgentSession was not started with a room.)r  rn  r   s   &rh   r1   AgentSession.room_ioj  s'    }}}V  }}rg   r  errorc               (    V ^8  d   QhRRRRRRRR/# )	rm   r  r<   r  rZ   r  zJllm.LLMError | stt.STTError | tts.TTSError | llm.RealtimeModelError | Nonerp   r   r_   )rq   s   "rh   rr   r   s  s5     
 
 
 	

 Z
 

rg   c               	    V P                   '       d   R # \        P                  ! V P                  W2VR7      4      V n         R # N)r  r  r  )r  r   r  r  )r   r  r  r  s   &$$$rh   _close_soonAgentSession._close_soons  s9     $00EvF
rg   c                    V ^8  d   QhRRRR/# )rm   r  rZ   rp   r   r_   )rq   s   "rh   rr   r     s     U U U Urg   c               	J    V P                  R V\        P                  R7       R # r  )r  r<   USER_INITIATED)r   r  s   &$rh   shutdownAgentSession.shutdown  s    t59S9STrg   r$   c               (    V ^8  d   QhRRRRRRRR/# )	rm   r  r<   r  rZ   r  zqllm.LLMError | stt.STTError | tts.TTSError | llm.RealtimeModelError | inference.InterruptionDetectionError | Nonerp   r   r_   )rq   s   "rh   rr   r     s@     xW xW xW 	xW
xW 
xWrg   c          
     	
  "   V P                   '       d!   \        P                  ! V P                   4       V P                  ;_uu_4       GR j  xL
  V P                  '       g    R R R 4      GR j  xL
  R # RV n        V P                  4        V P                  4        V P                  e*   V P                  P                  4       G R j  xL
  R V n        V P                  pV'       dn   \        VP                  ;p\        4      '       dL   VP                  4        VP                  4       G R j  xL
  VP                   ;p'       d   VP                  pKt   VEe
   V'       g    VP#                  RR7      G R j  xL
  VP'                  4       G R j  xL
  VP(                  '       d   VP(                  G R j  xL
  R V P*                  n        R V P*                  n        R V P0                  n        R V P0                  n        V\4        P6                  8w  d8   VP8                  ;pe(   VP;                  RV P<                  P>                  R7       VP                  4       G R j  xL
  R V n
        V P@                  '       d"   V P@                  PC                  4        R V n         V PD                  '       d"   V PD                  PC                  4        R V n"        V PF                  e2   \H        PJ                  PM                  V PF                  4      G R j  xL
  V PN                  '       d#   V PN                  P                  4       G R j  xL
  V PP                  e#   V PP                  P                  4       G R j  xL
  V PR                   Uu. uF'  p\        V\T        PV                  4      '       g   K%  VNK)  	  p	pV	'       d&   \X        PZ                  ! R V	 4       RR/ G R j  xL
  V P\                  '       d"   V P\                  PC                  4        R V n.        RV n        V P_                  R\a        W1R7      4       V P                  4        R	V n1        R
V n2        ^ V n3        ^ V n4        R V n         V Pj                  '       d*   V Pj                  P                  4       G R j  xL
  R V n5        V Pl                  '       d*   V Pl                  P                  4       G R j  xL
  R V n6        R R R 4      GR j  xL
  \n        Pp                  ! RRVPr                  RV/R7       R #  EL EL ELR EL EL  \$         d     ELi ; i EL EL EL EL4 EL ELu upi  ELt L L Lk  + GR j  xL 
 '       g   i     L; i5i)NTforce)audio_detachedtranscript_timeoutc              3  @   "   T F  qP                  4       x  K  	  R # 5ir   aclose).0toolsets   & rh   	<genexpr>,AgentSession._aclose_impl.<locals>.<genexpr>  s     ?h7nn&&hs   return_exceptionsFcloser  r  r   r   zsession closedr  r  r  ):r!  r  r  r  r   r  _cancel_user_away_timer_on_aec_warmup_expiredr)  r&  r  rt   r  r4   cancel_wait_for_inactive
_old_agent	interruptrn  r  rc  rO  r[   r  rT  r  r<   ERROR_audio_recognitioncommit_user_turnr   r   r  endr  r	  r   r  r  r  r(  r   r   Toolsetr   r  r   r=  r;   r  r  r   r   r  r  r%   r  rD  )
r   r  r  r  activity
agent_task	old_agentaudio_recognitiontooltoolsetss
   &$$$      rh   r  AgentSession._aclose_impl  s6     """ 7 78::::=== :: !DM((*'')yy$ii&&((( 	~~Hz*F*	RR!!# 33555 * 5 5595(22H#&00t0<<< nn&&& ***"1111 $(

 #'

 $(!,0) k///.6.I.II*V &66'++/::+V+V 7 
 oo'''!DN((())--/,0)'''((,,.+/(((4ii//0I0IJJJ   ''..000!!-((//111)-V
48UHVnn?h?&*  
 !!!""&&(%)"!DMIIgzEF((**D .D%&D"%&D"&*D#!!!((//111%)" }}}mm**,,, $M :P 	%hgu-UVQ  ) 6 ='  ' 2$ ( K 1 2V* 2
 -K :::s  AU2TU2U%U20T1U27AU	T
U)AU.T/UU$T$9T!:T$>UT6U(U7T98B'UT< U=2U0AUT?U"U?U /U/U0U"U)U/*UUU0B&UUU4UUUU2(U)-U2U2UU!T$$T3/U2T33U9U<U?UUUUUUU2U/	U
U/	(U/	*U2c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     C Cd Crg   c                	b   "   V P                  \        P                  R 7      G Rj  xL
  R#  L5i)r  N)r  r<   r  r   s   &rh   r&  AgentSession.aclose  s"     {'A'ABBBs   $/-/endpointing_optsc          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
rm   rC  zNotGivenOr[EndpointingOptions]r   z$NotGivenOr[TurnDetectionMode | None]r   r   r   rp   r   r_   )rq   s   "rh   rr   r     s>     9 9 99 =	9  19  19 
9rg   c                  \        V4      '       g   \        V4      '       d   \        P                  ! R4       \        V P                  P
                  R,          \        V4      '       d   TMV P                  P
                  R,          \        V4      '       d   TMV P                  P
                  R,          R7      p\        V4      '       d   VP                  R4      ;pe   WPP                  P
                  R&   VP                  R4      ;pe   W`P                  P
                  R&   VP                  R4      ;pe   WpP                  P
                  R&   VP                  R4      ;pe   WP                  P
                  R&   \        V4      '       d   W n        V P                  eK   V P                  P                  \        V4      '       d   V P                  P
                  M\        VR7       R# R# )	a  
Update the options for the agent session.

Args:
    endpointing_opts (NotGivenOr[EndpointingOptions], optional): Endpointing options.
    turn_detection (NotGivenOr[TurnDetectionMode | None], optional): Strategy for deciding
        when the user has finished speaking. ``None`` reverts to automatic selection.
    min_endpointing_delay: Deprecated, use ``endpointing_opts`` instead.
    max_endpointing_delay: Deprecated, use ``endpointing_opts`` instead.
z\min_endpointing_delay and max_endpointing_delay are deprecated, use endpointing_opts insteadr   	min_delay	max_delay)r   rF  rG  Nalpha)rC  r   )r/   r%   r   rI   r   r   r   r   r  update_optionsr+   )	r   rC  r   r   r   r   rF  rG  rH  s	   &$$$$    rh   rI  AgentSession.update_options  s   & )**h7L.M.MNN/  2ZZ++F3   566 *//<   566 *//<  $%%(,,V44A15

&&v.-11+>>	K6?

&&{3-11+>>	K6?

&&{3)--g66C27

&&w/N###1 >>%NN)).67G.H.HDJJ**i-	 *  &rg   c                    V ^8  d   QhRRRR/# )rm   r^   z
str | Nonerp   r   r_   )rq   s   "rh   rr   r   <  s      Z 4 rg   c                  "   V P                   e   \        P                  ! R4       R# \        V 4      V n         V P                  P                  V P                   P                  4       V P                   P                  4       G Rj  xL
  VeC   \        P                  ! RRV/R7       V P                   P                  \        VRR7      4       R# R#  LL5i)a  Start IVR detection on this session.

This method injects the DTMF tool and enables loop/silence detection,
allowing the agent to navigate IVR phone trees. Safe to call after AMD resolves.

Args:
    transcript (str | None, optional): The transcript to start IVR detection with.
Nz'IVR detection already started, skippingz%IVR detection started with transcriptr^   r  T)r^   is_final)r(  r%   r   rB   r   extendr   r  r  _on_user_input_transcribedr?   )r   r^   s   &&rh   r  !AgentSession._start_ivr_detection<  s      )NNDE(.4--334  &&(((!LL@WaHbc99)Z$O " 	)s   BCCACr[   add_to_chat_ctxc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )rm   r{  zstr | AsyncIterable[str]r[   z)NotGivenOr[AsyncIterable[rtc.AudioFrame]]r   r   rQ  rZ   rp   rH   r_   )rq   s   "rh   rr   r   R  s<        &  9	 
 .    
 rg   c          	     	B   V P                   f   \        R4      hV P                  pV P                   P                  '       d   V P                  MV P                   pVf   \        R4      h\        4       p\        P                  ! 4       \        P                  J d1   V P                  e#   \        P                  ! V P                  RR7      pT;_uu_ 4        VP                  VVVVR7      pV'       d   VP                  V4       R R R 4       V#   + '       g   i     X# ; i)Nr  z)AgentSession is closing, cannot use say()Fend_on_exit)r[   r   rQ  )r  rn  r  scheduling_pausedr  r   r   r  INVALID_SPANr   use_spansay_watch_handle)	r   r{  r[   r   rQ  r  r9  rX  handles	   &&$$$    rh   rY  AgentSession.sayR  s     >>!;<<**	*...*J*J*J4&&PTP^P^JKK ?Jm!!#u'9'99d>P>P>\~~d&8&8eLHX\\$7 /	 " F ''/   X s   /DD	r~  instructionstool_choicechat_ctxc               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )rm   r~  z!NotGivenOr[str | llm.ChatMessage]r]  zNotGivenOr[str | Instructions]r^  zNotGivenOr[llm.ToolChoice]r   zNotGivenOr[list[str]]r   r   r_  zNotGivenOr[ChatContext]rz  r  rp   rH   r_   )rq   s   "rh   rr   r   t  sf     @ @ 6@ 5	@
 0@ %@ .@ *@ 1@ 
@rg   c                  V P                   f   \        R4      h\        V\        4      '       d   \        P
                  ! RV.R7      MTpV P                  p	V P                   P                  '       d   V P                  MV P                   p
V
f   \        R4      h\        4       p\        P                  ! 4       \        P                  J d1   V P                  e#   \        P                  ! V P                  RR7      pT;_uu_ 4        T
P                  V'       d   TMRVVVVV\!        VR7      R	7      pV	'       d   V	P#                  V4       RRR4       V#   + '       g   i     X# ; i)
aC  Generate a reply for the agent to speak to the user.

Args:
    user_input (NotGivenOr[str | llm.ChatMessage], optional): The user's input that may influence the reply,
        such as answering a question.
    instructions (NotGivenOr[str], optional): Additional instructions for generating the reply.
    tool_choice (NotGivenOr[llm.ToolChoice], optional): Specifies the external tool to use when
        generating the reply. If generate_reply is invoked within a function_tool, defaults to "none".
    tools (NotGivenOr[list[str]], optional): List of tool IDs to make available for this response.
        When set, only the specified tools can be used. Tool IDs must match registered tools on the
        agent. For function tools, the ID is the function name (accessible via ``my_tool.id``).
        For toolsets, the ID is the one provided at construction (accessible via ``my_toolset.id``).
    allow_interruptions (NotGivenOr[bool], optional): Indicates whether the user can interrupt this speech.
    chat_ctx (NotGivenOr[ChatContext], optional): The chat context to use for generating the reply.
        Defaults to the chat context of the current agent if not provided.
    input_modality (Literal["text", "audio"], optional): The input mode to use for generating the reply.

Returns:
    SpeechHandle: A handle to the generated reply.
Nr  user)rolecontentz4AgentSession is closing, cannot use generate_reply()FrT  )modality)user_messager]  r^  r   r   r_  input_details)r  rn  rt   r   r   ChatMessager  rV  r  r   r   r  rW  r   rX  _generate_replyrG   rZ  )r   r~  r]  r^  r   r   r_  rz  rf  r  r9  rX  r[  s   &$$$$$$$     rh   r  AgentSession.generate_replyt  s-   > >>!;<< *c** OO*> 	 **	*...*J*J*J4&&PTP^P^UVV ?Jm!!#u'9'99d>P>P>\~~d&8&8eLHX---9\t)'$7!*NC . F ''/   X s   AEE&	r!  c                    V ^8  d   QhRRRR/# )rm   r!  rZ   rp   r  r_   )rq   s   "rh   rr   r     s     
5 
5$ 
53G 
5rg   c               l    V P                   f   \        R4      hV P                   P                  VR7      # )zInterrupt the current speech generation.

Returns:
    An asyncio.Future that completes when the interruption is fully processed
    and chat context has been updated.
r  r   )r  rn  r3  )r   r!  s   &$rh   r3  AgentSession.interrupt  s2     >>!;<<~~''e'44rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     ) ) )rg   c                	l    V P                   f   \        R4      hV P                   P                  4        R # r  )r  rn  clear_user_turnr   s   &rh   rp  AgentSession.clear_user_turn  s(    >>!;<<&&(rg   r#  stt_flush_duration
skip_replyc               (    V ^8  d   QhRRRRRRRR/# )rm   r#  r   rr  rs  rZ   rp   zasyncio.Future[str]r_   )rq   s   "rh   rr   r     s4     "
 "
 ""
 "	"

 "
 
"
rg   c               p    V P                   f   \        R4      hV P                   P                  VVVR7      # )a=  Commit the user turn and generate a reply.

Returns a future that resolves with the user's audio transcript once STT
is complete and end-of-turn detection has been triggered.

Args:
    transcript_timeout (float, optional): The timeout for the final transcript
        to be received after committing the user turn.
        Default ``2.0`` s. Increase this value if the STT is slow to respond.
    stt_flush_duration (float, optional): The duration of the silence to be appended to the STT
        to flush the buffer and generate the final transcript.
        Default ``2.0`` s.
    skip_reply (bool, optional): Whether to skip the reply generation after committing the user turn.

Returns:
    asyncio.Future[str]: A future that resolves with the audio transcript.

Raises:
    RuntimeError: If the AgentSession isn't running.
r  )r#  rr  rs  )r  rn  r6  )r   r#  rr  rs  s   &$$$rh   r6  AgentSession.commit_user_turn  s?    6 >>!;<<~~..11! / 
 	
rg   c                    V ^8  d   QhRRRR/# )rm   r  r3   rp   r   r_   )rq   s   "rh   rr   r     s     . .% .D .rg   c                	L   Wn         V P                  '       d   V P                  e   RV P                  n        \        P
                  ! V P                  V P                  V P                   4      RR7      ;V n        pV P                  pV'       d   VP                  V4       R # R # R # )NT_update_activity_taskr  )
r  r   r  _new_turns_blockedr   r  ry  r  r  rZ  )r   r  r  r  s   &&  rh   update_agentAgentSession.update_agent  s    === ~~)481181D1D**4+F+FT,2 D'$ ..I ''-  rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r      s     6 6 6rg   c                	v   "   V P                   e%   V P                   P                  4       G R j  xL
  R # R #  L5ir   )r  r1  r   s   &rh   wait_for_inactiveAgentSession.wait_for_inactive   s-     >>%..33555 &5s   ,97	9previous_activityr,  new_activityr  blocked_tasksr  c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )rm   r  r3   r  zLiteral['close', 'pause']r  zLiteral['start', 'resume']r  zlist[asyncio.Task] | Noner  rZ   rp   r   r_   )rq   s   "rh   rr   r     sV     V@ V@V@ 5	V@
 1V@ 1V@ V@ 
V@rg   c          	     	F  "   V P                   ;_uu_4       GR j  xL
  Wn        VR8X  da   V P                  '       d   V P                  P                  MR pVP                  e   WJg   VR8w  d   \	        R4      h\        W4      V n        M1VR8X  d+   VP                  f   \	        R4      hVP                  V n        V P                  e!   \        P                  ! V P                  4       R p V P                  pV P                  ;p	e{   VR8X  d>   V	P                  V P                  R7      G R j  xL
 pV	P                  4       G R j  xL
  M6VR8X  d0   T	P                  T;'       g    . V P                  R7      G R j  xL
 pV P                  '       d   VR8X  dz   \        P                  ! R	V R
V P                  P                  P                    24       Ve   VP#                  4       G R j  xL
  R pR V n        R V n         R R R 4      GR j  xL
  R # V P                  V n        R V n        V P$                  p
\'        V'       d   VP                  P                   MR V P                  P                  P                   R7      pV
'       d=   T
P)                  TV'       d   VP                  MR V P                  P                  R7       V P*                  P-                  V4       V P/                  R\1        VR7      4       VR8X  d&   V P                  P3                  VR7      G R j  xL
  M+VR8X  d%   V P                  P5                  VR7      G R j  xL
  R R R 4      GR j  xL
  V'       dO   V P                  P8                  f   Q h\:        P<                  ! V P                  P8                  4      G R j  xL
  R # R #  EL EL EL{ ELG EL EL L L  \6         d     Te   TP#                  4       G R j  xL 
  h i ; i L  + GR j  xL 
 '       g   i     L; i Li5i)Nr  r,  z2cannot start agent: an activity is already runningresumez:cannot resume agent: no existing active activity to resume)r  pause)r  r  zsession is closing, skipping z activity of )old_agent_idnew_agent_id)itemr;  	new_agentconversation_item_addedr  )reuse_resources)r  r  r  r  rn  r5   r  r!  r  r  r  r&  r  r  r%   r   r  cleanupr  r    _agent_handoffr   insertr=  r=   r  r  BaseException_on_enter_taskr   shield)r   r  r  r  r  r  previous_agentr  previous_activity_vr9  r  handoff_items   &&$$$$      rh   r  AgentSession._update_activity  sk     &&&&Kw&9=!5!5T??./3D3O&'[\\&3E&@#)??*&'cdd&+oo#&&2 ##D$;$;<9=O/&*nn# $.H;(G308DL_L_0`*`&oo///*g508*7*=*=2DL_L_ 1? 1 + ===\W%<NN7~]SWSfSfSlSlSoSoRpq '2-55777*.*.D'%)DN] '&&` "&!4!4&*# 22	+AT!4!:!:!=!=Z^!%!5!5!8!8  ,,)?R"5";";X\"&.."6"6 - 
 %%l3		35OUa5bc7*.....OOO!X-..///PPPI '&V >>00<<<..!>!>??? W ': +a/+ 8U 'D PP  ".)11333K '&&&Z @s3  P!N>P!PB/P/AO1O2O	O
O*O OOAO/O
0OP!OP!A4OO BO%O&O*P+&OOOP!!P"P!.AP!5P6	P!OOO
OP!OO"O>6O9
7O>>PP!P		P

P	P		P!c               $    V ^8  d   QhRRRRRR/# )rm   old_taskzasyncio.Task[None] | Noner  r3   rp   r   r_   )rq   s   "rh   rr   r   ]  s$     + +1+:?+	+rg   c                	d   "   Ve   VG R j  xL
  V P                  V4      G R j  xL
  R #  L L5ir   )r  )r   r  r  s   &&&rh   ry  "AgentSession._update_activity_task\  s0      NN##E*** *s   
0,0.00c                    V ^8  d   QhRRRR/# )rm   r  zCllm.LLMError | stt.STTError | tts.TTSError | llm.RealtimeModelErrorrp   r   r_   )rq   s   "rh   rr   r   e  s     < <X<	<rg   c                	"  a  S P                   '       g   VP                  '       d   R # VP                  R8X  dB   S ;P                  ^,          un        S P                  S P                  P
                  8:  d   R # MQVP                  R8X  dA   S ;P                  ^,          un        S P                  S P                  P
                  8:  d   R # \        VP                  \        4      '       d%   \        P                  ! RVP                   24       M"\        P                  ! RVP                  R7       R V 3R llp\        P                  ! S P                  V\        P                  R7      4      S n         S P                   P!                  V4       R # )	N	llm_error	tts_errorz4AgentSession is closing due to unrecoverable error: z2AgentSession is closing due to unrecoverable error)exc_infoc                    V ^8  d   QhRRRR/# )rm   r  zasyncio.Task[None]rp   r   r_   )rq   s   "rh   rr   ,AgentSession._on_error.<locals>.__annotate__|  s     	& 	&/ 	&D 	&rg   c                   < R Sn         R # r   )r  r  s   &rh   on_close_done-AgentSession._on_error.<locals>.on_close_done|  s    !%Drg   r-  )r  recoverabletyper   r   r}   r   rt   r  r   r%   r   r  r  r<   r4  r  )r   r  r  s   f& rh   	_on_errorAgentSession._on_errore  s)    !2!2!2::$""a'"%%):):)S)SS TZZ;&""a'"%%):):)S)SSekk8,,LLOPUP[P[}]^LLD
	& 	& %00E+2C2CD
 	,,];rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     1 14 1rg   c                	   "   V P                   P                  pVf   R # V  R j  xL
  pV P                  f   K  V P                  P                  V4       K7   L2D3R # 5ir   )rO  r[   r  
push_audio)r   r  r   s   &  rh   r   AgentSession._forward_audio_task  sO     jj&&& 	1 	1%~~)))%0	1;s*   AAAAAAAAc                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     
1 
14 
1rg   c                	  "   V P                   P                  pVf   R # V  R j  xL
  pV P                  f   K  V P                  e   V P                  W 4      '       g   KA  V P                  P	                  V4       K^   LYDZR # 5ir   )rO  r  r  r   
push_video)r   r  r   s   &  rh   r   AgentSession._forward_video_task  sn     jj&&& 	1 	1%~~)&&24;N;Nu;[;[))%0	1;s+   BBA?BBAB?BBc                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     
 
d 
rg   c                	j   V P                  4        V P                  P                  f   R # V P                  ;p'       d5   VP                  '       d#   VP                  P                  4       '       g   R # V P                  P                  V P                  P                  V P                  R4      V n	        R # )Naway)
r.  r   r   r  r  r  r   
call_later_update_user_stater  )r   r1   s   & rh   r  !AgentSession._set_user_away_timer  s    $$&::''/ %W%&&&**//11  $

 5 5JJ(($*A*A6!
rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     ) ) )rg   c                	h    V P                   e$   V P                   P                  4        R V n         R # R # r   )r  r0  r   s   &rh   r.  $AgentSession._cancel_user_away_timer  s-      ,!!((*$(D! -rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r     s     * * *rg   c                	    V P                   ^ 8  d)   V P                  '       g   \        P                  ! R4       RV n         V P                  e$   V P                  P                  4        RV n        R# R# )r   z-aec warmup expired, re-enabling interruptionsr   N)r   r  r%   r  r   r0  r   s   &rh   r/  #AgentSession._on_aec_warmup_expired  sX    %%)$---LLHI%("!!-""))+%)D" .rg   r  
start_timec               (    V ^8  d   QhRRRRRRRR/# )	rm   stater9   r  zotel_context.Context | Noner  r   rp   r   r_   )rq   s   "rh   rr   r     s2     9
 9
9
 2	9

 !9
 
9
rg   c               	   V P                   V8X  d   R # V'       d   \        VR,          4      MR pVR8X  d   ^ V n        ^ V n        V P                  fd   \
        P                  ! RW$R7      V n        V P                  '       d5   \        V P                  V P                  P                  P                  4       M/V P                  e"   V P                  P                  4        R V n        VR8X  d   V P                  ^ 8  d   V P                  f   V P                  P                  '       do   V P                  P                   eW   V P"                  P%                  V P                  V P&                  4      V n        \(        P*                  ! RV P                  4       VR8X  d#   V P,                  R8X  d   V P/                  4        MV P1                  4        V P                   pWn         V P3                  R\5        WQR7      4       R # )	N ʚ;r   agent_speaking)r   r  z4aec warmup active, disabling interruptions for %.2fsr   agent_state_changed)	old_state	new_state)r  r|   r   r   r  r)   r  r  r2   r  local_participantr7  r   r   r  audio_enabledr[   r   r  r/  r%   r  r  r  r.  r=  r:   )r   r  r  r  start_time_nsr  s   &&$$  rh   r   AgentSession._update_agent_state  s    %;EJ674J%&D"%&D"((0,2,=,=$l-) ===/114==3E3E3W3W &&2%%))+(,D% Z**Q.&&.***"".%)ZZ%:%:**D,G,G&D" LLF**
 KD$4$4$C%%'((*%%	!		!"YH	
rg   last_speaking_timec               $    V ^8  d   QhRRRRRR/# )rm   r  r@   r  r   rp   r   r_   )rq   s   "rh   rr   r     s$     )
 )
)
7C)
	)
rg   c          	     	   V P                   V8X  d   R # V'       d   \        VR,          4      MR pVR8X  d   V P                  fw   \        P                  ! RVR7      V n        V P
                  '       dG   V P
                  P                  '       d+   \        V P                  V P
                  P                  4       M1V P                  e$   V P                  P                  VR7       R V n        VR8X  d#   V P                  R8X  d   V P                  4        MV P                  4        V P                   pWn         T P                  R\        TTT;'       g    \        P                  ! 4       R7      4       R # )	Nr  r   user_speaking)r  )end_timer   user_state_changed)r  r  
created_at)r  r|   r  r)   r  r  linked_participantr2   r7  r  r  r.  r=  rA   r   )r   r  r  last_speaking_time_nsr  s   &&$  rh   r  AgentSession._update_user_state  s1    u$ 8JC"]23t 	 J4#;#;#C'-'8'8,A(D$ }}}!A!A!A+,,dmm.N.N
 %%1 $$((2G(H'+D$KD$5$5$D%%'((*$$	 		 !#-<<	
rg   c                    V ^8  d   QhRRRR/# )rm   r  rZ   rp   r   r_   )rq   s   "rh   rr   r      s     5 5 5$ 5rg   c                    V'       gR   V P                   R8X  d?   V P                  e   V P                  P                  R4       R# V P                  R4       R# R# R# )z:End user speaking state when audio is disabled by default.r   Nr   )r  r  on_end_of_speechr  )r   r  s   &&rh   r  &AgentSession._on_audio_enabled_changed   sC    4++z9~~)//5''4	 :wrg   c                    V ^8  d   QhRRRR/# )rm   evr?   rp   r   r_   )rq   s   "rh   rr   r   (  s     0 0*C 0 0rg   c                	    V P                   R 8X  d$   VP                  '       d   V P                  R4       V P                  RV4       R# )r  r   user_input_transcribedN)r   rM  r  r=  )r   r  s   &&rh   _user_input_transcribed$AgentSession._user_input_transcribed(  s3    ??f$##K0		*B/rg   c                    V ^8  d   QhRRRR/# )rm   messagezllm.ChatMessagerp   r   r_   )rq   s   "rh   rr   r   /  s     W W WD Wrg   c                	t    V P                   P                  V4       V P                  R \        VR7      4       R# )r  r  N)r   r  r=  r=   )r   r  s   &&rh   _conversation_item_added%AgentSession._conversation_item_added/  s)    g&		+-GW-UVrg   c                    V ^8  d   QhRRRR/# )rm   itemsz3Sequence[llm.FunctionCall | llm.FunctionCallOutput]rp   r   r_   )rq   s   "rh   rr   r   3  s     % %'Z %_c %rg   c                	<    V P                   P                  V4       R # r   )r   r  )r   r  s   &&rh   _tool_items_addedAgentSession._tool_items_added3  s    e$rg   c                   V ^8  d   QhRR/# )rm   rp   zstt.STT | Noner_   )rq   s   "rh   rr   r   8        ^ rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.stt7      yyrg   c                   V ^8  d   QhRR/# )rm   rp   z"llm.LLM | llm.RealtimeModel | Noner_   )rq   s   "rh   rr   r   <  s      7 rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.llm;  r  rg   c                   V ^8  d   QhRR/# )rm   rp   ztts.TTS | Noner_   )rq   s   "rh   rr   r   @  r  rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.tts?  r  rg   c                   V ^8  d   QhRR/# )rm   rp   zvad.VAD | Noner_   )rq   s   "rh   rr   r   D  r  rg   c                	    V P                   # r   )r   r   s   &rh   r   AgentSession.vadC  r  rg   c                   V ^8  d   QhRR/# )rm   rp   z&NotGivenOr[Literal['adaptive', 'vad']]r_   )rq   s   "rh   rr   r   H  s     , ,(N ,rg   c                	    V P                   # r   )r   r   s   &rh   interruption_detection#AgentSession.interruption_detectionG  s    +++rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r   M       	
 	
 	
rg   c                	    V P                   '       g   R # V P                  e   V P                  P                  4        \        P                  ! V P                  4       RR7      V n        R # )Nr  r  )r   r
  r0  r   r  r  r   s   &rh   r   $AgentSession._on_video_input_changedM  N    }}}$$0%%,,.$+$7$7$$&-B%
!rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r   X  r  rg   c                	    V P                   '       g   R # V P                  e   V P                  P                  4        \        P                  ! V P                  4       RR7      V n        R # )Nr  r  )r   r	  r0  r   r  r  r   s   &rh   r  $AgentSession._on_audio_input_changedX  r   rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r   c  s      $ rg   c                	    R # r   r_   r   s   &rh   r  %AgentSession._on_video_output_changedc      rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r   f  s     
 
$ 
rg   c                	(   V P                   '       d   V P                  P                  R ,          '       d[   V P                  P                  ;p'       d;   VP
                  '       g'   \        P                  ! RRVP                  /R7       R# R# R# R# R# )r   zZresume_false_interruption is enabled, but the audio output does not support pause, ignoredr  r  N)	r   r   r   rT  r[   r  r%   r   r  )r   r  s   & rh   r  %AgentSession._on_audio_output_changedf  st    MMM

''(CDD!%!2!222 ***NNl%|'9'9: + 3 E rg   c                   V ^8  d   QhRR/# r
  r_   )rq   s   "rh   rr   r   r  s       rg   c                	    R # r   r_   r   s   &rh   r  $AgentSession._on_text_output_changedr  r  rg   c                   V ^8  d   QhRR/# )rm   rp   r   r_   )rq   s   "rh   rr   r   w  s      , rg   c                	   "   V # 5ir   r_   r   s   &rh   
__aenter__AgentSession.__aenter__w  s
     r  c               (    V ^8  d   QhRRRRRRRR/# )	rm   exc_typeztype[BaseException] | NoneexczBaseException | Noneexc_tbzTracebackType | Nonerp   r   r_   )rq   s   "rh   rr   r   z  s2      , " %	
 
rg   c                	B   "   V P                  4       G R j  xL
  R #  L5ir   r%  )r   r  r  r  s   &&&&rh   	__aexit__AgentSession.__aexit__z  s      kkms   )3r  r  r   r   r  r  r  r)  r   r  r  r   r  r	  r
  r  r  r   r(  r  r   r   r  r   r   r  r   r  r#  r  r%  r  r!  r"  r  r   r   r&  r   r   r   r   r   r  r'  r  r  r  r  r   r   r   )Kr`   ra   rb   rc   r.   r+   r   r   r0  r7  r=  r   setterr   r   rO  rT  rX  r   r_  rc  r   rj  ro  r   rx  r  r   r  r  r1   r  r  r   log_exceptionsr%   r  r&  rI  r  rY  r  r3  rp  r6  r{  r  r  ry  r  r  r  r  r.  r/  r  r  r  r  r  r  r   r   r   r   r  r   r  r  r  r  r  r  rf   __classcell__)r,  s   @rh   r   r      s!   #%Y#%Y(*^')]!#W.0d')]#%Y$&ZR.0d	
  % 6?% $-	%
 JS% 6?% :C% ;D%  % 8A% LU% /2%  ,5!%" ;D#%$ -0%%& $'%( +/)%* 36+%. ;D/%0 261%4 3<5%6 4=7%8 4=9%: @I;%< 9B=%> >G?%@ 8AA%B 3<C%D 1:E%F 7@G%H FOI%J 8AK% %! %B  + +! !   __  $ $ ! !       " "   U U     ! !     N N 4:	
 +/ 
 &/ 9B +/ DM FO   ',	
 &/ 9B +/ DM FO G "	G
 &/G 9BG 7@G DMG FOGR%  
 	

 ]a
U U (xW 	xW xW )xWtC9 <E9 @I	9 4=9 4=9v,  <E	 
 1:  !% D@ 9B@ 8A	@
 3<@ (1@ 1:@ -6@ 4:@D
5 
5)"
 %("
 %(	"

 !"
H.&6V@ 8?	V@
 4;V@ 48V@ #V@p (+ )+<> (1 )1 (
1 )
1
")
*9
 59	9

 $(9
v)
FJ)
V50W%         , ,
	
	


 rg   r   )__conditional_annotations__
__future__r   r   r$  r   collections.abcr   r   r   
contextlibr   r   contextvarsr	   dataclassesr
   typesr   typingr   r   r   r   r   r   r   opentelemetryr   r  r   typing_extensionsr   livekitr    r   r   r   r   r   r   r   _exceptionsr   r  r   r    r!   r"   llm.chat_contextr#   logr%   metricsr&   r'   	telemetryr(   r)   r*   r+   r,   r-   utils.deprecationr.   
utils.miscr/   r0   r1   _utilsr2   r  r3   r4   agent_activityr5   r6   r0  r7   eventsr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   ivrrB   recorder_iorC   remote_sessionrD   rE   
run_resultrF   speech_handlerG   rH   turnrI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   transcription.text_transformsrW   rY   rj   re   rk   rv   rx   r   r   r   r   r   r   EventEmitterr   )r  s   @rh   <module>r:     s   " "    = = :  !    9 '  8 8 8 " ! : : +  < +  1 !  / # =     # = ! 5   ;;=Sy S0 Td
D$	' #  Ue
E%	( $ ? N N N ; ; ;0 \"

 RH R R
 2 6G4W 1 Ww3##J/1D wrg   