@vellumai/assistant 0.12.3 → 0.12.4-dev.202609231715.8da971c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/Dockerfile +7 -0
  2. package/README.md +12 -12
  3. package/docker/mousepad/90-vellum.gschema.override +4 -0
  4. package/node_modules/@vellumai/avatar-manifest/src/__tests__/notification-avatar.test.ts +48 -4
  5. package/node_modules/@vellumai/avatar-manifest/src/notification-avatar.ts +12 -8
  6. package/openapi.yaml +97 -4
  7. package/package.json +1 -1
  8. package/src/__tests__/approval-routes-http.test.ts +4 -2
  9. package/src/__tests__/call-routes-http.test.ts +4 -2
  10. package/src/__tests__/channel-readiness-discord.test.ts +8 -0
  11. package/src/__tests__/channel-readiness-slack-remote.test.ts +8 -0
  12. package/src/__tests__/config-loader-backfill.test.ts +1 -0
  13. package/src/__tests__/conversation-pairing.test.ts +10 -0
  14. package/src/__tests__/conversation-resurface-done.test.ts +289 -0
  15. package/src/__tests__/default-profile-catalog-fallback.test.ts +1 -0
  16. package/src/__tests__/gemini-provider.test.ts +31 -0
  17. package/src/__tests__/inference-profile-validation-jev.test.ts +17 -0
  18. package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
  19. package/src/__tests__/llm-catalog-parity.test.ts +4 -0
  20. package/src/__tests__/llm-resolver-override-or-default.test.ts +43 -0
  21. package/src/__tests__/openai-responses-prompt-cache.test.ts +3 -1
  22. package/src/__tests__/platform-callback-registration.test.ts +46 -1
  23. package/src/__tests__/plugin-api-model-profiles.test.ts +7 -0
  24. package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
  25. package/src/__tests__/pricing.test.ts +33 -0
  26. package/src/__tests__/provider-error-scenarios.test.ts +46 -0
  27. package/src/__tests__/provider-platform-proxy-integration.test.ts +45 -15
  28. package/src/__tests__/retry-fallback-escalation.test.ts +22 -0
  29. package/src/__tests__/runtime-attachment-metadata.test.ts +4 -2
  30. package/src/__tests__/scaffold-managed-skill-tool.test.ts +116 -66
  31. package/src/__tests__/secret-routes-platform-proxy.test.ts +1 -0
  32. package/src/__tests__/send-endpoint-busy.test.ts +4 -2
  33. package/src/__tests__/skill-load-inline-command.test.ts +35 -0
  34. package/src/__tests__/skill-load-tool.test.ts +42 -11
  35. package/src/__tests__/skill-tool-factory.test.ts +50 -2
  36. package/src/__tests__/steer-on-enqueue-question.test.ts +265 -34
  37. package/src/__tests__/validate-input.test.ts +73 -0
  38. package/src/__tests__/workspace-migration-159-rename-colliding-jev-profile-name.test.ts +197 -0
  39. package/src/api/ask-question-tool.ts +50 -0
  40. package/src/api/events/tool-result.ts +11 -0
  41. package/src/api/index.ts +7 -0
  42. package/src/api/requests/dictation.ts +2 -2
  43. package/src/api/responses/home.ts +27 -0
  44. package/src/avatar/notification-avatar.test.ts +42 -34
  45. package/src/avatar/notification-avatar.ts +1 -0
  46. package/src/calls/__tests__/call-controller.test.ts +18 -0
  47. package/src/calls/__tests__/voice-control-protocol.test.ts +6 -1
  48. package/src/calls/__tests__/voice-leg-coordinator.test.ts +42 -0
  49. package/src/calls/__tests__/voice-session-bridge.test.ts +97 -4
  50. package/src/calls/__tests__/voice-triage-escalate.test.ts +69 -11
  51. package/src/calls/call-controller.ts +3 -1
  52. package/src/calls/voice-control-protocol.ts +9 -4
  53. package/src/calls/voice-escalation-judge.ts +7 -6
  54. package/src/calls/voice-leg-coordinator.ts +15 -4
  55. package/src/calls/voice-screen-annotation.ts +44 -0
  56. package/src/calls/voice-session-bridge.ts +50 -20
  57. package/src/calls/voice-triage-escalate.ts +61 -26
  58. package/src/cli/commands/__tests__/plugins.test.ts +29 -1
  59. package/src/cli/commands/channel-verification-sessions.help.ts +12 -2
  60. package/src/cli/commands/oauth/index.help.ts +8 -2
  61. package/src/cli/commands/oauth/request.test.ts +32 -0
  62. package/src/cli/commands/platform/index.help.ts +2 -1
  63. package/src/cli/commands/platform/index.ts +8 -2
  64. package/src/cli/commands/plugins.ts +16 -0
  65. package/src/cli/lib/__tests__/inspect-plugin.test.ts +29 -0
  66. package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +92 -2
  67. package/src/cli/lib/__tests__/plugin-catalog-local.test.ts +15 -0
  68. package/src/cli/lib/__tests__/plugin-catalog-platform.test.ts +66 -2
  69. package/src/cli/lib/__tests__/plugin-catalog-resolve.test.ts +21 -0
  70. package/src/cli/lib/__tests__/plugin-catalog-visibility.test.ts +65 -0
  71. package/src/cli/lib/__tests__/plugin-details.test.ts +43 -0
  72. package/src/cli/lib/__tests__/plugins-install-offline.test.ts +26 -0
  73. package/src/cli/lib/bundled-marketplace.json +4 -4
  74. package/src/cli/lib/inspect-plugin.ts +5 -0
  75. package/src/cli/lib/plugin-catalog-cache.ts +41 -4
  76. package/src/cli/lib/plugin-catalog-local.ts +9 -0
  77. package/src/cli/lib/plugin-catalog-platform.ts +48 -9
  78. package/src/cli/lib/plugin-catalog-visibility.ts +41 -0
  79. package/src/cli/lib/plugin-details.ts +10 -7
  80. package/src/cli/lib/search-plugins.ts +2 -0
  81. package/src/config/__tests__/default-profile-catalog.test.ts +61 -1
  82. package/src/config/__tests__/jev-managed-profile.test.ts +82 -0
  83. package/src/config/__tests__/platform-identity.test.ts +59 -0
  84. package/src/config/__tests__/sync-gated-profiles.test.ts +71 -0
  85. package/src/config/bundled-skills/screen-annotation/SKILL.md +6 -3
  86. package/src/config/call-site-defaults.ts +17 -11
  87. package/src/config/default-profile-catalog.ts +118 -19
  88. package/src/config/default-profile-names.ts +69 -0
  89. package/src/config/feature-flag-registry.json +25 -9
  90. package/src/config/inference-profile-validation.ts +7 -6
  91. package/src/config/llm-resolver.ts +16 -0
  92. package/src/config/platform-identity.ts +22 -5
  93. package/src/config/profile-text-generation.test.ts +9 -0
  94. package/src/config/schemas/call-site-catalog.ts +8 -1
  95. package/src/config/schemas/llm.ts +70 -9
  96. package/src/config/sidebar-done-gate.ts +27 -0
  97. package/src/config/sync-gated-profiles.ts +96 -44
  98. package/src/daemon/__tests__/auto-profile-router.test.ts +228 -0
  99. package/src/daemon/auto-profile-router.ts +220 -0
  100. package/src/daemon/conversation-agent-loop.ts +77 -4
  101. package/src/daemon/conversation-slash.ts +2 -2
  102. package/src/daemon/conversation-turn-finalize.ts +12 -0
  103. package/src/daemon/dictation-text-processing.ts +4 -4
  104. package/src/daemon/handlers/__tests__/conversation-history-search.test.ts +61 -0
  105. package/src/daemon/handlers/config-channels.ts +3 -1
  106. package/src/daemon/handlers/conversation-history.ts +11 -1
  107. package/src/daemon/handlers/conversations.ts +118 -10
  108. package/src/daemon/pkb-reminder-builder.test.ts +10 -3
  109. package/src/daemon/pkb-reminder-builder.ts +1 -1
  110. package/src/desktop/desktop-browser-endpoint.ts +1 -0
  111. package/src/home/feed-types.ts +2 -0
  112. package/src/inbound/platform-callback-registration.ts +19 -6
  113. package/src/ipc/routes/__tests__/conversation-sync-ipc-routes.test.ts +49 -1
  114. package/src/ipc/routes/conversation-sync-ipc-routes.ts +38 -2
  115. package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +27 -0
  116. package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +37 -1
  117. package/src/live-voice/__tests__/live-voice-vad.test.ts +34 -2
  118. package/src/live-voice/__tests__/protocol.test.ts +22 -0
  119. package/src/live-voice/continuation-judge.ts +1 -1
  120. package/src/live-voice/live-voice-session.ts +17 -14
  121. package/src/live-voice/protocol.ts +16 -5
  122. package/src/messaging/providers/gmail/client.ts +4 -0
  123. package/src/notifications/README.md +11 -3
  124. package/src/notifications/__tests__/assistant-reply-producer.test.ts +13 -0
  125. package/src/notifications/__tests__/home-feed-side-effect.test.ts +87 -3
  126. package/src/notifications/conversation-pairing.ts +23 -8
  127. package/src/notifications/home-feed-mirror.ts +39 -0
  128. package/src/notifications/home-feed-side-effect.ts +46 -19
  129. package/src/oauth/AGENTS.md +9 -1
  130. package/src/oauth/byo-connection.test.ts +28 -0
  131. package/src/permissions/question-prompter.ts +14 -4
  132. package/src/persistence/conversation-crud.ts +116 -3
  133. package/src/persistence/conversation-queries.ts +48 -3
  134. package/src/persistence/conversation-types.ts +6 -2
  135. package/src/persistence/embeddings/__tests__/embedding-local-lifecycle.test.ts +228 -32
  136. package/src/persistence/embeddings/embedding-backend-shutdown.test.ts +47 -0
  137. package/src/persistence/embeddings/embedding-backend.ts +23 -41
  138. package/src/persistence/embeddings/embedding-gemini.test.ts +17 -0
  139. package/src/persistence/embeddings/embedding-gemini.ts +3 -1
  140. package/src/persistence/embeddings/embedding-local.ts +72 -17
  141. package/src/persistence/embeddings/embedding-types.ts +0 -19
  142. package/src/persistence/jobs-store.ts +229 -0
  143. package/src/persistence/migrations/383-normalize-opencode-host-connections.ts +44 -0
  144. package/src/persistence/migrations/__tests__/383-normalize-opencode-host-connections.test.ts +102 -0
  145. package/src/persistence/steps.ts +12 -0
  146. package/src/platform/sync-avatar.test.ts +29 -0
  147. package/src/plugin-api/model-profiles.ts +5 -3
  148. package/src/plugins/defaults/memory/AGENTS.md +5 -3
  149. package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +2 -0
  150. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-boundary-guard.test.ts +45 -0
  151. package/src/plugins/defaults/memory/__tests__/skill-update-receipt-job.test.ts +580 -0
  152. package/src/plugins/defaults/memory/graph/tools.ts +9 -5
  153. package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +4 -0
  154. package/src/plugins/defaults/memory/job-handlers.ts +8 -2
  155. package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +5 -0
  156. package/src/plugins/defaults/memory/skill-update-receipt-job.ts +334 -0
  157. package/src/plugins/defaults/memory/substrate/skill-content.ts +1 -1
  158. package/src/plugins/defaults/memory/tools.test.ts +17 -0
  159. package/src/plugins/defaults/memory/v3/__tests__/render-injection.test.ts +3 -0
  160. package/src/providers/__tests__/connection-model-compat.test.ts +2 -0
  161. package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
  162. package/src/providers/anthropic/client.ts +2 -2
  163. package/src/providers/gemini/client.ts +17 -1
  164. package/src/providers/inference/auth.ts +25 -0
  165. package/src/providers/jev/ask.test.ts +66 -0
  166. package/src/{calls/typesafe-noul.ts → providers/jev/ask.ts} +75 -36
  167. package/src/providers/malformed-tool-call.ts +55 -0
  168. package/src/providers/model-catalog.ts +257 -4
  169. package/src/providers/openai/__tests__/chat-completions-malformed-tool-call.test.ts +105 -0
  170. package/src/providers/openai/chat-completions-provider.ts +30 -0
  171. package/src/providers/openai/codex-models.ts +2 -0
  172. package/src/providers/platform-proxy/constants.ts +5 -0
  173. package/src/providers/retry.ts +68 -36
  174. package/src/providers/search-provider-catalog.ts +10 -0
  175. package/src/providers/vellum-model-routing.test.ts +1 -0
  176. package/src/runtime/__tests__/agent-wake-archived-gate.test.ts +90 -0
  177. package/src/runtime/__tests__/question-resolution.test.ts +32 -0
  178. package/src/runtime/agent-wake.ts +9 -2
  179. package/src/runtime/auth/__tests__/middleware.test.ts +138 -0
  180. package/src/runtime/auth/middleware.ts +15 -11
  181. package/src/runtime/middleware/auth.ts +7 -1
  182. package/src/runtime/pending-interactions.ts +8 -8
  183. package/src/runtime/question-resolution.ts +54 -8
  184. package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +146 -0
  185. package/src/runtime/routes/__tests__/dictation-processing.test.ts +174 -0
  186. package/src/runtime/routes/__tests__/global-search-routes.test.ts +74 -1
  187. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +60 -0
  188. package/src/runtime/routes/__tests__/llm-call-sites-routes.test.ts +16 -1
  189. package/src/runtime/routes/__tests__/oauth-proxy-routes.test.ts +61 -3
  190. package/src/runtime/routes/__tests__/plugins-routes.test.ts +8 -0
  191. package/src/runtime/routes/conversation-list-routes.ts +16 -14
  192. package/src/runtime/routes/conversation-query-routes.ts +4 -0
  193. package/src/runtime/routes/conversation-routes.ts +4 -2
  194. package/src/runtime/routes/diagnostics-routes.ts +66 -229
  195. package/src/runtime/routes/global-search-routes.ts +22 -7
  196. package/src/runtime/routes/inference-provider-connection-routes.ts +25 -8
  197. package/src/runtime/routes/llm-call-sites-routes.ts +19 -10
  198. package/src/runtime/routes/oauth-proxy-passthrough.test.ts +32 -0
  199. package/src/runtime/routes/platform-routes.ts +6 -1
  200. package/src/runtime/routes/plugins-routes.ts +5 -2
  201. package/src/runtime/sync/documents-sidecar-publish.test.ts +50 -4
  202. package/src/runtime/sync/resource-sync-events.ts +11 -0
  203. package/src/runtime/sync/worker-daemon-notify.test.ts +30 -0
  204. package/src/runtime/sync/worker-daemon-notify.ts +44 -0
  205. package/src/runtime/verification-outbound-actions.ts +2 -2
  206. package/src/skills/validate-input.ts +75 -11
  207. package/src/telegram/__tests__/webhook-health.test.ts +8 -0
  208. package/src/tools/ask-question/ask-question-tool.test.ts +38 -0
  209. package/src/tools/ask-question/ask-question-tool.ts +12 -1
  210. package/src/tools/network/__tests__/web-fetch-firecrawl.test.ts +28 -1
  211. package/src/tools/network/__tests__/web-fetch-metadata.test.ts +34 -0
  212. package/src/tools/network/__tests__/web-fetch-tinyfish.test.ts +35 -1
  213. package/src/tools/network/__tests__/web-search.test.ts +96 -0
  214. package/src/tools/network/web-fetch.ts +30 -9
  215. package/src/tools/network/web-search.ts +235 -4
  216. package/src/tools/skills/execute.ts +1 -1
  217. package/src/tools/skills/format-input-schema.ts +15 -0
  218. package/src/tools/skills/load.ts +15 -43
  219. package/src/tools/skills/scaffold-managed.ts +86 -71
  220. package/src/tools/skills/skill-tool-factory.ts +2 -1
  221. package/src/tools/workflows/manage-workflows.ts +4 -2
  222. package/src/util/oauth-request-body.test.ts +5 -1
  223. package/src/util/worker-pipe.test.ts +146 -0
  224. package/src/util/worker-pipe.ts +49 -0
  225. package/src/workspace/migrations/158-repoint-opencode-host-provider-fragments.ts +163 -0
  226. package/src/workspace/migrations/159-rename-colliding-jev-profile-name.ts +344 -0
  227. package/src/workspace/migrations/__tests__/158-repoint-opencode-host-provider-fragments.test.ts +188 -0
  228. package/src/workspace/migrations/registry.ts +4 -0
  229. package/src/runtime/routes/__tests__/dictation-cleanup-guard.test.ts +0 -107
