ReMe/reme/enumeration/chunk_enum.py
jinliyl 2a307f80a8
refactor(agent)!: unify lossless streaming and collected replies (#713)
* refactor(agent)!: unify lossless streaming and collected replies

* fix(agent): complete reply consumer migration

* fix(agent): migrate Home consumers to canonical replies
2026-11-05 16:04:27 +08:00

53 lines
1.6 KiB
Python

"""Chunk enumeration module."""
from enum import Enum
class ChunkEnum(str, Enum):
"""Enumeration of possible chunk categories for stream processing.
Covers AgentScope, Claude Code SDK, and Codex streaming protocols:
AgentScope events -> ChunkEnum mapping:
ReplyStartEvent -> REPLY_START
ReplyEndEvent -> REPLY_END
TextBlockStart/Delta/End -> CONTENT
ThinkingBlockStart/Delta/End -> THINK
DataBlockStart/Delta/End -> DATA
ToolCallStart/Delta/End -> TOOL_CALL
ToolResultStart/TextDelta/DataDelta/End -> TOOL_RESULT
ModelCallEndEvent -> USAGE
ExceedMaxItersEvent -> ERROR
Claude Code SDK events -> ChunkEnum mapping:
message_start/stop -> DATA (model-message boundaries)
message_delta -> USAGE
content_block_start/delta/stop (text) -> CONTENT
content_block_start/delta/stop (thinking) -> THINK
content_block_start/delta/stop (tool_use) -> TOOL_CALL
ToolResultBlock -> TOOL_RESULT
ResultMessage -> USAGE + REPLY_END
ResultMessage.is_error -> ERROR
Codex app-server notifications follow the same lifecycle categories;
thread ids are session ids and item ids correlate tool calls/results.
"""
# Lifecycle markers
REPLY_START = "reply_start"
REPLY_END = "reply_end"
# Content types
THINK = "think"
CONTENT = "content"
DATA = "data"
# Tool interaction
TOOL_CALL = "tool_call"
TOOL_RESULT = "tool_result"
APPROVAL = "approval"
# Metadata & terminal
USAGE = "usage"
ERROR = "error"
DONE = "done"