@vellumai/assistant 0.12.3 → 0.12.4-dev.202609231715.8da971c

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 (229) hide show
  1. package/Dockerfile +7 -0
  2. package/README.md +12 -12
  3. package/docker/mousepad/90-vellum.gschema.override +4 -0
  4. package/node_modules/@vellumai/avatar-manifest/src/__tests__/notification-avatar.test.ts +48 -4
  5. package/node_modules/@vellumai/avatar-manifest/src/notification-avatar.ts +12 -8
  6. package/openapi.yaml +97 -4
  7. package/package.json +1 -1
  8. package/src/__tests__/approval-routes-http.test.ts +4 -2
  9. package/src/__tests__/call-routes-http.test.ts +4 -2
  10. package/src/__tests__/channel-readiness-discord.test.ts +8 -0
  11. package/src/__tests__/channel-readiness-slack-remote.test.ts +8 -0
  12. package/src/__tests__/config-loader-backfill.test.ts +1 -0
  13. package/src/__tests__/conversation-pairing.test.ts +10 -0
  14. package/src/__tests__/conversation-resurface-done.test.ts +289 -0
  15. package/src/__tests__/default-profile-catalog-fallback.test.ts +1 -0
  16. package/src/__tests__/gemini-provider.test.ts +31 -0
  17. package/src/__tests__/inference-profile-validation-jev.test.ts +17 -0
  18. package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
  19. package/src/__tests__/llm-catalog-parity.test.ts +4 -0
  20. package/src/__tests__/llm-resolver-override-or-default.test.ts +43 -0
  21. package/src/__tests__/openai-responses-prompt-cache.test.ts +3 -1
  22. package/src/__tests__/platform-callback-registration.test.ts +46 -1
  23. package/src/__tests__/plugin-api-model-profiles.test.ts +7 -0
  24. package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
  25. package/src/__tests__/pricing.test.ts +33 -0
  26. package/src/__tests__/provider-error-scenarios.test.ts +46 -0
  27. package/src/__tests__/provider-platform-proxy-integration.test.ts +45 -15
  28. package/src/__tests__/retry-fallback-escalation.test.ts +22 -0
  29. package/src/__tests__/runtime-attachment-metadata.test.ts +4 -2
  30. package/src/__tests__/scaffold-managed-skill-tool.test.ts +116 -66
  31. package/src/__tests__/secret-routes-platform-proxy.test.ts +1 -0
  32. package/src/__tests__/send-endpoint-busy.test.ts +4 -2
  33. package/src/__tests__/skill-load-inline-command.test.ts +35 -0
  34. package/src/__tests__/skill-load-tool.test.ts +42 -11
  35. package/src/__tests__/skill-tool-factory.test.ts +50 -2
  36. package/src/__tests__/steer-on-enqueue-question.test.ts +265 -34
  37. package/src/__tests__/validate-input.test.ts +73 -0
  38. package/src/__tests__/workspace-migration-159-rename-colliding-jev-profile-name.test.ts +197 -0
  39. package/src/api/ask-question-tool.ts +50 -0
  40. package/src/api/events/tool-result.ts +11 -0
  41. package/src/api/index.ts +7 -0
  42. package/src/api/requests/dictation.ts +2 -2
  43. package/src/api/responses/home.ts +27 -0
  44. package/src/avatar/notification-avatar.test.ts +42 -34
  45. package/src/avatar/notification-avatar.ts +1 -0
  46. package/src/calls/__tests__/call-controller.test.ts +18 -0
  47. package/src/calls/__tests__/voice-control-protocol.test.ts +6 -1
  48. package/src/calls/__tests__/voice-leg-coordinator.test.ts +42 -0
  49. package/src/calls/__tests__/voice-session-bridge.test.ts +97 -4
  50. package/src/calls/__tests__/voice-triage-escalate.test.ts +69 -11
  51. package/src/calls/call-controller.ts +3 -1
  52. package/src/calls/voice-control-protocol.ts +9 -4
  53. package/src/calls/voice-escalation-judge.ts +7 -6
  54. package/src/calls/voice-leg-coordinator.ts +15 -4
  55. package/src/calls/voice-screen-annotation.ts +44 -0
  56. package/src/calls/voice-session-bridge.ts +50 -20
  57. package/src/calls/voice-triage-escalate.ts +61 -26
  58. package/src/cli/commands/__tests__/plugins.test.ts +29 -1
  59. package/src/cli/commands/channel-verification-sessions.help.ts +12 -2
  60. package/src/cli/commands/oauth/index.help.ts +8 -2
  61. package/src/cli/commands/oauth/request.test.ts +32 -0
  62. package/src/cli/commands/platform/index.help.ts +2 -1
  63. package/src/cli/commands/platform/index.ts +8 -2
  64. package/src/cli/commands/plugins.ts +16 -0
  65. package/src/cli/lib/__tests__/inspect-plugin.test.ts +29 -0
  66. package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +92 -2
  67. package/src/cli/lib/__tests__/plugin-catalog-local.test.ts +15 -0
  68. package/src/cli/lib/__tests__/plugin-catalog-platform.test.ts +66 -2
  69. package/src/cli/lib/__tests__/plugin-catalog-resolve.test.ts +21 -0
  70. package/src/cli/lib/__tests__/plugin-catalog-visibility.test.ts +65 -0
  71. package/src/cli/lib/__tests__/plugin-details.test.ts +43 -0
  72. package/src/cli/lib/__tests__/plugins-install-offline.test.ts +26 -0
  73. package/src/cli/lib/bundled-marketplace.json +4 -4
  74. package/src/cli/lib/inspect-plugin.ts +5 -0
  75. package/src/cli/lib/plugin-catalog-cache.ts +41 -4
  76. package/src/cli/lib/plugin-catalog-local.ts +9 -0
  77. package/src/cli/lib/plugin-catalog-platform.ts +48 -9
  78. package/src/cli/lib/plugin-catalog-visibility.ts +41 -0
  79. package/src/cli/lib/plugin-details.ts +10 -7
  80. package/src/cli/lib/search-plugins.ts +2 -0
  81. package/src/config/__tests__/default-profile-catalog.test.ts +61 -1
  82. package/src/config/__tests__/jev-managed-profile.test.ts +82 -0
  83. package/src/config/__tests__/platform-identity.test.ts +59 -0
  84. package/src/config/__tests__/sync-gated-profiles.test.ts +71 -0
  85. package/src/config/bundled-skills/screen-annotation/SKILL.md +6 -3
  86. package/src/config/call-site-defaults.ts +17 -11
  87. package/src/config/default-profile-catalog.ts +118 -19
  88. package/src/config/default-profile-names.ts +69 -0
  89. package/src/config/feature-flag-registry.json +25 -9
  90. package/src/config/inference-profile-validation.ts +7 -6
  91. package/src/config/llm-resolver.ts +16 -0
  92. package/src/config/platform-identity.ts +22 -5
  93. package/src/config/profile-text-generation.test.ts +9 -0
  94. package/src/config/schemas/call-site-catalog.ts +8 -1
  95. package/src/config/schemas/llm.ts +70 -9
  96. package/src/config/sidebar-done-gate.ts +27 -0
  97. package/src/config/sync-gated-profiles.ts +96 -44
  98. package/src/daemon/__tests__/auto-profile-router.test.ts +228 -0
  99. package/src/daemon/auto-profile-router.ts +220 -0
  100. package/src/daemon/conversation-agent-loop.ts +77 -4
  101. package/src/daemon/conversation-slash.ts +2 -2
  102. package/src/daemon/conversation-turn-finalize.ts +12 -0
  103. package/src/daemon/dictation-text-processing.ts +4 -4
  104. package/src/daemon/handlers/__tests__/conversation-history-search.test.ts +61 -0
  105. package/src/daemon/handlers/config-channels.ts +3 -1
  106. package/src/daemon/handlers/conversation-history.ts +11 -1
  107. package/src/daemon/handlers/conversations.ts +118 -10
  108. package/src/daemon/pkb-reminder-builder.test.ts +10 -3
  109. package/src/daemon/pkb-reminder-builder.ts +1 -1
  110. package/src/desktop/desktop-browser-endpoint.ts +1 -0
  111. package/src/home/feed-types.ts +2 -0
  112. package/src/inbound/platform-callback-registration.ts +19 -6
  113. package/src/ipc/routes/__tests__/conversation-sync-ipc-routes.test.ts +49 -1
  114. package/src/ipc/routes/conversation-sync-ipc-routes.ts +38 -2
  115. package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +27 -0
  116. package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +37 -1
  117. package/src/live-voice/__tests__/live-voice-vad.test.ts +34 -2
  118. package/src/live-voice/__tests__/protocol.test.ts +22 -0
  119. package/src/live-voice/continuation-judge.ts +1 -1
  120. package/src/live-voice/live-voice-session.ts +17 -14
  121. package/src/live-voice/protocol.ts +16 -5
  122. package/src/messaging/providers/gmail/client.ts +4 -0
  123. package/src/notifications/README.md +11 -3
  124. package/src/notifications/__tests__/assistant-reply-producer.test.ts +13 -0
  125. package/src/notifications/__tests__/home-feed-side-effect.test.ts +87 -3
  126. package/src/notifications/conversation-pairing.ts +23 -8
  127. package/src/notifications/home-feed-mirror.ts +39 -0
  128. package/src/notifications/home-feed-side-effect.ts +46 -19
  129. package/src/oauth/AGENTS.md +9 -1
  130. package/src/oauth/byo-connection.test.ts +28 -0
  131. package/src/permissions/question-prompter.ts +14 -4
  132. package/src/persistence/conversation-crud.ts +116 -3
  133. package/src/persistence/conversation-queries.ts +48 -3
  134. package/src/persistence/conversation-types.ts +6 -2
  135. package/src/persistence/embeddings/__tests__/embedding-local-lifecycle.test.ts +228 -32
  136. package/src/persistence/embeddings/embedding-backend-shutdown.test.ts +47 -0
  137. package/src/persistence/embeddings/embedding-backend.ts +23 -41
  138. package/src/persistence/embeddings/embedding-gemini.test.ts +17 -0
  139. package/src/persistence/embeddings/embedding-gemini.ts +3 -1
  140. package/src/persistence/embeddings/embedding-local.ts +72 -17
  141. package/src/persistence/embeddings/embedding-types.ts +0 -19
  142. package/src/persistence/jobs-store.ts +229 -0
  143. package/src/persistence/migrations/383-normalize-opencode-host-connections.ts +44 -0
  144. package/src/persistence/migrations/__tests__/383-normalize-opencode-host-connections.test.ts +102 -0
  145. package/src/persistence/steps.ts +12 -0
  146. package/src/platform/sync-avatar.test.ts +29 -0
  147. package/src/plugin-api/model-profiles.ts +5 -3
  148. package/src/plugins/defaults/memory/AGENTS.md +5 -3
  149. package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +2 -0
  150. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-boundary-guard.test.ts +45 -0
  151. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-job.test.ts +580 -0
  152. package/src/plugins/defaults/memory/graph/tools.ts +9 -5
  153. package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +4 -0
  154. package/src/plugins/defaults/memory/job-handlers.ts +8 -2
  155. package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +5 -0
  156. package/src/plugins/defaults/memory/skill-update-receipt-job.ts +334 -0
  157. package/src/plugins/defaults/memory/substrate/skill-content.ts +1 -1
  158. package/src/plugins/defaults/memory/tools.test.ts +17 -0
  159. package/src/plugins/defaults/memory/v3/__tests__/render-injection.test.ts +3 -0
  160. package/src/providers/__tests__/connection-model-compat.test.ts +2 -0
  161. package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
  162. package/src/providers/anthropic/client.ts +2 -2
  163. package/src/providers/gemini/client.ts +17 -1
  164. package/src/providers/inference/auth.ts +25 -0
  165. package/src/providers/jev/ask.test.ts +66 -0
  166. package/src/{calls/typesafe-noul.ts → providers/jev/ask.ts} +75 -36
  167. package/src/providers/malformed-tool-call.ts +55 -0
  168. package/src/providers/model-catalog.ts +257 -4
  169. package/src/providers/openai/__tests__/chat-completions-malformed-tool-call.test.ts +105 -0
  170. package/src/providers/openai/chat-completions-provider.ts +30 -0
  171. package/src/providers/openai/codex-models.ts +2 -0
  172. package/src/providers/platform-proxy/constants.ts +5 -0
  173. package/src/providers/retry.ts +68 -36
  174. package/src/providers/search-provider-catalog.ts +10 -0
  175. package/src/providers/vellum-model-routing.test.ts +1 -0
  176. package/src/runtime/__tests__/agent-wake-archived-gate.test.ts +90 -0
  177. package/src/runtime/__tests__/question-resolution.test.ts +32 -0
  178. package/src/runtime/agent-wake.ts +9 -2
  179. package/src/runtime/auth/__tests__/middleware.test.ts +138 -0
  180. package/src/runtime/auth/middleware.ts +15 -11
  181. package/src/runtime/middleware/auth.ts +7 -1
  182. package/src/runtime/pending-interactions.ts +8 -8
  183. package/src/runtime/question-resolution.ts +54 -8
  184. package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +146 -0
  185. package/src/runtime/routes/__tests__/dictation-processing.test.ts +174 -0
  186. package/src/runtime/routes/__tests__/global-search-routes.test.ts +74 -1
  187. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +60 -0
  188. package/src/runtime/routes/__tests__/llm-call-sites-routes.test.ts +16 -1
  189. package/src/runtime/routes/__tests__/oauth-proxy-routes.test.ts +61 -3
  190. package/src/runtime/routes/__tests__/plugins-routes.test.ts +8 -0
  191. package/src/runtime/routes/conversation-list-routes.ts +16 -14
  192. package/src/runtime/routes/conversation-query-routes.ts +4 -0
  193. package/src/runtime/routes/conversation-routes.ts +4 -2
  194. package/src/runtime/routes/diagnostics-routes.ts +66 -229
  195. package/src/runtime/routes/global-search-routes.ts +22 -7
  196. package/src/runtime/routes/inference-provider-connection-routes.ts +25 -8
  197. package/src/runtime/routes/llm-call-sites-routes.ts +19 -10
  198. package/src/runtime/routes/oauth-proxy-passthrough.test.ts +32 -0
  199. package/src/runtime/routes/platform-routes.ts +6 -1
  200. package/src/runtime/routes/plugins-routes.ts +5 -2
  201. package/src/runtime/sync/documents-sidecar-publish.test.ts +50 -4
  202. package/src/runtime/sync/resource-sync-events.ts +11 -0
  203. package/src/runtime/sync/worker-daemon-notify.test.ts +30 -0
  204. package/src/runtime/sync/worker-daemon-notify.ts +44 -0
  205. package/src/runtime/verification-outbound-actions.ts +2 -2
  206. package/src/skills/validate-input.ts +75 -11
  207. package/src/telegram/__tests__/webhook-health.test.ts +8 -0
  208. package/src/tools/ask-question/ask-question-tool.test.ts +38 -0
  209. package/src/tools/ask-question/ask-question-tool.ts +12 -1
  210. package/src/tools/network/__tests__/web-fetch-firecrawl.test.ts +28 -1
  211. package/src/tools/network/__tests__/web-fetch-metadata.test.ts +34 -0
  212. package/src/tools/network/__tests__/web-fetch-tinyfish.test.ts +35 -1
  213. package/src/tools/network/__tests__/web-search.test.ts +96 -0
  214. package/src/tools/network/web-fetch.ts +30 -9
  215. package/src/tools/network/web-search.ts +235 -4
  216. package/src/tools/skills/execute.ts +1 -1
  217. package/src/tools/skills/format-input-schema.ts +15 -0
  218. package/src/tools/skills/load.ts +15 -43
  219. package/src/tools/skills/scaffold-managed.ts +86 -71
  220. package/src/tools/skills/skill-tool-factory.ts +2 -1
  221. package/src/tools/workflows/manage-workflows.ts +4 -2
  222. package/src/util/oauth-request-body.test.ts +5 -1
  223. package/src/util/worker-pipe.test.ts +146 -0
  224. package/src/util/worker-pipe.ts +49 -0
  225. package/src/workspace/migrations/158-repoint-opencode-host-provider-fragments.ts +163 -0
  226. package/src/workspace/migrations/159-rename-colliding-jev-profile-name.ts +344 -0
  227. package/src/workspace/migrations/__tests__/158-repoint-opencode-host-provider-fragments.test.ts +188 -0
  228. package/src/workspace/migrations/registry.ts +4 -0
  229. package/src/runtime/routes/__tests__/dictation-cleanup-guard.test.ts +0 -107
