Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/server/src/provider/opencodeRuntime.cliParsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ describe("parseModelsCliOutput", () => {
NodeAssert.equal(Object.keys(result.providers.get("openai")!.models).length, 1);
});

it("parses model IDs with spaces without dropping the preceding model", () => {
const stdout = [
"custom/model-one",
JSON.stringify({
id: "model-one",
providerID: "custom",
name: "Model One",
}),
"custom/Model Two",
JSON.stringify({ id: "Model Two", providerID: "custom", name: "Model Two" }),
].join("\n");

const result = parseModelsCliOutput(stdout);
const provider = result.providers.get("custom")!;

NodeAssert.ok(provider.models["model-one"]);
NodeAssert.ok(provider.models["Model Two"]);
});

it("handles empty input", () => {
const result = parseModelsCliOutput("");
NodeAssert.equal(result.providers.size, 0);
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/provider/opencodeRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function parseServerUrlFromOutput(output: string): string | null {
return null;
}

const SLUG_LINE_RE = /^(\S+\/\S+)\s*$/;
const SLUG_LINE_RE = /^(\S+\/.*\S)\s*$/;
const AGENT_HEADER_RE = /^(.+)\s+\((\S+)\)\s*$/;

// Agents that are always hidden in OpenCode but the CLI "agent list" command
Expand Down
Loading