utils/message_queue/message_queue_manager library
Message queue management, command grouping, memoization, and sequential execution utilities.
Ported from:
- messageQueueManager.ts (547 LOC) -- unified command queue
- groupToolUses.ts (182 LOC) -- tool use grouping for rendering
- memoize.ts (269 LOC) -- TTL / LRU memoization
- sequential.ts (56 LOC) -- sequential async execution wrapper
Classes
- BlocksCommandValue
- A structured content block command value.
- CommandOrigin
- Origin of a queued command.
- ContentBlock
- Simplified content block for queued command values.
- GroupedToolUseMessage
- A grouped tool use message for rendering.
- GroupingResult
- Result of the grouping operation.
- ImageContentBlock
- An image content block.
-
MemoizeWithLRU<
R> - Creates a memoized function with LRU (Least Recently Used) eviction.
-
MemoizeWithTTL<
R> - Creates a memoized function that returns cached values while refreshing in parallel (write-through cache pattern).
-
MemoizeWithTTLAsync<
R> - Creates a memoized async function with TTL (write-through cache pattern).
- MessageQueueController
- Unified command queue controller.
- NormalizedMessage
- A normalized message for tool use grouping.
- PastedContent
- Represents pasted content (images) attached to a queued command.
- PopAllEditableResult
- Result of popping all editable commands from the queue.
- QueuedCommand
- A command in the unified command queue.
- QueuedCommandValue
- The value of a queued command -- either a string or a list of content blocks.
- QueueOperationMessage
- A logged queue operation message.
-
Sequential<
R> - Creates a sequential execution wrapper for async functions to prevent race conditions.
- Signal
- A simple signal for notifying subscribers of changes.
- StringCommandValue
- A simple string command value.
- TextContentBlock
- A text content block.
- ToolResultContentBlock
- A tool result content block.
- ToolUseInfo
- Information about a tool use extracted from a normalized message.
Enums
- PromptInputMode
- The mode in which a prompt was submitted.
- QueueOperation
- Represents a queue operation for logging purposes.
- QueuePriority
- Priority determines dequeue order: now > next > later. Within the same priority, commands are processed FIFO.
Functions
-
applyGrouping(
{required List< NormalizedMessage> messages, required Set<String> toolsWithGrouping, bool verbose = false}) → GroupingResult - Groups tool uses by message.id (same API response) if the tool supports grouped rendering.
-
getToolUseInfo(
NormalizedMessage msg) → ToolUseInfo? - Extract tool use info from a normalized message.
-
isPromptInputModeEditable(
PromptInputMode mode) → bool - Whether this mode is editable (can be pulled into the input buffer).