import { defineTool } from "./define-2Lj8Lm1t.js";
import { apiServiceFromContext } from "./api-CkLTFexT.js";
import { ParamOrganizationSlug, ParamProjectSlug, ParamRegionUrl } from "./schema-rwexXWFL.js";
import { setTag } from "@sentry/core";
import { z } from "zod";

//#region src/tools/create-dsn.ts
var create_dsn_default = defineTool({
	name: "create_dsn",
	requiredScopes: ["project:write"],
	description: [
		"Create an additional DSN for an EXISTING project.",
		"",
		"🔍 USE THIS TOOL WHEN:",
		"- Project already exists and needs additional DSN",
		"- 'Create another DSN for project X'",
		"- 'I need a production DSN for existing project'",
		"",
		"❌ DO NOT USE for new projects (use create_project instead)",
		"",
		"Be careful when using this tool!",
		"",
		"<examples>",
		"### Create additional DSN for existing project",
		"```",
		"create_dsn(organizationSlug='my-organization', projectSlug='my-project', name='Production')",
		"```",
		"</examples>",
		"",
		"<hints>",
		"- If the user passes a parameter in the form of name/otherName, its likely in the format of <organizationSlug>/<projectSlug>.",
		"- If any parameter is ambiguous, you should clarify with the user what they meant.",
		"</hints>"
	].join("\n"),
	inputSchema: {
		organizationSlug: ParamOrganizationSlug,
		regionUrl: ParamRegionUrl.optional(),
		projectSlug: ParamProjectSlug,
		name: z.string().trim().describe("The name of the DSN to create, for example 'Production'.")
	},
	annotations: {
		readOnlyHint: false,
		destructiveHint: false,
		openWorldHint: true
	},
	async handler(params, context) {
		const apiService = apiServiceFromContext(context, { regionUrl: params.regionUrl });
		const organizationSlug = params.organizationSlug;
		setTag("organization.slug", organizationSlug);
		setTag("project.slug", params.projectSlug);
		const clientKey = await apiService.createClientKey({
			organizationSlug,
			projectSlug: params.projectSlug,
			name: params.name
		});
		let output = `# New DSN in **${organizationSlug}/${params.projectSlug}**\n\n`;
		output += `**DSN**: ${clientKey.dsn.public}\n`;
		output += `**Name**: ${clientKey.name}\n\n`;
		output += "# Using this information\n\n";
		output += "- The `SENTRY_DSN` value is a URL that you can use to initialize Sentry's SDKs.\n";
		return output;
	}
});

//#endregion
export { create_dsn_default };
//# sourceMappingURL=create-dsn-Bx2s8Bik.js.map