+
    ^eòjÛ)  ã                  ó”  € R t ^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIHt ^ R	IHtHtHtHtHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt  R R ltRRRRRRRRRRRR/R R llt!RRRRRR/R R llt"RRRRRRRRRRRR/R R lltRRRRRR/R  R! llt]RRRRRRRRRRRRR"R/R# R$ ll4       t#. R%Ot$R# )&az  Scope stack operations.

Scopes define the hierarchy that tool calls, LLM calls, and mark events attach
to. They are the main way to model agents, tasks, and nested units of work.

Example::

    import nemo_relay

    with nemo_relay.scope.scope("demo-agent", nemo_relay.ScopeType.Agent) as handle:
        nemo_relay.scope.event("checkpoint", handle=handle, data={"step": 1})
)ÚannotationsN)Ú	Generator)Úcontextmanager)Údatetime)ÚSequence)Ú
DataSchemaÚJson)Úensure_scope_stack)ÚLogSeverityÚMetricMeasurementÚScopeAttributesÚScopeHandleÚ	ScopeType)Úevent)Ú
get_handle)Úmetric)Ú	pop_scope)Ú
push_scopec               ó   € V ^8„  d   QhRR/# )é   Úreturnr   © )Úformats   "Ú‡/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/nemo_relay/scope.pyÚ__annotate__r   1   s   € ÷  ñ  �Kñ  ó    c                 ó*   € \        4        \        4       # )a  Return the current top-of-stack ``ScopeHandle``.

Returns:
    ScopeHandle: The scope currently at the top of the active scope stack.

Notes:
    If the current Python context does not yet have a scope stack, one is
    created automatically before the handle lookup.
)Ú_ensure_scope_stackÚ_native_get_handler   r   r   r   r   1   s   € ô ÔÜÓÐr   ÚhandleÚ
attributesÚdataÚmetadataÚinputÚ	timestampc               ó<   € V ^8„  d   QhRRRRRRRRR	R
RR
RR
RRRR/	# )r   ÚnameÚstrÚ
scope_typer   r   úScopeHandle | Noner    úScopeAttributes | Noner!   úJson | Noner"   r#   r$   údatetime | Noner   r   r   )r   s   "r   r   r   ?   sb   € ÷ =ñ =Ø
ð=àð=ð ð	=ð
 'ð=ð ð=ð ð=ð ð=ð ð=ð ñ=r   c               ó<   € \        4        \        V VVVVVVVR7      # )a½  Push a new child scope and return its handle.

Args:
    name: Human-readable name for the new scope.
    scope_type: Semantic scope type, such as ``ScopeType.Agent`` or
        ``ScopeType.Function``.
    handle: Optional parent scope handle. When omitted, the current
        top-of-stack scope becomes the parent.
    attributes: Optional native scope attributes attached to the emitted
        start event.
    data: Optional JSON application payload stored on the scope handle.
    metadata: Optional JSON metadata recorded on the scope start event.
    input: Optional JSON payload exported as the semantic scope input.
    timestamp: Optional timezone-aware ``datetime`` recorded as the handle
        start time and on the scope start event. When omitted, the current
        runtime time is used.

Returns:
    ScopeHandle: Handle for the newly pushed scope.

Notes:
    A scope stack is created automatically if the current context does not
    yet have one. ``timestamp`` must be a timezone-aware ``datetime``;
    strings and naive datetimes are rejected.

Example::

    import nemo_relay

    with nemo_relay.scope.scope("parent", nemo_relay.ScopeType.Agent) as parent:
        handle = nemo_relay.scope.push(
            "worker",
            nemo_relay.ScopeType.Function,
            handle=parent,
            attributes=None,
            data={"step": 1},
            metadata={"source": "scope.push"},
        )
        nemo_relay.scope.pop(handle)
©r   r    r!   r"   r#   r$   )r   Ú_native_push_scope)r&   r(   r   r    r!   r"   r#   r$   s   &&$$$$$$r   Úpushr0   ?   s0   € ôf ÔÜØØØØØØØØô	ð 	r   Úoutputc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   r   r   r1   r+   r"   r$   r,   r   ÚNoner   )r   s   "r   r   r      s;   € ÷ Uñ UØðUØ$/ðUØBMðUØapðUà	ñUr   c               ó4   € \        4        \        WW#R7       R# )a	  Pop a scope previously returned by ``push()`` or ``scope()``.

