-
Notifications
You must be signed in to change notification settings - Fork 405
feat(ui): add A2A skills configuration to agent creation/editing #1291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
opspawn
wants to merge
2
commits into
kagent-dev:main
Choose a base branch
from
opspawn:feat/a2a-skills-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| import React from "react"; | ||
| import { Input } from "@/components/ui/input"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { Label } from "@/components/ui/label"; | ||
| import { Textarea } from "@/components/ui/textarea"; | ||
| import { PlusCircle, Trash2, ChevronDown, ChevronUp } from "lucide-react"; | ||
| import type { AgentSkill } from "@/types"; | ||
|
|
||
| export const EMPTY_A2A_SKILL: AgentSkill = { | ||
| id: "", | ||
| name: "", | ||
| description: "", | ||
| tags: [], | ||
| examples: [], | ||
| inputModes: ["text"], | ||
| outputModes: ["text"], | ||
| }; | ||
|
|
||
| interface A2ASkillsSectionProps { | ||
| skills: AgentSkill[]; | ||
| onChange: (skills: AgentSkill[]) => void; | ||
| disabled?: boolean; | ||
| error?: string; | ||
| } | ||
|
|
||
| export function A2ASkillsSection({ skills, onChange, disabled, error }: A2ASkillsSectionProps) { | ||
| const [expandedIndex, setExpandedIndex] = React.useState<number | null>(skills.length > 0 ? 0 : null); | ||
|
|
||
| const updateSkill = (index: number, updates: Partial<AgentSkill>) => { | ||
| const updated = [...skills]; | ||
| updated[index] = { ...updated[index], ...updates }; | ||
| onChange(updated); | ||
| }; | ||
|
|
||
| const addSkill = () => { | ||
| onChange([...skills, { ...EMPTY_A2A_SKILL }]); | ||
| setExpandedIndex(skills.length); | ||
| }; | ||
|
|
||
| const removeSkill = (index: number) => { | ||
| const updated = skills.filter((_, i) => i !== index); | ||
| onChange(updated); | ||
| if (expandedIndex === index) { | ||
| setExpandedIndex(null); | ||
| } else if (expandedIndex !== null && expandedIndex > index) { | ||
| setExpandedIndex(expandedIndex - 1); | ||
| } | ||
| }; | ||
|
|
||
| const parseCommaSeparated = (value: string): string[] => { | ||
| return value.split(",").map((s) => s.trim()).filter(Boolean); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="space-y-4"> | ||
| <div> | ||
| <Label className="text-sm mb-2 block font-semibold">A2A Skills</Label> | ||
| <p className="text-xs mb-3 block text-muted-foreground"> | ||
| Define A2A (Agent-to-Agent) skills that this agent exposes. Each skill describes a capability | ||
| that other agents can discover and invoke via the A2A protocol. | ||
| </p> | ||
| </div> | ||
|
|
||
| {skills.length === 0 && ( | ||
| <p className="text-xs text-muted-foreground italic">No A2A skills configured. Click "Add A2A Skill" to get started.</p> | ||
| )} | ||
|
|
||
| <div className="space-y-3"> | ||
| {skills.map((skill, index) => { | ||
| const isExpanded = expandedIndex === index; | ||
| const skillLabel = skill.name || skill.id || `Skill ${index + 1}`; | ||
|
|
||
| return ( | ||
| <div key={index} className="border rounded-md"> | ||
| <div | ||
| className="flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-muted/50" | ||
| role="button" | ||
| tabIndex={0} | ||
| aria-expanded={isExpanded} | ||
| onClick={() => setExpandedIndex(isExpanded ? null : index)} | ||
| onKeyDown={(e) => { | ||
| if (e.key === "Enter" || e.key === " ") { | ||
| e.preventDefault(); | ||
| setExpandedIndex(isExpanded ? null : index); | ||
| } | ||
| }} | ||
| > | ||
| <div className="flex items-center gap-2"> | ||
| {isExpanded ? ( | ||
| <ChevronUp className="h-4 w-4 text-muted-foreground" /> | ||
| ) : ( | ||
| <ChevronDown className="h-4 w-4 text-muted-foreground" /> | ||
| )} | ||
| <span className="text-sm font-medium">{skillLabel}</span> | ||
| {skill.id && skill.name && ( | ||
| <span className="text-xs text-muted-foreground">({skill.id})</span> | ||
| )} | ||
| </div> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| removeSkill(index); | ||
| }} | ||
| disabled={disabled} | ||
| title="Remove skill" | ||
| > | ||
| <Trash2 className="h-4 w-4 text-red-500" /> | ||
| </Button> | ||
| </div> | ||
|
|
||
| {isExpanded && ( | ||
| <div className="px-4 pb-4 space-y-3 border-t"> | ||
| <div className="grid grid-cols-2 gap-3 pt-3"> | ||
| <div> | ||
| <Label className="text-xs mb-1 block">ID <span className="text-red-500">*</span></Label> | ||
| <Input | ||
| placeholder="e.g. kubernetes-deploy" | ||
| value={skill.id} | ||
| onChange={(e) => updateSkill(index, { id: e.target.value })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <Label className="text-xs mb-1 block">Name <span className="text-red-500">*</span></Label> | ||
| <Input | ||
| placeholder="e.g. Kubernetes Deployment Manager" | ||
| value={skill.name} | ||
| onChange={(e) => updateSkill(index, { name: e.target.value })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div> | ||
| <Label className="text-xs mb-1 block">Description</Label> | ||
| <Textarea | ||
| placeholder="Describe what this skill does..." | ||
| value={skill.description || ""} | ||
| onChange={(e) => updateSkill(index, { description: e.target.value })} | ||
| disabled={disabled} | ||
| className="text-sm min-h-[60px]" | ||
| /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <Label className="text-xs mb-1 block">Tags (comma-separated)</Label> | ||
| <Input | ||
| placeholder="e.g. kubernetes, deploy, infrastructure" | ||
| value={(skill.tags || []).join(", ")} | ||
| onChange={(e) => updateSkill(index, { tags: parseCommaSeparated(e.target.value) })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <Label className="text-xs mb-1 block">Examples (comma-separated)</Label> | ||
| <Input | ||
| placeholder='e.g. Deploy my app to staging, Scale the web service to 3 replicas' | ||
| value={(skill.examples || []).join(", ")} | ||
| onChange={(e) => updateSkill(index, { examples: parseCommaSeparated(e.target.value) })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="grid grid-cols-2 gap-3"> | ||
| <div> | ||
| <Label className="text-xs mb-1 block">Input Modes (comma-separated)</Label> | ||
| <Input | ||
| placeholder="e.g. text, file" | ||
| value={(skill.inputModes || []).join(", ")} | ||
| onChange={(e) => updateSkill(index, { inputModes: parseCommaSeparated(e.target.value) })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <Label className="text-xs mb-1 block">Output Modes (comma-separated)</Label> | ||
| <Input | ||
| placeholder="e.g. text, file" | ||
| value={(skill.outputModes || []).join(", ")} | ||
| onChange={(e) => updateSkill(index, { outputModes: parseCommaSeparated(e.target.value) })} | ||
| disabled={disabled} | ||
| className="text-sm" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| onClick={addSkill} | ||
| disabled={disabled} | ||
| className="w-full" | ||
| > | ||
| <PlusCircle className="h-4 w-4 mr-2" /> | ||
| Add A2A Skill | ||
| </Button> | ||
|
|
||
| {error && ( | ||
| <p className="text-red-500 text-sm mt-1">{error}</p> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The collapsible skill header is clickable but lacks proper accessibility attributes. The div should have
role="button",tabIndex={0}, andonKeyDownhandler to support keyboard navigation (Enter/Space keys). Additionally, consider addingaria-expanded={isExpanded}to communicate the expand/collapse state to screen readers.