@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
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * - `[0]` ({@link HOLD_VERDICT_TOKEN}, unified front-door only): the
8
8
  * caller is mid-thought — the leg is discarded and listening continues.
9
- * - `[1]` ({@link ESCALATE_VERDICT_TOKEN}) followed by ONE short natural
10
- * holding phrase: the turn is too tricky — the phrase is spoken (capped
9
+ * - `[ESCALATE]` ({@link ESCALATE_VERDICT_TOKEN}) followed by ONE short natural
10
+ * holding phrase: the turn is too tricky. The phrase is spoken (capped
11
11
  * at a single sentence) while the turn re-runs on the conversation's
12
12
  * own profile, the model the caller's typed turns already run on.
13
13
  * Because the holding phrase is spoken, the caller never hears the
@@ -20,6 +20,9 @@
20
20
  * the escalation hand-off: the bridge is capped session-side instead of
21
21
  * trusting the model to stop. Every infra failure fails open to a normal
22
22
  * committed answer turn.
23
+ * A standalone terminal `[ESCALATE]` is recovered at normal completion without
24
+ * delaying answer streaming or repeating the already released speech.
25
+ * The numeric `[1]` verdict is accepted only at the start of a reply.
23
26
  *
24
27
  * This module owns the routing policy in one place: the profile key, the
25
28
  * leg-specific prompt rules, the leading-token classifier, and the bridge
@@ -32,13 +35,21 @@ import {
32
35
  localizedOrDefault,
33
36
  } from "../util/language-subtag.js";
34
37
  import {
38
+ createControlMarkerHoldback,
35
39
  ESCALATE_VERDICT_TOKEN,
40
+ ESCALATE_VERDICT_TOKENS,
36
41
  HOLD_VERDICT_TOKEN,
42
+ SCREEN_ACTION_VERDICT_TOKEN,
37
43
  stripInternalSpeechMarkers,
38
44
  } from "./voice-control-protocol.js";
39
45
 
40
46
  export { ESCALATE_VERDICT_TOKEN, HOLD_VERDICT_TOKEN };
41
47
 
48
+ export function leadingEscalationToken(text: string): string | undefined {
49
+ const leading = text.trimStart();
50
+ return ESCALATE_VERDICT_TOKENS.find((token) => leading.startsWith(token));
51
+ }
52
+
42
53
  // The fast model fronting every turn is pinned by the `voiceFrontDoor` call
43
54
  // site (see config/call-site-defaults.ts) — no per-turn profile override.
44
55
  // The escalated leg is pinned by the bridge to the conversation's own
@@ -156,7 +167,7 @@ export const BRIDGE_SENTENCE_END_REGEX = new RegExp(
156
167
  );
157
168
 
158
169
  /**
159
- * Normalize a raw post-`[1]` stream into the bridge that is actually
170
+ * Normalize the post-verdict stream into the bridge that is actually
160
171
  * spoken: internal markers stripped, cut just after the first sentence
161
172
  * terminator, hard-capped at {@link MAX_ESCALATION_BRIDGE_CHARS}, trimmed.
162
173
  * The session speaks exactly this, the persisted front-door row keeps
@@ -174,7 +185,7 @@ export function capEscalationBridge(rawBridge: string): string {
174
185
  }
175
186
 
176
187
  /**
177
- * Whether enough of the post-`[1]` stream has arrived to finalize the
188
+ * Whether enough of the post-verdict stream has arrived to finalize the
178
189
  * bridge and hand off: a sentence terminator landed, or the hard cap is
179
190
  * reached. Until then the session keeps buffering (the bridge is spoken in
180
191
  * one piece at hand-off, so what is spoken is exactly the capped bridge).
@@ -188,24 +199,21 @@ export function isEscalationBridgeComplete(rawBridge: string): boolean {
188
199
  }
189
200
 
190
201
  /**
191
- * The spoken bridge of a front-door leg's FULL raw output: empty unless the
192
- * output leads with {@link ESCALATE_VERDICT_TOKEN} (a stray token later in
193
- * an answer is not an escalation under the verdict-first protocol), else
194
- * the capped bridge that followed the token. Used by transcript hygiene to
195
- * reconstruct what the caller heard from a persisted row, by running the
196
- * same verdict machine the live stream ran through.
202
+ * The spoken bridge of a front-door leg's full raw output: the capped
203
+ * phrase following a leading verdict, or the already released speech
204
+ * before a terminal verdict. Other output has no bridge. Transcript hygiene
205
+ * replays the same verdict machine to reconstruct what the caller heard.
197
206
  */
198
207
  export function spokenBridgeText(frontDoorText: string): string {
199
208
  const machine = createFrontDoorVerdictMachine(false);
200
209
  const step = machine.push(frontDoorText);
201
- if (step.kind !== "escalate") {
202
- return "";
203
- }
204
- if (step.bridge !== null) {
210
+ if (step.kind === "escalate" && step.bridge !== null) {
205
211
  return step.bridge;
206
212
  }
207
213
  const finished = machine.finish();
208
- return finished.kind === "bridge" ? finished.bridge : "";
214
+ return finished.kind === "bridge" || finished.kind === "terminal-escalate"
215
+ ? finished.bridge
216
+ : "";
209
217
  }
210
218
 
211
219
  /**
@@ -221,7 +229,8 @@ export function needsFallbackBridge(frontDoorText: string): boolean {
221
229
  /**
222
230
  * Classification of a front-door leg's accumulated leading output (already
223
231
  * `trimStart()`ed). `pending` means the stream could still become a verdict
224
- * token — keep buffering; everything else is final for the leg.
232
+ * token: keep buffering. Other results select the leg's streaming path;
233
+ * a terminal escalation verdict is checked separately at completion.
225
234
  */
226
235
  export type FrontDoorLeadingVerdict =
227
236
  | "pending"
@@ -250,12 +259,12 @@ export function classifyFrontDoorLeading(
250
259
  if (holdEnabled && leading.startsWith(HOLD_VERDICT_TOKEN)) {
251
260
  return "hold";
252
261
  }
253
- if (leading.startsWith(ESCALATE_VERDICT_TOKEN)) {
262
+ if (leadingEscalationToken(leading) !== undefined) {
254
263
  return "escalate";
255
264
  }
256
265
  const candidates = holdEnabled
257
- ? [HOLD_VERDICT_TOKEN, ESCALATE_VERDICT_TOKEN]
258
- : [ESCALATE_VERDICT_TOKEN];
266
+ ? [HOLD_VERDICT_TOKEN, ...ESCALATE_VERDICT_TOKENS]
267
+ : ESCALATE_VERDICT_TOKENS;
259
268
  if (candidates.some((token) => token.startsWith(leading))) {
260
269
  return "pending";
261
270
  }
@@ -287,6 +296,8 @@ export type FrontDoorStep =
287
296
  | { readonly kind: "bridging" }
288
297
  /** The capped bridge is complete: hand off to the escalated leg. */
289
298
  | { readonly kind: "bridge"; readonly bridge: string }
299
+ /** A terminal verdict hands off using the answer text already released. */
300
+ | { readonly kind: "terminal-escalate"; readonly bridge: string }
290
301
  /** The leg already held, handed off, or finished; nothing more happens. */
291
302
  | { readonly kind: "done" };
292
303
 
@@ -299,12 +310,15 @@ export type FrontDoorStep =
299
310
  *
300
311
  * `push` feeds one delta and reports what it decided. `finish` is called
301
312
  * when the leg completes normally: a bridge that stopped short of a
302
- * sentence terminator hands off with what arrived. A leg that is cancelled
303
- * instead never calls `finish`.
313
+ * sentence terminator hands off with what arrived. A standalone terminal
314
+ * escalation token also hands off, using the already released answer as
315
+ * its bridge. A cancelled leg never calls `finish`.
304
316
  */
305
317
  export interface FrontDoorVerdictMachine {
306
318
  push(deltaText: string): FrontDoorStep;
307
319
  finish(): FrontDoorStep;
320
+ /** The model classified this hand-off as a screen action using current context. */
321
+ readonly screenAction: boolean;
308
322
  }
309
323
 
310
324
  const PENDING_STEP: FrontDoorStep = { kind: "pending" };
@@ -330,6 +344,7 @@ export function createFrontDoorVerdictMachine(
330
344
  let stage: "deciding" | "answer" | "bridging" | "done" = "deciding";
331
345
  let bridgeRaw = "";
332
346
  let releasedChars = 0;
347
+ let screenAction = false;
333
348
 
334
349
  const completeBridge = (): Extract<FrontDoorStep, { kind: "bridge" }> => {
335
350
  stage = "done";
@@ -337,6 +352,9 @@ export function createFrontDoorVerdictMachine(
337
352
  };
338
353
 
339
354
  return {
355
+ get screenAction() {
356
+ return screenAction;
357
+ },
340
358
  push(deltaText: string): FrontDoorStep {
341
359
  raw += deltaText;
342
360
  if (stage === "done") {
@@ -359,7 +377,9 @@ export function createFrontDoorVerdictMachine(
359
377
  }
360
378
  if (verdict === "escalate") {
361
379
  stage = "bridging";
362
- bridgeRaw = raw.trimStart().slice(ESCALATE_VERDICT_TOKEN.length);
380
+ const token = leadingEscalationToken(raw)!;
381
+ screenAction = token === SCREEN_ACTION_VERDICT_TOKEN;
382
+ bridgeRaw = raw.trimStart().slice(token.length);
363
383
  return {
364
384
  kind: "escalate",
365
385
  bridge: isEscalationBridgeComplete(bridgeRaw)
@@ -379,6 +399,24 @@ export function createFrontDoorVerdictMachine(
379
399
  if (stage === "bridging") {
380
400
  return completeBridge();
381
401
  }
402
+ if (stage === "answer") {
403
+ stage = "done";
404
+ const text = raw.trimEnd();
405
+ const terminalToken = [
406
+ ESCALATE_VERDICT_TOKEN,
407
+ SCREEN_ACTION_VERDICT_TOKEN,
408
+ ].find((token) => text.endsWith(token));
409
+ const beforeToken = terminalToken
410
+ ? text.slice(0, -terminalToken.length)
411
+ : "";
412
+ if (terminalToken && /\s$/.test(beforeToken)) {
413
+ screenAction = terminalToken === SCREEN_ACTION_VERDICT_TOKEN;
414
+ return {
415
+ kind: "terminal-escalate",
416
+ bridge: stripInternalSpeechMarkers(beforeToken).trim(),
417
+ };
418
+ }
419
+ }
382
420
  stage = "done";
383
421
  return DONE_STEP;
384
422
  },
@@ -419,14 +457,25 @@ export interface FrontDoorStreamGate {
419
457
  * `usesFallbackBridge` in `live-voice-session.ts`) and deletes the row
420
458
  * rather than persisting a phrase the model never really produced, so
421
459
  * there is no displayed text for the gate to agree with.
422
- * - `answer`: the leg's output IS the reply, so every delta passes through,
423
- * including the leading text held back while the verdict was pending.
460
+ * - `answer`: speech streams immediately, with control markers held back
461
+ * and stripped using the same filter as the audio drivers.
424
462
  */
425
463
  export function createFrontDoorStreamGate(
426
464
  holdEnabled: boolean,
427
465
  ): FrontDoorStreamGate {
428
466
  const machine = createFrontDoorVerdictMachine(holdEnabled);
429
467
  let answering = false;
468
+ let rawSpeech = "";
469
+ let releasedSpeech = "";
470
+ const flushSpeech = createControlMarkerHoldback((text) => {
471
+ releasedSpeech += text;
472
+ });
473
+ const filterSpeech = (text: string, force = false): string => {
474
+ rawSpeech += text;
475
+ releasedSpeech = "";
476
+ flushSpeech(rawSpeech, { force });
477
+ return releasedSpeech;
478
+ };
430
479
  const releasable = (bridge: string): string =>
431
480
  bridge.length < MIN_SPOKEN_BRIDGE_CHARS ? "" : bridge;
432
481
  const release = (step: FrontDoorStep): string => {
@@ -443,8 +492,8 @@ export function createFrontDoorStreamGate(
443
492
  }
444
493
  };
445
494
  return {
446
- push: (deltaText) => release(machine.push(deltaText)),
447
- finish: () => release(machine.finish()),
495
+ push: (deltaText) => filterSpeech(release(machine.push(deltaText))),
496
+ finish: () => filterSpeech(release(machine.finish()), true),
448
497
  get answering() {
449
498
  return answering;
450
499
  },
@@ -494,6 +543,7 @@ export function frontDoorCapabilityDigest(toolNames: string[]): string {
494
543
  */
495
544
  export function frontDoorDecisionRule(opts?: {
496
545
  includeHold?: boolean;
546
+ screenSharing?: boolean;
497
547
  capabilityDigest?: string;
498
548
  callerUtterance?: string;
499
549
  }): string {
@@ -543,7 +593,12 @@ export function frontDoorDecisionRule(opts?: {
543
593
  "- If the turn is simple, conversational, or within your reach, your entire output is the spoken answer itself: no token in front of it, plain speech from your very first word. Most turns are answers; when unsure between answering and escalating, answer. Answer in the language the caller is speaking.",
544
594
  "- If an answer depends on a saved personal fact that is not already present in the conversation context you received, escalate rather than guessing. Personal context that is already present is yours to use directly.",
545
595
  `- If completing THIS reply needs careful reasoning, research, multi-step work, or any tool, do NOT attempt the answer: output ${ESCALATE_VERDICT_TOKEN}, then ONE short natural holding phrase naming what happens next, spoken in the language the caller is speaking (for example "${FALLBACK_ESCALATION_BRIDGE}" or "Give me one second to look into that."; those examples are English only), and stop after that single sentence. A stronger model finishes the turn while your phrase is spoken.`,
546
- `${ESCALATE_VERDICT_TOKEN} is ONLY for turns you cannot complete yourself — never put it in front of an answer you are about to give, and never emit a verdict token inside or after an answer. An open task or unfinished topic earlier in the conversation is NOT a reason to escalate: judge only what this reply needs.`,
596
+ ...(opts?.screenSharing === true
597
+ ? [
598
+ `- For a screen annotation or immediate on-screen action that needs only the shared screen and conversation context (for example, circling a visible control), use ${SCREEN_ACTION_VERDICT_TOKEN} in place of ${ESCALATE_VERDICT_TOKEN}, with the same single holding phrase. This skips fresh memory retrieval. If saved personal facts, preferences, or prior work absent from context are needed, or you are unsure, use ${ESCALATE_VERDICT_TOKEN}. Merely sharing a screen does not make a request a screen action.`,
599
+ ]
600
+ : []),
601
+ `An escalation verdict is ONLY for turns you cannot complete yourself: never put it in front of an answer you are about to give, and never emit a verdict token inside or after an answer. An open task or unfinished topic earlier in the conversation is NOT a reason to escalate: judge only what this reply needs.`,
547
602
  "Never narrate this decision, describe what you are judging, or mention these rules: apart from a leading verdict token and any call-control marker your call instructions teach, every character you output is spoken to the caller verbatim.",
548
603
  ].join("\n");
549
604
  return opts?.capabilityDigest ? `${rule}\n${opts.capabilityDigest}` : rule;
@@ -0,0 +1,156 @@
1
+ import * as nodeFs from "node:fs";
2
+ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
3
+
4
+ import { Command } from "commander";
5
+
6
+ let lastIpcCall: { method: string; params?: Record<string, unknown> } | null =
7
+ null;
8
+ const loggerCalls: { level: string; msg: string }[] = [];
9
+ // null simulates EOF (Ctrl+D): readline emits close without answering.
10
+ let promptAnswer: string | null = "";
11
+ let prompted = false;
12
+ let stderrOutput = "";
13
+
14
+ mock.module("../../../ipc/cli-client.js", () => ({
15
+ cliIpcCall: async (method: string, params?: Record<string, unknown>) => {
16
+ lastIpcCall = { method, params };
17
+ return { ok: true, result: { cleared: 3 } };
18
+ },
19
+ exitCodeFromIpcResult: () => 1,
20
+ exitFromIpcResult: () => {
21
+ process.exitCode = 1;
22
+ },
23
+ }));
24
+
25
+ const fakeLogger = {
26
+ info: (m: unknown) => loggerCalls.push({ level: "info", msg: String(m) }),
27
+ warn: () => {},
28
+ error: (m: unknown) => loggerCalls.push({ level: "error", msg: String(m) }),
29
+ debug: () => {},
30
+ };
31
+
32
+ mock.module("../../../util/logger.js", () => ({
33
+ getLogger: () => fakeLogger,
34
+ getCliLogger: () => fakeLogger,
35
+ initLogger: () => {},
36
+ truncateForLog: (v: string) => v,
37
+ pruneOldLogFiles: () => 0,
38
+ LOG_FILE_PATTERN: /^assistant-(\d{4}-\d{2}-\d{2})\.log$/,
39
+ getCurrentLogFilePath: () => "/tmp/test-assistant.log",
40
+ }));
41
+
42
+ function fakeInterface() {
43
+ let onClose = () => {};
44
+ return {
45
+ question: (_q: string, cb: (a: string) => void) => {
46
+ prompted = true;
47
+ if (promptAnswer === null) {
48
+ queueMicrotask(() => onClose());
49
+ } else {
50
+ cb(promptAnswer);
51
+ }
52
+ },
53
+ on: (event: string, cb: () => void) => {
54
+ if (event === "close") {
55
+ onClose = cb;
56
+ }
57
+ },
58
+ close: () => {},
59
+ };
60
+ }
61
+ mock.module("node:readline", () => ({
62
+ default: { createInterface: fakeInterface },
63
+ createInterface: fakeInterface,
64
+ }));
65
+
66
+ // node:fs must stay fully functional for conversations.js's heavy import graph.
67
+ const realFs = { ...nodeFs };
68
+ mock.module("node:fs", () => ({ ...realFs }));
69
+
70
+ const { registerConversationsCommand } = await import("../conversations.js");
71
+
72
+ async function runClear(args: string[]): Promise<number> {
73
+ const program = new Command();
74
+ program.exitOverride();
75
+ program.configureOutput({ writeErr: () => {}, writeOut: () => {} });
76
+ registerConversationsCommand(program);
77
+ await program.parseAsync([
78
+ "node",
79
+ "assistant",
80
+ "conversations",
81
+ "clear",
82
+ ...args,
83
+ ]);
84
+ const code = Number(process.exitCode ?? 0);
85
+ process.exitCode = 0;
86
+ return code;
87
+ }
88
+
89
+ const savedIsTTY = process.stdin.isTTY;
90
+ const realStderrWrite = process.stderr.write.bind(process.stderr);
91
+
92
+ beforeEach(() => {
93
+ lastIpcCall = null;
94
+ loggerCalls.length = 0;
95
+ prompted = false;
96
+ stderrOutput = "";
97
+ process.exitCode = 0;
98
+ process.stderr.write = ((chunk: string) => {
99
+ stderrOutput += chunk;
100
+ return true;
101
+ }) as typeof process.stderr.write;
102
+ });
103
+
104
+ afterEach(() => {
105
+ process.stdin.isTTY = savedIsTTY;
106
+ process.stderr.write = realStderrWrite;
107
+ });
108
+
109
+ describe("conversations clear", () => {
110
+ test("interactive: Enter cancels without clearing", async () => {
111
+ process.stdin.isTTY = true;
112
+ promptAnswer = "";
113
+ expect(await runClear([])).toBe(0);
114
+ expect(prompted).toBe(true);
115
+ expect(lastIpcCall).toBeNull();
116
+ expect(loggerCalls.some((c) => c.msg === "Cancelled")).toBe(true);
117
+ });
118
+
119
+ test("interactive: y clears with the destructive-confirmation header", async () => {
120
+ process.stdin.isTTY = true;
121
+ promptAnswer = "y";
122
+ expect(await runClear([])).toBe(0);
123
+ expect(lastIpcCall).toEqual({
124
+ method: "conversations_clear_cli",
125
+ params: {
126
+ headers: { "x-confirm-destructive": "clear-all-conversations" },
127
+ },
128
+ });
129
+ });
130
+
131
+ test("non-TTY without --force fails fast naming the flag", async () => {
132
+ process.stdin.isTTY = false;
133
+ expect(await runClear([])).toBe(1);
134
+ expect(prompted).toBe(false);
135
+ expect(lastIpcCall).toBeNull();
136
+ expect(stderrOutput).toContain("--force");
137
+ });
138
+
139
+ test("interactive: EOF cancels instead of hanging", async () => {
140
+ process.stdin.isTTY = true;
141
+ promptAnswer = null;
142
+ expect(await runClear([])).toBe(0);
143
+ expect(lastIpcCall).toBeNull();
144
+ expect(loggerCalls.some((c) => c.msg === "Cancelled")).toBe(true);
145
+ });
146
+
147
+ test("non-TTY with --force clears without prompting", async () => {
148
+ process.stdin.isTTY = false;
149
+ expect(await runClear(["--force"])).toBe(0);
150
+ expect(prompted).toBe(false);
151
+ expect(lastIpcCall?.params).toEqual({
152
+ headers: { "x-confirm-destructive": "clear-all-conversations" },
153
+ });
154
+ expect(loggerCalls.some((c) => c.msg.includes("Cleared 3"))).toBe(true);
155
+ });
156
+ });
@@ -326,16 +326,21 @@ Examples:
326
326
  name: "clear",
327
327
  description:
328
328
  "Clear all conversations, messages, and vector data (dev only)",
329
+ options: [
330
+ { flags: "--force", description: "Skip the confirmation prompt" },
331
+ ],
329
332
  helpText: `
330
333
  Permanently deletes ALL conversations, messages, and associated data.
331
- Prompts for confirmation (y/N) before proceeding.
334
+ Prompts for confirmation (y/N) before proceeding unless --force is passed.
335
+ Without a terminal (e.g. run from a tool or script), --force is required.
332
336
 
333
337
  Requires the assistant to be running. Communicates via IPC socket.
334
338
 
335
339
  Intended for development use. This action cannot be undone.
336
340
 
337
341
  Examples:
338
- $ assistant conversations clear`,
342
+ $ assistant conversations clear
343
+ $ assistant conversations clear --force`,
339
344
  },
340
345
  {
341
346
  name: "wake",
@@ -8,6 +8,7 @@ import {
8
8
  exitFromIpcResult,
9
9
  } from "../../ipc/cli-client.js";
10
10
  import { applyCommandHelp, subcommand } from "../lib/cli-command-help.js";
11
+ import { confirmPrompt } from "../lib/confirm-prompt.js";
11
12
  import { registerCommand } from "../lib/register-command.js";
12
13
  import { timeAgo } from "../lib/time-ago.js";
13
14
  import { log } from "../logger.js";
@@ -497,40 +498,45 @@ export function registerConversationsCommand(program: Command): void {
497
498
  // clear
498
499
  // -------------------------------------------------------------------
499
500
 
500
- subcommand(conversations, "clear").action(async () => {
501
- log.info(
502
- "This will permanently delete all conversations, messages, and vector data.",
503
- );
501
+ subcommand(conversations, "clear").action(
502
+ async (opts: { force?: boolean }) => {
503
+ log.info(
504
+ "This will permanently delete all conversations, messages, and vector data.",
505
+ );
506
+
507
+ if (!opts.force) {
508
+ const confirm = await confirmPrompt({
509
+ question: "Are you sure? (y/N) ",
510
+ isTTY: Boolean(process.stdin.isTTY),
511
+ refuseNonInteractiveMessage:
512
+ "Refusing to clear all conversations non-interactively. Pass --force to confirm.",
513
+ });
514
+ if (confirm === "non-interactive") {
515
+ process.exitCode = 1;
516
+ return;
517
+ }
518
+ if (confirm === "denied") {
519
+ log.info("Cancelled");
520
+ return;
521
+ }
522
+ }
504
523
 
505
- const readline = await import("node:readline");
506
- const rl = readline.createInterface({
507
- input: process.stdin,
508
- output: process.stdout,
509
- });
510
- const answer = await new Promise<string>((resolve) => {
511
- rl.question("Are you sure? (y/N) ", resolve);
512
- });
513
- rl.close();
514
- if (answer.toLowerCase() !== "y") {
515
- log.info("Cancelled");
516
- return;
517
- }
518
-
519
- const result = await cliIpcCall<{ cleared: number }>(
520
- "conversations_clear_cli",
521
- {
522
- headers: {
523
- "x-confirm-destructive": "clear-all-conversations",
524
+ const result = await cliIpcCall<{ cleared: number }>(
525
+ "conversations_clear_cli",
526
+ {
527
+ headers: {
528
+ "x-confirm-destructive": "clear-all-conversations",
529
+ },
524
530
  },
525
- },
526
- );
531
+ );
527
532
 
528
- if (!result.ok) {
529
- return exitFromIpcResult(result);
530
- }
533
+ if (!result.ok) {
534
+ return exitFromIpcResult(result);
535
+ }
531
536
 
532
- log.info(`Cleared ${result.result!.cleared} conversations. Done.`);
533
- });
537
+ log.info(`Cleared ${result.result!.cleared} conversations. Done.`);
538
+ },
539
+ );
534
540
 
535
541
  // -------------------------------------------------------------------
536
542
  // wake
@@ -804,7 +804,8 @@ Examples:
804
804
  $ assistant oauth request --provider google https://www.googleapis.com/calendar/v3/calendars/primary/events
805
805
  $ assistant oauth request --provider slack -H "Content-Type: application/json" -d '{"channel":"C123"}' /api/chat.postMessage --json
806
806
  $ assistant oauth request --provider google -X POST -H "Content-Type: multipart/related; boundary=b" -d @upload.txt "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"
807
- $ assistant oauth request --provider google -X POST -H "Content-Type: application/pdf" -d @report.pdf "https://www.googleapis.com/upload/drive/v3/files?uploadType=media"`,
807
+ $ assistant oauth request --provider google -X POST -H "Content-Type: application/pdf" -d @report.pdf "https://www.googleapis.com/upload/drive/v3/files?uploadType=media"
808
+ $ assistant oauth request --provider google -X POST -H "Content-Type: message/rfc822" -d @draft.eml "https://www.googleapis.com/upload/gmail/v1/users/me/drafts?uploadType=media"`,
808
809
  },
809
810
  {
810
811
  name: "disconnect",
@@ -929,9 +930,14 @@ Requests with unsupported headers, including If-Match and Idempotency-Key,
929
930
  are rejected before calling the provider. A connection using your own OAuth
930
931
  app can preserve those headers.
931
932
 
933
+ The printed base URL is a path prefix. Concatenating a provider path onto it
934
+ works, and so does a host-absolute path such as /upload/gmail/... or
935
+ /v1/charges: the gateway remaps that request onto the grant's prefix.
936
+
932
937
  Examples:
933
938
  $ assistant oauth proxy-url stripe_link
934
- $ eval "$(assistant oauth proxy-url stripe_link --export)" && LINK_API_BASE_URL="$VELLUM_OAUTH_PROXY_BASE_URL" LINK_ACCESS_TOKEN="$VELLUM_OAUTH_PROXY_TOKEN" LINK_NO_REFRESH=1 link-cli payment-methods list --format json`,
939
+ $ eval "$(assistant oauth proxy-url stripe_link --export)" && LINK_API_BASE_URL="$VELLUM_OAUTH_PROXY_BASE_URL" LINK_ACCESS_TOKEN="$VELLUM_OAUTH_PROXY_TOKEN" LINK_NO_REFRESH=1 link-cli payment-methods list --format json
940
+ $ eval "$(assistant oauth proxy-url google --export)" && curl -X POST -H "Authorization: Bearer $VELLUM_OAUTH_PROXY_TOKEN" -H "Content-Type: message/rfc822" --data-binary @draft.eml "$VELLUM_OAUTH_PROXY_BASE_URL/upload/gmail/v1/users/me/drafts?uploadType=media"`,
935
941
  },
936
942
  ],
937
943
  };
@@ -309,6 +309,38 @@ describe("oauth request body encoding", () => {
309
309
  },
310
310
  ]);
311
311
  });
312
+
313
+ test("forwards a Gmail rfc822 draft upload URL and body", async () => {
314
+ const rfc822 =
315
+ "From: user@example.com\r\nTo: user@example.com\r\nSubject: Draft\r\n\r\nHello\r\n";
316
+ const { exitCode } = await runRequestCommand([
317
+ "--provider",
318
+ "google",
319
+ "-s",
320
+ "-X",
321
+ "POST",
322
+ "-H",
323
+ "Content-Type: message/rfc822",
324
+ "-d",
325
+ rfc822,
326
+ "https://www.googleapis.com/upload/gmail/v1/users/me/drafts?uploadType=media",
327
+ ]);
328
+
329
+ expect(exitCode).toBe(0);
330
+ expect(handleRequestCalls).toEqual([
331
+ {
332
+ body: {
333
+ provider: "google",
334
+ url: "https://www.googleapis.com/upload/gmail/v1/users/me/drafts?uploadType=media",
335
+ method: "POST",
336
+ headers: {
337
+ "Content-Type": "message/rfc822",
338
+ },
339
+ parsed_data: rfc822,
340
+ },
341
+ },
342
+ ]);
343
+ });
312
344
  });
313
345
 
314
346
  describe("oauth request body output", () => {
@@ -55,7 +55,8 @@ Fields:
55
55
  isPlatform Whether IS_PLATFORM is set (boolean)
56
56
  baseUrl VELLUM_PLATFORM_URL — the platform gateway base URL
57
57
  assistantId This assistant's platform UUID
58
- hasAssistantApiKey Whether a stored assistant API key is available
58
+ hasAssistantApiKey Whether a stored assistant API key is available; null
59
+ when the credential store could not be read
59
60
  hasWebhookSecret Whether a stored webhook secret is available (needed
60
61
  for email and other inbound webhook channels)
61
62
  available Whether callback registration prerequisites are satisfied
@@ -24,7 +24,7 @@ interface PlatformStatusResult {
24
24
  isPlatform: boolean;
25
25
  baseUrl: string;
26
26
  assistantId: string;
27
- hasAssistantApiKey: boolean;
27
+ hasAssistantApiKey: boolean | null;
28
28
  hasWebhookSecret: boolean;
29
29
  available: boolean;
30
30
  organizationId: string | null;
@@ -95,7 +95,13 @@ export function registerPlatformCommand(program: Command): void {
95
95
  log.info(`Base URL: ${result.baseUrl || "(not set)"}`);
96
96
  log.info(`Assistant ID: ${result.assistantId || "(not set)"}`);
97
97
  log.info(
98
- `Assistant API key: ${result.hasAssistantApiKey ? "set" : "not set"}`,
98
+ `Assistant API key: ${
99
+ result.hasAssistantApiKey === null
100
+ ? "unknown (credential store unreachable)"
101
+ : result.hasAssistantApiKey
102
+ ? "set"
103
+ : "not set"
104
+ }`,
99
105
  );
100
106
  log.info(
101
107
  `Webhook secret: ${result.hasWebhookSecret ? "set" : "not set (run ensure-registration to provision)"}`,