mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 06:05:03 +00:00
fix: align talk config secret schemas
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { ErrorObject } from "ajv";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatValidationErrors } from "./index.js";
|
||||
import { formatValidationErrors, validateTalkConfigResult } from "./index.js";
|
||||
|
||||
const makeError = (overrides: Partial<ErrorObject>): ErrorObject => ({
|
||||
keyword: "type",
|
||||
@@ -62,3 +62,41 @@ describe("formatValidationErrors", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateTalkConfigResult", () => {
|
||||
it("accepts Talk SecretRef payloads", () => {
|
||||
expect(
|
||||
validateTalkConfigResult({
|
||||
config: {
|
||||
talk: {
|
||||
provider: "elevenlabs",
|
||||
providers: {
|
||||
elevenlabs: {
|
||||
apiKey: {
|
||||
source: "env",
|
||||
provider: "default",
|
||||
id: "ELEVENLABS_API_KEY",
|
||||
},
|
||||
},
|
||||
},
|
||||
resolved: {
|
||||
provider: "elevenlabs",
|
||||
config: {
|
||||
apiKey: {
|
||||
source: "env",
|
||||
provider: "default",
|
||||
id: "ELEVENLABS_API_KEY",
|
||||
},
|
||||
},
|
||||
},
|
||||
apiKey: {
|
||||
source: "env",
|
||||
provider: "default",
|
||||
id: "ELEVENLABS_API_KEY",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -334,6 +334,7 @@ export const validateWizardCancelParams = ajv.compile<WizardCancelParams>(Wizard
|
||||
export const validateWizardStatusParams = ajv.compile<WizardStatusParams>(WizardStatusParamsSchema);
|
||||
export const validateTalkModeParams = ajv.compile<TalkModeParams>(TalkModeParamsSchema);
|
||||
export const validateTalkConfigParams = ajv.compile<TalkConfigParams>(TalkConfigParamsSchema);
|
||||
export const validateTalkConfigResult = ajv.compile<TalkConfigResult>(TalkConfigResultSchema);
|
||||
export const validateChannelsStatusParams = ajv.compile<ChannelsStatusParams>(
|
||||
ChannelsStatusParamsSchema,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { NonEmptyString } from "./primitives.js";
|
||||
import { NonEmptyString, SecretInputSchema } from "./primitives.js";
|
||||
|
||||
export const TalkModeParamsSchema = Type.Object(
|
||||
{
|
||||
@@ -22,7 +22,7 @@ const TalkProviderConfigSchema = Type.Object(
|
||||
voiceAliases: Type.Optional(Type.Record(Type.String(), Type.String())),
|
||||
modelId: Type.Optional(Type.String()),
|
||||
outputFormat: Type.Optional(Type.String()),
|
||||
apiKey: Type.Optional(Type.String()),
|
||||
apiKey: Type.Optional(SecretInputSchema),
|
||||
},
|
||||
{ additionalProperties: true },
|
||||
);
|
||||
@@ -49,7 +49,7 @@ export const TalkConfigResultSchema = Type.Object(
|
||||
voiceAliases: Type.Optional(Type.Record(Type.String(), Type.String())),
|
||||
modelId: Type.Optional(Type.String()),
|
||||
outputFormat: Type.Optional(Type.String()),
|
||||
apiKey: Type.Optional(Type.String()),
|
||||
apiKey: Type.Optional(SecretInputSchema),
|
||||
interruptOnSpeech: Type.Optional(Type.Boolean()),
|
||||
silenceTimeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
||||
},
|
||||
|
||||
@@ -20,3 +20,20 @@ export const GatewayClientIdSchema = Type.Union(
|
||||
export const GatewayClientModeSchema = Type.Union(
|
||||
Object.values(GATEWAY_CLIENT_MODES).map((value) => Type.Literal(value)),
|
||||
);
|
||||
|
||||
export const SecretRefSourceSchema = Type.Union([
|
||||
Type.Literal("env"),
|
||||
Type.Literal("file"),
|
||||
Type.Literal("exec"),
|
||||
]);
|
||||
|
||||
export const SecretRefSchema = Type.Object(
|
||||
{
|
||||
source: SecretRefSourceSchema,
|
||||
provider: NonEmptyString,
|
||||
id: NonEmptyString,
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const SecretInputSchema = Type.Union([Type.String(), SecretRefSchema]);
|
||||
|
||||
Reference in New Issue
Block a user