@@ -24,8 +24,10 @@ import {
24
24
  CHATGPT_SUBSCRIPTION_CONNECTION_NAME,
25
25
  type ConnectionModel,
26
26
  ConnectionModelSchema,
27
+ type ConnectionProvider,
27
28
  ConnectionProviderSchema,
28
29
  deriveAuthForProvider,
30
+ normalizeConnectionProvider,
29
31
  ProviderConnectionSchema,
30
32
  PROVIDERS_ALLOWING_CUSTOM_BASE_URL,
31
33
  VALID_CONNECTION_PROVIDERS,
@@ -379,8 +381,15 @@ async function handleCreateConnection({ body = {} }: RouteHandlerArgs) {
379
381
  `Provider "chatgpt" is reserved for the "${CHATGPT_SUBSCRIPTION_CONNECTION_NAME}" connection. Run the ChatGPT sign-in flow to connect a subscription.`,
380
382
  );
381
383
  }
384
+ // Resolved before auth derivation so an opencode.ai endpoint is held to
385
+ // OpenCode's keyed auth rather than the keyless option the generic
386
+ // provider allows.
387
+ const resolvedProvider = normalizeConnectionProvider(
388
+ providerResult.data,
389
+ body.base_url,
390
+ ) as ConnectionProvider;
382
391
  const authResult = AuthSchema.safeParse(
383
- auth ?? deriveConnectionAuth(providerResult.data, body.credential),
392
+ auth ?? deriveConnectionAuth(resolvedProvider, body.credential),
384
393
  );
