nova-personal-agent-server 0.4.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/LICENSE +674 -201
  2. package/README.md +12 -2
  3. package/bin/nova-space-host.mjs +4 -0
  4. package/node_modules/@nova-personal-agent/relay/dist/src/cli.js +71 -0
  5. package/node_modules/@nova-personal-agent/relay/dist/src/client.js +340 -0
  6. package/node_modules/@nova-personal-agent/relay/dist/src/crypto.js +167 -0
  7. package/node_modules/@nova-personal-agent/relay/dist/src/live.js +169 -0
  8. package/node_modules/@nova-personal-agent/relay/dist/src/mailbox.js +217 -0
  9. package/node_modules/@nova-personal-agent/relay/dist/src/media.js +320 -0
  10. package/node_modules/@nova-personal-agent/relay/dist/src/pairing.js +13 -0
  11. package/node_modules/@nova-personal-agent/relay/dist/src/protocol.js +50 -0
  12. package/node_modules/@nova-personal-agent/relay/dist/src/security.js +305 -0
  13. package/node_modules/@nova-personal-agent/relay/dist/src/server.js +477 -0
  14. package/node_modules/@nova-personal-agent/relay/dist/src/source-address.js +58 -0
  15. package/node_modules/@nova-personal-agent/relay/package.json +1 -0
  16. package/package.json +13 -6
  17. package/runtime/dist/src/cascaded-text-provider.js +8 -3
  18. package/runtime/dist/src/composition/assembly.js +133 -35
  19. package/runtime/dist/src/composition/cascaded-realtime-assembly.js +114 -59
  20. package/runtime/dist/src/composition/production-composition.js +57 -21
  21. package/runtime/dist/src/composition/realtime-assembly.js +160 -52
  22. package/runtime/dist/src/composition/soul-context.js +22 -0
  23. package/runtime/dist/src/config/capability-registry.js +48 -3
  24. package/runtime/dist/src/config/cascaded-realtime-config.js +23 -10
  25. package/runtime/dist/src/config/config.js +541 -128
  26. package/runtime/dist/src/config/credential-rotation.js +26 -0
  27. package/runtime/dist/src/config/data-root.js +764 -0
  28. package/runtime/dist/src/config/diagnostics.js +3 -1
  29. package/runtime/dist/src/config/environment-contract.js +190 -188
  30. package/runtime/dist/src/config/model-routes.js +140 -0
  31. package/runtime/dist/src/config/voice-credentials.js +55 -0
  32. package/runtime/dist/src/connectors/composio/index.js +9 -0
  33. package/runtime/dist/src/connectors/feishu/index.js +258 -44
  34. package/runtime/dist/src/connectors/macos/mail.js +7 -3
  35. package/runtime/dist/src/connectors/macos/reader.js +3 -1
  36. package/runtime/dist/src/conversation-voice-provider.js +5 -2
  37. package/runtime/dist/src/core/causal-runtime.js +38 -3
  38. package/runtime/dist/src/core/context-view.js +7 -0
  39. package/runtime/dist/src/core/guards.js +32 -0
  40. package/runtime/dist/src/core/runtime.js +3 -0
  41. package/runtime/dist/src/core/schedule-tools.js +2 -2
  42. package/runtime/dist/src/core/source-processing-instructions.js +2 -2
  43. package/runtime/dist/src/core/source-processing-tools.js +3 -1
  44. package/runtime/dist/src/core/tool-schema.js +42 -7
  45. package/runtime/dist/src/desktop/desktop-camera.js +3 -5
  46. package/runtime/dist/src/desktop/desktop-control.js +41 -8
  47. package/runtime/dist/src/desktop/desktop-session.js +90 -19
  48. package/runtime/dist/src/desktop/desktop-wire.js +5 -7
  49. package/runtime/dist/src/desktop/startup-error.js +18 -16
  50. package/runtime/dist/src/desktop/workbench-acceptance.js +52 -14
  51. package/runtime/dist/src/desktop-entry.js +6 -2
  52. package/runtime/dist/src/desktop.js +5 -1
  53. package/runtime/dist/src/device/attempt.js +65 -0
  54. package/runtime/dist/src/device/authority.js +159 -0
  55. package/runtime/dist/src/device/gateway.js +87 -0
  56. package/runtime/dist/src/device/ledger.js +91 -0
  57. package/runtime/dist/src/device/ownership.js +92 -0
  58. package/runtime/dist/src/device/port.js +2 -0
  59. package/runtime/dist/src/device/schedule-ownership.js +103 -0
  60. package/runtime/dist/src/executors/acp/transport.js +2 -0
  61. package/runtime/dist/src/executors/browser.js +4 -3
  62. package/runtime/dist/src/executors/codex/adapter-project.js +58 -12
  63. package/runtime/dist/src/executors/codex/app-server-schema.js +12 -21
  64. package/runtime/dist/src/executors/codex/app-server-transport.js +32 -18
  65. package/runtime/dist/src/executors/codex/common.js +1 -1
  66. package/runtime/dist/src/executors/codex/contract.js +12 -16
  67. package/runtime/dist/src/executors/codex/credential-snapshot.js +1 -9
  68. package/runtime/dist/src/executors/codex/factory.js +54 -32
  69. package/runtime/dist/src/executors/codex/host-config.js +69 -20
  70. package/runtime/dist/src/executors/codex/launch-profile.js +3 -2
  71. package/runtime/dist/src/executors/codex/local-provider-credential.js +39 -0
  72. package/runtime/dist/src/executors/codex/process-owner.js +4 -6
  73. package/runtime/dist/src/executors/codex/production-host.js +33 -34
  74. package/runtime/dist/src/executors/codex/protocol.js +9 -14
  75. package/runtime/dist/src/executors/codex/session-title.js +6 -8
  76. package/runtime/dist/src/executors/codex/spawn-env.js +27 -6
  77. package/runtime/dist/src/executors/codex/turn-projection.js +12 -17
  78. package/runtime/dist/src/executors/codex/windows-guardian.js +4 -6
  79. package/runtime/dist/src/executors/coding/intake.js +12 -7
  80. package/runtime/dist/src/executors/computer-backend.js +18 -10
  81. package/runtime/dist/src/executors/computer-config.js +32 -0
  82. package/runtime/dist/src/executors/computer-device.js +68 -16
  83. package/runtime/dist/src/executors/computer-worker.js +18 -6
  84. package/runtime/dist/src/executors/computer.js +29 -56
  85. package/runtime/dist/src/executors/device-lock.js +14 -5
  86. package/runtime/dist/src/executors/gui-execution.js +2 -0
  87. package/runtime/dist/src/executors/index.js +0 -1
  88. package/runtime/dist/src/executors/mobile.js +9 -8
  89. package/runtime/dist/src/executors/native-process.js +4 -0
  90. package/runtime/dist/src/executors/search.js +3 -5
  91. package/runtime/dist/src/executors/task-resources.js +21 -0
  92. package/runtime/dist/src/executors/watcher.js +2 -4
  93. package/runtime/dist/src/experience/host.js +179 -0
  94. package/runtime/dist/src/index.js +2 -0
  95. package/runtime/dist/src/knowledge/assembly.js +3 -4
  96. package/runtime/dist/src/knowledge/embeddings.js +50 -34
  97. package/runtime/dist/src/knowledge/service.js +1 -0
  98. package/runtime/dist/src/knowledge/store-client.js +1 -6
  99. package/runtime/dist/src/knowledge/store-worker.js +1 -3
  100. package/runtime/dist/src/mem0/resource.js +25 -0
  101. package/runtime/dist/src/mem0/store-worker.js +234 -21
  102. package/runtime/dist/src/memory/consumer.js +31 -0
  103. package/runtime/dist/src/memory/engine-worker.js +210 -0
  104. package/runtime/dist/src/memory/entry.js +8 -1
  105. package/runtime/dist/src/memory/explicit-memory.js +20 -0
  106. package/runtime/dist/src/memory/factory.js +30 -15
  107. package/runtime/dist/src/memory/grounded-voicemem.js +10 -0
  108. package/runtime/dist/src/memory/ledger-recall-engine.js +86 -0
  109. package/runtime/dist/src/memory/prerecall-port.js +27 -0
  110. package/runtime/dist/src/memory/prerecall.js +1 -1
  111. package/runtime/dist/src/memory/production-engine.js +151 -0
  112. package/runtime/dist/src/memory/provenance.js +1 -0
  113. package/runtime/dist/src/memory/remote-personal-memory.js +3 -1
  114. package/runtime/dist/src/memory/retrieval.js +107 -22
  115. package/runtime/dist/src/memory/sensitivity.js +6 -2
  116. package/runtime/dist/src/memory/source-retrieval.js +11 -0
  117. package/runtime/dist/src/memory/tool-capabilities.js +46 -0
  118. package/runtime/dist/src/memory/voicemem-sdk/LICENSE +202 -0
  119. package/runtime/dist/src/memory/voicemem-sdk/NOTICE.md +97 -0
  120. package/runtime/dist/src/memory/voicemem-sdk/PATCH-NOTICE.md +23 -0
  121. package/runtime/dist/src/memory/voicemem-sdk/archive.js +12 -0
  122. package/runtime/dist/src/memory/voicemem-sdk/audio.js +111 -0
  123. package/runtime/dist/src/memory/voicemem-sdk/barge-in.js +59 -0
  124. package/runtime/dist/src/memory/voicemem-sdk/checkpoint.js +56 -0
  125. package/runtime/dist/src/memory/voicemem-sdk/cleanup.js +139 -0
  126. package/runtime/dist/src/memory/voicemem-sdk/dashscope-asr.js +254 -0
  127. package/runtime/dist/src/memory/voicemem-sdk/dashscope-tts.js +247 -0
  128. package/runtime/dist/src/memory/voicemem-sdk/evaluation.js +330 -0
  129. package/runtime/dist/src/memory/voicemem-sdk/extraction.js +220 -0
  130. package/runtime/dist/src/memory/voicemem-sdk/finetune-data.js +115 -0
  131. package/runtime/dist/src/memory/voicemem-sdk/finetune.js +170 -0
  132. package/runtime/dist/src/memory/voicemem-sdk/grounded-reply-preferences.js +81 -0
  133. package/runtime/dist/src/memory/voicemem-sdk/index.js +22 -0
  134. package/runtime/dist/src/memory/voicemem-sdk/local-embedding.js +164 -0
  135. package/runtime/dist/src/memory/voicemem-sdk/local-runtime.js +53 -0
  136. package/runtime/dist/src/memory/voicemem-sdk/local-speaker.js +240 -0
  137. package/runtime/dist/src/memory/voicemem-sdk/memory.js +767 -0
  138. package/runtime/dist/src/memory/voicemem-sdk/model-json.js +14 -0
  139. package/runtime/dist/src/memory/voicemem-sdk/personamem.js +209 -0
  140. package/runtime/dist/src/memory/voicemem-sdk/prompts/addenda.js +215 -0
  141. package/runtime/dist/src/memory/voicemem-sdk/prompts/additive-extraction.js +478 -0
  142. package/runtime/dist/src/memory/voicemem-sdk/prompts/index.js +32 -0
  143. package/runtime/dist/src/memory/voicemem-sdk/prompts/update-memory.js +152 -0
  144. package/runtime/dist/src/memory/voicemem-sdk/providers.js +325 -0
  145. package/runtime/dist/src/memory/voicemem-sdk/ranking.js +65 -0
  146. package/runtime/dist/src/memory/voicemem-sdk/reaction.js +33 -0
  147. package/runtime/dist/src/memory/voicemem-sdk/realtime.js +215 -0
  148. package/runtime/dist/src/memory/voicemem-sdk/reply.js +68 -0
  149. package/runtime/dist/src/memory/voicemem-sdk/routing.js +209 -0
  150. package/runtime/dist/src/memory/voicemem-sdk/slots.js +61 -0
  151. package/runtime/dist/src/memory/voicemem-sdk/speaker-bindings.js +120 -0
  152. package/runtime/dist/src/memory/voicemem-sdk/speaker-profiles.js +327 -0
  153. package/runtime/dist/src/memory/voicemem-sdk/store.js +577 -0
  154. package/runtime/dist/src/memory/voicemem-sdk/stream.js +317 -0
  155. package/runtime/dist/src/memory/voicemem-sdk/subgraph.js +113 -0
  156. package/runtime/dist/src/memory/voicemem-sdk/summaries.js +56 -0
  157. package/runtime/dist/src/memory/voicemem-sdk/time.js +157 -0
  158. package/runtime/dist/src/memory/voicemem-sdk/types.js +2 -0
  159. package/runtime/dist/src/memory-ledger/store-client.js +235 -37
  160. package/runtime/dist/src/memory-ledger/store-worker.js +8 -5
  161. package/runtime/dist/src/memory-ledger/store.js +91 -1
  162. package/runtime/dist/src/memory-substrate/consolidation.js +23 -7
  163. package/runtime/dist/src/memory-substrate/diary.js +27 -0
  164. package/runtime/dist/src/memory-substrate/engine-outbox.js +107 -0
  165. package/runtime/dist/src/memory-substrate/explicit-memory.js +112 -0
  166. package/runtime/dist/src/memory-substrate/fact-fidelity.js +68 -0
  167. package/runtime/dist/src/memory-substrate/feishu-consent.js +41 -0
  168. package/runtime/dist/src/memory-substrate/file-authority.js +29 -6
  169. package/runtime/dist/src/memory-substrate/life-operations.js +35 -9
  170. package/runtime/dist/src/memory-substrate/markdown-repository.js +271 -65
  171. package/runtime/dist/src/memory-substrate/memory-documents.js +96 -0
  172. package/runtime/dist/src/memory-substrate/migration.js +2 -0
  173. package/runtime/dist/src/memory-substrate/purge.js +12 -2
  174. package/runtime/dist/src/memory-substrate/resource.js +514 -129
  175. package/runtime/dist/src/memory-substrate/retrieval.js +8 -5
  176. package/runtime/dist/src/memory-substrate/source-operations.js +9 -1
  177. package/runtime/dist/src/memory-substrate/source-processing.js +436 -40
  178. package/runtime/dist/src/memory-substrate/source-retrieval.js +28 -0
  179. package/runtime/dist/src/memory-substrate/source-state.js +8 -0
  180. package/runtime/dist/src/memory-substrate/space-source-input.js +90 -0
  181. package/runtime/dist/src/memory-substrate/store.js +125 -23
  182. package/runtime/dist/src/model/goal-checkin-writer.js +72 -0
  183. package/runtime/dist/src/model/goal-writer.js +80 -0
  184. package/runtime/dist/src/model/jev-client.js +24 -13
  185. package/runtime/dist/src/model/model-adapters.js +2 -3
  186. package/runtime/dist/src/model/model-catalog.js +80 -0
  187. package/runtime/dist/src/model/model-gateway.js +47 -18
  188. package/runtime/dist/src/model/model-purpose.js +3 -4
  189. package/runtime/dist/src/model/personal-writer.js +536 -44
  190. package/runtime/dist/src/model/proactivity.js +50 -6
  191. package/runtime/dist/src/model/responses-model-gateway.js +59 -0
  192. package/runtime/dist/src/model/task-verifier.js +3 -3
  193. package/runtime/dist/src/model/timeline-anchors.js +77 -0
  194. package/runtime/dist/src/model/timeline-perspective.js +13 -0
  195. package/runtime/dist/src/model/timeline-selection.js +182 -0
  196. package/runtime/dist/src/model/understanding-writer.js +27 -0
  197. package/runtime/dist/src/model/vision-capability.js +3 -1
  198. package/runtime/dist/src/model/workbench-writer.js +96 -0
  199. package/runtime/dist/src/news/feeds.js +6 -10
  200. package/runtime/dist/src/news/interests.js +23 -0
  201. package/runtime/dist/src/news/service.js +87 -31
  202. package/runtime/dist/src/news/sources.json +116 -0
  203. package/runtime/dist/src/notifications/adapters/space-relay.js +4 -0
  204. package/runtime/dist/src/notifications/content.js +41 -0
  205. package/runtime/dist/src/notifications/contracts.js +4 -2
  206. package/runtime/dist/src/notifications/feed.js +6 -2
  207. package/runtime/dist/src/notifications/service.js +27 -14
  208. package/runtime/dist/src/notifications/store.js +3 -1
  209. package/runtime/dist/src/personal-agent/app-context.js +39 -4
  210. package/runtime/dist/src/personal-agent/chat-failure.js +37 -0
  211. package/runtime/dist/src/personal-agent/computer-use/contract.js +42 -0
  212. package/runtime/dist/src/personal-agent/computer-use/session.js +280 -0
  213. package/runtime/dist/src/personal-agent/computer-use/skill.js +18 -0
  214. package/runtime/dist/src/personal-agent/computer-use/tools.js +15 -0
  215. package/runtime/dist/src/personal-agent/context-candidates.js +9 -13
  216. package/runtime/dist/src/personal-agent/context-dependencies.js +28 -0
  217. package/runtime/dist/src/personal-agent/contracts.js +24 -4
  218. package/runtime/dist/src/personal-agent/conversation-runtime.js +440 -42
  219. package/runtime/dist/src/personal-agent/conversation-tool-bridge.js +97 -0
  220. package/runtime/dist/src/personal-agent/conversation-tool-policy.js +22 -0
  221. package/runtime/dist/src/personal-agent/conversations.js +71 -15
  222. package/runtime/dist/src/personal-agent/daily-brief.js +5 -0
  223. package/runtime/dist/src/personal-agent/daily-workbench.js +558 -0
  224. package/runtime/dist/src/personal-agent/discovery-window.js +36 -0
  225. package/runtime/dist/src/personal-agent/goal-checkin.js +53 -0
  226. package/runtime/dist/src/personal-agent/host.js +2379 -223
  227. package/runtime/dist/src/personal-agent/identity-context.js +33 -0
  228. package/runtime/dist/src/personal-agent/life.js +129 -11
  229. package/runtime/dist/src/personal-agent/local-shell.js +181 -0
  230. package/runtime/dist/src/personal-agent/local-tools.js +234 -0
  231. package/runtime/dist/src/personal-agent/preferred-name-sync.js +35 -0
  232. package/runtime/dist/src/personal-agent/profile-warmup.js +100 -39
  233. package/runtime/dist/src/personal-agent/project-digests.js +7 -3
  234. package/runtime/dist/src/personal-agent/project-history.js +36 -0
  235. package/runtime/dist/src/personal-agent/reading-copies.js +183 -0
  236. package/runtime/dist/src/personal-agent/scheduled-tasks.js +50 -13
  237. package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +26 -10
  238. package/runtime/dist/src/personal-agent/source-processing-agent.js +239 -17
  239. package/runtime/dist/src/personal-agent/sources.js +9 -1
  240. package/runtime/dist/src/personal-agent/store.js +124 -14
  241. package/runtime/dist/src/personal-agent/task-loop.js +3 -0
  242. package/runtime/dist/src/personal-agent/tasks.js +16 -4
  243. package/runtime/dist/src/personal-agent/timeline-brief.js +462 -0
  244. package/runtime/dist/src/personal-agent/timeline-cache.js +191 -0
  245. package/runtime/dist/src/personal-agent/timeline-cluster.js +30 -0
  246. package/runtime/dist/src/personal-agent/timeline-inputs.js +47 -0
  247. package/runtime/dist/src/personal-agent/timeline-time.js +60 -0
  248. package/runtime/dist/src/personal-agent/understanding-products.js +49 -0
  249. package/runtime/dist/src/personal-agent/understanding.js +7 -22
  250. package/runtime/dist/src/personal-agent/workbench-context.js +17 -21
  251. package/runtime/dist/src/personal-agent/workbench-copy.js +124 -0
  252. package/runtime/dist/src/personal-agent/workbench-evidence.js +77 -0
  253. package/runtime/dist/src/personal-agent/workbench-instructions.js +21 -0
  254. package/runtime/dist/src/personal-agent/workbench-runtime.js +1006 -0
  255. package/runtime/dist/src/personal-agent/workbench-shell-class.js +304 -0
  256. package/runtime/dist/src/personal-agent/workbench-store.js +292 -0
  257. package/runtime/dist/src/personal-agent/workbench-temporal.js +66 -0
  258. package/runtime/dist/src/projects/project-native-resource.js +10 -8
  259. package/runtime/dist/src/projects/project-store.js +36 -4
  260. package/runtime/dist/src/realtime/bridge.js +77 -8
  261. package/runtime/dist/src/realtime/capabilities.js +19 -0
  262. package/runtime/dist/src/realtime/cascaded/adapter.js +180 -40
  263. package/runtime/dist/src/realtime/cascaded/ark-llm.js +150 -24
  264. package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +243 -83
  265. package/runtime/dist/src/realtime/cascaded/llm-stream-limits.js +18 -0
  266. package/runtime/dist/src/realtime/cascaded/llm.js +96 -0
  267. package/runtime/dist/src/realtime/cascaded/openai-compatible-speech.js +251 -0
  268. package/runtime/dist/src/realtime/cascaded/provider.js +8 -0
  269. package/runtime/dist/src/realtime/evidence.js +1 -1
  270. package/runtime/dist/src/realtime/frontend-instructions.js +76 -55
  271. package/runtime/dist/src/realtime/gemini.js +14 -3
  272. package/runtime/dist/src/realtime/host-delivery.js +37 -4
  273. package/runtime/dist/src/realtime/protocol.js +18 -3
  274. package/runtime/dist/src/realtime/provider-projection.js +4 -1
  275. package/runtime/dist/src/realtime/provider-session.js +73 -16
  276. package/runtime/dist/src/realtime/qwen-transport.js +35 -4
  277. package/runtime/dist/src/realtime/qwen.js +144 -9
  278. package/runtime/dist/src/realtime/service-state.js +0 -1
  279. package/runtime/dist/src/realtime/service.js +93 -7
  280. package/runtime/dist/src/realtime/session.js +39 -32
  281. package/runtime/dist/src/realtime/sglang-native.js +214 -0
  282. package/runtime/dist/src/realtime/system-prompts.en.js +14 -2
  283. package/runtime/dist/src/realtime/telemetry.js +6 -3
  284. package/runtime/dist/src/realtime/tool-continuations.js +84 -7
  285. package/runtime/dist/src/realtime/transport.js +17 -0
  286. package/runtime/dist/src/realtime/usage.js +33 -17
  287. package/runtime/dist/src/realtime/volcengine/ark.js +40 -15
  288. package/runtime/dist/src/realtime/volcengine/asr.js +2 -1
  289. package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +1 -7
  290. package/runtime/dist/src/realtime/volcengine/tts.js +2 -1
  291. package/runtime/dist/src/server/aoq-chat-server.js +1 -1
  292. package/runtime/dist/src/server/client-server.js +21 -0
  293. package/runtime/dist/src/server-entry.js +3 -0
  294. package/runtime/dist/src/space-host/admin-socket.js +115 -0
  295. package/runtime/dist/src/space-host/audio-owner.js +44 -0
  296. package/runtime/dist/src/space-host/cli.js +195 -0
  297. package/runtime/dist/src/space-host/config.js +247 -0
  298. package/runtime/dist/src/space-host/context-input.js +12 -0
  299. package/runtime/dist/src/space-host/contracts.js +10 -0
  300. package/runtime/dist/src/space-host/host-admin.js +114 -0
  301. package/runtime/dist/src/space-host/key-delivery.js +28 -0
  302. package/runtime/dist/src/space-host/mobile-tools.js +9 -0
  303. package/runtime/dist/src/space-host/model-settings.js +213 -0
  304. package/runtime/dist/src/space-host/projection.js +37 -0
  305. package/runtime/dist/src/space-host/push.js +137 -0
  306. package/runtime/dist/src/space-host/relay-transport.js +55 -0
  307. package/runtime/dist/src/space-host/service.js +841 -0
  308. package/runtime/dist/src/space-host/voice-crypto.js +240 -0
  309. package/runtime/dist/src/space-host/voice.js +600 -0
  310. package/runtime/dist/src/space-host/windows-secret-key.js +82 -0
  311. package/runtime/dist/src/storage/private-database.js +7 -10
  312. package/runtime/dist/src/text/unicode-normalize.js +5 -1
  313. package/runtime/dist/src/understanding/candidates.js +8 -10
  314. package/runtime/dist/src/understanding/fixture.js +1 -1
  315. package/runtime/dist/src/understanding/pipeline.js +4 -4
  316. package/runtime/dist/src/usage/context.js +23 -0
  317. package/runtime/dist/src/usage/index.js +4 -0
  318. package/runtime/dist/src/usage/ledger-worker.js +90 -0
  319. package/runtime/dist/src/usage/ledger.js +74 -0
  320. package/runtime/dist/src/usage/model-call.js +63 -0
  321. package/runtime/dist/src/usage/pricing.js +68 -0
  322. package/runtime/dist/src/usage/summary.js +69 -0
  323. package/runtime/dist/src/voicemem/store-client.js +104 -21
  324. package/runtime/dist/src/voicemem/store-worker.js +5 -8
  325. package/runtime/dist/src/voicemem/versioned-memory.js +1 -1
  326. package/src/command.mjs +8 -1
  327. package/runtime/dist/src/executors/autoglm.js +0 -376
