+
    .pÐjyŠ  ã                  ó`  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHtH	t	H
t
 ^ RIHtHt ^ RIHt ]P                   ! R4      tRt^
tRt^t^tRtRtR	]R
&   R R ltR R ltR R ltR tR R ltR R ltR R lt R R lt!R R lt"R R lt#R R lt$R  R! lt%R" R# lt&R$ R% lt'R& R' lt(R( R) lt)R* R+ lt*R, R- lt+R. R/ lt,R0 R1 lt-R2 R3 lt.RHR4 R5 llt/R6 t0]1! 0 RIm4      t2]1! 0 RJm4      t3R7 R8 lt4R9 R: lt5R; R< lt6R= R> lt7R? R@ lt8RA RB lt9RKt:]1! 0 RLm4      t;RC RD lt<RER/RF RG llt=R# )MzUDelegation config knobs (delegation.* keys) and child credential/provider resolution.)ÚannotationsN)ÚAnyÚDictÚListÚOptional)Úbase_url_hostnameÚis_truthy_value)Úscoped_fallback_chainztools.delegate_toolÚcustomFúOptional[float]ÚDEFAULT_CHILD_TIMEOUTc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚdict© )Úformats   "Ú)/opt/hermes/tools/delegate_tool_config.pyÚ__annotate__r      s   € ÷ ñ ˆdñ ó    c                 ó   € ^ RI Hp  V ! 4       # )zJThe ``delegation`` section, read through the origin so tests can patch it.©Ú_load_config)Útools.delegate_toolr   r   s    r   Ú_cfgr      s   € å0Ù‹>Ðr   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   ÚcommandÚstrÚdescriptionr   r   )r   s   "r   r   r   *   s!   € ÷ ñ  ð °3ð ÀSñ r   c                ó2   € \         P                  RW4       R# )zQAuto-deny (safe default): returns 'deny' so the child sees a recoverable refusal.zeSubagent auto-denied dangerous command: %s (%s). Set delegation.subagent_auto_approve: true to allow.Údeny©ÚloggerÚwarning©r   r    Úkwargss   &&,r   Ú_subagent_auto_denyr(   *   s   € ä
‡N�NØoØôñ r   c               ó$   € V ^8„  d   QhRRRRRR/# r   r   )r   s   "r   r   r   2   s!   € ÷ ñ  Cð °cð Èñ r   c                ó2   € \         P                  RW4       R# )zPAuto-approve (opt-in YOLO via delegation.subagent_auto_approve): returns 'once'.z1Subagent auto-approved dangerous command: %s (%s)Úoncer#   r&   s   &&,r   Ú_subagent_auto_approver,   2   s   € ä
‡N�NÐFÈÔ]Ùr   c                 ól   € \        \        4       P                  RR4      4      '       d   \        # \        # )zZCallback for subagent worker threads per delegation.subagent_auto_approve (default False).Úsubagent_auto_approveF)r   r   Úgetr,   r(   r   r   r   Ú_get_subagent_approval_callbackr0   7   s'   € ä”t“v—z‘zÐ"9¸5ÓA×BÒBÜ%Ð%ÜÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úkeyr   Úenv_varúOptional[str]Úinvalid_msgr   )r   s   "r   r   r   =   s!   € ÷ ñ ˆsð ˜]ð Èñ r   c                ó@  € \        4       P                  V 4      pVe
    V! V4      # V'       d   \        P                  ! V4      MRpV'       d
    V! V4      # V#   \        \        3 d    \        P                  YE4       Tu # i ; i  \        \        3 d     T# i ; i)zºdelegation.<key> > <env_var> > default. A config value that fails ``parse`` logs ``invalid_msg`` (``%r`` = the
value) and yields the default; an env value that fails is silently ignored.N)r   r/   Ú	TypeErrorÚ
ValueErrorr$   r%   ÚosÚgetenv)r2   r3   ÚparseÚdefaultr5   ÚvalÚenv_vals   &&&&&  r   Ú_knobr?   =   s˜   € ô ‹&�*‰*�S‹/€CØ
‚ð	Ù˜“:Ð÷ %,Œb�iŠi˜Ô °€Gßð	Ù˜“>Ð!ð €Nøô œ:Ð&ô 	Ü�N‰N˜;Ô,ØŠNð	ûô œ:Ð&ô 	ØØ€Nð	ús#   ŸA ÁB Á(BÂBÂBÂBc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	flag_namer   ÚmessageÚargsr   r   ÚNoner   )r   s   "r   r   r   O   s(   € ÷ 'ñ '˜#ð '¨ð '°Cð '¸Dñ 'r   c                ó‚   € \        4       V ,          '       g(   R\        4       V &   \        P                  ! V.VO5!   R# R# )zKModule-global one-shot warning (``flag_name`` is the ``_*_WARNED`` global).TN)Úglobalsr$   r%   )rA   rB   rC   s   &&*r   Ú
_warn_oncerG   O   s1   € ä‹9�Y×ÔØ#Œ‹	�)ÑÜ�Š�wÐ& Ö&ñ  r   c               ó   € V ^8„  d   QhRR/# ©r   r   Úintr   )r   s   "r   r   r   U   s   € ÷ ñ  3ñ r   c                 ó"   € \        RRR ^R4      # )z\delegation.oneshot_max_children (total children per finite one-shot session; 0 = unlimited).Úoneshot_max_childrenNc                ó,   € \        ^ \        V 4      4      # )é    ©ÚmaxrJ   ©Úvs   &r   Ú<lambda>Ú+_get_oneshot_max_children.<locals>.<lambda>X   s   € ´°A´s¸1³v´r   zJdelegation.oneshot_max_children=%r is not a valid integer; using default 2)r?   r   r   r   Ú_get_oneshot_max_childrenrU   U   s   € äØ Ñ&>ÀØTóð r   c               ó   € V ^8„  d   QhRR/# rI   r   )r   s   "r   r   r   ]   s   € ÷ ñ  cñ r   c                 óš   € \        RRR \        R\         24      p V ^
8”  d)   \        4       P                  R4      e   \	        RRV 4       V # )z�delegation.max_concurrent_children > DELEGATION_MAX_CONCURRENT_CHILDREN env > 10.

Floor of 1 is the only bound enforced; there is no ceiling.
Úmax_concurrent_childrenÚ"DELEGATION_MAX_CONCURRENT_CHILDRENc                ó,   € \        ^\        V 4      4      # )é   rO   rQ   s   &r   rS   Ú._get_max_concurrent_children.<locals>.<lambda>c   s   € ÔSVÐWXÔZ]Ð^_ÓZ`ÔSar   zLdelegation.max_concurrent_children=%r is not a valid integer; using default Ú_HIGH_CONCURRENCY_WARNEDzxdelegation.max_concurrent_children=%d: each child consumes API tokens independently. High values multiply cost linearly.)r?   Ú _DEFAULT_MAX_CONCURRENT_CHILDRENr   r/   rG   )Úresults    r   Ú_get_max_concurrent_childrenr`   ]   s[   € ô
 Ø!Ð#GÑIaÜ(Ø
VÔWwÐVxÐyó€Fð
 �„{”t“v—z‘zÐ";Ó<ÒHÜØ&ð )AØBHô	
ð €Mr   c               ó   € V ^8„  d   QhRR/# ©r   r   Úboolr   )r   s   "r   r   r   n   s   € ÷ Iñ I dñ Ir   c                 óH   € \        \        4       P                  RR4      4      # )z×delegation.independent_completions (bool, default False): split a background call into per-task / per-group
completion messages that land as each finishes. Off = one consolidated message when the whole call is done.Úindependent_completionsF©r   r   r/   r   r   r   Ú_get_independent_completionsrg   n   s   € ô œ4›6Ÿ:™:Ð&?ÀÓGÓHÐHr   c               ó   € V ^8„  d   QhRR/# rb   r   )r   s   "r   r   r   s   s   € ÷ 9ñ 9 ñ 9r   c                 óH   € \        \        4       P                  RR4      4      # )zådelegation.worktree_isolation (bool, default False): each child gets its own
git worktree off the parent's HEAD so parallel children never contend for one
working copy. Git-only and local-backend-only; otherwise silently ignored.Úworktree_isolationF)rc   r   r/   r   r   r   Ú_get_worktree_isolationrk   s   s   € ô ”“—
‘
Ð/°Ó7Ó8Ð8r   c               ó   € V ^8„  d   QhRR/# rI   r   )r   s   "r   r   r   y   s   € ÷ *ñ * ñ *r   c                 ój   € ^ RI Hp  \        4       P                  R4      e   \	        RR4       V ! 4       # )a@  Concurrency cap for background delegations == delegation.max_concurrent_children. At capacity a new async
dispatch is REJECTED (not queued) so a runaway model can't pile up unbounded background work; the caller then
runs synchronously. A leftover ``delegation.max_async_children`` key is ignored with a one-time warning.©r`   Úmax_async_childrenÚ_LEGACY_MAX_ASYNC_WARNEDz§delegation.max_async_children is deprecated and ignored; delegation.max_concurrent_children now caps background delegations too. Remove the stale key from config.yaml.)r   r`   r   r/   rG   rn   s    r   Ú_get_max_async_childrenrq   y   s6   € õ AÜƒv‡z�zÐ&Ó'Ò3ÜØ&ð )Fô	
ñ
 (Ó)Ð)r   c               ó    € V ^8„  d   QhRRRR/# )r   Úrawr   r   r   r   )r   s   "r   r   r   †   s   € ÷ 6ñ 6˜ð 6 ñ 6r   c                óB   € \        V 4      pV^ 8:  d   R# \        RV4      # )uJ   Seconds â†’ None (<= 0 disables) or max(30, value). Raises on non-numeric.Ng      >@)ÚfloatrP   )rs   Úparseds   & r   Ú_parse_timeoutrw   †   s#   € ä�3‹Z€FØ˜Q”;ˆ4Ð5¤C¨¨fÓ$5Ð5r   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   ‹   s   € ÷ 
ñ 
˜Oñ 
r   c                 ó0   € \        RR\        \        R4      # )u…  Inactivity cap for one child (seconds of NO progress), or None (default: no cap). Failures should come from
what the child does (API/tool errors, iteration budget), not a stopwatch: the cap restarts on every sign of
progress â€” a completed call, a tool change, an activity-clock tick â€” so a slow provider serving multi-minute
completions never loses a live child, and a child frozen for the whole window is still caught. A configured
value pre-empts nothing the heartbeat staleness monitor would not also catch. delegation.child_timeout_seconds
> 0 opts in (floor 30 s); 0 or negative disables. Env fallback: DELEGATION_CHILD_TIMEOUT_SECONDS.Úchild_timeout_secondsÚ DELEGATION_CHILD_TIMEOUT_SECONDSzUdelegation.child_timeout_seconds=%r is not a valid number; using default (no timeout))r?   rw   r   r   r   r   Ú_get_child_timeoutr|   ‹   s   € ô ØÐ!CÄ^ÔUjØ_óð r   c               ó   € V ^8„  d   QhRR/# rI   r   )r   s   "r   r   r   —   s   € ÷ ñ ˜cñ r   c                 ó<   € R p \        RRV \        R\         24      # )zÃdelegation.max_spawn_depth floored at 1 (no ceiling). Depth 0 is the parent; agents at depths 0..N-1 may spawn,
depth N is the leaf floor. Default 1 is flat. Each extra level multiplies API cost.c                óŽ   € \        V 4      pV\        8  d!   \        P                  R V\        \        4       \	        \        V4      # )z6delegation.max_spawn_depth=%d below floor %d; using %d)rJ   Ú_MIN_SPAWN_DEPTHr$   r%   rP   )rR   Úivals   & r   Ú_flooredÚ&_get_max_spawn_depth.<locals>._flooredš   s8   € Ü�1‹vˆØÔ"Ô"Ü�N‰NÐSÐUYÔ[kÔm}Ô~ÜÔ# TÓ*Ð*r   Úmax_spawn_depthNzDdelegation.max_spawn_depth=%r is not a valid integer; using default )r?   Ú	MAX_DEPTH)r‚   s    r   Ú_get_max_spawn_depthr†   —   s)   € ò+ô Ø˜4 ¬9Ø
NÌyÈkÐZóð r   c               ó   € V ^8„  d   QhRR/# rb   r   )r   s   "r   r   r   ¥   s   € ÷ ñ  4ñ r   c                 óØ   € \        4       P                  RR4      p \        V \        4      '       d   V # \        V \        4      '       d"   V P                  4       P                  4       R9   # R# )z]delegation.orchestrator_enabled kill switch (default True): False forces every child to leaf.Úorchestrator_enabledT>   Ú1ÚonÚyesÚtrue)r   r/   Ú
isinstancerc   r   ÚstripÚlower)r=   s    r   Ú_get_orchestrator_enabledr‘   ¥   sR   € ä
‹&�*‰*Ð+¨TÓ
2€CÜ�#”t×ÒØˆ
ä�#”s×ÒØ�y‰y‹{× Ñ Ó"Ð&@Ñ@Ð@Ùr   c               ó   € V ^8„  d   QhRR/# rb   r   )r   s   "r   r   r   ¯   s   € ÷ Mñ M 4ñ Mr   c                 óJ   € \        \        4       P                  R4      RR7      # )zFWhether narrowed child toolsets should keep the parent's MCP toolsets.Úinherit_mcp_toolsetsT)r<   rf   r   r   r   Ú_get_inherit_mcp_toolsetsr•   ¯   s   € äœ4›6Ÿ:™:Ð&<Ó=ÀtÔLÐLr   c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluer   r   r   r   )r   s   "r   r   r   ³   s   € ÷ 0ñ 0 3ð 0¨3ñ 0r   c                óf   € \        T ;'       g    R 4      P                  4       P                  R4      # )Ú Ú/)r   r�   Úrstrip)r—   s   &r   Ú_normalized_runtime_urlrœ   ³   s'   € Üˆu�{ˆ{˜Ó×!Ñ!Ó#×*Ñ*¨3Ó/Ð/r   c               ó   € V ^8„  d   QhRR/# )r   r   zOptional[dict]r   )r   s   "r   r   r   ¶   s   € ÷ rñ rÐXfñ rr   c                ó$  € V'       g	   V'       d   R# \        V RR4      p\        V\        4      '       g   R# VP                  4        UUu/ uF7  w  rE\        V\        4      '       g   K  \        V\
        4      '       g   K5  WEbK9  	  upp# u uppi )a5  Parent's endpoint-trust capability map for a child, or None. ``agent.capabilities`` is a trust decision scoped
to one provider+endpoint: inherited ONLY when the child runs the parent's exact route; any provider or base_url
override stays DEFAULT-DENY (matches the /model switch posture).

See #94036, #97292.
NÚcapabilities)ÚgetattrrŽ   r   Úitemsr   rc   )Úparent_agentÚoverride_providerÚoverride_base_urlÚparent_capsr2   r—   s   &&&   r   Ú_inherit_parent_capabilitiesr¦   ¶   sl   € ÷ ×-ÙÜ˜,¨¸Ó=€KÜ�k¤4×(Ò(ÙØ)4×):Ñ):Ô)<ÔqÑ)<™:˜3Ä
È3ÔPS×@TŒJÔYcÐdiÔko×YpŒJˆCŠJÑ)<ÒqÐqùÓqs   ÁBÁ*BÂBc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úsurface_base_urlr4   Úsurface_api_keyr   r   Útupler   )r   s   "r   r   r   Ä   s#   € ÷ 7ñ 7¸]ð 7Ð]`ð 7Ðejñ 7r   c                ó’  € \        V RR4      p\        V RR4      p\        V\        4      '       d#   VP                  R4      VP                  R4      3MRVe   \        VRR4      \        VRR4      3MR3pV F@  w  rg\	        V4      pV'       g   K  VP                  R4      '       g   K3  Y‡;'       g    T3u # 	  T;'       g    RV3# )	uO  ``(base_url, api_key)`` the parent is actually calling, taken from ONE source. ``parent_agent.base_url`` /
``api_key`` can lag the live client (old OpenRouter URL vs local Ollama; a fallback runtime the surface attributes
have not caught up with), and pairing the live endpoint with the surface key hands the child a (base_url, key)
pair that was never valid anywhere â€” an instant, non-retryable 401 (#90009). The live client's key travels with
its URL; the surface attributes are used only when there is no live OpenAI-wire client (native Anthropic/Bedrock
runtimes keep ``client=None``).Ú_client_kwargsNÚclientÚbase_urlÚapi_keyr™   ©NN)zhttp://zhttps://)r    rŽ   r   r/   rœ   Ú
startswith)	r¢   r¨   r©   Úclient_kwargsr­   Úlive_candidatesÚraw_urlÚlive_keyÚurls	   &&&      r   Ú_inherit_parent_endpointr·   Ä   sÌ   € ô ˜LÐ*:¸DÓA€MÜ�\ 8¨TÓ2€FäISÐTaÔcg×IhÒIhˆ×	Ñ	˜:Ó	&¨×(9Ñ(9¸)Ó(DÑEÐnzàOUÒOaŒ�˜ RÓ	(¬'°&¸)ÀTÓ*JÑKÐgsð€Oó
 -ÑˆÜ% gÓ.ˆß‰3�3—>‘>Ð"9×:Ô:Ø×4Ð4 _Ð5Ò5ñ -ð ×$Ð$  Ð6Ð6r   c               ó   € V ^8„  d   QhRR/# )r   r2   r   r   )r   s   "r   r   r   Ø   s   € ÷ Iñ I�cñ Ir   c                óZ   € ^ RI Hp V! V 4      pVe   VP                  4       '       d   V# R# )z8``load_pool(key)`` when it holds credentials, else None.)Ú	load_poolN)Úagent.credential_poolrº   Úhas_credentials)r2   rº   Úpools   &  r   Ú_loaded_poolr¾   Ø   s,   € å/Ù�S‹>€DØÒ#¨×(<Ñ(<×(>Ò(>ˆ4ÐHÀDÐHr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r½   r   Úproviderr4   r®   r   rc   r   )r   s   "r   r   r   Þ   s/   € ÷ nñ n ð n¨}ð nÈð nÐZ^ñ nr   c                ó:  aa€ ^ RI HoHp V! WSR7      '       g   R# \        V RR4      p\	        V4      '       g   R# V! 4       p\        V\        4      '       * ;'       g=    \        ;QJ d     VV3R lV 4       F  '       g   K   R# 	  R# ! VV3R lV 4       4      # )zeProvider identity AND at least one entry for the child's endpoint; pools without entry metadata pass.)Ú%credential_pool_entry_serves_endpointÚ credential_pool_matches_provider)r®   FÚentriesNTc              3  ó6   <"  € T F  pS! VS4      x € K  	  R # 5i)Nr   )Ú.0ÚentryÚ_entry_serves_endpointr®   s   & €€r   Ú	<genexpr>Ú(_pool_serves_endpoint.<locals>.<genexpr>é   s   øé € Ð/mÑelÐ\aÑ0FÀuÈh×0WÐ0WÓelùs   ƒ)r»   rÂ   rÃ   r    ÚcallablerŽ   ÚlistÚany)r½   rÀ   r®   rÃ   Ú
entries_fnrÄ   rÈ   s   &&f   @r   Ú_pool_serves_endpointrÏ   Þ   sz   ù€ ÷ñ ,¨DÀX×NÓNÙÜ˜˜y¨$Ó/€JÜ�J×ÒÙÙ‹l€GÜ˜'¤4Ó(Ô(×mÐm¯C«CÕ/mÑelÓ/m¯C¬CÐmªCÐm¨CÕ/mÑelÓ/mÓ,mÐmr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úeffective_providerr4   Úeffective_base_urlÚeffective_requested_providerr   )r   s   "r   r   r   ë   s$   € ÷ 7ñ 7Ø%ð7ØIVð7à"/ñ7r   c                ó–  € \        VRR4      pV '       g   V# \        VRR4      ;'       g    Rp V R8X  dX   ^ RIHp V! W#R7      pVf   R# V! \        VRR4      \        VR	R4      R7      pVe   VR8X  d   Ve	   W‡8X  d   V# \        V4      # W8X  d9   Vf   R# V'       d   \	        W@V4      '       d   V# \
        P                  R
W4       \        V 4      p	V	e   V'       d   \	        W�V4      '       g   R# V	#   \         dE   p
T R8X  d   \
        P                  RY*4        Rp
?
R# \
        P                  RY
4        Rp
?
R# Rp
?
ii ; i)uÍ  Credential pool for the child: parent's pool (same provider), that provider's own pool, or None (child keeps
its fixed credential). Custom endpoints all collapse to ``provider="custom"``, so they are matched by endpoint
identity (the ``custom:<name>`` pool key) â€” sharing the parent's pool across different custom endpoints would
overwrite the child's delegated base_url on lease; an unregistered custom endpoint (no custom_providers entry)
keeps the child's fixed credential rather than inherit the parent's.

Custom endpoints are a special case: every direct ``delegation.base_url`` runtime collapses to
``provider="custom"``, so bare provider equality would treat two *different* custom endpoints as
interchangeable and let the child inherit the parent's pool. We therefore resolve custom runtimes by
endpoint identity (the ``custom:<name>`` pool key derived from the base_url) and only share the parent's
pool when both resolve to the *same* custom endpoint. See #7833.

Named custom providers may share one gateway URL with different credentials, so the inherited
``requested_provider`` identity takes precedence over URL-only matching (#45763): the child must not
lease the first pool registered for the shared endpoint.
Ú_credential_poolNrÀ   r™   r
   )Úget_custom_provider_pool_key)Úprovider_namer®   Úrequested_providerzAParent %s pool has no entry for child endpoint %s; not sharing itzDCould not resolve custom credential pool for child endpoint '%s': %sz:Could not load credential pool for child provider '%s': %s)r    r»   rÖ   r¾   rÏ   r$   ÚdebugÚ	Exception)rÑ   r¢   rÒ   rÓ   Úparent_poolÚparent_providerrÖ   Ú	child_keyÚ
