refactor(runtime): restructure runs module with new execution architecture

Major refactoring of deerflow/runtime/:
- runs/callbacks/ - new callback system (builder, events, title, tokens)
- runs/internal/ - execution internals (executor, supervisor, stream_logic, registry)
- runs/internal/execution/ - execution artifacts and events handling
- runs/facade.py - high-level run facade
- runs/observer.py - run observation protocol
- runs/types.py - type definitions
- runs/store/ - simplified store interfaces (create, delete, query, event)

Refactor stream_bridge/:
- Replace old providers with contract.py and exceptions.py
- Remove async_provider.py, base.py, memory.py

Add documentation:
- README.md and README_zh.md for runtime module

Remove deprecated:
- manager.py moved to internal/
- worker.py, schemas.py
- user_context.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rayhpeng
2026-04-22 11:28:01 +08:00
parent 39a575617b
commit 9d0a42c1fb
43 changed files with 3928 additions and 1192 deletions
@@ -5,42 +5,98 @@ Re-exports the public API of :mod:`~deerflow.runtime.runs` and
directly from ``deerflow.runtime``.
"""
from .checkpointer import checkpointer_context, get_checkpointer, make_checkpointer, reset_checkpointer
from .runs import ConflictError, DisconnectMode, RunContext, RunManager, RunRecord, RunStatus, UnsupportedStrategyError, run_agent
from .runs import (
CallbackObserver,
CompositeObserver,
CancelAction,
LifecycleEventType,
NullObserver,
ObserverBinding,
ObserverLike,
RunEventCallback,
RunCreateStore,
RunDeleteStore,
RunEventStore,
RunManager,
RunRecord,
RunQueryStore,
RunScope,
RunSpec,
RunLifecycleEvent,
RunObserver,
RunResult,
RunsFacade,
RunStatus,
WaitResult,
ensure_observer,
)
from .actor_context import (
AUTO,
ActorContext,
DEFAULT_USER_ID,
bind_actor_context,
get_actor_context,
get_effective_user_id,
require_actor_context,
reset_actor_context,
resolve_user_id,
)
from .serialization import serialize, serialize_channel_values, serialize_lc_object, serialize_messages_tuple
from .store import get_store, make_store, reset_store, store_context
from .stream_bridge import END_SENTINEL, HEARTBEAT_SENTINEL, MemoryStreamBridge, StreamBridge, StreamEvent, make_stream_bridge
from .stream_bridge import (
CANCELLED_SENTINEL,
END_SENTINEL,
HEARTBEAT_SENTINEL,
StreamBridge,
StreamEvent,
StreamStatus,
)
__all__ = [
# checkpointer
"checkpointer_context",
"get_checkpointer",
"make_checkpointer",
"reset_checkpointer",
# runs
"ConflictError",
"DisconnectMode",
"RunContext",
# runs - hooks
"RunsFacade",
"RunCreateStore",
"RunDeleteStore",
"RunEventStore",
"RunManager",
"RunQueryStore",
"CallbackObserver",
"CompositeObserver",
"ensure_observer",
"LifecycleEventType",
"NullObserver",
"ObserverBinding",
"ObserverLike",
"RunEventCallback",
"RunLifecycleEvent",
"RunObserver",
"RunResult",
# runs - types
"CancelAction",
"RunScope",
"RunSpec",
"WaitResult",
"RunRecord",
"RunStatus",
"UnsupportedStrategyError",
"run_agent",
# actor context
"AUTO",
"ActorContext",
"DEFAULT_USER_ID",
"bind_actor_context",
"get_actor_context",
"get_effective_user_id",
"require_actor_context",
"reset_actor_context",
"resolve_user_id",
# serialization
"serialize",
"serialize_channel_values",
"serialize_lc_object",
"serialize_messages_tuple",
# store
"get_store",
"make_store",
"reset_store",
"store_context",
# stream_bridge
"CANCELLED_SENTINEL",
"END_SENTINEL",
"HEARTBEAT_SENTINEL",
"MemoryStreamBridge",
"StreamBridge",
"StreamEvent",
"make_stream_bridge",
"StreamStatus",
]