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,139 @@
1
+ import { loadCapabilityRegistry, parseCapabilityRegistry } from './capability-registry.js';
2
+ import { isAbsolute } from 'node:path';
3
+ import { z } from 'zod';
4
+ import { loadSettings, requireIntegratedRealtime, } from './config.js';
5
+ import { requireSelectedCascadedRealtimeConfig } from './cascaded-realtime-config.js';
6
+ import { stripLikePython } from '../text/python-text.js';
7
+ const diagnosticIdSchema = z.enum([
8
+ 'node.version',
9
+ 'configuration.parse',
10
+ 'provider.qwen',
11
+ 'provider.stepfun', 'provider.openai', 'provider.gemini',
12
+ 'provider.volcengine',
13
+ 'executors.contract',
14
+ 'search.credential',
15
+ 'camera.source',
16
+ ]);
17
+ const diagnosticCodeSchema = z.enum([
18
+ 'node_version_supported',
19
+ 'node_version_unsupported',
20
+ 'configuration_valid',
21
+ 'configuration_invalid',
22
+ 'qwen_configuration_valid',
23
+ 'qwen_configuration_invalid',
24
+ 'stepfun_configuration_valid',
25
+ 'stepfun_configuration_invalid',
26
+ 'openai_configuration_valid', 'openai_configuration_invalid',
27
+ 'gemini_configuration_valid', 'gemini_configuration_invalid',
28
+ 'volcengine_configuration_valid',
29
+ 'volcengine_configuration_invalid',
30
+ 'executor_configuration_valid',
31
+ 'executor_configuration_invalid',
32
+ 'search_credential_present',
33
+ 'search_credential_missing',
34
+ 'camera_local_selected',
35
+ 'camera_file_selected',
36
+ 'camera_source_invalid',
37
+ 'diagnostic_internal_failure',
38
+ ]);
39
+ const diagnosticCheckSchema = z.object({
40
+ id: diagnosticIdSchema,
41
+ status: z.enum(['pass', 'fail', 'unavailable']),
42
+ code: diagnosticCodeSchema,
43
+ }).strict();
44
+ export const diagnosticReportSchema = z.object({
45
+ schema_version: z.literal(1),
46
+ runtime: z.literal('node'),
47
+ ok: z.boolean(),
48
+ checks: z.array(diagnosticCheckSchema).max(7),
49
+ }).strict();
50
+ export function buildDiagnosticReport(options) {
51
+ const checks = [nodeVersionCheck(options.nodeVersion)];
52
+ let settings;
53
+ let capabilities;
54
+ try {
55
+ settings = loadSettings(options.environment);
56
+ capabilities = options.environment === process.env || options.environment.CAPABILITIES_CONFIG
57
+ ? loadCapabilityRegistry({ environment: options.environment })
58
+ : parseCapabilityRegistry({ version: 1 }, options.environment);
59
+ checks.push(check('configuration.parse', 'pass', 'configuration_valid'));
60
+ }
61
+ catch {
62
+ checks.push(check('configuration.parse', 'fail', 'configuration_invalid'));
63
+ return Promise.resolve(report(checks));
64
+ }
65
+ checks.push(providerCheck(settings));
66
+ checks.push(executorCheck(settings, options.executorChecks ?? []));
67
+ checks.push(searchCheck(capabilities));
68
+ try {
69
+ checks.push(cameraCheck(options.environment));
70
+ }
71
+ catch {
72
+ checks.push(check('camera.source', 'fail', 'diagnostic_internal_failure'));
73
+ }
74
+ return Promise.resolve(report(checks));
75
+ }
76
+ function nodeVersionCheck(version) {
77
+ const match = /^v?([0-9]+)\.([0-9]+)\.([0-9]+)$/u.exec(version);
78
+ if (match === null)
79
+ return check('node.version', 'fail', 'node_version_unsupported');
80
+ const major = Number(match[1]);
81
+ const minor = Number(match[2]);
82
+ const supported = major > 22 || (major === 22 && minor >= 12);
83
+ return supported
84
+ ? check('node.version', 'pass', 'node_version_supported')
85
+ : check('node.version', 'fail', 'node_version_unsupported');
86
+ }
87
+ function providerCheck(settings) {
88
+ if (settings.pipeline_mode === 'integrated') {
89
+ try {
90
+ requireIntegratedRealtime(settings);
91
+ return check(`provider.${settings.integrated_provider}`, 'pass', `${settings.integrated_provider}_configuration_valid`);
92
+ }
93
+ catch {
94
+ return check(`provider.${settings.integrated_provider}`, 'fail', `${settings.integrated_provider}_configuration_invalid`);
95
+ }
96
+ }
97
+ try {
98
+ requireSelectedCascadedRealtimeConfig(settings);
99
+ return check('provider.volcengine', 'pass', 'volcengine_configuration_valid');
100
+ }
101
+ catch {
102
+ return check('provider.volcengine', 'fail', 'volcengine_configuration_invalid');
103
+ }
104
+ }
105
+ function executorCheck(settings, executorChecks) {
106
+ for (const diagnose of executorChecks) {
107
+ const result = diagnose(settings);
108
+ if (result !== null && result.status === 'fail')
109
+ return result;
110
+ }
111
+ return check('executors.contract', 'pass', 'executor_configuration_valid');
112
+ }
113
+ function searchCheck(capabilities) {
114
+ if (!capabilities.modules.search.enabled || capabilities.modules.search.provider === 'mcp')
115
+ return check('search.credential', 'pass', 'search_credential_present');
116
+ return stripLikePython(capabilities.modules.search.tavily.apiKey ?? '') === ''
117
+ ? check('search.credential', 'fail', 'search_credential_missing')
118
+ : check('search.credential', 'pass', 'search_credential_present');
119
+ }
120
+ function cameraCheck(environment) {
121
+ const configured = stripLikePython(environment.DESKTOP_VIDEO_FILE ?? '');
122
+ if (configured === '')
123
+ return check('camera.source', 'pass', 'camera_local_selected');
124
+ return isAbsolute(configured)
125
+ ? check('camera.source', 'pass', 'camera_file_selected')
126
+ : check('camera.source', 'fail', 'camera_source_invalid');
127
+ }
128
+ function check(id, status, code) {
129
+ return Object.freeze({ id, status, code });
130
+ }
131
+ function report(checks) {
132
+ return Object.freeze({
133
+ schema_version: 1,
134
+ runtime: 'node',
135
+ ok: checks.every(item => item.status !== 'fail'),
136
+ checks: Object.freeze([...checks]),
137
+ });
138
+ }
139
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1,202 @@
1
+ const rows = [
2
+ ['SELF_HOSTED_ASR_URL', 'core', false, true, 'never', null, 'Self-hosted asr url; dedicated credential only.', '自托管 ASR_URL,仅使用专用凭据。'],
3
+ ['SELF_HOSTED_LLM_BASE_URL', 'core', false, true, 'never', null, 'Self-hosted llm base url; dedicated credential only.', '自托管 LLM_BASE_URL,仅使用专用凭据。'],
4
+ ['SELF_HOSTED_TTS_URL', 'core', false, true, 'never', null, 'Self-hosted tts url; dedicated credential only.', '自托管 TTS_URL,仅使用专用凭据。'],
5
+ ['SELF_HOSTED_ASR_API_KEY', 'core', true, true, 'never', null, 'Self-hosted asr api key; dedicated credential only.', '自托管 ASR_API_KEY,仅使用专用凭据。'],
6
+ ['SELF_HOSTED_LLM_API_KEY', 'core', true, true, 'never', null, 'Self-hosted llm api key; dedicated credential only.', '自托管 LLM_API_KEY,仅使用专用凭据。'],
7
+ ['SELF_HOSTED_TTS_API_KEY', 'core', true, true, 'never', null, 'Self-hosted tts api key; dedicated credential only.', '自托管 TTS_API_KEY,仅使用专用凭据。'],
8
+ ['NOVA_WORKBENCH_ACCEPTANCE_REPORT', 'host_private', false, false, 'never', null, 'Workbench acceptance report path.', 'Workbench acceptance report path.'],
9
+ ['NOVA_WORKBENCH_ACCEPTANCE_MANIFEST', 'host_private', false, false, 'never', null, 'Workbench acceptance manifest path.', 'Workbench acceptance manifest path.'],
10
+ ['XDG_CONFIG_HOME', 'host_private', false, false, 'never', null, 'Host configuration directory.', 'Host configuration directory.'],
11
+ ['GIT_CONFIG_GLOBAL', 'host_private', false, false, 'never', null, 'Host Git configuration file.', 'Host Git configuration file.'],
12
+ ['OPENROUTER_API_KEY', 'core', true, true, 'never', null, 'OpenRouter credential for Jev.', 'OpenRouter credential for Jev.'],
13
+ ['COMPOSIO_API_KEY', 'core', true, true, 'never', null, 'Composio application connection credential.', 'Composio application connection credential.'],
14
+ ['MEMORY_LEDGER_PATH', 'core', false, true, 'never', '~/.nova-audio-agent/workspace-graph.sqlite', 'Canonical memory ledger SQLite path; retains the v0.3 storage location.', '统一记忆账本 SQLite 路径,兼容 v0.3 已有存储位置。'],
15
+ ['WORKSPACE_GRAPH_PATH', 'host_private', false, false, 'never', null, 'Legacy alias for the memory ledger path.', '记忆账本路径的历史兼容别名。'],
16
+ ['AOQ_API_HOST', 'host_private', false, false, 'never', null, 'AOQ API host used by the remote server.', '远程服务使用的北京 AOQ API 主机。'],
17
+ ['SERVER_MEDIA_MODE', 'host_private', false, false, 'never', null, 'Remote media mode: relay, aoq_chat or aoq_runtime.', '远程媒体模式:relay、aoq_chat 或 aoq_runtime。'],
18
+ ['BACKEND', 'host_private', false, false, 'never', 'node', 'Node-only desktop backend guard.', '仅 Node 的桌面后端守卫。'],
19
+ ['MODEL_BASE_URL', 'core', false, true, 'never', 'DashScope compatible endpoint', 'FastBrain compatible API endpoint.', 'FastBrain 兼容 API 地址。'],
20
+ ['MODEL_API_KEY', 'core', true, true, 'never', null, 'Optional generic support-model API credential override.', '可选的通用辅助模型 API 凭据覆盖。'],
21
+ ['FAST_MODEL', 'core', false, true, 'never', 'qwen3-vl-plus', 'FastBrain model.', 'FastBrain 模型。'],
22
+ ['WATCH_MODEL', 'core', false, true, 'never', 'fast model', 'Watch model override.', 'Watch 模型覆盖。'],
23
+ ['SUPPORT_MODEL', 'core', false, true, 'never', 'qwen-plus', 'Shared support LLM for proactive communication, intake, task verification and personal content.', '主动沟通、任务接入、任务验收和个人内容共用的辅助 LLM。'],
24
+ ['COMPRESSOR_MODEL', 'core', false, true, 'never', 'qwen-flash', 'Memory compressor model.', '记忆压缩模型。'],
25
+ ['PIPELINE_MODE', 'core', false, true, 'never', 'integrated', 'Product pipeline shape: integrated or cascaded.', '产品管线形态:集成或级联。'],
26
+ ['NEWS_LANGUAGE', 'core', false, true, 'never', 'en', 'Native RSS language: zh-CN or en. Desktop supplies OS language independently of UI preference; applied at runtime start.', '原生 RSS 语言:zh-CN 或 en;桌面传入系统语言,独立于界面偏好,运行时启动时生效。'],
27
+ ['PROMPT_LANGUAGE', 'core', false, true, 'never', 'zh-CN', 'AI system prompt language: zh-CN or en; desktop supplies its saved preference.', 'AI system prompt 语言:zh-CN 或 en;桌面端会提供其保存的偏好。'],
28
+ ['CONVERSATION_VISION_ENABLED', 'camera', false, true, 'never', 'false', 'Attach a default-camera frame to user turns on verified cascaded VLMs.', '为已确认支持图片的级联模型附加默认摄像头画面。'],
29
+ ['MONITOR_CAMERA_DEVICE_ID', 'camera', false, true, 'never', null, 'Exact monitor camera device ID; empty uses the default device.', '监控摄像头设备 ID;空值使用默认设备。'],
30
+ ['CAMERA_MODULE_ENABLED', 'camera', false, true, 'never', 'true', 'Enable independent Vision monitoring.', '启用独立视觉监控。'],
31
+ ['INTEGRATED_PROVIDER', 'core', false, true, 'never', 'qwen', 'Integrated realtime provider.', '集成实时提供方。'],
32
+ ['CASCADE_ENDPOINTING_PROVIDER', 'core', false, true, 'never', 'auto', 'Cascaded endpointing provider.', '级联端点检测提供方。'],
33
+ ['CASCADE_ASR_PROVIDER', 'core', false, true, 'never', 'volcengine', 'Cascaded ASR provider.', '级联 ASR 提供方。'],
34
+ ['CASCADE_LLM_PROVIDER', 'core', false, true, 'never', 'deepseek', 'Cascaded LLM provider.', '级联 LLM 提供方。'],
35
+ ['CASCADE_LLM_MODEL', 'core', false, true, 'never', 'provider default', 'Cascaded LLM model override.', '级联 LLM 模型覆盖。'],
36
+ ['CASCADE_TTS_PROVIDER', 'core', false, true, 'never', 'volcengine', 'Cascaded TTS provider.', '级联 TTS 提供方。'],
37
+ ['EXECUTOR', 'core', false, true, 'never', null, 'Optional single executor selector; unset selects none.', '可选的单执行器选择器;未设置时不选择执行器。'],
38
+ ['EXECUTORS', 'core', false, true, 'never', null, 'Optional ordered executor list; unset selects none.', '可选的有序执行器列表;未设置时不选择执行器。'],
39
+ ['CODING_PROGRESS_NARRATION', 'core', false, true, 'never', 'smart', 'Coding progress narration.', '编程进度播报模式。'],
40
+ ['PROACTIVITY_PRESET', 'core', false, true, 'never', 'balanced', 'Proactivity preset.', '主动性预设。'],
41
+ ['SUGGESTION_COOLDOWN', 'core', false, true, 'never', 'preset', 'Suggestion cooldown override in seconds.', '建议冷却秒数覆盖。'],
42
+ ['FRESH_WINDOW', 'core', false, true, 'never', 'preset', 'Fresh-context window override in seconds.', '新鲜上下文窗口秒数覆盖。'],
43
+ ['CODEX_APPROVAL_MODE', 'codex', false, true, 'never', 'ask', 'Coding approval mode for Codex and ACP backends; Pi refuses ask.', '编程审批模式,适用于 Codex 与 ACP 执行器;Pi 不接受询问模式。'],
44
+ ['CLARIFICATION_DEPTH', 'core', false, true, 'never', 'balanced', 'Maximum clarification depth for intake.', '意图理解的最大澄清深度。'],
45
+ ['PLAN_READBACK', 'core', false, true, 'never', 'summary', 'Plan readback mode.', '规划回读模式。'],
46
+ ['GENERATE_PLAN', 'core', false, true, 'never', 'true', 'Generate a plan before execution.', '执行前生成计划。'],
47
+ ['PLANNER_MODEL', 'core', false, true, 'never', null, 'Optional planner model override.', '可选的规划模型覆盖。'],
48
+ ['PROGRESS_BUBBLES', 'core', false, true, 'never', 'milestones', 'Progress bubble display mode.', '进度气泡显示模式。'],
49
+ ['CAPABILITIES_CONFIG', 'core', false, true, 'never', '~/.nova-audio-agent/capabilities.json', 'Capabilities registry path.', '能力注册表路径。'],
50
+ ['SEARCH_PROVIDER', 'search', false, true, 'never', 'tavily', 'CLI or CI search provider override.', 'CLI 或 CI 搜索提供方覆盖。'],
51
+ ['SEARCH_MCP_URL', 'search', false, true, 'never', null, 'Web search MCP endpoint override; unset uses the verified Bailian preset when MCP is selected.', '网页搜索 MCP 地址覆盖;选择 MCP 且未设置时使用已核对的百炼预设。'],
52
+ ['SEARCH_MCP_TOOL', 'search', false, true, 'never', 'web_search', 'Web search MCP tool override (generic default web_search; Bailian preset search_pro).', '网页搜索 MCP 工具覆盖(通用默认 web_search;百炼预设 search_pro)。'],
53
+ ['MEMORY_PRERECALL_ENABLED', 'core', false, true, 'never', 'false', 'Optionally prefetch context for text replies; voice uses profile and summary.', '文本回复可选预检索;语音默认使用个人资料与摘要。'],
54
+ ['MEMORY_CONSOLIDATION_ENABLED', 'core', false, true, 'never', 'true', 'Generate derived memory summaries daily.', '每日生成派生记忆摘要。'],
55
+ ['MEMORY_CONSOLIDATION_HOUR', 'core', false, true, 'never', '0', 'Local hour for daily memory consolidation (0-23).', '每日记忆整理时间(0-23 时)。'],
56
+ ['MEMORY_CONSOLIDATION_TIMEZONE', 'core', false, true, 'never', 'UTC', 'IANA timezone for daily memory consolidation.', '每日记忆整理采用的 IANA 时区。'],
57
+ ['KNOWLEDGE_PATH', 'core', false, true, 'never', '~/.nova-audio-agent/knowledge.sqlite', 'Knowledge SQLite database path.', '知识库 SQLite 数据库路径。'],
58
+ ['EMBEDDING_PROVIDER', 'core', false, true, 'never', 'dashscope', 'Knowledge embedding provider.', '知识库 embedding 提供方。'],
59
+ ['EMBEDDING_MODEL', 'core', false, true, 'never', 'text-embedding-v4', 'Knowledge embedding model.', '知识库 embedding 模型。'],
60
+ ['MEMORY_BACKEND', 'core', false, false, 'never', null, 'Removed; rejected in favor of MEMORY_CONNECTION.', '已移除;使用时会报错,请改用 MEMORY_CONNECTION。'],
61
+ ['MEMORY_CONNECTION', 'core', false, true, 'never', 'local', 'Memory connection: disabled, local, or remote.', '记忆连接:disabled、local 或 remote。'],
62
+ ['MEMORY_PROVIDER', 'core', false, true, 'never', null, 'Local engine: voicemem (default; unified ledger) or explicit mem0. Remote engines are service-owned.', '本地引擎:voicemem(默认,统一账本)或显式选择 mem0。远程引擎由服务端选择。'],
63
+ ['BLACKBOARD_PATH', 'core', false, true, 'never', '~/.nova-audio-agent/blackboard.sqlite', 'Conversation recovery database path.', '会话恢复数据库路径。'],
64
+ ['BLACKBOARD_OWNER_ID', 'core', false, true, 'never', 'local', 'Stable conversation recovery owner.', '稳定的会话恢复所有者。'],
65
+ ['MEMORY_URL', 'core', false, true, 'when_selected', null, 'HTTP memory service origin; HTTPS or numeric loopback HTTP.', 'HTTP 记忆服务地址;仅 HTTPS 或数字回环 HTTP。'],
66
+ ['MEMORY_TOKEN', 'core', true, true, 'when_selected', null, 'Host-issued identity-bound memory bearer token.', '宿主提供的身份绑定记忆令牌。'],
67
+ ['MEMORY_PATH', 'core', false, true, 'never', '~/.nova-audio-agent/memory.sqlite', 'Personal memory database path.', '个人记忆数据库路径。'],
68
+ ['MEMORY_USER_ID', 'core', false, true, 'never', 'local', 'Stable personal memory user identity.', '稳定的个人记忆用户身份。'],
69
+ ['DASHSCOPE_API_KEY', 'qwen', true, true, 'when_selected', null, 'Qwen realtime credential.', 'Qwen 实时凭据。'],
70
+ ['QWEN_REALTIME_URL', 'qwen', false, true, 'never', 'DashScope realtime endpoint', 'Qwen secure realtime endpoint.', 'Qwen 安全实时地址。'],
71
+ ['QWEN_REALTIME_MODEL', 'qwen', false, true, 'never', 'qwen-audio-3.0-realtime-plus', 'Qwen realtime model.', 'Qwen 实时模型。'],
72
+ ['QWEN_REALTIME_VOICE', 'qwen', false, true, 'never', 'longanqian', 'Qwen realtime voice.', 'Qwen 实时音色。'],
73
+ ['OPENAI_API_KEY', 'openai', true, true, 'when_selected', null, 'OpenAI API credential.', 'OpenAI API 凭据。'],
74
+ ['OPENAI_REALTIME_URL', 'openai', false, true, 'never', 'wss://api.openai.com/v1/realtime', 'OpenAI secure realtime endpoint.', 'OpenAI 安全实时地址。'],
75
+ ['OPENAI_REALTIME_MODEL', 'openai', false, true, 'never', 'gpt-realtime-2.1-mini', 'OpenAI realtime model.', 'OpenAI 实时模型。'],
76
+ ['OPENAI_REALTIME_VOICE', 'openai', false, true, 'never', 'marin', 'OpenAI realtime voice.', 'OpenAI 实时音色。'],
77
+ ['GEMINI_API_KEY', 'gemini', true, true, 'when_selected', null, 'Gemini API credential.', 'Gemini API 凭据。'],
78
+ ['GEMINI_ASR_MODEL', 'gemini', false, true, 'never', 'gemini-3.5-flash', 'Gemini transcription model.', 'Gemini 转录模型。'],
79
+ ['GEMINI_TTS_MODEL', 'gemini', false, true, 'never', 'gemini-3.8-flash-tts', 'Gemini speech generation model.', 'Gemini 语音生成模型。'],
80
+ ['GEMINI_TTS_VOICE', 'gemini', false, true, 'never', 'Kore', 'Gemini speech generation voice.', 'Gemini 语音生成音色。'],
81
+ ['GEMINI_REALTIME_URL', 'gemini', false, true, 'never', 'wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent', 'Gemini secure realtime endpoint.', 'Gemini 安全实时地址。'],
82
+ ['GEMINI_REALTIME_MODEL', 'gemini', false, true, 'never', 'gemini-3.8-live', 'Gemini realtime model.', 'Gemini 实时模型。'],
83
+ ['GEMINI_REALTIME_VOICE', 'gemini', false, true, 'never', 'Kore', 'Gemini realtime voice.', 'Gemini 实时音色。'],
84
+ ['STEPFUN_API_KEY', 'stepfun', true, true, 'when_selected', null, 'StepFun realtime credential.', 'StepFun 实时凭据。'],
85
+ ['STEPFUN_REALTIME_URL', 'stepfun', false, true, 'never', 'wss://api.stepfun.com/v1/realtime', 'StepFun secure realtime endpoint.', 'StepFun 安全实时地址。'],
86
+ ['STEPFUN_REALTIME_MODEL', 'stepfun', false, true, 'never', 'stepaudio-3-realtime-preview', 'StepFun realtime model.', 'StepFun 实时模型。'],
87
+ ['STEPFUN_REALTIME_VOICE', 'stepfun', false, true, 'never', '', 'StepFun realtime voice; empty uses the service default.', 'StepFun 实时音色;留空使用服务默认音色。'],
88
+ ['QWEN_CONTROLLED_GUARD_RECONNECT', 'qwen', false, true, 'never', 'false', 'Allow controlled Guard reconnect.', '允许受控 Guard 重连。'],
89
+ ['QWEN_GUARD_HISTORY_RECOVERY', 'qwen', false, true, 'never', 'none', 'Guard history recovery mode.', 'Guard 历史恢复模式。'],
90
+ ['QWEN_GUARD_HISTORY_PAIRS', 'qwen', false, true, 'never', '4', 'Guard history pair count.', 'Guard 历史对话对数。'],
91
+ ['DEEPSEEK_API_KEY', 'deepseek', true, true, 'when_selected', null, 'Official DeepSeek cascaded LLM credential.', 'DeepSeek 官方级联 LLM 凭据。'],
92
+ ['ARK_API_KEY', 'ark', true, true, 'when_selected', null, 'Ark cascaded LLM credential.', '方舟级联 LLM 凭据。'],
93
+ ['DOUBAO_ASR_API_KEY', 'volcengine', true, true, 'never', 'Doubao big-model key', 'Volcengine ASR credential override.', '火山 ASR 凭据覆盖。'],
94
+ ['DOUBAO_BIGMODEL_API_KEY', 'volcengine', true, true, 'when_selected', null, 'Volcengine TTS and ASR fallback credential.', '火山 TTS 及 ASR 回退凭据。'],
95
+ ['VOLCENGINE_ARK_BASE_URL', 'ark', false, true, 'never', 'Volcengine Ark endpoint', 'Ark secure endpoint.', '方舟安全地址。'],
96
+ ['DOUBAO_ASR_ENDPOINT', 'volcengine', false, true, 'never', 'Doubao ASR endpoint', 'Doubao ASR secure endpoint.', '豆包 ASR 安全地址。'],
97
+ ['DOUBAO_ASR_RESOURCE_ID', 'volcengine', false, true, 'never', 'volc.seedasr.sauc.duration', 'Doubao ASR resource ID.', '豆包 ASR 资源 ID。'],
98
+ ['DOUBAO_ASR_VOICEPRINT_ENABLED', 'volcengine', false, true, 'never', 'false', 'Verify the registered speaker before accepting ASR text.', '只接收已注册说话人的 ASR 文本。'],
99
+ ['DOUBAO_ASR_VOICEPRINT_ID', 'volcengine', false, true, 'never', '', 'Registered voiceprint UUID.', '已注册声纹 UUID。'],
100
+ ['DOUBAO_ASR_VOICEPRINT_HEALTH_URL', 'volcengine', false, true, 'never', '', 'Disable verification when this HTTPS health endpoint is unavailable.', '健康检查失败时停用声纹验证的 HTTPS 地址。'],
101
+ ['DOUBAO_ASR_VOICEPRINT_NAME', 'volcengine', false, true, 'never', '', 'Exact registered SpeakerName.', '注册时的完整 SpeakerName。'],
102
+ ['DOUBAO_ASR_CHUNK_MS', 'volcengine', false, true, 'never', '200', 'ASR input chunk duration.', 'ASR 输入分块时长。'],
103
+ ['DOUBAO_TTS_ENDPOINT', 'volcengine', false, true, 'never', 'Doubao TTS endpoint', 'Doubao TTS secure endpoint.', '豆包 TTS 安全地址。'],
104
+ ['DOUBAO_TTS_RESOURCE_ID', 'volcengine', false, true, 'never', 'seed-tts-2.0', 'Doubao TTS resource ID.', '豆包 TTS 资源 ID。'],
105
+ ['DOUBAO_TTS_VOICE', 'volcengine', false, true, 'never', 'zh_female_vv_uranus_bigtts', 'Doubao TTS voice.', '豆包 TTS 音色。'],
106
+ ['DOUBAO_TTS_OUTPUT_SAMPLE_RATE', 'volcengine', false, true, 'never', '24000', 'Doubao TTS output sample rate.', '豆包 TTS 输出采样率。'],
107
+ ['VOLCENGINE_VAD_THRESHOLD', 'volcengine', false, true, 'never', '0.5', 'VAD speech threshold.', 'VAD 语音阈值。'],
108
+ ['VOLCENGINE_VAD_PRE_ROLL_MS', 'volcengine', false, true, 'never', '260', 'VAD pre-roll duration.', 'VAD 预滚时长。'],
109
+ ['VOLCENGINE_VAD_MIN_SPEECH_MS', 'volcengine', false, true, 'never', '250', 'VAD minimum speech duration.', 'VAD 最短语音时长。'],
110
+ ['VOLCENGINE_VAD_SILENCE_END_MS', 'volcengine', false, true, 'never', '300', 'VAD silence endpoint duration.', 'VAD 静音断句时长。'],
111
+ ['VOLCENGINE_VAD_SPEECH_PAD_MS', 'volcengine', false, true, 'never', '30', 'VAD speech padding.', 'VAD 语音补边。'],
112
+ ['VOLCENGINE_VAD_MAX_UTTERANCE_MS', 'volcengine', false, true, 'never', '60000', 'VAD maximum utterance duration.', 'VAD 最长话语时长。'],
113
+ ['CODEX_WORKSPACE', 'codex', false, true, 'when_selected', null, 'Host-approved Codex workspace.', '主机批准的 Codex 工作区。'],
114
+ ['CODEX_BIN', 'codex', false, true, 'never', 'codex', 'Host-approved Codex app-server binary.', '主机批准的 Codex app-server 可执行文件。'],
115
+ ['CODEX_PREFIX_ARGS', 'codex', false, false, 'never', '[]', 'Host-approved direct argv prefix for an official Codex launcher.', '宿主批准的官方 Codex 启动器直接 argv 前缀。'],
116
+ ['FEISHU_CLI_PATH', 'host_private', false, false, 'never', 'lark-cli', 'Host-configured Feishu CLI executable, version 1.0.69 or newer.', '宿主配置的飞书 CLI 路径,版本至少 1.0.69。'],
117
+ ['CODEX_RESOURCES_PATH', 'codex', false, false, 'never', 'codex', 'Host-owned native resource root.', '宿主持有的原生资源根目录。'],
118
+ ['CODEX_API_KEY', 'codex', true, true, 'never', 'Codex login', 'Optional Codex credential override.', '可选 Codex 凭据覆盖。'],
119
+ ['CODEX_PREWARM', 'codex', false, true, 'never', 'true', 'Prewarm Codex app-server.', '预热 Codex app-server。'],
120
+ ['CODEX_MANAGED_ROOT', 'codex', false, true, 'never', '~/.nova-audio-agent/workspaces', 'Managed project root.', '托管项目根目录。'],
121
+ ['CODEX_PROJECT_STATE_ROOT', 'codex', false, true, 'never', '~/.nova-audio-agent', 'Project state root.', '项目状态根目录。'],
122
+ ['CODEX_WORKING_INTERVAL', 'codex', false, true, 'never', '30', 'Codex progress interval in seconds.', 'Codex 进度间隔秒数。'],
123
+ ['TAVILY_API_KEY', 'search', true, true, 'when_selected', null, 'Tavily search credential.', 'Tavily 搜索凭据。'],
124
+ ['DESKTOP_VIDEO_FILE', 'camera', false, true, 'never', null, 'Absolute deterministic desktop video input.', '桌面确定性视频输入的绝对路径。'],
125
+ ['REALTIME_TELEMETRY', 'telemetry', false, true, 'never', '~/.nova-audio-agent/realtime-telemetry.jsonl', 'Source-runtime telemetry output path; set an empty value to disable.', '源码运行时遥测输出路径;设置为空值可禁用。'],
126
+ ['NOVA_ORB_OPAQUE', 'core', false, true, 'never', '0', 'Use an opaque desktop orb window.', '使用不透明桌面悬浮球窗口。'],
127
+ ['SERVER_PORT', 'host_private', false, false, 'when_selected', null, 'Fixed loopback remote server port.', '远程服务固定本地端口。'],
128
+ ['SERVER_TOKEN_FILE', 'host_private', true, false, 'when_selected', null, 'Absolute path to the private remote credential file.', '远程服务私有凭据文件的绝对路径。'],
129
+ ['DESKTOP_TOKEN', 'host_private', true, false, 'when_selected', null, 'Desktop transport handshake token.', '桌面传输握手令牌。'],
130
+ ['DESKTOP_READY_ENDPOINT', 'host_private', false, false, 'when_selected', null, 'Desktop readiness endpoint.', '桌面就绪端点。'],
131
+ ['DESKTOP_READY_FD', 'host_private', false, false, 'never', null, 'Legacy desktop readiness descriptor.', '旧桌面就绪描述符。'],
132
+ ['DEV_BACKEND_ENTRY', 'host_private', false, false, 'never', null, 'Unpackaged desktop backend entry override.', '未打包桌面的开发后端入口覆盖。'],
133
+ ['DEV_START_MUTED', 'host_private', false, false, 'never', null, 'Start the unpackaged desktop with microphone muted.', '未打包桌面以闭麦状态启动。'],
134
+ ['RELEASE_CAMERA_SMOKE', 'host_private', false, false, 'never', null, 'Packaged release camera capability sentinel.', '安装包发布相机能力哨兵。'],
135
+ ['RELEASE_SMOKE', 'host_private', false, false, 'never', null, 'Authenticated packaged lifecycle smoke mode.', '安装包认证生命周期冒烟模式。'],
136
+ ['DEVELOPER_DIR', 'host_private', false, false, 'never', null, 'Host Xcode developer directory used when binding an iOS Simulator.', '绑定 iOS 模拟器时使用的宿主 Xcode 开发者目录。'],
137
+ ['CODEX_HOME', 'host_private', false, false, 'never', null, 'Host Codex credential home.', '主机 Codex 凭据目录。'],
138
+ ['HOME', 'host_private', false, false, 'never', null, 'Host home directory.', '主机用户目录。'],
139
+ ['BROWSER_ENGINE', 'browser', false, true, 'never', 'chromium', 'Managed engine: chromium, firefox or webkit.', '专用引擎:chromium、firefox 或 webkit。'],
140
+ ['BROWSER_URL', 'browser', false, true, 'when_selected', null, 'Explicit starting URL; HTTPS or localhost HTTP.', '明确的起始 URL;HTTPS 或本机 HTTP。'],
141
+ ['BROWSER_HEADLESS', 'browser', false, true, 'never', 'true', 'Run the dedicated browser without occupying the foreground.', '专用浏览器是否在后台运行。'],
142
+ ['BROWSER_BASE_URL', 'browser', false, true, 'when_selected', null, 'Screenshot model endpoint.', '截图模型地址。'],
143
+ ['BROWSER_MODEL', 'browser', false, true, 'when_selected', null, 'Screenshot model identifier.', '截图模型名称。'],
144
+ ['BROWSER_MODEL_FAMILY', 'browser', false, true, 'when_selected', null, 'Verified screenshot model family.', '已核实的截图模型系列。'],
145
+ ['BROWSER_API_KEY', 'browser', true, true, 'when_selected', null, 'Screenshot model credential.', '截图模型凭据。'],
146
+ ['BROWSER_MAX_STEPS', 'browser', false, true, 'never', '30', 'Supervised browser action limit (1-100).', '受监督浏览器动作上限(1-100)。'],
147
+ ['BROWSER_TIMEOUT_SECONDS', 'browser', false, true, 'never', '600', 'Browser task deadline (1-1800 seconds).', '浏览器任务时限(1-1800 秒)。'],
148
+ ['BROWSER_SETTLE_MS', 'browser', false, true, 'never', '1000', 'Wait before observation and after actions.', '观察前和动作后稳定等待。'],
149
+ ['COMPUTER_DISPLAY_ID', 'computer', false, true, 'when_selected', null, 'Exact local display ID (Mac index or Windows DISPLAY name); display mode requires one display. Background Safari uses 0.', '明确的本机显示器 ID(Mac 索引或 Windows DISPLAY 名);全屏模式仅支持单显示器,后台 Safari 模式使用 0。'],
150
+ ['COMPUTER_MAC_WINDOW_PID', 'computer', false, true, 'never', null, 'Opt-in background Safari process ID; requires COMPUTER_MAC_WINDOW_ID and macOS 14+.', '后台 Safari 进程 ID;须同时配置窗口 ID,要求 macOS 14+。'],
151
+ ['COMPUTER_MAC_WINDOW_ID', 'computer', false, true, 'never', null, 'Exact Safari native window ID; must remain the Safari key window. No foreground fallback.', 'Safari 原生窗口 ID;须保持为 Safari 键窗口,不自动切换前台。'],
152
+ ['COMPUTER_BASE_URL', 'computer', false, true, 'when_selected', null, 'GUI model endpoint receiving desktop screenshots.', '接收桌面截图的 GUI 模型地址。'],
153
+ ['COMPUTER_MODEL', 'computer', false, true, 'when_selected', null, 'Desktop GUI model identifier.', '桌面 GUI 模型名称。'],
154
+ ['COMPUTER_MODEL_FAMILY', 'computer', false, true, 'when_selected', null, 'Verified SDK GUI model family: auto-glm, auto-glm-multilingual or qwen3-vl.', '已核实的 GUI 模型系列:auto-glm、auto-glm-multilingual 或 qwen3-vl。'],
155
+ ['COMPUTER_API_KEY', 'computer', true, true, 'when_selected', null, 'Desktop GUI model credential.', '桌面 GUI 模型凭据。'],
156
+ ['COMPUTER_MAX_STEPS', 'computer', false, true, 'never', '30', 'Supervised desktop action limit (1-100).', '受监督桌面动作上限(1-100)。'],
157
+ ['COMPUTER_TIMEOUT_SECONDS', 'computer', false, true, 'never', '600', 'Desktop task deadline (1-1800 seconds).', '桌面任务时限(1-1800 秒)。'],
158
+ ['COMPUTER_CLICK_HOLD_MS', 'computer', false, true, 'never', '100', 'Mouse click hold duration (10-1000 milliseconds).', '鼠标点击按住时长(10-1000 毫秒)。'],
159
+ ['COMPUTER_SETTLE_MS', 'computer', false, true, 'never', '4000', 'Wait before observation and after actions (0-30000 milliseconds).', '观察前和动作后稳定等待(0-30000 毫秒)。'],
160
+ ['MOBILE_ENGINE', 'mobile', false, true, 'never', 'midscene', 'Phone execution engine; currently midscene only.', '手机执行引擎;当前仅支持 midscene。'],
161
+ ['MOBILE_DEVICE_TYPE', 'mobile', false, true, 'never', 'ios-simulator', 'Phone platform: android, ios or ios-simulator; native execution supports Android ADB and iOS Simulator.', '手机平台:android、ios 或 ios-simulator;原生执行支持 Android ADB 和 iOS 模拟器。'],
162
+ ['MOBILE_DEVICE_ID', 'mobile', false, true, 'when_selected', null, 'Exact iOS device or Simulator UDID, or Android ADB serial.', '明确的 iOS 设备或模拟器 UDID,或 Android ADB 序列号。'],
163
+ ['MOBILE_WDA_URL', 'mobile', false, true, 'never', 'http://127.0.0.1:8100', 'WebDriverAgent endpoint for the configured iOS device.', '配置的 iOS 设备 WebDriverAgent 地址。'],
164
+ ['MOBILE_BASE_URL', 'mobile', false, true, 'when_selected', null, 'Phone model endpoint receiving screenshots.', '接收手机截图的模型服务地址。'],
165
+ ['MOBILE_MODEL', 'mobile', false, true, 'when_selected', null, 'Phone model identifier.', '手机操作模型名称。'],
166
+ ['MOBILE_MODEL_FAMILY', 'mobile', false, true, 'when_selected', null, 'Explicit model family used by the phone execution engine.', '手机执行引擎使用的明确模型系列。'],
167
+ ['MOBILE_API_KEY', 'mobile', true, true, 'when_selected', null, 'Phone model credential.', '手机操作模型凭据。'],
168
+ ['MOBILE_MAX_STEPS', 'mobile', false, true, 'never', '30', 'Supervised phone task step limit (1-100).', '受监督手机任务步骤上限(1-100)。'],
169
+ ['MOBILE_TIMEOUT_SECONDS', 'mobile', false, true, 'never', '600', 'Phone task deadline (1-1800 seconds).', '手机任务截止时间(1-1800 秒)。'],
170
+ ['MOBILE_SETTLE_MS', 'mobile', false, true, 'never', '4000', 'Screen settling delay before the first observation and after actions (0-30000 milliseconds).', '首次观察前及动作后等待画面稳定的时间(0-30000 毫秒)。'],
171
+ ['AUTOGLM_PYTHON', 'autoglm', false, true, 'when_selected', null, 'Absolute AutoGLM Python executable.', 'AutoGLM Python 可执行文件绝对路径。'],
172
+ ['AUTOGLM_SOURCE_PATH', 'autoglm', false, true, 'when_selected', null, 'Pinned Open-AutoGLM checkout.', '固定版本 Open-AutoGLM 目录。'],
173
+ ['AUTOGLM_DEVICE_ID', 'autoglm', false, true, 'when_selected', null, 'Exact iOS UDID or Android ADB serial.', '明确的 iOS UDID 或 Android ADB 序列号。'],
174
+ ['AUTOGLM_DEVICE_TYPE', 'autoglm', false, true, 'never', 'ios', 'Phone platform: ios, ios-simulator or android.', '手机平台:ios、ios-simulator 或 android。'],
175
+ ['AUTOGLM_WDA_URL', 'autoglm', false, true, 'never', 'http://127.0.0.1:8100', 'WebDriverAgent endpoint for the configured iOS device.', '配置的 iOS 设备 WebDriverAgent 地址。'],
176
+ ['AUTOGLM_BASE_URL', 'autoglm', false, true, 'when_selected', null, 'Phone model endpoint receiving screenshots.', '接收手机截图的模型服务地址。'],
177
+ ['AUTOGLM_MODEL', 'autoglm', false, true, 'when_selected', null, 'Phone model identifier.', '手机操作模型名称。'],
178
+ ['AUTOGLM_API_KEY', 'autoglm', true, true, 'when_selected', null, 'Phone model credential.', '手机操作模型凭据。'],
179
+ ['AUTOGLM_MAX_STEPS', 'autoglm', false, true, 'never', '30', 'Supervised phone task step limit (1-100).', '受监督手机任务步骤上限(1-100)。'],
180
+ ['AUTOGLM_TIMEOUT_SECONDS', 'autoglm', false, true, 'never', '600', 'Phone task deadline (1-1800 seconds).', '手机任务截止时间(1-1800 秒)。'],
181
+ ['CODING_BACKEND', 'core', false, true, 'never', 'codex', 'Backend for new coding sessions: codex, opencode, codebuddy, pi or deepseek. Existing sessions keep theirs.', '新编程会话使用的执行器:codex、opencode、codebuddy、pi 或 deepseek;已有会话保持原执行器。'],
182
+ ['CODING_PROFILES', 'host_private', false, false, 'never', null, 'Desktop-supplied registry of immutable ACP configuration-source profiles.', '桌面端提供的不可变 ACP 配置来源档案。'],
183
+ ['OPENCODE_ACP_BIN', 'core', false, true, 'never', 'opencode on PATH', 'Absolute path to the OpenCode executable used for ACP.', '用于 ACP 的 OpenCode 可执行文件绝对路径。'],
184
+ ['CODEBUDDY_ACP_BIN', 'core', false, true, 'never', 'codebuddy on PATH', 'Absolute path to the CodeBuddy executable used for ACP.', '用于 ACP 的 CodeBuddy 可执行文件绝对路径。'],
185
+ ['PI_ACP_BIN', 'core', false, true, 'never', 'pi-acp on PATH', 'Absolute path to the pi-acp adapter executable.', 'pi-acp 适配器可执行文件绝对路径。'],
186
+ ['DEEPSEEK_ACP_BIN', 'core', false, true, 'never', 'dsh on PATH', 'Absolute path to the DeepSeek Harness (dsh) executable used for ACP.', '用于 ACP 的 DeepSeek Harness(dsh)可执行文件绝对路径。'],
187
+ ['CODING_MODULE_ENABLED', 'codex', false, true, 'never', 'true', 'Enable the coding module; the desktop turns it off when no Codex CLI is available.', '启用编程模块;桌面端在找不到 Codex CLI 时自动关闭。'],
188
+ ];
189
+ export const environmentContract = Object.freeze(rows.map(([name, owner, secret, publicValue, required, defaultLabel, descriptionEn, descriptionZh]) => Object.freeze({
190
+ name,
191
+ owner,
192
+ secret,
193
+ public: publicValue,
194
+ required,
195
+ defaultLabel,
196
+ descriptionEn,
197
+ descriptionZh,
198
+ })));
199
+ export function publicEnvironmentContract() {
200
+ return Object.freeze(environmentContract.filter(entry => entry.public));
201
+ }
202
+ //# sourceMappingURL=environment-contract.js.map
@@ -0,0 +1,23 @@
1
+ import { isIP } from 'node:net';
2
+ import { ConfigurationError } from './config.js';
3
+ /** Cleartext is confined to literal loopback; credentials never ride in URLs. */
4
+ export function selfHostedEndpoint(value, transport, name) {
5
+ const normalized = value.trim();
6
+ let url;
7
+ try {
8
+ url = new URL(normalized);
9
+ }
10
+ catch {
11
+ throw new ConfigurationError(`${name} 地址无效`);
12
+ }
13
+ const host = url.hostname.replace(/^\[|\]$/g, '');
14
+ const loopback = host === '::1' || (isIP(host) === 4 && host.startsWith('127.'));
15
+ const authority = normalized.split('://')[1]?.split(/[/?#]/)[0] ?? '';
16
+ const literal = authority.replace(/:\d+$/, '').replace(/^\[|\]$/g, '');
17
+ if (!(url.protocol === `${transport}s:` || (url.protocol === `${transport}:` && loopback && isIP(literal)))
18
+ || url.username || url.password || normalized.includes('@') || normalized.includes('?') || normalized.includes('#')) {
19
+ throw new ConfigurationError(`${name} 必须使用 TLS;仅字面量回环地址可使用明文,且禁止 URL 凭据、查询和片段`);
20
+ }
21
+ return url.toString().replace(/\/$/, '');
22
+ }
23
+ //# sourceMappingURL=self-hosted.js.map
@@ -0,0 +1,195 @@
1
+ import { z } from 'zod';
2
+ import { abortable } from '../../core/camera-session.js';
3
+ import { readBoundedResponse } from '../../http/bounded-response.js';
4
+ export const COMPOSIO_VERSION = '20260915_00';
5
+ export const toolkitSchema = z.enum(['gmail', 'googlecalendar']);
6
+ const id = z.string().regex(/^[a-zA-Z0-9_-]{1,128}$/u);
7
+ const opaque = z.string().min(1).max(16384);
8
+ export const googleScopeSchema = z.discriminatedUnion('kind', [
9
+ z.object({ kind: z.literal('gmail'), labels: z.array(z.string().min(1).max(256)).min(1).max(20), pastDays: z.number().int().min(1).max(365) }).strict(),
10
+ z.object({ kind: z.literal('calendar'), calendars: z.array(z.string().min(1).max(1024)).min(1).max(20), pastDays: z.number().int().min(1).max(365), futureDays: z.number().int().min(1).max(365) }).strict(),
11
+ ]);
12
+ export const bindingSchema = z.object({ toolkit: toolkitSchema, userId: id, accountId: id, authConfigId: id, identity: z.string().email().max(320) }).strict();
13
+ export function createComposioBudget(signal, scopeAnchor = Date.now()) {
14
+ const now = Date.now();
15
+ if (!Number.isFinite(scopeAnchor) || scopeAnchor < now - 86400000 || scopeAnchor > now + 60000)
16
+ throw new ComposioFailure('snapshot_expired');
17
+ return { requests: 0, bytes: 0, deadline: now + 30000, scopeAnchor, signal: AbortSignal.any([AbortSignal.timeout(30000), ...(signal ? [signal] : [])]) };
18
+ }
19
+ export class ComposioFailure extends Error {
20
+ code;
21
+ retryAfter;
22
+ constructor(code, retryAfter = null) {
23
+ super(code);
24
+ this.code = code;
25
+ this.retryAfter = retryAfter;
26
+ this.name = 'ComposioFailure';
27
+ }
28
+ }
29
+ const record = z.record(z.string(), z.unknown());
30
+ const pageToken = { pageToken: opaque.optional() };
31
+ const readSchema = z.discriminatedUnion('kind', [
32
+ z.object({ kind: z.literal('gmail.labels') }).strict(),
33
+ z.object({ kind: z.literal('gmail.profile') }).strict(),
34
+ z.object({ kind: z.literal('gmail.list'), after: z.number().int().nonnegative(), before: z.number().int().positive(), ...pageToken }).strict(),
35
+ z.object({ kind: z.literal('gmail.message'), messageId: z.string().regex(/^[a-fA-F0-9]{1,128}$/u), format: z.enum(['minimal', 'metadata', 'full']) }).strict(),
36
+ z.object({ kind: z.literal('gmail.history'), historyId: z.string().regex(/^\d{1,100}$/u), ...pageToken }).strict(),
37
+ z.object({ kind: z.literal('calendar.calendars'), ...pageToken }).strict(),
38
+ z.object({ kind: z.literal('calendar.list'), calendarId: opaque, timeMin: z.iso.datetime({ offset: true }), timeMax: z.iso.datetime({ offset: true }), ...pageToken }).strict(),
39
+ ]);
40
+ const failure = (code) => new ComposioFailure(code);
41
+ function parse(schema, value) { const r = schema.safeParse(value); if (!r.success)
42
+ throw failure('invalid_contract'); return r.data; }
43
+ function statusFailure(status, retryAfter = null) {
44
+ return new ComposioFailure(status === 401 ? 'authorization_required' : status === 403 ? 'permission_denied' : status === 429 ? 'rate_limited' : status === 410 ? 'cursor_expired' : status === 404 ? 'not_found' : status >= 300 && status < 400 ? 'redirect_denied' : 'provider_failed', retryAfter);
45
+ }
46
+ /** Credentials and the arbitrary tool execution endpoint stay private to this host-owned client. */
47
+ export class ComposioClient {
48
+ fetcher;
49
+ #verified = new WeakMap();
50
+ #key;
51
+ constructor(key, fetcher = fetch) {
52
+ this.fetcher = fetcher;
53
+ if (!key || key.length > 4096)
54
+ throw failure('key_required');
55
+ this.#key = key;
56
+ }
57
+ async #request(path, method, budget, body) {
58
+ budget.signal.throwIfAborted();
59
+ if (budget.requests >= 20 || budget.bytes >= 5 * 1024 * 1024 || Date.now() >= budget.deadline)
60
+ throw failure('budget_exhausted');
61
+ const json = body === undefined ? undefined : JSON.stringify(body);
62
+ if (json && Buffer.byteLength(json) > 65536)
63
+ throw failure('request_too_large');
64
+ budget.requests++;
65
+ const signal = AbortSignal.any([budget.signal, AbortSignal.timeout(15000)]);
66
+ try {
67
+ const response = await abortable(this.fetcher('https://backend.composio.dev/api/v3.1' + path, { method, redirect: 'error', signal, headers: { 'x-api-key': this.#key, 'Content-Type': 'application/json' }, ...(json ? { body: json } : {}) }), signal);
68
+ if (!response.ok) {
69
+ void response.body?.cancel().catch(() => { });
70
+ const header = response.headers.get('Retry-After');
71
+ throw statusFailure(response.status, header && /^\d+$/u.test(header) ? Math.min(Number(header), 86400) : null);
72
+ }
73
+ const bytes = await readBoundedResponse(response, { limit: 2 * 1024 * 1024, signal, failure, consume: n => { budget.bytes += n; if (budget.bytes > 5 * 1024 * 1024 || Date.now() >= budget.deadline)
74
+ throw failure('budget_exhausted'); } });
75
+ return parse(record, JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)));
76
+ }
77
+ catch (error) {
78
+ if (error instanceof ComposioFailure)
79
+ throw error;
80
+ throw failure(signal.aborted ? 'cancelled' : 'transport_failed');
81
+ }
82
+ }
83
+ async createAuthConfig(toolkit, budget) {
84
+ toolkit = parse(toolkitSchema, toolkit);
85
+ const d = await this.#request('/auth_configs', 'POST', budget, { toolkit: { slug: toolkit }, auth_config: { type: 'use_composio_managed_auth', name: 'Nova readonly connector' } });
86
+ return parse(z.object({ auth_config: z.object({ id }) }), d).auth_config.id;
87
+ }
88
+ async link(authConfigId, userId, budget) {
89
+ const d = await this.#request('/connected_accounts/link', 'POST', budget, { auth_config_id: parse(id, authConfigId), user_id: parse(id, userId) });
90
+ const r = parse(z.object({ connected_account_id: id, redirect_url: z.string().url().max(4096), expires_at: z.string().max(100) }), d);
91
+ const url = new URL(r.redirect_url);
92
+ if (url.origin !== 'https://connect.composio.dev' || url.username || url.password || !url.pathname.startsWith('/link/'))
93
+ throw failure('redirect_denied');
94
+ return { accountId: r.connected_account_id, url: r.redirect_url, expiresAt: r.expires_at };
95
+ }
96
+ async #execute(binding, slug, args, budget) {
97
+ const r = await this.#request('/tools/execute/' + slug, 'POST', budget, { version: COMPOSIO_VERSION, user_id: binding.userId, connected_account_id: binding.accountId, arguments: args });
98
+ if (r.successful !== true) {
99
+ const nested = record.safeParse(r.data);
100
+ const status = nested.success ? Number(nested.data.status_code) : NaN;
101
+ throw Number.isInteger(status) && status >= 400 && status < 600 ? statusFailure(status) : failure('provider_failed');
102
+ }
103
+ return parse(record, r.data);
104
+ }
105
+ async inspect(toolkit, userId, accountId, authConfigId, budget) {
106
+ toolkit = parse(toolkitSchema, toolkit);
107
+ userId = parse(id, userId);
108
+ accountId = parse(id, accountId);
109
+ authConfigId = parse(id, authConfigId);
110
+ const list = await this.#request(`/connected_accounts?user_ids=${userId}&statuses=ACTIVE`, 'GET', budget);
111
+ const accounts = parse(z.array(z.object({ id, toolkit: z.object({ slug: toolkitSchema }), auth_config: z.object({ id }), is_disabled: z.boolean().optional() })).max(100), list.items);
112
+ const c = accounts[0];
113
+ if (accounts.length !== 1 || list.next_cursor || c?.id !== accountId || c.toolkit.slug !== toolkit || c.auth_config.id !== authConfigId || c.is_disabled)
114
+ throw failure('connection_unverified');
115
+ const p = await this.#execute({ toolkit, userId, accountId, authConfigId, identity: '' }, toolkit === 'gmail' ? 'GMAIL_GET_PROFILE' : 'GOOGLECALENDAR_GET_CURRENT_USER', toolkit === 'gmail' ? { user_id: 'me' } : {}, budget);
116
+ const identity = parse(z.string().email().max(320), p[toolkit === 'gmail' ? 'emailAddress' : 'email']);
117
+ // Requested scopes are unknown unless actually returned; never infer a read-only grant.
118
+ return { identity, requestedScopes: [] };
119
+ }
120
+ async verify(binding, scope, budget) {
121
+ binding = parse(bindingSchema, binding);
122
+ scope = parse(googleScopeSchema, scope);
123
+ if ((binding.toolkit === 'gmail') !== (scope.kind === 'gmail'))
124
+ throw failure('scope_denied');
125
+ const p = await this.inspect(binding.toolkit, binding.userId, binding.accountId, binding.authConfigId, budget);
126
+ if (p.identity !== binding.identity)
127
+ throw failure('identity_mismatch');
128
+ const handle = { identity: p.identity, scope: structuredClone(scope) };
129
+ this.#verified.set(handle, { binding: structuredClone(binding), scope: structuredClone(scope), budget });
130
+ return handle;
131
+ }
132
+ async scopes(binding, pageToken) {
133
+ const budget = createComposioBudget(), scope = binding.toolkit === 'gmail' ? { kind: 'gmail', labels: ['INBOX'], pastDays: 30 } : { kind: 'calendar', calendars: ['primary'], pastDays: 30, futureDays: 90 };
134
+ const verified = await this.verify(binding, scope, budget);
135
+ const d = await this.read(verified, binding.toolkit === 'gmail' ? { kind: 'gmail.labels' } : { kind: 'calendar.calendars', ...(pageToken ? { pageToken } : {}) }, budget);
136
+ const items = parse(z.array(z.object({ id: z.string().min(1).max(1024), name: z.string().max(1000).optional(), summary: z.string().max(1000).optional() })).max(1000), d[binding.toolkit === 'gmail' ? 'labels' : 'calendars']);
137
+ return { items: items.map(i => ({ id: i.id, name: i.name ?? i.summary ?? i.id })), next: parse(opaque.nullable(), d.next_page_token ?? null) };
138
+ }
139
+ async read(handle, input, budget) {
140
+ const verified = this.#verified.get(handle);
141
+ if (verified?.budget !== budget)
142
+ throw failure('connection_unverified');
143
+ const request = parse(readSchema, input), { binding, scope } = verified;
144
+ if (request.kind.startsWith('gmail.') !== (scope.kind === 'gmail'))
145
+ throw failure('scope_denied');
146
+ const now = budget.scopeAnchor;
147
+ let slug, args;
148
+ switch (request.kind) {
149
+ case 'gmail.profile':
150
+ slug = 'GMAIL_GET_PROFILE';
151
+ args = { user_id: 'me' };
152
+ break;
153
+ case 'gmail.labels':
154
+ slug = 'GMAIL_LIST_LABELS';
155
+ args = { user_id: 'me' };
156
+ break;
157
+ case 'gmail.list': {
158
+ if (request.after * 1000 < now - scope.pastDays * 86400000 - 60000 || request.before * 1000 > now + 60000 || request.before <= request.after || request.before - request.after > (scope.pastDays + 1) * 86400)
159
+ throw failure('scope_denied');
160
+ slug = 'GMAIL_FETCH_EMAILS';
161
+ args = { user_id: 'me', label_ids: scope.kind === 'gmail' ? scope.labels : [], query: `after:${request.after} before:${request.before}`, max_results: 100, ids_only: true, include_payload: false, ...(request.pageToken ? { page_token: request.pageToken } : {}) };
162
+ break;
163
+ }
164
+ case 'gmail.message':
165
+ slug = 'GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID';
166
+ args = { user_id: 'me', message_id: request.messageId, format: request.format };
167
+ break;
168
+ // Read all history metadata so label removals are not lost; the provider scopes message bodies.
169
+ case 'gmail.history':
170
+ slug = 'GMAIL_LIST_HISTORY';
171
+ args = { user_id: 'me', start_history_id: request.historyId, max_results: 100, ...(request.pageToken ? { page_token: request.pageToken } : {}) };
172
+ break;
173
+ case 'calendar.calendars':
174
+ slug = 'GOOGLECALENDAR_LIST_CALENDARS';
175
+ args = { max_results: 100, ...(request.pageToken ? { page_token: request.pageToken } : {}) };
176
+ break;
177
+ case 'calendar.list': {
178
+ if (scope.kind !== 'calendar' || !scope.calendars.includes(request.calendarId) || Date.parse(request.timeMin) < now - scope.pastDays * 86400000 - 60000 || Date.parse(request.timeMax) > now + scope.futureDays * 86400000 + 60000 || Date.parse(request.timeMax) <= Date.parse(request.timeMin) || Date.parse(request.timeMax) - Date.parse(request.timeMin) > (scope.pastDays + scope.futureDays + 1) * 86400000)
179
+ throw failure('scope_denied');
180
+ slug = 'GOOGLECALENDAR_EVENTS_LIST';
181
+ args = { calendarId: request.calendarId, timeMin: request.timeMin, timeMax: request.timeMax, singleEvents: true, showDeleted: true, maxResults: 100, ...(request.pageToken ? { pageToken: request.pageToken } : {}) };
182
+ break;
183
+ }
184
+ }
185
+ try {
186
+ return await this.#execute(binding, slug, args, budget);
187
+ }
188
+ catch (error) {
189
+ if (request.kind === 'gmail.history' && error instanceof ComposioFailure && error.code === 'not_found')
190
+ throw failure('cursor_expired');
191
+ throw error;
192
+ }
193
+ }
194
+ }
195
+ //# sourceMappingURL=client.js.map