From 70184d0a5e810be3a7c4497cc688f97d3f03581d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 27 Mar 2026 04:23:32 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20compaction=20API=20drift=20+=20Skill=20s?= =?UTF-8?q?ourceInfo=E2=86=92source=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/agents/compaction.retry.test.ts | 2 +- src/agents/compaction.ts | 1 - src/agents/pi-extensions/compaction-safeguard.ts | 6 ++---- src/agents/skills-install.download.test.ts | 8 +------- src/agents/skills-install.ts | 2 +- src/agents/skills-status.test.ts | 8 +------- src/agents/skills-status.ts | 2 +- src/agents/skills.buildworkspaceskillstatus.test.ts | 8 +------- src/agents/skills.resolveskillspromptforrun.test.ts | 8 +------- src/agents/skills/compact-format.test.ts | 8 +------- src/agents/skills/config.ts | 2 +- src/cli/skills-cli.formatting.test.ts | 8 +------- src/security/audit-extra.async.ts | 2 +- 13 files changed, 13 insertions(+), 52 deletions(-) diff --git a/src/agents/compaction.retry.test.ts b/src/agents/compaction.retry.test.ts index 30f81ca6664..31404e2e9b2 100644 --- a/src/agents/compaction.retry.test.ts +++ b/src/agents/compaction.retry.test.ts @@ -56,7 +56,7 @@ describe("compaction retry integration", () => { } as unknown as NonNullable; 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[1]) => retryAsync(() => invokeGenerateSummary(), options); diff --git a/src/agents/compaction.ts b/src/agents/compaction.ts index b19f9bc92b1..20a6d80fa43 100644 --- a/src/agents/compaction.ts +++ b/src/agents/compaction.ts @@ -257,7 +257,6 @@ async function summarizeChunks(params: { model, params.reserveTokens, params.apiKey, - params.headers, params.signal, effectiveInstructions, summary, diff --git a/src/agents/pi-extensions/compaction-safeguard.ts b/src/agents/pi-extensions/compaction-safeguard.ts index 61e5a2be0a6..ee136dfbd00 100644 --- a/src/agents/pi-extensions/compaction-safeguard.ts +++ b/src/agents/pi-extensions/compaction-safeguard.ts @@ -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.", diff --git a/src/agents/skills-install.download.test.ts b/src/agents/skills-install.download.test.ts index 49d20867fd1..bd8559b60fe 100644 --- a/src/agents/skills-install.download.test.ts +++ b/src/agents/skills-install.download.test.ts @@ -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: {}, diff --git a/src/agents/skills-install.ts b/src/agents/skills-install.ts index 8d38fda36c6..dca8da9db77 100644 --- a/src/agents/skills-install.ts +++ b/src/agents/skills-install.ts @@ -444,7 +444,7 @@ export async function installSkill(params: SkillInstallRequest): Promise { 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: {}, diff --git a/src/agents/skills-status.ts b/src/agents/skills-status.ts index d9b52a1dac3..1d4c660ae53 100644 --- a/src/agents/skills-status.ts +++ b/src/agents/skills-status.ts @@ -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) diff --git a/src/agents/skills.buildworkspaceskillstatus.test.ts b/src/agents/skills.buildworkspaceskillstatus.test.ts index eb6e40ad279..4b3cca8808f 100644 --- a/src/agents/skills.buildworkspaceskillstatus.test.ts +++ b/src/agents/skills.buildworkspaceskillstatus.test.ts @@ -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: {}, diff --git a/src/agents/skills.resolveskillspromptforrun.test.ts b/src/agents/skills.resolveskillspromptforrun.test.ts index d8cc67c461e..305e11f2f4e 100644 --- a/src/agents/skills.resolveskillspromptforrun.test.ts +++ b/src/agents/skills.resolveskillspromptforrun.test.ts @@ -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: {}, diff --git a/src/agents/skills/compact-format.test.ts b/src/agents/skills/compact-format.test.ts index aa85779e94b..20f3b8a256e 100644 --- a/src/agents/skills/compact-format.test.ts +++ b/src/agents/skills/compact-format.test.ts @@ -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, }; } diff --git a/src/agents/skills/config.ts b/src/agents/skills/config.ts index cf25b6fc50e..2dfe78acd5c 100644 --- a/src/agents/skills/config.ts +++ b/src/agents/skills/config.ts @@ -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 { diff --git a/src/cli/skills-cli.formatting.test.ts b/src/cli/skills-cli.formatting.test.ts index 57f6d3a50c6..19d4ba0b2ed 100644 --- a/src/cli/skills-cli.formatting.test.ts +++ b/src/cli/skills-cli.formatting.test.ts @@ -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: {}, diff --git a/src/security/audit-extra.async.ts b/src/security/audit-extra.async.ts index 55765b717ce..5e9c4036e09 100644 --- a/src/security/audit-extra.async.ts +++ b/src/security/audit-extra.async.ts @@ -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; }