+
    i                     \   R t ^ RIt^ RIt^ RI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 ]P"                  P%                  ^ ]! ]! ]4      P*                  P*                  4      4       ^ RIHt ^ RIHt ^ RIHt ]P:                  ! ]4      t] ! 0 Rm4      t!^ RI"H#t#H$t$H%t%H&t& Rt']! 4       t(](R	,          t)])R
,          t*R R lt+R R lt,RR R llt-^xt.R R lt/R R lt0R R lt1RR R llt2]R8X  d   ]2! RR7       R# R#   ]
 d    Rt	 ^ RIt L  ]
 d    Rt  ELi ; ii ; i)a  
Cron job scheduler - executes due jobs.

Provides tick() which checks for due jobs and runs them. The gateway
calls this every 60 seconds from a background thread.

Uses a file-based lock (~/.hermes/cron/.tick.lock) so only one tick
runs at a time if multiple processes overlap.
N)Path)Optionalget_hermes_home)load_config)now)get_due_jobsmark_job_runsave_job_outputadvance_next_runz[SILENT]cronz
.tick.lockc                F    V ^8  d   QhR\         R\        \         ,          /#    jobreturndictr   )formats   "+/home/ubuntu/hermes-agent/cron/scheduler.py__annotate__r   B   s     	 	 	(4. 	    c                    V P                  R4      pV'       g   R# VP                  R4      pVP                  R4      pV'       d   V'       d   V# R# )zFExtract origin info from a job, preserving any extra routing metadata.originNplatformchat_id)get)r   r   r   r   s   &   r   _resolve_originr   B   s?    WWXFzz*%Hjj#GGr   c                F    V ^8  d   QhR\         R\        \         ,          /# r   r   )r   s   "r   r   r   N   s"     Q Q$ Q8D> Qr   c                   V P                  RR4      p\        V 4      pVR8X  d   R# VR8X  d   V'       d/   RVR,          R\        VR,          4      RVP                  R4      /# R Ft  p\        P                  ! VP                  4        R2R	4      pV'       g   K5  \        P                  R
V P                  RV P                  RR4      4      V4       RVRVRR/u # 	  R# RV9   d{   TP                  R^4      w  r5VP                  4       p^ RI
Hp V! We4      w  rp
V
'       d   YrMTRr ^ RIHp V! Wd4      pV'       d   V! Wm4      w  rpV'       d   YrMTpRVRVRV/# TpV'       d>   VP                  R4      V8X  d(   RVR\        VR,          4      RVP                  R4      /# VP                  4       \        9  d   R# \        P                  ! VP                  4        R2R	4      pV'       g   R# RVRVRR/#   \         d     Li ; i)zAResolve the concrete auto-delivery target for a cron job, if any.deliverlocalNr   r   r   	thread_id_HOME_CHANNEL zJJob '%s' has deliver=origin but no origin; falling back to %s home channelnameid?:)_parse_target_ref)resolve_channel_name)matrixtelegramdiscordslack)r   r   strosgetenvupperloggerinfosplitlowertools.send_message_toolr)   gateway.channel_directoryr*   	Exception_KNOWN_DELIVERY_PLATFORMS)r   r    r   platform_namer   restplatform_keyr)   parsed_chat_idparsed_thread_idis_explicitr"   r*   resolvedresolved_is_explicits   &              r   _resolve_delivery_targetrC   N   s,   ggi)GS!F'(F:.3vi01VZZ4  HMii=#6#6#8"9 GLGw`GGFCGGD#$67! w  H 
g~%mmC3$**,=8I,8]5+!/Y!%tY
	F+LBHIZ[gIrF2F')7Y&G
 w
 	
 M&**Z(M9s6),-K0
 	
 $==ii=..01?DG 	M7T /  		s   ++G= G= =H
Hc                4    V ^8  d   QhR\         R\        RR/# )r   r   contentr   Nr   r/   )r   s   "r   r   r      s+     AW AW AW AW$ AWr   c                ,
   \        V 4      pV'       gH   V P                  RR4      R8w  d/   \        P                  RV R,          V P                  RR4      4       R# TR,          pVR,          pVP                  R4      p^ R	IHp ^ R
IHp	Hp
 RV
P                  RV
P                  RV
P                  RV
P                  RV
P                  RV
P                  RV
P                  RV
P                   RV
P"                  RV
P$                  RV
P&                  RV
P(                  RV
P*                  /pVP                  VP-                  4       4      pV'       g!   \        P                  RV R,          V4       R#  V	! 4       pTP2                  P                  T4      pT'       d   TP4                  '       g!   \        P                  RT R,          T4       R# Rp \7        4       pTP                  R/ 4      P                  RR4      pT'       d$   T P                  RT R,          4      pRT R T R!2pMTp^ R"IHp TP=                  T4      w  ppT;'       g    / P                  T4      pTe   Te   \?        TR#R$ 4      ! 4       '       d   T'       d   RT/MRp \@        PB                  ! TPE                  TTTR%7      T4      pTPG                  ^<R&7      pT'       dA   \?        TR'R4      '       g.   \?        TR(R)4      p\        P                  R*T R,          YVT4       M \        PI                  R+T R,          YV4       R# T! YTTTTR-7      p \@        PJ                  ! T4      pX'       d?   TP                  R(4      '       d(   \        P1                  R0T R,          TR(,          4       R# \        PI                  R1T R,          YV4       R#   \.         d*   p\        P1                  RT R,          T4        Rp?R# Rp?ii ; i  \.         d     ELi ; i  \.         d+   p\        P                  R,T R,          YVT4        Rp?ELRp?ii ; i  \L         d    TPO                  4        ^ RI(pTPR                  PU                  ^R.7      ;_uu_ 4       pTPW                  \@        PJ                  T! YTTTTR-7      4      pTPG                  ^R&7      pRRR4        EKt    + '       g   i      EL; i\.         d+   p\        P1                  R/T R,          YVT4        Rp?R# Rp?ii ; i)2ub  
Deliver job output to the configured target (origin chat, specific platform, etc.).

When ``adapters`` and ``loop`` are provided (gateway is running), tries to
use the live adapter first — this supports E2EE rooms (e.g. Matrix) where
the standalone HTTP path cannot encrypt.  Falls back to standalone send if
the adapter path fails or is unavailable.
r    r!   zEJob '%s' deliver=%s but no concrete delivery target could be resolvedr&   Nr   r   r"   )_send_to_platform)load_gateway_configPlatformr,   r-   r.   whatsappsignalr+   
mattermosthomeassistantdingtalkfeishuwecomemailsmsz,Job '%s': unknown platform '%s' for deliveryz8Job '%s': failed to load gateway config for delivery: %sz.Job '%s': platform '%s' not configured/enabledTr   wrap_responser%   zCronjob Response: z
-------------

zN

Note: The agent cannot see this message, and therefore cannot respond to it.)BasePlatformAdapter
is_runningc                      R # )F rX   r   r   <lambda>!_deliver_result.<locals>.<lambda>   s    `er   )metadatatimeoutsuccesserrorunknownzLJob '%s': live adapter send to %s:%s failed (%s), falling back to standalonez-Job '%s': delivered to %s:%s via live adapterzPJob '%s': live adapter delivery to %s:%s failed (%s), falling back to standalone)r"   media_filesmax_workersz&Job '%s': delivery to %s:%s failed: %szJob '%s': delivery error: %szJob '%s': delivered to %s:%s),rC   r   r3   warningr7   rH   gateway.configrI   rJ   TELEGRAMDISCORDSLACKWHATSAPPSIGNALMATRIX
MATTERMOSTHOMEASSISTANTDINGTALKFEISHUWECOMEMAILSMSr6   r9   r_   	platformsenabledr   gateway.platforms.baserU   extract_mediagetattrasynciorun_coroutine_threadsafesendresultr4   runRuntimeErrorcloseconcurrent.futuresfuturesThreadPoolExecutorsubmit) r   rE   adapterslooptargetr;   r   r"   rH   rI   rJ   platform_mapr   configepconfigrT   user_cfg	task_namedelivery_contentrU   ra   cleaned_delivery_contentruntime_adaptersend_metadatafuturesend_resulterrcoror{   
concurrentpools    &&&&                            r   _deliver_resultr      s{    &c*F779g&'1NNWD		7+
 	:&MYG

;'I9< 	H%%8##H%%(//(//h))//H%%(//x||L  3 3 56HEs4yR_`$&
 ""8,G'///GTTab
 M= VR044_dK GGFCI.	  , i [\ 	 # ;,?,M,MN^,_)K)  ~~2**84O"t'7GD,Xe<f<h<h4=i04	55$$W.>$WF !---3K7;	4#H#Hk7I>bI}s
 KSQUYXeo X9Q]ft  ADT" &**W%%3SYwP2CI}Vc  OQTUYQZ\]^   L  	NNbD	=1 	  	/
 	

!22q2AAT[[.?SZ\t  AJ  Xc  /d  eF]]2].F BAAA  =s4y-bcds   2N< ,O3 AP ?P P  P= <O0O++O03PPP:P55P:=AT >S
>T
STT(T)TTc                R    V ^8  d   QhR\         R\        \        \         3,          /# )r   script_pathr   )r/   tuplebool)r   s   "r   r   r   )  s'     K8 K8 K8tSy)9 K8r   c           	        ^ RI Hp V! 4       R,          pVP                  RRR7       VP                  4       p\	        V 4      P                  4       pVP                  4       '       d   VP                  4       pMW$,          P                  4       p VP                  V4       TP                  4       '       g   RRT 23# TP                  4       '       g   RR	T 23#  \        P                  ! \        P                  \        T4      .RR\         \        TP"                  4      R
7      pTP$                  ;'       g    RP'                  4       pTP(                  ;'       g    RP'                  4       pTP*                  ^ 8w  d\   RTP*                   2.p	T'       d   T	P-                  RT 24       T'       d   T	P-                  RT 24       RRP/                  T	4      3#  ^ RIHp
 T
! T4      pRT3#   \         d    RRT RT : 23u # i ; i  \4         d     L-i ; i  \        P6                   d    RR\          RT 23u # \4         d   pRRT 23u Rp?# Rp?ii ; i)u  Execute a cron job's data-collection script and capture its output.

Scripts must reside within HERMES_HOME/scripts/.  Both relative and
absolute paths are resolved and validated against this directory to
prevent arbitrary script execution via path traversal or absolute
path injection.

Args:
    script_path: Path to a Python script.  Relative paths are resolved
        against HERMES_HOME/scripts/.  Absolute and ~-prefixed paths
        are also validated to ensure they stay within the scripts dir.

Returns:
    (success, output) — on failure *output* contains the error message so the
    LLM can report the problem to the user.
r   scriptsTparentsexist_okFz=Blocked: script path resolves outside the scripts directory (z): zScript not found: zScript path is not a file: )capture_outputtextr]   cwdr$   zScript exited with code zstderr:
zstdout:

)redact_sensitive_textzScript timed out after zs: zScript execution failed: N)hermes_constantsr   mkdirresolver   
expanduseris_absoluterelative_to
ValueErrorexistsis_file
subprocessr|   sys
executabler/   _SCRIPT_TIMEOUTparentstdoutstripstderr
returncodeappendjoinagent.redactr   r9   TimeoutExpired)r   r   scripts_dirscripts_dir_resolvedrawpathr{   r   r   partsr   excs   &           r   _run_job_scriptr   )  sJ   " 1!#i/KdT2&..0
{

&
&
(C
{{}!**,
-. ;;==*4&111<<>>3D6:::8^^SY'#DKK 
 --%%2,,.--%%2,,.!/0A0A/BCDEy12y12$))E***	:*62F V|K  
$%S9
 	

F  		 $$ K//@D6JJJ 81#7778sy   G- AH 9#H 9H H 3&H H	 )H -HH	HH HH #I?II	IIIc                0    V ^8  d   QhR\         R\        /# r   rF   )r   s   "r   r   r   w  s     W W4 WC Wr   c           
        V P                  RR4      pV P                  R4      pV P                  R4      pV'       d5   \        V4      w  rEV'       d   V'       d
   RV RV 2pMRV 2pMRV RV 2pR	pWa,           pVf   V P                  R
4      pV'       d   V.M. pV Uu. uF=  p\        V4      P                  4       '       g   K$  \        V4      P                  4       NK?  	  p	pV	'       g   V# ^ RIHp
 . p. pV	 EF  p\        P                  ! V
! V4      4      pVP                  R4      '       gi   VP                  R4      ;'       g    RV R2p\        P                  RV P                  RV P                  R4      4      V4       VP                  V4       K  \        VP                  R4      ;'       g    R4      P                  4       pV'       d   VP                  R4       VP                  RV R2RV.4       EK  	  V'       d:   RRP                  V4       RRP                  V4       R2pVP                  ^ V4       V'       d   VP                  RRV 2.4       RP                  V4      # u upi )zWBuild the effective prompt for a cron job, optionally loading one or more skills first.promptr$   skillsscriptzq## Script Output
The following data was collected by a pre-run script. Use it as context for your analysis.

```
z
```

z3[Script ran successfully but produced no output.]

zQ## Script Error
The data-collection script failed. Report this to the user.

```
u  [SYSTEM: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]

skill)
skill_viewr^   r_   zFailed to load skill ''u/   Cron job '%s': skill not found, skipping — %sr%   r&   rE   z#[SYSTEM: The user has invoked the "zf" skill, indicating they want you to follow its instructions. The full skill content is loaded below.]zb[SYSTEM: The following skill(s) were listed for this job but could not be found and were skipped: z, un   . Start your response with a brief notice so the user is aware, e.g.: '⚠️ Skill(s) not found and skipped: z']zPThe user has provided the following instruction alongside the skill invocation: r   )r   r   r/   r   tools.skills_toolr   jsonloadsr3   rd   r   extendr   insert)r   r   r   r   r^   script_output	cron_hintlegacyr%   skill_namesr   r   skipped
skill_nameloadedr_   rE   notices   &                 r   _build_job_promptr   w  sl   WWXr"FWWXF ''(#K!0!= *?)h	   Lh  %i( 	D  F~!#&17M3t9??;L$3t9??$KM,EG!
Jz23zz)$$JJw'QQ-CJ<q+QENNLcggV\^a^e^efj^kNlnstNN:&fjj+11r288:LL5j\  Bh  i	
 "& !!%7!3 4 577;yy7I6J"N 	 	Qblmsltuvw99UM Ns   !!I3I3c          	      |    V ^8  d   QhR\         R\        \        \        \        \        \        ,          3,          /# r   )r   r   r   r/   r   )r   s   "r   r   r     s4     c^ c^ c^%c3 => c^r   c                   ^ RI Hp Rp ^ RIHp V! 4       pV R,          pV R,          p\        V 4      p\        V 4      pRV R	\        4       P                  R
4       2p	\
        P                  RWe4       \
        P                  RVR,          4        V'       do   VR,          \        P                  R&   \        VR,          4      \        P                  R&   VP                  R4      '       d   VR,          \        P                  R&   ^ RIHp
  V
! \        \$        R,          4      RRR7       \)        V 4      pV'       dt   VR,          \        P                  R&   \        VR,          4      \        P                  R&   VP                  R4      e$   \        VR,          4      \        P                  R&   V P                  R4      ;'       g!    \        P*                  ! R4      ;'       g    R p/ p ^ RIp\        \$        R!,          4      p\        P.                  P1                  V4      '       d   \3        V4      ;_uu_ 4       pVP5                  V4      ;'       g    / pRRR4       VP                  R/ 4      pV P                  R4      '       gB   \7        V\        4      '       d   TpM(\7        V\8        4      '       d   VP                  R"V4      p^ R$IHp \        P*                  ! R%R 4      pV'       g:   \        VP                  R&/ 4      P                  R'R 4      4      PA                  4       pV! V4      pRp\        P*                  ! R(R 4      ;'       g    VP                  R)R 4      pV'       d   ^ RI!p\E        V4      PG                  4       pVPI                  4       '       g   \$        V,          pVP1                  4       '       dJ    \3        VR*RR+7      ;_uu_ 4       pVPK                  V4      pRRR4       \7        V\L        4      '       g   RpVP                  R&/ 4      P                  R-4      ;'       g    VP                  R-4      ;'       g    ^ZpVP                  R./ 4      pVP                  R// 4      ;'       g    / p^ R0I'H(pH)p  R1V P                  R24      ;'       g    \        P*                  ! R34      /pV P                  R44      '       d   V P                  R44      VR5&   V! R{/ VB p ^ R6I+H,p# T#! TTRTR7T P                  R74      R4T P                  R44      R2T P                  R24      R8T P                  R84      R9T P                  R94      R:\M        T P                  R:4      ;'       g    . 4      /4      p$T! R{/ RT$R,          bR7T$R;,          P                  R74      bR4T$R;,          P                  R44      bR2T$R;,          P                  R24      bR8T$R;,          P                  R84      bR<T$R;,          P                  R94      bR=T$R;,          P                  R:4      bR>TbR?TbR@TbRATP                  RB4      bRCTP                  RD4      bRETP                  RF4      bRGTP                  RH4      bRI. R|ObRJRbRKRbRRLbRMT	bRNTb p%\[        \        P*                  ! RORP4      4      p&T&^ 8  d   T&MRp'RQp(\\        P^                  Pa                  ^RR7      p)T)Pc                  T%Pd                  T4      p*RSp+ T'f   T*Pg                  4       p,MRp, \\        P^                  Pi                  T*0T(RT7      w  p-p.T-'       d   T*Pg                  4       p,MCRUp/\k        T%RV4      '       d$    T%Pm                  4       p0T0P                  RWRU4      p/T/T'8  g   K  Rp+ T)Po                  RSRY7       T+'       d   / p1\k        T%RV4      '       d    T%Pm                  4       p1T1P                  RZR[4      p2T1P                  RW^ 4      p3T1P                  R\4      p4T1P                  R]^ 4      p5T1P                  R>^ 4      p6\
        Pq                  R^TT3T'T2T5T6T4;'       g    R_4       \k        T%R`4      '       d   T%Ps                  Ra4       \u        RbT Rc\w        T34       Rd\w        T'4       ReT2 24      hT,P                  RfR 4      ;'       g    R p7T7'       d   T7MRgp8RhT RiT Rj\        4       P                  Rk4       RlT P                  RmRn4       RoT RpT8 Rq2p9\
        P                  RrT4       RT9T7R3R} F#  p:\        P                  Py                  T:R4       K%  	  T'       d&    TP{                  T	Rs4        TP                  4        # #   \         d3   p\
        P                  RT P                  RR4      T4        Rp?E	LRp?ii ; i  \&         d$    T
