@vellumai/assistant 0.10.10-dev.202607211337.6d2617c → 0.10.10-dev.202607211519.4a4e758

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 (85) hide show
  1. package/openapi.yaml +3 -1
  2. package/package.json +1 -1
  3. package/scripts/generate-openapi.ts +21 -110
  4. package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +7 -0
  5. package/src/__tests__/cli-memory-v2-reembed-skills.test.ts +1 -1
  6. package/src/__tests__/estimator-calibration.test.ts +26 -0
  7. package/src/__tests__/injector-pkb-v2-silenced.test.ts +37 -7
  8. package/src/__tests__/injector-v3-suppression.test.ts +7 -0
  9. package/src/__tests__/lifecycle-memory-v2-seed.test.ts +8 -4
  10. package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
  11. package/src/__tests__/voice-config-update.test.ts +92 -1
  12. package/src/cli/commands/__tests__/tts.test.ts +121 -1
  13. package/src/cli/commands/memory/index.help.ts +5 -5
  14. package/src/cli/commands/memory/memory-v2.ts +1 -1
  15. package/src/cli/commands/memory/memory-v3.ts +2 -2
  16. package/src/cli/commands/tts.help.ts +33 -0
  17. package/src/cli/commands/tts.ts +80 -0
  18. package/src/cli/lib/__tests__/upgrade-plugin.test.ts +44 -6
  19. package/src/cli/lib/upgrade-plugin.ts +45 -13
  20. package/src/config/bundled-skills/settings/TOOLS.json +3 -3
  21. package/src/config/bundled-skills/settings/tools/voice-config-update.ts +42 -14
  22. package/src/config/memory-v3-gate.test.ts +40 -0
  23. package/src/config/memory-v3-gate.ts +39 -0
  24. package/src/context/estimator-calibration.ts +9 -2
  25. package/src/daemon/conversation-lifecycle.ts +7 -6
  26. package/src/daemon/tool-side-effects.ts +13 -0
  27. package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +1 -1
  28. package/src/live-voice/__tests__/live-voice-connection.test.ts +271 -0
  29. package/src/live-voice/live-voice-connection.ts +225 -0
  30. package/src/live-voice/live-voice-manager.ts +53 -0
  31. package/src/live-voice/live-voice-session-manager.ts +1 -0
  32. package/src/permissions/checker.test.ts +7 -0
  33. package/src/plugin-api/index.ts +15 -0
  34. package/src/plugins/AGENTS.md +1 -2
  35. package/src/plugins/defaults/main.ts +34 -0
  36. package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +7 -0
  37. package/src/plugins/defaults/memory/context-search/sources/memory.ts +2 -1
  38. package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +23 -39
  39. package/src/plugins/defaults/memory/graph/graph-search.ts +6 -5
  40. package/src/plugins/defaults/memory/graph/retriever.ts +6 -5
  41. package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +28 -5
  42. package/src/plugins/defaults/memory/graph/tool-handlers.ts +24 -56
  43. package/src/plugins/defaults/memory/graph/tools.ts +13 -14
  44. package/src/plugins/defaults/memory/indexer.ts +22 -21
  45. package/src/plugins/defaults/memory/injectors.ts +14 -9
  46. package/src/plugins/defaults/memory/job-handler-registration.ts +5 -5
  47. package/src/plugins/defaults/memory/job-handlers.ts +4 -3
  48. package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +7 -6
  49. package/src/plugins/defaults/memory/jobs-worker.ts +42 -36
  50. package/src/plugins/defaults/memory/pkb/pkb-search.ts +5 -4
  51. package/src/plugins/defaults/memory/search/semantic.ts +6 -4
  52. package/src/plugins/defaults/memory/{routes → src}/memory-item-routes.ts +6 -5
  53. package/src/plugins/defaults/memory/{routes → src}/memory-v2-routes.ts +10 -8
  54. package/src/plugins/defaults/memory/startup.ts +14 -12
  55. package/src/plugins/defaults/memory/tools.test.ts +29 -55
  56. package/src/plugins/defaults/memory/tools.ts +8 -7
  57. package/src/plugins/defaults/memory/v2/__tests__/consolidation-job.test.ts +7 -0
  58. package/src/plugins/defaults/memory/v2/consolidation-job.ts +7 -4
  59. package/src/plugins/defaults/memory/v2/frontmatter-sweep.ts +4 -3
  60. package/src/plugins/defaults/memory/v2/memory-v2-startup.test.ts +7 -0
  61. package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +6 -5
  62. package/src/plugins/defaults/memory/v2/static-context.ts +5 -4
  63. package/src/plugins/defaults/memory/v2/sweep-job.ts +6 -5
  64. package/src/plugins/defaults/memory/v3/__tests__/maintain-job.test.ts +7 -0
  65. package/src/providers/openai/__tests__/chat-completions-provider-reasoning.test.ts +39 -0
  66. package/src/providers/openai/chat-completions-provider.ts +7 -1
  67. package/src/runtime/http-server.ts +35 -182
  68. package/src/runtime/routes/__tests__/default-plugin-routes.test.ts +72 -8
  69. package/src/runtime/routes/__tests__/route-tags-guard.test.ts +26 -0
  70. package/src/runtime/routes/consolidation-routes.ts +11 -12
  71. package/src/runtime/routes/content-source-routes.ts +1 -0
  72. package/src/runtime/routes/filing-routes.ts +5 -2
  73. package/src/runtime/routes/index.ts +6 -6
  74. package/src/runtime/routes/sanity-routes.ts +2 -0
  75. package/src/runtime/routes/user-route-resolution.ts +46 -13
  76. package/src/tts/__tests__/tts-voice-field.test.ts +45 -0
  77. package/src/tts/tts-voice-field.ts +67 -0
  78. /package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-v2-routes.test.ts +0 -0
  79. /package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-v2-simulate-route.test.ts +0 -0
  80. /package/src/plugins/defaults/memory/{routes → src}/__tests__/memory-worker-routes.test.ts +0 -0
  81. /package/src/plugins/defaults/memory/{routes → src}/memory-eval-routes.ts +0 -0
  82. /package/src/plugins/defaults/memory/{routes → src}/memory-graph-routes.ts +0 -0
  83. /package/src/plugins/defaults/memory/{routes → src}/memory-item-routes.test.ts +0 -0
  84. /package/src/plugins/defaults/memory/{routes → src}/memory-v3-routes.ts +0 -0
  85. /package/src/plugins/defaults/memory/{routes → src}/memory-worker-routes.ts +0 -0
