"""编排器（C4 / ARCH §5.2）——写章图 + 审稿子图 + SSE 归一 + Postgres checkpointer。

- write 节点本体 `write_node`（被多章链 `chain` 复用；M1 单节点图 `build_write_graph` 已删）。
- M2：并行审子图（`build_review_graph`：START→各审并行→collect 落 `chapter_reviews`）+
  审稿 SSE（`section`/`conflict` 事件 + `normalize_review`）。
- accept（验收事务/`interrupt_before`）不在本图——属 T2.4（确定性代码读领域表，R3）。
"""

from __future__ import annotations

from ._protocols import GatewayRun
from .collect import (
    CHARACTERIZATION,
    CONTINUITY,
    FORESHADOW,
    PACE,
    STYLE,
    ReviewRecorder,
    collect_reviews,
    extract_characterization,
    extract_conflicts,
    extract_foreshadow_sug,
    extract_pace,
    extract_style,
)
from .generation_node import (
    build_brief_context,
    build_character_gen_context,
    build_continuation_context,
    build_outline_chapter_context,
    build_precheck_context,
    build_text_input_context,
    build_worldbuilder_context,
    precheck_generated_cards,
    run_character_gen,
    run_generator,
    run_worldbuilder,
)
from .graph import (
    COLLECT_NODE,
    REVIEW_SPECS,
    WRITE_NODE,
    build_review_graph,
    setup_checkpointer,
)
from .outline_node import build_outline_request, run_outline
from .review_node import (
    REVIEW_INCOMPLETE,
    REVIEW_OK,
    BoundReviewNode,
    build_review_context,
    build_review_request,
    make_review_node,
    run_review,
)
from .sse import (
    EVENT_CHARACTERIZATION,
    EVENT_CONFLICT,
    EVENT_DONE,
    EVENT_ERROR,
    EVENT_FORESHADOW,
    EVENT_PACE,
    EVENT_SECTION,
    EVENT_STYLE,
    EVENT_TOKEN,
    SECTION_DONE,
    SECTION_INCOMPLETE,
    SECTION_STARTED,
    SseEvent,
    characterization_event,
    conflict_event,
    done_event,
    error_event,
    foreshadow_event,
    normalize_deltas,
    normalize_review,
    pace_event,
    section_event,
    style_event,
    token_event,
)
from .state import ChapterState, merge_reviews
from .style_extract_node import build_style_extract_request, run_style_extraction
from .write_node import GatewayStream, build_write_request, stream_chapter_draft, write_node

__all__ = [
    "CHARACTERIZATION",
    "COLLECT_NODE",
    "CONTINUITY",
    "EVENT_CHARACTERIZATION",
    "EVENT_CONFLICT",
    "EVENT_DONE",
    "EVENT_ERROR",
    "EVENT_FORESHADOW",
    "EVENT_PACE",
    "EVENT_SECTION",
    "EVENT_STYLE",
    "EVENT_TOKEN",
    "FORESHADOW",
    "PACE",
    "REVIEW_INCOMPLETE",
    "REVIEW_OK",
    "REVIEW_SPECS",
    "SECTION_DONE",
    "SECTION_INCOMPLETE",
    "SECTION_STARTED",
    "STYLE",
    "WRITE_NODE",
    "BoundReviewNode",
    "ChapterState",
    "GatewayRun",
    "GatewayStream",
    "ReviewRecorder",
    "SseEvent",
    "build_brief_context",
    "build_character_gen_context",
    "build_continuation_context",
    "build_outline_chapter_context",
    "build_outline_request",
    "build_precheck_context",
    "build_review_context",
    "build_review_graph",
    "build_review_request",
    "build_style_extract_request",
    "build_text_input_context",
    "build_worldbuilder_context",
    "build_write_request",
    "characterization_event",
    "collect_reviews",
    "conflict_event",
    "done_event",
    "error_event",
    "extract_characterization",
    "extract_conflicts",
    "extract_foreshadow_sug",
    "extract_pace",
    "extract_style",
    "foreshadow_event",
    "make_review_node",
    "merge_reviews",
    "normalize_deltas",
    "normalize_review",
    "pace_event",
    "precheck_generated_cards",
    "run_character_gen",
    "run_generator",
    "run_outline",
    "run_review",
    "run_style_extraction",
    "run_worldbuilder",
    "section_event",
    "setup_checkpointer",
    "stream_chapter_draft",
    "style_event",
    "token_event",
    "write_node",
]
