@markusylisiurunen/tau 0.3.101 → 0.3.102
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/dist/core/config/ownership.js +3 -1
- package/dist/core/config/ownership.js.map +1 -1
- package/dist/core/config/schema.js +3 -1
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/history/migrations.js +6 -1
- package/dist/core/history/migrations.js.map +1 -1
- package/dist/core/static/tau_docs/config-reference.md +17 -5
- package/dist/core/static/tau_docs/credentials.md +4 -4
- package/dist/core/static/tau_docs/index.md +2 -1
- package/dist/core/static/tau_docs/manifest.json +1 -0
- package/dist/core/static/tau_docs/prompts-and-project-context.md +4 -4
- package/dist/core/static/tau_docs/session-protocol.md +1 -1
- package/dist/core/static/tau_docs/telegram-commands.md +55 -0
- package/dist/core/static/tau_docs/telegram.md +10 -38
- package/dist/core/static/tau_docs/tui.md +17 -11
- package/dist/core/subagents/claude_code_runner.mjs +65 -65
- package/dist/core/telegram/adapter.js +178 -61
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/cli.js +1 -3
- package/dist/core/telegram/cli.js.map +1 -1
- package/dist/core/telegram/config.js +3 -1
- package/dist/core/telegram/config.js.map +1 -1
- package/dist/core/telegram/runtime.js +1 -1
- package/dist/core/telegram/runtime.js.map +1 -1
- package/dist/core/utils/scribe_transcription.js +283 -0
- package/dist/core/utils/scribe_transcription.js.map +1 -0
- package/dist/core/utils/speech_cleanup.js +198 -0
- package/dist/core/utils/speech_cleanup.js.map +1 -0
- package/dist/core/utils/speech_to_text.js +3 -3
- package/dist/core/utils/speech_to_text_keywords.js +5 -4
- package/dist/core/utils/speech_to_text_keywords.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/diff_tool/app/dist/assets/{core-CXVpaOO1.js → core-Cnp6wBC7.js} +1 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-ConHyUk6.js +1 -0
- package/dist/diff_tool/app/dist/assets/{highlights-DuJNYjEh.js → highlights-DeO0fGqQ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/index-BDuQ2wXS.js +221 -0
- package/dist/diff_tool/app/dist/assets/langs-DDFHLNuJ.js +1 -0
- package/dist/diff_tool/app/dist/assets/{loader-bi21_x0K.js → loader-DrwOwtvp.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{preload-helper-CRzLMJPS.js → preload-helper-DclECHGd.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shiki-D6ZyrNQD.js → shiki-CwKGJZFi.js} +2 -2
- package/dist/diff_tool/app/dist/assets/{stream-tokenizer-BdsyU_yB.js → stream-tokenizer-D4-m26wx.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{themes-9lpTYI_i.js → themes-Do3waJhf.js} +2 -2
- package/dist/diff_tool/app/dist/index.html +2 -2
- package/dist/history/worker/index.js +77 -51
- package/dist/history/worker/index.js.map +1 -1
- package/dist/history/worker/migrations/0003_digest_schedule.sql +36 -0
- package/dist/history/worker/migrations/0004_recent_sessions.sql +1 -0
- package/dist/store/session_snapshot_migrations.js +14 -1
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/dist/tui/chat_view.js +3 -1
- package/dist/tui/chat_view.js.map +1 -1
- package/dist/tui/listen_capture.js +7 -5
- package/dist/tui/listen_capture.js.map +1 -1
- package/dist/tui/session_chat_controller.js +93 -15
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/ui/custom_editor.js +3 -0
- package/dist/tui/ui/custom_editor.js.map +1 -1
- package/package.json +8 -7
- package/dist/core/utils/gemini_transcription.js +0 -566
- package/dist/core/utils/gemini_transcription.js.map +0 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-Rz_7DPcV.js +0 -1
- package/dist/diff_tool/app/dist/assets/index-F9is7PUw.js +0 -221
- package/dist/diff_tool/app/dist/assets/langs-CTftvgbb.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFile, unlink } from "node:fs/promises";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { getElevenLabsApiKey, getOpenAIApiKey } from "../core/config/index.js";
|
|
5
5
|
import { createSpeechToTextTranscription, } from "../core/utils/speech_to_text.js";
|
|
6
6
|
export const LISTEN_TEMP_FILE_TEMPLATE = join(tmpdir(), "tau-listen.XXXXXX");
|
|
7
7
|
export const LISTEN_CAPTURE_START_TIMEOUT_MS = 15_000;
|
|
@@ -108,17 +108,19 @@ export async function cleanupListenTempFile(path) {
|
|
|
108
108
|
}
|
|
109
109
|
export function resolveSpeechToTextCredentials(config, deps) {
|
|
110
110
|
const env = deps.env.env();
|
|
111
|
-
const
|
|
112
|
-
return
|
|
111
|
+
const elevenLabsApiKey = getElevenLabsApiKey(config, env);
|
|
112
|
+
return elevenLabsApiKey
|
|
113
|
+
? { elevenLabsApiKey, openAIApiKey: getOpenAIApiKey(config, env) }
|
|
114
|
+
: undefined;
|
|
113
115
|
}
|
|
114
116
|
export function getSpeechToTextApiKeyErrorMessage(action) {
|
|
115
|
-
return `set
|
|
117
|
+
return `set ELEVENLABS_API_KEY or apiKeys.elevenlabs to ${action}`;
|
|
116
118
|
}
|
|
117
119
|
export function createListenTranscription(args) {
|
|
118
120
|
return createSpeechToTextTranscription({
|
|
119
121
|
onProgress: args.onProgress,
|
|
120
122
|
mode: args.mode,
|
|
121
|
-
apiKey: args.credentials.
|
|
123
|
+
apiKey: args.credentials.elevenLabsApiKey,
|
|
122
124
|
openAIApiKey: args.credentials.openAIApiKey,
|
|
123
125
|
context: args.context,
|
|
124
126
|
vocabulary: args.vocabulary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listen_capture.js","sourceRoot":"","sources":["../../src/tui/listen_capture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS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AAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO,gBAAgB;QACrB,CAAC,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;QAClE,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,MAAc;IAC9D,OAAO,mDAAmD,MAAM,EAAE,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAOzC;IACC,OAAO,+BAA+B,CAAC;QACrC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,gBAAgB;QACzC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY;QAC3C,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,IAAI,EAAE,IAAI,CAAC,gBAAgB;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -12,6 +12,7 @@ import { TOOL_NAME_BASH } from "../core/tools/tool_names.js";
|
|
|
12
12
|
import { REASONING_LEVELS } from "../core/types.js";
|
|
13
13
|
import { formatAdaptiveNumber, formatCwd, formatTokenWindow } from "../core/utils/format.js";
|
|
14
14
|
import { extractAssistantText } from "../core/utils/messages.js";
|
|
15
|
+
import { cleanupSpeechTranscript, nextSpeechCleanupStyle, prepareSpeechCleanup, } from "../core/utils/speech_cleanup.js";
|
|
15
16
|
import { getSpeechToTextRecordingMaxDurationMs, getSpeechToTextStreamingSampleRate, SPEECH_TO_TEXT_CLIENT_MAX_DURATION_MS, } from "../core/utils/speech_to_text.js";
|
|
16
17
|
import { collectSpeechToTextContext } from "../core/utils/speech_to_text_context.js";
|
|
17
18
|
import { composeSpeechVocabulary } from "../core/utils/speech_to_text_keywords.js";
|
|
@@ -92,6 +93,8 @@ export class SessionChatController {
|
|
|
92
93
|
listenTransition;
|
|
93
94
|
listenStartupAbortController;
|
|
94
95
|
activeListenTranscription;
|
|
96
|
+
activeListenCleanup;
|
|
97
|
+
preparedListenCleanup;
|
|
95
98
|
listenActivityLabel;
|
|
96
99
|
listenPreview;
|
|
97
100
|
editorHiddenSystemMessages = [];
|
|
@@ -175,6 +178,7 @@ export class SessionChatController {
|
|
|
175
178
|
this.subagentActivitiesUnsubscribe?.();
|
|
176
179
|
this.listenStartupAbortController?.abort(LISTEN_CAPTURE_START_CANCELLED);
|
|
177
180
|
this.activeListenTranscription?.abort();
|
|
181
|
+
this.activeListenCleanup?.abort();
|
|
178
182
|
if (this.listenTransition) {
|
|
179
183
|
await this.listenTransition;
|
|
180
184
|
}
|
|
@@ -231,6 +235,7 @@ export class SessionChatController {
|
|
|
231
235
|
onCtrlP: () => void this.cyclePersonality(),
|
|
232
236
|
onCtrlS: () => void this.stashEditorToClipboard(),
|
|
233
237
|
onToggleRecording: () => void this.toggleListenCapture(),
|
|
238
|
+
onCycleRecordingStyle: () => this.cycleListenCleanupStyle(),
|
|
234
239
|
recordingShortcut: this.config.speech.recordingShortcut,
|
|
235
240
|
onDisabledSubmit: (mode) => {
|
|
236
241
|
if (this.listenRecording && !this.listenTransition) {
|
|
@@ -641,6 +646,7 @@ export class SessionChatController {
|
|
|
641
646
|
this.listenPreview) {
|
|
642
647
|
this.listenStartupAbortController?.abort(LISTEN_CAPTURE_START_CANCELLED);
|
|
643
648
|
this.activeListenTranscription?.abort();
|
|
649
|
+
this.activeListenCleanup?.abort();
|
|
644
650
|
this.endListenPreview();
|
|
645
651
|
this.listenActivityLabel = undefined;
|
|
646
652
|
if (this.listenRecording) {
|
|
@@ -704,6 +710,25 @@ export class SessionChatController {
|
|
|
704
710
|
}
|
|
705
711
|
await this.startListenCaptureFromCommand();
|
|
706
712
|
}
|
|
713
|
+
cycleListenCleanupStyle() {
|
|
714
|
+
const recording = this.listenRecording;
|
|
715
|
+
if (!recording)
|
|
716
|
+
return;
|
|
717
|
+
recording.cleanupStyle = nextSpeechCleanupStyle(recording.cleanupStyle);
|
|
718
|
+
this.prepareListenCleanup(recording.cleanupStyle);
|
|
719
|
+
this.refreshStatus();
|
|
720
|
+
}
|
|
721
|
+
prepareListenCleanup(style) {
|
|
722
|
+
this.preparedListenCleanup?.dispose();
|
|
723
|
+
this.preparedListenCleanup =
|
|
724
|
+
style === "off"
|
|
725
|
+
? undefined
|
|
726
|
+
: prepareSpeechCleanup({
|
|
727
|
+
style,
|
|
728
|
+
apiKey: getOpenAIApiKey(this.config, this.deps.env.env()),
|
|
729
|
+
webSocketFactory: this.speechToTextDeps?.webSocketFactory,
|
|
730
|
+
});
|
|
731
|
+
}
|
|
707
732
|
async startListenCaptureFromCommand() {
|
|
708
733
|
if (this.pendingEditorMutations > 0) {
|
|
709
734
|
this.view.showFooterNotice("wait for the input update before recording", "default");
|
|
@@ -818,6 +843,7 @@ export class SessionChatController {
|
|
|
818
843
|
abortController,
|
|
819
844
|
completion,
|
|
820
845
|
transcription,
|
|
846
|
+
cleanupStyle: this.config.speech.cleanupStyle ?? "off",
|
|
821
847
|
};
|
|
822
848
|
recording.maxDurationTimeout = setTimeout(() => {
|
|
823
849
|
if (this.listenRecording !== recording || this.listenTransition)
|
|
@@ -825,6 +851,7 @@ export class SessionChatController {
|
|
|
825
851
|
void this.runListenTransition(() => this.stopListenCapture());
|
|
826
852
|
}, getSpeechToTextRecordingMaxDurationMs());
|
|
827
853
|
this.listenRecording = recording;
|
|
854
|
+
this.prepareListenCleanup(recording.cleanupStyle);
|
|
828
855
|
this.refreshStatus();
|
|
829
856
|
void this.watchListenRecording(recording);
|
|
830
857
|
}
|
|
@@ -900,7 +927,7 @@ export class SessionChatController {
|
|
|
900
927
|
return;
|
|
901
928
|
}
|
|
902
929
|
const durationMs = Math.min(Math.max(Date.now() - recording.startedAt, 0), SPEECH_TO_TEXT_CLIENT_MAX_DURATION_MS);
|
|
903
|
-
const transcribed = await this.transcribeListenAudioFile(recording.audioPath, durationMs, recording.transcription);
|
|
930
|
+
const transcribed = await this.transcribeListenAudioFile({ audioPath: recording.audioPath, durationMs, cleanupStyle: recording.cleanupStyle }, recording.transcription);
|
|
904
931
|
if (mode && transcribed && !this.disposed)
|
|
905
932
|
this.view.submitEditor(mode);
|
|
906
933
|
}
|
|
@@ -923,7 +950,7 @@ export class SessionChatController {
|
|
|
923
950
|
return;
|
|
924
951
|
}
|
|
925
952
|
await this.runListenTransition(async () => {
|
|
926
|
-
await this.transcribeListenAudioFile(retainedAudio
|
|
953
|
+
await this.transcribeListenAudioFile(retainedAudio);
|
|
927
954
|
});
|
|
928
955
|
}
|
|
929
956
|
async discardRetainedListenAudio() {
|
|
@@ -955,6 +982,8 @@ export class SessionChatController {
|
|
|
955
982
|
this.view.setEditorInputEnabled(false);
|
|
956
983
|
}
|
|
957
984
|
endListenPreview() {
|
|
985
|
+
this.preparedListenCleanup?.dispose();
|
|
986
|
+
this.preparedListenCleanup = undefined;
|
|
958
987
|
const preview = this.listenPreview;
|
|
959
988
|
this.listenPreview = undefined;
|
|
960
989
|
preview?.cancel();
|
|
@@ -978,7 +1007,8 @@ export class SessionChatController {
|
|
|
978
1007
|
},
|
|
979
1008
|
});
|
|
980
1009
|
}
|
|
981
|
-
async transcribeListenAudioFile(
|
|
1010
|
+
async transcribeListenAudioFile(recording, transcription) {
|
|
1011
|
+
const { audioPath } = recording;
|
|
982
1012
|
if (this.disposed) {
|
|
983
1013
|
transcription?.abort();
|
|
984
1014
|
if (this.retainedListenAudio?.audioPath === audioPath) {
|
|
@@ -991,9 +1021,9 @@ export class SessionChatController {
|
|
|
991
1021
|
this.beginListenPreview();
|
|
992
1022
|
const preview = this.listenPreview;
|
|
993
1023
|
try {
|
|
994
|
-
if (durationMs > SPEECH_TO_TEXT_CLIENT_MAX_DURATION_MS) {
|
|
1024
|
+
if (recording.durationMs > SPEECH_TO_TEXT_CLIENT_MAX_DURATION_MS) {
|
|
995
1025
|
transcription?.abort();
|
|
996
|
-
this.retainedListenAudio =
|
|
1026
|
+
this.retainedListenAudio = recording;
|
|
997
1027
|
this.view.addTranscriptNotice("failed to transcribe speech", "error", [
|
|
998
1028
|
"audio is longer than 20 minutes",
|
|
999
1029
|
`recording retained at ${audioPath}`,
|
|
@@ -1036,12 +1066,13 @@ export class SessionChatController {
|
|
|
1036
1066
|
return false;
|
|
1037
1067
|
}
|
|
1038
1068
|
let activeTranscription = transcription;
|
|
1069
|
+
let text;
|
|
1039
1070
|
this.listenActivityLabel = "transcribing voice input";
|
|
1040
1071
|
this.refreshStatus();
|
|
1041
1072
|
try {
|
|
1042
1073
|
activeTranscription ??= this.createSpeechTranscription("file");
|
|
1043
1074
|
this.activeListenTranscription = activeTranscription;
|
|
1044
|
-
|
|
1075
|
+
text = await activeTranscription.finish({
|
|
1045
1076
|
audio,
|
|
1046
1077
|
mimeType: "audio/wav",
|
|
1047
1078
|
});
|
|
@@ -1059,16 +1090,11 @@ export class SessionChatController {
|
|
|
1059
1090
|
}
|
|
1060
1091
|
if (this.listenPreview !== preview)
|
|
1061
1092
|
return false;
|
|
1062
|
-
preview.commit(text);
|
|
1063
|
-
if (text.trim() && !this.editorHiddenSystemMessages.includes(TRANSCRIPTION_GUIDANCE)) {
|
|
1064
|
-
this.editorHiddenSystemMessages.push(TRANSCRIPTION_GUIDANCE);
|
|
1065
|
-
}
|
|
1066
|
-
return Boolean(text.trim());
|
|
1067
1093
|
}
|
|
1068
1094
|
catch (error) {
|
|
1069
1095
|
if (this.listenPreview !== preview)
|
|
1070
1096
|
return false;
|
|
1071
|
-
this.retainedListenAudio =
|
|
1097
|
+
this.retainedListenAudio = recording;
|
|
1072
1098
|
this.view.addTranscriptNotice("failed to transcribe speech", "error", [
|
|
1073
1099
|
error.message,
|
|
1074
1100
|
`recording retained at ${audioPath}`,
|
|
@@ -1084,6 +1110,15 @@ export class SessionChatController {
|
|
|
1084
1110
|
this.listenActivityLabel = undefined;
|
|
1085
1111
|
this.refreshStatus();
|
|
1086
1112
|
}
|
|
1113
|
+
const cleanup = await this.cleanupListenTranscript(text, recording.cleanupStyle, preview);
|
|
1114
|
+
if (!cleanup || this.listenPreview !== preview)
|
|
1115
|
+
return false;
|
|
1116
|
+
preview.commit(cleanup.text);
|
|
1117
|
+
if (cleanup.text.trim() &&
|
|
1118
|
+
!this.editorHiddenSystemMessages.includes(TRANSCRIPTION_GUIDANCE)) {
|
|
1119
|
+
this.editorHiddenSystemMessages.push(TRANSCRIPTION_GUIDANCE);
|
|
1120
|
+
}
|
|
1121
|
+
return !cleanup.failed && Boolean(cleanup.text.trim());
|
|
1087
1122
|
}
|
|
1088
1123
|
finally {
|
|
1089
1124
|
if (this.listenPreview !== preview) {
|
|
@@ -1097,6 +1132,49 @@ export class SessionChatController {
|
|
|
1097
1132
|
}
|
|
1098
1133
|
}
|
|
1099
1134
|
}
|
|
1135
|
+
async cleanupListenTranscript(transcript, style, preview) {
|
|
1136
|
+
if (style === "off" || !transcript.trim())
|
|
1137
|
+
return { text: transcript, failed: false };
|
|
1138
|
+
preview.update(transcript);
|
|
1139
|
+
const abortController = new AbortController();
|
|
1140
|
+
this.activeListenCleanup = abortController;
|
|
1141
|
+
this.listenActivityLabel = "cleaning up voice input";
|
|
1142
|
+
this.refreshStatus();
|
|
1143
|
+
try {
|
|
1144
|
+
const input = {
|
|
1145
|
+
transcript,
|
|
1146
|
+
context: collectSpeechToTextContext(this.snapshot),
|
|
1147
|
+
vocabulary: composeSpeechVocabulary(this.snapshot.catalog.speechVocabulary, this.config.speech.personalVocabulary),
|
|
1148
|
+
signal: abortController.signal,
|
|
1149
|
+
};
|
|
1150
|
+
const text = this.preparedListenCleanup
|
|
1151
|
+
? await this.preparedListenCleanup.finish(input)
|
|
1152
|
+
: await cleanupSpeechTranscript({
|
|
1153
|
+
...input,
|
|
1154
|
+
style,
|
|
1155
|
+
apiKey: getOpenAIApiKey(this.config, this.deps.env.env()),
|
|
1156
|
+
fetchImpl: this.speechToTextDeps?.fetchImpl,
|
|
1157
|
+
});
|
|
1158
|
+
if (abortController.signal.aborted || this.listenPreview !== preview)
|
|
1159
|
+
return undefined;
|
|
1160
|
+
return { text, failed: false };
|
|
1161
|
+
}
|
|
1162
|
+
catch (error) {
|
|
1163
|
+
if (abortController.signal.aborted || this.listenPreview !== preview)
|
|
1164
|
+
return undefined;
|
|
1165
|
+
this.view.addTranscriptNotice("failed to clean up speech", "error", [
|
|
1166
|
+
error.message,
|
|
1167
|
+
"inserted the transcript without cleanup",
|
|
1168
|
+
]);
|
|
1169
|
+
return { text: transcript, failed: true };
|
|
1170
|
+
}
|
|
1171
|
+
finally {
|
|
1172
|
+
if (this.activeListenCleanup === abortController)
|
|
1173
|
+
this.activeListenCleanup = undefined;
|
|
1174
|
+
this.listenActivityLabel = undefined;
|
|
1175
|
+
this.refreshStatus();
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1100
1178
|
async cancelListenCapture() {
|
|
1101
1179
|
const recording = this.listenRecording;
|
|
1102
1180
|
if (!recording)
|
|
@@ -2331,7 +2409,9 @@ export class SessionChatController {
|
|
|
2331
2409
|
duration: this.getTurnDurationString(),
|
|
2332
2410
|
},
|
|
2333
2411
|
editor: {
|
|
2334
|
-
|
|
2412
|
+
...(this.listenRecording
|
|
2413
|
+
? { mode: "recording", recordingStyle: this.listenRecording.cleanupStyle }
|
|
2414
|
+
: { mode: this.getInputMode() }),
|
|
2335
2415
|
personaName: this.getCurrentPersonaSnapshot()?.label ?? this.snapshot.settings.personaId,
|
|
2336
2416
|
reasoningLabel: this.snapshot.settings.reasoning ?? "none",
|
|
2337
2417
|
reasoning: this.snapshot.settings.reasoning === undefined ||
|
|
@@ -2342,8 +2422,6 @@ export class SessionChatController {
|
|
|
2342
2422
|
});
|
|
2343
2423
|
}
|
|
2344
2424
|
getInputMode() {
|
|
2345
|
-
if (this.listenRecording)
|
|
2346
|
-
return "recording";
|
|
2347
2425
|
if (this.isBashIncognito)
|
|
2348
2426
|
return "bash_incognito";
|
|
2349
2427
|
if (this.isBashMode)
|