





















@@ -1121,6 +1121,64 @@ describe("gateway session utils", () => {
11211121);
11221122});
112311231124+test("listAgentsForGateway falls back to identity.name when name is unset", () => {
1125+const cfg = {
1126+session: { mainKey: "main" },
1127+agents: {
1128+list: [{ id: "main", default: true, identity: { name: "开发助手" } }],
1129+},
1130+} as OpenClawConfig;
1131+1132+const result = listAgentsForGateway(cfg);
1133+1134+expect(result.agents[0]).toMatchObject({
1135+id: "main",
1136+name: "开发助手",
1137+identity: { name: "开发助手" },
1138+});
1139+});
1140+1141+test("listAgentsForGateway prefers explicit name over identity.name", () => {
1142+const cfg = {
1143+session: { mainKey: "main" },
1144+agents: {
1145+list: [
1146+{
1147+id: "main",
1148+default: true,
1149+name: "Ops",
1150+identity: { name: "开发助手" },
1151+},
1152+],
1153+},
1154+} as OpenClawConfig;
1155+1156+const result = listAgentsForGateway(cfg);
1157+1158+expect(result.agents[0]).toMatchObject({
1159+id: "main",
1160+name: "Ops",
1161+identity: { name: "开发助手" },
1162+});
1163+});
1164+1165+test("listAgentsForGateway leaves name unset when both configured and identity names are absent", () => {
1166+const cfg = {
1167+session: { mainKey: "main" },
1168+agents: {
1169+list: [{ id: "main", default: true, identity: {} }],
1170+},
1171+} as OpenClawConfig;
1172+1173+const result = listAgentsForGateway(cfg);
1174+1175+expect(result.agents[0]).toMatchObject({
1176+id: "main",
1177+name: undefined,
1178+identity: {},
1179+});
1180+});
1181+11241182test("listAgentsForGateway keeps explicit agents.list scope over disk-only agents (scope boundary)", async () => {
11251183await withStateDirEnv("openclaw-agent-list-scope-", async ({ stateDir }) => {
11261184fs.mkdirSync(path.join(stateDir, "agents", "main"), { recursive: true });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。