from __future__ import annotations

from dataclasses import dataclass
from typing import Awaitable, Callable, Mapping, Protocol

from loushang.coding.diagnostics import DiagnosticsService

ToolEventSink = Callable[[Mapping[str, object]], Awaitable[None] | None]


@dataclass(frozen=True)
class ToolContext:
    tool_call_id: str
    cwd: str | None = None
    diagnostics: DiagnosticsService | None = None
    signal: object | None = None
    model: object | None = None
    event_sink: ToolEventSink | None = None


class ToolContextProvider(Protocol):
    def __call__(self, *, tool_call_id: str) -> ToolContext: ...
