diff --git a/src/agents/model-compat.ts b/src/agents/model-compat.ts index f00df2f0d..228ba3bfd 100644 --- a/src/agents/model-compat.ts +++ b/src/agents/model-compat.ts @@ -9,9 +9,11 @@ export function normalizeModelCompat(model: Model): Model { const isZai = model.provider === "zai" || baseUrl.includes("api.z.ai"); if (!isZai || !isOpenAiCompletionsModel(model)) return model; - const compat = model.compat ?? {}; - if (compat.supportsDeveloperRole === false) return model; + const compat = model.compat as { supportsDeveloperRole?: boolean } | undefined; + if (compat?.supportsDeveloperRole === false) return model; - model.compat = { ...compat, supportsDeveloperRole: false }; + model.compat = compat + ? { ...compat, supportsDeveloperRole: false } + : { supportsDeveloperRole: false }; return model; } diff --git a/src/tui/components/custom-editor.ts b/src/tui/components/custom-editor.ts index 80feb4145..e1a4a8d1c 100644 --- a/src/tui/components/custom-editor.ts +++ b/src/tui/components/custom-editor.ts @@ -12,8 +12,12 @@ export class CustomEditor extends Editor { onShiftTab?: () => void; onAltEnter?: () => void; - constructor(tui: TUI, theme: EditorTheme) { - super(tui, theme); + constructor(tuiOrTheme: TUI | EditorTheme, themeMaybe?: EditorTheme) { + const useTui = typeof themeMaybe !== "undefined" && Editor.length >= 2; + const args = (useTui ? [tuiOrTheme, themeMaybe] : [tuiOrTheme]) as ConstructorParameters< + typeof Editor + >; + super(...args); } handleInput(data: string): void { if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {