Files
PaperClipAI/server/src/services/agent-avatar-worker.ts
T
TonioandPaperclip 9dfdeaad86 Refine agent workspaces and organization charts (#20973)
Refine agent details, identity editing, responsive controls, and organization charts with three card tiers, clearer save feedback, and stable filtering.

Guard instruction-file renames and root configuration updates in one transaction through the agent lifecycle integration, preserving conflict checks, rollback, and configuration history.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-12 01:23:59 +00:00

18 lines
857 B
TypeScript

import { parentPort } from "node:worker_threads";
import sharp from "sharp";
import { renderAgentSvg } from "@paperclipai/shared/cliplab/static";
import { PAPERCLIP_DARK_AVATAR_BACKGROUND } from "@paperclipai/shared";
import type { AgentAvatarRequest } from "./agent-avatars.js";
parentPort!.on("message", async (request: AgentAvatarRequest) => {
try {
const svg = renderAgentSvg(request.appearance, request.size, request.scale, request.pose, request.muted, request.view);
const image = sharp(Buffer.from(svg));
if (request.background === "paperclip-dark") image.flatten({ background: PAPERCLIP_DARK_AVATAR_BACKGROUND });
const png = await image.png().toBuffer();
parentPort!.postMessage({ png });
} catch (error) {
parentPort!.postMessage({ error: error instanceof Error ? error.message : "Avatar rendering failed" });
}
});