@@ -51,6 +51,7 @@ import {
|
51 | 51 | convertDiscordPcm48kStereoToRealtimePcm24kMono, |
52 | 52 | convertRealtimePcm24kMonoToDiscordPcm48kStereo, |
53 | 53 | } from "./audio.js"; |
| 54 | +import { formatVoiceLogPreview } from "./log-preview.js"; |
54 | 55 | import { formatVoiceIngressPrompt } from "./prompt.js"; |
55 | 56 | import { loadDiscordVoiceSdk } from "./sdk-runtime.js"; |
56 | 57 | import { |
@@ -81,7 +82,6 @@ const DISCORD_REALTIME_RECENT_AGENT_PROXY_CONSULT_LIMIT = 16;
|
81 | 82 | const DISCORD_REALTIME_RECENT_AGENT_PROXY_CONSULT_TTL_MS = 15_000; |
82 | 83 | const DISCORD_REALTIME_IGNORED_WAKE_NAME_CONTEXT_TTL_MS = 10_000; |
83 | 84 | const DISCORD_REALTIME_WAKE_NAME_FOLLOWUP_TTL_MS = 10_000; |
84 | | -const DISCORD_REALTIME_LOG_PREVIEW_CHARS = 500; |
85 | 85 | const DISCORD_REALTIME_DEFAULT_MIN_BARGE_IN_AUDIO_END_MS = 250; |
86 | 86 | const DISCORD_REALTIME_FORCED_CONSULT_FALLBACK_DELAY_MS = 200; |
87 | 87 | const DISCORD_REALTIME_DUPLICATE_ERROR_SUPPRESS_MS = 60_000; |
@@ -139,14 +139,6 @@ type AgentProxyConsultState = {
|
139 | 139 | |
140 | 140 | type AgentProxyConsultHandle = RealtimeVoiceForcedConsultHandle<AgentProxyConsultState>; |
141 | 141 | |
142 | | -function formatRealtimeLogPreview(text: string): string { |
143 | | -const oneLine = text.replace(/\s+/g, " ").trim(); |
144 | | -if (oneLine.length <= DISCORD_REALTIME_LOG_PREVIEW_CHARS) { |
145 | | -return oneLine; |
146 | | -} |
147 | | -return `${oneLine.slice(0, DISCORD_REALTIME_LOG_PREVIEW_CHARS)}...`; |
148 | | -} |
149 | | - |
150 | 142 | function formatRealtimeInterruptionLog(event: RealtimeVoiceBridgeEvent): string | undefined { |
151 | 143 | const detail = event.detail ? ` ${event.detail}` : ""; |
152 | 144 | if (event.direction === "client") { |
@@ -522,7 +514,7 @@ export class DiscordRealtimeVoiceSession implements VoiceRealtimeSession {
|
522 | 514 | onTranscript: (role, text, isFinal) => { |
523 | 515 | if (isFinal && text.trim()) { |
524 | 516 | logger.info( |
525 | | -`discord voice: realtime ${role} transcript (${text.length} chars): ${formatRealtimeLogPreview(text)}`, |
| 517 | +`discord voice: realtime ${role} transcript (${text.length} chars): ${formatVoiceLogPreview(text)}`, |
526 | 518 | ); |
527 | 519 | } |
528 | 520 | if (isFinal && role === "assistant") { |
@@ -1420,7 +1412,7 @@ export class DiscordRealtimeVoiceSession implements VoiceRealtimeSession {
|
1420 | 1412 | if (skipReason) { |
1421 | 1413 | const context = this.consumePendingSpeakerContext(); |
1422 | 1414 | logger.info( |
1423 | | -`discord voice: realtime forced agent consult skipped reason=${skipReason} chars=${question.length} speaker=${context?.speakerLabel ?? "unknown"} transcript=${formatRealtimeLogPreview(question)}`, |
| 1415 | +`discord voice: realtime forced agent consult skipped reason=${skipReason} chars=${question.length} speaker=${context?.speakerLabel ?? "unknown"} transcript=${formatVoiceLogPreview(question)}`, |
1424 | 1416 | ); |
1425 | 1417 | return undefined; |
1426 | 1418 | } |
|