import { z } from 'zod';
import { type ApiSuccess } from '../../types/api/success';
/**
 * Body for kicking off an AI writeback run. The target repository is
 * cloned into a sandbox, the prompt is executed by the Claude Code CLI, and a
 * pull request is opened against the repo if the agent changes any files.
 *
 * The target repository (owner, repo) and the dbt project sub-folder are
 * resolved server-side from the Lightdash project's dbt connection — identified
 * by the `projectUuid` path parameter — so the caller only supplies the prompt.
 */
export type AiWritebackRequestBody = {
    prompt: string;
};
/**
 * Whether a writeback run opened a brand-new pull request or updated an
 * existing one (a resumed thread or a pasted PR link). `null` when no pull
 * request was touched (the agent made no file changes).
 */
export type PullRequestWritebackAction = 'opened' | 'updated';
/**
 * Result of a (synchronous) AI writeback run.
 *
 * - `output` is the text the agent produced.
 * - `exitCode` is the sandbox command's exit status.
 * - `prUrl` is the URL of the pull request opened from the agent's changes, or
 *   `null` when the agent made no file changes (nothing to raise a PR for).
 * - `prAction` is whether that PR was newly opened or an existing one updated,
 *   or `null` when no PR was touched.
 * - `projectName` is the Lightdash project the run targeted.
 * - `repository` is the GitHub repository (`owner/repo`) the run targeted.
 */
/**
 * One action the writeback sandbox took, in a generic shape the chat UI can
 * group and render as step rows without knowing anything about writeback.
 * `kind` buckets the action (consecutive same-kind steps are grouped, e.g.
 * "Read 3 files"); `label` is the file basename or a stage description.
 */
export type AiWritebackStep = {
    kind: 'read' | 'edit' | 'search' | 'compile' | 'stage';
    label: string;
};
export type AiWritebackRunResult = {
    output: string;
    exitCode: number;
    prUrl: string | null;
    prAction: PullRequestWritebackAction | null;
    /**
     * Head commit SHA this turn pushed onto the PR's branch; null when no commit
     * was made (no file changes, or the agent crashed before pushing). Pins the
     * PR card's CI checks to this turn's commit so a later turn's commit can't
     * retroactively change what an earlier card shows.
     */
    commitSha: string | null;
    /** Lines this turn's commit added/removed; null when no commit was made. */
    additions: number | null;
    deletions: number | null;
    projectName: string;
    repository: string;
    /** Ordered actions the sandbox took, for the chat UI's step rows. */
    steps: AiWritebackStep[];
};
export type ApiAiWritebackResponse = ApiSuccess<AiWritebackRunResult>;
export declare const MCP_TOOL_RUN_AI_WRITEBACK_DESCRIPTION = "Tool: run_ai_writeback\n\nPurpose:\nMake a change to the dbt project that backs the active Lightdash project by describing it in natural language, then open a pull request with the result. The target GitHub repository and dbt sub-folder are resolved server-side from the active project's dbt connection \u2014 you never specify them.\n\nHow it works:\n- A sandbox is created, the project's GitHub repository is cloned, and the prompt is executed by the Claude Code CLI against the dbt project.\n- If the agent changes any files, a branch is committed, pushed, and a pull request is opened. The PR URL is returned.\n- If the agent makes no file changes, no PR is opened and prUrl is null.\n\nRequirements:\n- An active project must be set first via set_project (or the X-Lightdash-Project header).\n- The project's dbt connection must be GitHub-backed, and the organization must have the GitHub App installed.\n- The AI writeback feature must be enabled for the organization.\n\nImportant:\n- This tool is NOT read-only and NOT idempotent \u2014 each call can open a new pull request. Use it only when the user explicitly wants to change their dbt project.\n- The run is synchronous and can take a few minutes (cloning, running the agent, opening the PR).\n\nParameters:\n- prompt: A clear, self-contained description of the change to make to the dbt project (e.g. \"Add a 'total_revenue' metric to the orders model as the sum of amount\").\n\nResponse shape (MCP CallToolResult):\n- content: [{ type: \"text\", text: \"<human-readable summary including the PR URL>\" }]\n- structuredContent: {\n    output:   string,           // the agent's text output\n    exitCode: number,           // the sandbox command's exit status\n    prUrl:    string | null     // URL of the opened pull request, or null when no changes were made\n  }\n";
export declare const mcpRunAiWritebackArgsSchema: z.ZodObject<{
    prompt: z.ZodString;
}, "strip", z.ZodTypeAny, {
    prompt: string;
}, {
    prompt: string;
}>;
export declare const mcpRunAiWritebackStructuredOutputSchema: z.ZodObject<{
    output: z.ZodString;
    exitCode: z.ZodNumber;
    prUrl: z.ZodNullable<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    output: string;
    exitCode: number;
    prUrl: string | null;
}, {
    output: string;
    exitCode: number;
    prUrl: string | null;
}>;
export type McpRunAiWritebackArgs = z.infer<typeof mcpRunAiWritebackArgsSchema>;
//# sourceMappingURL=types.d.ts.map