Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(group-chat): 所有 groupId 入口统一先经 groupSnapshot 校验房间类型
Dash61b7f742df4c
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 8c68c34436..96348e1723 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1975,6 +1975,23 @@ describe('Chat Server result delivery and refresh', () => {expect(writes()).toEqual([]);});+ it('answers a missing group from round, plan, thread, reply and reaction entries without touching the room', async () => {+ const planId = '80000000-0000-4000-8000-000000000002';+ expect(await service.stopRound(directId)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.continueRound(directId)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.startPlan({ groupId: directId, planId })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.dismissPlan({ groupId: directId, planId })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.continuePlan({ groupId: directId, planId })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.retryPlan({ groupId: directId, planId })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.editPlanStep({ groupId: directId, planId, position: 0, action: 'remove' })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });+ expect(await service.chatServer!.thread({ groupId: directId, rootId: planId })).toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ expect(await service.chatServer!.reply({ groupId: directId, rootId: planId, text: 'hi', clientId: 'reply-direct-1', mentions: { all: false, botIds: [] } }))+ .toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ expect(await service.chatServer!.react({ groupId: directId, messageId: planId, emoji: '👍', present: true })).toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ // Only the snapshot that answered "missing" was read; nothing else of the room was read or written.+ expect(fixture.handle.mock.calls.filter(([route]) => String(route).startsWith(`/conversations/${directId}`) && !String(route).endsWith('/snapshot'))).toEqual([]);+ });+it.each([directId, channelId, futureId])('fails a claimed execution in %s instead of running it as a group', async other => {fixture.handle.mockImplementation((route, method) => {if (route === '/executions/claim') { const next = claimed ? null : { ...execution, conversation_id: other }; claimed = true; return { body: { execution: next } }; }@@ -2012,6 +2029,7 @@ describe('Chat Server result delivery and refresh', () => {vi.mocked(socket.send).mockClear();expect(await service.getGroup(directId)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });expect(await service.chatServer!.createInvite({ groupId: channelId, clientId: 'invite-channel-1' })).toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ expect(await service.chatServer!.thread({ groupId: futureId, rootId: roomId })).toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });expect(vi.mocked(socket.send).mock.calls.filter(([raw]) => String(raw).includes('"subscribe"'))).toEqual([]);// A later reconnect resubscribes only the group.socket.emit('message', JSON.stringify({ type: 'ready' }));diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 4e52e50d17..52d19dfc72 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -697,6 +697,12 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDsubscribe(roomId, value.cursor);return value;}+ /** Every groupId entry resolves through here: a room that is not a group answers as missing before any other read or write. */+ async function groupRoom(groupId: string) {+ const room = await resolveGroup(groupId);+ await groupSnapshot(room);+ return room;+ }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;@@ -911,7 +917,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDasync function actPlan(input: unknown, action: string) {const i = z.object({ groupId: id, planId: id, position: z.number().int().min(0).max(11).optional(),action: z.enum(['remove','reassign']).optional(), botId: z.string().optional() }).parse(input);- const room = await resolveGroup(i.groupId);+ const room = await groupRoom(i.groupId);await replacePlanIntent(room);const plans = await api<ServerPlan[]>(`/conversations/${room}/plans?ids=${i.planId}`);const plan = plans.find(p => p.id === i.planId); if (!plan) throw new Error('PLAN_CLOSED');@@ -1519,7 +1525,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDstatus: async () => ({ enabled: true, connected: current() && connected }),thread: input => result(async () => {const i = z.object({ groupId: id, rootId: id, before: z.number().int().positive().optional(), sourceMessageIds: z.array(id).optional() }).parse(input);- i.groupId = await resolveGroup(i.groupId); subscribe(i.groupId);+ i.groupId = await groupRoom(i.groupId);const members = await api<Member[]>(`/conversations/${i.groupId}/members`);const root = await api<Message>(`/conversations/${i.groupId}/messages/${i.rootId}`);const page = await api<Message[]>(`/conversations/${i.groupId}/messages?threadRootId=${i.rootId}&limit=50${i.before ? `&before=${i.before}` : ''}`);@@ -1557,7 +1563,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDreply: input => result(async () => {const i = z.object({ groupId: id, rootId: id, text: z.string().trim().min(1).max(8000), clientId: operationId,mentions: z.object({ all: z.boolean(), botIds: z.array(z.string()).max(100) }) }).parse(input);- await register();+ i.groupId = await groupRoom(i.groupId);const posted = await api<{ id: string }>(`/conversations/${i.groupId}/messages`, 'POST', {operationId: i.clientId, threadRootId: i.rootId, content: [{ type: 'text', text: i.text }], mentions: await mentionIds(i.groupId, i.mentions),});@@ -1565,6 +1571,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD}),react: input => result(async () => {const i = z.object({ groupId: id, messageId: id, emoji: z.string().min(1).max(128), present: z.boolean() }).parse(input);+ i.groupId = await groupRoom(i.groupId);await api(`/conversations/${i.groupId}/messages/${i.messageId}/reactions`, 'POST', { operationId: randomUUID(), emoji: i.emoji, present: i.present });changed(i.groupId); return {};}),@@ -1761,7 +1768,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDchanged(i.groupId); return { ok: true as const };}),stopRound: roomId => safe(async () => {- const room = await resolveGroup(id.parse(roomId));+ const room = await groupRoom(id.parse(roomId));await replacePlanIntent(room);const plans = await api<ServerPlan[]>(`/conversations/${room}/plans`);for (const plan of plans.filter(p => ['proposed','running','waiting'].includes(p.status))) await actPlan({ groupId: room, planId: plan.id }, 'stop');@@ -1797,7 +1804,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDchanged(room); return { ok: true as const };}),continueRound: groupId => safe(async () => {- const room = await resolveGroup(id.parse(groupId));+ const room = await groupRoom(id.parse(groupId));const history = await api<Message[]>(`/conversations/${room}/messages?limit=100`);const executions = await api<Execution[]>(`/conversations/${room}/executions`);const sourceId = executions.find(e => !e.plan_id && ordinaryExecution(e))?.source_message_id ?? history.find(discussionSource)?.id;