fix: include free OpenCode models without -free suffix in suggested models (#1535)

The "opencode-free" suggested-models filter only kept models whose id ends
in "-free", so free-but-unsuffixed models like `big-pickle` (routed via
open-sse/executors/opencode.js MESSAGES_MODELS) never appeared in the
import UI.

Extract the filters into a testable module and include a
KNOWN_FREE_OPENCODE_MODELS allowlist (big-pickle) alongside the "-free"
suffix check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Delcado19
2026-05-29 17:07:32 +07:00
committed by decolua
parent 4baaa5c7aa
commit 9ee8b32887
2 changed files with 21 additions and 18 deletions

View File

@@ -0,0 +1,20 @@
// Free OpenCode models that don't use the "-free" id suffix
const KNOWN_FREE_OPENCODE_MODELS = ["big-pickle"];
export const FILTERS = {
"openrouter-free": (models) =>
models
.filter(
(m) =>
m.pricing?.prompt === "0" &&
m.pricing?.completion === "0" &&
m.context_length >= 200000
)
.map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length }))
.sort((a, b) => b.contextLength - a.contextLength),
"opencode-free": (models) =>
models
.filter((m) => m.id?.endsWith("-free") || KNOWN_FREE_OPENCODE_MODELS.includes(m.id))
.map((m) => ({ id: m.id, name: m.id })),
};

View File

@@ -1,25 +1,8 @@
import { NextResponse } from "next/server";
import { FILTERS } from "./filters.js";
export const dynamic = "force-dynamic";
const FILTERS = {
"openrouter-free": (models) =>
models
.filter(
(m) =>
m.pricing?.prompt === "0" &&
m.pricing?.completion === "0" &&
m.context_length >= 200000
)
.map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length }))
.sort((a, b) => b.contextLength - a.contextLength),
"opencode-free": (models) =>
models
.filter((m) => m.id?.endsWith("-free"))
.map((m) => ({ id: m.id, name: m.id })),
};
export async function GET(request) {
const { searchParams } = new URL(request.url);
const url = searchParams.get("url");