nova-personal-agent-server 0.4.0 → 1.0.2
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/LICENSE +674 -201
- package/README.md +12 -2
- package/bin/nova-space-host.mjs +4 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/cli.js +71 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/client.js +340 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/crypto.js +167 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/live.js +169 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/mailbox.js +217 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/media.js +320 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/pairing.js +13 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/protocol.js +50 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/security.js +305 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/server.js +477 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/source-address.js +58 -0
- package/node_modules/@nova-personal-agent/relay/package.json +1 -0
- package/package.json +13 -6
- package/runtime/dist/src/cascaded-text-provider.js +8 -3
- package/runtime/dist/src/composition/assembly.js +133 -35
- package/runtime/dist/src/composition/cascaded-realtime-assembly.js +114 -59
- package/runtime/dist/src/composition/production-composition.js +57 -21
- package/runtime/dist/src/composition/realtime-assembly.js +160 -52
- package/runtime/dist/src/composition/soul-context.js +22 -0
- package/runtime/dist/src/config/capability-registry.js +48 -3
- package/runtime/dist/src/config/cascaded-realtime-config.js +23 -10
- package/runtime/dist/src/config/config.js +541 -128
- package/runtime/dist/src/config/credential-rotation.js +26 -0
- package/runtime/dist/src/config/data-root.js +764 -0
- package/runtime/dist/src/config/diagnostics.js +3 -1
- package/runtime/dist/src/config/environment-contract.js +190 -188
- package/runtime/dist/src/config/model-routes.js +140 -0
- package/runtime/dist/src/config/voice-credentials.js +55 -0
- package/runtime/dist/src/connectors/composio/index.js +9 -0
- package/runtime/dist/src/connectors/feishu/index.js +258 -44
- package/runtime/dist/src/connectors/macos/mail.js +7 -3
- package/runtime/dist/src/connectors/macos/reader.js +3 -1
- package/runtime/dist/src/conversation-voice-provider.js +5 -2
- package/runtime/dist/src/core/causal-runtime.js +38 -3
- package/runtime/dist/src/core/context-view.js +7 -0
- package/runtime/dist/src/core/guards.js +32 -0
- package/runtime/dist/src/core/runtime.js +3 -0
- package/runtime/dist/src/core/schedule-tools.js +2 -2
- package/runtime/dist/src/core/source-processing-instructions.js +2 -2
- package/runtime/dist/src/core/source-processing-tools.js +3 -1
- package/runtime/dist/src/core/tool-schema.js +42 -7
- package/runtime/dist/src/desktop/desktop-camera.js +3 -5
- package/runtime/dist/src/desktop/desktop-control.js +41 -8
- package/runtime/dist/src/desktop/desktop-session.js +90 -19
- package/runtime/dist/src/desktop/desktop-wire.js +5 -7
- package/runtime/dist/src/desktop/startup-error.js +18 -16
- package/runtime/dist/src/desktop/workbench-acceptance.js +52 -14
- package/runtime/dist/src/desktop-entry.js +6 -2
- package/runtime/dist/src/desktop.js +5 -1
- package/runtime/dist/src/device/attempt.js +65 -0
- package/runtime/dist/src/device/authority.js +159 -0
- package/runtime/dist/src/device/gateway.js +87 -0
- package/runtime/dist/src/device/ledger.js +91 -0
- package/runtime/dist/src/device/ownership.js +92 -0
- package/runtime/dist/src/device/port.js +2 -0
- package/runtime/dist/src/device/schedule-ownership.js +103 -0
- package/runtime/dist/src/executors/acp/transport.js +2 -0
- package/runtime/dist/src/executors/browser.js +4 -3
- package/runtime/dist/src/executors/codex/adapter-project.js +58 -12
- package/runtime/dist/src/executors/codex/app-server-schema.js +12 -21
- package/runtime/dist/src/executors/codex/app-server-transport.js +32 -18
- package/runtime/dist/src/executors/codex/common.js +1 -1
- package/runtime/dist/src/executors/codex/contract.js +12 -16
- package/runtime/dist/src/executors/codex/credential-snapshot.js +1 -9
- package/runtime/dist/src/executors/codex/factory.js +54 -32
- package/runtime/dist/src/executors/codex/host-config.js +69 -20
- package/runtime/dist/src/executors/codex/launch-profile.js +3 -2
- package/runtime/dist/src/executors/codex/local-provider-credential.js +39 -0
- package/runtime/dist/src/executors/codex/process-owner.js +4 -6
- package/runtime/dist/src/executors/codex/production-host.js +33 -34
- package/runtime/dist/src/executors/codex/protocol.js +9 -14
- package/runtime/dist/src/executors/codex/session-title.js +6 -8
- package/runtime/dist/src/executors/codex/spawn-env.js +27 -6
- package/runtime/dist/src/executors/codex/turn-projection.js +12 -17
- package/runtime/dist/src/executors/codex/windows-guardian.js +4 -6
- package/runtime/dist/src/executors/coding/intake.js +12 -7
- package/runtime/dist/src/executors/computer-backend.js +18 -10
- package/runtime/dist/src/executors/computer-config.js +32 -0
- package/runtime/dist/src/executors/computer-device.js +68 -16
- package/runtime/dist/src/executors/computer-worker.js +18 -6
- package/runtime/dist/src/executors/computer.js +29 -56
- package/runtime/dist/src/executors/device-lock.js +14 -5
- package/runtime/dist/src/executors/gui-execution.js +2 -0
- package/runtime/dist/src/executors/index.js +0 -1
- package/runtime/dist/src/executors/mobile.js +9 -8
- package/runtime/dist/src/executors/native-process.js +4 -0
- package/runtime/dist/src/executors/search.js +3 -5
- package/runtime/dist/src/executors/task-resources.js +21 -0
- package/runtime/dist/src/executors/watcher.js +2 -4
- package/runtime/dist/src/experience/host.js +179 -0
- package/runtime/dist/src/index.js +2 -0
- package/runtime/dist/src/knowledge/assembly.js +3 -4
- package/runtime/dist/src/knowledge/embeddings.js +50 -34
- package/runtime/dist/src/knowledge/service.js +1 -0
- package/runtime/dist/src/knowledge/store-client.js +1 -6
- package/runtime/dist/src/knowledge/store-worker.js +1 -3
- package/runtime/dist/src/mem0/resource.js +25 -0
- package/runtime/dist/src/mem0/store-worker.js +234 -21
- package/runtime/dist/src/memory/consumer.js +31 -0
- package/runtime/dist/src/memory/engine-worker.js +210 -0
- package/runtime/dist/src/memory/entry.js +8 -1
- package/runtime/dist/src/memory/explicit-memory.js +20 -0
- package/runtime/dist/src/memory/factory.js +30 -15
- package/runtime/dist/src/memory/grounded-voicemem.js +10 -0
- package/runtime/dist/src/memory/ledger-recall-engine.js +86 -0
- package/runtime/dist/src/memory/prerecall-port.js +27 -0
- package/runtime/dist/src/memory/prerecall.js +1 -1
- package/runtime/dist/src/memory/production-engine.js +151 -0
- package/runtime/dist/src/memory/provenance.js +1 -0
- package/runtime/dist/src/memory/remote-personal-memory.js +3 -1
- package/runtime/dist/src/memory/retrieval.js +107 -22
- package/runtime/dist/src/memory/sensitivity.js +6 -2
- package/runtime/dist/src/memory/source-retrieval.js +11 -0
- package/runtime/dist/src/memory/tool-capabilities.js +46 -0
- package/runtime/dist/src/memory/voicemem-sdk/LICENSE +202 -0
- package/runtime/dist/src/memory/voicemem-sdk/NOTICE.md +97 -0
- package/runtime/dist/src/memory/voicemem-sdk/PATCH-NOTICE.md +23 -0
- package/runtime/dist/src/memory/voicemem-sdk/archive.js +12 -0
- package/runtime/dist/src/memory/voicemem-sdk/audio.js +111 -0
- package/runtime/dist/src/memory/voicemem-sdk/barge-in.js +59 -0
- package/runtime/dist/src/memory/voicemem-sdk/checkpoint.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/cleanup.js +139 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-asr.js +254 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-tts.js +247 -0
- package/runtime/dist/src/memory/voicemem-sdk/evaluation.js +330 -0
- package/runtime/dist/src/memory/voicemem-sdk/extraction.js +220 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune-data.js +115 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune.js +170 -0
- package/runtime/dist/src/memory/voicemem-sdk/grounded-reply-preferences.js +81 -0
- package/runtime/dist/src/memory/voicemem-sdk/index.js +22 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-embedding.js +164 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-runtime.js +53 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-speaker.js +240 -0
- package/runtime/dist/src/memory/voicemem-sdk/memory.js +767 -0
- package/runtime/dist/src/memory/voicemem-sdk/model-json.js +14 -0
- package/runtime/dist/src/memory/voicemem-sdk/personamem.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/addenda.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/additive-extraction.js +478 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/index.js +32 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/update-memory.js +152 -0
- package/runtime/dist/src/memory/voicemem-sdk/providers.js +325 -0
- package/runtime/dist/src/memory/voicemem-sdk/ranking.js +65 -0
- package/runtime/dist/src/memory/voicemem-sdk/reaction.js +33 -0
- package/runtime/dist/src/memory/voicemem-sdk/realtime.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/reply.js +68 -0
- package/runtime/dist/src/memory/voicemem-sdk/routing.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/slots.js +61 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-bindings.js +120 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-profiles.js +327 -0
- package/runtime/dist/src/memory/voicemem-sdk/store.js +577 -0
- package/runtime/dist/src/memory/voicemem-sdk/stream.js +317 -0
- package/runtime/dist/src/memory/voicemem-sdk/subgraph.js +113 -0
- package/runtime/dist/src/memory/voicemem-sdk/summaries.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/time.js +157 -0
- package/runtime/dist/src/memory/voicemem-sdk/types.js +2 -0
- package/runtime/dist/src/memory-ledger/store-client.js +235 -37
- package/runtime/dist/src/memory-ledger/store-worker.js +8 -5
- package/runtime/dist/src/memory-ledger/store.js +91 -1
- package/runtime/dist/src/memory-substrate/consolidation.js +23 -7
- package/runtime/dist/src/memory-substrate/diary.js +27 -0
- package/runtime/dist/src/memory-substrate/engine-outbox.js +107 -0
- package/runtime/dist/src/memory-substrate/explicit-memory.js +112 -0
- package/runtime/dist/src/memory-substrate/fact-fidelity.js +68 -0
- package/runtime/dist/src/memory-substrate/feishu-consent.js +41 -0
- package/runtime/dist/src/memory-substrate/file-authority.js +29 -6
- package/runtime/dist/src/memory-substrate/life-operations.js +35 -9
- package/runtime/dist/src/memory-substrate/markdown-repository.js +271 -65
- package/runtime/dist/src/memory-substrate/memory-documents.js +96 -0
- package/runtime/dist/src/memory-substrate/migration.js +2 -0
- package/runtime/dist/src/memory-substrate/purge.js +12 -2
- package/runtime/dist/src/memory-substrate/resource.js +514 -129
- package/runtime/dist/src/memory-substrate/retrieval.js +8 -5
- package/runtime/dist/src/memory-substrate/source-operations.js +9 -1
- package/runtime/dist/src/memory-substrate/source-processing.js +436 -40
- package/runtime/dist/src/memory-substrate/source-retrieval.js +28 -0
- package/runtime/dist/src/memory-substrate/source-state.js +8 -0
- package/runtime/dist/src/memory-substrate/space-source-input.js +90 -0
- package/runtime/dist/src/memory-substrate/store.js +125 -23
- package/runtime/dist/src/model/goal-checkin-writer.js +72 -0
- package/runtime/dist/src/model/goal-writer.js +80 -0
- package/runtime/dist/src/model/jev-client.js +24 -13
- package/runtime/dist/src/model/model-adapters.js +2 -3
- package/runtime/dist/src/model/model-catalog.js +80 -0
- package/runtime/dist/src/model/model-gateway.js +47 -18
- package/runtime/dist/src/model/model-purpose.js +3 -4
- package/runtime/dist/src/model/personal-writer.js +536 -44
- package/runtime/dist/src/model/proactivity.js +50 -6
- package/runtime/dist/src/model/responses-model-gateway.js +59 -0
- package/runtime/dist/src/model/task-verifier.js +3 -3
- package/runtime/dist/src/model/timeline-anchors.js +77 -0
- package/runtime/dist/src/model/timeline-perspective.js +13 -0
- package/runtime/dist/src/model/timeline-selection.js +182 -0
- package/runtime/dist/src/model/understanding-writer.js +27 -0
- package/runtime/dist/src/model/vision-capability.js +3 -1
- package/runtime/dist/src/model/workbench-writer.js +96 -0
- package/runtime/dist/src/news/feeds.js +6 -10
- package/runtime/dist/src/news/interests.js +23 -0
- package/runtime/dist/src/news/service.js +87 -31
- package/runtime/dist/src/news/sources.json +116 -0
- package/runtime/dist/src/notifications/adapters/space-relay.js +4 -0
- package/runtime/dist/src/notifications/content.js +41 -0
- package/runtime/dist/src/notifications/contracts.js +4 -2
- package/runtime/dist/src/notifications/feed.js +6 -2
- package/runtime/dist/src/notifications/service.js +27 -14
- package/runtime/dist/src/notifications/store.js +3 -1
- package/runtime/dist/src/personal-agent/app-context.js +39 -4
- package/runtime/dist/src/personal-agent/chat-failure.js +37 -0
- package/runtime/dist/src/personal-agent/computer-use/contract.js +42 -0
- package/runtime/dist/src/personal-agent/computer-use/session.js +280 -0
- package/runtime/dist/src/personal-agent/computer-use/skill.js +18 -0
- package/runtime/dist/src/personal-agent/computer-use/tools.js +15 -0
- package/runtime/dist/src/personal-agent/context-candidates.js +9 -13
- package/runtime/dist/src/personal-agent/context-dependencies.js +28 -0
- package/runtime/dist/src/personal-agent/contracts.js +24 -4
- package/runtime/dist/src/personal-agent/conversation-runtime.js +440 -42
- package/runtime/dist/src/personal-agent/conversation-tool-bridge.js +97 -0
- package/runtime/dist/src/personal-agent/conversation-tool-policy.js +22 -0
- package/runtime/dist/src/personal-agent/conversations.js +71 -15
- package/runtime/dist/src/personal-agent/daily-brief.js +5 -0
- package/runtime/dist/src/personal-agent/daily-workbench.js +558 -0
- package/runtime/dist/src/personal-agent/discovery-window.js +36 -0
- package/runtime/dist/src/personal-agent/goal-checkin.js +53 -0
- package/runtime/dist/src/personal-agent/host.js +2379 -223
- package/runtime/dist/src/personal-agent/identity-context.js +33 -0
- package/runtime/dist/src/personal-agent/life.js +129 -11
- package/runtime/dist/src/personal-agent/local-shell.js +181 -0
- package/runtime/dist/src/personal-agent/local-tools.js +234 -0
- package/runtime/dist/src/personal-agent/preferred-name-sync.js +35 -0
- package/runtime/dist/src/personal-agent/profile-warmup.js +100 -39
- package/runtime/dist/src/personal-agent/project-digests.js +7 -3
- package/runtime/dist/src/personal-agent/project-history.js +36 -0
- package/runtime/dist/src/personal-agent/reading-copies.js +183 -0
- package/runtime/dist/src/personal-agent/scheduled-tasks.js +50 -13
- package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +26 -10
- package/runtime/dist/src/personal-agent/source-processing-agent.js +239 -17
- package/runtime/dist/src/personal-agent/sources.js +9 -1
- package/runtime/dist/src/personal-agent/store.js +124 -14
- package/runtime/dist/src/personal-agent/task-loop.js +3 -0
- package/runtime/dist/src/personal-agent/tasks.js +16 -4
- package/runtime/dist/src/personal-agent/timeline-brief.js +462 -0
- package/runtime/dist/src/personal-agent/timeline-cache.js +191 -0
- package/runtime/dist/src/personal-agent/timeline-cluster.js +30 -0
- package/runtime/dist/src/personal-agent/timeline-inputs.js +47 -0
- package/runtime/dist/src/personal-agent/timeline-time.js +60 -0
- package/runtime/dist/src/personal-agent/understanding-products.js +49 -0
- package/runtime/dist/src/personal-agent/understanding.js +7 -22
- package/runtime/dist/src/personal-agent/workbench-context.js +17 -21
- package/runtime/dist/src/personal-agent/workbench-copy.js +124 -0
- package/runtime/dist/src/personal-agent/workbench-evidence.js +77 -0
- package/runtime/dist/src/personal-agent/workbench-instructions.js +21 -0
- package/runtime/dist/src/personal-agent/workbench-runtime.js +1006 -0
- package/runtime/dist/src/personal-agent/workbench-shell-class.js +304 -0
- package/runtime/dist/src/personal-agent/workbench-store.js +292 -0
- package/runtime/dist/src/personal-agent/workbench-temporal.js +66 -0
- package/runtime/dist/src/projects/project-native-resource.js +10 -8
- package/runtime/dist/src/projects/project-store.js +36 -4
- package/runtime/dist/src/realtime/bridge.js +77 -8
- package/runtime/dist/src/realtime/capabilities.js +19 -0
- package/runtime/dist/src/realtime/cascaded/adapter.js +180 -40
- package/runtime/dist/src/realtime/cascaded/ark-llm.js +150 -24
- package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +243 -83
- package/runtime/dist/src/realtime/cascaded/llm-stream-limits.js +18 -0
- package/runtime/dist/src/realtime/cascaded/llm.js +96 -0
- package/runtime/dist/src/realtime/cascaded/openai-compatible-speech.js +251 -0
- package/runtime/dist/src/realtime/cascaded/provider.js +8 -0
- package/runtime/dist/src/realtime/evidence.js +1 -1
- package/runtime/dist/src/realtime/frontend-instructions.js +76 -55
- package/runtime/dist/src/realtime/gemini.js +14 -3
- package/runtime/dist/src/realtime/host-delivery.js +37 -4
- package/runtime/dist/src/realtime/protocol.js +18 -3
- package/runtime/dist/src/realtime/provider-projection.js +4 -1
- package/runtime/dist/src/realtime/provider-session.js +73 -16
- package/runtime/dist/src/realtime/qwen-transport.js +35 -4
- package/runtime/dist/src/realtime/qwen.js +144 -9
- package/runtime/dist/src/realtime/service-state.js +0 -1
- package/runtime/dist/src/realtime/service.js +93 -7
- package/runtime/dist/src/realtime/session.js +39 -32
- package/runtime/dist/src/realtime/sglang-native.js +214 -0
- package/runtime/dist/src/realtime/system-prompts.en.js +14 -2
- package/runtime/dist/src/realtime/telemetry.js +6 -3
- package/runtime/dist/src/realtime/tool-continuations.js +84 -7
- package/runtime/dist/src/realtime/transport.js +17 -0
- package/runtime/dist/src/realtime/usage.js +33 -17
- package/runtime/dist/src/realtime/volcengine/ark.js +40 -15
- package/runtime/dist/src/realtime/volcengine/asr.js +2 -1
- package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +1 -7
- package/runtime/dist/src/realtime/volcengine/tts.js +2 -1
- package/runtime/dist/src/server/aoq-chat-server.js +1 -1
- package/runtime/dist/src/server/client-server.js +21 -0
- package/runtime/dist/src/server-entry.js +3 -0
- package/runtime/dist/src/space-host/admin-socket.js +115 -0
- package/runtime/dist/src/space-host/audio-owner.js +44 -0
- package/runtime/dist/src/space-host/cli.js +195 -0
- package/runtime/dist/src/space-host/config.js +247 -0
- package/runtime/dist/src/space-host/context-input.js +12 -0
- package/runtime/dist/src/space-host/contracts.js +10 -0
- package/runtime/dist/src/space-host/host-admin.js +114 -0
- package/runtime/dist/src/space-host/key-delivery.js +28 -0
- package/runtime/dist/src/space-host/mobile-tools.js +9 -0
- package/runtime/dist/src/space-host/model-settings.js +213 -0
- package/runtime/dist/src/space-host/projection.js +37 -0
- package/runtime/dist/src/space-host/push.js +137 -0
- package/runtime/dist/src/space-host/relay-transport.js +55 -0
- package/runtime/dist/src/space-host/service.js +841 -0
- package/runtime/dist/src/space-host/voice-crypto.js +240 -0
- package/runtime/dist/src/space-host/voice.js +600 -0
- package/runtime/dist/src/space-host/windows-secret-key.js +82 -0
- package/runtime/dist/src/storage/private-database.js +7 -10
- package/runtime/dist/src/text/unicode-normalize.js +5 -1
- package/runtime/dist/src/understanding/candidates.js +8 -10
- package/runtime/dist/src/understanding/fixture.js +1 -1
- package/runtime/dist/src/understanding/pipeline.js +4 -4
- package/runtime/dist/src/usage/context.js +23 -0
- package/runtime/dist/src/usage/index.js +4 -0
- package/runtime/dist/src/usage/ledger-worker.js +90 -0
- package/runtime/dist/src/usage/ledger.js +74 -0
- package/runtime/dist/src/usage/model-call.js +63 -0
- package/runtime/dist/src/usage/pricing.js +68 -0
- package/runtime/dist/src/usage/summary.js +69 -0
- package/runtime/dist/src/voicemem/store-client.js +104 -21
- package/runtime/dist/src/voicemem/store-worker.js +5 -8
- package/runtime/dist/src/voicemem/versioned-memory.js +1 -1
- package/src/command.mjs +8 -1
- package/runtime/dist/src/executors/autoglm.js +0 -376
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { environmentHome, legacyDataRootActive, mapLegacyDataPath, rebaseDataRootDefault } from './data-root.js';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
1
4
|
import { parseCapabilityRegistry } from './capability-registry.js';
|
|
2
5
|
import { CODING_BACKEND_IDS } from './coding-backends.js';
|
|
6
|
+
import { CASCADED_ASR_PROVIDERS, CASCADED_LLM_PROVIDERS, CASCADED_TTS_PROVIDERS, INTEGRATED_PROVIDERS, requiredVoiceCredentials } from './voice-credentials.js';
|
|
7
|
+
import { isIP } from 'node:net';
|
|
8
|
+
import { DASHSCOPE_COMPATIBLE_BASE_URL, DEEPSEEK_BASE_URL, GEMINI_BASE_URL, MODEL_ROUTE_PROVIDER_METADATA, OPENAI_BASE_URL, STEPFUN_COMPATIBLE_BASE_URL, ModelRoutesParseError, modelRoutesSchema, modelRouteProviders, parseModelRoutes, } from './model-routes.js';
|
|
3
9
|
import { z } from 'zod';
|
|
4
10
|
import { stripLikePython } from '../text/python-text.js';
|
|
5
11
|
import { supportsVision } from '../model/vision-capability.js';
|
|
12
|
+
export { DASHSCOPE_COMPATIBLE_BASE_URL, DEEPSEEK_BASE_URL, GEMINI_BASE_URL, MODEL_ROUTE_LANE_IDS, MODEL_ROUTE_PROVIDER_METADATA, OPENAI_BASE_URL, STEPFUN_COMPATIBLE_BASE_URL, parseModelRoutes, } from './model-routes.js';
|
|
6
13
|
export const proactivityPresetSchema = z.enum(['conservative', 'balanced', 'eager']);
|
|
7
14
|
const pipelineModeSchema = z.enum(['integrated', 'cascaded']);
|
|
8
15
|
const promptLanguageSchema = z.enum(['zh-CN', 'en']);
|
|
9
|
-
const integratedProviderNameSchema = z.enum(
|
|
16
|
+
const integratedProviderNameSchema = z.enum(INTEGRATED_PROVIDERS);
|
|
10
17
|
const cascadedEndpointingProviderNameSchema = z.enum(['auto']);
|
|
11
|
-
const cascadedAsrProviderNameSchema = z.enum(
|
|
12
|
-
const cascadedLlmProviderNameSchema = z.enum(
|
|
13
|
-
const cascadedTtsProviderNameSchema = z.enum(
|
|
18
|
+
const cascadedAsrProviderNameSchema = z.enum(CASCADED_ASR_PROVIDERS);
|
|
19
|
+
const cascadedLlmProviderNameSchema = z.enum(CASCADED_LLM_PROVIDERS);
|
|
20
|
+
const cascadedTtsProviderNameSchema = z.enum(CASCADED_TTS_PROVIDERS);
|
|
14
21
|
const qwenGuardHistoryRecoverySchema = z.enum(['none', 'packed']);
|
|
15
22
|
const qwenGuardHistoryPairsSchema = z.union([z.literal(1), z.literal(2), z.literal(4)]);
|
|
16
23
|
/** Validity of a name is decided by assembly (`resolveExecutors`), which knows the registered adapters. */
|
|
@@ -23,30 +30,88 @@ const embeddingProviderSchema = z.enum(['dashscope']);
|
|
|
23
30
|
const memoryConnectionSchema = z.enum(['disabled', 'local', 'remote']);
|
|
24
31
|
const searchProviderSchema = z.enum(['mcp', 'tavily']);
|
|
25
32
|
const volcFloatSchema = z.custom(value => typeof value === 'number');
|
|
26
|
-
export const DASHSCOPE_COMPATIBLE_BASE_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1';
|
|
27
|
-
export const STEPFUN_COMPATIBLE_BASE_URL = 'https://api.stepfun.com/v1';
|
|
28
|
-
export const OPENAI_BASE_URL = 'https://api.openai.com/v1';
|
|
29
|
-
export const GEMINI_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta/openai';
|
|
30
33
|
const STEPFUN_SUPPORT_MODEL = 'step-3.7-flash';
|
|
34
|
+
/** One default for the schema, the environment parser and the documentation. */
|
|
35
|
+
export const DEFAULT_CASCADED_LLM_PROVIDER = 'deepseek';
|
|
36
|
+
/**
|
|
37
|
+
* Auxiliary models are a property of the provider, not of the schema: the support gateway talks to
|
|
38
|
+
* the selected provider's endpoint, so the model name must come from the same profile.
|
|
39
|
+
*/
|
|
40
|
+
const AUXILIARY_MODEL_PROFILES = Object.freeze({
|
|
41
|
+
qwen: Object.freeze({ support: 'qwen-flash', fast: 'qwen-flash', compressor: 'qwen-flash', watch: 'qwen3-vl-plus' }),
|
|
42
|
+
stepfun: Object.freeze({ support: STEPFUN_SUPPORT_MODEL, fast: STEPFUN_SUPPORT_MODEL, compressor: STEPFUN_SUPPORT_MODEL, watch: STEPFUN_SUPPORT_MODEL }),
|
|
43
|
+
openai: Object.freeze({ support: 'gpt-6-luna', fast: 'gpt-6-luna', compressor: 'gpt-6-luna', watch: 'gpt-6-luna' }),
|
|
44
|
+
gemini: Object.freeze({ support: 'gemini-3.5-flash-lite', fast: 'gemini-3.5-flash-lite', compressor: 'gemini-3.5-flash-lite', watch: 'gemini-3.5-flash-lite' }),
|
|
45
|
+
deepseek: Object.freeze({ support: 'deepseek-flash', fast: 'deepseek-flash', compressor: 'deepseek-flash', watch: 'deepseek-flash' }),
|
|
46
|
+
});
|
|
47
|
+
/** The model a cascaded provider uses when CASCADE_LLM_MODEL is not set. */
|
|
48
|
+
export function defaultCascadedLlmModel(provider) {
|
|
49
|
+
return provider === 'qwen' ? 'qwen-plus'
|
|
50
|
+
: provider === 'openai' ? 'gpt-6-luna'
|
|
51
|
+
: provider === 'gemini' ? 'gemini-3.5-flash-lite'
|
|
52
|
+
: provider === 'deepseek' ? 'deepseek-flash' : 'doubao-seed-2-0-pro-260215';
|
|
53
|
+
}
|
|
54
|
+
/** Compressor defaults that mean "follow the selected text model" in a cascaded assembly. */
|
|
55
|
+
export function isProviderDefaultCompressor(model) {
|
|
56
|
+
return model === 'deepseek-flash' || model === 'qwen-flash' || model === 'step-3.7-flash'
|
|
57
|
+
|| model === 'gpt-6-luna' || model === 'gemini-3.5-flash-lite' || model === 'doubao-seed-2-0-pro-260215';
|
|
58
|
+
}
|
|
59
|
+
function auxiliaryModelProfile(provider, cascadeModel) {
|
|
60
|
+
if (provider === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
if (provider === 'self-hosted' || provider === 'openai-compatible') {
|
|
63
|
+
return cascadeModel === null ? undefined : {
|
|
64
|
+
support: cascadeModel, fast: cascadeModel, compressor: cascadeModel, watch: cascadeModel,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (provider === 'ark') {
|
|
68
|
+
// The schema default pairs the Ark endpoint; an explicit SUPPORT_MODEL still wins.
|
|
69
|
+
const model = 'doubao-seed-2-0-pro-260215';
|
|
70
|
+
return { support: model, fast: model, compressor: model, watch: model };
|
|
71
|
+
}
|
|
72
|
+
if (provider === 'minicpm-o' || provider === 'personaplex')
|
|
73
|
+
return undefined;
|
|
74
|
+
return AUXILIARY_MODEL_PROFILES[provider];
|
|
75
|
+
}
|
|
31
76
|
export const settingsSchema = z.object({
|
|
32
|
-
|
|
33
|
-
|
|
77
|
+
/** Per-provider model endpoints: one provider never borrows another provider's URL or key. */
|
|
78
|
+
dashscope_model_base_url: z.url().default(DASHSCOPE_COMPATIBLE_BASE_URL),
|
|
79
|
+
deepseek_model_base_url: z.url().default(DEEPSEEK_BASE_URL),
|
|
80
|
+
openai_model_base_url: z.url().default(OPENAI_BASE_URL),
|
|
81
|
+
gemini_model_base_url: z.url().default(GEMINI_BASE_URL),
|
|
82
|
+
stepfun_model_base_url: z.url().default(STEPFUN_COMPATIBLE_BASE_URL),
|
|
34
83
|
openrouter_api_key: z.string().nullable().default(null),
|
|
35
84
|
tavily_api_key: z.string().nullable().default(null),
|
|
36
|
-
fast_model: z.string().default('
|
|
85
|
+
fast_model: z.string().default('deepseek-flash'),
|
|
37
86
|
watch_model: z.string().nullable().default(null),
|
|
38
|
-
conversation_vision_enabled: z.boolean().default(false),
|
|
39
87
|
monitor_camera_device_id: z.string().max(256).refine(value => !/[\x00-\x1f]/u.test(value)).default(''),
|
|
40
|
-
support_model: z.string().default('
|
|
41
|
-
compressor_model: z.string().default('
|
|
88
|
+
support_model: z.string().default('deepseek-flash'),
|
|
89
|
+
compressor_model: z.string().default('deepseek-flash'),
|
|
90
|
+
/** Host-private per-lane routing; an absent lane keeps the historical default. */
|
|
91
|
+
model_routes: modelRoutesSchema,
|
|
42
92
|
language: promptLanguageSchema.default('zh-CN'),
|
|
43
93
|
news_language: promptLanguageSchema.default('en'),
|
|
44
94
|
pipeline_mode: pipelineModeSchema.default('integrated'),
|
|
45
95
|
integrated_provider: integratedProviderNameSchema.default('qwen'),
|
|
96
|
+
native_realtime_url: z.string().default('ws://127.0.0.1:8000/v1/realtime'),
|
|
97
|
+
native_realtime_api_key: z.string().nullable().default(null),
|
|
98
|
+
native_realtime_voice: z.string().default(''),
|
|
46
99
|
cascade_endpointing_provider: cascadedEndpointingProviderNameSchema.default('auto'),
|
|
47
100
|
cascade_asr_provider: cascadedAsrProviderNameSchema.default('volcengine'),
|
|
48
|
-
cascade_llm_provider: cascadedLlmProviderNameSchema.default(
|
|
101
|
+
cascade_llm_provider: cascadedLlmProviderNameSchema.default(DEFAULT_CASCADED_LLM_PROVIDER),
|
|
49
102
|
cascade_llm_model: z.string().nullable().default(null),
|
|
103
|
+
openai_compatible_base_url: z.string().default(OPENAI_BASE_URL),
|
|
104
|
+
openai_compatible_api_key: z.string().nullable().default(null),
|
|
105
|
+
openai_compatible_protocol: z.enum(['chat-completions', 'responses']).default('chat-completions'),
|
|
106
|
+
compatible_asr_base_url: z.string().default(OPENAI_BASE_URL),
|
|
107
|
+
compatible_asr_api_key: z.string().nullable().default(null),
|
|
108
|
+
compatible_asr_model: z.string().default('whisper-1'),
|
|
109
|
+
compatible_tts_base_url: z.string().default(OPENAI_BASE_URL),
|
|
110
|
+
compatible_tts_api_key: z.string().nullable().default(null),
|
|
111
|
+
compatible_tts_model: z.string().default('tts-1'),
|
|
112
|
+
compatible_tts_voice: z.string().default('alloy'),
|
|
113
|
+
compatible_asr_omit_response_format: z.boolean().default(false),
|
|
114
|
+
compatible_tts_send_sample_rate: z.boolean().default(false),
|
|
50
115
|
self_hosted_asr_url: z.string().default(''),
|
|
51
116
|
self_hosted_llm_base_url: z.string().default(''),
|
|
52
117
|
self_hosted_tts_url: z.string().default(''),
|
|
@@ -55,6 +120,7 @@ export const settingsSchema = z.object({
|
|
|
55
120
|
self_hosted_tts_api_key: z.string().nullable().default(null),
|
|
56
121
|
cascade_tts_provider: cascadedTtsProviderNameSchema.default('volcengine'),
|
|
57
122
|
camera_module_enabled: z.boolean().default(true),
|
|
123
|
+
profile_participant_messages: z.boolean().default(false),
|
|
58
124
|
qwen_realtime_url: z.string().default('wss://dashscope.aliyuncs.com/api-ws/v1/realtime'),
|
|
59
125
|
qwen_realtime_model: z.string().default('qwen-audio-3.0-realtime-plus'),
|
|
60
126
|
qwen_realtime_voice: z.string().default('longanqian'),
|
|
@@ -76,7 +142,6 @@ export const settingsSchema = z.object({
|
|
|
76
142
|
dashscope_api_key: z.string().nullable().default(null),
|
|
77
143
|
ark_api_key: z.string().nullable().default(null),
|
|
78
144
|
deepseek_api_key: z.string().nullable().default(null),
|
|
79
|
-
doubao_asr_api_key: z.string().nullable().default(null),
|
|
80
145
|
doubao_bigmodel_api_key: z.string().nullable().default(null),
|
|
81
146
|
volcengine_ark_base_url: z.string().default('https://ark.cn-beijing.volces.com/api/v3'),
|
|
82
147
|
volcengine_ark_model: z.string().default('doubao-seed-2-0-pro-260215'),
|
|
@@ -110,26 +175,29 @@ export const settingsSchema = z.object({
|
|
|
110
175
|
codex_prefix_args: z.array(z.string().min(1).max(32_768)).max(1).default([]),
|
|
111
176
|
codex_api_key: z.string().nullable().default(null),
|
|
112
177
|
codex_prewarm: z.boolean().default(true),
|
|
113
|
-
codex_managed_root: z.string().default('~/.nova-
|
|
114
|
-
codex_project_state_root: z.string().default('~/.nova-
|
|
178
|
+
codex_managed_root: z.string().default('~/.nova-personal-agent/workspaces'),
|
|
179
|
+
codex_project_state_root: z.string().default('~/.nova-personal-agent'),
|
|
115
180
|
coding_progress_narration: z.enum(['smart', 'continuous']).default('smart'),
|
|
116
181
|
proactivity_preset: proactivityPresetSchema.default('balanced'),
|
|
117
182
|
codex_working_interval: z.number().finite().min(5).max(600).default(30),
|
|
118
183
|
suggestion_cooldown: z.number().finite().nonnegative().nullable().default(null),
|
|
119
184
|
fresh_window: z.number().finite().nonnegative().nullable().default(null),
|
|
120
185
|
codex_approval_mode: executorApprovalModeSchema.default('ask'),
|
|
186
|
+
local_tool_approval: z.enum(['ask', 'never']).default('ask'),
|
|
121
187
|
clarification_depth: clarificationDepthSchema.default('balanced'),
|
|
122
188
|
plan_readback: planReadbackSchema.default('summary'),
|
|
189
|
+
build_reasoning: z.boolean().default(true),
|
|
123
190
|
generate_plan: z.boolean().default(true),
|
|
124
|
-
planner_model: z.string().default(''),
|
|
125
191
|
progress_bubbles: progressBubblesSchema.default('milestones'),
|
|
126
192
|
search_provider: searchProviderSchema.default('tavily'),
|
|
127
193
|
search_mcp_url: z.string().default(''),
|
|
128
194
|
search_mcp_tool: z.string().default('web_search'),
|
|
129
|
-
knowledge_path: z.string().default('~/.nova-
|
|
195
|
+
knowledge_path: z.string().default('~/.nova-personal-agent/knowledge.sqlite'),
|
|
130
196
|
embedding_provider: embeddingProviderSchema.default('dashscope'),
|
|
131
197
|
embedding_model: z.string().default('text-embedding-v4'),
|
|
132
|
-
|
|
198
|
+
embedding_base_url: z.url().default(DASHSCOPE_COMPATIBLE_BASE_URL),
|
|
199
|
+
embedding_api_key: z.string().nullable().default(null),
|
|
200
|
+
blackboard_path: z.string().min(1).default('~/.nova-personal-agent/blackboard.sqlite'),
|
|
133
201
|
blackboard_owner_id: z.string().min(1).max(512).default('local'),
|
|
134
202
|
memory_prerecall_enabled: z.boolean().default(false),
|
|
135
203
|
memory_consolidation_enabled: z.boolean().default(true),
|
|
@@ -143,23 +211,28 @@ export const settingsSchema = z.object({
|
|
|
143
211
|
} }, 'invalid timezone').default('UTC'),
|
|
144
212
|
memory_connection: memoryConnectionSchema.default('local'),
|
|
145
213
|
memory_provider: z.enum(['voicemem', 'mem0']).nullable().default(null),
|
|
214
|
+
memory_recall_engine: z.enum(['ledger', 'voicemem', 'mem0']).nullable().default(null),
|
|
215
|
+
memory_extractors: z.array(z.enum(['ledger', 'voicemem'])).min(1).nullable().default(null),
|
|
146
216
|
memory_url: z.string().default(''),
|
|
147
217
|
memory_token: z.string().nullable().default(null),
|
|
148
|
-
memory_path: z.string().min(1).default('~/.nova-
|
|
218
|
+
memory_path: z.string().min(1).default('~/.nova-personal-agent/memory.sqlite'),
|
|
149
219
|
memory_user_id: z.string().min(1).default('local'),
|
|
150
220
|
// Existing v0.3 ledger location; the retired workspace graph is not enabled.
|
|
151
|
-
workspace_graph_path: z.string().min(1).default('~/.nova-
|
|
221
|
+
workspace_graph_path: z.string().min(1).default('~/.nova-personal-agent/workspace-graph.sqlite'),
|
|
152
222
|
}).strict();
|
|
153
223
|
const proactivityPresets = {
|
|
154
224
|
conservative: { cooldown: 120, fresh_window: 20 },
|
|
155
225
|
balanced: { cooldown: 60, fresh_window: 30 },
|
|
156
226
|
eager: { cooldown: 30, fresh_window: 45 },
|
|
157
227
|
};
|
|
228
|
+
const memoryConfigurationVariables = ['MEMORY_PROVIDER', 'MEMORY_RECALL_ENGINE', 'MEMORY_EXTRACTORS', 'MEMORY_CONNECTION', 'MEMORY_URL', 'MEMORY_TOKEN'];
|
|
158
229
|
export class ConfigurationError extends Error {
|
|
159
230
|
code;
|
|
160
|
-
|
|
231
|
+
startupConfiguration;
|
|
232
|
+
constructor(message, code = 'invalid_configuration', startupConfiguration) {
|
|
161
233
|
super(message);
|
|
162
234
|
this.code = code;
|
|
235
|
+
this.startupConfiguration = startupConfiguration;
|
|
163
236
|
this.name = 'ConfigurationError';
|
|
164
237
|
}
|
|
165
238
|
}
|
|
@@ -176,22 +249,69 @@ export class BlockingConfigurationError extends ConfigurationError {
|
|
|
176
249
|
}
|
|
177
250
|
/** Environment names that were renamed without an alias; the old name is ignored, so its presence deserves a startup warning. */
|
|
178
251
|
export const RENAMED_ENVIRONMENT = { SURROGATE_MODEL: 'SUPPORT_MODEL' };
|
|
252
|
+
/**
|
|
253
|
+
* Generic cross-provider model overrides are gone: a model endpoint and credential always belong
|
|
254
|
+
* to one provider. Refuse the retired names instead of quietly sending one provider's request to
|
|
255
|
+
* another provider's URL or key.
|
|
256
|
+
*/
|
|
257
|
+
const REMOVED_AUTOGLM_VARIABLES = [
|
|
258
|
+
'AUTOGLM_PYTHON', 'AUTOGLM_SOURCE_PATH', 'AUTOGLM_DEVICE_ID', 'AUTOGLM_DEVICE_TYPE', 'AUTOGLM_WDA_URL',
|
|
259
|
+
'AUTOGLM_BASE_URL', 'AUTOGLM_MODEL', 'AUTOGLM_API_KEY', 'AUTOGLM_MAX_STEPS', 'AUTOGLM_TIMEOUT_SECONDS',
|
|
260
|
+
];
|
|
261
|
+
/** The AutoGLM executor is removed: its variables and its executor name fail closed before any executor is built. */
|
|
262
|
+
function rejectRemovedAutoGlm(environment) {
|
|
263
|
+
const removed = REMOVED_AUTOGLM_VARIABLES.filter(name => stripLikePython(environment[name] ?? '') !== '');
|
|
264
|
+
const selected = [environment.EXECUTORS, environment.EXECUTOR]
|
|
265
|
+
.some(raw => (raw ?? '').split(',').some(name => stripLikePython(name).toLowerCase() === 'autoglm'));
|
|
266
|
+
if (removed.length === 0 && !selected)
|
|
267
|
+
return;
|
|
268
|
+
throw new ConfigurationError(`${[...removed, ...(selected ? ['EXECUTORS=autoglm'] : [])].join(', ')} 已移除;AutoGLM 执行器已下线,请改用 mobile 执行器(EXECUTORS=mobile)`);
|
|
269
|
+
}
|
|
270
|
+
function rejectRemovedModelOverrides(environment) {
|
|
271
|
+
rejectRemovedAutoGlm(environment);
|
|
272
|
+
const removed = ['MODEL_BASE_URL', 'MODEL_API_KEY']
|
|
273
|
+
.filter(name => stripLikePython(environment[name] ?? '') !== '');
|
|
274
|
+
if (removed.length === 0)
|
|
275
|
+
return;
|
|
276
|
+
throw new ConfigurationError(`${removed.join(', ')} 已移除;模型地址和密钥按供应商分别配置:`
|
|
277
|
+
+ 'DASHSCOPE_MODEL_BASE_URL/DASHSCOPE_API_KEY、DEEPSEEK_MODEL_BASE_URL/DEEPSEEK_API_KEY、'
|
|
278
|
+
+ 'OPENAI_MODEL_BASE_URL/OPENAI_API_KEY、GEMINI_MODEL_BASE_URL/GEMINI_API_KEY、'
|
|
279
|
+
+ 'STEPFUN_MODEL_BASE_URL/STEPFUN_API_KEY、VOLCENGINE_ARK_BASE_URL/ARK_API_KEY;'
|
|
280
|
+
+ '兼容网关使用 OPENAI_COMPATIBLE_BASE_URL/API_KEY,自托管使用 SELF_HOSTED_LLM_BASE_URL/API_KEY');
|
|
281
|
+
}
|
|
179
282
|
/** One `[config-warning]` line per renamed variable still set in the environment. */
|
|
180
283
|
export function renamedEnvironmentWarnings(environment) {
|
|
181
284
|
return Object.entries(RENAMED_ENVIRONMENT)
|
|
182
285
|
.filter(([removed]) => environment[removed] !== undefined)
|
|
183
286
|
.map(([removed, current]) => `[config-warning] ${removed} is no longer read; rename it to ${current}`);
|
|
184
287
|
}
|
|
288
|
+
/** Parse the host-private routing document; malformed input is a configuration error, never partial routing. */
|
|
289
|
+
function loadModelRoutes(raw) {
|
|
290
|
+
try {
|
|
291
|
+
return parseModelRoutes(raw);
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
if (error instanceof ModelRoutesParseError)
|
|
295
|
+
throw new ConfigurationError('invalid configuration: MODEL_ROUTES');
|
|
296
|
+
throw error;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
185
299
|
export function loadSettings(environment = process.env, textConversations = false) {
|
|
300
|
+
rejectRemovedModelOverrides(environment);
|
|
186
301
|
const pipelineMode = parsePipelineMode(environment.PIPELINE_MODE);
|
|
187
302
|
const integratedProvider = pipelineMode === 'integrated'
|
|
188
303
|
? parseIntegratedProvider(environment.INTEGRATED_PROVIDER)
|
|
189
304
|
: undefined;
|
|
305
|
+
const modelRoutes = loadModelRoutes(environment.MODEL_ROUTES);
|
|
306
|
+
const routedProviders = modelRouteProviders(modelRoutes);
|
|
307
|
+
const routedText = modelRoutes.conversationText;
|
|
190
308
|
const cascadedProviders = pipelineMode === 'cascaded'
|
|
191
309
|
? {
|
|
192
310
|
endpointing: parseCascadedEndpointingProvider(environment.CASCADE_ENDPOINTING_PROVIDER),
|
|
193
311
|
asr: parseCascadedAsrProvider(environment.CASCADE_ASR_PROVIDER),
|
|
194
|
-
llm:
|
|
312
|
+
llm: routedText === undefined
|
|
313
|
+
? parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER)
|
|
314
|
+
: routedText.provider,
|
|
195
315
|
tts: parseCascadedTtsProvider(environment.CASCADE_TTS_PROVIDER),
|
|
196
316
|
}
|
|
197
317
|
: undefined;
|
|
@@ -200,14 +320,41 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
200
320
|
? null
|
|
201
321
|
: configuredExecutor;
|
|
202
322
|
const executors = parseExecutors(environment.EXECUTORS, configuredExecutor ?? '');
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
const
|
|
323
|
+
// Text conversations on the desktop use the cascaded LLM even when the voice pipeline is
|
|
324
|
+
// integrated; auxiliary models must therefore follow whichever provider answers text.
|
|
325
|
+
// Inactive selectors stay unread: integrated runtimes never touch the cascaded slots.
|
|
326
|
+
const cascadeText = textConversations || pipelineMode === 'cascaded';
|
|
327
|
+
const routeConversationText = cascadeText ? routedText : undefined;
|
|
328
|
+
const routedTextProvider = routeConversationText === undefined
|
|
329
|
+
? undefined : routeConversationText.provider;
|
|
330
|
+
const effectiveTextProvider = cascadeText
|
|
331
|
+
? routedTextProvider ?? parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER)
|
|
332
|
+
: integratedProvider;
|
|
333
|
+
const configuredCascadeModel = cascadeText
|
|
334
|
+
? routeConversationText?.model ?? optionalString(environment.CASCADE_LLM_MODEL) ?? null
|
|
335
|
+
: null;
|
|
336
|
+
const cascadeModel = configuredCascadeModel
|
|
337
|
+
?? (effectiveTextProvider === undefined || effectiveTextProvider === 'self-hosted' || effectiveTextProvider === 'openai-compatible'
|
|
338
|
+
? null : defaultCascadedLlmModel(effectiveTextProvider));
|
|
339
|
+
const auxiliary = auxiliaryModelProfile(effectiveTextProvider, cascadeModel);
|
|
340
|
+
const auxiliaryDefault = (value, key) => value ?? auxiliary?.[key];
|
|
341
|
+
// A routed lane overrides its legacy default, and the route's provider credential is read
|
|
342
|
+
// even when no legacy selector would have needed it.
|
|
343
|
+
const routesRequireKey = (provider) => routedProviders.has(provider);
|
|
209
344
|
const candidate = {
|
|
210
345
|
coding_backend: optionalString(environment.CODING_BACKEND),
|
|
346
|
+
openai_compatible_base_url: optionalString(environment.OPENAI_COMPATIBLE_BASE_URL),
|
|
347
|
+
openai_compatible_api_key: optionalSecret(environment.OPENAI_COMPATIBLE_API_KEY),
|
|
348
|
+
openai_compatible_protocol: parseSelector(z.enum(['chat-completions', 'responses']), environment.OPENAI_COMPATIBLE_PROTOCOL, 'chat-completions', 'OPENAI_COMPATIBLE_PROTOCOL'),
|
|
349
|
+
compatible_asr_base_url: optionalString(environment.COMPATIBLE_ASR_BASE_URL),
|
|
350
|
+
compatible_asr_api_key: optionalSecret(environment.COMPATIBLE_ASR_API_KEY),
|
|
351
|
+
compatible_asr_model: optionalString(environment.COMPATIBLE_ASR_MODEL),
|
|
352
|
+
compatible_tts_base_url: optionalString(environment.COMPATIBLE_TTS_BASE_URL),
|
|
353
|
+
compatible_tts_api_key: optionalSecret(environment.COMPATIBLE_TTS_API_KEY),
|
|
354
|
+
compatible_tts_model: optionalString(environment.COMPATIBLE_TTS_MODEL),
|
|
355
|
+
compatible_tts_voice: optionalString(environment.COMPATIBLE_TTS_VOICE),
|
|
356
|
+
compatible_asr_omit_response_format: optionalBoolean(environment.COMPATIBLE_ASR_OMIT_RESPONSE_FORMAT),
|
|
357
|
+
compatible_tts_send_sample_rate: optionalBoolean(environment.COMPATIBLE_TTS_SEND_SAMPLE_RATE),
|
|
211
358
|
self_hosted_asr_url: optionalString(environment.SELF_HOSTED_ASR_URL),
|
|
212
359
|
self_hosted_llm_base_url: optionalString(environment.SELF_HOSTED_LLM_BASE_URL),
|
|
213
360
|
self_hosted_tts_url: optionalString(environment.SELF_HOSTED_TTS_URL),
|
|
@@ -222,32 +369,45 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
222
369
|
openai_realtime_url: optionalString(environment.OPENAI_REALTIME_URL),
|
|
223
370
|
openai_realtime_model: optionalString(environment.OPENAI_REALTIME_MODEL),
|
|
224
371
|
openai_realtime_voice: optionalString(environment.OPENAI_REALTIME_VOICE),
|
|
372
|
+
native_realtime_url: optionalString(environment.NATIVE_REALTIME_URL),
|
|
373
|
+
native_realtime_api_key: optionalString(environment.NATIVE_REALTIME_API_KEY),
|
|
374
|
+
native_realtime_voice: optionalString(environment.NATIVE_REALTIME_VOICE),
|
|
225
375
|
gemini_realtime_url: optionalString(environment.GEMINI_REALTIME_URL),
|
|
226
376
|
gemini_realtime_model: optionalString(environment.GEMINI_REALTIME_MODEL),
|
|
227
377
|
gemini_realtime_voice: optionalString(environment.GEMINI_REALTIME_VOICE),
|
|
228
|
-
|
|
229
|
-
|
|
378
|
+
deepseek_api_key: optionalSecret(environment.DEEPSEEK_API_KEY),
|
|
379
|
+
embedding_base_url: optionalString(environment.EMBEDDING_BASE_URL),
|
|
380
|
+
embedding_api_key: optionalSecret(environment.EMBEDDING_API_KEY),
|
|
381
|
+
dashscope_model_base_url: optionalString(environment.DASHSCOPE_MODEL_BASE_URL),
|
|
382
|
+
deepseek_model_base_url: optionalString(environment.DEEPSEEK_MODEL_BASE_URL),
|
|
383
|
+
openai_model_base_url: optionalString(environment.OPENAI_MODEL_BASE_URL),
|
|
384
|
+
gemini_model_base_url: optionalString(environment.GEMINI_MODEL_BASE_URL),
|
|
385
|
+
stepfun_model_base_url: optionalString(environment.STEPFUN_MODEL_BASE_URL),
|
|
230
386
|
openrouter_api_key: optionalSecret(environment.OPENROUTER_API_KEY),
|
|
231
387
|
tavily_api_key: optionalSecret(environment.TAVILY_API_KEY),
|
|
232
|
-
fast_model: rawEnvironmentValue(environment.FAST_MODEL),
|
|
233
|
-
watch_model:
|
|
388
|
+
fast_model: modelRoutes.fast?.model ?? auxiliaryDefault(rawEnvironmentValue(environment.FAST_MODEL), 'fast'),
|
|
389
|
+
watch_model: modelRoutes.watch?.model ?? auxiliaryDefault(emptyAsUnset(rawEnvironmentValue(environment.WATCH_MODEL)), 'watch'),
|
|
234
390
|
...(supportsVision('qwen', environment.WATCH_MODEL ?? '')
|
|
391
|
+
|| routesRequireKey('qwen') || routesRequireKey('dashscope')
|
|
235
392
|
|| environment.MEMORY_CONNECTION?.trim() === 'local'
|
|
236
393
|
? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) } : {}),
|
|
237
|
-
...(supportsVision('ark', environment.WATCH_MODEL ?? '')
|
|
394
|
+
...(supportsVision('ark', environment.WATCH_MODEL ?? '') || routesRequireKey('ark')
|
|
238
395
|
? { ark_api_key: optionalSecret(environment.ARK_API_KEY),
|
|
239
396
|
volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL) } : {}),
|
|
240
|
-
|
|
397
|
+
...(routesRequireKey('stepfun')
|
|
398
|
+
? { stepfun_api_key: optionalSecret(environment.STEPFUN_API_KEY) } : {}),
|
|
241
399
|
monitor_camera_device_id: optionalString(environment.MONITOR_CAMERA_DEVICE_ID),
|
|
242
|
-
support_model:
|
|
243
|
-
compressor_model:
|
|
400
|
+
support_model: modelRoutes.support?.model ?? auxiliaryDefault(rawEnvironmentValue(environment.SUPPORT_MODEL), 'support'),
|
|
401
|
+
compressor_model: modelRoutes.compressor?.model ?? auxiliaryDefault(undefined, 'compressor'),
|
|
402
|
+
model_routes: modelRoutes,
|
|
244
403
|
language: parsePromptLanguageSetting(environment.PROMPT_LANGUAGE),
|
|
245
404
|
news_language: parseSelector(promptLanguageSchema, environment.NEWS_LANGUAGE, 'en', 'NEWS_LANGUAGE'),
|
|
246
405
|
pipeline_mode: pipelineMode,
|
|
247
406
|
camera_module_enabled: optionalBoolean(environment.CAMERA_MODULE_ENABLED),
|
|
407
|
+
profile_participant_messages: optionalBoolean(environment.PROFILE_PARTICIPANT_MESSAGES),
|
|
248
408
|
...(pipelineMode === 'integrated' ? {
|
|
249
|
-
...(textConversations ? { cascade_llm_provider: parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER),
|
|
250
|
-
cascade_llm_model: rawEnvironmentValue(environment.CASCADE_LLM_MODEL),
|
|
409
|
+
...(textConversations ? { cascade_llm_provider: routedTextProvider ?? parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER),
|
|
410
|
+
cascade_llm_model: routedText?.model ?? rawEnvironmentValue(environment.CASCADE_LLM_MODEL) ?? cascadeModel,
|
|
251
411
|
ark_api_key: optionalSecret(environment.ARK_API_KEY), deepseek_api_key: optionalSecret(environment.DEEPSEEK_API_KEY),
|
|
252
412
|
volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL) } : {}),
|
|
253
413
|
integrated_provider: integratedProvider,
|
|
@@ -268,7 +428,7 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
268
428
|
cascade_endpointing_provider: cascadedProviders.endpointing,
|
|
269
429
|
cascade_asr_provider: cascadedProviders.asr,
|
|
270
430
|
cascade_llm_provider: cascadedProviders.llm,
|
|
271
|
-
cascade_llm_model: rawEnvironmentValue(environment.CASCADE_LLM_MODEL),
|
|
431
|
+
cascade_llm_model: routedText?.model ?? rawEnvironmentValue(environment.CASCADE_LLM_MODEL),
|
|
272
432
|
cascade_tts_provider: cascadedProviders.tts,
|
|
273
433
|
...(cascadedProviders.llm === 'qwen'
|
|
274
434
|
? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) }
|
|
@@ -278,7 +438,6 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
278
438
|
...(cascadedProviders.llm === 'ark' ? {
|
|
279
439
|
volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL),
|
|
280
440
|
} : {}),
|
|
281
|
-
doubao_asr_api_key: optionalSecret(environment.DOUBAO_ASR_API_KEY),
|
|
282
441
|
doubao_bigmodel_api_key: optionalSecret(environment.DOUBAO_BIGMODEL_API_KEY),
|
|
283
442
|
doubao_asr_endpoint: rawEnvironmentValue(environment.DOUBAO_ASR_ENDPOINT),
|
|
284
443
|
doubao_asr_resource_id: rawEnvironmentValue(environment.DOUBAO_ASR_RESOURCE_ID),
|
|
@@ -307,15 +466,15 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
307
466
|
fresh_window: optionalPydanticFloat(environment.FRESH_WINDOW),
|
|
308
467
|
clarification_depth: parseClarificationDepth(environment.CLARIFICATION_DEPTH),
|
|
309
468
|
plan_readback: parsePlanReadback(environment.PLAN_READBACK),
|
|
469
|
+
build_reasoning: optionalBoolean(environment.NOVA_BUILD_REASONING),
|
|
310
470
|
generate_plan: optionalBoolean(environment.GENERATE_PLAN),
|
|
311
|
-
planner_model: supportDefault(emptyAsUnset(optionalString(environment.PLANNER_MODEL))),
|
|
312
471
|
progress_bubbles: parseProgressBubbles(environment.PROGRESS_BUBBLES),
|
|
313
472
|
search_provider: parseSearchProvider(environment.SEARCH_PROVIDER),
|
|
314
473
|
search_mcp_url: optionalString(environment.SEARCH_MCP_URL),
|
|
315
474
|
search_mcp_tool: optionalString(environment.SEARCH_MCP_TOOL),
|
|
316
475
|
knowledge_path: optionalString(environment.KNOWLEDGE_PATH),
|
|
317
476
|
embedding_provider: parseEmbeddingProvider(environment.EMBEDDING_PROVIDER),
|
|
318
|
-
embedding_model: optionalString(environment.EMBEDDING_MODEL),
|
|
477
|
+
embedding_model: modelRoutes.embedding?.model ?? optionalString(environment.EMBEDDING_MODEL),
|
|
319
478
|
blackboard_path: optionalString(environment.BLACKBOARD_PATH),
|
|
320
479
|
blackboard_owner_id: optionalString(environment.BLACKBOARD_OWNER_ID),
|
|
321
480
|
memory_prerecall_enabled: optionalBoolean(environment.MEMORY_PRERECALL_ENABLED),
|
|
@@ -326,11 +485,13 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
326
485
|
...((optionalString(environment.MEMORY_CONNECTION) ?? 'local') === 'local'
|
|
327
486
|
? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) } : {}),
|
|
328
487
|
memory_provider: optionalString(environment.MEMORY_PROVIDER),
|
|
488
|
+
memory_recall_engine: optionalNonEmptyString(environment.MEMORY_RECALL_ENGINE),
|
|
489
|
+
memory_extractors: optionalNonEmptyString(environment.MEMORY_EXTRACTORS)?.split(',').map(value => value.trim()),
|
|
329
490
|
memory_url: optionalString(environment.MEMORY_URL),
|
|
330
491
|
memory_token: optionalSecret(environment.MEMORY_TOKEN),
|
|
331
492
|
memory_path: optionalString(environment.MEMORY_PATH),
|
|
332
493
|
memory_user_id: optionalString(environment.MEMORY_USER_ID),
|
|
333
|
-
workspace_graph_path: optionalString(environment.MEMORY_LEDGER_PATH)
|
|
494
|
+
workspace_graph_path: optionalString(environment.MEMORY_LEDGER_PATH),
|
|
334
495
|
};
|
|
335
496
|
const withoutUndefined = Object.fromEntries(Object.entries(candidate).filter(([, value]) => value !== undefined));
|
|
336
497
|
const result = settingsSchema.safeParse(withoutUndefined);
|
|
@@ -338,14 +499,34 @@ export function loadSettings(environment = process.env, textConversations = fals
|
|
|
338
499
|
const fields = [...new Set(result.error.issues.map(issue => String(issue.path[0] ?? 'settings')))]
|
|
339
500
|
.sort(compareStrings)
|
|
340
501
|
.map(configurationFieldName);
|
|
341
|
-
throw new ConfigurationError(`invalid configuration: ${fields.join(', ')}
|
|
342
|
-
}
|
|
343
|
-
if (environment.MEMORY_BACKEND !== undefined) {
|
|
344
|
-
throw new ConfigurationError('MEMORY_BACKEND was removed; use MEMORY_CONNECTION');
|
|
502
|
+
throw new ConfigurationError(`invalid configuration: ${fields.join(', ')}`, 'invalid_configuration', fields.some(field => memoryConfigurationVariables.includes(field)) ? { code: 'memory_configuration_invalid', variables: fields.filter(field => memoryConfigurationVariables.includes(field)) } : undefined);
|
|
345
503
|
}
|
|
346
504
|
resolveMemoryConnection(result.data);
|
|
505
|
+
rebaseDataRootDefaults(result.data, environment);
|
|
347
506
|
return result.data;
|
|
348
507
|
}
|
|
508
|
+
/** Defaulted data paths follow the legacy root until its one-time migration has run; explicit values never move. */
|
|
509
|
+
const DATA_ROOT_DEFAULTS = [
|
|
510
|
+
['codex_managed_root', 'CODEX_MANAGED_ROOT'],
|
|
511
|
+
['codex_project_state_root', 'CODEX_PROJECT_STATE_ROOT'],
|
|
512
|
+
['knowledge_path', 'KNOWLEDGE_PATH'],
|
|
513
|
+
['blackboard_path', 'BLACKBOARD_PATH'],
|
|
514
|
+
['memory_path', 'MEMORY_PATH'],
|
|
515
|
+
['workspace_graph_path', 'MEMORY_LEDGER_PATH'],
|
|
516
|
+
];
|
|
517
|
+
function rebaseDataRootDefaults(settings, environment) {
|
|
518
|
+
const home = environmentHome(environment);
|
|
519
|
+
if (!legacyDataRootActive(home)) {
|
|
520
|
+
// Migrated: explicit paths named under the legacy root open the moved data, never a second copy.
|
|
521
|
+
for (const [key] of DATA_ROOT_DEFAULTS)
|
|
522
|
+
settings[key] = mapLegacyDataPath(settings[key], home);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
for (const [key, variable] of DATA_ROOT_DEFAULTS) {
|
|
526
|
+
if (optionalString(environment[variable]) === undefined)
|
|
527
|
+
settings[key] = rebaseDataRootDefault(settings[key], true);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
349
530
|
export function resolveProactivity(settings) {
|
|
350
531
|
const preset = resolveProactivityPreset(settings.proactivity_preset);
|
|
351
532
|
return {
|
|
@@ -356,37 +537,247 @@ export function resolveProactivity(settings) {
|
|
|
356
537
|
export function resolveProactivityPreset(preset) {
|
|
357
538
|
return proactivityPresets[preset];
|
|
358
539
|
}
|
|
540
|
+
/** Provider model endpoints allow no credentials, query or fragment in addition to the TLS rule. */
|
|
541
|
+
function secureModelEndpoint(value, name) {
|
|
542
|
+
const endpoint = secureEndpoint(value, 'https', name);
|
|
543
|
+
if (new URL(endpoint).search !== '')
|
|
544
|
+
throw new ConfigurationError(`${name} 禁止查询参数`);
|
|
545
|
+
return endpoint;
|
|
546
|
+
}
|
|
547
|
+
/** The dedicated model endpoint for one provider; every provider owns its own address. */
|
|
548
|
+
function providerModelEndpoint(settings, provider) {
|
|
549
|
+
switch (provider) {
|
|
550
|
+
case 'qwen': return secureModelEndpoint(settings.dashscope_model_base_url, 'DASHSCOPE_MODEL_BASE_URL');
|
|
551
|
+
case 'deepseek': return secureModelEndpoint(settings.deepseek_model_base_url, 'DEEPSEEK_MODEL_BASE_URL');
|
|
552
|
+
case 'openai': return secureModelEndpoint(settings.openai_model_base_url, 'OPENAI_MODEL_BASE_URL');
|
|
553
|
+
case 'gemini': return secureModelEndpoint(settings.gemini_model_base_url, 'GEMINI_MODEL_BASE_URL');
|
|
554
|
+
case 'stepfun': return secureModelEndpoint(settings.stepfun_model_base_url, 'STEPFUN_MODEL_BASE_URL');
|
|
555
|
+
case 'ark': return secureModelEndpoint(settings.volcengine_ark_base_url, 'VOLCENGINE_ARK_BASE_URL');
|
|
556
|
+
default: throw new ConfigurationError('invalid configuration: MODEL_ROUTES');
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Resolve one provider's own model endpoint and credential.
|
|
561
|
+
*
|
|
562
|
+
* There is deliberately no cross-provider fallback: an unselected provider's URL and key stay
|
|
563
|
+
* unread, and a missing key names that provider's variable instead of borrowing another key.
|
|
564
|
+
* `dashscope` is the embedding-only provider lane; it keeps EMBEDDING_BASE_URL's DashScope default,
|
|
565
|
+
* because the model URL does not own embeddings.
|
|
566
|
+
*/
|
|
567
|
+
export function resolveProviderModelConnection(settings, provider) {
|
|
568
|
+
if (!Object.hasOwn(MODEL_ROUTE_PROVIDER_METADATA, provider))
|
|
569
|
+
return null;
|
|
570
|
+
const typed = provider;
|
|
571
|
+
const metadata = MODEL_ROUTE_PROVIDER_METADATA[typed];
|
|
572
|
+
const apiKey = stripLikePython(settings[metadata.keyField] ?? '');
|
|
573
|
+
const keyMissing = apiKey === '' && !metadata.keyOptional ? metadata.keyName : null;
|
|
574
|
+
if (typed === 'self-hosted' || typed === 'openai-compatible') {
|
|
575
|
+
const name = typed === 'self-hosted' ? 'SELF_HOSTED_LLM_BASE_URL' : 'OPENAI_COMPATIBLE_BASE_URL';
|
|
576
|
+
const raw = stripLikePython(typed === 'self-hosted'
|
|
577
|
+
? settings.self_hosted_llm_base_url : settings.openai_compatible_base_url);
|
|
578
|
+
return {
|
|
579
|
+
provider: typed,
|
|
580
|
+
baseUrl: raw === '' ? '' : routeCompatibleEndpoint(raw, name),
|
|
581
|
+
apiKey,
|
|
582
|
+
missing: raw === '' ? name : keyMissing,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
if (typed === 'dashscope') {
|
|
586
|
+
return { provider: typed, baseUrl: DASHSCOPE_COMPATIBLE_BASE_URL, apiKey, missing: keyMissing };
|
|
587
|
+
}
|
|
588
|
+
return { provider: typed, baseUrl: providerModelEndpoint(settings, typed), apiKey, missing: keyMissing };
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Mirrors `selfHostedEndpoint`; importing it here would create a config <-> self-hosted cycle.
|
|
592
|
+
* TLS is required except for a literal loopback address, and URLs may not carry credentials,
|
|
593
|
+
* queries or fragments.
|
|
594
|
+
*/
|
|
595
|
+
function routeCompatibleEndpoint(value, name) {
|
|
596
|
+
const normalized = stripLikePython(value);
|
|
597
|
+
let url;
|
|
598
|
+
try {
|
|
599
|
+
url = new URL(normalized);
|
|
600
|
+
}
|
|
601
|
+
catch {
|
|
602
|
+
throw new ConfigurationError(`${name} 地址无效`);
|
|
603
|
+
}
|
|
604
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
605
|
+
const loopback = host === '::1' || (isIP(host) === 4 && host.startsWith('127.'));
|
|
606
|
+
const authority = normalized.split('://')[1]?.split(/[/?#]/)[0] ?? '';
|
|
607
|
+
const literal = authority.replace(/:\d+$/, '').replace(/^\[|\]$/g, '');
|
|
608
|
+
if (!(url.protocol === 'https:' || (url.protocol === 'http:' && loopback && isIP(literal)))
|
|
609
|
+
|| url.username || url.password || normalized.includes('@') || normalized.includes('?') || normalized.includes('#')) {
|
|
610
|
+
throw new ConfigurationError(`${name} 必须使用 TLS;仅字面量回环地址可使用明文,且禁止 URL 凭据、查询和片段`);
|
|
611
|
+
}
|
|
612
|
+
return url.toString().replace(/\/$/, '');
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Resolve one explicitly routed lane into a provider connection.
|
|
616
|
+
*
|
|
617
|
+
* Returns null when the lane is not routed, so every caller keeps its historical default.
|
|
618
|
+
* A routed model uses exactly its provider's endpoint and credential; no generic override and no
|
|
619
|
+
* other provider's configuration can retarget the lane.
|
|
620
|
+
*/
|
|
621
|
+
export function resolveModelRoute(settings, lane) {
|
|
622
|
+
const route = settings.model_routes[lane];
|
|
623
|
+
if (route === undefined || route === null)
|
|
624
|
+
return null;
|
|
625
|
+
const connection = resolveProviderModelConnection(settings, route.provider);
|
|
626
|
+
if (connection === null)
|
|
627
|
+
throw new ConfigurationError('invalid configuration: MODEL_ROUTES');
|
|
628
|
+
return Object.freeze({
|
|
629
|
+
provider: connection.provider,
|
|
630
|
+
model: route.model,
|
|
631
|
+
baseUrl: connection.baseUrl,
|
|
632
|
+
apiKey: connection.apiKey,
|
|
633
|
+
missing: connection.missing,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
function extractionCandidate(settings, provider) {
|
|
637
|
+
const connection = resolveProviderModelConnection(settings, provider);
|
|
638
|
+
if (connection === null)
|
|
639
|
+
return null;
|
|
640
|
+
const model = provider === 'ark' ? settings.volcengine_ark_support_model
|
|
641
|
+
: provider === 'self-hosted' || provider === 'openai-compatible' ? settings.cascade_llm_model ?? settings.fast_model
|
|
642
|
+
: AUXILIARY_MODEL_PROFILES[provider]?.fast;
|
|
643
|
+
if (model === undefined)
|
|
644
|
+
return null;
|
|
645
|
+
return { ...connection, model };
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* The provider that answers text and support. An explicit fast route is a separate lane and must
|
|
649
|
+
* not retarget support; model names never guess a provider. Text mode is the cascaded graph, or an
|
|
650
|
+
* integrated runtime with a configured cascaded text model (desktop text conversations set it).
|
|
651
|
+
*/
|
|
652
|
+
function effectiveTextProvider(settings) {
|
|
653
|
+
if (settings.pipeline_mode !== 'cascaded' && settings.cascade_llm_model === null) {
|
|
654
|
+
return settings.integrated_provider;
|
|
655
|
+
}
|
|
656
|
+
const routed = settings.model_routes.conversationText;
|
|
657
|
+
if (routed !== undefined && routed !== null)
|
|
658
|
+
return routed.provider;
|
|
659
|
+
return settings.cascade_llm_provider;
|
|
660
|
+
}
|
|
661
|
+
/** The selected text provider's own model endpoint and credential; null for native realtime only. */
|
|
662
|
+
export function resolveSelectedModelConnection(settings) {
|
|
663
|
+
return resolveProviderModelConnection(settings, effectiveTextProvider(settings));
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Extraction must reach the same provider that answers text. A local gateway is never replaced by
|
|
667
|
+
* a cloud provider with a matching model name; a missing local key stays local (self-hosted may be
|
|
668
|
+
* keyless) instead of silently sending content elsewhere, and no other provider's key is borrowed.
|
|
669
|
+
*/
|
|
670
|
+
export function resolveMemoryExtractionConnection(settings) {
|
|
671
|
+
// The fast lane is the memory-extraction lane: an explicit route wins over the provider default.
|
|
672
|
+
const fastRoute = resolveModelRoute(settings, 'fast');
|
|
673
|
+
if (fastRoute !== null) {
|
|
674
|
+
return {
|
|
675
|
+
baseUrl: fastRoute.baseUrl,
|
|
676
|
+
apiKey: fastRoute.apiKey,
|
|
677
|
+
model: fastRoute.model,
|
|
678
|
+
missing: fastRoute.missing,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
const primary = extractionCandidate(settings, effectiveTextProvider(settings));
|
|
682
|
+
if (primary === null) {
|
|
683
|
+
// Native realtime providers have no model channel of their own; extraction needs an explicit lane.
|
|
684
|
+
return { baseUrl: '', apiKey: '', model: settings.fast_model, missing: 'MODEL_ROUTES' };
|
|
685
|
+
}
|
|
686
|
+
return { ...primary, model: settings.fast_model };
|
|
687
|
+
}
|
|
359
688
|
export function requirePersonalMemory(settings) {
|
|
360
689
|
const connection = resolveMemoryConnection(settings);
|
|
361
690
|
if (connection === 'disabled')
|
|
362
691
|
return null;
|
|
363
692
|
if (connection === 'remote')
|
|
364
|
-
return
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (
|
|
693
|
+
return remoteMemoryConfig(settings);
|
|
694
|
+
// Local memory is optional: without its embedding and extraction credentials it stays off
|
|
695
|
+
// instead of blocking the voice pipeline or silently failing every extraction request.
|
|
696
|
+
if (!resolveEmbeddingConnection(settings).apiKey)
|
|
697
|
+
return null;
|
|
698
|
+
const extraction = resolveMemoryExtractionConnection(settings);
|
|
699
|
+
if (extraction.missing !== null)
|
|
371
700
|
return null;
|
|
372
701
|
return Object.freeze({
|
|
373
702
|
connection: 'local',
|
|
374
703
|
provider: settings.memory_provider ?? 'voicemem',
|
|
375
704
|
path: requiredSetting(settings.memory_path, 'MEMORY_PATH'),
|
|
376
705
|
userId: requiredSetting(settings.memory_user_id, 'MEMORY_USER_ID'),
|
|
377
|
-
extractionModel:
|
|
706
|
+
extractionModel: extraction.model,
|
|
707
|
+
extraction: { baseUrl: extraction.baseUrl, apiKey: extraction.apiKey },
|
|
378
708
|
embedding: Object.freeze({
|
|
379
|
-
|
|
380
|
-
apiKey: requiredCredential(resolveModelApiKey(settings), 'DASHSCOPE_API_KEY 或 MODEL_API_KEY'),
|
|
709
|
+
...resolveEmbeddingConnection(settings),
|
|
381
710
|
model: requiredSetting(settings.embedding_model, 'EMBEDDING_MODEL'),
|
|
382
711
|
}),
|
|
383
712
|
});
|
|
384
713
|
}
|
|
714
|
+
/** Pure plan: no stores, warnings, migrations or model calls happen during resolution. */
|
|
715
|
+
export function resolveMemoryComposition(settings) {
|
|
716
|
+
const configured = requirePersonalMemory(settings);
|
|
717
|
+
if (!configured)
|
|
718
|
+
return { kind: 'disabled' };
|
|
719
|
+
if (configured.connection === 'remote')
|
|
720
|
+
return { kind: 'remote', config: configured };
|
|
721
|
+
const path = resolve(configured.path.startsWith('~/') ? resolve(homedir(), configured.path.slice(2)) : configured.path);
|
|
722
|
+
const local = { ...configured, path };
|
|
723
|
+
if (settings.memory_provider === 'mem0')
|
|
724
|
+
return { kind: 'standalone-mem0', config: local };
|
|
725
|
+
const legacy = settings.memory_recall_engine === null && settings.memory_extractors === null;
|
|
726
|
+
return { kind: 'ledger', engine: settings.memory_recall_engine ?? 'ledger', extractors: settings.memory_extractors ?? ['ledger'], local,
|
|
727
|
+
...(legacy ? { migrateLegacy: { path, userId: local.userId } } : {}) };
|
|
728
|
+
}
|
|
729
|
+
/** Module status in the shape of `modules.search`; local memory is off without both credentials. */
|
|
730
|
+
export function memoryStatus(settings) {
|
|
731
|
+
try {
|
|
732
|
+
const connection = resolveMemoryConnection(settings);
|
|
733
|
+
if (connection === 'disabled')
|
|
734
|
+
return { enabled: false, reason: 'disabled', fallback: null };
|
|
735
|
+
if (connection === 'local') {
|
|
736
|
+
const embeddingRoute = resolveModelRoute(settings, 'embedding');
|
|
737
|
+
if (!resolveEmbeddingConnection(settings).apiKey)
|
|
738
|
+
return { enabled: false,
|
|
739
|
+
reason: `missing_environment:${embeddingRoute?.missing ?? (settings.embedding_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? 'DASHSCOPE_API_KEY' : 'EMBEDDING_API_KEY')}`, fallback: null };
|
|
740
|
+
const extraction = resolveMemoryExtractionConnection(settings);
|
|
741
|
+
if (extraction.missing !== null)
|
|
742
|
+
return { enabled: false, reason: `missing_environment:${extraction.missing}`, fallback: null };
|
|
743
|
+
}
|
|
744
|
+
return { enabled: true, reason: null, fallback: null };
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
// Memory is optional: an invalid endpoint must not make the whole composition (and Settings) fail.
|
|
748
|
+
return { enabled: false, reason: 'invalid_configuration', fallback: null };
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function remoteMemoryConfig(settings) {
|
|
752
|
+
const invalid = (variables) => new ConfigurationError('invalid remote memory configuration', 'invalid_configuration', { code: 'memory_configuration_invalid', variables });
|
|
753
|
+
const url = settings.memory_url.trim();
|
|
754
|
+
try {
|
|
755
|
+
const parsed = new URL(url);
|
|
756
|
+
if ((parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && ['127.0.0.1', '[::1]'].includes(parsed.hostname))) || parsed.username || parsed.password || parsed.search || parsed.hash || (parsed.pathname !== '/' && parsed.pathname !== ''))
|
|
757
|
+
throw Error();
|
|
758
|
+
}
|
|
759
|
+
catch {
|
|
760
|
+
throw invalid(['MEMORY_CONNECTION', 'MEMORY_URL']);
|
|
761
|
+
}
|
|
762
|
+
const token = (settings.memory_token ?? '').trim();
|
|
763
|
+
if (!token || token.length > 8192 || /\s/u.test(token))
|
|
764
|
+
throw invalid(['MEMORY_CONNECTION', 'MEMORY_TOKEN']);
|
|
765
|
+
return Object.freeze({ connection: 'remote', url, token });
|
|
766
|
+
}
|
|
385
767
|
function resolveMemoryConnection(settings) {
|
|
386
768
|
const connection = settings.memory_connection;
|
|
769
|
+
const newSettings = settings.memory_recall_engine !== null || settings.memory_extractors !== null;
|
|
770
|
+
if (newSettings && settings.memory_provider !== null)
|
|
771
|
+
throw new ConfigurationError('MEMORY_PROVIDER conflicts with MEMORY_RECALL_ENGINE/MEMORY_EXTRACTORS', 'invalid_configuration', { code: 'memory_provider_conflict', variables: ['MEMORY_PROVIDER', ...(settings.memory_recall_engine !== null ? ['MEMORY_RECALL_ENGINE'] : []), ...(settings.memory_extractors !== null ? ['MEMORY_EXTRACTORS'] : [])] });
|
|
772
|
+
if (newSettings && connection === 'remote')
|
|
773
|
+
throw new ConfigurationError('MEMORY_RECALL_ENGINE/MEMORY_EXTRACTORS are only valid for a local memory connection', 'invalid_configuration', { code: 'memory_configuration_invalid', variables: ['MEMORY_CONNECTION', ...(settings.memory_recall_engine !== null ? ['MEMORY_RECALL_ENGINE'] : []), ...(settings.memory_extractors !== null ? ['MEMORY_EXTRACTORS'] : [])] });
|
|
774
|
+
if (settings.memory_extractors !== null && (!settings.memory_extractors.includes('ledger') || new Set(settings.memory_extractors).size !== settings.memory_extractors.length))
|
|
775
|
+
throw new ConfigurationError('MEMORY_EXTRACTORS requires ledger and at most one voicemem', 'invalid_configuration', { code: 'memory_configuration_invalid', variables: ['MEMORY_EXTRACTORS'] });
|
|
387
776
|
if (settings.memory_provider !== null && connection !== 'local') {
|
|
388
|
-
throw new ConfigurationError('MEMORY_PROVIDER is only valid for a local memory connection; remote engines are selected by the service');
|
|
777
|
+
throw new ConfigurationError('MEMORY_PROVIDER is only valid for a local memory connection; remote engines are selected by the service', 'invalid_configuration', { code: 'memory_configuration_invalid', variables: ['MEMORY_PROVIDER', 'MEMORY_CONNECTION'] });
|
|
389
778
|
}
|
|
779
|
+
if (connection === 'remote')
|
|
780
|
+
remoteMemoryConfig(settings);
|
|
390
781
|
return connection;
|
|
391
782
|
}
|
|
392
783
|
export function requireQwenRealtime(settings) {
|
|
@@ -402,16 +793,26 @@ export function requireQwenRealtime(settings) {
|
|
|
402
793
|
if (voice === '') {
|
|
403
794
|
throw new ConfigurationError('QWEN_REALTIME_VOICE 不能为空');
|
|
404
795
|
}
|
|
405
|
-
const
|
|
406
|
-
const modelKey = stripLikePython(settings.model_api_key ?? '');
|
|
407
|
-
const apiKey = realtimeKey || modelKey;
|
|
796
|
+
const apiKey = stripLikePython(settings.dashscope_api_key ?? '');
|
|
408
797
|
if (apiKey === '') {
|
|
409
|
-
throw new ConfigurationError('缺少 DASHSCOPE_API_KEY
|
|
798
|
+
throw new ConfigurationError('缺少 DASHSCOPE_API_KEY');
|
|
410
799
|
}
|
|
411
800
|
return { url, model, voice, apiKey };
|
|
412
801
|
}
|
|
413
802
|
export function requireIntegratedRealtime(settings) {
|
|
414
803
|
const provider = settings.integrated_provider;
|
|
804
|
+
if (provider === 'minicpm-o' || provider === 'personaplex') {
|
|
805
|
+
let url;
|
|
806
|
+
try {
|
|
807
|
+
url = new URL(settings.native_realtime_url);
|
|
808
|
+
}
|
|
809
|
+
catch {
|
|
810
|
+
throw new ConfigurationError('NATIVE_REALTIME_URL 无效');
|
|
811
|
+
}
|
|
812
|
+
if ((url.protocol !== 'wss:' && !(url.protocol === 'ws:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))) || url.username || url.password || url.hash || url.search)
|
|
813
|
+
throw new ConfigurationError('NATIVE_REALTIME_URL 需要 wss 或本机 ws 隧道,不能包含凭据');
|
|
814
|
+
return Object.freeze({ url: url.toString(), model: provider, voice: settings.native_realtime_voice, apiKey: settings.native_realtime_api_key ?? '' });
|
|
815
|
+
}
|
|
415
816
|
if (provider === 'openai' || provider === 'gemini')
|
|
416
817
|
return Object.freeze({
|
|
417
818
|
url: secureEndpoint(settings[`${provider}_realtime_url`], 'wss', `${provider.toUpperCase()}_REALTIME_URL`),
|
|
@@ -439,58 +840,75 @@ export function requireIntegratedRealtime(settings) {
|
|
|
439
840
|
if (voice === '') {
|
|
440
841
|
throw new ConfigurationError('QWEN_REALTIME_VOICE 不能为空');
|
|
441
842
|
}
|
|
442
|
-
const
|
|
443
|
-
const compatibleGenericKey = settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL
|
|
444
|
-
? stripLikePython(settings.model_api_key ?? '')
|
|
445
|
-
: '';
|
|
446
|
-
const apiKey = explicitKey || compatibleGenericKey;
|
|
843
|
+
const apiKey = stripLikePython(settings.dashscope_api_key ?? '');
|
|
447
844
|
if (apiKey === '') {
|
|
448
845
|
throw new ConfigurationError('缺少 DASHSCOPE_API_KEY');
|
|
449
846
|
}
|
|
450
847
|
return Object.freeze({ url, model, voice, apiKey });
|
|
451
848
|
}
|
|
452
|
-
export function
|
|
453
|
-
|
|
454
|
-
|
|
849
|
+
export function resolveEmbeddingConnection(settings) {
|
|
850
|
+
// Knowledge and local memory share one embedding lane; a routed lane pins its provider.
|
|
851
|
+
const embeddingRoute = resolveModelRoute(settings, 'embedding');
|
|
852
|
+
if (embeddingRoute !== null)
|
|
853
|
+
return { baseUrl: embeddingRoute.baseUrl, apiKey: embeddingRoute.apiKey };
|
|
854
|
+
return { baseUrl: secureEndpoint(settings.embedding_base_url, 'https', 'EMBEDDING_BASE_URL'),
|
|
855
|
+
apiKey: stripLikePython(settings.embedding_api_key ?? '')
|
|
856
|
+
|| (settings.embedding_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? stripLikePython(settings.dashscope_api_key ?? '') : '') };
|
|
455
857
|
}
|
|
456
858
|
/** Preset monitor models keep their credential on their own provider endpoint. */
|
|
457
859
|
export function resolveWatchModelConnection(settings) {
|
|
860
|
+
const watchRoute = resolveModelRoute(settings, 'watch');
|
|
861
|
+
if (watchRoute !== null) {
|
|
862
|
+
if (watchRoute.missing !== null)
|
|
863
|
+
throw new ConfigurationError(`缺少 ${watchRoute.missing}`);
|
|
864
|
+
return { baseUrl: watchRoute.baseUrl, apiKey: watchRoute.apiKey };
|
|
865
|
+
}
|
|
458
866
|
const model = stripLikePython(settings.watch_model ?? '');
|
|
867
|
+
if (supportsVision('deepseek', model))
|
|
868
|
+
return {
|
|
869
|
+
baseUrl: secureModelEndpoint(settings.deepseek_model_base_url, 'DEEPSEEK_MODEL_BASE_URL'),
|
|
870
|
+
apiKey: requiredCredential(settings.deepseek_api_key, 'DEEPSEEK_API_KEY'),
|
|
871
|
+
};
|
|
459
872
|
if (supportsVision('stepfun', model))
|
|
460
873
|
return {
|
|
461
|
-
baseUrl:
|
|
874
|
+
baseUrl: secureModelEndpoint(settings.stepfun_model_base_url, 'STEPFUN_MODEL_BASE_URL'),
|
|
462
875
|
apiKey: requiredCredential(settings.stepfun_api_key, 'STEPFUN_API_KEY'),
|
|
463
876
|
};
|
|
464
877
|
if (supportsVision('qwen', model))
|
|
465
878
|
return {
|
|
466
|
-
baseUrl:
|
|
467
|
-
apiKey: requiredCredential(settings.dashscope_api_key
|
|
468
|
-
?? (settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? settings.model_api_key : null), 'DASHSCOPE_API_KEY'),
|
|
879
|
+
baseUrl: secureModelEndpoint(settings.dashscope_model_base_url, 'DASHSCOPE_MODEL_BASE_URL'),
|
|
880
|
+
apiKey: requiredCredential(settings.dashscope_api_key, 'DASHSCOPE_API_KEY'),
|
|
469
881
|
};
|
|
470
882
|
if (supportsVision('ark', model))
|
|
471
883
|
return {
|
|
472
|
-
baseUrl:
|
|
884
|
+
baseUrl: secureModelEndpoint(settings.volcengine_ark_base_url, 'VOLCENGINE_ARK_BASE_URL'),
|
|
473
885
|
apiKey: requiredCredential(settings.ark_api_key, 'ARK_API_KEY'),
|
|
474
886
|
};
|
|
475
887
|
return null;
|
|
476
888
|
}
|
|
477
889
|
/** The credential a vision watch model still needs, or null when it has one (or needs none). */
|
|
478
890
|
export function missingWatchModelCredential(settings) {
|
|
891
|
+
const watchRoute = resolveModelRoute(settings, 'watch');
|
|
892
|
+
if (watchRoute !== null)
|
|
893
|
+
return watchRoute.missing;
|
|
479
894
|
const model = stripLikePython(settings.watch_model ?? '');
|
|
480
895
|
if (supportsVision('qwen', model)) {
|
|
481
|
-
return stripLikePython(settings.dashscope_api_key
|
|
482
|
-
?? (settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? settings.model_api_key : null) ?? '') === ''
|
|
483
|
-
? 'DASHSCOPE_API_KEY' : null;
|
|
896
|
+
return stripLikePython(settings.dashscope_api_key ?? '') === '' ? 'DASHSCOPE_API_KEY' : null;
|
|
484
897
|
}
|
|
898
|
+
if (supportsVision('deepseek', model))
|
|
899
|
+
return stripLikePython(settings.deepseek_api_key ?? '') === '' ? 'DEEPSEEK_API_KEY' : null;
|
|
485
900
|
if (supportsVision('ark', model))
|
|
486
901
|
return stripLikePython(settings.ark_api_key ?? '') === '' ? 'ARK_API_KEY' : null;
|
|
487
902
|
return null;
|
|
488
903
|
}
|
|
489
|
-
/**
|
|
904
|
+
/** Embedding credentials are independent of text and vision models. */
|
|
490
905
|
export function missingKnowledgeCredential(settings) {
|
|
491
|
-
|
|
906
|
+
const embeddingRoute = resolveModelRoute(settings, 'embedding');
|
|
907
|
+
if (embeddingRoute !== null)
|
|
908
|
+
return embeddingRoute.missing;
|
|
909
|
+
if (resolveEmbeddingConnection(settings).apiKey)
|
|
492
910
|
return null;
|
|
493
|
-
return settings.
|
|
911
|
+
return settings.embedding_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? 'DASHSCOPE_API_KEY' : 'EMBEDDING_API_KEY';
|
|
494
912
|
}
|
|
495
913
|
/** Camera watch and knowledge are optional: without their credential they are reported off rather than failing startup. */
|
|
496
914
|
export function withoutUncredentialedModules(registry, settings) {
|
|
@@ -504,23 +922,34 @@ export function withoutUncredentialedModules(registry, settings) {
|
|
|
504
922
|
...(knowledge === null ? {} : { knowledge: { enabled: false, exposeToCodex: false, reason: `missing_environment:${knowledge}` } }),
|
|
505
923
|
} };
|
|
506
924
|
}
|
|
925
|
+
/** Settings field holding each credential named by the shared voice-credential table. */
|
|
926
|
+
const VOICE_CREDENTIAL_FIELDS = Object.freeze({
|
|
927
|
+
DASHSCOPE_API_KEY: 'dashscope_api_key',
|
|
928
|
+
STEPFUN_API_KEY: 'stepfun_api_key',
|
|
929
|
+
OPENAI_API_KEY: 'openai_api_key',
|
|
930
|
+
GEMINI_API_KEY: 'gemini_api_key',
|
|
931
|
+
ARK_API_KEY: 'ark_api_key',
|
|
932
|
+
DEEPSEEK_API_KEY: 'deepseek_api_key',
|
|
933
|
+
OPENAI_COMPATIBLE_API_KEY: 'openai_compatible_api_key',
|
|
934
|
+
DOUBAO_BIGMODEL_API_KEY: 'doubao_bigmodel_api_key',
|
|
935
|
+
COMPATIBLE_ASR_API_KEY: 'compatible_asr_api_key',
|
|
936
|
+
COMPATIBLE_TTS_API_KEY: 'compatible_tts_api_key',
|
|
937
|
+
});
|
|
507
938
|
/** Mirrors requireIntegratedRealtime and requireCascadedCredentials without throwing, for first-run guidance. */
|
|
508
939
|
export function describeMissingBlockingCredentials(settings, textConversations = false) {
|
|
509
|
-
const present = (
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
...(textConversations || settings.cascade_tts_provider === 'self-hosted' ? [] : settings.cascade_tts_provider === 'gemini' ? (present(settings.gemini_api_key) ? [] : ['GEMINI_API_KEY']) : (present(settings.doubao_bigmodel_api_key) ? [] : ['DOUBAO_BIGMODEL_API_KEY'])),
|
|
523
|
-
])] };
|
|
940
|
+
const present = (name) => {
|
|
941
|
+
const field = VOICE_CREDENTIAL_FIELDS[name];
|
|
942
|
+
const value = field === undefined ? null : settings[field];
|
|
943
|
+
return typeof value === 'string' && stripLikePython(value) !== '';
|
|
944
|
+
};
|
|
945
|
+
const { pipeline, credentials } = requiredVoiceCredentials({
|
|
946
|
+
pipeline: settings.pipeline_mode,
|
|
947
|
+
integratedProvider: settings.integrated_provider,
|
|
948
|
+
asrProvider: settings.cascade_asr_provider,
|
|
949
|
+
llmProvider: settings.cascade_llm_provider,
|
|
950
|
+
ttsProvider: settings.cascade_tts_provider,
|
|
951
|
+
}, textConversations);
|
|
952
|
+
return { pipeline, missing: credentials.filter(name => !present(name)) };
|
|
524
953
|
}
|
|
525
954
|
/** Host preflight over a launch environment; other configuration errors stay the runtime's to report. */
|
|
526
955
|
export function describeMissingBlockingEnvironment(environment, textConversations = false) {
|
|
@@ -538,28 +967,11 @@ export function requireBlockingCredentials(settings) {
|
|
|
538
967
|
if (missing.length > 0)
|
|
539
968
|
throw new BlockingConfigurationError(pipeline, missing);
|
|
540
969
|
}
|
|
541
|
-
/** Keeps a selected provider credential on its fixed compatible endpoint. */
|
|
542
|
-
export function resolveSupportModelConnection(settings, selectedProvider) {
|
|
543
|
-
const genericKey = stripLikePython(settings.model_api_key ?? '');
|
|
544
|
-
return genericKey === ''
|
|
545
|
-
? Object.freeze({
|
|
546
|
-
source: 'selected_provider',
|
|
547
|
-
baseUrl: selectedProvider.baseUrl,
|
|
548
|
-
apiKey: selectedProvider.apiKey,
|
|
549
|
-
})
|
|
550
|
-
: Object.freeze({
|
|
551
|
-
source: 'generic',
|
|
552
|
-
baseUrl: secureEndpoint(settings.model_base_url, 'https', 'MODEL_BASE_URL'),
|
|
553
|
-
apiKey: genericKey,
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
970
|
export function resolveCascadedSelection(settings) {
|
|
557
|
-
if (
|
|
971
|
+
if (['self-hosted', 'openai-compatible'].includes(settings.cascade_llm_provider) && !settings.cascade_llm_model?.trim())
|
|
558
972
|
throw new ConfigurationError('缺少 CASCADE_LLM_MODEL');
|
|
559
973
|
const llmModel = settings.cascade_llm_model === null
|
|
560
|
-
? (settings.cascade_llm_provider
|
|
561
|
-
? 'qwen-plus'
|
|
562
|
-
: settings.cascade_llm_provider === 'openai' ? 'gpt-6-luna' : settings.cascade_llm_provider === 'gemini' ? 'gemini-3.5-flash-lite' : settings.cascade_llm_provider === 'deepseek' ? 'deepseek-flash' : 'doubao-seed-2-0-pro-260215')
|
|
974
|
+
? defaultCascadedLlmModel(settings.cascade_llm_provider)
|
|
563
975
|
: requiredSetting(settings.cascade_llm_model, 'CASCADE_LLM_MODEL');
|
|
564
976
|
return Object.freeze({
|
|
565
977
|
endpointingProvider: settings.cascade_endpointing_provider,
|
|
@@ -572,21 +984,18 @@ export function resolveCascadedSelection(settings) {
|
|
|
572
984
|
export function requireCascadedCredentials(settings, selection) {
|
|
573
985
|
const field = cascadedCredentialField(selection.llmProvider);
|
|
574
986
|
const llmApiKey = selection.llmProvider === 'self-hosted' ? stripLikePython(settings.self_hosted_llm_api_key ?? '') : requiredCredential(settings[field], field.toUpperCase());
|
|
575
|
-
const ttsApiKey = selection.ttsProvider === 'self-hosted' ? stripLikePython(settings.self_hosted_tts_api_key ?? '') : selection.ttsProvider === 'gemini' ? requiredCredential(settings.gemini_api_key, 'GEMINI_API_KEY') : requiredCredential(settings.doubao_bigmodel_api_key, 'DOUBAO_BIGMODEL_API_KEY');
|
|
576
|
-
const asrApiKey = selection.asrProvider === 'self-hosted' ? stripLikePython(settings.self_hosted_asr_api_key ?? '') : selection.asrProvider === '
|
|
987
|
+
const ttsApiKey = selection.ttsProvider === 'self-hosted' ? stripLikePython(settings.self_hosted_tts_api_key ?? '') : selection.ttsProvider === 'openai-compatible' ? requiredCredential(settings.compatible_tts_api_key, 'COMPATIBLE_TTS_API_KEY') : selection.ttsProvider === 'gemini' ? requiredCredential(settings.gemini_api_key, 'GEMINI_API_KEY') : requiredCredential(settings.doubao_bigmodel_api_key, 'DOUBAO_BIGMODEL_API_KEY');
|
|
988
|
+
const asrApiKey = selection.asrProvider === 'self-hosted' ? stripLikePython(settings.self_hosted_asr_api_key ?? '') : selection.asrProvider === 'openai-compatible' ? requiredCredential(settings.compatible_asr_api_key, 'COMPATIBLE_ASR_API_KEY') : selection.asrProvider === 'gemini' ? requiredCredential(settings.gemini_api_key, 'GEMINI_API_KEY') : requiredCredential(settings.doubao_bigmodel_api_key, 'DOUBAO_BIGMODEL_API_KEY');
|
|
577
989
|
return Object.freeze({ llmApiKey, asrApiKey, ttsApiKey });
|
|
578
990
|
}
|
|
579
991
|
export function requireVolcengineRealtime(settings) {
|
|
580
992
|
const arkApiKey = stripLikePython(settings.ark_api_key ?? '');
|
|
581
993
|
const ttsApiKey = stripLikePython(settings.doubao_bigmodel_api_key ?? '');
|
|
582
|
-
const asrApiKey =
|
|
994
|
+
const asrApiKey = ttsApiKey;
|
|
583
995
|
if (arkApiKey === '')
|
|
584
996
|
throw new ConfigurationError('缺少 ARK_API_KEY');
|
|
585
997
|
if (ttsApiKey === '')
|
|
586
998
|
throw new ConfigurationError('缺少 DOUBAO_BIGMODEL_API_KEY');
|
|
587
|
-
if (asrApiKey === '') {
|
|
588
|
-
throw new ConfigurationError('缺少 DOUBAO_ASR_API_KEY 或 DOUBAO_BIGMODEL_API_KEY');
|
|
589
|
-
}
|
|
590
999
|
if (settings.doubao_asr_chunk_ms <= 0) {
|
|
591
1000
|
throw new ConfigurationError('DOUBAO_ASR_CHUNK_MS 必须为正整数');
|
|
592
1001
|
}
|
|
@@ -642,6 +1051,7 @@ const EXECUTOR_OWNED_SETTINGS = {
|
|
|
642
1051
|
codex_project_state_root: optionalString(environment.CODEX_PROJECT_STATE_ROOT),
|
|
643
1052
|
codex_working_interval: optionalPydanticFloat(environment.CODEX_WORKING_INTERVAL),
|
|
644
1053
|
codex_approval_mode: parseExecutorApprovalMode(environment.CODEX_APPROVAL_MODE),
|
|
1054
|
+
local_tool_approval: environment.NOVA_LOCAL_TOOL_APPROVAL,
|
|
645
1055
|
}),
|
|
646
1056
|
};
|
|
647
1057
|
function executorOwnedSettings(environment, executors) {
|
|
@@ -681,7 +1091,7 @@ function parseCascadedAsrProvider(value) {
|
|
|
681
1091
|
return parseSelector(cascadedAsrProviderNameSchema, value, 'volcengine', 'CASCADE_ASR_PROVIDER');
|
|
682
1092
|
}
|
|
683
1093
|
function parseCascadedLlmProvider(value) {
|
|
684
|
-
return parseSelector(cascadedLlmProviderNameSchema, value,
|
|
1094
|
+
return parseSelector(cascadedLlmProviderNameSchema, value, DEFAULT_CASCADED_LLM_PROVIDER, 'CASCADE_LLM_PROVIDER');
|
|
685
1095
|
}
|
|
686
1096
|
function parseCascadedTtsProvider(value) {
|
|
687
1097
|
return parseSelector(cascadedTtsProviderNameSchema, value, 'volcengine', 'CASCADE_TTS_PROVIDER');
|
|
@@ -719,6 +1129,10 @@ function optionalString(value) {
|
|
|
719
1129
|
return undefined;
|
|
720
1130
|
return stripLikePython(value);
|
|
721
1131
|
}
|
|
1132
|
+
function optionalNonEmptyString(value) {
|
|
1133
|
+
const parsed = optionalString(value);
|
|
1134
|
+
return parsed === '' ? undefined : parsed;
|
|
1135
|
+
}
|
|
722
1136
|
function optionalJsonStringArray(value) {
|
|
723
1137
|
if (value === undefined)
|
|
724
1138
|
return undefined;
|
|
@@ -786,7 +1200,7 @@ function emptyAsUnset(value) {
|
|
|
786
1200
|
function rawEnvironmentValue(value) {
|
|
787
1201
|
return value;
|
|
788
1202
|
}
|
|
789
|
-
function requiredSetting(value, name) {
|
|
1203
|
+
export function requiredSetting(value, name) {
|
|
790
1204
|
const normalized = stripLikePython(value);
|
|
791
1205
|
if (normalized === '')
|
|
792
1206
|
throw new ConfigurationError(`${name} 不能为空`);
|
|
@@ -829,7 +1243,6 @@ function configurationFieldName(field) {
|
|
|
829
1243
|
ark_api_key: 'ARK_API_KEY',
|
|
830
1244
|
deepseek_api_key: 'DEEPSEEK_API_KEY',
|
|
831
1245
|
dashscope_api_key: 'DASHSCOPE_API_KEY',
|
|
832
|
-
doubao_asr_api_key: 'DOUBAO_ASR_API_KEY',
|
|
833
1246
|
doubao_bigmodel_api_key: 'DOUBAO_BIGMODEL_API_KEY',
|
|
834
1247
|
tavily_api_key: 'TAVILY_API_KEY',
|
|
835
1248
|
openrouter_api_key: 'OPENROUTER_API_KEY',
|
|
@@ -852,6 +1265,6 @@ export function capabilitiesFromSettings(settings) {
|
|
|
852
1265
|
}), settings);
|
|
853
1266
|
}
|
|
854
1267
|
export function cascadedCredentialField(provider) {
|
|
855
|
-
return provider === 'self-hosted' ? 'self_hosted_llm_api_key' : provider === 'qwen' ? 'dashscope_api_key' : `${provider}_api_key`;
|
|
1268
|
+
return provider === 'openai-compatible' ? 'openai_compatible_api_key' : provider === 'self-hosted' ? 'self_hosted_llm_api_key' : provider === 'qwen' ? 'dashscope_api_key' : `${provider}_api_key`;
|
|
856
1269
|
}
|
|
857
1270
|
//# sourceMappingURL=config.js.map
|