/** * Shared plumbing every tool uses, now on Slipway. * * Tool modules keep describing themselves with a Zod shape, a risk and a * handler. This adapter turns each into a Slipway tool, so the MCP server, the * CLI, the write guard, annotations and errors all come from the framework * instead of a copy kept in this repo. */ import { SlipwayError, z, type Risk, type Tool } from "@thenavidm/slipway"; import type { ThriveCartClient } from "../api/client.js"; import type { Account, Config } from "../config.js"; import { ThriveCartError } from "../api/errors.js"; export type ToolContext = { client: ThriveCartClient; config: Config; /** Resolve which cart this call reads or acts on. */ account: (hint?: string) => Account; }; /** The optional argument that picks a cart, on every tool. */ export declare const accountArg: { account: z.ZodOptional; }; /** Page and per-page, on every paginating tool. */ export declare const pageArgs: { page: z.ZodOptional; per_page: z.ZodOptional; }; export type ToolSpec = { name: string; /** One line, imperative. Shown in tool pickers. */ title: string; description: string; schema: S; risk: Risk; /** True when calling twice has the same effect as calling once. */ idempotent?: boolean; handler: (args: z.infer>, ctx: ToolContext) => Promise; /** One line for the audit log and the confirm message, when this is a write. */ summary?: (args: z.infer>) => string; }; export type AnyToolSpec = Tool; export declare function makeContext(client: ThriveCartClient, config: Config): ToolContext; /** Clamp a caller-supplied page size into a range ThriveCart will accept. */ export declare function clamp(value: number | undefined, fallback: number, max?: number): number; /** * Kept so tool modules read the same, but never sent: Slipway adds `confirm` * to every irreversible tool itself, with one description everywhere. */ export declare const confirmArg: { confirm: z.ZodOptional; }; type Shape = Record; /** * Slipway reads the status (or, without one, the words) to pick the exit code * and the error code. What else the error knew, such as the endpoint, rides * along in `details` for the model to read. */ export declare function toSlipway(error: ThriveCartError): SlipwayError; export declare function defineTool(spec: ToolSpec): Tool; export {};