Spaces:
Sleeping
Sleeping
File size: 2,156 Bytes
2415446 a1bab2d 2415446 61bb677 2415446 a1bab2d 2415446 61bb677 2415446 7449374 61bb677 2415446 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | """Typed capabilities consumed by application use cases."""
from __future__ import annotations
from collections.abc import AsyncIterator, Callable
from dataclasses import dataclass
from typing import Protocol
from free_claude_code.config.settings import Settings
from free_claude_code.core.anthropic import MessagesRequest
from free_claude_code.core.reasoning import ReasoningPolicy
from .model_metadata import ProviderModelInfo
class ProviderPort(Protocol):
"""Minimal provider capability required to execute one request."""
def preflight_stream(
self,
request: MessagesRequest,
*,
reasoning: ReasoningPolicy,
) -> None: ...
def stream_response(
self,
request: MessagesRequest,
*,
input_tokens: int,
request_id: str,
response_model: str,
reasoning: ReasoningPolicy,
) -> AsyncIterator[str]: ...
ProviderResolver = Callable[[str], ProviderPort]
class RequestRuntimeLease(Protocol):
"""One provider generation retained for a complete API response."""
@property
def generation_id(self) -> int: ...
@property
def settings(self) -> Settings: ...
def is_provider_cached(self, provider_id: str) -> bool: ...
def resolve_provider(self, provider_id: str) -> ProviderPort: ...
async def release(self) -> None: ...
class RequestRuntimePort(Protocol):
"""Provider generation and model metadata required by application requests."""
async def acquire(self) -> RequestRuntimeLease: ...
def current_settings(self) -> Settings: ...
def cached_model_supports_thinking(
self, provider_id: str, model_id: str
) -> bool | None: ...
def cached_prefixed_model_infos(self) -> tuple[ProviderModelInfo, ...]: ...
@dataclass(frozen=True, slots=True)
class StopResult:
"""Implementation-neutral result retaining the existing ``/stop`` variants."""
cancelled_count: int | None = None
source: str | None = None
class TaskController(Protocol):
"""Stop managed work without exposing messaging or CLI resources."""
async def stop_all(self) -> StopResult | None: ...
|