@autoscriber/core 0.1.8 → 0.2.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.
@@ -20,6 +20,7 @@ export declare class AudioManager {
20
20
  stopRecorder(): void;
21
21
  stopPlayer(): void;
22
22
  teardown(): void;
23
+ isRecorderActive(): boolean;
23
24
  playbackPcm(buffer: ArrayBuffer): void;
24
25
  endOfAudio(): void;
25
26
  private convertFloat32ToPCM;
@@ -1 +1 @@
1
- {"version":3,"file":"audio-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-manager.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,eAAe,CAA6B;IAEpD,OAAO,CAAC,YAAY,CAAiC;IAErD,OAAO,CAAC,aAAa,CAA6B;IAElD,OAAO,CAAC,UAAU,CAAiC;IAEnD,OAAO,CAAC,SAAS,CAA4B;IAE7C,OAAO,CAAC,gBAAgB,CAAuB;IAE/C,OAAO,CAAC,gBAAgB,CAAiB;IAEnC,IAAI,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAStD,WAAW,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B7D,aAAa,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDrE,IAAI,IAAI,IAAI;IAKZ,YAAY,IAAI,IAAI;IAepB,UAAU,IAAI,IAAI;IAWlB,QAAQ,IAAI,IAAI;IAIhB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAKtC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,mBAAmB;CAO5B"}
1
+ {"version":3,"file":"audio-manager.d.ts","sourceRoot":"","sources":["../../src/audio/audio-manager.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,eAAe,CAA6B;IAEpD,OAAO,CAAC,YAAY,CAAiC;IAErD,OAAO,CAAC,aAAa,CAA6B;IAElD,OAAO,CAAC,UAAU,CAAiC;IAEnD,OAAO,CAAC,SAAS,CAA4B;IAE7C,OAAO,CAAC,gBAAgB,CAAuB;IAE/C,OAAO,CAAC,gBAAgB,CAAiB;IAEnC,IAAI,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAStD,WAAW,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B7D,aAAa,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDrE,IAAI,IAAI,IAAI;IAKZ,YAAY,IAAI,IAAI;IAepB,UAAU,IAAI,IAAI;IAWlB,QAAQ,IAAI,IAAI;IAIhB,gBAAgB,IAAI,OAAO;IAI3B,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAKtC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,mBAAmB;CAO5B"}
@@ -73,6 +73,12 @@ export declare class AssistantClient {
73
73
  private sendBufferedAudio;
74
74
  private concatPcmChunks;
75
75
  private resumeTranscriptionAfterVoiceCommand;
76
+ /**
77
+ * Resume recording after reconnection if it was active before disconnection.
78
+ * Only resumes transcription mode (not voice commands, which are short-lived).
79
+ * Checks if AudioManager is still active and restarts it if needed.
80
+ */
81
+ private resumeRecordingIfNeeded;
76
82
  private sendVoiceCommandAudio;
77
83
  private handleMessage;
78
84
  private handleErrorResponse;
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-client.d.ts","sourceRoot":"","sources":["../../src/core/assistant-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAEhB,cAAc,EAEd,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAwBlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmC;IAEvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IAEzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAE3C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwC;IAErE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAE5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEzD,OAAO,CAAC,KAAK,CAAS;IAEtB,OAAO,CAAC,QAAQ,CAAoB;IAEpC,OAAO,CAAC,WAAW,CAAuB;IAE1C,OAAO,CAAC,WAAW,CAAoB;IAEvC,OAAO,CAAC,kBAAkB,CAAoB;IAE9C,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,eAAe,CAAqC;IAE5D,OAAO,CAAC,cAAc,CAA8C;IAEpE,OAAO,CAAC,iBAAiB,CAAK;IAE9B,OAAO,CAAC,mBAAmB,CAAK;IAEhC,OAAO,CAAC,uBAAuB,CAAuB;IAEtD,OAAO,CAAC,oBAAoB,CAAS;IAErC,OAAO,CAAC,YAAY,CAAS;IAE7B;;;OAGG;IACH,O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116
  connectionRestored: "Connection restored",
117
117
  offlineBuffering: "Message buffered - will resend once connected",
118
118
  connectionLost: "\u26A0\uFE0F Connection lost - reconnecting...",
119
- serviceUnavailable: "\u26A0\uFE0F Service unavailable - reconnecting..."
119
+ serviceUnavailable: "\u26A0\uFE0F Service unavailable - reconnecting...",
120
+ transcriptionResumed: "Transcription resumed",
121
+ recordingInterrupted: "\u26A0\uFE0F Recording interrupted - please start transcription again"
120
122
  },
121
123
  nl: {
122
124
  askAnything: "Stel je vraag...",
@@ -150,7 +152,9 @@ var TRANSLATIONS = {
150
152
  connectionRestored: "Verbinding hersteld",
151
153
  offlineBuffering: "Bericht gebufferd - wordt verzonden zodra we weer online zijn",
152
154
  connectionLost: "\u26A0\uFE0F Verbinding verbroken - opnieuw verbinden...",
153
- serviceUnavailable: "\u26A0\uFE0F Service niet beschikbaar - opnieuw verbinden..."
155
+ serviceUnavailable: "\u26A0\uFE0F Service niet beschikbaar - opnieuw verbinden...",
156
+ transcriptionResumed: "Transcriptie hervat",
157
+ recordingInterrupted: "\u26A0\uFE0F Opname onderbroken - start transcriptie opnieuw"
154
158
  },
155
159
  de: {
156
160
  askAnything: "Stellen Sie eine Frage...",
@@ -184,7 +188,9 @@ var TRANSLATIONS = {
184
188
  connectionRestored: "Verbindung wiederhergestellt",
185
189
  offlineBuffering: "Nachricht gepuffert \u2013 wird gesendet, sobald wir wieder online sind",
186
190
  connectionLost: "\u26A0\uFE0F Verbindung verloren \u2013 erneut verbinden...",
187
- serviceUnavailable: "\u26A0\uFE0F Service nicht verf\xFCgbar \u2013 erneut verbinden..."
191
+ serviceUnavailable: "\u26A0\uFE0F Service nicht verf\xFCgbar \u2013 erneut verbinden...",
192
+ transcriptionResumed: "Transkription fortgesetzt",
193
+ recordingInterrupted: "\u26A0\uFE0F Aufnahme unterbrochen \u2013 bitte Transkription erneut starten"
188
194
  }
189
195
  };
190
196
  var DEFAULT_LANGUAGE = "en";
@@ -663,6 +669,9 @@ var AudioManager = class {
663
669
  teardown() {
664
670
  this.stop();
665
671
  }
672
+ isRecorderActive() {
673
+ return this.recorderContext !== null && this.micStream !== null;
674
+ }
666
675
  playbackPcm(buffer) {
667
676
  if (!this.playerNode)
668
677
  return;
@@ -1462,6 +1471,7 @@ var AssistantClient = class {
1462
1471
  this.emitConnection();
1463
1472
  this.flushOfflineQueue();
1464
1473
  this.hasConnected = true;
1474
+ void this.resumeRecordingIfNeeded();
1465
1475
  });
1466
1476
  this.websocket.on("close", () => {
1467
1477
  const preserveOffline = this.snapshot.connection.reason === "offline";
@@ -1910,6 +1920,72 @@ var AssistantClient = class {
1910
1920
  this.resetRecordingState();
1911
1921
  }
1912
1922
  }
1923
+ /**
1924
+ * Resume recording after reconnection if it was active before disconnection.
1925
+ * Only resumes transcription mode (not voice commands, which are short-lived).
1926
+ * Checks if AudioManager is still active and restarts it if needed.
1927
+ */
1928
+ async resumeRecordingIfNeeded() {
1929
+ if (!this.snapshot.recording.isRecording || this.snapshot.recording.mode !== "transcription") {
1930
+ return;
1931
+ }
1932
+ const transcriptionId = this.snapshot.recording.transcriptionId;
1933
+ const isPaused = this.snapshot.recording.isPaused;
1934
+ try {
1935
+ const isActive = this.audioManager.isRecorderActive();
1936
+ if (!isActive) {
1937
+ this.logger.info("[Autoscriber] Restarting AudioManager after reconnection");
1938
+ await this.audioManager.init({
1939
+ deviceId: this.snapshot.microphones.selected?.deviceId,
1940
+ targetSampleRate: this.options.targetSampleRate,
1941
+ onRecorderData: (pcm16) => this.handleRecorderData(pcm16, "transcription")
1942
+ });
1943
+ try {
1944
+ await this.wakeLockManager.request();
1945
+ } catch (error) {
1946
+ this.logger.warn("[Autoscriber] Failed to acquire wake lock on resume", error);
1947
+ }
1948
+ }
1949
+ if (!this.bufferTimer) {
1950
+ this.bufferTimer = window.setInterval(() => {
1951
+ if (this.snapshot.recording.mode === "transcription" && this.audioBuffer.length > 0 && !this.snapshot.recording.isPaused) {
1952
+ this.sendBufferedAudio();
1953
+ }
1954
+ }, 5e3);
1955
+ }
1956
+ const sessionId = getSessionIdFromToken(this.token);
1957
+ this.logStructured("info", "Recording resumed after reconnection", {
1958
+ transcriptionId,
1959
+ sessionId: sessionId ?? "unknown",
1960
+ audioManagerRestarted: !isActive
1961
+ });
1962
+ if (!isActive) {
1963
+ this.pushInteraction({
1964
+ id: generateMessageId(),
1965
+ label: translate(this.snapshot.language, "transcriptionResumed"),
1966
+ status: "success",
1967
+ type: "transcription",
1968
+ metadata: { translationKey: "transcriptionResumed" }
1969
+ });
1970
+ }
1971
+ } catch (error) {
1972
+ this.logger.error("[Autoscriber] Failed to resume recording after reconnection", error);
1973
+ const sessionId = getSessionIdFromToken(this.token);
1974
+ this.logStructured("error", "Failed to resume recording", {
1975
+ transcriptionId,
1976
+ sessionId: sessionId ?? "unknown",
1977
+ error: error instanceof Error ? error.message : String(error)
1978
+ });
1979
+ this.resetRecordingState();
1980
+ this.pushInteraction({
1981
+ id: generateMessageId(),
1982
+ label: translate(this.snapshot.language, "recordingInterrupted"),
1983
+ status: "error",
1984
+ type: "transcription",
1985
+ metadata: { translationKey: "recordingInterrupted" }
1986
+ });
1987
+ }
1988
+ }
1913
1989
  sendVoiceCommandAudio() {
1914
1990
  if (this.voiceCommandBuffer.length === 0)
1915
1991
  return;
package/dist/index.js CHANGED
@@ -88,7 +88,9 @@ var TRANSLATIONS = {
88
88
  connectionRestored: "Connection restored",
89
89
  offlineBuffering: "Message buffered - will resend once connected",
90
90
  connectionLost: "\u26A0\uFE0F Connection lost - reconnecting...",
91
- serviceUnavailable: "\u26A0\uFE0F Service unavailable - reconnecting..."
91
+ serviceUnavailable: "\u26A0\uFE0F Service unavailable - reconnecting...",
92
+ transcriptionResumed: "Transcription resumed",
93
+ recordingInterrupted: "\u26A0\uFE0F Recording interrupted - please start transcription again"
92
94
  },
93
95
  nl: {
94
96
  askAnything: "Stel je vraag...",
@@ -122,7 +124,9 @@ var TRANSLATIONS = {
122
124
  connectionRestored: "Verbinding hersteld",
123
125
  offlineBuffering: "Bericht gebufferd - wordt verzonden zodra we weer online zijn",
124
126
  connectionLost: "\u26A0\uFE0F Verbinding verbroken - opnieuw verbinden...",
125
- serviceUnavailable: "\u26A0\uFE0F Service niet beschikbaar - opnieuw verbinden..."
127
+ serviceUnavailable: "\u26A0\uFE0F Service niet beschikbaar - opnieuw verbinden...",
128
+ transcriptionResumed: "Transcriptie hervat",
129
+ recordingInterrupted: "\u26A0\uFE0F Opname onderbroken - start transcriptie opnieuw"
126
130
  },
127
131
  de: {
128
132
  askAnything: "Stellen Sie eine Frage...",
@@ -156,7 +160,9 @@ var TRANSLATIONS = {
156
160
  connectionRestored: "Verbindung wiederhergestellt",
157
161
  offlineBuffering: "Nachricht gepuffert \u2013 wird gesendet, sobald wir wieder online sind",
158
162
  connectionLost: "\u26A0\uFE0F Verbindung verloren \u2013 erneut verbinden...",
159
- serviceUnavailable: "\u26A0\uFE0F Service nicht verf\xFCgbar \u2013 erneut verbinden..."
163
+ serviceUnavailable: "\u26A0\uFE0F Service nicht verf\xFCgbar \u2013 erneut verbinden...",
164
+ transcriptionResumed: "Transkription fortgesetzt",
165
+ recordingInterrupted: "\u26A0\uFE0F Aufnahme unterbrochen \u2013 bitte Transkription erneut starten"
160
166
  }
161
167
  };
162
168
  var DEFAULT_LANGUAGE = "en";
@@ -635,6 +641,9 @@ var AudioManager = class {
635
641
  teardown() {
636
642
  this.stop();
637
643
  }
644
+ isRecorderActive() {
645
+ return this.recorderContext !== null && this.micStream !== null;
646
+ }
638
647
  playbackPcm(buffer) {
639
648
  if (!this.playerNode)
640
649
  return;
@@ -1434,6 +1443,7 @@ var AssistantClient = class {
1434
1443
  this.emitConnection();
1435
1444
  this.flushOfflineQueue();
1436
1445
  this.hasConnected = true;
1446
+ void this.resumeRecordingIfNeeded();
1437
1447
  });
1438
1448
  this.websocket.on("close", () => {
1439
1449
  const preserveOffline = this.snapshot.connection.reason === "offline";
@@ -1882,6 +1892,72 @@ var AssistantClient = class {
1882
1892
  this.resetRecordingState();
1883
1893
  }
1884
1894
  }
1895
+ /**
1896
+ * Resume recording after reconnection if it was active before disconnection.
1897
+ * Only resumes transcription mode (not voice commands, which are short-lived).
1898
+ * Checks if AudioManager is still active and restarts it if needed.
1899
+ */
1900
+ async resumeRecordingIfNeeded() {
1901
+ if (!this.snapshot.recording.isRecording || this.snapshot.recording.mode !== "transcription") {
1902
+ return;
1903
+ }
1904
+ const transcriptionId = this.snapshot.recording.transcriptionId;
1905
+ const isPaused = this.snapshot.recording.isPaused;
1906
+ try {
1907
+ const isActive = this.audioManager.isRecorderActive();
1908
+ if (!isActive) {
1909
+ this.logger.info("[Autoscriber] Restarting AudioManager after reconnection");
1910
+ await this.audioManager.init({
1911
+ deviceId: this.snapshot.microphones.selected?.deviceId,
1912
+ targetSampleRate: this.options.targetSampleRate,
1913
+ onRecorderData: (pcm16) => this.handleRecorderData(pcm16, "transcription")
1914
+ });
1915
+ try {
1916
+ await this.wakeLockManager.request();
1917
+ } catch (error) {
1918
+ this.logger.warn("[Autoscriber] Failed to acquire wake lock on resume", error);
1919
+ }
1920
+ }
1921
+ if (!this.bufferTimer) {
1922
+ this.bufferTimer = window.setInterval(() => {
1923
+ if (this.snapshot.recording.mode === "transcription" && this.audioBuffer.length > 0 && !this.snapshot.recording.isPaused) {
1924
+ this.sendBufferedAudio();
1925
+ }
1926
+ }, 5e3);
1927
+ }
1928
+ const sessionId = getSessionIdFromToken(this.token);
1929
+ this.logStructured("info", "Recording resumed after reconnection", {
1930
+ transcriptionId,
1931
+ sessionId: sessionId ?? "unknown",
1932
+ audioManagerRestarted: !isActive
1933
+ });
1934
+ if (!isActive) {
1935
+ this.pushInteraction({
1936
+ id: generateMessageId(),
1937
+ label: translate(this.snapshot.language, "transcriptionResumed"),
1938
+ status: "success",
1939
+ type: "transcription",
1940
+ metadata: { translationKey: "transcriptionResumed" }
1941
+ });
1942
+ }
1943
+ } catch (error) {
1944
+ this.logger.error("[Autoscriber] Failed to resume recording after reconnection", error);
1945
+ const sessionId = getSessionIdFromToken(this.token);
1946
+ this.logStructured("error", "Failed to resume recording", {
1947
+ transcriptionId,
1948
+ sessionId: sessionId ?? "unknown",
1949
+ error: error instanceof Error ? error.message : String(error)
1950
+ });
1951
+ this.resetRecordingState();
1952
+ this.pushInteraction({
1953
+ id: generateMessageId(),
1954
+ label: translate(this.snapshot.language, "recordingInterrupted"),
1955
+ status: "error",
1956
+ type: "transcription",
1957
+ metadata: { translationKey: "recordingInterrupted" }
1958
+ });
1959
+ }
1960
+ }
1885
1961
  sendVoiceCommandAudio() {
1886
1962
  if (this.voiceCommandBuffer.length === 0)
1887
1963
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AA0HlD,wBAAgB,SAAS,CACvB,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,GAC3C,MAAM,CASR;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,iBAAiB,CASjE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnF"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/utils/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAgIlD,wBAAgB,SAAS,CACvB,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,GAC3C,MAAM,CASR;AAED,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,iBAAiB,CASjE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoscriber/core",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "Headless Autoscriber Assistant SDK for web applications.",
5
5
  "license": "MIT",
6
6
  "keywords": [