fix: restore green build after upstream API drift

This commit is contained in:
Peter Steinberger
2026-03-27 02:47:56 +00:00
parent bd6c7969ea
commit a331270f8a
53 changed files with 3369 additions and 2762 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

@@ -212,7 +212,6 @@ async function summarizeChunks(params: {
messages: AgentMessage[];
model: NonNullable<ExtensionContext["model"]>;
apiKey: string;
headers?: Record<string, string>;
signal: AbortSignal;
reserveTokens: number;
maxChunkTokens: number;
@@ -240,7 +239,6 @@ async function summarizeChunks(params: {
params.model,
params.reserveTokens,
params.apiKey,
params.headers,
params.signal,
effectiveInstructions,
summary,
@@ -267,7 +265,6 @@ export async function summarizeWithFallback(params: {
messages: AgentMessage[];
model: NonNullable<ExtensionContext["model"]>;
apiKey: string;
headers?: Record<string, string>;
signal: AbortSignal;
reserveTokens: number;
maxChunkTokens: number;
@@ -337,7 +334,6 @@ export async function summarizeInStages(params: {
messages: AgentMessage[];
model: NonNullable<ExtensionContext["model"]>;
apiKey: string;
headers?: Record<string, string>;
signal: AbortSignal;
reserveTokens: number;
maxChunkTokens: number;

View File

@@ -614,18 +614,8 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
return { cancel: true };
}
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
if (!auth.ok) {
log.warn(
`Compaction safeguard: failed to resolve auth; cancelling compaction to preserve history. ${auth.error}`,
);
setCompactionSafeguardCancelReason(
ctx.sessionManager,
`Compaction safeguard could not resolve request auth for ${model.provider}/${model.id}: ${auth.error}`,
);
return { cancel: true };
}
if (!auth.apiKey && !auth.headers) {
const apiKey = await ctx.modelRegistry.getApiKey(model);
if (!apiKey) {
log.warn(
"Compaction safeguard: no request auth available; cancelling compaction to preserve history.",
);
@@ -635,8 +625,6 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
);
return { cancel: true };
}
const apiKey = auth.apiKey ?? "";
const headers = auth.headers;
try {
const modelContextWindow = resolveContextWindowTokens(model);
@@ -700,7 +688,6 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
messages: pruned.droppedMessagesList,
model,
apiKey,
headers,
signal,
reserveTokens: Math.max(1, Math.floor(preparation.settings.reserveTokens)),
maxChunkTokens: droppedMaxChunkTokens,
@@ -772,7 +759,6 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
messages: messagesToSummarize,
model,
apiKey,
headers,
signal,
reserveTokens,
maxChunkTokens,
@@ -789,7 +775,6 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
messages: turnPrefixMessages,
model,
apiKey,
headers,
signal,
reserveTokens,
maxChunkTokens,

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,9 +444,9 @@ 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"]);
if (!trustedInstallSources.has(entry.skill.sourceInfo.source)) {
if (!trustedInstallSources.has(entry.skill.source)) {
warnings.push(
`WARNING: Skill "${params.skillName}" install triggered from non-bundled source "${entry.skill.sourceInfo.source}". Verify the install recipe is trusted.`,
`WARNING: Skill "${params.skillName}" install triggered from non-bundled source "${entry.skill.source}". Verify the install recipe is trusted.`,
);
}
if (!spec) {

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

@@ -189,7 +189,7 @@ function buildSkillStatus(
const bundled =
bundledNames && bundledNames.size > 0
? bundledNames.has(entry.skill.name)
: entry.skill.sourceInfo.source === "openclaw-bundled";
: entry.skill.source === "openclaw-bundled";
const { emoji, homepage, required, missing, requirementsSatisfied, configChecks } =
evaluateEntryRequirementsForCurrentPlatform({
@@ -205,7 +205,7 @@ function buildSkillStatus(
return {
name: entry.skill.name,
description: entry.skill.description,
source: entry.skill.sourceInfo.source,
source: entry.skill.source,
bundled,
filePath: entry.skill.filePath,
baseDir: entry.skill.baseDir,

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;
}