MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / buildCodexTurnInput

Function buildCodexTurnInput

src/providers/codex/plugin.ts:851–880  ·  view source on GitHub ↗
(event: InboundTextEvent, inputText: string)

Source from the content-addressed store, hash-verified

849}
850
851function buildCodexTurnInput(event: InboundTextEvent, inputText: string): CodexTurnInput[] {
852 const attachments = Array.isArray(event.attachments) ? event.attachments : [];
853 const normalizedInputText = String(inputText ?? '').trim();
854 if (attachments.length === 0) {
855 return [{
856 type: 'text',
857 text: normalizedInputText,
858 text_elements: [],
859 }];
860 }
861
862 const textPrompt = shouldReuseAttachmentPrompt(normalizedInputText)
863 ? normalizedInputText
864 : buildAttachmentPrompt(normalizedInputText, attachments);
865 const input: CodexTurnInput[] = [{
866 type: 'text',
867 text: textPrompt,
868 text_elements: [],
869 }];
870 for (const attachment of attachments) {
871 if (attachment.kind !== 'image') {
872 continue;
873 }
874 input.push({
875 type: 'localImage',
876 path: attachment.localPath,
877 });
878 }
879 return input;
880}
881
882function shouldReuseAttachmentPrompt(inputText: string): boolean {
883 return /we(chat|ixin) attachments:/iu.test(inputText);

Callers 1

startTurnMethod · 0.70

Calls 2

buildAttachmentPromptFunction · 0.70

Tested by

no test coverage detected