/** * 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 { SubstackClient } from "../api/client.js"; import type { Config, Credentials } from "../config.js"; import { SubstackError } from "../api/errors.js"; export type ToolContext = { client: SubstackClient; config: Config; /** Resolve which publication this call targets. */ publication: (hint?: string) => Credentials; }; /** The optional argument that picks a publication, on every publication-scoped tool. */ export declare const publicationArg: { publication: z.ZodOptional; }; export type ToolSpec = { name: string; /** One line, imperative. Shown in tool pickers. */ title: string; description: string; schema: S; risk: Risk; /** True when the effect is visible to anyone but you. */ public?: boolean; /** True when repeating the call with the same arguments changes nothing more. Reads always are. */ idempotent?: boolean; handler: (args: z.infer>, ctx: ToolContext) => Promise; /** One line for the audit log, when this is a write. */ summary?: (args: z.infer>) => string; }; export type AnyToolSpec = Tool; export declare function makeContext(client: SubstackClient, config: Config): ToolContext; /** Clamp a caller-supplied limit into a range Substack will accept. */ export declare function clamp(value: number | undefined, fallback: number, max: number): number; /** Build a query string, dropping undefined values. */ export declare function query(params: Record): string; /** * 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: SubstackError): SlipwayError; export declare function defineTool(spec: ToolSpec): Tool; export {};