mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:34:35 +00:00
refactor(plugin-sdk): add shared helper utilities
This commit is contained in:
24
src/plugin-sdk/agent-media-payload.ts
Normal file
24
src/plugin-sdk/agent-media-payload.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type AgentMediaPayload = {
|
||||
MediaPath?: string;
|
||||
MediaType?: string;
|
||||
MediaUrl?: string;
|
||||
MediaPaths?: string[];
|
||||
MediaUrls?: string[];
|
||||
MediaTypes?: string[];
|
||||
};
|
||||
|
||||
export function buildAgentMediaPayload(
|
||||
mediaList: Array<{ path: string; contentType?: string | null }>,
|
||||
): AgentMediaPayload {
|
||||
const first = mediaList[0];
|
||||
const mediaPaths = mediaList.map((media) => media.path);
|
||||
const mediaTypes = mediaList.map((media) => media.contentType).filter(Boolean) as string[];
|
||||
return {
|
||||
MediaPath: first?.path,
|
||||
MediaType: first?.contentType ?? undefined,
|
||||
MediaUrl: first?.path,
|
||||
MediaPaths: mediaPaths.length > 0 ? mediaPaths : undefined,
|
||||
MediaUrls: mediaPaths.length > 0 ? mediaPaths : undefined,
|
||||
MediaTypes: mediaTypes.length > 0 ? mediaTypes : undefined,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user