mirror of https://github.com/openclaw/openclaw.git
fix: align anthropic and skills helpers with shared sdk
This commit is contained in:
parent
79c56d417b
commit
2d8351b3b4
|
|
@ -25,7 +25,7 @@ import {
|
|||
validateApiKeyInput,
|
||||
} from "openclaw/plugin-sdk/provider-auth";
|
||||
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
||||
import { normalizeModelCompat } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { cloneFirstTemplateModel } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { fetchClaudeUsage } from "openclaw/plugin-sdk/provider-usage";
|
||||
import { buildAnthropicCliBackend } from "./cli-backend.js";
|
||||
import { buildAnthropicCliMigrationResult, hasClaudeCliAuth } from "./cli-migration.js";
|
||||
|
|
@ -54,29 +54,6 @@ const ANTHROPIC_OAUTH_ALLOWLIST = [
|
|||
"anthropic/claude-haiku-4-5",
|
||||
] as const;
|
||||
|
||||
function cloneFirstTemplateModel(params: {
|
||||
modelId: string;
|
||||
templateIds: readonly string[];
|
||||
ctx: ProviderResolveDynamicModelContext;
|
||||
}): ProviderRuntimeModel | undefined {
|
||||
const trimmedModelId = params.modelId.trim();
|
||||
for (const templateId of [...new Set(params.templateIds)].filter(Boolean)) {
|
||||
const template = params.ctx.modelRegistry.find(
|
||||
PROVIDER_ID,
|
||||
templateId,
|
||||
) as ProviderRuntimeModel | null;
|
||||
if (!template) {
|
||||
continue;
|
||||
}
|
||||
return normalizeModelCompat({
|
||||
...template,
|
||||
id: trimmedModelId,
|
||||
name: trimmedModelId,
|
||||
} as ProviderRuntimeModel);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveAnthropic46ForwardCompatModel(params: {
|
||||
ctx: ProviderResolveDynamicModelContext;
|
||||
dashModelId: string;
|
||||
|
|
@ -106,6 +83,7 @@ function resolveAnthropic46ForwardCompatModel(params: {
|
|||
templateIds.push(...params.fallbackTemplateIds);
|
||||
|
||||
return cloneFirstTemplateModel({
|
||||
providerId: PROVIDER_ID,
|
||||
modelId: trimmedModelId,
|
||||
templateIds,
|
||||
ctx: params.ctx,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,6 @@ async function summarizeChunks(params: {
|
|||
params.model,
|
||||
params.reserveTokens,
|
||||
params.apiKey,
|
||||
params.headers,
|
||||
params.signal,
|
||||
effectiveInstructions,
|
||||
summary,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { installDownloadSpec } from "./skills-install-download.js";
|
||||
import { setTempStateDir } from "./skills-install.download-test-utils.js";
|
||||
|
|
@ -61,10 +60,7 @@ function buildEntry(name: string): SkillEntry {
|
|||
description: `${name} test skill`,
|
||||
filePath: path.join(skillDir, "SKILL.md"),
|
||||
baseDir: skillDir,
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(skillDir, "SKILL.md"), {
|
||||
source: "openclaw-workspace",
|
||||
baseDir: skillDir,
|
||||
}),
|
||||
source: "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||
import type { SkillEntry } from "./skills/types.js";
|
||||
|
|
@ -18,10 +17,7 @@ describe("buildWorkspaceSkillStatus", () => {
|
|||
description: "test",
|
||||
filePath: "/tmp/os-scoped",
|
||||
baseDir: "/tmp",
|
||||
sourceInfo: createSyntheticSourceInfo("/tmp/os-scoped", {
|
||||
source: "test",
|
||||
baseDir: "/tmp",
|
||||
}),
|
||||
source: "test",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withEnv } from "../test-utils/env.js";
|
||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||
|
|
@ -25,10 +24,7 @@ function makeEntry(params: {
|
|||
description: `desc:${params.name}`,
|
||||
filePath: `/tmp/${params.name}/SKILL.md`,
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
sourceInfo: createSyntheticSourceInfo(`/tmp/${params.name}/SKILL.md`, {
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
}),
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveSkillsPromptForRun } from "./skills.js";
|
||||
import type { SkillEntry } from "./skills/types.js";
|
||||
|
|
@ -18,10 +17,7 @@ describe("resolveSkillsPromptForRun", () => {
|
|||
description: "Demo",
|
||||
filePath: "/app/skills/demo-skill/SKILL.md",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
sourceInfo: createSyntheticSourceInfo("/app/skills/demo-skill/SKILL.md", {
|
||||
source: "openclaw-bundled",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
}),
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
import os from "node:os";
|
||||
import {
|
||||
createSyntheticSourceInfo,
|
||||
formatSkillsForPrompt,
|
||||
type Skill,
|
||||
} from "@mariozechner/pi-coding-agent";
|
||||
import { formatSkillsForPrompt, type Skill } from "@mariozechner/pi-coding-agent";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { SkillEntry } from "./types.js";
|
||||
|
|
@ -19,10 +15,7 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
|
|||
description: desc,
|
||||
filePath,
|
||||
baseDir: `/skills/${name}`,
|
||||
sourceInfo: createSyntheticSourceInfo(filePath, {
|
||||
source: "workspace",
|
||||
baseDir: `/skills/${name}`,
|
||||
}),
|
||||
source: "workspace",
|
||||
disableModelInvocation: false,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { Skill } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export function resolveSkillSource(skill: Skill): string {
|
||||
return skill.sourceInfo.source;
|
||||
return skill.source;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createSyntheticSourceInfo } from "@mariozechner/pi-coding-agent";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
|
||||
import type { SkillEntry } from "../agents/skills.js";
|
||||
|
|
@ -39,10 +38,7 @@ describe("skills-cli (e2e)", () => {
|
|||
description: "Capture UI screenshots",
|
||||
filePath: path.join(baseDir, "SKILL.md"),
|
||||
baseDir,
|
||||
sourceInfo: createSyntheticSourceInfo(path.join(baseDir, "SKILL.md"), {
|
||||
source: "openclaw-bundled",
|
||||
baseDir,
|
||||
}),
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
|
|
|||
Loading…
Reference in New Issue