core: expose v2 model listing API (#25821)

This commit is contained in:
Dax
2026-05-13 10:43:08 -04:00
committed by GitHub
parent bebe5442a5
commit 8345152319
138 changed files with 8191 additions and 305 deletions
@@ -16,6 +16,7 @@ import { SkillCommand } from "./skill"
import { SnapshotCommand } from "./snapshot"
import { AgentCommand } from "./agent"
import { StartupCommand } from "./startup"
import { V2Command } from "./v2"
export const DebugCommand = cmd({
command: "debug",
@@ -31,6 +32,7 @@ export const DebugCommand = cmd({
.command(SnapshotCommand)
.command(StartupCommand)
.command(AgentCommand)
.command(V2Command)
.command(InfoCommand)
.command(PathsCommand)
.command(WaitCommand)
+40
View File
@@ -0,0 +1,40 @@
import { EOL } from "os"
import { Effect, Layer, Option } from "effect"
import { Catalog } from "@opencode-ai/core/catalog"
import { effectCmd } from "../../effect-cmd"
import { PluginBoot } from "@/v2/plugin-boot"
const layer = Catalog.defaultLayer.pipe(Layer.provide(PluginBoot.defaultLayer))
export const V2Command = effectCmd({
command: "v2",
describe: "debug v2 catalog and built-in plugins",
instance: false,
handler: Effect.fn("Cli.debug.v2")(function* () {
const result = yield* Effect.gen(function* () {
const catalog = yield* Catalog.Service
const providers = (yield* catalog.provider.available()).sort((a, b) => a.id.localeCompare(b.id))
const all = (yield* catalog.provider.all()).sort((a, b) => a.id.localeCompare(b.id))
return {
providers,
default: catalog.model
.default()
.pipe(Effect.map(Option.map((item) => item.id)), Effect.map(Option.getOrUndefined)),
small: Object.fromEntries(
yield* Effect.all(
all.map((provider) =>
Effect.map(
catalog.model.small(provider.id),
(model) => [provider.id, Option.getOrUndefined(Option.map(model, (item) => item.id))] as const,
),
),
{ concurrency: "unbounded" },
),
),
}
}).pipe(Effect.provide(layer), Effect.orDie)
process.stdout.write(JSON.stringify(result, null, 2) + EOL)
}),
})