import { type DatabaseModule, type QueryExecutor, type ReconcileReport } from "@supacloud/db"; import { type DbWorkflowAction } from "./db-workflow"; import { type ToolServer, type ToolResult } from "../tool-server"; export interface DbToolArguments { action: "context" | "lint" | "explain" | "module_check" | DbWorkflowAction; module?: string; root?: string; module_file?: string; target?: string; database_url?: string; schema?: string; lite?: boolean; project_dir?: string; schema_dir?: string; db_major_version?: number; out?: string; dir?: string; ref?: string; approved_digest?: string; application_role?: string; migration_role?: string; database?: string; } export interface DatabaseAiContextObject { kind: "table" | "policy" | "function" | "trigger" | "grant"; name: string; module: string; table?: string; source: string | null; tests: string[]; security?: string; permission?: string; transaction?: string; audit?: string; idempotency?: string; } export interface DatabaseAiContext { version: 1; scope: "database-ai-context"; root: string; selectedModules: string[]; target: string | null; objects: DatabaseAiContextObject[]; maintenance: { structureSource: "drizzle" | "declarative-sql"; behaviorSource: "sql"; generatedPaths: string[]; protectedPaths: string[]; forwardMigrationPath: string; rules: string[]; }; verification: string[]; } export interface DbGovernanceToolOptions { environment?: NodeJS.ProcessEnv; currentWorkingDirectory?: string; liteSpawn?: LiteSpawn; /** Overrides the supacloud-lite binary lookup; null simulates a missing binary (tests). */ liteBinary?: string | null; projectRef?: string; apiUrl?: string; runDatabase?: () => ((args: Record) => Promise) | undefined; } /** * Load database governance module declarations: * --module_file points to a file exporting `default defineDatabaseModule(...)` (or an array); * defaults to /db/modules.ts (default or named "modules" export, single or array). */ export declare function loadDatabaseModules(root: string, moduleFile?: string): Promise; export declare function buildDatabaseAiContext(modules: readonly DatabaseModule[], root: string, moduleName?: string, target?: string): DatabaseAiContext; /** Testable orchestration point: inject executor, read catalog, and reconcile against declared modules. */ export declare function runModuleCheck(module: DatabaseModule, executor: QueryExecutor, schemas?: string[]): Promise; interface LiteSubprocessResult { exitCode: number; stdout: string; stderr: string; } type LiteSpawn = (command: string[], cwd: string) => Promise; export declare function registerDbGovernanceTools(server: ToolServer, options?: DbGovernanceToolOptions): void; export {};