refactor: isolate legacy flags
This commit is contained in:
parent
407ac2d8aa
commit
43c08387f1
65 changed files with 282 additions and 147 deletions
|
|
@ -4,7 +4,6 @@ import { HttpClient, HttpClientRequest } from "effect/unstable/http"
|
|||
import { ModelsDev } from "@opencode-ai/schema/models-dev"
|
||||
import { Money } from "@opencode-ai/schema/money"
|
||||
import { Global } from "./global"
|
||||
import { Flag } from "./flag/flag"
|
||||
import { Flock } from "./util/flock"
|
||||
import { Hash } from "./util/hash"
|
||||
import { FSUtil } from "./fs-util"
|
||||
|
|
@ -18,8 +17,6 @@ import { ProviderV2 } from "./provider"
|
|||
export const CatalogModelStatus = Schema.Literals(["alpha", "beta", "deprecated"])
|
||||
export type CatalogModelStatus = typeof CatalogModelStatus.Type
|
||||
|
||||
const USER_AGENT = `opencode/${InstallationChannel}/${InstallationVersion}/${Flag.OPENCODE_CLIENT}`
|
||||
|
||||
type Cost = {
|
||||
readonly input: Money.USDPerMillionTokens
|
||||
readonly output: Money.USDPerMillionTokens
|
||||
|
|
@ -534,6 +531,7 @@ export const Options = Schema.Struct({
|
|||
url: Schema.optional(Schema.String),
|
||||
file: Schema.optional(Schema.String),
|
||||
fetch: Schema.optional(Schema.Boolean),
|
||||
client: Schema.optional(Schema.String),
|
||||
})
|
||||
export type Options = typeof Options.Type
|
||||
|
||||
|
|
@ -556,6 +554,7 @@ export const layer = (options?: Options) => Layer.effect(
|
|||
|
||||
const source = options?.url ?? "https://models.dev"
|
||||
const fetch = options?.fetch ?? true
|
||||
const userAgent = `opencode/${InstallationChannel}/${InstallationVersion}/${options?.client ?? "cli"}`
|
||||
const filepath = path.join(
|
||||
Global.Path.cache,
|
||||
source === "https://models.dev" ? "models.json" : `models-${Hash.fast(source)}.json`,
|
||||
|
|
@ -572,7 +571,7 @@ export const layer = (options?: Options) => Layer.effect(
|
|||
|
||||
const fetchApi = Effect.fn("ModelsDev.fetchApi")(function* () {
|
||||
return yield* HttpClientRequest.get(`${source}/api.json`).pipe(
|
||||
HttpClientRequest.setHeader("User-Agent", USER_AGENT),
|
||||
HttpClientRequest.setHeader("User-Agent", userAgent),
|
||||
http.execute,
|
||||
Effect.flatMap((res) => res.text),
|
||||
Effect.timeout("10 seconds"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue