From 568f571d8ccbd570d405ac842da1f71edebc40a0 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Mon, 27 Apr 2026 09:16:35 -0400 Subject: [PATCH] fix(models): inline static model list in index.ts to break circular dep with server/models Co-Authored-By: Claude Sonnet 4.6 --- package.json | 2 +- src/index.ts | 29 ++++++++++++++++++++++++++++- src/server/models.test.ts | 20 +------------------- src/server/models.ts | 6 +++--- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index f3eec8f..4849c0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "paperclip-adapter-claude-k8s", - "version": "0.1.56", + "version": "0.1.57", "description": "Paperclip adapter plugin that runs Claude Code agents as Kubernetes Jobs", "license": "MIT", "repository": { diff --git a/src/index.ts b/src/index.ts index 85c1310..72b1510 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,34 @@ -import { DIRECT_MODELS, BEDROCK_MODELS, isBedrockEnv } from "./server/models.js"; +import type { AdapterModel } from "@paperclipai/adapter-utils"; export const type = "claude_k8s"; export const label = "Claude (Kubernetes)"; + +function isBedrockEnv(): boolean { + return ( + process.env.CLAUDE_CODE_USE_BEDROCK === "1" || + process.env.CLAUDE_CODE_USE_BEDROCK === "true" || + (typeof process.env.ANTHROPIC_BEDROCK_BASE_URL === "string" && + process.env.ANTHROPIC_BEDROCK_BASE_URL.trim().length > 0) + ); +} + +const DIRECT_MODELS: AdapterModel[] = [ + { id: "claude-opus-4-7", label: "Claude Opus 4.7" }, + { id: "claude-opus-4-6", label: "Claude Opus 4.6" }, + { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" }, + { id: "claude-haiku-4-6", label: "Claude Haiku 4.6" }, + { id: "claude-sonnet-4-5-20250929", label: "Claude Sonnet 4.5" }, + { id: "claude-haiku-4-5-20251001", label: "Claude Haiku 4.5" }, +]; + +const BEDROCK_MODELS: AdapterModel[] = [ + { id: "us.anthropic.claude-opus-4-7", label: "Bedrock Opus 4.7" }, + { id: "us.anthropic.claude-opus-4-6-v1", label: "Bedrock Opus 4.6" }, + { id: "us.anthropic.claude-sonnet-4-6", label: "Bedrock Sonnet 4.6" }, + { id: "us.anthropic.claude-sonnet-4-5-20250929-v1:0", label: "Bedrock Sonnet 4.5" }, + { id: "us.anthropic.claude-haiku-4-5-20251001-v1:0", label: "Bedrock Haiku 4.5" }, +]; + export const models = isBedrockEnv() ? BEDROCK_MODELS : DIRECT_MODELS; export const agentConfigurationDoc = `# claude_k8s agent configuration diff --git a/src/server/models.test.ts b/src/server/models.test.ts index 4df6636..54f09f1 100644 --- a/src/server/models.test.ts +++ b/src/server/models.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest"; -import { listK8sModels, DIRECT_MODELS, BEDROCK_MODELS } from "./models.js"; +import { listK8sModels } from "./models.js"; describe("listK8sModels", () => { const savedEnv: Record = {}; @@ -51,21 +51,3 @@ describe("listK8sModels", () => { }); }); -describe("static model lists", () => { - it("DIRECT_MODELS is non-empty and has valid ids", () => { - expect(DIRECT_MODELS.length).toBeGreaterThan(0); - for (const m of DIRECT_MODELS) { - expect(typeof m.id).toBe("string"); - expect(m.id.length).toBeGreaterThan(0); - expect(typeof m.label).toBe("string"); - } - }); - - it("BEDROCK_MODELS is non-empty and all ids contain 'anthropic.'", () => { - expect(BEDROCK_MODELS.length).toBeGreaterThan(0); - for (const m of BEDROCK_MODELS) { - expect(m.id).toContain("anthropic."); - expect(typeof m.label).toBe("string"); - } - }); -}); diff --git a/src/server/models.ts b/src/server/models.ts index 953013b..a153e11 100644 --- a/src/server/models.ts +++ b/src/server/models.ts @@ -1,6 +1,6 @@ import type { AdapterModel } from "@paperclipai/adapter-utils"; -export const DIRECT_MODELS: AdapterModel[] = [ +const DIRECT_MODELS: AdapterModel[] = [ { id: "claude-opus-4-7", label: "Claude Opus 4.7" }, { id: "claude-opus-4-6", label: "Claude Opus 4.6" }, { id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" }, @@ -9,7 +9,7 @@ export const DIRECT_MODELS: AdapterModel[] = [ { id: "claude-haiku-4-5-20251001", label: "Claude Haiku 4.5" }, ]; -export const BEDROCK_MODELS: AdapterModel[] = [ +const BEDROCK_MODELS: AdapterModel[] = [ { id: "us.anthropic.claude-opus-4-7", label: "Bedrock Opus 4.7" }, { id: "us.anthropic.claude-opus-4-6-v1", label: "Bedrock Opus 4.6" }, { id: "us.anthropic.claude-sonnet-4-6", label: "Bedrock Sonnet 4.6" }, @@ -17,7 +17,7 @@ export const BEDROCK_MODELS: AdapterModel[] = [ { id: "us.anthropic.claude-haiku-4-5-20251001-v1:0", label: "Bedrock Haiku 4.5" }, ]; -export function isBedrockEnv(): boolean { +function isBedrockEnv(): boolean { return ( process.env.CLAUDE_CODE_USE_BEDROCK === "1" || process.env.CLAUDE_CODE_USE_BEDROCK === "true" ||