parent_keyr½   Úexcs   &&&&       r   Ú_resolve_child_credential_poolrà   ë   sU  € ô( ˜,Ð(:¸DÓA€KßØÐÜ˜l¨J¸Ó=×CÐCÀ€OðpØ Ô)ÝJÙ4Ð5GÔtˆIØÒ ÙÙ5Ü˜ j°$Ó7ÄwÈ|Ð]qÐswÓGxôˆJð Ò&¨?¸hÔ+FÈ:ÒKaÐfpÔf}Ø"Ð"Ü 	Ó*Ð*ØÔ0ð Ò"Ùß%Ô)>¸{Ð`r×)sÒ)sØ"Ð"Ü�L‰LÐ\Ø+ôAäÐ.Ó/ˆØÒ× 2Ô;PÐQUÐk}×;~Ò;~ÙØˆøÜô pØ Ô)Ü�L‰LÐ_Ðas×yÐyñ ô �L‰LÐUÐWi×oÐoÙûðpúsM   °C9 Á6C9 Â
C9 Â
C9 ÂC9 Â"C9 Â6,C9 Ã#C9 Ã7C9 Ã9EÄEÄ'EÅEc                ó  € ^ RI p\        V \        4      '       d   T MRp \        V\        4      '       d   TMRpV '       g   V'       g   R# V '       d   VP                  V 4      M/ pV'       d   VP                  V4      M/ pVP	                  R4      pVP                  RR4      pVP                  V4       \        V\        4      '       d-   \        V\        4      '       d   VP                  V4       WSR&   MVe   WcR&   T;'       g    R# )aƒ  Merge explicit ``delegation.request_overrides`` OVER runtime-derived ones. Explicit top-level keys win;
``extra_body`` is deep-merged ONE level so provider personality (e.g. ``thinking: {type: disabled}``) survives
unless the explicit dict redefines that exact key. Both sides are deep-copied so transport-side mutation can't
leak into the config/runtime cache. None when both are empty.NÚ
extra_body)ÚcopyrŽ   r   Údeepcopyr/   ÚpopÚupdate)Úruntime_overridesÚexplicit_overridesÚ_copyÚmergedÚexplicitÚruntime_extraÚexplicit_extras   &&     r   Ú_merge_request_overridesrî   $  s×   € ó
 Ü-7Ð8IÌ4×-PÒ-PÑ)ÐVZÐÜ/9Ð:LÌd×/SÒ/SÑ+ÐY]Ðß×%7Ùß2CˆU�^‰^Ð-Ô.È€Fß5Gˆu�~‰~Ð0Ô1ÈR€HØ—J‘J˜|Ó,€MØ—\‘\ ,°Ó5€NØ
