feat: Make the models.dev domain configurable for offline environments (#9258)

This commit is contained in:
Bart Broere
2026-01-21 18:23:07 +01:00
committed by GitHub
parent 95b17bcf5e
commit 8df09abb1b
5 changed files with 18 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import path from "path"
import fs from "fs/promises"
import fsSync from "fs"
import { afterAll } from "bun:test"
const { Global } = await import("../src/global")
const dir = path.join(os.tmpdir(), "opencode-test-data-" + process.pid)
await fs.mkdir(dir, { recursive: true })
@@ -27,7 +28,8 @@ process.env["XDG_STATE_HOME"] = path.join(dir, "state")
const cacheDir = path.join(dir, "cache", "opencode")
await fs.mkdir(cacheDir, { recursive: true })
await fs.writeFile(path.join(cacheDir, "version"), "14")
const response = await fetch("https://models.dev/api.json")
const url = Global.Path.modelsDevUrl
const response = await fetch(`${url}/api.json`)
if (response.ok) {
await fs.writeFile(path.join(cacheDir, "models.json"), await response.text())
}