feat(FN-1737): auto-delete child/task-worker agents and hide system agents by default
- Auto-delete spawned child agents when their parent task terminates (reportsTo cleanup) - Auto-delete task-worker agents when their owned task completes - Add includeSystem filter to AgentStore.list() and REST API - Hide system agents by default on the agents page (show only user-facing agents) - Wire includeSystem toggle through the API layer and AgentsView component - Add changeset for @gsxdsm/fusion patch release - Add comprehensive tests for agent cleanup and includeSystem filtering
This commit is contained in:
@@ -9647,24 +9647,29 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
/**
|
||||
* GET /api/agents
|
||||
* List all agents with optional filtering.
|
||||
* Query params: state, role
|
||||
* Query params: state, role, includeSystem
|
||||
*/
|
||||
router.get("/agents", async (req, res) => {
|
||||
try {
|
||||
const filter: { state?: string; role?: string } = {};
|
||||
const filter: { state?: string; role?: string; includeSystem?: boolean } = {};
|
||||
if (req.query.state && typeof req.query.state === "string") {
|
||||
filter.state = req.query.state;
|
||||
}
|
||||
if (req.query.role && typeof req.query.role === "string") {
|
||||
filter.role = req.query.role;
|
||||
}
|
||||
if (req.query.includeSystem === "true") {
|
||||
filter.includeSystem = true;
|
||||
} else if (req.query.includeSystem === "false") {
|
||||
filter.includeSystem = false;
|
||||
}
|
||||
|
||||
const { store: scopedStore } = await getProjectContext(req);
|
||||
const { AgentStore } = await import("@fusion/core");
|
||||
const agentStore = new AgentStore({ rootDir: scopedStore.getFusionDir() });
|
||||
await agentStore.init();
|
||||
|
||||
const agents = await agentStore.listAgents(filter as { state?: "idle" | "active" | "paused" | "terminated"; role?: import("@fusion/core").AgentCapability });
|
||||
const agents = await agentStore.listAgents(filter as { state?: "idle" | "active" | "paused" | "terminated"; role?: import("@fusion/core").AgentCapability; includeSystem?: boolean });
|
||||
res.json(agents);
|
||||
} catch (err: any) {
|
||||
if (err instanceof ApiError) {
|
||||
|
||||
Reference in New Issue
Block a user