* Merge new workflow state into existing diff * Used for cumulative updates within the same message
(jsonContent: string, diffAnalysis?: DiffAnalysis)
| 688 | * Used for cumulative updates within the same message |
| 689 | */ |
| 690 | async mergeDiff(jsonContent: string, diffAnalysis?: DiffAnalysis): Promise<DiffResult> { |
| 691 | try { |
| 692 | logger.info('Merging diff from workflow state') |
| 693 | |
| 694 | // If no existing diff, create a new one |
| 695 | if (!this.currentDiff) { |
| 696 | logger.info('No existing diff, creating new diff') |
| 697 | return this.createDiff(jsonContent, diffAnalysis) |
| 698 | } |
| 699 | |
| 700 | const proposedState = parseWorkflowStateJson(jsonContent) |
| 701 | const result = await this.createDiffFromWorkflowState( |
| 702 | proposedState, |
| 703 | diffAnalysis, |
| 704 | this.currentDiff.proposedState |
| 705 | ) |
| 706 | |
| 707 | if (result.success && result.diff) { |
| 708 | logger.info('Diff merged successfully', { |
| 709 | totalBlocksCount: Object.keys(result.diff.proposedState.blocks).length, |
| 710 | totalEdgesCount: result.diff.proposedState.edges.length, |
| 711 | }) |
| 712 | } |
| 713 | |
| 714 | return result |
| 715 | } catch (error) { |
| 716 | logger.error('Failed to merge diff:', error) |
| 717 | return { |
| 718 | success: false, |
| 719 | errors: [getErrorMessage(error, 'Failed to merge diff')], |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | /** |
| 725 | * Get the current diff |
nothing calls this directly
no test coverage detected