feat: add structured part events to gateway for teamActivity, media, and error parts

Extends GatewayEvent union with structured_part variants, adds matching
HistoryPart types, wires SSE emission in runtime handleChat, and maps
agent-core content parts to history in session-state.
This commit is contained in:
Harivansh Rathi 2026-03-12 00:40:39 -04:00
parent a5d70ce55e
commit 4dc5e1b376
5 changed files with 165 additions and 2 deletions

View file

@ -85,6 +85,41 @@ export function messageContentToHistoryParts(msg: AgentMessage): HistoryPart[] {
args: toolCall.arguments,
state: "call",
});
} else if (contentPart.type === "teamActivity") {
const activity = contentPart as {
type: "teamActivity";
teamId: string;
status: string;
members?: Array<{ id: string; name: string; role?: string; status: string; message?: string }>;
};
parts.push({
type: "teamActivity",
teamId: activity.teamId,
status: activity.status,
members: Array.isArray(activity.members) ? activity.members : [],
});
} else if (contentPart.type === "image") {
const image = contentPart as {
type: "image";
url: string;
mimeType?: string;
};
parts.push({
type: "media",
url: image.url,
mimeType: image.mimeType,
});
} else if (contentPart.type === "error") {
const error = contentPart as {
type: "error";
code?: string;
message: string;
};
parts.push({
type: "error",
code: typeof error.code === "string" ? error.code : "unknown",
message: error.message,
});
}
}
return parts;