qw_agent: bash shell (not cmd), SSE streaming in serve mode, docs

This commit is contained in:
ENI
2026-11-21 00:24:17 +02:00
parent 029931fb73
commit 3fde9c5635
2 changed files with 80 additions and 6 deletions
+13 -1
View File
@@ -27,7 +27,7 @@ So the desktop harness cannot be repointed at an arbitrary endpoint.
| `fs_list` | directory listing with sizes |
| `fs_glob` | find files by glob (`**/*.py`) |
| `fs_grep` | regex search inside files, `file:line:text` |
| `shell` | run any command on the host (git-bash), returns exit/stdout/stderr |
| `shell` | run any command on the host in **git-bash** (auto-detected; `QW_SHELL_BIN` overrides), returns exit/stdout/stderr/shell |
| `http_get` | fetch a URL, status + first 20k chars |
| `todo_write` | keep a plan checklist |
| `task_done` | finish and return the final answer |
@@ -50,6 +50,8 @@ curl -s localhost:48970/v1/chat/completions -H 'Content-Type: application/json'
Backends: `--provider qw` (qwenwork shim, `http://127.0.0.1:48981/v1`, `qw-flash`),
`--provider router` (local DashScope rotator, `http://127.0.0.1:16432/v1`),
`--provider any --base ... --model ... --key ...` for anything OpenAI-compatible.
`serve` supports `"stream": true` (SSE chunks + `x_qw_tools` trailer + `[DONE]`), so any OpenAI SDK,
bot or gateway can call it unchanged.
Safety: destructive shell commands (`rm -rf`, `mkfs`, `diskpart`, ...) ask for confirmation unless
`--yolo`; `--root DIR` confines all file tools to one directory.
@@ -74,6 +76,16 @@ Serve proof:
GET /healthz {"ok": true, "model": "deepseek-v4.1-flash-1017", "tools": 10}
GET /v1/models {"data": [{"id": "deepseek-v4.1-flash-1017-agent"}]}
POST /v1/chat/completions {"choices": [...content "world qw"...], "x_qw_tools": ["fs_read","task_done"]}
POST +"stream":true 5 SSE chunks, content "1795213381" (real `date +%s` from the PC), [DONE]
```
Bash proof (`shell` goes through real git-bash, not cmd.exe) — 3 calls in parallel, 4.5 s, 2 turns:
```
[tool] shell {"command": "date +%s"} -> 1795213351 (exit 0)
[tool] shell {"command": "ls C:/Users/User/tmp/qwrepo | wc -l"} -> 12 (exit 0)
[tool] fs_grep {"path": "C:/Users/User/tmp/qwrepo", "pattern": "BASH = ", "glob": "*.py"}
-> qw_agent.py:240 "BASH = _find_bash()"
```
## Registration