fix: handle array-shaped SDK responses in getSdkMessages & dedup getMessageDir

- getSdkMessages now handles both response.data and direct array
  responses from SDK
- Consolidated getMessageDir: storage.ts now re-exports from shared
  opencode-message-dir.ts (with path traversal guards)
This commit is contained in:
YeonGyu-Kim
2026-02-16 15:54:29 +09:00
parent 5a6a9e9800
commit 9889ac0dd9
2 changed files with 6 additions and 23 deletions
@@ -47,9 +47,11 @@ function messageHasContentFromSDK(message: SDKMessage): boolean {
function getSdkMessages(response: unknown): SDKMessage[] {
if (typeof response !== "object" || response === null) return []
if (Array.isArray(response)) return response as SDKMessage[]
const record = response as Record<string, unknown>
const data = record["data"]
return Array.isArray(data) ? (data as SDKMessage[]) : []
if (Array.isArray(data)) return data as SDKMessage[]
return Array.isArray(record) ? (record as SDKMessage[]) : []
}
async function findEmptyMessagesFromSDK(client: Client, sessionID: string): Promise<string[]> {