! \        \$        R,          4      RRR7        ELi ; i  + '       g   i     EL; i  \         d"   p\
        P;                  R#YT4        Rp?ELFRp?ii ; i  + '       g   i     EL7; i  \         d&   p\
        P;                  R,TTT4       Rp Rp?ELMRp?ii ; i  \         d   p!T! T!4      p"\U        T"4      T!hRp!?!ii ; i  \         d     ELi ; i  \         d    T)Po                  RSRRX7       h i ; i  T)Po                  RSRY7       i ; i  \         d     ELi ; i  \        \|        3 d"   p\
        P                  RtYT4        Rp?ELRp?ii ; i  \        \|        3 d!   p\
        P                  RuYT4        Rp?# Rp?ii ; i  \         EdF   p\        T4      P                   Rv\        T4       2p;\
        P                  RwTT;4       RhT RxT Rj\        4       P                  Rk4       RlT P                  RmRn4       RoT RyT; Rz2p9RST9R T;3u Rp?R} F#  p:\        P                  Py                  T:R4       K%  	  T'       d    TP{                  T	Rs4       M4  \        \|        3 d!   p\
        P                  RtYT4        Rp?MRp?ii ; i TP                  4        #   \        \|        3 d!   p\
        P                  RuYT4        Rp?# Rp?ii ; i# Rp?ii ; i  R} F#  p:\        P                  Py                  T:R4       K%  	  T'       d    TP{                  T	Rs4       M4  \        \|        3 d!   p\
        P                  RtYT4        Rp?MRp?ii ; i TP                  4        i   \        \|        3 d!   p\
        P                  RuYT4        Rp?i Rp?ii ; ii ; i)~zm
