import { searchBlocks, getBlock, listMetrics, listDimensions, lineageImpact, certify, suggestBlock, kgSearch, } from '@duckcodeailabs/dql-mcp';
const SEARCH_BLOCKS_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    properties: {
        query: { type: 'string', description: 'Substring matched against name, description, or tags.' },
        domain: { type: 'string', description: 'Filter to a single business domain.' },
        status: {
            type: 'string',
            enum: ['draft', 'review', 'certified', 'deprecated', 'pending_recertification'],
            description: 'Filter by certification status.',
        },
        limit: { type: 'number', description: 'Max results (default 50).' },
    },
};
const GET_BLOCK_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    required: ['name'],
    properties: {
        name: { type: 'string', description: 'Block name (as shown in search_blocks).' },
        includeSource: { type: 'boolean', description: 'Include full .dql source text. Default true.' },
    },
};
const DOMAIN_FILTER_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    properties: {
        domain: { type: 'string', description: 'Filter to a single domain.' },
    },
};
const LINEAGE_IMPACT_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    required: ['focus'],
    properties: {
        focus: { type: 'string', description: 'Node id ("block:revenue") or bare name.' },
        upstreamDepth: { type: 'number' },
        downstreamDepth: { type: 'number' },
        paths: { type: 'boolean', description: 'Include full source→leaf paths (slower on large graphs).' },
    },
};
const CERTIFY_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    required: ['name'],
    properties: {
        name: { type: 'string', description: 'Block name to certify.' },
    },
};
const SUGGEST_BLOCK_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    required: ['name', 'domain', 'owner', 'description', 'sql'],
    properties: {
        name: { type: 'string', description: 'Proposed block name (kebab_case).' },
        domain: { type: 'string', description: 'Business domain (finance, product, …).' },
        owner: { type: 'string', description: 'Block owner identity (email or team handle).' },
        description: { type: 'string', description: 'One-line description.' },
        sql: { type: 'string', description: 'The block body SQL.' },
        tags: { type: 'array', items: { type: 'string' } },
        chartType: { type: 'string', description: 'Optional visualization type.' },
    },
};
const KG_SEARCH_SCHEMA = {
    type: 'object',
    additionalProperties: false,
    required: ['query'],
    properties: {
        query: { type: 'string', description: 'Natural-language or keyword query.' },
        kinds: {
            type: 'array',
            items: {
                type: 'string',
                enum: [
                    'block', 'term', 'business_view',
                    'metric', 'dimension', 'measure', 'entity', 'semantic_model', 'saved_query', 'domain',
                    'dbt_model', 'dbt_source', 'notebook', 'dashboard', 'app', 'skill',
                ],
            },
            description: 'Optional KG node-kind filter.',
        },
        domain: { type: 'string', description: 'Filter to a single business domain.' },
        limit: { type: 'number', description: 'Max hits (default 10).' },
    },
};
export function buildAgentTools(ctx) {
    return [
        {
            name: 'kg_search',
            description: 'Search the DQL knowledge graph across business terms, business views, blocks, apps, dashboards, notebooks, semantic objects, and dbt/source metadata.',
            inputSchema: KG_SEARCH_SCHEMA,
            run: async (args) => kgSearch(ctx, args),
        },
        {
            name: 'search_blocks',
            description: 'Find certified DQL blocks by keyword, domain, or status.',
            inputSchema: SEARCH_BLOCKS_SCHEMA,
            run: async (args) => searchBlocks(ctx, args),
        },
        {
            name: 'get_block',
            description: 'Return full metadata, dependencies, and SQL for a block.',
            inputSchema: GET_BLOCK_SCHEMA,
            run: async (args) => getBlock(ctx, args),
        },
        {
            name: 'list_metrics',
            description: 'List semantic-layer metrics, optionally filtered by domain.',
            inputSchema: DOMAIN_FILTER_SCHEMA,
            run: async (args) => listMetrics(ctx, args),
        },
        {
            name: 'list_dimensions',
            description: 'List semantic-layer dimensions, optionally filtered by domain.',
            inputSchema: DOMAIN_FILTER_SCHEMA,
            run: async (args) => listDimensions(ctx, args),
        },
        {
            name: 'lineage_impact',
            description: 'Return upstream/downstream lineage for a block, metric, or model.',
            inputSchema: LINEAGE_IMPACT_SCHEMA,
            run: async (args) => lineageImpact(ctx, args),
        },
        {
            name: 'certify',
            description: 'Run governance rules against a block and report pass/fail.',
            inputSchema: CERTIFY_SCHEMA,
            run: async (args) => certify(ctx, args),
        },
        {
            name: 'suggest_block',
            description: 'Write a proposed block to blocks/_drafts/ and return governance results. ' +
                'Use this at the end of a conversation to hand the user a reviewable draft.',
            inputSchema: SUGGEST_BLOCK_SCHEMA,
            run: async (args) => suggestBlock(ctx, args),
        },
    ];
}
//# sourceMappingURL=tools.js.map