Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Let an agent take a drawn avatar (Open Bot Avatar) (#76)

Eduardo Machado5107a636965d
diff --git a/README.md b/README.md
index c0f1fdd..fed1ad1 100644
--- a/README.md
+++ b/README.md
@@ -257,3 +257,5 @@ Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. The origi
[Apache-2.0](LICENSE). Tucano is not affiliated with Anthropic, OpenAI or any of the tools it connects to.
The apps feature runs on [agent-desktop](https://github.com/vercel-labs/agent-desktop) by Vercel Labs (Apache-2.0), installed separately. Thank you!
+
+Agents' drawn avatars come from [Open Bot Avatar](https://github.com/DominikScholz/open-bot-avatar) by Dominik Scholz (MIT), with its gallery. Thank you!
diff --git a/README.pt-BR.md b/README.pt-BR.md
index 0a44a56..6d0f2f0 100644
--- a/README.pt-BR.md
+++ b/README.pt-BR.md
@@ -257,3 +257,5 @@ Leia o [CONTRIBUTING.md](CONTRIBUTING.md) antes de abrir um pull request (o cód
[Apache-2.0](LICENSE). O Tucano não é afiliado à Anthropic, à OpenAI nem a nenhuma das ferramentas a que ele se conecta.
Os apps do computador rodam sobre o [agent-desktop](https://github.com/vercel-labs/agent-desktop), da Vercel Labs (Apache-2.0), instalado à parte. Obrigado!
+
+Os avatares desenhados dos agentes vêm do [Open Bot Avatar](https://github.com/DominikScholz/open-bot-avatar), de Dominik Scholz (MIT), com a galeria dele. Obrigado!
diff --git a/package-lock.json b/package-lock.json
index 1da5b52..b03a6ec 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23,6 +23,7 @@
"electron": "^44.8.0",
"electron-builder": "^26.15.3",
"electron-vite": "^6.0.0",
+ "open-bot-avatar": "0.1.1",
"playwright": "^1.64.1",
"react": "^19.3.1",
"react-dom": "^19.3.1",
@@ -6255,6 +6256,13 @@
"wrappy": "1"
}
},
+ "node_modules/open-bot-avatar": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/open-bot-avatar/-/open-bot-avatar-0.1.1.tgz",
+ "integrity": "sha512-Rl01S8qVEbXaiOYL/WnCwTU5PAoBsWtHCjo4mQSb5wK3w7SnkMnOTcXk4unbp+6LwllvB5AHIGz3tlWH8BxGWA==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/p-cancelable": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz",
diff --git a/package.json b/package.json
index 065eb2f..1db239b 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"electron": "^44.8.0",
"electron-builder": "^26.15.3",
"electron-vite": "^6.0.0",
+ "open-bot-avatar": "0.1.1",
"playwright": "^1.64.1",
"react": "^19.3.1",
"react-dom": "^19.3.1",
diff --git a/src/core/agent-look.ts b/src/core/agent-look.ts
index 2cdc2f8..512f5a6 100644
--- a/src/core/agent-look.ts
+++ b/src/core/agent-look.ts
@@ -1,10 +1,13 @@
+import { validateAvatar } from 'open-bot-avatar'
import type { Agent } from '../shared/types'
const MAX_PICTURE = 200_000
-// Shown in every window as they are: only a color and only a small picture stay.
-export function cleanLook<T extends Pick<Agent, 'customColor' | 'picture'>>(agent: T): T {
+// Shown in every window as they are: only a color, a small picture and a drawn avatar that passes its own check stay.
+export function cleanLook<T extends Partial<Pick<Agent, 'customColor' | 'picture' | 'avatar'>>>(agent: T): T {
const customColor = agent.customColor && /^#[0-9a-f]{6}$/i.test(agent.customColor) ? agent.customColor : undefined
const picture = agent.picture && agent.picture.length <= MAX_PICTURE && /^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/.test(agent.picture) ? agent.picture : undefined
- return { ...agent, customColor, picture }
+ const drawn = agent.avatar ? validateAvatar(agent.avatar) : undefined
+ const avatar = drawn?.ok ? drawn.value : undefined
+ return { ...agent, customColor, picture, avatar }
}
diff --git a/src/core/db.ts b/src/core/db.ts
index fe5dc10..ba9a514 100644
--- a/src/core/db.ts
+++ b/src/core/db.ts
@@ -237,6 +237,9 @@ const MIGRATIONS = [
`
ALTER TABLE agents ADD COLUMN custom_color TEXT;
ALTER TABLE agents ADD COLUMN picture TEXT;
+ `,
+ `
+ ALTER TABLE agents ADD COLUMN avatar TEXT;
`
]
@@ -336,6 +339,7 @@ export class Db {
apps: JSON.parse(str(r['apps']) || '[]') as AgentApp[],
...(r['custom_color'] ? { customColor: str(r['custom_color']) } : {}),
...(r['picture'] ? { picture: str(r['picture']) } : {}),
+ ...(r['avatar'] ? { avatar: JSON.parse(str(r['avatar'])) as Agent['avatar'] } : {}),
autoApprove: JSON.parse(str(r['auto_approve']) || '[]') as string[],
folders: JSON.parse(str(r['folders']) || '[]') as LentFolder[],
archived: r['archived'] === 1,
@@ -355,14 +359,14 @@ export class Db {
saveAgent(a: Agent): void {
this.db
.prepare(
- `INSERT INTO agents (id, name, handle, role, color, instructions, model, fallback_model, fallback_account, account, effort, limit_tokens, max_routines, grants, memory_mode, computer, computer_kind, web, browser, apps, auto_approve, archived, kind, custom_color, picture, created_at)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ `INSERT INTO agents (id, name, handle, role, color, instructions, model, fallback_model, fallback_account, account, effort, limit_tokens, max_routines, grants, memory_mode, computer, computer_kind, web, browser, apps, auto_approve, archived, kind, custom_color, picture, avatar, created_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (id) DO UPDATE SET name = excluded.name, handle = excluded.handle, role = excluded.role,
color = excluded.color, instructions = excluded.instructions, model = excluded.model, fallback_model = excluded.fallback_model, fallback_account = excluded.fallback_account, account = excluded.account, effort = excluded.effort,
limit_tokens = excluded.limit_tokens, max_routines = excluded.max_routines, grants = excluded.grants, memory_mode = excluded.memory_mode,
- computer = excluded.computer, computer_kind = excluded.computer_kind, web = excluded.web, browser = excluded.browser, apps = excluded.apps, auto_approve = excluded.auto_approve, archived = excluded.archived, kind = COALESCE(excluded.kind, agents.kind), custom_color = excluded.custom_color, picture = excluded.picture`
+ computer = excluded.computer, computer_kind = excluded.computer_kind, web = excluded.web, browser = excluded.browser, apps = excluded.apps, auto_approve = excluded.auto_approve, archived = excluded.archived, kind = COALESCE(excluded.kind, agents.kind), custom_color = excluded.custom_color, picture = excluded.picture, avatar = excluded.avatar`
)
- .run(a.id, a.name, a.handle, a.role, a.color, a.instructions, a.modelId, a.fallbackModelId || null, a.fallbackAccountId || null, a.accountId || null, a.effort, a.limit, routineCap(a.maxRoutines), JSON.stringify(a.grants), a.memory ?? 'auto', a.computer ? 1 : 0, a.computerKind === 'mac' ? 'mac' : 'linux', a.web === false ? 0 : 1, a.browser ? 1 : 0, JSON.stringify(a.apps ?? []), JSON.stringify(a.autoApprove ?? []), a.archived ? 1 : 0, a.kind ?? null, a.customColor ?? null, a.picture ?? null, Date.now())
+ .run(a.id, a.name, a.handle, a.role, a.color, a.instructions, a.modelId, a.fallbackModelId || null, a.fallbackAccountId || null, a.accountId || null, a.effort, a.limit, routineCap(a.maxRoutines), JSON.stringify(a.grants), a.memory ?? 'auto', a.computer ? 1 : 0, a.computerKind === 'mac' ? 'mac' : 'linux', a.web === false ? 0 : 1, a.browser ? 1 : 0, JSON.stringify(a.apps ?? []), JSON.stringify(a.autoApprove ?? []), a.archived ? 1 : 0, a.kind ?? null, a.customColor ?? null, a.picture ?? null, a.avatar ? JSON.stringify(a.avatar) : null, Date.now())
}
// Kept apart from saveAgent: folders change only after the core checks them.
diff --git a/src/core/team.ts b/src/core/team.ts
index 8a2789d..aba6045 100644
--- a/src/core/team.ts
+++ b/src/core/team.ts
@@ -7,6 +7,7 @@ import { randomUUID } from 'node:crypto'
import { join } from 'node:path'
import { L, locale } from '../shared/lang'
import { describeSchedule, MAX_AGENT_ROUTINES, modelInfo, type Agent, type AgentColor, type Effort, type GrantLevel, type Routine, type Schedule, type Trigger } from '../shared/types'
+import { cleanLook } from './agent-look'
import type { Db } from './db'
const FENCE = 'tucano-team'
@@ -21,6 +22,8 @@ interface TeamFile {
name: string
role: string
color: AgentColor
+ customColor?: string
+ avatar?: Agent['avatar'] // the drawn one; a picture stays on its computer
instructions: string
model: string
effort: Effort
@@ -52,6 +55,8 @@ export function exportTeam(db: Db): string {
name: a.name,
role: a.role,
color: a.color,
+ ...(a.customColor ? { customColor: a.customColor } : {}),
+ ...(a.avatar ? { avatar: a.avatar } : {}),
instructions: a.instructions,
model: a.modelId,
effort: a.effort,
@@ -130,6 +135,8 @@ export function importTeam(db: Db, text: string, defaultLimit: number): string {
handle: a.handle,
role: a.role ?? '',
color: a.color ?? 'sky',
+ customColor: a.customColor,
+ avatar: a.avatar,
instructions: a.instructions ?? '',
modelId: modelInfo(a.model)?.id ? a.model : 'sonnet',
effort: a.effort ?? 'medium',
@@ -142,7 +149,7 @@ export function importTeam(db: Db, text: string, defaultLimit: number): string {
web: a.web,
archived: false
}
- db.saveAgent(agent)
+ db.saveAgent(cleanLook(agent))
added.agents++
}
const byHandle = (h: string): string | undefined => db.agents().find((x) => x.handle === h)?.id
diff --git a/src/renderer/src/assets/bot-avatars.json b/src/renderer/src/assets/bot-avatars.json
new file mode 100644
index 0000000..da11559
--- /dev/null
+++ b/src/renderer/src/assets/bot-avatars.json
@@ -0,0 +1,212 @@
+[
+ {
+ "version": 1,
+ "id": "cat",
+ "name": "Cat",
+ "body": {
+ "path": "M50 23C68 23 82 30 82 45C82 58 68 65 50 65C32 65 18 58 18 45C18 30 32 23 50 23ZM24 42C21 32 20 22 22 15C23 11 26 10 29 12C34 16 39 21 44 28L36 42ZM64 42L56 28C61 21 66 16 71 12C74 10 77 11 78 15C80 22 79 32 76 42ZM38 56L62 56C70 56 74 66 74 76C74 83 70 86 63 86L37 86C30 86 26 83 26 76C26 66 30 56 38 56ZM70 72C77 74 81 70 80 64C79 60 81 57 84 58C87 59 88.5 63 88 68C87 77 80 83 70 81Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 43,
+ "spacing": 17,
+ "scale": 1.1
+ }
+ },
+ {
+ "version": 1,
+ "id": "bunny",
+ "name": "Bunny",
+ "body": {
+ "path": "M50 40C68 40 80 50 80 64C80 78 68 86 50 86C32 86 20 78 20 64C20 50 32 40 50 40ZM30 46C26 36 24 24 26 16C28 10 34 10 37 15C40 22 42 34 42 44ZM58 44C58 34 61 22 66 15C69 10 76 11 76 17C76 25 74 36 70 46Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 62,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "bull",
+ "name": "Bull",
+ "body": {
+ "path": "M40 28L60 28C70 28 76 36 76 48L76 62C76 74 66 84 50 84C34 84 24 74 24 62L24 48C24 36 30 28 40 28ZM32 40C22 38 15 32 15 24C15 18 18 13 22 10C25 8 28 10 27 13C25 18 24 22 28 26C31 29 36 30 42 30ZM58 30C64 30 69 29 72 26C76 22 75 18 73 13C72 10 75 8 78 10C82 13 85 18 85 24C85 32 78 38 68 40ZM29 55C23 56 17 55 12 52C9 50 8 47 10 45C14 41 22 40 28 42ZM72 42C78 40 86 41 90 45C92 47 91 50 88 52C83 55 77 56 71 55Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 52,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "ghost",
+ "name": "Ghost",
+ "body": {
+ "path": "M24 50C24 28 35 12 50 12C65 12 76 28 76 50L77 80C77 85 73 88 68 88C63 88 61 84 59 81C57 84 54 88 50 88C46 88 43 84 41 81C39 84 37 88 32 88C27 88 23 85 23 80Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 42,
+ "spacing": 16,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "rocket",
+ "name": "Rocket",
+ "body": {
+ "path": "M46 10C48 8.5 52 8.5 54 10C64 17 71 29 71 44V72H29V44C29 29 36 17 46 10ZM29 56H71C80 61 86 70 86 80C86 84 83 86 79 85L72 83H28L21 85C17 86 14 84 14 80C14 70 20 61 29 56ZM42 80H58C59 86 55 90 50 92C45 90 41 86 42 80Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 46,
+ "spacing": 15,
+ "scale": 1.05
+ }
+ },
+ {
+ "version": 1,
+ "id": "brain",
+ "name": "Brain",
+ "body": {
+ "path": "M14 50C10 42 14 32 22 30C24 21 34 17 41 21C46 15 56 15 61 20C68 16 78 20 79 28C87 30 91 39 88 47C92 54 89 64 81 66C80 71 76 74 71 73C67 75 64 74 62 72C61 74 61 76 61.5 78C62 81 59 82.5 57 81.5C55.5 80.5 55 78 54 76C53 74 50 72.5 47 72.5C42 74 38 72 36 70C30 73 20 71 18 64C12 62 10 56 14 50Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 45,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "book",
+ "name": "Book",
+ "body": {
+ "path": "M12 32C12 29 14 27 17 26C30 21.5 42 23 50 31C58 23 70 21.5 83 26C86 27 88 29 88 32V64H89C90.7 64 92 65.3 92 67V75C92 77 90.5 78 88.5 77.5C76 75 60 76 50 84C40 76 24 75 11.5 77.5C9.5 78 8 77 8 75V67C8 65.3 9.3 64 11 64H12Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 51,
+ "spacing": 18,
+ "scale": 1.1
+ }
+ },
+ {
+ "version": 1,
+ "id": "camera",
+ "name": "Camera",
+ "body": {
+ "path": "M17 34H20V31C20 29 21 28 23 28H27C29 28 30 29 30 31V34H36L40 23C41 21 42 20 44 20H56C58 20 59 21 60 23L64 34H83C87.5 34 91 37.5 91 42V72C91 76.5 87.5 80 83 80H17C12.5 80 9 76.5 9 72V42C9 37.5 12.5 34 17 34Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 54,
+ "spacing": 17,
+ "scale": 1.1
+ }
+ },
+ {
+ "version": 1,
+ "id": "cloud",
+ "name": "Cloud",
+ "body": {
+ "path": "M24 76C14 76 9 69 9 61C9 52 15 46 23 45.5C25 33 36 24 49 24C61 24 70 31 73 41C83 41 91 49 91 59C91 69 83 76 74 76Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 54,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "magnifier",
+ "name": "Magnifier",
+ "body": {
+ "path": "M41 12A29 29 0 0 1 64.44 58.08L68.50 62.13A8 8 0 0 1 75.65 64.33L87.67 76.36A8 8 0 0 1 76.36 87.67L64.33 75.65A8 8 0 0 1 62.13 68.50L58.08 64.44A29 29 0 1 1 41 12Z"
+ },
+ "eyes": {
+ "x": 41,
+ "y": 40,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "paint-brush",
+ "name": "Paint Brush",
+ "body": {
+ "path": "M77.2 8.5C80.3 8.7 82.3 10.2 83.4 13.1C84 14.5 83.3 16.2 82.3 17.6L65.9 40.8L56.2 33.7L73.2 11C74.2 9.6 75.6 8.5 77.2 8.5ZM55.4 26.8L72.8 39.4C74.2 40.4 74.5 42.2 73.5 43.6L66.6 53C65.6 54.4 63.8 54.7 62.4 53.7L45.1 41C43.7 40 43.4 38.2 44.4 36.8L51.2 27.4C52.2 26 54 25.8 55.4 26.8ZM48.4 38.7L63.7 49.8C67.9 57.1 66.8 65.9 61.8 72.9C54.7 82.6 41.2 86.6 25.2 85.1C22.2 85 20 82.9 21 79.9C24.6 71.4 21.1 57.1 28.2 47.4C33.3 40.4 40.8 37.4 48.4 38.7Z"
+ },
+ "eyes": {
+ "x": 44,
+ "y": 59,
+ "spacing": 16,
+ "scale": 1.05
+ }
+ },
+ {
+ "version": 1,
+ "id": "palette",
+ "name": "Palette",
+ "body": {
+ "path": "M46 18C70 16 90 28 90 48C90 68 74 84 52 84C42 84 36 80 34 74C32 68 36 64 32 60C28 56 22 62 16 58C10 54 10 46 12 40C16 26 30 19 46 18ZM21 44A5 5 0 1 0 31 44A5 5 0 1 0 21 44Z"
+ },
+ "eyes": {
+ "x": 58,
+ "y": 46,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "shield",
+ "name": "Shield",
+ "body": {
+ "path": "M50 14C60 18 72 18 82 16Q86 16 86 20L86 46C86 64 72 78 54 86.5Q50 88.5 46 86.5C28 78 14 64 14 46L14 20Q14 16 18 16C28 18 40 18 50 14Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 42,
+ "spacing": 17,
+ "scale": 1.15
+ }
+ },
+ {
+ "version": 1,
+ "id": "star",
+ "name": "Star",
+ "body": {
+ "path": "M53.7 17.95L62 31.2Q64.1 34.6 68 35.6L83.1 39.3Q89.9 41 85.4 46.4L75.4 58.3Q72.8 61.4 73.1 65.4L74.2 81Q74.7 88 68.2 85.4L53.7 79.5Q50 78 46.3 79.5L31.8 85.4Q25.3 88 25.8 81L26.9 65.4Q27.2 61.4 24.6 58.3L14.6 46.4Q10.1 41 16.9 39.3L32 35.6Q35.9 34.6 38 31.2L46.3 17.95Q50 12 53.7 17.95Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 52,
+ "spacing": 16,
+ "scale": 1.1
+ }
+ },
+ {
+ "version": 1,
+ "id": "witch-hat",
+ "name": "Witch Hat",
+ "body": {
+ "path": "M50 72C72 72 92 75 92 80C92 85 72 87 50 87C28 87 8 85 8 80C8 75 28 72 50 72ZM37 30L63 30Q68 30 68.8 35L77.5 76Q78 80 74 80L26 80Q22 80 22.5 76L31.2 35Q32 30 37 30ZM30.56 38C33 26.5 40 18 52 14C62 10.5 72 9 81 11A3.2 3.2 0 0 1 81 17.4C74 18 69.5 24.5 68.1 31.5L69.44 38Z"
+ },
+ "eyes": {
+ "x": 50,
+ "y": 54,
+ "spacing": 15,
+ "scale": 1.05
+ }
+ }
+]
diff --git a/src/renderer/src/components/Onboarding.tsx b/src/renderer/src/components/Onboarding.tsx
index 3664681..90c5130 100644
--- a/src/renderer/src/components/Onboarding.tsx
+++ b/src/renderer/src/components/Onboarding.tsx
@@ -41,7 +41,7 @@ import {
isTeam
} from '../store'
import { HarnessList, ModelPicker, usableEngines } from './Harness'
-import { ColorPicker, JevKey, LanguagePicker, ModelSelect, PicturePicker, Toggle } from './Pages'
+import { ColorPicker, JevKey, LanguagePicker, LookPicker, ModelSelect, Toggle } from './Pages'
import { Splash } from './Splash'
import { Composer, MessageList } from './Conversation'
import { draftAgent, UseDraft } from './Tuca'
@@ -840,8 +840,8 @@ function MakeAgent(p: {
<ColorPicker agent={agent} patch={patch} />
</div>
<div className="onb__field">
- <span>{L('Foto ou ícone', 'Photo or icon')}</span>
- <PicturePicker agent={agent} patch={patch} />
+ <span>{L('Aparência', 'Look')}</span>
+ <LookPicker agent={agent} patch={patch} />
</div>
<div className="onb__field">
<span>{L('Modelo', 'Model')}</span>
diff --git a/src/renderer/src/components/Pages.tsx b/src/renderer/src/components/Pages.tsx
index 9a1fff5..f89f938 100644
--- a/src/renderer/src/components/Pages.tsx
+++ b/src/renderer/src/components/Pages.tsx
@@ -61,7 +61,7 @@ import {
import { AccountPicker, AccountsCard, HarnessList, HarnessMcps, ModelPicker, onGateway, OutsideGateway, usableEngines } from './Harness'
import { AppsCard } from './Apps'
import { ApprovalCard } from './Conversation'
-import { AgentAvatar, Icon, NumberInput, SleepingToucan, time, tokens, UsageBar } from './ui'
+import { AgentAvatar, AVATARS, Icon, NumberInput, SleepingToucan, time, tokens, UsageBar } from './ui'
import { UpdateSettings } from './Update'
export function Page({ title, subtitle, actions, children }: { title: ReactNode; subtitle?: ReactNode; actions?: ReactNode; children: ReactNode }): ReactNode {
@@ -165,13 +165,24 @@ export function ColorPicker({ agent, patch }: { agent: Pick<Agent, 'color' | 'cu
)
}
-// A picture over the face, scaled down here; taken off the same way.
-export function PicturePicker({ agent, patch }: { agent: Pick<Agent, 'name' | 'color' | 'customColor' | 'picture'>; patch: (p: Partial<Agent>) => void }): ReactNode {
+// How an agent looks, here and in the onboarding: the face, a drawn character or a picture
+// of the person's own (scaled down here). One at a time.
+export function LookPicker({ agent, patch }: { agent: Pick<Agent, 'name' | 'color' | 'customColor' | 'picture' | 'avatar'>; patch: (p: Partial<Agent>) => void }): ReactNode {
const [error, setError] = useState('')
+ const base = { name: agent.name || '?', color: agent.color, customColor: agent.customColor }
return (
<>
+ <div className="looks">
+ <button type="button" className={`look ${!agent.picture && !agent.avatar ? 'is-active' : ''}`} title={L('Rosto padrão', 'Default face')} onClick={() => patch({ avatar: undefined, picture: undefined })}>
+ <AgentAvatar agent={base} size={30} />
+ </button>
+ {AVATARS.map((a) => (
+ <button key={a.id} type="button" className={`look ${!agent.picture && agent.avatar?.id === a.id ? 'is-active' : ''}`} title={a.name} onClick={() => patch({ avatar: a, picture: undefined })}>
+ <AgentAvatar agent={{ ...base, avatar: a }} size={30} />
+ </button>
+ ))}
+ </div>
<div className="row row--center">
- <AgentAvatar agent={{ ...agent, name: agent.name || '?' }} size={40} />
<label className="btn btn--sm">
{L('Enviar imagem', 'Upload image')}
<input
@@ -181,14 +192,17 @@ export function PicturePicker({ agent, patch }: { agent: Pick<Agent, 'name' | 'c
onChange={(e) => {
const file = e.target.files?.[0]
e.target.value = ''
- if (file) pictureFrom(file).then((picture) => (setError(''), patch({ picture })), () => setError(L('Não consegui abrir essa imagem.', "I couldn't open that image.")))
+ if (file) pictureFrom(file).then((picture) => (setError(''), patch({ picture, avatar: undefined })), () => setError(L('Não consegui abrir essa imagem.', "I couldn't open that image.")))
}}
/>
</label>
{agent.picture && (
- <button type="button" className="btn btn--sm btn--ghost" onClick={() => patch({ picture: undefined })}>
- {L('Tirar', 'Remove')}
- </button>
+ <>
+ <AgentAvatar agent={{ ...base, picture: agent.picture }} size={30} />
+ <button type="button" className="btn btn--sm btn--ghost" onClick={() => patch({ picture: undefined })}>
+ {L('Tirar a imagem', 'Remove the image')}
+ </button>
+ </>
)}
</div>
{error && <span className="field__error">{error}</span>}
@@ -327,9 +341,10 @@ export function AgentPage({ id, draft: proposed, fromMessage }: { id?: string; d
<Field label={L('Cor', 'Color')}>
<ColorPicker agent={draft} patch={patch} />
</Field>
- <Field label={L('Foto ou ícone', 'Photo or icon')}>
- <PicturePicker agent={draft} patch={patch} />
- </Field>
+ <div className="field">
+ <span className="field__label">{L('Aparência', 'Look')}</span>
+ <LookPicker agent={draft} patch={patch} />
+ </div>
</Card>
)}
diff --git a/src/renderer/src/components/ui.tsx b/src/renderer/src/components/ui.tsx
index da56c7f..7c19aaf 100644
--- a/src/renderer/src/components/ui.tsx
+++ b/src/renderer/src/components/ui.tsx
@@ -1,6 +1,9 @@
import { L, lang, locale } from '../../../shared/lang'
-import { useState, type CSSProperties, type InputHTMLAttributes, type ReactNode } from 'react'
-import type { Agent } from '../store'
+import { examples, type AvatarDefinition } from 'open-bot-avatar'
+import { mountAvatar, type AvatarOptions, type MountedAvatar } from 'open-bot-avatar/dom'
+import { useEffect, useRef, useState, type CSSProperties, type InputHTMLAttributes, type ReactNode } from 'react'
+import type { Agent, AgentColor } from '../store'
+import gallery from '../assets/bot-avatars.json'
const PATHS: Record<string, ReactNode> = {
hash: <path d="M5 9h14M5 15h14M10 4 8 20M16 4l-2 16" />,
@@ -178,9 +181,37 @@ export function SleepingToucan({ size = 120 }: { size?: number }): ReactNode {
// An agent's own color, over its class's, wherever the agent's color shows.
export const ownColor = (agent: Partial<Pick<Agent, 'customColor'>>): CSSProperties => (agent.customColor ? ({ '--agent': agent.customColor } as CSSProperties) : {})
+// The drawn characters an agent can take (Open Bot Avatar's starters and gallery, MIT).
+export const AVATARS: AvatarDefinition[] = [...examples, ...(gallery as AvatarDefinition[])]
+
+// The eight colors as the drawn avatar takes them (it wants #rrggbb, not a CSS variable).
+const HEX: Record<AgentColor, string> = { sky: '#3b9eea', indigo: '#5b6cf0', violet: '#8b5cf6', rose: '#e5557a', amber: '#e3a008', green: '#22a35a', teal: '#14a3a3', graphite: '#5d6470' }
+
+// A drawn avatar. Big ones and busy ones move (busy: thinking); the rest are one still SVG,
+// so a long chat stays light. The biggest follow the pointer with their eyes.
+function DrawnAvatar({ definition, color, size, busy }: { definition: AvatarDefinition; color: string; size: number; busy?: boolean }): ReactNode {
+ const host = useRef<HTMLSpanElement>(null)
+ const avatar = useRef<MountedAvatar | null>(null)
+ const options: AvatarOptions = { definition, color, mood: busy ? 'thinking' : 'idle', still: size < 40 && !busy, followPointer: size >= 64, label: '' }
+ useEffect(() => {
+ avatar.current = mountAvatar(host.current!, options)
+ return () => avatar.current?.destroy()
+ }, [])
+ useEffect(() => avatar.current?.update(options), [definition, color, options.mood, options.still, options.followPointer])
+ return <span ref={host} className="avatar__drawn" />
+}
+
// busy: the eyes read, left to right, while the agent works. Otherwise they blink now and then.
-export function AgentAvatar({ agent, size = 32, busy }: { agent: Pick<Agent, 'name' | 'color'> & Partial<Pick<Agent, 'kind' | 'customColor' | 'picture'>>; size?: number; busy?: boolean }): ReactNode {
+// A picture wins over a drawn avatar, and both over the face.
+export function AgentAvatar({ agent, size = 32, busy }: { agent: Pick<Agent, 'name' | 'color'> & Partial<Pick<Agent, 'kind' | 'customColor' | 'picture' | 'avatar'>>; size?: number; busy?: boolean }): ReactNode {
if (agent.kind === 'tuca') return <TucaMark size={size} />
+ if (!agent.picture && agent.avatar)
+ return (
+ <span className="avatar avatar--drawn" style={{ width: size, height: size }}>
+ <DrawnAvatar definition={agent.avatar} color={agent.customColor ?? HEX[agent.color]} size={size} busy={busy} />
+ <span className="sr-only">{agent.name}</span>
+ </span>
+ )
return (
<span className={`avatar avatar--agent c-${agent.color} ${busy ? 'is-busy' : ''}`} style={{ width: size, height: size, fontSize: size * 0.42, ...ownColor(agent) }}>
{agent.picture ? (
diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.css
index bf6ff78..c5d6719 100644
--- a/src/renderer/src/styles.css
+++ b/src/renderer/src/styles.css
@@ -1390,6 +1390,28 @@ h3 {
display: flex;
gap: 8px;
}
+.looks {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: 8px;
+}
+.look {
+ display: grid;
+ place-items: center;
+ width: 40px;
+ height: 40px;
+ border-radius: 10px;
+ background: transparent;
+ box-shadow: inset 0 0 0 1px var(--border);
+ transition: box-shadow 0.12s;
+}
+.look:hover {
+ box-shadow: inset 0 0 0 1px var(--text-3);
+}
+.look.is-active {
+ box-shadow: inset 0 0 0 2px var(--accent);
+}
.swatch {
width: 26px;
height: 26px;
@@ -6600,6 +6622,15 @@ kbd {
}
/* An agent's own color and picture */
+/* A drawn avatar (Open Bot Avatar): the character itself, no tile behind it */
+.avatar--drawn {
+ overflow: visible;
+}
+.avatar__drawn {
+ position: absolute;
+ inset: 0;
+ display: block;
+}
.avatar__photo {
width: 100%;
height: 100%;
diff --git a/src/shared/types.ts b/src/shared/types.ts
index b4ceaab..5a14da8 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1,4 +1,5 @@
// Domain types shared by the core (utility process) and the renderer.
+import type { AvatarDefinition } from 'open-bot-avatar'
import { L, lang, type Lang } from './lang'
export type AgentColor = 'sky' | 'indigo' | 'violet' | 'rose' | 'amber' | 'green' | 'teal' | 'graphite'
@@ -57,6 +58,7 @@ export interface Agent {
color: AgentColor
customColor?: string // a color of the person's own (#rrggbb), over `color`
picture?: string // a small picture (data URL), over the face
+ avatar?: AvatarDefinition // a drawn character (open-bot-avatar), over the face; a picture wins over it
instructions: string
modelId: string
// Where a reply goes when modelId's subscription is out (its 5-hour or weekly limit, a 429): tried
diff --git a/test/agent-look.test.ts b/test/agent-look.test.ts
index 1019587..12d162e 100644
--- a/test/agent-look.test.ts
+++ b/test/agent-look.test.ts
@@ -1,7 +1,9 @@
import { describe, expect, it } from 'vitest'
+import { examples } from 'open-bot-avatar'
import { cleanLook } from '../src/core/agent-look'
+import gallery from '../src/renderer/src/assets/bot-avatars.json'
-describe('an agent’s color and picture', () => {
+describe('an agent’s color, picture and drawn avatar', () => {
it('keeps a color and a small picture', () => {
const look = { customColor: '#FF00aa', picture: 'data:image/jpeg;base64,AAAA' }
expect(cleanLook(look)).toEqual(look)
@@ -10,4 +12,9 @@ describe('an agent’s color and picture', () => {
for (const customColor of ['red', '#fff', '#ff00aa;background:url(x)']) expect(cleanLook({ customColor }).customColor).toBeUndefined()
for (const picture of ['https://x.com/a.png', 'data:image/svg+xml;base64,AAAA', 'data:image/png;base64,AA"><script>', `data:image/png;base64,${'A'.repeat(200_001)}`]) expect(cleanLook({ picture }).picture).toBeUndefined()
})
+ it('keeps a drawn avatar that passes its own check (with its path tidied), and drops one that doesn’t', () => {
+ for (const avatar of [...examples, ...gallery]) expect(cleanLook({ avatar: avatar as never }).avatar).toMatchObject({ id: avatar.id, eyes: avatar.eyes })
+ const cat = gallery[0]!
+ for (const avatar of [{ ...cat, body: { path: '<script>' } }, { ...cat, extra: 1 }, { ...cat, version: 2 }, 'cat']) expect(cleanLook({ avatar: avatar as never }).avatar).toBeUndefined()
+ })
})
diff --git a/test/team.test.ts b/test/team.test.ts
index 795e8fc..13f88ae 100644
--- a/test/team.test.ts
+++ b/test/team.test.ts
@@ -2,6 +2,7 @@ import { existsSync, mkdtempSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
+import { examples } from 'open-bot-avatar'
import type { Agent } from '../src/shared/types'
import { Db } from '../src/core/db'
import { claudeParser } from '../src/core/engines/claude'
@@ -18,7 +19,7 @@ describe('the team as a file', () => {
const a = fresh()
a.saveConnector({ id: 'lin', name: 'Linear', kind: 'remote', url: 'https://mcp.linear.app/mcp', auth: 'oauth' })
a.saveAgent(agent('s', 'staff', { grants: { lin: 'read' } }))
- a.saveAgent(agent('p', 'pm', { role: 'Produto', computer: false }))
+ a.saveAgent(agent('p', 'pm', { role: 'Produto', computer: false, customColor: '#ff00aa', picture: 'data:image/webp;base64,AAAA', avatar: examples[0] }))
a.createConversation({ id: 'c1', kind: 'channel', name: 'simula-oab', members: ['s', 'p'] })
a.saveSkill({ id: 'k', name: 'testes-do-core', description: 'Ao rodar testes', body: 'swift test', agents: ['s'], state: 'active', createdAt: 1, updatedAt: 1 })
a.saveRoutine({ id: 'r', name: 'Issues novas', agentId: 'p', conversationId: 'c1', prompt: 'Planeje.', schedule: { days: [], time: '' }, trigger: { kind: 'poll', connectorId: 'lin', tool: 'list_issues', args: { label: 'agente' }, everyMinutes: 5 }, enabled: true, createdAt: 1 })
@@ -33,6 +34,10 @@ describe('the team as a file', () => {
expect(importTeam(b, md, 2_000_000)).toBe('Importei 2 agentes, 1 skill, 1 canal, 1 rotina (desligadas).')
const staff = b.agents().find((x) => x.handle === 'staff')!
expect(staff).toMatchObject({ modelId: 'opus', grants: { lin2: 'read' }, computer: false })
+ // The drawn avatar and the color travel; the picture stays on its computer.
+ const pm = b.agents().find((x) => x.handle === 'pm')!
+ expect(pm).toMatchObject({ customColor: '#ff00aa', avatar: { id: examples[0]!.id } })
+ expect(pm.picture).toBeUndefined()
expect(b.skills()[0]).toMatchObject({ name: 'testes-do-core', agents: [staff.id] })
expect(b.routines()[0]).toMatchObject({ enabled: false, trigger: { kind: 'poll', connectorId: 'lin2' } })
expect(importTeam(b, md, 2_000_000)).toBe('Nada novo: tudo já existia aqui.')