Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge main into group-task-home-reply-timeout
Chris56cdfc797012
diff --cc apps/desktop/src/main/maker-ipc/chatServer.tsindex f2ed02d716,a4118e9def..7758f00e70--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@@ -12,8 -12,8 +12,8 @@@ import { parseChatInvitationToken } froimport { existsSync, readFileSync } from 'node:fs';import { request as httpRequest } from 'node:http';import { request as httpsRequest } from 'node:https';-import { migrateLocalGroups } from './chatServerMigration.js';+import { migrateLocalGroups, type ChatContentBlock } from './chatServerMigration.js';- import { chatErrorDiagnostic, chatGroupFailure } from './chatServerErrors.js';+ import { chatErrorDiagnostic, chatGroupFailure, missingGroupCode } from './chatServerErrors.js';import { createChatMedia } from './chatServerMedia.js';import { chatServerWorkspaces } from './chatServerWorkspaces.js';import { buildPlanStepBrief } from './botGroupDivision.js';@@@ -1833,88 -1793,9 +1862,88 @@@ function createChatServer(local: BotGroawait settleExecution(run, terminal, terminal.undispatched);return true;},+ // A teammate's own message about an independent task it started from this group+ // (bot-group-chat.md §10): posted outside any execution, as that teammate, never as the owner.+ /** A server room (or an old local group already upgraded to one) carries task messages. */+ hasCompanionTaskChannel: async (groupId: string): Promise<boolean> => (await taskRoomFor(groupId)) !== null,+ postCompanionTaskMessage: async (input: BotGroupTaskPostInput): Promise<BotGroupTaskPostResult> => {+ const refused = (errorCode: string): BotGroupTaskPostResult => ({ ok: false, errorCode, retryable: false });+ try {+ if (!current()) return refused('OWNER_CHANGED');+ // An old local-only group has a UUID too: it is told from a server room by its local+ // history row and upgrade mapping, never by id shape. Such a group cannot carry a+ // teammate's own message, so the local service refuses for good and the result falls+ // back to the owner's private chat instead of retrying forever (bot-group-chat.md §10).+ const roomId = await taskRoomFor(input.groupId);+ if (!roomId) return local.postCompanionTaskMessage(input);+ await register();+ const actor = actors.find(a => a.kind === 'bot' && a.externalId === input.botId);+ if (!actor) return refused('BOT_UNAVAILABLE');+ const s = await snapshot(roomId);+ if (s.room.archived || !s.members.some(m => m.id === actor.id && m.state === 'joined')) return refused('MEMBER_UNAVAILABLE');+ const frozen = await prepareBotGroupTaskPost(input.card.data.meta.delegationId,+ { endpoint: config.baseUrl, selfId, roomId, clientId: input.clientId }, async () => {+ const produced: BotGroupAttachment[] = [];+ const fs = await import('node:fs/promises');+ for (const file of input.files ?? []) {+ try {+ const stat = await fs.lstat(file.absolutePath);+ if (stat.isFile()) produced.push({ id: file.absolutePath, name: path.basename(file.absolutePath), category: 'file',+ mimeType: 'application/octet-stream', size: stat.size, path: file.absolutePath, url: null });+ } catch (error) {+ // Gone or unreadable for good (deleted since the task finished): simply not delivered.+ // A transient filesystem failure keeps the whole message for a retry.+ if (!fileRefusedHere(error)) throw error;+ }+ }+ // Files go up one at a time so a refused file never holds back the others: a file this+ // computer cannot send (empty, over the size limit, unreadable) or the server definitely+ // refuses is left out with a warning, while a transient failure keeps the whole message for a retry.+ const uploaded: ChatContentBlock[] = [];+ for (const file of produced) {+ try {+ uploaded.push(...await media.upload(roomId, input.clientId, [file], actor.id));+ } catch (error) {+ if (!fileRefusedHere(error) && (!(error instanceof ChatResponseError) || retryableResponse(error))) throw error;+ deps.log?.warn('Chat task delivery file refused', { groupId: roomId, ...chatErrorDiagnostic(error) });+ }+ }+ // The server takes 8000 characters and BOT_GROUP_ATTACHMENTS_MAX files per message: a longer+ // result and further files continue in follow-up messages (same idempotent operation id+ // family), never silently cut.+ const [first = '', ...rest] = splitChatMessageText(input.text.trim());+ const fileBatches: ChatContentBlock[][] = [];+ for (let at = 0; at < uploaded.length; at += BOT_GROUP_ATTACHMENTS_MAX) fileBatches.push(uploaded.slice(at, at + BOT_GROUP_ATTACHMENTS_MAX));+ const [firstFiles = [], ...moreFiles] = fileBatches;+ const messages: BotGroupTaskPostSnapshot['messages'] = [{+ operationId: input.clientId, content: [...(first ? [{ type: 'text', text: first }] : []), input.card, ...firstFiles], mentions: [],+ }];+ for (const [index, text] of rest.entries()) messages.push({+ operationId: `${input.clientId}:${index + 2}`, content: [{ type: 'text', text }], mentions: [],+ });+ for (const [index, files] of moreFiles.entries()) messages.push({+ operationId: `${input.clientId}:files:${index + 2}`, content: files, mentions: [],+ });+ return { actorId: actor.id, messages };+ });+ // Persist every part before the first POST. Retries (including after restart) use the+ // same card, localized fallback, text and media references even if their sources change.+ let messageId = '';+ for (const body of frozen.messages) {+ const posted = await api<{ id: string }>(`/conversations/${roomId}/messages`, 'POST', body, frozen.actorId);+ messageId ||= posted.id;+ }+ changed(roomId);+ return { ok: true, messageId };+ } catch (error) {+ deps.log?.warn('Chat task message post failed', { groupId: input.groupId, ...chatErrorDiagnostic(error) });+ return { ok: false, errorCode: error instanceof Error ? error.message : 'REQUEST_FAILED',+ retryable: !(error instanceof ChatResponseError) || retryableResponse(error) };+ }+ },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));