@absolutejs/voice 0.0.22-beta.128 → 0.0.22-beta.129

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.
@@ -430,6 +430,17 @@ var serverMessageToAction = (message) => {
430
430
  transcript: message.transcript,
431
431
  type: "partial"
432
432
  };
433
+ case "replay":
434
+ return {
435
+ assistantTexts: message.assistantTexts,
436
+ call: message.call,
437
+ partial: message.partial,
438
+ scenarioId: message.scenarioId,
439
+ sessionId: message.sessionId,
440
+ status: message.status,
441
+ turns: message.turns,
442
+ type: "replay"
443
+ };
433
444
  case "session":
434
445
  return {
435
446
  sessionId: message.sessionId,
@@ -494,6 +505,7 @@ var isVoiceServerMessage = (value) => {
494
505
  case "final":
495
506
  case "partial":
496
507
  case "pong":
508
+ case "replay":
497
509
  case "session":
498
510
  case "turn":
499
511
  return true;
@@ -758,6 +770,20 @@ var createVoiceStreamStore = () => {
758
770
  partial: action.transcript.text
759
771
  };
760
772
  break;
773
+ case "replay":
774
+ state = {
775
+ ...state,
776
+ assistantTexts: [...action.assistantTexts],
777
+ call: action.call ?? null,
778
+ error: null,
779
+ isConnected: action.status === "active",
780
+ partial: action.partial,
781
+ scenarioId: action.scenarioId ?? state.scenarioId,
782
+ sessionId: action.sessionId,
783
+ status: action.status,
784
+ turns: [...action.turns]
785
+ };
786
+ break;
761
787
  case "session":
762
788
  state = {
763
789
  ...state,
@@ -10,8 +10,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
10
10
  event?: undefined;
11
11
  message?: undefined;
12
12
  transcript?: undefined;
13
+ assistantTexts?: undefined;
14
+ call?: undefined;
15
+ partial?: undefined;
13
16
  scenarioId?: undefined;
14
17
  status?: undefined;
18
+ turns?: undefined;
15
19
  turn?: undefined;
16
20
  } | {
17
21
  text: string;
@@ -24,8 +28,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
24
28
  event?: undefined;
25
29
  message?: undefined;
26
30
  transcript?: undefined;
31
+ assistantTexts?: undefined;
32
+ call?: undefined;
33
+ partial?: undefined;
27
34
  scenarioId?: undefined;
28
35
  status?: undefined;
36
+ turns?: undefined;
29
37
  turn?: undefined;
30
38
  } | {
31
39
  sessionId: string;
@@ -38,8 +46,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
38
46
  event?: undefined;
39
47
  message?: undefined;
40
48
  transcript?: undefined;
49
+ assistantTexts?: undefined;
50
+ call?: undefined;
51
+ partial?: undefined;
41
52
  scenarioId?: undefined;
42
53
  status?: undefined;
54
+ turns?: undefined;
43
55
  turn?: undefined;
44
56
  } | {
45
57
  event: import("..").VoiceCallLifecycleEvent;
@@ -52,8 +64,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
52
64
  text?: undefined;
53
65
  message?: undefined;
54
66
  transcript?: undefined;
67
+ assistantTexts?: undefined;
68
+ call?: undefined;
69
+ partial?: undefined;
55
70
  scenarioId?: undefined;
56
71
  status?: undefined;
72
+ turns?: undefined;
57
73
  turn?: undefined;
58
74
  } | {
59
75
  message: string;
@@ -66,8 +82,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
66
82
  sessionId?: undefined;
67
83
  event?: undefined;
68
84
  transcript?: undefined;
85
+ assistantTexts?: undefined;
86
+ call?: undefined;
87
+ partial?: undefined;
69
88
  scenarioId?: undefined;
70
89
  status?: undefined;
90
+ turns?: undefined;
71
91
  turn?: undefined;
72
92
  } | {
73
93
  transcript: import("..").Transcript;
@@ -80,8 +100,12 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
80
100
  sessionId?: undefined;
81
101
  event?: undefined;
82
102
  message?: undefined;
103
+ assistantTexts?: undefined;
104
+ call?: undefined;
105
+ partial?: undefined;
83
106
  scenarioId?: undefined;
84
107
  status?: undefined;
108
+ turns?: undefined;
85
109
  turn?: undefined;
86
110
  } | {
87
111
  transcript: import("..").Transcript;
@@ -94,8 +118,30 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
94
118
  sessionId?: undefined;
95
119
  event?: undefined;
96
120
  message?: undefined;
121
+ assistantTexts?: undefined;
122
+ call?: undefined;
123
+ partial?: undefined;
97
124
  scenarioId?: undefined;
98
125
  status?: undefined;
126
+ turns?: undefined;
127
+ turn?: undefined;
128
+ } | {
129
+ assistantTexts: string[];
130
+ call: import("..").VoiceCallLifecycleState | undefined;
131
+ partial: string;
132
+ scenarioId: string | undefined;
133
+ sessionId: string;
134
+ status: import("..").VoiceSessionStatus;
135
+ turns: import("..").VoiceTurnRecord<TResult>[];
136
+ type: "replay";
137
+ chunk?: undefined;
138
+ format?: undefined;
139
+ receivedAt?: undefined;
140
+ turnId?: undefined;
141
+ text?: undefined;
142
+ event?: undefined;
143
+ message?: undefined;
144
+ transcript?: undefined;
99
145
  turn?: undefined;
100
146
  } | {
101
147
  sessionId: string;
@@ -110,6 +156,10 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
110
156
  event?: undefined;
111
157
  message?: undefined;
112
158
  transcript?: undefined;
159
+ assistantTexts?: undefined;
160
+ call?: undefined;
161
+ partial?: undefined;
162
+ turns?: undefined;
113
163
  turn?: undefined;
114
164
  } | {
115
165
  turn: import("..").VoiceTurnRecord<TResult>;
@@ -123,6 +173,10 @@ export declare const serverMessageToAction: <TResult = unknown>(message: VoiceSe
123
173
  event?: undefined;
124
174
  message?: undefined;
125
175
  transcript?: undefined;
176
+ assistantTexts?: undefined;
177
+ call?: undefined;
178
+ partial?: undefined;
126
179
  scenarioId?: undefined;
127
180
  status?: undefined;
181
+ turns?: undefined;
128
182
  } | null;
@@ -209,6 +209,17 @@ var serverMessageToAction = (message) => {
209
209
  transcript: message.transcript,
210
210
  type: "partial"
211
211
  };
212
+ case "replay":
213
+ return {
214
+ assistantTexts: message.assistantTexts,
215
+ call: message.call,
216
+ partial: message.partial,
217
+ scenarioId: message.scenarioId,
218
+ sessionId: message.sessionId,
219
+ status: message.status,
220
+ turns: message.turns,
221
+ type: "replay"
222
+ };
212
223
  case "session":
213
224
  return {
214
225
  sessionId: message.sessionId,
@@ -273,6 +284,7 @@ var isVoiceServerMessage = (value) => {
273
284
  case "final":
274
285
  case "partial":
275
286
  case "pong":
287
+ case "replay":
276
288
  case "session":
277
289
  case "turn":
278
290
  return true;
@@ -537,6 +549,20 @@ var createVoiceStreamStore = () => {
537
549
  partial: action.transcript.text
538
550
  };
539
551
  break;
552
+ case "replay":
553
+ state = {
554
+ ...state,
555
+ assistantTexts: [...action.assistantTexts],
556
+ call: action.call ?? null,
557
+ error: null,
558
+ isConnected: action.status === "active",
559
+ partial: action.partial,
560
+ scenarioId: action.scenarioId ?? state.scenarioId,
561
+ sessionId: action.sessionId,
562
+ status: action.status,
563
+ turns: [...action.turns]
564
+ };
565
+ break;
540
566
  case "session":
541
567
  state = {
542
568
  ...state,
@@ -116,6 +116,7 @@ var isVoiceServerMessage = (value) => {
116
116
  case "final":
117
117
  case "partial":
118
118
  case "pong":
119
+ case "replay":
119
120
  case "session":
120
121
  case "turn":
121
122
  return true;
@@ -701,6 +702,17 @@ var serverMessageToAction = (message) => {
701
702
  transcript: message.transcript,
702
703
  type: "partial"
703
704
  };
705
+ case "replay":
706
+ return {
707
+ assistantTexts: message.assistantTexts,
708
+ call: message.call,
709
+ partial: message.partial,
710
+ scenarioId: message.scenarioId,
711
+ sessionId: message.sessionId,
712
+ status: message.status,
713
+ turns: message.turns,
714
+ type: "replay"
715
+ };
704
716
  case "session":
705
717
  return {
706
718
  sessionId: message.sessionId,
@@ -811,6 +823,20 @@ var createVoiceStreamStore = () => {
811
823
  partial: action.transcript.text
812
824
  };
813
825
  break;
826
+ case "replay":
827
+ state = {
828
+ ...state,
829
+ assistantTexts: [...action.assistantTexts],
830
+ call: action.call ?? null,
831
+ error: null,
832
+ isConnected: action.status === "active",
833
+ partial: action.partial,
834
+ scenarioId: action.scenarioId ?? state.scenarioId,
835
+ sessionId: action.sessionId,
836
+ status: action.status,
837
+ turns: [...action.turns]
838
+ };
839
+ break;
814
840
  case "session":
815
841
  state = {
816
842
  ...state,
package/dist/index.js CHANGED
@@ -3696,6 +3696,18 @@ var createVoiceSession = (options) => {
3696
3696
  type: "call_lifecycle"
3697
3697
  });
3698
3698
  };
3699
+ const sendReplay = async (session) => {
3700
+ await send({
3701
+ assistantTexts: session.turns.flatMap((turn) => turn.assistantText ? [turn.assistantText] : []),
3702
+ call: session.call,
3703
+ partial: session.currentTurn.partialText,
3704
+ scenarioId: session.scenarioId,
3705
+ sessionId: options.id,
3706
+ status: session.status,
3707
+ turns: session.turns,
3708
+ type: "replay"
3709
+ });
3710
+ };
3699
3711
  const runHandoff = async (input) => {
3700
3712
  const queuedDelivery = options.handoff?.deliveryQueue ? createVoiceHandoffDeliveryRecord({
3701
3713
  action: input.action,
@@ -5010,6 +5022,7 @@ var createVoiceSession = (options) => {
5010
5022
  scenarioId: session.scenarioId,
5011
5023
  type: "session"
5012
5024
  });
5025
+ await sendReplay(session);
5013
5026
  if (shouldFireOnSession) {
5014
5027
  await options.route.onCallStart?.({
5015
5028
  api,
@@ -2567,6 +2567,17 @@ var serverMessageToAction = (message) => {
2567
2567
  transcript: message.transcript,
2568
2568
  type: "partial"
2569
2569
  };
2570
+ case "replay":
2571
+ return {
2572
+ assistantTexts: message.assistantTexts,
2573
+ call: message.call,
2574
+ partial: message.partial,
2575
+ scenarioId: message.scenarioId,
2576
+ sessionId: message.sessionId,
2577
+ status: message.status,
2578
+ turns: message.turns,
2579
+ type: "replay"
2580
+ };
2570
2581
  case "session":
2571
2582
  return {
2572
2583
  sessionId: message.sessionId,
@@ -2631,6 +2642,7 @@ var isVoiceServerMessage = (value) => {
2631
2642
  case "final":
2632
2643
  case "partial":
2633
2644
  case "pong":
2645
+ case "replay":
2634
2646
  case "session":
2635
2647
  case "turn":
2636
2648
  return true;
@@ -2895,6 +2907,20 @@ var createVoiceStreamStore = () => {
2895
2907
  partial: action.transcript.text
2896
2908
  };
2897
2909
  break;
2910
+ case "replay":
2911
+ state = {
2912
+ ...state,
2913
+ assistantTexts: [...action.assistantTexts],
2914
+ call: action.call ?? null,
2915
+ error: null,
2916
+ isConnected: action.status === "active",
2917
+ partial: action.partial,
2918
+ scenarioId: action.scenarioId ?? state.scenarioId,
2919
+ sessionId: action.sessionId,
2920
+ status: action.status,
2921
+ turns: [...action.turns]
2922
+ };
2923
+ break;
2898
2924
  case "session":
2899
2925
  state = {
2900
2926
  ...state,
@@ -865,6 +865,17 @@ var serverMessageToAction = (message) => {
865
865
  transcript: message.transcript,
866
866
  type: "partial"
867
867
  };
868
+ case "replay":
869
+ return {
870
+ assistantTexts: message.assistantTexts,
871
+ call: message.call,
872
+ partial: message.partial,
873
+ scenarioId: message.scenarioId,
874
+ sessionId: message.sessionId,
875
+ status: message.status,
876
+ turns: message.turns,
877
+ type: "replay"
878
+ };
868
879
  case "session":
869
880
  return {
870
881
  sessionId: message.sessionId,
@@ -929,6 +940,7 @@ var isVoiceServerMessage = (value) => {
929
940
  case "final":
930
941
  case "partial":
931
942
  case "pong":
943
+ case "replay":
932
944
  case "session":
933
945
  case "turn":
934
946
  return true;
@@ -1193,6 +1205,20 @@ var createVoiceStreamStore = () => {
1193
1205
  partial: action.transcript.text
1194
1206
  };
1195
1207
  break;
1208
+ case "replay":
1209
+ state = {
1210
+ ...state,
1211
+ assistantTexts: [...action.assistantTexts],
1212
+ call: action.call ?? null,
1213
+ error: null,
1214
+ isConnected: action.status === "active",
1215
+ partial: action.partial,
1216
+ scenarioId: action.scenarioId ?? state.scenarioId,
1217
+ sessionId: action.sessionId,
1218
+ status: action.status,
1219
+ turns: [...action.turns]
1220
+ };
1221
+ break;
1196
1222
  case "session":
1197
1223
  state = {
1198
1224
  ...state,
@@ -2126,6 +2126,17 @@ var serverMessageToAction = (message) => {
2126
2126
  transcript: message.transcript,
2127
2127
  type: "partial"
2128
2128
  };
2129
+ case "replay":
2130
+ return {
2131
+ assistantTexts: message.assistantTexts,
2132
+ call: message.call,
2133
+ partial: message.partial,
2134
+ scenarioId: message.scenarioId,
2135
+ sessionId: message.sessionId,
2136
+ status: message.status,
2137
+ turns: message.turns,
2138
+ type: "replay"
2139
+ };
2129
2140
  case "session":
2130
2141
  return {
2131
2142
  sessionId: message.sessionId,
@@ -2190,6 +2201,7 @@ var isVoiceServerMessage = (value) => {
2190
2201
  case "final":
2191
2202
  case "partial":
2192
2203
  case "pong":
2204
+ case "replay":
2193
2205
  case "session":
2194
2206
  case "turn":
2195
2207
  return true;
@@ -2454,6 +2466,20 @@ var createVoiceStreamStore = () => {
2454
2466
  partial: action.transcript.text
2455
2467
  };
2456
2468
  break;
2469
+ case "replay":
2470
+ state = {
2471
+ ...state,
2472
+ assistantTexts: [...action.assistantTexts],
2473
+ call: action.call ?? null,
2474
+ error: null,
2475
+ isConnected: action.status === "active",
2476
+ partial: action.partial,
2477
+ scenarioId: action.scenarioId ?? state.scenarioId,
2478
+ sessionId: action.sessionId,
2479
+ status: action.status,
2480
+ turns: [...action.turns]
2481
+ };
2482
+ break;
2457
2483
  case "session":
2458
2484
  state = {
2459
2485
  ...state,
@@ -5316,6 +5342,18 @@ var createVoiceSession = (options) => {
5316
5342
  type: "call_lifecycle"
5317
5343
  });
5318
5344
  };
5345
+ const sendReplay = async (session) => {
5346
+ await send({
5347
+ assistantTexts: session.turns.flatMap((turn) => turn.assistantText ? [turn.assistantText] : []),
5348
+ call: session.call,
5349
+ partial: session.currentTurn.partialText,
5350
+ scenarioId: session.scenarioId,
5351
+ sessionId: options.id,
5352
+ status: session.status,
5353
+ turns: session.turns,
5354
+ type: "replay"
5355
+ });
5356
+ };
5319
5357
  const runHandoff = async (input) => {
5320
5358
  const queuedDelivery = options.handoff?.deliveryQueue ? createVoiceHandoffDeliveryRecord({
5321
5359
  action: input.action,
@@ -6630,6 +6668,7 @@ var createVoiceSession = (options) => {
6630
6668
  scenarioId: session.scenarioId,
6631
6669
  type: "session"
6632
6670
  });
6671
+ await sendReplay(session);
6633
6672
  if (shouldFireOnSession) {
6634
6673
  await options.route.onCallStart?.({
6635
6674
  api,
package/dist/types.d.ts CHANGED
@@ -686,6 +686,16 @@ export type VoiceServerSessionMessage = {
686
686
  status: VoiceSessionStatus;
687
687
  scenarioId?: string;
688
688
  };
689
+ export type VoiceServerReplayMessage<TResult = unknown> = {
690
+ type: 'replay';
691
+ assistantTexts: string[];
692
+ call?: VoiceCallLifecycleState;
693
+ partial: string;
694
+ scenarioId?: string;
695
+ sessionId: string;
696
+ status: VoiceSessionStatus;
697
+ turns: VoiceTurnRecord<TResult>[];
698
+ };
689
699
  export type VoiceServerPartialMessage = {
690
700
  type: 'partial';
691
701
  transcript: Transcript;
@@ -727,7 +737,7 @@ export type VoiceServerErrorMessage = {
727
737
  export type VoiceServerPongMessage = {
728
738
  type: 'pong';
729
739
  };
730
- export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAudioMessage | VoiceServerCallLifecycleMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage;
740
+ export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerReplayMessage<TResult> | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAudioMessage | VoiceServerCallLifecycleMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage;
731
741
  export type VoiceConnectionOptions = {
732
742
  protocols?: string[];
733
743
  scenarioId?: string;
@@ -978,6 +988,15 @@ export type VoiceStoreAction<TResult = unknown> = {
978
988
  sessionId: string;
979
989
  scenarioId?: string;
980
990
  status: VoiceSessionStatus;
991
+ } | {
992
+ type: 'replay';
993
+ assistantTexts: string[];
994
+ call?: VoiceCallLifecycleState;
995
+ partial: string;
996
+ scenarioId?: string;
997
+ sessionId: string;
998
+ status: VoiceSessionStatus;
999
+ turns: VoiceTurnRecord<TResult>[];
981
1000
  } | {
982
1001
  type: 'call_lifecycle';
983
1002
  event: VoiceCallLifecycleEvent;
package/dist/vue/index.js CHANGED
@@ -2338,6 +2338,17 @@ var serverMessageToAction = (message) => {
2338
2338
  transcript: message.transcript,
2339
2339
  type: "partial"
2340
2340
  };
2341
+ case "replay":
2342
+ return {
2343
+ assistantTexts: message.assistantTexts,
2344
+ call: message.call,
2345
+ partial: message.partial,
2346
+ scenarioId: message.scenarioId,
2347
+ sessionId: message.sessionId,
2348
+ status: message.status,
2349
+ turns: message.turns,
2350
+ type: "replay"
2351
+ };
2341
2352
  case "session":
2342
2353
  return {
2343
2354
  sessionId: message.sessionId,
@@ -2402,6 +2413,7 @@ var isVoiceServerMessage = (value) => {
2402
2413
  case "final":
2403
2414
  case "partial":
2404
2415
  case "pong":
2416
+ case "replay":
2405
2417
  case "session":
2406
2418
  case "turn":
2407
2419
  return true;
@@ -2666,6 +2678,20 @@ var createVoiceStreamStore = () => {
2666
2678
  partial: action.transcript.text
2667
2679
  };
2668
2680
  break;
2681
+ case "replay":
2682
+ state = {
2683
+ ...state,
2684
+ assistantTexts: [...action.assistantTexts],
2685
+ call: action.call ?? null,
2686
+ error: null,
2687
+ isConnected: action.status === "active",
2688
+ partial: action.partial,
2689
+ scenarioId: action.scenarioId ?? state.scenarioId,
2690
+ sessionId: action.sessionId,
2691
+ status: action.status,
2692
+ turns: [...action.turns]
2693
+ };
2694
+ break;
2669
2695
  case "session":
2670
2696
  state = {
2671
2697
  ...state,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.128",
3
+ "version": "0.0.22-beta.129",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",