4runr-os 2.10.39 → 2.10.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/apps/gateway/dist/apps/gateway/src/index.js +14 -4
  2. package/apps/gateway/dist/apps/gateway/src/index.js.map +1 -1
  3. package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.d.ts +18 -0
  4. package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.d.ts.map +1 -0
  5. package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.js +117 -0
  6. package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.js.map +1 -0
  7. package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.d.ts +2 -0
  8. package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.d.ts.map +1 -0
  9. package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.js +54 -0
  10. package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.js.map +1 -0
  11. package/apps/gateway/dist/apps/gateway/src/routes/monitoring.d.ts +15 -0
  12. package/apps/gateway/dist/apps/gateway/src/routes/monitoring.d.ts.map +1 -0
  13. package/apps/gateway/dist/apps/gateway/src/routes/monitoring.js +164 -0
  14. package/apps/gateway/dist/apps/gateway/src/routes/monitoring.js.map +1 -0
  15. package/apps/gateway/package-lock.json +204 -353
  16. package/apps/gateway/src/index.ts +27 -8
  17. package/apps/gateway/src/metrics/monitoring-detail.ts +162 -0
  18. package/apps/gateway/src/middleware/log-capture.ts +70 -0
  19. package/apps/gateway/src/routes/monitoring.ts +298 -0
  20. package/dist/gateway-client.d.ts +2 -0
  21. package/dist/gateway-client.d.ts.map +1 -1
  22. package/dist/gateway-client.js +22 -0
  23. package/dist/gateway-client.js.map +1 -1
  24. package/dist/tui-handlers.js +498 -0
  25. package/dist/tui-handlers.js.map +1 -1
  26. package/mk3-tui/src/app/render_scheduler.rs +111 -112
  27. package/mk3-tui/src/app.rs +1078 -295
  28. package/mk3-tui/src/debug_log.rs +131 -124
  29. package/mk3-tui/src/io/mod.rs +63 -66
  30. package/mk3-tui/src/io/protocol.rs +14 -15
  31. package/mk3-tui/src/io/stdio.rs +31 -32
  32. package/mk3-tui/src/io/ws.rs +25 -32
  33. package/mk3-tui/src/main.rs +774 -212
  34. package/mk3-tui/src/monitoring/mod.rs +428 -0
  35. package/mk3-tui/src/screens/mod.rs +53 -39
  36. package/mk3-tui/src/storage/cache.rs +221 -224
  37. package/mk3-tui/src/storage/mod.rs +5 -6
  38. package/mk3-tui/src/ui/agent_builder.rs +1148 -922
  39. package/mk3-tui/src/ui/agent_list.rs +344 -295
  40. package/mk3-tui/src/ui/boot.rs +145 -148
  41. package/mk3-tui/src/ui/connection_portal.rs +121 -98
  42. package/mk3-tui/src/ui/help.rs +340 -284
  43. package/mk3-tui/src/ui/layout.rs +966 -803
  44. package/mk3-tui/src/ui/mod.rs +1 -1
  45. package/mk3-tui/src/ui/portal_monitoring.rs +1027 -147
  46. package/mk3-tui/src/ui/run_manager.rs +784 -764
  47. package/mk3-tui/src/ui/safe_viewport.rs +236 -235
  48. package/mk3-tui/src/ui/settings.rs +414 -362
  49. package/mk3-tui/src/ui/setup_portal.rs +158 -101
  50. package/mk3-tui/src/websocket.rs +315 -308
  51. package/package.json +2 -2
