refactor: create normalizeSDKResponse helper and replace scattered patterns across 37 files

This commit is contained in:
YeonGyu-Kim
2026-02-16 18:20:19 +09:00
parent 90555f3d5e
commit 0b10245c34
41 changed files with 250 additions and 77 deletions
@@ -5,6 +5,7 @@ import { isSqliteBackend } from "../../shared/opencode-storage-detection"
import { stripThinkingPartsAsync } from "./storage/thinking-strip"
import { THINKING_TYPES } from "./constants"
import { log } from "../../shared/logger"
import { normalizeSDKResponse } from "../../shared"
type Client = ReturnType<typeof createOpencodeClient>
@@ -38,7 +39,7 @@ async function recoverThinkingDisabledViolationFromSDK(
): Promise<boolean> {
try {
const response = await client.session.messages({ path: { id: sessionID } })
const messages = ((response.data ?? response) as unknown as MessageData[]) ?? []
const messages = normalizeSDKResponse(response, [] as MessageData[], { preferResponseOnMissingData: true })
const messageIDsWithThinking: string[] = []
for (const msg of messages) {