- harness/es.py: append-only event store + проекции (образец — кооп-портал) - harness/levels.py: уровни 1с/1м/1ч/1д, контекст ∝ масштабу - harness/scheduler.py: уровневые потоки, идемпотентные тики, absorbed-стабы - harness/isolated_runner.py + _llm_worker.py: LLM-тик в сабпроцессе (глобальный asyncio-рантайм Strands не переживает 2+ create_harness) - cli.py: init/task/tasks/status/events + requeue (написан самим минутным агентом) - 9router: отдельный ключ sk-simbiot, модель auto (glm-5.3 первым)
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Stream protocols for MCP transports.
|
|
|
|
These are general-purpose protocols satisfied by both ``MemoryObjectSendStream``/
|
|
``MemoryObjectReceiveStream`` and the context-aware wrappers in ``_context_streams``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import TracebackType
|
|
from typing import Protocol, TypeVar
|
|
|
|
from typing_extensions import Self
|
|
|
|
T_co = TypeVar("T_co", covariant=True)
|
|
T_contra = TypeVar("T_contra", contravariant=True)
|
|
|
|
|
|
class ReadStream(Protocol[T_co]):
|
|
"""Protocol for reading items from a stream.
|
|
|
|
Consumers that need the sender's context should use
|
|
``getattr(stream, 'last_context', None)``.
|
|
"""
|
|
|
|
async def receive(self) -> T_co: ...
|
|
async def aclose(self) -> None: ...
|
|
def __aiter__(self) -> ReadStream[T_co]: ...
|
|
async def __anext__(self) -> T_co: ...
|
|
async def __aenter__(self) -> Self: ...
|
|
async def __aexit__(
|
|
self,
|
|
exc_type: type[BaseException] | None,
|
|
exc_val: BaseException | None,
|
|
exc_tb: TracebackType | None,
|
|
) -> bool | None: ...
|
|
|
|
|
|
class WriteStream(Protocol[T_contra]):
|
|
"""Protocol for writing items to a stream."""
|
|
|
|
async def send(self, item: T_contra, /) -> None: ...
|
|
async def aclose(self) -> None: ...
|
|
async def __aenter__(self) -> Self: ...
|
|
async def __aexit__(
|
|
self,
|
|
exc_type: type[BaseException] | None,
|
|
exc_val: BaseException | None,
|
|
exc_tb: TracebackType | None,
|
|
) -> bool | None: ...
|