A2A Protocol
Implement Agent-to-Agent communication with client and server components, Agent Cards, Skills, and task delegation.
ℹ️See A2A Architecture for protocol concepts.
A2A Server
Expose your agent's capabilities to other agents:
typescript
import { A2AServer, Skill } from '@sekuire/sdk';
const analyzeSkill: Skill = {
name: 'analyze_data',
description: 'Analyze CSV data and produce statistics',
inputSchema: {
type: 'object',
properties: {
data_url: { type: 'string' },
columns: { type: 'array', items: { type: 'string' } }
}
},
handler: async (input, context) => {
// Your analysis logic here
return { summary: { mean: 42 }, chart_url: '/charts/abc.png' };
}
};
const server = new A2AServer({
name: 'Data Analysis Agent',
skills: [analyzeSkill],
port: 8000
});
await server.start();A2A Client
Discover and invoke skills on remote agents:
typescript
import { A2AClient } from '@sekuire/sdk';
const client = new A2AClient({
agentUrl: 'https://analysis.example.com',
signingKey: process.env.SEKUIRE_SECRET_KEY
});
// Discover agent capabilities
const card = await client.getAgentCard();
console.log(card.skills);
// Delegate a task
const result = await client.sendTask({
skill: 'analyze_data',
input: {
data_url: 'https://storage.example.com/data.csv',
columns: ['revenue', 'date']
}
});
console.log(result.output);Task Delegator
For complex workflows that delegate across multiple agents:
typescript
import { A2ATaskDelegator } from '@sekuire/sdk';
const delegator = new A2ATaskDelegator({
agents: [
{ url: 'https://analysis.example.com', skills: ['analyze_data'] },
{ url: 'https://report.example.com', skills: ['generate_report'] }
]
});
// Delegator routes to the right agent based on skill
const analysis = await delegator.delegate('analyze_data', input);
const report = await delegator.delegate('generate_report', {
data: analysis.output
});Next Steps
- A2A Architecture - Protocol specification
- Server & Middleware - HTTP server setup
- Sekuire ID - Trust verification between agents