+
    lHàjÅ�  ã                  óŠ  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
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/RMR4 R5 llt0R6 t1]2! 0 RNm4      t3]2! 0 ROm4      t4R7 R8 lt5R9 R: lt6R; R< lt7R= R> lt8R? R@ lt9RA RB lt:RPt;]2! 0 RQm4      t<RC RD lt= ! RE RF]
4      t>RG RH lt?RIRRJR/RK RL llt@R# )RzUDelegation config knobs (delegation.* keys) and child credential/provider resolution.)ÚannotationsN)ÚAnyÚDictÚListÚ
NamedTupleÚ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   "Ú?/home/ubuntu/.hermes/hermes-agent/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_callbackr1   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   r0   Ú	TypeErrorÚ
ValueErrorr%   r&   ÚosÚgetenv)r3   r4   ÚparseÚdefaultr6   Ú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&   )rB   rC   rD   s   &&*r   Ú
_warn_oncerH   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      # )é    ©ÚmaxrK   ©Ú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_childrenrV   U   s   € äØ Ñ&>ÀØTóð r   c               ó   € V ^8„  d   QhRR/# rJ   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      # )é   rP   rR   s   &r   rT   Ú._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   r0   rH   )Úresults    r   Ú_get_max_concurrent_childrenra   ]   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   r0   r   r   r   Ú_get_independent_completionsrh   n   s   € ô œ4›6Ÿ:™:Ð&?ÀÓGÓHÐHr   c               ó   € V ^8„  d   QhRR/# rc   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)rd   r   r0   r   r   r   Ú_get_worktree_isolationrl   s   s   € ô ”“—
‘
Ð/°Ó7Ó8Ð8r   c               ó   € V ^8„  d   QhRR/# rJ   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.©ra   Ú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   ra   r   r0   rH   ro   s    r   Ú_get_max_async_childrenrr   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      >@)ÚfloatrQ   )rt   Úparseds   & r   Ú_parse_timeoutrx   †   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@   rx   r   r   r   r   Ú_get_child_timeoutr}   ‹   s   € ô ØÐ!CÄ^ÔUjØ_óð r   c               ó   € V ^8„  d   QhRR/# rJ   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)rK   Ú_MIN_SPAWN_DEPTHr%   r&   rQ   )rS   Ú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/# rc   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   r0   Ú
isinstancerd   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/# rc   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=   rg   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   ú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    rd   )Úparent_agentÚoverride_providerÚoverride_base_urlÚparent_capsr3   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_urlr5   Ú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   r0   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   r3   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)r3   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   Úproviderr5   r°   r   rd   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_providerr5   Úeffective_base_urlÚeffective_requested_providerr   )r   s   "r   r   r   ë   s$   € ÷ ;ñ ;Ø%ð;ØIVð;à"/ñ;r   c                óî  € \        VRR4      pV '       g   V# \        VRR4      ;'       g    Rp V R8X  d„   ^ 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# ^ R
IHp	Hp
 V	! W#4      pT
! \        V4      Y{'       d   V^,          4      # R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_provider)Úcustom_entry_for_endpointÚentry_scoped_poolzAParent %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Ø   Úagent.custom_entry_poolrÛ   rÜ   rÀ   rÑ   r%   ÚdebugÚ	Exception)rÓ   r¤   rÔ   rÕ   Úparent_poolÚparent_providerrØ   Ú	child_keyÚ
parent_keyrÛ   rÜ   Úownerr¿   Úexcs   &&&&          r   Ú_resolve_child_credential_poolræ   ë   s  € ô( ˜,Ð(:¸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}Ø"Ð"÷ ]Ù-Ð.@Ó_ˆEÙ$¤\°)Ó%<¸iÖUZÈÈqÍÓeÐeÐ`dÓeÐeØÔ0ð Ò"Ùß%Ô)>¸{Ð`r×)sÒ)sØ"Ð"Ü�L‰LÐ\Ø+ôAäÐ.Ó/ˆØÒ× 2Ô;PÐQUÐk}×;~Ò;~ÙØˆøÜô pØ Ô)Ü�L‰LÐ_Ðas×yÐyñ ô �L‰LÐUÐWi×oÐoÙûðpúsS   °D% Á6D% Â0D% Â4D% Â:
D% ÃD% ÃD% Ã",D% ÄD% Ä#D% Ä%E4Ä0E/ÅE/Å/E4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   Údeepcopyr0   Ú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   r5   rC   r    r   rE   r   )r   s   "r   r   r   C  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Úwhichr9   )r   rC   Ú_shutils   && r   Ú_require_pinned_commandrú   C  s*   € ó ß�w—}‘} W×-Ò-Ü˜Ó!Ð!ñ .�wr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   J  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  J  s3   € ð 	�˜
 H¨j¸(ÀIÈwÐXbÐdlØÐ.ðà27ðð r   c               ó    € V ^8„  d   QhRRRR/# ©r   rS   r   r   r   )r   s   "r   r   r   Q  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   r0   rß   r%   rÞ   r  rô   )rS   Úexplicit_request_overridesr  Ú
base_lowerÚhostrÂ   rþ   r
  rÿ   r  Úruntimerå   s   &&          r   Ú_direct_endpoint_credentialsr  Q  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   {  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ÿ   rD   )r   rD   )r  r  rß   r9   r0   rú   r�   r‘   Ú_NATIVE_SDK_PROVIDERSr  Ú_RUNTIME_PROVIDER_CUSTOMrô   rÎ   )rS   r  Úconfigured_providerr  r  rå   r±   Úpinned_commands   &&      r   Ú_runtime_provider_credentialsr  {  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    r0   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)
