fix: Agents hartcodiert mit File-Activity-Detection
CI - Build & Test / Backend (.NET) (push) Successful in 23s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 15s
CI - Build & Test / Security Check (push) Successful in 3s

- Tools/invoke Visibility scoped auf agent:main → keine Iris-Sessions sichtbar
- Hardcoded 6 Agenten mit korrekten Models
- Activity: checkt /mnt/workspace-{id}/memory Dateizeitstempel
This commit is contained in:
2026-06-10 00:33:49 +02:00
parent e0fc305832
commit dd509a75be
+40 -45
View File
@@ -87,60 +87,55 @@ public sealed class OpenClawGatewayClient(HttpClient httpClient, IConfiguration
public async Task<List<DashboardAgentInfo>> GetAgentsAsync() public async Task<List<DashboardAgentInfo>> GetAgentsAsync()
{ {
var agents = new List<DashboardAgentInfo>(); // Hardcoded agent list (known from OpenClaw config).
var seenIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase); // Tools/invoke visibility is restricted to agent:main scope,
// so we can't enumerate Iris sessions programmatically.
// Get sessions list var agentDefs = new[]
var sessionsResult = await InvokeToolAsync("sessions_list");
var sessionsData = ExtractToolData(sessionsResult);
if (sessionsData is JsonObject so)
{ {
// sessions_list returns { agents: [...], sessions: {...} } new { Id = "iris", Name = "Iris", Model = "GPT-5.4" },
// Try agents array first (from gateway call) new { Id = "programmer", Name = "Programmer", Model = "DeepSeek V4 Flash" },
if (so["agents"] is JsonArray agentArray) new { Id = "reviewer", Name = "Reviewer", Model = "DeepSeek V4 Pro" },
new { Id = "architekt", Name = "DevOps", Model = "DeepSeek V4 Pro" },
new { Id = "executor", Name = "Executor", Model = "DeepSeek V4 Flash" },
new { Id = "researcher", Name = "Researcher", Model = "DeepSeek V4 Pro" },
};
var agents = new List<DashboardAgentInfo>();
foreach (var def in agentDefs)
{
var isActive = false;
string? currentTask = null;
// Check workspace activity via file timestamps
var memDir = $"/mnt/workspace-{def.Id}/memory";
try
{ {
foreach (var a in agentArray) if (Directory.Exists(memDir))
{ {
if (a is null) continue; var latestFile = Directory.GetFiles(memDir, "*", SearchOption.AllDirectories)
var id = a["agentId"]?.GetValue<string>() ?? ""; .Select(f => new FileInfo(f))
if (string.IsNullOrWhiteSpace(id) || !seenIds.Add(id)) continue; .OrderByDescending(f => f.LastWriteTimeUtc)
var name = a["name"]?.GetValue<string>() ?? id; .FirstOrDefault();
var model = "GPT-5.4"; // default, overridden if available
var isActive = false;
var currentTask = (string?)null;
// Check if agent has recent sessions (active indicator) if (latestFile is not null)
if (a["sessions"] is JsonObject sess && sess["recent"] is JsonArray recent && recent.Count > 0)
{ {
var age = recent[0]?["age"]?.GetValue<long>() ?? long.MaxValue; var age = DateTime.UtcNow - latestFile.LastWriteTimeUtc;
isActive = age < 300_000; // active if session < 5 min ago isActive = age.TotalMinutes < 15;
currentTask = recent[0]?["key"]?.GetValue<string>(); if (isActive)
currentTask = $"Modified: {latestFile.Name}";
} }
agents.Add(new DashboardAgentInfo(id, name, DeriveRole(id), model, isActive, currentTask));
} }
} }
} catch { /* workspace not mounted or inaccessible */ }
// Also get subagents list agents.Add(new DashboardAgentInfo(
var subResult = await InvokeToolAsync("subagents", new { action = "list" }); Id: def.Id,
var subData = ExtractToolData(subResult); Name: def.Name,
Role: DeriveRole(def.Id),
if (subData is JsonArray subArray) Model: def.Model,
{ IsActive: isActive,
foreach (var s in subArray) CurrentTask: currentTask
{ ));
if (s is null) continue;
var id = s["id"]?.GetValue<string>() ?? s["agentId"]?.GetValue<string>() ?? "";
if (string.IsNullOrWhiteSpace(id) || !seenIds.Add(id)) continue;
var name = s["name"]?.GetValue<string>() ?? id;
var status = s["status"]?.GetValue<string>() ?? "";
var isActive = status is "active" or "running";
var currentTask = s["task"]?.GetValue<string>() ?? s["currentTask"]?.GetValue<string>();
agents.Add(new DashboardAgentInfo(id, name, DeriveRole(id), "", isActive, currentTask));
}
} }
return agents; return agents;