@vellumai/assistant 0.11.3-dev.202608172108.14b9345 → 0.11.3-dev.202608172253.65bf2a2

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 (55) hide show
  1. package/ARCHITECTURE.md +2 -0
  2. package/docs/architecture/memory.md +15 -0
  3. package/docs/flux-turn-detection-spike.md +11 -6
  4. package/openapi.yaml +132 -0
  5. package/package.json +1 -1
  6. package/src/__tests__/media-generate-image.test.ts +131 -21
  7. package/src/__tests__/memory-retrieval-hook.test.ts +94 -2
  8. package/src/__tests__/plugin-api-webhook-url.test.ts +10 -7
  9. package/src/__tests__/run-due-schedules.test.ts +21 -0
  10. package/src/__tests__/schedule-routes.test.ts +23 -0
  11. package/src/__tests__/schedule-store.test.ts +17 -0
  12. package/src/calls/__tests__/voice-session-bridge.test.ts +9 -0
  13. package/src/calls/__tests__/voice-triage-escalate.test.ts +8 -0
  14. package/src/calls/voice-session-bridge.ts +11 -3
  15. package/src/calls/voice-triage-escalate.ts +1 -0
  16. package/src/cli/commands/schedules.ts +35 -1
  17. package/src/cli/lib/bundled-marketplace.json +1 -1
  18. package/src/config/bundled-skills/image-studio/SKILL.md +5 -4
  19. package/src/config/bundled-skills/image-studio/TOOLS.json +1 -1
  20. package/src/config/bundled-skills/image-studio/tools/media-generate-image.ts +101 -0
  21. package/src/config/call-site-defaults.ts +7 -0
  22. package/src/config/feature-flag-registry.json +2 -2
  23. package/src/daemon/conversation-agent-loop.ts +3 -0
  24. package/src/daemon/conversation.ts +2 -0
  25. package/src/hooks/types.ts +5 -0
  26. package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +118 -0
  27. package/src/live-voice/live-voice-session.ts +63 -9
  28. package/src/persistence/conversation-queries.ts +66 -16
  29. package/src/plugin-api/constants.ts +8 -0
  30. package/src/plugin-api/index.ts +5 -1
  31. package/src/plugin-api/webhook-url.ts +13 -11
  32. package/src/plugins/defaults/memory/graph/__tests__/conversation-graph-memory-v2-routing.test.ts +77 -0
  33. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +24 -6
  34. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +53 -5
  35. package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +18 -0
  36. package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +66 -1
  37. package/src/plugins/defaults/memory/v3/injector.ts +8 -0
  38. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +23 -9
  39. package/src/plugins/mtime-cache.ts +17 -0
  40. package/src/providers/__tests__/context-overflow-error.test.ts +24 -0
  41. package/src/providers/__tests__/retry-callsite.test.ts +20 -0
  42. package/src/providers/openai/chat-completions-provider.ts +11 -1
  43. package/src/providers/speech-to-text/__tests__/deepgram-flux-realtime.test.ts +11 -6
  44. package/src/providers/speech-to-text/deepgram-flux-realtime.ts +9 -49
  45. package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +133 -0
  46. package/src/runtime/routes/__tests__/schedule-routes-disarm-reason.test.ts +215 -0
  47. package/src/runtime/routes/conversation-list-routes.ts +52 -21
  48. package/src/runtime/routes/schedule-routes.ts +94 -7
  49. package/src/schedule/__tests__/plugin-schedule-declarations.test.ts +68 -5
  50. package/src/schedule/__tests__/plugin-schedule-reconciler.test.ts +81 -0
  51. package/src/schedule/plugin-schedule-availability.ts +58 -0
  52. package/src/schedule/plugin-schedule-declarations.ts +23 -27
  53. package/src/schedule/plugin-schedule-reconciler.ts +12 -3
  54. package/src/schedule/schedule-store.ts +5 -1
  55. package/src/schedule/scheduler.ts +9 -4
package/ARCHITECTURE.md CHANGED
@@ -709,6 +709,8 @@ Live voice STT uses the same `resolveStreamingTranscriber()` path as conversatio
709
709
 
710
710
  Live voice TTS uses `streamLiveVoiceTtsAudio()` and the configured `services.tts.provider`. The selected provider must be registered, catalog-compatible, and expose `capabilities.supportsStreaming` plus `synthesizeStream()`. Providers whose catalog entry advertises `supportsStreaming` (currently all four catalog providers: ElevenLabs, Fish Audio, Deepgram, and xAI) satisfy this requirement; a buffered-only provider would remain available for buffered message playback or other supported surfaces, but live voice reports a TTS error instead of silently falling back to buffered playback.
