UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

29 lines • 991 B
const MAX_MCP_PAGES = 1000; export async function collectAllPages(listFn) { const items = []; const warnings = []; const seenCursors = new Set(); let cursor; let pages = 0; while (pages < MAX_MCP_PAGES) { const page = await listFn(cursor); pages += 1; items.push(...getPageItems(page)); const nextCursor = page.nextCursor; if (!nextCursor) { return { items, warnings, pages }; } if (seenCursors.has(nextCursor)) { warnings.push(`Stopped MCP pagination after duplicate cursor '${nextCursor}'.`); return { items, warnings, pages }; } seenCursors.add(nextCursor); cursor = nextCursor; } warnings.push(`Stopped MCP pagination after ${MAX_MCP_PAGES} pages.`); return { items, warnings, pages }; } function getPageItems(page) { return page.items ?? page.tools ?? page.resources ?? page.prompts ?? []; } //# sourceMappingURL=pagination.js.map