@vellumai/assistant 0.11.7-dev.202608302213.8788231 → 0.11.7-dev.202608310050.dde6a86
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.
package/package.json
CHANGED
|
@@ -206,7 +206,20 @@ describe("live-voice attach_frame frame", () => {
|
|
|
206
206
|
});
|
|
207
207
|
});
|
|
208
208
|
|
|
209
|
+
test("accepts a null attachmentId, which unparks", () => {
|
|
210
|
+
const result = validateLiveVoiceClientFrame({
|
|
211
|
+
type: "attach_frame",
|
|
212
|
+
attachmentId: null,
|
|
213
|
+
});
|
|
214
|
+
expect(result).toEqual({
|
|
215
|
+
ok: true,
|
|
216
|
+
frame: { type: "attach_frame", attachmentId: null },
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
209
220
|
test("rejects a missing attachmentId, naming the frame", () => {
|
|
221
|
+
// A missing field is not an unpark. A client that means to clear the slot
|
|
222
|
+
// says so with an explicit null; an absent field is a malformed frame.
|
|
210
223
|
const result = validateLiveVoiceClientFrame({ type: "attach_frame" });
|
|
211
224
|
expect(result.ok).toBe(false);
|
|
212
225
|
if (!result.ok) {
|
|
@@ -365,6 +378,96 @@ describe("live-voice camera frames parked for the next turn", () => {
|
|
|
365
378
|
await session.close("websocket_close");
|
|
366
379
|
});
|
|
367
380
|
|
|
381
|
+
test("unparking clears the slot and gives the frame up", async () => {
|
|
382
|
+
// The client's viewfinder closed. Nothing should still be staged for a
|
|
383
|
+
// turn that would show a view the user can no longer see.
|
|
384
|
+
const attachmentId = await uploadFrame();
|
|
385
|
+
const turns: VoiceTurnOptions[] = [];
|
|
386
|
+
const startVoiceTurn: LiveVoiceTurnStarter = mock(
|
|
387
|
+
async (options: VoiceTurnOptions) => {
|
|
388
|
+
turns.push(options);
|
|
389
|
+
options.callbacks?.message_complete?.(makeMessageComplete());
|
|
390
|
+
return { turnId: `bridge-turn-${turns.length}`, abort: mock() };
|
|
391
|
+
},
|
|
392
|
+
);
|
|
393
|
+
const { frames, session } = createSessionHarness(startVoiceTurn);
|
|
394
|
+
await session.start();
|
|
395
|
+
|
|
396
|
+
await session.handleClientFrame({ type: "attach_frame", attachmentId });
|
|
397
|
+
expect(parkedFrameId(session)).toBe(attachmentId);
|
|
398
|
+
const before = frames.length;
|
|
399
|
+
|
|
400
|
+
await session.handleClientFrame({
|
|
401
|
+
type: "attach_frame",
|
|
402
|
+
attachmentId: null,
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
expect(parkedFrameId(session)).toBeNull();
|
|
406
|
+
expect(frameStored(attachmentId)).toBe(false);
|
|
407
|
+
// Nothing is answered for an unpark: it is the client tidying up after
|
|
408
|
+
// itself, not a request that can fail.
|
|
409
|
+
expect(frames.slice(before)).toEqual([]);
|
|
410
|
+
|
|
411
|
+
await speakAndRelease(session, () => turns.length, 8_000);
|
|
412
|
+
expect(turns[0]?.attachments).toBeUndefined();
|
|
413
|
+
|
|
414
|
+
await session.close("websocket_close");
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test("unparking an empty slot does nothing", async () => {
|
|
418
|
+
const startVoiceTurn: LiveVoiceTurnStarter = mock(
|
|
419
|
+
async (options: VoiceTurnOptions) => {
|
|
420
|
+
options.callbacks?.message_complete?.(makeMessageComplete());
|
|
421
|
+
return { turnId: "bridge-turn-1", abort: mock() };
|
|
422
|
+
},
|
|
423
|
+
);
|
|
424
|
+
const { frames, session } = createSessionHarness(startVoiceTurn);
|
|
425
|
+
await session.start();
|
|
426
|
+
const before = frames.length;
|
|
427
|
+
|
|
428
|
+
await session.handleClientFrame({
|
|
429
|
+
type: "attach_frame",
|
|
430
|
+
attachmentId: null,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
expect(parkedFrameId(session)).toBeNull();
|
|
434
|
+
expect(frames.slice(before)).toEqual([]);
|
|
435
|
+
|
|
436
|
+
await session.close("websocket_close");
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
test("unparking leaves a frame that already rode a message alone", async () => {
|
|
440
|
+
// Same link-awareness the displacement path relies on: an unpark arriving
|
|
441
|
+
// after the turn drained the slot finds it empty, and the frame the
|
|
442
|
+
// transcript is showing is not this call's to collect.
|
|
443
|
+
const conversation = createConversation("Live voice frame unpark");
|
|
444
|
+
const message = await addMessage(conversation.id, "user", "what is this");
|
|
445
|
+
const sent = await uploadFrame();
|
|
446
|
+
linkAttachmentToMessage(message.id, sent, 0);
|
|
447
|
+
const startVoiceTurn: LiveVoiceTurnStarter = mock(
|
|
448
|
+
async (options: VoiceTurnOptions) => {
|
|
449
|
+
options.callbacks?.message_complete?.(makeMessageComplete());
|
|
450
|
+
return { turnId: "bridge-turn-1", abort: mock() };
|
|
451
|
+
},
|
|
452
|
+
);
|
|
453
|
+
const { session } = createSessionHarness(startVoiceTurn);
|
|
454
|
+
await session.start();
|
|
455
|
+
|
|
456
|
+
await session.handleClientFrame({
|
|
457
|
+
type: "attach_frame",
|
|
458
|
+
attachmentId: sent,
|
|
459
|
+
});
|
|
460
|
+
await session.handleClientFrame({
|
|
461
|
+
type: "attach_frame",
|
|
462
|
+
attachmentId: null,
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
expect(parkedFrameId(session)).toBeNull();
|
|
466
|
+
expect(frameStored(sent)).toBe(true);
|
|
467
|
+
|
|
468
|
+
await session.close("websocket_close");
|
|
469
|
+
});
|
|
470
|
+
|
|
368
471
|
test("ending the session drops the parked frame", async () => {
|
|
369
472
|
const attachmentId = await uploadFrame();
|
|
370
473
|
const startVoiceTurn: LiveVoiceTurnStarter = mock(
|
|
@@ -1640,7 +1640,7 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
|
|
|
1640
1640
|
}
|
|
1641
1641
|
|
|
1642
1642
|
/**
|
|
1643
|
-
* Park a camera frame for the next turn to carry.
|
|
1643
|
+
* Park a camera frame for the next turn to carry, or give up the parked one.
|
|
1644
1644
|
*
|
|
1645
1645
|
* Nothing is persisted and no turn runs: the frame is ambient context, and
|
|
1646
1646
|
* on its own it says nothing the user asked to say. It rides the next turn's
|
|
@@ -1648,12 +1648,23 @@ export class LiveVoiceSession implements LiveVoiceSessionContract {
|
|
|
1648
1648
|
* message. A frame that arrives while a turn is already running belongs to
|
|
1649
1649
|
* the turn after it, which the drain at launch takes care of.
|
|
1650
1650
|
*
|
|
1651
|
+
* A null id unparks: the client's camera is off, so the slot must stop
|
|
1652
|
+
* answering for a view nobody can see any more. The frame goes with it, and
|
|
1653
|
+
* unparking an empty slot is a no-op.
|
|
1654
|
+
*
|
|
1651
1655
|
* The id is checked against the attachment store here rather than at the
|
|
1652
1656
|
* turn, for the same reason a failed photo is reported: an id that resolves
|
|
1653
1657
|
* to nothing would otherwise leave the user believing the assistant can see
|
|
1654
1658
|
* something it never received, one turn later and with nothing said.
|
|
1655
1659
|
*/
|
|
1656
1660
|
private parkTurnFrame(frame: LiveVoiceClientAttachFrameFrame): void {
|
|
1661
|
+
if (frame.attachmentId === null) {
|
|
1662
|
+
const parked = this.pendingTurnAttachmentId;
|
|
1663
|
+
this.pendingTurnAttachmentId = null;
|
|
1664
|
+
this.reclaimParkedFrame(parked);
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1657
1668
|
let exists = false;
|
|
1658
1669
|
try {
|
|
1659
1670
|
exists = attachmentExists(frame.attachmentId);
|
|
@@ -227,10 +227,24 @@ export interface LiveVoiceClientAttachImageFrame {
|
|
|
227
227
|
*
|
|
228
228
|
* Latest wins. A second frame overwrites the first, because what matters is
|
|
229
229
|
* what the camera is pointed at when the user speaks.
|
|
230
|
+
*
|
|
231
|
+
* A `null` id is the other direction: unpark, meaning the client's camera is
|
|
232
|
+
* no longer on and the slot must not keep answering for it. It clears the slot
|
|
233
|
+
* and gives the frame up, so a viewfinder the user closed leaves nothing
|
|
234
|
+
* staged behind it. Sending it needs no id of its own because the slot only
|
|
235
|
+
* ever holds one frame and only the client that parked it can be closing.
|
|
236
|
+
*
|
|
237
|
+
* `null` and a missing field are different things. An absent `attachmentId` is
|
|
238
|
+
* still a malformed frame, because a client that meant to unpark says so.
|
|
239
|
+
*
|
|
240
|
+
* Version skew: a build carrying the park half but not this one refuses the
|
|
241
|
+
* null with the attributable recoverable error, which the web client logs and
|
|
242
|
+
* drops. Only dev builds cut between the two changes are affected, and there
|
|
243
|
+
* the cost is a frame the session gives up at close instead of at unpark.
|
|
230
244
|
*/
|
|
231
245
|
export interface LiveVoiceClientAttachFrameFrame {
|
|
232
246
|
readonly type: "attach_frame";
|
|
233
|
-
readonly attachmentId: string;
|
|
247
|
+
readonly attachmentId: string | null;
|
|
234
248
|
}
|
|
235
249
|
|
|
236
250
|
/**
|
|
@@ -792,10 +806,10 @@ function validateAttachFrameFrame(
|
|
|
792
806
|
);
|
|
793
807
|
}
|
|
794
808
|
|
|
795
|
-
if (!isNonEmptyString(value.attachmentId)) {
|
|
809
|
+
if (value.attachmentId !== null && !isNonEmptyString(value.attachmentId)) {
|
|
796
810
|
return protocolError(
|
|
797
811
|
"invalid_field",
|
|
798
|
-
"attach_frame frame field attachmentId must be a non-empty string",
|
|
812
|
+
"attach_frame frame field attachmentId must be a non-empty string or null",
|
|
799
813
|
"attachmentId",
|
|
800
814
|
"attach_frame",
|
|
801
815
|
);
|