‡M�M�(ÔÜ�-¤×&Ò&¬:°nÄd×+KÒ+KØ×Ñ˜^Ô,Ø,ˆ|ÒØ	Ò	#Ø-ˆ|ÑØ�>ˆ>�TÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r4   rB   r   r   rD   r   )r   s   "r   r   r   ?  s!   € ÷ "ñ " ]ð "¸Sð "ÀTñ "r   c                óf   € ^ RI pV '       d%   VP                  V 4      '       g   \        V4      hR# R# )u†   A pinned ACP transport command must exist on PATH â€” refuse loudly rather
than let the child silently fall back to another transport.N)ÚshutilÚwhichr8   )r   rB   Ú_shutils   && r   Ú_require_pinned_commandrô   ?  s*   € ó ß�w—}‘} W×-Ò-Ü˜Ó!Ð!ñ .�wr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   F  s   € ÷ ñ Ðdhñ r   c                ó"   € RV RVRVRVRVRV/VC# )zVThe child credential dict every branch of ``_resolve_delegation_credentials`` returns.ÚmodelrÀ   r®   r¯   Úapi_modeÚrequest_overridesr   )r÷   rÀ   r®   r¯   rø   rù   Úextras   &&&&&&,r   Ú_credential_bundlerû   F  s3   € ð 	�˜
 H¨j¸(ÀIÈwÐXbÐdlØÐ.ðà27ðð r   c               ó    € V ^8„  d   QhRRRR/# ©r   rR   r   r   r   )r   s   "r   r   r   M  s   € ÷ (ñ ( Dð (Èñ (r   c                óê  € ^ RI Hp V R,          P                  4       p\        V R,          4      pRpV! V R,          4      ;'       g    RpVR8X  d   RV9   d   RRreMVR	8X  d   R
RreM	RV9   d   Rp^ RIHp V R,          \        9   g#   V R,          '       d   V R,          V! 4       9   d
   V R,          pRpV R,          '       dN    ^ RI Hp	 V	! V R,          V R,          R7      p
\        V
P                  R4      ;'       g    / 4      ;'       g    Rp\        V R,          WPR,          V R,          V\        W�4      4      #   \         d)   p\        P                  RT R,          T4        Rp?L[Rp?ii ; i)zF``delegation.base_url`` branch: provider/api_mode from URL heuristics.)Ú_detect_api_mode_for_urlr®   r
   Úchat_completionszchatgpt.comz/backend-api/codexzopenai-codexÚcodex_responseszapi.anthropic.comÚ	anthropicÚanthropic_messageszapi.kimi.com/coding)Úregistered_api_modesrø   NrÀ   ©Úresolve_runtime_providerr÷   ©Ú	requestedÚtarget_modelrù   zjdelegation.base_url: runtime resolution for provider '%s' failed; proceeding without request_overrides: %sr¯   )Úhermes_cli.runtime_providerrÿ   r�   r   Úagent.transportsr  Ú_EXPLICIT_API_MODESr  r   r/   rÚ   r$   rÙ   rû   rî   )rR   Úexplicit_request_overridesrÿ   Ú
