+
    RiA                    (  a  0 t $ ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
 ]'       d   ^ RIHt ^ RIHt ^RIHt . ROt ! R	 R4      t]! R
]! 4       R7      tR]R
&   R R ltR R ltR R lt]R R l4       t]RR R ll4       t]R R l4       tR# )    )annotations)contextmanager)
ContextVar)TYPE_CHECKINGAny	Generator)Input)Output)Application
AppSessionc                  b    ] tR t^tRtRR R lltR R lt]R R l4       t]R	 R
 l4       t	Rt
R# )r   a-  
An AppSession is an interactive session, usually connected to one terminal.
Within one such session, interaction with many applications can happen, one
after the other.

The input/output device is not supposed to change during one session.

Warning: Always use the `create_app_session` function to create an
instance, so that it gets activated correctly.

:param input: Use this as a default input for all applications
    running in this session, unless an input is passed to the `Application`
    explicitly.
:param output: Use this as a default output.
Nc               $    V ^8  d   QhRRRRRR/# )   inputInput | NoneoutputOutput | NonereturnNone )formats   "a/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/prompt_toolkit/application/current.py__annotate__AppSession.__annotate__)   s$     1 1!12?1	1    c                	,    Wn         W n        R V n        R # N_input_outputapp)selfr   r   s   &&&r   __init__AppSession.__init__)   s      -1r   c                   V ^8  d   QhRR/# )r   r   strr   )r   s   "r   r   r   3   s     / /# /r   c                	$    R V P                   : R2# )zAppSession(app=))r!   )r"   s   &r   __repr__AppSession.__repr__3   s     A..r   c                   V ^8  d   QhRR/# )r   r   r	   r   )r   s   "r   r   r   7   s      u r   c                	Z    V P                   f   ^ RIHp V! 4       V n         V P                   # )Ncreate_input)r   prompt_toolkit.input.defaultsr.   )r"   r.   s   & r   r   AppSession.input6   s"    ;;B&.DK{{r   c                   V ^8  d   QhRR/# )r   r   r
   r   )r   s   "r   r   r   ?   s       r   c                	Z    V P                   f   ^ RIHp V! 4       V n         V P                   # )Ncreate_output)r    prompt_toolkit.output.defaultsr4   )r"   r4   s   & r   r   AppSession.output>   s"    <<D(?DL||r   r   NN)__name__
__module____qualname____firstlineno____doc__r#   r)   propertyr   r   __static_attributes__r   r   r   r   r      s9     1/    r   _current_app_session)defaultzContextVar[AppSession]c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   L   s     & & &r   c                 *    \         P                  4       # r   )r?   getr   r   r   get_app_sessionrD   L   s    ##%%r   c                   V ^8  d   QhRR/# )r   r   Application[Any]r   )r   s   "r   r   r   P   s      ! r   c                 x    \         P                  4       p V P                  e   V P                  # ^RIHp V! 4       # )a  
Get the current active (running) Application.
An :class:`.Application` is active during the
:meth:`.Application.run_async` call.

We assume that there can only be one :class:`.Application` active at the
same time. There is only one terminal window, with only one stdin and
stdout. This makes the code significantly easier than passing around the
:class:`.Application` everywhere.

If no :class:`.Application` is running, then return by default a
:class:`.DummyApplication`. For practical reasons, we prefer to not raise
an exception. This way, we don't have to check all over the place whether
an actual `Application` was returned.

(For applications like pymux where we can have more than one `Application`,
we'll use a work-around to handle that.)
)DummyApplication)r?   rC   r!   dummyrH   )sessionrH   s     r   get_apprK   P   s2    & #&&(G{{{{'r   c                   V ^8  d   QhRR/# )r   r   zApplication[Any] | Noner   )r   s   "r   r   r   l   s      0 r   c                 B    \         P                  4       p V P                  # )z^
Get the current active (running) Application, or return `None` if no
application is running.
r?   rC   r!   )rJ   s    r   get_app_or_nonerO   l   s    
 #&&(G;;r   c                    V ^8  d   QhRRRR/# )r   r!   rF   r   zGenerator[None, None, None]r   )r   s   "r   r   r   v   s     # #! #&A #r   c              #     "   \         P                  4       pVP                  pWn         Rx  W!n        R#   Y!n        i ; i5i)a  
Context manager that sets the given :class:`.Application` active in an
`AppSession`.

This should only be called by the `Application` itself.
The application will automatically be active while its running. If you want
the application to be active in other threads/coroutines, where that's not
the case, use `contextvars.copy_context()`, or use `Application.context` to
run it in the appropriate context.
NrN   )r!   rJ   previous_apps   &  r   set_apprS   u   s5      #&&(G;;LK#"ls   'A6 A>ANc               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   !Generator[AppSession, None, None]r   )r   s   "r   r   r      s$     * **(5*&*r   c              #    "   V f   \        4       P                  p Vf   \        4       P                  p\        WR7      p\        P                  V4      p Vx  \        P                  V4       R#   \        P                  T4       i ; i5i)z
Create a separate AppSession.

This is useful if there can be multiple individual ``AppSession``'s going
on. Like in the case of a Telnet/SSH server.
Nr   r   )rD   r   r    r   r?   setreset)r   r   rJ   tokens   &&  r   create_app_sessionr[      sp     $ }!((~ "** u4G $$W-E*""5)""5)s   AB
A0 B
0BB
c                   V ^8  d   QhRR/# )r   r   rU   r   )r   s   "r   r   r      s      %F r   c               #     "   ^ RI Hp  ^ RIHp V ! RR7      pV! RR7      p\	        W#R7      ;_uu_ 4       pVx  RRR4       R#   + '       g   i     R# ; i5i)am  
Create `AppSession` that always prefers the TTY input/output.

Even if `sys.stdin` and `sys.stdout` are connected to input/output pipes,
this will still use the terminal for interaction (because `sys.stderr` is
still connected to the terminal).

Usage::

    from prompt_toolkit.shortcuts import prompt

    with create_app_session_from_tty():
        prompt('>')
r-   r3   T)always_prefer_ttyrW   N)r/   r.   r5   r4   r[   )r.   r4   r   r   app_sessions        r   create_app_session_from_ttyr`      sB       ;<40ET2F	%	7	7; 
8	7	7	7s   3AA
AA		A)r   rD   rK   rO   rS   r[   r`   r7   )__conditional_annotations__
__future__r   
contextlibr   contextvarsr   typingr   r   r   prompt_toolkit.input.baser	   prompt_toolkit.output.baser
   applicationr   __all__r   r?   __annotations__rD   rK   rO   rS   r[   r`   )ra   s   @r   <module>rk      s    " " % " 0 0/1(, ,^ 0:JL0 , 
&8 # #* * *@  r   