Add multimodal image inputs to Face turns
This commit is contained in:
parent
2119ed3ee1
commit
c430e709fd
12 changed files with 281 additions and 16 deletions
|
|
@ -415,6 +415,7 @@ export class OwnerCodexProvider implements ProviderAdapter {
|
|||
timeoutMs: this.options.timeoutMs,
|
||||
workingDirectory: this.options.workingDirectory,
|
||||
prompt: input.prompt,
|
||||
imagePaths: collectCodexImagePaths(input.request.contextBundle),
|
||||
mcpServers: input.command === "repo-face-rumination"
|
||||
? restrictMcpServersToRepoFaceExploration(this.options.mcpServers ?? [])
|
||||
: this.options.mcpServers ?? [],
|
||||
|
|
@ -436,11 +437,19 @@ export class OwnerCodexProvider implements ProviderAdapter {
|
|||
timeoutMs: this.options.timeoutMs,
|
||||
workingDirectory: this.options.workingDirectory,
|
||||
prompt: input.prompt,
|
||||
imagePaths: collectCodexImagePaths(input.request.contextBundle),
|
||||
mcpServers: this.options.mcpServers ?? [],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function collectCodexImagePaths(contextBundle: ProviderRequest["contextBundle"]): string[] {
|
||||
return (contextBundle.imageAttachments ?? [])
|
||||
.map((attachment) => attachment.localPath)
|
||||
.filter((localPath): localPath is string => typeof localPath === "string" && localPath.trim().length > 0)
|
||||
.slice(0, 8);
|
||||
}
|
||||
|
||||
function getStringOption(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export function buildDiscordReplyPrompt(
|
|||
? context.recentMessages
|
||||
.map(
|
||||
(message) =>
|
||||
`- [${message.timestamp}] ${message.authorName}: ${message.content}`,
|
||||
`- [${message.timestamp}] ${message.authorName}: ${message.content}${renderAttachmentSuffix(message)}`,
|
||||
)
|
||||
.join("\n")
|
||||
: "- No recent messages captured.";
|
||||
|
|
@ -116,7 +116,7 @@ export function renderMarkdownBundle(context: ContextBundle): string {
|
|||
? context.recentMessages
|
||||
.map(
|
||||
(message) =>
|
||||
`- [${message.timestamp}] ${message.authorName} (${message.authorId}): ${message.content}`,
|
||||
`- [${message.timestamp}] ${message.authorName} (${message.authorId}): ${message.content}${renderAttachmentSuffix(message)}`,
|
||||
)
|
||||
.join("\n")
|
||||
: "- No recent messages captured.";
|
||||
|
|
@ -183,6 +183,20 @@ export function renderMarkdownBundle(context: ContextBundle): string {
|
|||
].join("\n");
|
||||
}
|
||||
|
||||
function renderAttachmentSuffix(message: ContextBundle["recentMessages"][number]): string {
|
||||
const attachments = message.attachments ?? [];
|
||||
if (attachments.length === 0) {
|
||||
return "";
|
||||
}
|
||||
return ` [media: ${attachments.map((attachment) => {
|
||||
const kind = attachment.kind === "image" ? "image" : "attachment";
|
||||
const name = attachment.filename ?? attachment.id ?? "unnamed";
|
||||
const dimensions = attachment.width && attachment.height ? ` ${attachment.width}x${attachment.height}` : "";
|
||||
const local = attachment.localPath ? ` local=${attachment.localPath}` : "";
|
||||
return `${kind} ${name}${dimensions}${local}`;
|
||||
}).join("; ")}]`;
|
||||
}
|
||||
|
||||
function renderVoidSelfState(context: ContextBundle): string {
|
||||
if (!context.voidSelfState) {
|
||||
return "- No private persistent self-state was attached.";
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export async function runCodexExec(input: {
|
|||
timeoutMs: number;
|
||||
workingDirectory: string;
|
||||
prompt: string;
|
||||
imagePaths?: string[];
|
||||
mcpServers: CodexMcpServerConfig[];
|
||||
}): Promise<CodexRunResult> {
|
||||
return new Promise<CodexRunResult>((resolve) => {
|
||||
|
|
@ -62,6 +63,7 @@ export async function runCodexExec(input: {
|
|||
"-c",
|
||||
`model_reasoning_effort=${JSON.stringify(input.reasoningEffort)}`,
|
||||
...buildMcpConfigArguments(input.mcpServers),
|
||||
...buildImageArguments(input.imagePaths ?? []),
|
||||
"--json",
|
||||
"--skip-git-repo-check",
|
||||
"-s",
|
||||
|
|
@ -226,6 +228,19 @@ export async function runCodexExec(input: {
|
|||
});
|
||||
}
|
||||
|
||||
function buildImageArguments(imagePaths: string[]): string[] {
|
||||
const args: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const imagePath of imagePaths) {
|
||||
if (seen.has(imagePath)) {
|
||||
continue;
|
||||
}
|
||||
seen.add(imagePath);
|
||||
args.push("--image", imagePath);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
export function normalizeDiscordReply(stdout: string): NormalizedDiscordReply {
|
||||
const messages: string[] = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ export function buildRequestPayload(
|
|||
stylePack: request.contextBundle.stylePack,
|
||||
voidSelfState: request.contextBundle.voidSelfState,
|
||||
recentMessages: request.contextBundle.recentMessages,
|
||||
imageAttachments: request.contextBundle.imageAttachments ?? [],
|
||||
retrieval: request.contextBundle.retrieval,
|
||||
options: request.options ?? {},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue