A desktop coding agent with free access to frontier models.
TypeScript
import { describe, expect, test } from "bun:test";
import type { DesktopAppRestrictionChecker } from "../src/app/cloud/desktop-app-restrictions";
import type { ModelOption } from "../src/app/types";
import { filterEntitledModelOptions } from "../src/react-app/domains/connections/provider-auth/provider-policy";
import { afterAll as afterAllUnlocked, beforeAll as beforeAllUnlocked } from "bun:test";
import { setProviderLockState } from "../src/app/lib/provider-lock";
// These cover the app while the server leaves model providers unlocked
// (providers.locked false); tests/provider-lock.test.ts covers the lock.
beforeAllUnlocked(() => setProviderLockState({ locked: false }));
afterAllUnlocked(() => setProviderLockState(null));
function modelOption(providerID: string): ModelOption {
return {
providerID,
modelID: "model",
title: `${providerID} model`,
behaviorTitle: "Reasoning",
behaviorLabel: "Default",
behaviorDescription: "",
behaviorValue: null,
isFree: false,
};
}
function restrictionChecker(blocked: readonly string[]): DesktopAppRestrictionChecker {
return ({ restriction }) => blocked.includes(restriction);
}
describe("filterEntitledModelOptions", () => {
test("keeps every provider when custom providers and Zen are allowed", () => {
const options = [modelOption("openai"), modelOption("lpr_team"), modelOption("opencode")];
expect(
filterEntitledModelOptions(options, {
restrictToCloud: false,
checkRestriction: restrictionChecker([]),
}).map((option) => option.providerID),
).toEqual(["openai", "lpr_team", "opencode"]);
});
test("keeps only org-managed providers plus Zen when custom providers are restricted", () => {
const options = [modelOption("openai"), modelOption("lpr_team"), modelOption("omnirush"), modelOption("opencode")];
expect(
filterEntitledModelOptions(options, {
restrictToCloud: true,
checkRestriction: restrictionChecker(["allowCustomProviders"]),
}).map((option) => option.providerID),
).toEqual(["lpr_team", "omnirush", "opencode"]);
});
test("drops Zen when the Zen desktop policy blocks it", () => {
const options = [modelOption("openai"), modelOption("lpr_team"), modelOption("opencode")];
expect(
filterEntitledModelOptions(options, {
restrictToCloud: true,
checkRestriction: restrictionChecker(["allowCustomProviders", "allowZenModel"]),
}).map((option) => option.providerID),
).toEqual(["lpr_team"]);
});
test("with custom providers allowed, the Zen restriction only drops Zen", () => {
const options = [modelOption("openai"), modelOption("lpr_team"), modelOption("opencode")];
expect(
filterEntitledModelOptions(options, {
restrictToCloud: false,
checkRestriction: restrictionChecker(["allowZenModel"]),
}).map((option) => option.providerID),
).toEqual(["openai", "lpr_team"]);
});
});