diff --git a/src/agents/model-compat.ts b/src/agents/model-compat.ts index 70bc56aad..f00df2f0d 100644 --- a/src/agents/model-compat.ts +++ b/src/agents/model-compat.ts @@ -1,9 +1,13 @@ import type { Api, Model } from "@mariozechner/pi-ai"; +function isOpenAiCompletionsModel(model: Model): model is Model<"openai-completions"> { + return model.api === "openai-completions"; +} + export function normalizeModelCompat(model: Model): Model { const baseUrl = model.baseUrl ?? ""; const isZai = model.provider === "zai" || baseUrl.includes("api.z.ai"); - if (!isZai || model.api !== "openai-completions") return model; + if (!isZai || !isOpenAiCompletionsModel(model)) return model; const compat = model.compat ?? {}; if (compat.supportsDeveloperRole === false) return model; diff --git a/src/tui/components/custom-editor.ts b/src/tui/components/custom-editor.ts index b66452e61..80feb4145 100644 --- a/src/tui/components/custom-editor.ts +++ b/src/tui/components/custom-editor.ts @@ -1,4 +1,4 @@ -import { Editor, type EditorTheme, Key, matchesKey } from "@mariozechner/pi-tui"; +import { Editor, type EditorTheme, Key, matchesKey, type TUI } from "@mariozechner/pi-tui"; export class CustomEditor extends Editor { onEscape?: () => void; @@ -12,8 +12,8 @@ export class CustomEditor extends Editor { onShiftTab?: () => void; onAltEnter?: () => void; - constructor(theme: EditorTheme) { - super(theme); + constructor(tui: TUI, theme: EditorTheme) { + super(tui, theme); } handleInput(data: string): void { if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) { diff --git a/src/tui/tui.ts b/src/tui/tui.ts index 753f5511f..a5e6e34d7 100644 --- a/src/tui/tui.ts +++ b/src/tui/tui.ts @@ -193,7 +193,7 @@ export async function runTui(opts: TuiOptions) { const statusContainer = new Container(); const footer = new Text("", 1, 0); const chatLog = new ChatLog(); - const editor = new CustomEditor(editorTheme); + const editor = new CustomEditor(tui, editorTheme); const root = new Container(); root.addChild(header); root.addChild(chatLog);