Compare commits

...

1 Commits

Author SHA1 Message Date
opencode-agent[bot] 2216fe506a fix(core): isolate models.dev auto refresh
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
2026-07-03 04:44:48 +00:00
4 changed files with 19 additions and 16 deletions
+1 -1
View File
@@ -3172,7 +3172,7 @@
"get-tsconfig": ["get-tsconfig@4.13.7", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-7tN6rFgBlMgpBML5j8typ92BKFi2sFQvIdpAqLA2beia5avZDrMs0FLZiM5etShWq5irVyGcGMEA1jcDaK7A/Q=="],
"ghostty-web": ["ghostty-web@github:anomalyco/ghostty-web#4af877d", {}, "anomalyco-ghostty-web-4af877d", "sha512-fbEK8mtr7ar4ySsF+JUGjhaZrane7dKphanN+SxHt5XXI6yLMAh/Hpf6sNCOyyVa2UlGCd7YpXG/T2v2RUAX+A=="],
"ghostty-web": ["ghostty-web@github:anomalyco/ghostty-web#513463a", {}, "anomalyco-ghostty-web-513463a", "sha512-GZR8LSmgGzViWnBJrqRI8MpAZRCJxhcr1Hi9Tyeh7YRooHZQjK9J97FQRD3tbBaM2wjq05gzGY2UEsG+JtZeBw=="],
"gifwrap": ["gifwrap@0.10.1", "", { "dependencies": { "image-q": "^4.0.0", "omggif": "^1.0.10" } }, "sha512-2760b1vpJHNmLzZ/ubTtNnEx5WApN/PYWJvXvgS+tL1egTTthayFYIQQNi136FLEDcN/IyEY2EcGpIITD6eYUw=="],
@@ -11,6 +11,7 @@ import { Flag } from "@/flag/flag"
import { writeHeapSnapshot } from "node:v8"
import { Heap } from "@/cli/heap"
import { AppRuntime } from "@/effect/app-runtime"
import { ModelsDev } from "@/provider/models"
await Log.init({
print: process.argv.includes("--print-logs"),
@@ -22,6 +23,7 @@ await Log.init({
})
Heap.start()
ModelsDev.startAutoRefresh()
process.on("unhandledRejection", (e) => {
Log.Default.error("rejection", {
+2
View File
@@ -37,6 +37,7 @@ import { errorMessage } from "./util/error"
import { PluginCommand } from "./cli/cmd/plug"
import { Heap } from "./cli/heap"
import { drizzle } from "drizzle-orm/bun-sqlite"
import { ModelsDev } from "./provider/models"
process.on("unhandledRejection", (e) => {
Log.Default.error("rejection", {
@@ -99,6 +100,7 @@ const cli = yargs(args)
})
Heap.start()
ModelsDev.startAutoRefresh()
process.env.AGENT = "1"
process.env.OPENCODE = "1"
+14 -15
View File
@@ -125,7 +125,7 @@ export namespace ModelsDev {
headers: { "User-Agent": Installation.USER_AGENT },
signal: AbortSignal.timeout(10000),
})
return { ok: result.ok, text: await result.text() }
return { ok: result.ok, status: result.status, text: await result.text() }
}
export const Data = lazy(async () => {
@@ -160,23 +160,22 @@ export namespace ModelsDev {
await Flock.withLock(`models-dev:${filepath}`, async () => {
if (skip(force)) return ModelsDev.Data.reset()
const result = await fetchApi()
if (!result.ok) return
if (!result.ok) throw new Error(`Failed to fetch models.dev: ${result.status}`)
await Filesystem.write(filepath, result.text)
ModelsDev.Data.reset()
}).catch((e) => {
log.error("Failed to fetch models.dev", {
error: e,
})
})
}
}
if (!Flag.OPENCODE_DISABLE_MODELS_FETCH && !process.argv.includes("--get-yargs-completions")) {
ModelsDev.refresh()
setInterval(
async () => {
await ModelsDev.refresh()
},
60 * 1000 * 60,
).unref()
export function startAutoRefresh() {
if (Flag.OPENCODE_DISABLE_MODELS_FETCH) return
if (process.argv.includes("--get-yargs-completions")) return
const refresh = () =>
ModelsDev.refresh().catch((e) => {
log.warn("Failed to refresh models.dev catalog", { error: e })
})
refresh()
setInterval(refresh, 60 * 1000 * 60).unref()
}
}