import { QueryExecutor, type ConnectionConfig, type DatabaseConnector } from '@duckcodeailabs/dql-connectors';
import { type SemanticLayer, type SemanticLayerProviderConfig } from '@duckcodeailabs/dql-core';
import { type AgentSchemaTable } from '@duckcodeailabs/dql-agent';
export interface ProjectConfig {
    project?: string;
    defaultConnection?: ConnectionConfig;
    defaultConnectionName?: string;
    connections?: Record<string, ConnectionConfig & {
        path?: string;
        type?: string;
    }>;
    dataDir?: string;
    semanticLayer?: SemanticLayerProviderConfig;
    dbt?: {
        projectDir?: string;
        manifestPath?: string;
    };
    preview?: {
        port?: number;
        theme?: string;
        open?: boolean;
    };
}
export interface DbtProfileConnectionCandidate {
    id: string;
    profileName: string;
    targetName: string;
    adapter: string;
    path: string;
    connection: ConnectionConfig;
    missingFields: string[];
    warnings: string[];
}
export interface LocalServerOptions {
    rootDir: string;
    projectRoot?: string;
    executor: QueryExecutor;
    connection: ConnectionConfig;
    preferredPort: number;
    /**
     * Host the HTTP server binds to. Defaults to `127.0.0.1` (loopback only)
     * for security. Set to `0.0.0.0` when running inside a container so the
     * port is reachable from the host. Honours `DQL_HOST` env var when unset.
     */
    host?: string;
}
export declare function startLocalServer(opts: LocalServerOptions): Promise<number>;
export declare function assertLocalQueryRuntimeReady(executor: QueryExecutor, connection: ConnectionConfig): Promise<void>;
export declare function formatLocalQueryRuntimeError(connection: ConnectionConfig, error: unknown): string;
export interface ConnectionTestResult {
    ok: boolean;
    message: string;
    details?: Record<string, unknown>;
}
export declare function validateConnectionForTest(connector: DatabaseConnector, connection: ConnectionConfig): Promise<ConnectionTestResult>;
export declare function serializeJSON(value: unknown): string;
export declare function findProjectRoot(startDir: string): string;
export declare function loadProjectConfig(projectRoot: string): ProjectConfig;
export declare function prepareLocalExecution(sql: string, connection: ConnectionConfig, projectRoot: string, projectConfig: ProjectConfig): {
    sql: string;
    connection: ConnectionConfig;
};
export declare function resolveDbtMacrosForExecution(sql: string, projectRoot: string, projectConfig?: ProjectConfig): string;
export declare function buildAgentPreviewSql(sql: string): string;
export interface PreparedSemanticSql {
    sql: string;
    semanticRefs: {
        metrics: string[];
        dimensions: string[];
    };
    unresolvedRefs: string[];
}
/**
 * Shared resolver for `@metric(name)` / `@dim(name)` refs in raw SQL.
 * Used by notebook SQL execution and Block Studio validation so both paths
 * behave identically. If the SQL has no refs, returns it unchanged.
 */
export declare function prepareSemanticSql(sql: string, semanticLayer: SemanticLayer | undefined): PreparedSemanticSql;
export declare function normalizeProjectConnection(connection: ConnectionConfig, projectRoot: string): ConnectionConfig;
export declare function resolveProjectRelativeSqlPaths(sql: string, projectRoot: string, dataDir?: string): string;
type BlockStudioDiagnostic = {
    severity: 'error' | 'warning' | 'info';
    message: string;
    code?: string;
};
export declare function resolveSemanticTableMapping(executor: QueryExecutor, connection: ConnectionConfig, semanticLayer?: SemanticLayer): Promise<Record<string, string> | undefined>;
export declare function buildSemanticTableMapping(semanticLayer: SemanticLayer, rows: Array<Record<string, unknown>>): Record<string, string> | undefined;
export declare function validateBlockStudioSource(source: string, semanticLayer?: SemanticLayer): {
    valid: boolean;
    diagnostics: BlockStudioDiagnostic[];
    semanticRefs: {
        metrics: string[];
        dimensions: string[];
        segments: string[];
    };
    chartConfig?: {
        chart?: string;
        x?: string;
        y?: string;
        color?: string;
        title?: string;
    };
    executableSql?: string | null;
};
export declare function saveBlockStudioArtifacts(projectRoot: string, options: {
    currentPath?: string;
    source: string;
    name: string;
    domain?: string;
    description?: string;
    owner?: string;
    tags?: string[];
    lineage?: string[];
    importMeta?: {
        importId?: string;
        candidateId?: string;
        sourceKind?: string;
        sourcePath?: string;
    };
}): string;
export interface BlockGitMetadata {
    commitSha: string;
    repo: string | null;
    branch: string | null;
}
export declare function readGitMetadata(projectRoot: string): BlockGitMetadata | null;
export declare function createBlockArtifacts(projectRoot: string, options: {
    name: string;
    domain?: string;
    owner?: string;
    content?: string;
    description?: string;
    tags?: string[];
    metricRefs?: string[];
    template?: string;
    blockType?: 'custom' | 'semantic';
    llmContext?: string;
    examples?: Array<{
        question: string;
        sql?: string;
    }>;
    invariants?: string[];
    gitMetadata?: BlockGitMetadata | null;
}): {
    path: string;
    content: string;
    companionPath: string;
};
export declare function createSemanticBuilderBlock(projectRoot: string, options: {
    name: string;
    domain?: string;
    description?: string;
    owner?: string;
    tags?: string[];
    metrics: string[];
    dimensions: string[];
    timeDimension?: {
        name: string;
        granularity: string;
    };
    chart?: string;
    blockType: 'semantic' | 'custom';
    sql: string;
    tables: string[];
    provider: string;
}): {
    path: string;
    content: string;
    companionPath: string;
};
export declare function discoverDbtProfileConnections(projectRoot: string, projectConfig: ProjectConfig): DbtProfileConnectionCandidate[];
export declare function buildDbtStatus(projectRoot: string, projectConfig: ProjectConfig, lastSyncTime: string | null): {
    configured: boolean;
    provider: "dbt" | "cubejs" | "snowflake" | "dql" | "lookml" | null;
    projectPath: string;
    projectName: any;
    artifacts: {
        manifest: {
            path: string;
            exists: boolean;
            count: number | undefined;
            generatedAt: string | null;
        };
        catalog: {
            path: string;
            exists: boolean;
            count: number | undefined;
            generatedAt: string | null;
        };
        semanticManifest: {
            path: string;
            exists: boolean;
            count: number | undefined;
            generatedAt: string | null;
        };
        runResults: {
            path: string;
            exists: boolean;
            count: number | undefined;
            generatedAt: string | null;
        };
    };
    counts: {
        models: number;
        sources: number;
        metrics: any;
        semanticModels: any;
        savedQueries: any;
    };
    lastSyncTime: string | null;
    setupHint: string;
};
export interface GitStatusResult {
    inRepo: boolean;
    branch: string | null;
    ahead: number;
    behind: number;
    changes: Array<{
        path: string;
        status: string;
    }>;
    error?: string;
}
export interface GitCommit {
    hash: string;
    author: string;
    date: string;
    subject: string;
}
export declare function buildAgentSchemaContext(question: string, rows: unknown[]): AgentSchemaTable[];
export declare function buildAgentValueProbeSql(table: AgentSchemaTable, column: string, searchTerms: string[], connection: ConnectionConfig): string;
export declare function extractAgentValueSearchTerms(question: string): string[];
export {};
//# sourceMappingURL=local-runtime.d.ts.map