
    CjJ                       S SK Jr  S SKJrJr  S SKJrJr  SSKJr  SSK	J
r
  SSKJr  SS	KJrJrJrJrJrJrJrJrJrJrJrJrJr  SS
KJr  SSKJr  \(       a  S SKJ r        S             SS jjr!S S jr"S!S jr#      S"               S#S jjr$   S$         S%S jjr%   S$           S&S jjr&     S             S'S jjr'        S(                 S)S jjr(    S*         S+S jjr)     S           S,S jjr*    S*           S-S jjr+    S.           S/S jjr,        S0                 S1S jjr-         S2                   S3S jjr.    S*         S4S jjr/     S           S5S jjr0g)6    )annotations)MappingSequence)TYPE_CHECKINGAny   )logger   )TracingConfig)get_trace_provider)AgentSpanDataCustomSpanDataFunctionSpanDataGenerationSpanDataGuardrailSpanDataHandoffSpanDataMCPListToolsSpanDataResponseSpanDataSpeechGroupSpanDataSpeechSpanDataTaskSpanDataTranscriptionSpanDataTurnSpanData)Span)Trace)ResponseNc           	         [        5       R                  5       nU(       a  [        R                  " S5        [        5       R	                  U UUUUUS9$ )a  
Create a new trace. The trace will not be started automatically; you should either use
it as a context manager (`with trace(...):`) or call `trace.start()` + `trace.finish()`
manually.

In addition to the workflow name and optional grouping identifier, you can provide
an arbitrary metadata dictionary to attach additional user-defined information to
the trace.

Args:
    workflow_name: The name of the logical app or workflow. For example, you might provide
        "code_bot" for a coding agent, or "customer_support_agent" for a customer support agent.
    trace_id: The ID of the trace. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_trace_id()` to generate a trace ID, to guarantee that IDs are
        correctly formatted.
    group_id: Optional grouping identifier to link multiple traces from the same conversation
        or process. For instance, you might use a chat thread ID.
    metadata: Optional dictionary of additional metadata to attach to the trace.
    tracing: Optional tracing configuration for exporting this trace.
    disabled: If True, we will return a Trace but the Trace will not be recorded.

Returns:
    The newly created trace object.
zKTrace already exists. Creating a new trace, but this is probably a mistake.)nametrace_idgroup_idmetadatatracingdisabled)r   get_current_tracer	   warningcreate_trace)workflow_namer   r    r!   r"   r#   current_traces          g/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/agents/tracing/create.pytracer*      sW    @ '(::<MY	
 ,, -      c                 2    [        5       R                  5       $ )z/Returns the currently active trace, if present.)r   r$    r+   r)   r$   r$   O   s    1133r+   c                 2    [        5       R                  5       $ )z.Returns the currently active span, if present.)r   get_current_spanr-   r+   r)   r/   r/   T   s    0022r+   c           	     F    [        5       R                  [        XX#S9UUUS9$ )az  Create a new agent span. The span will not be started automatically, you should either do
`with agent_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    name: The name of the agent.
    handoffs: Optional list of agent names to which this agent could hand off control.
    tools: Optional list of tool names available to this agent.
    output_type: Optional name of the output type produced by the agent.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created agent span.
)r   handoffstoolsoutput_type	span_dataspan_idparentr#   )r   create_spanr   )r   r1   r2   r3   r6   r7   r#   s          r)   
agent_spanr9   Y   s2    6 ++TEc	 ,  r+   c                D    [        5       R                  [        U S9UUUS9$ )zHCreate a new task span. This represents one top-level Runner invocation.)r   r4   )r   r8   r   )r   r6   r7   r#   s       r)   	task_spanr;   |   s0     ++D)	 ,  r+   c                D    [        5       R                  [        XS9UUUS9$ )z<Create a new turn span. This represents one agent loop turn.)turn
agent_namer4   )r   r8   r   )r=   r>   r6   r7   r#   s        r)   	turn_spanr?      s0     ++D@	 ,  r+   c                F    [        5       R                  [        XUS9UUUS9$ )a  Create a new function span. The span will not be started automatically, you should either do
`with function_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    name: The name of the function.
    input: The input to the function.
    output: The output of the function.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created function span.
)r   inputoutputr4   )r   r8   r   )r   rA   rB   r6   r7   r#   s         r)   function_spanrC      s2    2 ++"&I	 ,  r+   c           
     L    [        5       R                  [        U UUUUS9UUUS9$ )a  Create a new generation span. The span will not be started automatically, you should either
do `with generation_span() ...` or call `span.start()` + `span.finish()` manually.

This span captures the details of a model generation, including the
input message sequence, any generated outputs, the model name and
configuration, and usage data. If you only need to capture a model
response identifier, use `response_span()` instead.

Args:
    input: The sequence of input messages sent to the model.
    output: The sequence of output messages received from the model.
    model: The model identifier used for the generation.
    model_config: The model configuration (hyperparameters) used.
    usage: A dictionary of usage information (input tokens, output tokens, etc.).
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created generation span.
)rA   rB   modelmodel_configusager4   )r   r8   r   )rA   rB   rE   rF   rG   r6   r7   r#   s           r)   generation_spanrH      sB    D ++$%
  ,  r+   c                D    [        5       R                  [        U S9UUUS9$ )a}  Create a new response span. The span will not be started automatically, you should either do
`with response_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    response: The OpenAI Response object.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.
)responser4   )r   r8   r   )rJ   r6   r7   r#   s       r)   response_spanrK      s0    $ ++"H5	 ,  r+   c                D    [        5       R                  [        XS9UUUS9$ )a  Create a new handoff span. The span will not be started automatically, you should either do
`with handoff_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    from_agent: The name of the agent that is handing off.
    to_agent: The name of the agent that is receiving the handoff.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created handoff span.
)
from_agentto_agentr4   )r   r8   r   )rM   rN   r6   r7   r#   s        r)   handoff_spanrO     s0    . ++!ZK	 ,  r+   c                V    [        5       R                  [        X=(       d    0 S9UUUS9$ )a  Create a new custom span, to which you can add your own metadata. The span will not be
started automatically, you should either do `with custom_span() ...` or call
`span.start()` + `span.finish()` manually.

Args:
    name: The name of the custom span.
    data: Arbitrary structured data to associate with the span.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created custom span.
)r   datar4   )r   r8   r   )r   rQ   r6   r7   r#   s        r)   custom_spanrR   %  s4    0 ++ d<	 ,  r+   c                D    [        5       R                  [        XS9UUUS9$ )a  Create a new guardrail span. The span will not be started automatically, you should either
do `with guardrail_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    name: The name of the guardrail.
    triggered: Whether the guardrail was triggered.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.
)r   	triggeredr4   )r   r8   r   )r   rT   r6   r7   r#   s        r)   guardrail_spanrU   E  s0    ( ++#C	 ,  r+   c           
     L    [        5       R                  [        UUUU US9UUUS9$ )a  Create a new transcription span. The span will not be started automatically, you should
either do `with transcription_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    model: The name of the model used for the speech-to-text.
    input: The audio input of the speech-to-text transcription, as a base64 encoded string of
        audio bytes.
    input_format: The format of the audio input (defaults to "pcm").
    output: The output of the speech-to-text transcription.
    model_config: The model configuration (hyperparameters) used.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.

Returns:
    The newly created speech-to-text span.
)rA   input_formatrB   rE   rF   r4   )r   r8   r   )rE   rA   rW   rB   rF   r6   r7   r#   s           r)   transcription_spanrX   a  sA    < ++'%%
  ,  r+   c	                N    [        5       R                  [        U UUUUUS9UUUS9$ )a  Create a new speech span. The span will not be started automatically, you should either do
`with speech_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    model: The name of the model used for the text-to-speech.
    input: The text input of the text-to-speech.
    output: The audio output of the text-to-speech as base64 encoded string of PCM audio bytes.
    output_format: The format of the audio output (defaults to "pcm").
    model_config: The model configuration (hyperparameters) used.
    first_content_at: The time of the first byte of the audio output.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.
)rE   rA   rB   output_formatrF   first_content_atr4   )r   r8   r   )	rE   rA   rB   rZ   rF   r[   r6   r7   r#   s	            r)   speech_spanr\     sD    8 ++ '%-
  ,  r+   c                D    [        5       R                  [        U S9UUUS9$ )a  Create a new speech group span. The span will not be started automatically, you should
either do `with speech_group_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    input: The input text used for the speech request.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.
)rA   r4   )r   r8   r   )rA   r6   r7   r#   s       r)   speech_group_spanr^     s0    $ ++%E2	 ,  r+   c                D    [        5       R                  [        XS9UUUS9$ )a  Create a new MCP list tools span. The span will not be started automatically, you should
either do `with mcp_tools_span() ...` or call `span.start()` + `span.finish()` manually.

Args:
    server: The name of the MCP server.
    result: The result of the MCP list tools call.
    span_id: The ID of the span. Optional. If not provided, we will generate an ID. We
        recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are
        correctly formatted.
    parent: The parent span or trace. If not provided, we will automatically use the current
        trace/span as the parent.
    disabled: If True, we will return a Span but the Span will not be recorded.
)serverresultr4   )r   r8   r   )r`   ra   r6   r7   r#   s        r)   mcp_tools_spanrb     s0    ( ++&fD	 ,  r+   )NNNNF)r'   strr   
str | Noner    rd   r!   dict[str, Any] | Noner"   zTracingConfig | Noner#   boolreturnr   )rg   zTrace | None)rg   zSpan[Any] | None)NNNNNF)r   rc   r1   list[str] | Noner2   rh   r3   rd   r6   rd   r7   Trace | Span[Any] | Noner#   rf   rg   zSpan[AgentSpanData])NNF)
r   rc   r6   rd   r7   ri   r#   rf   rg   zSpan[TaskSpanData])r=   intr>   rc   r6   rd   r7   ri   r#   rf   rg   zSpan[TurnSpanData])r   rc   rA   rd   rB   rd   r6   rd   r7   ri   r#   rf   rg   zSpan[FunctionSpanData])NNNNNNNF)rA   "Sequence[Mapping[str, Any]] | NonerB   rk   rE   rd   rF   Mapping[str, Any] | NonerG   re   r6   rd   r7   ri   r#   rf   rg   zSpan[GenerationSpanData])NNNF)
rJ   zResponse | Noner6   rd   r7   ri   r#   rf   rg   zSpan[ResponseSpanData])rM   rd   rN   rd   r6   rd   r7   ri   r#   rf   rg   zSpan[HandoffSpanData])r   rc   rQ   re   r6   rd   r7   ri   r#   rf   rg   zSpan[CustomSpanData])FNNF)r   rc   rT   rf   r6   rd   r7   ri   r#   rf   rg   zSpan[GuardrailSpanData])NNpcmNNNNF)rE   rd   rA   rd   rW   rd   rB   rd   rF   rl   r6   rd   r7   ri   r#   rf   rg   zSpan[TranscriptionSpanData])	NNNrm   NNNNF)rE   rd   rA   rd   rB   rd   rZ   rd   rF   rl   r[   rd   r6   rd   r7   ri   r#   rf   rg   zSpan[SpeechSpanData])
rA   rd   r6   rd   r7   ri   r#   rf   rg   zSpan[SpeechGroupSpanData])r`   rd   ra   rh   r6   rd   r7   ri   r#   rf   rg   zSpan[MCPListToolsSpanData])1
__future__r   collections.abcr   r   typingr   r   r	   configr   setupr   r5   r   r   r   r   r   r   r   r   r   r   r   r   r   spansr   tracesr   openai.types.responsesr   r*   r$   r/   r9   r;   r?   rC   rH   rK   rO   rR   rU   rX   r\   r^   rb   r-   r+   r)   <module>rv      s   " - %  ! %     /
  &*$(--- - $	-
 "- - -`4
3 "&""'+ 
     	 
   %     J '+	
 % 	
 $ '+
  %	
  $ '+
  	
 %  D 1515-1#''+---.- - +	-
 !- - %- - -b !%'+	 % 	
 6 "'+  %	
  B #''+

  %	
  D '+
  %	
  : $-1'+))) ) 	)
 +) ) %) ) !)Z  %-1#''+((( ( 	(
 +( !( ( %( ( (X '+	 % 	
 6 #'+  %	
   r+   