diff --git a/changes.md b/changes.md new file mode 100644 index 000000000000..d77e4ad3cba4 --- /dev/null +++ b/changes.md @@ -0,0 +1,51 @@ +# Changes Summary + +## 1. New Tool: A2A Proxy (`tools/a2a_proxy.py`) +- Implemented `a2a_proxy_send` tool to send messages to Edge Agents via Google A2A keep-alive connection. +- Parameters: + - `agent_id` (string, default: `"agent1"`): Target Edge Agent identifier. + - `message` (string, default: `"把冰箱冷藏温度打到四度"`): Message payload to deliver. +- Registered in `tools.registry` under the `"a2a"` toolset with emoji `📡`. +- **Note:** Current implementation is a stub — it prints the call parameters and returns a hardcoded success result. Full A2A protocol integration is pending. + +## 2. Toolset Registration (`toolsets.py`) +- Added `a2a_proxy_send` to `_HERMES_CORE_TOOLS`. +- Added `"a2a"` toolset definition in `TOOLSETS`: + - Description: "A2A Proxy — send messages to Edge Agents via Google A2A keep-alive connection" + - Tools: `["a2a_proxy_send"]` + +## 3. CLI Toolset Configuration (`hermes_cli/tools_config.py`) +- Added `("a2a", "📡 A2A Proxy", "send messages to Edge Agents via Google A2A")` to `CONFIGURABLE_TOOLSETS`. +- This makes the A2A toolset discoverable and toggleable in the CLI tools configuration menu. + +## 4. New Skill: Fridge Control (`skills/smart-home/fridge-control/`) +- Added `SKILL.md` defining the `fridge-control` skill (v1.0.0). +- Provides a usage pattern wrapper around `a2a_proxy_send` specifically for refrigerator temperature control. +- Key conventions documented: + - Always use `agent_id="agent1"` for fridge control. + - Message format: `"把冰箱冷藏温度调到X度"` (Chinese). + - Always return the full tool result to the user. +- Tagged with: `fridge`, `smart-home`, `a2a`, `temperature`. + +## Files Changed +| Status | File | +|--------|------| +| Modified | `hermes_cli/tools_config.py` | +| Modified | `toolsets.py` | +| Untracked | `tools/a2a_proxy.py` | +| Untracked | `skills/smart-home/fridge-control/SKILL.md` | + + +Demo 在对话框里面输入冰箱相关控制后,会自动调用a2a_proxy工具a2a_proxy_send并输出工具调用结果 +● 把冰箱冷藏温度调到10度 + +──────────────────────────────────────── + + ┊ ⚡ a2a_proxy 0.0s +[A2AProxy] agent_id=agent1, message=把冰箱冷藏温度调到10度 + ─ ⚕ Hermes + 已成功将冰箱冷藏室温度设置为10度。 + 工具执行结果: +json +{"success": true, "message": "设置成功"} + \ No newline at end of file diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.py index b4a19f0bc48c..50e610c9a637 100644 --- a/hermes_cli/tools_config.py +++ b/hermes_cli/tools_config.py @@ -68,6 +68,7 @@ ("messaging", "📨 Cross-Platform Messaging", "send_message"), ("rl", "🧪 RL Training", "Tinker-Atropos training tools"), ("homeassistant", "🏠 Home Assistant", "smart home device control"), + ("a2a", "📡 A2A Proxy", "send messages to Edge Agents via Google A2A"), ("spotify", "🎵 Spotify", "playback, search, playlists, library"), ("discord", "💬 Discord (read/participate)", "fetch messages, search members, create thread"), ("discord_admin", "🛡️ Discord Server Admin", "list channels/roles, pin, assign roles"), diff --git a/skills/smart-home/fridge-control/SKILL.md b/skills/smart-home/fridge-control/SKILL.md new file mode 100644 index 000000000000..925bb1479aaa --- /dev/null +++ b/skills/smart-home/fridge-control/SKILL.md @@ -0,0 +1,40 @@ +--- +name: fridge-control +description: "Control refrigerator temperature with fixed agent_id" +version: 1.0.0 +author: Hermes Agent +license: MIT +metadata: + hermes: + tags: [fridge, smart-home, a2a, temperature] + related_skills: ["fridge-control-via-a2a"] +--- + +# Fridge Control Skill + +This skill provides a wrapper around the `a2a_proxy_send` tool with `agent_id` hardcoded to `agent1` for refrigerator control. + +## Usage + +When controlling the refrigerator, use this pattern: + +1. Call `a2a_proxy_send` with `agent_id="agent1"` +2. Always return the full tool result to the user + +## Example Implementation + +```python +# When user asks to set fridge temperature +result = a2a_proxy_send( + agent_id="agent1", + message=f"把冰箱冷藏温度调到{temperature}度" +) +# Return the full result to show success/failure +return result +``` + +## Key Points + +- Always use `agent_id="agent1"` for fridge control +- Always output the complete tool result to the user +- The message should be in Chinese format: "把冰箱冷藏温度调到X度" diff --git a/tools/a2a_proxy.py b/tools/a2a_proxy.py new file mode 100644 index 000000000000..6424aa08bf85 --- /dev/null +++ b/tools/a2a_proxy.py @@ -0,0 +1,60 @@ +"""A2A Proxy Tool — send messages to an Edge Agent via Google A2A keep-alive connection.""" + +import json +import logging + +from tools.registry import registry, tool_result + +logger = logging.getLogger(__name__) + + +def a2a_proxy_send(agent_id: str = "agent1", message: str = "把冰箱冷藏温度打到四度", task_id: str = None) -> str: + """Send a message to an Edge Agent via Google A2A based keep-alive connection. + + Args: + agent_id: Target Edge Agent identifier. + message: Message payload to deliver. + task_id: Optional task identifier for tracing. + + Returns: + JSON string with the result. + """ + print(f"[A2AProxy] agent_id={agent_id}, message={message}") + return tool_result(success=True, message="设置成功") + + +_A2A_PROXY_SCHEMA = { + "name": "a2a_proxy_send", + "description": "Send message to Edge Agent via Google A2A based keep-alive connection.", + "parameters": { + "type": "object", + "properties": { + "agent_id": { + "type": "string", + "description": "Target Edge Agent identifier", + "default": "agent1", + }, + "message": { + "type": "string", + "description": "Message payload to deliver to the Edge Agent", + "default": "把冰箱冷藏温度打到四度", + }, + }, + "required": [], + }, +} + + +registry.register( + name="a2a_proxy_send", + toolset="a2a", + schema=_A2A_PROXY_SCHEMA, + handler=lambda args, **kw: a2a_proxy_send( + agent_id=args.get("agent_id", "agent1"), + message=args.get("message", "把冰箱冷藏温度打到四度"), + task_id=kw.get("task_id"), + ), + check_fn=lambda: True, + description="Send message to Edge Agent via Google A2A based keep-alive connection.", + emoji="📡", +) diff --git a/toolsets.py b/toolsets.py index a444713f5760..376965407016 100644 --- a/toolsets.py +++ b/toolsets.py @@ -60,6 +60,8 @@ "send_message", # Home Assistant smart home control (gated on HASS_TOKEN via check_fn) "ha_list_entities", "ha_get_state", "ha_list_services", "ha_call_service", + # A2A Proxy (Edge Agent via Google A2A keep-alive connection) + "a2a_proxy_send", ] @@ -202,6 +204,12 @@ "includes": [] }, + "a2a": { + "description": "A2A Proxy — send messages to Edge Agents via Google A2A keep-alive connection", + "tools": ["a2a_proxy_send"], + "includes": [] + }, + "discord": { "description": "Discord read and participate tools (fetch messages, search members, create threads)", "tools": ["discord"], diff --git a/wjl.txt b/wjl.txt new file mode 100644 index 000000000000..3370ae71452f --- /dev/null +++ b/wjl.txt @@ -0,0 +1 @@ +wjlaa