mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-12 17:03:31 +00:00
force models.dev refresh on auth login
This commit is contained in:
parent
e1b7e25f4d
commit
71cd84dbbb
5 changed files with 16 additions and 33 deletions
|
|
@ -100,6 +100,7 @@ export const AuthLoginCommand = cmd({
|
|||
prompts.outro("Done")
|
||||
return
|
||||
}
|
||||
await ModelsDev.refresh().catch(() => {})
|
||||
const providers = await ModelsDev.get()
|
||||
const priority: Record<string, number> = {
|
||||
anthropic: 0,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ await Promise.all([
|
|||
fs.mkdir(Global.Path.log, { recursive: true }),
|
||||
])
|
||||
|
||||
const CACHE_VERSION = "3"
|
||||
const CACHE_VERSION = "4"
|
||||
|
||||
const version = await Bun.file(path.join(Global.Path.cache, "version"))
|
||||
.text()
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ export namespace LSP {
|
|||
}
|
||||
return {
|
||||
broken: new Set<string>(),
|
||||
servers,
|
||||
clients,
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -61,13 +61,19 @@ export namespace ModelsDev {
|
|||
|
||||
export async function refresh() {
|
||||
const file = Bun.file(filepath)
|
||||
log.info("refreshing")
|
||||
log.info("refreshing", {
|
||||
file,
|
||||
})
|
||||
const result = await fetch("https://models.dev/api.json", {
|
||||
headers: {
|
||||
"User-Agent": Installation.USER_AGENT,
|
||||
},
|
||||
}).catch(() => {})
|
||||
if (result && result.ok) await Bun.write(file, result)
|
||||
}).catch((e) => {
|
||||
log.error("Failed to fetch models.dev", {
|
||||
error: e,
|
||||
})
|
||||
})
|
||||
if (result && result.ok) await Bun.write(file, await result.text())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue