Address Greptile Claude model feedback

This commit is contained in:
Dotta committed 2026-05-29 04:07:59 +00:00
1 parent 23fd01f52e
commit b796cf4f18
2 files changed
+19 -2

No files matched your search

@@ -1,3 +1,4 @@
import { createHash } from "node:crypto";
import type { AdapterModel } from "@paperclipai/adapter-utils";
import { models as DIRECT_MODELS } from "../index.js";
@@ -26,7 +27,8 @@ function isBedrockEnv(): boolean {
}
function fingerprint(apiKey: string): string {
return `${apiKey.length}:${apiKey.slice(-6)}`;
const digest = createHash("sha256").update(apiKey).digest("base64url").slice(0, 16);
return `${apiKey.length}:${digest}`;
}
function dedupeModels(models: AdapterModel[]): AdapterModel[] {
@@ -88,7 +90,10 @@ async function fetchAnthropicModels(apiKey: string, baseUrl: string): Promise<Ad
});
}
return dedupeModels(models);
} catch {
} catch (error) {
console.warn("[paperclip] Claude model discovery failed", {
error: error instanceof Error ? error.message : String(error),
});
return [];
} finally {
clearTimeout(timeout);
@@ -106,6 +106,18 @@ describe("adapter model listing", () => {
expect(refreshed.some((model) => model.id === "claude-opus-4-8-20260529")).toBe(true);
});
it("falls back to static claude models when Anthropic model discovery fails", async () => {
process.env.ANTHROPIC_API_KEY = "sk-ant-test";
vi.spyOn(globalThis, "fetch").mockResolvedValue({
ok: false,
status: 401,
json: async () => ({}),
} as Response);
const models = await listAdapterModels("claude_local");
expect(models).toEqual(claudeFallbackModels);
});
it("loads codex models dynamically and merges fallback options", async () => {
process.env.OPENAI_API_KEY = "sk-test";
const fetchSpy = vi.spyOn(globalThis, "fetch").mockResolvedValue({