mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 12:30:44 +00:00
* fix(scripts): find codex protocol source from worktrees * fix(test): keep codex harness docker caches writable * fix(test): relax live codex cache mount permissions * test(codex): add live docker harness debug output * fix(test): detect numeric ci env in codex docker harness * fix(codex): skip duplicate agent-command telemetry * fix(tooling): skip sparse-missing oxlint tsconfig * fix(tooling): route changed checks through testbox * fix(qa): keep coverage json source-clean * fix(test): preflight codex docker auth * fix(codex): validate bind option values * fix(codex): parse quoted command arguments * fix(codex): reject extra control args * fix(codex): use content for blank bound prompts * fix(codex): decode local image file urls * fix(codex): treat local media urls as images * fix(codex): keep windows media paths local * fix(codex): reject malformed diagnostics confirmations * fix(codex): reject malformed resume commands * fix(codex): reject malformed thread actions * fix(codex): reject malformed turn controls * fix(codex): reject malformed model controls * fix(codex): resolve empty user input prompts * fix(codex): enforce user input options * fix(codex): reject ambiguous computer-use actions * fix(codex): ignore stale bound turn notifications * test(gateway): close task registries in gateway harness * test(gateway): route cleanup through task seams * fix(codex): describe current permission approvals * fix(codex): disclose command approval amendments * fix(codex): preserve approval detail under truncation * fix(codex): propagate dynamic tool failures * test(codex): align dynamic tool block contract * fix(codex): reject extra read-only command operands * fix(codex): escape command readout fields * fix(codex): escape status probe errors * fix(codex): narrow formatted thread details * fix(codex): escape successful status summaries * fix(codex): escape bound control replies * fix(codex): escape user input prompts * fix(codex): escape control failure replies * fix(codex): escape approval prompt text * test(codex): narrow escaped reply assertions * test(codex): complete strict reply fixtures * test(codex): preserve account fixture literals * test(codex): align status probe fixtures * fix(codex): satisfy sanitizer regex lint * fix(codex): harden command readouts * fix(codex): harden bound image inputs * fix(codex): sanitize command failure replies * test(codex): complete rate limit fixture * test(tooling): isolate postinstall compile cache fixture * fix(codex): keep app-server event ownership explicit --------- Co-authored-by: pashpashpash <nik@vault77.ai>
142 lines
4.0 KiB
TypeScript
142 lines
4.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildCodexConversationTurnInput } from "./conversation-turn-input.js";
|
|
|
|
describe("codex conversation turn input", () => {
|
|
it("forwards inbound image attachments to Codex app-server", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "what is this?",
|
|
event: {
|
|
content: "what is this?",
|
|
channel: "telegram",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaPaths: ["/tmp/photo.png", "/tmp/readme.txt"],
|
|
mediaUrls: ["https://example.test/photo.png"],
|
|
mediaTypes: ["image/png", "text/plain"],
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "what is this?", text_elements: [] },
|
|
{ type: "localImage", path: "/tmp/photo.png" },
|
|
]);
|
|
});
|
|
|
|
it("uses remote image urls when no local path is available", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaUrl: "https://example.test/photo.webp?sig=1",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "look", text_elements: [] },
|
|
{ type: "image", url: "https://example.test/photo.webp?sig=1" },
|
|
]);
|
|
});
|
|
|
|
it("keeps protocol-relative image urls remote", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaUrl: "//cdn.example.test/photo.webp",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "look", text_elements: [] },
|
|
{ type: "image", url: "//cdn.example.test/photo.webp" },
|
|
]);
|
|
});
|
|
|
|
it("decodes local file URLs for Codex local image input", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaPath: "file:///tmp/OpenClaw%20QA/photo.png",
|
|
mediaType: "image/png",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "look", text_elements: [] },
|
|
{ type: "localImage", path: "/tmp/OpenClaw QA/photo.png" },
|
|
]);
|
|
});
|
|
|
|
it("drops malformed local file URLs instead of throwing", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaPath: "file:///tmp/%zz/photo.png",
|
|
mediaType: "image/png",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([{ type: "text", text: "look", text_elements: [] }]);
|
|
});
|
|
|
|
it("treats local media URLs as Codex local image input", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaUrls: ["/tmp/staged-photo.png", "file:///tmp/OpenClaw%20QA/second.jpg"],
|
|
mediaTypes: ["image/png", "image/jpeg"],
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "look", text_elements: [] },
|
|
{ type: "localImage", path: "/tmp/staged-photo.png" },
|
|
{ type: "localImage", path: "/tmp/OpenClaw QA/second.jpg" },
|
|
]);
|
|
});
|
|
|
|
it("treats Windows media paths as Codex local image input", () => {
|
|
expect(
|
|
buildCodexConversationTurnInput({
|
|
prompt: "look",
|
|
event: {
|
|
content: "look",
|
|
channel: "webchat",
|
|
isGroup: false,
|
|
metadata: {
|
|
mediaUrl: "C:\\OpenClaw QA\\photo.png",
|
|
mediaType: "image/png",
|
|
},
|
|
},
|
|
}),
|
|
).toEqual([
|
|
{ type: "text", text: "look", text_elements: [] },
|
|
{ type: "localImage", path: "C:\\OpenClaw QA\\photo.png" },
|
|
]);
|
|
});
|
|
});
|