fix(electrobun): wizard fixes — native dialog, models, PathBrowser, ensureDir
- Native dialog: resolve to nearest existing parent dir, detect user cancel (exit code 1) vs actual error, add createIfMissing option - Claude models: fallback to KNOWN_CLAUDE_MODELS (6 models) when API key unavailable. Adds Opus 4.6, Sonnet 4.6, Opus 4.5, Sonnet 4, Haiku 4.5, Sonnet 3.7. Live API paginated to limit=100. - PathBrowser: Select button moved to sticky header (always visible). Current path shown compact in header with RTL ellipsis. - files.ensureDir RPC: creates directory recursively before project creation - files.ensureDir added to RPC schema
This commit is contained in:
parent
162b5417e4
commit
a4d180d382
6 changed files with 77 additions and 12 deletions
|
|
@ -13,24 +13,35 @@ export interface ModelInfo {
|
|||
|
||||
const TIMEOUT = 8000;
|
||||
|
||||
// Known Claude models as fallback when API key is not available
|
||||
const KNOWN_CLAUDE_MODELS: ModelInfo[] = [
|
||||
{ id: 'claude-opus-4-6', name: 'Claude Opus 4.6', provider: 'claude' },
|
||||
{ id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6', provider: 'claude' },
|
||||
{ id: 'claude-opus-4-5-20250514', name: 'Claude Opus 4.5', provider: 'claude' },
|
||||
{ id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4', provider: 'claude' },
|
||||
{ id: 'claude-haiku-4-5-20251001', name: 'Claude Haiku 4.5', provider: 'claude' },
|
||||
{ id: 'claude-sonnet-3-7-20250219', name: 'Claude Sonnet 3.7', provider: 'claude' },
|
||||
];
|
||||
|
||||
export async function fetchClaudeModels(): Promise<ModelInfo[]> {
|
||||
const apiKey = process.env.ANTHROPIC_API_KEY;
|
||||
if (!apiKey) return [];
|
||||
if (!apiKey) return KNOWN_CLAUDE_MODELS;
|
||||
try {
|
||||
const res = await fetch('https://api.anthropic.com/v1/models', {
|
||||
const res = await fetch('https://api.anthropic.com/v1/models?limit=100', {
|
||||
headers: {
|
||||
'x-api-key': apiKey,
|
||||
'anthropic-version': '2023-06-01',
|
||||
},
|
||||
signal: AbortSignal.timeout(TIMEOUT),
|
||||
});
|
||||
if (!res.ok) return [];
|
||||
if (!res.ok) return KNOWN_CLAUDE_MODELS;
|
||||
const data = await res.json() as { data?: Array<{ id: string; display_name?: string }> };
|
||||
return (data.data ?? [])
|
||||
const live = (data.data ?? [])
|
||||
.map(m => ({ id: m.id, name: m.display_name ?? m.id, provider: 'claude' }))
|
||||
.sort((a, b) => a.id.localeCompare(b.id));
|
||||
return live.length > 0 ? live : KNOWN_CLAUDE_MODELS;
|
||||
} catch {
|
||||
return [];
|
||||
return KNOWN_CLAUDE_MODELS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue