UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

27 lines (26 loc) • 999 B
//#region src/gateway/agent-turn/agent-image-understanding.ts /** Text-only agent turns share chat's image preparation while retaining their primary model. */ async function prepareAgentImageUnderstanding(e) { const { message: t, media: n, sessionKey: r, channel: i, chatType: a, ...o } = e; const s = { Body: t, media: n, SessionKey: r, AgentId: e.agentId, Provider: i, ChatType: a }; const { applyMediaUnderstanding: c } = await import("./media-understanding/apply.runtime.js"); await c({ ...o, ctx: s }); e.execution?.signal.throwIfAborted(); if (!s.MediaUnderstanding?.some((e) => e.kind === "image.description" && e.text.trim())) throw new Error("Image attachments could not be analyzed. Configure agents.defaults.imageModel or tools.media.models with an available vision model, then retry."); return { message: s.agentText ?? t, media: n.map((e) => Object.assign({}, e, { hydrationSuppressed: true })) }; } //#endregion export { prepareAgentImageUnderstanding };