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): 执行领取路径复用房间类型白名单,非群房间的执行不运行也不订阅
Dash90249169eae6
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 27590bdb11..8c68c34436 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,32 @@ describe('Chat Server result delivery and refresh', () => {expect(writes()).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 } }; }+ 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' },+ { id: botId, kind: 'bot', ownerActorId: selfId, state: 'joined', role: 'member' }] } };+ if (method !== 'GET') return { body: { id: '80000000-0000-4000-8000-000000000001' } };+ return response(route);+ });+ fixture.profiles = [{ id: 'local-bot', displayName: 'Bot', status: 'active' }];+ await vi.advanceTimersByTimeAsync(2000);+ expect(deps.ensureLane).not.toHaveBeenCalled();+ expect(deps.dispatch).not.toHaveBeenCalled();+ const results = fixture.handle.mock.calls.filter(([route, , body]) => route === `/conversations/${other}/executions/${execution.id}`+ && ['complete', 'fail'].includes(body?.action));+ expect(results.map(call => call[2].action)).toEqual(['fail']);+ // The rejected room was never subscribed, so a reconnect has nothing to resubscribe.+ const socket = fixture.sockets[0];+ Object.defineProperty(socket, 'readyState', { value: 1 });+ socket.emit('message', JSON.stringify({ type: 'ready' }));+ await vi.advanceTimersByTimeAsync(0);+ const scopes = vi.mocked(socket.send).mock.calls.map(([raw]) => JSON.parse(String(raw)))+ .filter(m => m.type === 'subscribe' && String(m.scope).startsWith('conversation:')).map(m => m.scope);+ expect(scopes).toEqual([]);+ });+it('never subscribes to a rejected room, so its traffic cannot invalidate the group list', async () => {await service.getGroup(roomId);await vi.advanceTimersByTimeAsync(2000);diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 38c351cf89..4e52e50d17 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -1095,7 +1095,15 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD|| execution.trigger_type != null && execution.trigger_type !== 'member.joined'|| run.context.trigger.messageId !== execution.source_message_id|| run.context.trigger.actorId !== execution.requester_id)) throw new Error('INVALID_EXECUTION_TRIGGER');- const s = await snapshot(execution.conversation_id);+ const s = await readSnapshot(execution.conversation_id);+ // A companion's own 1:1 room is not a group: hand the message to its main task instead.+ const joined = new Set(s.members.filter(m => m.state === 'joined').map(m => m.id));+ const ownDirectRoom = companionHome && (companion?.isDirectRoom(s.room.id)+ || (s.room.kind === 'direct' && joined.size === 2 && joined.has(selfId) && joined.has(execution.bot_id)));+ // Every other room must be a group. Someone else's 1:1 room, a channel or an unknown kind is never+ // answered as a group and never subscribed: nothing may run without a visible group entry to watch or stop it.+ if (!ownDirectRoom && !isGroupRoom(s.room)) throw new Error('INVALID_EXECUTION_TRIGGER');+ subscribe(execution.conversation_id, s.cursor);// Claim metadata and the persisted source must agree before creating a lane.// Reading this exact ID also covers sources outside the bounded history page.let eventSource: Message | undefined;@@ -1111,13 +1119,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDthrow new Error('INVALID_EXECUTION_TRIGGER');}if (!current() || running.get(execution.bot_id) !== run) throw new Error('STALE_EXECUTOR');- // A companion's own 1:1 room is not a group: hand the message to its main task instead.- const joined = new Set(s.members.filter(m => m.state === 'joined').map(m => m.id));- const ownDirectRoom = companionHome && (companion?.isDirectRoom(s.room.id)- || (s.room.kind === 'direct' && joined.size === 2 && joined.has(selfId) && joined.has(execution.bot_id)));if (ownDirectRoom) { await runDirectExecution(run, bot.id, s.room.id); return; }- // Any other 1:1 room is never answered as a group.- if (s.room.kind === 'direct') throw new Error('INVALID_EXECUTION_TRIGGER');// Metadata only: the server remains the sole message store and scheduler.if (!metadata.has(s.room.id)) metadata.set(s.room.id, (async () => {const client = getDbClient();