711
711
 
712
+ The `voiceFrontDoor` prompt skips current-turn legacy and v3 memory retrieval, while prior frozen memory cards and static memory context remain available. The front-door rule escalates rather than guessing when required personal context is absent. The escalated leg runs the ordinary memory pipeline against the latest visible caller prompt before the quality model, with low selector effort. This keeps memory work off the front-door TTFT path without cross-leg speculative state.
713
+
712
714
  V1 is local/gateway-scoped. Managed/cloud WebSocket proxy support, cross-region routing, and p50/p95 latency guarantees are out of scope for this version. Metrics frames expose timing data for measurement, but the architecture does not promise a hard latency SLO.
713
715
 
714
716
  **Client service-first boundary:**
@@ -172,6 +172,21 @@ Ingested pages carry provenance frontmatter with distinct consumers:
172
172
  machinery (graph extraction, summarization, PKB indexing/filing, PKB
173
173
  injection) is suppressed while the substrate is active.
174
174
 
175
+ #### Live voice front-door memory
176
+
177
+ The live voice front door does not await current-turn memory retrieval. Its
178
+ prompt hook skips legacy graph retrieval, and both v3 injectors skip
179
+ orchestration for `voiceFrontDoor`. Frozen cards from prior turns and the static
180
+ substrate context remain available. When the answer depends on a saved personal
181
+ fact that is absent from that context, the front-door rule escalates instead of
182
+ guessing.
183
+
184
+ The escalated leg runs the ordinary memory pipeline before the quality model.
185
+ V3 retrieval routes on the latest visible caller message, ignoring the hidden
186
+ continuation message used to start that leg. The selector uses low effort to
187
+ keep retrieval latency bounded. This keeps current-turn memory work off the
188
+ front-door TTFT path without maintaining speculative cross-leg state.
189
+
175
190
  ### Boot-time maintenance
176
191
 
177
192
  `substrate/boot-maintenance.ts`, invoked from the memory plugin's
@@ -12,7 +12,7 @@ Flux is a spike. `liveVoice.flux.turnEnd.enabled` defaults to `false`, the exist
12
12
 
13
13
  It is stamped in `releaseUtterance` (`live-voice-session.ts`), which every committed turn passes through whichever decider released it, from the same speech-stop anchor on both. So the two arms are one population measured over one span. It is absent only on a turn that never committed, and in push-to-talk, which this spike does not run.
14
14
 
15
- It is also the only endpoint number that the Flux socket teardown stays out of: `releaseUtterance` stamps it before it stops the transcriber. `roundTripMs`, `llmFirstDeltaMs`, and `totalMs` all carry that teardown on a Flux arm, and so does what the caller hears. Read "The per-turn socket teardown, and why it is load-bearing" in section 3 before you compare any of those three against a `deepgram` run.
15
+ It is also the only endpoint number that a Flux socket teardown stays out of: `releaseUtterance` stamps it before any stop. On a turn Flux itself closed there is no teardown to carry; on a caller-side release `roundTripMs`, `llmFirstDeltaMs`, and `totalMs` still carry one, and so does what the caller hears. Read "The socket teardown, and when it is load-bearing" in section 3 before you compare any of those three against a `deepgram` run.
16
16
 
17
17
  ### Why the other endpoint fields are not the comparison
18
18
 
