mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 22:51:15 +00:00
* 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>
24 lines
983 B
TypeScript
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];
|
|
}
|