+
    jHàj54  ã                   ó¾   € R t ^ RIt^ RIHt ]! 0 Rm4      tR tR tR tR t	R t
 ! R R	]4      t ! R
 R4      tR tR tR tR tR tR tRR/R ltR tR tR tR# )aÎ  Agent-construction inputs the owner resolves for a managed worker (``construct_v1``).

The in-process turn passes these to ``AIAgent`` from the owner's runner state; a fresh worker
cannot reconstruct them (its config readers serve the frozen session snapshot, and a bypass
worker must never reload the profile), so the owner resolves them per turn, mode-appropriately,
and they ride the hydrated request beside ``turn_v1``. The child validates the closed shape.
N)ÚPathc                ó¶   € ^ RI Hp V! V 4      ;_uu_ 4        R\        W4      R\        WV4      R\	        WV4      /uuRRR4       #   + '       g   i     R# ; i)z8Owner side, per turn (off the owner loop: config reads).)Úowner_scopeÚfallback_modelÚephemeral_system_promptÚprefill_messagesN)Úgateway.session_authoritiesr   Ú_fallback_chainÚ_ephemeral_promptÚsession_prefill)Ú	authorityÚpolicyÚchat_idr   s   &&& ÚE/home/ubuntu/.hermes/hermes-agent/gateway/session_worker_construct.pyÚconstruct_inputsr      sI   € å7Ù	�Y×	Õ	Ø ¤/°)Ó"DØ)Ô+<¸YÐPWÓ+XØ"¤O°IÀwÓ$OðQ÷ 
 ×	×	Ó	ús   —%AÁA	c                óä   € VP                   '       d   R# VP                  '       d(   ^ RIHp V! VP	                  V 4      4      ;'       g    R# \        V P                  RR4      pVe   V! 4       # R# )a  The chain ``_build_fresh_agent`` gives an in-process turn. Ordinary sessions keep the
profile refresh semantics (re-read per turn, last-known-good per home); a config-only session
takes its frozen explicit snapshot (never the profile); safe mode carries none.N)Úget_fallback_chainÚ_refresh_fallback_model)Ú	safe_modeÚignore_user_configÚhermes_cli.fallback_configr   ÚconfigÚgetattrÚrunner)r   r   r   Úrefreshs   &&  r   r	   r	      se   € ð ××ÐÙØ× × Ð ÝAÙ! &§-¡-°	Ó":Ó;×CÐC¸tÐCÜ�i×&Ñ&Ð(AÀ4ÓH€GØÒ+‰7‹9Ð5°Ð5ó    c                óh  € Rp\        V P                  RR4      pVP                  '       gI   VeE   ^ RIHp VP                  4       ;_uu_ 4        T! VP                  T;'       g    R4      pRRR4       RP                  R W1P                  3 4       4      ;'       g    R#   + '       g   i     L=; i)ad  ``TurnRunner``'s combined ephemeral prompt for a LOCAL turn (no platform context block):
the gateway prompt (``agent.system_prompt`` / ``display.personality`` / channel override) plus
the frozen ``-s`` skills blocks. API-time only, never part of the persisted system prefix.
A bypass session never reads the profile: only its frozen launch additions apply.NÚ_get_system_prompt_for_channel)ÚPlatformÚ z

c              3   ó8   "  € T F  q'       g   K  Vx € K  	  R # 5i©N© )Ú.0Úps   & r   Ú	<genexpr>Ú$_ephemeral_prompt.<locals>.<genexpr>/   s   é € ÐJÑ"D˜QË—q’qÓ"Dùs   ‚	�
)	r   r   r   Úgateway.configr   Úclient_env_scopeÚLOCALÚjoinÚskills_prompt)r   r   r   Ú
configuredÚresolver   s   &&&   r   r
   r
   $   s‹   € ð
 €JÜ�i×&Ñ&Ð(HÈ$ÓO€GØ×$×$Ð$¨Ò)<Ý+Ø×$Ñ$×&Õ&Ù  §¡°·°¸BÓ?ˆJ÷ 'à�;‰;ÑJ :×/CÑ/CÑ"DÓJÓJ×RÐRÈdÐR÷ '×&ús   ÁB!Â!B1	c                óz   € VP                  V RR7      P                  R4      p\        V\        4      '       d   V# / # )z•The session's ``provider_routing``: its own profile's, as of its creation (main's CLI read it
