@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
@@ -29,6 +29,11 @@ const capturedRunAgentLoopOptions: CapturedRunAgentLoopOptions[] = [];
29
29
  // When set, `runAgentLoop` never settles, so the spawned subagent stays in a
30
30
  // non-terminal state and can accept a follow-up `sendMessage`.
31
31
  let holdRunAgentLoop = false;
32
+ let queueFollowup = false;
33
+ const capturedQueuedOptions: Array<{
34
+ content: string;
35
+ cronRunId?: string | null;
36
+ }> = [];
32
37
 
33
38
  class FakeConversation {
34
39
  constructor() {}
@@ -55,8 +60,9 @@ class FakeConversation {
55
60
  setForkPolicy() {}
56
61
  setForkParentMessageCount() {}
57
62
  setForkParentSystemPrompt() {}
58
- enqueueMessage() {
59
- return { rejected: false, queued: false };
63
+ enqueueMessage(options: { content: string; cronRunId?: string | null }) {
64
+ capturedQueuedOptions.push(options);
65
+ return { rejected: false, queued: queueFollowup };
60
66
  }
61
67
  abort() {}
62
68
  dispose() {}
@@ -272,6 +278,39 @@ describe("SubagentManager: cronRunId reaches the child's agent loop", () => {
272
278
  }
273
279
  });
274
280
 
281
+ for (const cronRunId of ["cron-run-message", null, undefined]) {
282
+ test(`a busy child queues the follow-up's owner (${cronRunId ?? "user"})`, async () => {
283
+ capturedRunAgentLoopOptions.length = 0;
284
+ capturedQueuedOptions.length = 0;
285
+ holdRunAgentLoop = true;
286
+ queueFollowup = true;
287
+ try {
288
+ const manager = new SubagentManager();
289
+ const subagentId = await manager.spawn(
290
+ {
291
+ parentConversationId: "parent-cron-queued",
292
+ label: "child",
293
+ objective: "do the thing",
294
+ cronRunId: "cron-run-spawn",
295
+ },
296
+ () => {},
297
+ );
298
+ await Promise.resolve();
299
+ await Promise.resolve();
300
+ expect(
301
+ await manager.sendMessage(subagentId, "keep going", { cronRunId }),
302
+ ).toBe("sent");
303
+ expect(capturedQueuedOptions).toEqual([
304
+ { content: "keep going", cronRunId },
305
+ ]);
306
+ expect(capturedRunAgentLoopOptions).toHaveLength(1);
307
+ } finally {
308
+ holdRunAgentLoop = false;
309
+ queueFollowup = false;
310
+ }
311
+ });
312
+ }
313
+
275
314
  test("omits cronRunId on a continuation turn no schedule triggered", async () => {
276
315
  capturedRunAgentLoopOptions.length = 0;
277
316
  holdRunAgentLoop = true;
@@ -41,8 +41,10 @@ import type { SubagentState } from "../subagent/types.js";
41
41
 
42
42
  /** Minimal shape matching the private ManagedSubagent interface for test injection. */
43
43
  interface FakeManagedSubagent {
44
+ runInFlight?: boolean;
44
45
  conversation: {
45
46
  abort: () => void;
47
+ abortScheduledRun?: (runId: string) => void;
46
48
  dispose: () => void;
47
49
  messages: Array<{
48
50
  role: string;
@@ -628,6 +630,23 @@ describe("SubagentManager hasActiveChildren", () => {
628
630
  expect(manager.hasActiveChildren("parent-sess-1")).toBe(true);
629
631
  });
630
632
 
633
+ test("scopes active and unwinding children to their schedule owner", () => {
634
+ const manager = new SubagentManager();
635
+ const owned = makeState("sub-owned");
636
+ owned.config.cronRunId = "run-owned";
637
+ injectFakeSubagent(manager, "sub-owned", owned);
638
+ injectFakeSubagent(manager, "sub-user", makeState("sub-user"));
639
+ expect(manager.hasActiveChildren("parent-sess-1", "run-owned")).toBe(true);
640
+ expect(manager.hasActiveChildren("parent-sess-1", "run-other")).toBe(false);
641
+ const managed = asInternals(manager).subagents.get("sub-owned")!;
642
+ managed.state.status = "completed";
643
+ managed.runInFlight = true;
644
+ expect(manager.hasActiveChildren("parent-sess-1", "run-owned")).toBe(true);
645
+ managed.runInFlight = false;
646
+ expect(manager.hasActiveChildren("parent-sess-1", "run-owned")).toBe(false);
647
+ expect(manager.hasActiveChildren("parent-sess-1")).toBe(true);
648
+ });
649
+
631
650
  test("is false when every child is terminal or the parent has none", () => {
632
651
  const manager = new SubagentManager();
633
652
  expect(manager.hasActiveChildren("parent-sess-1")).toBe(false);
@@ -797,3 +816,32 @@ describe("SubagentManager sendMessage validation", () => {
797
816
  expect(await manager.sendMessage(subagentId, "\n\t")).toBe("empty");
798
817
  });
799
818
  });
819
+
820
+ describe("scheduled subagent cancellation", () => {
821
+ for (const owned of [true, false]) {
822
+ test(`cancels only run-owned child work (owned=${owned})`, () => {
823
+ const manager = new SubagentManager();
824
+ const state = makeState("task-schedule");
825
+ state.config.cronRunId = owned ? "run-timeout" : "run-other";
826
+ injectFakeSubagent(manager, "task-schedule", state);
827
+ const child =
828
+ asInternals(manager).subagents.get("task-schedule")!.conversation!;
829
+ const abort = mock(() => {});
830
+ const abortScheduledRun = mock((_runId: string) => {});
831
+ child.abort = abort;
832
+ child.abortScheduledRun = abortScheduledRun;
833
+ expect(
834
+ manager.abort("task-schedule", undefined, undefined, {
835
+ cronRunId: "run-timeout",
836
+ }),
837
+ ).toBe(owned);
838
+ expect(abort).not.toHaveBeenCalled();
839
+ expect(abortScheduledRun).toHaveBeenCalledTimes(owned ? 1 : 0);
840
+ if (owned) {
841
+ expect(abortScheduledRun).toHaveBeenCalledWith("run-timeout");
842
+ }
843
+ expect(state.status).toBe(owned ? "aborted" : "running");
844
+ asInternals(manager).stopSweep();
845
+ });
846
+ }
847
+ });
@@ -1308,15 +1308,15 @@ describe("(g) access_request resolver: requester code delivery", () => {
1308
1308
  expect(verificationSent.length).toBe(1);
1309
1309
  });
1310
1310
 
1311
- test("off-channel approval on a channel with no deliverable callback (e.g. email) still records verification_sent", async () => {
1312
- // `email` has no deliver URL (resolveDeliverCallbackUrlForChannel returns
1311
+ test("off-channel approval on a channel with no deliverable callback (e.g. a plugin channel) still records verification_sent", async () => {
1312
+ // `plugin` has no deliver URL (resolveDeliverCallbackUrlForChannel returns
1313
1313
  // null), so the requester cannot be auto-notified here. The guardian still
1314
1314
  // receives the code inline, so the lifecycle transition must be recorded —
1315
1315
  // the emit must not be gated on requester deliverability.
1316
1316
  const req = createAccessRequest({
1317
- sourceChannel: "email",
1318
- requesterChatId: "requester@example.com",
1319
- sourceConversationId: "conv-access-email",
1317
+ sourceChannel: "plugin",
1318
+ requesterChatId: "plugin-requester-1",
1319
+ sourceConversationId: "conv-access-plugin",
1320
1320
  });
1321
1321
 
1322
1322
  const result = await applyGuardianDecision({
@@ -1335,7 +1335,7 @@ describe("(g) access_request resolver: requester code delivery", () => {
1335
1335
  const replyText = result.applied ? result.resolverReplyText : undefined;
1336
1336
  expect(replyText).toContain("123456");
1337
1337
  const requesterDelivery = deliveredReplies.find(
1338
- (r) => r.payload.chatId === "requester@example.com",
1338
+ (r) => r.payload.chatId === "plugin-requester-1",
1339
1339
  );
1340
1340
  expect(requesterDelivery).toBeUndefined();
1341
1341
 
@@ -109,6 +109,37 @@ describe("resolveUsageAttribution", () => {
109
109
  expectResolvedProviderModelMatchesResolver("mainAgent", "pinned");
110
110
  });
111
111
 
112
+ test("reports an override the Auto router chose as the auto source", () => {
113
+ setLlmConfig({
114
+ profiles: {
115
+ active: { provider: "openai", model: "gpt-5.4" },
116
+ routed: { provider: "gemini", model: "gemini-3-pro" },
117
+ },
118
+ activeProfile: "active",
119
+ });
120
+
121
+ const snapshot = resolveUsageAttribution({
122
+ callSite: "mainAgent",
123
+ overrideProfile: "routed",
124
+ overrideProfileOrigin: "auto",
125
+ });
126
+
127
+ expect(snapshot).toMatchObject({
128
+ appliedProfile: "routed",
129
+ profileSource: "auto",
130
+ resolvedProvider: "gemini",
131
+ resolvedModel: "gemini-3-pro",
132
+ });
133
+ // The origin only relabels an override that actually won.
134
+ expect(
135
+ resolveUsageAttribution({
136
+ callSite: "mainAgent",
137
+ overrideProfile: "missing",
138
+ overrideProfileOrigin: "auto",
139
+ }).profileSource,
140
+ ).toBe("active");
141
+ });
142
+
112
143
  test("resolves call-site profile attribution", () => {
113
144
  setLlmConfig({
114
145
  profiles: {
@@ -26,6 +26,7 @@ const mockWakeAgentForOpportunity = mock(
26
26
  }> => Promise.resolve({ invoked: true, producedToolCalls: false }),
27
27
  );
28
28
  mock.module("../runtime/agent-wake.js", () => ({
29
+ hasPendingAgentWake: () => false,
29
30
  wakeAgentForOpportunity: mockWakeAgentForOpportunity,
30
31
  }));
31
32
 
package/src/agent/loop.ts CHANGED
@@ -747,6 +747,12 @@ interface AgentLoopRunOptionsBase {
747
747
  * call-site named profile. Missing profile names silently fall through.
748
748
  */
749
749
  overrideProfile?: string;
750
+ /**
751
+ * Who chose `overrideProfile`: `"auto"` when the Auto profile's router
752
+ * picked it for this turn. Threaded onto each send's config so usage
753
+ * attribution reports the routed profile under the `auto` source.
754
+ */
755
+ overrideProfileOrigin?: "auto";
750
756
  /**
751
757
  * Float the override profile above the call-site layers (named site
752
758
  * profile + call-site override) for non-main-agent call sites — the
@@ -1454,6 +1460,7 @@ export class AgentLoop {
1454
1460
  supportsDynamicUi = true,
1455
1461
  trust,
1456
1462
  overrideProfile,
1463
+ overrideProfileOrigin,
1457
1464
  forceOverrideProfile = false,
1458
1465
  resolveOverrideProfile,
1459
1466
  onModelCallPrepared,
@@ -2036,6 +2043,16 @@ export class AgentLoop {
2036
2043
  const effectiveOverrideProfile = resolveEffectiveOverrideProfile();
2037
2044
  if (effectiveOverrideProfile) {
2038
2045
  providerConfig.overrideProfile = effectiveOverrideProfile;
2046
+ // The origin describes the turn-start override. A profile switched
2047
+ // in mid-turn (a confirmed profile session) is the user's pick, so
2048
+ // the origin applies only while the effective override is still
2049
+ // the one the turn started with.
2050
+ if (
2051
+ overrideProfileOrigin &&
2052
+ effectiveOverrideProfile === overrideProfile
2053
+ ) {
2054
+ providerConfig.overrideProfileOrigin = overrideProfileOrigin;
2055
+ }
2039
2056
  if (forceOverrideProfile) {
2040
2057
  providerConfig.forceOverrideProfile = true;
2041
2058
  }
@@ -2236,7 +2253,13 @@ export class AgentLoop {
2236
2253
  // resolver layers `llm.profiles[overrideProfile]` at the top of
2237
2254
  // precedence for the user-facing call, so a model router can pick
2238
2255
  // the profile per message; clearing it drops any seeded override.
2256
+ // The hook context is seeded with the effective override, so an
2257
+ // unchanged profile is still the router's pick and keeps its
2258
+ // origin; a profile the hook changed or cleared is the hook's.
2239
2259
  const hookModelProfile = finalPreModelCtx.modelProfile?.trim();
2260
+ if (hookModelProfile !== effectiveOverrideProfile) {
2261
+ delete providerConfig.overrideProfileOrigin;
2262
+ }
2240
2263
  if (hookModelProfile) {
2241
2264
  providerConfig.overrideProfile = hookModelProfile;
2242
2265
  if (forceOverrideProfile) {
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * The `ask_question` tool's input as a recorded call carries it, for a client
5
+ * reading one back.
6
+ *
7
+ * The tool's own schema (`askQuestionInputSchema`) is the authority on what a
8
+ * model may send: it caps the batch, bounds the options, carries the
9
+ * descriptions the model reads, and refuses a call that passes both shapes.
10
+ * This one only has to read what was already accepted, so it validates the
11
+ * shape and nothing else, and tolerates a recorded call from an assistant
12
+ * whose bounds differed.
13
+ *
14
+ * Both shapes are here because both are what was asked. `desktopHelp` becomes
15
+ * a one-question prompt inside the daemon, so a reader that only understood
16
+ * `questions` would have nothing to show for a recorded desktop-help call.
17
+ *
18
+ * Structured records win where they exist: the answered record a settled
19
+ * prompt carries (`AnsweredQuestion`) and the live entries an outstanding one
20
+ * has. This is the fallback for a call that has neither, which is any prompt
21
+ * recorded before those records existed, one that timed out, and one whose
22
+ * outstanding entries a reload could not tie back to it.
23
+ */
24
+
25
+ const RecordedQuestionOptionSchema = z.looseObject({
26
+ id: z.string().optional().catch(undefined),
27
+ label: z.string(),
28
+ description: z.string().optional().catch(undefined),
29
+ });
30
+
31
+ const RecordedQuestionSchema = z.looseObject({
32
+ question: z.string(),
33
+ description: z.string().optional().catch(undefined),
34
+ options: z.array(RecordedQuestionOptionSchema).optional().catch(undefined),
35
+ });
36
+
37
+ export const AskQuestionInputSchema = z.looseObject({
38
+ questions: z.array(RecordedQuestionSchema).optional().catch(undefined),
39
+ desktopHelp: z
40
+ .looseObject({
41
+ message: z.string(),
42
+ doneLabel: z.string().optional().catch(undefined),
43
+ skipLabel: z.string().optional().catch(undefined),
44
+ })
45
+ .optional()
46
+ .catch(undefined),
47
+ });
48
+
49
+ export type AskQuestionInput = z.infer<typeof AskQuestionInputSchema>;
50
+ export type RecordedQuestion = z.infer<typeof RecordedQuestionSchema>;
@@ -34,6 +34,10 @@ export const GenerationHandoffEventSchema = z.object({
34
34
  modeSession: ModeSessionSchema.optional(),
35
35
  attachments: z.array(AssistantOutboundAttachmentSchema).optional(),
36
36
  attachmentWarnings: z.array(z.string()).optional(),
37
+ /** The default profile the Auto profile routed the finished turn to,
38
+ * mirroring `message_complete`, so a reply that hands off to a queued
39
+ * turn still gets its badge on the live row. */
40
+ autoRoutedProfile: z.string().optional(),
37
41
  });
38
42
 
39
43
  export type GenerationHandoffEvent = z.infer<
@@ -42,6 +42,10 @@ export const MessageCompleteEventSchema = z.object({
42
42
  * its reply through the `send_user_message` tool, so a client can give the
43
43
  * live row the same per-row treatment it will get from history. */
44
44
  assistantTextVisibility: z.enum(["private", "visible"]).optional(),
45
+ /** The default profile the Auto profile routed this turn to, mirroring the
46
+ * field of the same name on `ConversationMessage`. Set only on a turn that
47
+ * ran on Auto, so the live row can show which profile answered. */
48
+ autoRoutedProfile: z.string().optional(),
45
49
  });
46
50
 
47
51
  export type MessageCompleteEvent = z.infer<typeof MessageCompleteEventSchema>;
@@ -54,6 +54,7 @@ export const WebSearchProviderIdSchema = z.enum([
54
54
  "fastcrw",
55
55
  "searxng",
56
56
  "tinyfish",
57
+ "exa",
57
58
  ]);
58
59
 
59
60
  export type WebSearchProviderId = z.infer<typeof WebSearchProviderIdSchema>;
@@ -112,6 +113,16 @@ export const WebFetchMetadataSchema = z.object({
112
113
  durationMs: z.number(),
113
114
  errorMessage: z.string().optional(),
114
115
  mayRequireJavaScript: z.boolean().optional(),
116
+ /**
117
+ * The requested `start_index` was past the end of the page, so nothing was
118
+ * read. Always set, true or false, by an assistant whose metadata carries
119
+ * every warning a reader acts on (this and `providerWarning` included); a
120
+ * record without it came from one that predates them, whose remaining
121
+ * warnings are only in the result text.
122
+ */
123
+ startIndexPastEnd: z.boolean().optional(),
124
+ /** A hosted provider's own warning about the fetch, verbatim. */
125
+ providerWarning: z.string().optional(),
115
126
  });
116
127
 
117
128
  export type WebFetchMetadata = z.infer<typeof WebFetchMetadataSchema>;
package/src/api/index.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { z } from "zod";
2
2
 
3
+ export {
4
+ type AskQuestionInput,
5
+ AskQuestionInputSchema,
6
+ type RecordedQuestion,
7
+ } from "./ask-question-tool.js";
3
8
  export {
4
9
  isComputerUseToolCall,
5
10
  resolveComputerUseToolName,
@@ -766,6 +771,10 @@ export {
766
771
  type DictationRequest,
767
772
  DictationRequestSchema,
768
773
  } from "./requests/dictation.js";
774
+ export {
775
+ type GuardianActionDecisionRequest,
776
+ GuardianActionDecisionRequestSchema,
777
+ } from "./requests/guardian-actions.js";
769
778
  export {
770
779
  type BackgroundToolCompletion,
771
780
  type ConversationAttachmentBlock,
@@ -832,6 +841,8 @@ export {
832
841
  FeedItemStatusSchema,
833
842
  type FeedItemType,
834
843
  FeedItemTypeSchema,
844
+ type FeedItemUpdate,
845
+ FeedItemUpdateSchema,
835
846
  type FeedItemUrgency,
836
847
  FeedItemUrgencySchema,
837
848
  GUARDIAN_TERMINAL_REASON_SUPERSEDED,
@@ -0,0 +1,45 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { GuardianActionDecisionRequestSchema } from "./guardian-actions.js";
4
+
5
+ describe("GuardianActionDecisionRequestSchema", () => {
6
+ test("accepts every guardian decision action", () => {
7
+ for (const action of [
8
+ "approve_once",
9
+ "reject",
10
+ "trust",
11
+ "verify_code",
12
+ "leave_unverified",
13
+ "block",
14
+ ]) {
15
+ expect(
16
+ GuardianActionDecisionRequestSchema.safeParse({
17
+ requestId: "req-1",
18
+ action,
19
+ }).success,
20
+ ).toBe(true);
21
+ }
22
+ });
23
+
24
+ test("rejects an action that is not a decision", () => {
25
+ expect(
26
+ GuardianActionDecisionRequestSchema.safeParse({
27
+ requestId: "req-1",
28
+ action: "approve_always",
29
+ }).success,
30
+ ).toBe(false);
31
+ });
32
+
33
+ test("rejects a missing or empty request id", () => {
34
+ expect(
35
+ GuardianActionDecisionRequestSchema.safeParse({ action: "reject" })
36
+ .success,
37
+ ).toBe(false);
38
+ expect(
39
+ GuardianActionDecisionRequestSchema.safeParse({
40
+ requestId: "",
41
+ action: "reject",
42
+ }).success,
43
+ ).toBe(false);
44
+ });
45
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Wire contract for the guardian decision endpoint
3
+ * (`POST /guardian-actions/decision`).
4
+ *
5
+ * Canonical wire-contract source. The daemon route sources its `requestBody`
6
+ * from here and validates each body against it; external consumers (web
7
+ * client, gateway, evals) import via `@vellumai/assistant-api`.
8
+ */
9
+
10
+ import { GuardianDecisionActionIdSchema } from "@vellumai/service-contracts/guardian-requests";
11
+ import { z } from "zod";
12
+
13
+ export const GuardianActionDecisionRequestSchema = z.object({
14
+ requestId: z.string().min(1).describe("Guardian request ID"),
15
+ action: GuardianDecisionActionIdSchema.describe("Decision action"),
16
+ conversationId: z.string().describe("Conversation ID").optional(),
17
+ });
18
+ export type GuardianActionDecisionRequest = z.infer<
19
+ typeof GuardianActionDecisionRequestSchema
20
+ >;
@@ -624,6 +624,10 @@ export const ConversationMessageSchema = z.object({
624
624
  * sentinel text, and treat the row as the turn's reply so nothing keeps
625
625
  * waiting for one. */
626
626
  noResponse: z.boolean().optional(),
627
+ /** The default profile key the Auto profile routed this turn to
628
+ * (`metadata.autoRoutedProfile`). Set only on an assistant row produced by
629
+ * a turn that ran on Auto; clients show which profile answered. */
630
+ autoRoutedProfile: z.string().optional(),
627
631
  /** Set only on standalone ambient camera-frame rows, derived from
628
632
  * `messageMetadataIsAmbientSightKeep`. Clients may fold consecutive frames
629
633
  * into the following user message. Absent on shutter photos, spoken turns
@@ -167,6 +167,28 @@ export type FeedItemGuardianRequest = z.infer<
167
167
  typeof FeedItemGuardianRequestSchema
168
168
  >;
169
169
 
170
+ /**
171
+ * One background rewrite of a managed skill, as a receipt item lists it.
172
+ *
173
+ * A receipt (`detailPanel.kind === "updatesList"`) collapses every skill
174
+ * update a background pass made within one burst into a single feed item, and
175
+ * `updates` keeps each rewrite whole: the skill it touched, the pass's own
176
+ * account of what changed, and the conversation the change came from, when
177
+ * lineage resolved. The same skill can appear more than once, one entry per
178
+ * rewrite, in the order the rewrites happened. Clients group on `skillId`
179
+ * alone, never on `name` or the summary text.
180
+ */
181
+ export const FeedItemUpdateSchema = z.object({
182
+ skillId: z.string(),
183
+ /** The skill's display name at the time of the rewrite. */
184
+ name: z.string(),
185
+ /** The pass's own account of what it changed. Plain text, not markdown. */
186
+ summary: z.string(),
187
+ /** The conversation the rewrite was distilled from, when it resolved. */
188
+ conversationId: z.string().optional(),
189
+ });
190
+ export type FeedItemUpdate = z.infer<typeof FeedItemUpdateSchema>;
191
+
170
192
  /**
171
193
  * A single item rendered in the Home feed.
172
194
  *
@@ -198,6 +220,11 @@ export const FeedItemSchema = z.object({
198
220
  // Present only on the canonical "Needs attention" item projecting a
199
221
  // guardian request; see FeedItemGuardianRequestSchema.
200
222
  guardianRequest: FeedItemGuardianRequestSchema.optional(),
223
+ // Present only on a skill-update receipt (`detailPanel.kind` is
224
+ // `updatesList`); see FeedItemUpdateSchema. `summary` still carries the
225
+ // same content as a plain list, so a client without the panel loses only
226
+ // the per-skill links.
227
+ updates: z.array(FeedItemUpdateSchema).optional(),
201
228
  category: FeedItemCategorySchema.optional(),
202
229
  noteworthy: z.boolean().optional(),
203
230
  fromAssistant: z.boolean().optional(),
@@ -32,6 +32,8 @@
32
32
  * - Scoped grant minting only on explicit approve for requests with tool metadata
33
33
  */
34
34
 
35
+ import { isDenyingGuardianAction } from "@vellumai/service-contracts/guardian-requests";
36
+
35
37
  import {
36
38
  decideGuardianRequest,
37
39
  type DecideGuardianRequestIpcResponse,
@@ -41,7 +43,6 @@ import {
41
43
  import {
42
44
  APPROVAL_ACTION_SET,
43
45
  type ApprovalAction,
44
- DENYING_ACTION_SET,
45
46
  INTRODUCTION_ACTION_SET,
46
47
  } from "../runtime/channel-approval-types.js";
47
48
  import { getLogger } from "../util/logger.js";
@@ -383,7 +384,7 @@ export async function applyGuardianDecision(
383
384
  // 3. Plan the ACL outcome BEFORE any status write. Kinds without a
384
385
  // `prepare` hook decide as a plain status CAS.
385
386
  const effectiveAction: ApprovalAction = action;
386
- const targetStatus: "approved" | "denied" = DENYING_ACTION_SET.has(
387
+ const targetStatus: "approved" | "denied" = isDenyingGuardianAction(
387
388
  effectiveAction,
388
389
  )
389
390
  ? "denied"
@@ -528,12 +529,13 @@ export async function applyGuardianDecision(
528
529
  // never throws; the `.catch` is a defensive backstop.
529
530
  // For access requests the resolver folds the generic decision pair onto the
530
531
  // introduction outcomes (`reject` → `leave_unverified`, `approve_once` →
531
- // `verify_code`), so the resolved card must reflect the OUTCOME, not the raw
532
+ // `verify_code`, or `trust` for a requester who cannot complete a code
533
+ // handshake), so the resolved card must reflect the OUTCOME, not the raw
532
534
  // button — otherwise a `reject` that actually parked the contact at
533
535
  // `unverified` would still render "Denied". Other kinds have no such mapping.
534
536
  const cardAction =
535
537
  request.kind === "access_request"
536
- ? introductionOutcomeForAction(effectiveAction)
538
+ ? introductionOutcomeForAction(resolved, effectiveAction)
537
539
  : effectiveAction;
538
540
  void withdrawGuardianRequestCards({
539
541
  request: resolved,