/**
 * Generated by apps/api/scripts/generate-tool-contracts.ts.
 *
 * Browser-safe AI SDK tool contracts for Studio's built-in chat tools.
 */

export interface StudioGenerateImageResult {
  success: true;
  images: Array<{ uri: string; mediaType: string }>;
  prompt: string;
  model: string;
  usage: { inputTokens: number; outputTokens: number };
  usedReferenceImages: number;
}

export type StudioChatTools = {
  user_ask: {
    input: {
      prompt: string;
      type: "text" | "choice" | "confirm";
      options?: string[] | undefined;
      default?: string | undefined;
    };
    output: { response: string };
  };
  todo_write: {
    input: {
      todos: {
        content: string;
        status: "pending" | "in_progress" | "completed";
        activeForm: string;
      }[];
    };
    output: { ok: true; count: number };
  };
  propose_plan: { input: { plan: string }; output: { approved: boolean } };
  update_interests: {
    input: { interests: { title: string; summary: string }[] };
    output: { ok: true; count: number };
  };
  subtask: {
    input: { prompt: string; agent_id?: string | undefined };
    output:
      | { text: string; error?: undefined; finishReason?: undefined }
      | { text: string; error: string | undefined; finishReason: string };
  };
  read_tool_output: {
    input: { tool_call_id: string; pattern: string };
    output: { result: string; matchCount: number; totalLines: number };
  };
  generate_image: {
    input: {
      prompt: string;
      referenceImages?: { uri: string }[] | undefined;
      aspectRatio?:
        | "1:1"
        | "16:9"
        | "9:16"
        | "4:3"
        | "3:4"
        | "3:2"
        | "2:3"
        | undefined;
      n?: number | undefined;
    };
    output: StudioGenerateImageResult;
  };
  web_search: {
    input: { query: string };
    output:
      | {
          citations?: { url: string; title?: string }[] | undefined;
          success: true;
          uri: string;
          preview: string;
          query: string;
          usage: { inputTokens: number; outputTokens: number };
        }
      | {
          citations?: { url: string; title?: string }[] | undefined;
          success: true;
          content: string;
          query: string;
          usage: { inputTokens: number; outputTokens: number };
        };
  };
  deep_research: {
    input: { query: string };
    output:
      | {
          citations?: { url: string; title?: string }[] | undefined;
          success: true;
          uri: string;
          preview: string;
          query: string;
          usage: { inputTokens: number; outputTokens: number };
        }
      | {
          citations?: { url: string; title?: string }[] | undefined;
          success: true;
          content: string;
          query: string;
          usage: { inputTokens: number; outputTokens: number };
        };
  };
  take_screenshot: {
    input: { url: string; fullPage?: boolean | undefined };
    output:
      | { success: false; error: string; url?: undefined; image?: undefined }
      | { success: false; error: string; url: string; image?: undefined }
      | {
          success: true;
          image: { uri: string; mediaType: string };
          url: string;
          error?: undefined;
        };
  };
  scrape_url: {
    input: { url: string };
    output:
      | {
          success: boolean;
          error: string;
          url: string;
          uri?: undefined;
          preview?: undefined;
          tokenCount?: undefined;
          content?: undefined;
        }
      | {
          success: boolean;
          uri: string;
          preview: string;
          url: string;
          tokenCount: number;
          error?: undefined;
          content?: undefined;
        }
      | {
          success: boolean;
          content: string;
          url: string;
          tokenCount: number;
          error?: undefined;
          uri?: undefined;
          preview?: undefined;
        };
  };
  inspect_page: {
    input: {
      url: string;
      evaluate?: string | undefined;
      waitUntil?:
        | "load"
        | "domcontentloaded"
        | "networkidle0"
        | "networkidle2"
        | undefined;
    };
    output:
      | {
          success: boolean;
          error: string;
          url: string;
          uri?: undefined;
          preview?: undefined;
          tokenCount?: undefined;
          consoleLogCount?: undefined;
          errorCount?: undefined;
          hasEvaluateResult?: undefined;
          consoleLogs?: undefined;
          errors?: undefined;
          evaluateResult?: undefined;
        }
      | {
          success: boolean;
          uri: string;
          preview: string;
          url: string;
          tokenCount: number;
          consoleLogCount: number;
          errorCount: number;
          hasEvaluateResult: boolean;
          error?: undefined;
          consoleLogs?: undefined;
          errors?: undefined;
          evaluateResult?: undefined;
        }
      | {
          success: boolean;
          consoleLogs: { type: string; text: string }[] | undefined;
          errors: string[] | undefined;
          evaluateResult: unknown;
          url: string;
          tokenCount: number;
          error?: undefined;
          uri?: undefined;
          preview?: undefined;
          consoleLogCount?: undefined;
          errorCount?: undefined;
          hasEvaluateResult?: undefined;
        };
  };
};
