Files
openclaw/extensions/codex/src/session-catalog-create.test.ts
Jason (Json) c4911a2c77 improve(ui): simplify coding agent session headers (#112354)
* improve: simplify coding session catalog headers

* improve: simplify coding session catalog headers
2026-07-21 15:27:49 -06:00

74 lines
2.3 KiB
TypeScript

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import { resolveCodexCatalogCreateSession } from "./session-catalog-create.js";
function configWithAllowedModels(models: string[], runtime?: string): OpenClawConfig {
return {
agents: {
defaults: {
model: { primary: models[0] },
models: Object.fromEntries(
models.map((model) => [model, runtime ? { agentRuntime: { id: runtime } } : {}]),
),
},
},
};
}
describe("resolveCodexCatalogCreateSession", () => {
it("advertises the canonical implicit Codex default", () => {
expect(resolveCodexCatalogCreateSession({}, "main")).toEqual({
model: "openai/gpt-5.6-sol",
agentRuntime: "codex",
});
});
it("pins the Codex model even when ordinary chats use the direct runtime", () => {
expect(
resolveCodexCatalogCreateSession(
configWithAllowedModels(["openai/gpt-5.6-sol"], "openclaw"),
"main",
),
).toEqual({
model: "openai/gpt-5.6-sol",
agentRuntime: "codex",
});
});
it("does not advertise creation when the Codex model is outside the allowlist", () => {
expect(
resolveCodexCatalogCreateSession(configWithAllowedModels(["openai/gpt-5.6-terra"]), "main"),
).toBeUndefined();
});
it("uses the requested agent's model allowlist", () => {
const config = {
agents: {
defaults: {
model: { primary: "openai/gpt-5.6-sol" },
models: { "openai/gpt-5.6-sol": {} },
},
list: [
{ id: "main", default: true },
{
id: "research",
model: { primary: "openai/gpt-5.6-terra" },
models: { "openai/gpt-5.6-terra": {} },
modelPolicy: { allow: ["openai/gpt-5.6-terra"] },
},
],
},
} satisfies OpenClawConfig;
expect(resolveCodexCatalogCreateSession(config, "main")).toEqual({
model: "openai/gpt-5.6-sol",
agentRuntime: "codex",
});
expect(resolveCodexCatalogCreateSession(config, "research")).toBeUndefined();
});
it("does not advertise creation before runtime config is available", () => {
expect(resolveCodexCatalogCreateSession(undefined, "main")).toBeUndefined();
});
});