@@ -0,0 +1,97 @@
1
+ import { retrievalPrerecall } from '../memory/prerecall-port.js';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { chatToolAllowed } from './conversation-tool-policy.js';
4
+ export const memoryHostToolNames = new Set(['memory__remember', 'memory__lookup']);
5
+ export function memoryRememberSummary(args, result, accepted) {
6
+ const record = result && typeof result === 'object' ? result : null;
7
+ const receipt = record?.result && typeof record.result === 'object' ? record.result : record;
8
+ if (!accepted || record?.accepted === false || receipt?.state !== 'committed')
9
+ return '未保存';
10
+ const action = args.action === 'forget' ? '已忘记' : '已保存';
11
+ const slot = args.slot === 'preferred_name' ? ' · 称呼' : args.slot === 'reply_style' ? ' · 回答风格' : '';
12
+ return action + slot;
13
+ }
14
+ function summarizeToolResult(name, args, result, accepted) {
15
+ if (name === 'memory__remember')
16
+ return memoryRememberSummary(args, result, accepted);
17
+ if (result === null || typeof result !== 'object' || Array.isArray(result))
18
+ return '';
19
+ const record = result;
20
+ const inner = record.result;
21
+ if (inner !== null && typeof inner === 'object' && !Array.isArray(inner)) {
22
+ const value = inner;
23
+ if (Array.isArray(value.items))
24
+ return `${value.items.length} 条`;
25
+ if (Array.isArray(value.results))
26
+ return `${value.results.length} 条`;
27
+ if (Array.isArray(value.entries))
28
+ return `${value.entries.length} 条`;
29
+ }
30
+ if (Array.isArray(record.entries))
31
+ return `${record.entries.length} 条`;
32
+ if (typeof record.code === 'string' && /^[a-z_]{1,64}$/u.test(record.code))
33
+ return record.code;
34
+ return '';
35
+ }
36
+ /** Existing admission, controllers, approvals and executor implementations remain the authority. */
37
+ export function conversationToolBridge(core, graph, options = {}) {
38
+ const tools = core.tools.schemas.flatMap(schema => {
39
+ const fn = schema.function;
40
+ return fn?.name && fn.parameters && !core.tools.hidden.has(fn.name) && !['task', 'confirm'].includes(fn.name) ? [{ name: fn.name, ...(fn.description ? { description: fn.description } : {}), parameters: fn.parameters }] : [];
41
+ });
42
+ const readonlyNames = new Set(tools.filter(tool => { const binding = core.tools.bindings.get(tool.name); return binding?.kind === 'query' || binding?.executor && core.runtime.executors.get(binding.executor)?.manifest.ops.some(op => op.name === binding.op && op.readonly); }).map(tool => tool.name));
43
+ const chatTools = options.chat === true ? tools.filter(tool => chatToolAllowed(tool.name, core.tools.bindings.get(tool.name), readonlyNames)) : [];
44
+ const allowed = options.chat === true ? new Set(chatTools.map(tool => tool.name)) : new Set(tools.map(tool => tool.name));
45
+ const invoke = async (text, call, signal, task) => {
46
+ if (!allowed.has(call.name))
47
+ return { code: options.chat === true ? 'chat_tool_forbidden' : 'unknown_tool', state: 'refused', message: options.chat === true ? '本会话处于 Chat 模式,没有执行能力;请用户把本会话切换到 Plan 或 Build 后再执行' : 'unknown tool' };
48
+ signal.throwIfAborted();
49
+ const origin = await graph.bridge.acceptUserTranscript(text), epoch = graph.service.session.sessionEpoch;
50
+ const terminals = new Map(), listeners = new Set();
51
+ const unsubscribe = core.runtime.observe(event => { if (event.kind === 'handoff' || event.kind === 'deadline') {
52
+ const id = event.payload.delegate_id;
53
+ if (typeof id === 'string') {
54
+ terminals.set(id, event.kind === 'handoff' ? { ...event.payload } : { status: 'timed_out', outcome: 'unknown' });
55
+ for (const listener of listeners)
56
+ listener();
57
+ }
58
+ } });
59
+ try {
60
+ options.onTool?.({ name: call.name, state: 'running', summary: '' });
61
+ const acceptance = await graph.service.invokeConversationTool({ kind: 'tool_call_ready', session_epoch: epoch, response_id: null, item_id: randomUUID(), call_id: call.id, name: call.name, arguments: call.arguments }, { user: { text, epoch, origin_ref: origin }, authority: { originRef: origin, sessionEpoch: epoch, acceptedUserInputRevision: 0, stillWanted: () => !signal.aborted }, signal, ...(task ? { task } : {}) });
62
+ signal.throwIfAborted();
63
+ if (acceptance.sync_result && acceptance.delegate_id) {
64
+ const id = acceptance.delegate_id;
65
+ return await new Promise(resolve => {
66
+ const cleanup = () => { listeners.delete(check); signal.removeEventListener('abort', abort); }, check = () => { const result = terminals.get(id); if (result) {
67
+ cleanup();
68
+ resolve(result);
69
+ } }, abort = () => { core.runtime.cancelWork(id); cleanup(); resolve({ status: 'outcome_unknown', delegate_id: id, message: 'Inspect executor state before retrying.' }); };
70
+ listeners.add(check);
71
+ signal.addEventListener('abort', abort, { once: true });
72
+ if (signal.aborted)
73
+ abort();
74
+ check();
75
+ });
76
+ }
77
+ let result;
78
+ try {
79
+ result = JSON.parse(acceptance.host_item.content);
80
+ }
81
+ catch {
82
+ result = { message: acceptance.host_item.content };
83
+ }
84
+ options.onTool?.({ name: call.name, state: 'ok', summary: summarizeToolResult(call.name, call.arguments, result, acceptance.accepted) });
85
+ return { accepted: acceptance.accepted, code: acceptance.code, delegate_id: acceptance.delegate_id, result };
86
+ }
87
+ catch (error) {
88
+ options.onTool?.({ name: call.name, state: 'error', summary: call.name === 'memory__remember' ? '未保存' : error instanceof Error ? error.message.slice(0, 80) : '' });
89
+ throw error;
90
+ }
91
+ finally {
92
+ unsubscribe();
93
+ }
94
+ };
95
+ return { ...(graph.retrieval ? { prerecall: retrievalPrerecall(() => graph.retrieval, () => options.memoryConsumer ?? '') } : {}), tools, readonlyNames: [...readonlyNames], chatTools, origin: text => graph.bridge.acceptUserTranscript(text), invoke };
96
+ }
97
+ //# sourceMappingURL=conversation-tool-bridge.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Chat is the default conversation surface. It may retrieve context and write the user's own
3
+ * memory, but it must not dispatch delegated work, create or cancel tasks, or schedule runs.
4
+ * `enter_plan_mode` was removed: mode changes are an explicit UI action, never a model tool.
5
+ */
6
+ export const CHAT_DENIED_TOOLS = Object.freeze(new Set([
7
+ 'dispatch', 'cancel', 'confirm', 'task', 'schedule', 'publish_plan', 'finish_build',
8
+ ]));
9
+ export function chatToolAllowed(name, binding, readonlyNames) {
10
+ if (CHAT_DENIED_TOOLS.has(name))
11
+ return false;
12
+ if (name.startsWith('memory__'))
13
+ return true;
14
+ if (name === 'app__context')
15
+ return true;
16
+ if (binding?.kind === 'query')
17
+ return true;
18
+ if (binding?.executor != null && readonlyNames.has(name))
19
+ return true;
20
+ return false;
21
+ }
22
+ //# sourceMappingURL=conversation-tool-policy.js.map
@@ -1,16 +1,25 @@
1
+ import { contextDependenciesSchema } from './context-dependencies.js';
2
+ import { chatFailureSchema } from './chat-failure.js';
1
3
  import { scheduleReferenceSchema } from './schedule-reference.js';