base_lowerÚhostrÀ   rø   r  rù   r  Úruntimerß   s   &&          r   Ú_direct_endpoint_credentialsr  M  s^  € õ EØ�:•×$Ñ$Ó&€JÜ˜Q˜z�]Ó+€DØ€HÙ'¨¨*­Ó6×LÐLÐ:L€HØˆ}ÔÐ!5¸Ô!CØ+Ð->‘(Ø	Ð$Ô	$Ø(Ð*>‘(Ø	 *Ô	,Ø'ˆõ 6Øˆ…}Ô+Ô+°°*·´À!ÀJÅ-ÑSgÓSiÔBiØ�Z•=ˆð ÐØˆ‡}„}ð		ÝLÙ.¸¸:½ÐUVÐW^ÕU_Ô`ˆGÜ $ W§[¡[Ð1DÓ%E×%KÐ%KÈÓ L× TÐ TÐPTÐô Ø	ˆ'�
�H 
�m¨Q¨y­\¸8Ü Ð!2ÓOóð øô ô 	Ü�L‰LØ|Ø�*•˜s÷ñ ûð	ús$   Ã:D? ÄD? ÄD? Ä?E2Å
E-Å-E2c               ó    € V ^8„  d   QhRRRR/# rý   r   )r   s   "r   r   r   w  s   € ÷ ,ñ , Tð ,È$ñ ,r   c                óf  € V R,          p ^ RI Hp V! W R,          R7      pTP	                  R	R
4      pT'       g   \        RT R24      hTP	                  R4      p\        TRT RT R24       TP	                  R4      '       g?   T'       g7   TP                  4       P                  4       \        9  d   \        RT R24      h\        T R,          ;'       g    TP	                  R4      ;'       g    RTP	                  R4      \        8X  d   TMTP	                  R4      TP	                  R4      YdP	                  R4      \        TP	                  R4      T4      ;'       g    / T\        TP	                  R4      ;'       g    . 4      R7      #   \         d   p\        RT RT R24      ThRp?ii ; i)zL``delegation.provider`` branch: full bundle via the runtime provider system.rÀ   r  r÷   r  z$Cannot resolve delegation provider 'z': zÒ. Check that the provider is configured (API key set, valid provider name), or set delegation.base_url/delegation.api_key for a direct endpoint. Available providers: openrouter, nous, zai, kimi-coding, minimax.Nr¯   r™   zDelegation provider 'z]' resolved but has no API key. Set the appropriate environment variable or run 'hermes auth'.r   z' is pinned to the 'z]' command, which was not found on PATH. Install it or choose a different delegation provider.r®   uÁ   ' resolved without a base_url. Refusing to build a subagent with an incomplete credential bundle â€” check the provider's configuration / auth, or set delegation.base_url for a direct endpoint.rø   rù   rC   )r   rC   )r
  r  rÚ   r8   r/   rô   r�   r�   Ú_NATIVE_SDK_PROVIDERSrû   Ú_RUNTIME_PROVIDER_CUSTOMrî   rÌ   )rR   r  Úconfigured_providerr  r  rß   r¯   Úpinned_commands   &&      r   Ú_runtime_provider_credentialsr  w  sÌ  € à˜J�-Ðð	ÝHÙ*Ð5HÐY`ÕWaÔbˆð �k‰k˜) RÓ(€GßÜØ#Ð$7Ð#8ð 9Mð Nó
ð 	
ð —[‘[ Ó+€NÜØÐ/Ð0CÐ/Dð EØÐð @ðAôð �K‰K˜
×#Ò#¯NØ#×)Ñ)Ó+×1Ñ1Ó3Ô;PÔPÜØ#Ð$7Ð#8ð 9Vð Wó
ð 	
ô
 Ø	ˆ'�
×2Ð2�g—k‘k 'Ó*×2Ð2¨dØ&Ÿ{™{¨:Ó6Ô:RÔRÑÐX_×XcÑXcÐdnÓXoØ�‰�JÓ ¯+©+°jÓ*AÜ  §¡Ð-@Ó!AÐC]Ó^×dÐdÐbdØ¤T¨'¯+©+°fÓ*=×*CÐ*CÀÓ%Dôð øôA ô ÜØ2Ð3FÐ2GÀsÈ3È%ð PPð Qó
ð
 ð	ûðús   ‹F ÆF0ÆF+Æ+F0c               ó    € V ^8„  d   QhRRRR/# )r   Úcfgr   r   r   )r   s   "r   r   r   ¥  s   € ÷ Mñ M¨ð MÀñ Mr   c                óè  € R Uu/ uF?  q"\        V P                  V4      ;'       g    R4      P                  4       ;'       g    RbKA  	  pp\        V P                  R4      ;'       g    R4      P                  4       P                  4       ;'       g    RVR&   \	        V P                  R4      \
        4      '       d   V P                  R4      MRpVR,          ;'       g    RP                  4       P                  4       \        9   pVR,          '       d   V'       g   \        W44      # VR,          '       g-   \        VR,          RRRR\        \        VRR4      V4      4      # \        W44      # u upi )	uÐ  Child credential bundle from the ``delegation`` config section. Three branches: ``base_url`` set â†’ direct
endpoint (``api_key`` None means inherit the parent's key, so providers keyed outside OPENAI_API_KEY work);
``provider`` set â†’ full bundle via the runtime provider system (same path as CLI/gateway startup); neither â†’
None values, child inherits everything. ``request_overrides`` is honored on every branch. Raises ValueError
with a user-facing message.r÷   rÀ   r®   r™   Nrø   rù   )r÷   rÀ   r®   r¯   )r   r/   r�   r�   rŽ   r   r  r  rû   rî   r    r  )r  r¢   ÚkÚvaluesr  Úis_native_sdk_providers   &&    r   Ú_resolve_delegation_credentialsr  ¥  s=  € ñ AmÓmÑ@l¸1”�S—W‘W˜Q“Z×%Ð% 2Ó&×,Ñ,Ó.×6Ð6°$Ò6Ñ@l€FÐmÜ˜SŸW™W ZÓ0×6Ð6°BÓ7×=Ñ=Ó?×EÑEÓG×OÐOÈ4€Fˆ:ÑÜAKÈCÏGÉGÐTgÓLhÔjn×AoÒAo §¡Ð)<Ô!=ÐuyÐØ$ ZÕ0×6Ð6°B×=Ñ=Ó?×EÑEÓGÔK`Ñ`Ðàˆj×Ô×"8Ü+¨FÓOÐOØ�*×Ôä!Ø�7�O˜T 4¨¨tÜ$¤W¨\Ð;NÐPTÓ%UÐWqÓró
ð 	
ô )¨ÓLÐLùò ns   …!E/§E/ÁE/c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   º  s   € ÷ ñ �dñ r   c                 óŠ  € \         P                  P                  R4      R8w  dA    ^ RIHp  V ! 4       P                  R4      ;'       g    / p\        V\        4      '       d   V#   ^ RIH	p VP                  R4      ;'       g    / p\        V\        4      '       d   V# / #   \         d     LIi ; i  \         d    / u # i ; i)u•  The ``delegation`` config section (read-only â€” do NOT mutate). Prefers the shared ``load_config_readonly()``
(follows HERMES_HOME/profile; no deepcopy, since this runs on every get_definitions() rebuild) over the legacy
``cli.CLI_CONFIG``, which can hide user-set keys â€” except that ``HERMES_IGNORE_USER_CONFIG=1`` is only honored
by the legacy loader, so it stays authoritative when that flag is set.ÚHERMES_IGNORE_USER_CONFIGrŠ   )Úload_config_readonlyÚ
delegation)Ú
CLI_CONFIG)
r9   Úenvironr/   Úhermes_cli.configr#  rŽ   r   rÚ   Úclir%  )r#  r  r%  s      r   r   r   º  s²   € ô
 
