4
4
from src .webhooks .server import WebhookServer
5
5
from src .util .logging import Logger
6
6
from src .actions .result import ActionResult
7
+ from src .jobs .base import JobStatus
8
+ from src .config .config import Config
9
+ import os
7
10
8
11
9
12
class StatusAction (BaseAction ):
@@ -13,7 +16,8 @@ class StatusAction(BaseAction):
13
16
name = "status" ,
14
17
description = "Show system status" ,
15
18
help_text = """Show the current status of the system, including:
16
- - Running jobs
19
+ - Job statistics
20
+ - Installed extensions
17
21
- Scheduled actions
18
22
- Webhook server status""" ,
19
23
agent_hint = "Use this command to check the system status" ,
@@ -22,29 +26,53 @@ class StatusAction(BaseAction):
22
26
23
27
def __init__ (self ):
24
28
self .logger = Logger ("StatusAction" )
29
+ self .config = Config ()
25
30
26
31
async def execute (self , * args ) -> ActionResult :
27
32
"""Execute the status action"""
28
33
try :
29
34
lines = []
30
35
31
- # Add running jobs section
32
- lines .append ("🏃 Running Jobs :" )
36
+ # Add job statistics section
37
+ lines .append ("📊 Job Statistics :" )
33
38
try :
34
- # Get job status
35
39
job_manager = await JobManager .get_instance ()
36
40
jobs = await job_manager .list_jobs ()
37
41
38
- if jobs :
39
- for job in jobs :
40
- lines .append (f"• { job ['id' ]} ({ job ['type' ]} , status: { job ['status' ]} )" )
42
+ # Count jobs by status
43
+ running = sum (1 for job in jobs if job ["status" ] == JobStatus .RUNNING .value )
44
+ completed = sum (1 for job in jobs if job ["status" ] == JobStatus .COMPLETED .value )
45
+ cancelled = sum (1 for job in jobs if job ["status" ] == JobStatus .CANCELLED .value )
46
+
47
+ lines .append (f"• Running: { running } " )
48
+ lines .append (f"• Completed: { completed } " )
49
+ lines .append (f"• Cancelled: { cancelled } " )
50
+ except Exception as e :
51
+ lines .append (f"• Error getting job statistics: { str (e )} " )
52
+
53
+ # Add installed extensions section
54
+ lines .append ("\n 🧩 Installed Extensions:" )
55
+ try :
56
+ extensions_dir = self .config .get ("extensions_dir" , "./extensions" )
57
+ if os .path .exists (extensions_dir ):
58
+ # Get list of directories in extensions folder
59
+ extension_dirs = [
60
+ d
61
+ for d in os .listdir (extensions_dir )
62
+ if os .path .isdir (os .path .join (extensions_dir , d )) and not d .startswith ("_" )
63
+ ]
64
+ if extension_dirs :
65
+ for ext_dir in sorted (extension_dirs ):
66
+ lines .append (f"• { ext_dir } " )
67
+ else :
68
+ lines .append ("• No extensions installed" )
41
69
else :
42
- lines .append ("• No jobs currently running " )
70
+ lines .append ("• Extensions directory not found " )
43
71
except Exception as e :
44
- lines .append (f"• Error getting jobs : { str (e )} " )
72
+ lines .append (f"• Error getting extensions : { str (e )} " )
45
73
74
+ # Add scheduled actions section
46
75
try :
47
- # Get scheduled actions status
48
76
scheduler = await Scheduler .get_instance ()
49
77
actions = scheduler .list_actions ()
50
78
@@ -65,8 +93,8 @@ async def execute(self, *args) -> ActionResult:
65
93
except Exception as e :
66
94
lines .append (f"• Error getting scheduled actions: { str (e )} " )
67
95
96
+ # Add webhook server status section
68
97
try :
69
- # Get webhook status
70
98
webhook_server = await WebhookServer .get_instance ()
71
99
lines .append ("\n 🌐 Webhook Server:" )
72
100
if webhook_server and webhook_server .runner :
0 commit comments