qwen-audio-agent 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PRIVACY.md +5 -0
- package/README.md +65 -5
- package/README_EN.md +68 -7
- package/cli/bin/qwenaudio.mjs +21 -0
- package/cli/package.json +1 -1
- package/cli/src/gateway-service.mjs +4 -2
- package/cli/src/launcher.mjs +20 -0
- package/cli/src/runtime.mjs +88 -15
- package/docs/architecture.md +1 -1
- package/docs/configuration.md +42 -0
- package/package.json +2 -2
- package/server/package.json +2 -2
- package/server/src/agent/acp-process-client.mjs +27 -9
- package/server/src/agent/acp-session-registry.mjs +2 -1
- package/server/src/app/bootstrap.mjs +48 -2
- package/server/src/core/config.mjs +23 -19
- package/server/src/core/logger.mjs +16 -0
- package/server/src/index.mjs +45 -7
- package/server/src/process/managed-backend.mjs +15 -1
- package/server/src/task/task-manager.mjs +25 -0
- package/server/src/voice/active-voice-clients.mjs +7 -1
- package/server/src/voice/providers/dashscope.mjs +11 -3
- package/server/src/voice/providers/ga-protocol.mjs +114 -0
- package/server/src/voice/providers/openai-compatible-protocol.mjs +10 -0
- package/server/src/voice/providers/registry.mjs +67 -13
- package/server/src/voice/providers/s2s.mjs +140 -0
- package/server/src/voice/realtime-gateway.mjs +353 -96
- package/server/src/voice/realtime-provider.mjs +162 -16
- package/server/src/voice/response-context.mjs +37 -0
- package/server/src/voice/response-lifecycle.mjs +41 -0
- package/server/src/voice/turn-correlation.mjs +9 -3
- package/shared/gateway-instance-lock.mjs +184 -0
- package/shared/logger.mjs +301 -0
- package/shared/realtime-events.mjs +1 -0
- package/shared/realtime-provider-catalog.mjs +130 -0
- package/shared/runtime-environment.mjs +16 -0
- package/tui/package.json +1 -1
- package/tui/src/index.mjs +34 -5
- package/web/dist/assets/index-BVUqEVa4.js +38 -0
- package/web/dist/assets/index-DNCByEc_.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BuB0EFih.css +0 -1
- package/web/dist/assets/index-DfCChshH.js +0 -38
package/PRIVACY.md
CHANGED
|
@@ -21,6 +21,11 @@ qwen-audio-agent 是本地运行的语音前台,不包含内置遥测、广告
|
|
|
21
21
|
`~/.config/qwaudio/`。API Key 等凭据不应写入仓库、对话或用户档案。卸载应用不会
|
|
22
22
|
自动删除该目录,避免意外丢失用户数据。
|
|
23
23
|
|
|
24
|
+
运行日志默认保存在 `~/.config/qwaudio/logs/`,不会自动上传。日志系统会脱敏常见
|
|
25
|
+
凭据字段和 Bearer/API Key 文本,并且默认不记录音频、转写正文、模型回复正文、
|
|
26
|
+
任务目标或任务结果。诊断日志仍可能包含本机路径、所选 Agent/模型、Session/Task
|
|
27
|
+
标识和错误信息;分享日志前请再次检查,卸载应用也不会自动删除这些日志。
|
|
28
|
+
|
|
24
29
|
## 远程部署
|
|
25
30
|
|
|
26
31
|
Gateway 默认仅供本机使用。通过反向代理开放远程访问时,部署者负责启用 HTTPS、
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/qwen-audio-agent)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](LICENSE)
|
|
9
|
+
[](#交流与分享)
|
|
9
10
|
|
|
10
11
|
## Agent,始终在场
|
|
11
12
|
|
|
@@ -19,6 +20,12 @@
|
|
|
19
20
|
|
|
20
21
|
## News
|
|
21
22
|
|
|
23
|
+
- **2026-08-03 · [v1.3.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.3.0)**
|
|
24
|
+
🎙️ 新增 [🤗 speech-to-speech](https://github.com/huggingface/speech-to-speech) 前台接入,支持本地部署 VAD、STT、LLM 与 TTS 全链路。
|
|
25
|
+
- **2026-08-01 · [v1.2.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.2.0)**
|
|
26
|
+
⚡ 桌面版新增自动更新,优化启动速度与后台 Agent 检测。
|
|
27
|
+
- **2026-07-31 · [v1.1.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.1.0)**
|
|
28
|
+
🤝 新增 Kimi Code CLI 后台,原生 ACP 接入。
|
|
22
29
|
- **2026-07-30 · [v1.0.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.0.0)**
|
|
23
30
|
🚀 正式版发布,推出内置 Gateway 的 macOS 桌面版。
|
|
24
31
|
- **2026-07-28 · [v0.9.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v0.9.0)**
|
|
@@ -76,7 +83,8 @@ https://github.com/user-attachments/assets/42022655-36d1-46b2-9c26-ff0765284000
|
|
|
76
83
|
|
|
77
84
|
## 安装
|
|
78
85
|
|
|
79
|
-
需要 Node.js 22.22.2+ 或 24.15.0+、npm 10
|
|
86
|
+
需要 Node.js 22.22.2+ 或 24.15.0+、npm 10+。使用默认的 DashScope
|
|
87
|
+
实时语音前台时,还需要 DashScope API Key。
|
|
80
88
|
仓库提供 `.nvmrc` 和 `.node-version`;使用 nvm 时可直接运行 `nvm use`。
|
|
81
89
|
|
|
82
90
|
一键安装(推荐,从 npm 安装):
|
|
@@ -163,6 +171,55 @@ qwenaudio tui
|
|
|
163
171
|
qwenaudio webui
|
|
164
172
|
```
|
|
165
173
|
|
|
174
|
+
### 使用 Hugging Face speech-to-speech 前台
|
|
175
|
+
|
|
176
|
+
qwen-audio-agent 也可以连接用户自行运行的
|
|
177
|
+
[Hugging Face speech-to-speech](https://github.com/huggingface/speech-to-speech)。
|
|
178
|
+
它将 VAD、STT、LLM 和 TTS 组合成 OpenAI Realtime 兼容服务,整条语音链路既可以
|
|
179
|
+
完全运行在本地,也可以按需替换其中的模型或服务。
|
|
180
|
+
|
|
181
|
+
1. 安装 speech-to-speech:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
pip install "speech-to-speech[paraformer]"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
2. 启动全本地服务:
|
|
188
|
+
|
|
189
|
+
Linux / Windows(NVIDIA GPU):
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
speech-to-speech \
|
|
193
|
+
--stt paraformer \
|
|
194
|
+
--llm_backend transformers \
|
|
195
|
+
--device cuda
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Apple Silicon:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
speech-to-speech \
|
|
202
|
+
--stt paraformer \
|
|
203
|
+
--llm_backend mlx-lm \
|
|
204
|
+
--device mps
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
没有 NVIDIA GPU 时,也可以选择适合 CPU 的更小本地模型;还可以
|
|
208
|
+
将 LLM 指向本机运行的 vLLM / llama.cpp。服务默认运行在
|
|
209
|
+
`ws://127.0.0.1:8765/v1/realtime`。
|
|
210
|
+
|
|
211
|
+
3. 在 qwen-audio-agent 的 `config.env` 中设置:
|
|
212
|
+
|
|
213
|
+
```dotenv
|
|
214
|
+
QWEN_AUDIO_REALTIME_PROVIDER=speech-to-speech
|
|
215
|
+
SPEECH_TO_SPEECH_REALTIME_URL=ws://127.0.0.1:8765/v1/realtime
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
然后正常启动 `qwenaudio`。在全本地模式下无需云端 API Key。Gateway 只连接 Realtime
|
|
219
|
+
接口,不会修改 speech-to-speech 的 STT、LLM、TTS 或音色配置。
|
|
220
|
+
如果 Realtime 接口位于需要 Bearer 认证的代理后方,可设置
|
|
221
|
+
`SPEECH_TO_SPEECH_AUTH_TOKEN`。
|
|
222
|
+
|
|
166
223
|
### TUI 使用注意
|
|
167
224
|
|
|
168
225
|
| 平台 | 默认模式 | 打断方式 |
|
|
@@ -179,9 +236,10 @@ qwenaudio tui --audio-mode full
|
|
|
179
236
|
|
|
180
237
|
## macOS 桌面版
|
|
181
238
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
239
|
+
桌面版提供常驻桌面的语音悬浮球,并内置 Gateway,无需事先启动服务。同一用户配置
|
|
240
|
+
目录已有兼容的本地 Gateway 时会直接复用,否则由桌面版自动启动和管理。首次运行时,
|
|
241
|
+
应用会创建配置文件,并引导你在设置页填写 DashScope API Key、选择后台 Agent
|
|
242
|
+
(也可以使用仅前台模式)。
|
|
185
243
|
|
|
186
244
|
桌面版支持流光声波球和液态渐变球两种外观。下面分别展示它们在思考 / 呼吸状态
|
|
187
245
|
下的原始动态效果:
|
|
@@ -290,6 +348,7 @@ QWEN_AUDIO_AGENT_BACKEND_PERMISSION_MODE=full
|
|
|
290
348
|
- `USER.md`:称呼、所在地、偏好和常用项目
|
|
291
349
|
- `frontend-memory.json`:用户明确要求长期记住的信息
|
|
292
350
|
- `tasks.json`:任务结果和待通知状态
|
|
351
|
+
- `logs/`:经过凭据脱敏并自动轮转的本地运行日志
|
|
293
352
|
|
|
294
353
|
这些文件只保存在本机,不会写入源码仓库。可以直接编辑 `USER.md`,也可以在对话中
|
|
295
354
|
要求助理记住或忘记信息。
|
|
@@ -297,7 +356,8 @@ QWEN_AUDIO_AGENT_BACKEND_PERMISSION_MODE=full
|
|
|
297
356
|
## 使用注意事项
|
|
298
357
|
|
|
299
358
|
- 不要在用户档案或对话中保存密码、API Key、验证码和访问令牌。
|
|
300
|
-
- 麦克风音频与实时对话会发送到配置的
|
|
359
|
+
- 麦克风音频与实时对话会发送到配置的 Realtime 前台服务(DashScope 或
|
|
360
|
+
speech-to-speech)。
|
|
301
361
|
- 后台任务可能调用所选 Agent 的模型、工具、MCP 和外部服务。
|
|
302
362
|
- `full` 权限允许后台执行命令和修改文件,只应在可信项目中使用。
|
|
303
363
|
- Gateway 默认仅供本机访问;不要直接暴露到局域网或公网。
|
package/README_EN.md
CHANGED
|
@@ -25,6 +25,12 @@ tells you:
|
|
|
25
25
|
|
|
26
26
|
## News
|
|
27
27
|
|
|
28
|
+
- **2026-08-03 · [v1.3.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.3.0)**
|
|
29
|
+
🎙️ Adds a [🤗 speech-to-speech](https://github.com/huggingface/speech-to-speech) frontend for a locally deployed VAD–STT–LLM–TTS pipeline.
|
|
30
|
+
- **2026-08-01 · [v1.2.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.2.0)**
|
|
31
|
+
⚡ Desktop auto-update, faster startup, and smarter backend Agent detection.
|
|
32
|
+
- **2026-07-31 · [v1.1.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.1.0)**
|
|
33
|
+
🤝 Adds Kimi Code CLI backend with native ACP support.
|
|
28
34
|
- **2026-07-30 · [v1.0.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.0.0)**
|
|
29
35
|
🚀 First stable release with a macOS desktop app and integrated Gateway.
|
|
30
36
|
- **2026-07-28 · [v0.9.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v0.9.0)**
|
|
@@ -95,7 +101,8 @@ boundaries.
|
|
|
95
101
|
## Installation
|
|
96
102
|
|
|
97
103
|
You need Node.js 22.22.2+ or 24.15.0+, npm 10+, and a
|
|
98
|
-
DashScope API Key
|
|
104
|
+
DashScope API Key when using the default DashScope realtime frontend. The
|
|
105
|
+
repository includes `.nvmrc` and `.node-version`; if you
|
|
99
106
|
use nvm, run `nvm use`.
|
|
100
107
|
|
|
101
108
|
One-line install (recommended, from npm):
|
|
@@ -185,6 +192,57 @@ You can use the browser interface instead:
|
|
|
185
192
|
qwenaudio webui
|
|
186
193
|
```
|
|
187
194
|
|
|
195
|
+
### Use a Hugging Face speech-to-speech frontend
|
|
196
|
+
|
|
197
|
+
qwen-audio-agent can also connect to a user-managed
|
|
198
|
+
[Hugging Face speech-to-speech](https://github.com/huggingface/speech-to-speech)
|
|
199
|
+
server. It combines VAD, STT, LLM, and TTS behind an OpenAI Realtime-compatible
|
|
200
|
+
API. The entire voice pipeline can run locally, or you can replace individual
|
|
201
|
+
models and services as needed.
|
|
202
|
+
|
|
203
|
+
1. Install speech-to-speech:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pip install "speech-to-speech[paraformer]"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
2. Start a fully local service:
|
|
210
|
+
|
|
211
|
+
Linux / Windows with an NVIDIA GPU:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
speech-to-speech \
|
|
215
|
+
--stt paraformer \
|
|
216
|
+
--llm_backend transformers \
|
|
217
|
+
--device cuda
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Apple Silicon:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
speech-to-speech \
|
|
224
|
+
--stt paraformer \
|
|
225
|
+
--llm_backend mlx-lm \
|
|
226
|
+
--device mps
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Without an NVIDIA GPU, you can choose a smaller local model suitable for CPU
|
|
230
|
+
inference, or point the LLM backend at a local vLLM / llama.cpp server. The service listens on
|
|
231
|
+
`ws://127.0.0.1:8765/v1/realtime` by default.
|
|
232
|
+
|
|
233
|
+
3. Add the following to the qwen-audio-agent `config.env` file:
|
|
234
|
+
|
|
235
|
+
```dotenv
|
|
236
|
+
QWEN_AUDIO_REALTIME_PROVIDER=speech-to-speech
|
|
237
|
+
SPEECH_TO_SPEECH_REALTIME_URL=ws://127.0.0.1:8765/v1/realtime
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Then start `qwenaudio` as usual. Fully local mode requires no cloud API Key. The
|
|
241
|
+
Gateway only connects to the Realtime endpoint and does not alter the STT, LLM,
|
|
242
|
+
TTS, or voice configured in speech-to-speech. Set
|
|
243
|
+
`SPEECH_TO_SPEECH_AUTH_TOKEN` only when the Realtime endpoint is behind a proxy
|
|
244
|
+
that requires Bearer authentication.
|
|
245
|
+
|
|
188
246
|
### TUI Notes
|
|
189
247
|
|
|
190
248
|
| Platform | Default mode | How to interrupt |
|
|
@@ -203,10 +261,12 @@ qwenaudio tui --audio-mode full
|
|
|
203
261
|
|
|
204
262
|
## macOS Desktop App
|
|
205
263
|
|
|
206
|
-
The desktop app provides a persistent voice orb and
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
264
|
+
The desktop app provides a persistent voice orb and includes the Gateway, so no
|
|
265
|
+
service needs to be started in advance. It reuses a compatible local Gateway
|
|
266
|
+
already running for the same user configuration directory; otherwise, it
|
|
267
|
+
starts and manages one automatically. On first launch, the app creates its
|
|
268
|
+
configuration file and guides you to enter a DashScope API Key and choose a
|
|
269
|
+
backend Agent (or frontend-only mode) in Settings.
|
|
210
270
|
|
|
211
271
|
The desktop app includes a streaming wave orb and a liquid gradient orb. Their
|
|
212
272
|
original animated thinking / breathing states are shown below:
|
|
@@ -328,6 +388,7 @@ User data is stored in `~/.config/qwaudio/`:
|
|
|
328
388
|
- `frontend-memory.json`: information you explicitly ask the assistant to
|
|
329
389
|
remember long term
|
|
330
390
|
- `tasks.json`: task results and pending notification state
|
|
391
|
+
- `logs/`: credential-redacted, automatically rotated local runtime logs
|
|
331
392
|
|
|
332
393
|
These files remain on your computer and are never written to the source
|
|
333
394
|
repository. You can edit `USER.md` directly or ask the assistant to remember or
|
|
@@ -337,8 +398,8 @@ forget information during a conversation.
|
|
|
337
398
|
|
|
338
399
|
- Do not store passwords, API Keys, verification codes, or access tokens in
|
|
339
400
|
your user profile or conversations.
|
|
340
|
-
- Microphone audio and realtime conversations are sent to the configured
|
|
341
|
-
|
|
401
|
+
- Microphone audio and realtime conversations are sent to the configured
|
|
402
|
+
Realtime frontend (DashScope or speech-to-speech).
|
|
342
403
|
- Backend tasks may call models, tools, MCP servers, and external services
|
|
343
404
|
configured for the selected Agent.
|
|
344
405
|
- `full` permission allows command execution and file changes. Use it only in
|
package/cli/bin/qwenaudio.mjs
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { main } from '../src/launcher.mjs'
|
|
4
|
+
import { createLogger } from '../../shared/logger.mjs'
|
|
5
|
+
|
|
6
|
+
const logger = createLogger({
|
|
7
|
+
component: 'cli',
|
|
8
|
+
fileName: 'cli.log',
|
|
9
|
+
consoleEnabled: false,
|
|
10
|
+
})
|
|
11
|
+
const startedAt = Date.now()
|
|
12
|
+
logger.info('cli.started', {
|
|
13
|
+
command: process.argv[2] || 'gateway',
|
|
14
|
+
})
|
|
4
15
|
|
|
5
16
|
main(process.argv.slice(2)).then(code => {
|
|
6
17
|
if (Number.isInteger(code)) process.exitCode = code
|
|
18
|
+
logger.info('cli.completed', {
|
|
19
|
+
command: process.argv[2] || 'gateway',
|
|
20
|
+
exitCode: Number.isInteger(code) ? code : 0,
|
|
21
|
+
durationMs: Date.now() - startedAt,
|
|
22
|
+
})
|
|
7
23
|
}).catch(error => {
|
|
24
|
+
logger.error('cli.failed', {
|
|
25
|
+
command: process.argv[2] || 'gateway',
|
|
26
|
+
durationMs: Date.now() - startedAt,
|
|
27
|
+
error,
|
|
28
|
+
})
|
|
8
29
|
process.stderr.write(`qwenaudio: ${error.message}\n`)
|
|
9
30
|
process.exitCode = 1
|
|
10
31
|
})
|
package/cli/package.json
CHANGED
|
@@ -61,6 +61,8 @@ export function gatewayServiceDefinition({
|
|
|
61
61
|
const workingDirectory = dirname(gatewayPath)
|
|
62
62
|
const environment = {
|
|
63
63
|
QWAUDIO_CONFIG_DIR: configDirectory,
|
|
64
|
+
QWEN_AUDIO_GATEWAY_OWNER: 'service',
|
|
65
|
+
QWEN_AUDIO_LOG_CONSOLE: '0',
|
|
64
66
|
PATH: pathEnvironment,
|
|
65
67
|
...serviceEnvironment,
|
|
66
68
|
}
|
|
@@ -98,9 +100,9 @@ ${Object.entries(environment).map(([key, value]) => (
|
|
|
98
100
|
<key>ProcessType</key>
|
|
99
101
|
<string>Background</string>
|
|
100
102
|
<key>StandardOutPath</key>
|
|
101
|
-
<string>${xml(resolve(logsDirectory, 'gateway.log'))}</string>
|
|
103
|
+
<string>${xml(resolve(logsDirectory, 'gateway-console.log'))}</string>
|
|
102
104
|
<key>StandardErrorPath</key>
|
|
103
|
-
<string>${xml(resolve(logsDirectory, 'gateway.log'))}</string>
|
|
105
|
+
<string>${xml(resolve(logsDirectory, 'gateway-console.log'))}</string>
|
|
104
106
|
</dict>
|
|
105
107
|
</plist>
|
|
106
108
|
`
|
package/cli/src/launcher.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { helpText, parseArguments } from './arguments.mjs'
|
|
10
10
|
import {
|
|
11
11
|
ensureRuntime,
|
|
12
|
+
isLocalGateway,
|
|
12
13
|
readGatewayHealth,
|
|
13
14
|
waitForGateway,
|
|
14
15
|
} from './runtime.mjs'
|
|
@@ -62,6 +63,17 @@ function gatewaySummary(health) {
|
|
|
62
63
|
return `${label} ${state}`
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
function gatewayServiceEnvironment(url) {
|
|
67
|
+
const target = new URL(url)
|
|
68
|
+
if (target.protocol !== 'http:' || !isLocalGateway(url)) {
|
|
69
|
+
throw new Error('Gateway 后台服务只支持本机 HTTP 地址')
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
HOST: target.hostname.replace(/^\[(.*)\]$/, '$1'),
|
|
73
|
+
PORT: target.port || '80',
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
async function waitForGatewayStop(url, {
|
|
66
78
|
inspectGateway = readGatewayHealth,
|
|
67
79
|
timeoutMs = 15_000,
|
|
@@ -124,9 +136,17 @@ export async function main(argv, {
|
|
|
124
136
|
(options.command === 'gateway' && options.gatewayAction !== 'run')
|
|
125
137
|
|| options.command === 'status'
|
|
126
138
|
) {
|
|
139
|
+
const serviceEnvironment = [
|
|
140
|
+
'install',
|
|
141
|
+
'start',
|
|
142
|
+
'restart',
|
|
143
|
+
].includes(options.gatewayAction)
|
|
144
|
+
? gatewayServiceEnvironment(options.url)
|
|
145
|
+
: {}
|
|
127
146
|
const serviceOptions = {
|
|
128
147
|
configDirectory: environment.configDirectory,
|
|
129
148
|
gatewayPath,
|
|
149
|
+
serviceEnvironment,
|
|
130
150
|
serviceMetadata: {
|
|
131
151
|
url: options.url,
|
|
132
152
|
},
|
package/cli/src/runtime.mjs
CHANGED
|
@@ -7,11 +7,18 @@ import {
|
|
|
7
7
|
} from '../../shared/backend-catalog.mjs'
|
|
8
8
|
import {
|
|
9
9
|
loadRuntimeEnvironment,
|
|
10
|
-
|
|
10
|
+
requireRealtimeFrontendConfiguration,
|
|
11
11
|
} from '../../shared/runtime-environment.mjs'
|
|
12
|
+
import {
|
|
13
|
+
normalizeRealtimeProvider,
|
|
14
|
+
resolveRealtimeFrontendConfiguration,
|
|
15
|
+
} from '../../shared/realtime-provider-catalog.mjs'
|
|
12
16
|
import {
|
|
13
17
|
readGatewayHealth,
|
|
14
18
|
} from '../../shared/gateway-client.mjs'
|
|
19
|
+
import {
|
|
20
|
+
findRunningGateway,
|
|
21
|
+
} from '../../shared/gateway-instance-lock.mjs'
|
|
15
22
|
|
|
16
23
|
export {
|
|
17
24
|
readGatewayHealth,
|
|
@@ -132,6 +139,41 @@ export function assertGatewayCompatibility(health, backend) {
|
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
|
|
142
|
+
export function assertRealtimeGatewayCompatibility(health, env = process.env) {
|
|
143
|
+
const expected = resolveRealtimeFrontendConfiguration(env)
|
|
144
|
+
if (!String(health?.realtimeProvider || '').trim()) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
'现有 Gateway 未报告完整的 Realtime 前台配置,无法安全复用',
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
let actualProvider
|
|
150
|
+
try {
|
|
151
|
+
actualProvider = normalizeRealtimeProvider(health?.realtimeProvider)
|
|
152
|
+
} catch {
|
|
153
|
+
throw new Error(
|
|
154
|
+
'现有 Gateway 未报告完整的 Realtime 前台配置,无法安全复用',
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
const actualSignature = String(
|
|
158
|
+
health?.realtimeConfigurationSignature || '',
|
|
159
|
+
).trim()
|
|
160
|
+
if (!actualSignature) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
'现有 Gateway 未报告完整的 Realtime 前台配置,无法安全复用',
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
if (
|
|
166
|
+
actualProvider !== expected.provider
|
|
167
|
+
|| actualSignature !== expected.signature
|
|
168
|
+
) {
|
|
169
|
+
const mismatch = actualProvider !== expected.provider
|
|
170
|
+
? `现有 Gateway 使用 ${actualProvider} Realtime 前台,与当前配置 ${expected.provider} 不一致`
|
|
171
|
+
: `现有 Gateway 的 ${expected.provider} Realtime 前台参数与当前配置不一致`
|
|
172
|
+
throw new Error(`${mismatch};请关闭旧 Gateway 后重试`)
|
|
173
|
+
}
|
|
174
|
+
return expected
|
|
175
|
+
}
|
|
176
|
+
|
|
135
177
|
export async function waitForGateway(baseUrl, {
|
|
136
178
|
fetchImpl = fetch,
|
|
137
179
|
requireBackend = false,
|
|
@@ -306,9 +348,9 @@ export async function ensureRuntime(options, {
|
|
|
306
348
|
spawnImpl = spawn,
|
|
307
349
|
platform = process.platform,
|
|
308
350
|
loadEnvironment = () => loadRuntimeEnvironment({ root, env }),
|
|
309
|
-
requireCredential = () =>
|
|
351
|
+
requireCredential = () => requireRealtimeFrontendConfiguration(env),
|
|
310
352
|
} = {}) {
|
|
311
|
-
loadEnvironment()
|
|
353
|
+
const runtimeEnvironment = loadEnvironment()
|
|
312
354
|
const runtime = new ManagedRuntime([], { platform })
|
|
313
355
|
const local = isLocalGateway(options.url)
|
|
314
356
|
const backend = resolveBackend(options, env)
|
|
@@ -316,7 +358,19 @@ export async function ensureRuntime(options, {
|
|
|
316
358
|
? backendDefinition(backend.protocol)?.label || backend.protocol
|
|
317
359
|
: '后台 Agent'
|
|
318
360
|
let health = await readGatewayHealth(options.url, fetchImpl)
|
|
319
|
-
|
|
361
|
+
if (!health && local && runtimeEnvironment?.configDirectory) {
|
|
362
|
+
const active = await findRunningGateway(
|
|
363
|
+
runtimeEnvironment.configDirectory,
|
|
364
|
+
{
|
|
365
|
+
readHealth: origin => readGatewayHealth(origin, fetchImpl),
|
|
366
|
+
},
|
|
367
|
+
)
|
|
368
|
+
if (active) {
|
|
369
|
+
options.url = active.origin
|
|
370
|
+
health = active.health
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
let existingGateway = Boolean(health)
|
|
320
374
|
|
|
321
375
|
try {
|
|
322
376
|
if (!health) {
|
|
@@ -336,16 +390,30 @@ export async function ensureRuntime(options, {
|
|
|
336
390
|
)
|
|
337
391
|
const gateway = spawnImpl(spec.command, spec.args, spec.options)
|
|
338
392
|
runtime.children.push(gateway)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
393
|
+
try {
|
|
394
|
+
health = await waitForReadiness(
|
|
395
|
+
gateway,
|
|
396
|
+
waitForGateway(options.url, {
|
|
397
|
+
fetchImpl,
|
|
398
|
+
requireBackend: Boolean(
|
|
399
|
+
backend.protocol && options.waitForBackend !== false
|
|
400
|
+
),
|
|
401
|
+
}),
|
|
402
|
+
'Gateway',
|
|
403
|
+
)
|
|
404
|
+
} catch (startupError) {
|
|
405
|
+
const winner = runtimeEnvironment?.configDirectory
|
|
406
|
+
? await findRunningGateway(runtimeEnvironment.configDirectory, {
|
|
407
|
+
readHealth: origin => readGatewayHealth(origin, fetchImpl),
|
|
408
|
+
timeoutMs: 3000,
|
|
409
|
+
})
|
|
410
|
+
: null
|
|
411
|
+
if (!winner) throw startupError
|
|
412
|
+
runtime.children = runtime.children.filter(child => child !== gateway)
|
|
413
|
+
options.url = winner.origin
|
|
414
|
+
health = winner.health
|
|
415
|
+
existingGateway = true
|
|
416
|
+
}
|
|
349
417
|
}
|
|
350
418
|
|
|
351
419
|
// An owned Gateway may move its private backend to a free local port.
|
|
@@ -367,12 +435,17 @@ export async function ensureRuntime(options, {
|
|
|
367
435
|
)
|
|
368
436
|
}
|
|
369
437
|
}
|
|
438
|
+
const realtime = local
|
|
439
|
+
? assertRealtimeGatewayCompatibility(health, env)
|
|
440
|
+
: null
|
|
370
441
|
if (
|
|
371
442
|
health.voiceConfigured === false
|
|
372
443
|
&& options.allowMissingCredential !== true
|
|
373
444
|
) {
|
|
374
445
|
throw new Error(
|
|
375
|
-
|
|
446
|
+
realtime
|
|
447
|
+
? `现有 Gateway 的 ${realtime.label} Realtime 前台未配置完整;请修正配置后重启该 Gateway`
|
|
448
|
+
: '远程 Gateway 的 Realtime 前台未配置完整',
|
|
376
449
|
)
|
|
377
450
|
}
|
|
378
451
|
|
package/docs/architecture.md
CHANGED
|
@@ -150,7 +150,7 @@ Queue position is an internal scheduling detail and does not change the user's
|
|
|
150
150
|
duplex conversation.
|
|
151
151
|
|
|
152
152
|
Active Work cannot be safely resumed after a Gateway restart, so
|
|
153
|
-
|
|
153
|
+
it becomes failed with an explicit restart reason. Completed results and
|
|
154
154
|
notification delivery state are persisted.
|
|
155
155
|
|
|
156
156
|
## 6. Progress animation
|
package/docs/configuration.md
CHANGED
|
@@ -374,6 +374,13 @@ QWEN_AUDIO_AGENT_ALLOWED_ORIGINS=https://voice.example.com
|
|
|
374
374
|
|
|
375
375
|
## Gateway 运行方式
|
|
376
376
|
|
|
377
|
+
同一用户配置目录在任意时刻只允许一个本地 Gateway。CLI、TUI、WebUI 和桌面版会
|
|
378
|
+
优先复用这个实例;它们可以同时连接,但不会各自启动一套后台 Agent。实例身份记录在
|
|
379
|
+
用户配置目录下的临时 `gateway.lock` 中,Gateway 正常退出时会删除,异常退出留下的
|
|
380
|
+
锁会在确认原进程已经结束后自动回收。若现有 Gateway 的 Realtime、后台 Agent 或
|
|
381
|
+
权限配置与当前请求不一致,启动会明确报错,而不会静默另开随机端口。远程 Gateway
|
|
382
|
+
不参与本地单实例租约。
|
|
383
|
+
|
|
377
384
|
Gateway 默认启动并管理所选 Agent 的 ACP 进程。若 OpenCode 或 OpenClaw 的本地
|
|
378
385
|
服务端口已被其他进程占用,会选择空闲端口,不会接管或关闭用户进程。OpenClaw
|
|
379
386
|
始终由 qwen-audio-agent 启动独立 Gateway,并使用隔离的运行状态和 Session
|
|
@@ -398,6 +405,39 @@ qwenaudio gateway uninstall
|
|
|
398
405
|
`~/.config/qwaudio/logs/gateway.log`;Linux 也可以通过
|
|
399
406
|
`journalctl --user -u qwen-audio-agent-gateway` 查看。
|
|
400
407
|
|
|
408
|
+
## 本地日志
|
|
409
|
+
|
|
410
|
+
qwen-audio-agent 使用统一的本地结构化日志,默认写入:
|
|
411
|
+
|
|
412
|
+
```text
|
|
413
|
+
~/.config/qwaudio/logs/
|
|
414
|
+
├── gateway.log # Gateway、Realtime、ACP 与任务生命周期
|
|
415
|
+
├── desktop.log # 桌面主进程与内嵌 Gateway 生命周期
|
|
416
|
+
├── cli.log # CLI 命令生命周期
|
|
417
|
+
└── tui.log # 直接启动 TUI 时的生命周期
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
日志采用一行一个 JSON 对象的 JSON Lines 格式,包含稳定的 `schema`、`time`、
|
|
421
|
+
`level`、`component`、`event` 和 `pid` 字段,并按需携带 `sessionId`、`turnId`、
|
|
422
|
+
`taskId`、`provider`、`backend`、`durationMs` 等关联信息。API Key、Token、
|
|
423
|
+
Authorization、Cookie、密码和 Secret 字段会在写入前脱敏;默认不记录麦克风音频、
|
|
424
|
+
用户转写正文、模型回复正文、任务目标或任务结果。
|
|
425
|
+
|
|
426
|
+
桌面版可在“设置 → 应用 → 日志”中打开日志目录。默认日志级别为 `info`,单个文件
|
|
427
|
+
达到 10 MiB 后轮转,总共保留 5 份。可通过以下环境变量调整:
|
|
428
|
+
|
|
429
|
+
| 设置 | 默认值 | 说明 |
|
|
430
|
+
| --- | --- | --- |
|
|
431
|
+
| `QWEN_AUDIO_LOG_LEVEL` | `info` | `trace`、`debug`、`info`、`warn`、`error`、`fatal` 或 `silent` |
|
|
432
|
+
| `QWEN_AUDIO_LOG_DIR` | 用户配置目录下的 `logs` | 自定义日志目录 |
|
|
433
|
+
| `QWEN_AUDIO_LOG_MAX_BYTES` | `10485760` | 单个日志文件的轮转阈值 |
|
|
434
|
+
| `QWEN_AUDIO_LOG_MAX_FILES` | `5` | 当前文件和轮转文件的总保留数量 |
|
|
435
|
+
| `QWEN_AUDIO_LOG_FILE` | `1` | 设为 `0` 禁用文件日志 |
|
|
436
|
+
| `QWEN_AUDIO_LOG_CONSOLE` | `1` | 设为 `0` 禁用终端日志输出 |
|
|
437
|
+
|
|
438
|
+
日志仅保存在本机,不会自动上传。反馈问题前可按需检查并分享相关片段;即使系统会
|
|
439
|
+
自动脱敏,也应在发送前再次确认其中没有不希望公开的本机路径或业务信息。
|
|
440
|
+
|
|
401
441
|
TUI、WebUI 和桌面版只连接 Gateway,不直接连接、启动或停止任何后台 Agent。
|
|
402
442
|
桌面设置中的核心配置会保存到用户配置文件,在下次启动 Gateway 时生效;
|
|
403
443
|
Gateway 地址会立即验证并切换。
|
|
@@ -458,6 +498,8 @@ QWEN_AUDIO_AGENT_OPENCODE_ISOLATE_USER_CONFIG=true
|
|
|
458
498
|
| `QWEN_AUDIO_REALTIME_MODEL` | `qwen-audio-3.0-realtime-plus` |
|
|
459
499
|
| `QWEN_AUDIO_REALTIME_PROVIDER` | `dashscope` |
|
|
460
500
|
| `QWEN_AUDIO_REALTIME_VOICE` | `longanqian` |
|
|
501
|
+
| `SPEECH_TO_SPEECH_REALTIME_URL` | `ws://127.0.0.1:8765/v1/realtime` |
|
|
502
|
+
| `SPEECH_TO_SPEECH_AUTH_TOKEN` | 空;仅用于带 Bearer 认证的代理 |
|
|
461
503
|
| `QWEN_AUDIO_AGENT_IDENTITY_MODE` | `personal` |
|
|
462
504
|
| `QWEN_AUDIO_AGENT_TUI_AUDIO_MODE` | `half` |
|
|
463
505
|
| `AGENT_TIMEOUT_MS` | `300000` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qwen-audio-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A realtime voice frontend for mainstream AI agents.",
|
|
5
5
|
"author": "qwen-audio-agent contributors",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
114
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
115
|
-
"@modelcontextprotocol/sdk": "1.
|
|
115
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
116
116
|
"electron-updater": "6.8.9",
|
|
117
117
|
"express": "^4.22.2",
|
|
118
118
|
"ws": "^8.21.1",
|
package/server/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-audio-agent/server",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "node --watch src/index.mjs",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
13
|
-
"@modelcontextprotocol/sdk": "1.
|
|
13
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
14
14
|
"express": "^4.22.2",
|
|
15
15
|
"ws": "^8.21.1",
|
|
16
16
|
"zod": "^4.4.3"
|