Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions apps/mesh/src/ai-providers/adapters/claude-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,45 @@ import type { MeshProvider, ModelInfo, ProviderAdapter } from "../types";
export const CLAUDE_CODE_MODELS: ModelInfo[] = [
{
providerId: "claude-code",
modelId: "haiku",
title: "Claude Haiku",
modelId: "claude-code:haiku",
title: "Claude Code Haiku",
description: "Fast and lightweight",
capabilities: ["text"],
limits: null,
costs: null,
},
{
providerId: "claude-code",
modelId: "sonnet",
title: "Claude Sonnet",
modelId: "claude-code:sonnet",
title: "Claude Code Sonnet",
description: "Balanced performance",
capabilities: ["text", "reasoning"],
limits: null,
costs: null,
},
{
providerId: "claude-code",
modelId: "opus",
title: "Claude Opus",
modelId: "claude-code:opus",
title: "Claude Code Opus",
description: "Most capable",
capabilities: ["text", "reasoning"],
limits: null,
costs: null,
},
];

/** Map composite model IDs (e.g. "claude-code:sonnet") to SDK model names. */
const CLAUDE_CODE_SDK_MODELS: Record<string, string> = {
"claude-code:opus": "opus",
"claude-code:sonnet": "sonnet",
"claude-code:haiku": "haiku",
};

/** Resolve a composite claude-code model ID to the SDK model name. */
export function resolveClaudeCodeModelId(modelId: string): string {
return CLAUDE_CODE_SDK_MODELS[modelId] ?? modelId;
}

/**
* Create a Claude Code language model with MCP servers attached.
* This is separate from the adapter's create() because it needs
Expand Down
28 changes: 17 additions & 11 deletions apps/mesh/src/api/routes/decopilot/stream-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ import type { ChatMessage, ModelInfo, ModelsConfig } from "./types";
import type { CancelBroadcast } from "./cancel-broadcast";
import { ThreadMessage } from "@/storage/types";
import type { MeshProvider } from "@/ai-providers/types";
import { createClaudeCodeModel } from "@/ai-providers/adapters/claude-code";
import {
createClaudeCodeModel,
resolveClaudeCodeModelId,
} from "@/ai-providers/adapters/claude-code";
import { getInternalUrl } from "@/core/server-constants";

/**
Expand Down Expand Up @@ -436,19 +439,22 @@ export async function streamCore(
});

const mcpUrl = `${getInternalUrl()}/mcp/virtual-mcp/${input.agent.id}`;
languageModel = createClaudeCodeModel(input.models.thinking.id, {
mcpServers: {
mesh: {
type: "http",
url: mcpUrl,
headers: {
Authorization: `Bearer ${apiKey.key}`,
"x-org-id": input.organizationId,
languageModel = createClaudeCodeModel(
resolveClaudeCodeModelId(input.models.thinking.id),
{
mcpServers: {
mesh: {
type: "http",
url: mcpUrl,
headers: {
Authorization: `Bearer ${apiKey.key}`,
"x-org-id": input.organizationId,
},
},
},
toolApprovalLevel: input.toolApprovalLevel,
},
toolApprovalLevel: input.toolApprovalLevel,
});
);
} else {
languageModel = createLanguageModel(provider!, input.models.thinking);
}
Expand Down
3 changes: 3 additions & 0 deletions apps/mesh/src/web/components/chat/select-model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const TIER_PATTERNS: Array<{ tier: TierId; prefixes: string[] }> = [
{
tier: "smarter",
prefixes: [
"claude-code:opus",
"anthropic/claude-4.6-opus",
"anthropic/claude-opus-4.6",
"anthropic/claude-sonnet-4.6",
Expand All @@ -105,6 +106,7 @@ const TIER_PATTERNS: Array<{ tier: TierId; prefixes: string[] }> = [
{
tier: "faster",
prefixes: [
"claude-code:sonnet",
"anthropic/claude-haiku-4.5",
"anthropic/claude-4.5-haiku",
"google/gemini-3-flash",
Expand All @@ -120,6 +122,7 @@ const TIER_PATTERNS: Array<{ tier: TierId; prefixes: string[] }> = [
{
tier: "cheaper",
prefixes: [
"claude-code:haiku",
"google/gemini-2.5-flash-lite",
"google/gemini-2.5-flash",
"google/gemini-2.0-flash",
Expand Down
5 changes: 5 additions & 0 deletions packages/mesh-sdk/src/lib/default-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const DEFAULT_MODEL_PREFERENCES: Partial<Record<ProviderId, string[]>> =
"anthropic/claude",
],
google: ["gemini-3-flash"],
"claude-code": [
"claude-code:sonnet",
"claude-code:opus",
"claude-code:haiku",
],
};

/**
Expand Down
Loading