From a82f4ee86a0a353b071e7b9aadbf71f83a086a45 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 23 Feb 2026 02:42:28 +0900 Subject: [PATCH] fix(hooks/thinking-block-validator): replace as any with typed interfaces Add ThinkingPart and MessageInfoExtended local interfaces Replace 3 as any casts with proper unknown-to-typed casts Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/hooks/thinking-block-validator/hook.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hooks/thinking-block-validator/hook.ts b/src/hooks/thinking-block-validator/hook.ts index a4217b3e8..18a4d3e0b 100644 --- a/src/hooks/thinking-block-validator/hook.ts +++ b/src/hooks/thinking-block-validator/hook.ts @@ -21,6 +21,18 @@ interface MessageWithParts { parts: Part[] } +interface ThinkingPart { + thinking?: string + text?: string +} + +interface MessageInfoExtended { + id: string + role: string + sessionID?: string + modelID?: string +} + type MessagesTransformHook = { "experimental.chat.messages.transform"?: ( input: Record, @@ -91,7 +103,7 @@ function findPreviousThinkingContent( for (const part of msg.parts) { const type = part.type as string if (type === "thinking" || type === "reasoning") { - const thinking = (part as any).thinking || (part as any).text + const thinking = (part as unknown as ThinkingPart).thinking || (part as unknown as ThinkingPart).text if (thinking && typeof thinking === "string" && thinking.trim().length > 0) { return thinking } @@ -114,7 +126,7 @@ function prependThinkingBlock(message: MessageWithParts, thinkingContent: string const thinkingPart = { type: "thinking" as const, id: `prt_0000000000_synthetic_thinking`, - sessionID: (message.info as any).sessionID || "", + sessionID: (message.info as unknown as MessageInfoExtended).sessionID || "", messageID: message.info.id, thinking: thinkingContent, synthetic: true, @@ -138,7 +150,7 @@ export function createThinkingBlockValidatorHook(): MessagesTransformHook { // Get the model info from the last user message const lastUserMessage = messages.findLast(m => m.info.role === "user") - const modelID = (lastUserMessage?.info as any)?.modelID || "" + const modelID = (lastUserMessage?.info as unknown as MessageInfoExtended)?.modelID || "" // Only process if extended thinking might be enabled if (!isExtendedThinkingModel(modelID)) {