2
4
  import { z } from 'zod';
3
5
  import { discussionReferenceSchema } from './contracts.js';
4
6
  import { randomUUID } from 'node:crypto';
7
+ import { computerUseStateSchema } from './computer-use/contract.js';
8
+ import { buildStatusSchema } from './workbench-store.js';
9
+ export const planReferenceSchema = z.object({ id: z.string(), version: z.number().int().positive(), title: z.string().max(120) }).strict();
10
+ export const localBuildSchema = z.object({ computer_use: computerUseStateSchema.optional(), project: z.string(), plan_id: z.string().optional(), plan_version: z.number().int().positive().optional(), source_conversation_id: z.string(), status: buildStatusSchema, reason: z.string().nullable().default(null), reason_detail: z.string().max(300).nullable().optional(), log_revision: z.number().int().nonnegative().default(0), approval: z.object({ id: z.string(), call_id: z.string(), name: z.string(), preview: z.string().max(1800) }).strict().nullable().default(null) }).strict();
5
11
  export const sourceTodoSchema = z.object({ id: z.string().min(1).max(512), version: z.number().int().nonnegative() }).strict();
6
- export const conversationMessageSchema = z.object({ id: z.string().min(1).max(128), conversation_id: z.string().min(1).max(128), role: z.enum(['user', 'assistant']), schedule_ref: scheduleReferenceSchema.optional(), references: z.array(discussionReferenceSchema).max(2).optional(), source_todo: sourceTodoSchema.optional(), delivery: z.enum(['completed', 'interrupted', 'generated']).optional(), generation_status: z.enum(['pending', 'completed', 'failed', 'interrupted']).optional(), read: z.boolean().optional(), text: z.string().max(16000), created_at: z.string().datetime(), reply_to: z.string().max(128).optional(), request_id: z.string().max(128).optional(), turn_id: z.string().max(512).optional() }).strict();
12
+ const toolTraceSchema = z.array(z.object({ name: z.string().min(1).max(128), state: z.enum(['running', 'ok', 'error']), summary: z.string().max(160) }).strict()).max(16);
13
+ export const conversationMessageSchema = z.object({ id: z.string().min(1).max(128), conversation_id: z.string().min(1).max(128), role: z.enum(['user', 'assistant']), context_dependencies: contextDependenciesSchema.optional(), task_ids: z.array(z.string().min(1).max(128)).max(16).optional(), memory_origin: z.literal('non_product').optional(), origin: z.literal('proactive').optional(), input_mode: z.literal('voice').optional(), schedule_ref: scheduleReferenceSchema.optional(), references: z.array(discussionReferenceSchema).max(2).optional(), source_todo: sourceTodoSchema.optional(), delivery: z.enum(['completed', 'interrupted', 'generated']).optional(), generation_status: z.enum(['pending', 'completed', 'failed', 'interrupted']).optional(), failure_reason: chatFailureSchema.optional(), read: z.boolean().optional(), text: z.string().max(16000), full_text_ref: z.boolean().optional(), tool_trace: toolTraceSchema.optional(), created_at: z.string().datetime(), reply_to: z.string().max(128).optional(), request_id: z.string().max(128).optional(), turn_id: z.string().max(512).optional() }).strict();
7
14
  export const codingTargetSchema = z.object({ workspace_id: z.string().min(1).max(128), session_id: z.string().min(1).max(128).nullable(), project: z.string().min(1).max(120), title: z.string().max(120), executor: z.literal('codex') }).strict();
