feat: add avatar support for agent identity

- Add avatar field to IdentityConfig type
- Add avatar parsing in AgentIdentity from IDENTITY.md
- Add renderAvatar support for image avatars in webchat
- Add CSS styling for image avatars

Users can now configure a custom avatar for the assistant in the webchat
by setting 'identity.avatar' in the agent config or adding 'Avatar: path'
to IDENTITY.md. The avatar can be served from the assets folder.

Closes #TBD
This commit is contained in:
Dave Lauer
2026-01-20 14:45:58 -05:00
parent 2dfd3b9a81
commit 6402a48482
4 changed files with 18 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ export type AgentIdentity = {
creature?: string;
vibe?: string;
theme?: string;
avatar?: string;
};
export function listAgentEntries(cfg: ClawdbotConfig): AgentEntry[] {
@@ -90,6 +91,7 @@ export function parseIdentityMarkdown(content: string): AgentIdentity {
if (label === "creature") identity.creature = value;
if (label === "vibe") identity.vibe = value;
if (label === "theme") identity.theme = value;
if (label === "avatar") identity.avatar = value;
}
return identity;
}
@@ -99,7 +101,7 @@ export function loadAgentIdentity(workspace: string): AgentIdentity | null {
try {
const content = fs.readFileSync(identityPath, "utf-8");
const parsed = parseIdentityMarkdown(content);
if (!parsed.name && !parsed.emoji && !parsed.theme && !parsed.creature && !parsed.vibe) {
if (!parsed.name && !parsed.emoji && !parsed.theme && !parsed.creature && !parsed.vibe && !parsed.avatar) {
return null;
}
return parsed;

View File

@@ -144,4 +144,6 @@ export type IdentityConfig = {
name?: string;
theme?: string;
emoji?: string;
/** Path to a custom avatar image (relative to workspace or absolute). */
avatar?: string;
};