// Openai plugin module implements thinking policy behavior. import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry"; const OPENAI_THINKING_BASE_LEVELS = [ { id: "off" }, { id: "minimal" }, { id: "low" }, { id: "medium" }, { id: "high" }, ] as const satisfies ProviderThinkingProfile["levels"]; const OPENAI_CODEX_XHIGH_MODEL_IDS = [ "gpt-5.6", "gpt-5.5", "gpt-5.5-pro", "gpt-5.4", "gpt-5.4-pro", "gpt-5.3-codex-spark", ] as const; const OPENAI_UNIFIED_XHIGH_MODEL_IDS = [ ...OPENAI_CODEX_XHIGH_MODEL_IDS, "gpt-5.4-mini", "gpt-5.4-nano", ] as const; function normalizeModelId(value: string): string { return value.trim().toLowerCase(); } function matchesExactOrPrefix(id: string, values: readonly string[]): boolean { const normalizedId = normalizeModelId(id); return values.some((value) => { const normalizedValue = normalizeModelId(value); return normalizedId === normalizedValue || normalizedId.startsWith(normalizedValue); }); } function buildOpenAIThinkingProfile(params: { modelId: string; xhighModelIds: readonly string[]; }): ProviderThinkingProfile { const supportsMax = normalizeModelId(params.modelId).startsWith("gpt-5.6"); return { levels: [ ...OPENAI_THINKING_BASE_LEVELS, ...(matchesExactOrPrefix(params.modelId, params.xhighModelIds) ? [{ id: "xhigh" as const }] : []), ...(supportsMax ? [{ id: "max" as const }] : []), ], }; } export function resolveOpenAICodexThinkingProfile(modelId: string): ProviderThinkingProfile { return buildOpenAIThinkingProfile({ modelId, xhighModelIds: OPENAI_CODEX_XHIGH_MODEL_IDS }); } export function resolveUnifiedOpenAIThinkingProfile(modelId: string): ProviderThinkingProfile { return buildOpenAIThinkingProfile({ modelId, xhighModelIds: OPENAI_UNIFIED_XHIGH_MODEL_IDS }); }