import { z } from "zod";
import { HttpError } from "../../errors";
import type { ApiContext, ScopedRepo } from "../../api/http";
import { requireScopedRepo } from "../../api/http";
import type { TokenArea } from "../../token-scope";
import type { JsonObject, McpCaller } from "../protocol";
import type { Permission } from "~/lib/types";
export const MAX_TEXT_BYTES = 64 * 1024;
export type ResourceLink = {
type: "resource_link";
uri: string;
name: string;
mimeType?: string;
description?: string;
};
export type ToolResult = {
structured: Record<string, unknown>;
text?: string;
links?: ResourceLink[];
repoId?: string | null;
};
/** A tool asking the client for input first (2026 multi round-trip requests, e.g. a confirmation). */
export type InputRequired = { inputRequired: Record<string, { method: "elicitation/create"; params: JsonObject }> };
export type ToolContext = {
caller: McpCaller;
signal: AbortSignal;
progress: (message: string, progress: number, total?: number) => void;
inputResponses: JsonObject | null;
};
export type Tool = {
name: string;
title: string;
description: string;
input: z.ZodObject;