+
    iHàj(  ã                  ó  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIHtHt ^ RIHtHtHtHtHt RR.tRtRt]P0                  ! R	4      tR
 R ltR R ltR R ltR R ltR R lt ! R R]4      tR# )uz  ``command`` secret source â€” resolve secrets via a user-configured helper.

Ports the desktop app's TypeScript ``CommandSecretsProvider`` semantics. The
helper (``keepassxc-cli``, ``secret-tool``, a script that cats a tmpfs env
file, ...) comes from ``secrets.command`` in ``config.yaml`` â€” NEVER from
``.env``, which holds only secret values.

Security model: the command string is the USER'S OWN configuration, so it runs
via ``/bin/sh -c``; the requested key reaches the child ONLY via
``HERMES_SECRET_KEY`` (never interpolated, so a hostile key name is inert); hard
timeout (default 3s) + 1 MiB output cap, every failure degrades to "no value";
failure logs carry ONLY structured fields (exit code / signal / errno), never
the command, the helper's stderr (captured and DISCARDED) or any value; startup
runs the helper exactly ONCE with an empty key; POSIX-only (needs ``/bin/sh``).
)ÚannotationsN)ÚPath)ÚDictÚOptional)Ú	ErrorKindÚFetchResultÚSecretSourceÚcoerce_floatÚsource_child_envr   Úunquote_dotenv_valueg      @z^([A-Za-z_][A-Za-z0-9_]*)=(.*)$c               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚbool© )Úformats   "ÚA/home/ubuntu/.hermes/hermes-agent/agent/secret_sources/command.pyÚ__annotate__r   )   s   € ÷ =ñ =�Tñ =ó    c                 óh   € \         P                  R 8H  ;'       g    \        P                  ! 4       R8H  # )ÚntÚWindows)ÚosÚnameÚplatformÚsystemr   r   r   Ú_is_windowsr   )   s$   € Ü�7‰7�d‰?×<Ð<œhŸošoÓ/°9Ñ<Ð<r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚmessageÚstrr   ÚNoner   )r   s   "r   r   r   -   s   € ÷ ;ñ ;�#ð ;˜$ñ ;r   c                óB   € \        R V  2\        P                  R7       R# )z[secrets:command] )ÚfileN)ÚprintÚsysÚstderr)r   s   &r   Ú_logr&   -   s   € Ü	Ð˜w˜iÐ
(¬s¯z©z×:r   c               ó    € V ^8„  d   QhRRRR/# )r   Úrawr   r   r   )r   s   "r   r   r   1   s   € ÷ 	ñ 	˜cð 	 cñ 	r   c                ó–   € V P                  4       p\        V4      ^8¼  d)   V^ ,          VR,          8X  d   V^ ,          R9   d   V^R # V# )z¬Strip one layer of matching surrounding quotes from a dotenv value.

Requires length >= 2 so a lone ``"`` stays intact while ``""``/``''``
correctly yield an empty string.
z"'éÿÿÿÿ)ÚstripÚlen)r(   Úts   & r   r   r   1   sB   € ð 	�	‰	‹€AÜ
ˆ1ƒv�„{�q˜•t˜q �u”}¨¨1­°¬Ø��2ˆwˆØ€Hr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   Úcommandr   Ú
secret_keyÚtimeout_secondsÚfloatÚmax_output_bytesÚintr   zOptional[str]r   )r   s   "r   r   r   =   s1   € ÷ 9:ñ 9:˜ð 9:¨#ð 9:Àð 9:ÐY\ð 9:Ðanñ 9:r   c           	     óÐ  € \        4       '       d   \        R4       R# \        4       pWR&    \        P                  ! RRV .V\        P
                  \        P                  \        P                  RR7      p TP                  TR	7      w  rxTP*                  ^ 8w  di   \-        TP*                  4      Rr©TP*                  ^ 8  d/    \        P.                  ! TP*                  ) 4      P0                  p
Rp	\        RT	 RT
 24       R# \3        T4      T8”  d   \        RT R24       R# TP5                  RRR7      #   \         d$   p\        RTP                   24        Rp?R# Rp?ii ; i  \        P                   dÀ     \        P                  ! \        P                  ! TP                  4      \        P                   4       M,  \"        \$        \        3 d    TP'                  4         Mi ; i TP                  R
