"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toolEditProjectContextOutputSchema = exports.toolEditProjectContextArgsSchema = exports.TOOL_EDIT_PROJECT_CONTEXT_DESCRIPTION = void 0;
const zod_1 = require("zod");
const projectContext_1 = require("../../projectContext");
exports.TOOL_EDIT_PROJECT_CONTEXT_DESCRIPTION = [
    "Open or update a pull request that changes this project's Lightdash project context — the lightdash.project_context.yml living document of business definitions and routing/context facts the AI agents read before answering.",
    'Use this ONLY to add or refine a durable, project-specific fact: a business definition or acronym ("HR" = high-risk cohort, not human resources), routing/join guidance about which explore answers a question, or an object-scoped context note — something that would prevent a class of wrong answers in future turns.',
    'Do NOT use this for dbt / semantic-layer YAML changes (use editDbtProject for those) or for read-only questions.',
    'The change is applied deterministically via a GitHub-API merge of the YAML — there is no sandbox — and a pull request is opened or updated. The call is synchronous. Treat the result as your own work when you report it to the user.',
].join(' ');
// Mirrors AiAgentJudgeProjectContextEntry — the structured entry the
// deterministic ProjectContextService.writebackEntry applies to the YAML.
exports.toolEditProjectContextArgsSchema = zod_1.z.object({
    op: zod_1.z
        .enum(['create', 'update'])
        .describe('Use "update" to replace an existing project-context entry (set id), otherwise "create".'),
    id: zod_1.z
        .string()
        .nullable()
        .describe('The id of the existing entry to replace when op="update"; otherwise null.'),
    kind: zod_1.z
        .enum(['definition', 'context'])
        .describe('Use "definition" for acronyms and business vocabulary ("X means Y"); use "context" for routing/join rules, guidance, or durable object-scoped facts.'),
    content: zod_1.z
        .string()
        .describe('A single self-contained sentence stating the fact (e.g. \'"HR" = the high-risk diabetes cohort, not human resources.\').'),
    terms: zod_1.z
        .array(zod_1.z.string())
        .describe('The prompt-facing trigger words/phrases that should surface this entry (e.g. ["HR","high risk"]). Required for definitions.'),
    objects: zod_1.z
        .array(projectContext_1.aiProjectContextTypedObjectRefSchema)
        .describe('The semantic objects this fact concerns. Use {type:"explore",name} for explores and {type:"field",explore,fieldId} for fields; [] when purely prompt-driven.'),
});
exports.toolEditProjectContextOutputSchema = zod_1.z.object({
    result: zod_1.z.string(),
    metadata: zod_1.z.discriminatedUnion('status', [
        zod_1.z.object({
            status: zod_1.z.literal('success'),
            prUrl: zod_1.z.string().nullable(),
            // Nullish, not required: tool-call metadata is persisted, so cards
            // rendered from rows written before this field existed must parse.
            prAction: zod_1.z.enum(['opened', 'updated']).nullish(),
        }),
        zod_1.z.object({
            status: zod_1.z.literal('error'),
            errorCode: zod_1.z
                .enum([
                'github_not_installed',
                'unsupported_source_control',
                'git_write_permission',
                'unknown',
            ])
                .nullish(),
        }),
    ]),
});
//# sourceMappingURL=toolEditProjectContextArgs.js.map