mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 01:18:40 +02:00
test(skills): cover capability normalization variants
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveSkillInvocationPolicy } from "./frontmatter.js";
|
||||
import { resolveOpenClawMetadata, resolveSkillInvocationPolicy } from "./frontmatter.js";
|
||||
|
||||
describe("resolveSkillInvocationPolicy", () => {
|
||||
it("defaults to enabled behaviors", () => {
|
||||
@@ -17,3 +17,58 @@ describe("resolveSkillInvocationPolicy", () => {
|
||||
expect(policy.disableModelInvocation).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveOpenClawMetadata", () => {
|
||||
it("parses canonical capabilities from string array", () => {
|
||||
const metadata = resolveOpenClawMetadata({
|
||||
metadata: '{"openclaw":{"capabilities":["shell","network"]}}',
|
||||
});
|
||||
expect(metadata?.capabilities).toEqual(["shell", "network"]);
|
||||
});
|
||||
|
||||
it("normalizes capability aliases used by other harnesses", () => {
|
||||
const metadata = resolveOpenClawMetadata({
|
||||
metadata: JSON.stringify({
|
||||
openclaw: {
|
||||
capabilities: ["web_fetch", "terminal", "subagent", "cron", "message"],
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(metadata?.capabilities).toEqual([
|
||||
"network",
|
||||
"shell",
|
||||
"sessions",
|
||||
"scheduling",
|
||||
"messaging",
|
||||
]);
|
||||
});
|
||||
|
||||
it("supports object map capability shape with constraints payload", () => {
|
||||
const metadata = resolveOpenClawMetadata({
|
||||
metadata: JSON.stringify({
|
||||
openclaw: {
|
||||
capabilities: {
|
||||
shell: { mode: "restricted", allow: ["git", "gh"] },
|
||||
network: { web_search: true, web_fetch: true },
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(metadata?.capabilities).toEqual(["shell", "network"]);
|
||||
});
|
||||
|
||||
it("supports object array capability shape", () => {
|
||||
const metadata = resolveOpenClawMetadata({
|
||||
metadata: JSON.stringify({
|
||||
openclaw: {
|
||||
capabilities: [
|
||||
{ type: "network.search", constraints: { provider: "brave" } },
|
||||
{ name: "filesystem", constraints: { paths: ["workspace"] } },
|
||||
{ id: "browser", constraints: { screen: "read" } },
|
||||
],
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(metadata?.capabilities).toEqual(["network", "filesystem", "browser"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user