@vellumai/assistant 0.12.4 → 0.12.5-dev.202609251017.e467a6c

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 (281) hide show
  1. package/docs/architecture/memory.md +9 -1
  2. package/docs/architecture/scheduling.md +13 -5
  3. package/docs/desktop-browser-cli.md +3 -2
  4. package/docs/guardian-request-flow.md +1 -1
  5. package/node_modules/@vellumai/avatar-manifest/src/__tests__/notification-avatar.test.ts +48 -4
  6. package/node_modules/@vellumai/avatar-manifest/src/notification-avatar.ts +12 -8
  7. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
  8. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
  9. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
  10. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
  11. package/node_modules/@vellumai/gateway-client/src/outbound-contract.ts +2 -4
  12. package/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
  13. package/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
  14. package/openapi.yaml +152 -3
  15. package/package.json +1 -1
  16. package/src/__tests__/agent-loop.test.ts +76 -0
  17. package/src/__tests__/anthropic-error-formatting.test.ts +9 -0
  18. package/src/__tests__/background-shell-bash.test.ts +34 -0
  19. package/src/__tests__/background-shell-host-bash.test.ts +98 -1
  20. package/src/__tests__/background-tool-registry.test.ts +39 -0
  21. package/src/__tests__/channel-readiness-discord.test.ts +8 -0
  22. package/src/__tests__/channel-readiness-slack-remote.test.ts +8 -0
  23. package/src/__tests__/client-os-metadata-persistence.test.ts +4 -20
  24. package/src/__tests__/conversation-agent-loop.test.ts +529 -1
  25. package/src/__tests__/conversation-error.test.ts +18 -0
  26. package/src/__tests__/conversation-pairing.test.ts +69 -0
  27. package/src/__tests__/conversation-queue.test.ts +257 -4
  28. package/src/__tests__/conversation-runtime-assembly.test.ts +27 -0
  29. package/src/__tests__/emit-signal-routing-intent.test.ts +62 -0
  30. package/src/__tests__/evict-conversations-for-reload.test.ts +21 -0
  31. package/src/__tests__/gemini-provider.test.ts +9 -0
  32. package/src/__tests__/host-cu-proxy.test.ts +79 -0
  33. package/src/__tests__/host-cu-routes-targeted.test.ts +14 -5
  34. package/src/__tests__/introduction-card-resolver.test.ts +53 -8
  35. package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
  36. package/src/__tests__/non-member-access-request.test.ts +48 -0
  37. package/src/__tests__/notification-events-source-context-probe.test.ts +48 -1
  38. package/src/__tests__/notification-platform-adapter.test.ts +97 -0
  39. package/src/__tests__/notification-vellum-adapter.test.ts +103 -3
  40. package/src/__tests__/platform-callback-registration.test.ts +46 -1
  41. package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
  42. package/src/__tests__/scaffold-managed-skill-tool.test.ts +116 -66
  43. package/src/__tests__/scheduler-disk-pressure.test.ts +1 -0
  44. package/src/__tests__/scheduler-result-notification.test.ts +521 -7
  45. package/src/__tests__/scheduler-wake.test.ts +1 -0
  46. package/src/__tests__/skill-load-inline-command.test.ts +35 -0
  47. package/src/__tests__/subagent-cron-run-attribution.test.ts +41 -2
  48. package/src/__tests__/subagent-manager-notify.test.ts +48 -0
  49. package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +6 -6
  50. package/src/__tests__/usage-attribution.test.ts +31 -0
  51. package/src/__tests__/wake-schedule-escalation.test.ts +1 -0
  52. package/src/agent/loop.ts +23 -0
  53. package/src/api/ask-question-tool.ts +50 -0
  54. package/src/api/events/generation-handoff.ts +4 -0
  55. package/src/api/events/message-complete.ts +4 -0
  56. package/src/api/events/tool-result.ts +11 -0
  57. package/src/api/index.ts +11 -0
  58. package/src/api/requests/guardian-actions.test.ts +45 -0
  59. package/src/api/requests/guardian-actions.ts +20 -0
  60. package/src/api/responses/conversation-message.ts +4 -0
  61. package/src/api/responses/home.ts +27 -0
  62. package/src/approvals/guardian-decision-primitive.ts +6 -4
  63. package/src/approvals/guardian-request-resolvers.ts +35 -30
  64. package/src/avatar/notification-avatar.test.ts +42 -34
  65. package/src/avatar/notification-avatar.ts +1 -0
  66. package/src/calls/__tests__/call-controller.test.ts +18 -0
  67. package/src/calls/__tests__/voice-control-protocol.test.ts +6 -1
  68. package/src/calls/__tests__/voice-leg-coordinator.test.ts +70 -0
  69. package/src/calls/__tests__/voice-session-bridge.test.ts +116 -4
  70. package/src/calls/__tests__/voice-triage-escalate.test.ts +77 -11
  71. package/src/calls/call-controller.ts +3 -1
  72. package/src/calls/voice-control-protocol.ts +12 -4
  73. package/src/calls/voice-escalation-judge.ts +2 -2
  74. package/src/calls/voice-leg-coordinator.ts +23 -5
  75. package/src/calls/voice-screen-annotation.ts +44 -0
  76. package/src/calls/voice-session-bridge.ts +63 -20
  77. package/src/calls/voice-triage-escalate.ts +82 -27
  78. package/src/cli/commands/__tests__/conversations-clear.test.ts +156 -0
  79. package/src/cli/commands/conversations.help.ts +7 -2
  80. package/src/cli/commands/conversations.ts +36 -30
  81. package/src/cli/commands/oauth/index.help.ts +8 -2
  82. package/src/cli/commands/oauth/request.test.ts +32 -0
  83. package/src/cli/commands/platform/index.help.ts +2 -1
  84. package/src/cli/commands/platform/index.ts +8 -2
  85. package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +60 -0
  86. package/src/cli/lib/__tests__/plugin-catalog-platform.test.ts +66 -2
  87. package/src/cli/lib/bundled-marketplace.json +35 -0
  88. package/src/cli/lib/bundled-plugin-packages.json +21 -0
  89. package/src/cli/lib/plugin-catalog-cache.ts +17 -2
  90. package/src/cli/lib/plugin-catalog-platform.ts +48 -9
  91. package/src/config/__tests__/default-profile-catalog.test.ts +28 -0
  92. package/src/config/__tests__/platform-identity.test.ts +59 -0
  93. package/src/config/__tests__/profile-order.test.ts +19 -0
  94. package/src/config/__tests__/sync-gated-profiles.test.ts +71 -0
  95. package/src/config/bundled-skills/computer-use/SKILL.md +20 -0
  96. package/src/config/bundled-skills/computer-use/TOOLS.json +11 -11
  97. package/src/config/bundled-skills/screen-annotation/SKILL.md +41 -29
  98. package/src/config/bundled-skills/screen-annotation/TOOLS.json +5 -5
  99. package/src/config/call-site-defaults.ts +6 -0
  100. package/src/config/default-profile-catalog.ts +30 -1
  101. package/src/config/default-profile-names.ts +36 -2
  102. package/src/config/feature-flag-registry.json +9 -1
  103. package/src/config/platform-identity.ts +22 -5
  104. package/src/config/profile-order.ts +7 -1
  105. package/src/config/schemas/call-site-catalog.ts +7 -0
  106. package/src/config/schemas/llm.ts +21 -5
  107. package/src/config/sync-gated-profiles.ts +96 -44
  108. package/src/daemon/__tests__/abort-null-controller.test.ts +135 -1
  109. package/src/daemon/__tests__/auto-profile-router.test.ts +380 -0
  110. package/src/daemon/__tests__/turn-tail-assistant-reply-notify.test.ts +16 -0
  111. package/src/daemon/activity-trail.test.ts +206 -0
  112. package/src/daemon/activity-trail.ts +190 -0
  113. package/src/daemon/auto-profile-router.ts +431 -0
  114. package/src/daemon/computer-use-observation.test.ts +81 -0
  115. package/src/daemon/computer-use-observation.ts +23 -0
  116. package/src/daemon/conversation-agent-loop-handlers.ts +11 -0
  117. package/src/daemon/conversation-agent-loop.ts +157 -32
  118. package/src/daemon/conversation-error.ts +19 -0
  119. package/src/daemon/conversation-lifecycle.ts +70 -7
  120. package/src/daemon/conversation-media-retry.ts +1 -2
  121. package/src/daemon/conversation-messaging.ts +31 -2
  122. package/src/daemon/conversation-process.ts +107 -16
  123. package/src/daemon/conversation-queue-manager.ts +7 -0
  124. package/src/daemon/conversation-runtime-assembly.ts +1 -0
  125. package/src/daemon/conversation-turn-finalize.ts +14 -0
  126. package/src/daemon/conversation.ts +25 -6
  127. package/src/daemon/event-loop-watchdog.test.ts +201 -2
  128. package/src/daemon/event-loop-watchdog.ts +182 -6
  129. package/src/daemon/host-cu-proxy.ts +34 -3
  130. package/src/daemon/pkb-reminder-builder.test.ts +10 -3
  131. package/src/daemon/pkb-reminder-builder.ts +1 -1
  132. package/src/daemon/wake-conversation-ops.ts +4 -2
  133. package/src/desktop/desktop-computer-use.test.ts +14 -4
  134. package/src/home/feed-types.ts +2 -0
  135. package/src/inbound/platform-callback-registration.ts +19 -6
  136. package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +27 -0
  137. package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +83 -0
  138. package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +48 -1
  139. package/src/live-voice/__tests__/live-voice-vad.test.ts +34 -2
  140. package/src/live-voice/__tests__/protocol.test.ts +22 -0
  141. package/src/live-voice/continuation-judge.ts +1 -1
  142. package/src/live-voice/live-voice-session.ts +25 -19
  143. package/src/live-voice/protocol.ts +16 -5
  144. package/src/messaging/providers/discord/withdraw.ts +4 -5
  145. package/src/messaging/providers/gmail/client.ts +4 -0
  146. package/src/messaging/providers/slack/withdraw.ts +5 -5
  147. package/src/messaging/providers/telegram-bot/withdraw.ts +4 -5
  148. package/src/monitoring/__tests__/proc-fixtures.ts +28 -0
  149. package/src/monitoring/__tests__/proc-wait-state.test.ts +232 -0
  150. package/src/monitoring/__tests__/process-usage.test.ts +243 -0
  151. package/src/monitoring/proc-wait-state.ts +366 -0
  152. package/src/monitoring/process-memory.ts +4 -3
  153. package/src/monitoring/process-usage.ts +215 -0
  154. package/src/monitoring/resource-sample-types.ts +8 -0
  155. package/src/monitoring/resource-sampler.ts +17 -2
  156. package/src/monitoring/stall-capture.ts +12 -0
  157. package/src/notifications/README.md +88 -9
  158. package/src/notifications/__tests__/assistant-reply-producer.test.ts +390 -119
  159. package/src/notifications/__tests__/background-result-producer.test.ts +1272 -0
  160. package/src/notifications/__tests__/broadcaster.test.ts +292 -1
  161. package/src/notifications/__tests__/completion-policy.test.ts +243 -0
  162. package/src/notifications/__tests__/decision-engine.test.ts +51 -4
  163. package/src/notifications/__tests__/has-pending-background-work.test.ts +281 -0
  164. package/src/notifications/__tests__/home-feed-side-effect.test.ts +161 -3
  165. package/src/notifications/__tests__/resolve-visible-in-source.test.ts +110 -1
  166. package/src/notifications/__tests__/schedule-result-producer.test.ts +11 -4
  167. package/src/notifications/adapters/macos.ts +24 -12
  168. package/src/notifications/adapters/platform.ts +16 -5
  169. package/src/notifications/assistant-reply-producer.ts +96 -71
  170. package/src/notifications/background-result-producer.ts +369 -0
  171. package/src/notifications/broadcaster.ts +28 -8
  172. package/src/notifications/completion-policy.ts +115 -0
  173. package/src/notifications/completion-work.ts +46 -0
  174. package/src/notifications/conversation-pairing.ts +32 -13
  175. package/src/notifications/decision-engine.ts +18 -24
  176. package/src/notifications/emit-signal.ts +16 -1
  177. package/src/notifications/events-store.ts +4 -0
  178. package/src/notifications/has-pending-background-work.ts +91 -0
  179. package/src/notifications/home-feed-mirror.ts +44 -0
  180. package/src/notifications/home-feed-side-effect.ts +54 -28
  181. package/src/notifications/resolve-visible-in-source.ts +56 -2
  182. package/src/notifications/result-output.ts +154 -0
  183. package/src/notifications/schedule-result-producer.ts +6 -187
  184. package/src/notifications/types.ts +2 -0
  185. package/src/oauth/AGENTS.md +9 -1
  186. package/src/oauth/byo-connection.test.ts +28 -0
  187. package/src/persistence/__tests__/recent-conversation-messages.test.ts +41 -0
  188. package/src/persistence/conversation-crud.ts +26 -0
  189. package/src/persistence/conversation-types.ts +15 -37
  190. package/src/persistence/embeddings/__tests__/embedding-local-lifecycle.test.ts +85 -14
  191. package/src/persistence/jobs-store.ts +229 -0
  192. package/src/persistence/migrations/383-normalize-opencode-host-connections.ts +44 -0
  193. package/src/persistence/migrations/__tests__/383-normalize-opencode-host-connections.test.ts +102 -0
  194. package/src/persistence/steps.ts +12 -0
  195. package/src/platform/sync-avatar.test.ts +29 -0
  196. package/src/plugins/defaults/memory/AGENTS.md +5 -3
  197. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-boundary-guard.test.ts +45 -0
  198. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-job.test.ts +580 -0
  199. package/src/plugins/defaults/memory/__tests__/turn-retrieval.test.ts +21 -0
  200. package/src/plugins/defaults/memory/graph/tools.ts +9 -5
  201. package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +4 -0
  202. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +7 -3
  203. package/src/plugins/defaults/memory/job-handlers.ts +8 -2
  204. package/src/plugins/defaults/memory/skill-update-receipt-job.ts +334 -0
  205. package/src/plugins/defaults/memory/tools.test.ts +17 -0
  206. package/src/plugins/defaults/memory/turn-retrieval.ts +8 -0
  207. package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +24 -0
  208. package/src/plugins/defaults/memory/v3/injector.ts +4 -4
  209. package/src/plugins/types.ts +2 -0
  210. package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
  211. package/src/providers/anthropic/client.ts +4 -0
  212. package/src/providers/gemini/client.ts +7 -1
  213. package/src/providers/inference/auth.ts +25 -0
  214. package/src/providers/inference/profile-probe.ts +1 -0
  215. package/src/{calls/__tests__/typesafe-noul.test.ts → providers/jev/ask.test.ts} +4 -4
  216. package/src/{calls/typesafe-noul.ts → providers/jev/ask.ts} +67 -34
  217. package/src/providers/openai/__tests__/api-error-normalization.test.ts +12 -0
  218. package/src/providers/openai/api-error-normalization.ts +4 -0
  219. package/src/providers/retry.ts +2 -0
  220. package/src/providers/search-provider-catalog.ts +10 -0
  221. package/src/providers/types.ts +7 -0
  222. package/src/providers/usage-tracking.ts +5 -3
  223. package/src/runtime/__tests__/agent-wake.test.ts +308 -0
  224. package/src/runtime/access-request-helper.ts +16 -9
  225. package/src/runtime/agent-wake-queue.ts +52 -0
  226. package/src/runtime/agent-wake.ts +111 -18
  227. package/src/runtime/channel-approval-types.ts +6 -38
  228. package/src/runtime/channel-approvals.ts +4 -5
  229. package/src/runtime/http-server.ts +4 -1
  230. package/src/runtime/introduction-policy.test.ts +17 -1
  231. package/src/runtime/introduction-policy.ts +25 -7
  232. package/src/runtime/migrations/vbundle-builder.ts +9 -0
  233. package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +21 -1
  234. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +60 -0
  235. package/src/runtime/routes/__tests__/oauth-proxy-routes.test.ts +61 -3
  236. package/src/runtime/routes/auto-profile-routes.ts +83 -0
  237. package/src/runtime/routes/conversation-management-routes.ts +1 -3
  238. package/src/runtime/routes/conversation-routes.ts +9 -0
  239. package/src/runtime/routes/guardian-action-routes.ts +8 -23
  240. package/src/runtime/routes/host-cu-routes.ts +3 -1
  241. package/src/runtime/routes/index.ts +2 -0
  242. package/src/runtime/routes/inference-profiles-routes.ts +5 -2
  243. package/src/runtime/routes/inference-provider-connection-routes.ts +25 -8
  244. package/src/runtime/routes/migration-routes.ts +8 -2
  245. package/src/runtime/routes/oauth-proxy-passthrough.test.ts +32 -0
  246. package/src/runtime/routes/platform-routes.ts +6 -1
  247. package/src/runtime/routes/user-route-dispatcher.ts +1 -2
  248. package/src/runtime/web-presence.ts +3 -4
  249. package/src/schedule/schedule-store.ts +10 -0
  250. package/src/schedule/scheduler.ts +92 -24
  251. package/src/subagent/manager.ts +32 -12
  252. package/src/telegram/__tests__/webhook-health.test.ts +8 -0
  253. package/src/telemetry/telemetry-wire-source.json +1 -1
  254. package/src/telemetry/telemetry-wire.generated.ts +1 -0
  255. package/src/tools/background-tool-registry.ts +30 -3
  256. package/src/tools/browser/cdp-client/local-cdp-client.ts +1 -2
  257. package/src/tools/host-terminal/host-shell.ts +7 -0
  258. package/src/tools/network/__tests__/web-fetch-firecrawl.test.ts +28 -1
  259. package/src/tools/network/__tests__/web-fetch-metadata.test.ts +34 -0
  260. package/src/tools/network/__tests__/web-fetch-tinyfish.test.ts +35 -1
  261. package/src/tools/network/__tests__/web-search.test.ts +96 -0
  262. package/src/tools/network/web-fetch.ts +30 -9
  263. package/src/tools/network/web-search.ts +235 -4
  264. package/src/tools/skills/load.ts +13 -17
  265. package/src/tools/skills/scaffold-managed.ts +86 -71
  266. package/src/tools/terminal/shell-launch.test.ts +27 -1
  267. package/src/tools/terminal/shell.ts +4 -0
  268. package/src/tools/workspace-tools/loader.ts +1 -2
  269. package/src/usage/attribution.ts +18 -1
  270. package/src/util/abort-reasons.ts +2 -0
  271. package/src/util/errors.ts +1 -0
  272. package/src/util/oauth-request-body.test.ts +5 -1
  273. package/src/util/provider-error-patterns.ts +11 -0
  274. package/src/util/single-flight.test.ts +6 -0
  275. package/src/util/single-flight.ts +2 -0
  276. package/src/util/worker-pipe.test.ts +56 -10
  277. package/src/util/worker-pipe.ts +9 -4
  278. package/src/workspace/git-service.ts +6 -1
  279. package/src/workspace/migrations/158-repoint-opencode-host-provider-fragments.ts +163 -0
  280. package/src/workspace/migrations/__tests__/158-repoint-opencode-host-provider-fragments.test.ts +188 -0
  281. package/src/workspace/migrations/registry.ts +2 -0