R	7       M&  \        P                  \(        \        3 d     Mi ; i\        RTR R24        R# i ; i  \(         d    \-        TP*                  ) 4      p
 ELui ; i)u   Run the helper via ``/bin/sh -c`` and return its stdout, or None.

The key travels as DATA in ``HERMES_SECRET_KEY``. stdout/stderr are piped
(never inherited); stderr is discarded. Any failure logs structured fields
only and returns None â€” never raises.
zSthe 'command' provider is POSIX-only (needs /bin/sh); resolving no value on WindowsNÚHERMES_SECRET_KEYz/bin/shz-cT)ÚenvÚstdinÚstdoutr%   Ústart_new_sessionz2helper failed to spawn; resolving no value: errno=)Útimeoutg      ð?zhelper timed out after Úgzs; resolving no valueÚnoneÚ?z(helper failed; resolving no value: code=z signal=zhelper output exceeded the z-byte cap; resolving no valuezutf-8Úreplace)Úerrors)r   r&   r
   Ú
subprocessÚPopenÚDEVNULLÚPIPEÚOSErrorÚerrnoÚcommunicateÚTimeoutExpiredr   ÚkillpgÚgetpgidÚpidÚ_signalÚSIGKILLÚProcessLookupErrorÚPermissionErrorÚkillÚ
ValueErrorÚ
returncoder   ÚSignalsr   r,   Údecode)r/   r0   r1   r3   r7   ÚprocÚexcÚstdout_bytesÚ_stderr_discardedÚcodeÚsignames   &&&&       r   Ú_run_helperr[   =   s  € ô ‡}‚}ÜÐbÔcÙô Ó
€CØ)ÐÑðÜ×ÒØ˜˜gÐ&¨C´z×7IÑ7IÜ—?‘?¬:¯?©?Ø"ô
ˆðØ*.×*:Ñ*:À?Ð*:Ó*SÑ'ˆð ‡�˜!ÔÜ˜DŸO™OÓ,¨fˆgØ�?‰?˜QÔð0Ü!Ÿ/š/¨4¯?©?Ð*:Ó;×@Ñ@�ð ˆDÜÐ7¸°v¸XÀgÀYÐOÔPÙä
ˆ<ÓÐ+Ô+ÜÐ*Ð+;Ð*<Ð<YÐZÔ[Ùà×Ñ˜w¨yÐÓ9Ð9øôG ô ÜÐAÀ#Ç)Á)ÀÐMÔNÝûðûô ×$Ñ$ô ð	Ü�IŠI”b—j’j §¡Ó*¬G¯O©OÕ<øÜ"¤O´WÐ=ô 	Ø�I‰IŽKð	úð	Ø×Ñ SÐÕ)øÜ×)Ñ)¬:´wÐ?ô 	Ùð	úäÐ& °qÐ&9Ð9NÐOÔPÚðûô& ô 0Ü˜tŸ™Ð.Ó/“ð0ús…   ­A	D8 Á7E) Ã+I  Ä8E&ÅE!Å!E&Å)H=Å?AGÇH=Ç&G,Ç)H=Ç+G,Ç,H=Ç0HÈH=È H&È#H=È%H&È&H=È<H=É !I%É$I%c               ó    € V ^8„  d   QhRRRR/# )r   r9   r   r   zdict[str, str]r   )r   s   "r   r   r   y   s   € ÷ 
ñ 
˜cð 
 nñ 
r   c                óP  € / pV P                  RR4      P                  R4       F~  pVP                  4       pV'       d   VP                  R4      '       d   K4  \        P                  V4      pV'       g   KS  \        VP                  ^4      4      WP                  ^4      &   K€  	  V# )zFParse a KEY=VALUE blob; comments and non-env-shaped lines are skipped.z
Ú
Ú#)r?   Úsplitr+   Ú
startswithÚ	_ENV_LINEÚmatchr   Úgroup)r9   Úoutr(   ÚlineÚms   &    r   Ú_parse_dotenv_maprh   y   s|   € à€CØ�~‰~˜f dÓ+×1Ñ1°$Ö7ˆØ�y‰y‹{ˆß�t—‘ s×+Ò+ÙÜ�O‰O˜DÓ!ˆß‰1Ü2°1·7±7¸1³:Ó>ˆC—‘˜“
‹Oñ 8ð €Jr   c                  ór   € ] tR t^†tRtRtRtRt]P                  R]P                  R/tR R ltR	 R
 ltRtR# )ÚCommandSourceaU  User-configured helper command as a registered **bulk** source.

