feat: add emulated tool-calling bridge for Lingma

Add a proxy-side tool emulation layer so Lingma requests can surface stable OpenAI tool_calls and Anthropic tool_use blocks even when upstream tool events are missing or inconsistent.

Constraint: Keep native Lingma tool event bridging as the first path and layer emulation as a fallback

Rejected: Depend exclusively on Lingma native tool/invoke events | tool visibility remains inconsistent across models and transports

Confidence: high

Scope-risk: moderate
This commit is contained in:
mmc
2026-05-07 18:10:01 +08:00
parent 5911e4322e
commit 94a8025ae5
11 changed files with 1808 additions and 4 deletions

View File

@@ -419,6 +419,17 @@ class LspWsRpcClient:
method = msg.get("method")
params = msg.get("params") or {}
if method and (
method.startswith("tool/")
or method.startswith("mcp/")
or method in {"chat/answer", "chat/finish"}
):
logger.info(
"lingma server message method=%s params=%s",
method,
params,
)
if method == "chat/answer":
req_id = params.get("requestId")
stream = self._chat_streams.get(req_id)