refactor: add canonical talk config payload

This commit is contained in:
Peter Steinberger
2026-03-08 14:47:29 +00:00
parent 4f482d2a2b
commit 4e2290b841
10 changed files with 171 additions and 16 deletions

View File

@@ -27,6 +27,14 @@ const TalkProviderConfigSchema = Type.Object(
{ additionalProperties: true },
);
const ResolvedTalkConfigSchema = Type.Object(
{
provider: Type.String(),
config: TalkProviderConfigSchema,
},
{ additionalProperties: false },
);
export const TalkConfigResultSchema = Type.Object(
{
config: Type.Object(
@@ -36,6 +44,7 @@ export const TalkConfigResultSchema = Type.Object(
{
provider: Type.Optional(Type.String()),
providers: Type.Optional(Type.Record(Type.String(), TalkProviderConfigSchema)),
resolved: Type.Optional(ResolvedTalkConfigSchema),
voiceId: Type.Optional(Type.String()),
voiceAliases: Type.Optional(Type.Record(Type.String(), Type.String())),
modelId: Type.Optional(Type.String()),

View File

@@ -91,6 +91,10 @@ describe("gateway talk.config", () => {
providers?: {
elevenlabs?: { voiceId?: string; apiKey?: string };
};
resolved?: {
provider?: string;
config?: { voiceId?: string; apiKey?: string };
};
apiKey?: string;
voiceId?: string;
silenceTimeoutMs?: number;
@@ -103,6 +107,9 @@ describe("gateway talk.config", () => {
expect(res.payload?.config?.talk?.providers?.elevenlabs?.apiKey).toBe(
"__OPENCLAW_REDACTED__",
);
expect(res.payload?.config?.talk?.resolved?.provider).toBe("elevenlabs");
expect(res.payload?.config?.talk?.resolved?.config?.voiceId).toBe("voice-123");
expect(res.payload?.config?.talk?.resolved?.config?.apiKey).toBe("__OPENCLAW_REDACTED__");
expect(res.payload?.config?.talk?.voiceId).toBe("voice-123");
expect(res.payload?.config?.talk?.apiKey).toBe("__OPENCLAW_REDACTED__");
expect(res.payload?.config?.talk?.silenceTimeoutMs).toBe(1500);
@@ -156,6 +163,10 @@ describe("gateway talk.config", () => {
providers?: {
elevenlabs?: { voiceId?: string };
};
resolved?: {
provider?: string;
config?: { voiceId?: string };
};
voiceId?: string;
};
};
@@ -163,6 +174,8 @@ describe("gateway talk.config", () => {
expect(res.ok).toBe(true);
expect(res.payload?.config?.talk?.provider).toBe("elevenlabs");
expect(res.payload?.config?.talk?.providers?.elevenlabs?.voiceId).toBe("voice-normalized");
expect(res.payload?.config?.talk?.resolved?.provider).toBe("elevenlabs");
expect(res.payload?.config?.talk?.resolved?.config?.voiceId).toBe("voice-normalized");
expect(res.payload?.config?.talk?.voiceId).toBe("voice-normalized");
});
});