Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4db64afccc |
No files matched your search
@@ -32,6 +32,7 @@ import {
|
|||||||
spawnAndCollect,
|
spawnAndCollect,
|
||||||
type CommandResult,
|
type CommandResult,
|
||||||
} from "../providerSnapshot";
|
} from "../providerSnapshot";
|
||||||
|
import { DEFAULT_CODEX_MODEL_CAPABILITIES } from "@t3tools/shared/model";
|
||||||
import { makeManagedServerProvider } from "../makeManagedServerProvider";
|
import { makeManagedServerProvider } from "../makeManagedServerProvider";
|
||||||
import {
|
import {
|
||||||
formatCodexCliUpgradeMessage,
|
formatCodexCliUpgradeMessage,
|
||||||
@@ -159,13 +160,8 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
|
|||||||
export function getCodexModelCapabilities(model: string | null | undefined): ModelCapabilities {
|
export function getCodexModelCapabilities(model: string | null | undefined): ModelCapabilities {
|
||||||
const slug = model?.trim();
|
const slug = model?.trim();
|
||||||
return (
|
return (
|
||||||
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ?? {
|
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ??
|
||||||
reasoningEffortLevels: [],
|
DEFAULT_CODEX_MODEL_CAPABILITIES
|
||||||
supportsFastMode: false,
|
|
||||||
supportsThinkingToggle: false,
|
|
||||||
contextWindowOptions: [],
|
|
||||||
promptInjectedEffortLevels: [],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,7 +335,12 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
|
|||||||
Effect.map((settings) => settings.providers.codex),
|
Effect.map((settings) => settings.providers.codex),
|
||||||
);
|
);
|
||||||
const checkedAt = new Date().toISOString();
|
const checkedAt = new Date().toISOString();
|
||||||
const models = providerModelsFromSettings(BUILT_IN_MODELS, PROVIDER, codexSettings.customModels);
|
const models = providerModelsFromSettings(
|
||||||
|
BUILT_IN_MODELS,
|
||||||
|
PROVIDER,
|
||||||
|
codexSettings.customModels,
|
||||||
|
DEFAULT_CODEX_MODEL_CAPABILITIES,
|
||||||
|
);
|
||||||
|
|
||||||
if (!codexSettings.enabled) {
|
if (!codexSettings.enabled) {
|
||||||
return buildServerProvider({
|
return buildServerProvider({
|
||||||
|
|||||||
@@ -220,6 +220,41 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest()))(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.effect("adds standard codex capabilities to custom codex models", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
yield* withTempCodexHome();
|
||||||
|
const serverSettingsLayer = ServerSettingsService.layerTest({
|
||||||
|
providers: {
|
||||||
|
codex: {
|
||||||
|
customModels: ["custom-codex-model"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const status = yield* checkCodexProviderStatus().pipe(
|
||||||
|
Effect.provide(serverSettingsLayer),
|
||||||
|
);
|
||||||
|
const customModel = status.models.find((model) => model.slug === "custom-codex-model");
|
||||||
|
|
||||||
|
assert.ok(customModel);
|
||||||
|
assert.strictEqual(customModel.isCustom, true);
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
customModel.capabilities?.reasoningEffortLevels.map((level) => level.value),
|
||||||
|
["xhigh", "high", "medium", "low"],
|
||||||
|
);
|
||||||
|
assert.strictEqual(customModel.capabilities?.supportsFastMode, true);
|
||||||
|
}).pipe(
|
||||||
|
Effect.provide(
|
||||||
|
mockSpawnerLayer((args) => {
|
||||||
|
const joined = args.join(" ");
|
||||||
|
if (joined === "--version") return { stdout: "codex 1.0.0\n", stderr: "", code: 0 };
|
||||||
|
if (joined === "login status") return { stdout: "Logged in\n", stderr: "", code: 0 };
|
||||||
|
throw new Error(`Unexpected args: ${joined}`);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
it.effect("hides spark from codex models for unsupported chatgpt plans", () =>
|
it.effect("hides spark from codex models for unsupported chatgpt plans", () =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
yield* withTempCodexHome();
|
yield* withTempCodexHome();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
|
ModelCapabilities,
|
||||||
ServerProvider,
|
ServerProvider,
|
||||||
ServerProviderAuth,
|
ServerProviderAuth,
|
||||||
ServerProviderModel,
|
ServerProviderModel,
|
||||||
@@ -102,6 +103,7 @@ export function providerModelsFromSettings(
|
|||||||
builtInModels: ReadonlyArray<ServerProviderModel>,
|
builtInModels: ReadonlyArray<ServerProviderModel>,
|
||||||
provider: ServerProvider["provider"],
|
provider: ServerProvider["provider"],
|
||||||
customModels: ReadonlyArray<string>,
|
customModels: ReadonlyArray<string>,
|
||||||
|
defaultCustomCapabilities: ModelCapabilities | null = null,
|
||||||
): ReadonlyArray<ServerProviderModel> {
|
): ReadonlyArray<ServerProviderModel> {
|
||||||
const resolvedBuiltInModels = [...builtInModels];
|
const resolvedBuiltInModels = [...builtInModels];
|
||||||
const seen = new Set(resolvedBuiltInModels.map((model) => model.slug));
|
const seen = new Set(resolvedBuiltInModels.map((model) => model.slug));
|
||||||
@@ -117,7 +119,7 @@ export function providerModelsFromSettings(
|
|||||||
slug: normalized,
|
slug: normalized,
|
||||||
name: normalized,
|
name: normalized,
|
||||||
isCustom: true,
|
isCustom: true,
|
||||||
capabilities: null,
|
capabilities: defaultCustomCapabilities,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -477,6 +477,23 @@ describe("TraitsPicker (Codex)", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("shows default effort options for custom codex models without capabilities", async () => {
|
||||||
|
await using _ = await mountCodexPicker({
|
||||||
|
model: "custom-codex-model",
|
||||||
|
options: { reasoningEffort: "low" },
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByRole("button").click();
|
||||||
|
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
const text = document.body.textContent ?? "";
|
||||||
|
expect(text).toContain("Extra High");
|
||||||
|
expect(text).toContain("High");
|
||||||
|
expect(text).toContain("Medium");
|
||||||
|
expect(text).toContain("Low");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("persists sticky codex model options when traits change", async () => {
|
it("persists sticky codex model options when traits change", async () => {
|
||||||
await using _ = await mountCodexPicker({
|
await using _ = await mountCodexPicker({
|
||||||
options: { fastMode: false },
|
options: { fastMode: false },
|
||||||
|
|||||||
@@ -149,6 +149,36 @@ describe("getComposerProviderState", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses standard codex defaults for custom codex models without capabilities", () => {
|
||||||
|
const state = getComposerProviderState({
|
||||||
|
provider: "codex",
|
||||||
|
model: "custom-codex-model",
|
||||||
|
models: [
|
||||||
|
...CODEX_MODELS,
|
||||||
|
{
|
||||||
|
slug: "custom-codex-model",
|
||||||
|
name: "custom-codex-model",
|
||||||
|
isCustom: true,
|
||||||
|
capabilities: null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
prompt: "",
|
||||||
|
modelOptions: {
|
||||||
|
codex: {
|
||||||
|
reasoningEffort: "low",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(state).toEqual({
|
||||||
|
provider: "codex",
|
||||||
|
promptEffort: "low",
|
||||||
|
modelOptionsForDispatch: {
|
||||||
|
reasoningEffort: "low",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("preserves codex fast mode when it is the only active option", () => {
|
it("preserves codex fast mode when it is the only active option", () => {
|
||||||
const state = getComposerProviderState({
|
const state = getComposerProviderState({
|
||||||
provider: "codex",
|
provider: "codex",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
type ServerProvider,
|
type ServerProvider,
|
||||||
type ServerProviderModel,
|
type ServerProviderModel,
|
||||||
} from "@t3tools/contracts";
|
} from "@t3tools/contracts";
|
||||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
import { DEFAULT_CODEX_MODEL_CAPABILITIES, normalizeModelSlug } from "@t3tools/shared/model";
|
||||||
|
|
||||||
const EMPTY_CAPABILITIES: ModelCapabilities = {
|
const EMPTY_CAPABILITIES: ModelCapabilities = {
|
||||||
reasoningEffortLevels: [],
|
reasoningEffortLevels: [],
|
||||||
@@ -53,7 +53,10 @@ export function getProviderModelCapabilities(
|
|||||||
provider: ProviderKind,
|
provider: ProviderKind,
|
||||||
): ModelCapabilities {
|
): ModelCapabilities {
|
||||||
const slug = normalizeModelSlug(model, provider);
|
const slug = normalizeModelSlug(model, provider);
|
||||||
return models.find((candidate) => candidate.slug === slug)?.capabilities ?? EMPTY_CAPABILITIES;
|
const capabilities = models.find((candidate) => candidate.slug === slug)?.capabilities;
|
||||||
|
return (
|
||||||
|
capabilities ?? (provider === "codex" ? DEFAULT_CODEX_MODEL_CAPABILITIES : EMPTY_CAPABILITIES)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultServerModel(
|
export function getDefaultServerModel(
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ export interface SelectableModelOption {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_CODEX_MODEL_CAPABILITIES: ModelCapabilities = {
|
||||||
|
reasoningEffortLevels: [
|
||||||
|
{ value: "xhigh", label: "Extra High" },
|
||||||
|
{ value: "high", label: "High", isDefault: true },
|
||||||
|
{ value: "medium", label: "Medium" },
|
||||||
|
{ value: "low", label: "Low" },
|
||||||
|
],
|
||||||
|
supportsFastMode: true,
|
||||||
|
supportsThinkingToggle: false,
|
||||||
|
contextWindowOptions: [],
|
||||||
|
promptInjectedEffortLevels: [],
|
||||||
|
};
|
||||||
|
|
||||||
// ── Effort helpers ────────────────────────────────────────────────────
|
// ── Effort helpers ────────────────────────────────────────────────────
|
||||||
|
|
||||||
/** Check whether a capabilities object includes a given effort value. */
|
/** Check whether a capabilities object includes a given effort value. */
|
||||||
|
|||||||
Reference in new issue
Block a user