@vellumai/assistant 0.11.8-dev.202609012313.7a1acce → 0.11.8-dev.202609020319.a47fda9

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 (31) hide show
  1. package/openapi.yaml +48 -0
  2. package/package.json +1 -1
  3. package/src/__tests__/canned-reply-release.test.ts +48 -5
  4. package/src/__tests__/client-os-metadata-persistence.test.ts +16 -0
  5. package/src/__tests__/conversation-routes-disk-view.test.ts +28 -1
  6. package/src/__tests__/conversation-routes-slash-commands.test.ts +125 -0
  7. package/src/__tests__/conversation-store-ephemeral.test.ts +323 -10
  8. package/src/__tests__/dm-persistence.test.ts +16 -0
  9. package/src/__tests__/inbound-slack-persistence.test.ts +16 -0
  10. package/src/__tests__/persist-user-message-set-processing-failure.test.ts +83 -65
  11. package/src/__tests__/process-message-display-content.test.ts +16 -0
  12. package/src/__tests__/processing-acquire-fenced-guard.test.ts +56 -0
  13. package/src/__tests__/scripted-turn-metadata-persistence.test.ts +16 -0
  14. package/src/__tests__/voice-session-bridge.test.ts +18 -0
  15. package/src/config/feature-flag-registry.json +8 -0
  16. package/src/daemon/conversation-messaging.ts +66 -23
  17. package/src/daemon/conversation-process.ts +20 -4
  18. package/src/daemon/conversation-store.ts +159 -11
  19. package/src/daemon/conversation.ts +240 -15
  20. package/src/live-voice/__tests__/live-voice-photo.test.ts +910 -50
  21. package/src/live-voice/__tests__/live-voice-sight-frame-inline.test.ts +31 -25
  22. package/src/live-voice/live-voice-photo.ts +544 -61
  23. package/src/live-voice/live-voice-session.ts +3 -2
  24. package/src/persistence/conversation-crud.ts +66 -10
  25. package/src/plugins/defaults/memory/__tests__/memory-retrospective-accounting.test.ts +2 -2
  26. package/src/runtime/routes/__tests__/sight-frame-routes.test.ts +487 -0
  27. package/src/runtime/routes/canned-reply-release.ts +19 -9
  28. package/src/runtime/routes/conversation-management-routes.ts +2 -1
  29. package/src/runtime/routes/conversation-routes.ts +111 -48
  30. package/src/runtime/routes/index.ts +2 -0
  31. package/src/runtime/routes/sight-frame-routes.ts +136 -0
package/openapi.yaml CHANGED
@@ -8189,6 +8189,54 @@ paths:
8189
8189
  description: The assistant is currently responding
8190
8190
  "422":
8191
8191
  description: No user message exists to retry from
8192
+ /v1/conversations/{id}/sight-frame:
8193
+ post:
8194
+ operationId: conversations_by_id_sightframe_post
8195
+ summary: Persist an ambient camera frame
8196
+ description:
8197
+ Add an already-uploaded camera frame to a conversation as its own message, tagged so retention can age the
8198
+ image out of the model's context while the transcript keeps it. No reply is generated. Returns persisted=false
8199
+ when the frame was dropped, in which case the assistant owns the upload and there is nothing to clean up.
8200
+ tags:
8201
+ - conversations
8202
+ parameters:
8203
+ - name: id
8204
+ in: path
8205
+ required: true
8206
+ schema:
8207
+ type: string
8208
+ requestBody:
8209
+ required: true
8210
+ content:
8211
+ application/json:
8212
+ schema:
8213
+ type: object
8214
+ properties:
8215
+ attachmentId:
8216
+ type: string
8217
+ description: Id of the uploaded attachment holding the frame.
8218
+ required:
8219
+ - attachmentId
8220
+ responses:
8221
+ "200":
8222
+ description: Successful response
8223
+ content:
8224
+ application/json:
8225
+ schema:
8226
+ type: object
8227
+ properties:
8228
+ persisted:
8229
+ type: boolean
8230
+ messageId:
8231
+ description: The message the frame landed on, when one was written.
8232
+ type: string
8233
+ required:
8234
+ - persisted
8235
+ additionalProperties: false
8236
+ "400":
8237
+ description: Missing or empty attachmentId
8238
+ "404":
8239
+ description: Conversation not found
8192
8240
  /v1/conversations/{id}/slash:
8193
8241
  post:
8194
8242
  operationId: conversations_by_id_slash_post
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.11.8-dev.202609012313.7a1acce",
3
+ "version": "0.11.8-dev.202609020319.a47fda9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -5,21 +5,35 @@
5
5
  * turns get: no agent loop runs, so a throw escaping the burst would latch the
6
6
  * conversation "processing" for the life of the daemon and queue every later
7
7
  * send behind an idle conversation.
8
+ *
9
+ * It releases the claim its scheduler took, and only that one: the timer fires
10
+ * a tick after the route returned, so a Stop and a fresh acquire can land in
11
+ * between, and clearing there would free a turn that is running.
8
12
  */
9
13
  import { describe, expect, test } from "bun:test";
10
14
 
11
15
  import type { QueueDrainReason } from "../daemon/conversation-queue-manager.js";
12
16
  import { scheduleCannedReplyRelease } from "../runtime/routes/canned-reply-release.js";
13
17
 
14
- function makeConversation() {
18
+ function makeConversation(owner = 1) {
15
19
  let processing = true;
20
+ let holder = owner;
16
21
  const drainOrigins: string[] = [];
17
22
  return {
18
23
  isProcessing: () => processing,
19
24
  drainOrigins,
25
+ /** The force-clear-then-reacquire a Stop and a new request perform. */
26
+ claimAway: (nextOwner: number) => {
27
+ processing = true;
28
+ holder = nextOwner;
29
+ },
20
30
  target: {
21
- setProcessing: (value: boolean) => {
22
- processing = value;
31
+ releaseProcessing: (claim: number) => {
32
+ if (claim !== holder) {
33
+ return false;
34
+ }
35
+ processing = false;
36
+ return true;
23
37
  },
24
38
  kickDrainQueue: (_reason?: QueueDrainReason, origin?: string) => {
25
39
  drainOrigins.push(origin ?? "");
@@ -41,12 +55,13 @@ describe("scheduleCannedReplyRelease", () => {
41
55
 
42
56
  scheduleCannedReplyRelease({
43
57
  conversation: {
44
- setProcessing: (value: boolean) => {
58
+ releaseProcessing: (claim: number) => {
45
59
  order.push("release");
46
- conversation.target.setProcessing(value);
60
+ return conversation.target.releaseProcessing(claim);
47
61
  },
48
62
  kickDrainQueue: conversation.target.kickDrainQueue,
49
63
  },
64
+ owner: 1,
50
65
  origin: "canned_greeting",
51
66
  emit: () => {
52
67
  order.push("emit");
@@ -72,6 +87,7 @@ describe("scheduleCannedReplyRelease", () => {
72
87
 
73
88
  scheduleCannedReplyRelease({
74
89
  conversation: conversation.target,
90
+ owner: 1,
75
91
  origin: "slash_command",
76
92
  emit: () => {
77
93
  throw new Error("broadcast exploded");
@@ -83,4 +99,31 @@ describe("scheduleCannedReplyRelease", () => {
83
99
  expect(conversation.isProcessing()).toBe(false);
84
100
  expect(conversation.drainOrigins).toEqual(["slash_command"]);
85
101
  });
102
+
103
+ test("leaves a hold claimed away since it was scheduled alone", async () => {
104
+ // Stop force-clears the flag and the next request acquires, all before
105
+ // this timer runs. Clearing here would release a turn that is running,
106
+ // and kicking the drain would start the next message inside it.
107
+ const conversation = makeConversation();
108
+ const after: string[] = [];
109
+
110
+ scheduleCannedReplyRelease({
111
+ conversation: conversation.target,
112
+ owner: 1,
113
+ origin: "canned_greeting",
114
+ emit: () => {},
115
+ afterRelease: () => {
116
+ after.push("after");
117
+ },
118
+ });
119
+
120
+ conversation.claimAway(2);
121
+ await nextTick();
122
+
123
+ // The newer hold survives, nothing drains into the turn that owns it, and
124
+ // the follow-up work waits for whoever does.
125
+ expect(conversation.isProcessing()).toBe(true);
126
+ expect(conversation.drainOrigins).toEqual([]);
127
+ expect(after).toEqual([]);
128
+ });
86
129
  });
@@ -84,6 +84,7 @@ function createWebTurnContext(
84
84
  size: () => 0,
85
85
  } as unknown as MessageQueue;
86
86
  let processing = false;
87
+ let owner = 0;
87
88
  return {
88
89
  conversationId: "conv-client-os-test",
89
90
  messages: [],
@@ -91,6 +92,21 @@ function createWebTurnContext(
91
92
  setProcessing: (value: boolean) => {
92
93
  processing = value;
93
94
  },
95
+ acquireProcessingFenced: async () => {
96
+ if (processing) {
97
+ return null;
98
+ }
99
+ processing = true;
100
+ owner += 1;
101
+ return owner;
102
+ },
103
+ releaseProcessing: (claim: number) => {
104
+ if (claim !== owner) {
105
+ return false;
106
+ }
107
+ processing = false;
108
+ return true;
109
+ },
94
110
  abortController: null,
95
111
  queue: queueStub,
96
112
  clientOs,
@@ -97,8 +97,35 @@ function createFakeConversation(conversationId: string): Conversation {
97
97
  isProcessing(this: { processing: boolean }) {
98
98
  return this.processing;
99
99
  },
100
- setProcessing(this: { processing: boolean }, value: boolean) {
100
+ setProcessing(
101
+ this: { processing: boolean; owner: number },
102
+ value: boolean,
103
+ ) {
101
104
  this.processing = value;
105
+ this.owner = value ? this.owner + 1 : 0;
106
+ },
107
+ owner: 0,
108
+ async acquireProcessingFenced(this: {
109
+ processing: boolean;
110
+ owner: number;
111
+ }) {
112
+ if (this.processing) {
113
+ return null;
114
+ }
115
+ this.processing = true;
116
+ this.owner += 1;
117
+ return this.owner;
118
+ },
119
+ releaseProcessing(
120
+ this: { processing: boolean; owner: number },
121
+ claim: number,
122
+ ) {
123
+ if (claim !== this.owner) {
124
+ return false;
125
+ }
126
+ this.processing = false;
127
+ this.owner = 0;
128
+ return true;
102
129
  },
103
130
  setChannelCapabilities: () => {},
104
131
  setAssistantId: () => {},
@@ -162,6 +162,7 @@ mock.module("../ipc/gateway-client.js", () => ({
162
162
  ipcCall: ipcCallMock,
163
163
  }));
164
164
 
165
+ import { CONVERSATION_BUSY_MESSAGE } from "../daemon/conversation-messaging.js";
165
166
  import type { AuthContext } from "../runtime/auth/types.js";
166
167
  import { handleSendMessage } from "../runtime/routes/conversation-routes.js";
167
168
  import { callHandler } from "./helpers/call-route-handler.js";
@@ -226,6 +227,7 @@ function makeConversation() {
226
227
  const events: unknown[] = [];
227
228
  const messages: unknown[] = [];
228
229
  let processing = false;
230
+ let owner = 0;
229
231
  const conversation = {
230
232
  conversationId: "conv-slash-test",
231
233
  messages,
@@ -244,6 +246,23 @@ function makeConversation() {
244
246
  isProcessing: () => processing,
245
247
  setProcessing: (value: boolean) => {
246
248
  processing = value;
249
+ owner = value ? owner + 1 : 0;
250
+ },
251
+ acquireProcessingFenced: async () => {
252
+ if (processing) {
253
+ return null;
254
+ }
255
+ processing = true;
256
+ owner += 1;
257
+ return owner;
258
+ },
259
+ releaseProcessing: (claim: number) => {
260
+ if (claim !== owner) {
261
+ return false;
262
+ }
263
+ processing = false;
264
+ owner = 0;
265
+ return true;
247
266
  },
248
267
  hasAnyPendingConfirmation: () => false,
249
268
  denyAllPendingConfirmations: () => {},
@@ -530,6 +549,36 @@ describe("handleSendMessage canned wake-up greeting", () => {
530
549
  }
531
550
  });
532
551
 
552
+ test("queues a first greeting whose flag went away during the awaits", async () => {
553
+ // The canned wake-up greeting used to claim the flag unconditionally, so
554
+ // it greeted over a turn already writing and both mutated one history.
555
+ // It declines instead and falls through, the way its sibling branches do,
556
+ // and the gate below answers as a busy conversation owes.
557
+ const { conversation, persistUserMessage, runAgentLoop } =
558
+ makeConversation();
559
+ conversation.setProcessing(true);
560
+ const stub = conversation as unknown as { isProcessing: () => boolean };
561
+ stub.isProcessing = () => false;
562
+ // What the real one does while another holder has the flag, which is what
563
+ // the fall-through below runs into.
564
+ persistUserMessage.mockImplementationOnce(async () => {
565
+ throw new Error(CONVERSATION_BUSY_MESSAGE);
566
+ });
567
+
568
+ const res = await callHandler(
569
+ (args) => handleSendMessage(args, makeDeps(conversation)),
570
+ makeRequest("Wake up, my friend!"),
571
+ undefined,
572
+ 202,
573
+ );
574
+
575
+ expect(res.status).toBe(202);
576
+ expect(await res.json()).toMatchObject({ accepted: true, queued: true });
577
+ expect(runAgentLoop).not.toHaveBeenCalled();
578
+ // No greeting rows: the branch never ran.
579
+ expect(addMessageMock).not.toHaveBeenCalled();
580
+ });
581
+
533
582
  test("persists the clientMessageId on the user row", async () => {
534
583
  const { conversation, runAgentLoop } = makeConversation();
535
584
  const res = await callHandler(
@@ -550,3 +599,79 @@ describe("handleSendMessage canned wake-up greeting", () => {
550
599
  expect(options?.clientMessageId).toBe("nonce-wake-123");
551
600
  });
552
601
  });
602
+
603
+ describe("handleSendMessage flag taken after its queue decision", () => {
604
+ beforeEach(() => {
605
+ addMessageMock.mockClear();
606
+ });
607
+
608
+ test("queues a plain send whose flag went away during the awaits", async () => {
609
+ // The route decides to queue or run at the top, then awaits guardian
610
+ // cleanup, history scoping and slash resolution. A camera frame taking the
611
+ // flag inside those awaits leaves the persist rejecting busy, and the send
612
+ // has to reach the queue the early decision would have used rather than
613
+ // failing in the client's face.
614
+ const { conversation, persistUserMessage, runAgentLoop } =
615
+ makeConversation();
616
+ persistUserMessage.mockImplementationOnce(async () => {
617
+ throw new Error(CONVERSATION_BUSY_MESSAGE);
618
+ });
619
+
620
+ const res = await callHandler(
621
+ (args) => handleSendMessage(args, makeDeps(conversation)),
622
+ makeRequest("what is this"),
623
+ undefined,
624
+ 202,
625
+ );
626
+
627
+ expect(res.status).toBe(202);
628
+ expect(await res.json()).toMatchObject({ accepted: true, queued: true });
629
+ expect(runAgentLoop).not.toHaveBeenCalled();
630
+ });
631
+
632
+ test("still fails a send whose persist failed for any other reason", async () => {
633
+ // The control: only the busy rejection queues. Everything else is a real
634
+ // failure and must not be answered as an accepted message.
635
+ const { conversation } = makeConversation();
636
+ const { persistUserMessage } = makeConversation();
637
+ void persistUserMessage;
638
+ (
639
+ conversation as unknown as {
640
+ persistUserMessage: ReturnType<typeof mock>;
641
+ }
642
+ ).persistUserMessage = mock(async () => {
643
+ throw new Error("disk on fire");
644
+ });
645
+
646
+ await expect(
647
+ callHandler(
648
+ (args) => handleSendMessage(args, makeDeps(conversation)),
649
+ makeRequest("what is this"),
650
+ undefined,
651
+ 202,
652
+ ),
653
+ ).rejects.toThrow("disk on fire");
654
+ });
655
+
656
+ test("queues a slash command whose flag went away during the awaits", async () => {
657
+ // Same window, the branch that hand-rolls its own claim. It takes the flag
658
+ // rather than setting it, so a hold taken since is answered by the queue
659
+ // instead of being claimed away from the turn that owns it.
660
+ const { conversation, runAgentLoop } = makeConversation();
661
+ conversation.setProcessing(true);
662
+ // The early gate reads idle, the claim below does not.
663
+ const stub = conversation as unknown as { isProcessing: () => boolean };
664
+ stub.isProcessing = () => false;
665
+
666
+ const res = await callHandler(
667
+ (args) => handleSendMessage(args, makeDeps(conversation)),
668
+ makeRequest("/context"),
669
+ undefined,
670
+ 202,
671
+ );
672
+
673
+ expect(res.status).toBe(202);
674
+ expect(await res.json()).toMatchObject({ accepted: true, queued: true });
675
+ expect(runAgentLoop).not.toHaveBeenCalled();
676
+ });
677
+ });