fix agent list

This commit is contained in:
Levi Neely 2026-05-19 12:45:20 +02:00
parent 700d0dae46
commit c377280fca
2 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import { useState, useEffect } from 'preact/hooks' import { useState, useEffect } from 'preact/hooks'
import { getBackends } from '../lib/api' import { getBackends, getAgents } from '../lib/api'
interface CreateParams { interface CreateParams {
cwd: string cwd: string
@ -13,8 +13,6 @@ interface Props {
onCreate: (p: CreateParams) => Promise<void> onCreate: (p: CreateParams) => Promise<void>
} }
const AGENTS = ['default', 'coding', 'devops', 'greybeard', 'qa', 'reviewer', 'writer']
const DEFAULT_MODELS: Record<string, string> = { const DEFAULT_MODELS: Record<string, string> = {
anthropic: 'claude-opus-4-5', anthropic: 'claude-opus-4-5',
openai: 'gpt-4o', openai: 'gpt-4o',
@ -29,6 +27,7 @@ export function NewSession({ onClose, onCreate }: Props) {
const [model, setModel] = useState(DEFAULT_MODELS['anthropic']) const [model, setModel] = useState(DEFAULT_MODELS['anthropic'])
const [agent, setAgent] = useState('default') const [agent, setAgent] = useState('default')
const [backends, setBackends] = useState<string[]>([]) const [backends, setBackends] = useState<string[]>([])
const [agents, setAgents] = useState<string[]>(['default'])
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
useEffect(() => { useEffect(() => {
@ -39,6 +38,9 @@ export function NewSession({ onClose, onCreate }: Props) {
setModel(DEFAULT_MODELS[bs[0]] ?? '') setModel(DEFAULT_MODELS[bs[0]] ?? '')
} }
}).catch(() => {}) }).catch(() => {})
getAgents().then(as => {
if (as.length > 0) setAgents(as)
}).catch(() => {})
}, []) }, [])
const handleBackend = (b: string) => { const handleBackend = (b: string) => {
@ -100,7 +102,7 @@ export function NewSession({ onClose, onCreate }: Props) {
value={agent} value={agent}
onChange={e => setAgent((e.target as HTMLSelectElement).value)} onChange={e => setAgent((e.target as HTMLSelectElement).value)}
> >
{AGENTS.map(a => <option key={a} value={a}>{a}</option>)} {agents.map(a => <option key={a} value={a}>{a}</option>)}
</select> </select>
</div> </div>
</div> </div>

View File

@ -67,6 +67,16 @@ export async function getBackends(): Promise<string[]> {
return Array.isArray(data) ? (data as string[]) : [] return Array.isArray(data) ? (data as string[]) : []
} }
export async function getAgents(): Promise<string[]> {
const r = await fetch('/a/')
if (!r.ok) return []
const data = await r.json()
if (!Array.isArray(data)) return []
return data
.filter((e: any) => e.name?.endsWith('.json'))
.map((e: any) => e.name.replace(/\.json$/, ''))
}
export async function killSession(id: string): Promise<void> { export async function killSession(id: string): Promise<void> {
await fetch(`/s/${id}`, { method: 'DELETE' }) await fetch(`/s/${id}`, { method: 'DELETE' })
} }