Execute a single cron job.

Returns:
    Tuple of (success, full_output_doc, final_response, error_message)
)AIAgentN)	SessionDBz0Job '%s': SQLite session store not available: %sr&   r'   r%   cron__z%Y%m%d_%H%M%SzRunning job '%s' (ID: %s)z
Prompt: %s:Nd   Nr   HERMES_SESSION_PLATFORMr   HERMES_SESSION_CHAT_ID	chat_nameHERMES_SESSION_CHAT_NAME)load_dotenvz.envTzutf-8)overrideencodingzlatin-1!HERMES_CRON_AUTO_DELIVER_PLATFORM HERMES_CRON_AUTO_DELIVER_CHAT_IDr"   "HERMES_CRON_AUTO_DELIVER_THREAD_IDmodelHERMES_MODELr$   zconfig.yamldefaultz8Job '%s': failed to load config.yaml, using defaults: %s)parse_reasoning_effortHERMES_REASONING_EFFORTagentreasoning_effortHERMES_PREFILL_MESSAGES_FILEprefill_messages_filer)r   z8Job '%s': failed to parse prefill messages file '%s': %s	max_turnsprovider_routingsmart_model_routing)resolve_runtime_providerformat_runtime_provider_error	requestedproviderHERMES_INFERENCE_PROVIDERbase_urlexplicit_base_url)resolve_turn_routeapi_keyapi_modecommandargsruntimeacp_commandacp_argsmax_iterationsreasoning_configprefill_messagesproviders_allowedonlyproviders_ignoredignoreproviders_orderorderprovider_sortsortdisabled_toolsets
quiet_modeskip_memoryr   
session_id
session_dbHERMES_CRON_TIMEOUTiX  g      @rb   Fr\   g        get_activity_summaryseconds_since_activity)waitcancel_futures)r  last_activity_descr`   current_toolapi_call_countz_Job '%s' idle for %.0fs (inactivity limit %.0fs) | last_activity=%s | iteration=%s/%s | tool=%snone	interruptzCron job timed out (inactivity)z
Cron job 'z' idle for z	s (limit u   s) — last activity: final_responsez(No response generated)z# Cron Job: z

**Job ID:** z
**Run Time:** z%Y-%m-%d %H:%M:%Sz
**Schedule:** schedule_displayzN/Az

## Prompt

z

## Response

r   zJob '%s' completed successfullycron_completez#Job '%s': failed to end session: %sz2Job '%s': failed to close SQLite session store: %sz: zJob '%s' failed: %sz (FAILED)

**Job ID:** z

## Error

```
z
```
rX   )cronjob	messagingclarify)r   r   r   r   r   r   )C	run_agentr   hermes_stater   r9   r3   debugr   r   r   _hermes_nowstrftimer4   r0   environr/   dotenvr   _hermes_homeUnicodeDecodeErrorrC   r1   yamlr   r   open	safe_load
isinstancer   rd   r   r   r   r   r   r   r   loadlisthermes_cli.runtime_providerr   r   r}   agent.smart_model_routingr   floatr   r   r   r   run_conversationr{   r  hasattrr  shutdownr_   r  TimeoutErrorintpopend_sessionKeyboardInterruptr~   type__name__	exception)<r   r   _session_dbr   r   job_idjob_namer   r   _cron_session_idr   delivery_targetr   _cfgr.  	_cfg_path_f
_model_cfgr   effortr  r  prefill_file_jsonpfpath_pfr  prsmart_routingr   r   runtime_kwargsr  r   messager   
turn_router   _cron_timeout_cron_inactivity_limit_POLL_INTERVAL
_cron_pool_cron_future_inactivity_timeoutr{   doner   
_idle_secs_act	_activity
_last_desc	_secs_ago	_cur_tool_iter_n	_iter_maxr  logged_responseoutputkey	error_msgs<   &                                                           r   run_jobrh    s    " K`*k YF6{Hs#FS!Fvha(>(>(O'PQ
KK+X>
KKfTl+H^ 4::4FBJJ0136vi7H3IBJJ/0zz+&&9?9L

56 	'	WL612TGT 337>Mj>YBJJ:;=@QZA[=\BJJ9:"";/;CFWbGcCd

?@ CCBIIn$=CC 	bL=89Iww~~i(()__>>"-33D %!XXgr2
www''!*c22 *#J55 *y% @
 	<4b9'2.223ErJKQQSF1&9  yy!?DmmQhjlHm ,'224F%%''%.}},fcG<<+0::c?( =%&6==+/( '2.22;?^^488KCX^^\^ XX("-!6;AAr	
		1SWWZ0ZZBII>Y4ZN wwz""69ggj6I23.@@G
 	A'7;;y1GKK
3GKK
3GKK
37;;y1W[[066B7

  
W%
y)--i8
  	*..z:
  	*..z:	

  	*..z:
 #9-11)<
  	*..v6
 *
 .
 .
 !ffVn
 !ffX.
 FF7O
 &&.
 B
  !
" #
$ %
& ('
( #)
> bii(=sCD2?!2C''::q:I
!(()?)?H#	,%-%,,.(0055% 6 GD! !-!4!4!6!$Ju&<==!#(#=#=#?D)-2JC)PJ "%;;.2+
 U+Iu455 % : : <I #';YGJ!&>BI!n5Imm$4a8G!&6:ILLA)%;GY##V uk** ABXJky>")C0F,G+H I&&0\3   $4b9??R -;.@Y!( ,H }%%&9:; <ww)512 3  	    	5x@V^T14
C JJNN3%
 O''(8/J^!!# Y  `GQUWZI[]^__`2 " 	WL612TIVV	W$ %__  	bNNUW]aa	b( =<< ! ,NN#]_egmopq'+$,,  	13C8Gw'S0	1V  ) ! !
  	U4@	 U+ ! d 01 OBFNNO 01 ^QSY]]^Q  ,Aw''(3q6(3	.)D!( ,H }%%&9:; <ww)512 3  	
    fb)++
C JJNN3%
 O''(8/J01 OBFNNO^!!#01 ^QSY]]^ C,0
C JJNN3%
 O''(8/J01 OBFNNO^!!#01 ^QSY]]^ s  e* A<m f* .Bm m *m 0Ag/ g0g/ g/ 'm ((g/ $m 5A m m 1Am h2 h0 h2 'm 8m -m ?m i% $.i% i% /A>m .Fm 1j k /j 6j k j "j >j j 	k 
m $m 9k 	A7m A+m -
m 8Am k*l*f'5'f""f'**gm gm g,	&	g/ /h:hm hm h/	)	h2 2i"=im i""m %j	0jj		m jj jj  j>>k km k'#m &k''m *l;llm0mmr$A;rr$r' p$$q5qqq**r;rrr$$r' '1u(s-,u(-t>tu(tu("t32u(3u$uu(u$$u(Tc                0    V ^8  d   QhR\         R\        /# )r   verboser   )r   r;  )r   s   "r   r   r     s     W W$ WC Wr   c           	     
   \         P                  RRR7       Rp \        \        R4      p\        '       d<   \        P
                  ! V\        P                  \        P                  ,          4       M@\        '       d5   \        P                  ! VP                  4       \        P                  ^4        \#        4       pV '       d   V'       g   \        P%                  R\'        4       P)                  R4      4        \        '       d'   \        P
                  ! V\        P*                  4       MA\        '       d6    \        P                  ! VP                  4       \        P,                  ^4       VP!                  4        ^ # V '       d8   \        P%                  R\'        4       P)                  R4      \/        V4      4       ^ pV EF  p \1        VR	,          4       \3        V4      w  rxr\5        VR	,          V4      pV '       d   \        P%                  R
V4       V'       d   T	MRVP7                  RVR	,          4       RV
 2p\9        V4      pV'       dT   V'       dL   \:        VP=                  4       P?                  4       9   d%   \        P%                  RVR	,          \:        4       RpV'       d    \A        WlWR7       \G        VR	,          Wz4       V^,          pEK  	  T\        '       d'   \        P
                  ! V\        P*                  4       MA\        '       d6    \        P                  ! VP                  4       \        P,                  ^4       VP!                  4        #   \        \        3 d.    \        P                  R4       Te   TP!                  4         ^ # i ; i  \        \        3 d     ELKi ; i  \B         d*   p\        PE                  RTR	,          T4        Rp?EL.Rp?ii ; i  \B         dH   p\        PE                  RTR	,          T4       \G        TR	,          R\I        T4      4        Rp?EK~  Rp?ii ; i  \        \        3 d     EL
i ; i  \        '       d'   \        P
                  ! T\        P*                  4       MY\        '       dN    \        P                  ! TP                  4       \        P,                  ^4       M  \        \        3 d     Mi ; iTP!                  4        i ; i)u  
Check and run all due jobs.

Uses a file lock so only one tick runs at a time, even if the gateway's
in-process ticker and a standalone daemon or manual tick overlap.

Args:
    verbose: Whether to print status messages
    adapters: Optional dict mapping Platform → live adapter (from gateway)
    loop: Optional asyncio event loop (from gateway) for live adapter sends

Returns:
    Number of jobs executed (0 if another tick is already running)
Tr   Nwu0   Tick skipped — another instance holds the lockz%s - No jobs duez%H:%M:%Sz%s - %s job(s) duer&   zOutput saved to: %su   ⚠️ Cron job 'r%   z
' failed:
u1   Job '%s': agent returned %s — skipping deliveryF)r   r   zDelivery failed for job %s: %szError processing job %s: %s)%	_LOCK_DIRr   r/  
_LOCK_FILEfcntlflockLOCK_EXLOCK_NBmsvcrtlockingfilenoLK_NBLCKOSErrorIOErrorr3   r'  r~   r   r4   r(  r)  LOCK_UNLK_UNLCKlenr   rh  r
   r   r   SILENT_MARKERr   r2   r   r9   r_   r	   r/   )rj  r   r   lock_fddue_jobsexecutedr   r^   re  r  r_   output_filedeliver_contentshould_deliverder   s   &&&             r   tickr    s    OOD4O0 G
z3'5KK!>?VNN7>>+V__a@8>8KK*KM,B,B:,NOX 5KK/Vw~~/!D 	c KK,km.D.DZ.PRUV^R_`C!7
 !T+9@6-c$i@KK 5{C
 5<.CTUXU\U\]cehimenUoTpp{  }B  |C  BD!%o!6!g-?CXCXCZC`C`Cb2bKK SUXY]U^`mn%*N!V'x[ SY7A= H 5KK/Vw~~/!D 	} W GHMMO	x W% # % V%Es4yRTUUV  7:CIqISYs1v667 W%  5KK/Vw~~/!DW% s   AM$ 2M$ >4M$ 3Q! -Q! :4N%  Q! ?Q! AO4!;O4AO41N=>O4Q! 4Q	$:N"!N"%N:9N:=O1O,&O4,O11O44Q?;Q:Q! QQ! 	QQ!>S>!4SS>S*'S>)S**S>__main__)rj  >   rS   rR   r.   rQ   rP   r+   rL   r-   webhookrO   r,   rK   rM   rN   )NN)TNN)3__doc__rx   r   r   r   loggingr0   r   r   ro  ImportErrorrs  timepathlibr   typingr   r   r   r/   __file__r   r   r   hermes_cli.configr   hermes_timer   r(  	getLoggerr@  r3   	frozensetr:   	cron.jobsr   r	   r
   r   r|  r,  rm  rn  r   rC   r   r   r   r   rh  r  rX   r   r   <module>r     s:       	  
   
 3tH~,,334 5 , ) *			8	$ & '   T S
    6!	%
	QhAWH K8\Wtc^L	Wt z w  E 	s)   D	 		D+D	D'"D+&D''D+