"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functions/comsFunctions/ResearchReport.ts
var ResearchReport_exports = {};
__export(ResearchReport_exports, {
  researchReport: () => researchReport
});
module.exports = __toCommonJS(ResearchReport_exports);

// src/utils/uuid.ts
function uuidv4() {
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
    const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
    return v.toString(16);
  });
}

// src/functions/comsFunctions/ResearchReport.ts
async function researchReport(context, event, task) {
  const response = await fetch("https://api.openai.com/v1/responses", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${process.env.OPEN_AI_KEY}`
    },
    body: JSON.stringify({
      model: "gpt-4o",
      input: [
        {
          role: "system",
          content: [
            {
              type: "input_text",
              text: "You are an AI consultant who is regularly tasked with research for a wide variety of research activities. You specialize in business and technology. You always organize your response in a well-formatted manner, using tables to present key facts and information and lists to outline key points. You carefully listen to the amount of detail the user is looking for in their research report. You always search the internet for updated key facts and figures and to cross-check your work."
            }
          ]
        },
        {
          role: "user",
          content: [
            {
              type: "input_text",
              text: task
            }
          ]
        }
      ],
      text: {
        format: {
          type: "text"
        }
      },
      reasoning: {},
      tools: [
        {
          type: "web_search_preview",
          user_location: {
            type: "approximate",
            country: "US"
          },
          search_context_size: "high"
        }
      ],
      temperature: 1,
      max_output_tokens: 4096,
      top_p: 1,
      store: true
    })
  });
  const data = await response.json();
  const content = data.output?.filter((message) => message.type === "message")?.[0]?.content?.[0]?.text;
  return {
    id: uuidv4(),
    content
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  researchReport
});
