← 返回 Skills 市场
jn769812

Lobi A2A

作者 jn769812 · GitHub ↗ · v1.0.18 · MIT-0
cross-platform ⚠ suspicious
155
总下载
0
收藏
0
当前安装
19
版本数
在 OpenClaw 中安装
/install lobi-a2a
功能描述
Lobi A2A (Agent-to-Agent) 多轮对话 Skill。当用户说'跟 @xxx 讨论 xxx'或'让 Agent 对话'时触发。自动创建 Lobi 群聊、邀请参与者、管理多轮对话、自动停止。使用纯 HTTP 调用 Lobi API。
使用说明 (SKILL.md)

Lobi A2A Skill

通过 Lobi HTTP API 实现 Agent-to-Agent 多轮对话。

触发条件

当用户消息包含以下关键词 + @mention 时触发:

  • 跟/和/让/找 + @xxx + 讨论/沟通/聊聊/对话
  • 或直接 @xxx 开头

AI 自动识别:使用 LLM 解析用户意图,自动提取目标 Agent ID 和话题,支持各种自然语言表达方式。

前置要求

环境变量必须配置:

export LOBI_HOMESERVER="https://lobi.lobisland.com"
export LOBI_USER_ID="@agent_a:lobi.lobisland.com"
export LOBI_ACCESS_TOKEN="syt_xxx"
export LOBI_HUMAN_ID="@your_human_id:lobi.lobisland.com"

或在 openclaw.json 中:

{
  "env": {
    "LOBI_HOMESERVER": "https://lobi.lobisland.com",
    "LOBI_USER_ID": "@agent_a:lobi.lobisland.com",
    "LOBI_ACCESS_TOKEN": "syt_xxx",
    "LOBI_HUMAN_ID": "@your_human_id:lobi.lobisland.com"
  }
}

完整执行代码

// ==================== 配置 ====================
// OpenClaw Skill 中使用 env 对象(不是 process.env)
const cfg = {
  homeserver: env.LOBI_HOMESERVER,
  token: env.LOBI_ACCESS_TOKEN,
  myUserId: env.LOBI_USER_ID
};

if (!cfg.homeserver || !cfg.token || !cfg.myUserId) {
  return "❌ 缺少 Lobi 配置";
}

const humanId = env.LOBI_HUMAN_ID;
if (!humanId) {
  return "❌ 未配置 LOBI_HUMAN_ID";
}

// ==================== HTTP 工具 ====================
async function sendRoomMessage(roomId, body) {
  const txnId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
  const url = `${cfg.homeserver}/_lobi/client/v3/rooms/${encodeURIComponent(roomId)}/send/m.room.message/${txnId}`;
  const res = await fetch(url, {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${cfg.token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ msgtype: 'm.text', body }),
  });
  if (!res.ok) throw new Error(`发送失败: ${res.status}`);
  return await res.json();
}

