myagent-ai 1.23.70 → 1.23.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/myagent/scripts/cli.py +6 -35
- package/myagent/web/api_server.py +12 -9
- package/package.json +1 -1
- package/scripts/cli.py +27 -55
- package/web/api_server.py +12 -12
package/myagent/scripts/cli.py
CHANGED
|
@@ -1079,7 +1079,7 @@ async def cmd_chat(args):
|
|
|
1079
1079
|
"""Agent间通信 — 向群内其他Agent发送消息或文件"""
|
|
1080
1080
|
import argparse
|
|
1081
1081
|
p = argparse.ArgumentParser(prog="myagent-ai chat", description="向群内其他Agent发送消息或文件,消息会出现在群聊记录中")
|
|
1082
|
-
p.add_argument("--agent", "-a", required=True, help="目标Agent
|
|
1082
|
+
p.add_argument("--agent", "-a", required=True, help="目标Agent ID(群成员列表中显示的唯一ID)")
|
|
1083
1083
|
p.add_argument("--message", "-m", default="", help="要发送的消息内容")
|
|
1084
1084
|
p.add_argument("--file", "-f", default="", help="要发送的文件路径(可多次使用: -f file1 -f file2)")
|
|
1085
1085
|
p.add_argument("--group", "-g", help="群ID(可选,默认使用最近活跃的群)")
|
|
@@ -1089,12 +1089,11 @@ async def cmd_chat(args):
|
|
|
1089
1089
|
print("错误: 必须指定 --message 或 --file", file=sys.stderr)
|
|
1090
1090
|
sys.exit(1)
|
|
1091
1091
|
|
|
1092
|
-
# [v1.23.
|
|
1093
|
-
agents_data_dir = Path(
|
|
1092
|
+
# [v1.23.72] Agent 查找:按 ID 匹配,数据目录为 ~/.myagent/data/agents/
|
|
1093
|
+
agents_data_dir = Path.home() / ".myagent" / "data" / "agents"
|
|
1094
1094
|
resolved_path = None
|
|
1095
1095
|
|
|
1096
1096
|
if agents_data_dir.exists():
|
|
1097
|
-
# 第一优先级:精确匹配名字
|
|
1098
1097
|
for dept_dir in agents_data_dir.iterdir():
|
|
1099
1098
|
if not dept_dir.is_dir():
|
|
1100
1099
|
continue
|
|
@@ -1105,8 +1104,8 @@ async def cmd_chat(args):
|
|
|
1105
1104
|
if cf.exists():
|
|
1106
1105
|
try:
|
|
1107
1106
|
ag_cfg = json.loads(cf.read_text(encoding="utf-8"))
|
|
1108
|
-
|
|
1109
|
-
if
|
|
1107
|
+
# 按 ID 精确匹配
|
|
1108
|
+
if ag_cfg.get("id", "") == a.agent:
|
|
1110
1109
|
resolved_path = ag_dir.relative_to(agents_data_dir).as_posix()
|
|
1111
1110
|
break
|
|
1112
1111
|
except Exception:
|
|
@@ -1114,36 +1113,8 @@ async def cmd_chat(args):
|
|
|
1114
1113
|
if resolved_path:
|
|
1115
1114
|
break
|
|
1116
1115
|
|
|
1117
|
-
# 第二优先级:部分匹配(名字包含输入 或 路径末尾匹配)
|
|
1118
|
-
if not resolved_path:
|
|
1119
|
-
for dept_dir in agents_data_dir.iterdir():
|
|
1120
|
-
if not dept_dir.is_dir():
|
|
1121
|
-
continue
|
|
1122
|
-
for ag_dir in dept_dir.iterdir():
|
|
1123
|
-
if not ag_dir.is_dir():
|
|
1124
|
-
continue
|
|
1125
|
-
cf = ag_dir / "config.json"
|
|
1126
|
-
if cf.exists():
|
|
1127
|
-
try:
|
|
1128
|
-
ag_cfg = json.loads(cf.read_text(encoding="utf-8"))
|
|
1129
|
-
ag_name = ag_cfg.get("name", "")
|
|
1130
|
-
ag_rel = ag_dir.relative_to(agents_data_dir).as_posix()
|
|
1131
|
-
if a.agent in ag_name or ag_rel.endswith("/" + a.agent):
|
|
1132
|
-
resolved_path = ag_rel
|
|
1133
|
-
break
|
|
1134
|
-
except Exception:
|
|
1135
|
-
pass
|
|
1136
|
-
if resolved_path:
|
|
1137
|
-
break
|
|
1138
|
-
|
|
1139
|
-
# 第三优先级:也尝试直接当路径用(兼容旧方式)
|
|
1140
|
-
if not resolved_path:
|
|
1141
|
-
agent_dir = agents_data_dir / a.agent
|
|
1142
|
-
if (agent_dir / "config.json").exists():
|
|
1143
|
-
resolved_path = a.agent
|
|
1144
|
-
|
|
1145
1116
|
if not resolved_path:
|
|
1146
|
-
print(f"错误: Agent 不存在: {a.agent}
|
|
1117
|
+
print(f"错误: Agent 不存在: {a.agent}(请使用Agent的ID,从群成员列表中获取)", file=sys.stderr)
|
|
1147
1118
|
sys.exit(1)
|
|
1148
1119
|
|
|
1149
1120
|
agent_dir = agents_data_dir / resolved_path
|
|
@@ -7839,10 +7839,11 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7839
7839
|
for m in group.members:
|
|
7840
7840
|
mc = self._read_agent_config(m.agent_path)
|
|
7841
7841
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
7842
|
+
m_id = mc.get("id", "") if mc else ""
|
|
7842
7843
|
m_desc = mc.get("description", "") if mc else ""
|
|
7843
7844
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
7844
7845
|
nick = f"(昵称: {m.nickname})" if m.nickname else ""
|
|
7845
|
-
line = f" - {m_name} ({role_label})"
|
|
7846
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
7846
7847
|
if m_desc:
|
|
7847
7848
|
line += f" — {m_desc}"
|
|
7848
7849
|
line += nick
|
|
@@ -7898,9 +7899,9 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7898
7899
|
- @某个Agent: 只有被@的Agent需要回复
|
|
7899
7900
|
- @所有人 / @all: 所有成员都需要回复
|
|
7900
7901
|
- 不@任何人(广播): 你自行判断是否需要回复
|
|
7901
|
-
2. **跨Agent私下沟通**: 你可以使用 `myagent-ai chat --agent
|
|
7902
|
-
-
|
|
7903
|
-
- 正确示例: `myagent-ai chat --agent
|
|
7902
|
+
2. **跨Agent私下沟通**: 你可以使用 `myagent-ai chat --agent <ID> --message "消息"` 命令向群内其他Agent发送私下消息。对方会在自己下次处理消息时收到。
|
|
7903
|
+
- **必须使用Agent的ID**,不是名字。从上方「群成员列表」中找到目标Agent的 `[ID: xxx]` 就是它的唯一ID
|
|
7904
|
+
- 正确示例: `myagent-ai chat --agent a1b2c3d4e5f6 --message "你好"`
|
|
7904
7905
|
- 私下沟通的内容不会直接显示给用户,适合讨论细节、交换数据、协调方案
|
|
7905
7906
|
- 当任务需要多个Agent协作时,应该先在群里讨论分工,然后私下沟通具体细节
|
|
7906
7907
|
3. **协作分工模式**(复杂任务):
|
|
@@ -7917,7 +7918,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7917
7918
|
- 你只代表你自己发言,使用第一人称
|
|
7918
7919
|
- 不要假装是其他Agent或代替其他Agent回答
|
|
7919
7920
|
- 如果问题超出你的能力范围,建议用户@相关专家Agent
|
|
7920
|
-
- 如果需要其他Agent的信息,使用 `myagent-ai chat --agent
|
|
7921
|
+
- 如果需要其他Agent的信息,使用 `myagent-ai chat --agent <ID>` 命令私下沟通(使用Agent的ID,从群成员列表的[ID: xxx]中获取)
|
|
7921
7922
|
|
|
7922
7923
|
### 能力提醒(关键)
|
|
7923
7924
|
- 你拥有完整的工具调用能力(搜索、文件操作、代码执行、图片生成等)
|
|
@@ -8261,9 +8262,10 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8261
8262
|
for m in group.members:
|
|
8262
8263
|
mc = self._read_agent_config(m.agent_path)
|
|
8263
8264
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
8265
|
+
m_id = mc.get("id", "") if mc else ""
|
|
8264
8266
|
m_desc = mc.get("description", "") if mc else ""
|
|
8265
8267
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
8266
|
-
line = f" - {m_name} ({role_label})"
|
|
8268
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
8267
8269
|
if m_desc:
|
|
8268
8270
|
line += f" — {m_desc}"
|
|
8269
8271
|
member_lines.append(line)
|
|
@@ -8284,7 +8286,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8284
8286
|
+ "\n".join(member_lines)
|
|
8285
8287
|
+ "\n\n注意:你只代表自己发言,回复时使用第一人称。"
|
|
8286
8288
|
"如果消息不是跟你相关的,可以简短回复或不回复。"
|
|
8287
|
-
"\n向其他Agent
|
|
8289
|
+
"\n向其他Agent发消息时使用其ID(从群成员列表的[ID: xxx]中获取)。"
|
|
8288
8290
|
)
|
|
8289
8291
|
|
|
8290
8292
|
if agent_system_prompt:
|
|
@@ -8425,9 +8427,10 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8425
8427
|
for m in group.members:
|
|
8426
8428
|
mc = self._read_agent_config(m.agent_path)
|
|
8427
8429
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
8430
|
+
m_id = mc.get("id", "") if mc else ""
|
|
8428
8431
|
m_desc = mc.get("description", "") if mc else ""
|
|
8429
8432
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
8430
|
-
line = f" - {m_name} ({role_label})"
|
|
8433
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
8431
8434
|
if m_desc:
|
|
8432
8435
|
line += f" — {m_desc}"
|
|
8433
8436
|
member_lines.append(line)
|
|
@@ -8448,7 +8451,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8448
8451
|
+ "\n".join(member_lines)
|
|
8449
8452
|
+ "\n\n注意:你只代表自己发言,回复时使用第一人称。"
|
|
8450
8453
|
"如果消息不是跟你相关的,可以简短回复或不回复。"
|
|
8451
|
-
"\n向其他Agent
|
|
8454
|
+
"\n向其他Agent发消息时使用其ID(从群成员列表的[ID: xxx]中获取)。"
|
|
8452
8455
|
)
|
|
8453
8456
|
|
|
8454
8457
|
if agent_system_prompt:
|
package/package.json
CHANGED
package/scripts/cli.py
CHANGED
|
@@ -1079,7 +1079,7 @@ async def cmd_chat(args):
|
|
|
1079
1079
|
"""Agent间通信 — 向群内其他Agent发送消息或文件"""
|
|
1080
1080
|
import argparse
|
|
1081
1081
|
p = argparse.ArgumentParser(prog="myagent-ai chat", description="向群内其他Agent发送消息或文件,消息会出现在群聊记录中")
|
|
1082
|
-
p.add_argument("--agent", "-a", required=True, help="目标Agent
|
|
1082
|
+
p.add_argument("--agent", "-a", required=True, help="目标Agent ID(群成员列表中显示的唯一ID)")
|
|
1083
1083
|
p.add_argument("--message", "-m", default="", help="要发送的消息内容")
|
|
1084
1084
|
p.add_argument("--file", "-f", default="", help="要发送的文件路径(可多次使用: -f file1 -f file2)")
|
|
1085
1085
|
p.add_argument("--group", "-g", help="群ID(可选,默认使用最近活跃的群)")
|
|
@@ -1089,61 +1089,33 @@ async def cmd_chat(args):
|
|
|
1089
1089
|
print("错误: 必须指定 --message 或 --file", file=sys.stderr)
|
|
1090
1090
|
sys.exit(1)
|
|
1091
1091
|
|
|
1092
|
-
# [v1.23.
|
|
1093
|
-
agents_data_dir = Path(
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
for dept_dir in agents_data_dir.iterdir():
|
|
1103
|
-
if not dept_dir.is_dir():
|
|
1092
|
+
# [v1.23.72] Agent 查找:按 ID 匹配,数据目录为 ~/.myagent/data/agents/
|
|
1093
|
+
agents_data_dir = Path.home() / ".myagent" / "data" / "agents"
|
|
1094
|
+
resolved_path = None
|
|
1095
|
+
|
|
1096
|
+
if agents_data_dir.exists():
|
|
1097
|
+
for dept_dir in agents_data_dir.iterdir():
|
|
1098
|
+
if not dept_dir.is_dir():
|
|
1099
|
+
continue
|
|
1100
|
+
for ag_dir in dept_dir.iterdir():
|
|
1101
|
+
if not ag_dir.is_dir():
|
|
1104
1102
|
continue
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
break
|
|
1122
|
-
# 如果精确匹配也没找到,尝试部分匹配(路径末尾或名字包含)
|
|
1123
|
-
if not found:
|
|
1124
|
-
for dept_dir in agents_data_dir.iterdir():
|
|
1125
|
-
if not dept_dir.is_dir():
|
|
1126
|
-
continue
|
|
1127
|
-
for ag_dir in dept_dir.iterdir():
|
|
1128
|
-
if not ag_dir.is_dir():
|
|
1129
|
-
continue
|
|
1130
|
-
cf = ag_dir / "config.json"
|
|
1131
|
-
if cf.exists():
|
|
1132
|
-
try:
|
|
1133
|
-
ag_cfg = json.loads(cf.read_text(encoding="utf-8"))
|
|
1134
|
-
ag_name = ag_cfg.get("name", "")
|
|
1135
|
-
ag_rel = ag_dir.relative_to(agents_data_dir).as_posix()
|
|
1136
|
-
if ag_rel.endswith("/" + a.agent) or a.agent in ag_name:
|
|
1137
|
-
resolved_path = ag_rel
|
|
1138
|
-
found = True
|
|
1139
|
-
break
|
|
1140
|
-
except Exception:
|
|
1141
|
-
pass
|
|
1142
|
-
if found:
|
|
1143
|
-
break
|
|
1144
|
-
if not found:
|
|
1145
|
-
print(f"错误: Agent 不存在: {a.agent}(请使用 Agent 路径/ID,而非名字。例如: myagent-ai chat --agent 部门名/Agent名 --message \"消息\")", file=sys.stderr)
|
|
1146
|
-
sys.exit(1)
|
|
1103
|
+
cf = ag_dir / "config.json"
|
|
1104
|
+
if cf.exists():
|
|
1105
|
+
try:
|
|
1106
|
+
ag_cfg = json.loads(cf.read_text(encoding="utf-8"))
|
|
1107
|
+
# 按 ID 精确匹配
|
|
1108
|
+
if ag_cfg.get("id", "") == a.agent:
|
|
1109
|
+
resolved_path = ag_dir.relative_to(agents_data_dir).as_posix()
|
|
1110
|
+
break
|
|
1111
|
+
except Exception:
|
|
1112
|
+
pass
|
|
1113
|
+
if resolved_path:
|
|
1114
|
+
break
|
|
1115
|
+
|
|
1116
|
+
if not resolved_path:
|
|
1117
|
+
print(f"错误: Agent 不存在: {a.agent}(请使用Agent的ID,从群成员列表中获取)", file=sys.stderr)
|
|
1118
|
+
sys.exit(1)
|
|
1147
1119
|
|
|
1148
1120
|
agent_dir = agents_data_dir / resolved_path
|
|
1149
1121
|
cfg_file = agent_dir / "config.json"
|
package/web/api_server.py
CHANGED
|
@@ -7839,10 +7839,11 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7839
7839
|
for m in group.members:
|
|
7840
7840
|
mc = self._read_agent_config(m.agent_path)
|
|
7841
7841
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
7842
|
+
m_id = mc.get("id", "") if mc else ""
|
|
7842
7843
|
m_desc = mc.get("description", "") if mc else ""
|
|
7843
7844
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
7844
7845
|
nick = f"(昵称: {m.nickname})" if m.nickname else ""
|
|
7845
|
-
line = f" - {m_name} [{
|
|
7846
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
7846
7847
|
if m_desc:
|
|
7847
7848
|
line += f" — {m_desc}"
|
|
7848
7849
|
line += nick
|
|
@@ -7898,11 +7899,9 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7898
7899
|
- @某个Agent: 只有被@的Agent需要回复
|
|
7899
7900
|
- @所有人 / @all: 所有成员都需要回复
|
|
7900
7901
|
- 不@任何人(广播): 你自行判断是否需要回复
|
|
7901
|
-
2. **跨Agent私下沟通**: 你可以使用 `myagent-ai chat --agent
|
|
7902
|
-
-
|
|
7903
|
-
-
|
|
7904
|
-
- 正确示例: `myagent-ai chat --agent 五香鸡/薇纸 --message "你好"`
|
|
7905
|
-
- 错误示例: `myagent-ai chat --agent 薇纸 --message "你好"`(名字可能重复或找不到)
|
|
7902
|
+
2. **跨Agent私下沟通**: 你可以使用 `myagent-ai chat --agent <ID> --message "消息"` 命令向群内其他Agent发送私下消息。对方会在自己下次处理消息时收到。
|
|
7903
|
+
- **必须使用Agent的ID**,不是名字。从上方「群成员列表」中找到目标Agent的 `[ID: xxx]` 就是它的唯一ID
|
|
7904
|
+
- 正确示例: `myagent-ai chat --agent a1b2c3d4e5f6 --message "你好"`
|
|
7906
7905
|
- 私下沟通的内容不会直接显示给用户,适合讨论细节、交换数据、协调方案
|
|
7907
7906
|
- 当任务需要多个Agent协作时,应该先在群里讨论分工,然后私下沟通具体细节
|
|
7908
7907
|
3. **协作分工模式**(复杂任务):
|
|
@@ -7919,8 +7918,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
7919
7918
|
- 你只代表你自己发言,使用第一人称
|
|
7920
7919
|
- 不要假装是其他Agent或代替其他Agent回答
|
|
7921
7920
|
- 如果问题超出你的能力范围,建议用户@相关专家Agent
|
|
7922
|
-
- 如果需要其他Agent的信息,使用 `myagent-ai chat --agent
|
|
7923
|
-
**注意:--agent 参数必须使用路径(ID),不是名字!从群成员列表的[方括号]中获取路径**
|
|
7921
|
+
- 如果需要其他Agent的信息,使用 `myagent-ai chat --agent <ID>` 命令私下沟通(使用Agent的ID,从群成员列表的[ID: xxx]中获取)
|
|
7924
7922
|
|
|
7925
7923
|
### 能力提醒(关键)
|
|
7926
7924
|
- 你拥有完整的工具调用能力(搜索、文件操作、代码执行、图片生成等)
|
|
@@ -8264,9 +8262,10 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8264
8262
|
for m in group.members:
|
|
8265
8263
|
mc = self._read_agent_config(m.agent_path)
|
|
8266
8264
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
8265
|
+
m_id = mc.get("id", "") if mc else ""
|
|
8267
8266
|
m_desc = mc.get("description", "") if mc else ""
|
|
8268
8267
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
8269
|
-
line = f" - {m_name} [{
|
|
8268
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
8270
8269
|
if m_desc:
|
|
8271
8270
|
line += f" — {m_desc}"
|
|
8272
8271
|
member_lines.append(line)
|
|
@@ -8287,7 +8286,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8287
8286
|
+ "\n".join(member_lines)
|
|
8288
8287
|
+ "\n\n注意:你只代表自己发言,回复时使用第一人称。"
|
|
8289
8288
|
"如果消息不是跟你相关的,可以简短回复或不回复。"
|
|
8290
|
-
"\n向其他Agent
|
|
8289
|
+
"\n向其他Agent发消息时使用其ID(从群成员列表的[ID: xxx]中获取)。"
|
|
8291
8290
|
)
|
|
8292
8291
|
|
|
8293
8292
|
if agent_system_prompt:
|
|
@@ -8428,9 +8427,10 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8428
8427
|
for m in group.members:
|
|
8429
8428
|
mc = self._read_agent_config(m.agent_path)
|
|
8430
8429
|
m_name = mc.get("name", m.agent_path) if mc else m.agent_path
|
|
8430
|
+
m_id = mc.get("id", "") if mc else ""
|
|
8431
8431
|
m_desc = mc.get("description", "") if mc else ""
|
|
8432
8432
|
role_label = {"owner": "群主", "admin": "管理员"}.get(m.role, "成员")
|
|
8433
|
-
line = f" - {m_name} [{
|
|
8433
|
+
line = f" - {m_name} [ID: {m_id}] ({role_label})"
|
|
8434
8434
|
if m_desc:
|
|
8435
8435
|
line += f" — {m_desc}"
|
|
8436
8436
|
member_lines.append(line)
|
|
@@ -8451,7 +8451,7 @@ window.addEventListener('beforeunload', function() {{
|
|
|
8451
8451
|
+ "\n".join(member_lines)
|
|
8452
8452
|
+ "\n\n注意:你只代表自己发言,回复时使用第一人称。"
|
|
8453
8453
|
"如果消息不是跟你相关的,可以简短回复或不回复。"
|
|
8454
|
-
"\n向其他Agent
|
|
8454
|
+
"\n向其他Agent发消息时使用其ID(从群成员列表的[ID: xxx]中获取)。"
|
|
8455
8455
|
)
|
|
8456
8456
|
|
|
8457
8457
|
if agent_system_prompt:
|