package/openapi.yaml CHANGED
@@ -17703,7 +17703,9 @@ paths:
17703
17703
  post:
17704
17704
  operationId: memory_v2_reembedskills_post
17705
17705
  summary: Re-seed v2 skill entries from the current skill catalog
17706
- description: Synchronously re-runs seedV2SkillEntries against the current skill catalog. Gated on config.memory.v2.enabled.
17706
+ description:
17707
+ Synchronously re-runs seedV2SkillEntries against the current skill catalog. Gated on concept-page memory
17708
+ being active.
17707
17709
  tags:
17708
17710
  - memory
17709
17711
  requestBody:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.10-dev.202607211337.6d2617c",
3
+ "version": "0.10.10-dev.202607211519.4a4e758",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -4,8 +4,8 @@
4
4
  * HTTP route definitions.
5
5
  *
6
6
  * Pipeline:
7
- * 1. Programmatically import every route module under src/runtime/routes/
8
- * and collect all exported ROUTES arrays — no regex, no source-text parsing.
7
+ * 1. Import the assembled `ROUTES` table from src/runtime/routes/index.ts —
8
+ * the same single source of truth the HTTP and IPC servers serve.
9
9
  * 2. Combine with pre-auth / non-v1 routes.
10
10
  * 3. Convert to OpenAPI path items.
11
11
  * 4. Write to openapi.yaml.
@@ -16,8 +16,8 @@
16
16
  * cd assistant && bun run generate:openapi -- --check # CI: fail if stale
17
17
  */
18
18
 
19
- import { existsSync, readFileSync } from "node:fs";
20
- import { readdir, readFile, writeFile } from "node:fs/promises";
19
+ import { readFileSync } from "node:fs";
20
+ import { readFile, writeFile } from "node:fs/promises";
21
21
  import { join, resolve } from "node:path";
22
22
 
23
23
  import { stringify } from "yaml";
@@ -30,6 +30,7 @@ import type {
30
30
  } from "zod-openapi";
31
31
  import { createDocument } from "zod-openapi";
32
32
 
33
+ import { ROUTES } from "../src/runtime/routes/index.js";
33
34
  import { jsonValueSchema } from "../src/telemetry/telemetry-wire.generated.js";
34
35
 
35
36
  // The recursive wire JSON-value schema (`claims`/`suggestions` item type) must
@@ -39,8 +40,6 @@ import { jsonValueSchema } from "../src/telemetry/telemetry-wire.generated.js";
39
40
  z.globalRegistry.add(jsonValueSchema, { id: "TelemetryJsonValue" });
40
41
 
41
42
  const ROOT = resolve(import.meta.dir, "..");
