Skip to content

Commit 8247f82

Browse files
committed
fix(google-meet): bound timer config values
1 parent c767b37 commit 8247f82

2 files changed

Lines changed: 36 additions & 7 deletions

File tree

extensions/google-meet/src/config.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@ import { describe, expect, it } from "vitest";
33
import { resolveGoogleMeetConfig, resolveGoogleMeetGatewayOperationTimeoutMs } from "./config.js";
44

55
describe("google meet gateway operation timeout", () => {
6+
it("caps timer config fields before runtime polling uses them", () => {
7+
const config = resolveGoogleMeetConfig({
8+
chrome: {
9+
joinTimeoutMs: Number.MAX_VALUE,
10+
waitForInCallMs: Number.MAX_VALUE,
11+
bargeInCooldownMs: Number.MAX_VALUE,
12+
},
13+
voiceCall: {
14+
requestTimeoutMs: Number.MAX_VALUE,
15+
dtmfDelayMs: Number.MAX_VALUE,
16+
postDtmfSpeechDelayMs: Number.MAX_VALUE,
17+
},
18+
});
19+
20+
expect(config.chrome.joinTimeoutMs).toBe(MAX_TIMER_TIMEOUT_MS);
21+
expect(config.chrome.waitForInCallMs).toBe(MAX_TIMER_TIMEOUT_MS);
22+
expect(config.chrome.bargeInCooldownMs).toBe(MAX_TIMER_TIMEOUT_MS);
23+
expect(config.voiceCall.requestTimeoutMs).toBe(MAX_TIMER_TIMEOUT_MS);
24+
expect(config.voiceCall.dtmfDelayMs).toBe(MAX_TIMER_TIMEOUT_MS);
25+
expect(config.voiceCall.postDtmfSpeechDelayMs).toBe(MAX_TIMER_TIMEOUT_MS);
26+
});
27+
628
it("adds operation grace to normal transport timeouts", () => {
729
expect(resolveGoogleMeetGatewayOperationTimeoutMs(resolveGoogleMeetConfig({}))).toBe(60_000);
830
expect(

extensions/google-meet/src/config.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { addTimerTimeoutGraceMs } from "openclaw/plugin-sdk/number-runtime";
1+
import {
2+
addTimerTimeoutGraceMs,
3+
resolvePositiveTimerTimeoutMs,
4+
} from "openclaw/plugin-sdk/number-runtime";
25
import {
36
REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME,
47
resolveRealtimeVoiceAgentConsultToolPolicy,
@@ -280,6 +283,10 @@ function resolveNumber(value: unknown, fallback: number): number {
280283
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
281284
}
282285

286+
function resolveTimerConfigMs(value: unknown, fallback: number): number {
287+
return resolvePositiveTimerTimeoutMs(resolveNumber(value, fallback), fallback);
288+
}
289+
283290
function resolveOptionalNumber(value: unknown): number | undefined {
284291
if (typeof value === "number" && Number.isFinite(value)) {
285292
return value;
@@ -481,11 +488,11 @@ export function resolveGoogleMeetConfigWithEnv(
481488
DEFAULT_GOOGLE_MEET_CONFIG.chrome.reuseExistingTab,
482489
),
483490
autoJoin: resolveBoolean(chrome.autoJoin, DEFAULT_GOOGLE_MEET_CONFIG.chrome.autoJoin),
484-
joinTimeoutMs: resolveNumber(
491+
joinTimeoutMs: resolveTimerConfigMs(
485492
chrome.joinTimeoutMs,
486493
DEFAULT_GOOGLE_MEET_CONFIG.chrome.joinTimeoutMs,
487494
),
488-
waitForInCallMs: resolveNumber(
495+
waitForInCallMs: resolveTimerConfigMs(
489496
chrome.waitForInCallMs,
490497
DEFAULT_GOOGLE_MEET_CONFIG.chrome.waitForInCallMs,
491498
),
@@ -502,7 +509,7 @@ export function resolveGoogleMeetConfigWithEnv(
502509
chrome.bargeInPeakThreshold,
503510
DEFAULT_GOOGLE_MEET_CONFIG.chrome.bargeInPeakThreshold,
504511
),
505-
bargeInCooldownMs: resolveNumber(
512+
bargeInCooldownMs: resolveTimerConfigMs(
506513
chrome.bargeInCooldownMs,
507514
DEFAULT_GOOGLE_MEET_CONFIG.chrome.bargeInCooldownMs,
508515
),
@@ -521,15 +528,15 @@ export function resolveGoogleMeetConfigWithEnv(
521528
enabled: resolveBoolean(voiceCall.enabled, DEFAULT_GOOGLE_MEET_CONFIG.voiceCall.enabled),
522529
gatewayUrl: normalizeOptionalString(voiceCall.gatewayUrl),
523530
token: normalizeOptionalString(voiceCall.token),
524-
requestTimeoutMs: resolveNumber(
531+
requestTimeoutMs: resolveTimerConfigMs(
525532
voiceCall.requestTimeoutMs,
526533
DEFAULT_GOOGLE_MEET_CONFIG.voiceCall.requestTimeoutMs,
527534
),
528-
dtmfDelayMs: resolveNumber(
535+
dtmfDelayMs: resolveTimerConfigMs(
529536
voiceCall.dtmfDelayMs,
530537
DEFAULT_GOOGLE_MEET_CONFIG.voiceCall.dtmfDelayMs,
531538
),
532-
postDtmfSpeechDelayMs: resolveNumber(
539+
postDtmfSpeechDelayMs: resolveTimerConfigMs(
533540
voiceCall.postDtmfSpeechDelayMs,
534541
DEFAULT_GOOGLE_MEET_CONFIG.voiceCall.postDtmfSpeechDelayMs,
535542
),

0 commit comments

Comments
 (0)