MCPcopy
hub / github.com/opactorai/Claudable / streamAssistantDraft

Function streamAssistantDraft

lib/services/cli/codex.ts:603–635  ·  view source on GitHub ↗
(force = false)

Source from the content-addressed store, hash-verified

601 };
602
603 const streamAssistantDraft = (force = false) => {
604 const combined = buildAssistantPayload();
605 if (!combined) {
606 return;
607 }
608 if (!force && combined === lastStreamedAssistantPayload) {
609 return;
610 }
611 const id = assistantMessageId ?? (assistantMessageId = randomUUID());
612
613 // Enhanced duplicate prevention
614 if (streamedMessageIds.has(id) && !force) {
615 console.debug(`[CodexService] Assistant message ${id} already streamed, skipping`);
616 return;
617 }
618
619 const realtime = createRealtimeMessage({
620 id,
621 projectId,
622 role: 'assistant',
623 messageType: 'chat',
624 content: combined,
625 metadata: { cli_type: 'codex' },
626 cliSource: 'codex',
627 requestId,
628 isStreaming: true,
629 isFinal: false,
630 });
631 streamManager.publish(projectId, { type: 'message', data: realtime });
632 streamedMessageIds.add(id);
633 lastStreamedAssistantPayload = combined;
634 console.debug(`[CodexService] Streamed assistant message: ${id} (length: ${combined.length})`);
635 };
636
637 const resetAssistantBuffers = () => {
638 agentBuffer = '';

Callers 2

handleItemCompletedFunction · 0.85
handleItemDeltaFunction · 0.85

Calls 3

createRealtimeMessageFunction · 0.90
buildAssistantPayloadFunction · 0.85
publishMethod · 0.80

Tested by

no test coverage detected