42
- const ROUTES_DIR = join(ROOT, "src/runtime/routes");
43
- const PLUGIN_DEFAULTS_DIR = join(ROOT, "src/plugins/defaults");
44
43
  const OUTPUT_PATH = join(ROOT, "openapi.yaml");
45
44
  const PKG_PATH = join(ROOT, "package.json");
46
45
 
@@ -120,8 +119,6 @@ const RouteEntrySchema = z.object({
120
119
  additionalResponses: z
121
120
  .record(z.string(), RouteAdditionalResponseSchema)
122
121
  .optional(),
123
- /** Source module filename, used for auto-deriving tags. */
124
- sourceModule: z.string().optional(),
125
122
  });
126
123
 
127
124
  type RouteEntry = z.infer<typeof RouteEntrySchema>;
@@ -156,93 +153,23 @@ function resolveSchemaForDocument(schemaSource: unknown): ContentSchema {
156
153
  // ---------------------------------------------------------------------------
157
154
 
158
155
  /**
159
- * Directories holding `RouteDefinition` modules: the host `runtime/routes`
160
- * tree plus every default plugin's `routes/` subdirectory. A default plugin
161
- * that owns model-facing HTTP/IPC routes defines them under
162
- * `plugins/defaults/<plugin>/routes/` and the host route aggregator registers
163
- * them at runtime; the generator scans those dirs too so the spec stays
164
- * complete no matter which package a route lives in. Sorted for reproducible
165
- * output (see {@link collectRoutesFromModules}).
156
+ * Collect the OpenAPI-relevant fields of every route from the assembled
157
+ * `runtime/routes/index.ts` `ROUTES` table — the same single source of truth
158
+ * the HTTP and IPC servers serve. Each `RouteDefinition` is parsed through
159
+ * {@link RouteEntrySchema}, which keeps only the documentable fields (method,
160
+ * endpoint, summary, tags, request/response bodies, …) and drops the runtime
161
+ * ones (handler, policy). Routes that omit `tags` are surfaced without a tag —
162
+ * a lint-style guard test asserts every route sets one, so the spec never
163
+ * loses grouping.
166
164
  */
167
- async function routeModuleDirs(): Promise<string[]> {
168
- const dirs = [ROUTES_DIR];
169
- for (const entry of await readdir(PLUGIN_DEFAULTS_DIR, {
170
- withFileTypes: true,
171
- })) {
172
- if (!entry.isDirectory()) continue;
173
- const routesDir = join(PLUGIN_DEFAULTS_DIR, entry.name, "routes");
174
- if (existsSync(routesDir)) dirs.push(routesDir);
175
- }
176
- return dirs.sort();
177
- }
178
-
179
- /**
180
- * Dynamically import every route module under each {@link routeModuleDirs}
181
- * entry and collect all exported `ROUTES` / `*_ROUTES` arrays. Each route
182
- * module exports a `RouteDefinition[]`; new modules are picked up without
183
- * manual updates.
184
- */
185
- async function collectRoutesFromModules(): Promise<RouteEntry[]> {
165
+ function collectRoutes(): RouteEntry[] {
186
166
  const routes: RouteEntry[] = [];
187
-
188
- for (const dir of await routeModuleDirs()) {
189
- // Skip the `index.ts` barrel: it re-exports every other route module's
190
- // ROUTES into a single combined array, so importing it would double-count
191
- // every entry. The duplicate `method:endpoint` keys are deduped later by
192
- // first-seen, but the surviving entry's `sourceModule` (used to derive
193
- // OpenAPI `tags`) depends on `readdir` order — which is filesystem
194
- // dependent and diverges between local sandbox and the CI runner, making
195
- // the generator non-reproducible. Sort the file list as well so directory
196
- // entry order can never affect the output.
197
- const files = (await readdir(dir, { recursive: true }))
198
- .filter(
199
- (f) =>
200
- typeof f === "string" &&
201
- f.endsWith(".ts") &&
202
- !f.endsWith(".test.ts") &&
203
- !f.endsWith(".benchmark.test.ts") &&
204
- !f.includes("node_modules") &&
205
- f !== "index.ts" &&
206
- !f.endsWith("/index.ts"),
207
- )
208
- .sort();
209
-
210
- for (const file of files) {
211
- const filePath = join(dir, file);
212
- let mod: Record<string, unknown>;
213
- try {
214
- mod = (await import(filePath)) as Record<string, unknown>;
215
- } catch (err) {
216
- console.warn(
217
- `Warning: could not import ${file}: ${err instanceof Error ? err.message : err}`,
218
- );
219
- continue;
220
- }
221
-
222
- // Collect every export whose name is `ROUTES` or ends in `_ROUTES`.
223
- // A handful of route files (e.g. `channel-route-definitions.ts`,
224
- // `contact-prompt-routes.ts`) export under domain-prefixed names like
225
- // `CHANNEL_ROUTES` and `CONTACT_PROMPT_ROUTES` rather than the
226
- // canonical `ROUTES`. Without this fan-out the only way those routes
227
- // reached the spec was via the `index.ts` barrel — which is excluded
228
- // above for reproducibility.
229
- const exportNames = Object.keys(mod)
230
- .filter((k) => k === "ROUTES" || k.endsWith("_ROUTES"))
231
- .sort();
232
- for (const name of exportNames) {
233
- const arr = mod[name];
234
- if (!Array.isArray(arr)) continue;
235
- for (const raw of arr) {
236
- const result = RouteEntrySchema.safeParse({
237
- ...(typeof raw === "object" && raw !== null ? raw : {}),
238
- sourceModule: file,
239
- });
240
- if (result.success) routes.push(result.data);
241
- }
242
- }
167
+ for (const raw of ROUTES) {
168
+ const result = RouteEntrySchema.safeParse(raw);
169
+ if (result.success) {
170
+ routes.push(result.data);
243
171
  }
244
172
  }
245
-
246
173
  return routes;
247
174
  }
248
175
 
@@ -388,14 +315,6 @@ function resolveBodyContent(body: unknown): {
388
315
  return { contentType: "application/json", schemaSource: body };
389
316
  }
390
317
 
391
- /** Derive a tag name from a route module filename (e.g. "secret-routes.ts" → "secrets"). */
392
- function deriveTagFromModule(filename: string): string {
393
- // Strip directory prefix and extension
394
- const base = filename.replace(/^.*[\/]/, "").replace(/\.ts$/, "");
395
- // Remove trailing "-routes" suffix
396
- return base.replace(/-routes$/, "");
397
- }
398
-
399
318
  function buildSpec(
400
319
  routes: RouteEntry[],
401
320
  version: string,
@@ -498,13 +417,8 @@ function buildSpec(
498
417
  }
499
418
  }
500
419
 
501
- // Determine tags: explicit tags > auto-derived from source module
502
420
  const tags: string[] | undefined =
503
- entry.tags && entry.tags.length > 0
504
- ? entry.tags
505
- : entry.sourceModule
506
- ? [deriveTagFromModule(entry.sourceModule)]
507
- : undefined;
421
+ entry.tags && entry.tags.length > 0 ? entry.tags : undefined;
508
422
 
509
423
  // Build the operation. Default success status is 200; async endpoints
510
424
  // that enqueue a job and return immediately set responseStatus: "202"
@@ -606,11 +520,8 @@ async function main() {
606
520
  };
607
521
  const version = pkg.version;
608
522
 
609
- // Collect routes programmatically from route modules
610
- const moduleRoutes = await collectRoutesFromModules();
611
-
612
- // Combine all route sources
613
- const allRoutes: RouteEntry[] = moduleRoutes;
523
+ // Collect routes from the assembled shared route table
524
+ const allRoutes: RouteEntry[] = collectRoutes();
614
525
 
615
526
  // Build the spec
616
527
  const spec = buildSpec(allRoutes, version);
@@ -18,6 +18,13 @@ import { afterEach, describe, expect, mock, test } from "bun:test";
18
18
  let memoryV3LiveSlot = false;
19
19
  mock.module("../config/memory-v3-gate.js", () => ({
20
20
  isMemoryV3Live: () => memoryV3LiveSlot,
21
+ usesConceptPageMemory: (memory?: {
22
+ enabled?: boolean;
23
+ v2?: { enabled?: boolean };
24
+ v3?: { live?: boolean };
25
+ }) =>
26
+ memory?.enabled !== false &&
27
+ (memory?.v3?.live === true || memory?.v2?.enabled === true),
21
28
  }));
22
29
 
23
30
  import { AgentLoop } from "../agent/loop.js";
@@ -56,7 +56,7 @@ const { memoryHelp } = await import("../cli/commands/memory/index.help.js");
56
56
  const { registerMemoryV2Command } =
57
57
  await import("../cli/commands/memory/memory-v2.js");
58
58
  const { ROUTES: memoryV2Routes, MEMORY_V2_DISABLED_CODE } =
59
- await import("../plugins/defaults/memory/routes/memory-v2-routes.js");
59
+ await import("../plugins/defaults/memory/src/memory-v2-routes.js");
60
60
  const { RouteError } = await import("../runtime/routes/errors.js");
61
61
 
62
62
  // ---------------------------------------------------------------------------
@@ -197,6 +197,32 @@ describe("estimator calibration", () => {
197
197
  expect(getCorrection("anthropic", "claude-opus-4-7")).toBeCloseTo(1.2, 1);
198
198
  });
199
199
 
200
+ test("an undefined model is tolerated and folded into the per-provider aggregate", () => {
201
+ // Some OpenAI-compatible providers (opencode/OpenRouter) omit `model` in
202
+ // their usage report, so `recordEstimate` can be called with a runtime
203
+ // undefined despite the static `string` type. It must not throw — an
204
+ // unhandled rejection here crashes the whole assistant process — and the
205
+ // sample should still land on the per-provider aggregate key.
206
+ expect(() =>
207
+ recordEstimate(
208
+ "openrouter",
209
+ undefined as unknown as string,
210
+ 100_000,
211
+ 120_000,
212
+ ),
213
+ ).not.toThrow();
214
+ expect(getCorrection("openrouter", "")).toBeCloseTo(1.2, 5);
215
+
216
+ // Exactly one sample landed on the aggregate — the undefined-model path
217
+ // must not double-count into a specific key.
218
+ const snap = getCalibrationSnapshot().filter(
219
+ (e) => e.provider === "openrouter",
220
+ );
221
+ expect(snap).toHaveLength(1);
222
+ expect(snap[0].model).toBe("");
223
+ expect(snap[0].samples).toBe(1);
224
+ });
225
+
200
226
  test("explicit empty-model recording does not double-count the aggregate", () => {
201
227
  // When a caller passes an empty model string (degenerate case), the
202
228
  // aggregate update path must not run — otherwise the sample would be
@@ -18,24 +18,32 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
18
18
 
19
19
  import { setConfig } from "./helpers/set-config.js";
20
20
 
21
- let v2Active = false;
21
+ let memoryState: {
22
+ enabled?: boolean;
23
+ v2: { enabled: boolean };
24
+ v3?: { live?: boolean };
25
+ } = { v2: { enabled: false } };
22
26
 
23
27
  /**
24
- * Flip the v2 gate: seeds the workspace config for real (covering any
25
- * loader-based readers) and drives the mocked plugin accessor below.
28
+ * Set the memory gate state: seeds the workspace config for real (covering
29
+ * any loader-based readers) and drives the mocked plugin accessor below.
26
30
  */
27
- function setV2Active(enabled: boolean): void {
28
- v2Active = enabled;
31
+ function setMemoryState(state: typeof memoryState): void {
32
+ memoryState = state;
29
33
  setConfig("memory", {
30
- v2: { enabled },
34
+ ...state,
31
35
  retrieval: { scratchpadInjection: { enabled: true } },
32
36
  });
33
37
  }
34
38
 
39
+ function setV2Active(enabled: boolean): void {
40
+ setMemoryState({ v2: { enabled } });
41
+ }
42
+
35
43
  // The PKB silencing gate reads the plugin's own config accessor.
36
44
  mock.module("../plugins/defaults/memory/config.js", () => ({
37
45
  getMemoryConfig: () => ({
38
- v2: { enabled: v2Active },
46
+ ...memoryState,
39
47
  retrieval: { scratchpadInjection: { enabled: true } },
40
48
  }),
41
49
  }));
@@ -124,4 +132,26 @@ describe("PKB injector v2 cutover behavior", () => {
124
132
  expect(texts.some((t) => t.includes("<NOW.md"))).toBe(true);
125
133
  expect(texts).toContain("What next?");
126
134
  });
135
+
136
+ test("v3 live with the v2 flag off → pkb-context and pkb-reminder silenced", async () => {
137
+ setMemoryState({ v2: { enabled: false }, v3: { live: true } });
138
+ const result = await applyRuntimeInjections(RUN_MESSAGES, {
139
+ ...makeTurnContext(),
140
+ });
141
+
142
+ const texts = tailTexts(result.messages);
143
+ expect(texts.some((t) => t.includes("<knowledge_base>"))).toBe(false);
144
+ expect(texts.some((t) => t.includes("<system_reminder>"))).toBe(false);
145
+ });
146
+
147
+ test("memory disabled → pkb-context and pkb-reminder stay silenced even with no engine active", async () => {
148
+ setMemoryState({ enabled: false, v2: { enabled: false } });
149
+ const result = await applyRuntimeInjections(RUN_MESSAGES, {
150
+ ...makeTurnContext(),
151
+ });
152
+
153
+ const texts = tailTexts(result.messages);
154
+ expect(texts.some((t) => t.includes("<knowledge_base>"))).toBe(false);
155
+ expect(texts.some((t) => t.includes("<system_reminder>"))).toBe(false);
156
+ });
127
157
  });
@@ -63,6 +63,13 @@ let memoryV3LiveSlot = false;
63
63
  mock.module("../config/memory-v3-gate.js", () => ({
64
64
  isMemoryV3Live: () => memoryV3LiveSlot,
65
65
  isProcToSkillsActive: () => false,
66
+ usesConceptPageMemory: (memory?: {
67
+ enabled?: boolean;
68
+ v2?: { enabled?: boolean };
69
+ v3?: { live?: boolean };
70
+ }) =>
71
+ memory?.enabled !== false &&
72
+ (memory?.v3?.live === true || memory?.v2?.enabled === true),
66
73
  }));
67
74
 
68
75
  const { applyRuntimeInjections } =
@@ -158,17 +158,21 @@ function makeConfig(v2Enabled: boolean): AssistantConfig {
158
158
  }
159
159
 
160
160
  /**
161
- * Drain all microtasks so any `void`-prefixed promise inside
161
+ * Drain all pending async work so any `void`-prefixed promise inside
162
162
  * `maybeSeedMemoryV2Skills` settles before the test asserts. The fire-and-
163
163
  * forget chain involves: dynamic-import settle → `.then` callback →
164
- * inner `seedV2SkillEntries` resolution → `.catch` settle. We yield
165
- * generously to cover that whole chain regardless of the bundler's task
166
- * scheduling.
164
+ * inner `seedV2SkillEntries` resolution → `.catch` settle. Dynamic-import
165
+ * settlement can take a macrotask (not just microtasks), so yield through
166
+ * a timer with microtask drains on both sides.
167
167
  */
168
168
  async function flushMicrotasks(): Promise<void> {
169
169
  for (let i = 0; i < 10; i++) {
170
170
  await Promise.resolve();
171
171
  }
172
+ await new Promise((resolve) => setTimeout(resolve, 0));
173
+ for (let i = 0; i < 10; i++) {
174
+ await Promise.resolve();
175
+ }
172
176
  }
173
177
 
174
178
  // ---------------------------------------------------------------------------
@@ -79,6 +79,7 @@ const BASELINE: Record<string, readonly string[]> = {
79
79
  "../../../util/logger.js",
80
80
  ],
81
81
  memory: [
82
+ "../../../../../config/memory-v3-gate.js",
82
83
  "../../../../../config/types.js",
83
84
  "../../../../../messaging/providers/slack/message-metadata.js",
84
85
  "../../../../../persistence/auto-analysis-constants.js",
@@ -203,7 +203,7 @@ describe("voice_config_update — tts_voice_id", () => {
203
203
  expect((config.elevenlabs as any)?.voiceId).toBeUndefined();
204
204
  });
205
205
 
206
- test("rejects non-alphanumeric voice ID", async () => {
206
+ test("rejects non-alphanumeric voice ID when provider is elevenlabs", async () => {
207
207
  const result = await run(
208
208
  { setting: "tts_voice_id", value: "abc-123!" },
209
209
  makeContext(),
@@ -214,6 +214,97 @@ describe("voice_config_update — tts_voice_id", () => {
214
214
  });
215
215
  });
216
216
 
217
+ // ---------------------------------------------------------------------------
218
+ // Tests: tts_voice_id targets the active provider's voice field
219
+ // ---------------------------------------------------------------------------
220
+
221
+ describe("voice_config_update — tts_voice_id (managed/vellum active)", () => {
222
+ function makeVellumActive(): void {
223
+ writeConfig({ services: { tts: { provider: "vellum" } } });
224
+ invalidateConfigCache();
225
+ }
226
+
227
+ test("writes a Deepgram Aura model id to services.tts.providers.vellum.model", async () => {
228
+ makeVellumActive();
229
+
230
+ const result = await run(
231
+ { setting: "tts_voice_id", value: "aura-2-zeus-en" },
232
+ makeContext(),
233
+ );
234
+
235
+ expect(result.isError).toBe(false);
236
+ const config = readConfig();
237
+ expect((config.services as any)?.tts?.providers?.vellum?.model).toBe(
238
+ "aura-2-zeus-en",
239
+ );
240
+ // The ElevenLabs field is never touched when vellum is active.
241
+ expect(
242
+ (config.services as any)?.tts?.providers?.elevenlabs?.voiceId,
243
+ ).toBeUndefined();
244
+ });
245
+
246
+ test("accepts an ElevenLabs voice id as a managed model (managed serves ElevenLabs voices)", async () => {
247
+ makeVellumActive();
248
+
249
+ const result = await run(
250
+ { setting: "tts_voice_id", value: "EXAVITQu4vr4xnSDxMaL" },
251
+ makeContext(),
252
+ );
253
+
254
+ expect(result.isError).toBe(false);
255
+ expect((readConfig().services as any)?.tts?.providers?.vellum?.model).toBe(
256
+ "EXAVITQu4vr4xnSDxMaL",
257
+ );
258
+ });
259
+
260
+ test("does not broadcast the ElevenLabs ttsVoiceId key for a managed voice", async () => {
261
+ makeVellumActive();
262
+ const messages: any[] = [];
263
+ const ctx = makeContext({
264
+ sendToClient: (msg: any) => messages.push(msg),
265
+ });
266
+
267
+ const result = await run(
268
+ { setting: "tts_voice_id", value: "aura-2-zeus-en" },
269
+ ctx,
270
+ );
271
+
272
+ expect(result.isError).toBe(false);
273
+ expect(messages).toHaveLength(0);
274
+ expect(result.content).not.toContain("broadcast");
275
+ });
276
+
277
+ test("rejects a value with characters invalid for any voice id", async () => {
278
+ makeVellumActive();
279
+
280
+ const result = await run(
281
+ { setting: "tts_voice_id", value: "a british man" },
282
+ makeContext(),
283
+ );
284
+
285
+ expect(result.isError).toBe(true);
286
+ expect((readConfig().services as any)?.tts?.providers?.vellum?.model).toBe(
287
+ undefined,
288
+ );
289
+ });
290
+
291
+ test("broadcasts the ElevenLabs ttsVoiceId key when elevenlabs is active", async () => {
292
+ writeConfig({ services: { tts: { provider: "elevenlabs" } } });
293
+ invalidateConfigCache();
294
+ const messages: any[] = [];
295
+ const ctx = makeContext({
296
+ sendToClient: (msg: any) => messages.push(msg),
297
+ });
298
+
299
+ const result = await run({ setting: "tts_voice_id", value: "abc123" }, ctx);
300
+
301
+ expect(result.isError).toBe(false);
302
+ expect(messages).toHaveLength(1);
303
+ expect(messages[0].key).toBe("ttsVoiceId");
304
+ expect(messages[0].value).toBe("abc123");
305
+ });
306
+ });
307
+
217
308
  // ---------------------------------------------------------------------------
218
309
  // Tests: fish_audio_reference_id persists to canonical path only
219
310
  // ---------------------------------------------------------------------------
@@ -21,12 +21,21 @@ import { Command } from "commander";
21
21
  /** The last `cliIpcCall` invocation captured for assertions. */
22
22
  let lastIpcCall: { method: string; params?: any } | null = null;
23
23
 
24
+ /** Every `cliIpcCall` invocation in order (the `voice` command makes two). */
25
+ let ipcCalls: Array<{ method: string; params?: any }> = [];
26
+
24
27
  /** The result that cliIpcCall will return. */
25
28
  let mockIpcResult: { ok: boolean; result?: unknown; error?: string } = {
26
29
  ok: true,
27
30
  result: { audioBase64: "dGVzdA==", contentType: "audio/mpeg" },
28
31
  };
29
32
 
33
+ /** Optional per-method result overrides (falls back to `mockIpcResult`). */
34
+ let ipcResponders: Record<
35
+ string,
36
+ { ok: boolean; result?: unknown; error?: string }
37
+ > = {};
38
+
30
39
  /** Captured writeFileSync calls. */
31
40
  let writeFileCalls: Array<{ path: string; data: Buffer }> = [];
32
41
 
@@ -40,7 +49,8 @@ let stdinReturnsText = false;
40
49
  mock.module("../../../ipc/cli-client.js", () => ({
41
50
  cliIpcCall: async (method: string, params?: any) => {
42
51
  lastIpcCall = { method, params };
43
- return mockIpcResult;
52
+ ipcCalls.push({ method, params });
53
+ return ipcResponders[method] ?? mockIpcResult;
44
54
  },
45
55
  exitFromIpcResult: (r: any) => {
46
56
  process.exitCode = 1;
@@ -156,6 +166,8 @@ async function runCommand(
156
166
 
157
167
  beforeEach(() => {
158
168
  lastIpcCall = null;
169
+ ipcCalls = [];
170
+ ipcResponders = {};
159
171
  mockIpcResult = {
160
172
  ok: true,
161
173
  result: { audioBase64: "dGVzdA==", contentType: "audio/mpeg" },
@@ -326,3 +338,111 @@ describe("tts synthesize — base64 round-trip", () => {
326
338
  );
327
339
  });
328
340
  });
341
+
342
+ // ---------------------------------------------------------------------------
343
+ // voice — routes to the active provider's config key
344
+ // ---------------------------------------------------------------------------
345
+
346
+ describe("tts voice — active-provider routing", () => {
347
+ function respondProvider(provider: string): void {
348
+ ipcResponders.config_get = {
349
+ ok: true,
350
+ result: { services: { tts: { provider } } },
351
+ };
352
+ ipcResponders.config_set = { ok: true, result: {} };
353
+ }
354
+
355
+ test("managed (vellum) writes to services.tts.providers.vellum.model", async () => {
356
+ respondProvider("vellum");
357
+
358
+ const { exitCode } = await runCommand(["tts", "voice", "aura-2-zeus-en"]);
359
+
360
+ expect(exitCode).toBe(0);
361
+ const setCall = ipcCalls.find((c) => c.method === "config_set");
362
+ expect(setCall).toBeDefined();
363
+ expect(setCall!.params.body.path).toBe(
364
+ "services.tts.providers.vellum.model",
365
+ );
366
+ expect(setCall!.params.body.value).toBe("aura-2-zeus-en");
367
+ });
368
+
369
+ test("an ElevenLabs voice id on a managed assistant still writes vellum.model", async () => {
370
+ respondProvider("vellum");
371
+
372
+ const { exitCode } = await runCommand([
373
+ "tts",
374
+ "voice",
375
+ "pqHfZKP75CvOlQylNhV4",
376
+ ]);
377
+
378
+ expect(exitCode).toBe(0);
379
+ const setCall = ipcCalls.find((c) => c.method === "config_set");
380
+ expect(setCall!.params.body.path).toBe(
381
+ "services.tts.providers.vellum.model",
382
+ );
383
+ });
384
+
385
+ test("elevenlabs writes to services.tts.providers.elevenlabs.voiceId", async () => {
386
+ respondProvider("elevenlabs");
387
+
388
+ const { exitCode } = await runCommand(["tts", "voice", "abc123"]);
389
+
390
+ expect(exitCode).toBe(0);
391
+ const setCall = ipcCalls.find((c) => c.method === "config_set");
392
+ expect(setCall!.params.body.path).toBe(
393
+ "services.tts.providers.elevenlabs.voiceId",
394
+ );
395
+ });
396
+
397
+ test("defaults to elevenlabs when no provider is configured", async () => {
398
+ ipcResponders.config_get = { ok: true, result: {} };
399
+ ipcResponders.config_set = { ok: true, result: {} };
400
+
401
+ const { exitCode } = await runCommand(["tts", "voice", "abc123"]);
402
+
403
+ expect(exitCode).toBe(0);
404
+ const setCall = ipcCalls.find((c) => c.method === "config_set");
405
+ expect(setCall!.params.body.path).toBe(
406
+ "services.tts.providers.elevenlabs.voiceId",
407
+ );
408
+ });
409
+
410
+ test("no voice id exits code 1 without touching config", async () => {
411
+ respondProvider("vellum");
412
+
413
+ const { exitCode } = await runCommand(["tts", "voice"]);
414
+
415
+ expect(exitCode).toBe(1);
416
+ expect(ipcCalls.find((c) => c.method === "config_set")).toBeUndefined();
417
+ });
418
+
419
+ test("--json emits the provider and path it wrote", async () => {
420
+ respondProvider("vellum");
421
+
422
+ const { exitCode, stdout } = await runCommand([
423
+ "tts",
424
+ "voice",
425
+ "aura-2-luna-en",
426
+ "--json",
427
+ ]);
428
+
429
+ expect(exitCode).toBe(0);
430
+ const parsed = JSON.parse(stdout.trim());
431
+ expect(parsed.ok).toBe(true);
432
+ expect(parsed.provider).toBe("vellum");
433
+ expect(parsed.path).toBe("services.tts.providers.vellum.model");
434
+ expect(parsed.voiceId).toBe("aura-2-luna-en");
435
+ });
436
+
437
+ test("a config_set failure sets a non-zero exit code", async () => {
438
+ ipcResponders.config_get = {
439
+ ok: true,
440
+ result: { services: { tts: { provider: "vellum" } } },
441
+ };
442
+ ipcResponders.config_set = { ok: false, error: "daemon error" };
443
+
444
+ const { exitCode } = await runCommand(["tts", "voice", "aura-2-zeus-en"]);
445
+
446
+ expect(exitCode).not.toBe(0);
447
+ });
448
+ });