qwen-audio-agent 2.0.1 → 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.
- package/README.md +21 -10
- package/README_ZH.md +19 -10
- 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 +36 -6
- package/cli/src/gateway-service.mjs +7 -1
- package/cli/src/launcher.mjs +13 -0
- package/config/frontend-agent/LIVE_PROMPT.md +64 -0
- package/config/frontend-agent/PROMPT.md +29 -26
- package/desktop/src/i18n.mjs +6 -1
- package/desktop/src/settings-config.mjs +32 -40
- 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 +4 -4
- package/docs/backends/configuration.zh.md +4 -4
- package/docs/backends/overview.md +3 -0
- package/docs/backends/overview.zh.md +3 -0
- package/docs/configuration/backend.md +15 -1
- package/docs/configuration/backend.zh.md +15 -1
- package/docs/configuration/frontend.md +78 -28
- package/docs/configuration/frontend.zh.md +76 -28
- package/docs/configuration.md +1 -1
- package/docs/configuration.zh.md +1 -1
- package/docs/contract.md +24 -2
- package/docs/contract.zh.md +20 -2
- package/docs/extensions.md +14 -0
- package/docs/extensions.zh.md +11 -0
- 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 +4 -1
- package/docs/getting-started/install.zh.md +4 -1
- package/docs/getting-started/mobile.md +8 -2
- package/docs/getting-started/mobile.zh.md +5 -0
- 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 +32 -1
- package/docs/guides/web-search.zh.md +28 -1
- package/docs/operations/troubleshooting.md +30 -0
- package/docs/operations/troubleshooting.zh.md +26 -0
- 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 +22 -4
- package/docs/voice-frontends/custom-provider.zh.md +22 -4
- package/docs/voice-frontends/google-live.md +14 -8
- package/docs/voice-frontends/google-live.zh.md +13 -8
- package/docs/voice-frontends/gpt-live-1.md +149 -0
- package/docs/voice-frontends/gpt-live-1.zh.md +114 -0
- package/docs/voice-frontends/minicpm-o.md +8 -4
- package/docs/voice-frontends/minicpm-o.zh.md +7 -4
- package/docs/voice-frontends/{gpt-live.md → openai-realtime.md} +19 -10
- package/docs/voice-frontends/{gpt-live.zh.md → openai-realtime.zh.md} +18 -10
- package/docs/voice-frontends/qwen-audio-live.md +164 -0
- package/docs/voice-frontends/qwen-audio-live.zh.md +122 -0
- package/docs/voice-frontends/qwen-audio-realtime.md +41 -15
- package/docs/voice-frontends/qwen-audio-realtime.zh.md +34 -12
- package/docs/voice-frontends/qwen-omni-realtime.md +12 -9
- package/docs/voice-frontends/qwen-omni-realtime.zh.md +12 -9
- 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 +34 -16
- package/scripts/audit-dependencies.mjs +3 -25
- package/scripts/electron-smoke.mjs +5 -5
- package/scripts/patch-build-node-gyp.mjs +63 -0
- package/scripts/prepare-build.mjs +2 -0
- package/scripts/release-check +2 -2
- package/scripts/runtime/claude-code-acp.mjs +5 -5
- package/scripts/verify-package.mjs +3 -0
- package/server/package.json +5 -5
- 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 +703 -251
- 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/openclaw.mjs +1 -2
- package/server/src/backend/adapters/acp/input-broker.mjs +2 -0
- package/server/src/backend/adapters/acp/process-client.mjs +111 -16
- 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-agent-context.mjs +18 -5
- 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/citation.mjs +8 -2
- package/server/src/core/config.mjs +46 -54
- package/server/src/core/gateway-protocol.mjs +4 -1
- package/server/src/core/request-security.mjs +7 -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 +20 -7
- package/server/src/frontend/retrieval/providers/bing.mjs +23 -12
- package/server/src/frontend/retrieval/providers/factory.mjs +18 -1
- package/server/src/frontend/retrieval/providers/mcp.mjs +30 -11
- package/server/src/frontend/retrieval/providers/so360.mjs +23 -12
- package/server/src/frontend/tools/agent-task-runtime.mjs +119 -99
- 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 +166 -86
- 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 +24 -11
- package/server/src/orchestration/session-task-coordinator.mjs +13 -3
- package/server/src/orchestration/task-operations.mjs +54 -12
- package/server/src/orchestration/task-updates.mjs +82 -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 +35 -0
- package/server/src/transport/webrtc/protocol.mjs +1 -1
- package/server/src/voice/announcement/announcement-manager.mjs +3 -0
- package/server/src/voice/audio-stream-diagnostics.mjs +139 -0
- package/server/src/voice/native-delegation-runtime.mjs +360 -0
- package/server/src/voice/providers/dashscope-live.mjs +93 -0
- package/server/src/voice/providers/dashscope.mjs +45 -33
- package/server/src/voice/providers/doubao-seeduplex-protocol.mjs +54 -0
- package/server/src/voice/providers/doubao-seeduplex.mjs +16 -11
- package/server/src/voice/providers/ga-protocol.mjs +7 -2
- package/server/src/voice/providers/google-live-protocol.mjs +124 -34
- package/server/src/voice/providers/google-live.mjs +20 -14
- package/server/src/voice/providers/gpt-live-1-protocol.mjs +597 -0
- package/server/src/voice/providers/gpt-live-1.mjs +3 -0
- package/server/src/voice/providers/gpt-live-client-context.mjs +182 -0
- package/server/src/voice/providers/minicpm-o.mjs +9 -7
- package/server/src/voice/providers/openai-live.mjs +150 -0
- package/server/src/voice/providers/{gpt-live.mjs → openai-realtime.mjs} +23 -19
- package/server/src/voice/providers/provider-registry.mjs +11 -1
- package/server/src/voice/providers/qwen-live-protocol.mjs +399 -0
- package/server/src/voice/providers/registry.mjs +47 -12
- package/server/src/voice/providers/runtime-configuration.mjs +34 -0
- package/server/src/voice/providers/s2s.mjs +9 -7
- package/server/src/voice/providers/stepfun.mjs +14 -11
- package/server/src/voice/realtime-input-runtime.mjs +58 -20
- package/server/src/voice/realtime-presentation-runtime.mjs +111 -27
- package/server/src/voice/realtime-provider-session.mjs +59 -14
- package/server/src/voice/realtime-provider.mjs +358 -45
- package/server/src/voice/realtime-session-runtime.mjs +282 -35
- package/server/src/voice/realtime-task-presentation.mjs +8 -2
- package/server/src/voice/realtime-turn-state.mjs +33 -2
- package/shared/backend/catalog.mjs +26 -2
- package/shared/backend/install.mjs +3 -1
- package/shared/backend/setup.mjs +43 -0
- package/shared/gateway/client-sdk.mjs +21 -6
- package/shared/gateway/setup.mjs +13 -1
- package/shared/gateway/websocket-auth.mjs +2 -1
- package/shared/protocol/gateway-client-protocol.mjs +14 -0
- package/shared/protocol/gateway-events.mjs +39 -1
- package/shared/realtime-legacy-environment.mjs +81 -0
- package/shared/realtime-model-catalog.mjs +68 -194
- package/shared/realtime-models/README.md +33 -0
- package/shared/realtime-models/dashscope.mjs +57 -0
- package/shared/realtime-models/google.mjs +10 -0
- package/shared/realtime-models/openai.mjs +24 -0
- package/shared/realtime-models/profile.mjs +38 -0
- package/shared/realtime-models/stepfun.mjs +10 -0
- package/shared/realtime-models/volcengine.mjs +12 -0
- package/shared/realtime-provider-catalog.mjs +23 -11
- package/shared/realtime-provider-definitions.mjs +168 -235
- package/shared/runtime-environment.mjs +23 -30
- package/shared/skill-library.mjs +49 -13
- package/shared/web-search-configuration.mjs +25 -2
- package/tui/package.json +2 -2
- package/tui/src/index.mjs +14 -9
- package/tui/src/runtime-configuration.mjs +2 -0
- package/tui/src/terminal-commands.mjs +40 -0
- package/tui/src/text-cli.mjs +10 -1
- package/web/dist/assets/index-Bc2Q04J9.css +1 -0
- package/web/dist/assets/index-bY4DFXKT.js +96 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BRaiI-dW.js +0 -91
- package/web/dist/assets/index-D9k8R2JY.css +0 -1
|
@@ -1,163 +1,97 @@
|
|
|
1
|
-
// Browser-safe
|
|
2
|
-
//
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL,
|
|
8
|
-
DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_VOICE,
|
|
9
|
-
DEFAULT_STEPFUN_REALTIME_MODEL,
|
|
10
|
-
resolveDashScopeRealtimeModelProfile,
|
|
11
|
-
} from './realtime-model-catalog.mjs'
|
|
1
|
+
// Browser-safe connection metadata. One active connection uses the same fields
|
|
2
|
+
// for every provider; model catalogs and wire adapters remain separate concerns.
|
|
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'
|
|
12
7
|
|
|
13
8
|
export const DEFAULT_REALTIME_PROVIDER = 'dashscope'
|
|
14
9
|
export const DEFAULT_DASHSCOPE_REALTIME_URL = 'wss://dashscope.aliyuncs.com/api-ws/v1/realtime'
|
|
15
10
|
export const DEFAULT_STEPFUN_REALTIME_URL = 'wss://api.stepfun.com/v1/realtime'
|
|
16
11
|
export const DEFAULT_SPEECH_TO_SPEECH_REALTIME_URL = 'ws://127.0.0.1:8765/v1/realtime'
|
|
17
12
|
export const DEFAULT_MINICPM_O_REALTIME_URL = 'ws://127.0.0.1:8006/v1/realtime?mode=audio'
|
|
18
|
-
export const DEFAULT_GPT_LIVE_REALTIME_URL = 'wss://api.openai.com/v1/realtime'
|
|
19
13
|
export const DEFAULT_GOOGLE_LIVE_REALTIME_URL = 'wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent'
|
|
20
14
|
export const DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL = 'wss://openspeech.bytedance.com/api/v3/duplex/realtime/dialogue'
|
|
21
15
|
|
|
22
|
-
// The desktop always presents these four slots, in this order. Providers
|
|
23
|
-
// only bind the slots they can configure; absent bindings render disabled.
|
|
24
16
|
export const REALTIME_SETTING_SLOTS = Object.freeze([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
])
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
{ slot: 'model', key: 'realtimeModel', label: '模型', type: 'model', environment: ['QWEN_AUDIO_REALTIME_MODEL'] },
|
|
18
|
+
{ slot: 'credential', key: 'realtimeApiKey', label: 'API Key', type: 'password', environment: ['QWEN_AUDIO_REALTIME_API_KEY'] },
|
|
19
|
+
{ slot: 'endpoint', key: 'realtimeUrl', label: '服务地址', type: 'url', environment: ['QWEN_AUDIO_REALTIME_URL'] },
|
|
20
|
+
{ slot: 'voice', key: 'realtimeVoice', label: '音色', type: 'text', environment: ['QWEN_AUDIO_REALTIME_VOICE'] },
|
|
21
|
+
].map(field => Object.freeze({ ...field, environment: Object.freeze(field.environment) })))
|
|
22
|
+
|
|
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 }) {
|
|
29
|
+
const catalog = realtimeModelCatalog(definition.key)
|
|
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)
|
|
32
32
|
return Object.freeze({
|
|
33
33
|
...definition,
|
|
34
34
|
aliases: Object.freeze(definition.aliases || []),
|
|
35
|
-
requiredConfiguration: Object.freeze(
|
|
36
|
-
settings: Object.freeze(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
requiredConfiguration: Object.freeze({ field: requiredField.key, key: requiredField.environment[0] }),
|
|
36
|
+
settings: Object.freeze(REALTIME_SETTING_SLOTS
|
|
37
|
+
.filter(field => fields.includes(field.slot))
|
|
38
|
+
.map(field => Object.freeze({
|
|
39
|
+
...field,
|
|
40
|
+
default: field.slot === 'model' ? catalog?.defaultModel || '' : field.slot === 'endpoint' ? endpoint : '',
|
|
41
|
+
...(field.slot === 'credential' ? { helpUrl, placeholder: required === 'credential' ? 'API Key' : '可选,用于 Bearer 认证' } : {}),
|
|
42
|
+
}))),
|
|
41
43
|
})
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export const REALTIME_PROVIDERS = Object.freeze([
|
|
45
47
|
defineProvider({
|
|
46
48
|
key: 'dashscope', label: 'DashScope', aliases: ['qwen'],
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
slot: 'credential', placeholder: 'sk-…',
|
|
52
|
-
environment: ['DASHSCOPE_API_KEY'],
|
|
53
|
-
helpUrl: 'https://bailian.console.aliyun.com/?tab=model#/api-key' },
|
|
54
|
-
{ key: 'realtimeModel', environment: ['QWEN_AUDIO_REALTIME_MODEL'], slot: 'model', default: DEFAULT_DASHSCOPE_REALTIME_MODEL },
|
|
55
|
-
{ key: 'audioRealtimeVoice', environment: ['QWEN_AUDIO_REALTIME_VOICE'], slot: 'voice', modelFamily: 'audio' },
|
|
56
|
-
{ key: 'omniRealtimeVoice', slot: 'voice', modelFamily: 'omni',
|
|
57
|
-
environment: ['QWEN_OMNI_REALTIME_VOICE'] },
|
|
58
|
-
{ key: 'realtimeBaseUrl',
|
|
59
|
-
slot: 'endpoint', default: DEFAULT_DASHSCOPE_REALTIME_URL,
|
|
60
|
-
environment: ['QWEN_AUDIO_REALTIME_BASE_URL', 'QWEN_AUDIO_REALTIME_URL'] },
|
|
61
|
-
],
|
|
49
|
+
required: 'credential', fields: MODEL_CONNECTION_FIELDS,
|
|
50
|
+
description: 'Qwen Realtime / Live · DashScope',
|
|
51
|
+
endpoint: DEFAULT_DASHSCOPE_REALTIME_URL,
|
|
52
|
+
helpUrl: 'https://bailian.console.aliyun.com/?tab=model#/api-key',
|
|
62
53
|
}),
|
|
63
54
|
defineProvider({
|
|
64
|
-
key: 'stepfun', label: 'StepFun',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
settings: [
|
|
68
|
-
{ key: 'stepfunApiKey', slot: 'credential', placeholder: 'sk-…',
|
|
69
|
-
environment: ['STEPFUN_API_KEY'] },
|
|
70
|
-
{ key: 'stepfunRealtimeModel', slot: 'model', default: DEFAULT_STEPFUN_REALTIME_MODEL,
|
|
71
|
-
environment: ['STEPFUN_REALTIME_MODEL'] },
|
|
72
|
-
{ key: 'stepfunRealtimeVoice', slot: 'voice', placeholder: '留空使用服务默认音色',
|
|
73
|
-
environment: ['STEPFUN_REALTIME_VOICE'] },
|
|
74
|
-
{ key: 'stepfunRealtimeUrl', slot: 'endpoint', default: DEFAULT_STEPFUN_REALTIME_URL,
|
|
75
|
-
environment: ['STEPFUN_REALTIME_URL'] },
|
|
76
|
-
],
|
|
55
|
+
key: 'stepfun', label: 'StepFun', description: 'StepAudio 3 Realtime · 阶跃星辰',
|
|
56
|
+
required: 'credential', fields: MODEL_CONNECTION_FIELDS,
|
|
57
|
+
endpoint: DEFAULT_STEPFUN_REALTIME_URL,
|
|
77
58
|
}),
|
|
78
59
|
defineProvider({
|
|
79
|
-
key: '
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
slot: 'credential', placeholder: 'sk-…',
|
|
85
|
-
helpUrl: 'https://platform.openai.com/api-keys' },
|
|
86
|
-
{ key: 'gptLiveRealtimeModel', environment: ['GPT_LIVE_REALTIME_MODEL', 'OPENAI_REALTIME_MODEL'],
|
|
87
|
-
slot: 'model', default: DEFAULT_GPT_LIVE_REALTIME_MODEL },
|
|
88
|
-
{ key: 'gptLiveRealtimeVoice', environment: ['GPT_LIVE_REALTIME_VOICE', 'OPENAI_REALTIME_VOICE'],
|
|
89
|
-
slot: 'voice', placeholder: '留空使用服务默认音色' },
|
|
90
|
-
{ key: 'gptLiveRealtimeUrl', environment: ['GPT_LIVE_REALTIME_URL', 'OPENAI_REALTIME_URL'],
|
|
91
|
-
slot: 'endpoint', default: DEFAULT_GPT_LIVE_REALTIME_URL },
|
|
92
|
-
],
|
|
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,
|
|
64
|
+
helpUrl: 'https://platform.openai.com/api-keys',
|
|
93
65
|
}),
|
|
94
66
|
defineProvider({
|
|
95
|
-
key: 'google
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{ key: 'googleApiKey', environment: ['GOOGLE_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_LIVE_API_KEY'],
|
|
100
|
-
slot: 'credential', placeholder: 'AIza…',
|
|
101
|
-
helpUrl: 'https://aistudio.google.com/apikey' },
|
|
102
|
-
{ key: 'googleLiveRealtimeModel', environment: ['GOOGLE_LIVE_REALTIME_MODEL', 'GEMINI_LIVE_REALTIME_MODEL'],
|
|
103
|
-
slot: 'model', default: DEFAULT_GOOGLE_LIVE_REALTIME_MODEL },
|
|
104
|
-
{ key: 'googleLiveRealtimeVoice', environment: ['GOOGLE_LIVE_REALTIME_VOICE', 'GEMINI_LIVE_REALTIME_VOICE'],
|
|
105
|
-
slot: 'voice', placeholder: '留空使用服务默认音色' },
|
|
106
|
-
{ key: 'googleLiveRealtimeUrl', environment: ['GOOGLE_LIVE_REALTIME_URL', 'GEMINI_LIVE_REALTIME_URL'],
|
|
107
|
-
slot: 'endpoint', default: DEFAULT_GOOGLE_LIVE_REALTIME_URL },
|
|
108
|
-
],
|
|
67
|
+
key: 'google', label: 'Google', aliases: ['google-live', 'gemini-live', 'googlelive'],
|
|
68
|
+
required: 'credential', fields: MODEL_CONNECTION_FIELDS,
|
|
69
|
+
description: 'Gemini Live API · Google AI', endpoint: DEFAULT_GOOGLE_LIVE_REALTIME_URL,
|
|
70
|
+
helpUrl: 'https://aistudio.google.com/apikey',
|
|
109
71
|
}),
|
|
110
72
|
defineProvider({
|
|
111
|
-
key: '
|
|
73
|
+
key: 'volcengine', label: 'Volcengine', displayLabel: '火山引擎', aliases: ['doubao-seeduplex', 'doubao', 'seeduplex'],
|
|
74
|
+
required: 'credential', fields: MODEL_CONNECTION_FIELDS,
|
|
112
75
|
description: '豆包实时语音模型 3.0(Seeduplex)· 端到端全双工',
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
{ key: 'doubaoApiKey', slot: 'credential', placeholder: '火山引擎豆包语音 API Key',
|
|
116
|
-
environment: ['DOUBAO_API_KEY', 'SEEDUPLEX_API_KEY', 'VOLCENGINE_DOUBAO_API_KEY'],
|
|
117
|
-
helpUrl: 'https://console.volcengine.com/speech/app' },
|
|
118
|
-
{ key: 'doubaoSeeduplexRealtimeModel', slot: 'model', default: DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_MODEL,
|
|
119
|
-
environment: ['DOUBAO_SEEDUPLEX_REALTIME_MODEL'] },
|
|
120
|
-
{ key: 'doubaoSeeduplexRealtimeVoice', slot: 'voice', default: DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_VOICE,
|
|
121
|
-
environment: ['DOUBAO_SEEDUPLEX_REALTIME_VOICE'] },
|
|
122
|
-
{ key: 'doubaoSeeduplexRealtimeUrl', slot: 'endpoint', default: DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL,
|
|
123
|
-
environment: ['DOUBAO_SEEDUPLEX_REALTIME_URL'] },
|
|
124
|
-
],
|
|
76
|
+
endpoint: DEFAULT_DOUBAO_SEEDUPLEX_REALTIME_URL,
|
|
77
|
+
helpUrl: 'https://console.volcengine.com/speech/app',
|
|
125
78
|
}),
|
|
126
79
|
defineProvider({
|
|
127
80
|
key: 'speech-to-speech', label: 'Speech-to-Speech', aliases: ['s2s'],
|
|
81
|
+
required: 'endpoint', fields: SERVICE_CONNECTION_FIELDS,
|
|
128
82
|
description: 'Speech-to-Speech · Hugging Face · 需单独启动本地服务',
|
|
129
|
-
|
|
130
|
-
settings: [
|
|
131
|
-
{ key: 'speechToSpeechRealtimeUrl',
|
|
132
|
-
slot: 'endpoint', activeDefault: DEFAULT_SPEECH_TO_SPEECH_REALTIME_URL,
|
|
133
|
-
environment: ['SPEECH_TO_SPEECH_REALTIME_URL', 'S2S_REALTIME_URL'] },
|
|
134
|
-
{ key: 'speechToSpeechAuthToken',
|
|
135
|
-
slot: 'credential', placeholder: '可选,用于 Bearer 认证',
|
|
136
|
-
environment: ['SPEECH_TO_SPEECH_AUTH_TOKEN', 'S2S_API_KEY'] },
|
|
137
|
-
],
|
|
83
|
+
endpoint: DEFAULT_SPEECH_TO_SPEECH_REALTIME_URL,
|
|
138
84
|
}),
|
|
139
85
|
defineProvider({
|
|
140
86
|
key: 'minicpm-o', label: 'ModelBest', displayLabel: '面壁智能', aliases: ['minicpmo'],
|
|
141
|
-
|
|
142
|
-
modelLabel: 'MiniCPM-o 4.5',
|
|
143
|
-
|
|
144
|
-
settings: [
|
|
145
|
-
{ key: 'miniCpmORealtimeUrl', slot: 'endpoint', activeDefault: DEFAULT_MINICPM_O_REALTIME_URL,
|
|
146
|
-
environment: ['MINICPM_O_REALTIME_URL'] },
|
|
147
|
-
{ key: 'miniCpmOAuthToken', slot: 'credential', placeholder: '可选,用于 Bearer 认证',
|
|
148
|
-
environment: ['MINICPM_O_AUTH_TOKEN'] },
|
|
149
|
-
],
|
|
87
|
+
required: 'endpoint', fields: SERVICE_CONNECTION_FIELDS,
|
|
88
|
+
description: 'MiniCPM-o 4.5 · 面壁智能 · 本地或云端服务', modelLabel: 'MiniCPM-o 4.5',
|
|
89
|
+
endpoint: DEFAULT_MINICPM_O_REALTIME_URL,
|
|
150
90
|
}),
|
|
151
91
|
])
|
|
152
92
|
|
|
153
|
-
export const REALTIME_SETTING_FIELDS = Object.freeze([
|
|
154
|
-
|
|
155
|
-
...REALTIME_PROVIDERS.flatMap(provider => provider.settings.map(field => field.key)),
|
|
156
|
-
])
|
|
157
|
-
|
|
158
|
-
export function realtimeProfileFieldKey(field) {
|
|
159
|
-
return field.modelFamily ? field.modelFamily + 'Voice' : field.slot
|
|
160
|
-
}
|
|
93
|
+
export const REALTIME_SETTING_FIELDS = Object.freeze(['realtimeProvider', ...REALTIME_SETTING_SLOTS.map(field => field.key)])
|
|
94
|
+
export function realtimeProfileFieldKey(field) { return field.slot }
|
|
161
95
|
|
|
162
96
|
function settingsProvider(value = DEFAULT_REALTIME_PROVIDER) {
|
|
163
97
|
const key = String(value || DEFAULT_REALTIME_PROVIDER).trim().toLowerCase()
|
|
@@ -166,152 +100,151 @@ function settingsProvider(value = DEFAULT_REALTIME_PROVIDER) {
|
|
|
166
100
|
return provider
|
|
167
101
|
}
|
|
168
102
|
|
|
169
|
-
function
|
|
170
|
-
|
|
171
|
-
return key === undefined ? undefined : String(env[key] ?? '').trim()
|
|
103
|
+
export function realtimeCredentialFromEnvironment(env = {}, providerName = env.QWEN_AUDIO_REALTIME_PROVIDER) {
|
|
104
|
+
return realtimeSettingsFromEnvironment({ ...env, QWEN_AUDIO_REALTIME_PROVIDER: providerName }).realtimeApiKey
|
|
172
105
|
}
|
|
173
106
|
|
|
174
|
-
//
|
|
175
|
-
|
|
107
|
+
// Normalize legacy names at the input boundary only. Never rewrite credentials
|
|
108
|
+
// belonging to backend Agents, MCP servers or other modules sharing config.env.
|
|
109
|
+
export function migrateRealtimeFileEnvironment(input = {}, providerName = input.QWEN_AUDIO_REALTIME_PROVIDER) {
|
|
176
110
|
const provider = settingsProvider(providerName)
|
|
177
|
-
|
|
178
|
-
return field ? providerEnvironmentValue(env, field) ?? '' : ''
|
|
111
|
+
return { ...input, ...legacyRealtimeEnvironment({ ...input, QWEN_AUDIO_REALTIME_PROVIDER: providerName }, provider.key) }
|
|
179
112
|
}
|
|
180
113
|
|
|
181
|
-
//
|
|
114
|
+
// Sources are merged low-to-high. A provider switch must not carry another
|
|
115
|
+
// provider's generic credential, URL, model or voice into the new connection.
|
|
182
116
|
export function mergeRealtimeEnvironment(base = {}, overrides = {}) {
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
117
|
+
const previous = settingsProvider(base.QWEN_AUDIO_REALTIME_PROVIDER)
|
|
118
|
+
const selected = settingsProvider(overrides.QWEN_AUDIO_REALTIME_PROVIDER ?? previous.key)
|
|
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 }) }
|
|
126
|
+
if (previous.key !== selected.key) {
|
|
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
|
+
}
|
|
139
|
+
}
|
|
140
|
+
Object.assign(result, overrides, projectedOverrides)
|
|
141
|
+
// A higher-priority legacy Omni voice (including blank) overrides a lower
|
|
142
|
+
// canonical voice only for Omni. An explicit canonical value in the same
|
|
143
|
+
// source still wins. Use the merged model when that source only sets voice.
|
|
144
|
+
if (selected.key === 'dashscope'
|
|
145
|
+
&& overrides.QWEN_AUDIO_REALTIME_VOICE === undefined
|
|
146
|
+
&& legacyOmniVoiceFromEnvironment(overrides, result.QWEN_AUDIO_REALTIME_MODEL) !== undefined) {
|
|
147
|
+
delete result.QWEN_AUDIO_REALTIME_VOICE
|
|
148
|
+
}
|
|
149
|
+
// Normalize each source before overlaying so a higher-priority legacy value
|
|
150
|
+
// can still override a lower-priority canonical value of the same provider.
|
|
151
|
+
// Keep model-dependent aliases in their original fields until final settings
|
|
152
|
+
// resolution: another source may switch Omni to Audio (and back) afterwards.
|
|
153
|
+
return {
|
|
154
|
+
...result,
|
|
155
|
+
...legacyRealtimeEnvironment(result, selected.key, { deferModelVoice: true }),
|
|
156
|
+
...projectedOverrides,
|
|
157
|
+
}
|
|
188
158
|
}
|
|
189
159
|
|
|
190
|
-
// Provider-owned fields override draft fallbacks, including explicit blanks.
|
|
191
160
|
export function realtimeSettingsFromEnvironment(env = {}, drafts = {}) {
|
|
192
|
-
const
|
|
193
|
-
const provider = settingsProvider(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
if (!['QWEN_AUDIO_REALTIME_BASE_URL', 'QWEN_AUDIO_REALTIME_URL'].some(key => env[key] !== undefined)
|
|
202
|
-
&& String(env.DASHSCOPE_WORKSPACE_ID || '').trim()) {
|
|
203
|
-
values.realtimeBaseUrl = 'wss://' + String(env.DASHSCOPE_WORKSPACE_ID).trim()
|
|
204
|
-
+ '.cn-beijing.maas.aliyuncs.com/api-ws/v1/realtime'
|
|
161
|
+
const requested = env.QWEN_AUDIO_REALTIME_PROVIDER ?? drafts.realtimeProvider
|
|
162
|
+
const provider = settingsProvider(requested)
|
|
163
|
+
const sameProvider = settingsProvider(drafts.realtimeProvider).key === provider.key
|
|
164
|
+
const normalized = migrateRealtimeFileEnvironment(env, requested)
|
|
165
|
+
const values = sameProvider ? { ...drafts, realtimeProvider: requested } : { realtimeProvider: requested }
|
|
166
|
+
for (const field of provider.settings) {
|
|
167
|
+
const raw = normalized[field.environment[0]]
|
|
168
|
+
if (raw !== undefined) values[field.key] = String(raw ?? '').trim()
|
|
205
169
|
}
|
|
170
|
+
return realtimeSettingsValues(values)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// A stable allowlisted active snapshot also serves form drafts and dirty checks.
|
|
174
|
+
export function realtimeSettingsValues(settings = {}) {
|
|
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)
|
|
179
|
+
const values = { realtimeProvider: provider.key, ...Object.fromEntries(REALTIME_SETTING_SLOTS.map(field => [field.key, ''])) }
|
|
206
180
|
for (const field of provider.settings) {
|
|
207
|
-
|
|
208
|
-
|
|
181
|
+
const value = String(settings[field.key] ?? '').trim()
|
|
182
|
+
values[field.key] = field.slot === 'model' ? model
|
|
183
|
+
: field.slot === 'endpoint' ? value || profile.endpoint || field.default : value
|
|
209
184
|
}
|
|
210
185
|
return values
|
|
211
186
|
}
|
|
212
187
|
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
+
}
|
|
220
212
|
}
|
|
213
|
+
return next
|
|
221
214
|
}
|
|
222
215
|
|
|
216
|
+
// Provider drafts exist only in the settings form's memory, not in config.env.
|
|
223
217
|
export function realtimeSettingsProfileState(settings = {}) {
|
|
224
218
|
const values = realtimeSettingsValues(settings)
|
|
225
|
-
const
|
|
226
|
-
provider.key,
|
|
227
|
-
Object.freeze(Object.fromEntries(provider.settings.map(field => [realtimeProfileFieldKey(field), values[field.key]]))),
|
|
228
|
-
]))
|
|
219
|
+
const provider = settingsProvider(values.realtimeProvider)
|
|
229
220
|
return Object.freeze({
|
|
230
|
-
activeProvider:
|
|
231
|
-
profiles: Object.freeze(
|
|
221
|
+
activeProvider: provider.key,
|
|
222
|
+
profiles: Object.freeze({
|
|
223
|
+
[provider.key]: Object.freeze(Object.fromEntries(provider.settings.map(field => [field.slot, values[field.key]]))),
|
|
224
|
+
}),
|
|
232
225
|
})
|
|
233
226
|
}
|
|
234
227
|
|
|
235
228
|
export function realtimeSettingsFromProfileState(state = {}) {
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
for (const provider of REALTIME_PROVIDERS) {
|
|
242
|
-
const profile = state.profiles?.[provider.key]
|
|
243
|
-
for (const field of provider.settings) {
|
|
244
|
-
values[field.key] = String(profile?.[realtimeProfileFieldKey(field)] ?? defaults[field.key])
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return values
|
|
229
|
+
const provider = settingsProvider(state.activeProvider)
|
|
230
|
+
return realtimeSettingsValues({
|
|
231
|
+
realtimeProvider: provider.key,
|
|
232
|
+
...Object.fromEntries(provider.settings.map(field => [field.key, state.profiles?.[provider.key]?.[field.slot]])),
|
|
233
|
+
})
|
|
248
234
|
}
|
|
249
235
|
|
|
250
236
|
export function realtimeRuntimeEnvironment(settings = {}) {
|
|
251
237
|
const values = realtimeSettingsValues(settings)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
environment[field.environment[0]] = values[field.key]
|
|
256
|
-
}
|
|
238
|
+
return {
|
|
239
|
+
QWEN_AUDIO_REALTIME_PROVIDER: values.realtimeProvider,
|
|
240
|
+
...Object.fromEntries(REALTIME_SETTING_SLOTS.map(field => [field.environment[0], values[field.key]])),
|
|
257
241
|
}
|
|
258
|
-
return environment
|
|
259
242
|
}
|
|
260
243
|
|
|
261
|
-
// Runtime normalization is internal data, never a public override namespace.
|
|
262
244
|
export function realtimeSettingsConnection(settings = {}) {
|
|
263
245
|
const values = realtimeSettingsValues(settings)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const family = provider.key === 'dashscope' ? resolveDashScopeRealtimeModelProfile(model).family : null
|
|
268
|
-
const connection = { provider: provider.key, model, endpoint: '', credential: '', voice: '' }
|
|
269
|
-
for (const field of provider.settings) {
|
|
270
|
-
if (field.modelFamily && field.modelFamily !== family) continue
|
|
271
|
-
connection[field.slot] = values[field.key]
|
|
272
|
-
|| (field.slot === 'endpoint' ? field.default || field.activeDefault || '' : '')
|
|
273
|
-
}
|
|
274
|
-
connection.model = model
|
|
275
|
-
return connection
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Import only persisted transitional files, before merging configuration sources.
|
|
279
|
-
// Removed variables in the process environment are deliberately NOT supported.
|
|
280
|
-
export function migrateRealtimeFileEnvironment(input = {}) {
|
|
281
|
-
const values = { ...input }
|
|
282
|
-
const legacyKey = 'QWEN_AUDIO_REALTIME_API_KEY'
|
|
283
|
-
const legacyEndpoint = 'QWEN_AUDIO_REALTIME_ENDPOINT'
|
|
284
|
-
if (!Object.hasOwn(values, legacyKey) && !Object.hasOwn(values, legacyEndpoint)) return values
|
|
285
|
-
const provider = settingsProvider(values.QWEN_AUDIO_REALTIME_PROVIDER)
|
|
286
|
-
const move = (source, destination, credential = false) => {
|
|
287
|
-
if (!destination || source === destination || !Object.hasOwn(values, source)) return
|
|
288
|
-
if (credential && Object.hasOwn(values, destination)
|
|
289
|
-
&& String(values[source]).trim() !== String(values[destination]).trim()) {
|
|
290
|
-
throw new Error('Realtime configuration migration conflict: ' + source + ' and ' + destination
|
|
291
|
-
+ ' differ. Keep the intended provider credential in ' + destination + ' and remove ' + source + '.')
|
|
292
|
-
}
|
|
293
|
-
if (!Object.hasOwn(values, destination)) values[destination] = values[source]
|
|
294
|
-
delete values[source]
|
|
295
|
-
}
|
|
296
|
-
const fieldFor = slot => provider.settings.find(field => field.slot === slot)
|
|
297
|
-
move(legacyKey, fieldFor('credential')?.environment[0], true)
|
|
298
|
-
move(legacyEndpoint, fieldFor('endpoint')?.environment[0])
|
|
299
|
-
const modelKey = 'QWEN_AUDIO_REALTIME_MODEL'
|
|
300
|
-
const voiceKey = 'QWEN_AUDIO_REALTIME_VOICE'
|
|
301
|
-
if (provider.key === 'stepfun') {
|
|
302
|
-
// A historical DashScope model alongside StepFun is not a StepFun override.
|
|
303
|
-
if (resolveDashScopeRealtimeModelProfile(values[modelKey] || '').family === 'unknown') {
|
|
304
|
-
move(modelKey, fieldFor('model')?.environment[0])
|
|
305
|
-
}
|
|
306
|
-
move(voiceKey, fieldFor('voice')?.environment[0])
|
|
307
|
-
} else if (provider.key === 'dashscope'
|
|
308
|
-
&& resolveDashScopeRealtimeModelProfile(values[modelKey]).family === 'omni') {
|
|
309
|
-
move(voiceKey, 'QWEN_OMNI_REALTIME_VOICE')
|
|
310
|
-
} else if (provider.key !== 'dashscope') {
|
|
311
|
-
if (!values[modelKey]) delete values[modelKey]
|
|
312
|
-
if (!values[voiceKey]) delete values[voiceKey]
|
|
246
|
+
return {
|
|
247
|
+
provider: values.realtimeProvider,
|
|
248
|
+
...Object.fromEntries(REALTIME_SETTING_SLOTS.map(field => [field.slot, values[field.key]])),
|
|
313
249
|
}
|
|
314
|
-
delete values[legacyKey]
|
|
315
|
-
delete values[legacyEndpoint]
|
|
316
|
-
return values
|
|
317
250
|
}
|
|
@@ -10,40 +10,29 @@ import { resolve } from 'node:path'
|
|
|
10
10
|
import { parseEnv } from 'node:util'
|
|
11
11
|
import { resolveRuntimePaths, runtimePathEnvironment, userConfigDirectory } from './runtime-paths.mjs'
|
|
12
12
|
import { backendDefinitions } from './backend/catalog.mjs'
|
|
13
|
-
import { assertRealtimeFrontendModel, resolveRealtimeFrontendConfiguration } from './realtime-provider-catalog.mjs'
|
|
14
|
-
import {
|
|
13
|
+
import { assertRealtimeFrontendModel, DEFAULT_DASHSCOPE_REALTIME_VOICE, resolveRealtimeFrontendConfiguration } from './realtime-provider-catalog.mjs'
|
|
14
|
+
import { mergeRealtimeEnvironment, realtimeRuntimeEnvironment } from './realtime-provider-definitions.mjs'
|
|
15
15
|
|
|
16
16
|
const SECRET_KEY = 'QWEN_AUDIO_AGENT_AUTH_SECRET'
|
|
17
17
|
const USER_CONFIG_TEMPLATE = [
|
|
18
18
|
'# qwen-audio-agent 用户配置',
|
|
19
|
-
'# 前台 API Key
|
|
20
|
-
'#
|
|
21
|
-
|
|
22
|
-
'#
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
'#
|
|
26
|
-
'# STEPFUN_REALTIME_URL=wss://api.stepfun.com/v1/realtime',
|
|
27
|
-
'# STEPFUN_REALTIME_MODEL=stepaudio-3-realtime-preview',
|
|
28
|
-
'# STEPFUN_REALTIME_VOICE=',
|
|
29
|
-
'# 豆包 Seeduplex 端到端全双工:将 Provider 改为 doubao-seeduplex,并填写 DOUBAO_API_KEY',
|
|
30
|
-
'# DOUBAO_SEEDUPLEX_REALTIME_URL=wss://openspeech.bytedance.com/api/v3/duplex/realtime/dialogue',
|
|
31
|
-
'# DOUBAO_SEEDUPLEX_REALTIME_MODEL=1.2.6.1',
|
|
32
|
-
'# DOUBAO_SEEDUPLEX_REALTIME_VOICE=zh_female_vv_jupiter_bigtts',
|
|
33
|
-
'# Hugging Face speech-to-speech:将上一行改为 speech-to-speech,并设置服务地址',
|
|
34
|
-
'# SPEECH_TO_SPEECH_REALTIME_URL=ws://127.0.0.1:8765/v1/realtime',
|
|
35
|
-
'# MiniCPM-o 4.5:将 Provider 改为 minicpm-o,并先启动本地 Realtime 服务',
|
|
36
|
-
'# MINICPM_O_REALTIME_URL=ws://127.0.0.1:8006/v1/realtime?mode=audio',
|
|
19
|
+
'# 前台 API Key:默认 DashScope 必填,请直接在等号后填写',
|
|
20
|
+
'# 所有前台使用同一组参数,只配置当前供应商;切换时同步更换密钥、模型和地址',
|
|
21
|
+
...Object.entries(realtimeRuntimeEnvironment()).map(([key, value]) => `${key}=${value}`),
|
|
22
|
+
'# 模型留空使用供应商默认模型,地址留空使用所选模型或供应商的默认值',
|
|
23
|
+
`# 音色留空跟随模型;默认模型的音色为 ${DEFAULT_DASHSCOPE_REALTIME_VOICE}`,
|
|
24
|
+
'# 可选 dashscope、stepfun、openai、google、volcengine、speech-to-speech、minicpm-o',
|
|
25
|
+
'# speech-to-speech / minicpm-o 的模型与音色由上游服务管理,只需地址及可选密钥',
|
|
37
26
|
'',
|
|
38
27
|
'# 可选目录:QWAUDIO_DATA_DIR / QWAUDIO_STATE_DIR / QWAUDIO_CACHE_DIR',
|
|
39
28
|
'# 所有后台默认工作区:QWAUDIO_WORKSPACE=/absolute/path/to/projects',
|
|
40
29
|
'',
|
|
41
30
|
'# 可选:选择后台 Agent;留空时仅使用前台实时语音聊天',
|
|
42
|
-
'# 可选 openclaw、opencode、qoder、qwen、minimax、kimi、hermes、codebuddy、codex、claude、deepseek、pi、acp 或 none',
|
|
31
|
+
'# 可选 openclaw、opencode、qoder、qwen、minimax、kimi、hermes、codebuddy、codex、claude、deepseek、pi、muse、acp、llm 或 none',
|
|
43
32
|
'AGENT_PROTOCOL=',
|
|
44
33
|
'# 权限模式:native(后台自行询问)或 full(最高权限;仅支持安全映射的后端)',
|
|
45
34
|
'# Pi 没有权限审批机制,无论配置什么都始终生效 full',
|
|
46
|
-
'
|
|
35
|
+
'QWEN_AUDIO_AGENT_BACKEND_PERMISSION_MODE=native',
|
|
47
36
|
'# 可选:通过 ACP 标准覆盖 Session 模型;OpenCode/OpenClaw 托管初始化也会使用',
|
|
48
37
|
'# 留空时完全沿用 Agent 原有模型;后台未声明 ACP 模型选项时显式覆盖会失败',
|
|
49
38
|
'# QWEN_AUDIO_AGENT_BACKEND_MODEL=',
|
|
@@ -52,12 +41,16 @@ const USER_CONFIG_TEMPLATE = [
|
|
|
52
41
|
'# DeepSeek(Harness Developer Preview):DEEPSEEK_API_KEY=your-key',
|
|
53
42
|
'# 通用 ACP:ACP_COMMAND=your-agent,ACP_ARGS=["--acp"]',
|
|
54
43
|
'# 通用 ACP 如需额外环境变量:QWEN_AUDIO_AGENT_ACP_FORWARD_ENV=NAME_A,NAME_B',
|
|
44
|
+
'# 裸 LLM(OpenAI-compatible):AGENT_PROTOCOL=llm,并设置后台模型与 API Key',
|
|
45
|
+
'# QWEN_AUDIO_AGENT_LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
46
|
+
'# QWEN_AUDIO_AGENT_LLM_API_KEY=',
|
|
47
|
+
'# QWEN_AUDIO_AGENT_LLM_SYSTEM_PROMPT=',
|
|
55
48
|
'',
|
|
56
49
|
'# 可选:前台 MCP 配置文件的绝对路径;MCP 引用的持久变量也写在本文件中',
|
|
57
50
|
'# QWEN_AUDIO_FRONTEND_MCP_CONFIG=/absolute/path/to/frontend-mcp.json',
|
|
58
51
|
'',
|
|
59
|
-
'#
|
|
60
|
-
'
|
|
52
|
+
'# 记忆 Provider:markdown(默认)或 voicemem;VoiceMem 需先安装 Python 依赖',
|
|
53
|
+
'QWEN_AUDIO_MEMORY_PROVIDER=markdown',
|
|
61
54
|
'# VOICEMEM_INPUT_MODE=text',
|
|
62
55
|
'# VOICEMEM_PYTHON=/absolute/path/to/voicemem-python',
|
|
63
56
|
'# VOICEMEM_SIDECAR=/absolute/path/to/voicemem-sidecar.py',
|
|
@@ -68,10 +61,10 @@ const USER_CONFIG_TEMPLATE = [
|
|
|
68
61
|
'# QWEN_AUDIO_GATEWAY_ACCESS_TOKEN=至少24字符的随机密钥',
|
|
69
62
|
'# QWEN_AUDIO_AGENT_ALLOWED_ORIGINS=https://voice.example.com',
|
|
70
63
|
'',
|
|
71
|
-
'#
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
64
|
+
'# 日志设置:默认 info、单文件 10 MiB、保留 5 份',
|
|
65
|
+
'QWEN_AUDIO_LOG_LEVEL=info',
|
|
66
|
+
'QWEN_AUDIO_LOG_MAX_BYTES=10485760',
|
|
67
|
+
'QWEN_AUDIO_LOG_MAX_FILES=5',
|
|
75
68
|
'',
|
|
76
69
|
].join('\n')
|
|
77
70
|
const USER_MODEL_TEMPLATE = [
|
|
@@ -107,7 +100,7 @@ const MEMORY_TEMPLATE = [
|
|
|
107
100
|
function loadFile(path, env) {
|
|
108
101
|
let values
|
|
109
102
|
try {
|
|
110
|
-
values =
|
|
103
|
+
values = parseEnv(readFileSync(path, 'utf8'))
|
|
111
104
|
} catch (error) {
|
|
112
105
|
if (error.code === 'ENOENT') return false
|
|
113
106
|
throw error
|
|
@@ -389,7 +382,7 @@ export function hasDashScopeCredential(env = process.env) {
|
|
|
389
382
|
export function requireDashScopeCredential(env = process.env) {
|
|
390
383
|
if (hasDashScopeCredential(env)) return
|
|
391
384
|
throw new Error(
|
|
392
|
-
'缺少
|
|
385
|
+
'缺少 QWEN_AUDIO_REALTIME_API_KEY。请运行 qwenaudio config 查看配置文件位置。',
|
|
393
386
|
)
|
|
394
387
|
}
|
|
395
388
|
|