"use client"; import { useState } from "react"; import { Plus, FileText, Trash2, Info } from "lucide-react"; import type { Agent } from "@multica/core/types"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@multica/ui/components/ui/dialog"; import { Button } from "@multica/ui/components/ui/button"; import { toast } from "sonner"; import { api } from "@multica/core/api"; import { useWorkspaceId } from "@multica/core/hooks"; import { skillListOptions, workspaceKeys } from "@multica/core/workspace/queries"; import { useQuery, useQueryClient } from "@tanstack/react-query"; export function SkillsTab({ agent, }: { agent: Agent; }) { const qc = useQueryClient(); const wsId = useWorkspaceId(); const { data: workspaceSkills = [] } = useQuery(skillListOptions(wsId)); const [saving, setSaving] = useState(false); const [showPicker, setShowPicker] = useState(false); const agentSkillIds = new Set(agent.skills.map((s) => s.id)); const availableSkills = workspaceSkills.filter((s) => !agentSkillIds.has(s.id)); const handleAdd = async (skillId: string) => { setSaving(true); try { const newIds = [...agent.skills.map((s) => s.id), skillId]; await api.setAgentSkills(agent.id, { skill_ids: newIds }); qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) }); } catch (e) { toast.error(e instanceof Error ? e.message : "Failed to add skill"); } finally { setSaving(false); setShowPicker(false); } }; const handleRemove = async (skillId: string) => { setSaving(true); try { const newIds = agent.skills.filter((s) => s.id !== skillId).map((s) => s.id); await api.setAgentSkills(agent.id, { skill_ids: newIds }); qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) }); } catch (e) { toast.error(e instanceof Error ? e.message : "Failed to remove skill"); } finally { setSaving(false); } }; return (
Workspace skills assigned to this agent.
Local runtime skills (from your CLI's skills directory) are always available automatically — no need to add them here.
No skills assigned
Add workspace skills to share team knowledge with this agent. Local skills are already used automatically.
{availableSkills.length > 0 && ( )}