385
394
  if (!authResult.success) {
386
395
  throw new BadRequestError(`Invalid auth: ${authResult.error.message}`);
@@ -388,7 +397,7 @@ async function handleCreateConnection({ body = {} }: RouteHandlerArgs) {
388
397
  // Asserted on derived auth as well: derivation pairs every provider
389
398
  // correctly except the chatgpt identity, whose fallthrough would mint
390
399
  // api_key auth from a bare credential.
391
- assertAuthMatchesProvider(providerResult.data, authResult.data);
400
+ assertAuthMatchesProvider(resolvedProvider, authResult.data);
392
401
 
393
402
  const labelRaw = body.label;
394
403
  if (
@@ -401,18 +410,15 @@ async function handleCreateConnection({ body = {} }: RouteHandlerArgs) {
401
410
  );
402
411
  }
403
412
 
404
- const customFields = await parseCustomProviderFields(
405
- body,
406
- providerResult.data,
407
- );
413
+ const customFields = await parseCustomProviderFields(body, resolvedProvider);
408
414
 
409
415
  // Same event-loop turn as the write: no await separates this check from
410
416
  // createConnection, so concurrent requests cannot both pass it.
411
- assertValidCustomProviderIdentity(providerResult.data, labelRaw, name);
417
+ assertValidCustomProviderIdentity(resolvedProvider, labelRaw, name);
412
418
 
413
419
  const result = createConnection(getDb(), {
414
420
  name,
415
- provider: providerResult.data,
421
+ provider: resolvedProvider,
416
422
  auth: authResult.data,
417
423
  ...(labelRaw !== undefined ? { label: labelRaw as string | null } : {}),
418
424
  ...customFields,
@@ -525,6 +531,17 @@ async function handleUpdateConnection({
525
531
  );
526
532
  }
527
533
  const customFields = await parseCustomProviderFields(body, existing.provider);
534
+ // Provider is immutable on PATCH, and profiles bound to this row under the
535
+ // legacy `{provider, provider_connection}` shape declare its kind, so the
536
+ // row cannot be repointed at an endpoint that needs a different kind.
537
+ if (
538
+ normalizeConnectionProvider(existing.provider, customFields.baseUrl) !==
539
+ existing.provider
540
+ ) {
541
+ throw new BadRequestError(
542
+ `base_url points at OpenCode, which needs an "opencode" connection. Create a new connection with provider "opencode" instead of repointing "${name}".`,
543
+ );
544
+ }
528
545
 
529
546
  // Only a CHANGED label is validated: keeping a stored label — whatever it
530
547
  // is — must never block unrelated edits (key rotation, models).
@@ -1,14 +1,16 @@
1
1
  import { z } from "zod";
2
2
 
3
- import { CALL_SITE_DEFAULTS } from "../../config/call-site-defaults.js";
4
3
  import { getUserSelectableProfilesForProvider } from "../../config/default-profile-catalog.js";
5
- import { resolveDefaultProfileKey } from "../../config/llm-resolver.js";
4
+ import {
5
+ resolveDefaultProfileKey,
6
+ resolveShippedDefaultProfileKey,
7
+ } from "../../config/llm-resolver.js";
6
8
  import { loadConfig } from "../../config/loader.js";
7
9
  import {
8
10
  CALL_SITE_CATALOG,
9
11
  CALL_SITE_DOMAINS,
10
12
  } from "../../config/schemas/call-site-catalog.js";
11
- import type { LLMCallSite } from "../../config/schemas/llm.js";
13
+ import type { LLMCallSite, LLMConfig } from "../../config/schemas/llm.js";
12
14
  import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
13
15
  import type { RouteDefinition } from "./types.js";
14
16
 
@@ -30,7 +32,8 @@ const callSiteEntrySchema = z.object({
30
32
  * `defaultProfile` would scatter pinned or remapped sites across their
31
33
  * winners. Profileless call sites report `balanced`: the resolver's
32
34
  * fallback anchor consults the balanced remap for them, so they follow
33
- * the Balanced tier like any balanced-keyed site.
35
+ * the Balanced tier like any balanced-keyed site. A managed-only tier is
36
+ * omitted when it has no body under the workspace's default provider.
34
37
  */
35
38
  shippedDefaultProfile: z.string().optional(),
36
39
  });
@@ -40,16 +43,22 @@ const callSiteCatalogResponseSchema = z.object({
40
43
  callSites: z.array(callSiteEntrySchema),
41
44
  });
42
45
 
46
+ export function buildCallSiteCatalog(llm: LLMConfig) {
47
+ return CALL_SITE_CATALOG.map((entry) => ({
48
+ ...entry,
49
+ defaultProfile: resolveDefaultProfileKey(entry.id as LLMCallSite, llm),
50
+ shippedDefaultProfile: resolveShippedDefaultProfileKey(
51
+ entry.id as LLMCallSite,
52
+ llm,
53
+ ),
54
+ }));
55
+ }
56
+
43
57
  async function handleGetCallSites() {
44
58
  const { llm } = loadConfig();
45
59
  return {
46
60
  domains: CALL_SITE_DOMAINS,
47
- callSites: CALL_SITE_CATALOG.map((entry) => ({
48
- ...entry,
49
- defaultProfile: resolveDefaultProfileKey(entry.id as LLMCallSite, llm),
50
- shippedDefaultProfile:
51
- CALL_SITE_DEFAULTS[entry.id]?.profile ?? "balanced",
52
- })),
61
+ callSites: buildCallSiteCatalog(llm),
53
62
  };
54
63
  }
55
64
 
@@ -44,6 +44,38 @@ describe("route constants", () => {
44
44
  expect(url.pathname).toBe(`${PROXY_PATH_PREFIX}stripe_link/v1/items`);
45
45
  expect(extractProxyRemainder(url)).toBe("v1/items");
46
46
  });
47
+
48
+ test("keeps Gmail's /upload/gmail remainder including the query on the raw URL", () => {
49
+ const url = proxyUrl(
50
+ "google/upload/gmail/v1/users/me/drafts?uploadType=media",
51
+ );
52
+
53
+ expect(extractProxyRemainder(url)).toBe(
54
+ "upload/gmail/v1/users/me/drafts",
55
+ );
56
+ expect(url.search).toBe("?uploadType=media");
57
+ expect(normalizeProxyPath("upload/gmail/v1/users/me/drafts")).toBe(
58
+ "/upload/gmail/v1/users/me/drafts",
59
+ );
60
+ });
61
+
62
+ test("the catch-all route pattern matches a multi-segment Gmail upload path", () => {
63
+ const regexSource = PROXY_ROUTE_ENDPOINT.split("/")
64
+ .map((segment) => {
65
+ if (segment.startsWith(":")) {
66
+ return segment.endsWith("*") ? "(.+)" : "([^/]+)";
67
+ }
68
+ return RegExp.escape(segment);
69
+ })
70
+ .join("\\/");
71
+ const regex = new RegExp(`^${regexSource}$`);
72
+ const match = "oauth/proxy/google/upload/gmail/v1/users/me/drafts".match(
73
+ regex,
74
+ );
75
+
76
+ expect(match?.[1]).toBe("google");
77
+ expect(match?.[2]).toBe("upload/gmail/v1/users/me/drafts");
78
+ });
47
79
  });
48
80
 
49
81
  describe("provider segment", () => {
@@ -90,7 +90,12 @@ const PlatformStatusResponseSchema = z.object({
90
90
  isPlatform: z.boolean(),
91
91
  baseUrl: z.string(),
92
92
  assistantId: z.string(),
93
- hasAssistantApiKey: z.boolean(),
93
+ hasAssistantApiKey: z
94
+ .boolean()
95
+ .nullable()
96
+ .describe(
97
+ "Whether a managed assistant API key is stored. Null when the credential store could not be read, which is not evidence that no key is stored.",
98
+ ),
94
99
  hasWebhookSecret: z.boolean(),
95
100
  clientInstallationId: z.string().nullable(),
96
101
  available: z.boolean(),
@@ -48,7 +48,10 @@ import {
48
48
  type InstalledPluginInfo,
49
49
  listInstalledPlugins,
50
50
  } from "../../cli/lib/list-installed-plugins.js";
51
- import { getPluginCatalog } from "../../cli/lib/plugin-catalog-cache.js";
51
+ import {
52
+ getPluginCatalog,
53
+ getPluginCatalogForInstalledMetadata,
54
+ } from "../../cli/lib/plugin-catalog-cache.js";
52
55
  import { resolvePluginSourceFromCatalog } from "../../cli/lib/plugin-catalog-resolve.js";
53
56
  import {
54
57
  DEFAULT_PIN_HISTORY_LIMIT,
@@ -969,7 +972,7 @@ export async function loadCategoryMapBounded(
969
972
  let timer: ReturnType<typeof setTimeout> | undefined;
970
973
  try {
971
974
  const catalog = await Promise.race([
972
- getPluginCatalog(DEFAULT_PLUGIN_REF, {
975
+ getPluginCatalogForInstalledMetadata(DEFAULT_PLUGIN_REF, {
973
976
  fetch: globalThis.fetch.bind(globalThis),
974
977
  }),
975
978
  new Promise<null>((resolve) => {
@@ -1,22 +1,32 @@
1
1
  /**
2
- * A scheduled, heartbeat, or background turn runs its document tools in a
3
- * sidecar worker, whose local hub has no SSE subscriber. The documents-changed
4
- * broadcast has to be handed to the daemon there, or the document edited while
5
- * the user was not looking stays invisible on every client.
2
+ * A scheduled, heartbeat, or background turn runs its document tools and its
3
+ * conversation writes in a sidecar worker, whose local hub has no SSE
4
+ * subscriber. Those broadcasts have to be handed to the daemon there, or the
5
+ * document edited and the conversation changed while the user was not looking
6
+ * stay invisible on every client.
6
7
  */
7
8
 
8
9
  import { beforeEach, describe, expect, mock, test } from "bun:test";
9
10
 
10
11
  let notifyCount = 0;
12
+ const listHandoffs: Array<{ reason: string; conversationIds: string[] }> = [];
11
13
 
12
14
  mock.module("./worker-daemon-notify.js", () => ({
13
15
  NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD:
14
16
  "notify_conversation_persisted_externally",
17
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD:
18
+ "notify_conversation_list_changed_externally",
15
19
  NOTIFY_DOCUMENTS_CHANGED_IPC_METHOD: "notify_documents_changed_externally",
16
20
  NOTIFY_ACTIVATION_PROGRESS_CHANGED_IPC_METHOD:
17
21
  "notify_activation_progress_changed_externally",
18
22
  notifyDaemonActivationProgressChanged: async () => {},
19
23
  notifyDaemonConversationPersisted: async () => {},
24
+ notifyDaemonConversationListChanged: async (
25
+ reason: string,
26
+ conversationIds: string[],
27
+ ) => {
28
+ listHandoffs.push({ reason, conversationIds });
29
+ },
20
30
  notifyDaemonDocumentsChanged: async () => {
21
31
  notifyCount++;
22
32
  },
@@ -30,6 +40,7 @@ import {
30
40
  } from "../assistant-stream-state.js";
31
41
  import {
32
42
  DOCUMENTS_CHANGED_COALESCE_MS,
43
+ publishConversationListAndMetadataChanged,
33
44
  publishDocumentsChanged,
34
45
  } from "./resource-sync-events.js";
35
46
 
@@ -66,6 +77,7 @@ describe("publishDocumentsChanged in a sidecar worker", () => {
66
77
  beforeEach(async () => {
67
78
  await settle();
68
79
  notifyCount = 0;
80
+ listHandoffs.length = 0;
69
81
  _resetStreamStateForTesting();
70
82
  });
71
83
 
@@ -102,3 +114,37 @@ describe("publishDocumentsChanged in a sidecar worker", () => {
102
114
  expect(events[0].message).toMatchObject({ type: "sync_changed" });
103
115
  });
104
116
  });
117
+
118
+ describe("publishConversationListAndMetadataChanged in a sidecar worker", () => {
119
+ beforeEach(async () => {
120
+ await settle();
121
+ listHandoffs.length = 0;
122
+ _resetStreamStateForTesting();
123
+ });
124
+
125
+ test("hands the list invalidation to the daemon instead of publishing into a void", async () => {
126
+ disableStreamSeqStamping();
127
+
128
+ const events = await captureLocalPublishes(() => {
129
+ publishConversationListAndMetadataChanged("reordered", "conv-1");
130
+ });
131
+
132
+ expect(listHandoffs).toEqual([
133
+ { reason: "reordered", conversationIds: ["conv-1"] },
134
+ ]);
135
+ expect(events).toEqual([]);
136
+ });
137
+
138
+ test("publishes on the local hub in the daemon, where subscribers live", async () => {
139
+ const events = await captureLocalPublishes(() => {
140
+ publishConversationListAndMetadataChanged("reordered", "conv-1");
141
+ });
142
+
143
+ expect(listHandoffs).toEqual([]);
144
+ expect(events).toHaveLength(1);
145
+ expect(events[0].message).toMatchObject({
146
+ type: "sync_changed",
147
+ tags: ["conversations:list", "conversation:conv-1:metadata"],
148
+ });
149
+ });
150
+ });
@@ -12,6 +12,7 @@ import { isStreamSeqStampingDisabled } from "../assistant-stream-state.js";
12
12
  import { publishSyncInvalidation } from "./sync-publisher.js";
13
13
  import {
14
14
  notifyDaemonActivationProgressChanged,
15
+ notifyDaemonConversationListChanged,
15
16
  notifyDaemonConversationPersisted,
16
17
  notifyDaemonDocumentsChanged,
17
18
  } from "./worker-daemon-notify.js";
@@ -236,6 +237,16 @@ export function publishConversationListAndMetadataChanged(
236
237
  ? conversationIds
237
238
  : [conversationIds];
238
239
 
240
+ // In a sidecar worker the local hub has no SSE subscribers, so a publish
241
+ // here reaches nobody and the sidebar keeps showing a list the worker has
242
+ // already changed. Hand off to the daemon, which republishes on the hub
243
+ // clients actually subscribe to. A background worker turn has no
244
+ // originating client, so no `originClientId` is forwarded.
245
+ if (isStreamSeqStampingDisabled()) {
246
+ void notifyDaemonConversationListChanged(reason, ids);
247
+ return;
248
+ }
249
+
239
250
  // Shape-changing reasons (`created`, `deleted`, `reordered`) add or
240
251
  // remove rows or change the order of the paginated window — web must
241
252
  // refetch the list, so include the `conversationsList` umbrella tag.
@@ -33,13 +33,43 @@ mock.module("../../ipc/cli-client.js", () => ({
33
33
 
34
34
  import {
35
35
  NOTIFY_ACTIVATION_PROGRESS_CHANGED_IPC_METHOD,
36
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD,
36
37
  NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD,
37
38
  NOTIFY_DOCUMENTS_CHANGED_IPC_METHOD,
38
39
  notifyDaemonActivationProgressChanged,
40
+ notifyDaemonConversationListChanged,
39
41
  notifyDaemonConversationPersisted,
40
42
  notifyDaemonDocumentsChanged,
41
43
  } from "./worker-daemon-notify.js";
42
44
 
45
+ describe("notifyDaemonConversationListChanged", () => {
46
+ beforeEach(() => {
47
+ calls.length = 0;
48
+ nextResult = { ok: true };
49
+ shouldThrow = false;
50
+ });
51
+
52
+ test("hands the reason and ids to the daemon over the shared IPC method", async () => {
53
+ await notifyDaemonConversationListChanged("reordered", ["conv-1"]);
54
+
55
+ expect(calls).toHaveLength(1);
56
+ expect(calls[0]!.method).toBe(NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD);
57
+ expect(calls[0]!.params).toEqual({
58
+ body: { reason: "reordered", conversationIds: ["conv-1"] },
59
+ });
60
+ });
61
+
62
+ test("swallows a thrown IPC error (best-effort, no throw)", async () => {
63
+ shouldThrow = true;
64
+
65
+ const result = await notifyDaemonConversationListChanged("reordered", [
66
+ "conv-1",
67
+ ]);
68
+ expect(result).toBeUndefined();
69
+ expect(calls).toHaveLength(1);
70
+ });
71
+ });
72
+
43
73
  describe("notifyDaemonConversationPersisted", () => {
44
74
  beforeEach(() => {
45
75
  calls.length = 0;
@@ -31,6 +31,14 @@ export const NOTIFY_CONVERSATION_PERSISTED_IPC_METHOD =
31
31
  export const NOTIFY_DOCUMENTS_CHANGED_IPC_METHOD =
32
32
  "notify_documents_changed_externally";
33
33
 
34
+ /**
35
+ * IPC method the daemon exposes for the conversation-list hand-off. Shared by
36
+ * the worker caller and the daemon route registration so the wire name cannot
37
+ * drift.
38
+ */
39
+ export const NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD =
40
+ "notify_conversation_list_changed_externally";
41
+
34
42
  /**
35
43
  * IPC method the daemon exposes for the activation-progress hand-off. Shared
36
44
  * by the worker caller and the daemon route registration so the wire name
@@ -79,6 +87,42 @@ export async function notifyDaemonConversationPersisted(
79
87
  }
80
88
  }
81
89
 
90
+ /**
91
+ * Ask the daemon to republish a conversation-list-and-metadata invalidation.
92
+ *
93
+ * A worker turn can change which rows the sidebar should hold, not just what
94
+ * one row contains: clearing `archived_at` on a Done conversation the turn
95
+ * woke is the case that matters. The list tag has to reach real subscribers
96
+ * for the conversation to reappear, and the worker's own hub has none.
97
+ *
98
+ * Best-effort by design, like the other hand-offs: an unreachable daemon is
99
+ * logged at debug and swallowed, and the client picks the change up on its
100
+ * next list fetch.
101
+ */
102
+ export async function notifyDaemonConversationListChanged(
103
+ reason: string,
104
+ conversationIds: string[],
105
+ ): Promise<void> {
106
+ try {
107
+ const result = await cliIpcCall(
108
+ NOTIFY_CONVERSATION_LIST_CHANGED_IPC_METHOD,
109
+ { body: { reason, conversationIds } },
110
+ { timeoutMs: NOTIFY_TIMEOUT_MS },
111
+ );
112
+ if (!result.ok) {
113
+ log.debug(
114
+ { reason, conversationIds, error: result.error },
115
+ "daemon conversation-list-changed notify was not acknowledged",
116
+ );
117
+ }
118
+ } catch (err) {
119
+ log.debug(
120
+ { err, reason, conversationIds },
121
+ "daemon conversation-list-changed notify failed",
122
+ );
123
+ }
124
+ }
125
+
82
126
  /**
83
127
  * Ask the daemon to republish the documents-list invalidation.
84
128
  *
@@ -278,7 +278,7 @@ async function startOutboundTelegram(
278
278
  success: false,
279
279
  error: "already_bound",
280
280
  message:
281
- "A guardian is already bound for this channel. Set rebind: true to replace.",
281
+ "A guardian is already bound for this channel. To verify a different account, revoke the existing binding first. Set rebind: true only to verify the same account again.",
282
282
  channel,
283
283
  };
284
284
  }
@@ -820,7 +820,7 @@ async function startOutboundTextChannel(
820
820
  success: false,
821
821
  error: "already_bound",
822
822
  message:
823
- "A guardian is already bound for this channel. Set rebind: true to replace.",
823
+ "A guardian is already bound for this channel. To verify a different account, revoke the existing binding first. Set rebind: true only to verify the same account again.",
824
824
  channel,
825
825
  };
826
826
  }
@@ -3,10 +3,11 @@
3
3
  *
4
4
  * Deliberate strict subset of JSON Schema: it covers only the keywords
5
5
  * actually used by `assistant/src/config/bundled-skills/**\/TOOLS.json`
6
- * (required / type / enum / items.type) plus unknown-key detection. Anything
7
- * else (`$ref`, `oneOf`, `anyOf`, `allOf`, `format`, `pattern`, `minimum`,
8
- * `maximum`, object-shape `additionalProperties`, etc.) is silently skipped so
9
- * a richer schema can never cause us to reject a legitimate call.
6
+ * (required / type / enum / nested properties and items / required-only oneOf)
7
+ * plus unknown-key detection. Anything else (`$ref`, richer `oneOf`, `anyOf`,
8
+ * `allOf`, `format`, `pattern`, `minimum`, `maximum`, object-shape
9
+ * `additionalProperties`, etc.) is skipped. Nested objects allow extra keys
10
+ * unless their schema explicitly closes them.
10
11
  *
11
12
  * Each error message is written to be agent-readable and self-correcting
12
13
  * (e.g. `surface_id is required`, `mode must be one of "replace", "append"`).
@@ -313,6 +314,15 @@ export function validateInputAgainstSchema(
313
314
  _toolName: string,
314
315
  input: Record<string, unknown>,
315
316
  schema: Record<string, unknown> | undefined,
317
+ ): InputValidationResult {
318
+ return validateObjectInput(input, schema, "", true);
319
+ }
320
+
321
+ function validateObjectInput(
322
+ input: Record<string, unknown>,
323
+ schema: Record<string, unknown> | undefined,
324
+ path: string,
325
+ rejectUnknown: boolean,
316
326
  ): InputValidationResult {
317
327
  // Skip when there's no schema or no properties block — matches today's
318
328
  // lenient behaviour for tools that declare only `{ type: "object" }`.
@@ -338,17 +348,46 @@ export function validateInputAgainstSchema(
338
348
  continue;
339
349
  }
340
350
  if (!(key in input)) {
341
- errors.push(`${key} is required`);
351
+ errors.push(`${path}${key} is required`);
342
352
  }
343
353
  }
344
354
  }
345
355
 
356
+ // Only enforce alternatives whose complete contract is field presence.
357
+ // Richer unions stay permissive because unsupported keywords can decide
358
+ // which branch matches.
359
+ const alternatives = schema.oneOf;
360
+ if (
361
+ Array.isArray(alternatives) &&
362
+ alternatives.length > 0 &&
363
+ alternatives.every(
364
+ (branch) =>
365
+ isPlainObject(branch) &&
366
+ Object.keys(branch).every(
367
+ (key) => key === "required" || key === "description",
368
+ ) &&
369
+ Array.isArray(branch.required) &&
370
+ branch.required.every((key: unknown) => typeof key === "string"),
371
+ )
372
+ ) {
373
+ const choices = alternatives as { required: string[] }[];
374
+ if (
375
+ choices.filter((branch) => branch.required.every((key) => key in input))
376
+ .length !== 1
377
+ ) {
378
+ errors.push(
379
+ `${path ? path.slice(0, -1) : "input"} must match exactly one required field set: ${choices.map((branch) => quoteList(branch.required)).join(" or ")}`,
380
+ );
381
+ }
382
+ }
383
+
346
384
  // 2. Per-property checks: type, enum, items.type.
347
- for (const [key, rawSubSchema] of Object.entries(properties)) {
348
- if (!(key in input)) {
385
+ for (const [property, rawSubSchema] of Object.entries(properties)) {
386
+ if (!(property in input)) {
349
387
  continue;
350
388
  }
351
- const value = input[key];
389
+ const key = `${path}${property}`;
390
+ const value = input[property];
352
391
  // Skip type-checking for absent values; presence is enforced by the
353
392
  // `required` check above. Note: `null` IS a present value and is
354
393
  // type-checked below — only schemas that explicitly opt in to null via
@@ -381,13 +420,25 @@ export function validateInputAgainstSchema(
381
420
  if (!matchesType(value, type)) {
382
421
  errors.push(
383
422
  type === "boolean" && typeof value === "string"
384
- ? `${key} must be a boolean — pass true or false as a JSON boolean, not a string`
423
+ ? `${key} must be a boolean: pass true or false as a JSON boolean, not a string`
385
424
  : `${key} must be ${typeArticle(type)} ${type}`,
386
425
  );
387
426
  // No point checking enum/items if the base type is wrong.
388
427
  continue;
389
428
  }
390
429
 
430
+ if (type === "object" && isPlainObject(value)) {
431
+ const nested = validateObjectInput(
432
+ value,
433
+ rawSubSchema,
434
+ `${key}.`,
435
+ rawSubSchema.additionalProperties === false,
436
+ );
437
+ if (!nested.ok) {
438
+ errors.push(...nested.errors);
439
+ }
440
+ }
441
+
391
442
  // 2a. Enum (string enums are the only shape used today).
392
443
  const enumValues = rawSubSchema.enum;
393
444
  if (Array.isArray(enumValues) && enumValues.length > 0) {
@@ -412,6 +463,17 @@ export function validateInputAgainstSchema(
412
463
  errors.push(
413
464
  `${key}[${index}] must be ${typeArticle(itemTypeName)} ${itemTypeName}`,
414
465
  );
466
+ } else if (itemTypeName === "object" && isPlainObject(element)) {
467
+ const itemSchema = rawSubSchema.items as Record<string, unknown>;
468
+ const nested = validateObjectInput(
469
+ element,
470
+ itemSchema,
471
+ `${key}[${index}].`,
472
+ itemSchema.additionalProperties === false,
473
+ );
474
+ if (!nested.ok) {
475
+ errors.push(...nested.errors);
476
+ }
415
477
  }
416
478
  });
417
479
  }
@@ -420,10 +482,12 @@ export function validateInputAgainstSchema(
420
482
  }
421
483
 
422
484
  // 3. Unknown keys — parity with the previous `validateNoUnknownParams`.
423
- const unknownKeys = Object.keys(input).filter((k) => !knownKeySet.has(k));
485
+ const unknownKeys = rejectUnknown
486
+ ? Object.keys(input).filter((k) => !knownKeySet.has(k))
487
+ : [];
424
488
  for (const key of unknownKeys) {
425
489
  errors.push(
426
- `Unknown parameter "${key}". Supported: ${quoteList(knownKeys)}`,
490
+ `Unknown parameter "${path}${key}". Supported: ${quoteList(knownKeys)}`,
427
491
  );
428
492
  }
429
493
 
@@ -29,8 +29,16 @@ let emitFails = false;
29
29
 
30
30
  // ── Module mocks ──────────────────────────────────────────────────────
31
31
 
32
+ // Spread the real module: mocks are shared across files in a combined run,
33
+ // and a wholesale replacement drops the exports peer modules import.
34
+ const actualSecureKeys = await import("../../security/secure-keys.js");
32
35
  mock.module("../../security/secure-keys.js", () => ({
36
+ ...actualSecureKeys,
33
37
  getSecureKeyAsync: async (account: string) => secureKeyValues.get(account),
38
+ getSecureKeyResultAsync: async (account: string) => ({
39
+ value: secureKeyValues.get(account),
40
+ unreachable: false,
41
+ }),
34
42
  }));
35
43
 
36
44
  mock.module("../../security/credential-key.js", () => ({
@@ -200,6 +200,44 @@ describe("AskQuestionTool.execute", () => {
200
200
  expect(result.isError).toBe(false);
201
201
  });
202
202
 
203
+ test("says so when the user answered in the chat instead of the card", async () => {
204
+ const q2 = {
205
+ question: "Preferred time?",
206
+ options: [
207
+ { id: "morning", label: "Morning" },
208
+ { id: "afternoon", label: "Afternoon" },
209
+ ],
210
+ };
211
+ setNextResult({
212
+ entries: [
213
+ {
214
+ questionId: "q1",
215
+ decision: "free_text",
216
+ text: "banana, after lunch",
217
+ },
218
+ { questionId: "q2", decision: "skipped" },
219
+ ],
220
+ overall: "completed",
221
+ answeredInChat: true,
222
+ });
223
+
224
+ const result = await askQuestionTool.execute(
225
+ { questions: [singleQ, q2] },
226
+ makeContext(),
227
+ );
228
+
229
+ expect(result.isError).toBe(false);
230
+ const lines = String(result.content).split("\n");
231
+ // The model is told where the answer came from, then reads the batch: the
232
+ // typed text on the first question, the rest unanswered, so it can map the
233
+ // reply onto them itself.
234
+ expect(lines[0]).toContain("replied in the chat");
235
+ expect(lines.slice(1)).toEqual([
236
+ `Question "${singleQ.question}" → Free text: banana, after lunch`,
237
+ `Question "${q2.question}" → Skipped`,
238
+ ]);
239
+ });
240
+
203
241
  test("formats skipped result", async () => {
204
242
  setNextResult(singleCompleted({ decision: "skipped" }));
205
243
  const result = await askQuestionTool.execute(validInput, makeContext());