‡z�z‡~�~Ð1Ó2°cÔ9ð	Ý>Ù&Ó(×,Ñ,¨\Ó:×@Ð@¸bˆCÜ˜#œt×$Ò$Ø�
ð %ðÝ"Ø�n‰n˜\Ó*×0Ð0¨bˆÜ  ¤d×+Ò+ˆsÐ3°Ð3øô ô 	Ùð	ûô ô ØŠ	ðús5   ¦"B! Á	B! Á&B2 ÂB2 ÂB2 Â!B/Â.B/Â2CÃCc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úrouting_cfgr   Úpinnedrc   r   zOptional[list[dict[str, Any]]]r   )r   s   "r   r   r   Ù  s"   € ÷ +ñ +¸Sð +È$ð +ÐSqñ +r   c                ó„   € \        \        V RR4      \        V\        4      '       d   VP	                  R4      MRVRR7      # )a¢  Fallback chain for a child, owned by the same config block as its route.

Pinned children (provider, endpoint or model override) never borrow the parent chain;
unpinned children inherit it when ``fallback_providers`` is absent/null. An explicit ``[]``
disables fallback either way. Malformed entries are dropped by the canonical normalizer.
Same rule as a pinned cron job (``cron/scheduler.py::_job_fallback_chain``).
Ú_fallback_chainNÚfallback_providersr$  )r+  Úowner)r	   r    rŽ   r   r/   )r¢   r*  r+  s   &&&r   Ú_resolve_child_fallback_chainr0  Ù  s?   € ô !Ü�Ð/°Ó6Ü1;¸KÌ×1NÒ1Nˆ�‰Ð,Ô-ÐTXØ˜\ô+ð +r   r*  c               óD   € 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   Údelegation_cfgr   Úparent_api_keyr   r÷   r4   r£   r¤   Úoverride_api_keyÚoverride_api_modeÚoverride_acp_commandÚoverride_acp_argszOptional[list[str]]r*  zOptional[dict[str, Any]]r   zdict[str, Any]r   )r   s   "r   r   r   ç  sz   € ÷ sñ sØ"&ðsØ8;ðsØGTðsØivðsà$ðsà8EðsàZgðsð (ðsð =Pðsð *ð	sð
 ñsr   c               ó  € T;'       g    V P                   pV'       d   TpTpM=V'       d   \        V RR4      pTpM%\        V RR4      p\        W P                  V4      w  rÒ\        V RR4      ;'       g    RpVe   TpMVT;'       g    RP	                  4       P                  4       \        9   d   ^ RIHp V! V4      pMWÎ8w  d   RpM\        V RR4      p\        VRV R24       T;'       g    \        V RR4      p\        V	e   T	M\        V R	. 4      ;'       g    . 4      pV'       d   V'       g   R. ppV'       d1   ^ R
IHp T! T;'       g    R4      pVe   VP                  R8w  d   RRrüTpV'       g(   V'       g    V'       g   \        V RR4      ;'       g    Tp\        V RR4      p VP                  R4      pV'       g   VRJ d,   ^ RIHp V! V4      pVf   \"        P%                  RV4       MTpRTRT;'       g    TRTRTRTR\+        WV4      RTRTR	TRTR\-        Y
f   TMT
\/        T;'       g    T;'       g    T4      R7      R\        V RR4      /\0         UUu/ uF  w  ppTV'       d   TM\        V VV4      bK   	  uppCpV'       g   VR,          ;'       g    RVR&   \        V RR4      p\3        V\4        4      '       d   VVR&   V#   \&         d"   p\"        P)                  RT4        Rp?ELRp?ii ; iu uppi )aÜ  Child credentials, transport and routing (config override > parent inherit) as ``AIAgent`` kwargs. Rules that
are easy to break: api_mode is re-derived (not inherited) when the child's provider differs from the parent's
or is Nous Portal (dual-wire); a pinned ``delegation.command`` must exist on PATH or the spawn fails loudly;
``override_provider`` clears the parent's ACP transport, fallback chain and OpenRouter routing filters so the
pinned provider is actually honoured.rÀ   Nr™   )Únous_api_moderø   zPinned delegation command 'zR' was not found on PATH. Install it or remove delegation.command from config.yaml.Úacp_commandÚacp_args)Úget_provider_profileÚexternal_processzcopilot-acpr   rØ   Úreasoning_configÚreasoning_effortF)Úparse_reasoning_effortzAUnknown delegation.reasoning_effort '%s', inheriting parent levelz.Could not load delegation reasoning_effort: %sr®   r¯   r÷   rŸ   Úfallback_model)r+  Úopenrouter_min_coding_scoreÚprovider_data_collectionÚ
max_tokens)r÷   r    r·   r®   r�   r�   Ú_NOUS_PROVIDERSÚhermes_cli.providersr9  rô   rÌ   Ú	providersr<  Ú	auth_typer/   Úhermes_constantsr@  r$   r%   rÚ   rÙ   r¦   r0  rc   Ú_ROUTING_FILTER_DEFAULTSrŽ   rJ   )r¢   r2  r3  r÷   r£   r¤   r4  r5  r6  r7  r*  Úeffective_modelrÑ   rÒ   Ú_parent_providerÚeffective_api_moder9  Úeffective_acp_commandÚeffective_acp_argsr<  ÚprofilerÓ   Úchild_reasoningÚdelegation_effortr@  rv   rß   ÚaÚdr'   Úchild_max_tokenss   &&&$$$$$$$$                    r   Ú_resolve_child_runtimerV  ç  sN  € ð ×1Ð1˜|×1Ñ1€O÷ Ø.ÐØ.Ñß	Ü$ \°:¸tÓDÐØ.Ñä$ \°:¸tÓDÐÜ-EÀl×TiÑTiÐkyÓ-zÑ*Ðô ˜|¨Z¸Ó>×DÐDÀ"ÐØÒ$Ø.ÑØ
×
"Ð
" ×	)Ñ	)Ó	+×	1Ñ	1Ó	3´Ô	FÝ6Ù*¨?Ó;ÑØ	Ô	/Ø!Ñä$ \°:¸tÓDÐô ØÐ ;Ð<PÐ;Qð RSð Tôð 1×^Ð^´G¸LÈ-ÐY]Ó4^ÐÜØ.Ò:ÑÄÈÐWaÐceÓAf×AlÐAlÐjlóÐ÷ ×!5Ø48¸"Ð1Ð÷
 Ý2Ù&Ð'9×'?Ð'?¸RÓ@ˆàŠ?˜g×/Ñ/Ð3EÔEØ5BÐDVÐ 2ð $6Ð ß×%6×?Sä�LÐ"6¸Ó=×SÐSÐASð 	%ô ˜lÐ,>ÀÓE€Oð
