import {
  vercel_exports
} from "../../chunk-W3SYYZ3X.js";
import {
  anthropic_exports
} from "../../chunk-TGWLXJMM.js";
import {
  openai_exports
} from "../../chunk-3I5KHU25.js";
import {
  BROWSER_SYSTEM_PROMPT,
  BROWSER_TOOL_DESCRIPTION
} from "../../chunk-2HMEZZKK.js";
import {
  BrowserClient,
  checkHealth,
  executeBrowserTask,
  executeWithRecording,
  getErrors,
  getRecording,
  getWebp,
  waitForRecording
} from "../../chunk-RDMI5MI7.js";
import {
  ProfilesClient
} from "../../chunk-WAWGBDBT.js";
import "../../chunk-2AMEQAO2.js";
import {
  MorphAPIError,
  MorphAuthenticationError,
  MorphError,
  MorphNotFoundError,
  MorphProfileLimitError,
  MorphRateLimitError,
  MorphValidationError,
  parseAPIError
} from "../../chunk-2VERUKO2.js";
import {
  LIVE_PRESETS,
  buildEmbedCode,
  buildLiveIframe,
  buildLiveUrl
} from "../../chunk-YTYCHRQ2.js";
import "../../chunk-E6BQJL5D.js";
import "../../chunk-F3NCFNUX.js";
import "../../chunk-S4Y6O7CT.js";
import {
  __export
} from "../../chunk-PZ5AY32C.js";

// tools/browser/gemini.ts
var gemini_exports = {};
__export(gemini_exports, {
  browserFunctionDeclaration: () => browserFunctionDeclaration,
  browserTool: () => browserTool,
  createBrowserTool: () => createBrowserTool,
  default: () => gemini_default,
  execute: () => execute,
  formatResult: () => formatResult,
  getSystemPrompt: () => getSystemPrompt
});
import { SchemaType } from "@google/generative-ai";
var TOOL_PARAMETERS = {
  type: SchemaType.OBJECT,
  properties: {
    task: {
      type: SchemaType.STRING,
      description: 'Natural language description of what to do (e.g., "Test checkout flow for buying a pineapple")'
    },
    url: {
      type: SchemaType.STRING,
      description: "Starting URL (e.g., https://3000-xyz.e2b.dev). Required if navigating to a specific page."
    },
    maxSteps: {
      type: SchemaType.NUMBER,
      description: "Maximum number of browser actions to take (1-50). Default: 10. Use 15-30 for complex flows."
    },
    region: {
      type: SchemaType.STRING,
      description: "Browserless region: sfo (US West Coast) or lon (Europe). Default: sfo."
    }
  },
  required: ["task"]
};
var browserFunctionDeclaration = {
  name: "browser_task",
  description: BROWSER_TOOL_DESCRIPTION,
  parameters: TOOL_PARAMETERS
};
async function execute(input, config) {
  const parsedInput = typeof input === "string" ? JSON.parse(input) : input;
  return executeBrowserTask(parsedInput, config);
}
function formatResult(result) {
  if (result.success) {
    const parts = [
      "\u2705 Browser task completed successfully",
      `Steps taken: ${result.stepsTaken ?? 0}`,
      result.executionTimeMs ? `Execution time: ${result.executionTimeMs}ms` : null,
      "",
      "Result:",
      result.result || "Task completed"
    ];
    return parts.filter(Boolean).join("\n");
  }
  return `\u274C Browser task failed: ${result.error || "Unknown error"}`;
}
function getSystemPrompt() {
  return BROWSER_SYSTEM_PROMPT;
}
function createBrowserTool(config) {
  const declaration = {
    name: "browser_task",
    description: BROWSER_TOOL_DESCRIPTION,
    parameters: TOOL_PARAMETERS
  };
  return Object.assign(declaration, {
    execute: async (input) => {
      return execute(input, config);
    },
    formatResult: (result) => {
      return formatResult(result);
    },
    getSystemPrompt: () => {
      return getSystemPrompt();
    }
  });
}
var browserTool = browserFunctionDeclaration;
var gemini_default = browserFunctionDeclaration;
export {
  BROWSER_SYSTEM_PROMPT,
  BROWSER_TOOL_DESCRIPTION,
  BrowserClient,
  LIVE_PRESETS,
  MorphAPIError,
  MorphAuthenticationError,
  MorphError,
  MorphNotFoundError,
  MorphProfileLimitError,
  MorphRateLimitError,
  MorphValidationError,
  ProfilesClient,
  anthropic_exports as anthropic,
  buildEmbedCode,
  buildLiveIframe,
  buildLiveUrl,
  checkHealth,
  executeBrowserTask,
  executeWithRecording,
  gemini_exports as gemini,
  getErrors,
  getRecording,
  getWebp,
  openai_exports as openai,
  parseAPIError,
  vercel_exports as vercel,
  waitForRecording
};
//# sourceMappingURL=index.js.map