fix(ts-sdk): unwrap v1.1 search response in client, fix TS2339 type errors

search() now unwraps { results: [...] } -> [...] internally (same
pattern getAll() already uses), so callers always get Array<Memory>.

Removes redundant unwrap logic from integration test helpers and
search.test.ts that caused TS2339 'Property results does not exist
on type never' — the false branch of Array.isArray() was unreachable
since search() is typed as returning Array<Memory>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chaithanyak42
2026-04-14 01:48:22 +05:30
co-authored by Claude Opus 4.6
parent 7f19c499ca
commit e51df348ce
3 changed files with 5 additions and 16 deletions
@@ -92,11 +92,7 @@ export async function waitForSearchResults(
maxRetries = 4,
): Promise<Memory[]> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
const response = await withRetry(() => client.search(query, options));
// v3 returns { results: [...] }, unwrap for backward compat
const results = Array.isArray(response)
? response
: (response?.results ?? []);
const results = await withRetry(() => client.search(query, options));
if (results.length > 0) {
return results;
}