forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
70 lines (64 loc) · 2.06 KB
/
Copy pathconfig.ts
File metadata and controls
70 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { normalizeOptionalString as readString } from "../shared/string-coerce.js";
export type TranscriptsAutoStartConfig = {
providerId: string;
sessionId?: string;
title?: string;
accountId?: string;
guildId?: string;
channelId?: string;
meetingUrl?: string;
};
export type ResolvedTranscriptsAutoStartConfig = {
providerId: string;
sessionId?: string;
title?: string;
accountId?: string;
guildId?: string;
channelId?: string;
meetingUrl?: string;
};
export type TranscriptsConfig = {
enabled?: boolean;
maxUtterances?: number;
autoStart?: TranscriptsAutoStartConfig[];
};
export type ResolvedTranscriptsConfig = {
enabled: boolean;
maxUtterances: number;
autoStart: ResolvedTranscriptsAutoStartConfig[];
};
function resolveAutoStart(raw: unknown): ResolvedTranscriptsAutoStartConfig[] {
if (!Array.isArray(raw)) {
return [];
}
return raw
.map((entry): ResolvedTranscriptsAutoStartConfig | undefined => {
const config = entry && typeof entry === "object" ? (entry as Record<string, unknown>) : {};
const providerId = readString(config.providerId);
if (!providerId) {
return undefined;
}
return {
providerId,
sessionId: readString(config.sessionId),
title: readString(config.title),
accountId: readString(config.accountId),
guildId: readString(config.guildId),
channelId: readString(config.channelId),
meetingUrl: readString(config.meetingUrl),
};
})
.filter((entry): entry is ResolvedTranscriptsAutoStartConfig => entry !== undefined);
}
export function resolveTranscriptsConfig(raw: unknown): ResolvedTranscriptsConfig {
const config = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
const maxUtterances =
typeof config.maxUtterances === "number" && Number.isFinite(config.maxUtterances)
? Math.max(1, Math.min(10_000, Math.floor(config.maxUtterances)))
: 2_000;
return {
enabled: config.enabled === true,
maxUtterances,
autoStart: resolveAutoStart(config.autoStart),
};
}