@@ -53,8 +53,13 @@ import {
53
53
  getSectionTrail,
54
54
  type SectionTrailEntry,
55
55
  } from "../persistence/slow-sync-log.js";
56
+ import { watchdogTelemetryEventSchema } from "../telemetry/telemetry-wire.generated.js";
56
57
  import { recordWatchdogEvent } from "../telemetry/watchdog-events-store.js";
57
58
  import { getLogger } from "../util/logger.js";
59
+ import {
60
+ type DaemonActivityGroup,
61
+ getActivityOverlapping,
62
+ } from "./activity-trail.js";
58
63
 
59
64
  const log = getLogger("event-loop-watchdog");
60
65
 
@@ -85,6 +90,167 @@ const REPORT_COOLDOWN_MS = 30_000;
85
90
  */
86
91
  const STALL_CAPTURE_MATCH_GRACE_MS = 5_000;
87
92
 
93
+ /**
94
+ * Whether ingest accepts `detail`, judged by the generated wire contract so
95
+ * the byte measurement matches the server's exactly. The detail is checked
96
+ * as serialized (undefined keys dropped, as on the wire). The other event
97
+ * fields are fixed valid values; only issues on `detail` count.
98
+ */
99
+ export function detailFitsServerCap(detail: object): boolean {
100
+ const result = watchdogTelemetryEventSchema.safeParse({
101
+ type: "watchdog",
102
+ daemon_event_id: "size-check",
103
+ recorded_at: 0,
104
+ check_name: EVENT_LOOP_BLOCKED_CHECK_NAME,
105
+ detail: JSON.parse(JSON.stringify(detail)),
106
+ });
107
+ return (
108
+ result.success || !result.error.issues.some((i) => i.path[0] === "detail")
109
+ );
110
+ }
111
+
112
+ type BlockTelemetryDetail = {
113
+ threshold_ms: number;
114
+ tick_interval_ms: number;
115
+ /** Process uptime at report time; small values mean boot work. */
116
+ daemon_uptime_ms: number;
117
+ /** Work on this process that overlapped the block, grouped by label. */
118
+ activity: DaemonActivityGroup[];
119
+ section_trail: SectionTrailEntry[];
120
+ stall_capture: StallCapture | null;
121
+ /** Trim steps applied to fit the byte cap, in order. Absent when none. */
122
+ trimmed?: string[];
123
+ };
124
+
125
+ /**
126
+ * Ordered steps that shrink an oversize report, least diagnostic loss first.
127
+ * The activity groups, the busiest processes, the newest section-trail
128
+ * entries, and the capture's wait state are what attribute a block, so they
129
+ * go last.
130
+ */
131
+ const TRIM_STEPS: Array<{
132
+ name: string;
133
+ apply: (detail: BlockTelemetryDetail) => void;
134
+ }> = [
135
+ {
136
+ name: "section_trail_8",
137
+ apply: (d) => {
138
+ d.section_trail = d.section_trail.slice(0, 8);
139
+ },
140
+ },
141
+ {
142
+ name: "thread_groups",
143
+ apply: (d) => {
144
+ if (d.stall_capture?.waitState) {
145
+ d.stall_capture.waitState.threads = [];
146
+ }
147
+ },
148
+ },
149
+ {
150
+ name: "active_conversations",
151
+ apply: (d) => {
152
+ if (d.stall_capture) {
153
+ d.stall_capture.sample.activeConversations = null;
154
+ }
155
+ },
156
+ },
157
+ {
158
+ name: "memory_stat",
159
+ apply: (d) => {
160
+ if (d.stall_capture) {
161
+ d.stall_capture.sample.memoryStat = null;
162
+ }
163
+ },
164
+ },
165
+ {
166
+ name: "kernel_stack_512",
167
+ apply: (d) => {
168
+ if (d.stall_capture?.kernelStack) {
169
+ d.stall_capture.kernelStack = d.stall_capture.kernelStack.slice(0, 512);
170
+ }
171
+ },
172
+ },
173
+ {
174
+ name: "section_trail_3",
175
+ apply: (d) => {
176
+ d.section_trail = d.section_trail.slice(0, 3);
177
+ },
178
+ },
179
+ {
180
+ // Keeps the daemon, which the sampler always lists last, for comparison.
181
+ name: "processes_3",
182
+ apply: (d) => {
183
+ const processes = d.stall_capture?.sample.processes;
184
+ if (processes) {
185
+ const daemon = processes.find((p) => p.name === "daemon");
186
+ const kept = processes.slice(0, 3);
187
+ d.stall_capture!.sample.processes =
188
+ daemon && !kept.includes(daemon) ? [...kept, daemon] : kept;
189
+ }
190
+ },
191
+ },
192
+ {
193
+ name: "activity_4",
194
+ apply: (d) => {
195
+ d.activity = d.activity.slice(0, 4);
196
+ },
197
+ },
198
+ {
199
+ // Last resort so the report itself always lands: blockedMs and the
200
+ // longest activity groups survive.
201
+ name: "stall_capture",
202
+ apply: (d) => {
203
+ d.stall_capture = null;
204
+ d.section_trail = [];
205
+ },
206
+ },
207
+ ];
208
+
209
+ /**
210
+ * The telemetry `detail` for a block report. Conversation titles are dropped
211
+ * (the event is metadata only and titles can carry user content), then trim
212
+ * steps apply until the bag fits the server's byte cap. An oversize bag is
213
+ * rejected outright, losing the whole report. Pure so the budget
214
+ * logic is unit-testable.
215
+ */
216
+ export function buildBlockTelemetryDetail(input: {
217
+ thresholdMs: number;
218
+ daemonUptimeMs: number;
219
+ activity: DaemonActivityGroup[];
220
+ sectionTrail: SectionTrailEntry[];
221
+ stallCapture: StallCapture | null;
222
+ }): BlockTelemetryDetail {
223
+ // Deep copy: the trim steps mutate, and the caller's objects also feed the log.
224
+ const stallCapture: StallCapture | null = input.stallCapture
225
+ ? structuredClone(input.stallCapture)
226
+ : null;
227
+ if (stallCapture?.sample.activeConversations) {
228
+ stallCapture.sample.activeConversations =
229
+ stallCapture.sample.activeConversations.map((conversation) => ({
230
+ ...conversation,
231
+ title: null,
232
+ }));
233
+ }
234
+ const detail: BlockTelemetryDetail = {
235
+ threshold_ms: input.thresholdMs,
236
+ tick_interval_ms: TICK_INTERVAL_MS,
237
+ daemon_uptime_ms: input.daemonUptimeMs,
238
+ activity: [...input.activity],
239
+ section_trail: [...input.sectionTrail],
240
+ stall_capture: stallCapture,
241
+ };
242
+
243
+ for (const step of TRIM_STEPS) {
244
+ if (detailFitsServerCap(detail)) {
245
+ break;
246
+ }
247
+ step.apply(detail);
248
+ // Assigned before the next measurement so the marker counts too.
249
+ detail.trimmed = [...(detail.trimmed ?? []), step.name];
250
+ }
251
+ return detail;
252
+ }
253
+
88
254
  let tickTimer: ReturnType<typeof setInterval> | null = null;
