qwen-audio-agent 1.10.0 → 1.10.1
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 +16 -4
- package/README_ZH.md +13 -4
- package/cli/package.json +1 -1
- package/cli/src/launcher.mjs +3 -2
- package/docs/configuration.md +9 -3
- package/docs/configuration.zh.md +8 -2
- package/package.json +1 -1
- package/server/package.json +1 -1
- package/server/src/agent/acp-backend-adapter.mjs +112 -33
- package/server/src/agent/acp-process-client.mjs +27 -4
- package/server/src/agent/agent-client.mjs +13 -1
- package/server/src/app/bootstrap.mjs +19 -6
- package/server/src/conversation/memory-extractor.mjs +27 -2
- package/shared/backend-auth-status.mjs +31 -35
- package/shared/backend-catalog.mjs +1 -14
- package/shared/backend-install.mjs +176 -40
- package/shared/backend-lifecycle.mjs +32 -40
- package/shared/backend-onboarding.mjs +130 -0
- package/shared/backend-setup.mjs +103 -10
- package/shared/path-environment.mjs +36 -0
- package/tui/package.json +1 -1
- package/web/dist/assets/{index-CvDxtcYA.js → index-4IeKEmc-.js} +1 -1
- package/web/dist/index.html +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ tells you:
|
|
|
26
26
|
|
|
27
27
|
## News
|
|
28
28
|
|
|
29
|
+
- **2026-08-15 · [v1.10.1](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.10.1)**
|
|
30
|
+
🐛 Fixed known issues; 🖥️ improved desktop usability.
|
|
29
31
|
- **2026-08-13 · [v1.10.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.10.0)**
|
|
30
32
|
🐋 Added experimental DeepSeek Harness backend support with one-click installation.
|
|
31
33
|
- **2026-08-13 · [v1.9.1](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.9.1)**
|
|
@@ -75,11 +77,13 @@ https://github.com/user-attachments/assets/42022655-36d1-46b2-9c26-ff0765284000
|
|
|
75
77
|
### Core Features
|
|
76
78
|
|
|
77
79
|
- Full-duplex realtime voice interaction, natural interruption, and sustained multi-turn conversation
|
|
80
|
+
- DashScope Qwen Audio and Qwen3.5 Omni Realtime model selection from one shared model catalog
|
|
78
81
|
- One-click selection of your preferred coding Agent, reusing existing tools, MCP, and Skills
|
|
79
82
|
- Frontend conversation and background tasks run in parallel; ask about progress or cancel at any time
|
|
80
83
|
- Create multiple independent tasks executed asynchronously by the backend Agent, with continuous status tracking
|
|
81
84
|
- Task results automatically return to the current conversation, supporting follow-up questions and modifications
|
|
82
85
|
- WebUI, terminal TUI, and desktop floating orb (macOS / Windows / Linux)
|
|
86
|
+
- Desktop auto-sleep disconnects cloud Realtime without stopping submitted tasks; wake with a configurable shortcut or the local wake word
|
|
83
87
|
- Per-user long-term personalization and cross-session memory
|
|
84
88
|
|
|
85
89
|
## Architecture
|
|
@@ -141,7 +145,7 @@ qwenaudio config
|
|
|
141
145
|
|
|
142
146
|
```dotenv
|
|
143
147
|
DASHSCOPE_API_KEY=your-key
|
|
144
|
-
# Voice frontend model: Omni Flash/Plus or Audio Flash/Plus (Plus is default)
|
|
148
|
+
# Voice frontend model: Omni Flash/Plus or Audio Flash/Plus (Audio Plus is default)
|
|
145
149
|
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.0-realtime-plus
|
|
146
150
|
# Backend Agent: optional, leave empty or set to none for frontend-only mode
|
|
147
151
|
AGENT_PROTOCOL=openclaw
|
|
@@ -174,7 +178,11 @@ platform notes, see [quick start](docs/getting-started/quickstart.md),
|
|
|
174
178
|
## Desktop App
|
|
175
179
|
|
|
176
180
|
The desktop app provides a floating voice orb that stays on your desktop,
|
|
177
|
-
with a built-in Gateway,
|
|
181
|
+
with a built-in Gateway, automatic idle sleep, a configurable wake shortcut,
|
|
182
|
+
and a local voice wake word. Sleep disconnects the Realtime frontend while
|
|
183
|
+
keeping the app, Gateway, backend Agent, and submitted tasks alive; it is not
|
|
184
|
+
the same as quitting or restarting the desktop app. Completed tasks can wake
|
|
185
|
+
the app and return their results to the conversation.
|
|
178
186
|
Download the installer for your platform from the releases page, or build
|
|
179
187
|
from source:
|
|
180
188
|
|
|
@@ -190,8 +198,12 @@ For visuals, orb behavior, and build instructions, see the [desktop documentatio
|
|
|
190
198
|
|
|
191
199
|
`AGENT_PROTOCOL` is optional. Leave empty for frontend-only mode; when set,
|
|
192
200
|
it reuses the installed Agent's user-level models, tools, MCP, Skills, and
|
|
193
|
-
authentication.
|
|
194
|
-
|
|
201
|
+
authentication. The CLI and desktop app share one onboarding contract: reuse
|
|
202
|
+
an existing Agent when available, install only missing components when the
|
|
203
|
+
user requests one-click installation, and keep installation, configuration,
|
|
204
|
+
and runtime readiness as separate states. Configuration stays backend-owned;
|
|
205
|
+
the desktop app opens the Agent's native setup entry instead of copying or
|
|
206
|
+
rewriting its credentials.
|
|
195
207
|
|
|
196
208
|
```bash
|
|
197
209
|
qwenaudio setup # View available backend Agents
|
package/README_ZH.md
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
## News
|
|
22
22
|
|
|
23
|
+
- **2026-08-15 · [v1.10.1](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.10.1)**
|
|
24
|
+
🐛 修复若干已知问题;🖥️ 提升桌面版易用性。
|
|
23
25
|
- **2026-08-13 · [v1.10.0](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.10.0)**
|
|
24
26
|
🐋 新增实验性 DeepSeek Harness 后台接入,支持一键安装。
|
|
25
27
|
- **2026-08-13 · [v1.9.1](https://github.com/QwenAudio/qwen-audio-agent/releases/tag/v1.9.1)**
|
|
@@ -68,11 +70,13 @@ https://github.com/user-attachments/assets/42022655-36d1-46b2-9c26-ff0765284000
|
|
|
68
70
|
### 核心特色
|
|
69
71
|
|
|
70
72
|
- 全双工实时语音交互、自然打断和持续多轮对话
|
|
73
|
+
- 从统一模型目录选择 DashScope Qwen Audio 与 Qwen3.5 Omni Realtime 模型
|
|
71
74
|
- 一键选择你喜欢的办事 Agent,复用已有的工具、MCP、Skill
|
|
72
75
|
- 前台对话与后台任务并驾齐驱,可随时追问任务进度或取消任务
|
|
73
76
|
- 支持创建多个独立任务,由后台 Agent 异步执行,并持续追踪任务状态
|
|
74
77
|
- 任务结果自动回到当前对话,支持继续追问和修改
|
|
75
78
|
- 支持 WebUI、终端 TUI 和桌面悬浮球(macOS / Windows / Linux)
|
|
79
|
+
- 桌面版自动休眠时断开云端 Realtime,但不停止已提交任务;可通过自定义快捷键或本地唤醒词恢复
|
|
76
80
|
- 支持当前用户的长期个性化覆盖与跨会话记忆
|
|
77
81
|
|
|
78
82
|
## 参考架构
|
|
@@ -132,7 +136,7 @@ qwenaudio config
|
|
|
132
136
|
|
|
133
137
|
```dotenv
|
|
134
138
|
DASHSCOPE_API_KEY=your-key
|
|
135
|
-
# 语音前台模型:Omni Flash/Plus 或 Audio Flash/Plus
|
|
139
|
+
# 语音前台模型:Omni Flash/Plus 或 Audio Flash/Plus(默认 Audio Plus)
|
|
136
140
|
QWEN_AUDIO_REALTIME_MODEL=qwen-audio-3.0-realtime-plus
|
|
137
141
|
# 后台Agent:可选,不设置或设置为 none 时,启动仅前台模式
|
|
138
142
|
AGENT_PROTOCOL=openclaw
|
|
@@ -162,8 +166,10 @@ qwenaudio tui # 终端 2:TUI
|
|
|
162
166
|
|
|
163
167
|
## 桌面版
|
|
164
168
|
|
|
165
|
-
桌面版提供常驻桌面的语音悬浮球,内置 Gateway
|
|
166
|
-
|
|
169
|
+
桌面版提供常驻桌面的语音悬浮球,内置 Gateway,支持空闲自动休眠、自定义唤醒
|
|
170
|
+
快捷键和本地语音唤醒。休眠时会断开 Realtime 前台,但桌面进程、Gateway、后台
|
|
171
|
+
Agent 和已提交任务仍继续运行;它不等于退出或重启桌面版。任务完成后可以唤醒
|
|
172
|
+
桌面版,并把结果带回当前对话。从发布页下载对应平台安装包,或从源码构建:
|
|
167
173
|
|
|
168
174
|
```bash
|
|
169
175
|
npm run desktop:build:local # macOS
|
|
@@ -176,7 +182,10 @@ npm run desktop:build:linux # Linux(AppImage + deb,无需签名)
|
|
|
176
182
|
## 后台 Agent
|
|
177
183
|
|
|
178
184
|
`AGENT_PROTOCOL` 可选。留空即仅前台模式;选择后可复用已安装 Agent 的用户级
|
|
179
|
-
模型、工具、MCP、Skill 和认证。
|
|
185
|
+
模型、工具、MCP、Skill 和认证。CLI 与桌面版共用同一套接入规范:检测到已有 Agent
|
|
186
|
+
时直接复用;用户选择一键安装时只补齐缺失组件;安装、配置和运行状态分别判断。
|
|
187
|
+
配置仍由后台 Agent 自己负责,桌面版打开其原生配置入口,不读取、复制或改写它的
|
|
188
|
+
凭据。
|
|
180
189
|
|
|
181
190
|
```bash
|
|
182
191
|
qwenaudio setup # 查看当前可用的后台 Agent
|
package/cli/package.json
CHANGED
package/cli/src/launcher.mjs
CHANGED
|
@@ -233,11 +233,12 @@ export async function main(argv, {
|
|
|
233
233
|
? `✓ ${label} 已安装\n`
|
|
234
234
|
: `✓ ${label} 安装完成\n`,
|
|
235
235
|
)
|
|
236
|
+
const configurationHint = result.configurationHint || result.loginHint
|
|
236
237
|
if (
|
|
237
|
-
|
|
238
|
+
configurationHint
|
|
238
239
|
&& result.authentication?.status !== 'authenticated'
|
|
239
240
|
) {
|
|
240
|
-
stdout.write(`${
|
|
241
|
+
stdout.write(`${configurationHint}\n`)
|
|
241
242
|
}
|
|
242
243
|
return 0
|
|
243
244
|
}
|
package/docs/configuration.md
CHANGED
|
@@ -43,7 +43,7 @@ It checks the backend executable, ACP integration method, and necessary Adapters
|
|
|
43
43
|
displays the current selection. The check command itself does not install or download the backend
|
|
44
44
|
Agent, does not trigger login, and does not output or validate credentials or modify model
|
|
45
45
|
configuration. It indicates whether OpenCode/OpenClaw can automatically download and configure
|
|
46
|
-
itself at formal startup; the
|
|
46
|
+
itself at formal startup; the configuration status of other backends is managed by the Agent
|
|
47
47
|
itself.
|
|
48
48
|
|
|
49
49
|
To check only a specified backend or get machine-readable results:
|
|
@@ -78,8 +78,8 @@ qwenaudio install deepseek
|
|
|
78
78
|
- ACP adapters for Codex and Claude Code are provided together with the main body; Hermes uses
|
|
79
79
|
the official installation script. Script-type steps display the full command before execution
|
|
80
80
|
and wait for confirmation; `--yes` skips confirmation (use with caution).
|
|
81
|
-
- After installation
|
|
82
|
-
|
|
81
|
+
- After installation, backend availability is detected again automatically; backends that need
|
|
82
|
+
initialization, login, or credentials expose one consistent **Configure** action.
|
|
83
83
|
- The generic `acp` backend does not provide one-click installation; please install it yourself
|
|
84
84
|
and configure it via `ACP_COMMAND`.
|
|
85
85
|
- In the "Backend Agent" list on the desktop edition settings page, backends that are not
|
|
@@ -87,6 +87,12 @@ qwenaudio install deepseek
|
|
|
87
87
|
the row, using the same installation logic as the CLI; script-type installations will pop up
|
|
88
88
|
a native confirmation dialog.
|
|
89
89
|
|
|
90
|
+
Desktop provides a shared shell for installation, configuration, and connection state without
|
|
91
|
+
encoding any Agent-specific login flow. Each backend onboarding adapter declares its trusted
|
|
92
|
+
configuration entry and status probe. An adapter may open a terminal today and can later provide
|
|
93
|
+
a browser, form, or instructions action without changing product-specific logic in Settings.
|
|
94
|
+
The renderer submits only a backend ID and can never assemble or execute configuration commands.
|
|
95
|
+
|
|
90
96
|
DeepSeek Harness is currently an experimental integration. After installation,
|
|
91
97
|
run `dsh web` and configure the official API key in its model settings. The ACP
|
|
92
98
|
integration reuses that credential. Its model setting is intentionally separate
|
package/docs/configuration.zh.md
CHANGED
|
@@ -39,7 +39,7 @@ qwenaudio setup
|
|
|
39
39
|
它会检查后台可执行文件、ACP 接入方式和必要的 Adapter,并明确显示当前选择。
|
|
40
40
|
检查命令本身不会安装或下载后台 Agent,不会触发登录,也不会输出或验证凭据、修改模型
|
|
41
41
|
配置。它会提示 OpenCode/OpenClaw 是否能在正式启动时自动下载和配置;其他后台
|
|
42
|
-
|
|
42
|
+
的配置状态由 Agent 自己管理。
|
|
43
43
|
|
|
44
44
|
只检查指定后台或获取机器可读结果:
|
|
45
45
|
|
|
@@ -67,11 +67,17 @@ qwenaudio install deepseek
|
|
|
67
67
|
- Codex、Claude Code 的 ACP 适配器随本体一并提供;Hermes 使用官方安装
|
|
68
68
|
脚本。脚本类步骤执行前会逐个展示完整命令并等待确认,`--yes` 跳过确认
|
|
69
69
|
(谨慎使用)。
|
|
70
|
-
-
|
|
70
|
+
- 安装完成后自动重新检测该后台的可用状态;需要初始化、登录或填写凭据的后台会
|
|
71
|
+
给出统一的“配置”入口。
|
|
71
72
|
- 通用 `acp` 后台不提供一键安装,请自行安装后通过 `ACP_COMMAND` 配置。
|
|
72
73
|
- 桌面版设置页的“后台 Agent”列表中,未安装且支持一键安装的后台行尾会显示
|
|
73
74
|
“安装”按钮,与 CLI 使用同一份安装逻辑;脚本类安装会弹出原生确认框。
|
|
74
75
|
|
|
76
|
+
桌面版只提供统一的安装、配置和连接状态外壳,不理解具体 Agent 的登录流程。
|
|
77
|
+
每个后台 Onboarding Adapter 声明自己的受信配置入口与状态检测方式;目前入口可以
|
|
78
|
+
打开官方终端流程,后续也可扩展为网页、表单或纯说明,而不需要修改设置页的产品逻辑。
|
|
79
|
+
渲染层只提交后台 ID,不能自行拼接或执行配置命令。
|
|
80
|
+
|
|
75
81
|
DeepSeek Harness 当前为实验性接入。安装后运行 `dsh web`,在模型设置中配置官方
|
|
76
82
|
API Key,ACP 接入会直接复用该凭据。它的模型配置独立于其他后台,避免把 Qwen 等
|
|
77
83
|
模型名称误传给 DeepSeek:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qwen-audio-agent",
|
|
3
3
|
"desktopName": "qwen-audio-agent.desktop",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.1",
|
|
5
5
|
"description": "A realtime voice frontend for mainstream AI agents.",
|
|
6
6
|
"author": "qwen-audio-agent contributors",
|
|
7
7
|
"license": "Apache-2.0",
|
package/server/package.json
CHANGED
|
@@ -27,7 +27,10 @@ import {
|
|
|
27
27
|
|
|
28
28
|
const MAX_SESSION_RESULTS = 100
|
|
29
29
|
const MAX_DELEGATION_RESULT_CHARS = 12_000
|
|
30
|
-
|
|
30
|
+
// Health endpoints are polled frequently by desktop and web clients. A local
|
|
31
|
+
// ACP process that cannot start (missing credentials, invalid configuration,
|
|
32
|
+
// missing executable, etc.) must not be respawned on every probe.
|
|
33
|
+
const HEALTH_FAILURE_BACKOFF_MS = 30_000
|
|
31
34
|
|
|
32
35
|
export { acpBackendProfile } from './acp-backend-profile.mjs'
|
|
33
36
|
|
|
@@ -35,8 +38,20 @@ function clean(value) {
|
|
|
35
38
|
return String(value || '').trim()
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
function
|
|
39
|
-
|
|
41
|
+
function backendFailureCode(error) {
|
|
42
|
+
const code = clean(error?.code || error?.cause?.code).toUpperCase()
|
|
43
|
+
const message = clean(error?.message || error).toLowerCase()
|
|
44
|
+
if (code === 'ENOENT') return 'NOT_INSTALLED'
|
|
45
|
+
if (/api key|credential|not configured|未配置|凭据/.test(message)) {
|
|
46
|
+
return 'CONFIG_REQUIRED'
|
|
47
|
+
}
|
|
48
|
+
if (/unauth|not logged in|login|认证|登录/.test(message)) {
|
|
49
|
+
return 'AUTH_REQUIRED'
|
|
50
|
+
}
|
|
51
|
+
if (/protocol version|协议版本/.test(message)) return 'PROTOCOL_MISMATCH'
|
|
52
|
+
if (/timeout|timed out|超时/.test(message)) return 'START_TIMEOUT'
|
|
53
|
+
if (/exited|退出/.test(message)) return 'PROCESS_EXITED'
|
|
54
|
+
return 'START_FAILED'
|
|
40
55
|
}
|
|
41
56
|
|
|
42
57
|
function explicitModel(value) {
|
|
@@ -204,7 +219,16 @@ export class AcpBackendAdapter {
|
|
|
204
219
|
this.activeCoordinatorTurns = new Set()
|
|
205
220
|
this.delegatedWorkRuns = new Map()
|
|
206
221
|
this.pendingCoordinatorFacts = new Map()
|
|
207
|
-
this.
|
|
222
|
+
this.lastHealthFailure = null
|
|
223
|
+
this.runtimeHealth = {
|
|
224
|
+
ok: false,
|
|
225
|
+
status: 'stopped',
|
|
226
|
+
code: 'NOT_STARTED',
|
|
227
|
+
protocol: this.protocol,
|
|
228
|
+
ownership: this.ownership,
|
|
229
|
+
transport: 'acp',
|
|
230
|
+
acpConnection: this.profile.acpConnection?.kind || null,
|
|
231
|
+
}
|
|
208
232
|
this.nativeDelegationAdapter = nativeDelegationAdapter || null
|
|
209
233
|
this.backendAvailable = client ? null : backendAvailable
|
|
210
234
|
this.client = client || clientFactory({
|
|
@@ -247,13 +271,62 @@ export class AcpBackendAdapter {
|
|
|
247
271
|
}
|
|
248
272
|
}
|
|
249
273
|
|
|
274
|
+
status() {
|
|
275
|
+
if (this.runtimeHealth.ok && this.client.ready === false) {
|
|
276
|
+
return {
|
|
277
|
+
...this.runtimeHealth,
|
|
278
|
+
ok: false,
|
|
279
|
+
status: 'stopped',
|
|
280
|
+
code: 'PROCESS_EXITED',
|
|
281
|
+
error: `${this.label} ACP 进程已退出`,
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (!this.lastHealthFailure) return { ...this.runtimeHealth }
|
|
285
|
+
const elapsed = Date.now() - this.lastHealthFailure.at
|
|
286
|
+
return {
|
|
287
|
+
...this.runtimeHealth,
|
|
288
|
+
retryAfterMs: Math.max(0, HEALTH_FAILURE_BACKOFF_MS - elapsed),
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
markRuntimeReady(initialized) {
|
|
293
|
+
this.lastHealthFailure = null
|
|
294
|
+
this.runtimeHealth = {
|
|
295
|
+
ok: true,
|
|
296
|
+
status: 'ready',
|
|
297
|
+
code: 'READY',
|
|
298
|
+
protocol: this.protocol,
|
|
299
|
+
ownership: this.ownership,
|
|
300
|
+
transport: 'acp',
|
|
301
|
+
acpConnection: this.profile.acpConnection?.kind || null,
|
|
302
|
+
agentInfo: initialized?.agentInfo || null,
|
|
303
|
+
capabilities: initialized?.agentCapabilities || {},
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
markRuntimeFailure(error) {
|
|
308
|
+
const result = {
|
|
309
|
+
ok: false,
|
|
310
|
+
status: 'failed',
|
|
311
|
+
code: backendFailureCode(error),
|
|
312
|
+
protocol: this.protocol,
|
|
313
|
+
ownership: this.ownership,
|
|
314
|
+
transport: 'acp',
|
|
315
|
+
acpConnection: this.profile.acpConnection?.kind || null,
|
|
316
|
+
error: `${error.message}${
|
|
317
|
+
clean(this.client.stderr) ? `:${clean(this.client.stderr)}` : ''
|
|
318
|
+
}`,
|
|
319
|
+
}
|
|
320
|
+
this.runtimeHealth = result
|
|
321
|
+
this.lastHealthFailure = { at: Date.now(), result }
|
|
322
|
+
}
|
|
323
|
+
|
|
250
324
|
async health() {
|
|
251
325
|
if (
|
|
252
|
-
this.
|
|
253
|
-
&& Date.now() - this.
|
|
254
|
-
< HEALTH_SPAWN_FAILURE_BACKOFF_MS
|
|
326
|
+
this.lastHealthFailure
|
|
327
|
+
&& Date.now() - this.lastHealthFailure.at < HEALTH_FAILURE_BACKOFF_MS
|
|
255
328
|
) {
|
|
256
|
-
return this.
|
|
329
|
+
return this.status()
|
|
257
330
|
}
|
|
258
331
|
try {
|
|
259
332
|
if (
|
|
@@ -262,41 +335,31 @@ export class AcpBackendAdapter {
|
|
|
262
335
|
&& this.backendAvailable
|
|
263
336
|
&& !await this.backendAvailable(this.baseUrl)
|
|
264
337
|
) {
|
|
265
|
-
|
|
338
|
+
this.runtimeHealth = {
|
|
266
339
|
ok: false,
|
|
340
|
+
status: 'starting',
|
|
341
|
+
code: 'BACKEND_STARTING',
|
|
267
342
|
protocol: this.protocol,
|
|
268
343
|
ownership: this.ownership,
|
|
269
344
|
transport: 'acp',
|
|
270
345
|
acpConnection: this.profile.acpConnection?.kind || null,
|
|
271
346
|
error: this.profile.readinessMessage,
|
|
272
347
|
}
|
|
348
|
+
return this.status()
|
|
273
349
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return {
|
|
277
|
-
ok: true,
|
|
278
|
-
protocol: this.protocol,
|
|
279
|
-
ownership: this.ownership,
|
|
280
|
-
transport: 'acp',
|
|
281
|
-
acpConnection: this.profile.acpConnection?.kind || null,
|
|
282
|
-
agentInfo: initialized.agentInfo || null,
|
|
283
|
-
capabilities: initialized.agentCapabilities || {},
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
const result = {
|
|
350
|
+
this.runtimeHealth = {
|
|
351
|
+
...this.runtimeHealth,
|
|
287
352
|
ok: false,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
acpConnection: this.profile.acpConnection?.kind || null,
|
|
292
|
-
error: `${error.message}${
|
|
293
|
-
clean(this.client.stderr) ? `:${clean(this.client.stderr)}` : ''
|
|
294
|
-
}`,
|
|
295
|
-
}
|
|
296
|
-
if (isMissingExecutable(error)) {
|
|
297
|
-
this.lastSpawnFailure = { at: Date.now(), result }
|
|
353
|
+
status: 'starting',
|
|
354
|
+
code: 'STARTING',
|
|
355
|
+
error: '',
|
|
298
356
|
}
|
|
299
|
-
|
|
357
|
+
const initialized = await this.client.start()
|
|
358
|
+
this.markRuntimeReady(initialized)
|
|
359
|
+
return this.status()
|
|
360
|
+
} catch (error) {
|
|
361
|
+
this.markRuntimeFailure(error)
|
|
362
|
+
return this.status()
|
|
300
363
|
}
|
|
301
364
|
}
|
|
302
365
|
|
|
@@ -1281,6 +1344,14 @@ export class AcpBackendAdapter {
|
|
|
1281
1344
|
signal,
|
|
1282
1345
|
onEvent,
|
|
1283
1346
|
} = {}) {
|
|
1347
|
+
if (typeof this.client.start === 'function') {
|
|
1348
|
+
try {
|
|
1349
|
+
this.markRuntimeReady(await this.client.start())
|
|
1350
|
+
} catch (error) {
|
|
1351
|
+
this.markRuntimeFailure(error)
|
|
1352
|
+
throw error
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1284
1355
|
const key = coordinatorKey(ownerId, this.protocol)
|
|
1285
1356
|
const initial = await this.serialize(
|
|
1286
1357
|
`coordinator:${key}`,
|
|
@@ -1540,5 +1611,13 @@ export class AcpBackendAdapter {
|
|
|
1540
1611
|
this.client.close(),
|
|
1541
1612
|
])
|
|
1542
1613
|
await this.builtinMcpLifecycle.close()
|
|
1614
|
+
this.lastHealthFailure = null
|
|
1615
|
+
this.runtimeHealth = {
|
|
1616
|
+
...this.runtimeHealth,
|
|
1617
|
+
ok: false,
|
|
1618
|
+
status: 'stopped',
|
|
1619
|
+
code: 'STOPPED',
|
|
1620
|
+
error: '',
|
|
1621
|
+
}
|
|
1543
1622
|
}
|
|
1544
1623
|
}
|
|
@@ -108,6 +108,15 @@ export class AcpProcessClient {
|
|
|
108
108
|
return this.initializeResult?.agentInfo || null
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
get ready() {
|
|
112
|
+
return Boolean(
|
|
113
|
+
this.initializeResult
|
|
114
|
+
&& this.context
|
|
115
|
+
&& this.child?.exitCode == null
|
|
116
|
+
&& this.child?.signalCode == null
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
111
120
|
appendStderr(chunk) {
|
|
112
121
|
this.stderr = cleanProcessOutput(
|
|
113
122
|
`${this.stderr}${String(chunk || '')}`,
|
|
@@ -235,13 +244,25 @@ export class AcpProcessClient {
|
|
|
235
244
|
}).catch(() => {})
|
|
236
245
|
return this.initializeResult
|
|
237
246
|
} catch (error) {
|
|
238
|
-
|
|
239
|
-
connection
|
|
247
|
+
// stdout may close a tick before the child 'exit' event. In that race
|
|
248
|
+
// the ACP SDK reports only "connection closed" even though the native
|
|
249
|
+
// backend already wrote an actionable explanation to stderr. Preserve
|
|
250
|
+
// that backend-owned diagnostic without teaching the client any
|
|
251
|
+
// product-specific error strings.
|
|
252
|
+
const stderr = cleanProcessOutput(
|
|
253
|
+
this.stderr,
|
|
254
|
+
this.sanitizeProcessOutput,
|
|
255
|
+
)
|
|
256
|
+
const failure = stderr && !(error instanceof AgentError)
|
|
257
|
+
? processError(this.label, '初始化失败', stderr)
|
|
258
|
+
: error
|
|
259
|
+
processLogger.error('acp.initialization_failed', { error: failure })
|
|
260
|
+
connection.close(failure)
|
|
240
261
|
await this.stopProcessTree(child)
|
|
241
262
|
this.connection = null
|
|
242
263
|
this.context = null
|
|
243
264
|
this.initializeResult = null
|
|
244
|
-
throw
|
|
265
|
+
throw failure
|
|
245
266
|
}
|
|
246
267
|
}
|
|
247
268
|
|
|
@@ -582,7 +603,9 @@ export class AcpProcessClient {
|
|
|
582
603
|
}
|
|
583
604
|
killer.once?.('error', () => finish(false))
|
|
584
605
|
killer.once?.('exit', code => finish(code === 0))
|
|
585
|
-
|
|
606
|
+
// The returned Promise is part of the shutdown contract. Keep taskkill
|
|
607
|
+
// referenced until it reports exit; a pending Promise alone does not
|
|
608
|
+
// keep the Node 22 event loop alive on Windows.
|
|
586
609
|
})
|
|
587
610
|
}
|
|
588
611
|
|
|
@@ -77,6 +77,10 @@ export class AgentClient {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
status() {
|
|
81
|
+
return this.adapter.status()
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
runCoordinator(message, options = {}) {
|
|
81
85
|
return this.adapter.runCoordinator(message, options)
|
|
82
86
|
}
|
|
@@ -171,8 +175,16 @@ export const agent = {
|
|
|
171
175
|
: Promise.resolve({
|
|
172
176
|
enabled: false,
|
|
173
177
|
ok: true,
|
|
178
|
+
status: 'not_configured',
|
|
179
|
+
}),
|
|
180
|
+
status: () => config.agentProtocol
|
|
181
|
+
? requireAgent().status()
|
|
182
|
+
: {
|
|
183
|
+
enabled: false,
|
|
184
|
+
ok: true,
|
|
174
185
|
status: 'not_configured',
|
|
175
|
-
|
|
186
|
+
code: 'NOT_CONFIGURED',
|
|
187
|
+
},
|
|
176
188
|
runCoordinator: (message, options = {}) =>
|
|
177
189
|
requireAgent().runCoordinator(message, options),
|
|
178
190
|
respondPermission: (id, decision, options = {}) =>
|
|
@@ -191,8 +191,11 @@ app.use((req, res, next) => {
|
|
|
191
191
|
status: res.statusCode,
|
|
192
192
|
durationMs: Date.now() - startedAt,
|
|
193
193
|
}
|
|
194
|
-
if (res.statusCode >= 500)
|
|
195
|
-
|
|
194
|
+
if (res.statusCode >= 500) {
|
|
195
|
+
logger.warn('http.request_failed', fields)
|
|
196
|
+
} else {
|
|
197
|
+
logger.debug('http.request_completed', fields)
|
|
198
|
+
}
|
|
196
199
|
})
|
|
197
200
|
next()
|
|
198
201
|
})
|
|
@@ -200,12 +203,22 @@ app.use(express.json({ limit: '1mb' }))
|
|
|
200
203
|
|
|
201
204
|
let realtimeGateway
|
|
202
205
|
|
|
203
|
-
app.get('/
|
|
204
|
-
|
|
206
|
+
app.get('/livez', (req, res) => {
|
|
207
|
+
res.json({ ok: true, status: 'live' })
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
app.get('/readyz', (req, res) => {
|
|
211
|
+
res.json({ ok: true, status: 'ready' })
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
app.get('/api/health', (req, res) => {
|
|
215
|
+
const backend = agent.status()
|
|
205
216
|
const backendDescription = agent.describe()
|
|
206
217
|
const realtime = describeActiveRealtime()
|
|
207
|
-
res.
|
|
208
|
-
|
|
218
|
+
res.json({
|
|
219
|
+
// Gateway liveness is independent from optional backend readiness.
|
|
220
|
+
ok: true,
|
|
221
|
+
status: 'ready',
|
|
209
222
|
gatewayInstanceId: process.env.QWEN_AUDIO_GATEWAY_INSTANCE_ID || null,
|
|
210
223
|
gatewayStartedAt: process.env.QWEN_AUDIO_GATEWAY_STARTED_AT || null,
|
|
211
224
|
voiceConfigured: realtime.configured,
|
|
@@ -88,11 +88,36 @@ function cleanPatch(value) {
|
|
|
88
88
|
.join('')
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// The model may wrap JSON in a Markdown code fence
|
|
91
|
+
// The model may wrap JSON in a Markdown code fence or append a short
|
|
92
|
+
// explanation despite instructions. Extract exactly the first complete JSON
|
|
93
|
+
// object so a harmless suffix cannot discard an otherwise valid memory patch.
|
|
94
|
+
function firstJsonObject(value) {
|
|
95
|
+
const start = value.indexOf('{')
|
|
96
|
+
if (start < 0) return value
|
|
97
|
+
let depth = 0
|
|
98
|
+
let quoted = false
|
|
99
|
+
let escaped = false
|
|
100
|
+
for (let index = start; index < value.length; index += 1) {
|
|
101
|
+
const character = value[index]
|
|
102
|
+
if (quoted) {
|
|
103
|
+
if (escaped) escaped = false
|
|
104
|
+
else if (character === '\\') escaped = true
|
|
105
|
+
else if (character === '"') quoted = false
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
if (character === '"') quoted = true
|
|
109
|
+
else if (character === '{') depth += 1
|
|
110
|
+
else if (character === '}' && --depth === 0) {
|
|
111
|
+
return value.slice(start, index + 1)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return value
|
|
115
|
+
}
|
|
116
|
+
|
|
92
117
|
function parsePatch(text) {
|
|
93
118
|
const raw = String(text || '').trim()
|
|
94
119
|
const unfenced = raw.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/, '')
|
|
95
|
-
const parsed = JSON.parse(unfenced)
|
|
120
|
+
const parsed = JSON.parse(firstJsonObject(unfenced))
|
|
96
121
|
if (!parsed || !Array.isArray(parsed.changes)) {
|
|
97
122
|
throw new Error('extractor output has no changes array')
|
|
98
123
|
}
|