Args:
    handle: Scope handle to close.
    output: Optional JSON payload exported as the semantic scope output.
    metadata: Optional JSON metadata to append to the metadata set when the scope was created.
    timestamp: Optional timezone-aware ``datetime`` recorded on the scope
        end event. When omitted, the runtime default end timestamp is used.

Returns:
    None: This function returns after the scope is closed successfully.

Notes:
    The handle must correspond to an active scope in the current scope
    stack. Popping a scope also removes any scope-local registrations owned
    by that scope. ``timestamp`` must be a timezone-aware ``datetime``;
    strings and naive datetimes are rejected.
)r1   r"   r$   N)r   Ú_native_pop_scope)r   r1   r"   r$   s   &$$$r   Úpopr6      s   € ô* ÔÜ�f°h×Tr   Údata_schemaÚseverityc               ó8   € 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+   r7   zDataSchema | Noner"   r8   zLogSeverity | Noner$   r,   r   r3   r   )r   s   "r   r   r   ˜   sZ   € ÷ )ñ )Ø
ð)ð ð)ð ð	)ð
 #ð)ð ð)ð !ð)ð ð)ð 
ñ)r   c          
     ó>   € \        4        \        V VVVVVVR7       R# )a¾  Emit a ``Mark`` event under the current or provided scope.

Args:
    name: Event name to emit.
    handle: Optional scope handle that should own the event. When omitted,
        the current top-of-stack scope is used.
    data: Optional JSON payload attached to the event.
    data_schema: Optional name and version identifying the ``data`` schema.
    metadata: Optional JSON metadata attached to the event.
    severity: Optional typed severity used when the mark is exported as a log.
    timestamp: Optional timezone-aware ``datetime`` recorded on the mark
        event. When omitted, the current runtime time is used.

Returns:
    None: This function returns after the event has been queued for
    sanitization and publication.

Notes:
    A scope stack is created automatically when needed before the event is
    queued through the native runtime. ``timestamp`` must be a
    timezone-aware ``datetime``; strings and naive datetimes are rejected.
)r   r!   r7   r"   r8   r$   N)r   Ú_native_event)r&   r   r!   r7   r"   r8   r$   s   &$$$$$$r   r   r   ˜   s(   € ô@ ÔÜØØØØØØØ÷r   c               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# )r   r&   r'   ÚmeasurementszSequence[MetricMeasurement]r   r)   r"   r+   r$   r,   r   r3   r   )r   s   "r   r   r   Ä   sL   € ÷ dñ dØ
ðdà-ðdð ð	dð
 ðdð ðdð 
ñdr   c               óJ   € \        4        \        V \        V4      W#VR7       R# )a5  Emit a validated group of OpenTelemetry metric recording operations.

Args:
    name: Mark name that groups the measurements atomically.
    measurements: Typed measurements to record.
    handle: Optional parent scope. The current scope is used when omitted.
    metadata: Optional JSON metadata attached to the metric mark.
    timestamp: Optional timezone-aware timestamp for the metric mark.

Returns:
    None: This function returns after the metric mark has been queued.

Raises:
    ValueError: If any measurement is invalid; the complete group is rejected.
)r   r"   r$   N)r   Ú_native_metricÚlist)r&   r=   r   r"   r$   s   &&$$$r   r   r   Ä   s   € ô. ÔÜ�4œ˜lÓ+°FÐYb×cr   Úend_timestampc               ó@   € 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,   rA   r   zGenerator[ScopeHandle]r   )r   s   "r   r   r   à   s„   € ÷ YKñ YKØ
ðYKàðYKð ð	YKð
 'ðYKð ðYKð ðYKð ðYKð ðYKð #ðYKð ñYKr   c             #  óŠ  "  € \        4        Rp	Rp
Rp \        V VVVVVVVR7      p	V	x € Rp
 T	e   RT
