import { ConfigurationError } from "./errors-D_R568zP.js";
import { callEmbeddedAgent } from "./callEmbeddedAgent-BSnzLPfW.js";
import { createWhoamiTool } from "./whoami-D8-XCgVJ.js";
import { createDatasetFieldsTool } from "./dataset-fields-C1o_cZrM.js";
import { systemPrompt } from "./config-BMC-126h.js";
import { z } from "zod";

//#region src/tools/search-issues/agent.ts
const outputSchema = z.object({
	query: z.string().default("").nullish().describe("The Sentry issue search query"),
	sort: z.enum([
		"date",
		"freq",
		"new",
		"user"
	]).default("date").nullish().describe("How to sort the results"),
	explanation: z.string().describe("Brief explanation of how you translated this query.")
});
/**
* Search issues agent - single entry point for translating natural language queries to Sentry issue search syntax
* This returns both the translated query result AND the tool calls made by the agent
*/
async function searchIssuesAgent(options) {
	if (!process.env.OPENAI_API_KEY) throw new ConfigurationError("OPENAI_API_KEY environment variable is required for semantic search");
	return await callEmbeddedAgent({
		system: systemPrompt,
		prompt: options.query,
		tools: {
			issueFields: createDatasetFieldsTool({
				apiService: options.apiService,
				organizationSlug: options.organizationSlug,
				dataset: "search_issues",
				projectId: options.projectId
			}),
			whoami: createWhoamiTool({ apiService: options.apiService })
		},
		schema: outputSchema
	});
}

//#endregion
export { searchIssuesAgent };
//# sourceMappingURL=agent-CRc61dcC.js.map