Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(agent): add agent management UI, skills/tools/triggers, and issue assignment

Jiayuan Zhangb4303f9bec4d
diff --git a/apps/web/app/(dashboard)/agents/page.tsx b/apps/web/app/(dashboard)/agents/page.tsx
index c8f03704f2..4517f1f71a 100644
--- a/apps/web/app/(dashboard)/agents/page.tsx
+++ b/apps/web/app/(dashboard)/agents/page.tsx
@@ -6,11 +6,36 @@ import {
Cloud,
Monitor,
Plus,
- Zap,
ListTodo,
+ Wrench,
+ FileText,
+ Timer,
+ Trash2,
+ Save,
+ X,
+ Key,
+ Link2,
+ Clock,
+ CheckCircle2,
+ XCircle,
+ Loader2,
+ AlertCircle,
+ MoreHorizontal,
+ Play,
+ ChevronDown,
} from "lucide-react";
-import type { Agent, AgentStatus, AgentStatusPayload } from "@multica/types";
+import type {
+ Agent,
+ AgentStatus,
+ AgentTool,
+ AgentTrigger,
+ AgentTask,
+ RuntimeDevice,
+ CreateAgentRequest,
+ UpdateAgentRequest,
+} from "@multica/types";
import { api } from "../../../lib/api";
+import { useAuth } from "../../../lib/auth-context";
import { useWSEvent } from "../../../lib/ws-context";
// ---------------------------------------------------------------------------
@@ -25,6 +50,15 @@ const statusConfig: Record<AgentStatus, { label: string; color: string; dot: str
offline: { label: "Offline", color: "text-muted-foreground/50", dot: "bg-muted-foreground/40" },
};
+const taskStatusConfig: Record<string, { label: string; icon: typeof CheckCircle2; color: string }> = {
+ queued: { label: "Queued", icon: Clock, color: "text-muted-foreground" },
+ dispatched: { label: "Dispatched", icon: Play, color: "text-blue-500" },
+ running: { label: "Running", icon: Loader2, color: "text-green-500" },
+ completed: { label: "Completed", icon: CheckCircle2, color: "text-green-600" },
+ failed: { label: "Failed", icon: XCircle, color: "text-red-500" },
+ cancelled: { label: "Cancelled", icon: XCircle, color: "text-muted-foreground" },
+};
+
function getInitials(name: string): string {
return name
.split(/[\s-]+/)
@@ -34,8 +68,231 @@ function getInitials(name: string): string {
.slice(0, 2);
}
+function generateId(): string {
+ return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
+}
+
+// ---------------------------------------------------------------------------
+// Mock Runtime Devices (will be replaced with real daemon registration API)
+// ---------------------------------------------------------------------------
+
+const MOCK_RUNTIME_DEVICES: RuntimeDevice[] = [
+ {
+ id: "runtime-cloud",
+ name: "Multica Agent",
+ runtime_mode: "cloud",
+ status: "online",
+ device_info: "Cloud",
+ },
+ {
+ id: "runtime-macbook",
+ name: "Jiayuan's MacBook Pro",
+ runtime_mode: "local",
+ status: "online",
+ device_info: "macOS 15.4 · Claude Code v1.2",
+ },
+ {
+ id: "runtime-linux",
+ name: "Dev Server (gpu-01)",
+ runtime_mode: "local",
+ status: "online",
+ device_info: "Ubuntu 24.04 · Codex v0.8",
+ },
+ {
+ id: "runtime-ci",
+ name: "CI Runner",
+ runtime_mode: "local",
+ status: "offline",
+ device_info: "Linux · GitHub Actions",
+ },
+];
+
+function getRuntimeDevice(agent: Agent): RuntimeDevice | undefined {
+ const runtimeId = agent.runtime_config?.runtime_id as string | undefined;
+ if (runtimeId) {
+ return MOCK_RUNTIME_DEVICES.find((d) => d.id === runtimeId);
+ }
+ if (agent.runtime_mode === "cloud") {
+ return MOCK_RUNTIME_DEVICES.find((d) => d.runtime_mode === "cloud");
+ }
+ return undefined;
+}
+
+// ---------------------------------------------------------------------------
+// Create Agent Dialog
+// ---------------------------------------------------------------------------
+
+function CreateAgentDialog({
+ onClose,
+ onCreate,
+}: {
+ onClose: () => void;
+ onCreate: (data: CreateAgentRequest) => Promise<void>;
+}) {
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [selectedRuntimeId, setSelectedRuntimeId] = useState(MOCK_RUNTIME_DEVICES[0]!.id);
+ const [creating, setCreating] = useState(false);
+ const [runtimeOpen, setRuntimeOpen] = useState(false);
+
+ const selectedRuntime = MOCK_RUNTIME_DEVICES.find((d) => d.id === selectedRuntimeId)!;
+
+ const handleSubmit = async () => {
+ if (!name.trim()) return;
+ setCreating(true);
+ try {
+ await onCreate({
+ name: name.trim(),
+ description: description.trim(),
+ runtime_mode: selectedRuntime.runtime_mode,
+ runtime_config: {
+ runtime_id: selectedRuntime.id,
+ runtime_name: selectedRuntime.name,
+ },
+ triggers: [{ id: generateId(), type: "on_assign", enabled: true, config: {} }],
+ });
+ onClose();
+ } catch {
+ setCreating(false);
+ }
+ };
+
+ return (
+ <>
+ <div
+ className="fixed inset-0 z-50 bg-black/10 backdrop-blur-xs"
+ onClick={onClose}
+ />
+ <div className="fixed top-1/2 left-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 rounded-xl bg-background p-6 shadow-lg ring-1 ring-foreground/10">
+ <div className="flex items-center justify-between">
+ <h2 className="text-lg font-semibold">Create Agent</h2>
+ <button onClick={onClose} className="rounded-md p-1 hover:bg-accent">
+ <X className="h-4 w-4" />
+ </button>
+ </div>
+ <p className="mt-1 text-sm text-muted-foreground">
+ Create a new AI agent for your workspace.
+ </p>
+
+ <div className="mt-5 space-y-4">
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Name</label>
+ <input
+ autoFocus
+ type="text"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="e.g. Deep Research Agent"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
+ onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
+ />
+ </div>
+
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Description</label>
+ <input
+ type="text"
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ placeholder="What does this agent do?"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Runtime</label>
+ <div className="relative mt-1.5">
+ <button
+ type="button"
+ onClick={() => setRuntimeOpen(!runtimeOpen)}
+ className="flex w-full items-center gap-3 rounded-md border bg-background px-3 py-2.5 text-left text-sm transition-colors hover:bg-accent/50 focus:outline-none focus:ring-2 focus:ring-ring"
+ >
+ {selectedRuntime.runtime_mode === "cloud" ? (
+ <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
+ ) : (
+ <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="truncate font-medium">{selectedRuntime.name}</span>
+ {selectedRuntime.runtime_mode === "cloud" && (
+ <span className="shrink-0 rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-600">
+ Cloud
+ </span>
+ )}
+ </div>
+ <div className="text-xs text-muted-foreground">{selectedRuntime.device_info}</div>
+ </div>
+ <ChevronDown className={`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${runtimeOpen ? "rotate-180" : ""}`} />
+ </button>
+
+ {runtimeOpen && (
+ <>
+ <div className="fixed inset-0 z-40" onClick={() => setRuntimeOpen(false)} />
+ <div className="absolute left-0 right-0 top-full z-50 mt-1 max-h-60 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md">
+ {MOCK_RUNTIME_DEVICES.map((device) => (
+ <button
+ key={device.id}
+ onClick={() => {
+ setSelectedRuntimeId(device.id);
+ setRuntimeOpen(false);
+ }}
+ className={`flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors ${
+ device.id === selectedRuntimeId ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ {device.runtime_mode === "cloud" ? (
+ <Cloud className="h-4 w-4 shrink-0 text-muted-foreground" />
+ ) : (
+ <Monitor className="h-4 w-4 shrink-0 text-muted-foreground" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="truncate font-medium">{device.name}</span>
+ {device.runtime_mode === "cloud" && (
+ <span className="shrink-0 rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-600">
+ Cloud
+ </span>
+ )}
+ </div>
+ <div className="text-xs text-muted-foreground">{device.device_info}</div>
+ </div>
+ <span
+ className={`h-2 w-2 shrink-0 rounded-full ${
+ device.status === "online" ? "bg-green-500" : "bg-muted-foreground/40"
+ }`}
+ />
+ </button>
+ ))}
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="mt-6 flex justify-end gap-2">
+ <button
+ onClick={onClose}
+ className="rounded-md px-3 py-1.5 text-sm hover:bg-accent"
+ >
+ Cancel
+ </button>
+ <button
+ onClick={handleSubmit}
+ disabled={creating || !name.trim()}
+ className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
+ >
+ {creating ? "Creating..." : "Create"}
+ </button>
+ </div>
+ </div>
+ </>
+ );
+}
+
// ---------------------------------------------------------------------------
-// Components
+// Agent List Item
// ---------------------------------------------------------------------------
function AgentListItem({
@@ -78,83 +335,717 @@ function AgentListItem({
);
}
-function AgentDetail({ agent }: { agent: Agent }) {
- const st = statusConfig[agent.status];
+// ---------------------------------------------------------------------------
+// Skills Tab
+// ---------------------------------------------------------------------------
+
+function SkillsTab({
+ agent,
+ onSave,
+}: {
+ agent: Agent;
+ onSave: (skills: string) => Promise<void>;
+}) {
+ const [skills, setSkills] = useState(agent.skills);
+ const [saving, setSaving] = useState(false);
+ const isDirty = skills !== agent.skills;
+
+ useEffect(() => {
+ setSkills(agent.skills);
+ }, [agent.id, agent.skills]);
+
+ const handleSave = async () => {
+ setSaving(true);
+ try {
+ await onSave(skills);
+ } finally {
+ setSaving(false);
+ }
+ };
return (
- <div className="p-6 space-y-8">
- {/* Header */}
- <div className="flex items-start gap-4">
- <div className="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-muted text-sm font-bold">
- {getInitials(agent.name)}
- </div>
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-3">
- <h2 className="text-lg font-semibold">{agent.name}</h2>
- <span className={`flex items-center gap-1.5 text-sm ${st.color}`}>
- <span className={`h-2 w-2 rounded-full ${st.dot}`} />
- {st.label}
- </span>
- </div>
- <p className="mt-1 text-sm text-muted-foreground">
- {agent.runtime_mode === "cloud" ? "Cloud-hosted" : "Local"} agent
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-sm font-semibold">Skills</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Define what this agent does and how it should accomplish tasks. Supports Markdown.
</p>
</div>
+ {isDirty && (
+ <button
+ onClick={handleSave}
+ disabled={saving}
+ className="flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
+ >
+ <Save className="h-3 w-3" />
+ {saving ? "Saving..." : "Save"}
+ </button>
+ )}
</div>
+ <textarea
+ value={skills}
+ onChange={(e) => setSkills(e.target.value)}
+ placeholder={`# Agent Name\n\nDescribe what this agent does and how it should work.\n\n## Workflow\n1. Step one\n2. Step two\n3. Step three\n\n## Output Format\nDescribe the expected output...`}
+ className="h-96 w-full resize-none rounded-lg border bg-background px-4 py-3 font-mono text-sm leading-relaxed focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+ );
+}
- {/* Meta info */}
- <div className="grid grid-cols-2 gap-4 rounded-lg border p-4">
- <div>
- <div className="text-xs text-muted-foreground">Runtime</div>
- <div className="mt-1 flex items-center gap-1.5 text-sm font-medium">
- {agent.runtime_mode === "cloud" ? (
- <Cloud className="h-3.5 w-3.5" />
- ) : (
- <Monitor className="h-3.5 w-3.5" />
- )}
- {agent.runtime_mode === "cloud" ? "Cloud" : "Local"}
+// ---------------------------------------------------------------------------
+// Tools Tab
+// ---------------------------------------------------------------------------
+
+function AddToolDialog({
+ onClose,
+ onAdd,
+}: {
+ onClose: () => void;
+ onAdd: (tool: AgentTool) => void;
+}) {
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [authType, setAuthType] = useState<"oauth" | "api_key" | "none">("api_key");
+
+ const handleAdd = () => {
+ if (!name.trim()) return;
+ onAdd({
+ id: generateId(),
+ name: name.trim(),
+ description: description.trim(),
+ auth_type: authType,
+ connected: false,
+ config: {},
+ });
+ onClose();
+ };
+
+ return (
+ <>
+ <div
+ className="fixed inset-0 z-50 bg-black/10 backdrop-blur-xs"
+ onClick={onClose}
+ />
+ <div className="fixed top-1/2 left-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-xl bg-background p-6 shadow-lg ring-1 ring-foreground/10">
+ <h3 className="text-sm font-semibold">Add Tool</h3>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Connect an external tool for this agent to use.
+ </p>
+
+ <div className="mt-4 space-y-3">
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Tool Name</label>
+ <input
+ autoFocus
+ type="text"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="e.g. Google Search, Slack, GitHub"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
+ onKeyDown={(e) => e.key === "Enter" && handleAdd()}
+ />
+ </div>
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Description</label>
+ <input
+ type="text"
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ placeholder="What does this tool do?"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">Authentication</label>
+ <div className="mt-1.5 flex gap-2">
+ {(["api_key", "oauth", "none"] as const).map((type) => (
+ <button
+ key={type}
+ onClick={() => setAuthType(type)}
+ className={`flex-1 rounded-md border px-2 py-1.5 text-xs transition-colors ${
+ authType === type
+ ? "border-primary bg-primary/5 font-medium"
+ : "hover:bg-accent"
+ }`}
+ >
+ {type === "api_key" ? "API Key" : type === "oauth" ? "OAuth" : "None"}
+ </button>
+ ))}
+ </div>
</div>
</div>
- <div>
- <div className="text-xs text-muted-foreground">Visibility</div>
- <div className="mt-1 text-sm font-medium capitalize">{agent.visibility}</div>
+
+ <div className="mt-5 flex justify-end gap-2">
+ <button onClick={onClose} className="rounded-md px-3 py-1.5 text-sm hover:bg-accent">
+ Cancel
+ </button>
+ <button
+ onClick={handleAdd}
+ disabled={!name.trim()}
+ className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
+ >
+ Add
+ </button>
</div>
+ </div>
+ </>
+ );
+}
+
+function ToolsTab({
+ agent,
+ onSave,
+}: {
+ agent: Agent;
+ onSave: (tools: AgentTool[]) => Promise<void>;
+}) {
+ const [tools, setTools] = useState<AgentTool[]>(agent.tools ?? []);
+ const [showAdd, setShowAdd] = useState(false);
+ const [saving, setSaving] = useState(false);
+
+ useEffect(() => {
+ setTools(agent.tools ?? []);
+ }, [agent.id, agent.tools]);
+
+ const isDirty = JSON.stringify(tools) !== JSON.stringify(agent.tools ?? []);
+
+ const handleSave = async () => {
+ setSaving(true);
+ try {
+ await onSave(tools);
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ const toggleConnect = (toolId: string) => {
+ setTools((prev) =>
+ prev.map((t) => (t.id === toolId ? { ...t, connected: !t.connected } : t)),
+ );
+ };
+
+ const removeTool = (toolId: string) => {
+ setTools((prev) => prev.filter((t) => t.id !== toolId));
+ };
+
+ return (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
<div>
- <div className="text-xs text-muted-foreground">Max Concurrent Tasks</div>
- <div className="mt-1 text-sm font-medium">{agent.max_concurrent_tasks}</div>
+ <h3 className="text-sm font-semibold">Tools</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ External tools and APIs this agent can use during task execution.
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {isDirty && (
+ <button
+ onClick={handleSave}
+ disabled={saving}
+ className="flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
+ >
+ <Save className="h-3 w-3" />
+ {saving ? "Saving..." : "Save"}
+ </button>
+ )}
+ <button
+ onClick={() => setShowAdd(true)}
+ className="flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium hover:bg-accent"
+ >
+ <Plus className="h-3 w-3" />
+ Add Tool
+ </button>
+ </div>
+ </div>
+
+ {tools.length === 0 ? (
+ <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
+ <Wrench className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">No tools configured</p>
+ <button
+ onClick={() => setShowAdd(true)}
+ className="mt-3 flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90"
+ >
+ <Plus className="h-3 w-3" />
+ Add Tool
+ </button>
+ </div>
+ ) : (
+ <div className="space-y-2">
+ {tools.map((tool) => (
+ <div
+ key={tool.id}
+ className="flex items-center gap-3 rounded-lg border px-4 py-3"
+ >
+ <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted">
+ {tool.auth_type === "oauth" ? (
+ <Link2 className="h-4 w-4 text-muted-foreground" />
+ ) : tool.auth_type === "api_key" ? (
+ <Key className="h-4 w-4 text-muted-foreground" />
+ ) : (
+ <Wrench className="h-4 w-4 text-muted-foreground" />
+ )}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-medium">{tool.name}</div>
+ {tool.description && (
+ <div className="text-xs text-muted-foreground truncate">
+ {tool.description}
+ </div>
+ )}
+ </div>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={() => toggleConnect(tool.id)}
+ className={`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${
+ tool.connected
+ ? "bg-green-500/10 text-green-600"
+ : "bg-muted text-muted-foreground hover:bg-accent"
+ }`}
+ >
+ {tool.connected ? "Connected" : "Connect"}
+ </button>
+ <button
+ onClick={() => removeTool(tool.id)}
+ className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-red-500"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </button>
+ </div>
+ </div>
+ ))}
</div>
+ )}
+
+ {showAdd && (
+ <AddToolDialog
+ onClose={() => setShowAdd(false)}
+ onAdd={(tool) => setTools((prev) => [...prev, tool])}
+ />
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Triggers Tab
+// ---------------------------------------------------------------------------
+
+function TriggersTab({
+ agent,
+ onSave,
+}: {
+ agent: Agent;
+ onSave: (triggers: AgentTrigger[]) => Promise<void>;
+}) {
+ const [triggers, setTriggers] = useState<AgentTrigger[]>(agent.triggers ?? []);
+ const [saving, setSaving] = useState(false);
+
+ useEffect(() => {
+ setTriggers(agent.triggers ?? []);
+ }, [agent.id, agent.triggers]);
+
+ const isDirty = JSON.stringify(triggers) !== JSON.stringify(agent.triggers ?? []);
+
+ const handleSave = async () => {
+ setSaving(true);
+ try {
+ await onSave(triggers);
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ const toggleTrigger = (triggerId: string) => {
+ setTriggers((prev) =>
+ prev.map((t) => (t.id === triggerId ? { ...t, enabled: !t.enabled } : t)),
+ );
+ };
+
+ const removeTrigger = (triggerId: string) => {
+ setTriggers((prev) => prev.filter((t) => t.id !== triggerId));
+ };
+
+ const addTrigger = (type: "on_assign" | "scheduled") => {
+ const newTrigger: AgentTrigger = {
+ id: generateId(),
+ type,
+ enabled: true,
+ config: type === "scheduled" ? { cron: "0 9 * * 1-5", timezone: "UTC" } : {},
+ };
+ setTriggers((prev) => [...prev, newTrigger]);
+ };
+
+ const updateTriggerConfig = (triggerId: string, config: Record<string, unknown>) => {
+ setTriggers((prev) =>
+ prev.map((t) => (t.id === triggerId ? { ...t, config } : t)),
+ );
+ };
+
+ return (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
<div>
- <div className="text-xs text-muted-foreground">Created</div>
- <div className="mt-1 text-sm font-medium">
- {new Date(agent.created_at).toLocaleDateString()}
- </div>
+ <h3 className="text-sm font-semibold">Triggers</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Configure when this agent should start working.
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ {isDirty && (
+ <button
+ onClick={handleSave}
+ disabled={saving}
+ className="flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
+ >
+ <Save className="h-3 w-3" />
+ {saving ? "Saving..." : "Save"}
+ </button>
+ )}
</div>
</div>
- {/* Status */}
- <div>
- <div className="flex items-center gap-2 mb-3">
- <Zap className="h-4 w-4 text-muted-foreground" />
- <h3 className="text-sm font-semibold">Status</h3>
- </div>
- <div className="rounded-lg border px-4 py-3">
- <div className="flex items-center gap-2">
- <span className={`h-2 w-2 rounded-full ${st.dot}`} />
- <span className={`text-sm font-medium ${st.color}`}>{st.label}</span>
+ <div className="space-y-2">
+ {triggers.map((trigger) => (
+ <div
+ key={trigger.id}
+ className="rounded-lg border px-4 py-3"
+ >
+ <div className="flex items-center gap-3">
+ <div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted">
+ {trigger.type === "on_assign" ? (
+ <Bot className="h-4 w-4 text-muted-foreground" />
+ ) : (
+ <Timer className="h-4 w-4 text-muted-foreground" />
+ )}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-medium">
+ {trigger.type === "on_assign" ? "On Issue Assign" : "Scheduled"}
+ </div>
+ <div className="text-xs text-muted-foreground">
+ {trigger.type === "on_assign"
+ ? "Runs when an issue is assigned to this agent"
+ : `Cron: ${(trigger.config as { cron?: string }).cron ?? "Not set"}`}
+ </div>
+ </div>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={() => toggleTrigger(trigger.id)}
+ className={`relative h-5 w-9 rounded-full transition-colors ${
+ trigger.enabled ? "bg-primary" : "bg-muted"
+ }`}
+ >
+ <span
+ className={`absolute top-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform ${
+ trigger.enabled ? "left-[18px]" : "left-0.5"
+ }`}
+ />
+ </button>
+ <button
+ onClick={() => removeTrigger(trigger.id)}
+ className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-red-500"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </button>
+ </div>
+ </div>
+
+ {trigger.type === "scheduled" && (
+ <div className="mt-3 grid grid-cols-2 gap-3 pl-12">
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">
+ Cron Expression
+ </label>
+ <input
+ type="text"
+ value={(trigger.config as { cron?: string }).cron ?? ""}
+ onChange={(e) =>
+ updateTriggerConfig(trigger.id, {
+ ...trigger.config,
+ cron: e.target.value,
+ })
+ }
+ placeholder="0 9 * * 1-5"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-1.5 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+ <div>
+ <label className="text-xs font-medium text-muted-foreground">
+ Timezone
+ </label>
+ <input
+ type="text"
+ value={(trigger.config as { timezone?: string }).timezone ?? ""}
+ onChange={(e) =>
+ updateTriggerConfig(trigger.id, {
+ ...trigger.config,
+ timezone: e.target.value,
+ })
+ }
+ placeholder="UTC"
+ className="mt-1 w-full rounded-md border bg-background px-3 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+ </div>
+ )}
</div>
- </div>
+ ))}
</div>
- {/* Tasks placeholder */}
+ <div className="flex gap-2">
+ <button
+ onClick={() => addTrigger("on_assign")}
+ className="flex items-center gap-1.5 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ <Bot className="h-3 w-3" />
+ Add On Assign
+ </button>
+ <button
+ onClick={() => addTrigger("scheduled")}
+ className="flex items-center gap-1.5 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
+ >
+ <Timer className="h-3 w-3" />
+ Add Scheduled
+ </button>
+ </div>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Tasks Tab
+// ---------------------------------------------------------------------------
+
+function TasksTab({ agent }: { agent: Agent }) {
+ const [tasks, setTasks] = useState<AgentTask[]>([]);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ setLoading(true);
+ api
+ .listAgentTasks(agent.id)
+ .then(setTasks)
+ .catch(() => setTasks([]))
+ .finally(() => setLoading(false));
+ }, [agent.id]);
+
+ if (loading) {
+ return (
+ <div className="flex items-center justify-center py-12 text-sm text-muted-foreground">
+ Loading tasks...
+ </div>
+ );
+ }
+
+ return (
+ <div className="space-y-4">
<div>
- <div className="flex items-center gap-2 mb-3">
- <ListTodo className="h-4 w-4 text-muted-foreground" />
- <h3 className="text-sm font-semibold">Tasks</h3>
- </div>
- <p className="text-sm text-muted-foreground">
- Task queue will be shown here when agents are assigned issues.
+ <h3 className="text-sm font-semibold">Task Queue</h3>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ Issues assigned to this agent and their execution status.
</p>
</div>
+
+ {tasks.length === 0 ? (
+ <div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
+ <ListTodo className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">No tasks in queue</p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Assign an issue to this agent to get started.
+ </p>
+ </div>
+ ) : (
+ <div className="space-y-2">
+ {tasks.map((task) => {
+ const config = taskStatusConfig[task.status] ?? taskStatusConfig.queued!;
+ const Icon = config.icon;
+ return (
+ <div key={task.id} className="flex items-center gap-3 rounded-lg border px-4 py-3">
+ <Icon className={`h-4 w-4 shrink-0 ${config.color}`} />
+ <div className="min-w-0 flex-1">
+ <div className="text-sm font-medium truncate">
+ Issue {task.issue_id.slice(0, 8)}...
+ </div>
+ <div className="text-xs text-muted-foreground">
+ {new Date(task.created_at).toLocaleString()}
+ </div>
+ </div>
+ <span className={`text-xs font-medium ${config.color}`}>
+ {config.label}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Agent Detail
+// ---------------------------------------------------------------------------
+
+type DetailTab = "skills" | "tools" | "triggers" | "tasks";
+
+const detailTabs: { id: DetailTab; label: string; icon: typeof FileText }[] = [
+ { id: "skills", label: "Skills", icon: FileText },
+ { id: "tools", label: "Tools", icon: Wrench },
+ { id: "triggers", label: "Triggers", icon: Timer },
+ { id: "tasks", label: "Tasks", icon: ListTodo },
+];
+
+function AgentDetail({
+ agent,
+ onUpdate,
+ onDelete,
+}: {
+ agent: Agent;
+ onUpdate: (id: string, data: Partial<Agent>) => Promise<void>;
+ onDelete: (id: string) => Promise<void>;
+}) {
+ const st = statusConfig[agent.status];
+ const runtimeDevice = getRuntimeDevice(agent);
+ const [activeTab, setActiveTab] = useState<DetailTab>("skills");
+ const [showMenu, setShowMenu] = useState(false);
+ const [confirmDelete, setConfirmDelete] = useState(false);
+
+ return (
+ <div className="flex h-full flex-col">
+ {/* Header */}
+ <div className="flex items-start gap-4 border-b px-6 py-5">
+ <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-muted text-sm font-bold">
+ {getInitials(agent.name)}
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-3">
+ <h2 className="text-base font-semibold">{agent.name}</h2>
+ <span className={`flex items-center gap-1.5 text-xs ${st.color}`}>
+ <span className={`h-1.5 w-1.5 rounded-full ${st.dot}`} />
+ {st.label}
+ </span>
+ <span className="flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground">
+ {agent.runtime_mode === "cloud" ? (
+ <Cloud className="h-3 w-3" />
+ ) : (
+ <Monitor className="h-3 w-3" />
+ )}
+ {runtimeDevice?.name ?? (agent.runtime_mode === "cloud" ? "Cloud" : "Local")}
+ </span>
+ </div>
+ {agent.description && (
+ <p className="mt-1 text-sm text-muted-foreground">{agent.description}</p>
+ )}
+ </div>
+ <div className="relative">
+ <button
+ onClick={() => setShowMenu(!showMenu)}
+ className="rounded-md p-1.5 hover:bg-accent"
+ >
+ <MoreHorizontal className="h-4 w-4 text-muted-foreground" />
+ </button>
+ {showMenu && (
+ <>
+ <div className="fixed inset-0 z-40" onClick={() => setShowMenu(false)} />
+ <div className="absolute right-0 top-8 z-50 w-40 rounded-lg border bg-popover p-1 shadow-md">
+ <button
+ onClick={() => {
+ setShowMenu(false);
+ setConfirmDelete(true);
+ }}
+ className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-red-500 hover:bg-accent"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ Delete Agent
+ </button>
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+
+ {/* Tabs */}
+ <div className="flex border-b px-6">
+ {detailTabs.map((tab) => (
+ <button
+ key={tab.id}
+ onClick={() => setActiveTab(tab.id)}
+ className={`flex items-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors ${
+ activeTab === tab.id
+ ? "border-primary text-foreground"
+ : "border-transparent text-muted-foreground hover:text-foreground"
+ }`}
+ >
+ <tab.icon className="h-3.5 w-3.5" />
+ {tab.label}
+ </button>
+ ))}
+ </div>
+
+ {/* Tab Content */}
+ <div className="flex-1 overflow-y-auto p-6">
+ {activeTab === "skills" && (
+ <SkillsTab
+ agent={agent}
+ onSave={(skills) => onUpdate(agent.id, { skills })}
+ />
+ )}
+ {activeTab === "tools" && (
+ <ToolsTab
+ agent={agent}
+ onSave={(tools) => onUpdate(agent.id, { tools })}
+ />
+ )}
+ {activeTab === "triggers" && (
+ <TriggersTab
+ agent={agent}
+ onSave={(triggers) => onUpdate(agent.id, { triggers })}
+ />
+ )}
+ {activeTab === "tasks" && <TasksTab agent={agent} />}
+ </div>
+
+ {/* Delete Confirmation */}
+ {confirmDelete && (
+ <>
+ <div
+ className="fixed inset-0 z-50 bg-black/10 backdrop-blur-xs"
+ onClick={() => setConfirmDelete(false)}
+ />
+ <div className="fixed top-1/2 left-1/2 z-50 w-full max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-xl bg-background p-6 shadow-lg ring-1 ring-foreground/10">
+ <div className="flex items-center gap-3">
+ <div className="flex h-10 w-10 items-center justify-center rounded-full bg-red-500/10">
+ <AlertCircle className="h-5 w-5 text-red-500" />
+ </div>
+ <div>
+ <h3 className="text-sm font-semibold">Delete agent?</h3>
+ <p className="mt-0.5 text-xs text-muted-foreground">
+ This will permanently delete &quot;{agent.name}&quot; and all its configuration.
+ </p>
+ </div>
+ </div>
+ <div className="mt-5 flex justify-end gap-2">
+ <button
+ onClick={() => setConfirmDelete(false)}
+ className="rounded-md px-3 py-1.5 text-sm hover:bg-accent"
+ >
+ Cancel
+ </button>
+ <button
+ onClick={() => {
+ setConfirmDelete(false);
+ onDelete(agent.id);
+ }}
+ className="rounded-md bg-red-500 px-3 py-1.5 text-sm font-medium text-white hover:bg-red-600"
+ >
+ Delete
+ </button>
+ </div>
+ </div>
+ </>
+ )}
</div>
);
}
@@ -164,32 +1055,47 @@ function AgentDetail({ agent }: { agent: Agent }) {
// ---------------------------------------------------------------------------
export default function AgentsPage() {
- const [agents, setAgents] = useState<Agent[]>([]);
+ const { agents, refreshAgents, isLoading } = useAuth();
const [selectedId, setSelectedId] = useState<string>("");
- const [loading, setLoading] = useState(true);
+ const [showCreate, setShowCreate] = useState(false);
+ // Select first agent on initial load
useEffect(() => {
- api
- .listAgents()
- .then((a) => {
- setAgents(a);
- if (a.length > 0) setSelectedId(a[0]!.id);
- })
- .catch(console.error)
- .finally(() => setLoading(false));
- }, []);
+ if (agents.length > 0 && !selectedId) {
+ setSelectedId(agents[0]!.id);
+ }
+ }, [agents, selectedId]);
useWSEvent(
"agent:status",
- useCallback((payload: unknown) => {
- const { agent } = payload as AgentStatusPayload;
- setAgents((prev) => prev.map((a) => (a.id === agent.id ? agent : a)));
- }, []),
+ useCallback(() => {
+ refreshAgents();
+ }, [refreshAgents]),
);
+ const handleCreate = async (data: CreateAgentRequest) => {
+ const agent = await api.createAgent(data);
+ await refreshAgents();
+ setSelectedId(agent.id);
+ };
+
+ const handleUpdate = async (id: string, data: Record<string, unknown>) => {
+ await api.updateAgent(id, data as UpdateAgentRequest);
+ await refreshAgents();
+ };
+
+ const handleDelete = async (id: string) => {
+ await api.deleteAgent(id);
+ if (selectedId === id) {
+ const remaining = agents.filter((a) => a.id !== id);
+ setSelectedId(remaining[0]?.id ?? "");
+ }
+ await refreshAgents();
+ };
+
const selected = agents.find((a) => a.id === selectedId) ?? null;
- if (loading) {
+ if (isLoading) {
return (
<div className="flex h-full items-center justify-center text-sm text-muted-foreground">
Loading...
@@ -203,32 +1109,68 @@ export default function AgentsPage() {
<div className="w-72 shrink-0 overflow-y-auto border-r">
<div className="flex h-12 items-center justify-between border-b px-4">
<h1 className="text-sm font-semibold">Agents</h1>
- <button className="flex h-6 w-6 items-center justify-center rounded-md hover:bg-accent">
+ <button
+ onClick={() => setShowCreate(true)}
+ className="flex h-6 w-6 items-center justify-center rounded-md hover:bg-accent"
+ >
<Plus className="h-4 w-4 text-muted-foreground" />
</button>
</div>
- <div className="divide-y">
- {agents.map((agent) => (
- <AgentListItem
- key={agent.id}
- agent={agent}
- isSelected={agent.id === selectedId}
- onClick={() => setSelectedId(agent.id)}
- />
- ))}
- </div>
+ {agents.length === 0 ? (
+ <div className="flex flex-col items-center justify-center px-4 py-12">
+ <Bot className="h-8 w-8 text-muted-foreground/40" />
+ <p className="mt-3 text-sm text-muted-foreground">No agents yet</p>
+ <button
+ onClick={() => setShowCreate(true)}
+ className="mt-3 flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90"
+ >
+ <Plus className="h-3 w-3" />
+ Create Agent
+ </button>
+ </div>
+ ) : (
+ <div className="divide-y">
+ {agents.map((agent) => (
+ <AgentListItem
+ key={agent.id}
+ agent={agent}
+ isSelected={agent.id === selectedId}
+ onClick={() => setSelectedId(agent.id)}
+ />
+ ))}
+ </div>
+ )}
</div>
{/* Right column — agent detail */}
- <div className="flex-1 overflow-y-auto">
+ <div className="flex-1 overflow-hidden">
{selected ? (
- <AgentDetail agent={selected} />
+ <AgentDetail
+ agent={selected}
+ onUpdate={handleUpdate}
+ onDelete={handleDelete}
+ />
) : (
- <div className="flex h-full items-center justify-center text-muted-foreground">
- Select an agent to view details
+ <div className="flex h-full flex-col items-center justify-center text-muted-foreground">
+ <Bot className="h-10 w-10 text-muted-foreground/30" />
+ <p className="mt-3 text-sm">Select an agent to view details</p>
+ <button
+ onClick={() => setShowCreate(true)}
+ className="mt-3 flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90"
+ >
+ <Plus className="h-3 w-3" />
+ Create Agent
+ </button>
</div>
)}
</div>
+
+ {showCreate && (
+ <CreateAgentDialog
+ onClose={() => setShowCreate(false)}
+ onCreate={handleCreate}
+ />
+ )}
</div>
);
}
diff --git a/apps/web/app/(dashboard)/issues/[id]/page.tsx b/apps/web/app/(dashboard)/issues/[id]/page.tsx
index 4661ba8c75..a10f126790 100644
--- a/apps/web/app/(dashboard)/issues/[id]/page.tsx
+++ b/apps/web/app/(dashboard)/issues/[id]/page.tsx
@@ -1,13 +1,15 @@
"use client";
-import { use, useState, useEffect } from "react";
+import { use, useState, useEffect, useRef } from "react";
import Link from "next/link";
import {
Bot,
ChevronRight,
Send,
+ UserCircle,
+ X,
} from "lucide-react";
-import type { Issue, Comment } from "@multica/types";
+import type { Issue, Comment, IssueAssigneeType } from "@multica/types";
import { STATUS_CONFIG, PRIORITY_CONFIG } from "../_data/config";
import { StatusIcon, PriorityIcon } from "../page";
import { api } from "../../../../lib/api";
@@ -79,12 +81,19 @@ function ActorAvatar({
function PropRow({
label,
children,
+ onClick,
}: {
label: string;
children: React.ReactNode;
+ onClick?: () => void;
}) {
return (
- <div className="flex min-h-[32px] items-center gap-3 rounded-md px-2 -mx-2 hover:bg-accent/50 transition-colors">
+ <div
+ onClick={onClick}
+ className={`flex min-h-[32px] items-center gap-3 rounded-md px-2 -mx-2 hover:bg-accent/50 transition-colors ${
+ onClick ? "cursor-pointer" : ""
+ }`}
+ >
<span className="w-20 shrink-0 text-[13px] text-muted-foreground">{label}</span>
<div className="flex min-w-0 flex-1 items-center justify-end gap-1.5 text-[13px]">
{children}
@@ -93,6 +102,151 @@ function PropRow({
);
}
+// ---------------------------------------------------------------------------
+// Assignee Picker
+// ---------------------------------------------------------------------------
+
+function AssigneePicker({
+ issue,
+ onSelect,
+ onClose,
+}: {
+ issue: Issue;
+ onSelect: (type: IssueAssigneeType | null, id: string | null) => void;
+ onClose: () => void;
+}) {
+ const { members, agents } = useAuth();
+ const [search, setSearch] = useState("");
+ const ref = useRef<HTMLDivElement>(null);
+ const inputRef = useRef<HTMLInputElement>(null);
+
+ useEffect(() => {
+ inputRef.current?.focus();
+ }, []);
+
+ useEffect(() => {
+ function handleClickOutside(e: MouseEvent) {
+ if (ref.current && !ref.current.contains(e.target as Node)) {
+ onClose();
+ }
+ }
+ document.addEventListener("mousedown", handleClickOutside);
+ return () => document.removeEventListener("mousedown", handleClickOutside);
+ }, [onClose]);
+
+ const q = search.toLowerCase();
+ const filteredMembers = members.filter((m) =>
+ m.name.toLowerCase().includes(q) || m.email.toLowerCase().includes(q),
+ );
+ const filteredAgents = agents.filter((a) =>
+ a.name.toLowerCase().includes(q),
+ );
+
+ const isSelected = (type: string, id: string) =>
+ issue.assignee_type === type && issue.assignee_id === id;
+
+ return (
+ <div
+ ref={ref}
+ className="absolute right-0 top-full z-50 mt-1 w-64 rounded-lg border bg-popover shadow-md"
+ >
+ <div className="p-2">
+ <input
+ ref={inputRef}
+ type="text"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder="Search..."
+ className="w-full rounded-md border bg-background px-2.5 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-ring"
+ />
+ </div>
+
+ <div className="max-h-64 overflow-y-auto px-1 pb-1">
+ {/* Unassign option */}
+ {issue.assignee_id && (
+ <>
+ <button
+ onClick={() => onSelect(null, null)}
+ className="flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-xs hover:bg-accent"
+ >
+ <X className="h-3.5 w-3.5 text-muted-foreground" />
+ <span className="text-muted-foreground">Unassign</span>
+ </button>
+ <div className="my-1 border-t mx-1" />
+ </>
+ )}
+
+ {/* Members */}
+ {filteredMembers.length > 0 && (
+ <>
+ <div className="px-2 py-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
+ Members
+ </div>
+ {filteredMembers.map((m) => (
+ <button
+ key={m.user_id}
+ onClick={() => onSelect("member", m.user_id)}
+ className={`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-xs transition-colors ${
+ isSelected("member", m.user_id) ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ <div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground">
+ {m.name
+ .split(" ")
+ .map((w) => w[0])
+ .join("")
+ .toUpperCase()
+ .slice(0, 2)}
+ </div>
+ <div className="min-w-0 flex-1 text-left">
+ <div className="truncate font-medium">{m.name}</div>
+ </div>
+ {isSelected("member", m.user_id) && (
+ <span className="text-primary text-[10px] font-medium">Assigned</span>
+ )}
+ </button>
+ ))}
+ </>
+ )}
+
+ {/* Agents */}
+ {filteredAgents.length > 0 && (
+ <>
+ <div className="px-2 py-1 mt-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
+ Agents
+ </div>
+ {filteredAgents.map((a) => (
+ <button
+ key={a.id}
+ onClick={() => onSelect("agent", a.id)}
+ className={`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-xs transition-colors ${
+ isSelected("agent", a.id) ? "bg-accent" : "hover:bg-accent/50"
+ }`}
+ >
+ <div className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-purple-100 text-purple-700 dark:bg-purple-950 dark:text-purple-300">
+ <Bot className="h-3 w-3" />
+ </div>
+ <div className="min-w-0 flex-1 text-left">
+ <div className="truncate font-medium">{a.name}</div>
+ </div>
+ {isSelected("agent", a.id) && (
+ <span className="text-primary text-[10px] font-medium">Assigned</span>
+ )}
+ </button>
+ ))}
+ </>
+ )}
+
+ {filteredMembers.length === 0 && filteredAgents.length === 0 && (
+ <div className="px-2 py-3 text-center text-xs text-muted-foreground">
+ No results found
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
+
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
@@ -109,6 +263,7 @@ export default function IssueDetailPage({
const [loading, setLoading] = useState(true);
const [commentText, setCommentText] = useState("");
const [submitting, setSubmitting] = useState(false);
+ const [showAssigneePicker, setShowAssigneePicker] = useState(false);
useEffect(() => {
setIssue(null);
@@ -138,6 +293,31 @@ export default function IssueDetailPage({
}
};
+ const handleAssigneeChange = async (
+ type: IssueAssigneeType | null,
+ assigneeId: string | null,
+ ) => {
+ if (!issue) return;
+ setShowAssigneePicker(false);
+ // Optimistic update
+ setIssue({
+ ...issue,
+ assignee_type: type,
+ assignee_id: assigneeId,
+ });
+ try {
+ const updated = await api.updateIssue(id, {
+ assignee_type: type,
+ assignee_id: assigneeId,
+ });
+ setIssue(updated);
+ } catch (err) {
+ console.error("Failed to update assignee:", err);
+ // Revert on error
+ setIssue(issue);
+ }
+ };
+
if (loading) {
return (
<div className="flex h-full items-center justify-center text-sm text-muted-foreground">
@@ -259,20 +439,33 @@ export default function IssueDetailPage({
<span>{priorityCfg.label}</span>
</PropRow>
- <PropRow label="Assignee">
- {issue.assignee_type && issue.assignee_id ? (
- <>
- <ActorAvatar
- actorType={issue.assignee_type}
- actorId={issue.assignee_id}
- size={18}
- />
- <span>{getActorName(issue.assignee_type, issue.assignee_id)}</span>
- </>
- ) : (
- <span className="text-muted-foreground">Unassigned</span>
+ <div className="relative">
+ <PropRow
+ label="Assignee"
+ onClick={() => setShowAssigneePicker(!showAssigneePicker)}
+ >
+ {issue.assignee_type && issue.assignee_id ? (
+ <>
+ <ActorAvatar
+ actorType={issue.assignee_type}
+ actorId={issue.assignee_id}
+ size={18}
+ />
+ <span>{getActorName(issue.assignee_type, issue.assignee_id)}</span>
+ </>
+ ) : (
+ <span className="text-muted-foreground">Unassigned</span>
+ )}
+ </PropRow>
+
+ {showAssigneePicker && (
+ <AssigneePicker
+ issue={issue}
+ onSelect={handleAssigneeChange}
+ onClose={() => setShowAssigneePicker(false)}
+ />
)}
- </PropRow>
+ </div>
<PropRow label="Due date">
{issue.due_date ? (
diff --git a/apps/web/lib/auth-context.test.tsx b/apps/web/lib/auth-context.test.tsx
index 4431c0ff28..5da73903b2 100644
--- a/apps/web/lib/auth-context.test.tsx
+++ b/apps/web/lib/auth-context.test.tsx
@@ -77,6 +77,7 @@ const mockAgents: Agent[] = [
id: "agent-1",
workspace_id: "ws-1",
name: "Claude",
+ description: "",
avatar_url: null,
status: "idle",
runtime_mode: "cloud",
@@ -84,6 +85,9 @@ const mockAgents: Agent[] = [
visibility: "workspace",
max_concurrent_tasks: 3,
owner_id: null,
+ skills: "",
+ tools: [],
+ triggers: [],
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
},
diff --git a/apps/web/test/helpers.tsx b/apps/web/test/helpers.tsx
index ab472138c8..169ffbbbd7 100644
--- a/apps/web/test/helpers.tsx
+++ b/apps/web/test/helpers.tsx
@@ -44,6 +44,7 @@ export const mockAgents: Agent[] = [
id: "agent-1",
workspace_id: "ws-1",
name: "Claude Agent",
+ description: "",
avatar_url: null,
status: "idle",
runtime_mode: "cloud",
@@ -51,6 +52,9 @@ export const mockAgents: Agent[] = [
visibility: "workspace",
max_concurrent_tasks: 3,
owner_id: null,
+ skills: "",
+ tools: [],
+ triggers: [],
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
},
diff --git a/packages/sdk/src/api-client.ts b/packages/sdk/src/api-client.ts
index 811b494655..b64e335792 100644
--- a/packages/sdk/src/api-client.ts
+++ b/packages/sdk/src/api-client.ts
@@ -7,6 +7,9 @@ import type {
CreateMemberRequest,
UpdateMemberRequest,
Agent,
+ CreateAgentRequest,
+ UpdateAgentRequest,
+ AgentTask,
InboxItem,
Comment,
Workspace,
@@ -151,6 +154,28 @@ export class ApiClient {
return this.fetch(`/api/agents/${id}`);
}
+ async createAgent(data: CreateAgentRequest): Promise<Agent> {
+ return this.fetch("/api/agents", {
+ method: "POST",
+ body: JSON.stringify(data),
+ });
+ }
+
+ async updateAgent(id: string, data: UpdateAgentRequest): Promise<Agent> {
+ return this.fetch(`/api/agents/${id}`, {
+ method: "PUT",
+ body: JSON.stringify(data),
+ });
+ }
+
+ async deleteAgent(id: string): Promise<void> {
+ await this.fetch(`/api/agents/${id}`, { method: "DELETE" });
+ }
+
+ async listAgentTasks(agentId: string): Promise<AgentTask[]> {
+ return this.fetch(`/api/agents/${agentId}/tasks`);
+ }
+
// Inbox
async listInbox(): Promise<InboxItem[]> {
return this.fetch("/api/inbox");
diff --git a/packages/types/src/agent.ts b/packages/types/src/agent.ts
index 2fe5a98018..dbd2b46e7f 100644
--- a/packages/types/src/agent.ts
+++ b/packages/types/src/agent.ts
@@ -4,10 +4,51 @@ export type AgentRuntimeMode = "local" | "cloud";
export type AgentVisibility = "workspace" | "private";
+export type AgentTriggerType = "on_assign" | "scheduled";
+
+export interface RuntimeDevice {
+ id: string;
+ name: string;
+ runtime_mode: AgentRuntimeMode;
+ status: "online" | "offline";
+ device_info: string;
+}
+
+export interface AgentTool {
+ id: string;
+ name: string;
+ description: string;
+ auth_type: "oauth" | "api_key" | "none";
+ connected: boolean;
+ config: Record<string, unknown>;
+}
+
+export interface AgentTrigger {
+ id: string;
+ type: AgentTriggerType;
+ enabled: boolean;
+ config: Record<string, unknown>;
+}
+
+export interface AgentTask {
+ id: string;
+ agent_id: string;
+ issue_id: string;
+ status: "queued" | "dispatched" | "running" | "completed" | "failed" | "cancelled";
+ priority: number;
+ dispatched_at: string | null;
+ started_at: string | null;
+ completed_at: string | null;
+ result: unknown;
+ error: string | null;
+ created_at: string;
+}
+
export interface Agent {
id: string;
workspace_id: string;
name: string;
+ description: string;
avatar_url: string | null;
runtime_mode: AgentRuntimeMode;
runtime_config: Record<string, unknown>;
@@ -15,6 +56,35 @@ export interface Agent {
status: AgentStatus;
max_concurrent_tasks: number;
owner_id: string | null;
+ skills: string;
+ tools: AgentTool[];
+ triggers: AgentTrigger[];
created_at: string;
updated_at: string;
}
+
+export interface CreateAgentRequest {
+ name: string;
+ description?: string;
+ avatar_url?: string;
+ runtime_mode?: AgentRuntimeMode;
+ runtime_config?: Record<string, unknown>;
+ visibility?: AgentVisibility;
+ max_concurrent_tasks?: number;
+ skills?: string;
+ tools?: AgentTool[];
+ triggers?: AgentTrigger[];
+}
+
+export interface UpdateAgentRequest {
+ name?: string;
+ description?: string;
+ avatar_url?: string;
+ runtime_config?: Record<string, unknown>;
+ visibility?: AgentVisibility;
+ status?: AgentStatus;
+ max_concurrent_tasks?: number;
+ skills?: string;
+ tools?: AgentTool[];
+ triggers?: AgentTrigger[];
+}
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 28917ebd59..3834a5d0d9 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -1,5 +1,17 @@
export type { Issue, IssueStatus, IssuePriority, IssueAssigneeType } from "./issue.js";
-export type { Agent, AgentStatus, AgentRuntimeMode, AgentVisibility } from "./agent.js";
+export type {
+ Agent,
+ AgentStatus,
+ AgentRuntimeMode,
+ AgentVisibility,
+ AgentTriggerType,
+ AgentTool,
+ AgentTrigger,
+ AgentTask,
+ RuntimeDevice,
+ CreateAgentRequest,
+ UpdateAgentRequest,
+} from "./agent.js";
export type { Workspace, Member, MemberRole, User, MemberWithUser } from "./workspace.js";
export type { InboxItem, InboxSeverity, InboxItemType } from "./inbox.js";
export type { Comment, CommentType, CommentAuthorType } from "./comment.js";
diff --git a/server/cmd/seed/main.go b/server/cmd/seed/main.go
index 27ecb74baa..376bb0743a 100644
--- a/server/cmd/seed/main.go
+++ b/server/cmd/seed/main.go
@@ -62,13 +62,45 @@ func main() {
// Create some agents
agents := []struct {
name string
+ description string
runtimeMode string
status string
+ skills string
+ tools string
+ triggers string
}{
- {"Claude-1", "cloud", "idle"},
- {"Claude-2", "cloud", "working"},
- {"Local Agent", "local", "offline"},
- {"Code Review Bot", "cloud", "idle"},
+ {
+ "Deep Research Agent",
+ "Performs deep research on topics using web search and analysis",
+ "local", "idle",
+ "# Deep Research Agent\n\nYou are a research agent that performs thorough analysis on assigned topics.\n\n## Workflow\n1. Break down the research question into sub-questions\n2. Use web search to gather information from multiple sources\n3. Cross-reference and validate findings\n4. Synthesize a comprehensive report\n5. Post the report as a comment on the issue\n\n## Output Format\nAlways produce a structured report with:\n- Executive Summary\n- Key Findings\n- Sources\n- Recommendations",
+ `[{"id":"tool-1","name":"Google Search","description":"Search the web for information","auth_type":"api_key","connected":true,"config":{}},{"id":"tool-2","name":"Web Scraper","description":"Extract content from web pages","auth_type":"none","connected":true,"config":{}}]`,
+ `[{"id":"trigger-1","type":"on_assign","enabled":true,"config":{}}]`,
+ },
+ {
+ "Code Review Bot",
+ "Reviews pull requests and provides feedback on code quality",
+ "cloud", "idle",
+ "# Code Review Bot\n\nYou review code changes and provide constructive feedback.\n\n## Review Criteria\n- Code correctness and logic\n- Performance implications\n- Security vulnerabilities\n- Code style and readability\n- Test coverage\n\n## Process\n1. Read the issue description for context\n2. Analyze code changes\n3. Post review comments on specific lines\n4. Provide an overall summary",
+ `[{"id":"tool-3","name":"GitHub","description":"Access GitHub repositories and PRs","auth_type":"oauth","connected":true,"config":{}}]`,
+ `[{"id":"trigger-2","type":"on_assign","enabled":true,"config":{}}]`,
+ },
+ {
+ "Daily Standup Bot",
+ "Generates daily standup summaries from recent activity",
+ "cloud", "working",
+ "# Daily Standup Bot\n\nGenerate a daily standup summary based on workspace activity.\n\n## Tasks\n1. Collect all issue status changes from the last 24 hours\n2. Summarize what each team member worked on\n3. Identify blocked items\n4. Post the summary to the team channel",
+ `[{"id":"tool-4","name":"Slack","description":"Send messages to Slack channels","auth_type":"oauth","connected":true,"config":{"channel":"#standup"}}]`,
+ `[{"id":"trigger-3","type":"scheduled","enabled":true,"config":{"cron":"0 9 * * 1-5","timezone":"Asia/Shanghai"}}]`,
+ },
+ {
+ "Local Dev Agent",
+ "A local development agent running on your machine",
+ "local", "offline",
+ "",
+ `[]`,
+ `[{"id":"trigger-4","type":"on_assign","enabled":true,"config":{}}]`,
+ },
}
for _, a := range agents {
@@ -82,10 +114,10 @@ func main() {
continue
}
err = pool.QueryRow(ctx, `
- INSERT INTO agent (workspace_id, name, runtime_mode, status, owner_id)
- VALUES ($1, $2, $3, $4, $5)
+ INSERT INTO agent (workspace_id, name, description, runtime_mode, status, owner_id, skills, tools, triggers)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8::jsonb, $9::jsonb)
RETURNING id
- `, workspaceID, a.name, a.runtimeMode, a.status, userID).Scan(&agentID)
+ `, workspaceID, a.name, a.description, a.runtimeMode, a.status, userID, a.skills, a.tools, a.triggers).Scan(&agentID)
if err != nil {
log.Printf("Failed to create agent %s: %v", a.name, err)
continue
diff --git a/server/migrations/002_agent_config.down.sql b/server/migrations/002_agent_config.down.sql
new file mode 100644
index 0000000000..ac6b8e55ad
--- /dev/null
+++ b/server/migrations/002_agent_config.down.sql
@@ -0,0 +1,5 @@
+ALTER TABLE agent
+ DROP COLUMN IF EXISTS description,
+ DROP COLUMN IF EXISTS skills,
+ DROP COLUMN IF EXISTS tools,
+ DROP COLUMN IF EXISTS triggers;
diff --git a/server/migrations/002_agent_config.up.sql b/server/migrations/002_agent_config.up.sql
new file mode 100644
index 0000000000..5c0af0e85b
--- /dev/null
+++ b/server/migrations/002_agent_config.up.sql
@@ -0,0 +1,6 @@
+-- Add agent configuration columns: skills, tools, triggers
+ALTER TABLE agent
+ ADD COLUMN description TEXT NOT NULL DEFAULT '',
+ ADD COLUMN skills TEXT NOT NULL DEFAULT '',
+ ADD COLUMN tools JSONB NOT NULL DEFAULT '[]',
+ ADD COLUMN triggers JSONB NOT NULL DEFAULT '[]';