Composes with the other sources through ``apply_all()``; there is
deliberately NO single-provider selector. The helper enumerates a
KEY=VALUE blob in one run. Config::

    secrets:
      command:
        enabled: true
        command: "cat /run/user/1000/hermes-secrets.env"
r/   zCommand helperÚbulkziSet secrets.command.command in config.yaml to a fast, non-interactive helper that prints KEY=VALUE lines.u…   Run the helper manually in a shell to see its real error â€” Hermes discards helper stderr so diagnostics can't leak secret material.c               ó   € V ^8„  d   QhRR/# )r   r   Údictr   )r   s   "r   r   ÚCommandSource.__annotate__ž   s   € ÷ 
ñ 
˜tñ 
r   c                	ó>   € R RRRR/RRRRR/RRR	R\         /R
RRRR//# )ÚenabledÚdescriptionzMaster switchÚdefaultFr/   z@Helper run via /bin/sh -c; must print a KEY=VALUE blob on stdoutÚ Úhelper_timeout_secondszHard timeout for one helper runÚoverride_existingz)Helper values overwrite .env/shell values)Ú_COMMAND_TIMEOUT_SECONDS)Úselfs   &r   Úconfig_schemaÚCommandSource.config_schemaž   sQ   € à˜ ¸	À5ÐIØ˜Ð'iØ! 2ð'à$ }Ð6WØ'0Ô2Jð'Là -Ð1\Ð^gÐinÐ!oð
ð 	
r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úcfgrm   Ú	home_pathr   r   r   r   )r   s   "r   r   rn   ¨   s!   € ÷ ñ ˜ð ¨$ð °;ñ r   c                	ó‚  € \        V\        4      '       d   TM/ p\        4       p\        VP	                  R 4      ;'       g    R4      P                  4       pV'       g!   VP                  R\        P                  4      # \        4       '       d!   VP                  R\        P                  4      # \        VP	                  R\        4      \        4      p\        VRV\        4      pVf!   VP                  R\        P                  4      # \        V4      pV'       g   VP                   P#                  R4       V# Wsn        V# )r/   rs   zmsecrets.command.enabled is true but secrets.command.command is empty.  Set the helper command in config.yaml.zNthe 'command' secret source is POSIX-only (needs /bin/sh); skipping on Windowsrt   zGhelper command failed (see structured fields above); no secrets appliedz7helper output was not a KEY=VALUE map; nothing to apply)Ú
isinstancerm   r   r   Úgetr+   Úfailr   ÚNOT_CONFIGUREDr   r	   rv   r[   Ú_MAX_OUTPUT_BYTESÚINTERNALrh   ÚwarningsÚappendÚsecrets)rw   r{   r|   Úresultr/   r;   r9   r†   s   &&&     r   ÚfetchÚCommandSource.fetch¨   s  € Ü ¤T×*Ò*‰c°ˆÜ“ˆä�c—g‘g˜iÓ(×.Ð.¨BÓ/×5Ñ5Ó7ˆßØ—;‘;ð  SÜT]×TlÑTlónð nä�=Š=Ø—;‘;ÐoÜ(×7Ñ7ó9ð 9ô ˜sŸw™wÐ'?ÔAYÓZÜ7ó9ˆä˜W b¨'Ô3DÓEˆØŠ>Ø—;‘;ÐhÜ(×1Ñ1ó3ð 3ô $ FÓ+ˆßØ�O‰O×"Ñ"Ð#\Ô]ØˆMØ ŒØˆr   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   ÚlabelÚshaper   r�   rƒ   Úremediation_hintsrx   rˆ   Ú__static_attributes__r   r   r   rj   rj   †   sL   † ñ
ð €DØ€EØ€Eà× Ñ ð #Xà×Ñð /ðÐõ
÷ñ r   rj   i   ) rŽ   Ú
__future__r   r   r   ÚreÚsignalrL   rA   r$   Úpathlibr   Útypingr   r   Úagent.secret_sources.baser   r   r   r	   r
   Ú__all__rv   r‚   Úcompilerb   r   r&   r   r[   rh   rj   r   r   r   Ú<module>r›      s}   ðñõ  #ã 	Û Û 	Û Û Û 
Ý ß !ç jÕ jàÐ0Ð
1€ð Ð ØÐ ð �JŠJÐ9Ó:€	õ=õ;õ	õ9:õx
ô:�Lö :r   