8
- export const conversationSchema = z.object({ scheduled_result_focus: z.string().min(1).max(128).optional(), coding_target: codingTargetSchema.nullable().default(null), id: z.string().min(1).max(128), kind: z.enum(['chat', 'topic', 'proactive', 'schedule']), title: z.string().min(1).max(120), subject_key: z.string().max(512).nullable(), created_at: z.string().datetime(), updated_at: z.string().datetime(), generation: z.number().int().nonnegative(), messages: z.array(conversationMessageSchema).max(512), feed_ids: z.array(z.string().max(128)).max(256), read_through_id: z.string().nullable().default(null), prepared: z.object({ trust: z.literal('untrusted_external'), text: z.string().max(12000), evidence_refs: z.array(z.string().max(512)).max(32) }).strict().nullable() }).strict();
9
- export const conversationsStateSchema = z.object({ selected_id: z.string(), voice_id: z.string().nullable(), items: z.array(conversationSchema).min(2).max(192), work_owners: z.record(z.string(), z.string()), approval_owners: z.record(z.string(), z.string()) }).strict().refine(state => state.items.filter(item => item.kind !== 'schedule').length <= 128 && state.items.filter(item => item.kind === 'schedule').length <= 64 && !state.items.some(item => item.kind === 'schedule' && (item.id === state.selected_id || item.id === state.voice_id)), 'invalid_conversation_ownership');
15
+ // Preserve opaque persona metadata from older profiles without exposing a character catalogue.
16
+ export const conversationSchema = z.object({ persona: z.string().min(1).max(128).optional(), mode: z.enum(['chat', 'plan']).optional(), plan: planReferenceSchema.optional(), build: localBuildSchema.optional(), scheduled_result_focus: z.string().min(1).max(128).optional(), coding_target: codingTargetSchema.nullable().default(null), id: z.string().min(1).max(128), kind: z.enum(['chat', 'topic', 'schedule', 'build']), title: z.string().min(1).max(120), subject_key: z.string().max(512).nullable(), created_at: z.string().datetime(), updated_at: z.string().datetime(), generation: z.number().int().nonnegative(), messages: z.array(conversationMessageSchema).max(512), feed_ids: z.array(z.string().max(128)).max(256), read_through_id: z.string().nullable().default(null), prepared: z.object({ trust: z.literal('untrusted_external'), text: z.string().max(12000), evidence_refs: z.array(z.string().max(512)).max(32) }).strict().nullable() }).strict();
17
+ export const voiceModeSchema = z.enum(['chat', 'plan', 'build', 'delegate']);
18
+ export const conversationsStateSchema = z.object({ selected_id: z.string(), voice_id: z.string().nullable(), items: z.array(conversationSchema).min(1).max(192), work_owners: z.record(z.string(), z.string()), approval_owners: z.record(z.string(), z.string()) }).strict().refine(state => state.items.filter(item => item.kind !== 'schedule').length <= 128 && state.items.filter(item => item.kind === 'schedule').length <= 64 && !state.items.some(item => item.kind === 'schedule' && (item.id === state.selected_id || item.id === state.voice_id)), 'invalid_conversation_ownership');
10
19
  export function createConversation(kind, title, subject_key = null, id = randomUUID()) { const at = new Date().toISOString(); return { id, kind, title, subject_key, coding_target: null, created_at: at, updated_at: at, generation: 0, messages: [], feed_ids: [], read_through_id: null, prepared: null }; }