once at startup). Never the runner's daemon-start copy.F©ÚsecretsÚprovider_routing)r   ÚgetÚ
isinstanceÚdict)r   r   Úroutings   && r   Úsession_routingr6   2   s9   € ð �m‰m˜I¨uˆmÓ5×9Ñ9Ð:LÓM€GÜ  ¬$×/Ò/ˆ7Ð7°RÐ7r   c                ó¢   € VP                   '       d   R# \        V 4      pW#9  d   VP                  V\        W4      34       W2,          ^ ,          # )aX  The session's prefill examples, for the in-process turn and a managed worker alike: the
snapshot ``stage_session_prefill`` took when the session was created (main's CLI read the file
once at startup). A session this owner did not create (restored after a restart, a branch)
reads it on first use and keeps that. A bypass session never loads it.N)r   Ú_held_prefillÚ
setdefaultÚ_read_prefill)r   r   Ú
session_idÚhelds   &&& r   r   r   9   sG   € ð
 × × Ð ÙÜ˜Ó#€DØÔØ�‰˜
¤]°9Ó%EÐ$GÔHØÕ˜AÕÐr   c                   ó8   a € ] tR t^Ft o RtRtRtV 3R ltRtV t	R# )ÚStagedReceiptz­A creation receipt plus owner memory ``commit_local_session`` publishes only from the
transaction that creates the session (never persisted: the receipt itself is the dict).Nc                ó.   <€ V ^8„  d   Qh/ R;R&   R;R&   # )é   z_PrefillPublication | NoneÚ	on_createzdict | NoneÚclient_requestr"   )ÚformatÚ__classdict__s   "€r   Ú__annotate__ÚStagedReceipt.__annotate__F   s   ø‡ ‚ ð ,Ñ2ñ ð
 "Ñ(ò r   r"   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rA   rB   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©rD   s   @r   r>   r>   F   s   ø‡ € ñ_à.2€Ià$(€N÷ ƒ r   r>   c                   ó8   a € ] tR t^Nt o R tR tR tR tRtV t	R# )Ú_PrefillPublicationc                óB   € WVR 3w  V n         V n        V n        V n        R # r!   )r   r   r;   Úbox)Úselfr   r   r;   s   &&&&r   Ú__init__Ú_PrefillPublication.__init__O   s!   € àAJÐT^Ð`dÐAdÑ>ˆŒ˜œ T¤_°d¶hr   c                óR   € \        V P                  V P                  4      3V n        R# )zXThis attempt's snapshot, read by its commit before the transaction (off the owner loop).N)r:   r   r   rS   ©rT   s   &r   ÚreadÚ_PrefillPublication.readS   s   € ä! $§.¡.°$·+±+Ó>Ð@ˆŽr   c                ó^   € V P                   \        V P                  4      V P                  &   R # r!   )rS   r8   r   r;   rX   s   &r   ÚpublishÚ_PrefillPublication.publishW   s   € Ø9=¿¹Œ�d—n‘nÓ% d§o¡oÓ6r   c                ó¾   € \        V P                  4      pVP                  V P                  4      V P                  J d   VP                  V P                  R 4       R # R # r!   )r8   r   r2   r;   rS   Úpop)rT   r<   s   & r   ÚwithdrawÚ_PrefillPublication.withdrawZ   s@   € Ü˜TŸ^™^Ó,ˆØ�8‰8�D—O‘OÓ$¨¯©Ó0Ø�H‰H�T—_‘_ dÖ+ñ 1r   )r   rS   r   r;   N)