@@ -105,18 +105,23 @@ The rest of `liveVoice.flux` is optional and defaulted (`config/schemas/live-voi
105
105
 
106
106
  Say the same scripted set of utterances in both arms. Include at least a few deliberate mid-sentence thinking pauses, because that is the case the hold path exists for and the case Flux has to not regress.
107
107
 
108
- ### The per-turn socket teardown, and why it is load-bearing
108
+ ### The socket teardown, and when it is load-bearing
109
109
 
110
110
  The Flux adapter implements no `finalizeUtterance`. That is forced by Flux's wire protocol, not a statement that Flux owns the turn boundary, and adding the method as a no-op would break transcript correctness.
111
111
 
112
112
  `parseFluxFrame` emits `final` only on `EndOfTurn`, and that is the adapter's sole source of `final`. Flux offers no mid-stream flush, so `CloseStream` is the only message that makes it answer for a turn still in progress, which is exactly what `stop()` sends. A no-op `finalizeUtterance` would report `finalized` without flushing anything, so a turn released on a caller-side boundary would dispatch on an empty transcript while its real text arrived afterwards and was dropped as a late final segment. With `turnEnd.enabled` at its default `false` that is every turn, because the release always comes from the local silence path. With the latch on it is still every fail-open fallback, every max-duration force-end, and every barge-in, all of which release with a Flux turn open.
113
113
 
114
- So the release path is: `stop()` sends `CloseStream`, the adapter waits for Deepgram's close frame under a `CLOSE_GRACE_MS` ceiling (**5000ms**, `deepgram-flux-realtime.ts`), and then emits `closed`. The cycle only reaches `transcriber_closed` on that `closed` event, and `startAssistantTurnIfReady` refuses to dispatch before it. Two consequences for the numbers:
114
+ That reasoning holds for a turn the **caller** releases, and only for those. A turn Flux itself closes needs no flush at all: `EndOfTurn` emits the `final` immediately before `turn-end`, so the transcript is already complete when the release runs, and the stream can stay open (JARVIS-1538). The session reflects that split:
115
115
 
116
- - **`endpointCommitLatencyMs` does not contain the teardown.** `releaseUtterance` stamps the commit latency and `utteranceEndAtMs` before it calls `stop()`, so the headline comparison is clean on both arms.
117
- - **`roundTripMs`, `llmFirstDeltaMs`, and `totalMs` do contain it,** and so does the silence the caller sits through. On a Flux arm the assistant turn cannot start until the socket has closed. A `deepgram` run pays none of that: the shared stream stays open and the cycle reaches `transcriber_closed` on the `finalized` event instead.
116
+ - **Provider-closed turns seal in place.** `handleProviderTurnEnd` marks the cycle `providerClosedTurn`, and the release moves it straight to `transcriber_closed` without stopping the transcriber. The stream serves the whole session, and `rearmAfterTurn` re-arms onto it synchronously.
117
+ - **Caller-side releases still close it.** The fail-open deadline, a max-duration force-end, and barge-in all release with a Flux turn potentially still open, and `CloseStream` remains the only message that makes Flux answer for one. Those releases retire the shared stream and tear it down; the next arm dials a fresh one.
118
118
 
119
- The re-dial is off the end-of-turn path but is not free either. `rearmAfterTurn` opens the next `/v2/listen` socket once the assistant turn finishes, and speech arriving during that handshake is held in the VAD pre-roll buffer, so its cost lands on the next utterance's first partial rather than on its commit.
119
+ Consequences for the numbers, all now specific to the caller-side path:
120
+
121
+ - **`endpointCommitLatencyMs` never contains a teardown.** `releaseUtterance` stamps the commit latency and `utteranceEndAtMs` before any stop, so the headline comparison is clean on both arms.
122
+ - **`roundTripMs`, `llmFirstDeltaMs`, and `totalMs` contain it only when the caller released the turn,** which with the latch on means the exceptional paths rather than every turn.
123
+
124
+ Before JARVIS-1538 every utterance dialed its own socket, and the audio arriving during that handshake was lost rather than replayed from the VAD pre-roll buffer. The opening words of each turn after the first went missing ("How many days are in February?" transcribed as "many days are in February?"). A persistent stream removes the handshake, and with it the gap.
120
125
 
121
126
  ### What this A/B still does not hold constant
122
127
 
package/openapi.yaml CHANGED
@@ -6596,6 +6596,18 @@ paths:
6596
6596
  "system:all" for conversations in no group, "system:pinned" for the Pinned section, or a custom group id. A
6597
6597
  group-scoped request is recency-ordered like every list read (COALESCE(last_message_at, updated_at)
6598
6598
  descending) and never has pinned rows appended to it. Omit to span every group.
6599
+ - name: needsAttention
6600
+ in: query
6601
+ required: false
6602
+ schema:
6603
+ type: string
6604
+ enum:
6605
+ - "true"
6606
+ description:
6607
+ 'Pass "true" to return only conversations whose latest assistant message the user has not seen: the same
6608
+ predicate behind the unread count and the section index, so a client that keeps no complete conversation
6609
+ list can ask for exactly the rows its attention surfaces need. Composes with every other filter. Any value
6610
+ other than "true" is rejected. Omit to span every conversation.'
6599
6611
  responses:
6600
6612
  "200":
6601
6613
  description: Successful response
@@ -25778,6 +25790,20 @@ paths:
25778
25790
  description:
25779
25791
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
25780
25792
  applies. Always null for user-created schedules.
25793
+ disarmReason:
25794
+ anyOf:
25795
+ - type: string
25796
+ enum:
25797
+ - user_disabled
25798
+ - plugin_removed
25799
+ - plugin_disabled
25800
+ - declaration_removed
25801
+ - declaration_disabled
25802
+ - type: "null"
25803
+ description:
25804
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
25805
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
25806
+ is on, and always null for user-created schedules."
25781
25807
  isOneShot:
25782
25808
  type: boolean
25783
25809
  isDeferred:
@@ -25814,6 +25840,7 @@ paths:
25814
25840
  - workflowName
25815
25841
  - sourceKey
25816
25842
  - userEnabled
25843
+ - disarmReason
25817
25844
  - isOneShot
25818
25845
  - isDeferred
25819
25846
  additionalProperties: false
@@ -26011,6 +26038,20 @@ paths:
26011
26038
  description:
26012
26039
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26013
26040
  applies. Always null for user-created schedules.
26041
+ disarmReason:
26042
+ anyOf:
26043
+ - type: string
26044
+ enum:
26045
+ - user_disabled
26046
+ - plugin_removed
26047
+ - plugin_disabled
26048
+ - declaration_removed
26049
+ - declaration_disabled
26050
+ - type: "null"
26051
+ description:
26052
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
26053
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
26054
+ is on, and always null for user-created schedules."
26014
26055
  isOneShot:
26015
26056
  type: boolean
26016
26057
  isDeferred:
@@ -26047,6 +26088,7 @@ paths:
26047
26088
  - workflowName
26048
26089
  - sourceKey
26049
26090
  - userEnabled
26091
+ - disarmReason
26050
26092
  - isOneShot
26051
26093
  - isDeferred
26052
26094
  additionalProperties: false
@@ -26196,6 +26238,20 @@ paths:
26196
26238
  description:
26197
26239
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26198
26240
  applies. Always null for user-created schedules.
26241
+ disarmReason:
26242
+ anyOf:
26243
+ - type: string
26244
+ enum:
26245
+ - user_disabled
26246
+ - plugin_removed
26247
+ - plugin_disabled
26248
+ - declaration_removed
26249
+ - declaration_disabled
26250
+ - type: "null"
26251
+ description:
26252
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
26253
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
26254
+ is on, and always null for user-created schedules."
26199
26255
  isOneShot:
26200
26256
  type: boolean
26201
26257
  isDeferred:
@@ -26232,6 +26288,7 @@ paths:
26232
26288
  - workflowName
26233
26289
  - sourceKey
26234
26290
  - userEnabled
26291
+ - disarmReason
26235
26292
  - isOneShot
26236
26293
  - isDeferred
26237
26294
  additionalProperties: false
@@ -26378,6 +26435,20 @@ paths:
26378
26435
  description:
26379
26436
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26380
26437
  applies. Always null for user-created schedules.
26438
+ disarmReason:
26439
+ anyOf:
26440
+ - type: string
26441
+ enum:
26442
+ - user_disabled
26443
+ - plugin_removed
26444
+ - plugin_disabled
26445
+ - declaration_removed
26446
+ - declaration_disabled
26447
+ - type: "null"
26448
+ description:
26449
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
26450
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
26451
+ is on, and always null for user-created schedules."
26381
26452
  isOneShot:
26382
26453
  type: boolean
26383
26454
  isDeferred:
@@ -26414,6 +26485,7 @@ paths:
26414
26485
  - workflowName
26415
26486
  - sourceKey
26416
26487
  - userEnabled
26488
+ - disarmReason
26417
26489
  - isOneShot
26418
26490
  - isDeferred
26419
26491
  additionalProperties: false
@@ -26620,6 +26692,20 @@ paths:
26620
26692
  description:
26621
26693
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26622
26694
  applies. Always null for user-created schedules.
26695
+ disarmReason:
26696
+ anyOf:
26697
+ - type: string
26698
+ enum:
26699
+ - user_disabled
26700
+ - plugin_removed
26701
+ - plugin_disabled
26702
+ - declaration_removed
26703
+ - declaration_disabled
26704
+ - type: "null"
26705
+ description:
26706
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
26707
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
26708
+ is on, and always null for user-created schedules."
26623
26709
  isOneShot:
26624
26710
  type: boolean
26625
26711
  isDeferred:
@@ -26656,6 +26742,7 @@ paths:
26656
26742
  - workflowName
26657
26743
  - sourceKey
26658
26744
  - userEnabled
26745
+ - disarmReason
26659
26746
  - isOneShot
26660
26747
  - isDeferred
26661
26748
  additionalProperties: false
@@ -26805,6 +26892,20 @@ paths:
26805
26892
  description:
26806
26893
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26807
26894
  applies. Always null for user-created schedules.
26895
+ disarmReason:
26896
+ anyOf:
26897
+ - type: string
26898
+ enum:
26899
+ - user_disabled
26900
+ - plugin_removed
26901
+ - plugin_disabled
26902
+ - declaration_removed
26903
+ - declaration_disabled
26904
+ - type: "null"
26905
+ description:
26906
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
26907
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
26908
+ is on, and always null for user-created schedules."
26808
26909
  isOneShot:
26809
26910
  type: boolean
26810
26911
  isDeferred:
@@ -26841,6 +26942,7 @@ paths:
26841
26942
  - workflowName
26842
26943
  - sourceKey
26843
26944
  - userEnabled
26945
+ - disarmReason
26844
26946
  - isOneShot
26845
26947
  - isDeferred
26846
26948
  additionalProperties: false
@@ -26992,6 +27094,20 @@ paths:
26992
27094
  description:
26993
27095
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
26994
27096
  applies. Always null for user-created schedules.
27097
+ disarmReason:
27098
+ anyOf:
27099
+ - type: string
27100
+ enum:
27101
+ - user_disabled
27102
+ - plugin_removed
27103
+ - plugin_disabled
27104
+ - declaration_removed
27105
+ - declaration_disabled
27106
+ - type: "null"
27107
+ description:
27108
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
27109
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
27110
+ is on, and always null for user-created schedules."
26995
27111
  isOneShot:
26996
27112
  type: boolean
26997
27113
  isDeferred:
@@ -27028,6 +27144,7 @@ paths:
27028
27144
  - workflowName
27029
27145
  - sourceKey
27030
27146
  - userEnabled
27147
+ - disarmReason
27031
27148
  - isOneShot
27032
27149
  - isDeferred
27033
27150
  additionalProperties: false
@@ -27314,6 +27431,20 @@ paths:
27314
27431
  description:
27315
27432
  User enable/disable override on a plugin-sourced schedule; null when the declaration's own enabled value
27316
27433
  applies. Always null for user-created schedules.
27434
+ disarmReason:
27435
+ anyOf:
27436
+ - type: string
27437
+ enum:
27438
+ - user_disabled
27439
+ - plugin_removed
27440
+ - plugin_disabled
27441
+ - declaration_removed
27442
+ - declaration_disabled
27443
+ - type: "null"
27444
+ description:
27445
+ "Why a plugin-sourced schedule is off: the user turned it off, the plugin is gone, the plugin is disabled,
27446
+ the declaration is gone, or the plugin's own files turned it off. Null whenever the schedule
27447
+ is on, and always null for user-created schedules."
27317
27448
  isOneShot:
27318
27449
  type: boolean
27319
27450
  isDeferred:
@@ -27350,6 +27481,7 @@ paths:
27350
27481
  - workflowName
27351
27482
  - sourceKey
27352
27483
  - userEnabled
27484
+ - disarmReason
27353
27485
  - isOneShot
27354
27486
  - isDeferred
27355
27487
  additionalProperties: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.11.3-dev.202608172108.14b9345",
3
+ "version": "0.11.3-dev.202608172253.65bf2a2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,14 @@
1
1
  import { afterAll, beforeEach, describe, expect, mock, test } from "bun:test";
2
2
 
3
- import { readFileSync } from "fs";
3
+ import {
4
+ mkdtempSync,
5
+ readdirSync,
6
+ readFileSync,
7
+ rmSync,
8
+ symlinkSync,
9
+ writeFileSync,
10
+ } from "fs";
11
+ import { tmpdir } from "os";
4
12
  import { dirname, join } from "path";
5
13
 
6
14
  import { __resetRegistryForTesting, getTool } from "../tools/registry.js";
@@ -97,8 +105,23 @@ import { run } from "../config/bundled-skills/image-studio/tools/media-generate-
97
105
  // Clean up after this file to prevent contamination of later test files.
98
106
  afterAll(() => {
99
107
  __resetRegistryForTesting();
108
+ for (const dir of tempWorkingDirs) {
109
+ rmSync(dir, { recursive: true, force: true });
110
+ }
100
111
  });
101
112
 
113
+ const tempWorkingDirs: string[] = [];
114
+
115
+ /** Build a ToolContext with a fresh temp working directory. */
116
+ function makeContext(): ToolContext {
117
+ const workingDir = mkdtempSync(join(tmpdir(), "media-gen-test-"));
118
+ tempWorkingDirs.push(workingDir);
119
+ return {
120
+ conversationId: "conv-123",
121
+ workingDir,
122
+ } as unknown as ToolContext;
123
+ }
124
+
102
125
  const CONFIG_DIR = join(
103
126
  dirname(import.meta.dirname!),
104
127
  "config",
@@ -128,12 +151,10 @@ beforeEach(() => {
128
151
  platformBaseUrl: "",
129
152
  assistantApiKey: "",
130
153
  };
154
+ fakeContext = makeContext();
131
155
  });
132
156
 
133
- const fakeContext = {
134
- conversationId: "conv-123",
135
- workingDir: "/tmp",
136
- } as unknown as ToolContext;
157
+ let fakeContext: ToolContext;
137
158
 
138
159
  describe("image-studio skill script wrapper", () => {
139
160
  test("exports a run function without registering media_generate_image in the tool registry", async () => {
@@ -431,28 +452,117 @@ describe("image-studio skill script wrapper", () => {
431
452
  });
432
453
 
433
454
  test("reads source images from file paths on disk", async () => {
434
- // Write a temp image file inside the workspace (fakeContext.workingDir = /tmp)
435
- const tmpPath = join("/tmp", "test-source-image.png");
455
+ // Write a temp image file inside the workspace
456
+ const tmpPath = join(fakeContext.workingDir, "test-source-image.png");
436
457
  const pngBytes = Buffer.from(
437
458
  "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
438
459
  "base64",
439
460
  );
440
461
  await Bun.write(tmpPath, pngBytes);
441
462
 
442
- try {
443
- const result = await run(
444
- { prompt: "edit this", mode: "edit", source_paths: [tmpPath] },
445
- fakeContext,
446
- );
447
-
448
- expect(result.isError).toBe(false);
449
- expect(result.content).toContain("Generated 1 image");
450
- } finally {
451
- const { unlink } = await import("fs/promises");
452
- if (await Bun.file(tmpPath).exists()) {
453
- await unlink(tmpPath);
454
- }
455
- }
463
+ const result = await run(
464
+ { prompt: "edit this", mode: "edit", source_paths: [tmpPath] },
465
+ fakeContext,
466
+ );
467
+
468
+ expect(result.isError).toBe(false);
469
+ expect(result.content).toContain("Generated 1 image");
470
+ });
471
+
472
+ test("saves the image into media/generated and returns the embed instruction", async () => {
473
+ const result = await run({ prompt: "a sunset" }, fakeContext);
474
+
475
+ expect(result.isError).toBe(false);
476
+ expect(result.content).toContain("Saved to media/generated/a-sunset.png");
477
+ expect(result.content).toContain(
478
+ "![description](vellum://workspace/media/generated/a-sunset.png)",
479
+ );
480
+ const saved = Bun.file(
481
+ join(fakeContext.workingDir, "media/generated/a-sunset.png"),
482
+ );
483
+ expect(await saved.exists()).toBe(true);
484
+ const bytes = Buffer.from(await saved.arrayBuffer());
485
+ expect(bytes.equals(Buffer.from("generated-data", "base64"))).toBe(true);
486
+ });
487
+
488
+ test("uses the image title for the filename when present", async () => {
489
+ mockGenerateResult = {
490
+ images: [
491
+ {
492
+ mimeType: "image/png",
493
+ dataBase64: "img1",
494
+ title: "Twilight Gremlin!",
495
+ } as never,
496
+ ],
497
+ text: "",
498
+ resolvedModel: "gemini-3.1-flash-image-preview",
499
+ };
500
+
501
+ const result = await run({ prompt: "a pond creature" }, fakeContext);
502
+
503
+ expect(result.isError).toBe(false);
504
+ expect(result.content).toContain(
505
+ "Saved to media/generated/twilight-gremlin.png",
506
+ );
507
+ });
508
+
509
+ test("gives each variant a distinct filename", async () => {
510
+ mockGenerateResult = {
511
+ images: [
512
+ { mimeType: "image/png", dataBase64: "img1" },
513
+ { mimeType: "image/png", dataBase64: "img2" },
514
+ ],
515
+ text: undefined as unknown as string,
516
+ resolvedModel: "gemini-3.1-flash-image-preview",
517
+ };
518
+
519
+ const result = await run({ prompt: "a robot", variants: 2 }, fakeContext);
520
+
521
+ expect(result.isError).toBe(false);
522
+ expect(result.content).toContain("- media/generated/a-robot.png");
523
+ expect(result.content).toContain("- media/generated/a-robot-2.png");
524
+ expect(
525
+ await Bun.file(
526
+ join(fakeContext.workingDir, "media/generated/a-robot-2.png"),
527
+ ).exists(),
528
+ ).toBe(true);
529
+ });
530
+
531
+ test("suffixes the filename when a previous generation already used it", async () => {
532
+ const first = await run({ prompt: "a fox" }, fakeContext);
533
+ expect(first.content).toContain("Saved to media/generated/a-fox.png");
534
+
535
+ const second = await run({ prompt: "a fox" }, fakeContext);
536
+ expect(second.content).toContain("Saved to media/generated/a-fox-2.png");
537
+ });
538
+
539
+ test("refuses to write through a symlink that escapes the workspace", async () => {
540
+ const outside = mkdtempSync(join(tmpdir(), "media-gen-outside-"));
541
+ tempWorkingDirs.push(outside);
542
+ symlinkSync(outside, join(fakeContext.workingDir, "media"));
543
+
544
+ const result = await run({ prompt: "a cat" }, fakeContext);
545
+
546
+ expect(result.isError).toBe(false);
547
+ expect(result.content).toContain("Could not save to the workspace");
548
+ expect(result.content).not.toContain("vellum://workspace/");
549
+ expect(readdirSync(outside)).toEqual([]);
550
+ });
551
+
552
+ test("falls back to inline-only when the workspace write fails", async () => {
553
+ // Occupy the media path with a regular file so the directory creation
554
+ // under it fails.
555
+ writeFileSync(join(fakeContext.workingDir, "media"), "not a directory");
556
+
557
+ const result = await run({ prompt: "a cat" }, fakeContext);
558
+
559
+ expect(result.isError).toBe(false);
560
+ expect(result.content).toContain("Could not save to the workspace");
561
+ expect(result.content).toContain(
562
+ "will be attached to your reply automatically",
563
+ );
564
+ expect(result.content).not.toContain("vellum://workspace/");
565
+ expect(result.contentBlocks).toHaveLength(1);
456
566
  });
457
567
 
458
568
  test("returns error when all source_paths are invalid", async () => {
@@ -64,9 +64,13 @@ mock.module("../runtime/assistant-event-hub.js", () => ({
64
64
  broadcastMessage: broadcastMessageMock,
65
65
  }));
66
66
 
67
- import type { UserPromptSubmitContext } from "@vellumai/plugin-api";
67
+ import {
68
+ type UserPromptSubmitContext,
69
+ VOICE_ESCALATION_CONTINUATION_MESSAGE_KIND,
70
+ } from "@vellumai/plugin-api";
68
71
 
69
72
  import type { AssistantEvent } from "../api/index.js";
73
+ import { ESCALATION_CONTINUATION_CONTENT } from "../calls/voice-triage-escalate.js";
70
74
  import type { AssistantConfig } from "../config/schema.js";
71
75
  import type { Conversation } from "../daemon/conversation.js";
72
76
  import type { QdrantSparseVector } from "../persistence/embeddings/qdrant-client.js";
@@ -74,6 +78,7 @@ import type { ConversationGraphMemory } from "../plugins/defaults/memory/graph/c
74
78
  import userPromptSubmitMemoryRetrieval from "../plugins/defaults/memory/hooks/user-prompt-submit.js";
75
79
  import type { Message } from "../providers/types.js";
76
80
  import { asConversation } from "./helpers/mock-conversation.js";
81
+ import { setConfig } from "./helpers/set-config.js";
77
82
 
78
83
  /** Canonical metrics payload the graph retriever attaches to a real hit. */
79
84
  function makeMetrics() {
@@ -175,13 +180,14 @@ function installConversation(
175
180
  trusted?: boolean;
176
181
  abortController?: AbortController;
177
182
  },
178
- ): void {
183
+ ): Conversation {
179
184
  currentTrustClass = opts?.trusted === false ? "unknown" : "guardian";
180
185
  currentConversation = asConversation({
181
186
  graphMemory,
182
187
  trustContext: undefined,
183
188
  abortController: opts?.abortController ?? new AbortController(),
184
189
  });
190
+ return currentConversation;
185
191
  }
186
192
 
187
193
  beforeEach(() => {
@@ -192,9 +198,95 @@ beforeEach(() => {
192
198
  broadcastMessageMock.mockReset();
193
199
  currentConversation = undefined;
194
200
  currentTrustClass = "guardian";
201
+ setConfig("memory", { enabled: true, v3: { live: false } });
195
202
  });
196
203
 
197
204
  describe("user-prompt-submit hook (memory retrieval)", () => {
205
+ test("voice front door skips serial legacy retrieval", async () => {
206
+ const { memory, prepareMemoryMock, recordPkbQueryVectorsMock } =
207
+ makeFakeGraphMemory();
208
+ const conversation = installConversation(memory, { trusted: true });
209
+ conversation.currentCallSite = "voiceFrontDoor";
210
+ const ctx = makeHookCtx({ conversationId: "conv-voice" });
211
+
212
+ await userPromptSubmitMemoryRetrieval(ctx);
213
+
214
+ expect(prepareMemoryMock).not.toHaveBeenCalled();
215
+ expect(recordPkbQueryVectorsMock).toHaveBeenCalledWith(
216
+ undefined,
217
+ undefined,
218
+ );
219
+ expect(applyRuntimeInjectionsMock).toHaveBeenCalledTimes(1);
220
+ });
221
+
222
+ test("voice escalation continuation routes legacy retrieval on the preceding user message", async () => {
223
+ const { memory, prepareMemoryMock } = makeFakeGraphMemory();
224
+ installConversation(memory, { trusted: true });
225
+ const latestMessages: Message[] = [
226
+ {
227
+ role: "user",
228
+ content: [
229
+ { type: "text", text: "<info>\ncarried context\n</info>" },
230
+ {
231
+ type: "text",
232
+ text: "<turn_context>\nturn context\n</turn_context>",
233
+ },
234
+ { type: "text", text: "What is my preferred editor?" },
235
+ ],
236
+ },
237
+ {
238
+ role: "assistant",
239
+ content: [{ type: "text", text: "Let me check that." }],
240
+ },
241
+ {
242
+ role: "user",
243
+ content: [{ type: "text", text: "Continue the answer." }],
244
+ },
245
+ ];
246
+ const ctx = makeHookCtx({
247
+ latestMessages,
248
+ isHiddenPrompt: true,
249
+ prompt: ESCALATION_CONTINUATION_CONTENT,
250
+ messageKind: VOICE_ESCALATION_CONTINUATION_MESSAGE_KIND,
251
+ });
252
+
253
+ await userPromptSubmitMemoryRetrieval(ctx);
254
+
255
+ expect(prepareMemoryMock).toHaveBeenCalledTimes(1);
256
+ expect(prepareMemoryMock.mock.calls[0]?.[0]).toBe(latestMessages);
257
+ expect(prepareMemoryMock.mock.calls[0]?.[4]).toEqual([
258
+ {
259
+ role: "user",
260
+ content: [{ type: "text", text: "What is my preferred editor?" }],
261
+ },
262
+ ]);
263
+ });
264
+
265
+ test("generic hidden prompts route legacy retrieval on their own content", async () => {
266
+ const { memory, prepareMemoryMock } = makeFakeGraphMemory();
267
+ installConversation(memory, { trusted: true });
268
+ const latestMessages: Message[] = [
269
+ {
270
+ role: "user",
271
+ content: [{ type: "text", text: "Visible caller message" }],
272
+ },
273
+ {
274
+ role: "user",
275
+ content: [{ type: "text", text: "Hidden prompt content" }],
276
+ },
277
+ ];
278
+ const ctx = makeHookCtx({
279
+ latestMessages,
280
+ isHiddenPrompt: true,
281
+ prompt: "Hidden prompt content",
282
+ });
283
+
284
+ await userPromptSubmitMemoryRetrieval(ctx);
285
+
286
+ expect(prepareMemoryMock).toHaveBeenCalledTimes(1);
287
+ expect(prepareMemoryMock.mock.calls[0]?.[4]).toBe(latestMessages);
288
+ });
289
+
198
290
  test("adopts the injected run messages when the actor is trusted", async () => {
199
291
  const injected: Message[] = [
200
292
  { role: "user", content: [{ type: "text", text: "injected" }] },