/** * Runs one operation, or every page of one, against the JSM API. * * This is where a `RequestPlan` stops being data and becomes a request. It is * the only route the code API has to the network, which is what lets the * budgets, the deadline, the write allowlist and the audit trail all be * enforced in one place rather than per operation. * * What it deliberately does not do is render. A dispatched read returns the * rows, untruncated — see the note in list-executor.ts for why reusing a * handler's output would cap a 2,000-row fetch at whatever fit a markdown page. */ import { type JsmClient } from "../../services/client.js"; import { type CallContext } from "./context.js"; import type { OperationRegistry } from "./registry.js"; /** One page of a collection, as a script sees it. */ export interface PageResult { items: unknown[]; /** The grand total, where the endpoint reports one. */ total?: number; nextOffset?: number; nextCursor?: string; } /** Every page of a collection, bounded. */ export interface AllPagesResult { items: unknown[]; pages: number; /** * False when a budget or the endpoint's own paging stopped this early. * * In the value rather than only in a log line, because the repo's standing * bug class is "told 20 was all of them": a partial read that looks complete * is a wrong answer, and a script can branch on this. */ complete: boolean; stoppedBecause?: string; } export interface Dispatcher { /** One operation, one page. */ call(name: string, args: unknown, ctx: CallContext): Promise; /** One operation, every page it will serve, inside the invocation's budgets. */ callAll(name: string, args: unknown, ctx: CallContext, max?: number): Promise; } export interface DispatcherOptions { /** * Whether jsm_apply is registered on this server. * * Only changes what a refusal says. Pointing a model at jsm_apply on a * read-only install sends it looking for a tool that is not there. */ writesAvailable?: boolean; } export declare function createDispatcher(registry: OperationRegistry, client: JsmClient, options?: DispatcherOptions): Dispatcher; //# sourceMappingURL=dispatch.d.ts.map