LØ*×.Ñ.Ð/AÓBÐßÐ 1°UÓ :Ý?Ù+Ð,=Ó>ˆFØŠ~Ü—‘ÐbÐduÕvà"(�ð
 	Ð&¨	Ð3C×3UÐ3UÀ~ÐW^Ð`oØÐ&Ð(<Ð>ZØÔ4°\ÐVgÓhØÐ&¨Ð7LÈjÐZlØ˜Oð 	Ô7ØÒ,?™.À[ÜÐ)×GÐGÐ->×GÐGÀ%ÓHôJð 	&¤w¨|Ð=ZÐ\`Ó'aðõ SkÔ
kÑRjÉ$È!ÈQˆ1×$‰a¬'°,ÀÀ1Ó*EÒEÑRjÒ
kð€F÷ Ø-3Ð4NÕ-O×-UÐ-UÐSUˆÐ)Ñ*Ü˜|¨\¸4Ó@ÐÜÐ"¤C×(Ò(Ø/ˆˆ|ÑØ€Møô/ ô LÜ�‰ÐEÀs×KÒKûðLüó  ls+   Æ-AK Ç5K É&LÉ7LËLË"K>Ë>Lr°   >   ÚgoogleÚvertexÚbedrockúgoogle-genai>   r  r   r  ))Úproviders_allowedN)Úproviders_ignoredN)Úproviders_orderN)Úprovider_sortN)Úprovider_require_parametersF)rC  r™   >   ÚnousÚnousresearchúnous-portal)>Ú__conditional_annotations__Ú__doc__Ú
__future__r   Úloggingr9   Útypingr   r   r   r   Úutilsr   r   Úhermes_cli.fallback_configr	   Ú	getLoggerr$   r  r^   r]   r…   r€   rp   r   Ú__annotations__r   r(   r,   r0   r?   rG   rU   r`   rg   rk   rq   rw   r|   r†   r‘   r•   rœ   r¦   r·   r¾   rÏ   rà   rî   Ú	frozensetr  r  rô   rû   r  r  r  r   rJ  rE  r0  rV  )rc  s   @r   Ú<module>rm     sH  øðÜ [å "ã Û 	ß ,Ó ,ß 4Ý <à	×	Ò	Ð0Ó	1€ð $Ð à#%Ð  ð !Ð Ø€	ØÐ Ø Ð ð *.Ð �Ó -õõõò
õõ$'õõõ"Iõ
9õ*õ6õ

õõõMõ0õrõ7õ(Iõn÷7òrñ0 "Ò"QÓRÐ ÙÒ ]Ó^Ð õ"õõ(õT,õ\Mõ*ð.Ð ñ
 ÒCÓD€õ+ðsð -1÷	sñ sr   