rG   rH   rI   rJ   rU   rY   r\   r`   rM   rN   rO   s   @r   rQ   rQ   N   s!   ø‡ € òeòAòB÷,ð ,r   rQ   c                óp   € \        V4      pVP                  '       g   \        WVR,          4      Vn        V# )a<  Stage a new session's prefill snapshot: the ``prefill_messages_file`` of its config, relative
to its own profile home, read by this attempt's commit (``commit_local_session``, which the async
creates run in ``tracked_write``'s worker thread), never on the owner loop. The snapshot is held
in the authority's memory only if this attempt's commit creates the session: an overlapping
retry or conflicting create never replaces the winner's, and a refused or failed create leaves
nothing. Never evicted by other sessions; ``release_session_prefill`` drops it with the session.r;   )r>   r   rQ   rA   )r   r   ÚreceiptÚstageds   &&& r   Ústage_session_prefillre   `   s3   € ô ˜7Ó#€FØ×$×$Ð$Ü.¨yÀ'È,ÕBWÓXˆÔØ€Mr   c                 ó|   € \        V R R4      ;'       g    / pV F  pVP                  \        V4      R4       K   	  R# ©Ú_local_prefillN)r   r_   Ústr)r   Úsession_idsr<   Úsids   &&  r   Úrelease_session_prefillrl   m   s5   € Ü�9Ð.°Ó5×;Ð;¸€DÛˆØ�‰”�S“˜4Ö ó r   c                 ó8   € \        V R R4      pVf	   / ;qn        V# rg   )r   rh   )r   r<   s   & r   r8   r8   s   s&   € Ü�9Ð.°Ó5€DØ‚|Ø*,Ð,ˆÔ'Ø€Kr   c           	      óT  € ^ RI HpHp \        \	        V P
                  4      4      pVP                  4       '       g   ^ RIHp V! 4       pVP                  4       ;_uu_ 4        V! VP                  V RR7      4      pRRR4       V! XV4      ;'       g    R#   + '       g   i     L#; i)é    )Ú_load_prefill_messagesÚ_resolve_prefill_messages_file)Úget_hermes_homeFr/   N)Úhermes_cli.cli_config_loadrp   rq   r   ri   Ú