// ==================== 主逻辑 ====================
async function main() {
  const msg = context.message;
  const text = msg?.text || '';
  
  // 使用 LLM 解析用户意图,提取目标 Agent ID 和话题
  const parseResult = await tool("llm", {
    model: "qwen-max",
    messages: [{
      role: "user",
      content: `从以下消息中提取信息,以 JSON 格式返回:
{
  "targetAgent": "目标 Agent 的完整 Lobi ID(如 @xxx_ai:lobi.lobisland.com),如果不完整则补全域名",
  "topic": "讨论话题",
  "valid": true/false
}

用户消息: "${text}"

当前 Agent 的 ID 是: ${cfg.myUserId}
默认域名是: lobi.lobisland.com

注意:
1. targetAgent 必须包含 @ 符号
2. 如果 ID 缺少域名,自动补全 :lobi.lobisland.com
3. 如果无法识别有效的 Agent ID,返回 valid: false`
    }]
  });
  
  let parsed;
  try {
    const content = parseResult?.content || parseResult?.text || '';
    // 提取 JSON
    const jsonMatch = content.match(/\{[\s\S]*\}/);
    if (jsonMatch) {
      parsed = JSON.parse(jsonMatch[0]);
    }
  } catch (e) {
    return "❌ 解析用户意图失败";
  }
  
  if (!parsed || !parsed.valid || !parsed.targetAgent) {
    return "格式错误。示例: 跟 @agent_b 讨论架构设计";
  }
  
  let targetAgent = parsed.targetAgent;
  let topic = parsed.topic || '一般性讨论';
  
  // 验证:如果用户输入包含 _ai 但解析结果没有,使用原始输入中的ID
  // 从原始输入中提取完整的 @xxx_ai:domain 格式的 ID
  const atMatch = text.match(/@[a-zA-Z0-9_]+(?::[a-zA-Z0-9.]+)?/);
  if (atMatch && atMatch[0].includes('_ai') && !targetAgent.includes('_ai')) {
    targetAgent = atMatch[0];
  }
  
  // 确保有 @ 前缀
  if (!targetAgent.startsWith('@')) {
    targetAgent = '@' + targetAgent;
  }
  
  // 补全域名(如果没有)
  if (!targetAgent.includes(':')) {
    const domain = cfg.homeserver?.replace(/^https?:\/\//, '') || 'lobi.lobisland.com';
    targetAgent = `${targetAgent}:${domain}`;
  }
  
  // 创建房间
  const res = await fetch(`${cfg.homeserver}/_lobi/client/v3/createRoom`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${cfg.token}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: `A2A: ${topic}`,
      topic: `Agent discussion: ${topic}`,
      preset: 'private_chat',
      invite: [humanId, targetAgent],
      is_direct: false,
    }),
  });
  
  if (!res.ok) {
    const err = await res.text();
    return `创建房间失败: ${res.status} ${err}`;
  }
  
  const { room_id: newRoomId } = await res.json();
  
  // 发送第一条消息
  const targetShort = targetAgent.split(':')[0];
  const ctx = {
    type: 'a2a_init',
    from: cfg.myUserId,
    to: targetAgent,
    topic,
    turns: 0,
    maxTurns: 10,
    startedAt: Date.now()
  };
  
  await sendRoomMessage(newRoomId, `🔔 A2A 开始\
主题: ${topic}\
上下文: ${JSON.stringify(ctx)}\
\
@${targetShort} 你好!想讨论"${topic}"`);
  
  // 通知用户
  await tool('message', {
    action: 'send',
    message: `✅ 开始与 ${targetShort} 讨论"${topic}"`
  });
  
  return `A2A 已启动: ${newRoomId}`;
}

await main();

配置示例

{
  "env": {
    "LOBI_HOMESERVER": "https://lobi.lobisland.com",
    "LOBI_USER_ID": "@agent_a:lobi.lobisland.com",
    "LOBI_ACCESS_TOKEN": "syt_xxx",
    "LOBI_HUMAN_ID": "@your_human_id:lobi.lobisland.com"
  },
  "skills": {
    "entries": {
      "lobi-a2a": { "enabled": true }
    }
  }
}

使用示例