11
20
  export function nextConversationTitle(items) { const titles = new Set(items.map(item => item.title)); let number = 1; while (titles.has(`新对话 ${number}`))
12
21
  number++; return `新对话 ${number}`; }
13
- export function initialConversations() { return { selected_id: 'chat:main', voice_id: null, items: [createConversation('chat', nextConversationTitle([]), null, 'chat:main'), createConversation('proactive', '主动提醒', null, 'chat:proactive')], work_owners: {}, approval_owners: {} }; }
22
+ export function initialConversations() { return { selected_id: 'chat:main', voice_id: null, items: [createConversation('chat', nextConversationTitle([]), null, 'chat:main')], work_owners: {}, approval_owners: {} }; }
14
23
  /** The global host owns resources; this pool owns only each conversation's scoped turn graph. */
15
24
  export class ConversationRuntimePool {
16
25
  create;
@@ -18,6 +27,8 @@ export class ConversationRuntimePool {
18
27
  #modes = new Map();
19
28
  #lifetimes = new Map();
20
29
  #retired = new Map();
30
+ #isolated = new Set();
31
+ #isolatedLifetimes = new Set();
21
32
  #ready = new Map();
22
33
  #runtimes = new Map();
23
34
  #tails = new Map();
@@ -29,9 +40,42 @@ export class ConversationRuntimePool {
29
40
  this.create = create;
30
41
  this.emit = emit;
31
42
  }
32
- async prepare(conversation, execution) { return this.#prepare(conversation, false, execution); }
33
- async restore(conversation, execution) { return this.#prepare(conversation, true, execution); }
34
- async #prepare(conversation, recovery, execution) {
43
+ /** Host action graphs share task ownership, never the foreground Chat slot. */
44
+ async isolated(conversation, operation, recovery = false) {
45
+ if (this.#closed)
46
+ throw Error('conversation_runtime_closed');
47
+ const lifetime = new AbortController(), id = conversation.id;
48
+ this.#isolatedLifetimes.add(lifetime);
49
+ const starting = this.create(structuredClone(conversation), frame => { if (!lifetime.signal.aborted)
50
+ this.emit({ ...frame, conversation_id: id }); }, 'text', lifetime.signal, recovery, undefined, { chat: false });
51
+ this.#isolated.add(starting);
52
+ let runtime;
53
+ try {
54
+ runtime = await starting;
55
+ if (this.#closed)
56
+ throw Error('conversation_runtime_closed');
57
+ const retained = this.#retired.get(id) ?? new Set();
58
+ retained.add(runtime);
59
+ this.#retired.set(id, retained);
60
+ return await operation(runtime);
61
+ }
62
+ finally {
63
+ lifetime.abort();
64
+ this.#isolatedLifetimes.delete(lifetime);
65
+ this.#isolated.delete(starting);
66
+ if (runtime) {
67
+ if (!this.#closed && runtime.retainTasks?.())
68
+ await runtime.parkVoice?.();
69
+ else {
70
+ this.#retired.get(id)?.delete(runtime);
71
+ await runtime.close();
72
+ }
73
+ }
74
+ }
75
+ }
76
+ async prepare(conversation, execution, overrides) { return this.#prepare(conversation, false, execution, overrides); }
77
+ async restore(conversation, execution, overrides) { return this.#prepare(conversation, true, execution, overrides); }
78
+ async #prepare(conversation, recovery, execution, overrides) {
35
79
  if (this.#closed)
36
80
  throw Error('conversation_runtime_closed');
37
81
  if (conversation.kind === 'schedule' && !execution)
@@ -49,7 +93,7 @@ export class ConversationRuntimePool {
49
93
  this.#lifetimes.set(id, lifetime);
50
94
  this.#modes.set(id, 'text');
51
95
  const promise = this.create(structuredClone(conversation), frame => { if (!lifetime.signal.aborted && this.#lifetimes.get(id) === lifetime)
52
- this.emit({ ...frame, conversation_id: id }); }, 'text', lifetime.signal, recovery, execution);
96
+ this.emit({ ...frame, conversation_id: id }); }, 'text', lifetime.signal, recovery, execution, overrides);
53
97
  this.#runtimes.set(id, promise);
54
98
  try {
55
99
  const runtime = await promise;
@@ -84,11 +128,14 @@ export class ConversationRuntimePool {
84
128
  if (this.#modes.get(id) === 'parked') {
85
129
  this.#lifetimes.get(id)?.abort();
86
130
  this.#lifetimes.delete(id);
87
- const previous = this.#ready.get(id);
131
+ const previous = this.#ready.get(id), starting = this.#runtimes.get(id);
88
132
  this.#ready.delete(id);
89
133
  this.#runtimes.delete(id);
90
134
  this.#modes.delete(id);
91
- await previous?.close();
135
+ if (previous)
136
+ await previous.close();
137
+ else
138
+ void starting?.then(late => late.close(), () => { });
92
139
  }
93
140
  let runtime = this.#runtimes.get(id);
94
141
  if (!runtime) {
@@ -117,11 +164,18 @@ export class ConversationRuntimePool {
117
164
  this.#busy.delete(id); });
118
165
  }
119
166
  canChangeTarget(id) { return !this.#busy.has(id) && this.#ready.get(id)?.canSwitch?.() !== false; }
167
+ capabilities(id) { return this.#modes.get(id) === 'voice' ? this.#ready.get(id)?.capabilities : undefined; }
120
168
  hasVoice(id) { return this.#modes.get(id) === 'voice'; }
121
169
  acceptsText(id) { return this.#modes.get(id) !== 'voice' && (this.#modes.get(id) !== 'parked' || this.#ready.get(id)?.canSwitch?.() !== false); }
122
170
  async stopVoice(id) { const runtime = this.#ready.get(id); await runtime?.parkVoice?.(); this.#modes.set(id, 'parked'); }
171
+ async stopBuild(id) { const controller = this.#controllers.get(id); controller?.abort('user_stop'); const runtime = await this.#runtimes.get(id); await runtime?.stopBuild?.(); await this.#tails.get(id); if (this.#controllers.get(id) === controller)
172
+ this.#controllers.delete(id); }
173
+ async localApproval(id, approvalId, approved, always) { const runtime = await this.#runtimes.get(id); if (!runtime?.localApproval)
174
+ throw Error('local_approval_unavailable'); await runtime.localApproval(approvalId, approved, always); }
123
175
  async clear(id) { this.#modes.delete(id); this.#lifetimes.get(id)?.abort(); this.#lifetimes.delete(id); this.#controllers.get(id)?.abort(); await this.#tails.get(id); const runtime = this.#runtimes.get(id); this.#runtimes.delete(id); this.#ready.delete(id); this.#controllers.delete(id); this.#tails.delete(id); if (runtime) {
124
- const ready = await runtime;
176
+ const ready = await runtime.catch(() => undefined);
177
+ if (!ready)
178
+ return;
125
179
  if (!this.#closed && ready.retainTasks?.()) {
126
180
  await ready.parkVoice?.();
127
181
  const retained = this.#retired.get(id) ?? new Set();
@@ -131,12 +185,12 @@ export class ConversationRuntimePool {
131
185
  else
132
186
  await ready.close();
133
187
  } }
134
- async startVoice(conversation) { if (conversation.kind === 'schedule')
188
+ async startVoice(conversation, voiceMode) { if (conversation.kind === 'schedule')
135
189
  throw Error('hidden_conversation'); if (this.#closed)
136
190
  throw Error('conversation_runtime_closed'); if (this.#busy.has(conversation.id) || this.#ready.get(conversation.id)?.canSwitch?.() === false)
137
191
  throw Error('conversation_busy'); await this.clear(conversation.id); if (this.#closed)
138
192
  throw Error('conversation_runtime_closed'); this.#modes.set(conversation.id, 'voice'); const lifetime = new AbortController(); this.#lifetimes.set(conversation.id, lifetime); const runtime = this.create(structuredClone(conversation), frame => { if (!lifetime.signal.aborted && this.#lifetimes.get(conversation.id) === lifetime)
139
- this.emit({ ...frame, conversation_id: conversation.id }); }, 'voice', lifetime.signal); this.#runtimes.set(conversation.id, runtime); let ready; try {
193
+ this.emit({ ...frame, conversation_id: conversation.id }); }, 'voice', lifetime.signal, undefined, undefined, voiceMode ? { voice_mode: voiceMode, ...(voiceMode === 'delegate' ? { chat: false } : {}) } : undefined); this.#runtimes.set(conversation.id, runtime); let ready; try {
140
194
  ready = await runtime;
141
195
  }
142
196
  catch (error) {
@@ -170,7 +224,8 @@ export class ConversationRuntimePool {
170
224
  }
171
225
  catch { }
172
226
  } throw Error('approval_unavailable'); }
173
- async close() { this.#closed = true; await Promise.all([...new Set([...this.#controllers.keys(), ...this.#runtimes.keys()])].map(id => this.clear(id))); await Promise.all([...this.#retired.values()].flatMap(items => [...items].map(runtime => runtime.close()))); this.#retired.clear(); }
227
+ async close() { this.#closed = true; for (const lifetime of this.#isolatedLifetimes)
228
+ lifetime.abort(); await Promise.allSettled(this.#isolated); await Promise.all([...new Set([...this.#controllers.keys(), ...this.#runtimes.keys()])].map(id => this.clear(id))); await Promise.all([...this.#retired.values()].flatMap(items => [...items].map(runtime => runtime.close()))); this.#retired.clear(); }
174
229
  }
175
230
  /** Acknowledgements cover only messages actually visible, never later arrivals. */
176
231
  export function markConversationRead(conversation, throughId) {
@@ -181,7 +236,8 @@ export function markConversationRead(conversation, throughId) {
181
236
  message.read = true;
182
237
  conversation.read_through_id = throughId;
183
238
  }
239
+ /** Only messages Nova sent on its own (notifications, scheduled results) count; replies to the user never do. */
184
240
  export function conversationUnreadCount(conversation) {
185
- return conversation.messages.filter(message => message.role === 'assistant' && message.read !== true && (conversation.kind === 'proactive' || message.schedule_ref?.run_id !== undefined)).length;
241
+ return conversation.messages.filter(message => message.role === 'assistant' && message.read !== true && (message.origin === 'proactive' || message.schedule_ref?.run_id !== undefined)).length;
186
242
  }
187
243
  //# sourceMappingURL=conversations.js.map
@@ -25,6 +25,11 @@ export function isQuietTime(input, now) {
25
25
  const settings = dailyBriefSettings(input);
26
26
  return quiet(localParts(formatter(settings.timezone), now).time, settings.quiet_start, settings.quiet_end);
27
27
  }
28
+ /** Briefs that are switched on but scheduled inside quiet hours: the scheduler skips those slots, so they would never be sent. */
29
+ export function briefQuietConflicts(input) {
30
+ const settings = dailyBriefSettings(input);
31
+ return ['outlook', 'review'].filter(kind => settings[`briefing_${kind}_enabled`] && quiet(settings[`briefing_${kind}_time`], settings.quiet_start, settings.quiet_end));
32
+ }
28
33
  /** Returns only recent real wall-clock slots; the host tracks bounded durable attempts for each key. */
29
34
  export function dueDailyBriefs(input, now, claimed) {
30
35
  const settings = dailyBriefSettings(input), format = formatter(settings.timezone), current = localParts(format, now);