feat(agent): store preset avatars as real files in s3 storage (#381)

* feat(agent): store preset avatars as real files in s3 storage

* fix(agent): use inline base64 previews in dialog and remove static avatar files

* feat(agent): add 4 avatar presets and track avatarPreset in agent config

* refactor(agent): consolidate preset avatar base64 data in dtos
This commit is contained in:
Yiling-J
2026-09-04 16:39:19 +08:00
committed by GitHub
parent dd0ea05a88
commit 1e60933cdb
15 changed files with 545 additions and 42 deletions
+38
View File
@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest'
import {
getPresetAvatarBuffer,
isPresetAvatarId,
PRESET_AVATAR_IDS,
type PresetAvatarId,
} from './presets'
describe('agent presets', () => {
it('identifies preset avatar IDs correctly', () => {
expect(PRESET_AVATAR_IDS).toHaveLength(8)
for (const id of PRESET_AVATAR_IDS) {
expect(isPresetAvatarId(id)).toBe(true)
}
expect(isPresetAvatarId('avatar-999')).toBe(false)
expect(isPresetAvatarId('')).toBe(false)
expect(isPresetAvatarId(null)).toBe(false)
expect(isPresetAvatarId(undefined)).toBe(false)
})
it('returns valid buffer for all preset avatars', () => {
for (const id of PRESET_AVATAR_IDS) {
const buf = getPresetAvatarBuffer(id)
expect(buf).toBeInstanceOf(Buffer)
expect(buf?.length).toBeGreaterThan(5000)
}
expect(getPresetAvatarBuffer('unknown' as PresetAvatarId)).toBeNull()
})
it('provides AVAILABLE_AVATARS with 8 previews via dtos', async () => {
const { AVAILABLE_AVATARS } = await import('@shumai/dtos')
expect(AVAILABLE_AVATARS).toHaveLength(8)
for (const avatar of AVAILABLE_AVATARS) {
expect(avatar.id).toMatch(/^avatar-[1-8]$/)
expect(avatar.preview).toMatch(/^data:image\/webp;base64,/)
}
})
})