fix(provider): restore model suggestions (#27372)
This commit is contained in:
parent
22a5e6cc50
commit
20cec91550
2 changed files with 73 additions and 7 deletions
|
|
@ -19,6 +19,7 @@ import { testEffect } from "../lib/effect"
|
|||
|
||||
const env = makeRuntime(Env.Service, Env.defaultLayer)
|
||||
const set = (k: string, v: string) => env.runSync((svc) => svc.set(k, v))
|
||||
const remove = (k: string) => env.runSync((svc) => svc.remove(k))
|
||||
|
||||
async function run<A, E>(fn: (provider: Provider.Interface) => Effect.Effect<A, E, never>) {
|
||||
return AppRuntime.runPromise(
|
||||
|
|
@ -1604,6 +1605,32 @@ test("ModelNotFoundError for provider includes suggestions", async () => {
|
|||
})
|
||||
})
|
||||
|
||||
test("ModelNotFoundError suggests catalog models for unloaded providers", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
await Bun.write(
|
||||
path.join(dir, "opencode.json"),
|
||||
JSON.stringify({
|
||||
$schema: "https://opencode.ai/config.json",
|
||||
}),
|
||||
)
|
||||
},
|
||||
})
|
||||
await WithInstance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
remove("OPENCODE_API_KEY")
|
||||
try {
|
||||
await getModel(ProviderID.opencode, ModelID.make("claude-haiku-fake-model"))
|
||||
throw new Error("expected model lookup to fail")
|
||||
} catch (e) {
|
||||
if (!Provider.ModelNotFoundError.isInstance(e)) throw e
|
||||
expect(e.data.suggestions).toContain("claude-haiku-4-5")
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("getProvider returns undefined for nonexistent provider", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue