mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-30 00:47:36 +00:00
* refactor(agent)!: unify lossless streaming and collected replies * fix(agent): complete reply consumer migration * fix(agent): migrate Home consumers to canonical replies
53 lines
1.6 KiB
Python
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"
|