fix(gateway): resolve local avatars to URL in HTML injection and RPC
The frontend fix alone wasn't enough because:
1. serveIndexHtml() was injecting the raw avatar filename into HTML
2. agent.identity.get RPC was returning raw filename, overwriting the
HTML-injected value
Now both paths resolve local file avatars (*.png, *.jpg, etc.) to the
/avatar/{agentId} endpoint URL.
This commit is contained in:
@@ -407,7 +407,18 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
}
|
||||
const cfg = loadConfig();
|
||||
const identity = resolveAssistantIdentity({ cfg, agentId });
|
||||
respond(true, identity, undefined);
|
||||
// Resolve local file avatars to /avatar/{agentId} URL
|
||||
let avatarValue = identity.avatar;
|
||||
if (
|
||||
avatarValue &&
|
||||
!/^https?:\/\//i.test(avatarValue) &&
|
||||
!/^data:image\//i.test(avatarValue) &&
|
||||
/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(avatarValue) &&
|
||||
identity.agentId
|
||||
) {
|
||||
avatarValue = `/avatar/${identity.agentId}`;
|
||||
}
|
||||
respond(true, { ...identity, avatar: avatarValue }, undefined);
|
||||
},
|
||||
"agent.wait": async ({ params, respond }) => {
|
||||
if (!validateAgentWaitParams(params)) {
|
||||
|
||||
Reference in New Issue
Block a user