A2A Worker
NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.
When to Use This Skill
Features involving:
- A2A server auto-start hook creation
- A2A client library development
- Router-to-A2A integration
- Cross-session communication via A2A HTTP
- A2A test suite development
Work Procedure
Read CTO Directive #3 from AGENTS.md: A2A server MUST be spawned as fully detached background subprocess. NEVER synchronous.
Study the existing pattern in .claude/hooks/channels/channel-auto-start.cjs:
- How it checks env vars and prerequisites
- How it uses lockfile with
wx flag for cooldown
- How it records PID in
terminal-pids.json
- How it spawns a detached process via
.bat file + start "" /D
- How it uses VBScript for auto-accept
Write tests first (red) for the component you're building:
- Auto-start hook: test lockfile creation, PID tracking, duplicate prevention
- Client library: test discovery, send, get, cancel, subscribe
- Router integration: test dispatch flow
Implement following existing A2A code patterns:
- Server code is in
.claude/lib/a2a/server.cjs (Express, JSON-RPC 2.0)
- Task state machine in
.claude/lib/a2a/task-state-machine.cjs
- Agent card in
.claude/lib/a2a/agent-card.cjs
- SSE in
.claude/lib/a2a/sse-stream.cjs
- JSON-RPC in
.claude/lib/a2a/jsonrpc-handler.cjs
For auto-start hook (a2a-server-autostart.cjs):
- Register as UserPromptSubmit hook in settings.json
- Check
A2A_AUTO_START=true env var
- Check not already inside A2A session
- Use atomic lockfile with 2-min cooldown
- Check terminal-pids.json for existing live PID
- Spawn via
.bat file + start "" /D pattern (Windows)
- Record PID in terminal-pids.json with purpose: 'a2a-server'
- Exit hook promptly (< 5 seconds)
For client library (client.cjs):
- Create at
.claude/lib/a2a/client.cjs
- Methods: discover(), sendTask(), getTask(), cancelTask(), sendSubscribe()
- Uses standard http/https module (no external dependencies)
- Handles JSON-RPC 2.0 request/response envelope
- Handles SSE streaming for subscribe
For router integration:
- Wire A2A client into the routing/dispatch flow
- Router can send tasks to channel session via A2A HTTP
- Handle task results and failures
Run tests:
node --test tests/lib/a2a/*.test.cjs
Verify coexistence with Telegram:
- Both auto-start hooks should work independently
- Separate lockfiles, separate PID entries
- No port conflicts
Commit with descriptive message.
Example Handoff
{
"salientSummary": "Created a2a-server-autostart.cjs hook following channel-auto-start.cjs pattern. Spawns Express server on port 3100 as detached background process via .bat file. Uses independent lockfile and PID tracking. Created A2A client at .claude/lib/a2a/client.cjs with discover/send/get/cancel/subscribe methods. Both Telegram and A2A auto-start work independently.",
"whatWasImplemented": "Auto-start hook with env check, lockfile, PID tracking, detached spawn. Client library with full JSON-RPC 2.0 support and SSE streaming. Both registered in settings.json.",
"whatWasLeftUndone": "",
"verification": {
"commandsRun": [
{
"command": "node --test tests/lib/a2a/a2a-server.test.cjs",
"exitCode": 0,
"observation": "All server tests pass"
},
{
"command": "node --test tests/lib/a2a/a2a-client.test.cjs",
"exitCode": 0,
"observation": "All client tests pass"
},
{ "command": "pnpm test:framework", "exitCode": 0, "observation": "No regressions" }
],
"interactiveChecks": []
},
"tests": {
"added": [
{
"file": "tests/lib/a2a/a2a-client.test.cjs",
"cases": [
{ "name": "discovers remote agent card", "verifies": "client discovery" },
{ "name": "sends task via JSON-RPC", "verifies": "task creation" },
{ "name": "polls task status", "verifies": "status retrieval" }
]
}
],
"coverage": "A2A server, client, and autostart hook covered"
},
"discoveredIssues": []
}
When to Return to Orchestrator
- Express server can't bind to port 3100 (port conflict)
- Telegram auto-start interferes with A2A auto-start
- Existing A2A server code has bugs that block integration
- Windows-specific spawn pattern doesn't work as expected
1---2name: a2a-worker3description: Builds A2A protocol integration - auto-start hook, client library, router wiring4metadata:5 source: https://skillmd.com/skills/oimiragieo/a2a-worker6---78# A2A Worker910NOTE: Startup and cleanup are handled by `worker-base`. This skill defines the WORK PROCEDURE.1112## When to Use This Skill1314Features involving:1516- A2A server auto-start hook creation17- A2A client library development18- Router-to-A2A integration19- Cross-session communication via A2A HTTP20- A2A test suite development2122## Work Procedure23241. **Read CTO Directive #3 from AGENTS.md:** A2A server MUST be spawned as fully detached background subprocess. NEVER synchronous.25262. **Study the existing pattern** in `.claude/hooks/channels/channel-auto-start.cjs`:27 - How it checks env vars and prerequisites28 - How it uses lockfile with `wx` flag for cooldown29 - How it records PID in `terminal-pids.json`30 - How it spawns a detached process via `.bat` file + `start "" /D`31 - How it uses VBScript for auto-accept32333. **Write tests first (red)** for the component you're building:34 - Auto-start hook: test lockfile creation, PID tracking, duplicate prevention35 - Client library: test discovery, send, get, cancel, subscribe36 - Router integration: test dispatch flow37384. **Implement following existing A2A code patterns:**39 - Server code is in `.claude/lib/a2a/server.cjs` (Express, JSON-RPC 2.0)40 - Task state machine in `.claude/lib/a2a/task-state-machine.cjs`41 - Agent card in `.claude/lib/a2a/agent-card.cjs`42 - SSE in `.claude/lib/a2a/sse-stream.cjs`43 - JSON-RPC in `.claude/lib/a2a/jsonrpc-handler.cjs`44455. **For auto-start hook (`a2a-server-autostart.cjs`):**46 - Register as UserPromptSubmit hook in settings.json47 - Check `A2A_AUTO_START=true` env var48 - Check not already inside A2A session49 - Use atomic lockfile with 2-min cooldown50 - Check terminal-pids.json for existing live PID51 - Spawn via `.bat` file + `start "" /D` pattern (Windows)52 - Record PID in terminal-pids.json with purpose: 'a2a-server'53 - Exit hook promptly (< 5 seconds)54556. **For client library (`client.cjs`):**56 - Create at `.claude/lib/a2a/client.cjs`57 - Methods: discover(), sendTask(), getTask(), cancelTask(), sendSubscribe()58 - Uses standard http/https module (no external dependencies)59 - Handles JSON-RPC 2.0 request/response envelope60 - Handles SSE streaming for subscribe61627. **For router integration:**63 - Wire A2A client into the routing/dispatch flow64 - Router can send tasks to channel session via A2A HTTP65 - Handle task results and failures66678. **Run tests:**6869 ```70 node --test tests/lib/a2a/*.test.cjs71 ```72739. **Verify coexistence with Telegram:**74 - Both auto-start hooks should work independently75 - Separate lockfiles, separate PID entries76 - No port conflicts777810. **Commit** with descriptive message.7980## Example Handoff8182```json83{84 "salientSummary": "Created a2a-server-autostart.cjs hook following channel-auto-start.cjs pattern. Spawns Express server on port 3100 as detached background process via .bat file. Uses independent lockfile and PID tracking. Created A2A client at .claude/lib/a2a/client.cjs with discover/send/get/cancel/subscribe methods. Both Telegram and A2A auto-start work independently.",85 "whatWasImplemented": "Auto-start hook with env check, lockfile, PID tracking, detached spawn. Client library with full JSON-RPC 2.0 support and SSE streaming. Both registered in settings.json.",86 "whatWasLeftUndone": "",87 "verification": {88 "commandsRun": [89 {90 "command": "node --test tests/lib/a2a/a2a-server.test.cjs",91 "exitCode": 0,92 "observation": "All server tests pass"93 },94 {95 "command": "node --test tests/lib/a2a/a2a-client.test.cjs",96 "exitCode": 0,97 "observation": "All client tests pass"98 },99 { "command": "pnpm test:framework", "exitCode": 0, "observation": "No regressions" }100 ],101 "interactiveChecks": []102 },103 "tests": {104 "added": [105 {106 "file": "tests/lib/a2a/a2a-client.test.cjs",107 "cases": [108 { "name": "discovers remote agent card", "verifies": "client discovery" },109 { "name": "sends task via JSON-RPC", "verifies": "task creation" },110 { "name": "polls task status", "verifies": "status retrieval" }111 ]112 }113 ],114 "coverage": "A2A server, client, and autostart hook covered"115 },116 "discoveredIssues": []117}118```119120## When to Return to Orchestrator121122- Express server can't bind to port 3100 (port conflict)123- Telegram auto-start interferes with A2A auto-start124- Existing A2A server code has bugs that block integration125- Windows-specific spawn pattern doesn't work as expected