@@ -32,6 +32,7 @@ import type { ChannelId, InterfaceId } from "../channels/types.js";
32
32
  import { parseChannelId, parseInterfaceId } from "../channels/types.js";
33
33
  import { CHANNEL_IDS, isChannelId } from "../channels/types.js";
34
34
  import { getConfig } from "../config/loader.js";
35
+ import { isSidebarDoneEnabled } from "../config/sidebar-done-gate.js";
35
36
  import { findDisplayTurnEndIndex } from "../conversations/message-consolidation.js";
36
37
  import { findConversation } from "../daemon/conversation-registry.js";
37
38
  import { conversationMetadataSyncTag } from "../daemon/message-types/sync.js";
@@ -48,6 +49,7 @@ import { indexMessageNow } from "../plugins/defaults/memory/indexer.js";
48
49
  import { runHook } from "../plugins/pipeline.js";
49
50
  import type { ContentBlock } from "../providers/types.js";
50
51
  import { getCurrentSeq } from "../runtime/assistant-stream-state.js";
52
+ import { publishConversationListAndMetadataChanged } from "../runtime/sync/resource-sync-events.js";
51
53
  import { publishSyncInvalidation } from "../runtime/sync/sync-publisher.js";
52
54
  import { UserError } from "../util/errors.js";
53
55
  import { getLogger } from "../util/logger.js";
@@ -100,6 +102,7 @@ import {
100
102
  computerUseScreenshotAttachmentIdsFromMetadata,
101
103
  type ConversationCreateType,
102
104
  type ConversationOrigin,
105
+ isEchoSuppressedUserMessage,
103
106
  isHiddenMessageMetadata,
104
107
  isNoResponseMetadata,
105
108
  isReactionMessageMetadata,
@@ -429,6 +432,8 @@ export const messageMetadataSchema = z
429
432
  * treat message text as organic user input.
430
433
  */
431
434
  hidden: z.boolean().optional(),
435
+ /** A hidden voice continuation trigger whose finished reply can raise a push. */
436
+ voiceContinuationResult: z.boolean().optional(),
432
437
  /**
433
438
  * Marks a role-`"user"` row that opened a live phone or in-app voice turn.
434
439
  * Test with {@link isVoiceSessionUserMessage}, which documents why the
@@ -942,6 +947,11 @@ interface InsertMessageCoreParams {
942
947
  /** Answered synchronously at the top of every insert attempt. See
943
948
  * {@link AddMessageOptions.insertPrecondition}. */
944
949
  insertPrecondition?: () => boolean;
950
+ /** The row is a reservation booked ahead of the content that will fill it
951
+ * ({@link reserveMessage}), so it carries nothing to read yet. */
952
+ reserved?: boolean;
953
+ /** See {@link AddMessageOptions.skipResurface}. */
954
+ skipResurface?: boolean;
945
955
  }
946
956
 
947
957
  /**
@@ -1029,6 +1039,8 @@ async function insertMessageCore(
1029
1039
  clientMessageId,
1030
1040
  id,
1031
1041
  insertPrecondition,
1042
+ reserved,
1043
+ skipResurface,
1032
1044
  } = params;
1033
1045
  warnOnModelInvisibleContent(content, conversationId);
1034
1046
  const db = getDb();
@@ -1054,7 +1066,7 @@ async function insertMessageCore(
1054
1066
 
1055
1067
  // The timestamp is recomputed each attempt so a late retry doesn't persist a
1056
1068
  // stale `updatedAt`.
1057
- return withSqliteRetry(
1069
+ const inserted = await withSqliteRetry(
1058
1070
  (): InsertedMessage => {
1059
1071
  // Asked at the top of EVERY attempt, and synchronously, because that is
1060
1072
  // the scope the answer holds for. Contention retries this function after
@@ -1179,6 +1191,32 @@ async function insertMessageCore(
1179
1191
  },
1180
1192
  { op: "insertMessageCore", context: { conversationId } },
1181
1193
  );
1194
+
1195
+ // A message the user reads brings a Done conversation back to the list.
1196
+ // Four kinds of insert are not that: the echo-suppressed set, which never
1197
+ // renders in the transcript; the empty row `reserveMessage` books for an LLM
1198
+ // call that has not run yet, whose content arrives at the finalize seam and
1199
+ // resurfaces from there; a row whose producer declared it bookkeeping ABOUT
1200
+ // the conversation rather than activity in it (`skipResurface`); and a
1201
+ // deduplicated insert, which wrote no row at all. Best-effort: a failure
1202
+ // here must not escalate into a failed persist.
1203
+ if (
1204
+ !inserted.deduplicated &&
1205
+ !reserved &&
1206
+ !skipResurface &&
1207
+ !isEchoSuppressedUserMessage(metadata)
1208
+ ) {
1209
+ try {
1210
+ resurfaceArchivedConversation(conversationId, inserted.createdAt);
1211
+ } catch (err) {
1212
+ log.warn(
1213
+ { err, conversationId, messageId: inserted.id },
1214
+ "Failed to resurface Done conversation after message insert",
1215
+ );
1216
+ }
1217
+ }
1218
+
1219
+ return inserted;
1182
1220
  }
1183
1221
 
1184
1222
  /**
@@ -2653,6 +2691,17 @@ export interface AddMessageOptions {
2653
2691
  * during that sleep.
2654
2692
  */
2655
2693
  insertPrecondition?: () => boolean;
2694
+ /**
2695
+ * The row is the assistant's bookkeeping ABOUT this conversation rather than
2696
+ * activity in it, so it must not bring the conversation back from Done (see
2697
+ * {@link resurfaceArchivedConversation}). The producer declares this, because
2698
+ * only the producer knows which of the two a row is.
2699
+ *
2700
+ * The retrospective skill card is the case: a pass runs once a conversation
2701
+ * has gone idle, which is exactly when the user has just marked it done, so
2702
+ * a card that resurfaced would bounce fresh done chats back into the sidebar.
2703
+ */
2704
+ skipResurface?: boolean;
2656
2705
  }
2657
2706
 
2658
2707
  /**
@@ -2666,8 +2715,14 @@ export async function addMessage(
2666
2715
  content: string,
2667
2716
  options?: AddMessageOptions,
2668
2717
  ) {
2669
- const { metadata, skipIndexing, clientMessageId, id, insertPrecondition } =
2670
- options ?? {};
2718
+ const {
2719
+ metadata,
2720
+ skipIndexing,
2721
+ clientMessageId,
2722
+ id,
2723
+ insertPrecondition,
2724
+ skipResurface,
2725
+ } = options ?? {};
2671
2726
  const inserted = await insertMessageCore({
2672
2727
  conversationId,
2673
2728
  role,
@@ -2676,6 +2731,7 @@ export async function addMessage(
2676
2731
  clientMessageId,
2677
2732
  id,
2678
2733
  ...(insertPrecondition ? { insertPrecondition } : {}),
2734
+ ...(skipResurface ? { skipResurface } : {}),
2679
2735
  });
2680
2736
 
2681
2737
  if (inserted.deduplicated) {
@@ -3521,6 +3577,62 @@ export function unarchiveConversation(id: string): boolean {
3521
3577
  return true;
3522
3578
  }
3523
3579
 
3580
+ /**
3581
+ * Bring a Done conversation back to the list because a message the user reads
3582
+ * landed in it at `activityAt`.
3583
+ *
3584
+ * Under the `sidebar-done` gate "Done" is a completion mark, not a deletion:
3585
+ * the conversation keeps its schedules and its channel threads, so anything
3586
+ * the user would read arriving in it has to be reachable again. Two seams call
3587
+ * this, which between them cover every ingest path without a per-provider
3588
+ * hook: {@link insertMessageCore}, where each durable append lands (channel
3589
+ * inbound, web and CLI sends, wake tail messages, assistant-initiated
3590
+ * notification bodies), and the turn's finalize effect, where a streamed
3591
+ * assistant reply becomes readable content.
3592
+ *
3593
+ * Rows the user never reads resurface nothing. `insertMessageCore` excludes
3594
+ * the echo-suppressed set (hidden signals, subagent and ACP notifications, and
3595
+ * the `<background_event>` trigger each wake persists); the empty row an LLM
3596
+ * call reserves before it runs, so a call rejected before producing anything
3597
+ * leaves the conversation Done; and any row whose producer passed
3598
+ * {@link AddMessageOptions.skipResurface}. Retrospectives and memory
3599
+ * consolidation are excluded by construction: they append to a fork or to a
3600
+ * conversation of their own, never to the conversation under review.
3601
+ *
3602
+ * The clear is conditional on `archived_at <= activityAt` in one statement, so
3603
+ * a Done mark the user makes after this activity (while a turn's deferred tail
3604
+ * is still settling, or from the daemon while a worker runs the turn) wins
3605
+ * instead of being erased by it.
3606
+ *
3607
+ * No-ops when the gate is off, which is the shipped behavior: nothing but the
3608
+ * unarchive route clears `archived_at`.
3609
+ */
3610
+ export function resurfaceArchivedConversation(
3611
+ conversationId: string,
3612
+ activityAt: number,
3613
+ ): boolean {
3614
+ if (!isSidebarDoneEnabled(getConfig())) {
3615
+ return false;
3616
+ }
3617
+ const now = Date.now();
3618
+ const changed = rawRun(
3619
+ "conversation:resurface",
3620
+ "UPDATE conversations SET archived_at = NULL, updated_at = ? WHERE id = ? AND archived_at IS NOT NULL AND archived_at <= ?",
3621
+ now,
3622
+ conversationId,
3623
+ activityAt,
3624
+ );
3625
+ if (changed === 0) {
3626
+ return false;
3627
+ }
3628
+ publishConversationListAndMetadataChanged("reordered", conversationId);
3629
+ log.info(
3630
+ { conversationId },
3631
+ "Resurfaced Done conversation on user-visible activity",
3632
+ );
3633
+ return true;
3634
+ }
3635
+
3524
3636
  /**
3525
3637
  * Persist the processing-start timestamp for a conversation. Called by
3526
3638
  * `Conversation.setProcessing(true)` so out-of-process callers can detect
@@ -4530,6 +4642,7 @@ export async function reserveMessage(
4530
4642
  content: inflightRef ? JSON.stringify({ ref: inflightRef }) : "[]",
4531
4643
  ...(inflightRef ? { finalized: 0 as const } : {}),
4532
4644
  metadata,
4645
+ reserved: true,
4533
4646
  });
4534
4647
  }
4535
4648
 
@@ -116,6 +116,16 @@ export function hasLexicalTokens(text: string): boolean {
116
116
  */
117
117
  export type ArchiveStatusFilter = "active" | "archived" | "all";
118
118
 
119
+ /**
120
+ * Which bucket a listing covers.
121
+ *
122
+ * The persisted {@link ConversationType} values plus `"all"`, a read-side
123
+ * union that exists only here: no row carries it, and nothing writes it. It
124
+ * lets one paginated request span a user's whole history, which is what a
125
+ * full-history view needs and what three interleaved cursors cannot give it.
126
+ */
127
+ export type ConversationListTypeFilter = ConversationType | "all";
128
+
119
129
  function archiveStatusClause(status: ArchiveStatusFilter) {
120
130
  switch (status) {
121
131
  case "active":
@@ -196,6 +206,25 @@ function surfacedVisibilitySql(alias = "conversations"): string {
196
206
  );
197
207
  }
198
208
 
209
+ /**
210
+ * Raw SQL predicate for the background **umbrella**: background and scheduled
211
+ * rows together, matched on `conversation_type` or on the system group the
212
+ * producer filed them in, with subagent runs excluded so the sidebar never
213
+ * surfaces them.
214
+ *
215
+ * Shared by the `"background"` bucket of {@link conversationTypeClause} and by
216
+ * the `"all"` bucket, which is the union of that one with the standard
217
+ * listing, so the combined read can never admit a row either bucket alone
218
+ * would have withheld.
219
+ */
220
+ function backgroundUmbrellaSql(alias = "conversations"): string {
221
+ return (
222
+ `((${alias}.conversation_type IN ('background', 'scheduled')` +
223
+ ` OR COALESCE(${alias}.group_id, 'system:all') IN ('system:background', 'system:scheduled'))` +
224
+ ` AND (${alias}.source IS NULL OR ${alias}.source != 'subagent'))`
225
+ );
226
+ }
227
+
199
228
  /**
200
229
  * Raw SQL predicate for "not an automated background/scheduled row".
201
230
  *
@@ -289,6 +318,11 @@ function ungroupedSql(alias = "conversations"): string {
289
318
  * Background and Scheduled sidebar sections from one request.
290
319
  * - `"scheduled"` — scheduled rows only, so the Scheduled section can load
291
320
  * independently of the broader background backlog without over-fetching it.
321
+ * - `"all"`: the union of `"standard"` and `"background"`, so one paginated
322
+ * request covers a user's whole history instead of interleaving three. Not
323
+ * a bypass of the visibility rules: it is exactly those two predicates
324
+ * OR-ed, with the legacy `private` type excluded on top, so nothing reaches
325
+ * it that neither bucket would have returned.
292
326
  *
293
327
  * `group_id` is matched alongside `conversationType` so conversations routed to
294
328
  * `system:background` / `system:scheduled` (heartbeat, reminders, schedule-job
@@ -296,7 +330,7 @@ function ungroupedSql(alias = "conversations"): string {
296
330
  * correct bucket. Subagent runs are excluded from the background/scheduled
297
331
  * buckets so the sidebar never surfaces them.
298
332
  */
299
- function conversationTypeClause(type: ConversationType) {
333
+ function conversationTypeClause(type: ConversationListTypeFilter) {
300
334
  const notSubagent = sql`(${conversations.source} IS NULL OR ${conversations.source} != 'subagent')`;
301
335
  switch (type) {
302
336
  case "standard":
@@ -305,9 +339,20 @@ function conversationTypeClause(type: ConversationType) {
305
339
  // standardListingVisibilitySql for the full predicate semantics.
306
340
  return sql.raw(standardListingVisibilitySql());
307
341
  case "background":
308
- return sql`(${conversations.conversationType} IN ('background', 'scheduled') OR group_id IN ('system:background', 'system:scheduled')) AND ${notSubagent}`;
342
+ return sql.raw(backgroundUmbrellaSql());
309
343
  case "scheduled":
310
344
  return sql`(${conversations.conversationType} = 'scheduled' OR group_id = 'system:scheduled') AND ${notSubagent}`;
345
+ case "all":
346
+ /* `private` is excluded explicitly rather than left to the two arms.
347
+ The standard arm already drops it everywhere, but the umbrella
348
+ matches on the system group as well as on the type, so a legacy
349
+ private row filed in `system:background` would otherwise arrive
350
+ through it. Those rows exist transiently after an in-place snapshot
351
+ restore, before migration cleanup deletes them. */
352
+ return sql.raw(
353
+ `((${standardListingVisibilitySql()} OR ${backgroundUmbrellaSql()})` +
354
+ ` AND conversations.conversation_type != 'private')`,
355
+ );
311
356
  }
312
357
  }
313
358
 
@@ -321,7 +366,7 @@ function conversationTypeClause(type: ConversationType) {
321
366
  * transposition waiting to happen.
322
367
  */
323
368
  export interface ConversationListFilter {
324
- conversationType?: ConversationType;
369
+ conversationType?: ConversationListTypeFilter;
325
370
  archiveStatus?: ArchiveStatusFilter;
326
371
  originChannel?: string;
327
372
  /**
@@ -430,7 +430,8 @@ function isReplyDeliveredOffApp(
430
430
  *
431
431
  * - `automated`: a scheduled or background prompt injected into an ordinary
432
432
  * user conversation, which has its own producer (e.g. `schedule.notify`).
433
- * - Echo-suppressed: internal scaffolding, nobody's prompt awaiting a reply.
433
+ * - Echo-suppressed: internal scaffolding, except a hidden voice continuation
434
+ * result whose finished reply reaches the user through this push.
434
435
  * - Voice-session: the reply is spoken back over the still-open session.
435
436
  * - Channel-originated: the finished reply is delivered back to the
436
437
  * originating messaging surface (`finalizeEventDelivery`), so the sender
@@ -455,7 +456,10 @@ export function isReplyPushIneligibleUserMessage(
455
456
  return (
456
457
  metadata?.automated === true ||
457
458
  metadata?.pointerInstruction === true ||
458
- isEchoSuppressedUserMessage(metadata) ||
459
+ (isEchoSuppressedUserMessage(metadata) &&
460
+ !(
461
+ metadata?.hidden === true && metadata?.voiceContinuationResult === true
462
+ )) ||
459
463
  (!options?.replyDeliveredInAppOnly && isReplyDeliveredOffApp(metadata))
460
464
  );
461
465
  }