fix(webchat): keep trustedLocalMedia internal to reply payloads · openclaw/openclaw@35e1c7a
leno23
·
2026-05-17
·
via Recent Commits to openclaw:main
File tree
extensions/speech-core/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -210,7 +210,7 @@ async function expectTtsPayloadResult(params: {
|
210 | 210 | expect(result.audioAsVoice).toBe(params.audioAsVoice); |
211 | 211 | expect(result.mediaUrl).toMatch(new RegExp(`voice-\\d+\\.${params.mediaExtension ?? "ogg"}$`)); |
212 | 212 | expect(result.spokenText).toBe(params.text); |
213 | | -expect(result.trustedLocalMedia).toBe(true); |
| 213 | +expect((result as { trustedLocalMedia?: boolean }).trustedLocalMedia).toBe(true); |
214 | 214 | |
215 | 215 | mediaDir = result.mediaUrl ? path.dirname(result.mediaUrl) : undefined; |
216 | 216 | } finally { |
@@ -453,7 +453,7 @@ describe("speech-core native voice-note routing", () => {
|
453 | 453 | }); |
454 | 454 | |
455 | 455 | expect(synthesizeMock).not.toHaveBeenCalled(); |
456 | | -expect(result.trustedLocalMedia).toBeUndefined(); |
| 456 | +expect((result as { trustedLocalMedia?: boolean }).trustedLocalMedia).toBeUndefined(); |
457 | 457 | expect(result.text).toBe("WebChat block stream chunks defer TTS to the final tail."); |
458 | 458 | }); |
459 | 459 | |
@@ -468,7 +468,7 @@ describe("speech-core native voice-note routing", () => {
|
468 | 468 | }); |
469 | 469 | |
470 | 470 | expect(synthesizeMock).not.toHaveBeenCalled(); |
471 | | -expect(result.trustedLocalMedia).toBeUndefined(); |
| 471 | +expect((result as { trustedLocalMedia?: boolean }).trustedLocalMedia).toBeUndefined(); |
472 | 472 | expect(result.text).toBe("Intermediate tool output should not be spoken."); |
473 | 473 | }); |
474 | 474 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1850,7 +1850,7 @@ export async function maybeApplyTtsToPayload(params: {
|
1850 | 1850 | audioAsVoice: result.audioAsVoice || params.payload.audioAsVoice, |
1851 | 1851 | spokenText: textForAudio, |
1852 | 1852 | trustedLocalMedia: true, |
1853 | | -}; |
| 1853 | +} as ReplyPayload; |
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | lastTtsAttempt = { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -89,16 +89,14 @@ async function main() {
|
89 | 89 | throw new Error("expected final-mode tail TTS to write a local media file"); |
90 | 90 | } |
91 | 91 | |
| 92 | +// Same shape as dispatch-from-config accumulated block TTS-only final payload. |
92 | 93 | const ttsOnlyPayload = { |
93 | 94 | mediaUrl: tailResult.mediaUrl, |
94 | 95 | audioAsVoice: tailResult.audioAsVoice, |
95 | 96 | spokenText: accumulatedBlockText, |
96 | | -trustedLocalMedia: tailResult.trustedLocalMedia, |
| 97 | +trustedLocalMedia: true, |
97 | 98 | }; |
98 | | -console.log( |
99 | | -"dispatch ttsOnlyPayload.trustedLocalMedia =", |
100 | | -ttsOnlyPayload.trustedLocalMedia ?? false, |
101 | | -); |
| 99 | +console.log("dispatch ttsOnlyPayload.trustedLocalMedia =", ttsOnlyPayload.trustedLocalMedia); |
102 | 100 | |
103 | 101 | const localRoots = [path.dirname(mediaPath)]; |
104 | 102 | const trustedBlocks = await buildWebchatAudioContentBlocksFromReplyPayloads([ttsOnlyPayload], { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1700,7 +1700,7 @@ export async function dispatchReplyFromConfig(
|
1700 | 1700 | mediaUrl: ttsSyntheticReply.mediaUrl, |
1701 | 1701 | audioAsVoice: ttsSyntheticReply.audioAsVoice, |
1702 | 1702 | spokenText: accumulatedBlockTtsText, |
1703 | | -trustedLocalMedia: ttsSyntheticReply.trustedLocalMedia, |
| 1703 | +trustedLocalMedia: true, |
1704 | 1704 | }; |
1705 | 1705 | const normalizedTtsOnlyPayload = await normalizeReplyMediaPayload(ttsOnlyPayload); |
1706 | 1706 | const result = await routeReplyToOriginating(normalizedTtsOnlyPayload); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ import { normalizeLowercaseStringOrEmpty, readStringValue } from "../shared/stri
|
6 | 6 | |
7 | 7 | export type { MediaPayload, MediaPayloadInput } from "../channels/plugins/media-payload.js"; |
8 | 8 | export { buildMediaPayload } from "../channels/plugins/media-payload.js"; |
9 | | -export type ReplyPayload = InternalReplyPayload; |
| 9 | +export type ReplyPayload = Omit<InternalReplyPayload, "trustedLocalMedia">; |
10 | 10 | |
11 | 11 | export type OutboundReplyPayload = { |
12 | 12 | text?: string; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。