fix: allow custom skill config bag
Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
This commit is contained in:
46
src/config/config.skills-entries-config.test.ts
Normal file
46
src/config/config.skills-entries-config.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ClawdbotSchema } from "./zod-schema.js";
|
||||
|
||||
describe("skills entries config schema", () => {
|
||||
it("accepts custom fields under config", () => {
|
||||
const res = ClawdbotSchema.safeParse({
|
||||
skills: {
|
||||
entries: {
|
||||
"custom-skill": {
|
||||
enabled: true,
|
||||
config: {
|
||||
url: "https://example.invalid",
|
||||
token: "abc123",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unknown top-level fields", () => {
|
||||
const res = ClawdbotSchema.safeParse({
|
||||
skills: {
|
||||
entries: {
|
||||
"custom-skill": {
|
||||
url: "https://example.invalid",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.success).toBe(false);
|
||||
if (res.success) return;
|
||||
|
||||
expect(
|
||||
res.error.issues.some(
|
||||
(issue) =>
|
||||
issue.path.join(".") === "skills.entries.custom-skill" &&
|
||||
issue.message.toLowerCase().includes("unrecognized"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ export type SkillConfig = {
|
||||
enabled?: boolean;
|
||||
apiKey?: string;
|
||||
env?: Record<string, string>;
|
||||
[key: string]: unknown;
|
||||
config?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type SkillsLoadConfig = {
|
||||
|
||||
@@ -380,6 +380,7 @@ export const ClawdbotSchema = z
|
||||
enabled: z.boolean().optional(),
|
||||
apiKey: z.string().optional(),
|
||||
env: z.record(z.string(), z.string()).optional(),
|
||||
config: z.record(z.string(), z.unknown()).optional(),
|
||||
})
|
||||
.strict(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user