refactor(cli): drop ModelsDev Promise compat shim (#25460)

This commit is contained in:
Kit Langton
2026-05-02 15:11:01 -04:00
committed by GitHub
parent 6cd02c05c2
commit 05b82a6a30
3 changed files with 8 additions and 13 deletions

View File

@@ -212,7 +212,7 @@ export const GithubInstallCommand = cmd({
const app = await getAppInfo()
await installGitHubApp()
const providers = await ModelsDev.get().then((p) => {
const providers = await AppRuntime.runPromise(ModelsDev.Service.use((s) => s.get())).then((p) => {
// TODO: add guide for copilot, for now just hide it
delete p["github-copilot"]
return p

View File

@@ -4,6 +4,9 @@ import { cmd } from "./cmd"
import * as prompts from "@clack/prompts"
import { UI } from "../ui"
import { ModelsDev } from "@/provider/models"
const getModels = () => AppRuntime.runPromise(ModelsDev.Service.use((s) => s.get()))
const refreshModels = () => AppRuntime.runPromise(ModelsDev.Service.use((s) => s.refresh(true)))
import { map, pipe, sortBy, values } from "remeda"
import path from "path"
import os from "os"
@@ -245,7 +248,7 @@ export const ProvidersListCommand = cmd({
return Object.entries(yield* auth.all())
}),
)
const database = await ModelsDev.get()
const database = await getModels()
for (const [providerID, result] of results) {
const name = database[providerID]?.name || providerID
@@ -334,14 +337,14 @@ export const ProvidersLoginCommand = cmd({
prompts.outro("Done")
return
}
await ModelsDev.refresh(true).catch(() => {})
await refreshModels().catch(() => {})
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.get()))
const disabled = new Set(config.disabled_providers ?? [])
const enabled = config.enabled_providers ? new Set(config.enabled_providers) : undefined
const providers = await ModelsDev.get().then((x) => {
const providers = await getModels().then((x) => {
const filtered: Record<string, (typeof x)[string]> = {}
for (const [key, value] of Object.entries(x)) {
if ((enabled ? enabled.has(key) : true) && !disabled.has(key)) {
@@ -505,7 +508,7 @@ export const ProvidersLogoutCommand = cmd({
prompts.log.error("No credentials found")
return
}
const database = await ModelsDev.get()
const database = await getModels()
const selected = await prompts.select({
message: "Select provider",
options: credentials.map(([key, value]) => ({