Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { track } from '@/lib/metrics/track'
import { getModelContextLength, getModelOptions } from './models'

const providerTypeEnum = z.enum([
'moonshot',
'anthropic',
'openai',
'openai-compatible',
Expand Down
5 changes: 5 additions & 0 deletions apps/agent/entrypoints/app/ai-settings/ProviderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const ProviderCard: FC<ProviderCardProps> = ({
</Badge>
)}
</div>
{isBuiltIn && provider.type === 'browseros' && (
<span className="mb-1 inline-block rounded-full bg-gradient-to-r from-orange-500 to-amber-500 px-3 py-0.5 font-semibold text-white text-xs">
Free model Sponsored by Kimi K2.5
</span>
)}
<p className="truncate text-muted-foreground text-sm">
{isBuiltIn ? (
<>
Expand Down
2 changes: 2 additions & 0 deletions apps/agent/entrypoints/app/ai-settings/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export interface ModelsData {
lmstudio: ModelInfo[]
bedrock: ModelInfo[]
browseros: ModelInfo[]
moonshot: ModelInfo[]
}

/**
* Available models per provider with context lengths
* Based on: https://github.com/browseros-ai/BrowserOS-agent/blob/main/src/options/data/models.ts
*/
export const MODELS_DATA: ModelsData = {
moonshot: [{ modelId: 'kimi-k2-0905-preview', contextLength: 128000 }],
anthropic: [
{ modelId: 'claude-opus-4-5-20251101', contextLength: 200000 },
{ modelId: 'claude-haiku-4-5-20251001', contextLength: 200000 },
Expand Down
21 changes: 17 additions & 4 deletions apps/agent/entrypoints/app/llm-hub/HubProviderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Globe2, Trash2 } from 'lucide-react'
import type { FC } from 'react'
import { useMemo } from 'react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import { getFaviconUrl, type LlmHubProvider } from './models'

interface HubProviderRowProps {
Expand All @@ -18,9 +19,16 @@ export const HubProviderRow: FC<HubProviderRowProps> = ({
onDelete,
}) => {
const iconUrl = useMemo(() => getFaviconUrl(provider.url), [provider.url])
const isKimi = provider.name === 'Kimi'

return (
<div className="group flex w-full items-center gap-4 rounded-xl border border-border bg-card p-4 transition-all hover:border-[var(--accent-orange)] hover:shadow-md">
<div
className={cn(
'group flex w-full items-center gap-4 rounded-xl border border-border bg-card p-4 transition-all hover:border-[var(--accent-orange)] hover:shadow-md',
isKimi &&
'border-orange-400/60 shadow-[0_0_15px_rgba(251,146,60,0.3)] ring-2 ring-orange-400/50',
)}
>
<div className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted">
{iconUrl ? (
<img
Expand All @@ -34,9 +42,14 @@ export const HubProviderRow: FC<HubProviderRowProps> = ({
</div>

<div className="min-w-0 flex-1">
<span className="mb-0.5 block truncate font-semibold">
{provider.name}
</span>
<div className="mb-0.5 flex items-center gap-2">
<span className="block truncate font-semibold">{provider.name}</span>
{isKimi && (
<span className="rounded-full bg-gradient-to-r from-orange-500 to-amber-500 px-2.5 py-0.5 font-medium text-white text-xs">
Try Kimi
</span>
)}
</div>
<p className="truncate text-muted-foreground/70 text-xs">
{provider.url}
</p>
Expand Down
1 change: 1 addition & 0 deletions apps/agent/lib/llm-hub/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface LlmHubProvider {
}

export const DEFAULT_PROVIDERS: LlmHubProvider[] = [
{ name: 'Kimi', url: 'https://www.kimi.com' },
{ name: 'ChatGPT', url: 'https://chatgpt.com' },
{ name: 'Claude', url: 'https://claude.ai' },
{ name: 'Grok', url: 'https://grok.com' },
Expand Down
2 changes: 2 additions & 0 deletions apps/agent/lib/llm-providers/providerIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Azure,
Bedrock,
Gemini,
Kimi,
LmStudio,
Ollama,
OpenAI,
Expand Down Expand Up @@ -30,6 +31,7 @@ const providerIconMap: Record<ProviderType, IconComponent | null> = {
lmstudio: LmStudio,
bedrock: Bedrock,
browseros: null,
moonshot: Kimi,
}

interface ProviderIconProps {
Expand Down
11 changes: 11 additions & 0 deletions apps/agent/lib/llm-providers/providerTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export interface ProviderTemplate {
* @public
*/
export const providerTemplates: ProviderTemplate[] = [
{
id: 'moonshot',
name: 'Moonshot / Kimi',
defaultBaseUrl: 'https://api.moonshot.ai/v1',
defaultModelId: 'kimi-k2-0905-preview',
supportsImages: true,
contextWindow: 128000,
apiKeyUrl: 'https://platform.moonshot.ai/console/api-keys',
},
{
id: 'openai',
name: 'OpenAI',
Expand Down Expand Up @@ -119,6 +128,7 @@ export const providerTemplates: ProviderTemplate[] = [
* @public
*/
export const providerTypeOptions: { value: ProviderType; label: string }[] = [
{ value: 'moonshot', label: 'Moonshot / Kimi' },
{ value: 'anthropic', label: 'Anthropic' },
{ value: 'openai', label: 'OpenAI' },
{ value: 'openai-compatible', label: 'OpenAI Compatible' },
Expand Down Expand Up @@ -146,6 +156,7 @@ export const getProviderTemplate = (
* Auto-fills when user selects a provider type
*/
export const DEFAULT_BASE_URLS: Record<ProviderType, string> = {
moonshot: 'https://api.moonshot.ai/v1',
anthropic: 'https://api.anthropic.com/v1',
openai: 'https://api.openai.com/v1',
'openai-compatible': '',
Expand Down
1 change: 1 addition & 0 deletions apps/agent/lib/llm-providers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type ProviderType =
| 'lmstudio'
| 'bedrock'
| 'browseros'
| 'moonshot'

/**
* LLM Provider configuration
Expand Down
12 changes: 12 additions & 0 deletions apps/server/src/agent/provider-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ function createOpenAICompatibleFactory(
})
}

function createMoonshotFactory(
config: VercelAIConfig,
): (modelId: string) => unknown {
if (!config.baseUrl) throw new Error('Moonshot provider requires baseUrl')
return createOpenAICompatible({
name: 'moonshot',
baseURL: config.baseUrl,
...(config.apiKey && { apiKey: config.apiKey }),
})
}

const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[AIProvider.ANTHROPIC]: createAnthropicFactory,
[AIProvider.OPENAI]: createOpenAIFactory,
Expand All @@ -171,6 +182,7 @@ const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[AIProvider.BEDROCK]: createBedrockFactory,
[AIProvider.BROWSEROS]: createBrowserOSFactory,
[AIProvider.OPENAI_COMPATIBLE]: createOpenAICompatibleFactory,
[AIProvider.MOONSHOT]: createMoonshotFactory,
}

/**
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/agent/provider-adapter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export enum AIProvider {
BEDROCK = 'bedrock',
BROWSEROS = 'browseros',
OPENAI_COMPATIBLE = 'openai-compatible',
MOONSHOT = 'moonshot',
}

/**
Expand Down
12 changes: 12 additions & 0 deletions apps/server/src/agent/tool-loop/provider-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ function createOpenAICompatibleFactory(
})
}

function createMoonshotFactory(
config: ResolvedAgentConfig,
): (modelId: string) => unknown {
if (!config.baseUrl) throw new Error('Moonshot provider requires baseUrl')
return createOpenAICompatible({
name: 'moonshot',
baseURL: config.baseUrl,
...(config.apiKey && { apiKey: config.apiKey }),
})
}

const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[LLM_PROVIDERS.ANTHROPIC]: createAnthropicFactory,
[LLM_PROVIDERS.OPENAI]: createOpenAIFactory,
Expand All @@ -147,6 +158,7 @@ const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[LLM_PROVIDERS.BEDROCK]: createBedrockFactory,
[LLM_PROVIDERS.BROWSEROS]: createBrowserOSFactory,
[LLM_PROVIDERS.OPENAI_COMPATIBLE]: createOpenAICompatibleFactory,
[LLM_PROVIDERS.MOONSHOT]: createMoonshotFactory,
}

export function createLanguageModel(
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/lib/clients/llm/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ function createOpenAICompatibleModel(config: ResolvedLLMConfig): LanguageModel {
})(config.model)
}

function createMoonshotModel(config: ResolvedLLMConfig): LanguageModel {
if (!config.baseUrl) throw new Error('Moonshot provider requires baseUrl')
return createOpenAICompatible({
name: 'moonshot',
baseURL: config.baseUrl,
...(config.apiKey && { apiKey: config.apiKey }),
})(config.model)
}

const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[LLM_PROVIDERS.ANTHROPIC]: createAnthropicModel,
[LLM_PROVIDERS.OPENAI]: createOpenAIModel,
Expand All @@ -135,6 +144,7 @@ const PROVIDER_FACTORIES: Record<string, ProviderFactory> = {
[LLM_PROVIDERS.BEDROCK]: createBedrockModel,
[LLM_PROVIDERS.BROWSEROS]: createBrowserOSModel,
[LLM_PROVIDERS.OPENAI_COMPATIBLE]: createOpenAICompatibleModel,
[LLM_PROVIDERS.MOONSHOT]: createMoonshotModel,
}

export function createLLMProvider(config: ResolvedLLMConfig): LanguageModel {
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/src/schemas/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LLM_PROVIDERS = {
BEDROCK: 'bedrock',
BROWSEROS: 'browseros',
OPENAI_COMPATIBLE: 'openai-compatible',
MOONSHOT: 'moonshot',
} as const

/**
Expand All @@ -40,6 +41,7 @@ export const LLMProviderSchema: z.ZodEnum<
'bedrock',
'browseros',
'openai-compatible',
'moonshot',
]
> = z.enum([
LLM_PROVIDERS.ANTHROPIC,
Expand All @@ -52,6 +54,7 @@ export const LLMProviderSchema: z.ZodEnum<
LLM_PROVIDERS.BEDROCK,
LLM_PROVIDERS.BROWSEROS,
LLM_PROVIDERS.OPENAI_COMPATIBLE,
LLM_PROVIDERS.MOONSHOT,
])

export type LLMProvider = z.infer<typeof LLMProviderSchema>
Expand Down
Loading