Files
openclaw/extensions/codex/src/app-server/user-input.ts
Wynne668 f1f4b8ae8d fix: keep image attachments when steering active runs (#107657)
* fix: preserve images during active-run steering

* fix(codex): preserve steering fallback order

Co-authored-by: ZengWen-DT <ceng.wen@xydigit.com>

* test(codex): satisfy strict steering assertions

Co-authored-by: ZengWen-DT <ceng.wen@xydigit.com>

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-16 04:23:03 -07:00

24 lines
983 B
TypeScript

import type { EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
import { invalidInlineImageText, sanitizeInlineImageDataUrl } from "./image-payload-sanitizer.js";
import type { CodexUserInput } from "./protocol.js";
/** Builds ordered Codex user input for both new turns and same-turn steering. */
export function buildCodexUserInput(
text: string | undefined,
images?: EmbeddedRunAttemptParams["images"],
): CodexUserInput[] {
const imageInputs = (images ?? []).map((image): CodexUserInput => {
const imageUrl = sanitizeInlineImageDataUrl(`data:${image.mimeType};base64,${image.data}`);
return imageUrl
? { type: "image", url: imageUrl }
: {
type: "text",
text: invalidInlineImageText("codex user input"),
text_elements: [],
};
});
const textInput: CodexUserInput[] =
text === undefined ? [] : [{ type: "text", text, text_elements: [] }];
return [...textInput, ...imageInputs];
}