Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat: add working badge
Gus1067c6be9ec0
diff --git a/src/shared/src/db/queries/task.ts b/src/shared/src/db/queries/task.tsindex 20f2882b2..73edafb83 100644--- a/src/shared/src/db/queries/task.ts+++ b/src/shared/src/db/queries/task.ts@@ -254,6 +254,49 @@ export async function countRunningTasks(db: Database, agentId: string, workspacereturn Number(rows[0]?.value ?? 0);}+export async function listActiveTaskCountsByWorkspace(+ db: Database,+ workspaceId: string+) {+ return db+ .select({+ agentId: agentTaskQueue.agentId,+ count: count(),+ })+ .from(agentTaskQueue)+ .where(+ and(+ eq(agentTaskQueue.workspaceId, workspaceId),+ inArray(agentTaskQueue.status, ["queued", "dispatched", "running"])+ )+ )+ .groupBy(agentTaskQueue.agentId);+}++export async function listActiveTasksByAgent(+ db: Database,+ agentId: string,+ workspaceId: string+) {+ return db+ .select({+ id: agentTaskQueue.id,+ status: agentTaskQueue.status,+ type: agentTaskQueue.type,+ createdAt: agentTaskQueue.createdAt,+ })+ .from(agentTaskQueue)+ .where(+ and(+ eq(agentTaskQueue.agentId, agentId),+ eq(agentTaskQueue.workspaceId, workspaceId),+ inArray(agentTaskQueue.status, ["queued", "dispatched", "running"])+ )+ )+ .orderBy(desc(agentTaskQueue.priority), asc(agentTaskQueue.createdAt))+ .limit(100);+}+export async function getActiveTaskByConversation(db: Database,conversationId: string,diff --git a/src/shared/src/db/schema.ts b/src/shared/src/db/schema.tsindex a0a159b38..4d7b672ab 100644--- a/src/shared/src/db/schema.ts+++ b/src/shared/src/db/schema.ts@@ -254,6 +254,9 @@ export const agentTaskQueue = sqliteTable(index("idx_task_queue_pending").on(t.agentId, t.status).where(sql`status IN ('queued', 'dispatched')`),+ index("idx_task_queue_workspace_active")+ .on(t.workspaceId, t.status, t.agentId)+ .where(sql`status IN ('queued', 'dispatched', 'running')`),foreignKey({columns: [t.agentId, t.workspaceId],foreignColumns: [agent.id, agent.workspaceId],diff --git a/src/shared/test/queries/task.test.ts b/src/shared/test/queries/task.test.tsnew file mode 100644index 000000000..6863bdff1--- /dev/null+++ b/src/shared/test/queries/task.test.ts@@ -0,0 +1,30 @@+import { describe, it, expect } from "vitest";+import * as taskQueries from "../../src/db/queries/task";++describe("task query module exports", () => {+ it("exports listActiveTaskCountsByWorkspace", () => {+ expect(typeof taskQueries.listActiveTaskCountsByWorkspace).toBe("function");+ });++ it("exports listActiveTasksByAgent", () => {+ expect(typeof taskQueries.listActiveTasksByAgent).toBe("function");+ });++ it("exports countRunningTasks", () => {+ expect(typeof taskQueries.countRunningTasks).toBe("function");+ });++ it("exports getActiveTaskByConversation", () => {+ expect(typeof taskQueries.getActiveTaskByConversation).toBe("function");+ });+});++describe("task query function signatures", () => {+ it("listActiveTaskCountsByWorkspace accepts (db, workspaceId)", () => {+ expect(taskQueries.listActiveTaskCountsByWorkspace.length).toBe(2);+ });++ it("listActiveTasksByAgent accepts (db, agentId, workspaceId)", () => {+ expect(taskQueries.listActiveTasksByAgent.length).toBe(3);+ });+});diff --git a/src/web/migrations/0005_task_queue_workspace_status_idx.sql b/src/web/migrations/0005_task_queue_workspace_status_idx.sqlnew file mode 100644index 000000000..82a881e68--- /dev/null+++ b/src/web/migrations/0005_task_queue_workspace_status_idx.sql@@ -0,0 +1,2 @@+CREATE INDEX idx_task_queue_workspace_active ON agent_task_queue(workspace_id, status, agent_id)+ WHERE status IN ('queued', 'dispatched', 'running');diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsxindex a1bfdf286..12502a445 100644--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/layout.tsx@@ -9,7 +9,7 @@ import { Button } from "@/components/ui/button";import { ConfirmDialog } from "@/components/ui/confirm-dialog";import { AgentEditForm } from "@/components/agent-edit-form";import { Skeleton } from "@/components/ui/skeleton";-import { cn } from "@/lib/utils";+import { AgentStatusBadge } from "@/components/agent-status-badge";import { CalendarDays, Mail, MessageSquare, MoreHorizontal, Pencil, Trash2, X } from "lucide-react";import { MobileSidebarLogo } from "@/components/mobile-sidebar-logo";import {@@ -33,6 +33,8 @@ export default function AgentDetailLayout({ children }: { children: ReactNode })const agent = agents.find((a) => a.id === agentId);const runtime = agent ? runtimes.find((r) => r.id === agent.runtime_id) : null;const isOnline = runtime?.status === "online";+ const { activeTaskCounts } = useAgentContext();+ const taskCount = activeTaskCounts[agentId] ?? 0;const [editing, setEditing] = useState(false);const [saving, setSaving] = useState(false);@@ -51,17 +53,11 @@ export default function AgentDetailLayout({ children }: { children: ReactNode })<div className="flex items-center gap-2 min-w-0"><MobileSidebarLogo />{agent ? (- <Link- href={`/w/${slug}/runtimes`}- title={isOnline ? "Runtime online" : "Runtime offline"}- >- <span- className={cn(- "size-2 rounded-full shrink-0 block",- isOnline ? "bg-status-online" : "bg-status-offline"- )}- />- </Link>+ <AgentStatusBadge+ isOnline={isOnline}+ taskCount={taskCount}+ agentId={agentId}+ />) : (<Skeleton className="size-2 rounded-full shrink-0" />)}diff --git a/src/web/src/app/api/agents/[id]/active-tasks/route.test.ts b/src/web/src/app/api/agents/[id]/active-tasks/route.test.tsnew file mode 100644index 000000000..e8aa57e60--- /dev/null+++ b/src/web/src/app/api/agents/[id]/active-tasks/route.test.ts@@ -0,0 +1,101 @@+import { describe, it, expect, vi, beforeEach } from "vitest";+import { NextRequest } from "next/server";++const mockGetAgent = vi.fn();+const mockListActiveTasksByAgent = vi.fn();++vi.mock("@/lib/middleware/helpers", () => ({+ writeJSON: (data: any, status = 200) =>+ new Response(JSON.stringify(data), {+ status,+ headers: { "content-type": "application/json" },+ }),+ writeError: (message: string, status: number) =>+ new Response(JSON.stringify({ error: message }), {+ status,+ headers: { "content-type": "application/json" },+ }),+}));+vi.mock("@opennextjs/cloudflare", () => ({+ getCloudflareContext: vi.fn(() => ({ env: { DB: {} } })),+}));+vi.mock("@alook/shared", () => ({+ createDb: vi.fn(() => ({})),+ queries: {+ agent: { getAgent: (...args: any[]) => mockGetAgent(...args) },+ task: { listActiveTasksByAgent: (...args: any[]) => mockListActiveTasksByAgent(...args) },+ },+}));+vi.mock("@/lib/middleware/auth", () => ({+ withAuth: vi.fn((handler: any) => async (req: any, ctx?: any) => {+ const params = ctx?.params instanceof Promise ? await ctx.params : ctx?.params;+ return handler(req, { userId: "u1", email: "[email protected]", params });+ }),+}));+vi.mock("@/lib/middleware/workspace", () => ({+ withWorkspaceMember: vi.fn(async () => ({ workspaceId: "w1" })),+}));++import { GET } from "./route";++const withParams = (id: string) => ({ params: Promise.resolve({ id }) });++describe("GET /api/agents/[id]/active-tasks", () => {+ beforeEach(() => vi.clearAllMocks());++ it("returns correct task list", async () => {+ mockGetAgent.mockResolvedValue({ id: "a1" });+ mockListActiveTasksByAgent.mockResolvedValue([+ { id: "t1", status: "running", type: "user_dm_message", conversationId: "c1", createdAt: "2026-01-01T00:00:00Z" },+ { id: "t2", status: "queued", type: "email_notification", conversationId: "c2", createdAt: "2026-01-01T00:01:00Z" },+ ]);++ const res = await GET(+ new NextRequest("http://localhost/api/agents/a1/active-tasks"),+ withParams("a1")+ );+ const body = await res.json();++ expect(res.status).toBe(200);+ expect(body.tasks).toHaveLength(2);+ expect(body.tasks[0]).toEqual({+ id: "t1",+ status: "running",+ type: "user_dm_message",+ created_at: "2026-01-01T00:00:00Z",+ });+ expect(body.tasks[1]).toEqual({+ id: "t2",+ status: "queued",+ type: "email_notification",+ created_at: "2026-01-01T00:01:00Z",+ });+ });++ it("returns 404 when agent not found", async () => {+ mockGetAgent.mockResolvedValue(null);++ const res = await GET(+ new NextRequest("http://localhost/api/agents/a1/active-tasks"),+ withParams("a1")+ );+ const body = await res.json();++ expect(res.status).toBe(404);+ expect(body.error).toBe("agent not found");+ });++ it("returns empty tasks array when no active tasks", async () => {+ mockGetAgent.mockResolvedValue({ id: "a1" });+ mockListActiveTasksByAgent.mockResolvedValue([]);++ const res = await GET(+ new NextRequest("http://localhost/api/agents/a1/active-tasks"),+ withParams("a1")+ );+ const body = await res.json();++ expect(res.status).toBe(200);+ expect(body.tasks).toEqual([]);+ });+});diff --git a/src/web/src/app/api/agents/[id]/active-tasks/route.ts b/src/web/src/app/api/agents/[id]/active-tasks/route.tsnew file mode 100644index 000000000..183525e02--- /dev/null+++ b/src/web/src/app/api/agents/[id]/active-tasks/route.ts@@ -0,0 +1,30 @@+import { getCloudflareContext } from "@opennextjs/cloudflare";+import { createDb, queries } from "@alook/shared";+import { withAuth } from "@/lib/middleware/auth";+import { withWorkspaceMember } from "@/lib/middleware/workspace";+import { writeJSON, writeError } from "@/lib/middleware/helpers";++export const GET = withAuth(async (req, ctx) => {+ const ws = await withWorkspaceMember(req, ctx);+ if (ws instanceof Response) return ws;++ const { env } = getCloudflareContext();+ const db = createDb((env as Env).DB);++ const id = ctx.params?.id;+ if (!id) return writeError("agent id is required", 400);++ const agent = await queries.agent.getAgent(db, id, ws.workspaceId);+ if (!agent) return writeError("agent not found", 404);++ const tasks = await queries.task.listActiveTasksByAgent(db, id, ws.workspaceId);++ return writeJSON({+ tasks: tasks.map((t) => ({+ id: t.id,+ status: t.status,+ type: t.type,+ created_at: t.createdAt,+ })),+ });+});diff --git a/src/web/src/app/api/agents/active-task-counts/route.test.ts b/src/web/src/app/api/agents/active-task-counts/route.test.tsnew file mode 100644index 000000000..6ae9c89f0--- /dev/null+++ b/src/web/src/app/api/agents/active-task-counts/route.test.ts@@ -0,0 +1,74 @@+import { describe, it, expect, vi, beforeEach } from "vitest";+import { NextRequest } from "next/server";++const mockListActiveTaskCountsByWorkspace = vi.fn();++vi.mock("@/lib/middleware/helpers", () => ({+ writeJSON: (data: any, status = 200) =>+ new Response(JSON.stringify(data), {+ status,+ headers: { "content-type": "application/json" },+ }),+ writeError: (message: string, status: number) =>+ new Response(JSON.stringify({ error: message }), {+ status,+ headers: { "content-type": "application/json" },+ }),+}));+vi.mock("@opennextjs/cloudflare", () => ({+ getCloudflareContext: vi.fn(() => ({ env: { DB: {} } })),+}));+vi.mock("@alook/shared", () => ({+ createDb: vi.fn(() => ({})),+ queries: {+ task: {+ listActiveTaskCountsByWorkspace: (...args: any[]) =>+ mockListActiveTaskCountsByWorkspace(...args),+ },+ },+}));+vi.mock("@/lib/middleware/auth", () => ({+ withAuth: vi.fn((handler: any) => async (req: any, ctx?: any) => {+ const params = ctx?.params instanceof Promise ? await ctx.params : ctx?.params;+ return handler(req, { userId: "u1", email: "[email protected]", params });+ }),+}));+vi.mock("@/lib/middleware/workspace", () => ({+ withWorkspaceMember: vi.fn(async () => ({ workspaceId: "w1" })),+}));++import { GET } from "./route";++describe("GET /api/agents/active-task-counts", () => {+ beforeEach(() => vi.clearAllMocks());++ it("returns correct counts per agent", async () => {+ mockListActiveTaskCountsByWorkspace.mockResolvedValue([+ { agentId: "a1", count: 3 },+ { agentId: "a2", count: 1 },+ ]);++ const res = await GET(+ new NextRequest("http://localhost/api/agents/active-task-counts"),+ {}+ );+ const body = await res.json();++ expect(res.status).toBe(200);+ expect(body).toEqual({ counts: { a1: 3, a2: 1 } });+ expect(mockListActiveTaskCountsByWorkspace).toHaveBeenCalledWith({}, "w1");+ });++ it("returns empty counts when no active tasks", async () => {+ mockListActiveTaskCountsByWorkspace.mockResolvedValue([]);++ const res = await GET(+ new NextRequest("http://localhost/api/agents/active-task-counts"),+ {}+ );+ const body = await res.json();++ expect(res.status).toBe(200);+ expect(body).toEqual({ counts: {} });+ });+});diff --git a/src/web/src/app/api/agents/active-task-counts/route.ts b/src/web/src/app/api/agents/active-task-counts/route.tsnew file mode 100644index 000000000..8a1979f0a--- /dev/null+++ b/src/web/src/app/api/agents/active-task-counts/route.ts@@ -0,0 +1,21 @@+import { getCloudflareContext } from "@opennextjs/cloudflare";+import { createDb, queries } from "@alook/shared";+import { withAuth } from "@/lib/middleware/auth";+import { withWorkspaceMember } from "@/lib/middleware/workspace";+import { writeJSON } from "@/lib/middleware/helpers";++export const GET = withAuth(async (req, ctx) => {+ const ws = await withWorkspaceMember(req, ctx);+ if (ws instanceof Response) return ws;++ const { env } = getCloudflareContext();+ const db = createDb((env as Env).DB);++ const rows = await queries.task.listActiveTaskCountsByWorkspace(db, ws.workspaceId);+ const counts: Record<string, number> = {};+ for (const row of rows) {+ counts[row.agentId] = Number(row.count);+ }++ return writeJSON({ counts });+});diff --git a/src/web/src/components/agent-status-badge.tsx b/src/web/src/components/agent-status-badge.tsxnew file mode 100644index 000000000..ae527b13f--- /dev/null+++ b/src/web/src/components/agent-status-badge.tsx@@ -0,0 +1,165 @@+"use client";++import { useState, useCallback, useMemo } from "react";+import Link from "next/link";+import { useRouter } from "next/navigation";+import { CalendarDays, Mail, MessageSquare } from "lucide-react";+import { badgeVariants } from "@/components/ui/badge";+import { Badge } from "@/components/ui/badge";+import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";+import { Skeleton } from "@/components/ui/skeleton";+import { cn } from "@/lib/utils";+import { listAgentActiveTasks, type ActiveTask } from "@/lib/api";+import { useWorkspace } from "@/contexts/workspace-context";++interface AgentStatusBadgeProps {+ isOnline: boolean;+ taskCount: number;+ agentId: string;+}++const TASK_TYPES = [+ { type: "user_dm_message", icon: MessageSquare, label: "Chat" },+ { type: "email_notification", icon: Mail, label: "Email" },+ { type: "calendar_event", icon: CalendarDays, label: "Calendar" },+] as const;++function getTaskRoute(slug: string, agentId: string, type: string) {+ switch (type) {+ case "email_notification":+ return `/w/${slug}/agents/${agentId}/email`;+ case "calendar_event":+ return `/w/${slug}/calendar?agents=${agentId}`;+ default:+ return `/w/${slug}/agents/${agentId}`;+ }+}++function StatusDot({ online, pulse }: { online: boolean; pulse?: boolean }) {+ return (+ <span+ className={cn(+ "size-1.5 rounded-full shrink-0",+ online ? "bg-status-online" : "bg-status-offline",+ pulse && "animate-pulse"+ )}+ />+ );+}++function groupByType(tasks: ActiveTask[]) {+ const map: Record<string, { total: number; running: number }> = {};+ for (const t of tasks) {+ const entry = map[t.type] ?? (map[t.type] = { total: 0, running: 0 });+ entry.total++;+ if (t.status === "running") entry.running++;+ }+ return map;+}++const badgeBase = "gap-1.5 text-muted-foreground hover:text-foreground cursor-pointer";++export function AgentStatusBadge({ isOnline, taskCount, agentId }: AgentStatusBadgeProps) {+ const { slug, workspaceId } = useWorkspace();+ const router = useRouter();+ const [tasks, setTasks] = useState<ActiveTask[] | null>(null);+ const [loadingTasks, setLoadingTasks] = useState(false);+ const [error, setError] = useState(false);++ const fetchTasks = useCallback(async () => {+ setTasks(null);+ setLoadingTasks(true);+ setError(false);+ try {+ const res = await listAgentActiveTasks(agentId, workspaceId);+ setTasks(res.tasks);+ } catch {+ setError(true);+ } finally {+ setLoadingTasks(false);+ }+ }, [agentId, workspaceId]);++ const grouped = useMemo(() => (tasks ? groupByType(tasks) : null), [tasks]);++ if (!isOnline) {+ return (+ <Badge+ variant="outline"+ render={<Link href={`/w/${slug}/runtimes`} title="Runtime offline — click to manage runtimes" />}+ className={badgeBase}+ >+ <StatusDot online={false} />+ <span className="hidden sm:inline">Offline</span>+ </Badge>+ );+ }++ return (+ <Popover onOpenChange={(open) => { if (open) fetchTasks(); }}>+ <PopoverTrigger+ render={+ <button+ type="button"+ className={cn(badgeVariants({ variant: "outline" }), badgeBase)}+ />+ }+ >+ <StatusDot online pulse={taskCount > 0} />+ {taskCount > 0 ? (+ <>+ <span className="hidden sm:inline">Working</span>+ <span className="tabular-nums">{taskCount}</span>+ </>+ ) : (+ <span className="hidden sm:inline">Online</span>+ )}+ </PopoverTrigger>+ <PopoverContent className="w-52 p-0">+ {loadingTasks ? (+ <div className="p-2 space-y-1">+ {Array.from({ length: 3 }).map((_, i) => (+ <div key={i} className="flex items-center gap-2 py-1.5 px-2">+ <Skeleton className="size-3.5 rounded" />+ <Skeleton className="h-3 w-12" />+ <div className="flex-1" />+ <Skeleton className="h-3 w-6" />+ </div>+ ))}+ </div>+ ) : error ? (+ <div className="p-3 text-xs text-muted-foreground">Failed to load</div>+ ) : !tasks || tasks.length === 0 ? (+ <div className="p-3 text-xs text-muted-foreground">No active tasks</div>+ ) : (+ <div className="py-1">+ {TASK_TYPES.map(({ type, icon: Icon, label }) => {+ const entry = grouped?.[type];+ return (+ <button+ key={type}+ type="button"+ onClick={() => router.push(getTaskRoute(slug, agentId, type))}+ className="flex items-center gap-2 w-full py-1.5 px-2 text-left hover:bg-muted rounded-md transition-colors cursor-pointer"+ >+ <Icon className="size-3.5 text-muted-foreground shrink-0" />+ <span className="text-xs flex-1">{label}</span>+ {entry ? (+ <span className="inline-flex items-center gap-1 text-xs text-muted-foreground tabular-nums">+ {entry.running > 0 && (+ <span className="size-1.5 rounded-full bg-status-online animate-pulse" />+ )}+ {entry.running > 0 ? entry.running : entry.total}+ </span>+ ) : (+ <span className="text-xs text-muted-foreground/40">0</span>+ )}+ </button>+ );+ })}+ </div>+ )}+ </PopoverContent>+ </Popover>+ );+}diff --git a/src/web/src/components/app-sidebar.tsx b/src/web/src/components/app-sidebar.tsxindex 8cff087d2..7cd335cb3 100644--- a/src/web/src/components/app-sidebar.tsx+++ b/src/web/src/components/app-sidebar.tsx@@ -18,6 +18,7 @@ export function AppSidebar({ onNavigate }: { onNavigate?: () => void } = {}) {const { slug } = useWorkspace();const { resolvedTheme, setTheme } = useTheme();+ const { activeTaskCounts: taskCounts } = useAgentContext();const sorted = [...agents].sort((a, b) => a.name.localeCompare(b.name));const prefix = `/w/${slug}`;@@ -66,6 +67,9 @@ export function AppSidebar({ onNavigate }: { onNavigate?: () => void } = {}) {)}>{agent.name.charAt(0).toUpperCase()}+ {(taskCounts[agent.id] ?? 0) > 0 && (+ <span className="absolute bottom-0 right-0 size-2 rounded-full bg-status-online animate-pulse ring-2 ring-background" />+ )}</button>);})diff --git a/src/web/src/contexts/agent-context.tsx b/src/web/src/contexts/agent-context.tsxindex 16f5c8d97..8935a3fe4 100644--- a/src/web/src/contexts/agent-context.tsx+++ b/src/web/src/contexts/agent-context.tsx@@ -17,6 +17,7 @@ import {deleteAgent,createMachineToken,deleteMachine,+ listAgentActiveTaskCounts,} from "@/lib/api";import type { AgentRuntime as Runtime } from "@alook/shared";import { toast } from "sonner";@@ -35,6 +36,7 @@ interface AgentContextValue {agents: Agent[];runtimes: Runtime[];loading: boolean;+ activeTaskCounts: Record<string, number>;reload: () => Promise<void>;subscribeWs: (fn: WsSubscriber) => () => void;handleCreateAgent: (req: CreateAgentRequest) => Promise<Agent | null>;@@ -63,14 +65,35 @@ export function AgentProvider({const [agents, setAgents] = useState<Agent[]>([]);const [runtimes, setRuntimes] = useState<Runtime[]>([]);const [loading, setLoading] = useState(true);+ const [activeTaskCounts, setActiveTaskCounts] = useState<Record<string, number>>({});const loadedRef = useRef(false);const subscribersRef = useRef(new Set<WsSubscriber>());+ const taskCountsMountedRef = useRef(true);const subscribeWs = useCallback((fn: WsSubscriber) => {subscribersRef.current.add(fn);return () => { subscribersRef.current.delete(fn); };}, []);+ const fetchTaskCounts = useCallback(async () => {+ try {+ const res = await listAgentActiveTaskCounts(workspaceId);+ if (taskCountsMountedRef.current) setActiveTaskCounts(res.counts);+ } catch {+ // ignore+ }+ }, [workspaceId]);++ useEffect(() => {+ taskCountsMountedRef.current = true;+ fetchTaskCounts();+ const id = setInterval(fetchTaskCounts, 5000);+ return () => {+ taskCountsMountedRef.current = false;+ clearInterval(id);+ };+ }, [fetchTaskCounts]);+const reload = useCallback(async () => {try {const [a, r] = await Promise.all([@@ -129,9 +152,12 @@ export function AgentProvider({if (msg.workspaceId !== workspaceId) break;debouncedReload();break;+ case "task.updated":+ fetchTaskCounts();+ break;}},- [reload, debouncedReload, workspaceId]+ [reload, debouncedReload, fetchTaskCounts, workspaceId]);useUserWs(handleWsMessage);@@ -223,6 +249,7 @@ export function AgentProvider({agents,runtimes,loading,+ activeTaskCounts,reload,subscribeWs,handleCreateAgent,diff --git a/src/web/src/lib/api.ts b/src/web/src/lib/api.tsindex 49d9d05ac..71bf1a8d5 100644--- a/src/web/src/lib/api.ts+++ b/src/web/src/lib/api.ts@@ -329,6 +329,20 @@ export const createMachineToken = (name?: string, workspaceId?: string) =>});+// Agent active tasks+export const listAgentActiveTaskCounts = (workspaceId: string) =>+ apiFetch<{ counts: Record<string, number> }>(`/api/agents/active-task-counts${wsQuery(workspaceId)}`);++export interface ActiveTask {+ id: string;+ status: string;+ type: string;+ created_at: string;+}++export const listAgentActiveTasks = (agentId: string, workspaceId: string) =>+ apiFetch<{ tasks: ActiveTask[] }>(`/api/agents/${agentId}/active-tasks${wsQuery(workspaceId)}`);+// Tasks (polling)export const getTask = (id: string, workspaceId: string) =>apiFetch<TaskApi>(`/api/tasks/${id}${wsQuery(workspaceId)}`);