feat: update Makelore modules and conversations
This commit is contained in:
@@ -214,6 +214,51 @@ export function extractTextSegments(message: RawMessage | unknown): string[] {
|
||||
.filter((segment) => segment.length > 0);
|
||||
}
|
||||
|
||||
export interface CodexAssistantTextProjection {
|
||||
finalText: string;
|
||||
processSegments: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Split assistant text around native executable blocks. Text before or between
|
||||
* tool calls is execution narration; trailing text after the last executable
|
||||
* block is the answer shown in the primary transcript column.
|
||||
*/
|
||||
export function projectAssistantTextForCodex(
|
||||
message: RawMessage | unknown,
|
||||
): CodexAssistantTextProjection {
|
||||
if (!message || typeof message !== 'object') return { finalText: '', processSegments: [] };
|
||||
const record = message as Record<string, unknown>;
|
||||
if (record.role !== 'assistant' || !Array.isArray(record.content)) {
|
||||
return { finalText: extractText(message), processSegments: [] };
|
||||
}
|
||||
|
||||
const blocks = record.content as ContentBlock[];
|
||||
const executableIndex = blocks.reduce((latest, block, index) => (
|
||||
block.type === 'tool_use' || block.type === 'toolCall'
|
||||
? index
|
||||
: latest
|
||||
), -1);
|
||||
if (executableIndex < 0) {
|
||||
return { finalText: extractText(message), processSegments: [] };
|
||||
}
|
||||
|
||||
const textBlockMessage = (selected: ContentBlock[]): RawMessage => ({
|
||||
...message as RawMessage,
|
||||
content: selected,
|
||||
});
|
||||
const processBlocks = blocks
|
||||
.slice(0, executableIndex + 1)
|
||||
.filter((block) => block.type === 'text');
|
||||
const finalBlocks = blocks
|
||||
.slice(executableIndex + 1)
|
||||
.filter((block) => block.type === 'text');
|
||||
return {
|
||||
finalText: extractText(textBlockMessage(finalBlocks)),
|
||||
processSegments: extractTextSegments(textBlockMessage(processBlocks)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract thinking/reasoning content from a message.
|
||||
* Returns null if no thinking content found.
|
||||
|
||||
Reference in New Issue
Block a user