profile_idÚis_absoluteÚhermes_constantsrr   r(   r   )r   r   rp   rq   Úhomerr   Úpaths   &&     r   r:   r:   z   s}   € ßaÜ”�I×(Ñ(Ó)Ó*€DØ×Ñ×ÒÝ4ÙÓ ˆØ	×	 Ñ	 ×	"Õ	"Ù-¨f¯m©m¸IÈu¨mÓ.UÓVˆ÷ 
#á! $¨Ó-×5Ð5°Ð5÷ 
#×	"ús   Á"BÂB'	c                óÈ  € \         P                  ! V R,          P                  R4      ;'       g    R4      P                  R4      pVf   / # \        V\        4      '       dm   \        V4      \        8w  gY   \        VR,          4      '       dA   \        VR,          4      '       d)   \        VR,          \        \        R4      34      '       g   \        R	4      h\	        V4      # )
zChild side: the validated ``AIAgent`` keyword arguments; a frame without the object
(older owner) constructs exactly as before.r   Úrequest_jsonz{}Úconstruct_v1Nr   r   r   Ú invalid_managed_worker_bootstrap)ÚjsonÚloadsr2   r3   r4   ÚsetÚKEYSÚ
_dict_listri   ÚtypeÚ
ValueError)ÚframeÚinputss   & r   Úconstruct_kwargsr†   …   s©   € ô �ZŠZ˜˜h�×+Ñ+¨NÓ;×CÐC¸tÓD×HÑHÈÓX€FØ‚~Øˆ	Ü�vœt×$Ò$¬¨F«´tÔ(;Ü˜fÐ%5Õ6×7Ò7¼zÈ&ÐQcÕJd×?eÒ?eÜ˜fÐ%>Õ?Ä#ÄtÈDÃzÐAR×SÒSÜÐ;Ó<Ð<Ü�‹<Ðr   c                 ó²   € V R J ;'       gM    \        V \        4      ;'       d5    \        ;QJ d    R V  4       F  '       d   K   R# 	  R# ! R V  4       4      # )Nc              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir!   )r3   r4   )r#   Úes   & r   r%   Ú_dict_list.<locals>.<genexpr>“   s   é € Ð<`ÑZ_ÐUV¼ZÈÌ4×=PÐ=PÓZ_ùs   ‚FT)r3   ÚlistÚall)Úvalues   &r   r�   r�   ’   sH   € Ø�Dˆ=×aÐaœZ¨¬tÓ4×`Ð`¿»Ñ<`ÑZ_Ó<`¿¼ÐaºÐa¸Ñ<`ÑZ_Ó<`Ó9`Ðar   ÚfallbackTc          
     óT  € ^ RI HpHpHp ^ RIHp VP                  R4      ;'       g    / P                  R4      p	\        P                  ! V P                  4      P                  R4      p
V
'       dD   ^ RI
Hp V! V
4      T! VP                  R4      ;'       g    / P                  R4      4      8w  d   Rp
V! V4      ;_uu_ 4        V! V	W:W!R7      pVe   VR3uuRRR4       # V'       g   V! W’W£R	7      R3uuRRR4       # V! WW:VR
7      uuRRR4       #   + '       g   i     R# ; i)av  ``(runtime, fallback_entry)`` for a launch-policy route: the session's FROZEN config and launch
credential, walking its own fallback chain on an AuthError unless ``fallback=False`` (a session
control asking which route the session itself runs). The one resolver an in-process turn
(``_resolve_policy_agent_runtime``) and a key-less managed worker (``worker_api_key``) share.)Úfrozen_runtime_configÚresolve_runtime_providerÚresolve_runtime_with_fallback)Ú_resolve_named_custom_runtimeÚmodelÚproviderÚbase_url)Únormalize_route_base_urlN)Úrequested_providerÚexplicit_api_keyÚexplicit_base_urlÚtarget_modelr   )Ú	requestedr›   rš   r™   )rœ   r™   rš   r›   )Úhermes_cli.runtime_providerr�   r‘   r’   Ú"hermes_cli.runtime_provider_customr“   r2   r}   r~   rz   Úhermes_cli.route_identityr—   )r   Úfrozenr”   ÚkeyrŽ   r�   r‘   r’   r“   r•   Ú
launch_urlr—   Úruntimes   &&&&$        r   Úroute_runtimer¤   –   s  € ÷
ñ õ QØ—
‘
˜7Ó#×)Ð) r×.Ñ.¨zÓ:€HÜ—’˜F×/Ñ/Ó0×4Ñ4°ZÓ@€Jßõ 	GÙ# JÓ/Ñ3KÈVÏZÉZÐX_ÓM`×MfÐMfÐdf×LkÑLkÐlvÓLwÓ3xÔxØˆJñ 
˜v×	&Õ	&Ù/À8Ø Øô/ˆð ÒØ˜D�=÷ 
'Ò	&÷ á+°hØ",ôDØEIðJ÷! 
'Ò	&ñ$ -¨VØ ÈUôT÷% 
'×	&×	&Ó	&ús   ÃDÃ#DÃ+DÄ
DÄD'	c                ó¶   € V P                  4       w  r#RV9   d   / VCRVR,          ;'       g    . RR/Cp\        WVR4      w  rEVf   VP                  R4      # R# )aU  Child side, for a worker launched without a key (every Kanban run): the route's own credential,
resolved as the in-process turn resolves it, from this process's profile home (its HERMES_HOME and
``.env``). A fallback entry's key belongs to another provider and model, so the primary never
carries it; the agent's own fallback chain switches all three together (#139155).

