qwen-audio-agent 2.1.0 → 2.2.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.
Files changed (110) hide show
  1. package/README.md +6 -3
  2. package/README_ZH.md +6 -3
  3. package/cli/package.json +1 -1
  4. package/cli/src/config-command.mjs +33 -2
  5. package/cli/src/gateway-service.mjs +7 -1
  6. package/config/frontend-agent/LIVE_PROMPT.md +64 -0
  7. package/desktop/src/i18n.mjs +1 -1
  8. package/desktop/src/settings-config.mjs +10 -24
  9. package/docs/configuration/frontend.md +29 -12
  10. package/docs/configuration/frontend.zh.md +28 -12
  11. package/docs/contract.md +2 -0
  12. package/docs/contract.zh.md +2 -0
  13. package/docs/extensions.md +14 -0
  14. package/docs/extensions.zh.md +11 -0
  15. package/docs/getting-started/install.md +3 -0
  16. package/docs/getting-started/install.zh.md +3 -0
  17. package/docs/getting-started/mobile.md +8 -2
  18. package/docs/getting-started/mobile.zh.md +5 -0
  19. package/docs/guides/web-search.md +17 -1
  20. package/docs/guides/web-search.zh.md +15 -1
  21. package/docs/operations/troubleshooting.md +30 -0
  22. package/docs/operations/troubleshooting.zh.md +26 -0
  23. package/docs/voice-frontends/custom-provider.md +18 -3
  24. package/docs/voice-frontends/custom-provider.zh.md +18 -3
  25. package/docs/voice-frontends/google-live.md +7 -3
  26. package/docs/voice-frontends/google-live.zh.md +6 -3
  27. package/docs/voice-frontends/gpt-live-1.md +149 -0
  28. package/docs/voice-frontends/gpt-live-1.zh.md +114 -0
  29. package/docs/voice-frontends/{gpt-live.md → openai-realtime.md} +12 -5
  30. package/docs/voice-frontends/{gpt-live.zh.md → openai-realtime.zh.md} +11 -5
  31. package/docs/voice-frontends/qwen-audio-live.md +164 -0
  32. package/docs/voice-frontends/qwen-audio-live.zh.md +122 -0
  33. package/docs/voice-frontends/qwen-audio-realtime.md +2 -1
  34. package/docs/voice-frontends/qwen-audio-realtime.zh.md +2 -1
  35. package/docs/voice-frontends/qwen-omni-realtime.md +1 -1
  36. package/docs/voice-frontends/qwen-omni-realtime.zh.md +1 -1
  37. package/package.json +13 -4
  38. package/scripts/patch-build-node-gyp.mjs +63 -0
  39. package/scripts/prepare-build.mjs +2 -0
  40. package/scripts/verify-package.mjs +3 -0
  41. package/server/package.json +2 -2
  42. package/server/src/conversation/frontend-agent-context.mjs +18 -5
  43. package/server/src/core/citation.mjs +8 -2
  44. package/server/src/core/config.mjs +16 -5
  45. package/server/src/core/request-security.mjs +7 -1
  46. package/server/src/frontend/frontend-tools.mjs +14 -1
  47. package/server/src/frontend/retrieval/providers/bing.mjs +23 -12
  48. package/server/src/frontend/retrieval/providers/factory.mjs +9 -1
  49. package/server/src/frontend/retrieval/providers/mcp.mjs +17 -9
  50. package/server/src/frontend/retrieval/providers/so360.mjs +23 -12
  51. package/server/src/frontend/tools/agent-task-runtime.mjs +22 -4
  52. package/server/src/frontend/tools/tool-call-handler.mjs +56 -20
  53. package/server/src/memory/providers/markdown/context-store.mjs +3 -1
  54. package/server/src/orchestration/session-task-coordinator.mjs +4 -1
  55. package/server/src/orchestration/task-operations.mjs +5 -3
  56. package/server/src/orchestration/task-updates.mjs +2 -1
  57. package/server/src/transport/gateway-client-transport.mjs +19 -0
  58. package/server/src/transport/webrtc/protocol.mjs +1 -1
  59. package/server/src/voice/audio-stream-diagnostics.mjs +139 -0
  60. package/server/src/voice/native-delegation-runtime.mjs +360 -0
  61. package/server/src/voice/providers/dashscope-live.mjs +93 -0
  62. package/server/src/voice/providers/dashscope.mjs +12 -4
  63. package/server/src/voice/providers/doubao-seeduplex-protocol.mjs +54 -0
  64. package/server/src/voice/providers/doubao-seeduplex.mjs +6 -5
  65. package/server/src/voice/providers/ga-protocol.mjs +7 -2
  66. package/server/src/voice/providers/google-live-protocol.mjs +124 -34
  67. package/server/src/voice/providers/google-live.mjs +6 -5
  68. package/server/src/voice/providers/gpt-live-1-protocol.mjs +597 -0
  69. package/server/src/voice/providers/gpt-live-1.mjs +3 -0
  70. package/server/src/voice/providers/gpt-live-client-context.mjs +182 -0
  71. package/server/src/voice/providers/openai-live.mjs +150 -0
  72. package/server/src/voice/providers/{gpt-live.mjs → openai-realtime.mjs} +15 -14
  73. package/server/src/voice/providers/provider-registry.mjs +11 -1
  74. package/server/src/voice/providers/qwen-live-protocol.mjs +399 -0
  75. package/server/src/voice/providers/registry.mjs +45 -10
  76. package/server/src/voice/providers/runtime-configuration.mjs +17 -6
  77. package/server/src/voice/providers/stepfun.mjs +1 -1
  78. package/server/src/voice/realtime-input-runtime.mjs +56 -20
  79. package/server/src/voice/realtime-presentation-runtime.mjs +21 -4
  80. package/server/src/voice/realtime-provider-session.mjs +59 -14
  81. package/server/src/voice/realtime-provider.mjs +332 -36
  82. package/server/src/voice/realtime-session-runtime.mjs +207 -16
  83. package/server/src/voice/realtime-task-presentation.mjs +6 -2
  84. package/server/src/voice/realtime-turn-state.mjs +33 -2
  85. package/shared/gateway/client-sdk.mjs +15 -5
  86. package/shared/gateway/websocket-auth.mjs +2 -1
  87. package/shared/protocol/gateway-events.mjs +31 -0
  88. package/shared/realtime-legacy-environment.mjs +37 -8
  89. package/shared/realtime-model-catalog.mjs +12 -10
  90. package/shared/realtime-models/README.md +10 -2
  91. package/shared/realtime-models/dashscope.mjs +11 -0
  92. package/shared/realtime-models/{google-live.mjs → google.mjs} +1 -1
  93. package/shared/realtime-models/openai.mjs +24 -0
  94. package/shared/realtime-models/profile.mjs +6 -3
  95. package/shared/realtime-models/{doubao-seeduplex.mjs → volcengine.mjs} +1 -1
  96. package/shared/realtime-provider-catalog.mjs +7 -6
  97. package/shared/realtime-provider-definitions.mjs +87 -22
  98. package/shared/runtime-environment.mjs +2 -2
  99. package/shared/web-search-configuration.mjs +14 -2
  100. package/tui/package.json +2 -2
  101. package/tui/src/index.mjs +14 -9
  102. package/tui/src/runtime-configuration.mjs +2 -0
  103. package/tui/src/terminal-commands.mjs +40 -0
  104. package/tui/src/text-cli.mjs +10 -1
  105. package/web/dist/assets/index-Bc2Q04J9.css +1 -0
  106. package/web/dist/assets/index-bY4DFXKT.js +96 -0
  107. package/web/dist/index.html +2 -2
  108. package/shared/realtime-models/gpt-live.mjs +0 -10
  109. package/web/dist/assets/index-8erKDCr2.css +0 -1
  110. package/web/dist/assets/index-Cs4hYWbS.js +0 -96
