feat: add OpenAI/Anthropic tools support with tool emulation

- Parse tools/tool_choice from OpenAI and Anthropic requests
- Inject tool definitions into system prompt via toolemulation
- Parse action blocks (```json action) from model responses
- Retry logic for forced tool_choice (any/required)
- Return proper tool_calls / tool_use in responses
- Support streaming tools via collect-and-replay pattern
- Add tool history projection (assistant tool_calls + tool results)
- Model ID normalization: use official names (Qwen3.6-Plus, etc.)
- Fix resolveSessionMode to use Fresh mode when tools present
This commit is contained in:
lutc5
2026-04-25 13:37:58 +08:00
parent c49b4b63e7
commit 74bbd8e6d2
13 changed files with 648 additions and 115 deletions

View File

@@ -14,6 +14,8 @@ Current scope:
- one request at a time
- supports Windows named-pipe transport and local websocket transport
- directly uses Lingma IPC, not DOM/CDP
- OpenAI-compatible `tools` / `tool_choice` support (tool emulation via prompt engineering)
- Anthropic-compatible `tools` / `tool_choice` support
## Run
@@ -69,6 +71,41 @@ Recommended layout:
}
```
## macOS / Linux
This project also works on macOS and Linux via **WebSocket transport**. The Windows named-pipe transport is automatically skipped on non-Windows platforms.
### Run on macOS
```bash
cd ~/OpenSources/lingma-ipc-proxy
go run ./cmd/lingma-ipc-proxy --transport websocket --port 8095
# Or use auto-detect (will discover websocket port from Lingma's shared client cache)
go run ./cmd/lingma-ipc-proxy --port 8095
```
### Build on macOS / Linux
```bash
cd ~/OpenSources/lingma-ipc-proxy
go build -o ./dist/lingma-ipc-proxy ./cmd/lingma-ipc-proxy
```
### macOS Config Example
```json
{
"host": "127.0.0.1",
"port": 8095,
"transport": "websocket",
"mode": "agent",
"shell_type": "zsh",
"session_mode": "auto",
"timeout": 120
}
```
## Build
Build a Windows executable: