@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
@@ -6,7 +6,7 @@ import { buildPkbReminder } from "./pkb-reminder-builder.js";
6
6
  // future edit to the BODY text is caught by tests.
7
7
  const BASE_REMINDER =
8
8
  "<system_reminder>" +
9
- "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark — corrections (highest priority), plans, decisions, felt moments. You don't have to capture everything in the moment — a retrospective pass reviews this conversation in the background and saves what you didn't capture." +
9
+ "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark: corrections (highest priority), plans, decisions, felt moments. A later pass may review this conversation and save what you did not capture, but it is not guaranteed and never runs over scheduled work, so save now anything that must survive." +
10
10
  "\nIf you're unsure about something that may live in the workspace — past decisions, prior conversations, files — use `recall` before asking or guessing." +
11
11
  "\n</system_reminder>";
12
12
 
@@ -19,7 +19,7 @@ describe("buildPkbReminder", () => {
19
19
  const out = buildPkbReminder(["projects/alpha.md"]);
20
20
  const expected =
21
21
  "<system_reminder>" +
22
- "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark — corrections (highest priority), plans, decisions, felt moments. You don't have to capture everything in the moment — a retrospective pass reviews this conversation in the background and saves what you didn't capture." +
22
+ "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark: corrections (highest priority), plans, decisions, felt moments. A later pass may review this conversation and save what you did not capture, but it is not guaranteed and never runs over scheduled work, so save now anything that must survive." +
23
23
  "\nIf you're unsure about something that may live in the workspace — past decisions, prior conversations, files — use `recall` before asking or guessing." +
24
24
  "\nBased on the current context, these files look especially relevant:" +
25
25
  "\n- projects/alpha.md" +
@@ -39,7 +39,7 @@ describe("buildPkbReminder", () => {
39
39
  const out = buildPkbReminder(hints);
40
40
  const expected =
41
41
  "<system_reminder>" +
42
- "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark — corrections (highest priority), plans, decisions, felt moments. You don't have to capture everything in the moment — a retrospective pass reviews this conversation in the background and saves what you didn't capture." +
42
+ "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark: corrections (highest priority), plans, decisions, felt moments. A later pass may review this conversation and save what you did not capture, but it is not guaranteed and never runs over scheduled work, so save now anything that must survive." +
43
43
  "\nIf you're unsure about something that may live in the workspace — past decisions, prior conversations, files — use `recall` before asking or guessing." +
44
44
  "\nBased on the current context, these files look especially relevant:" +
45
45
  "\n- a.md" +
@@ -57,6 +57,13 @@ describe("buildPkbReminder", () => {
57
57
  expect(idxC).toBeGreaterThan(idxB);
58
58
  });
59
59
 
60
+ test("says later capture is conditional and never covers scheduled work", () => {
61
+ const out = buildPkbReminder([]);
62
+ expect(out).toContain("not guaranteed");
63
+ expect(out).toContain("never runs over scheduled work");
64
+ expect(out).not.toContain("reviews this conversation in the background");
65
+ });
66
+
60
67
  test("hints with special chars (< and &) are emitted verbatim (no escaping)", () => {
61
68
  const hints = ["weird<name>.md", "foo&bar.md"];
62
69
  const out = buildPkbReminder(hints);
@@ -1,5 +1,5 @@
1
1
  const BODY =
2
- "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark — corrections (highest priority), plans, decisions, felt moments. You don't have to capture everything in the moment — a retrospective pass reviews this conversation in the background and saves what you didn't capture." +
2
+ "\nStay present in this conversation. Use `remember` when something feels worth pausing to mark: corrections (highest priority), plans, decisions, felt moments. A later pass may review this conversation and save what you did not capture, but it is not guaranteed and never runs over scheduled work, so save now anything that must survive." +
3
3
  "\nIf you're unsure about something that may live in the workspace — past decisions, prior conversations, files — use `recall` before asking or guessing.";
4
4
 
5
5
  /**
@@ -134,6 +134,7 @@ export function desktopChromeArguments(
134
134
  `--class=${DESKTOP_CHROME_WINDOW_CLASS}`,
135
135
  "--force-renderer-accessibility",
136
136
  "--disable-dev-shm-usage",
137
+ "--disable-features=Prerender2",
137
138
  ...(shouldRestoreDesktopChromeSession(profileDir)
138
139
  ? ["--restore-last-session", "--hide-crash-restore-bubble"]
139
140
  : []),
@@ -39,6 +39,8 @@ export {
39
39
  FeedItemSchema as feedItemSchema,
40
40
  type FeedItemStatus,
41
41
  type FeedItemType,
42
+ type FeedItemUpdate,
43
+ FeedItemUpdateSchema as feedItemUpdateSchema,
42
44
  type FeedItemUrgency,
43
45
  isPendingGuardianFeedItem,
44
46
  type SuggestedPrompt,
@@ -24,7 +24,10 @@ import { getConfig } from "../config/loader.js";
24
24
  import { resolvePlatformAssistantId } from "../config/platform-identity.js";
25
25
  import { ipcRegisterWebhookRoute } from "../ipc/gateway-client.js";
26
26
  import { credentialKey } from "../security/credential-key.js";
27
- import { getSecureKeyAsync } from "../security/secure-keys.js";
27
+ import {
28
+ getSecureKeyAsync,
29
+ getSecureKeyResultAsync,
30
+ } from "../security/secure-keys.js";
28
31
  import { getLogger } from "../util/logger.js";
29
32
  import { resolveClaimedPodWebhookUrl } from "./pod-webhook-claim.js";
30
33
  import {
@@ -39,17 +42,23 @@ export interface PlatformCallbackRegistrationContext {
39
42
  isPlatform: boolean;
40
43
  platformBaseUrl: string;
41
44
  assistantId: string;
42
- hasAssistantApiKey: boolean;
45
+ /**
46
+ * Whether a managed assistant API key is available: `null` when the
47
+ * credential store could not be read, so its absence is not evidence that
48
+ * no key is stored. A client deciding whether to provision one must not
49
+ * read `null` as "missing".
50
+ */
51
+ hasAssistantApiKey: boolean | null;
43
52
  authHeader: string | null;
44
53
  enabled: boolean;
45
54
  }
46
55
 
47
56
  export async function resolvePlatformCallbackRegistrationContext(): Promise<PlatformCallbackRegistrationContext> {
48
57
  const platform = getIsPlatform();
49
- const [storedBaseUrlRaw, storedAssistantApiKeyRaw, assistantId] =
58
+ const [storedBaseUrlRaw, storedAssistantApiKey, assistantId] =
50
59
  await Promise.all([
51
60
  getSecureKeyAsync(credentialKey("vellum", "platform_base_url")),
52
- getSecureKeyAsync(credentialKey("vellum", "assistant_api_key")),
61
+ getSecureKeyResultAsync(credentialKey("vellum", "assistant_api_key")),
53
62
  resolvePlatformAssistantId(),
54
63
  ]);
55
64
 
@@ -60,16 +69,20 @@ export async function resolvePlatformCallbackRegistrationContext(): Promise<Plat
60
69
  );
61
70
  const envAssistantCredential = process.env.ASSISTANT_API_KEY?.trim();
62
71
  const assistantCredential =
63
- storedAssistantApiKeyRaw?.trim() || envAssistantCredential || undefined;
72
+ storedAssistantApiKey.value?.trim() || envAssistantCredential || undefined;
64
73
  const authHeader = assistantCredential
65
74
  ? `Api-Key ${assistantCredential}`
66
75
  : null;
76
+ const hasAssistantApiKey =
77
+ !assistantCredential && storedAssistantApiKey.unreachable
78
+ ? null
79
+ : !!assistantCredential;
67
80
 
68
81
  return {
69
82
  isPlatform: platform,
70
83
  platformBaseUrl,
71
84
  assistantId,
72
- hasAssistantApiKey: !!assistantCredential,
85
+ hasAssistantApiKey,
73
86
  authHeader,
74
87
  // Enabled when we have enough context to register callback routes.
75
88
  // Does NOT require IS_PLATFORM — self-hosted assistants with stored
@@ -16,6 +16,7 @@ import { beforeEach, describe, expect, mock, test } from "bun:test";
16
16
 
17
17
  const recordCalls: Array<[string, number]> = [];
18
18
  const publishCalls: string[] = [];
19
+ const listPublishCalls: Array<[string, string | string[]]> = [];
19
20
 
20
21
  mock.module("../../../persistence/conversation-crud.js", () => ({
21
22
  recordConversationPersistedSeq: (id: string, seq: number) => {
@@ -27,6 +28,12 @@ mock.module("../../../runtime/sync/resource-sync-events.js", () => ({
27
28
  publishConversationMessagesChanged: (id: string) => {
28
29
  publishCalls.push(id);
29
30
  },
31
+ publishConversationListAndMetadataChanged: (
32
+ reason: string,
33
+ ids: string | string[],
34
+ ) => {
35
+ listPublishCalls.push([reason, ids]);
36
+ },
30
37
  }));
31
38
 
32
39
  import type { AssistantEventEnvelope } from "../../../api/index.js";
@@ -40,9 +47,13 @@ import {
40
47
  _resetStreamStateForTesting,
41
48
  stampAndBuffer,
42
49
  } from "../../../runtime/assistant-stream-state.js";
43
- import { NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD } from "../../../runtime/sync/worker-daemon-notify.js";
50
+ import {
51
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD,
52
+ NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD,
53
+ } from "../../../runtime/sync/worker-daemon-notify.js";
44
54
  import {
45
55
  CONVERSATION_SYNC_IPC_METHODS,
56
+ handleNotifyConversationListChanged,
46
57
  handleNotifyConversationPersisted,
47
58
  } from "../conversation-sync-ipc-routes.js";
48
59
 
@@ -176,3 +187,40 @@ describe("conversation-sync IPC route", () => {
176
187
  ).toBe(false);
177
188
  });
178
189
  });
190
+
191
+ describe("conversation-list-changed IPC route", () => {
192
+ beforeEach(() => {
193
+ listPublishCalls.length = 0;
194
+ });
195
+
196
+ test("republishes the worker's list invalidation on the daemon's hub", () => {
197
+ const result = handleNotifyConversationListChanged({
198
+ body: { reason: "reordered", conversationIds: ["conv-1"] },
199
+ });
200
+
201
+ expect(result).toEqual({ ok: true });
202
+ expect(listPublishCalls).toEqual([["reordered", ["conv-1"]]]);
203
+ });
204
+
205
+ test("rejects an unknown reason and an empty id list", () => {
206
+ expect(() =>
207
+ handleNotifyConversationListChanged({
208
+ body: { reason: "resurfaced", conversationIds: ["conv-1"] },
209
+ }),
210
+ ).toThrow();
211
+ expect(() =>
212
+ handleNotifyConversationListChanged({
213
+ body: { reason: "reordered", conversationIds: [] },
214
+ }),
215
+ ).toThrow();
216
+ expect(listPublishCalls).toEqual([]);
217
+ });
218
+
219
+ test("is reachable on the IPC surface under the shared method name", () => {
220
+ expect(
221
+ typeof CONVERSATION_SYNC_IPC_METHODS[
222
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD
223
+ ],
224
+ ).toBe("function");
225
+ });
226
+ });
@@ -29,13 +29,30 @@ import { getInflightFlushedContentSeq } from "../../daemon/inflight-turn-registr
29
29
  import { recordConversationPersistedSeq } from "../../persistence/conversation-crud.js";
30
30
  import { getCurrentSeq } from "../../runtime/assistant-stream-state.js";
31
31
  import type { RouteHandlerArgs } from "../../runtime/routes/types.js";
32
- import { publishConversationMessagesChanged } from "../../runtime/sync/resource-sync-events.js";
33
- import { NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD } from "../../runtime/sync/worker-daemon-notify.js";
32
+ import {
33
+ publishConversationListAndMetadataChanged,
34
+ publishConversationMessagesChanged,
35
+ } from "../../runtime/sync/resource-sync-events.js";
36
+ import {
37
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD,
38
+ NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD,
39
+ } from "../../runtime/sync/worker-daemon-notify.js";
34
40
 
35
41
  const NotifyConversationPersistedParamsSchema = z.object({
36
42
  conversationId: z.string().min(1),
37
43
  });
38
44
 
45
+ const NotifyConversationListChangedParamsSchema = z.object({
46
+ reason: z.enum([
47
+ "created",
48
+ "renamed",
49
+ "deleted",
50
+ "reordered",
51
+ "seen_changed",
52
+ ]),
53
+ conversationIds: z.array(z.string().min(1)).min(1),
54
+ });
55
+
39
56
  /**
40
57
  * Record the daemon-issued snapshot anchor for a worker-persisted turn and
41
58
  * republish its messages-changed invalidation to the daemon's subscribers.
@@ -61,6 +78,23 @@ export function handleNotifyConversationPersisted({
61
78
  return { ok: true };
62
79
  }
63
80
 
81
+ /**
82
+ * Republish a worker's conversation-list-and-metadata invalidation on the
83
+ * daemon's hub, where the SSE subscribers live.
84
+ *
85
+ * A worker turn that changes which rows belong in the list (clearing
86
+ * `archived_at` on a Done conversation it woke) has to reach connected
87
+ * sidebars, and a publish in the worker reaches none of them.
88
+ */
89
+ export function handleNotifyConversationListChanged({
90
+ body = {},
91
+ }: RouteHandlerArgs) {
92
+ const { reason, conversationIds } =
93
+ NotifyConversationListChangedParamsSchema.parse(body);
94
+ publishConversationListAndMetadataChanged(reason, conversationIds);
95
+ return { ok: true };
96
+ }
97
+
64
98
  /**
65
99
  * IPC-only conversation-sync methods, keyed by operationId. Registered directly
66
100
  * on the assistant IPC server (see `assistant-server.ts`).
@@ -70,4 +104,6 @@ export const CONVERSATION_SYNC_IPC_METHODS: Record<
70
104
  (args: RouteHandlerArgs) => unknown
71
105
  > = {
72
106
  [NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD]: handleNotifyConversationPersisted,
107
+ [NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD]:
108
+ handleNotifyConversationListChanged,
73
109
  };
@@ -238,6 +238,33 @@ function assistantDeltaTexts(frames: LiveVoiceServerFrame[]): string[] {
238
238
  }
239
239
 
240
240
  describe("LiveVoiceSession assistant turn", () => {
241
+ test.each([true, false])(
242
+ "passes current screen sharing state %p to the desktop voice bridge",
243
+ async (screenSharing) => {
244
+ const startVoiceTurn = mock(async (_options: VoiceTurnOptions) => ({
245
+ turnId: "bridge-turn-1",
246
+ abort: mock(),
247
+ }));
248
+ const { session, transcriber } = createSessionHarness({
249
+ startFrame: { ...START_FRAME, client: "macos" },
250
+ startVoiceTurn,
251
+ });
252
+ await session.start();
253
+ await session.handleClientFrame({
254
+ type: "update_config",
255
+ screenSharing: true,
256
+ });
257
+ await session.handleClientFrame({ type: "update_config", screenSharing });
258
+ transcriber.emit({ type: "final", text: "Show me the speed control" });
259
+ await session.handleClientFrame({ type: "ptt_release" });
260
+ expect(startVoiceTurn.mock.calls[0]?.[0]).toMatchObject({
261
+ macosDesktopSession: true,
262
+ screenSharing,
263
+ });
264
+ await session.close("client_end");
265
+ },
266
+ );
267
+
241
268
  test("runs final transcripts through the voice bridge and forwards ordered assistant events", async () => {
242
269
  const startVoiceTurn = mock(async (options: VoiceTurnOptions) => {
243
270
  options.callbacks?.assistant_text_delta?.({
@@ -217,7 +217,7 @@ describe("live-voice triage-and-escalate routing", () => {
217
217
 
218
218
  test("tricky turn: the escalate verdict hands off to a second quality leg", async () => {
219
219
  const { starter } = scriptedStartVoiceTurn({
220
- frontDoor: ["[1] ", "Let me think about that."],
220
+ frontDoor: ["[ESCALATE] ", "Let me think about that."],
221
221
  escalated: ["The detailed answer is 42."],
222
222
  });
223
223
  const { frames, session } = createHarness(starter);
@@ -493,6 +493,42 @@ describe("live-voice triage-and-escalate routing", () => {
493
493
  expect(spokenText(frames)).toContain("Give me a moment");
494
494
  });
495
495
 
496
+ test.each([
497
+ "I will highlight the Rotate control on your screen.",
498
+ "Let me highlight that control",
499
+ ])(
500
+ "a terminal verdict hands off without repeating speech: %s",
501
+ async (bridge) => {
502
+ const { starter } = scriptedStartVoiceTurn({
503
+ frontDoor: [bridge, " [", "ESCALATE", "]"],
504
+ escalated: ["The control is highlighted."],
505
+ });
506
+ const speech: string[] = [];
507
+ const { frames, session } = createHarness(starter, {
508
+ streamTtsAudio: async (options) => {
509
+ speech.push(options.text);
510
+ return {
511
+ provider: "fish-audio",
512
+ contentType: "audio/pcm",
513
+ sampleRate: 24_000,
514
+ chunks: 0,
515
+ bytes: 0,
516
+ };
517
+ },
518
+ });
519
+
520
+ await driveTurn(session);
521
+ await waitFor(() => frames.some((frame) => frame.type === "tts_done"));
522
+
523
+ expect(starter).toHaveBeenCalledTimes(2);
524
+ expect(starter.mock.calls[1]?.[0]?.routingLeg).toBe("escalated");
525
+ expect(starter.mock.calls[1]?.[0]?.spokenEscalationBridge).toBe(bridge);
526
+ expect(spokenText(frames)).toBe(`${bridge} The control is highlighted.`);
527
+ expect(speech).toEqual([bridge, "The control is highlighted."]);
528
+ await session.close("client_end");
529
+ },
530
+ );
531
+
496
532
  test("the escalated leg receives the front-door leg's actual spoken bridge", async () => {
497
533
  const { starter } = scriptedStartVoiceTurn({
498
534
  frontDoor: ["[1] Let me check your calendar.", " ignored tail"],
@@ -3702,12 +3702,13 @@ describe("LiveVoiceSession server VAD", () => {
3702
3702
  // thread instead of being dropped.
3703
3703
  await session.close("client_end");
3704
3704
  expect(injectMessageIntoParentMock).toHaveBeenCalledTimes(1);
3705
- const [conversationId, message] =
3705
+ const [conversationId, message, metadata] =
3706
3706
  injectMessageIntoParentMock.mock.calls[0] ?? [];
3707
3707
  expect(conversationId).toBe("conversation-123");
3708
3708
  expect(message).toContain("THE_RESULT");
3709
3709
  expect(message).toContain("[Background work finished]");
3710
3710
  expect(message).toContain("first question");
3711
+ expect(metadata).toEqual({ hidden: true, voiceContinuationResult: true });
3711
3712
  });
3712
3713
 
3713
3714
  test("closing during an active announcement delivers the result into the conversation", async () => {
@@ -3739,12 +3740,43 @@ describe("LiveVoiceSession server VAD", () => {
3739
3740
 
3740
3741
  await session.close("client_end");
3741
3742
  expect(injectMessageIntoParentMock).toHaveBeenCalledTimes(1);
3742
- const [conversationId, message] =
3743
+ const [conversationId, message, metadata] =
3743
3744
  injectMessageIntoParentMock.mock.calls[0] ?? [];
3744
3745
  expect(conversationId).toBe("conversation-123");
3745
3746
  expect(message).toContain("THE_RESULT");
3746
3747
  expect(message).toContain("[Background work finished]");
3747
3748
  expect(message).toContain("first question");
3749
+ expect(metadata).toEqual({ hidden: true, voiceContinuationResult: true });
3750
+ });
3751
+
3752
+ test("a continuation finishing after the room closes stays hidden in the conversation", async () => {
3753
+ injectMessageIntoParentMock.mockClear();
3754
+ const continuation = makeControlledContinuation();
3755
+ const { startVoiceTurn } = makeResurfaceTurnStarter();
3756
+ const { frames, session } = createHarness({
3757
+ finals: ["first question", ""],
3758
+ startVoiceTurn,
3759
+ streamTtsAudio: makeImmediateTts(),
3760
+ spawnBackgroundContinuation: continuation.spawnBackgroundContinuation,
3761
+ });
3762
+
3763
+ await session.start();
3764
+ await session.handleBinaryAudio(LOUD_CHUNK);
3765
+ await waitFor(() => frames.some((frame) => frame.type === "thinking"));
3766
+ await session.handleBinaryAudio(SUSTAINED_LOUD_CHUNK);
3767
+ await waitFor(
3768
+ () => continuation.spawnBackgroundContinuation.mock.calls.length === 1,
3769
+ );
3770
+ await session.close("client_end");
3771
+ expect(injectMessageIntoParentMock).not.toHaveBeenCalled();
3772
+
3773
+ continuation.finish("THE_RESULT");
3774
+ await waitFor(() => injectMessageIntoParentMock.mock.calls.length === 1);
3775
+ const [conversationId, message, metadata] =
3776
+ injectMessageIntoParentMock.mock.calls[0] ?? [];
3777
+ expect(conversationId).toBe("conversation-123");
3778
+ expect(message).toContain("THE_RESULT");
3779
+ expect(metadata).toEqual({ hidden: true, voiceContinuationResult: true });
3748
3780
  });
3749
3781
 
3750
3782
  test("a speculative user reply preserves the pending announcement", async () => {
@@ -77,6 +77,28 @@ describe("parseLiveVoiceClientTextFrame", () => {
77
77
  expect(result).toEqual({ ok: true, frame });
78
78
  });
79
79
 
80
+ test.each([true, false])(
81
+ "parses screen sharing state %p",
82
+ (screenSharing) => {
83
+ const frame = { type: "update_config", screenSharing } as const;
84
+ expect(parseLiveVoiceClientTextFrame(JSON.stringify(frame))).toEqual({
85
+ ok: true,
86
+ frame,
87
+ });
88
+ },
89
+ );
90
+
91
+ test("rejects malformed screen sharing state", () => {
92
+ expect(
93
+ parseLiveVoiceClientTextFrame(
94
+ JSON.stringify({
95
+ type: "update_config",
96
+ screenSharing: "true",
97
+ }),
98
+ ).ok,
99
+ ).toBe(false);
100
+ });
101
+
80
102
  test("parses an update_config frame with a single field, omitting the other", () => {
81
103
  const result = parseLiveVoiceClientTextFrame(
82
104
  JSON.stringify({ type: "update_config", silenceThresholdMs: 900 }),
@@ -17,7 +17,7 @@
17
17
  import {
18
18
  askTypesafeNoul,
19
19
  resolveTypesafeProvider,
20
- } from "../calls/typesafe-noul.js";
20
+ } from "../providers/jev/ask.js";
21
21
  import type { Provider } from "../providers/types.js";
22
22
 
23
23
  export const VOICE_CONTINUATION_JUDGE_CALL_SITE = "voiceContinuationJudge";
@@ -1217,6 +1217,7 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
1217
1217
  private releaseModeSessionResidency?: () => void;
1218
1218
  private cameraModeSessions?: CameraModeSessionProducer;
1219
1219
  private sightFrameSequence: Promise<void> = Promise.resolve();
1220
+ private screenSharing = false;
1220
1221
  /**
1221
1222
  * Mirrors phase changes to the iOS Live Activity through the platform, for
1222
1223
  * the case the client cannot cover: an app backgrounded long enough for iOS
@@ -2084,13 +2085,13 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
2084
2085
  }
2085
2086
 
2086
2087
  /**
2087
- * Apply a mid-session `update_config` frame: retune the live turn detector's
2088
- * pause ("pause before reply") and/or the barge-in guard ("interrupt
2089
- * sensitivity") without reconnecting. Each field is optional and independent;
2090
- * changes take effect from the next utterance. A no-op on manual (non-
2091
- * server_vad) sessions, which have no turn detector.
2088
+ * Apply screen-sharing state and turn-detection tuning independently.
2089
+ * Changes take effect from the next utterance.
2092
2090
  */
2093
2091
  private applyConfigUpdate(frame: LiveVoiceClientUpdateConfigFrame): void {
2092
+ if (frame.screenSharing !== undefined) {
2093
+ this.screenSharing = frame.screenSharing;
2094
+ }
2094
2095
  if (frame.silenceThresholdMs !== undefined) {
2095
2096
  this.turnDetector?.setSilenceThresholdMs(frame.silenceThresholdMs);
2096
2097
  this.silenceThresholdMs = frame.silenceThresholdMs;
@@ -3607,7 +3608,7 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
3607
3608
  const outcome: VoiceTaskOutcome = {
3608
3609
  taskId: `voice-continuation:${turn.turnId}`,
3609
3610
  message: buildContinuationResult(interruptedRequest, answer),
3610
- metadata: {},
3611
+ metadata: { hidden: true, voiceContinuationResult: true },
3611
3612
  source: "continuation",
3612
3613
  };
3613
3614
  accepted = this.receiveTaskOutcome(outcome);
@@ -6602,7 +6603,7 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
6602
6603
  userMessageInterface: "macos",
6603
6604
  assistantMessageInterface: "macos",
6604
6605
  ...(this.context.startFrame.client === "macos"
6605
- ? { macosDesktopSession: true }
6606
+ ? { macosDesktopSession: true, screenSharing: this.screenSharing }
6606
6607
  : {}),
6607
6608
  voiceTelemetry: {
6608
6609
  sessionId: this.context.sessionId,
@@ -6922,13 +6923,15 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
6922
6923
  ): void {
6923
6924
  const { spokenBridge, usesFallback, language } = bridge;
6924
6925
  if (!usesFallback) {
6925
- this.markFirstAssistantDelta(activeTurn.utterance, activeTurn.turnId);
6926
- this.markAssistantDelta(activeTurn);
6927
- void this.sendFrame(
6928
- { type: "assistant_text_delta", text: spokenBridge },
6929
- () => !activeTurn.abortController.signal.aborted && !this.isClosed,
6930
- );
6931
- this.bufferAssistantTextForTts(activeTurn.token, `${spokenBridge} `);
6926
+ if (!bridge.alreadyReleased) {
6927
+ this.markFirstAssistantDelta(activeTurn.utterance, activeTurn.turnId);
6928
+ this.markAssistantDelta(activeTurn);
6929
+ void this.sendFrame(
6930
+ { type: "assistant_text_delta", text: spokenBridge },
6931
+ () => !activeTurn.abortController.signal.aborted && !this.isClosed,
6932
+ );
6933
+ this.bufferAssistantTextForTts(activeTurn.token, `${spokenBridge} `);
6934
+ }
6932
6935
  // Force-flush now: on the TTS path an unpunctuated bridge would
6933
6936
  // otherwise sit buffered until a sentence boundary and leave the
6934
6937
  // caller in silence during the escalated model's call.
@@ -276,16 +276,16 @@ export interface LiveVoiceClientEndFrame {
276
276
  }
277
277
 
278
278
  /**
279
- * Mid-session tuning update: applies the same turn-detection knobs the start
280
- * frame carries to the *running* session, so the client can retune "pause
281
- * before reply" / "interrupt sensitivity" without reconnecting. Each field is
282
- * optional and independently applied; the same bounds as the start frame apply.
283
- * Only meaningful for `server_vad` sessions.
279
+ * Mid-session screen-sharing state and turn-detection tuning. Each field is
280
+ * optional and independently applied. Tuning uses the start frame's bounds
281
+ * and affects `server_vad` sessions.
284
282
  */
285
283
  export interface LiveVoiceClientUpdateConfigFrame {
286
284
  readonly type: "update_config";
287
285
  readonly silenceThresholdMs?: number;
288
286
  readonly bargeInMinSpeechMs?: number;
287
+ /** A shared desktop surface is available for annotation. */
288
+ readonly screenSharing?: boolean;
289
289
  }
290
290
 
291
291
  /**
@@ -1279,6 +1279,14 @@ function validateSightFrameTiming(
1279
1279
  function validateUpdateConfigFrame(
1280
1280
  value: Record<string, unknown>,
1281
1281
  ): LiveVoiceParseResult<LiveVoiceClientUpdateConfigFrame> {
1282
+ if ("screenSharing" in value && typeof value.screenSharing !== "boolean") {
1283
+ return protocolError(
1284
+ "invalid_field",
1285
+ "update_config field screenSharing must be a boolean",
1286
+ "screenSharing",
1287
+ "update_config",
1288
+ );
1289
+ }
1282
1290
  if (
1283
1291
  "silenceThresholdMs" in value &&
1284
1292
  !isIntInRange(
@@ -1315,6 +1323,9 @@ function validateUpdateConfigFrame(
1315
1323
  ok: true,
1316
1324
  frame: {
1317
1325
  type: "update_config",
1326
+ ...(typeof value.screenSharing === "boolean"
1327
+ ? { screenSharing: value.screenSharing }
1328
+ : {}),
1318
1329
  ...(typeof value.silenceThresholdMs === "number"
1319
1330
  ? { silenceThresholdMs: value.silenceThresholdMs }
1320
1331
  : {}),
@@ -33,6 +33,10 @@ export const GMAIL_API_BASE_URL =
33
33
  * requests Calendar-only). Resolving against Gmail read access turns a
34
34
  * downstream 403 into an actionable "reconnect Google and grant Gmail" error
35
35
  * at resolution time when the selected connection cannot read Gmail.
36
+ *
37
+ * Managed connections never carry this scope: Vellum's app grants Gmail as
38
+ * `https://mail.google.com/`, which `scopeDifference` in `oauth/scope-utils.ts`
39
+ * accepts as covering it.
36
40
  */
37
41
  export const GMAIL_REQUIRED_SCOPES = [
38
42
  "https://www.googleapis.com/auth/gmail.readonly",
@@ -13,7 +13,7 @@ Producer → NotificationSignal → Source-Active Gate → Candidate Generation
13
13
 
14
14
  ### 1. Signal
15
15
 
16
- A producer calls `emitNotificationSignal()` with a free-form event name, attention hints (urgency, requiresAction, deadlineAt), and a context payload. The signal is persisted as a `notification_events` row.
16
+ A producer calls `emitNotificationSignal()` with a free-form event name, attention hints (urgency, requiresAction, deadlineAt), and a context payload. The signal is persisted as a `notification_events` row. A `dedupeKey` the producer passes is claimed by that row on insert, with no time window: a later signal carrying a key an existing row holds gets no row of its own and returns `deduplicated: true` before anything below runs. See [Choosing `dedupeKey`](#choosing-dedupekey).
17
17
 
18
18
  Immediately after persistence, a **source-active pre-gate** runs (`checkSourceActiveSuppression`): when `visibleInSourceNow` is set, a hard signal-only invariant the decision engine cannot override, the signal is suppressed and short-circuits here, before candidate generation and the LLM decision. This keeps an always-suppressed signal (e.g. trusted-contact `verification_sent`) from spending an LLM inference whose result would be discarded. The `notification_events` row is still written for the audit trail.
19
19
 
@@ -65,7 +65,7 @@ Hard invariants that the LLM cannot override:
65
65
 
66
66
  - **Schema validity** -- fail-closed if the decision is malformed
67
67
  - **Channel availability** -- at least one selected channel must be connected
68
- - **Deduplication** -- same `dedupeKey` within the dedupe window (1 hour default) is suppressed
68
+ - **Deduplication** -- the decision's `dedupeKey` matches another event row younger than the dedupe window (1 hour default). This is the engine's own key; the producer's key was already checked at event insert in step 1, with no window.
69
69
  - **Rendered copy quality** -- fail-closed on empty copy or a fallback leak (body equal to the raw event name)
70
70
 
71
71
  Source-active suppression depends only on the signal, so it runs earlier — as the pre-decision gate in `emit-signal.ts` (see step 1), not as a pre-send check here.
@@ -470,7 +470,15 @@ Step 1 suppresses on this hint before anything else runs, and nothing downstream
470
470
  - **Opt in only when the notification duplicates something that conversation has already rendered, and only behind a flag that names your producer.** `resolveVisibleInSourceNow()` reads `activity-presence-suppression`, which gates the background-activity failure producer alone, so a new producer needs its own flag or an extension of that one before it calls the resolver. Otherwise the flag silently governs a producer its description does not cover. Having a conversation id in scope is not sufficient; the producer must know that _this_ arrival put the announced thing on screen there. `runtime/background-job-runner.ts` is the worked example: one catch block is reached from several directions, and it passes `presenceConversationId` only when the failure carries a `turnFailure`, the one arrival whose conversation is guaranteed to have emitted a `conversation_error` the user can read. A runner timeout leaves the turn still rendering as in progress and a bootstrap throw never reaches the agent loop, so both keep notifying.
471
471
  - **Pass a literal `false` for global and infra signals.** Heartbeat, credential health, webhook health, and worker liveness have no source surface to watch, so there is nothing to duplicate.
472
472
  - **Never opt in a `guardian.question` producer.** The card _is_ the prompt, so a `true` suppresses the question's only rendering and the tool hangs until the prompt timeout. `runtime/question-request-guardian-bridge.ts` carries the rationale at its hint block, and three regression pins hold the line: `runtime/__tests__/question-request-guardian-bridge.test.ts`, `__tests__/confirmation-request-guardian-bridge.test.ts`, and `__tests__/notification-guardian-path.test.ts`.
473
- - **A producer running inside the schedule worker cannot read presence at all.** `schedule/worker.ts` is a standalone OS process and the sole runner of schedule execution, while the resolver reads `assistantEventHub` through `isWebConversationFocused()` and that hub's SSE clients exist only in the assistant process. Every presence read from the worker resolves `false`, whatever the user is watching. The trap is in testing: a test that drives the producer and mocks presence in one process passes while the shipped worker suppresses nothing. Tracked as JARVIS-1711.
473
+ - **A producer running outside the main assistant process cannot read presence at all.** The schedule worker (`schedule/worker.ts`) and the memory jobs worker (`plugins/defaults/memory/worker.ts`) are standalone OS processes, while the resolver reads `assistantEventHub` through `isWebConversationFocused()` and that hub's SSE clients exist only in the assistant process. Every presence read from a worker resolves `false`, whatever the user is watching. The trap is in testing: a test that drives the producer and mocks presence in one process passes while the shipped worker suppresses nothing. Tracked as JARVIS-1711. The boundary runs the other way too: a hub publish from a worker is forwarded to the assistant process best-effort (`runtime/assistant-event-hub.ts`, logged rather than thrown on failure). A worker-side producer is therefore guaranteed its event row and nothing past it: the home-feed write is best-effort in every process (`writeHomeFeedItemForSignal` returns `null` for an ineligible signal, a missing summary, or a failed write, and `emit-signal.ts` only logs a rejection), and the live push to open clients depends on the forward as well.
474
+
475
+ ### Choosing `dedupeKey`
476
+
477
+ There are two keys and they do different jobs. Choose the producer's by what it names, not by how often it fires.
478
+
479
+ - **The producer's key is a permanent claim, not a rate limit.** `createEvent` refuses a second row for a key any row already holds (`events-store.ts`), however old that row is. Key on a durable identity (a job row, a request id) to attempt a thing at most once ever; key on that identity plus a time bucket to attempt it at most once per bucket. A key with no identity in it silences every later instance for the whole bucket, whether or not it was the same thing. At most once, not exactly once: the claim lands at insert, before the decision and dispatch, so a process that dies between the two leaves the key claimed with nothing announced, and the retry short-circuits `deduplicated: true` and reports success. A producer that must not lose an announcement across a mid-pipeline shutdown (routine during an app update) needs its own record of delivery, not the key.
480
+ - **A failed pipeline releases the claim; a retry re-emits.** When the pipeline fails after the row landed and no channel ran (`hasChannelSideEffect` is false), `emit-signal.ts` writes the key back to `null`, so the same producer can retry the same key. When any channel already ran, the claim stays: releasing it would double-send to those channels. This is what makes a crash retry idempotent against a double send for a producer keyed on a durable row id: `plugins/defaults/memory/skill-update-receipt-job.ts` keys on its job row, so a retry past the event row meets the claim, is reported `deduplicated: true, pipelineFailed: false`, and completes.
481
+ - **The decision's key is windowed.** The engine picks its own key per decision; step 4 checks it against event rows inside the 1-hour window and writes it onto the row only when the producer passed none. A producer never passes the engine's key and never appeals its verdict.
474
482
 
475
483
  ## Audit Trail
476
484