import { n as openOutputSchema, r as withOpenOutputSchema, t as openJsonSchema } from "./open-output-schema.js"; import { SupabaseMcpClientContext } from "./types.js"; import { z } from "zod"; import { CallToolResult, ResourceLink } from "@modelcontextprotocol/server"; //#region src/results.d.ts type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; }; type ResourceResultLink = ResourceLink; type ResultContentBlock = CallToolResult["content"][number]; /** * Operational instructions the agent must act on (what to do next, what not * to repeat, or conditions that changed under it). Authored once and emitted * into both `content[].text` and the leading keys of `structuredContent`. */ interface ResultGuidance { readonly next?: string | null | false; readonly warnings?: readonly (string | null | false | undefined)[]; } interface NormalizedResultGuidance { readonly next?: string; readonly warnings?: string[]; } type GuidedValue> = T & NormalizedResultGuidance; interface ResultContentComposition { /** Content inserted before every block authored by the tool handler. */ readonly prepend?: readonly ResultContentBlock[]; /** Content inserted after every block authored by the tool handler. */ readonly append?: readonly ResultContentBlock[]; /** Dual-lane operational guidance merged into text and structuredContent. */ readonly guidance?: ResultGuidance; } interface ResourceResultFallbackOptions { /** Client context for conditional inline fallback rendering. */ readonly client?: SupabaseMcpClientContext; /** Explicit read tool to name when the client may not dereference `resource_link`. */ readonly fallbackTool?: { readonly name: string; readonly arguments?: Readonly>; }; /** Bounded inline excerpt appended when `client.supports.resourceLinks === "unsupported"`. */ readonly inlineExcerpt?: string; } /** Raw Zod shape for spreading into custom `z.object({ ...resultGuidanceShape, ... })` output schemas. */ declare const resultGuidanceShape: Readonly<{ next: z.ZodOptional; warnings: z.ZodOptional>; }>; /** Standalone Standard Schema for guidance fields. */ declare const resultGuidanceSchema: z.ZodObject<{ next: z.ZodOptional; warnings: z.ZodOptional>; }, z.core.$strip>; /** * Return a new `z.ZodObject` whose advertised property order leads with `next` * and `warnings` followed by `schema.shape`. */ declare function withResultGuidance(schema: z.ZodObject): z.ZodObject; /** Normalize `ResultGuidance` into clean fields; returns `{}` when empty. */ declare function guidanceFields(guidance?: ResultGuidance): NormalizedResultGuidance; declare function formatGuidanceLines(fields: NormalizedResultGuidance): string[]; /** * Add MCP content blocks and/or dual-lane guidance without replacing authored * fields. Additions are bounded; collection results also enforce their complete * byte budget. The original result remains untouched. */ declare function composeResultContent(result: CallToolResult, composition: ResultContentComposition): CallToolResult; /** Append bounded model-facing text while preserving the authored result. */ declare function appendResultText(result: CallToolResult, text: string): CallToolResult; /** Prepend bounded model-facing text while preserving the authored result. */ declare function prependResultText(result: CallToolResult, text: string): CallToolResult; /** Return purpose-written text for an agent or person. */ declare function textResult(text: string): CallToolResult; /** * Return exact machine-readable JSON without manufacturing a duplicate text * representation. Register an outputSchema on the tool that describes value. */ declare function structuredResult(value: T): CallToolResult; /** * Return intentionally different representations for two real consumers: * purpose-written model-facing text and exact machine-readable JSON. Register * an outputSchema on the tool that describes value. */ declare function renderResult(value: T, render: (value: T) => string): CallToolResult; /** * Build a dual-lane result whose prose is authored first and whose guidance * rides as a text footer AND as the leading keys of `structuredContent`. */ declare function guidedResult>(text: string, value: T, guidance?: ResultGuidance): CallToolResult; /** * Build a dual-lane result whose text is rendered from the structured value * with normalized guidance already merged onto it. */ declare function renderGuidedResult>(value: T, guidance: ResultGuidance | undefined, render: (value: GuidedValue) => string): CallToolResult; /** * Point at content registered through MCP resources instead of embedding a * large body in a tool result. Text is the concise agent-facing reading card. */ declare function resourceResult(text: string, resource: ResourceResultLink, fallback?: ResourceResultFallbackOptions): CallToolResult; /** Return a recoverable tool-level error. */ declare function errorResult(message: string, nextStep?: string): CallToolResult; type SupabaseErrorCategory = "notFound" | "conflict" | "foreignKey" | "invalidInput" | "permissionDenied" | "custom" | "unknown"; interface RedactedSupabaseErrorInfo { readonly code: string | undefined; readonly category: SupabaseErrorCategory; } type SupabaseErrorReply = string | readonly [message: string, nextStep?: string] | { readonly message: string; readonly nextStep?: string; } | CallToolResult; type SupabaseErrorHandler = SupabaseErrorReply | ((info: RedactedSupabaseErrorInfo) => SupabaseErrorReply); interface FromSupabaseErrorHandlers { readonly notFound?: SupabaseErrorHandler; readonly conflict?: SupabaseErrorHandler; readonly foreignKey?: SupabaseErrorHandler; readonly invalidInput?: SupabaseErrorHandler; readonly permissionDenied?: SupabaseErrorHandler; /** Explicit SQLSTATE or PostgREST code overrides (checked before category slots). */ readonly codes?: Readonly>; /** Catch-all override for unmapped codes. */ readonly fallback?: SupabaseErrorHandler; } interface FromSupabaseErrorOptions { /** * Override local-development detection for `42501` Data API grant hints on stderr. * Defaults to `isLocalDevelopmentRuntime()` (false on hosted Deno Deploy / Edge Runtime * and when `NODE_ENV === "production"`). */ readonly devHint?: boolean; /** Optional sink override for deterministic testing of dev stderr diagnostics. */ readonly stderr?: (line: string) => void; } /** * Map a Supabase / PostgREST error into a domain-explicit `errorResult` without * leaking SQL text, table names, constraint names, or row values to callers. */ declare function fromSupabaseError(error: unknown, handlers?: FromSupabaseErrorHandlers, options?: FromSupabaseErrorOptions): CallToolResult; //#endregion export { FromSupabaseErrorHandlers, FromSupabaseErrorOptions, GuidedValue, JsonValue, NormalizedResultGuidance, RedactedSupabaseErrorInfo, ResourceResultFallbackOptions, ResourceResultLink, ResultContentBlock, ResultContentComposition, ResultGuidance, SupabaseErrorCategory, SupabaseErrorHandler, SupabaseErrorReply, appendResultText, composeResultContent, errorResult, formatGuidanceLines, fromSupabaseError, guidanceFields, guidedResult, openJsonSchema, openOutputSchema, prependResultText, renderGuidedResult, renderResult, resourceResult, resultGuidanceSchema, resultGuidanceShape, structuredResult, textResult, withOpenOutputSchema, withResultGuidance }; //# sourceMappingURL=results.d.ts.map