qwen-audio-agent 2.0.0 → 2.1.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/README.md +15 -5
- package/README_ZH.md +13 -5
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/cli/package.json +1 -1
- package/cli/src/arguments.mjs +4 -1
- package/cli/src/config-command.mjs +5 -6
- package/cli/src/launcher.mjs +13 -0
- package/config/frontend-agent/PROMPT.md +29 -26
- package/desktop/src/i18n.mjs +6 -0
- package/desktop/src/settings-config.mjs +34 -28
- package/desktop/src/settings-store.mjs +19 -28
- package/docs/architecture/deep-dive.md +103 -66
- package/docs/architecture/deep-dive.zh.md +73 -50
- package/docs/backends/configuration.md +21 -20
- package/docs/backends/configuration.zh.md +19 -17
- package/docs/backends/overview.md +14 -8
- package/docs/backends/overview.zh.md +11 -5
- package/docs/configuration/backend.md +16 -2
- package/docs/configuration/backend.zh.md +16 -2
- package/docs/configuration/frontend.md +59 -26
- package/docs/configuration/frontend.zh.md +58 -26
- package/docs/configuration.md +1 -1
- package/docs/configuration.zh.md +1 -1
- package/docs/contract.md +22 -2
- package/docs/contract.zh.md +18 -2
- package/docs/gateway-protocol.md +26 -0
- package/docs/gateway-protocol.zh.md +22 -0
- package/docs/gateway-webrtc-client.md +3 -3
- package/docs/gateway-webrtc-client.zh.md +3 -3
- package/docs/getting-started/install.md +1 -1
- package/docs/getting-started/install.zh.md +1 -1
- package/docs/getting-started/quickstart.md +2 -2
- package/docs/getting-started/quickstart.zh.md +2 -2
- package/docs/getting-started/webui.md +2 -0
- package/docs/getting-started/webui.zh.md +2 -0
- package/docs/guides/knowledge.md +8 -5
- package/docs/guides/knowledge.zh.md +4 -3
- package/docs/guides/tasks.md +63 -2
- package/docs/guides/tasks.zh.md +45 -1
- package/docs/guides/web-search.md +16 -1
- package/docs/guides/web-search.zh.md +14 -1
- package/docs/reference/backend-adapter-sdk.md +33 -2
- package/docs/reference/backend-adapter-sdk.zh.md +29 -2
- package/docs/reference/cli.md +3 -3
- package/docs/reference/cli.zh.md +3 -3
- package/docs/scenarios/lightrag.md +2 -2
- package/docs/scenarios/lightrag.zh.md +2 -2
- package/docs/scenarios/x-omni.md +5 -2
- package/docs/scenarios/x-omni.zh.md +5 -2
- package/docs/voice-agent-architecture-presentation.zh.md +34 -37
- package/docs/voice-frontends/custom-provider.md +6 -3
- package/docs/voice-frontends/custom-provider.zh.md +6 -3
- package/docs/voice-frontends/google-live.md +7 -5
- package/docs/voice-frontends/google-live.zh.md +7 -5
- package/docs/voice-frontends/gpt-live.md +7 -5
- package/docs/voice-frontends/gpt-live.zh.md +7 -5
- package/docs/voice-frontends/minicpm-o.md +8 -4
- package/docs/voice-frontends/minicpm-o.zh.md +7 -4
- package/docs/voice-frontends/qwen-audio-realtime.md +39 -14
- package/docs/voice-frontends/qwen-audio-realtime.zh.md +32 -11
- package/docs/voice-frontends/qwen-omni-realtime.md +11 -8
- package/docs/voice-frontends/qwen-omni-realtime.zh.md +11 -8
- package/docs/voice-frontends/speech-to-speech.md +8 -4
- package/docs/voice-frontends/speech-to-speech.zh.md +7 -3
- package/docs/voice-frontends/stepfun.md +7 -4
- package/docs/voice-frontends/stepfun.zh.md +7 -4
- package/examples/webrtc/start.mjs +2 -1
- package/package.json +22 -14
- package/scripts/audit-dependencies.mjs +3 -25
- package/scripts/electron-smoke.mjs +5 -5
- package/scripts/release-check +13 -21
- package/scripts/runtime/claude-code-acp.mjs +5 -5
- package/scripts/runtime/codex-acp.mjs +1 -1
- package/scripts/runtime/openclaw.mjs +3 -2
- package/scripts/runtime/opencode.mjs +2 -10
- package/scripts/runtime/pi-acp.mjs +1 -1
- package/scripts/verify-package.mjs +0 -2
- package/server/package.json +4 -4
- package/server/src/app/gateway-application.mjs +3 -0
- package/server/src/app/gateway-http-routes.mjs +3 -0
- package/server/src/app/session-conversation-history.mjs +9 -1
- package/server/src/backend/adapters/a2a/backend-adapter.mjs +32 -26
- package/server/src/backend/adapters/acp/backend-adapter.mjs +710 -263
- package/server/src/backend/adapters/acp/coordinator-contract.mjs +2 -13
- package/server/src/backend/adapters/acp/coordinator-instructions.mjs +29 -8
- package/server/src/backend/adapters/acp/coordinator-queue.mjs +58 -0
- package/server/src/backend/adapters/acp/drivers/codex.mjs +1 -1
- package/server/src/backend/adapters/acp/drivers/deepseek-harness.mjs +12 -36
- package/server/src/backend/adapters/acp/drivers/openclaw.mjs +1 -2
- package/server/src/backend/adapters/acp/input-broker.mjs +2 -0
- package/server/src/backend/adapters/acp/process-client.mjs +117 -17
- package/server/src/backend/adapters/acp/session-configuration.mjs +2 -19
- package/server/src/backend/adapters/acp/session-registry.mjs +9 -0
- package/server/src/backend/adapters/acp/session-tools.mjs +1 -1
- package/server/src/backend/adapters/acp/turn-updates.mjs +188 -0
- package/server/src/backend/adapters/acp/work-continuation.mjs +48 -0
- package/server/src/backend/adapters/agent-client.mjs +24 -1
- package/server/src/backend/adapters/llm/backend-adapter.mjs +393 -0
- package/server/src/backend/adapters/muse/backend-adapter.mjs +2 -0
- package/server/src/backend/availability.mjs +12 -3
- package/server/src/backend/backend-adapter-sdk.mjs +3 -0
- package/server/src/backend/backend-port.mjs +13 -0
- package/server/src/backend/backend-work-runtime.mjs +23 -0
- package/server/src/client/client-command-runtime.mjs +14 -0
- package/server/src/conversation/conversation-sync.mjs +26 -2
- package/server/src/conversation/frontend-notes.mjs +7 -5
- package/server/src/conversation/task-result-projector.mjs +1 -1
- package/server/src/core/backend-events.mjs +4 -0
- package/server/src/core/config.mjs +32 -55
- package/server/src/core/gateway-protocol.mjs +4 -1
- package/server/src/core/work-conversation-context.mjs +138 -0
- package/server/src/core/work-input-request.mjs +1 -0
- package/server/src/frontend/frontend-tools.mjs +6 -6
- package/server/src/frontend/retrieval/providers/factory.mjs +10 -1
- package/server/src/frontend/retrieval/providers/mcp.mjs +13 -2
- package/server/src/frontend/tools/agent-task-runtime.mjs +97 -95
- package/server/src/frontend/tools/features/agent-task-tools.mjs +23 -42
- package/server/src/frontend/tools/frontend-tool-context.mjs +2 -2
- package/server/src/frontend/tools/spawn-thinking-tool.mjs +2 -2
- package/server/src/frontend/tools/tool-call-handler.mjs +112 -68
- package/server/src/knowledge/providers/local/library.mjs +26 -6
- package/server/src/knowledge/providers/local/provider.mjs +25 -6
- package/server/src/memory/providers/markdown/context-store.mjs +21 -10
- package/server/src/orchestration/session-task-coordinator.mjs +9 -2
- package/server/src/orchestration/task-operations.mjs +50 -10
- package/server/src/orchestration/task-updates.mjs +81 -0
- package/server/src/task/reminder-scheduler.mjs +5 -1
- package/server/src/task/task-manager.mjs +72 -15
- package/server/src/task/task-recovery.mjs +12 -2
- package/server/src/task/task-scheduler.mjs +5 -5
- package/server/src/task/task-state.mjs +13 -0
- package/server/src/transport/gateway-client-transport.mjs +16 -0
- package/server/src/voice/announcement/announcement-manager.mjs +3 -0
- package/server/src/voice/providers/dashscope.mjs +34 -30
- package/server/src/voice/providers/doubao-seeduplex.mjs +13 -9
- package/server/src/voice/providers/google-live.mjs +18 -13
- package/server/src/voice/providers/gpt-live.mjs +13 -10
- package/server/src/voice/providers/minicpm-o.mjs +9 -7
- package/server/src/voice/providers/registry.mjs +2 -2
- package/server/src/voice/providers/runtime-configuration.mjs +23 -0
- package/server/src/voice/providers/s2s.mjs +9 -7
- package/server/src/voice/providers/stepfun.mjs +13 -10
- package/server/src/voice/realtime-input-runtime.mjs +2 -0
- package/server/src/voice/realtime-presentation-runtime.mjs +90 -23
- package/server/src/voice/realtime-provider.mjs +26 -9
- package/server/src/voice/realtime-session-runtime.mjs +79 -23
- package/server/src/voice/realtime-task-presentation.mjs +2 -0
- package/shared/backend/catalog.mjs +44 -45
- package/shared/backend/install.mjs +15 -17
- package/shared/backend/runtime-package.mjs +3 -3
- package/shared/backend/setup.mjs +59 -113
- package/shared/gateway/client-sdk.mjs +6 -1
- package/shared/gateway/setup.mjs +13 -1
- package/shared/protocol/gateway-client-protocol.mjs +14 -0
- package/shared/protocol/gateway-events.mjs +8 -1
- package/shared/realtime-legacy-environment.mjs +52 -0
- package/shared/realtime-model-catalog.mjs +66 -194
- package/shared/realtime-models/README.md +25 -0
- package/shared/realtime-models/dashscope.mjs +46 -0
- package/shared/realtime-models/doubao-seeduplex.mjs +12 -0
- package/shared/realtime-models/google-live.mjs +10 -0
- package/shared/realtime-models/gpt-live.mjs +10 -0
- package/shared/realtime-models/profile.mjs +35 -0
- package/shared/realtime-models/stepfun.mjs +10 -0
- package/shared/realtime-provider-catalog.mjs +16 -5
- package/shared/realtime-provider-definitions.mjs +99 -231
- package/shared/runtime-environment.mjs +23 -30
- package/shared/skill-library.mjs +49 -13
- package/shared/web-search-configuration.mjs +13 -2
- package/tui/package.json +1 -1
- package/web/dist/assets/index-8erKDCr2.css +1 -0
- package/web/dist/assets/index-Cs4hYWbS.js +96 -0
- package/web/dist/index.html +2 -2
- package/config/backends/deepseek-harness/cordis.yml +0 -59
- package/scripts/runtime/deepseek-harness-acp.mjs +0 -59
- package/web/dist/assets/index-BRaiI-dW.js +0 -91
- package/web/dist/assets/index-D9k8R2JY.css +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ tells you:
|
|
|
27
27
|
|
|
28
28
|
## News
|
|
29
29
|
|
|
30
|
+
- **2026-11-10 · [v2.1.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v2.1.0)**
|
|
31
|
+
🎙️ Adds Qwen Audio 3.1 Realtime and unified frontend configuration; 🧩 supports updating running tasks and continuing completed work; 🎭 adds a runnable [dual-connection digital-human example](https://github.com/QwenAudio/qwen-audio-agent/tree/main/examples/digital-human) with replaceable rendering services; 📷 adds photo capture to WebUI.
|
|
30
32
|
- **2026-09-23 · [v2.0.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v2.0.0)**
|
|
31
33
|
🏗️ Rebuilt the orchestration runtime with a unified client protocol and ACP / A2A backend integration; 🎙️ expanded [voice and video model support](#voice-frontends); 🧠 enhanced frontend tools, memory, and knowledge libraries; 💬 added a desktop conversation panel and remote mobile access; 🧩 added [customer service, smart cockpit, digital human, and other examples](#examples-and-scenario-expansion); 📄 published the [technical report](https://arxiv.org/pdf/2609.25195).
|
|
32
34
|
- **2026-08-20 · [v1.11.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.11.0)**
|
|
@@ -103,7 +105,7 @@ tasks. They integrate independently and can be combined as needed.
|
|
|
103
105
|
|
|
104
106
|
| Voice frontend | Deployment | Setup | Features |
|
|
105
107
|
| --- | --- | --- | --- |
|
|
106
|
-
| [Qwen Audio 3.0 Realtime](docs/voice-frontends/qwen-audio-realtime.md) | Cloud | Bailian API Key | Duplex voice, tool calling |
|
|
108
|
+
| [Qwen Audio 3.0/3.1 Realtime](docs/voice-frontends/qwen-audio-realtime.md) | Cloud | Bailian API Key | Duplex voice, tool calling |
|
|
107
109
|
| [GPT-Live / OpenAI Realtime](docs/voice-frontends/gpt-live.md) | Cloud | OpenAI API Key | — |
|
|
108
110
|
| [Google Gemini Live](docs/voice-frontends/google-live.md) | Cloud | Google API Key | Live video input |
|
|
109
111
|
| [Qwen3.5-Omni Realtime](docs/voice-frontends/qwen-omni-realtime.md) | Cloud | Bailian API Key | Live video input |
|
|
@@ -113,6 +115,10 @@ tasks. They integrate independently and can be combined as needed.
|
|
|
113
115
|
| [Hugging Face Speech-to-Speech](docs/voice-frontends/speech-to-speech.md) | Local | Start the service and set its URL | Configurable STT / LLM / TTS |
|
|
114
116
|
| [MiniCPM-o 4.5](docs/voice-frontends/minicpm-o.md) | Local or cloud | Compatible service URL | Live video input, no tool calling |
|
|
115
117
|
|
|
118
|
+
Frontend connections share the same provider, model, API Key, service URL, and
|
|
119
|
+
voice settings. Supported models and protocol parameters are maintained by the
|
|
120
|
+
framework; see [frontend configuration](docs/configuration/frontend.md).
|
|
121
|
+
|
|
116
122
|
To connect another voice service, implement the
|
|
117
123
|
[Realtime Provider interface](docs/voice-frontends/custom-provider.md) without
|
|
118
124
|
changing the Gateway's core voice-session or backend-task logic.
|
|
@@ -122,6 +128,7 @@ changing the Gateway's core voice-session or backend-task logic.
|
|
|
122
128
|
| Backend Agent | Integration | Setup | Rating |
|
|
123
129
|
| --- | --- | --- | --- |
|
|
124
130
|
| None | N/A | Frontend-only mode, no backend config needed | ★★★★★ |
|
|
131
|
+
| Bare LLM | Built-in Chat Completions | OpenAI-compatible API key, URL, and model | Experimental |
|
|
125
132
|
| Qwen Code | Native ACP | One-click install, user config required | ★★★★★ |
|
|
126
133
|
| OpenCode | Native ACP | One-click install + Bailian config | ★★★★★ |
|
|
127
134
|
| OpenClaw | Built-in ACP bridge | One-click install + Bailian config | ★★★★★ |
|
|
@@ -163,9 +170,9 @@ qwenaudio config
|
|
|
163
170
|
```
|
|
164
171
|
|
|
165
172
|
```dotenv
|
|
166
|
-
|
|
167
|
-
# Voice frontend model: optional, defaults to Qwen Audio 3.
|
|
168
|
-
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.
|
|
173
|
+
QWEN_AUDIO_REALTIME_API_KEY=your-key
|
|
174
|
+
# Voice frontend model: optional, defaults to Qwen Audio 3.1 Realtime Plus
|
|
175
|
+
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.1-realtime-plus
|
|
169
176
|
# Backend Agent: optional, leave empty or set to none for frontend-only mode
|
|
170
177
|
AGENT_PROTOCOL=openclaw
|
|
171
178
|
# Backend model: optional; explicit values use standard ACP, empty reuses Agent config
|
|
@@ -180,6 +187,9 @@ Quota and billing rules are subject to the current official Bailian documentatio
|
|
|
180
187
|
> The example above uses the default DashScope voice frontend. See
|
|
181
188
|
> [Voice Frontends](#voice-frontends) for other cloud and self-hosted options.
|
|
182
189
|
|
|
190
|
+
Backend credentials remain in the Agent's own configuration. For managed Bailian setup,
|
|
191
|
+
see [backend configuration](docs/configuration/backend.md).
|
|
192
|
+
|
|
183
193
|
With a visual-capable Realtime frontend, WebUI can explicitly stream bounded
|
|
184
194
|
camera frames alongside live audio. See [Realtime frontend configuration](docs/configuration/frontend.md).
|
|
185
195
|
|
|
@@ -245,7 +255,7 @@ to be invited.
|
|
|
245
255
|
|
|
246
256
|
| WeChat Group | Personal | Personal |
|
|
247
257
|
| :---: | :---: | :---: |
|
|
248
|
-
| <img src="docs/wechat-group-qr.png"
|
|
258
|
+
| <img src="docs/wechat-group-qr.png" height="345" alt="WeChat group QR code"> | <img src="docs/wechat-contact-qr.png" height="345" alt="Li Xu personal WeChat QR code"> | <img src="docs/wechat-pigeon-dan-qr.png" height="345" alt="Pigeon.Dan personal WeChat QR code"> |
|
|
249
259
|
|
|
250
260
|
## Contributing and Security
|
|
251
261
|
|
package/README_ZH.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
## News
|
|
23
23
|
|
|
24
|
+
- **2026-11-10 · [v2.1.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v2.1.0)**
|
|
25
|
+
🎙️ 接入 Qwen Audio 3.1 Realtime,统一前台配置;🧩 支持执行中调整任务、完成后继续加工;🎭 新增可运行的[双连接数字人示例](https://github.com/QwenAudio/qwen-audio-agent/blob/main/examples/digital-human/README_ZH.md),支持替换渲染服务;📷 WebUI 新增拍照输入。
|
|
24
26
|
- **2026-09-23 · [v2.0.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v2.0.0)**
|
|
25
27
|
🏗️ 重构编排运行时,统一客户端协议与 ACP / A2A 后台接入;🎙️ 扩展[语音与视频模型](#语音前台);🧠 完善前台工具、记忆与资料库;💬 新增桌面对话面板与手机远程连接;🧩 新增[客服、座舱、数字人等示例](#示例与场景扩展);📄 发布[技术报告](https://arxiv.org/pdf/2609.25195)。
|
|
26
28
|
- **2026-08-20 · [v1.11.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.11.0)**
|
|
@@ -95,7 +97,7 @@
|
|
|
95
97
|
|
|
96
98
|
| 语音前台 | 部署方式 | 接入准备 | 特点 |
|
|
97
99
|
| --- | --- | --- | --- |
|
|
98
|
-
| [Qwen Audio 3.0 Realtime](docs/voice-frontends/qwen-audio-realtime.zh.md) | 云端 | 百炼 API Key | 双工语音、工具调用 |
|
|
100
|
+
| [Qwen Audio 3.0/3.1 Realtime](docs/voice-frontends/qwen-audio-realtime.zh.md) | 云端 | 百炼 API Key | 双工语音、工具调用 |
|
|
99
101
|
| [GPT-Live / OpenAI Realtime](docs/voice-frontends/gpt-live.zh.md) | 云端 | OpenAI API Key | — |
|
|
100
102
|
| [Google Gemini Live](docs/voice-frontends/google-live.zh.md) | 云端 | Google API Key | 实时视频输入 |
|
|
101
103
|
| [Qwen3.5-Omni Realtime](docs/voice-frontends/qwen-omni-realtime.zh.md) | 云端 | 百炼 API Key | 实时视频输入 |
|
|
@@ -105,6 +107,9 @@
|
|
|
105
107
|
| [Hugging Face Speech-to-Speech](docs/voice-frontends/speech-to-speech.zh.md) | 本地 | 启动服务并填写地址 | 可配置 STT / LLM / TTS |
|
|
106
108
|
| [MiniCPM-o 4.5](docs/voice-frontends/minicpm-o.zh.md) | 本地或云端 | 提供兼容服务地址 | 实时视频输入、不支持工具调用 |
|
|
107
109
|
|
|
110
|
+
前台连接统一使用供应商、模型、API Key、服务地址和音色配置;模型支持列表与协议参数
|
|
111
|
+
由框架维护。详见[语音前台配置](docs/configuration/frontend.zh.md)。
|
|
112
|
+
|
|
108
113
|
需要接入其他语音服务时,可实现 [Realtime Provider 接口](docs/voice-frontends/custom-provider.zh.md),
|
|
109
114
|
无需修改 Gateway 的核心语音会话与后台任务逻辑。
|
|
110
115
|
|
|
@@ -113,6 +118,7 @@
|
|
|
113
118
|
| 后台 Agent | 接入方式 | 接入准备 | 推荐指数 |
|
|
114
119
|
| --- | --- | --- | --- |
|
|
115
120
|
| 无 | N/A | 仅前台模式,无需后台配置 | ★★★★★ |
|
|
121
|
+
| 裸 LLM | 内置 Chat Completions | OpenAI-compatible API Key、URL 与模型 | 实验性 |
|
|
116
122
|
| Qwen Code | 原生 ACP | 支持一键安装,需用户配置 | ★★★★★ |
|
|
117
123
|
| OpenCode | 原生 ACP | 支持一键安装和百炼配置 | ★★★★★ |
|
|
118
124
|
| OpenClaw | 内置 ACP 桥接 | 支持一键安装和百炼配置 | ★★★★★ |
|
|
@@ -152,9 +158,9 @@ qwenaudio config
|
|
|
152
158
|
```
|
|
153
159
|
|
|
154
160
|
```dotenv
|
|
155
|
-
|
|
156
|
-
# 语音前台模型:可选,默认 Qwen Audio 3.
|
|
157
|
-
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.
|
|
161
|
+
QWEN_AUDIO_REALTIME_API_KEY=your-key
|
|
162
|
+
# 语音前台模型:可选,默认 Qwen Audio 3.1 Realtime Plus
|
|
163
|
+
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.1-realtime-plus
|
|
158
164
|
# 后台Agent:可选,不设置或设置为 none 时,启动仅前台模式
|
|
159
165
|
AGENT_PROTOCOL=openclaw
|
|
160
166
|
# 后台模型:可为空;显式设置通过 ACP 标准覆盖,留空沿用 Agent 配置
|
|
@@ -168,6 +174,8 @@ QWEN_AUDIO_AGENT_BACKEND_MODEL=qwen3.7-max
|
|
|
168
174
|
|
|
169
175
|
> 以上使用默认的 DashScope 语音前台。其他云端或自部署方案见[语音前台](#语音前台)。
|
|
170
176
|
|
|
177
|
+
后台凭据沿用 Agent 自身配置;托管百炼配置见[后台配置](docs/configuration/backend.zh.md)。
|
|
178
|
+
|
|
171
179
|
使用支持视觉的 Realtime 前台时,WebUI 可由用户显式开启相机,将有界画面帧与实时
|
|
172
180
|
音频一同发送。详见[语音前台配置](docs/configuration/frontend.zh.md)。
|
|
173
181
|
|
|
@@ -226,7 +234,7 @@ npm run desktop:build:linux # Linux(AppImage + deb,无需签名)
|
|
|
226
234
|
|
|
227
235
|
| 微信交流群 | 个人微信 | 个人微信 |
|
|
228
236
|
| :---: | :---: | :---: |
|
|
229
|
-
| <img src="docs/wechat-group-qr.png"
|
|
237
|
+
| <img src="docs/wechat-group-qr.png" height="345" alt="微信交流群二维码"> | <img src="docs/wechat-contact-qr.png" height="345" alt="李旭个人微信二维码"> | <img src="docs/wechat-pigeon-dan-qr.png" height="345" alt="Pigeon.Dan 个人微信二维码"> |
|
|
230
238
|
|
|
231
239
|
## 参与贡献与安全
|
|
232
240
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -19,7 +19,7 @@ qwen-audio-agent 使用并分发若干开源组件。项目自身使用 Apache L
|
|
|
19
19
|
| Agent2Agent Protocol JavaScript SDK | Apache-2.0 | https://github.com/a2aproject/a2a-js |
|
|
20
20
|
| Agent Client Protocol TypeScript SDK | Apache-2.0 | https://github.com/agentclientprotocol/typescript-sdk |
|
|
21
21
|
| Codex ACP adapter | Apache-2.0 | https://github.com/agentclientprotocol/codex-acp |
|
|
22
|
-
| Claude
|
|
22
|
+
| Claude Agent ACP adapter | Apache-2.0 | https://github.com/agentclientprotocol/claude-agent-acp |
|
|
23
23
|
| Model Context Protocol TypeScript SDK | MIT | https://github.com/modelcontextprotocol/typescript-sdk |
|
|
24
24
|
| Zod | MIT | https://github.com/colinhacks/zod |
|
|
25
25
|
| concurrently | MIT | https://github.com/open-cli-tools/concurrently |
|
package/cli/package.json
CHANGED
package/cli/src/arguments.mjs
CHANGED
|
@@ -53,7 +53,9 @@ function cleanOrigin(value, label) {
|
|
|
53
53
|
throw new Error(`无效的${label}:${value}`)
|
|
54
54
|
}
|
|
55
55
|
if (!['http:', 'https:'].includes(url.protocol)) {
|
|
56
|
-
|
|
56
|
+
// label 允许带前导空格(如 ' Gateway URL')以适配「无效的${label}」的中英
|
|
57
|
+
// 混排间距;以此为开头的消息需先去掉,避免句子以前导空格开头。
|
|
58
|
+
throw new Error(`${label.trim()}只支持 http 或 https`)
|
|
57
59
|
}
|
|
58
60
|
return url.origin
|
|
59
61
|
}
|
|
@@ -480,6 +482,7 @@ export function helpText() {
|
|
|
480
482
|
' --audio-mode MODE Linux / Windows 使用 half(默认)或 full',
|
|
481
483
|
' --takeover 显式接管同一用户的现有活动客户端(仅 TUI)',
|
|
482
484
|
' --no-open WebUI 只打印地址,不打开浏览器',
|
|
485
|
+
' -v, --version 显示版本',
|
|
483
486
|
' -h, --help 显示帮助',
|
|
484
487
|
'',
|
|
485
488
|
'TUI 按键:',
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
realtimeModelCatalog,
|
|
12
12
|
resolveRealtimeModelProfile,
|
|
13
13
|
} from '../../shared/realtime-provider-catalog.mjs'
|
|
14
|
+
import { mergeRealtimeEnvironment, realtimeSettingsFromEnvironment } from '../../shared/realtime-provider-definitions.mjs'
|
|
14
15
|
|
|
15
16
|
export const GATEWAY_RESTART_FOLLOW_UP = '配置已更新;请执行 qwenaudio gateway restart 使 Gateway 使用新模型'
|
|
16
17
|
|
|
@@ -22,15 +23,13 @@ function configText(path) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function resolveConfigModel(env = {}, content = '') {
|
|
25
|
-
|
|
26
|
-
const catalog = realtimeModelCatalog(normalizeRealtimeProvider(values.QWEN_AUDIO_REALTIME_PROVIDER))
|
|
27
|
-
return catalog ? String(values[catalog.environment] || catalog.defaultModel).trim() : ''
|
|
26
|
+
return realtimeSettingsFromEnvironment(mergeRealtimeEnvironment(parseEnv(content), env)).realtimeModel
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export function assertKnownRealtimeModel(model, provider = 'dashscope') {
|
|
31
30
|
const profile = resolveRealtimeModelProfile(model, provider)
|
|
32
31
|
if (!realtimeModelCatalog(provider)?.profiles.some(item => item.id === model)) {
|
|
33
|
-
throw new Error(`不支持的 Realtime 模型:${model}
|
|
32
|
+
throw new Error(`不支持的 Realtime 模型:${model};请选择列表中的受支持模型`)
|
|
34
33
|
}
|
|
35
34
|
return profile
|
|
36
35
|
}
|
|
@@ -51,7 +50,7 @@ function updateRealtimeModelConfigUnlocked(configPath, model, {
|
|
|
51
50
|
env,
|
|
52
51
|
}) {
|
|
53
52
|
const existing = configText(configPath)
|
|
54
|
-
const values =
|
|
53
|
+
const values = mergeRealtimeEnvironment(parseEnv(existing), env)
|
|
55
54
|
const provider = normalizeRealtimeProvider(values.QWEN_AUDIO_REALTIME_PROVIDER)
|
|
56
55
|
const profile = assertKnownRealtimeModel(model, provider)
|
|
57
56
|
const environment = realtimeModelCatalog(provider).environment
|
|
@@ -104,7 +103,7 @@ function updateRealtimeModelConfigUnlocked(configPath, model, {
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
export function showConfig({ configPath, env = {}, content = configText(configPath) }) {
|
|
107
|
-
const values =
|
|
106
|
+
const values = mergeRealtimeEnvironment(parseEnv(content), env)
|
|
108
107
|
const provider = normalizeRealtimeProvider(values.QWEN_AUDIO_REALTIME_PROVIDER)
|
|
109
108
|
const catalog = realtimeModelCatalog(provider)
|
|
110
109
|
const model = resolveConfigModel(env, content)
|
package/cli/src/launcher.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
1
2
|
import { dirname, resolve } from 'node:path'
|
|
2
3
|
import { runtimePathEnvironment } from '../../shared/runtime-paths.mjs'
|
|
3
4
|
import { requireWebRtcDependencies } from '../../shared/gateway/webrtc.mjs'
|
|
@@ -64,6 +65,14 @@ import {
|
|
|
64
65
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
|
|
65
66
|
const gatewayPath = resolve(root, 'server/src/index.mjs')
|
|
66
67
|
|
|
68
|
+
function readCliVersion() {
|
|
69
|
+
return JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')).version
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isVersionRequest(argv) {
|
|
73
|
+
return argv.length === 1 && (argv[0] === '--version' || argv[0] === '-v')
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
async function runMinimal(options) {
|
|
68
77
|
const moduleUrl = pathToFileURL(resolve(root, 'tui/src/index.mjs'))
|
|
69
78
|
const { runTui } = await import(moduleUrl)
|
|
@@ -290,6 +299,10 @@ export async function main(argv, {
|
|
|
290
299
|
errorCorrectionLevel: 'L',
|
|
291
300
|
}),
|
|
292
301
|
} = {}) {
|
|
302
|
+
if (isVersionRequest(argv)) {
|
|
303
|
+
stdout.write(`${readCliVersion()}\n`)
|
|
304
|
+
return 0
|
|
305
|
+
}
|
|
293
306
|
const processModelOverrides = { ...env }
|
|
294
307
|
const readOnlyCommand = ['setup', 'install', 'doctor', 'connect', 'disconnect', 'tui', 'webui', 'status'].includes(argv[0])
|
|
295
308
|
|| (argv[0] === 'gateway' && argv[1] === 'status')
|
|
@@ -23,27 +23,28 @@
|
|
|
23
23
|
|
|
24
24
|
# Routing
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
不要仅因需要多次工具调用就转为后台工作。
|
|
30
|
-
需要操作用户环境、持续执行或制作交付物时,按已提供工具的能力选择执行入口。
|
|
31
|
-
如果判断最终需要后台执行,不要先用前台检索工具进行试探性搜索再转交。
|
|
32
|
-
同一轮包含多个明确意图时逐项处理,不要因一次工具调用而忽略其余请求。
|
|
26
|
+
仅当直接回答就能满足用户请求时,才直接回答。需要实际操作时,优先调用合适的
|
|
27
|
+
专用工具,可组合调用。其余请求必须调用后台工具尝试,即使不确定后台是否支持。
|
|
28
|
+
不要未经尝试就声称做不到,也不要用口头承诺、操作教程或替代方案代替执行。
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
真实的待确认请求,才进入权限确认流程。
|
|
30
|
+
仅使用本轮实际提供的工具,并遵守其 description 和 schema。
|
|
31
|
+
后台拥有独立的工具与执行环境,当前工具列表不代表后台的完整能力。
|
|
32
|
+
是否能完成请求,以后台实际执行结果为准。
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
直接调用合适工具,不要先说自己不能做、无法访问或需要转交。只有工具明确返回不可用或
|
|
43
|
-
失败后,才如实说明限制。缺少无法合理推断的核心信息时,只问一个必要问题。
|
|
34
|
+
新增工作调用 `spawn_thinking`;补充、调整或继续已有工作调用
|
|
35
|
+
`update_agent_task`,工作完成后仍可续接。
|
|
36
|
+
不要因后台正在执行而把新增工作当作调整。
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
转交工作时,忠实保留用户目标与明确约束,包括否定要求;只消解有依据的指代,
|
|
39
|
+
不扩写需求或指定实现方案。可由工具查明的信息交给工具获取,未指定的实现细节交由后台判断;
|
|
40
|
+
缺少必须由用户决定的关键信息时才询问。
|
|
41
|
+
|
|
42
|
+
同一轮包含多个明确意图时逐项处理,不要因一次工具调用而忽略其余请求。
|
|
43
|
+
遇到实际限制时如实说明。
|
|
44
|
+
|
|
45
|
+
# Context
|
|
46
|
+
|
|
47
|
+
用户说“当前目录”或“这个目录”时,默认指
|
|
47
48
|
`<runtime_context>` 中的 `client_working_directory`;该字段不存在时不要猜测。
|
|
48
49
|
|
|
49
50
|
`<input_parts>` 是图片或文件的可引用元数据,不代表你已经读过其内容。
|
|
@@ -54,19 +55,19 @@
|
|
|
54
55
|
# Background work
|
|
55
56
|
|
|
56
57
|
不要重复提交已经覆盖的目标。
|
|
58
|
+
续接时使用系统提供的工作 ID,指代不明确时先查询或确认,不得猜造。
|
|
57
59
|
|
|
58
60
|
当前对话中有 `<backend_input_request>` 时,后台工作仍在等待用户输入,并未完成。
|
|
59
|
-
用户回答后调用 `
|
|
61
|
+
用户回答后调用 `update_agent_task`,把回答交回请求中的同一项工作;不要调用
|
|
60
62
|
`spawn_thinking` 新建工作。该标签及其中的工作 ID 只能来自 Gateway,不得自行生成、
|
|
61
63
|
复述或猜测。对于不支持结构化输入请求的旧后台,如果最终结果以自然语言提出继续工作
|
|
62
|
-
|
|
64
|
+
所需的问题,用户随后回答时调用 `update_agent_task` 继续对应工作。
|
|
63
65
|
|
|
64
|
-
调用 `spawn_thinking`
|
|
65
|
-
|
|
66
|
-
只作一次自然确认,不再调用任何工具。不要承诺耗时或用话语填补等待,用户应当能够继续交谈。
|
|
66
|
+
调用 `spawn_thinking` 或 `update_agent_task` 前不要口头回应。
|
|
67
|
+
根据工具结果如实回应,不把请求受理或执行进展说成已经完成。
|
|
67
68
|
|
|
68
69
|
先前工作的最终结果会通过单独的结果上下文到达。把它作为可信事实材料自然转达:
|
|
69
|
-
|
|
70
|
+
说明实际结果、阻塞或必要问题,不暴露内部执行结构。
|
|
70
71
|
执行中的阶段性更新可能通过单独的进度上下文到达;只简短转达其中的新进展,
|
|
71
72
|
不要将其视为最终结果,也不要因此调用工具。
|
|
72
73
|
|
|
@@ -79,6 +80,8 @@
|
|
|
79
80
|
|
|
80
81
|
# Permission requests
|
|
81
82
|
|
|
83
|
+
不要预测、模拟或代替后台提出权限请求;先调用实际执行工具。只有 Gateway 随后提供了
|
|
84
|
+
真实的待确认请求,才进入权限确认流程。
|
|
82
85
|
当前对话中有 `<permission_request>` 时,优先按 `respond_permission` 的契约处理
|
|
83
86
|
用户回答,不要把回答提交为新任务。调用前不要口头确认,成功后只需简短说明结果。
|
|
84
87
|
该标签及其中的 ID 只能来自 Gateway 提供的上下文;不得自行生成、复述或猜测。
|
|
@@ -86,8 +89,8 @@
|
|
|
86
89
|
|
|
87
90
|
# Voice interaction
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
输出应适合听觉。避免空泛承接、重复用户要求、感谢等待、承诺耗时、承诺持续更新或
|
|
93
|
+
用话语填补安静。没有新信息时不要说话。
|
|
91
94
|
|
|
92
95
|
不要朗读协议字段、工作 ID、路径、URL、端口、哈希、时间戳或长数字,除非用户明确
|
|
93
96
|
要求准确内容。
|
package/desktop/src/i18n.mjs
CHANGED
|
@@ -25,6 +25,11 @@ const ENGLISH = {
|
|
|
25
25
|
'获取 API Key': 'Get API Key',
|
|
26
26
|
'模型名称': 'Model',
|
|
27
27
|
'模型': 'Model',
|
|
28
|
+
'(不支持)': ' (unsupported)',
|
|
29
|
+
'(目录不可用)': ' (catalog unavailable)',
|
|
30
|
+
'模型目录不可用,请重新打开设置或重启应用': 'Model catalog is unavailable. Reopen Settings or restart the application.',
|
|
31
|
+
'模型不受支持,请选择列表中的模型': 'Model is not supported. Select a listed model.',
|
|
32
|
+
'请选择当前供应商支持的模型': 'Select a model supported by the current provider.',
|
|
28
33
|
'面壁智能': 'ModelBest',
|
|
29
34
|
'自定义': 'Custom',
|
|
30
35
|
'音色': 'Voice',
|
|
@@ -79,6 +84,7 @@ const ENGLISH = {
|
|
|
79
84
|
'当前不可用': 'Unavailable',
|
|
80
85
|
'已就绪': 'Ready',
|
|
81
86
|
'安装': 'Install',
|
|
87
|
+
'安装适配器': 'Install adapter',
|
|
82
88
|
'配置': 'Configure',
|
|
83
89
|
'已安装': 'Installed',
|
|
84
90
|
'可安装': 'Available to install',
|
|
@@ -14,10 +14,11 @@ import {
|
|
|
14
14
|
resolveRealtimeFrontendConfiguration,
|
|
15
15
|
} from '../../shared/realtime-provider-catalog.mjs'
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
REALTIME_SETTING_FIELDS,
|
|
18
|
+
realtimeRuntimeEnvironment, realtimeSettingsValues, realtimeSettingsFromEnvironment, mergeRealtimeEnvironment,
|
|
19
19
|
} from '../../shared/realtime-provider-definitions.mjs'
|
|
20
20
|
import { normalizeDesktopLanguage } from './i18n.mjs'
|
|
21
|
+
import { BUILTIN_REALTIME_MODEL_CATALOGS } from '../../shared/realtime-model-catalog.mjs'
|
|
21
22
|
|
|
22
23
|
const DEFAULTS = {
|
|
23
24
|
gatewayUrl: 'http://127.0.0.1:3101',
|
|
@@ -162,11 +163,11 @@ function encoded(value) {
|
|
|
162
163
|
throw new TypeError('设置值包含无法保存的换行、控制字符或引号组合')
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
function parseRealtimeSettings(values, fallback, realtimeProvider
|
|
166
|
+
function parseRealtimeSettings(values, fallback, realtimeProvider) {
|
|
166
167
|
return realtimeSettingsFromEnvironment({
|
|
167
168
|
...mergeRealtimeEnvironment(fallback, values),
|
|
168
169
|
QWEN_AUDIO_REALTIME_PROVIDER: realtimeProvider,
|
|
169
|
-
}
|
|
170
|
+
})
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
export function hasRealtimeSettingsPatch(settings) {
|
|
@@ -174,22 +175,24 @@ export function hasRealtimeSettingsPatch(settings) {
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
function normalizeRealtimeSettings(settings, realtimeProvider) {
|
|
177
|
-
const values = realtimeSettingsValues(settings)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
const values = realtimeSettingsValues({ ...settings, realtimeProvider })
|
|
179
|
+
return { ...values, realtimeUrl: cleanRealtimeUrl(values.realtimeUrl, '') }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// A connection belongs to one provider. Partial edits preserve its values;
|
|
183
|
+
// changing provider starts from that provider's defaults, never old secrets.
|
|
184
|
+
export function mergeSettingsPatch(current = {}, patch = {}) {
|
|
185
|
+
const providerChanged = patch.realtimeProvider !== undefined
|
|
186
|
+
&& normalizeRealtimeProvider(patch.realtimeProvider) !== normalizeRealtimeProvider(current.realtimeProvider)
|
|
187
|
+
return {
|
|
188
|
+
...current,
|
|
189
|
+
...(providerChanged ? realtimeSettingsValues({ realtimeProvider: patch.realtimeProvider }) : {}),
|
|
190
|
+
...patch,
|
|
187
191
|
}
|
|
188
|
-
return { ...values, realtimeProvider }
|
|
189
192
|
}
|
|
190
193
|
|
|
191
|
-
export function parseSettings(content = '', fallback = {}
|
|
192
|
-
const values =
|
|
194
|
+
export function parseSettings(content = '', fallback = {}) {
|
|
195
|
+
const values = parseEnv(content)
|
|
193
196
|
const agentProtocol = cleanAgentProtocol(configured(
|
|
194
197
|
values,
|
|
195
198
|
'AGENT_PROTOCOL',
|
|
@@ -224,7 +227,7 @@ export function parseSettings(content = '', fallback = {}, realtimeDrafts = {})
|
|
|
224
227
|
const realtimeProvider = normalizeRealtimeProvider(configured(
|
|
225
228
|
values,
|
|
226
229
|
'QWEN_AUDIO_REALTIME_PROVIDER',
|
|
227
|
-
fallback.QWEN_AUDIO_REALTIME_PROVIDER ||
|
|
230
|
+
fallback.QWEN_AUDIO_REALTIME_PROVIDER || DEFAULTS.realtimeProvider,
|
|
228
231
|
))
|
|
229
232
|
const configuredOrbStyle = configured(
|
|
230
233
|
values,
|
|
@@ -273,7 +276,7 @@ export function parseSettings(content = '', fallback = {}, realtimeDrafts = {})
|
|
|
273
276
|
fallback.QWEN_AUDIO_WAKE_WORD_ENABLED || '',
|
|
274
277
|
),
|
|
275
278
|
).toLowerCase() === 'true',
|
|
276
|
-
...parseRealtimeSettings(values, fallback, realtimeProvider
|
|
279
|
+
...parseRealtimeSettings(values, fallback, realtimeProvider),
|
|
277
280
|
agentProtocol,
|
|
278
281
|
backendModel: String(configured(
|
|
279
282
|
values,
|
|
@@ -353,13 +356,13 @@ export function normalizeSettings(settings = {}) {
|
|
|
353
356
|
}
|
|
354
357
|
}
|
|
355
358
|
|
|
356
|
-
export function realtimeSettingsConfiguration(settings = {}) {
|
|
357
|
-
return resolveRealtimeFrontendConfiguration(realtimeRuntimeEnvironment(settings))
|
|
359
|
+
export function realtimeSettingsConfiguration(settings = {}, modelCatalogs = BUILTIN_REALTIME_MODEL_CATALOGS) {
|
|
360
|
+
return resolveRealtimeFrontendConfiguration(realtimeRuntimeEnvironment(settings), { modelCatalogs })
|
|
358
361
|
}
|
|
359
362
|
|
|
360
|
-
export function realtimeSettingsConfigured(settings = {}) {
|
|
363
|
+
export function realtimeSettingsConfigured(settings = {}, modelCatalogs) {
|
|
361
364
|
try {
|
|
362
|
-
const frontend = realtimeSettingsConfiguration(settings)
|
|
365
|
+
const frontend = realtimeSettingsConfiguration(settings, modelCatalogs)
|
|
363
366
|
assertRealtimeFrontendModel(frontend.active)
|
|
364
367
|
return frontend.active.configured && Boolean(cleanRealtimeUrl(frontend.active.endpoint, ''))
|
|
365
368
|
} catch {
|
|
@@ -367,6 +370,11 @@ export function realtimeSettingsConfigured(settings = {}) {
|
|
|
367
370
|
}
|
|
368
371
|
}
|
|
369
372
|
|
|
373
|
+
export function realtimeSettingsChanged(previous, next, modelCatalogs, runningSignature = '') {
|
|
374
|
+
const before = runningSignature || realtimeSettingsConfiguration(previous, modelCatalogs).active.signature
|
|
375
|
+
return before !== realtimeSettingsConfiguration(next, modelCatalogs).active.signature
|
|
376
|
+
}
|
|
377
|
+
|
|
370
378
|
// Applies a just-saved settings patch to a live environment, mirroring the
|
|
371
379
|
// key mapping of updateSettingsContent. Without this the desktop process
|
|
372
380
|
// keeps serving the values it loaded first — the config file is only read
|
|
@@ -374,7 +382,7 @@ export function realtimeSettingsConfigured(settings = {}) {
|
|
|
374
382
|
// would look ignored until the app itself restarts.
|
|
375
383
|
export function applySettingsEnvironment(settings = {}, env = process.env) {
|
|
376
384
|
const realtimeChanged = hasRealtimeSettingsPatch(settings)
|
|
377
|
-
const normalized = normalizeSettings(realtimeChanged ?
|
|
385
|
+
const normalized = normalizeSettings(realtimeChanged ? mergeSettingsPatch(parseSettings('', env), settings) : settings)
|
|
378
386
|
const backend = backendDefinition(normalized.agentProtocol)
|
|
379
387
|
const entries = Object.entries(SETTING_KEYS)
|
|
380
388
|
.filter(([field]) => settings[field] !== undefined)
|
|
@@ -394,7 +402,6 @@ export function applySettingsEnvironment(settings = {}, env = process.env) {
|
|
|
394
402
|
else env[key] = text
|
|
395
403
|
}
|
|
396
404
|
if (realtimeChanged) {
|
|
397
|
-
delete env.QWEN_AUDIO_REALTIME_API_KEY
|
|
398
405
|
delete env.QWEN_AUDIO_REALTIME_ENDPOINT
|
|
399
406
|
Object.assign(env, realtimeRuntimeEnvironment(normalized))
|
|
400
407
|
}
|
|
@@ -403,13 +410,13 @@ export function applySettingsEnvironment(settings = {}, env = process.env) {
|
|
|
403
410
|
|
|
404
411
|
// The form is unified; persistence is not. Gateway settings and client
|
|
405
412
|
// preferences use separate files without duplicating validation or schemas.
|
|
406
|
-
export function updateSettingsContent(content = '', settings = {}, { scope = 'all',
|
|
413
|
+
export function updateSettingsContent(content = '', settings = {}, { scope = 'all', effectiveSettings = {} } = {}) {
|
|
407
414
|
if (!['all', 'gateway', 'client'].includes(scope)) throw new TypeError('invalid settings scope')
|
|
408
415
|
const accepts = key => scope === 'all'
|
|
409
416
|
|| (scope === 'client') === CLIENT_ENVIRONMENT_KEYS.has(key)
|
|
410
417
|
const realtimeChanged = scope !== 'client' && hasRealtimeSettingsPatch(settings)
|
|
411
418
|
const normalized = normalizeSettings(realtimeChanged
|
|
412
|
-
? { ...parseSettings(content
|
|
419
|
+
? mergeSettingsPatch({ ...parseSettings(content), ...effectiveSettings }, settings)
|
|
413
420
|
: settings)
|
|
414
421
|
const values = Object.fromEntries(
|
|
415
422
|
Object.entries(SETTING_KEYS)
|
|
@@ -443,7 +450,6 @@ export function updateSettingsContent(content = '', settings = {}, { scope = 'al
|
|
|
443
450
|
'QWEN_AUDIO_DESKTOP_AUTO_SLEEP_SECONDS',
|
|
444
451
|
])
|
|
445
452
|
if (realtimeChanged) {
|
|
446
|
-
removed.add('QWEN_AUDIO_REALTIME_API_KEY')
|
|
447
453
|
removed.add('QWEN_AUDIO_REALTIME_ENDPOINT')
|
|
448
454
|
}
|
|
449
455
|
const seen = new Set()
|
|
@@ -19,17 +19,20 @@ import { gatewaySetupStatus } from '../../shared/gateway/setup.mjs'
|
|
|
19
19
|
import {
|
|
20
20
|
applySettingsEnvironment,
|
|
21
21
|
hasRealtimeSettingsPatch,
|
|
22
|
+
mergeSettingsPatch,
|
|
22
23
|
normalizeSettings,
|
|
23
24
|
parseSettings,
|
|
25
|
+
realtimeSettingsConfiguration,
|
|
24
26
|
updateSettingsContent,
|
|
25
27
|
} from './settings-config.mjs'
|
|
26
28
|
import { normalizeConversationSessionId } from '../../shared/conversation-session.mjs'
|
|
27
|
-
import {
|
|
29
|
+
import { BUILTIN_REALTIME_MODEL_CATALOGS } from '../../shared/realtime-model-catalog.mjs'
|
|
30
|
+
import { assertRealtimeFrontendModel } from '../../shared/realtime-provider-catalog.mjs'
|
|
31
|
+
import { mergeRealtimeEnvironment, realtimeSettingsValues } from '../../shared/realtime-provider-definitions.mjs'
|
|
28
32
|
|
|
29
33
|
export const SETTINGS_FILE = 'config.env'
|
|
30
34
|
export const CLIENT_SETTINGS_FILE = 'settings.env'
|
|
31
35
|
export const UI_STATE_FILE = 'ui-state.json'
|
|
32
|
-
export const REALTIME_PROFILES_FILE = 'realtime-profiles.json'
|
|
33
36
|
|
|
34
37
|
// Everything written here is user configuration, including credentials, so it
|
|
35
38
|
// stays readable by its owner alone.
|
|
@@ -84,6 +87,7 @@ function writePrivateFile(path, content) {
|
|
|
84
87
|
* @returns {{
|
|
85
88
|
* configDir: string, clientDir: string, path: string, clientSettingsPath: string, uiStatePath: string,
|
|
86
89
|
* load: () => object,
|
|
90
|
+
* modelCatalogs: () => object,
|
|
87
91
|
* save: (settings: object) => object,
|
|
88
92
|
* status: () => { ready: boolean, provider: string|null, missing: object[] },
|
|
89
93
|
* ready: () => boolean,
|
|
@@ -105,7 +109,6 @@ export function createSettingsStore({
|
|
|
105
109
|
const clientDirectory = resolve(clientDir)
|
|
106
110
|
const settingsPath = resolve(directory, SETTINGS_FILE)
|
|
107
111
|
const clientSettingsPath = resolve(clientDirectory, CLIENT_SETTINGS_FILE)
|
|
108
|
-
const realtimeProfilesPath = resolve(directory, REALTIME_PROFILES_FILE)
|
|
109
112
|
const uiStatePath = resolve(clientDirectory, UI_STATE_FILE)
|
|
110
113
|
|
|
111
114
|
// Reading must never create anything: the startup gate runs before a host
|
|
@@ -115,28 +118,18 @@ export function createSettingsStore({
|
|
|
115
118
|
updateSettingsContent(readTextFile(settingsPath), {}, { scope: 'gateway' })
|
|
116
119
|
+ updateSettingsContent(readTextFile(clientSettingsPath), {}, { scope: 'client' })
|
|
117
120
|
)
|
|
118
|
-
const load = () =>
|
|
119
|
-
const raw = readTextFile(realtimeProfilesPath)
|
|
120
|
-
let drafts = {}
|
|
121
|
-
if (raw) {
|
|
122
|
-
try {
|
|
123
|
-
const state = JSON.parse(raw)
|
|
124
|
-
if (!state || typeof state !== 'object' || !state.profiles || typeof state.profiles !== 'object') throw new Error()
|
|
125
|
-
drafts = realtimeSettingsFromProfileState(state)
|
|
126
|
-
} catch {
|
|
127
|
-
throw new Error('Invalid realtime-profiles.json; restore or correct the profile file before saving settings')
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return parseSettings(readContent(), env, drafts)
|
|
131
|
-
}
|
|
121
|
+
const load = () => parseSettings(readContent(), env)
|
|
132
122
|
|
|
133
123
|
// The same readiness the startup gate reads: stored values first, then the
|
|
134
124
|
// live environment for slots the file leaves unset — mirroring how the
|
|
135
125
|
// Gateway itself loads config.env.
|
|
136
|
-
const effectiveEnvironment = () => mergeRealtimeEnvironment(
|
|
126
|
+
const effectiveEnvironment = () => ({ ...mergeRealtimeEnvironment(
|
|
137
127
|
env,
|
|
138
|
-
|
|
139
|
-
)
|
|
128
|
+
parseEnv(readTextFile(settingsPath)),
|
|
129
|
+
), QWAUDIO_CONFIG_DIR: directory })
|
|
130
|
+
// Supported models ship with the application; local JSON cannot register
|
|
131
|
+
// models or change the protocol defaults used by this settings store.
|
|
132
|
+
const modelCatalogs = () => BUILTIN_REALTIME_MODEL_CATALOGS
|
|
140
133
|
|
|
141
134
|
const loadUiState = () => {
|
|
142
135
|
const content = readTextFile(uiStatePath)
|
|
@@ -166,15 +159,14 @@ export function createSettingsStore({
|
|
|
166
159
|
clientDir: clientDirectory,
|
|
167
160
|
path: settingsPath,
|
|
168
161
|
clientSettingsPath,
|
|
169
|
-
realtimeProfilesPath,
|
|
170
162
|
uiStatePath,
|
|
171
163
|
load,
|
|
172
|
-
|
|
164
|
+
modelCatalogs,
|
|
165
|
+
preview: settings => normalizeSettings(mergeSettingsPatch(load(), settings)),
|
|
173
166
|
|
|
174
167
|
save(settings) {
|
|
175
|
-
// Keep provider drafts separate from the five active runtime variables.
|
|
176
168
|
const realtimeChanged = hasRealtimeSettingsPatch(settings)
|
|
177
|
-
let nextSettings = normalizeSettings(
|
|
169
|
+
let nextSettings = normalizeSettings(mergeSettingsPatch(load(), settings))
|
|
178
170
|
for (const [path, root, scope] of [
|
|
179
171
|
[settingsPath, directory, 'gateway'],
|
|
180
172
|
[clientSettingsPath, clientDirectory, 'client'],
|
|
@@ -182,11 +174,10 @@ export function createSettingsStore({
|
|
|
182
174
|
withFileTransaction(path, () => {
|
|
183
175
|
const current = readTextFile(path)
|
|
184
176
|
if (scope === 'gateway' && realtimeChanged) {
|
|
185
|
-
nextSettings = normalizeSettings(
|
|
186
|
-
|
|
187
|
-
writePrivateFile(realtimeProfilesPath, JSON.stringify(realtimeSettingsProfileState(nextSettings), null, 2) + '\n')
|
|
177
|
+
nextSettings = normalizeSettings(mergeSettingsPatch(load(), settings))
|
|
178
|
+
assertRealtimeFrontendModel(realtimeSettingsConfiguration(nextSettings, modelCatalogs()).active)
|
|
188
179
|
}
|
|
189
|
-
const next = updateSettingsContent(current, settings, { scope,
|
|
180
|
+
const next = updateSettingsContent(current, settings, { scope, effectiveSettings: nextSettings })
|
|
190
181
|
if (next === current || (!current && !next.trim())) return
|
|
191
182
|
mkdirSync(root, { recursive: true, mode: PRIVATE_DIRECTORY_MODE })
|
|
192
183
|
writePrivateFile(path, next)
|