fix: compaction API drift + Skill sourceInfo→source migration

- compaction.ts: drop removed 'headers' param from generateSummary call
- compaction.retry.test.ts: align test call with new generateSummary signature
- compaction-safeguard.ts: replace getApiKeyAndHeaders with getApiKey (upstream removed)
- Migrate all Skill sourceInfo.source → flat source field across agents, cli, security
- Update 6 test files to match new Skill shape
This commit is contained in:
Peter Steinberger
2026-03-27 04:23:32 +00:00
parent d8a1808bd6
commit 70184d0a5e
13 changed files with 13 additions and 52 deletions

View File

@@ -56,7 +56,7 @@ describe("compaction retry integration", () => {
} as unknown as NonNullable<ExtensionContext["model"]>;
const invokeGenerateSummary = (signal = new AbortController().signal) =>
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", undefined, signal);
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", signal);
const runSummaryRetry = (options: Parameters<typeof retryAsync>[1]) =>
retryAsync(() => invokeGenerateSummary(), options);

View File

@@ -257,7 +257,6 @@ async function summarizeChunks(params: {
model,
params.reserveTokens,
params.apiKey,
params.headers,
params.signal,
effectiveInstructions,
summary,

View File

@@ -614,13 +614,11 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
return { cancel: true };
}
const fallbackHeaders =
const headers =
model.headers && typeof model.headers === "object" && !Array.isArray(model.headers)
? model.headers
: undefined;
const requestAuth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
const apiKey = requestAuth.ok ? (requestAuth.apiKey ?? "") : "";
const headers = requestAuth.ok ? (requestAuth.headers ?? fallbackHeaders) : fallbackHeaders;
const apiKey = (await ctx.modelRegistry.getApiKey(model)) ?? "";
if (!apiKey && !headers) {
log.warn(
"Compaction safeguard: no request auth available; cancelling compaction to preserve history.",

View File

@@ -60,13 +60,7 @@ function buildEntry(name: string): SkillEntry {
description: `${name} test skill`,
filePath: path.join(skillDir, "SKILL.md"),
baseDir: skillDir,
sourceInfo: {
path: path.join(skillDir, "SKILL.md"),
source: "openclaw-workspace",
scope: "project",
origin: "top-level",
baseDir: skillDir,
},
source: "openclaw-workspace",
disableModelInvocation: false,
},
frontmatter: {},

View File

@@ -444,7 +444,7 @@ export async function installSkill(params: SkillInstallRequest): Promise<SkillIn
// Warn when install is triggered from a non-bundled source.
// Workspace/project/personal agent skills can contain attacker-controlled metadata.
const trustedInstallSources = new Set(["openclaw-bundled", "openclaw-managed", "openclaw-extra"]);
const skillSource = entry.skill.sourceInfo.source;
const skillSource = entry.skill.source;
if (!trustedInstallSources.has(skillSource)) {
warnings.push(
`WARNING: Skill "${params.skillName}" install triggered from non-bundled source "${skillSource}". Verify the install recipe is trusted.`,

View File

@@ -17,13 +17,7 @@ describe("buildWorkspaceSkillStatus", () => {
description: "test",
filePath: "/tmp/os-scoped",
baseDir: "/tmp",
sourceInfo: {
path: "/tmp/os-scoped",
source: "test",
scope: "project",
origin: "top-level",
baseDir: "/tmp",
},
source: "test",
disableModelInvocation: false,
},
frontmatter: {},

View File

@@ -186,7 +186,7 @@ function buildSkillStatus(
(skillConfig?.apiKey && entry.metadata?.primaryEnv === envName),
);
const isConfigSatisfied = (pathStr: string) => isConfigPathTruthy(config, pathStr);
const skillSource = entry.skill.sourceInfo.source;
const skillSource = entry.skill.source;
const bundled =
bundledNames && bundledNames.size > 0
? bundledNames.has(entry.skill.name)

View File

@@ -24,13 +24,7 @@ function makeEntry(params: {
description: `desc:${params.name}`,
filePath: `/tmp/${params.name}/SKILL.md`,
baseDir: `/tmp/${params.name}`,
sourceInfo: {
path: `/tmp/${params.name}/SKILL.md`,
source: params.source ?? "openclaw-workspace",
scope: "project",
origin: "top-level",
baseDir: `/tmp/${params.name}`,
},
source: params.source ?? "openclaw-workspace",
disableModelInvocation: false,
},
frontmatter: {},

View File

@@ -17,13 +17,7 @@ describe("resolveSkillsPromptForRun", () => {
description: "Demo",
filePath: "/app/skills/demo-skill/SKILL.md",
baseDir: "/app/skills/demo-skill",
sourceInfo: {
path: "/app/skills/demo-skill/SKILL.md",
source: "openclaw-bundled",
scope: "project",
origin: "top-level",
baseDir: "/app/skills/demo-skill",
},
source: "openclaw-bundled",
disableModelInvocation: false,
},
frontmatter: {},

View File

@@ -14,13 +14,7 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
description: desc,
filePath,
baseDir: `/skills/${name}`,
sourceInfo: {
path: filePath,
source: "workspace",
scope: "project",
origin: "top-level",
baseDir: `/skills/${name}`,
},
source: "workspace",
disableModelInvocation: false,
};
}

View File

@@ -50,7 +50,7 @@ function normalizeAllowlist(input: unknown): string[] | undefined {
const BUNDLED_SOURCES = new Set(["openclaw-bundled"]);
function isBundledSkill(entry: SkillEntry): boolean {
return BUNDLED_SOURCES.has(entry.skill.sourceInfo.source);
return BUNDLED_SOURCES.has(entry.skill.source);
}
export function resolveBundledAllowlist(config?: OpenClawConfig): string[] | undefined {

View File

@@ -38,13 +38,7 @@ describe("skills-cli (e2e)", () => {
description: "Capture UI screenshots",
filePath: path.join(baseDir, "SKILL.md"),
baseDir,
sourceInfo: {
path: path.join(baseDir, "SKILL.md"),
source: "openclaw-bundled",
scope: "project",
origin: "top-level",
baseDir,
},
source: "openclaw-bundled",
disableModelInvocation: false,
} as SkillEntry["skill"],
frontmatter: {},

View File

@@ -1261,7 +1261,7 @@ export async function collectInstalledSkillsCodeSafetyFindings(params: {
for (const workspaceDir of workspaceDirs) {
const entries = loadWorkspaceSkillEntries(workspaceDir, { config: params.cfg });
for (const entry of entries) {
if (entry.skill.sourceInfo.source === "openclaw-bundled") {
if (entry.skill.source === "openclaw-bundled") {
continue;
}