@escapeaihq/client-core 0.4.1 → 0.5.0

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/src/audio.ts CHANGED
@@ -247,6 +247,18 @@ export class AudioFramePlayer {
247
247
  this.context = new AudioContext({ sampleRate: SAMPLE_RATE });
248
248
  this.gainNode = this.context.createGain();
249
249
  this.gainNode.connect(this.context.destination);
250
+
251
+ // Re-anchor queuedTime on AudioContext resume so post-suspension
252
+ // frames aren't scheduled in the past (mobile lock screen / tab
253
+ // background recovery). See docs/features/2026-05-10-audio-pipeline-safety-net.md.
254
+ this.context.onstatechange = () => {
255
+ if (
256
+ this.context.state === 'running' &&
257
+ this.queuedTime < this.context.currentTime
258
+ ) {
259
+ this.queuedTime = this.context.currentTime;
260
+ }
261
+ };
250
262
  }
251
263
 
252
264
  /** Return the playback time elapsed since the first frame was scheduled. */
package/src/websocket.ts CHANGED
@@ -26,6 +26,18 @@ export interface ToolResult {
26
26
  citations: Citation[];
27
27
  }
28
28
 
29
+ /** Why an audio session ended.
30
+ * - `'complete'`: normal end of an assistant turn (no `reason` field set
31
+ * on the wire today; treat absent as `'complete'`).
32
+ * - `'timeout'`: server-side `_receive_messages` loop exceeded
33
+ * `default_timeout` waiting for the next client frame. The STT
34
+ * pipeline is dead on the server; the client must tear down the
35
+ * recorder and re-handshake to resume voice.
36
+ * - Future reasons may be added; the trailing `(string & {})` keeps
37
+ * autocomplete for known values without rejecting unknown strings.
38
+ */
39
+ export type DoneReason = 'complete' | 'timeout' | (string & {});
40
+
29
41
  export interface WebSocketMessage {
30
42
  type:
31
43
  | 'token'
@@ -54,6 +66,8 @@ export interface WebSocketMessage {
54
66
  final?: boolean;
55
67
  text?: string;
56
68
  resultId?: string;
69
+ /** Set on `{type: 'done'}` messages — see `DoneReason`. */
70
+ reason?: DoneReason;
57
71
  mode?: 'hybrid' | 'sonic';
58
72
  sessionId?: string;
59
73
  // Image regeneration fields