/** * The shared pipeline behind every list tool. * * This exists because the four list handlers used to each carry their own copy * of: fetch, empty-check, truncate, build pagination, pick a format. Two bugs * lived in those copies — an empty page returned `ok(text)` with no structured * payload, which the SDK rejects when an outputSchema is declared, and the * pagination block was computed from the untruncated page, so `next_offset` * skipped every record truncation had dropped. Both were fixed in every copy. * There is now one copy. * * It is split in three because code mode needs the first part without the rest: * * fetchList issue the GET, normalise the envelope. Nothing else. * executeListFromPlan + empty-check, truncate, paginate, render. * executeList + build the page-size parameter from the dialect. * * The split is the whole reason a code-API read is not just a handler call. * `executeListFromPlan` truncates to CHARACTER_LIMIT and then slices the * structured payload to whatever survived, because its reader is a model with a * context window. A script's reader is a `for` loop, and handing it 20 of 2,000 * alerts because 2,000 would not render as markdown would defeat the point of * filtering in code. So code mode stops at `fetchList`. */ import { type JsmClient } from "../services/client.js"; import { type ToolResult } from "../services/format.js"; import type { ResponseFormat } from "../schemas/common.js"; import type { Paged } from "../types.js"; import type { RequestPlan } from "./define.js"; import { type PagingDialect } from "./paging.js"; /** * Issues the GET a collection plan describes and normalises the envelope. * * The one place a collection read reaches the network, so the `data`/`values`/ * bare-array/`platformTeams` handling in getCollection has exactly one caller * in this file and code mode cannot grow a second interpretation of an envelope. */ export declare function fetchList(plan: RequestPlan, client: JsmClient, signal?: AbortSignal | undefined): Promise>; /** The render half: everything a model-facing list result needs beyond the fetch. */ export interface ListRenderOptions { client: JsmClient; /** Key the items sit under in structuredContent, e.g. "alerts". */ key: string; /** Context for error messages, e.g. "list alerts". */ context: string; /** Page size the caller asked for, reported in the pagination block. */ limit: number; /** Numeric offset, for offset-paged endpoints. Omit for cursor-paged ones. */ offset?: number | undefined; render: (items: T[]) => string; /** Shown when the API returns nothing. Say what to try next, not just "none". */ emptyMessage: string; /** Appended to a truncated response, telling the model how to get the rest. */ hint: string; format: ResponseFormat; } export interface ListToolOptions extends ListRenderOptions { /** Path below the cloud-id root, e.g. "/v1/alerts". */ path: string; /** * Query parameters *other than* the page size. Do not pass a page size here: * executeList sends it, under the name the API actually reads. */ params?: Record | undefined; /** * How this endpoint pages. Defaults to `size` + `offset`, the common case. * State it for anything else — see ./paging.ts. */ paging?: PagingDialect | undefined; /** * Envelope key the items sit under, for the endpoints that use neither * `data` nor `values` — `GET /v1/teams` answers under `platformTeams`. */ itemsKey?: string | undefined; } /** * Runs a collection plan and renders it for a model. * * `plan.params` is sent verbatim, page size included: a plan is the whole * request. Re-deriving the page size here would mean two places decide it, and * the bug that cost this repo months — every list sending `limit` to endpoints * that read `size`, so callers asking for 100 records were told 20 was all of * them — was exactly one place deciding it wrongly. */ export declare function executeListFromPlan(plan: RequestPlan, options: ListRenderOptions): Promise; /** * The long-standing entry point: takes query parameters without the page size * and builds it from the dialect. * * Kept so the twenty-odd hand-written call sites did not all have to change * shape in the same commit that introduced plans. New code paths should build a * `RequestPlan` and call `executeListFromPlan`, which is what the family * factory does. */ export declare function executeList(options: ListToolOptions): Promise; //# sourceMappingURL=list-executor.d.ts.map