<!-- source-hash: 118d3a4cacf89174498282067448e4bf -->
Defines TypeScript types for message processing pipeline operations, including chunk parsing, accumulator state management, stream control, and buffer management for AI chat message flows.

## Key Components

| Export | Type | Description |
|--------|------|-------------|
| `ParsedChunkAction` | Union type | Discriminated union of all possible chunk parse results (text, tool execution, approvals, metadata, etc.) |
| `AccumulatorState` | Interface | Stateful container tracking message segments, pending approvals, and executing tools during stream processing |
| `PendingApproval` | Interface | Represents an approval request awaiting user action (command, explanation, type) |
| `MessageProcessingOptions` | Interface | Configuration for assistant rendering, approval callbacks, chat filtering, and batch approval UI |
| `ChunkProcessor` | Interface | Contract for processing raw `ChunkData` into `ParsedChunkAction` results |
| `ChunkProcessorOptions` | Interface | Lifecycle callbacks for chunk processing events |
| `MessageTransformer` | Interface | Contract for transforming raw inputs into `ProcessedMessage` objects |
| `StreamProcessor` | Interface | Full lifecycle control (start/stop/pause/resume/reset) for stream consumers |
| `StreamState` | Interface | Snapshot of stream health: active status, buffered chunks, error log, and last activity timestamp |
| `BufferManager` | Interface | CRUD-style contract for managing `ChunkData` buffers |
| `BufferOptions` | Interface | Configuration for buffer capacity, flush intervals, and overflow handling callbacks |

## Usage Example

```typescript
import type {
  ParsedChunkAction,
  AccumulatorState,
  MessageProcessingOptions,
  StreamState
} from './processing.types'

// Handling a parsed chunk action via discriminated union
function handleChunkAction(action: ParsedChunkAction): void {
  switch (action.action) {
    case 'text':
      console.log('Received text:', action.text)
      break
    case 'tool_execution':
      console.log('Tool executing:', action.segment)
      break
    case 'approval_batch':
      console.log('Batch approval request:', action.requestId, action.toolCalls)
      break
    case 'error':
      console.error('Processing error:', action.error, action.details)
      break
  }
}

// Initializing accumulator state
const state: AccumulatorState = {
  segments: [],
  pendingApprovals: new Map(),
  executingTools: new Map()
}

// Configuring message processing
const options: MessageProcessingOptions = {
  assistantName: 'Mingo',
  assistantType: 'mingo',
  batchApprovalsEnabled: true,
  displayApprovalTypes: ['shell', 'file'],
  onApprove: async (requestId) => {
    await submitApproval(requestId)
  },
  onReject: (requestId) => {
    logRejection(requestId)
  }
}
```