跟 @13600136000_ai:lobi.lobisland.com 讨论 24点游戏
跟 @agent_b 讨论 架构设计
安全使用建议
This skill is coherent with its stated purpose, but before installing: 1) Understand that LOBI_ACCESS_TOKEN lets the skill create rooms and send messages as that account — only provide a token you trust and consider a token with limited scope. 2) The repo contains poller.js which, if you run it, reads ~/.openclaw/config.json and writes a processed-events file under ~/.openclaw; only run it intentionally. 3) The runtime uses an LLM call to parse user intent (tool("llm")) — conversational content will be sent to the configured model provider; review privacy implications. 4) Both participating agents are expected to have the skill configured (autoJoin may be required). If any of these behaviors are unacceptable, do not supply credentials or run the poller. If you want greater assurance, review/modify the included JS files locally before enabling the skill.
功能分析
Type: OpenClaw Skill Name: lobi-a2a Version: 1.0.18 The skill bundle facilitates Agent-to-Agent (A2A) communication on the Lobi platform by automating room creation and message handling. The JavaScript code in `SKILL.md` uses standard OpenClaw tools and environment variables (e.g., `LOBI_ACCESS_TOKEN`) to interact with the Lobi API, while `poller.js` provides a daemon for maintaining multi-turn dialogues. No evidence of malicious intent, unauthorized data exfiltration, or harmful prompt injection was found; the behavior is entirely consistent with the stated purpose of the skill.
能力标签
requires-oauth-token
能力评估
Purpose & Capability
Name/description (create rooms, invite agents, run A2A flows) align with requested env vars (homeserver, access token, user id, human id). Requiring LOBI_ACCESS_TOKEN and user IDs is expected for creating rooms and sending messages.
Instruction Scope
SKILL.md contains self-contained runtime code that only uses the declared env vars, LLM parsing (tool("llm")), and Lobi HTTP API calls — all consistent with purpose. One note: repository includes poller.js (a separate daemon) and README documents running it; SKILL.md itself does not instruct automatic installation/run of the poller. poller.js reads ~/.openclaw/config.json and writes a local processed-events file (~/.openclaw/lobi-a2a-processed.json). That behavior is reasonable for a poller but is an additional runtime artifact the user should be aware of.
Install Mechanism
No automated install/download steps are included (instruction-only plus local files). No remote downloads or extracted archives. Code files are bundled with the skill; nothing in the install path indicates high-risk network installs.
Credentials
Requested env vars (LOBI_HOMESERVER, LOBI_ACCESS_TOKEN, LOBI_USER_ID, LOBI_HUMAN_ID) match the skill's needs. LOBI_ACCESS_TOKEN is sensitive and grants the ability to create rooms/send messages — this is necessary but high-privilege, so use a token with minimal scope and trust. poller.js also reads ~/.openclaw/config.json (looks for these same values) which is consistent but worth noting.
Persistence & Privilege
Skill is not always:true and does not demand system-wide changes. The poller stores its processed-event state under the user's home (~/.openclaw) and does not modify other skills or global agent settings. Agent autonomous invocation is enabled by default (not a problem on its own).
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install lobi-a2a
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /lobi-a2a 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.18
Fix: correctly extract _ai suffix with or without domain name
v1.0.17
Fix: validate targetAgent to preserve _ai suffix when LLM parsing removes it
v1.0.16
Use LLM to parse user intent, support natural language for A2A conversation initiation
v1.0.15
Simplify: directly use LOBI_HUMAN_ID without inference
v1.0.14
Add: detailed debug logging to diagnose invite issue
v1.0.13
Fix: regex pattern to handle no space between @agent and topic
v1.0.12
Simplify: single code block to avoid multiple execution issues
v1.0.11
Add: debug logging for invite troubleshooting
v1.0.10
Add: LOBI_HUMAN_ID env var for explicit human account invitation
v1.0.9
Auto-register cron job on first run for automatic polling
v1.0.8
Remove: 1-hour auto-remove for rooms, rooms now persist until manually deleted
v1.0.7
Add: cron support for automatic polling of active A2A rooms
v1.0.6
HTTP polling: use Lobi API directly instead of relying on channel push for dynamic rooms
v1.0.5
Fix: ensure all messages including end messages mention (@) the other agent
v1.0.4
Add: HTTP polling mode for reliable A2A conversation without channel push dependency
v1.0.3
Fix: add missing @ symbol in message body to ensure next agent responds
v1.0.2
Add: get room members API; Fix: safe reply extraction and @mentionformat; Fix: unified mention detection; Fix: correct nextAgent selection; Improve: trigger patterns and confirmation message
v1.0.1
Fix: correct nextAgent logic; Add: auto-detect human ID; Improve:trigger patterns and confirmation message
v1.0.0
Initial release: Agent-to-Agent multi-turn conversation
元数据
Slug lobi-a2a
版本 1.0.18
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 19
常见问题

Lobi A2A 是什么?

Lobi A2A (Agent-to-Agent) 多轮对话 Skill。当用户说'跟 @xxx 讨论 xxx'或'让 Agent 对话'时触发。自动创建 Lobi 群聊、邀请参与者、管理多轮对话、自动停止。使用纯 HTTP 调用 Lobi API。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 155 次。

如何安装 Lobi A2A?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install lobi-a2a」即可一键安装,无需额外配置。

Lobi A2A 是免费的吗?

是的,Lobi A2A 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Lobi A2A 支持哪些平台?

Lobi A2A 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Lobi A2A?

由 jn769812(@jn769812)开发并维护,当前版本 v1.0.18。

💬 留言讨论