@@ -15,6 +15,32 @@ export const GatewayEventEnvelopeSchema = z.object({
15
15
  type: z.string().min(1),
16
16
  }).passthrough()
17
17
 
18
+ // Optional, numeric-only client observations. Invalid diagnostics must not
19
+ // invalidate a real playback receipt or leak arbitrary client data into logs.
20
+ const AudioDiagnosticNumber = z.number().finite().nonnegative().max(Number.MAX_SAFE_INTEGER)
21
+ const AudioDiagnosticCount = AudioDiagnosticNumber.int()
22
+ export const GatewayAudioPlaybackDiagnosticsSchema = z.object({
23
+ chunkCount: AudioDiagnosticCount.optional(),
24
+ pcmDurationMs: AudioDiagnosticNumber.optional(),
25
+ maxReceiveGapMs: AudioDiagnosticNumber.optional(),
26
+ startDelayMs: AudioDiagnosticNumber.optional(),
27
+ maxScheduledAheadMs: AudioDiagnosticNumber.optional(),
28
+ scheduleGapCount: AudioDiagnosticCount.optional(),
29
+ maxScheduleGapMs: AudioDiagnosticNumber.optional(),
30
+ contextSuspensionCount: AudioDiagnosticCount.optional(),
31
+ underrunCount: AudioDiagnosticCount.optional(),
32
+ })
33
+
34
+ export function normalizeAudioPlaybackDiagnostics(value) {
35
+ const parsed = GatewayAudioPlaybackDiagnosticsSchema.safeParse(value)
36
+ return parsed.success && Object.keys(parsed.data).length ? parsed.data : undefined
37
+ }
38
+
39
+ const OptionalAudioDiagnosticsSchema = z.preprocess(
40
+ normalizeAudioPlaybackDiagnostics,
41
+ GatewayAudioPlaybackDiagnosticsSchema.optional(),
42
+ )
43
+
18
44
  export const GatewayArtifactPartSchema = z.union([
19
45
  z.object({
20
46
  text: z.string(),
@@ -218,13 +244,16 @@ const GatewayClientPayloadSchemas = Object.freeze({
218
244
  [GatewayClientEvent.INPUT_MESSAGE]: GatewayInputMessagePayloadSchema,
219
245
  [GatewayClientEvent.PLAYBACK_STARTED]: z.object({
220
246
  responseId: z.string().min(1),
247
+ audioDiagnostics: OptionalAudioDiagnosticsSchema,
221
248
  }).passthrough(),
222
249
  [GatewayClientEvent.PLAYBACK_ENDED]: z.object({
223
250
  responseId: z.string().min(1),
251
+ audioDiagnostics: OptionalAudioDiagnosticsSchema,
224
252
  }).passthrough(),
225
253
  [GatewayClientEvent.PLAYBACK_CANCELLED]: z.object({
226
254
  responseId: z.string().min(1),
227
255
  reason: z.string().optional(),
256
+ audioDiagnostics: OptionalAudioDiagnosticsSchema,
228
257
  }).passthrough(),
229
258
  })
230
259
 
@@ -233,6 +262,8 @@ const GatewayVoicePayloadSchemas = Object.freeze({
233
262
  inputSampleRate: z.number().int().positive(),
234
263
  provider: z.string().min(1).optional(),
235
264
  providerLabel: z.string().min(1).optional(),
265
+ interruptionPlaysOut: z.boolean().optional(),
266
+ pacedOutputAudio: z.boolean().optional(),
236
267
  }).passthrough(),
237
268
  [GatewayServerEvent.VOICE_CONNECTION]: z.object({
238
269
  state: z.string().min(1),
@@ -1,6 +1,21 @@
1
1
  // Read-only compatibility at the config boundary. New settings are always
2
2
  // written with the shared REALTIME_* names; legacy names are not runtime fields.
3
- import { resolveDashScopeRealtimeModelProfile } from './realtime-model-catalog.mjs'
3
+ import { resolveDashScopeRealtimeModelProfile, resolveRealtimeModelProfile } from './realtime-model-catalog.mjs'
4
+ import { DEFAULT_OPENAI_REALTIME_MODEL, DEFAULT_GPT_LIVE_1_REALTIME_MODEL } from './realtime-models/openai.mjs'
5
+
6
+ const LEGACY_OPENAI_MODELS = Object.freeze({
7
+ 'gpt-live': DEFAULT_OPENAI_REALTIME_MODEL,
8
+ 'openai-realtime': DEFAULT_OPENAI_REALTIME_MODEL,
9
+ gptlive: DEFAULT_OPENAI_REALTIME_MODEL,
10
+ 'gpt-realtime': DEFAULT_OPENAI_REALTIME_MODEL,
11
+ 'gpt-live-1': DEFAULT_GPT_LIVE_1_REALTIME_MODEL,
12
+ 'openai-live': DEFAULT_GPT_LIVE_1_REALTIME_MODEL,
13
+ gptlive1: DEFAULT_GPT_LIVE_1_REALTIME_MODEL,
14
+ })
15
+
16
+ export function legacyRealtimeModel(provider) {
17
+ return LEGACY_OPENAI_MODELS[String(provider || '').trim().toLowerCase()]
18
+ }
4
19
 
5
20
  const LEGACY_FIELDS = {
6
21
  dashscope: {
@@ -10,15 +25,15 @@ const LEGACY_FIELDS = {
10
25
  API_KEY: ['STEPFUN_API_KEY'], URL: ['STEPFUN_REALTIME_URL'],
11
26
  MODEL: ['STEPFUN_REALTIME_MODEL'], VOICE: ['STEPFUN_REALTIME_VOICE'],
12
27
  },
13
- 'gpt-live': {
28
+ openai: {
14
29
  API_KEY: ['OPENAI_API_KEY', 'GPT_LIVE_API_KEY'], URL: ['GPT_LIVE_REALTIME_URL', 'OPENAI_REALTIME_URL'],
15
30
  MODEL: ['GPT_LIVE_REALTIME_MODEL', 'OPENAI_REALTIME_MODEL'], VOICE: ['GPT_LIVE_REALTIME_VOICE', 'OPENAI_REALTIME_VOICE'],
16
31
  },
17
- 'google-live': {
32
+ google: {
18
33
  API_KEY: ['GOOGLE_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_LIVE_API_KEY'], URL: ['GOOGLE_LIVE_REALTIME_URL', 'GEMINI_LIVE_REALTIME_URL'],
19
34
  MODEL: ['GOOGLE_LIVE_REALTIME_MODEL', 'GEMINI_LIVE_REALTIME_MODEL'], VOICE: ['GOOGLE_LIVE_REALTIME_VOICE', 'GEMINI_LIVE_REALTIME_VOICE'],
20
35
  },
21
- 'doubao-seeduplex': {
36
+ volcengine: {
22
37
  API_KEY: ['DOUBAO_API_KEY', 'SEEDUPLEX_API_KEY', 'VOLCENGINE_DOUBAO_API_KEY'], URL: ['DOUBAO_SEEDUPLEX_REALTIME_URL'],
23
38
  MODEL: ['DOUBAO_SEEDUPLEX_REALTIME_MODEL'], VOICE: ['DOUBAO_SEEDUPLEX_REALTIME_VOICE'],
24
39
  },
@@ -31,17 +46,31 @@ export function legacyOmniVoiceFromEnvironment(env, model = env.QWEN_AUDIO_REALT
31
46
  ? env.QWEN_OMNI_REALTIME_VOICE : undefined
32
47
  }
33
48
 
34
- export function legacyRealtimeEnvironment(env, provider, { deferModelVoice = false } = {}) {
49
+ export function legacyRealtimeEnvironment(env, provider, { deferModelVoice = false, model = env.QWEN_AUDIO_REALTIME_MODEL } = {}) {
35
50
  const result = {}
36
- for (const suffix of ['MODEL', 'API_KEY', 'URL', 'VOICE']) {
51
+ const legacyModel = legacyRealtimeModel(env.QWEN_AUDIO_REALTIME_PROVIDER)
52
+ // Resolve the model before any model-specific fallback, including old model
53
+ // variables. A legacy Live provider never inherits Realtime-only variables.
54
+ const modelSource = ['QWEN_AUDIO_REALTIME_MODEL',
55
+ ...(legacyModel === DEFAULT_GPT_LIVE_1_REALTIME_MODEL ? [] : LEGACY_FIELDS[provider]?.MODEL || []),
56
+ ].find(name => env[name] !== undefined)
57
+ if (modelSource) result.QWEN_AUDIO_REALTIME_MODEL = env[modelSource]
58
+ else if (legacyModel) result.QWEN_AUDIO_REALTIME_MODEL = legacyModel
59
+ const selectedModel = String(result.QWEN_AUDIO_REALTIME_MODEL ?? model ?? '').trim() || legacyModel || ''
60
+ // OpenAI credentials are service-wide. Old Realtime-specific URL/model/voice
61
+ // variables must never configure a Live connection.
62
+ const fields = provider === 'openai' && resolveRealtimeModelProfile(selectedModel, provider).adapter === 'openai-live'
63
+ ? { API_KEY: ['OPENAI_API_KEY'] } : LEGACY_FIELDS[provider]
64
+ for (const suffix of ['API_KEY', 'URL', 'VOICE']) {
37
65
  const key = 'QWEN_AUDIO_REALTIME_' + suffix
38
- const source = [key, ...(LEGACY_FIELDS[provider]?.[suffix] || [])].find(name => env[name] !== undefined)
66
+ const source = [key, ...(fields?.[suffix] || [])].find(name => env[name] !== undefined)
39
67
  if (source) result[key] = env[source]
40
68
  }
41
69
  if (provider === 'dashscope') {
42
70
  if (result.QWEN_AUDIO_REALTIME_URL === undefined && String(env.DASHSCOPE_WORKSPACE_ID || '').trim()) {
71
+ const api = resolveRealtimeModelProfile(selectedModel, provider).api === 'live' ? 'live' : 'realtime'
43
72
  result.QWEN_AUDIO_REALTIME_URL = 'wss://' + String(env.DASHSCOPE_WORKSPACE_ID).trim()
44
- + '.cn-beijing.maas.aliyuncs.com/api-ws/v1/realtime'
73
+ + '.cn-beijing.maas.aliyuncs.com/api-ws/v1/' + api
45
74
  }
46
75
  const omniVoice = deferModelVoice ? undefined : legacyOmniVoiceFromEnvironment(env)
47
76
  if (result.QWEN_AUDIO_REALTIME_VOICE === undefined && omniVoice !== undefined) {
@@ -2,22 +2,22 @@
2
2
  // own model declarations; this module assembles and queries the immutable data.
3
3
  import { DEFAULT_DASHSCOPE_REALTIME_MODEL, dashscopeModels } from './realtime-models/dashscope.mjs'
4
4
  import { stepfunModels } from './realtime-models/stepfun.mjs'
5
- import { gptLiveModels } from './realtime-models/gpt-live.mjs'
6
- import { googleLiveModels } from './realtime-models/google-live.mjs'
7
- import { doubaoSeeduplexModels } from './realtime-models/doubao-seeduplex.mjs'
5
+ import { openaiModels } from './realtime-models/openai.mjs'
6
+ import { googleLiveModels } from './realtime-models/google.mjs'
7
+ import { doubaoSeeduplexModels } from './realtime-models/volcengine.mjs'
8
8
 
9
9
  export * from './realtime-models/dashscope.mjs'
10
10
  export * from './realtime-models/stepfun.mjs'
11
- export * from './realtime-models/gpt-live.mjs'
12
- export * from './realtime-models/google-live.mjs'
13
- export * from './realtime-models/doubao-seeduplex.mjs'
11
+ export * from './realtime-models/openai.mjs'
12
+ export * from './realtime-models/google.mjs'
13
+ export * from './realtime-models/volcengine.mjs'
14
14
 
15
15
  export const REALTIME_MODEL_BUILTINS = Object.freeze({
16
16
  dashscope: dashscopeModels,
17
17
  stepfun: stepfunModels,
18
- 'gpt-live': gptLiveModels,
19
- 'google-live': googleLiveModels,
20
- 'doubao-seeduplex': doubaoSeeduplexModels,
18
+ openai: openaiModels,
19
+ google: googleLiveModels,
20
+ volcengine: doubaoSeeduplexModels,
21
21
  })
22
22
 
23
23
  // Model parameters come only from provider code, never from user configuration.
@@ -32,6 +32,8 @@ export const BUILTIN_REALTIME_MODEL_CATALOGS = Object.freeze(Object.fromEntries(
32
32
  id,
33
33
  label: model.label,
34
34
  api: model.api,
35
+ adapter: preset.adapter || provider,
36
+ endpoint: preset.endpoint || null,
35
37
  family: preset.family,
36
38
  sessionDefaults: Object.freeze({
37
39
  voice: model.voice,
@@ -64,7 +66,7 @@ const UNKNOWN_SESSION_CONSTRAINTS = Object.freeze({})
64
66
 
65
67
  function unknownModelProfile(id) {
66
68
  return Object.freeze({
67
- id, label: id, api: null, family: 'unknown',
69
+ id, label: id, api: null, adapter: null, endpoint: null, family: 'unknown',
68
70
  sessionDefaults: UNKNOWN_SESSION_DEFAULTS,
69
71
  modelCapabilities: UNKNOWN_MODEL_CAPABILITIES,
70
72
  transportCapabilities: UNKNOWN_TRANSPORT_CAPABILITIES,
@@ -2,24 +2,32 @@
2
2
 
3
3
  This directory contains provider-owned data for the framework's static realtime model catalog. The shared catalog entry handles aggregation and resolution without provider-specific configuration. The modules are browser-safe and contain no credentials or connection implementations.
4
4
 
5
- - `dashscope.mjs`, `stepfun.mjs`, `gpt-live.mjs`, `google-live.mjs`, and `doubao-seeduplex.mjs`: pure data for each provider's model IDs, labels, API bindings, default voices, turn detection, capabilities, and integration constraints.
5
+ - `dashscope.mjs`, `stepfun.mjs`, `openai.mjs`, `google.mjs`, and `volcengine.mjs`: pure data for each provider's model IDs, labels, API/adapter bindings, endpoints, default voices, turn detection, capabilities, and integration constraints.
6
6
  - `profile.mjs`: browser-safe helpers for immutable model and API declarations.
7
7
  - `../realtime-model-catalog.mjs`: the shared entry used by Gateway, Desktop, and CLI. It aggregates provider declarations and default selections, constructs immutable model profiles, and provides catalog queries and model resolution. It does not read user model files or merge user overrides.
8
8
 
9
9
  Users select a supported provider and model with `QWEN_AUDIO_REALTIME_PROVIDER` and `QWEN_AUDIO_REALTIME_MODEL`, alongside the existing API key, URL, and voice connection fields in `config.env`. Model API bindings, capabilities, turn detection, and hard constraints are maintained in code, not exposed as user parameters. Explicit environment and session voice overrides keep their existing precedence. See the [user guide](../../docs/configuration/frontend.md#select-a-supported-model).
10
10
 
11
+ Connection settings select the service and hold credentials and overrides; model records declare supported behavior; protocol adapters implement the wire protocol. For example, `openai.mjs` owns both `gpt-realtime-2.1` and `gpt-live-1`, with fixed `openai-realtime` and `openai-live` adapter bindings and separate default endpoints. The public provider is `openai` for both. Runtime selects the adapter from these declarations, never from a model-name heuristic or user-provided adapter field.
12
+
13
+ `google.mjs` binds Gemini models to `google-live`; `volcengine.mjs` binds Doubao Seeduplex to `doubao-seeduplex`. These are internal adapter IDs, not public provider choices. Services such as speech-to-speech and MiniCPM-o manage models upstream and need no static catalog here. Each service declares its required and editable connection fields explicitly in `../realtime-provider-definitions.mjs`, independently of catalog presence.
14
+
11
15
  DashScope includes Qwen Audio 3.1 Plus and 3.1 Flash; both use `longanqian_v3.1` and `smart_turn_v2`. The default model remains 3.1 Plus. The catalog records implemented support, not live account authorization or a cloud-service verification.
12
16
 
13
17
  To add framework support for a model, update the corresponding provider data file and tests. If its wire behavior or required capabilities differ, update the provider adapter as well. Model names are never used to infer a protocol or capabilities.
14
18
 
15
19
  本目录保存框架静态实时模型目录中的供应商专属数据。统一目录入口负责聚合与解析,不包含供应商具体配置。模块保持浏览器可用,不含凭据或连接实现。
16
20
 
17
- - `dashscope.mjs`、`stepfun.mjs`、`gpt-live.mjs`、`google-live.mjs`、`doubao-seeduplex.mjs`:各供应商的纯数据,包括模型 ID、展示名称、API 绑定、默认音色、话轮检测、能力和接入约束。
21
+ - `dashscope.mjs`、`stepfun.mjs`、`openai.mjs`、`google.mjs`、`volcengine.mjs`:各供应商的纯数据,包括模型 ID、展示名称、API/Adapter 绑定、服务地址、默认音色、话轮检测、能力和接入约束。
18
22
  - `profile.mjs`:用于定义不可变模型和 API 数据的浏览器安全辅助函数。
19
23
  - `../realtime-model-catalog.mjs`:Gateway、桌面版和 CLI 共用的统一入口,汇总供应商声明与默认选择,生成不可变模型档案,并提供目录查询和模型解析;不读取用户模型文件,也不合并用户覆盖。
20
24
 
21
25
  用户通过 `config.env` 中的 `QWEN_AUDIO_REALTIME_PROVIDER`、`QWEN_AUDIO_REALTIME_MODEL` 选择受支持的供应商和模型,同时配置现有 API Key、地址和音色连接字段。模型的 API 绑定、能力、话轮检测和硬约束由代码维护,不作为用户参数开放;环境变量和会话显式指定的音色仍保持原有优先级。详见[用户手册](../../docs/configuration/frontend.zh.md#选择受支持模型)。
22
26
 
27
+ 连接配置选择服务并保存凭据与覆盖项;模型记录声明已支持的行为;协议适配器实现线协议。例如,`openai.mjs` 统一维护 `gpt-realtime-2.1` 和 `gpt-live-1`,分别固定绑定 `openai-realtime`、`openai-live` Adapter 和各自的默认地址,对用户均为 `openai`。运行时依据声明选择 Adapter,不根据模型名猜测,也不接受用户配置 Adapter 字段。
28
+
29
+ `google.mjs` 将 Gemini 模型绑定到 `google-live`,`volcengine.mjs` 将豆包 Seeduplex 绑定到 `doubao-seeduplex`;这些是内部 Adapter 标识,不是公开的供应商选项。speech-to-speech 和 MiniCPM-o 等服务在上游管理模型,无需在此建立静态模型目录。各服务的连接必填项和可编辑字段在 `../realtime-provider-definitions.mjs` 显式声明,不依赖是否存在模型目录。
30
+
23
31
  DashScope 内置 Qwen Audio 3.1 Plus 和 3.1 Flash,二者均使用 `longanqian_v3.1` 和 `smart_turn_v2`;默认模型仍为 3.1 Plus。目录表示代码已实现的支持,不代表实时账号授权或已完成云端验证。
24
32
 
25
33
  为框架新增模型支持时,修改对应供应商数据文件并补充测试;若线协议行为或所需能力不同,还需修改 Provider adapter。不会通过模型名称推断协议或能力。
@@ -3,6 +3,7 @@ import { apiProfile, defineProviderModels } from './profile.mjs'
3
3
  export const DASHSCOPE_AUDIO_30_REALTIME_MODEL = 'qwen-audio-3.0-realtime-plus'
4
4
  export const DASHSCOPE_AUDIO_31_REALTIME_MODEL = 'qwen-audio-3.1-realtime-plus'
5
5
  export const DASHSCOPE_AUDIO_31_FLASH_REALTIME_MODEL = 'qwen-audio-3.1-realtime-flash'
6
+ export const DASHSCOPE_AUDIO_31_LIVE_MODEL = 'qwen-audio-3.1-live'
6
7
  export const DEFAULT_DASHSCOPE_REALTIME_MODEL = DASHSCOPE_AUDIO_31_REALTIME_MODEL
7
8
  export const DEFAULT_DASHSCOPE_REALTIME_VOICE = 'longanqian_v3.1'
8
9
  export const DASHSCOPE_AUDIO_FLASH_REALTIME_MODEL = 'qwen-audio-3.0-realtime-flash'
@@ -19,6 +20,11 @@ export const dashscopeModels = defineProviderModels(DEFAULT_DASHSCOPE_REALTIME_M
19
20
  'omni-v2': apiProfile('omni', 'semantic_vad', {
20
21
  visual: true, sessionConstraints: { workspaceEndpoint: true },
21
22
  }),
23
+ live: apiProfile('dashscope-live', 'duplex', {
24
+ // This integration uses native Client delegation, not frontend function tools.
25
+ adapter: 'dashscope-live', functionCalling: false,
26
+ sessionConstraints: { workspaceEndpoint: true },
27
+ }),
22
28
  }, {
23
29
  [DASHSCOPE_OMNI_38_FLASH_REALTIME_MODEL]: {
24
30
  label: 'Qwen3.8 Omni Flash Realtime', api: 'omni-v2', voice: 'Tina',
@@ -29,6 +35,11 @@ export const dashscopeModels = defineProviderModels(DEFAULT_DASHSCOPE_REALTIME_M
29
35
  [DASHSCOPE_OMNI_PLUS_REALTIME_MODEL]: {
30
36
  label: 'Qwen3.5 Omni Plus Realtime', api: 'omni', voice: 'Ethan',
31
37
  },
38
+ [DASHSCOPE_AUDIO_31_LIVE_MODEL]: {
39
+ // The public ID selects the Live service; its adapter binds the 4.0 Preview
40
+ // voice model used by the official duplex example, not another user setting.
41
+ label: 'Qwen Audio 3.1 Live', api: 'live', voice: 'yunshu',
42
+ },
32
43
  [DASHSCOPE_AUDIO_31_REALTIME_MODEL]: {
33
44
  label: 'Qwen Audio 3.1 Realtime Plus', api: 'audio', voice: DEFAULT_DASHSCOPE_REALTIME_VOICE,
34
45
  turnDetection: 'smart_turn_v2',
@@ -2,7 +2,7 @@ import { apiProfile, defineProviderModels } from './profile.mjs'
2
2
 
3
3
  export const DEFAULT_GOOGLE_LIVE_REALTIME_MODEL = 'gemini-3.8-live'
4
4
  export const googleLiveModels = defineProviderModels(DEFAULT_GOOGLE_LIVE_REALTIME_MODEL, {
5
- 'google-live': apiProfile('google-live', 'server_vad', { visual: true }),
5
+ 'google-live': apiProfile('google-live', 'server_vad', { visual: true, adapter: 'google-live' }),
6
6
  }, {
7
7
  [DEFAULT_GOOGLE_LIVE_REALTIME_MODEL]: {
8
8
  label: 'Gemini 3.8 Live', api: 'google-live', voice: null,
@@ -0,0 +1,24 @@
1
+ import { apiProfile, defineProviderModels } from './profile.mjs'
2
+
3
+ export const DEFAULT_OPENAI_REALTIME_MODEL = 'gpt-realtime-2.1'
4
+ export const DEFAULT_GPT_LIVE_1_REALTIME_MODEL = 'gpt-live-1'
5
+ export const DEFAULT_OPENAI_REALTIME_URL = 'wss://api.openai.com/v1/realtime'
6
+ export const DEFAULT_GPT_LIVE_1_REALTIME_URL = 'wss://api.openai.com/v1/live/sessions'
7
+
8
+ // Models belong to the service; each API binding selects its own wire adapter.
9
+ export const openaiModels = defineProviderModels(DEFAULT_OPENAI_REALTIME_MODEL, {
10
+ realtime: apiProfile('openai-realtime', 'server_vad', {
11
+ adapter: 'openai-realtime', endpoint: DEFAULT_OPENAI_REALTIME_URL,
12
+ }),
13
+ live: apiProfile('openai-live', null, {
14
+ adapter: 'openai-live', endpoint: DEFAULT_GPT_LIVE_1_REALTIME_URL,
15
+ functionCalling: false,
16
+ }),
17
+ }, {
18
+ [DEFAULT_OPENAI_REALTIME_MODEL]: {
19
+ label: 'GPT Realtime 2.1', api: 'realtime', voice: null,
20
+ },
21
+ [DEFAULT_GPT_LIVE_1_REALTIME_MODEL]: {
22
+ label: 'GPT-Live 1', api: 'live', voice: null,
23
+ },
24
+ })
@@ -13,11 +13,14 @@ const OMNI_TRANSPORT_CAPABILITIES = Object.freeze({
13
13
  ...AUDIO_TRANSPORT_CAPABILITIES, imageBufferInput: true,
14
14
  })
15
15
 
16
- export function apiProfile(family, turnDetection, { visual = false, sessionConstraints = {} } = {}) {
16
+ export function apiProfile(family, turnDetection, { visual = false, functionCalling = true, sessionConstraints = {}, adapter, endpoint } = {}) {
17
+ const capabilities = visual ? OMNI_MODEL_CAPABILITIES : AUDIO_MODEL_CAPABILITIES
17
18
  return Object.freeze({
18
19
  family,
19
- turnDetection: Object.freeze({ type: turnDetection }),
20
- defaultModelCapabilities: visual ? OMNI_MODEL_CAPABILITIES : AUDIO_MODEL_CAPABILITIES,
20
+ ...(adapter ? { adapter } : {}),
21
+ ...(endpoint ? { endpoint } : {}),
22
+ turnDetection: turnDetection ? Object.freeze({ type: turnDetection }) : null,
23
+ defaultModelCapabilities: functionCalling ? capabilities : Object.freeze({ ...capabilities, functionCalling: false }),
21
24
  transportCapabilities: visual ? OMNI_TRANSPORT_CAPABILITIES : AUDIO_TRANSPORT_CAPABILITIES,
22
25
  sessionConstraints: Object.freeze(sessionConstraints),
23
26
  })
@@ -3,7 +3,7 @@ import { apiProfile, defineProviderModels } from './profile.mjs'
3
3
  export const DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL = '1.2.6.1'
4
4
  export const DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_VOICE = 'zh_female_vv_jupiter_bigtts'
5
5
  export const doubaoSeeduplexModels = defineProviderModels(DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL, {
6
- 'doubao-seeduplex': apiProfile('doubao-seeduplex', 'server_vad'),
6
+ 'doubao-seeduplex': apiProfile('doubao-seeduplex', 'server_vad', { adapter: 'doubao-seeduplex' }),
7
7
  }, {
8
8
  [DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL]: {
9
9
  label: 'Doubao Seeduplex 3.0 Realtime', api: 'doubao-seeduplex',
@@ -11,6 +11,7 @@ export {
11
11
  DASHSCOPE_AUDIO_30_REALTIME_MODEL,
12
12
  DASHSCOPE_AUDIO_31_REALTIME_MODEL,
13
13
  DASHSCOPE_AUDIO_31_FLASH_REALTIME_MODEL,
14
+ DASHSCOPE_AUDIO_31_LIVE_MODEL,
14
15
  DASHSCOPE_AUDIO_FLASH_REALTIME_MODEL,
15
16
  DASHSCOPE_OMNI_38_FLASH_REALTIME_MODEL,
16
17
  DASHSCOPE_OMNI_FLASH_REALTIME_MODEL,
@@ -18,7 +19,8 @@ export {
18
19
  DASHSCOPE_REALTIME_MODEL_PROFILES,
19
20
  DEFAULT_DASHSCOPE_REALTIME_MODEL,
20
21
  DEFAULT_DASHSCOPE_REALTIME_VOICE,
21
- DEFAULT_GPT_LIVE_REALTIME_MODEL,
22
+ DEFAULT_OPENAI_REALTIME_MODEL,
23
+ DEFAULT_GPT_LIVE_1_REALTIME_MODEL,
22
24
  DEFAULT_GOOGLE_LIVE_REALTIME_MODEL,
23
25
  DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL,
24
26
  DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_VOICE,
@@ -39,7 +41,8 @@ import {
39
41
  export {
40
42
  DEFAULT_REALTIME_PROVIDER,
41
43
  DEFAULT_DASHSCOPE_REALTIME_URL,
42
- DEFAULT_GPT_LIVE_REALTIME_URL,
44
+ DEFAULT_OPENAI_REALTIME_URL,
45
+ DEFAULT_GPT_LIVE_1_REALTIME_URL,
43
46
  DEFAULT_GOOGLE_LIVE_REALTIME_URL,
44
47
  DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL,
45
48
  DEFAULT_STEPFUN_REALTIME_URL,
@@ -114,10 +117,7 @@ export function resolveRealtimeFrontendConfiguration(env = process.env, {
114
117
  modelCatalogs = BUILTIN_REALTIME_MODEL_CATALOGS,
115
118
  } = {}) {
116
119
  const provider = normalizeRealtimeProvider(env.QWEN_AUDIO_REALTIME_PROVIDER)
117
- const settings = realtimeSettingsFromEnvironment({
118
- ...env,
119
- QWEN_AUDIO_REALTIME_PROVIDER: provider,
120
- })
120
+ const settings = realtimeSettingsFromEnvironment(env)
121
121
  const connection = realtimeSettingsConnection(settings)
122
122
  const runtime = realtimeRuntimeEnvironment(settings)
123
123
  const endpoint = withoutTrailing(connection.endpoint, /[/?]+$/)
@@ -136,6 +136,7 @@ export function resolveRealtimeFrontendConfiguration(env = process.env, {
136
136
  .digest('hex')
137
137
  const active = Object.freeze({
138
138
  provider,
139
+ adapter: modelProfile ? modelProfile.adapter : provider,
139
140
  label: PROVIDERS[provider].label,
140
141
  configured,
141
142
  endpoint,
@@ -1,14 +1,15 @@
1
1
  // Browser-safe connection metadata. One active connection uses the same fields
2
2
  // for every provider; model catalogs and wire adapters remain separate concerns.
3
- import { realtimeModelCatalog } from './realtime-model-catalog.mjs'
4
- import { legacyOmniVoiceFromEnvironment, legacyRealtimeEnvironment } from './realtime-legacy-environment.mjs'
3
+ import { realtimeModelCatalog, resolveRealtimeModelProfile } from './realtime-model-catalog.mjs'
4
+ import { DEFAULT_OPENAI_REALTIME_URL } from './realtime-models/openai.mjs'
5
+ import { legacyOmniVoiceFromEnvironment, legacyRealtimeEnvironment, legacyRealtimeModel } from './realtime-legacy-environment.mjs'
6
+ export { DEFAULT_OPENAI_REALTIME_URL, DEFAULT_GPT_LIVE_1_REALTIME_URL } from './realtime-models/openai.mjs'
5
7
 
6
8
  export const DEFAULT_REALTIME_PROVIDER = 'dashscope'
7
9
  export const DEFAULT_DASHSCOPE_REALTIME_URL = 'wss://dashscope.aliyuncs.com/api-ws/v1/realtime'
8
10
  export const DEFAULT_STEPFUN_REALTIME_URL = 'wss://api.stepfun.com/v1/realtime'
9
11
  export const DEFAULT_SPEECH_TO_SPEECH_REALTIME_URL = 'ws://127.0.0.1:8765/v1/realtime'
10
12
  export const DEFAULT_MINICPM_O_REALTIME_URL = 'ws://127.0.0.1:8006/v1/realtime?mode=audio'
11
- export const DEFAULT_GPT_LIVE_REALTIME_URL = 'wss://api.openai.com/v1/realtime'
12
13
  export const DEFAULT_GOOGLE_LIVE_REALTIME_URL = 'wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent'
13
14
  export const DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL = 'wss://openspeech.bytedance.com/api/v3/duplex/realtime/dialogue'
14
15
 
@@ -19,19 +20,25 @@ export const REALTIME_SETTING_SLOTS = Object.freeze([
19
20
  { slot: 'voice', key: 'realtimeVoice', label: '音色', type: 'text', environment: ['QWEN_AUDIO_REALTIME_VOICE'] },
20
21
  ].map(field => Object.freeze({ ...field, environment: Object.freeze(field.environment) })))
21
22
 
22
- function defineProvider({ endpoint, helpUrl, ...definition }) {
23
+ const MODEL_CONNECTION_FIELDS = Object.freeze(['model', 'credential', 'endpoint', 'voice'])
24
+ const SERVICE_CONNECTION_FIELDS = Object.freeze(['credential', 'endpoint'])
25
+
26
+ // Connection requirements are service declarations, not consequences of having
27
+ // a model catalog. A self-hosted service can expose models without requiring a key.
28
+ function defineProvider({ endpoint, helpUrl, required, fields, ...definition }) {
23
29
  const catalog = realtimeModelCatalog(definition.key)
24
- const required = REALTIME_SETTING_SLOTS.find(field => field.slot === (catalog ? 'credential' : 'endpoint'))
30
+ const requiredField = REALTIME_SETTING_SLOTS.find(field => field.slot === required)
31
+ if (!requiredField || !fields.includes(required)) throw new TypeError('Invalid connection settings: ' + definition.key)
25
32
  return Object.freeze({
26
33
  ...definition,
27
34
  aliases: Object.freeze(definition.aliases || []),
28
- requiredConfiguration: Object.freeze({ field: required.key, key: required.environment[0] }),
35
+ requiredConfiguration: Object.freeze({ field: requiredField.key, key: requiredField.environment[0] }),
29
36
  settings: Object.freeze(REALTIME_SETTING_SLOTS
30
- .filter(field => catalog || ['credential', 'endpoint'].includes(field.slot))
37
+ .filter(field => fields.includes(field.slot))
31
38
  .map(field => Object.freeze({
32
39
  ...field,
33
- default: field.slot === 'model' ? catalog.defaultModel : field.slot === 'endpoint' ? endpoint : '',
34
- ...(field.slot === 'credential' ? { helpUrl, placeholder: catalog ? 'API Key' : '可选,用于 Bearer 认证' } : {}),
40
+ default: field.slot === 'model' ? catalog?.defaultModel || '' : field.slot === 'endpoint' ? endpoint : '',
41
+ ...(field.slot === 'credential' ? { helpUrl, placeholder: required === 'credential' ? 'API Key' : '可选,用于 Bearer 认证' } : {}),
35
42
  }))),
36
43
  })
37
44
  }
@@ -39,37 +46,45 @@ function defineProvider({ endpoint, helpUrl, ...definition }) {
39
46
  export const REALTIME_PROVIDERS = Object.freeze([
40
47
  defineProvider({
41
48
  key: 'dashscope', label: 'DashScope', aliases: ['qwen'],
42
- description: 'Qwen Realtime · DashScope 兼容协议',
49
+ required: 'credential', fields: MODEL_CONNECTION_FIELDS,
50
+ description: 'Qwen Realtime / Live · DashScope',
43
51
  endpoint: DEFAULT_DASHSCOPE_REALTIME_URL,
44
52
  helpUrl: 'https://bailian.console.aliyun.com/?tab=model#/api-key',
45
53
  }),
46
54
  defineProvider({
47
55
  key: 'stepfun', label: 'StepFun', description: 'StepAudio 3 Realtime · 阶跃星辰',
56
+ required: 'credential', fields: MODEL_CONNECTION_FIELDS,
48
57
  endpoint: DEFAULT_STEPFUN_REALTIME_URL,
49
58
  }),
50
59
  defineProvider({
51
- key: 'gpt-live', label: 'GPT-Live', aliases: ['openai', 'gptlive', 'gpt-realtime'],
52
- description: 'GPT-Live · OpenAI Realtime', endpoint: DEFAULT_GPT_LIVE_REALTIME_URL,
60
+ key: 'openai', label: 'OpenAI',
61
+ required: 'credential', fields: MODEL_CONNECTION_FIELDS,
62
+ aliases: ['gpt-live', 'openai-realtime', 'gptlive', 'gpt-realtime', 'gpt-live-1', 'gptlive1', 'openai-live'],
63
+ description: 'OpenAI · Realtime / Live', endpoint: DEFAULT_OPENAI_REALTIME_URL,
53
64
  helpUrl: 'https://platform.openai.com/api-keys',
54
65
  }),
55
66
  defineProvider({
56
- key: 'google-live', label: 'Google Live', aliases: ['google', 'gemini-live', 'googlelive'],
67
+ key: 'google', label: 'Google', aliases: ['google-live', 'gemini-live', 'googlelive'],
68
+ required: 'credential', fields: MODEL_CONNECTION_FIELDS,
57
69
  description: 'Gemini Live API · Google AI', endpoint: DEFAULT_GOOGLE_LIVE_REALTIME_URL,
58
70
  helpUrl: 'https://aistudio.google.com/apikey',
59
71
  }),
60
72
  defineProvider({
61
- key: 'doubao-seeduplex', label: 'Doubao Seeduplex', aliases: ['doubao', 'seeduplex', 'volcengine'],
73
+ key: 'volcengine', label: 'Volcengine', displayLabel: '火山引擎', aliases: ['doubao-seeduplex', 'doubao', 'seeduplex'],
74
+ required: 'credential', fields: MODEL_CONNECTION_FIELDS,
62
75
  description: '豆包实时语音模型 3.0(Seeduplex)· 端到端全双工',
63
76
  endpoint: DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL,
64
77
  helpUrl: 'https://console.volcengine.com/speech/app',
65
78
  }),
66
79
  defineProvider({
67
80
  key: 'speech-to-speech', label: 'Speech-to-Speech', aliases: ['s2s'],
81
+ required: 'endpoint', fields: SERVICE_CONNECTION_FIELDS,
68
82
  description: 'Speech-to-Speech · Hugging Face · 需单独启动本地服务',
69
83
  endpoint: DEFAULT_SPEECH_TO_SPEECH_REALTIME_URL,
70
84
  }),
71
85
  defineProvider({
72
86
  key: 'minicpm-o', label: 'ModelBest', displayLabel: '面壁智能', aliases: ['minicpmo'],
87
+ required: 'endpoint', fields: SERVICE_CONNECTION_FIELDS,
73
88
  description: 'MiniCPM-o 4.5 · 面壁智能 · 本地或云端服务', modelLabel: 'MiniCPM-o 4.5',
74
89
  endpoint: DEFAULT_MINICPM_O_REALTIME_URL,
75
90
  }),
@@ -93,7 +108,7 @@ export function realtimeCredentialFromEnvironment(env = {}, providerName = env.Q
93
108
  // belonging to backend Agents, MCP servers or other modules sharing config.env.
94
109
  export function migrateRealtimeFileEnvironment(input = {}, providerName = input.QWEN_AUDIO_REALTIME_PROVIDER) {
95
110
  const provider = settingsProvider(providerName)
96
- return { ...input, ...legacyRealtimeEnvironment(input, provider.key) }
111
+ return { ...input, ...legacyRealtimeEnvironment({ ...input, QWEN_AUDIO_REALTIME_PROVIDER: providerName }, provider.key) }
97
112
  }
98
113
 
99
114
  // Sources are merged low-to-high. A provider switch must not carry another
@@ -101,11 +116,28 @@ export function migrateRealtimeFileEnvironment(input = {}, providerName = input.
101
116
  export function mergeRealtimeEnvironment(base = {}, overrides = {}) {
102
117
  const previous = settingsProvider(base.QWEN_AUDIO_REALTIME_PROVIDER)
103
118
  const selected = settingsProvider(overrides.QWEN_AUDIO_REALTIME_PROVIDER ?? previous.key)
104
- const result = { ...base }
119
+ const previousSettings = realtimeSettingsFromEnvironment(base)
120
+ const projectedOverrides = legacyRealtimeEnvironment(overrides, selected.key, {
121
+ deferModelVoice: true,
122
+ model: overrides.QWEN_AUDIO_REALTIME_MODEL || legacyRealtimeModel(overrides.QWEN_AUDIO_REALTIME_PROVIDER)
123
+ || (previous.key === selected.key ? previousSettings.realtimeModel : undefined),
124
+ })
125
+ const result = { ...base, ...legacyRealtimeEnvironment(base, previous.key, { deferModelVoice: true }) }
105
126
  if (previous.key !== selected.key) {
106
127
  for (const field of REALTIME_SETTING_SLOTS) delete result[field.environment[0]]
128
+ } else if (projectedOverrides.QWEN_AUDIO_REALTIME_MODEL !== undefined) {
129
+ const next = mergeRealtimeSettings(previousSettings, {
130
+ realtimeProvider: overrides.QWEN_AUDIO_REALTIME_PROVIDER ?? base.QWEN_AUDIO_REALTIME_PROVIDER,
131
+ realtimeModel: projectedOverrides.QWEN_AUDIO_REALTIME_MODEL,
132
+ })
133
+ const beforeAdapter = resolveRealtimeModelProfile(previousSettings.realtimeModel, previous.key).adapter
134
+ const afterAdapter = resolveRealtimeModelProfile(next.realtimeModel, selected.key).adapter
135
+ if (beforeAdapter && afterAdapter && beforeAdapter !== afterAdapter) {
136
+ result.QWEN_AUDIO_REALTIME_VOICE = next.realtimeVoice
137
+ result.QWEN_AUDIO_REALTIME_URL = next.realtimeUrl
138
+ }
107
139
  }
108
- Object.assign(result, overrides)
140
+ Object.assign(result, overrides, projectedOverrides)
109
141
  // A higher-priority legacy Omni voice (including blank) overrides a lower
110
142
  // canonical voice only for Omni. An explicit canonical value in the same
111
143
  // source still wins. Use the merged model when that source only sets voice.
@@ -121,15 +153,16 @@ export function mergeRealtimeEnvironment(base = {}, overrides = {}) {
121
153
  return {
122
154
  ...result,
123
155
  ...legacyRealtimeEnvironment(result, selected.key, { deferModelVoice: true }),
124
- ...legacyRealtimeEnvironment(overrides, selected.key, { deferModelVoice: true }),
156
+ ...projectedOverrides,
125
157
  }
126
158
  }
127
159
 
128
160
  export function realtimeSettingsFromEnvironment(env = {}, drafts = {}) {
129
- const provider = settingsProvider(env.QWEN_AUDIO_REALTIME_PROVIDER ?? drafts.realtimeProvider)
161
+ const requested = env.QWEN_AUDIO_REALTIME_PROVIDER ?? drafts.realtimeProvider
162
+ const provider = settingsProvider(requested)
130
163
  const sameProvider = settingsProvider(drafts.realtimeProvider).key === provider.key
131
- const normalized = migrateRealtimeFileEnvironment(env, provider.key)
132
- const values = sameProvider ? { ...drafts, realtimeProvider: provider.key } : { realtimeProvider: provider.key }
164
+ const normalized = migrateRealtimeFileEnvironment(env, requested)
165
+ const values = sameProvider ? { ...drafts, realtimeProvider: requested } : { realtimeProvider: requested }
133
166
  for (const field of provider.settings) {
134
167
  const raw = normalized[field.environment[0]]
135
168
  if (raw !== undefined) values[field.key] = String(raw ?? '').trim()
@@ -140,14 +173,46 @@ export function realtimeSettingsFromEnvironment(env = {}, drafts = {}) {
140
173
  // A stable allowlisted active snapshot also serves form drafts and dirty checks.
141
174
  export function realtimeSettingsValues(settings = {}) {
142
175
  const provider = settingsProvider(settings.realtimeProvider)
176
+ const model = String(settings.realtimeModel || '').trim()
177
+ || legacyRealtimeModel(settings.realtimeProvider) || realtimeModelCatalog(provider.key)?.defaultModel
178
+ const profile = resolveRealtimeModelProfile(model, provider.key)
143
179
  const values = { realtimeProvider: provider.key, ...Object.fromEntries(REALTIME_SETTING_SLOTS.map(field => [field.key, ''])) }
144
180
  for (const field of provider.settings) {
145
181
  const value = String(settings[field.key] ?? '').trim()
146
- values[field.key] = ['model', 'endpoint'].includes(field.slot) ? value || field.default : value
182
+ values[field.key] = field.slot === 'model' ? model
183
+ : field.slot === 'endpoint' ? value || profile.endpoint || field.default : value
147
184
  }
148
185
  return values
149
186
  }
150
187
 
188
+ // Selection changes retain service credentials, but not another API's endpoint
189
+ // or voice. Explicit values in the same edit always take precedence.
190
+ export function mergeRealtimeSettings(current = {}, patch = {}) {
191
+ const before = realtimeSettingsValues(current)
192
+ const requested = patch.realtimeProvider ?? before.realtimeProvider
193
+ const selected = settingsProvider(requested)
194
+ const changedProvider = before.realtimeProvider !== selected.key
195
+ const modelPatch = patch.realtimeModel === undefined && patch.realtimeProvider !== undefined
196
+ && legacyRealtimeModel(requested)
197
+ ? { realtimeModel: legacyRealtimeModel(requested) } : {}
198
+ const effectivePatch = { ...modelPatch, ...patch }
199
+ const next = realtimeSettingsValues({
200
+ ...(changedProvider ? { realtimeProvider: requested } : before), ...effectivePatch,
201
+ })
202
+ if (!changedProvider && next.realtimeModel !== before.realtimeModel) {
203
+ const previousProfile = resolveRealtimeModelProfile(before.realtimeModel, before.realtimeProvider)
204
+ const nextProfile = resolveRealtimeModelProfile(next.realtimeModel, next.realtimeProvider)
205
+ if (patch.realtimeVoice === undefined) next.realtimeVoice = ''
206
+ // An unknown model cannot establish that the protocol changed. Preserve
207
+ // custom routing while the user repairs an unsupported model selection.
208
+ if (previousProfile.adapter && nextProfile.adapter
209
+ && previousProfile.adapter !== nextProfile.adapter && patch.realtimeUrl === undefined) {
210
+ next.realtimeUrl = realtimeSettingsValues({ realtimeProvider: next.realtimeProvider, realtimeModel: next.realtimeModel }).realtimeUrl
211
+ }
212
+ }
213
+ return next
214
+ }
215
+
151
216
  // Provider drafts exist only in the settings form's memory, not in config.env.
152
217
  export function realtimeSettingsProfileState(settings = {}) {
153
218
  const values = realtimeSettingsValues(settings)
@@ -19,9 +19,9 @@ const USER_CONFIG_TEMPLATE = [
19
19
  '# 前台 API Key:默认 DashScope 必填,请直接在等号后填写',
20
20
  '# 所有前台使用同一组参数,只配置当前供应商;切换时同步更换密钥、模型和地址',
21
21
  ...Object.entries(realtimeRuntimeEnvironment()).map(([key, value]) => `${key}=${value}`),
22
- '# 模型、地址留空可恢复供应商默认值',
22
+ '# 模型留空使用供应商默认模型,地址留空使用所选模型或供应商的默认值',
23
23
  `# 音色留空跟随模型;默认模型的音色为 ${DEFAULT_DASHSCOPE_REALTIME_VOICE}`,
24
- '# 可选 dashscope、stepfun、gpt-live、google-live、doubao-seeduplex、speech-to-speech、minicpm-o',
24
+ '# 可选 dashscope、stepfun、openai、google、volcengine、speech-to-speech、minicpm-o',
25
25
  '# speech-to-speech / minicpm-o 的模型与音色由上游服务管理,只需地址及可选密钥',
26
26
  '',
27
27
  '# 可选目录:QWAUDIO_DATA_DIR / QWAUDIO_STATE_DIR / QWAUDIO_CACHE_DIR',
@@ -3,14 +3,15 @@
3
3
  export function resolveWebSearchConfiguration(env = process.env) {
4
4
  const bailianMcpUrl = 'https://dashscope.aliyuncs.com/api/v1/mcps/WebSearch/mcp'
5
5
  const keenableMcpUrl = 'https://api.keenable.ai/mcp?keenable_title=qwen-audio-agent'
6
+ const parallelMcpUrl = 'https://mcp.parallel.ai/mcp?tools=web_search'
6
7
  const explicitMcpUrl = String(env.QWEN_AUDIO_WEB_SEARCH_MCP_URL || '').trim()
7
8
  const dashscopeApiKey = String(env.DASHSCOPE_API_KEY || '').trim()
8
9
  const requestedProvider = String(env.QWEN_AUDIO_WEB_SEARCH_PROVIDER || '').trim().toLowerCase()
9
10
  const provider = requestedProvider || (explicitMcpUrl ? 'mcp' : 'so360')
10
- if (!['bailian', 'bing', 'keenable', 'mcp', 'none', 'so360'].includes(provider)) {
11
+ if (!['bailian', 'bing', 'keenable', 'mcp', 'none', 'parallel', 'so360'].includes(provider)) {
11
12
  throw new Error(
12
13
  '不支持的 Web Search Provider:'
13
- + `${provider}(可选 bailian、bing、keenable、mcp、none、so360)`,
14
+ + `${provider}(可选 bailian、bing、keenable、mcp、none、parallel、so360)`,
14
15
  )
15
16
  }
16
17
  if (provider === 'keenable') {
@@ -23,6 +24,17 @@ export function resolveWebSearchConfiguration(env = process.env) {
23
24
  mcpTool: 'search_web_pages',
24
25
  }
25
26
  }
27
+ if (provider === 'parallel') {
28
+ // Keyless by default, and `tools=web_search` keeps the shared Parallel MCP
29
+ // server scoped to search. Never forward credentials or endpoint overrides
30
+ // saved for another MCP service; use the custom mcp route for an API key.
31
+ return {
32
+ provider,
33
+ mcpUrl: parallelMcpUrl,
34
+ mcpToken: '',
35
+ mcpTool: 'web_search',
36
+ }
37
+ }
26
38
  const usesBailianMcp = provider === 'bailian'
27
39
  return {
28
40
  provider,