89
255
  let lastTickAt = 0;
90
256
  let lastReportAt = Number.NEGATIVE_INFINITY;
@@ -124,6 +290,14 @@ async function reportBlock(
124
290
  } catch {
125
291
  // Diagnostics-only — never let it escape the timer callback.
126
292
  }
293
+ // Work that overlapped the block window. Read before the first await so
294
+ // work that starts after the loop frees up is not attributed to the block.
295
+ let activity: DaemonActivityGroup[] = [];
296
+ try {
297
+ activity = getActivityOverlapping(blockedMs + TICK_INTERVAL_MS);
298
+ } catch {
299
+ // Diagnostics-only; never let it escape the timer callback.
300
+ }
127
301
  // The resource monitor's mid-stall capture of this block, if it took one:
128
302
  // the monitor detects the stale heartbeat within its 250ms sampling cadence,
129
303
  // so a capture for a threshold-length block exists before this report fires.
@@ -142,6 +316,7 @@ async function reportBlock(
142
316
  blockedMs,
143
317
  thresholdMs,
144
318
  tickIntervalMs: TICK_INTERVAL_MS,
319
+ activity,
145
320
  sectionTrail,
146
321
  stallCapture,
147
322
  },
@@ -157,12 +332,13 @@ async function reportBlock(
157
332
  recordWatchdogEvent({
158
333
  checkName: EVENT_LOOP_BLOCKED_CHECK_NAME,
159
334
  value: blockedMs,
160
- detail: {
161
- threshold_ms: thresholdMs,
162
- tick_interval_ms: TICK_INTERVAL_MS,
163
- section_trail: sectionTrail,
164
- stall_capture: stallCapture,
165
- },
335
+ detail: buildBlockTelemetryDetail({
336
+ thresholdMs,
337
+ daemonUptimeMs: Math.round(process.uptime() * 1000),
338
+ activity,
339
+ sectionTrail,
340
+ stallCapture,
341
+ }),
166
342
  });
167
343
  } catch {
168
344
  // Never let a telemetry failure escape the timer callback.
@@ -28,6 +28,7 @@ import { POINT_AT_PROXY_TOOL } from "../tools/computer-use/skill-proxy-bridge.js
28
28
  import type { ToolExecutionResult } from "../tools/types.js";
29
29
  import { AssistantError, ErrorCode } from "../util/errors.js";
30
30
  import { getLogger } from "../util/logger.js";
31
+ import { prepareComputerUseObservation } from "./computer-use-observation.js";
31
32
  import { resolveHostCuTarget } from "./host-cu-target.js";
32
33
  import { bestEffortModeSessionTracking } from "./mode-session-tracking.js";
33
34
 
@@ -615,7 +616,7 @@ export class HostCuProxy {
615
616
  this.recordAction(toolName, input, reasoning);
616
617
  this._previousAXTree = undefined;
617
618
  this._consecutiveUnchangedSteps = 0;
618
- const observation = await execute();
619
+ const observation = await prepareComputerUseObservation(await execute());
619
620
  return this.formatObservation(observation, undefined, false, {
620
621
  toolName,
621
622
  input,
@@ -791,7 +792,7 @@ export class HostCuProxy {
791
792
  );
792
793
  }
793
794
 
794
- const screenshotMeta = this.formatScreenshotMetadata(obs);
795
+ const screenshotMeta = this.formatScreenshotMetadata(obs, action);
795
796
  if (screenshotMeta.length > 0) {
796
797
  parts.push("");
797
798
  parts.push(...screenshotMeta);
@@ -898,7 +899,10 @@ export class HostCuProxy {
898
899
  }
899
900
  }
900
901
 
901
- private formatScreenshotMetadata(obs: CuObservationResult): string[] {
902
+ private formatScreenshotMetadata(
903
+ obs: CuObservationResult,
904
+ action: ActionIdentity | undefined,
905
+ ): string[] {
902
906
  if (!obs.screenshot) {
903
907
  return [];
904
908
  }
@@ -914,6 +918,33 @@ export class HostCuProxy {
914
918
  `Screen metadata: ${obs.screenWidthPt}x${obs.screenHeightPt} pt`,
915
919
  );
916
920
  }
921
+ if (action && hasCaptureTarget(action.input)) {
922
+ lines.push(
923
+ "This screenshot is capture-relative. Full-screen dimensions do not map its pixels to action coordinates. Use accessibility element IDs, or request an unscoped desktop observation before using coordinates.",
924
+ );
925
+ } else if (
926
+ [
927
+ obs.screenshotWidthPx,
928
+ obs.screenshotHeightPx,
929
+ obs.screenWidthPt,
930
+ obs.screenHeightPt,
931
+ ].every(
932
+ (dimension) =>
933
+ typeof dimension === "number" &&
934
+ Number.isFinite(dimension) &&
935
+ dimension > 0,
936
+ )
937
+ ) {
938
+ const scaleX = obs.screenWidthPt! / obs.screenshotWidthPx!;
939
+ const scaleY = obs.screenHeightPt! / obs.screenshotHeightPx!;
940
+ lines.push(
941
+ `Action coordinates are screen points, not screenshot pixels. Convert this image's pixels: x = round(image_x * ${scaleX.toFixed(6)}), y = round(image_y * ${scaleY.toFixed(6)}). Prefer accessibility element IDs when available.`,
942
+ );
943
+ } else {
944
+ lines.push(
945
+ "Screenshot-to-screen coordinate mapping is unavailable. Use accessibility element IDs or obtain an observation with both screenshot and screen dimensions before using coordinates.",
946
+ );
947
+ }
917
948
  return lines;
918
949
  }
919
950
  }
@@ -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
  /**
@@ -219,7 +219,7 @@ export function broadcastWakeSurface(
219
219
  export async function persistWakeTailMessage(
220
220
  conversation: Conversation,
221
221
  message: Message,
222
- ): Promise<void> {
222
+ ): Promise<string> {
223
223
  const turnChannelCtx = conversation.getTurnChannelContext();
224
224
  const turnInterfaceCtx = conversation.getTurnInterfaceContext();
225
225
  const metadata: Record<string, unknown> = {
@@ -262,6 +262,7 @@ export async function persistWakeTailMessage(
262
262
  "wake persist: syncMessageToDisk failed (non-fatal)",
263
263
  );
264
264
  }
265
+ return persisted.id;
265
266
  }
266
267
 
267
268
  /**
@@ -296,7 +297,7 @@ export async function persistWakeTriggerMessage(
296
297
  source: string,
297
298
  clientless: boolean,
298
299
  completion?: CompletedBackgroundTool,
299
- ): Promise<void> {
300
+ ): Promise<string> {
300
301
  const backgroundEventInteractive =
301
302
  !clientless && !conversation.hasNoClient && !conversation.headlessLock;
302
303
  const turnChannelCtx = conversation.getTurnChannelContext();
@@ -348,6 +349,7 @@ export async function persistWakeTriggerMessage(
348
349
  "wake trigger persist: publishConversationMessagesChanged failed (non-fatal)",
349
350
  );
350
351
  }
352
+ return persisted.id;
351
353
  }
352
354
 
353
355
  /**
@@ -1,5 +1,7 @@
1
1
  import { describe, expect, mock, spyOn, test } from "bun:test";
2
2
 
3
+ import sharp from "sharp";
4
+
3
5
  import { run as click } from "../config/bundled-skills/computer-use/tools/computer-use-click.js";
4
6
  import * as configLoader from "../config/loader.js";
5
7
  import { HostCuProxy } from "../daemon/host-cu-proxy.js";
@@ -14,12 +16,20 @@ import {
14
16
  } from "./desktop-computer-use.js";
15
17
  import * as sessionManager from "./desktop-session-manager.js";
16
18
 
19
+ const SCREENSHOT = (
20
+ await sharp({
21
+ create: { width: 1440, height: 810, channels: 3, background: "white" },
22
+ })
23
+ .jpeg()
24
+ .toBuffer()
25
+ ).toString("base64");
26
+
17
27
  function driver(userGuidance?: string) {
18
28
  return {
19
29
  input: mock(async (_args: string[], _signal?: AbortSignal) => {}),
20
30
  capture: mock(async (_signal: AbortSignal) => ({
21
31
  userGuidance,
22
- screenshot: "anBlZw==",
32
+ screenshot: SCREENSHOT,
23
33
  screenshotWidthPx: 1440,
24
34
  screenshotHeightPx: 810,
25
35
  screenWidthPt: 1440,
@@ -52,7 +62,7 @@ describe("virtual desktop computer use", () => {
52
62
  signal(),
53
63
  backend,
54
64
  );
55
- expect(result.screenshot).toBe("anBlZw==");
65
+ expect(result.screenshot).toBe(SCREENSHOT);
56
66
  }
57
67
  expect(backend.input).not.toHaveBeenCalled();
58
68
  expect(backend.capture).toHaveBeenCalledTimes(2);
@@ -161,7 +171,7 @@ describe("virtual desktop computer use", () => {
161
171
  );
162
172
  expect(backend.input).toHaveBeenCalledTimes(1);
163
173
  expect(result.executionError).toBe("Input failed");
164
- expect(result.screenshot).toBe("anBlZw==");
174
+ expect(result.screenshot).toBe(SCREENSHOT);
165
175
  });
166
176
 
167
177
  test("done releases only its conversation without starting the desktop", async () => {
@@ -316,7 +326,7 @@ describe("virtual desktop computer use", () => {
316
326
  source: {
317
327
  type: "base64",
318
328
  media_type: "image/jpeg",
319
- data: "anBlZw==",
329
+ data: SCREENSHOT,
320
330
  },
321
331
  },
322
332
  ]);
@@ -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
@@ -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?.({
@@ -1771,6 +1771,89 @@ describe("LiveVoiceSession Flux end-of-turn during the STT dial", () => {
1771
1771
  await session.close("client_end");
1772
1772
  }, 10_000);
1773
1773
 
1774
+ test("rearms an empty fallback cycle while the previous reply is active", async () => {
1775
+ const abort = mock();
1776
+ const { frames, session, transcribers, turnCalls } = createHarness({
1777
+ fluxConfig: FLUX_ON,
1778
+ startVoiceTurn: async (turnOptions) => {
1779
+ turnOptions.callbacks?.assistant_text_delta?.(
1780
+ makeTextDelta("Working on the edit."),
1781
+ );
1782
+ return { turnId: "editing-turn", abort };
1783
+ },
1784
+ });
1785
+
1786
+ try {
1787
+ await session.start();
1788
+ await waitFor(() => transcribers.length === 1);
1789
+ const transcriber = transcribers[0]!;
1790
+ await session.handleBinaryAudio(LOUD_CHUNK);
1791
+ transcriber.startOfTurn(0);
1792
+ transcriber.endOfTurn("edit the clip", 0);
1793
+ await waitFor(() => turnCalls.length === 1);
1794
+
1795
+ const speechStarts = countFrames(frames, "speech_started");
1796
+ await session.handleBinaryAudio(SUSTAINED_LOUD_CHUNK);
1797
+ // No provider speech start or transcript arrives for this local onset.
1798
+ await waitFor(() => transcriber.stopped);
1799
+ await waitFor(
1800
+ () => transcribers.length >= 2,
1801
+ "An empty fallback cycle blocked the replacement stream behind the reply",
1802
+ );
1803
+ expect(countFrames(frames, "utterance_discarded")).toBe(1);
1804
+ expect(countFrames(frames, "speech_started")).toBe(speechStarts);
1805
+ expect(countFrames(frames, "turn_cancelled")).toBe(0);
1806
+ expect(abort).not.toHaveBeenCalled();
1807
+ expect(turnCalls).toHaveLength(1);
1808
+
1809
+ const replacement = transcribers.at(-1)!;
1810
+ await session.handleBinaryAudio(SUSTAINED_LOUD_CHUNK);
1811
+ expect(replacement.received.length).toBeGreaterThan(0);
1812
+ replacement.startOfTurn(0);
1813
+ await waitFor(() => countFrames(frames, "turn_cancelled") === 1);
1814
+ expect(countFrames(frames, "speech_started")).toBe(speechStarts + 1);
1815
+ expect(abort).toHaveBeenCalledTimes(1);
1816
+
1817
+ replacement.endOfTurn("stop editing", 0);
1818
+ await waitFor(() => turnCalls.length === 2);
1819
+ expect(turnCalls[1]?.content).toBe("stop editing");
1820
+ } finally {
1821
+ await session.close("client_end");
1822
+ }
1823
+ }, 10_000);
1824
+
1825
+ test("keeps a nonempty fallback transcript queued behind the previous reply", async () => {
1826
+ const abort = mock();
1827
+ const { frames, session, transcribers, turnCalls } = createHarness({
1828
+ fluxConfig: FLUX_ON,
1829
+ startVoiceTurn: async () => ({ turnId: "editing-turn", abort }),
1830
+ });
1831
+
1832
+ try {
1833
+ await session.start();
1834
+ await waitFor(() => transcribers.length === 1);
1835
+ const transcriber = transcribers[0]!;
1836
+ await session.handleBinaryAudio(LOUD_CHUNK);
1837
+ transcriber.startOfTurn(0);
1838
+ transcriber.endOfTurn("edit the clip", 0);
1839
+ await waitFor(() => turnCalls.length === 1);
1840
+
1841
+ transcriber.pendingFlushText = "show me the result";
1842
+ await session.handleBinaryAudio(SUSTAINED_LOUD_CHUNK);
1843
+ await waitFor(() => transcriber.stopped);
1844
+ await flushAsyncCallbacks();
1845
+ expect(turnCalls).toHaveLength(1);
1846
+ expect(countFrames(frames, "utterance_discarded")).toBe(0);
1847
+ expect(abort).not.toHaveBeenCalled();
1848
+
1849
+ turnCalls[0]?.callbacks?.message_complete?.(makeMessageComplete());
1850
+ await waitFor(() => turnCalls.length === 2);
1851
+ expect(turnCalls[1]?.content).toBe("show me the result");
1852
+ } finally {
1853
+ await session.close("client_end");
1854
+ }
1855
+ }, 10_000);
1856
+
1774
1857
  test("routes a closing stream's flush into the turn it released", async () => {
1775
1858
  const { session, transcribers, turnCalls } = createHarness({
1776
1859
  fluxConfig: FLUX_ON,