mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat: add OpenCode models editor and bump version to 0.9.13
This commit is contained in:
1 parent
bfd65592f3
commit
0a37fd14a3
8 files changed
+1176
-4
No files matched your search
@@ -96,11 +96,11 @@ export async function importOpenCodeStateDirectory(sourcePath: string, targetPat
|
||||
const resolvedTargetPath = path.resolve(targetPath)
|
||||
const sourceDbPath = path.join(resolvedSourcePath, 'opencode.db')
|
||||
|
||||
if (!await fileExists(sourceDbPath)) {
|
||||
if (resolvedSourcePath === resolvedTargetPath) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (resolvedSourcePath === resolvedTargetPath) {
|
||||
if (!await fileExists(sourceDbPath)) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { AgentsEditor } from './AgentsEditor'
|
||||
import { AgentsMdEditor } from './AgentsMdEditor'
|
||||
import { McpManager } from './McpManager'
|
||||
import { SkillsEditor } from './SkillsEditor'
|
||||
import { OpenCodeModelsEditor, type ConfigProvider } from './OpenCodeModelsEditor'
|
||||
import { VersionSelectDialog } from './VersionSelectDialog'
|
||||
import { MemoryPluginConfig } from './MemoryPluginConfig'
|
||||
import { settingsApi } from '@/api/settings'
|
||||
@@ -65,6 +66,7 @@ export function OpenCodeConfigManager() {
|
||||
agents: false,
|
||||
skills: false,
|
||||
mcp: false,
|
||||
models: false,
|
||||
})
|
||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
|
||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
|
||||
@@ -76,6 +78,7 @@ export function OpenCodeConfigManager() {
|
||||
const agentsRef = useRef<HTMLButtonElement>(null)
|
||||
const skillsRef = useRef<HTMLButtonElement>(null)
|
||||
const mcpRef = useRef<HTMLButtonElement>(null)
|
||||
const modelsRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const { data: managedSkills = [] } = useQuery({
|
||||
queryKey: ['managed-skills'],
|
||||
@@ -868,6 +871,50 @@ export function OpenCodeConfigManager() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card border border-border rounded-lg overflow-hidden min-w-0">
|
||||
<button
|
||||
ref={modelsRef}
|
||||
className={cn("w-full px-4 py-3 flex items-center justify-between transition-colors min-w-0", expandedSections.models ? "bg-muted/40 hover:bg-muted/50" : "hover:bg-muted/50")}
|
||||
onClick={() => {
|
||||
const isExpanding = !expandedSections.models
|
||||
setExpandedSections(prev => ({ ...prev, models: isExpanding }))
|
||||
|
||||
if (isExpanding) {
|
||||
setTimeout(() => scrollToSection(modelsRef), 100)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
<h4 className="text-sm font-medium truncate">Models</h4>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{(() => {
|
||||
const provider = selectedConfig.content?.provider as Record<string, unknown> | undefined
|
||||
if (!provider) return 0
|
||||
return Object.values(provider).reduce<number>((acc, p) => {
|
||||
const models = (p as { models?: Record<string, unknown> })?.models
|
||||
return acc + (models ? Object.keys(models).length : 0)
|
||||
}, 0)
|
||||
})()} configured
|
||||
</span>
|
||||
</div>
|
||||
<ChevronDown className={`h-4 w-4 transition-transform ${expandedSections.models ? 'rotate-90' : ''}`} />
|
||||
</button>
|
||||
<div className={`${expandedSections.models ? 'block' : 'hidden'} border-t border-border`}>
|
||||
<div className="p-4 max-h-[50vh] overflow-y-auto">
|
||||
<OpenCodeModelsEditor
|
||||
providers={(selectedConfig.content?.provider as Record<string, ConfigProvider> | undefined) ?? {}}
|
||||
onChange={(providers) => {
|
||||
const updatedContent = {
|
||||
...selectedConfig.content,
|
||||
provider: providers
|
||||
}
|
||||
updateConfigContent(selectedConfig.name, updatedContent)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="bg-card border border-border rounded-lg p-6">
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { z } from 'zod'
|
||||
import { useCallback, useEffect, useMemo } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
|
||||
const modelFormSchema = z.object({
|
||||
providerId: z.string().min(1, 'Provider is required'),
|
||||
modelId: z.string().min(1, 'Model ID is required').regex(/^[a-zA-Z0-9_-]+$/, 'Must be alphanumeric with hyphens/underscores'),
|
||||
name: z.string().min(1, 'Display name is required'),
|
||||
contextLimit: z.number().min(0).optional(),
|
||||
outputLimit: z.number().min(0).optional(),
|
||||
createNewProvider: z.boolean(),
|
||||
newProviderType: z.enum(['api', 'npm']),
|
||||
newProviderId: z.string(),
|
||||
newProviderName: z.string().optional(),
|
||||
newProviderBaseUrl: z.string().optional(),
|
||||
newProviderNpm: z.string().optional(),
|
||||
}).superRefine((data, ctx) => {
|
||||
if (data.createNewProvider) {
|
||||
if (!data.newProviderId?.trim()) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Provider ID is required when creating a new provider',
|
||||
path: ['newProviderId'],
|
||||
})
|
||||
} else if (!/^[a-z0-9-]+$/.test(data.newProviderId)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Must be lowercase letters, numbers, and hyphens only',
|
||||
path: ['newProviderId'],
|
||||
})
|
||||
}
|
||||
if (data.newProviderType === 'api' && !data.newProviderBaseUrl?.trim()) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'Base URL is required for API providers',
|
||||
path: ['newProviderBaseUrl'],
|
||||
})
|
||||
}
|
||||
if (data.newProviderType === 'npm' && !data.newProviderNpm?.trim()) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: 'NPM package is required for npm providers',
|
||||
path: ['newProviderNpm'],
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
type ModelFormValues = z.infer<typeof modelFormSchema>
|
||||
|
||||
interface ConfigModel {
|
||||
name?: string
|
||||
limit?: {
|
||||
context?: number
|
||||
output?: number
|
||||
}
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface ConfigProvider {
|
||||
name?: string
|
||||
npm?: string
|
||||
api?: string
|
||||
options?: Record<string, unknown>
|
||||
models?: Record<string, ConfigModel>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface NewProviderConfig {
|
||||
id: string
|
||||
type: 'api' | 'npm'
|
||||
name?: string
|
||||
baseUrl?: string
|
||||
npm?: string
|
||||
}
|
||||
|
||||
interface OpenCodeModelDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
onSubmit: (providerId: string, modelId: string, model: ConfigModel, newProvider?: NewProviderConfig) => void
|
||||
availableProviders: string[]
|
||||
existingProviders?: Record<string, ConfigProvider>
|
||||
selectedProviderId: string
|
||||
editingModel?: {
|
||||
providerId: string
|
||||
modelId: string
|
||||
model: ConfigModel
|
||||
}
|
||||
}
|
||||
|
||||
export function OpenCodeModelDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
onSubmit,
|
||||
availableProviders,
|
||||
existingProviders,
|
||||
selectedProviderId,
|
||||
editingModel,
|
||||
}: OpenCodeModelDialogProps) {
|
||||
const getDefaultValues = useCallback((): ModelFormValues => {
|
||||
if (editingModel) {
|
||||
return {
|
||||
providerId: editingModel.providerId,
|
||||
modelId: editingModel.modelId,
|
||||
name: editingModel.model.name || '',
|
||||
contextLimit: editingModel.model.limit?.context,
|
||||
outputLimit: editingModel.model.limit?.output,
|
||||
createNewProvider: false,
|
||||
newProviderType: 'api' as const,
|
||||
newProviderId: '',
|
||||
newProviderName: '',
|
||||
newProviderBaseUrl: '',
|
||||
newProviderNpm: '',
|
||||
}
|
||||
}
|
||||
return {
|
||||
providerId: selectedProviderId || availableProviders[0] || '',
|
||||
modelId: '',
|
||||
name: '',
|
||||
contextLimit: undefined,
|
||||
outputLimit: undefined,
|
||||
createNewProvider: availableProviders.length === 0,
|
||||
newProviderType: 'api' as const,
|
||||
newProviderId: '',
|
||||
newProviderName: '',
|
||||
newProviderBaseUrl: '',
|
||||
newProviderNpm: '',
|
||||
}
|
||||
}, [editingModel, selectedProviderId, availableProviders])
|
||||
|
||||
const form = useForm<ModelFormValues>({
|
||||
resolver: zodResolver(modelFormSchema),
|
||||
defaultValues: getDefaultValues(),
|
||||
})
|
||||
|
||||
const createNewProvider = form.watch('createNewProvider')
|
||||
const newProviderType = form.watch('newProviderType')
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
form.reset(getDefaultValues())
|
||||
}
|
||||
}, [open, getDefaultValues, form])
|
||||
|
||||
const handleSubmit = (values: ModelFormValues) => {
|
||||
const model: ConfigModel = {
|
||||
name: values.name,
|
||||
}
|
||||
|
||||
if (values.contextLimit !== undefined || values.outputLimit !== undefined) {
|
||||
model.limit = {}
|
||||
if (values.contextLimit !== undefined) {
|
||||
model.limit.context = values.contextLimit
|
||||
}
|
||||
if (values.outputLimit !== undefined) {
|
||||
model.limit.output = values.outputLimit
|
||||
}
|
||||
}
|
||||
|
||||
let newProvider: NewProviderConfig | undefined
|
||||
if (values.createNewProvider) {
|
||||
newProvider = {
|
||||
id: values.newProviderId,
|
||||
type: values.newProviderType,
|
||||
name: values.newProviderName || undefined,
|
||||
baseUrl: values.newProviderBaseUrl || undefined,
|
||||
npm: values.newProviderNpm || undefined,
|
||||
}
|
||||
}
|
||||
|
||||
if (newProvider) {
|
||||
onSubmit(values.providerId, values.modelId, model, newProvider)
|
||||
} else {
|
||||
onSubmit(values.providerId, values.modelId, model)
|
||||
}
|
||||
form.reset()
|
||||
onOpenChange(false)
|
||||
}
|
||||
|
||||
const handleOpenChange = (isOpen: boolean) => {
|
||||
if (!isOpen) {
|
||||
form.reset()
|
||||
}
|
||||
onOpenChange(isOpen)
|
||||
}
|
||||
|
||||
const providerOptions = useMemo(() => {
|
||||
return availableProviders.map((p: string) => ({
|
||||
value: p,
|
||||
label: existingProviders?.[p]?.name || p,
|
||||
}))
|
||||
}, [availableProviders, existingProviders])
|
||||
|
||||
const isEditing = !!editingModel
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<DialogContent mobileFullscreen className="sm:max-w-2xl sm:max-h-[85vh] gap-0 flex flex-col p-0 md:p-6">
|
||||
<DialogHeader className="p-4 sm:p-6 border-b flex flex-row items-center justify-between space-y-0">
|
||||
<DialogTitle>{isEditing ? 'Edit Model' : 'Create Model'}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-2 sm:p-4" onClick={(e) => e.stopPropagation()} onPointerDown={(e) => e.stopPropagation()}>
|
||||
<Form {...form}>
|
||||
<div className="space-y-4">
|
||||
{!isEditing && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="createNewProvider"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
||||
<div className="space-y-0.5">
|
||||
<FormLabel>Create new provider</FormLabel>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Add a new provider configuration
|
||||
</p>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Switch
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{createNewProvider ? (
|
||||
<div className="space-y-4 border rounded-lg p-4 bg-muted/30">
|
||||
<h4 className="text-sm font-medium">New Provider</h4>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newProviderType"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Provider Type</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="api">API (HTTP endpoint)</SelectItem>
|
||||
<SelectItem value="npm">NPM Package</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newProviderId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Provider ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., my-provider"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newProviderName"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Display Name (optional)</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., My Provider"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{newProviderType === 'api' && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newProviderBaseUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Base URL</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., https://api.openai.com/v1"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{newProviderType === 'npm' && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="newProviderNpm"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>NPM Package</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., @modelcontextprotocol/server-filesystem"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="providerId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Provider</FormLabel>
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
defaultValue={field.value}
|
||||
disabled={isEditing}
|
||||
>
|
||||
<FormControl>
|
||||
<SelectTrigger className={isEditing ? 'bg-muted' : ''}>
|
||||
<SelectValue placeholder="Select provider" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{providerOptions.map(option => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="modelId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Model ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., gpt-4o, claude-3-opus"
|
||||
disabled={isEditing}
|
||||
className={isEditing ? 'bg-muted' : ''}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Display Name</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="e.g., GPT-4o, Claude 3 Opus"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="contextLimit"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Context Limit</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder="e.g., 128000"
|
||||
value={field.value ?? ''}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value
|
||||
field.onChange(val ? parseInt(val, 10) : undefined)
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="outputLimit"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Output Limit</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder="e.g., 4096"
|
||||
value={field.value ?? ''}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value
|
||||
field.onChange(val ? parseInt(val, 10) : undefined)
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="p-3 sm:p-4 border-t gap-2 pb-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => handleOpenChange(false)}
|
||||
className="flex-1 sm:flex-none"
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => form.handleSubmit(handleSubmit)()}
|
||||
disabled={!form.formState.isValid}
|
||||
className="flex-1 sm:flex-none"
|
||||
>
|
||||
{isEditing ? 'Update' : 'Create'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import { OpenCodeModelsEditor } from './OpenCodeModelsEditor'
|
||||
import type { ConfigProvider, ConfigModel } from './OpenCodeModelsEditor'
|
||||
|
||||
const mockProviders: Record<string, ConfigProvider> = {
|
||||
openai: {
|
||||
name: 'OpenAI',
|
||||
models: {
|
||||
'gpt-4o': {
|
||||
name: 'GPT-4o',
|
||||
limit: { context: 128000, output: 4096 },
|
||||
},
|
||||
},
|
||||
},
|
||||
anthropic: {
|
||||
name: 'Anthropic',
|
||||
models: {
|
||||
'claude-3-5-sonnet': {
|
||||
name: 'Claude 3.5 Sonnet',
|
||||
limit: { context: 200000, output: 8192 },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
describe('OpenCodeModelsEditor', () => {
|
||||
describe('rendering', () => {
|
||||
it('should render empty state when no providers configured', () => {
|
||||
const onChange = vi.fn()
|
||||
render(<OpenCodeModelsEditor providers={{}} onChange={onChange} />)
|
||||
|
||||
expect(screen.getByText(/No models configured/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/Add your first model to get started/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render provider groups with model counts', () => {
|
||||
const onChange = vi.fn()
|
||||
render(<OpenCodeModelsEditor providers={mockProviders} onChange={onChange} />)
|
||||
|
||||
expect(screen.getByText('OpenAI')).toBeInTheDocument()
|
||||
expect(screen.getByText('Anthropic')).toBeInTheDocument()
|
||||
const modelCountSpans = screen.getAllByText(/\(1 model\)/)
|
||||
expect(modelCountSpans.length).toBe(2)
|
||||
})
|
||||
|
||||
it('should render model entries with display names and IDs', () => {
|
||||
const onChange = vi.fn()
|
||||
render(<OpenCodeModelsEditor providers={mockProviders} onChange={onChange} />)
|
||||
|
||||
expect(screen.getByText('GPT-4o')).toBeInTheDocument()
|
||||
expect(screen.getByText('gpt-4o')).toBeInTheDocument()
|
||||
expect(screen.getByText('Claude 3.5 Sonnet')).toBeInTheDocument()
|
||||
expect(screen.getByText('claude-3-5-sonnet')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should render model limits when present', () => {
|
||||
const onChange = vi.fn()
|
||||
render(<OpenCodeModelsEditor providers={mockProviders} onChange={onChange} />)
|
||||
|
||||
expect(screen.getByText(/Context 128000/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/Output 4096/)).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
describe('delete model', () => {
|
||||
it('should call onChange with updated providers when model is deleted', () => {
|
||||
const onChange = vi.fn()
|
||||
render(<OpenCodeModelsEditor providers={mockProviders} onChange={onChange} />)
|
||||
|
||||
const deleteButtons = document.querySelectorAll('button')
|
||||
let deleteButton: HTMLButtonElement | null = null
|
||||
deleteButtons.forEach(btn => {
|
||||
const svg = btn.querySelector('svg')
|
||||
if (svg && svg.className.baseVal.includes('Trash2')) {
|
||||
deleteButton = btn as HTMLButtonElement
|
||||
}
|
||||
})
|
||||
|
||||
expect(deleteButton).not.toBeNull()
|
||||
if (deleteButton) {
|
||||
fireEvent.click(deleteButton)
|
||||
}
|
||||
|
||||
expect(onChange).toHaveBeenCalled()
|
||||
const updatedProviders = onChange.mock.calls[0][0]
|
||||
expect(updatedProviders.openai).toBeDefined()
|
||||
expect(updatedProviders.openai.models).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('model content structure', () => {
|
||||
it('should preserve provider structure when models change', () => {
|
||||
const onChange = vi.fn()
|
||||
const providersWithExtras: Record<string, ConfigProvider> = {
|
||||
openai: {
|
||||
name: 'OpenAI',
|
||||
api: 'https://api.openai.com',
|
||||
npm: '@opencode-manager/provider-openai',
|
||||
models: {
|
||||
'gpt-4o': {
|
||||
name: 'GPT-4o',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
render(<OpenCodeModelsEditor providers={providersWithExtras} onChange={onChange} />)
|
||||
|
||||
const deleteButtons = document.querySelectorAll('button')
|
||||
let deleteButton: HTMLButtonElement | null = null
|
||||
deleteButtons.forEach(btn => {
|
||||
const svg = btn.querySelector('svg')
|
||||
if (svg && svg.className.baseVal.includes('Trash2')) {
|
||||
deleteButton = btn as HTMLButtonElement
|
||||
}
|
||||
})
|
||||
|
||||
if (deleteButton) {
|
||||
fireEvent.click(deleteButton)
|
||||
}
|
||||
|
||||
expect(onChange).toHaveBeenCalled()
|
||||
const updatedProviders = onChange.mock.calls[0][0]
|
||||
expect(updatedProviders.openai.name).toBe('OpenAI')
|
||||
expect(updatedProviders.openai.api).toBe('https://api.openai.com')
|
||||
expect(updatedProviders.openai.npm).toBe('@opencode-manager/provider-openai')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('OpenCodeModelDialog', () => {
|
||||
const defaultProps = {
|
||||
open: true,
|
||||
onOpenChange: vi.fn(),
|
||||
onSubmit: vi.fn(),
|
||||
availableProviders: ['openai', 'anthropic'],
|
||||
selectedProviderId: 'openai',
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('form validation', () => {
|
||||
it('should require model id when submitting empty form', async () => {
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(<OpenCodeModelDialog {...defaultProps} />)
|
||||
|
||||
const createButton = screen.getByRole('button', { name: /create/i })
|
||||
fireEvent.click(createButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/model id is required/i)).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
it('should require display name when submitting empty form', async () => {
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(<OpenCodeModelDialog {...defaultProps} />)
|
||||
|
||||
const createButton = screen.getByRole('button', { name: /create/i })
|
||||
fireEvent.click(createButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/display name is required/i)).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
it('should validate model id format', async () => {
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(<OpenCodeModelDialog {...defaultProps} />)
|
||||
|
||||
const modelIdInput = document.querySelector('input[name="modelId"]') as HTMLInputElement
|
||||
if (modelIdInput) {
|
||||
fireEvent.change(modelIdInput, { target: { value: 'invalid model id!' } })
|
||||
const createButton = screen.getByRole('button', { name: /create/i })
|
||||
fireEvent.click(createButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/alphanumeric/i)).toBeInTheDocument()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('form submission', () => {
|
||||
it('should call onSubmit with correct provider id, model id, and model data', async () => {
|
||||
const onSubmit = vi.fn()
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(<OpenCodeModelDialog {...defaultProps} onSubmit={onSubmit} />)
|
||||
|
||||
const modelIdInput = document.querySelector('input[name="modelId"]') as HTMLInputElement
|
||||
const nameInput = document.querySelector('input[name="name"]') as HTMLInputElement
|
||||
|
||||
if (modelIdInput && nameInput) {
|
||||
fireEvent.change(modelIdInput, { target: { value: 'gpt-5' } })
|
||||
fireEvent.change(nameInput, { target: { value: 'GPT-5' } })
|
||||
}
|
||||
|
||||
const createButton = screen.getByRole('button', { name: /create/i })
|
||||
fireEvent.click(createButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onSubmit).toHaveBeenCalledWith(
|
||||
'openai',
|
||||
'gpt-5',
|
||||
expect.objectContaining({
|
||||
name: 'GPT-5',
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('should include limit data when provided', async () => {
|
||||
const onSubmit = vi.fn()
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(<OpenCodeModelDialog {...defaultProps} onSubmit={onSubmit} />)
|
||||
|
||||
const modelIdInput = document.querySelector('input[name="modelId"]') as HTMLInputElement
|
||||
const nameInput = document.querySelector('input[name="name"]') as HTMLInputElement
|
||||
const contextLimitInput = document.querySelector('input[name="contextLimit"]') as HTMLInputElement
|
||||
const outputLimitInput = document.querySelector('input[name="outputLimit"]') as HTMLInputElement
|
||||
|
||||
if (modelIdInput && nameInput && contextLimitInput && outputLimitInput) {
|
||||
fireEvent.change(modelIdInput, { target: { value: 'gpt-5' } })
|
||||
fireEvent.change(nameInput, { target: { value: 'GPT-5' } })
|
||||
fireEvent.change(contextLimitInput, { target: { value: '256000' } })
|
||||
fireEvent.change(outputLimitInput, { target: { value: '8192' } })
|
||||
}
|
||||
|
||||
const createButton = screen.getByRole('button', { name: /create/i })
|
||||
fireEvent.click(createButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onSubmit).toHaveBeenCalledWith(
|
||||
'openai',
|
||||
'gpt-5',
|
||||
expect.objectContaining({
|
||||
name: 'GPT-5',
|
||||
limit: {
|
||||
context: 256000,
|
||||
output: 8192,
|
||||
},
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('edit mode', () => {
|
||||
it('should pre-fill form with existing model data', async () => {
|
||||
const editingModel = {
|
||||
providerId: 'openai',
|
||||
modelId: 'gpt-4o',
|
||||
model: {
|
||||
name: 'GPT-4o',
|
||||
limit: { context: 128000, output: 4096 },
|
||||
} as ConfigModel,
|
||||
}
|
||||
|
||||
const onSubmit = vi.fn()
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(
|
||||
<OpenCodeModelDialog
|
||||
{...defaultProps}
|
||||
onSubmit={onSubmit}
|
||||
editingModel={editingModel}
|
||||
open={true}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(screen.getByDisplayValue('GPT-4o')).toBeInTheDocument()
|
||||
expect(screen.getByDisplayValue('gpt-4o')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should emit Update button text when editing', async () => {
|
||||
const editingModel = {
|
||||
providerId: 'openai',
|
||||
modelId: 'gpt-4o',
|
||||
model: {
|
||||
name: 'GPT-4o',
|
||||
} as ConfigModel,
|
||||
}
|
||||
|
||||
const { OpenCodeModelDialog } = await import('./OpenCodeModelDialog')
|
||||
render(
|
||||
<OpenCodeModelDialog
|
||||
{...defaultProps}
|
||||
editingModel={editingModel}
|
||||
open={true}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(screen.getByRole('button', { name: /update/i })).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,258 @@
|
||||
import { useState } from 'react'
|
||||
import { Plus, Trash2, Edit, Box } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Dialog, DialogTrigger } from '@/components/ui/dialog'
|
||||
import { OpenCodeModelDialog, type NewProviderConfig } from './OpenCodeModelDialog'
|
||||
|
||||
export interface ConfigModel {
|
||||
name?: string
|
||||
limit?: {
|
||||
context?: number
|
||||
output?: number
|
||||
}
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface ConfigProvider {
|
||||
name?: string
|
||||
npm?: string
|
||||
api?: string
|
||||
options?: Record<string, unknown>
|
||||
models?: Record<string, ConfigModel>
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
interface ProviderModels {
|
||||
providerId: string
|
||||
providerName: string
|
||||
models: Record<string, ConfigModel>
|
||||
}
|
||||
|
||||
interface OpenCodeModelsEditorProps {
|
||||
providers: Record<string, ConfigProvider>
|
||||
onChange: (providers: Record<string, ConfigProvider>) => void
|
||||
}
|
||||
|
||||
interface EditingModel {
|
||||
providerId: string
|
||||
modelId: string
|
||||
model: ConfigModel
|
||||
}
|
||||
|
||||
export function OpenCodeModelsEditor({ providers, onChange }: OpenCodeModelsEditorProps) {
|
||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false)
|
||||
const [editingModel, setEditingModel] = useState<EditingModel | null>(null)
|
||||
const [selectedProviderId, setSelectedProviderId] = useState<string>('')
|
||||
|
||||
const providerEntries: ProviderModels[] = Object.entries(providers).map(
|
||||
([providerId, provider]) => ({
|
||||
providerId,
|
||||
providerName: provider.name || providerId,
|
||||
models: provider.models || {},
|
||||
})
|
||||
)
|
||||
|
||||
const totalModelCount = providerEntries.reduce(
|
||||
(acc, p) => acc + Object.keys(p.models).length,
|
||||
0
|
||||
)
|
||||
|
||||
const handleModelSubmit = (
|
||||
providerId: string,
|
||||
modelId: string,
|
||||
model: ConfigModel,
|
||||
newProvider?: NewProviderConfig,
|
||||
originalProviderId?: string,
|
||||
originalModelId?: string
|
||||
) => {
|
||||
const updatedProviders = { ...providers }
|
||||
|
||||
if (newProvider) {
|
||||
const providerConfig: ConfigProvider = {
|
||||
name: newProvider.name || newProvider.id,
|
||||
}
|
||||
if (newProvider.type === 'api' && newProvider.baseUrl) {
|
||||
providerConfig.api = newProvider.baseUrl
|
||||
providerConfig.options = { baseURL: newProvider.baseUrl }
|
||||
} else if (newProvider.type === 'npm' && newProvider.npm) {
|
||||
providerConfig.npm = newProvider.npm
|
||||
}
|
||||
updatedProviders[newProvider.id] = providerConfig
|
||||
providerId = newProvider.id
|
||||
}
|
||||
|
||||
if (originalProviderId && originalModelId && originalProviderId !== providerId) {
|
||||
const originalProvider = updatedProviders[originalProviderId]
|
||||
if (originalProvider?.models) {
|
||||
const updatedModels = { ...originalProvider.models }
|
||||
delete updatedModels[originalModelId]
|
||||
updatedProviders[originalProviderId] = {
|
||||
...originalProvider,
|
||||
models: updatedModels,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (originalModelId && originalModelId !== modelId) {
|
||||
const targetProvider = updatedProviders[providerId] || {}
|
||||
if (targetProvider.models?.[originalModelId]) {
|
||||
const updatedModels = { ...targetProvider.models }
|
||||
delete updatedModels[originalModelId]
|
||||
updatedProviders[providerId] = {
|
||||
...targetProvider,
|
||||
models: updatedModels,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const targetProvider = updatedProviders[providerId] || {}
|
||||
updatedProviders[providerId] = {
|
||||
...targetProvider,
|
||||
models: {
|
||||
...(targetProvider.models || {}),
|
||||
[modelId]: {
|
||||
...(targetProvider.models?.[modelId] || {}),
|
||||
...model,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
onChange(updatedProviders)
|
||||
setEditingModel(null)
|
||||
setIsCreateDialogOpen(false)
|
||||
}
|
||||
|
||||
const deleteModel = (providerId: string, modelId: string) => {
|
||||
const updatedProviders = { ...providers }
|
||||
const provider = updatedProviders[providerId]
|
||||
if (provider?.models?.[modelId]) {
|
||||
const updatedModels = { ...provider.models }
|
||||
delete updatedModels[modelId]
|
||||
updatedProviders[providerId] = {
|
||||
...provider,
|
||||
models: updatedModels,
|
||||
}
|
||||
onChange(updatedProviders)
|
||||
}
|
||||
}
|
||||
|
||||
const startEdit = (providerId: string, modelId: string, model: ConfigModel) => {
|
||||
setEditingModel({ providerId, modelId, model })
|
||||
}
|
||||
|
||||
const openCreateDialog = (providerId?: string) => {
|
||||
setSelectedProviderId(providerId || Object.keys(providers)[0] || '')
|
||||
setIsCreateDialogOpen(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-lg font-semibold">Models</h3>
|
||||
<Dialog open={isCreateDialogOpen} onOpenChange={setIsCreateDialogOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button className="mr-1 h-6" onClick={() => openCreateDialog()}>
|
||||
<Plus className="h-4 w-4" />
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<OpenCodeModelDialog
|
||||
open={isCreateDialogOpen}
|
||||
onOpenChange={setIsCreateDialogOpen}
|
||||
onSubmit={handleModelSubmit}
|
||||
availableProviders={Object.keys(providers)}
|
||||
existingProviders={providers}
|
||||
selectedProviderId={selectedProviderId}
|
||||
/>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
{totalModelCount === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="p-2 sm:p-8 text-center">
|
||||
<p className="text-muted-foreground">
|
||||
No models configured. Add your first model to get started.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<div className="grid gap-4">
|
||||
{providerEntries.map(({ providerId, providerName, models }) => {
|
||||
const modelEntries = Object.entries(models)
|
||||
if (modelEntries.length === 0) return null
|
||||
|
||||
return (
|
||||
<Card key={providerId}>
|
||||
<CardHeader className="pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="text-base flex items-center gap-2">
|
||||
<Box className="h-4 w-4" />
|
||||
{providerName}
|
||||
<span className="text-xs text-muted-foreground font-normal">
|
||||
({modelEntries.length} model{modelEntries.length !== 1 ? 's' : ''})
|
||||
</span>
|
||||
</CardTitle>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="p-2 space-y-3">
|
||||
{modelEntries.map(([modelId, model]) => (
|
||||
<div
|
||||
key={modelId}
|
||||
className="flex items-center justify-between p-2 bg-muted/50 rounded-lg"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="font-medium text-sm truncate">{model.name || modelId}</p>
|
||||
<p className="text-xs text-muted-foreground font-mono truncate">
|
||||
{modelId}
|
||||
</p>
|
||||
{(model.limit?.context || model.limit?.output) && (
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
Limits:{' '}
|
||||
{model.limit.context && `Context ${model.limit.context}`}
|
||||
{model.limit.context && model.limit.output && ' / '}
|
||||
{model.limit.output && `Output ${model.limit.output}`}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-1 ml-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => startEdit(providerId, modelId, model)}
|
||||
>
|
||||
<Edit className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => deleteModel(providerId, modelId)}
|
||||
className="text-red-500 hover:text-red-600"
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<OpenCodeModelDialog
|
||||
open={!!editingModel}
|
||||
onOpenChange={() => setEditingModel(null)}
|
||||
onSubmit={(providerId: string, modelId: string, model: ConfigModel) => {
|
||||
if (editingModel) {
|
||||
handleModelSubmit(providerId, modelId, model, undefined, editingModel.providerId, editingModel.modelId)
|
||||
}
|
||||
}}
|
||||
availableProviders={Object.keys(providers)}
|
||||
existingProviders={providers}
|
||||
selectedProviderId={editingModel?.providerId || ''}
|
||||
editingModel={editingModel ? { providerId: editingModel.providerId, modelId: editingModel.modelId, model: editingModel.model } : undefined}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "opencode-manager",
|
||||
"version": "0.9.12",
|
||||
"version": "0.9.13",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@10.28.1",
|
||||
|
||||
@@ -181,12 +181,102 @@ export const UpdateSettingsRequestSchema = z.object({
|
||||
preferences: UserPreferencesSchema.partial(),
|
||||
});
|
||||
|
||||
export const ProviderApiConfigSchema = z.object({
|
||||
url: z.string(),
|
||||
npm: z.string().optional(),
|
||||
});
|
||||
|
||||
export type ProviderApiConfig = z.infer<typeof ProviderApiConfigSchema>;
|
||||
|
||||
export const ModelCapabilitiesSchema = z.object({
|
||||
temperature: z.boolean(),
|
||||
reasoning: z.boolean(),
|
||||
attachment: z.boolean(),
|
||||
toolcall: z.boolean(),
|
||||
input: z.object({
|
||||
text: z.boolean(),
|
||||
audio: z.boolean(),
|
||||
image: z.boolean(),
|
||||
video: z.boolean(),
|
||||
pdf: z.boolean(),
|
||||
}),
|
||||
output: z.object({
|
||||
text: z.boolean(),
|
||||
audio: z.boolean(),
|
||||
image: z.boolean(),
|
||||
video: z.boolean(),
|
||||
pdf: z.boolean(),
|
||||
}),
|
||||
interleaved: z.union([
|
||||
z.boolean(),
|
||||
z.object({
|
||||
field: z.enum(["reasoning_content", "reasoning_details"]),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
export const ModelCostSchema = z.object({
|
||||
input: z.number(),
|
||||
output: z.number(),
|
||||
cache: z.object({
|
||||
read: z.number(),
|
||||
write: z.number(),
|
||||
}),
|
||||
experimentalOver200K: z.object({
|
||||
input: z.number(),
|
||||
output: z.number(),
|
||||
cache: z.object({
|
||||
read: z.number(),
|
||||
write: z.number(),
|
||||
}),
|
||||
}).optional(),
|
||||
});
|
||||
|
||||
export const ModelLimitSchema = z.object({
|
||||
context: z.number(),
|
||||
input: z.number().optional(),
|
||||
output: z.number(),
|
||||
});
|
||||
|
||||
export const ModelConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
providerID: z.string(),
|
||||
api: ProviderApiConfigSchema,
|
||||
name: z.string(),
|
||||
family: z.string().optional(),
|
||||
capabilities: ModelCapabilitiesSchema,
|
||||
cost: ModelCostSchema,
|
||||
limit: ModelLimitSchema,
|
||||
status: z.enum(["alpha", "beta", "deprecated", "active"]),
|
||||
options: z.record(z.string(), z.any()).optional(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
release_date: z.string(),
|
||||
variants: z.record(z.string(), z.record(z.string(), z.any())).optional(),
|
||||
});
|
||||
|
||||
export type ModelConfig = z.infer<typeof ModelConfigSchema>;
|
||||
|
||||
export const ProviderSourceSchema = z.enum(["env", "config", "custom", "api"]);
|
||||
|
||||
export const ProviderConfigSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
source: ProviderSourceSchema,
|
||||
env: z.array(z.string()),
|
||||
key: z.string().optional(),
|
||||
options: z.record(z.string(), z.any()).optional(),
|
||||
models: z.record(z.string(), ModelConfigSchema),
|
||||
});
|
||||
|
||||
export type ProviderSource = z.infer<typeof ProviderSourceSchema>;
|
||||
export type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
|
||||
|
||||
export const OpenCodeConfigSchema = z.object({
|
||||
$schema: z.string().optional(),
|
||||
theme: z.string().optional(),
|
||||
model: z.string().optional(),
|
||||
small_model: z.string().optional(),
|
||||
provider: z.record(z.string(), z.any()).optional(),
|
||||
provider: z.record(z.string(), ProviderConfigSchema).optional(),
|
||||
agent: z.record(z.string(), z.any()).optional(),
|
||||
command: z.record(z.string(), z.any()).optional(),
|
||||
keybinds: z.record(z.string(), z.any()).optional(),
|
||||
|
||||
@@ -80,6 +80,12 @@ export interface SuccessResponse {
|
||||
|
||||
export type { SSHHostKeyRequest, SSHHostKeyResponse, TrustedSSHHost } from '../schemas/ssh'
|
||||
export type { GitCredential } from '../schemas/settings'
|
||||
export type {
|
||||
ProviderApiConfig,
|
||||
ModelConfig,
|
||||
ProviderConfig,
|
||||
ProviderSource,
|
||||
} from '../schemas/settings'
|
||||
|
||||
export type {
|
||||
Memory,
|
||||
|
||||
Reference in new issue
Block a user