Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(group-chat): 伙伴群列表只显示 kind=group 的房间

Dash97951768c83b
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
index c63e37559a..6e4d5650a2 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
@@ -90,7 +90,7 @@ describe('Chat Server result delivery and refresh', () => {
const execution = { id: '40000000-0000-4000-8000-000000000001', conversation_id: roomId,
source_message_id: '50000000-0000-4000-8000-000000000001', bot_id: botId,
context_seq: '1', epoch: 1, status: 'running', access_mode: 'chat', access_revision: 1 };
- const room = (id: string) => ({ id, name: 'Room', state: 'joined', response_mode: 'all', speaking_mode: 'auto',
+ const room = (id: string) => ({ id, kind: 'group', name: 'Room', state: 'joined', response_mode: 'all', speaking_mode: 'auto',
created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z', revision: 1, archived: false });
let service: BotGroupChatService;
let deps: BotGroupChatServiceDeps;
@@ -1931,6 +1931,47 @@ describe('Chat Server result delivery and refresh', () => {
expect(prompt).not.toContain('forged words');
});
});
+
+ describe('rooms that are not groups', () => {
+ const directId = '70000000-0000-4000-8000-000000000001';
+ const channelId = '70000000-0000-4000-8000-000000000002';
+ const futureId = '70000000-0000-4000-8000-000000000003';
+ const kinds: Record<string, string | undefined> = { [directId]: 'direct', [channelId]: 'channel', [futureId]: 'board' };
+ const roomOf = (id: string) => ({ ...room(id), kind: id in kinds ? kinds[id] : 'group' });
+ beforeEach(() => {
+ fixture.handle.mockImplementation((route, method) => {
+ if (route === '/conversations?limit=100') return { body: [roomOf(directId), roomOf(roomId), roomOf(channelId), roomOf(futureId)] };
+ if (route.endsWith('/snapshot')) return { body: { room: roomOf(route.split('/')[2]), cursor: '1', messages: [],
+ members: [{ id: selfId, kind: 'human', ownerActorId: selfId, state: 'joined', role: 'owner' }] } };
+ if (method !== 'GET') return { body: { id: '80000000-0000-4000-8000-000000000001' } };
+ return response(route);
+ });
+ });
+ const writes = () => fixture.handle.mock.calls.filter(([route, method]) => method !== 'GET' && String(route).startsWith(`/conversations/${directId}`));
+
+ it('lists only group rooms, never direct companion chats, channels or unknown kinds', async () => {
+ const result = await service.listGroups();
+ expect(result.ok && result.groups.map(group => group.id)).toEqual([roomId]);
+ for (const other of [directId, channelId, futureId])
+ expect(fixture.handle.mock.calls.some(([route]) => String(route).startsWith(`/conversations/${other}/`))).toBe(false);
+ });
+
+ it.each([directId, channelId, futureId])('answers a missing group when %s is opened directly', async other => {
+ expect(await service.getGroup(other)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
+ });
+
+ it('does not archive, leave, rename, re-member, post into or invite to a direct room through group actions', async () => {
+ expect(await service.deleteGroup(directId)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
+ expect(await service.updateGroup({ groupId: directId, name: 'Renamed' })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
+ expect(await service.setMembers({ groupId: directId, botIds: [] })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
+ expect(await service.sendMessage({ groupId: directId, text: 'hi', clientId: 'client-direct-1', mentions: { all: false, botIds: [] } }))
+ .toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });
+ expect(await service.chatServer!.manage({ groupId: directId, action: { type: 'member', actorId: selfId, action: 'leave' } }))
+ .toMatchObject({ ok: false, errorCode: 'NOT_A_GROUP' });
+ expect(await service.chatServer!.createInvite({ groupId: directId, clientId: 'invite-direct-1' })).toMatchObject({ ok: false, errorCode: 'NOT_A_GROUP' });
+ expect(writes()).toEqual([]);
+ });
+ });
});
@@ -1954,7 +1995,7 @@ describe('Chat Server directed sends', () => {
if (route === '/me') return { body: { actor: { id: selfId } } };
if (route === '/actors') return { body: [{ id: botId, kind: 'bot', externalId: 'local-bot', name: 'Bot' }] };
if (route.endsWith('/members')) return { body: members };
- if (route.endsWith('/snapshot')) return { body: { room: { id: roomId, response_mode: responseMode }, members, messages: [], cursor: '0' } };
+ if (route.endsWith('/snapshot')) return { body: { room: { id: roomId, kind: 'group', response_mode: responseMode }, members, messages: [], cursor: '0' } };
if (route.endsWith('/messages') && method === 'POST') return { body: { id: 'posted-message' } };
return { body: [] };
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerErrors.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerErrors.test.ts
index 28f92e9eab..cd8a5196cc 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerErrors.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerErrors.test.ts
@@ -11,7 +11,7 @@ describe('chat group errors', () => {
['IMPORT_PENDING', 'IMPORT_PENDING'], ['REQUEST_TIMEOUT', 'REQUEST_TIMEOUT'],
['REVISION_CONFLICT', 'REVISION_CONFLICT'],
['ROLE_REQUIRED', 'PERMISSION_DENIED'], ['CONVERSATION_ARCHIVED', 'GROUP_ARCHIVED'],
- ['CONVERSATION_NOT_FOUND', 'NOT_FOUND'], ['untrusted /private/path?token=secret', 'SERVICE_ERROR'],
+ ['CONVERSATION_NOT_FOUND', 'NOT_FOUND'], ['NOT_A_GROUP', 'NOT_FOUND'], ['untrusted /private/path?token=secret', 'SERVICE_ERROR'],
])('classifies %s without exposing exception text', (code, expected) => {
expect(chatGroupFailure(new Error(code))).toEqual({ ok: false, errorCode: expected, message: expected });
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerGroupOpen.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerGroupOpen.test.ts
index aa6e3f4a26..397d97f481 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerGroupOpen.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerGroupOpen.test.ts
@@ -66,7 +66,7 @@ import type { BotGroupChatService, BotGroupChatServiceDeps } from '../botGroupCh
const selfId = '30000000-0000-4000-8000-000000000001';
const rooms = Array.from({ length: 8 }, (_, index) => `10000000-0000-4000-8000-00000000000${index + 1}`);
-const room = (id: string) => ({ id, name: `Room ${id.slice(-1)}`, state: 'joined', response_mode: 'all', speaking_mode: 'auto',
+const room = (id: string) => ({ id, kind: 'group', name: `Room ${id.slice(-1)}`, state: 'joined', response_mode: 'all', speaking_mode: 'auto',
created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z', revision: 1, archived: false });
const message = { id: '50000000-0000-4000-8000-000000000001', seq: '1', authorId: selfId, author: { kind: 'human', name: 'Me' },
content: [{ type: 'text', text: 'hello' }], createdAt: '2026-10-03T00:00:00Z', deleted: false, threadRootId: null };
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerInvitations.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerInvitations.test.ts
index 2dcb01c47b..553c9386cb 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerInvitations.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerInvitations.test.ts
@@ -59,7 +59,7 @@ describe('Chat Server invitation contract', () => {
members = [{ id: selfId, ownerActorId: selfId, state: 'joined', role: 'owner' }];
fixture.handle.mockImplementation(route => {
if (route === '/me') return { body: { actor: { id: selfId } } };
- if (route.endsWith('/snapshot')) return { body: { room: { id: groupId, dissolved_at: null }, members, cursor: '0' } };
+ if (route.endsWith('/snapshot')) return { body: { room: { id: groupId, kind: 'group', dissolved_at: null }, members, cursor: '0' } };
if (route === `/conversations/${groupId}/invite-links`) return { body: { token, expiresAt, ...(reusable !== undefined ? { reusable } : {}) } };
if (route === '/invite-links/preview') return { body: { groupId, name: 'Group', inviterName: 'Host', expiresAt, ...(reusable !== undefined ? { reusable } : {}), joined: false } };
if (route.endsWith('/invite-links/revoke')) return { body: { revoked: true } };
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts
index 2eebafc2f3..fc0869dddc 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts
@@ -62,10 +62,10 @@ describe('Chat Server membership notices', () => {
messages = [joined()];
fixture.handle.mockImplementation(route => {
if (route === '/me') return { body: { actor: { id: selfId } } };
- if (route === '/conversations?limit=100') return { body: [{ id: roomId, state: 'joined' }] };
+ if (route === '/conversations?limit=100') return { body: [{ id: roomId, kind: 'group', state: 'joined' }] };
if (route === '/executions/claim') return { body: { execution: null } };
if (route.endsWith('/snapshot')) return { body: {
- room: { id: roomId, name: 'Group', response_mode: 'all', speaking_mode: 'auto',
+ room: { id: roomId, kind: 'group', name: 'Group', response_mode: 'all', speaking_mode: 'auto',
created_at: '2026-10-08T00:00:00Z', updated_at: '2026-10-08T00:00:00Z' },
members: [{ id: memberId, kind: 'human', name: 'Renamed after joining', state: 'left', ownerActorId: memberId, ownerName: '' }],
messages, cursor: '12',
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
index ce0269ca27..23241f1f58 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerParity.test.ts
@@ -51,7 +51,7 @@ describe('server group feature parity', () => {
const execution = { id: '40000000-0000-4000-8000-000000000001', conversation_id: roomId,
source_message_id: '50000000-0000-4000-8000-000000000001', bot_id: botId,
context_seq: '100', epoch: 1, status: 'running', access_mode: 'chat', access_revision: 1 };
- const room = (id: string) => ({ id, name: 'Room', state: 'joined', response_mode: 'all', speaking_mode: 'auto',
+ const room = (id: string) => ({ id, kind: 'group', name: 'Room', state: 'joined', response_mode: 'all', speaking_mode: 'auto',
created_at: '2026-10-03T00:00:00Z', updated_at: '2026-10-03T00:00:00Z', revision: 1, archived: false });
let service: BotGroupChatService;
let deps: BotGroupChatServiceDeps;
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreadContext.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreadContext.test.ts
index e5345bc714..fe63f118b7 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreadContext.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerThreadContext.test.ts
@@ -109,7 +109,7 @@ function handle(route: string, method: string, body: Record<string, unknown> | u
if (next) next.status = 'running';
return { body: { execution: next ? { ...next } : null } };
}
- if (path.endsWith('/snapshot')) return { body: { room: { id: roomId, name: 'Product room', response_mode: 'all', speaking_mode: 'auto',
+ if (path.endsWith('/snapshot')) return { body: { room: { id: roomId, kind: 'group', name: 'Product room', response_mode: 'all', speaking_mode: 'auto',
created_at: '2026-10-13T00:00:00Z', updated_at: '2026-10-13T00:00:00Z', revision: 1, archived: false },
members: [{ id: ownerId, kind: 'human', name: 'Alex' }, ...bots.map(bot => ({ id: bot.id, kind: 'bot', name: bot.name }))], messages: [], cursor: '1' } };
if (path === `/conversations/${roomId}/messages` && method === 'POST') { directPosts++; return { body: { id: uuid(++ids) } }; }
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index 5bda860d5f..d9f111ffcd 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -106,6 +106,8 @@ const id = z.string().uuid();
const memberJoinedTrigger = z.object({ type: z.literal('member.joined'), messageId: id, actorId: id,
displayName: z.string().min(1).refine(value => value.trim().length > 0) }).strict();
type ExecutionContext = { kind: 'message' } | { kind: 'member.joined'; trigger: z.infer<typeof memberJoinedTrigger> };
+/** Only `group` rooms are bot groups; direct companion chats, channels and later kinds are not. */
+const isGroupRoom = (room: Pick<Room, 'kind'>) => room.kind === 'group';
const ordinaryExecution = (execution: Execution) => execution.trigger === undefined && execution.trigger_type == null;
const groupInput = z.object({ name: z.string().trim().min(1).max(40), botIds: z.array(z.string().min(1)).max(6) });
// A recognized quote card is shown as the quote, not as body text; unknown revisions keep their fallback.
@@ -684,6 +686,12 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
subscribe(roomId, value.cursor);
return value;
}
+ /** A room read through a bot-group entry point; any other kind answers as a missing group. */
+ async function groupSnapshot(roomId: string) {
+ const value = await snapshot(roomId);
+ if (!isGroupRoom(value.room)) throw new Error('NOT_A_GROUP');
+ return value;
+ }
function managementActor(s: Snapshot) {
const eligible = s.members.filter(m => m.ownerActorId === selfId && m.state === 'joined' && ['owner', 'admin'].includes(m.role));
return (eligible.find(m => m.role === 'owner') ?? eligible.find(m => m.id === selfId) ?? eligible[0])?.id;
@@ -841,7 +849,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
// reported (a left room stays 「not found」), whichever request fails first in time.
// A followed room reports every later change, so its snapshot may run alongside. A new
// room first takes the snapshot cursor it will follow from, before the rest is read.
- const snapshotRead = snapshot(roomId);
+ const snapshotRead = groupSnapshot(roomId);
if (!rooms.has(roomId)) await snapshotRead;
const messagesRead = summaryOnly ? null : api<Message[]>(`/conversations/${roomId}/messages?${query}`);
const executionsRead = api<Execution[]>(`/conversations/${roomId}/executions`);
@@ -1494,7 +1502,8 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const { type, ...payload } = action;
const route = type === 'update' || type === 'archive' ? '' : type === 'member' ? '/members' : type === 'botAccess' ? '/bot-access' : `/${type}`;
const asManager = type === 'update' || type === 'archive' || type === 'transfer' || (type === 'member' && !['leave', 'invite'].includes(action.action));
- const actorId = asManager ? managementActor(await snapshot(target)) : undefined;
+ const s = await groupSnapshot(target);
+ const actorId = asManager ? managementActor(s) : undefined;
await api(`/conversations/${target}${route}`, type === 'update' || type === 'archive' ? 'PATCH' : 'POST', {
operationId: randomUUID(), ...payload, ...(type === 'archive' ? { archived: action.archived } : {}),
}, actorId);
@@ -1580,14 +1589,14 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
createInvite: input => result(async () => {
const i = z.object({ groupId: id, clientId: operationId }).parse(input);
const invite = inviteResponse(z.object({ token: z.string().regex(/^[A-Za-z0-9_-]{43}$/), ...inviteFields }).refine(validInvite),
- await api(`/conversations/${i.groupId}/invite-links`, 'POST', { operationId: i.clientId }, managementActor(await snapshot(i.groupId)), false, 200),
+ await api(`/conversations/${i.groupId}/invite-links`, 'POST', { operationId: i.clientId }, managementActor(await groupSnapshot(i.groupId)), false, 200),
);
return { link: `cindy://chat-invite/${invite.token}`, expiresAt: invite.expiresAt, ...(invite.reusable !== undefined ? { reusable: invite.reusable } : {}) };
}),
revokeInvite: input => result(async () => {
const i = z.object({ groupId: id, link: z.string(), clientId: z.string().uuid() }).strict().parse(input);
const token = inviteToken(i.link);
- const actor = managementActor(await snapshot(i.groupId));
+ const actor = managementActor(await groupSnapshot(i.groupId));
if (!actor) throw new Error('ROLE_REQUIRED');
try {
return inviteResponse(z.object({ revoked: z.literal(true) }), await api(`/conversations/${i.groupId}/invite-links/revoke`, 'POST', { token, operationId: i.clientId }, actor, false, 200));
@@ -1619,7 +1628,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
if (!i.text.trim() && !i.attachments?.length) throw new Error('INVALID_INPUT');
// An attempted send must not cancel a valid decision until its message exists.
const intentVersion = ++nextIntentVersion;
- const s = await snapshot(i.groupId);
+ const s = await groupSnapshot(i.groupId);
// Read before preparing attachments: an unavailable quote must not stage files.
const quoteKey = i.quote ? `${i.groupId}:${i.clientId}:${i.quote.messageId}` : '';
const quote = i.quote ? postedQuotes.get(quoteKey) ?? await quoteSnapshot(i.groupId, i.quote.messageId, s.members) : null;
@@ -1685,7 +1694,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
let after: string | undefined;
do {
const page = await api<Array<Room & { state: string }>>(`/conversations?limit=100${after ? `&after=${after}` : ''}`);
- const joined = page.filter(r => r.state === 'joined' && r.kind !== 'direct' && !personalList.hidden(r.id));
+ const joined = page.filter(r => r.state === 'joined' && isGroupRoom(r) && !personalList.hidden(r.id));
for (let i = 0; i < joined.length; i += 8)
groups.push(...await Promise.all(joined.slice(i, i + 8).map(r => detail(r.id, undefined, true))));
after = page.length === 100 ? page.at(-1)!.id : undefined;
@@ -1735,7 +1744,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const i = z.object({ groupId: id, name: z.string().min(1).max(40).optional(), replyMode: z.enum(['all', 'mentioned']).optional(),
speakingMode: z.enum(['auto', 'sequential']).optional(), organizerBotId: z.string().nullable().optional(), projectDir: z.string().max(4096).nullable().optional(), expectedRevision: z.number().int().positive().optional() }).parse(input);
i.groupId = await resolveGroup(i.groupId);
- const s = await snapshot(i.groupId);
+ const s = await groupSnapshot(i.groupId);
let projectDir = i.projectDir;
if (projectDir) { const checked = await deps.validateProjectDir?.(projectDir); if (!checked?.ok) throw new Error('INVALID_DIRECTORY'); projectDir = checked.dir; }
const organizerId = i.organizerBotId ? actors.find(a => a.externalId === i.organizerBotId)?.id ?? id.parse(i.organizerBotId) : i.organizerBotId;
@@ -1766,7 +1775,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
},
setMembers: input => safe(async () => {
const i = z.object({ groupId: id, botIds: z.array(z.string()).max(6), addOnly: z.boolean().optional() }).parse(input);
- const room = await resolveGroup(i.groupId); const s = await snapshot(room);
+ const room = await resolveGroup(i.groupId); const s = await groupSnapshot(room);
const selected = i.botIds.map(bot => actors.find(a => a.externalId === bot)?.id ?? id.parse(bot));
for (const m of s.members.filter(m => !i.addOnly && m.kind === 'bot' && m.state === 'joined' && !selected.includes(m.id)))
await api(`/conversations/${room}/members`, 'POST', { operationId: randomUUID(), actorId: m.id, action: 'remove' }, managementActor(s));
@@ -1775,7 +1784,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
changed(room); return { ok: true as const };
}),
deleteGroup: groupId => safe(async () => {
- const room = await resolveGroup(id.parse(groupId)); const s = await snapshot(room);
+ const room = await resolveGroup(id.parse(groupId)); const s = await groupSnapshot(room);
if (s.members.some(m => m.ownerActorId === selfId && m.role === 'owner')) await api(`/conversations/${room}`, 'PATCH', { operationId: randomUUID(), expectedRevision: s.room.revision, archived: true }, managementActor(s));
else await api(`/conversations/${room}/members`, 'POST', { operationId: randomUUID(), actorId: selfId, action: 'leave' });
changed(room); return { ok: true as const };
diff --git a/apps/desktop/src/main/maker-ipc/chatServerErrors.ts b/apps/desktop/src/main/maker-ipc/chatServerErrors.ts
index 69b8db2356..60499d9bf6 100644
--- a/apps/desktop/src/main/maker-ipc/chatServerErrors.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServerErrors.ts
@@ -16,7 +16,7 @@ export function chatGroupFailure(error: unknown): BotGroupFailure {
if (['PLAN_OPEN', 'PLAN_CLOSED', 'MENTION_UNAVAILABLE', 'MEMBER_LIMIT', 'MEMBER_UNAVAILABLE', 'HOST_NOT_READY',
'INVALID_ATTACHMENT', 'ATTACHMENT_UNAVAILABLE', 'ATTACHMENT_TOO_LARGE', 'MEDIA_UPLOAD_FAILED',
'LIFECYCLE_UNAVAILABLE', 'LAST_OWNER', 'AUTH_REQUIRED', 'IMPORT_PENDING', 'REQUEST_TIMEOUT', 'REVISION_CONFLICT', 'QUOTE_UNAVAILABLE'].includes(code)) errorCode = code as BotGroupErrorCode;
- else if (code === 'CONVERSATION_NOT_FOUND' || code === 'OWNER_CHANGED') errorCode = 'NOT_FOUND';
+ else if (code === 'CONVERSATION_NOT_FOUND' || code === 'NOT_A_GROUP' || code === 'OWNER_CHANGED') errorCode = 'NOT_FOUND';
else if (['ROLE_REQUIRED', 'ACTOR_NOT_OWNED', 'OWNER_REQUIRED'].includes(code) || status === 403) errorCode = 'PERMISSION_DENIED';
else if (status === 401) errorCode = 'AUTH_REQUIRED';
else if (code === 'CHAT_ENDPOINT_UNAVAILABLE' || code === 'INVALID_CHAT_ENDPOINT' || ['ECONNREFUSED', 'ENOTFOUND', 'EAI_AGAIN'].includes(code)) errorCode = 'CHAT_UNAVAILABLE';