惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
量子位
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
D
Docker
罗磊的独立博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
IT之家
IT之家
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(discord): share voice log preview formatting · o...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,13 @@

1+

import { describe, expect, it } from "vitest";

2+

import { formatVoiceLogPreview } from "./log-preview.js";

3+
4+

describe("formatVoiceLogPreview", () => {

5+

it("collapses whitespace and trims the preview", () => {

6+

expect(formatVoiceLogPreview(" hello \n world\t")).toBe("hello world");

7+

});

8+
9+

it("truncates long previews after 500 characters", () => {

10+

const preview = formatVoiceLogPreview("x".repeat(501));

11+

expect(preview).toBe(`${"x".repeat(500)}...`);

12+

});

13+

});

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,9 @@

1+

const DISCORD_VOICE_LOG_PREVIEW_CHARS = 500;

2+
3+

export function formatVoiceLogPreview(text: string): string {

4+

const oneLine = text.replace(/\s+/g, " ").trim();

5+

if (oneLine.length <= DISCORD_VOICE_LOG_PREVIEW_CHARS) {

6+

return oneLine;

7+

}

8+

return `${oneLine.slice(0, DISCORD_VOICE_LOG_PREVIEW_CHARS)}...`;

9+

}

Original file line numberDiff line numberDiff line change

@@ -35,6 +35,7 @@ import {

3535

resolveDiscordVoiceIngressContext,

3636

runDiscordVoiceAgentTurn,

3737

} from "./ingress.js";

38+

import { formatVoiceLogPreview } from "./log-preview.js";

3839

