import {
  prepareGeminiOnSandbox
} from "./chunk-PAQ2JFVD.js";
import {
  createGeminiTranslator
} from "./chunk-S3JRZFF5.js";
import {
  GEMINI_WRAPPER_PATH
} from "./chunk-PZ5EGY64.js";
import {
  buildGeminiArgs
} from "./chunk-IBYOMAZ3.js";
import {
  buildGeminiAuthEnv,
  validateGeminiRuntime
} from "./chunk-5R6325PY.js";
import {
  wrapPromptWithSystem
} from "./chunk-YE2RMJY7.js";
import {
  ApiError
} from "./chunk-EZYKRG4W.js";

// src/backends/gemini/index.ts
function buildTurn(input) {
  const { agent, backendSessionId, promptText, toolResults } = input;
  if (toolResults.length > 0) {
    throw new ApiError(
      400,
      "invalid_request_error",
      "gemini backend does not support user.custom_tool_result re-entry in v1"
    );
  }
  const wrappedPrompt = wrapPromptWithSystem(promptText, agent.system, agent.skills);
  const argv = buildGeminiArgs({ agent, backendSessionId, prompt: wrappedPrompt });
  const env = buildGeminiAuthEnv();
  return { argv, env, stdin: "" };
}
var geminiBackend = {
  name: "gemini",
  wrapperPath: GEMINI_WRAPPER_PATH,
  buildTurn,
  createTranslator: (opts) => createGeminiTranslator(opts),
  prepareOnSandbox: (name, provider) => prepareGeminiOnSandbox(name, provider),
  validateRuntime: validateGeminiRuntime
};

export {
  geminiBackend
};
