mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-09 10:54:59 +01:00
add version to user-agent
This commit is contained in:
@@ -136,6 +136,7 @@ export namespace Installation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const VERSION = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "dev"
|
export const VERSION = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "dev"
|
||||||
|
export const USER_AGENT = `opencode/${VERSION}`
|
||||||
|
|
||||||
export async function latest() {
|
export async function latest() {
|
||||||
return fetch("https://api.github.com/repos/sst/opencode/releases/latest")
|
return fetch("https://api.github.com/repos/sst/opencode/releases/latest")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Log } from "../util/log"
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { data } from "./models-macro" with { type: "macro" }
|
import { data } from "./models-macro" with { type: "macro" }
|
||||||
|
import { Installation } from "../installation"
|
||||||
|
|
||||||
export namespace ModelsDev {
|
export namespace ModelsDev {
|
||||||
const log = Log.create({ service: "models.dev" })
|
const log = Log.create({ service: "models.dev" })
|
||||||
@@ -63,7 +64,7 @@ export namespace ModelsDev {
|
|||||||
log.info("refreshing")
|
log.info("refreshing")
|
||||||
const result = await fetch("https://models.dev/api.json", {
|
const result = await fetch("https://models.dev/api.json", {
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent": "opencode",
|
"User-Agent": Installation.USER_AGENT,
|
||||||
},
|
},
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
if (result && result.ok) await Bun.write(file, result)
|
if (result && result.ok) await Bun.write(file, result)
|
||||||
|
|||||||
Reference in New Issue
Block a user