import {

3940

DiscordRealtimeVoiceSession,

4041

type DiscordVoiceMode,

@@ -67,7 +68,6 @@ import {

6768

import { DiscordVoiceSpeakerContextResolver } from "./speaker-context.js";

6869
6970

const logger = createSubsystemLogger("discord/voice");

70-

const VOICE_LOG_PREVIEW_CHARS = 500;

7171

const FOLLOW_USERS_RECONCILE_INTERVAL_MS = 10_000;

7272

const FOLLOW_USERS_RECONCILE_MAX_GUILDS_PER_RUN = 4;

7373

const FOLLOW_USERS_RECONCILE_MAX_REST_LOOKUPS_PER_RUN = 32;

@@ -96,14 +96,6 @@ type VoiceChannelResidency = {

9696

channelId: string;

9797

};

9898
99-

function formatVoiceLogPreview(text: string): string {

100-

const oneLine = text.replace(/\s+/g, " ").trim();

101-

if (oneLine.length <= VOICE_LOG_PREVIEW_CHARS) {

102-

return oneLine;

103-

}

104-

return `${oneLine.slice(0, VOICE_LOG_PREVIEW_CHARS)}...`;

105-

}

106-
10799

function isVoiceConnectionDestroyed(

108100

connection: DiscordVoiceConnection,

109101

voiceSdk: DiscordVoiceSdk,

Original file line numberDiff line numberDiff line change

@@ -51,6 +51,7 @@ import {

5151

convertDiscordPcm48kStereoToRealtimePcm24kMono,

5252

convertRealtimePcm24kMonoToDiscordPcm48kStereo,

5353

} from "./audio.js";

54+

import { formatVoiceLogPreview } from "./log-preview.js";

5455

import { formatVoiceIngressPrompt } from "./prompt.js";

5556

import { loadDiscordVoiceSdk } from "./sdk-runtime.js";

5657

import {

@@ -81,7 +82,6 @@ const DISCORD_REALTIME_RECENT_AGENT_PROXY_CONSULT_LIMIT = 16;

8182

const DISCORD_REALTIME_RECENT_AGENT_PROXY_CONSULT_TTL_MS = 15_000;

8283

const DISCORD_REALTIME_IGNORED_WAKE_NAME_CONTEXT_TTL_MS = 10_000;

8384

const DISCORD_REALTIME_WAKE_NAME_FOLLOWUP_TTL_MS = 10_000;

84-

const DISCORD_REALTIME_LOG_PREVIEW_CHARS = 500;

8585

const DISCORD_REALTIME_DEFAULT_MIN_BARGE_IN_AUDIO_END_MS = 250;

8686

const DISCORD_REALTIME_FORCED_CONSULT_FALLBACK_DELAY_MS = 200;

8787

const DISCORD_REALTIME_DUPLICATE_ERROR_SUPPRESS_MS = 60_000;

@@ -139,14 +139,6 @@ type AgentProxyConsultState = {

139139
140140

type AgentProxyConsultHandle = RealtimeVoiceForcedConsultHandle<AgentProxyConsultState>;

141141
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-
150142

function formatRealtimeInterruptionLog(event: RealtimeVoiceBridgeEvent): string | undefined {

151143

const detail = event.detail ? ` ${event.detail}` : "";

152144

if (event.direction === "client") {

@@ -522,7 +514,7 @@ export class DiscordRealtimeVoiceSession implements VoiceRealtimeSession {

522514

onTranscript: (role, text, isFinal) => {

523515

if (isFinal && text.trim()) {

524516

logger.info(

525-

`discord voice: realtime ${role} transcript (${text.length} chars): ${formatRealtimeLogPreview(text)}`,

517+

`discord voice: realtime ${role} transcript (${text.length} chars): ${formatVoiceLogPreview(text)}`,

526518

);

527519

}

528520

if (isFinal && role === "assistant") {

@@ -1420,7 +1412,7 @@ export class DiscordRealtimeVoiceSession implements VoiceRealtimeSession {

14201412

if (skipReason) {

14211413

const context = this.consumePendingSpeakerContext();

14221414

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)}`,

14241416

);

14251417

return undefined;

14261418

}

Original file line numberDiff line numberDiff line change

@@ -8,6 +8,7 @@ import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime";

88

import { maybeControlDiscordVoiceAgentRun } from "./agent-control.js";

99

import { createDiscordOpusPlaybackStream } from "./audio.js";

1010

import { resolveDiscordVoiceIngressContext, runDiscordVoiceAgentTurn } from "./ingress.js";

11+

import { formatVoiceLogPreview } from "./log-preview.js";

1112

import { formatVoiceIngressPrompt } from "./prompt.js";

1213

import { loadDiscordVoiceSdk } from "./sdk-runtime.js";

1314

import {

@@ -19,17 +20,8 @@ import {

1920

import type { DiscordVoiceSpeakerContextResolver } from "./speaker-context.js";

2021

import { synthesizeVoiceReplyAudio, transcribeVoiceAudio } from "./tts.js";

2122
22-

const VOICE_TRANSCRIPT_LOG_PREVIEW_CHARS = 500;

2323

const logger = createSubsystemLogger("discord/voice");

2424
25-

function formatVoiceTranscriptLogPreview(text: string): string {

26-

const oneLine = text.replace(/\s+/g, " ").trim();

27-

if (oneLine.length <= VOICE_TRANSCRIPT_LOG_PREVIEW_CHARS) {

28-

return oneLine;

29-

}

30-

return `${oneLine.slice(0, VOICE_TRANSCRIPT_LOG_PREVIEW_CHARS)}...`;

31-

}

32-
3325

export async function processDiscordVoiceSegment(params: {

3426

entry: VoiceSessionEntry;

3527

wavPath: string;

@@ -78,7 +70,7 @@ export async function processDiscordVoiceSegment(params: {

7870

`transcription ok (${transcript.length} chars): guild ${entry.guildId} channel ${entry.channelId}`,

7971

);

8072

logVoiceVerbose(

81-

`transcript from ${ingress.speakerLabel} (${userId}) in guild ${entry.guildId} channel ${entry.channelId}: ${formatVoiceTranscriptLogPreview(transcript)}`,

73+

`transcript from ${ingress.speakerLabel} (${userId}) in guild ${entry.guildId} channel ${entry.channelId}: ${formatVoiceLogPreview(transcript)}`,

8274

);

8375

if (params.transcripts) {

8476

await params.transcripts.onUtterance({