nova-personal-agent-server 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +30 -2
  3. package/bin/novapersonal-server.mjs +4 -0
  4. package/package.json +61 -4
  5. package/resources/endpointing/volcengine-v1/LICENSE.silero-vad.txt +21 -0
  6. package/resources/endpointing/volcengine-v1/MANIFEST.json +31 -0
  7. package/resources/endpointing/volcengine-v1/silence-16k-s16le.pcm +0 -0
  8. package/resources/endpointing/volcengine-v1/speech-16k-s16le.pcm +0 -0
  9. package/resources/native/codex-sandbox-probe +0 -0
  10. package/resources/native/project-native/nova_project_native.node +0 -0
  11. package/resources/native-resources-v1.json +1 -0
  12. package/runtime/dist/eval/demos.js +156 -0
  13. package/runtime/dist/eval/fixture-host.js +385 -0
  14. package/runtime/dist/eval/fixtures.js +319 -0
  15. package/runtime/dist/eval/realtime/session-fixtures.js +474 -0
  16. package/runtime/dist/eval/scorecard.js +285 -0
  17. package/runtime/dist/eval/sim.js +43 -0
  18. package/runtime/dist/src/cascaded-text-provider.js +31 -0
  19. package/runtime/dist/src/cli.js +96 -0
  20. package/runtime/dist/src/composition/assembly.js +352 -0
  21. package/runtime/dist/src/composition/cascaded-realtime-assembly.js +455 -0
  22. package/runtime/dist/src/composition/production-composition.js +389 -0
  23. package/runtime/dist/src/composition/realtime-assembly.js +1330 -0
  24. package/runtime/dist/src/config/capability-registry.js +315 -0
  25. package/runtime/dist/src/config/cascaded-realtime-config.js +146 -0
  26. package/runtime/dist/src/config/coding-backends.js +8 -0
  27. package/runtime/dist/src/config/coding-profiles.js +98 -0
  28. package/runtime/dist/src/config/config.js +857 -0
  29. package/runtime/dist/src/config/diagnostics.js +139 -0
  30. package/runtime/dist/src/config/environment-contract.js +202 -0
  31. package/runtime/dist/src/config/self-hosted.js +23 -0
  32. package/runtime/dist/src/connectors/composio/client.js +195 -0
  33. package/runtime/dist/src/connectors/composio/google.js +208 -0
  34. package/runtime/dist/src/connectors/composio/index.js +334 -0
  35. package/runtime/dist/src/connectors/feishu/cli.js +220 -0
  36. package/runtime/dist/src/connectors/feishu/index.js +980 -0
  37. package/runtime/dist/src/connectors/macos/calendar.js +35 -0
  38. package/runtime/dist/src/connectors/macos/mail.js +32 -0
  39. package/runtime/dist/src/connectors/macos/reader.js +62 -0
  40. package/runtime/dist/src/conversation-voice-provider.js +41 -0
  41. package/runtime/dist/src/core/approval-port.js +9 -0
  42. package/runtime/dist/src/core/approval.js +1328 -0
  43. package/runtime/dist/src/core/calls.js +35 -0
  44. package/runtime/dist/src/core/camera-session.js +32 -0
  45. package/runtime/dist/src/core/causal-runtime.js +650 -0
  46. package/runtime/dist/src/core/clock.js +139 -0
  47. package/runtime/dist/src/core/context-view.js +156 -0
  48. package/runtime/dist/src/core/effects.js +62 -0
  49. package/runtime/dist/src/core/events.js +217 -0
  50. package/runtime/dist/src/core/executor-diagnostic.js +9 -0
  51. package/runtime/dist/src/core/ids.js +32 -0
  52. package/runtime/dist/src/core/media-store.js +104 -0
  53. package/runtime/dist/src/core/memory.js +296 -0
  54. package/runtime/dist/src/core/pending-decision.js +64 -0
  55. package/runtime/dist/src/core/ports.js +125 -0
  56. package/runtime/dist/src/core/runtime.js +1459 -0
  57. package/runtime/dist/src/core/schedule-tools.js +15 -0
  58. package/runtime/dist/src/core/sims.js +186 -0
  59. package/runtime/dist/src/core/slots.js +97 -0
  60. package/runtime/dist/src/core/source-processing-instructions.js +3 -0
  61. package/runtime/dist/src/core/source-processing-tools.js +12 -0
  62. package/runtime/dist/src/core/suggestions.js +143 -0
  63. package/runtime/dist/src/core/task-tools.js +22 -0
  64. package/runtime/dist/src/core/tool-schema.js +212 -0
  65. package/runtime/dist/src/core/trace.js +34 -0
  66. package/runtime/dist/src/core/work-tools.js +94 -0
  67. package/runtime/dist/src/desktop/desktop-camera-source.js +31 -0
  68. package/runtime/dist/src/desktop/desktop-camera.js +281 -0
  69. package/runtime/dist/src/desktop/desktop-control.js +140 -0
  70. package/runtime/dist/src/desktop/desktop-progress.js +162 -0
  71. package/runtime/dist/src/desktop/desktop-session.js +2106 -0
  72. package/runtime/dist/src/desktop/desktop-tasks.js +80 -0
  73. package/runtime/dist/src/desktop/desktop-wire.js +605 -0
  74. package/runtime/dist/src/desktop/phone-desktop-entry.js +17 -0
  75. package/runtime/dist/src/desktop/startup-error.js +18 -0
  76. package/runtime/dist/src/desktop/workbench-acceptance.js +262 -0
  77. package/runtime/dist/src/desktop-entry.js +106 -0
  78. package/runtime/dist/src/desktop.js +1092 -0
  79. package/runtime/dist/src/executors/acp/backends.js +105 -0
  80. package/runtime/dist/src/executors/acp/mcp.js +81 -0
  81. package/runtime/dist/src/executors/acp/preflight.js +14 -0
  82. package/runtime/dist/src/executors/acp/process-owner.js +112 -0
  83. package/runtime/dist/src/executors/acp/transport.js +760 -0
  84. package/runtime/dist/src/executors/acp/windows-launch.js +68 -0
  85. package/runtime/dist/src/executors/agent-controller.js +244 -0
  86. package/runtime/dist/src/executors/autoglm.js +376 -0
  87. package/runtime/dist/src/executors/browser-device.js +102 -0
  88. package/runtime/dist/src/executors/browser.js +61 -0
  89. package/runtime/dist/src/executors/camera.js +101 -0
  90. package/runtime/dist/src/executors/chromium-frame-source.js +173 -0
  91. package/runtime/dist/src/executors/codex/adapter-live.js +292 -0
  92. package/runtime/dist/src/executors/codex/adapter-project.js +1306 -0
  93. package/runtime/dist/src/executors/codex/app-server-schema.js +712 -0
  94. package/runtime/dist/src/executors/codex/app-server-transport.js +1798 -0
  95. package/runtime/dist/src/executors/codex/approval-protocol.js +439 -0
  96. package/runtime/dist/src/executors/codex/common.js +655 -0
  97. package/runtime/dist/src/executors/codex/contract.js +581 -0
  98. package/runtime/dist/src/executors/codex/controller.js +141 -0
  99. package/runtime/dist/src/executors/codex/credential-snapshot.js +195 -0
  100. package/runtime/dist/src/executors/codex/factory.js +463 -0
  101. package/runtime/dist/src/executors/codex/host-config.js +238 -0
  102. package/runtime/dist/src/executors/codex/host.js +17 -0
  103. package/runtime/dist/src/executors/codex/index.js +19 -0
  104. package/runtime/dist/src/executors/codex/launch-profile.js +37 -0
  105. package/runtime/dist/src/executors/codex/local-sessions.js +119 -0
  106. package/runtime/dist/src/executors/codex/managed-mcp.js +196 -0
  107. package/runtime/dist/src/executors/codex/process-owner.js +398 -0
  108. package/runtime/dist/src/executors/codex/production-host.js +887 -0
  109. package/runtime/dist/src/executors/codex/progress-instructions.js +10 -0
  110. package/runtime/dist/src/executors/codex/protocol.js +581 -0
  111. package/runtime/dist/src/executors/codex/safe-json.js +87 -0
  112. package/runtime/dist/src/executors/codex/session-title.js +61 -0
  113. package/runtime/dist/src/executors/codex/shared-home.js +29 -0
  114. package/runtime/dist/src/executors/codex/spawn-env.js +162 -0
  115. package/runtime/dist/src/executors/codex/turn-projection.js +435 -0
  116. package/runtime/dist/src/executors/codex/version.js +38 -0
  117. package/runtime/dist/src/executors/codex/windows-guardian.js +716 -0
  118. package/runtime/dist/src/executors/coding/intake-model.js +103 -0
  119. package/runtime/dist/src/executors/coding/intake.js +824 -0
  120. package/runtime/dist/src/executors/coding/json-completion.js +14 -0
  121. package/runtime/dist/src/executors/coding/target-resolution.js +61 -0
  122. package/runtime/dist/src/executors/coding/work-order.js +50 -0
  123. package/runtime/dist/src/executors/coding-executor.js +23 -0
  124. package/runtime/dist/src/executors/computer-backend.js +188 -0
  125. package/runtime/dist/src/executors/computer-device.js +187 -0
  126. package/runtime/dist/src/executors/computer-worker.js +125 -0
  127. package/runtime/dist/src/executors/computer.js +100 -0
  128. package/runtime/dist/src/executors/device-lock.js +127 -0
  129. package/runtime/dist/src/executors/frame-source.js +29 -0
  130. package/runtime/dist/src/executors/gui-evidence.js +30 -0
  131. package/runtime/dist/src/executors/gui-execution.js +237 -0
  132. package/runtime/dist/src/executors/gui-runner.js +88 -0
  133. package/runtime/dist/src/executors/host-executor-capability.js +12 -0
  134. package/runtime/dist/src/executors/index.js +13 -0
  135. package/runtime/dist/src/executors/mcp-client.js +198 -0
  136. package/runtime/dist/src/executors/mcp.js +210 -0
  137. package/runtime/dist/src/executors/mobile-android.js +180 -0
  138. package/runtime/dist/src/executors/mobile-ios.js +303 -0
  139. package/runtime/dist/src/executors/mobile.js +78 -0
  140. package/runtime/dist/src/executors/search-mcp.js +146 -0
  141. package/runtime/dist/src/executors/search.js +524 -0
  142. package/runtime/dist/src/executors/task-resources.js +38 -0
  143. package/runtime/dist/src/executors/vision/assess.js +296 -0
  144. package/runtime/dist/src/executors/vision/controller-core.js +373 -0
  145. package/runtime/dist/src/executors/vision/controller.js +164 -0
  146. package/runtime/dist/src/executors/vision/lifecycle.js +69 -0
  147. package/runtime/dist/src/executors/vision.js +5 -0
  148. package/runtime/dist/src/executors/watcher.js +718 -0
  149. package/runtime/dist/src/http/bounded-response.js +37 -0
  150. package/runtime/dist/src/index.js +56 -0
  151. package/runtime/dist/src/knowledge/assembly.js +60 -0
  152. package/runtime/dist/src/knowledge/documents.js +520 -0
  153. package/runtime/dist/src/knowledge/embeddings.js +201 -0
  154. package/runtime/dist/src/knowledge/mcp.js +218 -0
  155. package/runtime/dist/src/knowledge/parse-worker.js +122 -0
  156. package/runtime/dist/src/knowledge/references.js +51 -0
  157. package/runtime/dist/src/knowledge/service.js +526 -0
  158. package/runtime/dist/src/knowledge/store-client.js +185 -0
  159. package/runtime/dist/src/knowledge/store-worker.js +843 -0
  160. package/runtime/dist/src/knowledge/types.js +2 -0
  161. package/runtime/dist/src/mcp/http-server.js +177 -0
  162. package/runtime/dist/src/mem0/resource.js +35 -0
  163. package/runtime/dist/src/mem0/store-worker.js +330 -0
  164. package/runtime/dist/src/memory/blackboard-session.js +205 -0
  165. package/runtime/dist/src/memory/blackboard-store.js +194 -0
  166. package/runtime/dist/src/memory/blackboard-worker.js +369 -0
  167. package/runtime/dist/src/memory/entry.js +39 -0
  168. package/runtime/dist/src/memory/factory.js +20 -0
  169. package/runtime/dist/src/memory/personal-memory-inspection.js +18 -0
  170. package/runtime/dist/src/memory/personal-memory.js +10 -0
  171. package/runtime/dist/src/memory/prerecall.js +20 -0
  172. package/runtime/dist/src/memory/provenance.js +17 -0
  173. package/runtime/dist/src/memory/remote-personal-memory.js +194 -0
  174. package/runtime/dist/src/memory/retrieval.js +235 -0
  175. package/runtime/dist/src/memory/sensitivity.js +261 -0
  176. package/runtime/dist/src/memory-ledger/models.js +98 -0
  177. package/runtime/dist/src/memory-ledger/store-client.js +210 -0
  178. package/runtime/dist/src/memory-ledger/store-worker.js +130 -0
  179. package/runtime/dist/src/memory-ledger/store.js +597 -0
  180. package/runtime/dist/src/memory-substrate/candidates.js +16 -0
  181. package/runtime/dist/src/memory-substrate/consolidation.js +124 -0
  182. package/runtime/dist/src/memory-substrate/file-authority.js +111 -0
  183. package/runtime/dist/src/memory-substrate/life-operations.js +280 -0
  184. package/runtime/dist/src/memory-substrate/markdown-repository.js +610 -0
  185. package/runtime/dist/src/memory-substrate/migration.js +87 -0
  186. package/runtime/dist/src/memory-substrate/profile-source-input.js +9 -0
  187. package/runtime/dist/src/memory-substrate/purge.js +398 -0
  188. package/runtime/dist/src/memory-substrate/resolution.js +32 -0
  189. package/runtime/dist/src/memory-substrate/resource.js +867 -0
  190. package/runtime/dist/src/memory-substrate/retrieval.js +85 -0
  191. package/runtime/dist/src/memory-substrate/source-operations.js +306 -0
  192. package/runtime/dist/src/memory-substrate/source-processing.js +326 -0
  193. package/runtime/dist/src/memory-substrate/source-state.js +93 -0
  194. package/runtime/dist/src/memory-substrate/store.js +534 -0
  195. package/runtime/dist/src/memory-substrate/workspace-projections.js +106 -0
  196. package/runtime/dist/src/memory-substrate/workspace.js +21 -0
  197. package/runtime/dist/src/model/jev-client.js +25 -0
  198. package/runtime/dist/src/model/model-adapters.js +64 -0
  199. package/runtime/dist/src/model/model-gateway.js +399 -0
  200. package/runtime/dist/src/model/model-lane.js +34 -0
  201. package/runtime/dist/src/model/model-purpose.js +5 -0
  202. package/runtime/dist/src/model/personal-writer.js +361 -0
  203. package/runtime/dist/src/model/proactivity.js +72 -0
  204. package/runtime/dist/src/model/prompting.js +279 -0
  205. package/runtime/dist/src/model/task-verifier.js +217 -0
  206. package/runtime/dist/src/model/vision-capability.js +10 -0
  207. package/runtime/dist/src/news/feeds.js +114 -0
  208. package/runtime/dist/src/news/jev-ranking.js +25 -0
  209. package/runtime/dist/src/news/ranking.js +26 -0
  210. package/runtime/dist/src/news/service.js +262 -0
  211. package/runtime/dist/src/notifications/adapters/feishu.js +10 -0
  212. package/runtime/dist/src/notifications/adapters/nova.js +15 -0
  213. package/runtime/dist/src/notifications/content.js +15 -0
  214. package/runtime/dist/src/notifications/contracts.js +9 -0
  215. package/runtime/dist/src/notifications/feed.js +8 -0
  216. package/runtime/dist/src/notifications/service.js +412 -0
  217. package/runtime/dist/src/notifications/store.js +4 -0
  218. package/runtime/dist/src/personal-agent/app-context.js +113 -0
  219. package/runtime/dist/src/personal-agent/approval-scope.js +8 -0
  220. package/runtime/dist/src/personal-agent/coding-targets.js +82 -0
  221. package/runtime/dist/src/personal-agent/context-candidates.js +94 -0
  222. package/runtime/dist/src/personal-agent/contracts.js +32 -0
  223. package/runtime/dist/src/personal-agent/conversation-runtime.js +536 -0
  224. package/runtime/dist/src/personal-agent/conversations.js +187 -0
  225. package/runtime/dist/src/personal-agent/daily-brief.js +53 -0
  226. package/runtime/dist/src/personal-agent/host.js +2403 -0
  227. package/runtime/dist/src/personal-agent/intake-task.js +37 -0
  228. package/runtime/dist/src/personal-agent/life.js +260 -0
  229. package/runtime/dist/src/personal-agent/memory-overview.js +19 -0
  230. package/runtime/dist/src/personal-agent/profile-sources.js +34 -0
  231. package/runtime/dist/src/personal-agent/profile-warmup.js +244 -0
  232. package/runtime/dist/src/personal-agent/project-digests.js +242 -0
  233. package/runtime/dist/src/personal-agent/sampling.js +20 -0
  234. package/runtime/dist/src/personal-agent/schedule-agent.js +60 -0
  235. package/runtime/dist/src/personal-agent/schedule-api.js +61 -0
  236. package/runtime/dist/src/personal-agent/schedule-presets.js +13 -0
  237. package/runtime/dist/src/personal-agent/schedule-reference.js +3 -0
  238. package/runtime/dist/src/personal-agent/scheduled-response-scope.js +38 -0
  239. package/runtime/dist/src/personal-agent/scheduled-run-authority.js +44 -0
  240. package/runtime/dist/src/personal-agent/scheduled-tasks.js +280 -0
  241. package/runtime/dist/src/personal-agent/scheduled-time.js +99 -0
  242. package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +109 -0
  243. package/runtime/dist/src/personal-agent/source-priority.js +142 -0
  244. package/runtime/dist/src/personal-agent/source-processing-agent.js +158 -0
  245. package/runtime/dist/src/personal-agent/source-walk.js +25 -0
  246. package/runtime/dist/src/personal-agent/sources.js +1484 -0
  247. package/runtime/dist/src/personal-agent/store-lock-worker.js +17 -0
  248. package/runtime/dist/src/personal-agent/store.js +146 -0
  249. package/runtime/dist/src/personal-agent/task-loop.js +163 -0
  250. package/runtime/dist/src/personal-agent/tasks.js +920 -0
  251. package/runtime/dist/src/personal-agent/turn-deadline.js +55 -0
  252. package/runtime/dist/src/personal-agent/understanding.js +160 -0
  253. package/runtime/dist/src/personal-agent/workbench-context.js +239 -0
  254. package/runtime/dist/src/projects/confirmed-project-capability.js +60 -0
  255. package/runtime/dist/src/projects/host-paths.js +133 -0
  256. package/runtime/dist/src/projects/managed-workspace-maintenance.js +351 -0
  257. package/runtime/dist/src/projects/project-confirmation.js +486 -0
  258. package/runtime/dist/src/projects/project-native-resource.js +284 -0
  259. package/runtime/dist/src/projects/project-node-files.js +169 -0
  260. package/runtime/dist/src/projects/project-root-file.js +16 -0
  261. package/runtime/dist/src/projects/project-state.js +504 -0
  262. package/runtime/dist/src/projects/project-store-files.js +1271 -0
  263. package/runtime/dist/src/projects/project-store.js +1345 -0
  264. package/runtime/dist/src/realtime/aoq.js +141 -0
  265. package/runtime/dist/src/realtime/bridge.js +652 -0
  266. package/runtime/dist/src/realtime/cascaded/adapter.js +1669 -0
  267. package/runtime/dist/src/realtime/cascaded/ark-llm.js +219 -0
  268. package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +478 -0
  269. package/runtime/dist/src/realtime/cascaded/gemini-speech.js +232 -0
  270. package/runtime/dist/src/realtime/cascaded/llm.js +37 -0
  271. package/runtime/dist/src/realtime/cascaded/ports.js +2 -0
  272. package/runtime/dist/src/realtime/cascaded/provider.js +216 -0
  273. package/runtime/dist/src/realtime/cascaded/qwen-llm.js +7 -0
  274. package/runtime/dist/src/realtime/cascaded/self-hosted-asr.js +110 -0
  275. package/runtime/dist/src/realtime/cascaded/self-hosted-tts.js +137 -0
  276. package/runtime/dist/src/realtime/cascaded/transcribe.js +42 -0
  277. package/runtime/dist/src/realtime/coding-progress-narration.js +28 -0
  278. package/runtime/dist/src/realtime/confirmation-turn-isolation.js +586 -0
  279. package/runtime/dist/src/realtime/dictation.js +28 -0
  280. package/runtime/dist/src/realtime/evidence.js +276 -0
  281. package/runtime/dist/src/realtime/floor.js +43 -0
  282. package/runtime/dist/src/realtime/frontend-instructions.js +195 -0
  283. package/runtime/dist/src/realtime/gemini.js +517 -0
  284. package/runtime/dist/src/realtime/history.js +122 -0
  285. package/runtime/dist/src/realtime/host-delivery.js +1711 -0
  286. package/runtime/dist/src/realtime/integrated-wire-profile.js +128 -0
  287. package/runtime/dist/src/realtime/memory-board.js +105 -0
  288. package/runtime/dist/src/realtime/openai-wire-profile.js +46 -0
  289. package/runtime/dist/src/realtime/playback.js +242 -0
  290. package/runtime/dist/src/realtime/project-confirmation-flow.js +1428 -0
  291. package/runtime/dist/src/realtime/prompt-language.js +17 -0
  292. package/runtime/dist/src/realtime/protocol.js +428 -0
  293. package/runtime/dist/src/realtime/provider-projection.js +526 -0
  294. package/runtime/dist/src/realtime/provider-session.js +491 -0
  295. package/runtime/dist/src/realtime/qwen-transport.js +144 -0
  296. package/runtime/dist/src/realtime/qwen.js +1377 -0
  297. package/runtime/dist/src/realtime/recall.js +341 -0
  298. package/runtime/dist/src/realtime/service-ports.js +8 -0
  299. package/runtime/dist/src/realtime/service-state.js +259 -0
  300. package/runtime/dist/src/realtime/service.js +1726 -0
  301. package/runtime/dist/src/realtime/session-state.js +684 -0
  302. package/runtime/dist/src/realtime/session.js +1976 -0
  303. package/runtime/dist/src/realtime/speech-prep.js +63 -0
  304. package/runtime/dist/src/realtime/streaming-speech.js +120 -0
  305. package/runtime/dist/src/realtime/system-prompts.en.js +136 -0
  306. package/runtime/dist/src/realtime/telemetry.js +144 -0
  307. package/runtime/dist/src/realtime/tool-continuations.js +1510 -0
  308. package/runtime/dist/src/realtime/transport.js +8 -0
  309. package/runtime/dist/src/realtime/usage.js +55 -0
  310. package/runtime/dist/src/realtime/user-origin-binding.js +173 -0
  311. package/runtime/dist/src/realtime/volcengine/ark.js +428 -0
  312. package/runtime/dist/src/realtime/volcengine/asr.js +573 -0
  313. package/runtime/dist/src/realtime/volcengine/audio.js +39 -0
  314. package/runtime/dist/src/realtime/volcengine/endpointing-capability.js +834 -0
  315. package/runtime/dist/src/realtime/volcengine/livekit-endpointing.js +714 -0
  316. package/runtime/dist/src/realtime/volcengine/local-eot-executor.js +33 -0
  317. package/runtime/dist/src/realtime/volcengine/protocol.js +247 -0
  318. package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +237 -0
  319. package/runtime/dist/src/realtime/volcengine/tts.js +444 -0
  320. package/runtime/dist/src/realtime/volcengine/websocket.js +293 -0
  321. package/runtime/dist/src/server/aoq-chat-server.js +497 -0
  322. package/runtime/dist/src/server/client-pairing.js +192 -0
  323. package/runtime/dist/src/server/client-protocol.js +87 -0
  324. package/runtime/dist/src/server/client-server.js +312 -0
  325. package/runtime/dist/src/server/server-config.js +72 -0
  326. package/runtime/dist/src/server-entry.js +135 -0
  327. package/runtime/dist/src/storage/bounded-json.js +63 -0
  328. package/runtime/dist/src/storage/native-file-lock.js +8 -0
  329. package/runtime/dist/src/storage/native-resource-snapshot.js +41 -0
  330. package/runtime/dist/src/storage/private-database.js +120 -0
  331. package/runtime/dist/src/text/canonical-json.js +60 -0
  332. package/runtime/dist/src/text/python-number.js +18 -0
  333. package/runtime/dist/src/text/python-text.js +92 -0
  334. package/runtime/dist/src/text/unicode-casefold.js +29 -0
  335. package/runtime/dist/src/text/unicode-normalize.js +138 -0
  336. package/runtime/dist/src/text/unicode-tables.js +210 -0
  337. package/runtime/dist/src/understanding/candidates.js +77 -0
  338. package/runtime/dist/src/understanding/fixture.js +7 -0
  339. package/runtime/dist/src/understanding/jev.js +20 -0
  340. package/runtime/dist/src/understanding/pipeline.js +38 -0
  341. package/runtime/dist/src/voicemem/store-client.js +476 -0
  342. package/runtime/dist/src/voicemem/store-worker.js +380 -0
  343. package/runtime/dist/src/voicemem/versioned-memory.js +170 -0
  344. package/runtime/scripts/pair-device.mjs +109 -0
  345. package/src/command.mjs +48 -0
@@ -0,0 +1,857 @@
1
+ import { parseCapabilityRegistry } from './capability-registry.js';
2
+ import { CODING_BACKEND_IDS } from './coding-backends.js';
3
+ import { z } from 'zod';
4
+ import { stripLikePython } from '../text/python-text.js';
5
+ import { supportsVision } from '../model/vision-capability.js';
6
+ export const proactivityPresetSchema = z.enum(['conservative', 'balanced', 'eager']);
7
+ const pipelineModeSchema = z.enum(['integrated', 'cascaded']);
8
+ const promptLanguageSchema = z.enum(['zh-CN', 'en']);
9
+ const integratedProviderNameSchema = z.enum(['qwen', 'stepfun', 'openai', 'gemini']);
10
+ const cascadedEndpointingProviderNameSchema = z.enum(['auto']);
11
+ const cascadedAsrProviderNameSchema = z.enum(['volcengine', 'gemini', 'self-hosted']);
12
+ const cascadedLlmProviderNameSchema = z.enum(['qwen', 'ark', 'deepseek', 'openai', 'gemini', 'self-hosted']);
13
+ const cascadedTtsProviderNameSchema = z.enum(['volcengine', 'gemini', 'self-hosted']);
14
+ const qwenGuardHistoryRecoverySchema = z.enum(['none', 'packed']);
15
+ const qwenGuardHistoryPairsSchema = z.union([z.literal(1), z.literal(2), z.literal(4)]);
16
+ /** Validity of a name is decided by assembly (`resolveExecutors`), which knows the registered adapters. */
17
+ const executorNameSchema = z.string().min(1);
18
+ const executorApprovalModeSchema = z.enum(['ask', 'yolo']);
19
+ const clarificationDepthSchema = z.enum(['minimal', 'balanced', 'thorough']);
20
+ const planReadbackSchema = z.enum(['summary', 'confirm', 'silent']);
21
+ const progressBubblesSchema = z.enum(['off', 'milestones', 'all']);
22
+ const embeddingProviderSchema = z.enum(['dashscope']);
23
+ const memoryConnectionSchema = z.enum(['disabled', 'local', 'remote']);
24
+ const searchProviderSchema = z.enum(['mcp', 'tavily']);
25
+ 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
+ const STEPFUN_SUPPORT_MODEL = 'step-3.7-flash';
31
+ export const settingsSchema = z.object({
32
+ model_base_url: z.url().default(DASHSCOPE_COMPATIBLE_BASE_URL),
33
+ model_api_key: z.string().nullable().default(null),
34
+ openrouter_api_key: z.string().nullable().default(null),
35
+ tavily_api_key: z.string().nullable().default(null),
36
+ fast_model: z.string().default('qwen3-vl-plus'),
37
+ watch_model: z.string().nullable().default(null),
38
+ conversation_vision_enabled: z.boolean().default(false),
39
+ monitor_camera_device_id: z.string().max(256).refine(value => !/[\x00-\x1f]/u.test(value)).default(''),
40
+ support_model: z.string().default('qwen-plus'),
41
+ compressor_model: z.string().default('qwen-flash'),
42
+ language: promptLanguageSchema.default('zh-CN'),
43
+ news_language: promptLanguageSchema.default('en'),
44
+ pipeline_mode: pipelineModeSchema.default('integrated'),
45
+ integrated_provider: integratedProviderNameSchema.default('qwen'),
46
+ cascade_endpointing_provider: cascadedEndpointingProviderNameSchema.default('auto'),
47
+ cascade_asr_provider: cascadedAsrProviderNameSchema.default('volcengine'),
48
+ cascade_llm_provider: cascadedLlmProviderNameSchema.default('deepseek'),
49
+ cascade_llm_model: z.string().nullable().default(null),
50
+ self_hosted_asr_url: z.string().default(''),
51
+ self_hosted_llm_base_url: z.string().default(''),
52
+ self_hosted_tts_url: z.string().default(''),
53
+ self_hosted_asr_api_key: z.string().nullable().default(null),
54
+ self_hosted_llm_api_key: z.string().nullable().default(null),
55
+ self_hosted_tts_api_key: z.string().nullable().default(null),
56
+ cascade_tts_provider: cascadedTtsProviderNameSchema.default('volcengine'),
57
+ camera_module_enabled: z.boolean().default(true),
58
+ qwen_realtime_url: z.string().default('wss://dashscope.aliyuncs.com/api-ws/v1/realtime'),
59
+ qwen_realtime_model: z.string().default('qwen-audio-3.0-realtime-plus'),
60
+ qwen_realtime_voice: z.string().default('longanqian'),
61
+ stepfun_realtime_url: z.string().default('wss://api.stepfun.com/v1/realtime'),
62
+ stepfun_realtime_model: z.string().default('stepaudio-3-realtime-preview'),
63
+ stepfun_realtime_voice: z.string().default(''),
64
+ openai_api_key: z.string().nullable().default(null),
65
+ gemini_api_key: z.string().nullable().default(null),
66
+ gemini_asr_model: z.string().default('gemini-3.5-flash'),
67
+ gemini_tts_model: z.string().default('gemini-3.8-flash-tts'),
68
+ gemini_tts_voice: z.string().default('Kore'),
69
+ openai_realtime_url: z.string().default('wss://api.openai.com/v1/realtime'),
70
+ openai_realtime_model: z.string().default('gpt-realtime-2.1-mini'),
71
+ openai_realtime_voice: z.string().default('marin'),
72
+ gemini_realtime_url: z.string().default('wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent'),
73
+ gemini_realtime_model: z.string().default('gemini-3.8-live'),
74
+ gemini_realtime_voice: z.string().default('Kore'),
75
+ stepfun_api_key: z.string().nullable().default(null),
76
+ dashscope_api_key: z.string().nullable().default(null),
77
+ ark_api_key: z.string().nullable().default(null),
78
+ deepseek_api_key: z.string().nullable().default(null),
79
+ doubao_asr_api_key: z.string().nullable().default(null),
80
+ doubao_bigmodel_api_key: z.string().nullable().default(null),
81
+ volcengine_ark_base_url: z.string().default('https://ark.cn-beijing.volces.com/api/v3'),
82
+ volcengine_ark_model: z.string().default('doubao-seed-2-0-pro-260215'),
83
+ volcengine_ark_support_model: z.string().default('doubao-seed-2-0-pro-260215'),
84
+ doubao_asr_endpoint: z.string().default('wss://openspeech.bytedance.com/api/v3/sauc/bigmodel'),
85
+ doubao_asr_resource_id: z.string().default('volc.seedasr.sauc.duration'),
86
+ doubao_asr_voiceprint_enabled: z.boolean().default(false),
87
+ doubao_asr_voiceprint_id: z.string().default(''),
88
+ doubao_asr_voiceprint_name: z.string().default(''),
89
+ doubao_asr_voiceprint_health_url: z.string().default(''),
90
+ doubao_asr_chunk_ms: z.number().int().default(200),
91
+ doubao_tts_endpoint: z.string().default('wss://openspeech.bytedance.com/api/v3/tts/bidirection'),
92
+ doubao_tts_resource_id: z.string().default('seed-tts-2.0'),
93
+ doubao_tts_voice: z.string().default('zh_female_vv_uranus_bigtts'),
94
+ doubao_tts_output_sample_rate: z.number().int().default(24_000),
95
+ volcengine_vad_threshold: volcFloatSchema.default(0.5),
96
+ volcengine_vad_pre_roll_ms: z.number().int().default(260),
97
+ volcengine_vad_min_speech_ms: z.number().int().default(250),
98
+ volcengine_vad_silence_end_ms: z.number().int().default(300),
99
+ volcengine_vad_speech_pad_ms: z.number().int().default(30),
100
+ volcengine_vad_max_utterance_ms: z.number().int().default(60_000),
101
+ qwen_controlled_guard_reconnect: z.boolean().default(false),
102
+ qwen_guard_history_recovery: qwenGuardHistoryRecoverySchema.default('none'),
103
+ qwen_guard_history_pairs: qwenGuardHistoryPairsSchema.default(4),
104
+ executor: executorNameSchema.nullable().default(null),
105
+ executors: z.array(executorNameSchema),
106
+ /** Backend for new coding sessions; existing sessions keep their bound backend. */
107
+ coding_backend: z.enum(CODING_BACKEND_IDS).default('codex'),
108
+ codex_workspace: z.string().nullable().default(null),
109
+ codex_bin: z.string().default('codex'),
110
+ codex_prefix_args: z.array(z.string().min(1).max(32_768)).max(1).default([]),
111
+ codex_api_key: z.string().nullable().default(null),
112
+ codex_prewarm: z.boolean().default(true),
113
+ codex_managed_root: z.string().default('~/.nova-audio-agent/workspaces'),
114
+ codex_project_state_root: z.string().default('~/.nova-audio-agent'),
115
+ coding_progress_narration: z.enum(['smart', 'continuous']).default('smart'),
116
+ proactivity_preset: proactivityPresetSchema.default('balanced'),
117
+ codex_working_interval: z.number().finite().min(5).max(600).default(30),
118
+ suggestion_cooldown: z.number().finite().nonnegative().nullable().default(null),
119
+ fresh_window: z.number().finite().nonnegative().nullable().default(null),
120
+ codex_approval_mode: executorApprovalModeSchema.default('ask'),
121
+ clarification_depth: clarificationDepthSchema.default('balanced'),
122
+ plan_readback: planReadbackSchema.default('summary'),
123
+ generate_plan: z.boolean().default(true),
124
+ planner_model: z.string().default(''),
125
+ progress_bubbles: progressBubblesSchema.default('milestones'),
126
+ search_provider: searchProviderSchema.default('tavily'),
127
+ search_mcp_url: z.string().default(''),
128
+ search_mcp_tool: z.string().default('web_search'),
129
+ knowledge_path: z.string().default('~/.nova-audio-agent/knowledge.sqlite'),
130
+ embedding_provider: embeddingProviderSchema.default('dashscope'),
131
+ embedding_model: z.string().default('text-embedding-v4'),
132
+ blackboard_path: z.string().min(1).default('~/.nova-audio-agent/blackboard.sqlite'),
133
+ blackboard_owner_id: z.string().min(1).max(512).default('local'),
134
+ memory_prerecall_enabled: z.boolean().default(false),
135
+ memory_consolidation_enabled: z.boolean().default(true),
136
+ memory_consolidation_hour: z.number().int().min(0).max(23).default(0),
137
+ memory_consolidation_timezone: z.string().refine(value => { try {
138
+ new Intl.DateTimeFormat('en', { timeZone: value });
139
+ return true;
140
+ }
141
+ catch {
142
+ return false;
143
+ } }, 'invalid timezone').default('UTC'),
144
+ memory_connection: memoryConnectionSchema.default('local'),
145
+ memory_provider: z.enum(['voicemem', 'mem0']).nullable().default(null),
146
+ memory_url: z.string().default(''),
147
+ memory_token: z.string().nullable().default(null),
148
+ memory_path: z.string().min(1).default('~/.nova-audio-agent/memory.sqlite'),
149
+ memory_user_id: z.string().min(1).default('local'),
150
+ // Existing v0.3 ledger location; the retired workspace graph is not enabled.
151
+ workspace_graph_path: z.string().min(1).default('~/.nova-audio-agent/workspace-graph.sqlite'),
152
+ }).strict();
153
+ const proactivityPresets = {
154
+ conservative: { cooldown: 120, fresh_window: 20 },
155
+ balanced: { cooldown: 60, fresh_window: 30 },
156
+ eager: { cooldown: 30, fresh_window: 45 },
157
+ };
158
+ export class ConfigurationError extends Error {
159
+ code;
160
+ constructor(message, code = 'invalid_configuration') {
161
+ super(message);
162
+ this.code = code;
163
+ this.name = 'ConfigurationError';
164
+ }
165
+ }
166
+ /** Names the credentials the selected voice pipeline cannot start without, so the host can ask for exactly those. */
167
+ export class BlockingConfigurationError extends ConfigurationError {
168
+ pipeline;
169
+ missing;
170
+ constructor(pipeline, missing) {
171
+ super(`缺少 ${missing.join(', ')}`);
172
+ this.pipeline = pipeline;
173
+ this.missing = missing;
174
+ this.name = 'BlockingConfigurationError';
175
+ }
176
+ }
177
+ /** Environment names that were renamed without an alias; the old name is ignored, so its presence deserves a startup warning. */
178
+ export const RENAMED_ENVIRONMENT = { SURROGATE_MODEL: 'SUPPORT_MODEL' };
179
+ /** One `[config-warning]` line per renamed variable still set in the environment. */
180
+ export function renamedEnvironmentWarnings(environment) {
181
+ return Object.entries(RENAMED_ENVIRONMENT)
182
+ .filter(([removed]) => environment[removed] !== undefined)
183
+ .map(([removed, current]) => `[config-warning] ${removed} is no longer read; rename it to ${current}`);
184
+ }
185
+ export function loadSettings(environment = process.env, textConversations = false) {
186
+ const pipelineMode = parsePipelineMode(environment.PIPELINE_MODE);
187
+ const integratedProvider = pipelineMode === 'integrated'
188
+ ? parseIntegratedProvider(environment.INTEGRATED_PROVIDER)
189
+ : undefined;
190
+ const cascadedProviders = pipelineMode === 'cascaded'
191
+ ? {
192
+ endpointing: parseCascadedEndpointingProvider(environment.CASCADE_ENDPOINTING_PROVIDER),
193
+ asr: parseCascadedAsrProvider(environment.CASCADE_ASR_PROVIDER),
194
+ llm: parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER),
195
+ tts: parseCascadedTtsProvider(environment.CASCADE_TTS_PROVIDER),
196
+ }
197
+ : undefined;
198
+ const configuredExecutor = optionalString(environment.EXECUTOR);
199
+ const executor = configuredExecutor === undefined || configuredExecutor === ''
200
+ ? null
201
+ : configuredExecutor;
202
+ const executors = parseExecutors(environment.EXECUTORS, configuredExecutor ?? '');
203
+ // StepFun support chat defaults to its own model. fast_model keeps its DashScope default
204
+ // because local memory extraction reaches it through the DashScope embedding connection;
205
+ // an empty watch or planner model would fall back to it, so empty counts as unset there.
206
+ const stepfunSupport = !textConversations && integratedProvider === 'stepfun'
207
+ && (optionalSecret(environment.MODEL_API_KEY) ?? '').trim() === '';
208
+ const supportDefault = (value) => value ?? (stepfunSupport ? STEPFUN_SUPPORT_MODEL : !textConversations && !(environment.MODEL_API_KEY ?? '').trim() && integratedProvider === 'openai' ? 'gpt-6-luna' : !textConversations && !(environment.MODEL_API_KEY ?? '').trim() && integratedProvider === 'gemini' ? 'gemini-3.5-flash-lite' : undefined);
209
+ const candidate = {
210
+ coding_backend: optionalString(environment.CODING_BACKEND),
211
+ self_hosted_asr_url: optionalString(environment.SELF_HOSTED_ASR_URL),
212
+ self_hosted_llm_base_url: optionalString(environment.SELF_HOSTED_LLM_BASE_URL),
213
+ self_hosted_tts_url: optionalString(environment.SELF_HOSTED_TTS_URL),
214
+ self_hosted_asr_api_key: optionalSecret(environment.SELF_HOSTED_ASR_API_KEY),
215
+ self_hosted_llm_api_key: optionalSecret(environment.SELF_HOSTED_LLM_API_KEY),
216
+ self_hosted_tts_api_key: optionalSecret(environment.SELF_HOSTED_TTS_API_KEY),
217
+ openai_api_key: optionalSecret(environment.OPENAI_API_KEY),
218
+ gemini_api_key: optionalSecret(environment.GEMINI_API_KEY),
219
+ gemini_asr_model: optionalString(environment.GEMINI_ASR_MODEL),
220
+ gemini_tts_model: optionalString(environment.GEMINI_TTS_MODEL),
221
+ gemini_tts_voice: optionalString(environment.GEMINI_TTS_VOICE),
222
+ openai_realtime_url: optionalString(environment.OPENAI_REALTIME_URL),
223
+ openai_realtime_model: optionalString(environment.OPENAI_REALTIME_MODEL),
224
+ openai_realtime_voice: optionalString(environment.OPENAI_REALTIME_VOICE),
225
+ gemini_realtime_url: optionalString(environment.GEMINI_REALTIME_URL),
226
+ gemini_realtime_model: optionalString(environment.GEMINI_REALTIME_MODEL),
227
+ gemini_realtime_voice: optionalString(environment.GEMINI_REALTIME_VOICE),
228
+ model_base_url: optionalString(environment.MODEL_BASE_URL),
229
+ model_api_key: optionalSecret(environment.MODEL_API_KEY),
230
+ openrouter_api_key: optionalSecret(environment.OPENROUTER_API_KEY),
231
+ tavily_api_key: optionalSecret(environment.TAVILY_API_KEY),
232
+ fast_model: rawEnvironmentValue(environment.FAST_MODEL),
233
+ watch_model: supportDefault(emptyAsUnset(rawEnvironmentValue(environment.WATCH_MODEL))),
234
+ ...(supportsVision('qwen', environment.WATCH_MODEL ?? '')
235
+ || environment.MEMORY_CONNECTION?.trim() === 'local'
236
+ ? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) } : {}),
237
+ ...(supportsVision('ark', environment.WATCH_MODEL ?? '')
238
+ ? { ark_api_key: optionalSecret(environment.ARK_API_KEY),
239
+ volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL) } : {}),
240
+ conversation_vision_enabled: optionalBoolean(environment.CONVERSATION_VISION_ENABLED),
241
+ monitor_camera_device_id: optionalString(environment.MONITOR_CAMERA_DEVICE_ID),
242
+ support_model: supportDefault(rawEnvironmentValue(environment.SUPPORT_MODEL)),
243
+ compressor_model: supportDefault(rawEnvironmentValue(environment.COMPRESSOR_MODEL)),
244
+ language: parsePromptLanguageSetting(environment.PROMPT_LANGUAGE),
245
+ news_language: parseSelector(promptLanguageSchema, environment.NEWS_LANGUAGE, 'en', 'NEWS_LANGUAGE'),
246
+ pipeline_mode: pipelineMode,
247
+ camera_module_enabled: optionalBoolean(environment.CAMERA_MODULE_ENABLED),
248
+ ...(pipelineMode === 'integrated' ? {
249
+ ...(textConversations ? { cascade_llm_provider: parseCascadedLlmProvider(environment.CASCADE_LLM_PROVIDER),
250
+ cascade_llm_model: rawEnvironmentValue(environment.CASCADE_LLM_MODEL),
251
+ ark_api_key: optionalSecret(environment.ARK_API_KEY), deepseek_api_key: optionalSecret(environment.DEEPSEEK_API_KEY),
252
+ volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL) } : {}),
253
+ integrated_provider: integratedProvider,
254
+ qwen_realtime_url: optionalString(environment.QWEN_REALTIME_URL),
255
+ qwen_realtime_model: optionalString(environment.QWEN_REALTIME_MODEL),
256
+ qwen_realtime_voice: optionalString(environment.QWEN_REALTIME_VOICE)
257
+ ?? (environment.QWEN_REALTIME_MODEL?.startsWith('qwen3.5-omni-') ? 'Ethan'
258
+ : environment.QWEN_REALTIME_MODEL === 'qwen-audio-3.1-realtime-plus' ? 'longanqian_v3.1' : undefined),
259
+ dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY),
260
+ stepfun_realtime_url: optionalString(environment.STEPFUN_REALTIME_URL),
261
+ stepfun_realtime_model: optionalString(environment.STEPFUN_REALTIME_MODEL),
262
+ stepfun_realtime_voice: optionalString(environment.STEPFUN_REALTIME_VOICE),
263
+ stepfun_api_key: optionalSecret(environment.STEPFUN_API_KEY),
264
+ qwen_controlled_guard_reconnect: optionalBoolean(environment.QWEN_CONTROLLED_GUARD_RECONNECT),
265
+ qwen_guard_history_recovery: environment.QWEN_GUARD_HISTORY_RECOVERY,
266
+ qwen_guard_history_pairs: optionalQwenGuardHistoryPairs(environment.QWEN_GUARD_HISTORY_PAIRS),
267
+ } : {
268
+ cascade_endpointing_provider: cascadedProviders.endpointing,
269
+ cascade_asr_provider: cascadedProviders.asr,
270
+ cascade_llm_provider: cascadedProviders.llm,
271
+ cascade_llm_model: rawEnvironmentValue(environment.CASCADE_LLM_MODEL),
272
+ cascade_tts_provider: cascadedProviders.tts,
273
+ ...(cascadedProviders.llm === 'qwen'
274
+ ? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) }
275
+ : cascadedProviders.llm === 'deepseek'
276
+ ? { deepseek_api_key: optionalSecret(environment.DEEPSEEK_API_KEY) }
277
+ : { ark_api_key: optionalSecret(environment.ARK_API_KEY) }),
278
+ ...(cascadedProviders.llm === 'ark' ? {
279
+ volcengine_ark_base_url: rawEnvironmentValue(environment.VOLCENGINE_ARK_BASE_URL),
280
+ } : {}),
281
+ doubao_asr_api_key: optionalSecret(environment.DOUBAO_ASR_API_KEY),
282
+ doubao_bigmodel_api_key: optionalSecret(environment.DOUBAO_BIGMODEL_API_KEY),
283
+ doubao_asr_endpoint: rawEnvironmentValue(environment.DOUBAO_ASR_ENDPOINT),
284
+ doubao_asr_resource_id: rawEnvironmentValue(environment.DOUBAO_ASR_RESOURCE_ID),
285
+ doubao_asr_voiceprint_enabled: optionalBoolean(environment.DOUBAO_ASR_VOICEPRINT_ENABLED),
286
+ doubao_asr_voiceprint_id: rawEnvironmentValue(environment.DOUBAO_ASR_VOICEPRINT_ID),
287
+ doubao_asr_voiceprint_name: rawEnvironmentValue(environment.DOUBAO_ASR_VOICEPRINT_NAME),
288
+ doubao_asr_voiceprint_health_url: rawEnvironmentValue(environment.DOUBAO_ASR_VOICEPRINT_HEALTH_URL),
289
+ doubao_asr_chunk_ms: optionalPydanticInteger(environment.DOUBAO_ASR_CHUNK_MS),
290
+ doubao_tts_endpoint: rawEnvironmentValue(environment.DOUBAO_TTS_ENDPOINT),
291
+ doubao_tts_resource_id: rawEnvironmentValue(environment.DOUBAO_TTS_RESOURCE_ID),
292
+ doubao_tts_voice: rawEnvironmentValue(environment.DOUBAO_TTS_VOICE),
293
+ doubao_tts_output_sample_rate: optionalPydanticInteger(environment.DOUBAO_TTS_OUTPUT_SAMPLE_RATE),
294
+ volcengine_vad_threshold: optionalPydanticFloat(environment.VOLCENGINE_VAD_THRESHOLD),
295
+ volcengine_vad_pre_roll_ms: optionalPydanticInteger(environment.VOLCENGINE_VAD_PRE_ROLL_MS),
296
+ volcengine_vad_min_speech_ms: optionalPydanticInteger(environment.VOLCENGINE_VAD_MIN_SPEECH_MS),
297
+ volcengine_vad_silence_end_ms: optionalPydanticInteger(environment.VOLCENGINE_VAD_SILENCE_END_MS),
298
+ volcengine_vad_speech_pad_ms: optionalPydanticInteger(environment.VOLCENGINE_VAD_SPEECH_PAD_MS),
299
+ volcengine_vad_max_utterance_ms: optionalPydanticInteger(environment.VOLCENGINE_VAD_MAX_UTTERANCE_MS),
300
+ }),
301
+ executor,
302
+ executors,
303
+ ...executorOwnedSettings(environment, executors),
304
+ coding_progress_narration: optionalString(environment.CODING_PROGRESS_NARRATION),
305
+ proactivity_preset: optionalString(environment.PROACTIVITY_PRESET),
306
+ suggestion_cooldown: optionalPydanticFloat(environment.SUGGESTION_COOLDOWN),
307
+ fresh_window: optionalPydanticFloat(environment.FRESH_WINDOW),
308
+ clarification_depth: parseClarificationDepth(environment.CLARIFICATION_DEPTH),
309
+ plan_readback: parsePlanReadback(environment.PLAN_READBACK),
310
+ generate_plan: optionalBoolean(environment.GENERATE_PLAN),
311
+ planner_model: supportDefault(emptyAsUnset(optionalString(environment.PLANNER_MODEL))),
312
+ progress_bubbles: parseProgressBubbles(environment.PROGRESS_BUBBLES),
313
+ search_provider: parseSearchProvider(environment.SEARCH_PROVIDER),
314
+ search_mcp_url: optionalString(environment.SEARCH_MCP_URL),
315
+ search_mcp_tool: optionalString(environment.SEARCH_MCP_TOOL),
316
+ knowledge_path: optionalString(environment.KNOWLEDGE_PATH),
317
+ embedding_provider: parseEmbeddingProvider(environment.EMBEDDING_PROVIDER),
318
+ embedding_model: optionalString(environment.EMBEDDING_MODEL),
319
+ blackboard_path: optionalString(environment.BLACKBOARD_PATH),
320
+ blackboard_owner_id: optionalString(environment.BLACKBOARD_OWNER_ID),
321
+ memory_prerecall_enabled: optionalBoolean(environment.MEMORY_PRERECALL_ENABLED),
322
+ memory_consolidation_enabled: optionalBoolean(environment.MEMORY_CONSOLIDATION_ENABLED),
323
+ memory_consolidation_hour: optionalPydanticInteger(environment.MEMORY_CONSOLIDATION_HOUR),
324
+ memory_consolidation_timezone: environment.MEMORY_CONSOLIDATION_TIMEZONE,
325
+ memory_connection: optionalString(environment.MEMORY_CONNECTION),
326
+ ...((optionalString(environment.MEMORY_CONNECTION) ?? 'local') === 'local'
327
+ ? { dashscope_api_key: optionalSecret(environment.DASHSCOPE_API_KEY) } : {}),
328
+ memory_provider: optionalString(environment.MEMORY_PROVIDER),
329
+ memory_url: optionalString(environment.MEMORY_URL),
330
+ memory_token: optionalSecret(environment.MEMORY_TOKEN),
331
+ memory_path: optionalString(environment.MEMORY_PATH),
332
+ memory_user_id: optionalString(environment.MEMORY_USER_ID),
333
+ workspace_graph_path: optionalString(environment.MEMORY_LEDGER_PATH) ?? optionalString(environment.WORKSPACE_GRAPH_PATH),
334
+ };
335
+ const withoutUndefined = Object.fromEntries(Object.entries(candidate).filter(([, value]) => value !== undefined));
336
+ const result = settingsSchema.safeParse(withoutUndefined);
337
+ if (!result.success) {
338
+ const fields = [...new Set(result.error.issues.map(issue => String(issue.path[0] ?? 'settings')))]
339
+ .sort(compareStrings)
340
+ .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');
345
+ }
346
+ resolveMemoryConnection(result.data);
347
+ return result.data;
348
+ }
349
+ export function resolveProactivity(settings) {
350
+ const preset = resolveProactivityPreset(settings.proactivity_preset);
351
+ return {
352
+ cooldown: settings.suggestion_cooldown ?? preset.cooldown,
353
+ fresh_window: settings.fresh_window ?? preset.fresh_window,
354
+ };
355
+ }
356
+ export function resolveProactivityPreset(preset) {
357
+ return proactivityPresets[preset];
358
+ }
359
+ export function requirePersonalMemory(settings) {
360
+ const connection = resolveMemoryConnection(settings);
361
+ if (connection === 'disabled')
362
+ return null;
363
+ if (connection === 'remote')
364
+ return Object.freeze({
365
+ connection: 'remote',
366
+ url: requiredSetting(settings.memory_url, 'MEMORY_URL'),
367
+ token: requiredCredential(settings.memory_token, 'MEMORY_TOKEN'),
368
+ });
369
+ // Local memory is optional: without an embedding credential it stays off instead of blocking the voice pipeline.
370
+ if (stripLikePython(resolveModelApiKey(settings) ?? '') === '')
371
+ return null;
372
+ return Object.freeze({
373
+ connection: 'local',
374
+ provider: settings.memory_provider ?? 'voicemem',
375
+ path: requiredSetting(settings.memory_path, 'MEMORY_PATH'),
376
+ userId: requiredSetting(settings.memory_user_id, 'MEMORY_USER_ID'),
377
+ extractionModel: requiredSetting(settings.fast_model, 'FAST_MODEL'),
378
+ embedding: Object.freeze({
379
+ baseUrl: secureEndpoint(settings.model_base_url, 'https', 'MODEL_BASE_URL'),
380
+ apiKey: requiredCredential(resolveModelApiKey(settings), 'DASHSCOPE_API_KEY 或 MODEL_API_KEY'),
381
+ model: requiredSetting(settings.embedding_model, 'EMBEDDING_MODEL'),
382
+ }),
383
+ });
384
+ }
385
+ function resolveMemoryConnection(settings) {
386
+ const connection = settings.memory_connection;
387
+ 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');
389
+ }
390
+ return connection;
391
+ }
392
+ export function requireQwenRealtime(settings) {
393
+ const url = stripLikePython(settings.qwen_realtime_url);
394
+ const model = stripLikePython(settings.qwen_realtime_model);
395
+ const voice = stripLikePython(settings.qwen_realtime_voice);
396
+ if (!url.startsWith('wss://')) {
397
+ throw new ConfigurationError('QWEN_REALTIME_URL 必须使用 wss://');
398
+ }
399
+ if (model === '') {
400
+ throw new ConfigurationError('QWEN_REALTIME_MODEL 不能为空');
401
+ }
402
+ if (voice === '') {
403
+ throw new ConfigurationError('QWEN_REALTIME_VOICE 不能为空');
404
+ }
405
+ const realtimeKey = stripLikePython(settings.dashscope_api_key ?? '');
406
+ const modelKey = stripLikePython(settings.model_api_key ?? '');
407
+ const apiKey = realtimeKey || modelKey;
408
+ if (apiKey === '') {
409
+ throw new ConfigurationError('缺少 DASHSCOPE_API_KEY 或 MODEL_API_KEY');
410
+ }
411
+ return { url, model, voice, apiKey };
412
+ }
413
+ export function requireIntegratedRealtime(settings) {
414
+ const provider = settings.integrated_provider;
415
+ if (provider === 'openai' || provider === 'gemini')
416
+ return Object.freeze({
417
+ url: secureEndpoint(settings[`${provider}_realtime_url`], 'wss', `${provider.toUpperCase()}_REALTIME_URL`),
418
+ model: requiredSetting(settings[`${provider}_realtime_model`], `${provider.toUpperCase()}_REALTIME_MODEL`),
419
+ voice: requiredSetting(settings[`${provider}_realtime_voice`], `${provider.toUpperCase()}_REALTIME_VOICE`),
420
+ apiKey: requiredCredential(settings[`${provider}_api_key`], `${provider.toUpperCase()}_API_KEY`),
421
+ });
422
+ if (settings.integrated_provider === 'stepfun') {
423
+ const url = secureEndpoint(settings.stepfun_realtime_url, 'wss', 'STEPFUN_REALTIME_URL');
424
+ const model = stripLikePython(settings.stepfun_realtime_model);
425
+ const voice = stripLikePython(settings.stepfun_realtime_voice);
426
+ const apiKey = stripLikePython(settings.stepfun_api_key ?? '');
427
+ if (model === '')
428
+ throw new ConfigurationError('STEPFUN_REALTIME_MODEL 不能为空');
429
+ if (apiKey === '')
430
+ throw new ConfigurationError('缺少 STEPFUN_API_KEY');
431
+ return Object.freeze({ url, model, voice, apiKey });
432
+ }
433
+ const url = secureEndpoint(settings.qwen_realtime_url, 'wss', 'QWEN_REALTIME_URL');
434
+ const model = stripLikePython(settings.qwen_realtime_model);
435
+ const voice = stripLikePython(settings.qwen_realtime_voice);
436
+ if (model === '') {
437
+ throw new ConfigurationError('QWEN_REALTIME_MODEL 不能为空');
438
+ }
439
+ if (voice === '') {
440
+ throw new ConfigurationError('QWEN_REALTIME_VOICE 不能为空');
441
+ }
442
+ const explicitKey = stripLikePython(settings.dashscope_api_key ?? '');
443
+ const compatibleGenericKey = settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL
444
+ ? stripLikePython(settings.model_api_key ?? '')
445
+ : '';
446
+ const apiKey = explicitKey || compatibleGenericKey;
447
+ if (apiKey === '') {
448
+ throw new ConfigurationError('缺少 DASHSCOPE_API_KEY');
449
+ }
450
+ return Object.freeze({ url, model, voice, apiKey });
451
+ }
452
+ export function resolveModelApiKey(settings) {
453
+ return stripLikePython(settings.model_api_key ?? '')
454
+ || (settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? settings.dashscope_api_key : null);
455
+ }
456
+ /** Preset monitor models keep their credential on their own provider endpoint. */
457
+ export function resolveWatchModelConnection(settings) {
458
+ const model = stripLikePython(settings.watch_model ?? '');
459
+ if (supportsVision('stepfun', model))
460
+ return {
461
+ baseUrl: STEPFUN_COMPATIBLE_BASE_URL,
462
+ apiKey: requiredCredential(settings.stepfun_api_key, 'STEPFUN_API_KEY'),
463
+ };
464
+ if (supportsVision('qwen', model))
465
+ return {
466
+ baseUrl: DASHSCOPE_COMPATIBLE_BASE_URL,
467
+ apiKey: requiredCredential(settings.dashscope_api_key
468
+ ?? (settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? settings.model_api_key : null), 'DASHSCOPE_API_KEY'),
469
+ };
470
+ if (supportsVision('ark', model))
471
+ return {
472
+ baseUrl: secureEndpoint(settings.volcengine_ark_base_url, 'https', 'VOLCENGINE_ARK_BASE_URL'),
473
+ apiKey: requiredCredential(settings.ark_api_key, 'ARK_API_KEY'),
474
+ };
475
+ return null;
476
+ }
477
+ /** The credential a vision watch model still needs, or null when it has one (or needs none). */
478
+ export function missingWatchModelCredential(settings) {
479
+ const model = stripLikePython(settings.watch_model ?? '');
480
+ 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;
484
+ }
485
+ if (supportsVision('ark', model))
486
+ return stripLikePython(settings.ark_api_key ?? '') === '' ? 'ARK_API_KEY' : null;
487
+ return null;
488
+ }
489
+ /** Knowledge embeds through the generic model gateway, so it needs that gateway's key. */
490
+ export function missingKnowledgeCredential(settings) {
491
+ if (resolveModelApiKey(settings))
492
+ return null;
493
+ return settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? 'DASHSCOPE_API_KEY' : 'MODEL_API_KEY';
494
+ }
495
+ /** Camera watch and knowledge are optional: without their credential they are reported off rather than failing startup. */
496
+ export function withoutUncredentialedModules(registry, settings) {
497
+ const camera = registry.modules.camera.enabled ? missingWatchModelCredential(settings) : null;
498
+ const knowledge = registry.modules.knowledge.enabled ? missingKnowledgeCredential(settings) : null;
499
+ if (camera === null && knowledge === null)
500
+ return registry;
501
+ return { ...registry, modules: {
502
+ ...registry.modules,
503
+ ...(camera === null ? {} : { camera: { enabled: false, reason: `missing_environment:${camera}` } }),
504
+ ...(knowledge === null ? {} : { knowledge: { enabled: false, exposeToCodex: false, reason: `missing_environment:${knowledge}` } }),
505
+ } };
506
+ }
507
+ /** Mirrors requireIntegratedRealtime and requireCascadedCredentials without throwing, for first-run guidance. */
508
+ export function describeMissingBlockingCredentials(settings, textConversations = false) {
509
+ const present = (value) => stripLikePython(value ?? '') !== '';
510
+ if (!textConversations && settings.pipeline_mode === 'integrated') {
511
+ if (settings.integrated_provider === 'openai' || settings.integrated_provider === 'gemini')
512
+ return { pipeline: 'integrated', missing: present(settings[`${settings.integrated_provider}_api_key`]) ? [] : [`${settings.integrated_provider.toUpperCase()}_API_KEY`] };
513
+ if (settings.integrated_provider === 'stepfun')
514
+ return { pipeline: 'integrated', missing: present(settings.stepfun_api_key) ? [] : ['STEPFUN_API_KEY'] };
515
+ const compatibleGenericKey = settings.model_base_url === DASHSCOPE_COMPATIBLE_BASE_URL ? settings.model_api_key : null;
516
+ return { pipeline: 'integrated', missing: present(settings.dashscope_api_key) || present(compatibleGenericKey) ? [] : ['DASHSCOPE_API_KEY'] };
517
+ }
518
+ const llmField = cascadedCredentialField(settings.cascade_llm_provider);
519
+ return { pipeline: 'cascaded', missing: [...new Set([
520
+ ...(settings.cascade_llm_provider === 'self-hosted' || present(settings[llmField]) ? [] : [configurationFieldName(llmField)]),
521
+ ...(textConversations || settings.cascade_asr_provider === 'self-hosted' ? [] : settings.cascade_asr_provider === 'gemini' ? (present(settings.gemini_api_key) ? [] : ['GEMINI_API_KEY']) : (present(settings.doubao_asr_api_key) || present(settings.doubao_bigmodel_api_key) || settings.cascade_tts_provider === 'volcengine' ? [] : ['DOUBAO_ASR_API_KEY'])),
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
+ ])] };
524
+ }
525
+ /** Host preflight over a launch environment; other configuration errors stay the runtime's to report. */
526
+ export function describeMissingBlockingEnvironment(environment, textConversations = false) {
527
+ try {
528
+ return describeMissingBlockingCredentials(loadSettings(environment, textConversations), textConversations);
529
+ }
530
+ catch (error) {
531
+ if (error instanceof ConfigurationError)
532
+ return null;
533
+ throw error;
534
+ }
535
+ }
536
+ export function requireBlockingCredentials(settings) {
537
+ const { pipeline, missing } = describeMissingBlockingCredentials(settings);
538
+ if (missing.length > 0)
539
+ throw new BlockingConfigurationError(pipeline, missing);
540
+ }
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
+ export function resolveCascadedSelection(settings) {
557
+ if (settings.cascade_llm_provider === 'self-hosted' && !settings.cascade_llm_model?.trim())
558
+ throw new ConfigurationError('缺少 CASCADE_LLM_MODEL');
559
+ const llmModel = settings.cascade_llm_model === null
560
+ ? (settings.cascade_llm_provider === 'qwen'
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')
563
+ : requiredSetting(settings.cascade_llm_model, 'CASCADE_LLM_MODEL');
564
+ return Object.freeze({
565
+ endpointingProvider: settings.cascade_endpointing_provider,
566
+ asrProvider: settings.cascade_asr_provider,
567
+ llmProvider: settings.cascade_llm_provider,
568
+ llmModel,
569
+ ttsProvider: settings.cascade_tts_provider,
570
+ });
571
+ }
572
+ export function requireCascadedCredentials(settings, selection) {
573
+ const field = cascadedCredentialField(selection.llmProvider);
574
+ 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 === 'gemini' ? requiredCredential(settings.gemini_api_key, 'GEMINI_API_KEY') : requiredCredential(stripLikePython(settings.doubao_asr_api_key ?? '') || settings.doubao_bigmodel_api_key, 'DOUBAO_ASR_API_KEY');
577
+ return Object.freeze({ llmApiKey, asrApiKey, ttsApiKey });
578
+ }
579
+ export function requireVolcengineRealtime(settings) {
580
+ const arkApiKey = stripLikePython(settings.ark_api_key ?? '');
581
+ const ttsApiKey = stripLikePython(settings.doubao_bigmodel_api_key ?? '');
582
+ const asrApiKey = stripLikePython(settings.doubao_asr_api_key ?? '') || ttsApiKey;
583
+ if (arkApiKey === '')
584
+ throw new ConfigurationError('缺少 ARK_API_KEY');
585
+ if (ttsApiKey === '')
586
+ throw new ConfigurationError('缺少 DOUBAO_BIGMODEL_API_KEY');
587
+ if (asrApiKey === '') {
588
+ throw new ConfigurationError('缺少 DOUBAO_ASR_API_KEY 或 DOUBAO_BIGMODEL_API_KEY');
589
+ }
590
+ if (settings.doubao_asr_chunk_ms <= 0) {
591
+ throw new ConfigurationError('DOUBAO_ASR_CHUNK_MS 必须为正整数');
592
+ }
593
+ if (settings.doubao_tts_output_sample_rate !== 24_000) {
594
+ throw new ConfigurationError('DOUBAO_TTS_OUTPUT_SAMPLE_RATE 必须为 24000');
595
+ }
596
+ if (!(settings.volcengine_vad_threshold > 0 && settings.volcengine_vad_threshold <= 1)) {
597
+ throw new ConfigurationError('VOLCENGINE_VAD_THRESHOLD 必须在 (0, 1] 内');
598
+ }
599
+ if (settings.volcengine_vad_pre_roll_ms < 0 || settings.volcengine_vad_speech_pad_ms < 0) {
600
+ throw new ConfigurationError('火山 VAD pre-roll 与 speech pad 不能为负数');
601
+ }
602
+ if (settings.volcengine_vad_min_speech_ms <= 0 || settings.volcengine_vad_silence_end_ms <= 0) {
603
+ throw new ConfigurationError('火山 VAD min speech 与 silence end 必须为正整数');
604
+ }
605
+ if (settings.volcengine_vad_max_utterance_ms < settings.volcengine_vad_min_speech_ms) {
606
+ throw new ConfigurationError('火山 VAD max utterance 不能短于 min speech');
607
+ }
608
+ return Object.freeze({
609
+ arkBaseUrl: secureEndpoint(settings.volcengine_ark_base_url, 'https', 'VOLCENGINE_ARK_BASE_URL'),
610
+ arkModel: requiredSetting(settings.volcengine_ark_model, 'CASCADE_LLM_MODEL'),
611
+ arkSupportModel: requiredSetting(settings.volcengine_ark_support_model, 'SUPPORT_MODEL'),
612
+ arkApiKey,
613
+ asrEndpoint: secureEndpoint(settings.doubao_asr_endpoint, 'wss', 'DOUBAO_ASR_ENDPOINT'),
614
+ asrResourceId: requiredSetting(settings.doubao_asr_resource_id, 'DOUBAO_ASR_RESOURCE_ID'),
615
+ asrApiKey,
616
+ asrChunkMs: settings.doubao_asr_chunk_ms,
617
+ ttsEndpoint: secureEndpoint(settings.doubao_tts_endpoint, 'wss', 'DOUBAO_TTS_ENDPOINT'),
618
+ ttsResourceId: requiredSetting(settings.doubao_tts_resource_id, 'DOUBAO_TTS_RESOURCE_ID'),
619
+ ttsVoice: requiredSetting(settings.doubao_tts_voice, 'DOUBAO_TTS_VOICE'),
620
+ ttsApiKey,
621
+ ttsOutputSampleRate: 24_000,
622
+ vadThreshold: settings.volcengine_vad_threshold,
623
+ vadPreRollMs: settings.volcengine_vad_pre_roll_ms,
624
+ vadMinSpeechMs: settings.volcengine_vad_min_speech_ms,
625
+ vadSilenceEndMs: settings.volcengine_vad_silence_end_ms,
626
+ vadSpeechPadMs: settings.volcengine_vad_speech_pad_ms,
627
+ vadMaxUtteranceMs: settings.volcengine_vad_max_utterance_ms,
628
+ });
629
+ }
630
+ /**
631
+ * Settings an executor owns are read only when that executor is selected, so its secrets stay
632
+ * lazy. Keyed by executor name as data (like `owner` in the environment contract), not branched on.
633
+ */
634
+ const EXECUTOR_OWNED_SETTINGS = {
635
+ codex: environment => ({
636
+ codex_workspace: optionalSecret(environment.CODEX_WORKSPACE),
637
+ codex_bin: optionalString(environment.CODEX_BIN),
638
+ codex_prefix_args: optionalJsonStringArray(environment.CODEX_PREFIX_ARGS),
639
+ codex_api_key: optionalSecret(environment.CODEX_API_KEY),
640
+ codex_prewarm: optionalBoolean(environment.CODEX_PREWARM),
641
+ codex_managed_root: optionalString(environment.CODEX_MANAGED_ROOT),
642
+ codex_project_state_root: optionalString(environment.CODEX_PROJECT_STATE_ROOT),
643
+ codex_working_interval: optionalPydanticFloat(environment.CODEX_WORKING_INTERVAL),
644
+ codex_approval_mode: parseExecutorApprovalMode(environment.CODEX_APPROVAL_MODE),
645
+ }),
646
+ };
647
+ function executorOwnedSettings(environment, executors) {
648
+ const result = {};
649
+ for (const name of executors) {
650
+ const read = Object.hasOwn(EXECUTOR_OWNED_SETTINGS, name) ? EXECUTOR_OWNED_SETTINGS[name] : undefined;
651
+ if (read !== undefined)
652
+ Object.assign(result, read(environment));
653
+ }
654
+ return result;
655
+ }
656
+ function parseExecutors(raw, fallback) {
657
+ if (raw === undefined || raw === '')
658
+ return fallback === '' ? [] : [fallback];
659
+ const names = raw.split(',').map(stripLikePython);
660
+ if (names.some(name => name === '')) {
661
+ throw new ConfigurationError('EXECUTORS contains an empty name');
662
+ }
663
+ if (new Set(names).size !== names.length) {
664
+ throw new ConfigurationError('EXECUTORS contains duplicate names');
665
+ }
666
+ return names;
667
+ }
668
+ function parsePipelineMode(value) {
669
+ return parseSelector(pipelineModeSchema, value, 'integrated', 'PIPELINE_MODE');
670
+ }
671
+ function parsePromptLanguageSetting(value) {
672
+ return parseSelector(promptLanguageSchema, value, 'zh-CN', 'PROMPT_LANGUAGE');
673
+ }
674
+ function parseIntegratedProvider(value) {
675
+ return parseSelector(integratedProviderNameSchema, value, 'qwen', 'INTEGRATED_PROVIDER');
676
+ }
677
+ function parseCascadedEndpointingProvider(value) {
678
+ return parseSelector(cascadedEndpointingProviderNameSchema, value, 'auto', 'CASCADE_ENDPOINTING_PROVIDER');
679
+ }
680
+ function parseCascadedAsrProvider(value) {
681
+ return parseSelector(cascadedAsrProviderNameSchema, value, 'volcengine', 'CASCADE_ASR_PROVIDER');
682
+ }
683
+ function parseCascadedLlmProvider(value) {
684
+ return parseSelector(cascadedLlmProviderNameSchema, value, 'qwen', 'CASCADE_LLM_PROVIDER');
685
+ }
686
+ function parseCascadedTtsProvider(value) {
687
+ return parseSelector(cascadedTtsProviderNameSchema, value, 'volcengine', 'CASCADE_TTS_PROVIDER');
688
+ }
689
+ function parseExecutorApprovalMode(value) {
690
+ return parseSafeSelector(executorApprovalModeSchema, value, 'ask');
691
+ }
692
+ function parseClarificationDepth(value) {
693
+ return parseSafeSelector(clarificationDepthSchema, value, 'balanced');
694
+ }
695
+ function parsePlanReadback(value) {
696
+ return parseSafeSelector(planReadbackSchema, value, 'summary');
697
+ }
698
+ function parseProgressBubbles(value) {
699
+ return parseSafeSelector(progressBubblesSchema, value, 'milestones');
700
+ }
701
+ function parseEmbeddingProvider(value) {
702
+ return parseSelector(embeddingProviderSchema, value, 'dashscope', 'EMBEDDING_PROVIDER (allowed: dashscope)');
703
+ }
704
+ function parseSearchProvider(value) {
705
+ return parseSafeSelector(searchProviderSchema, value, 'tavily');
706
+ }
707
+ function parseSafeSelector(schema, value, fallback) {
708
+ const result = schema.safeParse(optionalString(value) ?? fallback);
709
+ return result.success ? result.data : fallback;
710
+ }
711
+ function parseSelector(schema, value, fallback, field) {
712
+ const result = schema.safeParse(optionalString(value) ?? fallback);
713
+ if (result.success)
714
+ return result.data;
715
+ throw new ConfigurationError(`invalid configuration: ${field}`);
716
+ }
717
+ function optionalString(value) {
718
+ if (value === undefined)
719
+ return undefined;
720
+ return stripLikePython(value);
721
+ }
722
+ function optionalJsonStringArray(value) {
723
+ if (value === undefined)
724
+ return undefined;
725
+ try {
726
+ return JSON.parse(value);
727
+ }
728
+ catch {
729
+ return value;
730
+ }
731
+ }
732
+ function optionalSecret(value) {
733
+ if (value === undefined)
734
+ return undefined;
735
+ return stripLikePython(value) || null;
736
+ }
737
+ function optionalBoolean(value) {
738
+ if (value === undefined)
739
+ return undefined;
740
+ const normalized = value.toLowerCase();
741
+ if (['true', 't', '1', 'on', 'yes', 'y'].includes(normalized))
742
+ return true;
743
+ if (['false', 'f', '0', 'off', 'no', 'n'].includes(normalized))
744
+ return false;
745
+ return normalized;
746
+ }
747
+ function optionalQwenGuardHistoryPairs(value) {
748
+ if (value === undefined)
749
+ return undefined;
750
+ if (value === '1')
751
+ return 1;
752
+ if (value === '2')
753
+ return 2;
754
+ if (value === '4')
755
+ return 4;
756
+ return value;
757
+ }
758
+ const pydanticNumericSpace = '[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680'
759
+ + '\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]';
760
+ const underscoredDigits = '[0-9](?:_?[0-9])*';
761
+ const pydanticIntegerPattern = new RegExp(`^${pydanticNumericSpace}*[+-]?${underscoredDigits}(?:\\.0+)?${pydanticNumericSpace}*$`, 'u');
762
+ const pydanticFloatPattern = new RegExp(`^${pydanticNumericSpace}*[+-]?(?:(?:${underscoredDigits}(?:\\.(?:${underscoredDigits})?)?`
763
+ + `|\\.${underscoredDigits})(?:[eE][+-]?${underscoredDigits})?`
764
+ + `|inf(?:inity)?|nan)${pydanticNumericSpace}*$`, 'iu');
765
+ const pydanticNumericEdges = new RegExp(`^${pydanticNumericSpace}+|${pydanticNumericSpace}+$`, 'gu');
766
+ function optionalPydanticInteger(value) {
767
+ if (value === undefined)
768
+ return undefined;
769
+ if (!pydanticIntegerPattern.test(value))
770
+ return value;
771
+ const parsed = Number(value.replace(pydanticNumericEdges, '').replaceAll('_', ''));
772
+ return Number.isSafeInteger(parsed) ? parsed : value;
773
+ }
774
+ function optionalPydanticFloat(value) {
775
+ if (value === undefined)
776
+ return undefined;
777
+ if (!pydanticFloatPattern.test(value))
778
+ return value;
779
+ const normalized = value.replace(pydanticNumericEdges, '').replaceAll('_', '');
780
+ const parsed = Number(normalized.toLowerCase().replace('infinity', 'Infinity').replace('inf', 'Infinity'));
781
+ return Number.isNaN(parsed) && !/^[+-]?nan$/iu.test(normalized) ? value : parsed;
782
+ }
783
+ function emptyAsUnset(value) {
784
+ return value === '' ? undefined : value;
785
+ }
786
+ function rawEnvironmentValue(value) {
787
+ return value;
788
+ }
789
+ function requiredSetting(value, name) {
790
+ const normalized = stripLikePython(value);
791
+ if (normalized === '')
792
+ throw new ConfigurationError(`${name} 不能为空`);
793
+ return normalized;
794
+ }
795
+ function requiredCredential(value, name) {
796
+ const normalized = stripLikePython(value ?? '');
797
+ if (normalized === '')
798
+ throw new ConfigurationError(`缺少 ${name}`);
799
+ return normalized;
800
+ }
801
+ function secureEndpoint(value, scheme, name) {
802
+ let normalized = stripLikePython(value);
803
+ while (normalized.endsWith('/'))
804
+ normalized = normalized.slice(0, -1);
805
+ const schemeSeparator = normalized.indexOf('://');
806
+ const authorityTail = schemeSeparator < 0 ? '' : normalized.slice(schemeSeparator + 3);
807
+ const authorityEnd = authorityTail.search(/[/?#]/u);
808
+ const authority = authorityEnd < 0 ? authorityTail : authorityTail.slice(0, authorityEnd);
809
+ let parsed = null;
810
+ try {
811
+ parsed = new URL(normalized);
812
+ }
813
+ catch {
814
+ // The fixed error below deliberately does not retain the submitted URL.
815
+ }
816
+ const valid = parsed?.protocol === `${scheme}:` && parsed.hostname !== ''
817
+ && !authority.includes('@') && parsed.username === '' && parsed.password === ''
818
+ && parsed.hash === '';
819
+ if (!valid) {
820
+ throw new ConfigurationError(`${name} 必须是安全的 ${scheme}:// 地址`);
821
+ }
822
+ return normalized;
823
+ }
824
+ function compareStrings(left, right) {
825
+ return left < right ? -1 : left > right ? 1 : 0;
826
+ }
827
+ function configurationFieldName(field) {
828
+ const aliases = {
829
+ ark_api_key: 'ARK_API_KEY',
830
+ deepseek_api_key: 'DEEPSEEK_API_KEY',
831
+ dashscope_api_key: 'DASHSCOPE_API_KEY',
832
+ doubao_asr_api_key: 'DOUBAO_ASR_API_KEY',
833
+ doubao_bigmodel_api_key: 'DOUBAO_BIGMODEL_API_KEY',
834
+ tavily_api_key: 'TAVILY_API_KEY',
835
+ openrouter_api_key: 'OPENROUTER_API_KEY',
836
+ };
837
+ return aliases[field] ?? field.toUpperCase();
838
+ }
839
+ /** Injected settings never trigger ambient filesystem reads. Production passes its loaded registry explicitly. */
840
+ export function capabilitiesFromSettings(settings) {
841
+ const needsDashscopeSearch = settings.search_mcp_url === ''
842
+ && (settings.search_provider === 'mcp' || !settings.tavily_api_key?.trim());
843
+ return withoutUncredentialedModules(parseCapabilityRegistry({ version: 1, modules: {
844
+ camera: { enabled: settings.camera_module_enabled },
845
+ search: { provider: settings.search_provider, ...(settings.search_mcp_url === '' ? {} : { mcp: {
846
+ url: settings.search_mcp_url, tool: settings.search_mcp_tool,
847
+ } }) },
848
+ } }, {
849
+ ...(!needsDashscopeSearch || settings.dashscope_api_key === null ? {} : { DASHSCOPE_API_KEY: settings.dashscope_api_key }),
850
+ ...(settings.search_provider !== 'tavily' || settings.tavily_api_key === null ? {} : { TAVILY_API_KEY: settings.tavily_api_key }),
851
+ ...(settings.search_mcp_tool === 'web_search' ? {} : { SEARCH_MCP_TOOL: settings.search_mcp_tool }),
852
+ }), settings);
853
+ }
854
+ export function cascadedCredentialField(provider) {
855
+ return provider === 'self-hosted' ? 'self_hosted_llm_api_key' : provider === 'qwen' ? 'dashscope_api_key' : `${provider}_api_key`;
856
+ }
857
+ //# sourceMappingURL=config.js.map