* Process a turn_diff message and check if the unified_diff has changed
(unifiedDiff: string)
| 39 | * Process a turn_diff message and check if the unified_diff has changed |
| 40 | */ |
| 41 | processDiff(unifiedDiff: string): void { |
| 42 | // Check if the diff has changed from the previous value |
| 43 | if (this.previousDiff !== unifiedDiff) { |
| 44 | logger.debug('[DiffProcessor] Unified diff changed, sending CodexDiff tool call'); |
| 45 | |
| 46 | // Generate a unique call ID for this diff |
| 47 | const callId = randomUUID(); |
| 48 | |
| 49 | // Send tool call for the diff change |
| 50 | const toolCall: DiffToolCall = { |
| 51 | type: 'tool-call', |
| 52 | name: 'CodexDiff', |
| 53 | callId: callId, |
| 54 | input: { |
| 55 | unified_diff: unifiedDiff |
| 56 | }, |
| 57 | id: randomUUID() |
| 58 | }; |
| 59 | |
| 60 | this.onMessage?.(toolCall); |
| 61 | |
| 62 | // Immediately send the tool result to mark it as completed |
| 63 | const toolResult: DiffToolResult = { |
| 64 | type: 'tool-call-result', |
| 65 | callId: callId, |
| 66 | output: { |
| 67 | status: 'completed' |
| 68 | }, |
| 69 | id: randomUUID() |
| 70 | }; |
| 71 | |
| 72 | this.onMessage?.(toolResult); |
| 73 | } |
| 74 | |
| 75 | // Update the stored diff value |
| 76 | this.previousDiff = unifiedDiff; |
| 77 | logger.debug('[DiffProcessor] Updated stored diff'); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Reset the processor state (called on task_complete or turn_aborted) |