@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
@@ -17,6 +17,8 @@
17
17
  */
18
18
  import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
19
19
 
20
+ import sharp from "sharp";
21
+
20
22
  // ── Module mocks ─────────────────────────────────────────────────────────────
21
23
  // Must be registered before the host-cu-routes module is loaded.
22
24
 
@@ -487,7 +489,14 @@ describe("handleHostCuResult: request body validation", () => {
487
489
  expect(pendingStore.has(requestId)).toBe(true);
488
490
  });
489
491
 
490
- test("forwards a full observation payload unchanged", async () => {
492
+ test("forwards observation metadata with dimensions from the screenshot bytes", async () => {
493
+ const screenshot = (
494
+ await sharp({
495
+ create: { width: 835, height: 540, channels: 3, background: "white" },
496
+ })
497
+ .jpeg()
498
+ .toBuffer()
499
+ ).toString("base64");
491
500
  const requestId = "req-cu-full-observation";
492
501
  registerPending(requestId);
493
502
 
@@ -496,7 +505,7 @@ describe("handleHostCuResult: request body validation", () => {
496
505
  requestId,
497
506
  axTree: "Button [1]",
498
507
  axDiff: "+Button [1]",
499
- screenshot: "base64png",
508
+ screenshot,
500
509
  screenshotWidthPx: 1600,
501
510
  screenshotHeightPx: 1000,
502
511
  screenWidthPt: 800,
@@ -512,9 +521,9 @@ describe("handleHostCuResult: request body validation", () => {
512
521
  expect(cuResolveSpy[0].payload).toMatchObject({
513
522
  axTree: "Button [1]",
514
523
  axDiff: "+Button [1]",
515
- screenshot: "base64png",
516
- screenshotWidthPx: 1600,
517
- screenshotHeightPx: 1000,
524
+ screenshot,
525
+ screenshotWidthPx: 835,
526
+ screenshotHeightPx: 540,
518
527
  screenWidthPt: 800,
519
528
  screenHeightPt: 500,
520
529
  executionResult: "Clicked",
@@ -218,6 +218,29 @@ describe("introduction card decisions", () => {
218
218
  }
219
219
  });
220
220
 
221
+ test("handshake approval on an email sender is coerced to direct trust", async () => {
222
+ for (const action of ["approve_once", "verify_code"] as const) {
223
+ resetState();
224
+ const req = makeAccessRequest({ sourceChannel: "email" });
225
+
226
+ const result = await applyGuardianDecision({
227
+ requestId: req.id,
228
+ action,
229
+ actorContext: desktopGuardian(),
230
+ });
231
+
232
+ expect(result.applied).toBe(true);
233
+ // No code is minted: email has no route to deliver one to the sender.
234
+ expect(outcomesOfType("mint_outbound_session")).toHaveLength(0);
235
+ const activations = outcomesOfType("activate_member");
236
+ expect(activations).toHaveLength(1);
237
+ expect(activations[0].sourceChannel).toBe("email");
238
+ expect(activations[0].verifiedVia).toBe("manual_channel_claim");
239
+ // The reported and projected outcome is the trust that was applied.
240
+ expect(result.applied && result.decidedAction).toBe("trust");
241
+ }
242
+ });
243
+
221
244
  test("leave_unverified persists the sender as unverified and is silent (legacy reject path)", async () => {
222
245
  for (const action of ["leave_unverified", "reject"] as const) {
223
246
  resetState();
@@ -392,18 +415,40 @@ describe("introduction card decisions", () => {
392
415
  });
393
416
 
394
417
  describe("introductionOutcomeForAction", () => {
418
+ const slackStranger = {
419
+ sourceChannel: "slack",
420
+ requesterSignals: serializeRequesterSignals({ isStranger: true }) ?? null,
421
+ };
422
+
395
423
  test("folds the generic decision pair onto the introduction outcomes", () => {
396
424
  // `reject` and `leave_unverified` both park the contact at `unverified`;
397
425
  // `approve_once` starts the handshake. Introduction actions map to
398
426
  // themselves. Callers that must present the resolved outcome (the card
399
427
  // projection) rely on this so a `reject` park never reads as "Denied".
400
- expect(introductionOutcomeForAction("reject")).toBe("leave_unverified");
401
- expect(introductionOutcomeForAction("leave_unverified")).toBe(
402
- "leave_unverified",
403
- );
404
- expect(introductionOutcomeForAction("approve_once")).toBe("verify_code");
405
- expect(introductionOutcomeForAction("verify_code")).toBe("verify_code");
406
- expect(introductionOutcomeForAction("trust")).toBe("trust");
407
- expect(introductionOutcomeForAction("block")).toBe("block");
428
+ const outcome = (
429
+ action: Parameters<typeof introductionOutcomeForAction>[1],
430
+ ) => introductionOutcomeForAction(slackStranger, action);
431
+ expect(outcome("reject")).toBe("leave_unverified");
432
+ expect(outcome("leave_unverified")).toBe("leave_unverified");
433
+ expect(outcome("approve_once")).toBe("verify_code");
434
+ expect(outcome("verify_code")).toBe("verify_code");
435
+ expect(outcome("trust")).toBe("trust");
436
+ expect(outcome("block")).toBe("block");
437
+ });
438
+
439
+ test("a handshake approval resolves to trust where the handshake cannot complete", () => {
440
+ const email = { sourceChannel: "email", requesterSignals: null };
441
+ const bot = {
442
+ sourceChannel: "slack",
443
+ requesterSignals: serializeRequesterSignals({ isBot: true }) ?? null,
444
+ };
445
+ for (const request of [email, bot]) {
446
+ expect(introductionOutcomeForAction(request, "approve_once")).toBe(
447
+ "trust",
448
+ );
449
+ expect(introductionOutcomeForAction(request, "verify_code")).toBe(
450
+ "trust",
451
+ );
452
+ }
408
453
  });
409
454
  });
@@ -35,6 +35,7 @@ const MEMORY_JOB_TYPES = [
35
35
  "memory_retrospective",
36
36
  "memory_retrospective_sweep",
37
37
  "skill_card_insert",
38
+ "skill_update_receipt",
38
39
  "pkb_filing",
39
40
  "pkb_compaction",
40
41
  ].sort();
@@ -598,6 +598,54 @@ describe("access-request-helper unit tests", () => {
598
598
  expect(payload.guardianBindingChannel).toBe("vellum");
599
599
  });
600
600
 
601
+ test("an email access request routes to every channel the guardian is connected on", async () => {
602
+ const result = await notifyGuardianOfAccessRequest({
603
+ sourceChannel: "email",
604
+ conversationExternalId: "<thread-1@example.com>",
605
+ actorExternalId: "stranger@example.com",
606
+ });
607
+
608
+ expect(result.notified).toBe(true);
609
+ expect(emitSignalCalls.length).toBe(1);
610
+ expect(emitSignalCalls[0].routingIntent).toBe("all_channels");
611
+ });
612
+
613
+ test("an admitted email sender's nudge keeps the default routing", async () => {
614
+ await maybeNotifyGuardianOfAdmittedContact({
615
+ sourceChannel: "email",
616
+ conversationExternalId: "<thread-2@example.com>",
617
+ actorExternalId: "admitted@example.com",
618
+ });
619
+
620
+ expect(emitSignalCalls.length).toBe(1);
621
+ expect(emitSignalCalls[0].routingIntent).toBeUndefined();
622
+ });
623
+
624
+ test("a telegram access request with a telegram guardian stays on telegram", async () => {
625
+ seedGatewayGuardian({
626
+ channelType: "telegram",
627
+ address: "guardian-tg",
628
+ externalChatId: "tg-chat",
629
+ principalId: anchorPrincipalId,
630
+ });
631
+ createGuardianBinding({
632
+ channel: "telegram",
633
+ guardianExternalUserId: "guardian-tg",
634
+ guardianDeliveryChatId: "tg-chat",
635
+ guardianPrincipalId: anchorPrincipalId,
636
+ verifiedVia: "test",
637
+ });
638
+
639
+ await notifyGuardianOfAccessRequest({
640
+ sourceChannel: "telegram",
641
+ conversationExternalId: "chat-123",
642
+ actorExternalId: "unknown-user",
643
+ });
644
+
645
+ expect(emitSignalCalls.length).toBe(1);
646
+ expect(emitSignalCalls[0].routingIntent).toBe("single_channel");
647
+ });
648
+
601
649
  test("notifyGuardianOfAccessRequest prefers source-channel binding over vellum anchor", async () => {
602
650
  // Both Telegram and voice bindings exist with the anchor principal
603
651
  seedGatewayGuardian({
@@ -59,11 +59,12 @@ function seedSignalAt(
59
59
  sourceContextId: string,
60
60
  createdAt: number,
61
61
  outcome: SeedOutcome = "sent",
62
+ sourceEventName = "assistant.share",
62
63
  ): void {
63
64
  const eventId = crypto.randomUUID();
64
65
  createEvent({
65
66
  id: eventId,
66
- sourceEventName: "assistant.share",
67
+ sourceEventName,
67
68
  sourceChannel: "assistant_tool",
68
69
  sourceContextId,
69
70
  attentionHints: {
@@ -108,6 +109,52 @@ function seedSignalAt(
108
109
  describe("hasNotifiedSourceContextSince", () => {
109
110
  const runStartedAt = 1_700_000_000_000;
110
111
 
112
+ test("result-only probes ignore approval cards while the scheduler keeps its broad contract", () => {
113
+ seedSignalAt(
114
+ CONVERSATION_ID,
115
+ runStartedAt + 100,
116
+ "sent",
117
+ "guardian.question",
118
+ );
119
+ const resultEvents = ["assistant.share", "activity.complete"];
120
+ expect(hasNotifiedSourceContextSince(CONVERSATION_ID, runStartedAt)).toBe(
121
+ true,
122
+ );
123
+ expect(
124
+ hasNotifiedSourceContextSince(
125
+ CONVERSATION_ID,
126
+ runStartedAt,
127
+ resultEvents,
128
+ ),
129
+ ).toBe(false);
130
+ seedSignalAt(
131
+ CONVERSATION_ID,
132
+ runStartedAt + 200,
133
+ "failed",
134
+ "activity.complete",
135
+ );
136
+ expect(
137
+ hasNotifiedSourceContextSince(
138
+ CONVERSATION_ID,
139
+ runStartedAt,
140
+ resultEvents,
141
+ ),
142
+ ).toBe(false);
143
+ seedSignalAt(
144
+ CONVERSATION_ID,
145
+ runStartedAt + 300,
146
+ "declined",
147
+ "assistant.share",
148
+ );
149
+ expect(
150
+ hasNotifiedSourceContextSince(
151
+ CONVERSATION_ID,
152
+ runStartedAt,
153
+ resultEvents,
154
+ ),
155
+ ).toBe(true);
156
+ });
157
+
111
158
  describe("the since bound", () => {
112
159
  test("finds a notification sent during the run", () => {
113
160
  seedSignalAt(CONVERSATION_ID, runStartedAt + 500);
@@ -164,6 +164,103 @@ describe("PlatformPushAdapter", () => {
164
164
  );
165
165
  });
166
166
 
167
+ test.each(["chat.assistant_reply", "schedule.result", "activity.complete"])(
168
+ "%s targets the resolved completion recipient",
169
+ async (sourceEventName) => {
170
+ const adapter = new PlatformPushAdapter();
171
+ const result = await adapter.send(
172
+ makePayload({
173
+ sourceEventName,
174
+ contextPayload: {
175
+ completion: {
176
+ workId: "task-1",
177
+ conversationId: "conv-1",
178
+ recipientPrincipalId: "principal-1",
179
+ owner: "parent_continuation",
180
+ },
181
+ },
182
+ }),
183
+ makeDestination({ metadata: { guardianPrincipalId: "principal-1" } }),
184
+ );
185
+
186
+ expect(result.success).toBe(true);
187
+ expect(fetchCalls[0]?.body.target_guardian_principal_id).toBe(
188
+ "principal-1",
189
+ );
190
+ },
191
+ );
192
+
193
+ test.each([undefined, " ", "other-principal"])(
194
+ "does not send typed completion preview with unavailable recipient %s",
195
+ async (guardianPrincipalId) => {
196
+ const adapter = new PlatformPushAdapter();
197
+ const result = await adapter.send(
198
+ makePayload({
199
+ sourceEventName: "activity.complete",
200
+ contextPayload: {
201
+ completion: {
202
+ workId: "task-1",
203
+ conversationId: "conv-1",
204
+ recipientPrincipalId: "principal-1",
205
+ owner: "parent_continuation",
206
+ },
207
+ },
208
+ }),
209
+ makeDestination({ metadata: { guardianPrincipalId } }),
210
+ );
211
+
212
+ expect(result).toEqual({
213
+ success: false,
214
+ error: "completion recipient unavailable",
215
+ });
216
+ expect(fetchCalls).toEqual([]);
217
+ },
218
+ );
219
+
220
+ test.each(["chat.assistant_reply", "schedule.result"])(
221
+ "%s preserves owner-scoped push when recipient lookup is unavailable",
222
+ async (sourceEventName) => {
223
+ const result = await new PlatformPushAdapter().send(
224
+ makePayload({ sourceEventName }),
225
+ makeDestination(),
226
+ );
227
+
228
+ expect(result.success).toBe(true);
229
+ expect(fetchCalls).toHaveLength(1);
230
+ expect(fetchCalls[0]?.body.target_guardian_principal_id).toBeUndefined();
231
+ },
232
+ );
233
+
234
+ test.each([
235
+ null,
236
+ {},
237
+ {
238
+ workId: "task-1",
239
+ conversationId: "conv-private",
240
+ recipientPrincipalId: "principal-1",
241
+ owner: "unknown",
242
+ },
243
+ ])(
244
+ "malformed ownership %j never dispatches a mobile preview",
245
+ async (completion) => {
246
+ const result = await new PlatformPushAdapter().send(
247
+ makePayload({
248
+ sourceEventName: "activity.complete",
249
+ urgency: "high",
250
+ copy: { title: "Private result", body: "Sensitive result preview." },
251
+ contextPayload: { completion },
252
+ }),
253
+ makeDestination({ metadata: { guardianPrincipalId: "principal-1" } }),
254
+ );
255
+
256
+ expect(result).toEqual({
257
+ success: false,
258
+ error: "completion recipient unavailable",
259
+ });
260
+ expect(fetchCalls).toEqual([]);
261
+ },
262
+ );
263
+
167
264
  test("omits target_guardian_principal_id for non-guardian events even with principalId in metadata", async () => {
168
265
  const adapter = new PlatformPushAdapter();
169
266
  const payload = makePayload({ sourceEventName: "schedule.notify" });
@@ -368,22 +368,28 @@ describe("VellumAdapter guardian scoping", () => {
368
368
  function captureOptions(): {
369
369
  adapter: VellumAdapter;
370
370
  options: Array<BroadcastMessageOptions | undefined>;
371
+ intents: AssistantEvent[];
371
372
  } {
372
373
  const options: Array<BroadcastMessageOptions | undefined> = [];
373
- const adapter = new VellumAdapter((_msg, _conversationId, opts) => {
374
+ const intents: AssistantEvent[] = [];
375
+ const adapter = new VellumAdapter((msg, _conversationId, opts) => {
374
376
  options.push(opts);
377
+ intents.push(msg);
375
378
  });
376
- return { adapter, options };
379
+ return { adapter, options, intents };
377
380
  }
378
381
 
379
382
  test("a guardian-sensitive intent is delivered only to the guardian's connections", async () => {
380
- const { adapter, options } = captureOptions();
383
+ const { adapter, options, intents } = captureOptions();
381
384
  await adapter.send(
382
385
  makePayload({ sourceEventName: "guardian.question", urgency: "high" }),
383
386
  makeDestination({ metadata: { guardianPrincipalId: "principal-g" } }),
384
387
  );
385
388
 
386
389
  expect(options).toEqual([{ targetActorPrincipalId: "principal-g" }]);
390
+ expect(intents[0]).toMatchObject({
391
+ targetGuardianPrincipalId: "principal-g",
392
+ });
387
393
  });
388
394
 
389
395
  test("an ordinary intent is broadcast to every connection", async () => {
@@ -395,4 +401,98 @@ describe("VellumAdapter guardian scoping", () => {
395
401
 
396
402
  expect(options).toEqual([{ targetActorPrincipalId: undefined }]);
397
403
  });
404
+
405
+ test.each(["chat.assistant_reply", "schedule.result", "activity.complete"])(
406
+ "%s remains recipient-scoped without the legacy guardian-card marker",
407
+ async (sourceEventName) => {
408
+ const intents: AssistantEvent[] = [];
409
+ const scopes: Array<BroadcastMessageOptions | undefined> = [];
410
+ const adapter = new VellumAdapter((message, _conversationId, options) => {
411
+ intents.push(message);
412
+ scopes.push(options);
413
+ });
414
+ const result = await adapter.send(
415
+ makePayload({
416
+ sourceEventName,
417
+ urgency: "medium",
418
+ contextPayload: {
419
+ completion: {
420
+ workId: "task-1",
421
+ conversationId: "conv-result",
422
+ recipientPrincipalId: "principal-g",
423
+ owner: "parent_continuation",
424
+ },
425
+ },
426
+ }),
427
+ makeDestination({ metadata: { guardianPrincipalId: "principal-g" } }),
428
+ );
429
+
430
+ expect(result.success).toBe(true);
431
+ expect(scopes).toEqual([{ targetActorPrincipalId: "principal-g" }]);
432
+ expect(intents[0]).toMatchObject({
433
+ silent: false,
434
+ targetGuardianPrincipalId: undefined,
435
+ });
436
+ },
437
+ );
438
+
439
+ test("a completion with no resolved recipient sends no preview", async () => {
440
+ const { adapter, sent } = captureBroadcast();
441
+ const result = await adapter.send(
442
+ makePayload({ sourceEventName: "chat.assistant_reply" }),
443
+ makeDestination(),
444
+ );
445
+
446
+ expect(result).toEqual({
447
+ success: false,
448
+ error: "completion recipient unavailable",
449
+ });
450
+ expect(sent).toEqual([]);
451
+ });
452
+
453
+ test.each([
454
+ null,
455
+ {},
456
+ {
457
+ workId: "task-1",
458
+ conversationId: "conv-private",
459
+ recipientPrincipalId: "principal-1",
460
+ owner: "unknown",
461
+ },
462
+ ])(
463
+ "malformed ownership %j never broadcasts a private preview",
464
+ async (completion) => {
465
+ const { adapter, options, intents } = captureOptions();
466
+ const result = await adapter.send(
467
+ makePayload({
468
+ sourceEventName: "activity.complete",
469
+ urgency: "high",
470
+ copy: { title: "Private result", body: "Sensitive result preview." },
471
+ contextPayload: { completion },
472
+ }),
473
+ makeDestination({ metadata: { guardianPrincipalId: "principal-1" } }),
474
+ );
475
+
476
+ expect(result).toEqual({
477
+ success: false,
478
+ error: "completion recipient unavailable",
479
+ });
480
+ expect(intents).toEqual([]);
481
+ expect(options).toEqual([]);
482
+ },
483
+ );
484
+
485
+ test("honors broadcaster presentation independently of urgency", async () => {
486
+ const { adapter, sent } = captureBroadcast();
487
+ await adapter.send(
488
+ makePayload({
489
+ sourceEventName: "chat.assistant_reply",
490
+ urgency: "medium",
491
+ silent: true,
492
+ }),
493
+ makeDestination({ metadata: { guardianPrincipalId: "principal-g" } }),
494
+ );
495
+
496
+ expect(sent[0]).toMatchObject({ silent: true });
497
+ });
398
498
  });
@@ -11,6 +11,7 @@ let mockVelayWebhooksEnabled = false;
11
11
  let mockPlatformBaseUrl = "";
12
12
  let mockPlatformAssistantId = "";
13
13
  let mockSecureKeys: Record<string, string> = {};
14
+ let mockSecureKeysUnreachable = false;
14
15
  let mockConfig: { ingress?: { publicBaseUrl?: string; enabled?: boolean } } =
15
16
  {};
16
17
 
@@ -65,7 +66,12 @@ mock.module("../ipc/gateway-client.js", () => ({
65
66
  const actualSecureKeys = await import("../security/secure-keys.js");
66
67
  mock.module("../security/secure-keys.js", () => ({
67
68
  ...actualSecureKeys,
68
- getSecureKeyAsync: async (key: string) => mockSecureKeys[key] ?? undefined,
69
+ getSecureKeyAsync: async (key: string) =>
70
+ mockSecureKeysUnreachable ? undefined : (mockSecureKeys[key] ?? undefined),
71
+ getSecureKeyResultAsync: async (key: string) =>
72
+ mockSecureKeysUnreachable
73
+ ? { value: undefined, unreachable: true }
74
+ : { value: mockSecureKeys[key] ?? undefined, unreachable: false },
69
75
  }));
70
76
 
71
77
  const actualLoader = await import("../config/loader.js");
@@ -92,6 +98,7 @@ describe("platform callback registration", () => {
92
98
  mockPlatformBaseUrl = "";
93
99
  mockPlatformAssistantId = "";
94
100
  mockSecureKeys = {};
101
+ mockSecureKeysUnreachable = false;
95
102
  mockConfig = {};
96
103
  setIngressPublicBaseUrl(undefined);
97
104
  delete process.env.ASSISTANT_API_KEY;
@@ -156,6 +163,43 @@ describe("platform callback registration", () => {
156
163
  expect(context.authHeader).toBe("Api-Key env-key");
157
164
  });
158
165
 
166
+ test("reports the key as missing when the store answers and holds none", async () => {
167
+ mockPlatformBaseUrl = "https://platform.example.com";
168
+ mockPlatformAssistantId = "44444444-5555-4666-8777-888888888888";
169
+
170
+ const context = await resolvePlatformCallbackRegistrationContext();
171
+
172
+ expect(context.hasAssistantApiKey).toBe(false);
173
+ expect(context.authHeader).toBeNull();
174
+ expect(context.enabled).toBe(false);
175
+ });
176
+
177
+ test("reports the key state as unknown when the store did not answer", async () => {
178
+ // A client that provisions a key when it sees none must not be told
179
+ // "none" by a daemon whose store did not answer.
180
+ mockSecureKeysUnreachable = true;
181
+ mockPlatformBaseUrl = "https://platform.example.com";
182
+ mockPlatformAssistantId = "44444444-5555-4666-8777-888888888888";
183
+
184
+ const context = await resolvePlatformCallbackRegistrationContext();
185
+
186
+ expect(context.hasAssistantApiKey).toBeNull();
187
+ expect(context.authHeader).toBeNull();
188
+ expect(context.enabled).toBe(false);
189
+ });
190
+
191
+ test("an environment key counts as present even when the store did not answer", async () => {
192
+ mockSecureKeysUnreachable = true;
193
+ process.env.ASSISTANT_API_KEY = "env-key";
194
+ mockPlatformBaseUrl = "https://platform.example.com";
195
+ mockPlatformAssistantId = "44444444-5555-4666-8777-888888888888";
196
+
197
+ const context = await resolvePlatformCallbackRegistrationContext();
198
+
199
+ expect(context.hasAssistantApiKey).toBe(true);
200
+ expect(context.authHeader).toBe("Api-Key env-key");
201
+ });
202
+
159
203
  test("registerCallbackRoute falls back to assistant API key auth", async () => {
160
204
  mockSecureKeys[credentialKey("vellum", "platform_base_url")] =
161
205
  "https://platform.example.com";
@@ -402,6 +446,7 @@ describe("resolveCallbackUrl resolution order", () => {
402
446
  mockPlatformBaseUrl = "";
403
447
  mockPlatformAssistantId = "";
404
448
  mockSecureKeys = {};
449
+ mockSecureKeysUnreachable = false;
405
450
  mockConfig = {};
406
451
  setIngressPublicBaseUrl(undefined);
407
452
  delete process.env.ASSISTANT_API_KEY;
@@ -196,6 +196,9 @@ const BASELINE: Record<string, readonly string[]> = {
196
196
  "../../../daemon/trust-context.js",
197
197
  "../../../home/job-handlers/conversation-starters.js",
198
198
  "../../../media/job-handlers/media-processing.js",
199
+ // The skill-update receipt job announces a burst through the
200
+ // notification pipeline's single entry point. No plugin-api equivalent.
201
+ "../../../notifications/emit-signal.js",
199
202
  "../../../permissions/types.js",
200
203
  "../../../persistence/auto-analysis-constants.js",
201
204
  "../../../persistence/checkpoints.js",