@@ -1,224 +1,221 @@
1
- /// Cache implementation for local data storage
2
- /// Stores agents, runs, and system status in JSON format
3
-
4
- use serde::{Deserialize, Serialize};
5
- use std::fs;
6
- use std::path::PathBuf;
7
- use std::time::{SystemTime, UNIX_EPOCH};
8
-
9
- #[derive(Debug, Clone, Serialize, Deserialize)]
10
- pub struct AgentData {
11
- pub name: String,
12
- pub description: Option<String>,
13
- pub model: String,
14
- pub provider: String,
15
- pub created_at: u64,
16
- }
17
-
18
- #[derive(Debug, Clone, Serialize, Deserialize)]
19
- pub struct RunData {
20
- pub id: String,
21
- pub name: String,
22
- pub agent: String,
23
- pub status: String,
24
- pub started_at: u64,
25
- pub duration: Option<u64>,
26
- pub tokens_used: Option<u64>,
27
- pub cost: Option<f64>,
28
- }
29
-
30
- #[derive(Debug, Clone, Serialize, Deserialize)]
31
- pub struct SystemStatusData {
32
- pub connected: bool,
33
- pub gateway_url: Option<String>,
34
- pub posture: String,
35
- pub last_updated: u64,
36
- }
37
-
38
- #[derive(Debug, Clone, Serialize, Deserialize, Default)]
39
- pub struct CacheData {
40
- pub agents: Vec<AgentData>,
41
- pub runs: Vec<RunData>,
42
- pub system_status: Option<SystemStatusData>,
43
- pub last_updated: u64,
44
- }
45
-
46
- #[derive(Debug, Clone)]
47
- pub struct Cache {
48
- cache_path: PathBuf,
49
- data: CacheData,
50
- }
51
-
52
- impl Cache {
53
- /// Create a new cache instance
54
- pub fn new() -> Result<Self, std::io::Error> {
55
- let cache_dir = Self::get_cache_dir()?;
56
- fs::create_dir_all(&cache_dir)?;
57
-
58
- let cache_path = cache_dir.join("4runr_cache.json");
59
- let data = Self::load_from_file(&cache_path)?;
60
-
61
- Ok(Self { cache_path, data })
62
- }
63
-
64
- /// Get the cache directory path
65
- fn get_cache_dir() -> Result<PathBuf, std::io::Error> {
66
- #[cfg(target_os = "windows")]
67
- {
68
- let appdata = std::env::var("APPDATA")
69
- .unwrap_or_else(|_| String::from("C:\\Users\\Default\\AppData\\Roaming"));
70
- Ok(PathBuf::from(appdata).join("4runr"))
71
- }
72
-
73
- #[cfg(not(target_os = "windows"))]
74
- {
75
- let home = std::env::var("HOME")
76
- .unwrap_or_else(|_| String::from("/tmp"));
77
- Ok(PathBuf::from(home).join(".4runr"))
78
- }
79
- }
80
-
81
- /// Load cache from file
82
- fn load_from_file(path: &PathBuf) -> Result<CacheData, std::io::Error> {
83
- if !path.exists() {
84
- return Ok(CacheData::default());
85
- }
86
-
87
- let contents = fs::read_to_string(path)?;
88
- let data: CacheData = serde_json::from_str(&contents)
89
- .unwrap_or_default();
90
-
91
- Ok(data)
92
- }
93
-
94
- /// Save cache to file
95
- fn save_to_file(&self) -> Result<(), std::io::Error> {
96
- let json = serde_json::to_string_pretty(&self.data)?;
97
- fs::write(&self.cache_path, json)?;
98
- Ok(())
99
- }
100
-
101
- /// Get current timestamp
102
- fn now() -> u64 {
103
- SystemTime::now()
104
- .duration_since(UNIX_EPOCH)
105
- .unwrap()
106
- .as_secs()
107
- }
108
-
109
- // === Agent Operations ===
110
-
111
- /// Get all cached agents
112
- pub fn get_agents(&self) -> Vec<AgentData> {
113
- self.data.agents.clone()
114
- }
115
-
116
- /// Update agents cache
117
- pub fn update_agents(&mut self, agents: Vec<AgentData>) -> Result<(), std::io::Error> {
118
- self.data.agents = agents;
119
- self.data.last_updated = Self::now();
120
- self.save_to_file()
121
- }
122
-
123
- /// Add a single agent
124
- #[allow(dead_code)]
125
- pub fn add_agent(&mut self, agent: AgentData) -> Result<(), std::io::Error> {
126
- self.data.agents.push(agent);
127
- self.data.last_updated = Self::now();
128
- self.save_to_file()
129
- }
130
-
131
- /// Remove an agent by name
132
- #[allow(dead_code)]
133
- pub fn remove_agent(&mut self, name: &str) -> Result<(), std::io::Error> {
134
- self.data.agents.retain(|a| a.name != name);
135
- self.data.last_updated = Self::now();
136
- self.save_to_file()
137
- }
138
-
139
- // === Run Operations ===
140
-
141
- /// Get all cached runs
142
- #[allow(dead_code)]
143
- pub fn get_runs(&self) -> Vec<RunData> {
144
- self.data.runs.clone()
145
- }
146
-
147
- /// Update runs cache
148
- #[allow(dead_code)]
149
- pub fn update_runs(&mut self, runs: Vec<RunData>) -> Result<(), std::io::Error> {
150
- self.data.runs = runs;
151
- self.data.last_updated = Self::now();
152
- self.save_to_file()
153
- }
154
-
155
- /// Add a single run
156
- #[allow(dead_code)]
157
- pub fn add_run(&mut self, run: RunData) -> Result<(), std::io::Error> {
158
- self.data.runs.push(run);
159
- self.data.last_updated = Self::now();
160
- self.save_to_file()
161
- }
162
-
163
- /// Update a run by ID
164
- #[allow(dead_code)]
165
- pub fn update_run(&mut self, id: &str, run: RunData) -> Result<(), std::io::Error> {
166
- if let Some(existing) = self.data.runs.iter_mut().find(|r| r.id == id) {
167
- *existing = run;
168
- self.data.last_updated = Self::now();
169
- self.save_to_file()?;
170
- }
171
- Ok(())
172
- }
173
-
174
- // === System Status Operations ===
175
-
176
- /// Get cached system status
177
- pub fn get_system_status(&self) -> Option<SystemStatusData> {
178
- self.data.system_status.clone()
179
- }
180
-
181
- /// Update system status cache
182
- #[allow(dead_code)]
183
- pub fn update_system_status(&mut self, status: SystemStatusData) -> Result<(), std::io::Error> {
184
- self.data.system_status = Some(status);
185
- self.data.last_updated = Self::now();
186
- self.save_to_file()
187
- }
188
-
189
- // === Cache Management ===
190
-
191
- /// Get cache age in seconds
192
- #[allow(dead_code)]
193
- pub fn get_age(&self) -> u64 {
194
- Self::now().saturating_sub(self.data.last_updated)
195
- }
196
-
197
- /// Check if cache is stale (older than threshold)
198
- #[allow(dead_code)]
199
- pub fn is_stale(&self, threshold_secs: u64) -> bool {
200
- self.get_age() > threshold_secs
201
- }
202
-
203
- /// Clear all cached data
204
- #[allow(dead_code)]
205
- pub fn clear(&mut self) -> Result<(), std::io::Error> {
206
- self.data = CacheData::default();
207
- self.save_to_file()
208
- }
209
-
210
- /// Get cache data reference
211
- #[allow(dead_code)]
212
- pub fn data(&self) -> &CacheData {
213
- &self.data
214
- }
215
- }
216
-
217
- impl Default for Cache {
218
- fn default() -> Self {
219
- Self::new().unwrap_or_else(|_| Self {
220
- cache_path: PathBuf::from("4runr_cache.json"),
221
- data: CacheData::default(),
222
- })
223
- }
224
- }
1
+ /// Cache implementation for local data storage
2
+ /// Stores agents, runs, and system status in JSON format
3
+ use serde::{Deserialize, Serialize};
4
+ use std::fs;
5
+ use std::path::PathBuf;
6
+ use std::time::{SystemTime, UNIX_EPOCH};
7
+
8
+ #[derive(Debug, Clone, Serialize, Deserialize)]
9
+ pub struct AgentData {
10
+ pub name: String,
11
+ pub description: Option<String>,
12
+ pub model: String,
13
+ pub provider: String,
14
+ pub created_at: u64,
15
+ }
16
+
17
+ #[derive(Debug, Clone, Serialize, Deserialize)]
18
+ pub struct RunData {
19
+ pub id: String,
20
+ pub name: String,
21
+ pub agent: String,
22
+ pub status: String,
23
+ pub started_at: u64,
24
+ pub duration: Option<u64>,
25
+ pub tokens_used: Option<u64>,
26
+ pub cost: Option<f64>,
27
+ }
28
+
29
+ #[derive(Debug, Clone, Serialize, Deserialize)]
30
+ pub struct SystemStatusData {
31
+ pub connected: bool,
32
+ pub gateway_url: Option<String>,
33
+ pub posture: String,
34
+ pub last_updated: u64,
35
+ }
36
+
37
+ #[derive(Debug, Clone, Serialize, Deserialize, Default)]
38
+ pub struct CacheData {
39
+ pub agents: Vec<AgentData>,
40
+ pub runs: Vec<RunData>,
41
+ pub system_status: Option<SystemStatusData>,
42
+ pub last_updated: u64,
43
+ }
44
+
45
+ #[derive(Debug, Clone)]
46
+ pub struct Cache {
47
+ cache_path: PathBuf,
48
+ data: CacheData,
49
+ }
50
+
51
+ impl Cache {
52
+ /// Create a new cache instance
53
+ pub fn new() -> Result<Self, std::io::Error> {
54
+ let cache_dir = Self::get_cache_dir()?;
55
+ fs::create_dir_all(&cache_dir)?;
56
+
57
+ let cache_path = cache_dir.join("4runr_cache.json");
58
+ let data = Self::load_from_file(&cache_path)?;
59
+
60
+ Ok(Self { cache_path, data })
61
+ }
62
+
63
+ /// Get the cache directory path
64
+ fn get_cache_dir() -> Result<PathBuf, std::io::Error> {
65
+ #[cfg(target_os = "windows")]
66
+ {
67
+ let appdata = std::env::var("APPDATA")
68
+ .unwrap_or_else(|_| String::from("C:\\Users\\Default\\AppData\\Roaming"));
69
+ Ok(PathBuf::from(appdata).join("4runr"))
70
+ }
71
+
72
+ #[cfg(not(target_os = "windows"))]
73
+ {
74
+ let home = std::env::var("HOME").unwrap_or_else(|_| String::from("/tmp"));
75
+ Ok(PathBuf::from(home).join(".4runr"))
76
+ }
77
+ }
78
+
79
+ /// Load cache from file
80
+ fn load_from_file(path: &PathBuf) -> Result<CacheData, std::io::Error> {
81
+ if !path.exists() {
82
+ return Ok(CacheData::default());
83
+ }
84
+
85
+ let contents = fs::read_to_string(path)?;
86
+ let data: CacheData = serde_json::from_str(&contents).unwrap_or_default();
87
+
88
+ Ok(data)
89
+ }
90
+
91
+ /// Save cache to file
92
+ fn save_to_file(&self) -> Result<(), std::io::Error> {
93
+ let json = serde_json::to_string_pretty(&self.data)?;
94
+ fs::write(&self.cache_path, json)?;
95
+ Ok(())
96
+ }
97
+
98
+ /// Get current timestamp
99
+ fn now() -> u64 {
100
+ SystemTime::now()
101
+ .duration_since(UNIX_EPOCH)
102
+ .unwrap()
103
+ .as_secs()
104
+ }
105
+
106
+ // === Agent Operations ===
107
+
108
+ /// Get all cached agents
109
+ pub fn get_agents(&self) -> Vec<AgentData> {
110
+ self.data.agents.clone()
111
+ }
112
+
113
+ /// Update agents cache
114
+ pub fn update_agents(&mut self, agents: Vec<AgentData>) -> Result<(), std::io::Error> {
115
+ self.data.agents = agents;
116
+ self.data.last_updated = Self::now();
117
+ self.save_to_file()
118
+ }
119
+
120
+ /// Add a single agent
121
+ #[allow(dead_code)]
122
+ pub fn add_agent(&mut self, agent: AgentData) -> Result<(), std::io::Error> {
123
+ self.data.agents.push(agent);
124
+ self.data.last_updated = Self::now();
125
+ self.save_to_file()
126
+ }
127
+
128
+ /// Remove an agent by name
129
+ #[allow(dead_code)]
130
+ pub fn remove_agent(&mut self, name: &str) -> Result<(), std::io::Error> {
131
+ self.data.agents.retain(|a| a.name != name);
132
+ self.data.last_updated = Self::now();
133
+ self.save_to_file()
134
+ }
135
+
136
+ // === Run Operations ===
137
+
138
+ /// Get all cached runs
139
+ #[allow(dead_code)]
140
+ pub fn get_runs(&self) -> Vec<RunData> {
141
+ self.data.runs.clone()
142
+ }
143
+
144
+ /// Update runs cache
145
+ #[allow(dead_code)]
146
+ pub fn update_runs(&mut self, runs: Vec<RunData>) -> Result<(), std::io::Error> {
147
+ self.data.runs = runs;
148
+ self.data.last_updated = Self::now();
149
+ self.save_to_file()
150
+ }
151
+
152
+ /// Add a single run
153
+ #[allow(dead_code)]
154
+ pub fn add_run(&mut self, run: RunData) -> Result<(), std::io::Error> {
155
+ self.data.runs.push(run);
156
+ self.data.last_updated = Self::now();
157
+ self.save_to_file()
158
+ }
159
+
160
+ /// Update a run by ID
161
+ #[allow(dead_code)]
162
+ pub fn update_run(&mut self, id: &str, run: RunData) -> Result<(), std::io::Error> {
163
+ if let Some(existing) = self.data.runs.iter_mut().find(|r| r.id == id) {
164
+ *existing = run;
165
+ self.data.last_updated = Self::now();
166
+ self.save_to_file()?;
167
+ }
168
+ Ok(())
169
+ }
170
+
171
+ // === System Status Operations ===
172
+
173
+ /// Get cached system status
174
+ pub fn get_system_status(&self) -> Option<SystemStatusData> {
175
+ self.data.system_status.clone()
176
+ }
177
+
178
+ /// Update system status cache
179
+ #[allow(dead_code)]
180
+ pub fn update_system_status(&mut self, status: SystemStatusData) -> Result<(), std::io::Error> {
181
+ self.data.system_status = Some(status);
182
+ self.data.last_updated = Self::now();
183
+ self.save_to_file()
184
+ }
185
+
186
+ // === Cache Management ===
187
+
188
+ /// Get cache age in seconds
189
+ #[allow(dead_code)]
190
+ pub fn get_age(&self) -> u64 {
191
+ Self::now().saturating_sub(self.data.last_updated)
192
+ }
193
+
194
+ /// Check if cache is stale (older than threshold)
195
+ #[allow(dead_code)]
196
+ pub fn is_stale(&self, threshold_secs: u64) -> bool {
197
+ self.get_age() > threshold_secs
198
+ }
199
+
200
+ /// Clear all cached data
201
+ #[allow(dead_code)]
202
+ pub fn clear(&mut self) -> Result<(), std::io::Error> {
203
+ self.data = CacheData::default();
204
+ self.save_to_file()
205
+ }
206
+
207
+ /// Get cache data reference
208
+ #[allow(dead_code)]
209
+ pub fn data(&self) -> &CacheData {
210
+ &self.data
211
+ }
212
+ }
213
+
214
+ impl Default for Cache {
215
+ fn default() -> Self {
216
+ Self::new().unwrap_or_else(|_| Self {
217
+ cache_path: PathBuf::from("4runr_cache.json"),
218
+ data: CacheData::default(),
219
+ })
220
+ }
221
+ }
@@ -1,6 +1,5 @@
1
- /// Local data storage and caching module
2
- /// Provides persistent storage for agents, runs, and system status
3
-
4
- pub mod cache;
5
-
6
- pub use cache::Cache;
1
+ /// Local data storage and caching module
2
+ /// Provides persistent storage for agents, runs, and system status
3
+ pub mod cache;
4
+
5
+ pub use cache::Cache;