Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(agent-island): 预设头像原路径保持不动,群专线身份复用统一路由解析
Dasha5bfd2861723
diff --git a/apps/desktop/src/main/agent-island/companionIdentity.ts b/apps/desktop/src/main/agent-island/companionIdentity.tsindex dd140e26b2..d443513742 100644--- a/apps/desktop/src/main/agent-island/companionIdentity.ts+++ b/apps/desktop/src/main/agent-island/companionIdentity.ts@@ -4,6 +4,7 @@ import { app } from 'electron';import { and, eq, inArray } from 'drizzle-orm';import sharp from 'sharp';import type { AgentIslandCompanionSnapshot } from '../../shared/agentIsland.js';+import { parseBotGroupIdFromRouteKey } from '../../shared/botGroupChat.js';import { botAvatarInitial, normalizeBotAvatarHue } from '../../shared/botAvatarHue.js';import { BOT_AVATAR_MAX_BYTES, isManagedBotAvatarUrl, isSingleBotAvatarGrapheme } from '../../shared/botAvatarValue.js';import { resolveSafe } from '../cindy-media/blobStore.js';@@ -21,7 +22,12 @@ export interface AgentIslandCompanionIdentity {/** Links that speak as the companion; delegated executions stay ordinary tasks. */const COMPANION_SPEAKING_ROLES = ['canonical', 'history', 'group', 'channel'] as const;-/** Bundled preset artwork, relative to the packaged resources directory. */+/**+ * Bundled preset artwork, relative to the packaged resources directory. The Cindy portrait is a+ * byte copy of `src/renderer/assets/bot-presets/cindy.png`: that path is also read by the mobile+ * notification plugin and its fingerprint config, so it must not move, while main can only read+ * files shipped as resources (the renderer bundle inlines its asset).+ */const PRESET_AVATAR_FILES: Readonly<Record<string, string>> = {'cindy://avatar/preset/cindy': 'companion-preset-avatars/cindy.png','cindy://avatar/preset/dash': 'legacy-teammate-avatars/dash.png',@@ -64,7 +70,8 @@ export async function readAgentIslandCompanion(sessionId: string): Promise<Agent)).get();if (!row) return null;- const groupId = row.role === 'group' && row.routeKey?.startsWith('group:') ? row.routeKey.slice('group:'.length) : null;+ // Lane, 分工 Session and authorized Chat Server lane keys all start `group:<groupId>`.+ const groupId = row.role === 'group' ? parseBotGroupIdFromRouteKey(row.routeKey) : null;const group = groupId? await db.select({ name: botGroups.name }).from(botGroups).where(eq(botGroups.id, groupId)).get(): undefined;diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex c2ed5e6679..29b0eb1c1d 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -1181,7 +1181,7 @@ describe('Bot canonical Session lifecycle', () => {if (state === 'deleted') h.providers = [];if (state === 'empty') readDefault.mockResolvedValue([]);const sharp = (await import('sharp')).default;- const bytes = await sharp(resolve(__dirname, '../../../../../resources/companion-preset-avatars/cindy.png')).resize(256, 256).jpeg({ quality: 80 }).toBuffer();+ const bytes = await sharp(resolve(__dirname, '../../../../renderer/assets/bot-presets/cindy.png')).resize(256, 256).jpeg({ quality: 80 }).toBuffer();await expect(botRemoteManagement.invoke(context, {collectionId: 'teammates', resourceRef: resource.ref, actionId: resource.actions![0].id,client: { protocolVersion: 1, primitives: ['form'], locale: 'en' },@@ -1194,7 +1194,7 @@ describe('Bot canonical Session lifecycle', () => {it('reconciles mobile creation after a lost receipt without bypassing invitation preparation', async () => {const { botRemoteManagement } = await import('../botRemoteManagement');const sharp = (await import('sharp')).default;- const bytes = await sharp(resolve(__dirname, '../../../../../resources/companion-preset-avatars/cindy.png')).resize(256, 256).jpeg({ quality: 80 }).toBuffer();+ const bytes = await sharp(resolve(__dirname, '../../../../renderer/assets/bot-presets/cindy.png')).resize(256, 256).jpeg({ quality: 80 }).toBuffer();const context = { controllerDeviceId: 'mobile-creation-test' };const client = { protocolVersion: 1, primitives: ['form'], locale: 'zh-CN' };const input = { name: '手机创建的伙伴', avatarImageBase64: bytes.toString('base64'), requestId: 'mobile-creation-intent-001' };@@ -1243,7 +1243,7 @@ describe('Bot canonical Session lifecycle', () => {await invoke('local-db:bots:create', { id: 'removed-cindy', name: 'Cindy', templateId: 'cindy' });h.sqlite!.prepare("UPDATE bot_profiles SET status = 'archived' WHERE id = 'removed-cindy'").run();await h.tx!('bots.deleteProfile', { botId: 'removed-cindy', sessionIds: [], keepTaskHistory: true, at: Date.now() });- const bytes = readFileSync(resolve(__dirname, '../../../../../resources/companion-preset-avatars/cindy.png'));+ const bytes = readFileSync(resolve(__dirname, '../../../../renderer/assets/bot-presets/cindy.png'));const created = await invoke('local-db:bots:create', {id: 'new-cindy', name: 'Cindy', avatarImageBase64: bytes.toString('base64'),});@@ -1261,7 +1261,7 @@ describe('Bot canonical Session lifecycle', () => {botId: 'bot-1', expectedCanonicalSessionId: null, expectedProfileVersion: 1,});const before = await invoke('local-db:bots:get', 'bot-1');- const bytes = readFileSync(resolve(__dirname, '../../../../../resources/companion-preset-avatars/cindy.png'));+ const bytes = readFileSync(resolve(__dirname, '../../../../renderer/assets/bot-presets/cindy.png'));const result = await invoke('local-db:bots:choose-avatar', {botId: 'bot-1', avatarImageBase64: bytes.toString('base64'),});diff --git a/apps/desktop/src/renderer/assets/bot-presets/cindy.png b/apps/desktop/src/renderer/assets/bot-presets/cindy.pngnew file mode 100644index 0000000000..18c2d2a0aeBinary files /dev/null and b/apps/desktop/src/renderer/assets/bot-presets/cindy.png differdiff --git a/apps/desktop/src/renderer/features/bots/BotAvatar.tsx b/apps/desktop/src/renderer/features/bots/BotAvatar.tsxindex 117a6b744f..7357968b81 100644--- a/apps/desktop/src/renderer/features/bots/BotAvatar.tsx+++ b/apps/desktop/src/renderer/features/bots/BotAvatar.tsx@@ -24,7 +24,7 @@import { rewriteToRemoteMediaOrigin } from '@/../shared/remoteMediaUrl';import { useEffect, useState } from 'react';-import cindyPresetAvatar from '../../../../resources/companion-preset-avatars/cindy.png';+import cindyPresetAvatar from '@/assets/bot-presets/cindy.png';// Upgrade failure/older remote-host fallback only; migrated profiles use cindy-media.import dashPresetAvatar from '../../../../resources/legacy-teammate-avatars/dash.png';import liziPresetAvatar from '../../../../resources/legacy-teammate-avatars/lizi.png';diff --git a/apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsx b/apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsxindex d2b9cdacc3..6efd0aa2c9 100644--- a/apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsx+++ b/apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsx@@ -3,7 +3,7 @@ import * as Popover from '@radix-ui/react-popover';import { useEffect, useRef, useState, type ReactElement, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';import { Camera, Check, ChevronDown, Plus } from 'lucide-react';-import cindyPortrait from '../../../../resources/companion-preset-avatars/cindy.png';+import cindyPortrait from '@/assets/bot-presets/cindy.png';import { Tip } from '@/components/ui/tooltip';import gallery from '../../../../resources/teammate-portrait-gallery.png';import { BOT_AVATAR_MAX_BYTES } from '../../../shared/botAvatarValue';