A primary AuthError walks the chain the agent will actually get: the owner's per-turn
``construct_v1`` chain (an ordinary session's refreshed profile fallbacks) when it was sent,
the frozen snapshot's otherwise (older owner).r   Úfallback_providersNÚapi_key)Ú	effectiver¤   r2   )r   Ú	constructr    r”   r£   Úfallback_entrys   &&    r   Úworker_api_keyr«   À   sm   € ð ×$Ñ$Ó&�M€FØ˜9Ô$Øl�FÐlÐ0°)Ð<LÕ2M×2SÐ2SÐQSÐUeÐgkÑlˆÜ+¨F¸EÀ4ÓHÑ€GØ%3Ò%;ˆ7�;‰;�yÓ!ÐEÀÐEr   c                ó¦  € \        V \        4      '       d   V P                  R/ 4      M/ p\        V\        4      '       d   RV/pM\        V\        4      '       g   / p^ RIHp VR,          pRVP                  RVR,          4      RVP                  RVR,          4      RVP                  RVR,          4      R	VP                  R
VR
,          4      /# )zê``AIAgent`` checkpoint arguments from a config dict (every turn: the gateway's live config, a
managed worker's frozen session snapshot). The gateway bypasses ``load_config()``, so defaults
are here; legacy ``checkpoints: true`` works.ÚcheckpointsÚenabled)ÚDEFAULT_CONFIGÚcheckpoints_enabledÚcheckpoint_max_snapshotsÚmax_snapshotsÚcheckpoint_max_total_size_mbÚmax_total_size_mbÚcheckpoint_max_file_size_mbÚmax_file_size_mb)r3   r4   r2   ÚboolÚhermes_cli.configr¯   )r   Úcp_cfgr¯   Údefaultss   &   r   Úcheckpoint_agent_kwargsr»   Ð   s¼   € ô /9¸Ä×.FÒ.FˆV�Z‰Z˜ rÔ*ÈB€FÜ�&œ$×ÒØ˜VÐ$‰Ü˜¤×%Ò%ØˆÝ0Ø˜mÕ,€Hà˜vŸz™z¨)°X¸iÕ5HÓIØ" F§J¡J¨ÀÈÕ@YÓ$ZØ&¨¯
©
Ð3FÈÐQdÕHeÓ(fØ% v§z¡zÐ2DÀhÐOaÕFbÓ'cð	eð er   c                ój  € ^ RI HpHp ^ RIHp V P                  R4      ;'       g    / pV P                  R4      ;'       g    / P                  R4      pT! V P                  R4      ;'       g    / P                  RR4      4      p	W”9   d   V! WW9R	7      MR
p
RVP                  R4      RVP                  R4      RVP                  R4      RVP                  R4      RVP                  RR4      RVP                  R4      RT	RT
R\        V\        \        34      '       d   ^ Tu;8:  d
   ^8:  d   V/	#  R
/	# )zþThe provider-routing ``AIAgent`` arguments every in-process surface passes (the CLI's
``provider_routing`` / ``openrouter.min_coding_score`` / ``agent.service_tier``, a static fast
tier's request overrides), from a managed worker's frozen session config.)ÚSTATIC_TIERSÚparse_service_tier)Úresolve_fast_mode_overridesr1   Ú
openrouterÚmin_coding_scoreÚagentÚservice_tierr   )r•   r–   ÚtierNÚproviders_allowedÚonlyÚproviders_ignoredÚignoreÚproviders_orderÚorderÚprovider_sortÚsortÚprovider_require_parametersÚrequire_parametersFÚprovider_data_collectionÚdata_collectionÚrequest_overridesÚopenrouter_min_coding_score)	Úagent.fast_moder½   r¾   Úhermes_cli.modelsr¿   r2   r3   ÚintÚfloat)r   r”   r•   r–   r½   r¾   r¿   ÚprÚscorerÄ   Ú	overridess   &&&&       r   Úrouting_agent_kwargsrÚ   â   s1  € ÷ AÝ=Ø	�‰Ð&Ó	'×	-Ð	-¨2€BØ�Z‰Z˜Ó%×+Ð+¨×0Ñ0Ð1CÓD€EÙ˜vŸz™z¨'Ó2×8Ð8°b×=Ñ=¸nÈbÓQÓR€DØgkÔg{Ñ+¨EÈxÕcð  BF€IØ §¡¨£Ð1DÀbÇfÁfÈXÓFVÐXiÐkm×kqÑkqÐryÓkzØ˜RŸV™V F›^Ð-JÈBÏFÉFÐSgÐinÓLoØ&¨¯©Ð/@Ó(AÀ>ÐSWÐYlÐnwØ)´J¸uÄsÌEÀl×4SÒ4SÐXYÐ]bÖXgÐfgÔXg¨5ðsð sð YhÐmqðsð sr   >   r   r   r   )rK   r}   Úpathlibr   Ú	frozensetr€   r   r	   r
   r6   r   r4   r>   rQ   re   rl   r8   r:   r†   r�   r¤   r«   r»   rÚ   r"   r   r   Ú<module>rÝ      sŽ   ðñó Ý áÒRÓS€òQò
6òSò8ò
ô)�Dô )÷,ñ ,ò$
ò!òò6ò
òbð'T¸$ô 'TòTFò eô$sr   