import type Database from "better-sqlite3"; import { z } from "zod"; import type { ProjectRuntime, ProjectContext } from "../active-project.js"; export declare function projectSchema(schema: z.ZodObject): z.ZodObject<(keyof T & "expected_project_id" extends never ? T & { expected_project_id: z.ZodOptional; } : { [K in keyof T as K extends "expected_project_id" ? never : K]: T[K]; } & { expected_project_id: z.ZodOptional; }) extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.core.$strip>; type ToolContent = { type: "text"; text: string; }; type ToolResponse = { content: ToolContent[]; isError?: boolean; }; /** Return a success response with JSON-serialized data */ export declare function jsonOk(obj: Record): ToolResponse; /** Return a failure response (success: false, no isError flag) */ export declare function jsonFail(message: string): ToolResponse; /** Return an error response with isError: true — signals MCP protocol-level error */ export declare function jsonErr(toolName: string, err: unknown): ToolResponse; /** * Wrap a tool handler with try/catch. * Catches any thrown error and returns an MCP-compliant error response * instead of letting the raw error propagate. */ export declare function wrapProjectHandler>(runtime: ProjectRuntime, name: string, handler: (params: T, context: ProjectContext) => Promise): (params: T) => Promise; /** * Validate that a session_id exists in the sessions table. * Returns the ID if valid, or null if the ID is undefined/null or doesn't exist. * This prevents FOREIGN KEY constraint failures when a stale or invalid * session_id is passed by the caller (e.g. an AI agent with cached IDs). */ export declare function resolveSessionId(db: Database.Database, session_id: number | undefined, projectId: number): number | null; /** * Validate that a plan_id exists in the plan table. * Returns the ID if valid, or null if the ID is undefined/null or doesn't exist. */ export declare function resolvePlanId(db: Database.Database, plan_id: number | undefined, projectId: number): number | null; /** * Build a WHERE-clause fragment scoping queries to a single project. * * - `whereWith("d")` → "d.project_id = ?" * - `whereWith()` → "project_id = ?" (unaliased) * * Use with the projectId param appended to the query's bound parameters. */ export declare function projectPredicate(alias?: string): string; /** * Append a project predicate to an existing WHERE fragment list. * Mutates nothing — returns a new array with the predicate added. */ export declare function withProject(conds: string[], projectId: number, alias?: string): { conds: string[]; param: number; }; export {}; //# sourceMappingURL=utils.d.ts.map