/** * The operation catalogue, as the code API sees it. * * One object per tool, carrying the code name a script calls it by, whether * this process can actually dispatch it, and a lazily-built TypeScript * declaration. Built once per process — `jsm_search_api` and `jsm_read_api` * read it on every call, and running 94 shapes through z.toJSONSchema per call * would be work with no reason to repeat. * * It holds the WHOLE catalogue, not just what this process registered, and * marks each entry `available`. That split is deliberate and it is the same * argument jsm_list_capabilities makes: a model that cannot find an operation * will tell the user the server cannot do it. Searching wider than we can * dispatch, and saying which is which, is what stops that. */ import { z } from "zod"; import type { ToolGroup } from "../../toolsets.js"; import type { AnyToolDefinition } from "../define.js"; /** How a script may use an operation, and how a client should treat it. */ export type OperationKind = "read" | "write" | "destructive"; export interface Operation { /** What a script calls it: `jsm_list_alerts` -> `listAlerts`. */ codeName: string; toolName: string; toolset: ToolGroup; kind: OperationKind; /** Whether this process can dispatch it: its toolset is loaded and it has a data layer. */ available: boolean; /** Why it is not available, when it is not. Reuses jsm_list_capabilities' wording. */ unavailableReason?: string; /** True for the auto-pageable reads, which also get a `listAll*` form. */ pageable: boolean; tool: AnyToolDefinition; /** The description's first line. Written as a standalone summary in every case. */ summary: string; /** The TypeScript argument type. Memoised: an operation nobody reads never pays. */ declaration(): string; } export interface SearchQuery { query?: string | undefined; toolset?: string | undefined; kind?: "read" | "write" | "any" | undefined; limit?: number | undefined; } export interface OperationRegistry { /** Every operation in the catalogue, available or not. */ all(): readonly Operation[]; /** By code name (`listAlerts`) or tool name (`jsm_list_alerts`). Both are accepted. */ find(name: string): Operation | undefined; search(query: SearchQuery): readonly Operation[]; /** The ones this process can dispatch. */ reachable(): readonly Operation[]; /** Code names of the reachable operations, sorted — the index a description embeds. */ index(): readonly string[]; } /** `jsm_list_alerts` -> `listAlerts`. Mechanical, so it inherits tool names' stability. */ export declare function toCodeName(toolName: string): string; /** Builds the registry. `reachable` is the set of tool names this process may dispatch. */ export declare function createRegistry(catalogue: readonly AnyToolDefinition[], reachable: ReadonlySet): OperationRegistry; /** The shape every tool's arguments are validated against before dispatch. */ export declare function argumentSchema(tool: AnyToolDefinition): z.ZodType; //# sourceMappingURL=registry.d.ts.map