r:   Úenvironr0   Ú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   Úpinnedrd   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*  )r1  rä   )r
   r¢   r�   r   r0   )r¤   r0  r1  s   &&&r   Ú_resolve_child_fallback_chainr5  Ý  s?   € ô !Ü�Ð/°Ó6Ü1;¸KÌ×1NÒ1Nˆ�‰Ð,Ô-ÐTXØ˜\ô+ð +r   c                  ó&   € ] tR tRt$ RtR]R&   RtR# )ÚResolvedReasoningië  a"  A route's FINAL reasoning config, used as-is (``None`` included = the route's own default): a profile route
resolves its profile's ``agent.reasoning_effort`` / ``reasoning_overrides``, so neither the launching profile's
``delegation.reasoning_effort`` nor the parent's level may fill it in.rŸ   Úconfigr   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   r   r   r7  r7  ë  s   ‡ ñNð ×r   r7  c               ó$   € V ^8„  d   QhRRRRRR/# )r   Údelegation_cfgr   Úroute_effortr   r   r   )r   s   "r   r   r   ó  s!   € ÷ ñ °4ð Àsð Èsñ r   c                ó.  € \        V\        4      '       d   VP                  # \        V RR4      pTpV'       g"   VRJ g   T;'       g    / P	                  R4      pV'       g   VRJ d-   ^ RIHp V! V4      pVf   \        P                  RV4       V# TpV# )uø   Child reasoning config: a :class:`ResolvedReasoning` route value as-is, else the route's raw effort >
``delegation.reasoning_effort`` > the parent's level. Keep the raw value â€” a YAML ``false`` must disable
thinking, not coerce to "" and inherit.Úreasoning_configNFÚreasoning_effort)Úparse_reasoning_effortzAUnknown delegation.reasoning_effort '%s', inheriting parent level)	r�   r7  r8  r¢   r0   Úhermes_constantsrF  r%   r&   )r¤   rA  rB  Úchild_reasoningÚdelegation_effortrF  rw   s   &&&    r   Ú_child_reasoningrJ  ó  s›   € ô �,Ô 1×2Ò2Ø×"Ñ"Ð"Ü˜lÐ,>ÀÓE€OØ$ÐßÐ!2°eÓ!;Ø+×1Ð1¨r×6Ñ6Ð7IÓJÐßÐ-°Ó6Ý;Ù'Ð(9Ó:ˆØŠ>Ü�N‰NÐ^Ð`qÔrð Ðð %ˆOØÐr   r0  Úoverride_reasoning_effortc               óH   € 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   rA  r   Úparent_api_keyr   rý   r5   r¥   r¦   Úoverride_api_keyÚoverride_api_modeÚoverride_acp_commandÚoverride_acp_argszOptional[list[str]]r0  zOptional[dict[str, Any]]rK  r   zdict[str, Any]r   )r   s   "r   r   r     s‡   € ÷ gñ gØ"&ðgØ8;ðgØGTðgØivðgà$ðgà8EðgàZgðgð (ðgð =Pðgð *ð	gð NQð	gð
 ñg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'       d2   ^ R
IHp T! T;'       g    R4      pVe   VP                  R8w  d   RRppTpV'       g(   V'       g    V'       g   \        V RR4      ;'       g    Tp\        WV4      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      /\$         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\'        V\(        4      '       d   VVR&   V# 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Ú   r°   r±   rý   r¡   rD  Úfallback_model)r1  Úopenrouter_min_coding_scoreÚprovider_data_collectionÚ
max_tokens)rý   r¢   r¹   r°   r�   r‘   Ú_NOUS_PROVIDERSÚhermes_cli.providersrS  rú   rÎ   Ú	providersrV  Ú	auth_typerJ  r¨   r5  rd   Ú_ROUTING_FILTER_DEFAULTSr�   rK   )r¤   rA  rM  rý   r¥   r¦   rN  rO  rP  rQ  r0  rK  Úeffective_modelrÓ   rÔ   Ú_parent_providerÚeffective_api_moderS  Úeffective_acp_commandÚeffective_acp_argsrV  ÚprofilerÕ   rH  ÚaÚdr(   Úchild_max_tokenss   &&&$$$$$$$$$                r   Ú_resolve_child_runtimerj    sß  € ð ×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ð 	%ô
 ' |ÐE^Ó_€Oð 	Ð&¨	Ð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s   ÈJÈ,Jr²   >   ÚgoogleÚvertexÚbedrockúgoogle-genai>   r  r  r	  ))Úproviders_allowedN)Úproviders_ignoredN)Úproviders_orderN)Úprovider_sortN)Úprovider_require_parametersF)rZ  rš   >   ÚnousÚnousresearchúnous-portal)AÚ__conditional_annotations__r=  Ú
__future__r   Úloggingr:   Útypingr   r   r   r   r   Úutilsr   r	   Úhermes_cli.fallback_configr
   Ú	getLoggerr%   r  r_   r^   r†   r�   rq   r   r>  r   r)   r-   r1   r@   rH   rV   ra   rh   rl   rr   rx   r}   r‡   r’   r–   r�   r¨   r¹   rÀ   rÑ   ræ   rô   Ú	frozensetr  r  rú   r  r  r  r%  r   r`  r\  r5  r7  rJ  rj  )rw  s   @r   Ú<module>r     sf  øðÜ [å "ã Û 	ß 8Õ 8ß 4Ý <à	×	Ò	Ð0Ó	1€ð $Ð à#%Ð  ð !Ð Ø€	ØÐ Ø Ð ð *.Ð �Ó -õõõò
õõ$'õõõ"Iõ
9õ*õ6õ

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