/pTe   YµR&   \        Y•TR	7       R# R#   \        P                   d   pRp
\	        T4      ;'       g    Rph Rp?i\
         d   pRp
\	        T4      ph Rp?ii ; i  T	e   RT
/pTe   YµR&   \        Y•TR	7       i i ; i5i)
a¶  Create a scope for the duration of a ``with`` block.

OTEL status codes will be automatically recorded in the scope's metadata.

Args:
    name: Human-readable name for the new scope.
    scope_type: Semantic scope type, such as ``ScopeType.Agent`` or
        ``ScopeType.Function``.
    handle: Optional parent scope handle. When omitted, the current
        top-of-stack scope becomes the parent.
    attributes: Optional native scope attributes attached to the emitted
        start event.
    data: Optional JSON application payload stored on the scope handle.
    metadata: Optional JSON metadata recorded on the scope start event.
    input: Optional JSON payload exported as the semantic scope input.
    timestamp: Optional timezone-aware ``datetime`` recorded as the handle
        start time and on the scope start event.
    end_timestamp: Optional timezone-aware ``datetime`` recorded on the
        scope end event.

Yields:
    ScopeHandle: Handle for the scope that remains active inside the
    ``with`` block.

Returns:
    Iterator[ScopeHandle]: Context-manager iterator that closes the scope
    when the ``with`` block exits.

Notes:
    The scope is always popped when the ``with`` block exits, even if the
    body raises an exception. Timestamp arguments must be timezone-aware
    ``datetime`` objects; strings and naive datetimes are rejected.

Example::

    import nemo_relay

    with nemo_relay.scope.scope(
        "demo",
        nemo_relay.ScopeType.Agent,
        handle=None,
        attributes=None,
        data={"stage": "start"},
        metadata={"owner": "docs"},
    ) as handle:
        nemo_relay.scope.event("inside", handle=handle, data={"ok": True}, metadata={"step": 1})
NÚUNSETr.   ÚOKÚERRORÚ	cancelledzotel.status_codezotel.status_description)r"   r$   )r   r/   ÚasyncioÚCancelledErrorr'   Ú	Exceptionr6   )r&   r(   r   r    r!   r"   r#   r$   rA   Úpushed_handleÚstatus_codeÚstatus_messageÚes   &&$$$$$$$    r   ÚscoperO   ß   sý   é € ôx ÔØ€MØ€KØ€NðKÜ*ØØØØ!ØØØØô	
ˆð ÒØ‰ð Ò$Ø*¨KÐ8ˆHØÒ)Ø6DÐ2Ñ3Ü�¸M×Jñ	 %øô ×!Ñ!ô ØˆÜ˜Q›×.Ð. ;ˆØûÜô ØˆÜ˜Q›ˆØûðûð
 Ò$Ø*¨KÐ8ˆHØÒ)Ø6DÐ2Ñ3Ü�¸MÖJð	 %üsE   ‚C”A ®!CÁBÁ$A<Á<BÂ	BÂ
BÂBÂB  Â  C Ã C)r   r   r   r6   r0   rO   )%Ú__doc__Ú
__future__r   rH   Úcollections.abcr   Ú
contextlibr   r   Útypingr   Ú
nemo_relayr   r   Únemo_relay._contextr	   r   Únemo_relay._nativer
   r   r   r   r   r   r;   r   r   r   r?   r   r5   r   r/   r0   r6   rO   Ú__all__r   r   r   Ú<module>rY      s�  ðñõ #ã Ý %Ý %Ý Ý ç 'Ý I÷õ õõõ 8õõõ
 ð=ð "&ð	=ð
 *.ð=ð ð=ð !ð=ð ð=ð "&÷=ð@UØ26ðUØPTðUØsw÷Uð2)ð "&ð)ð ð	)ð
 &*ð)ð !ð)ð $(ð)ð "&÷)ðXdð "&ð	dð
 !ðdð "&÷dð6 ðYKð "&ð	YKð
 *.ðYKð ðYKð !ðYKð ðYKð "&ðYKð &*öYKó ðYKòx D‚r   