//#region ../mcp-core/dist/skills-DEPBbN1h.js
const SKILLS = {
	inspect: {
		id: "inspect",
		name: "Inspect Issues & Events",
		description: "Search for errors, analyze traces, and explore event details",
		defaultEnabled: true,
		order: 1
	},
	seer: {
		id: "seer",
		name: "Seer",
		description: "Sentry's AI debugger that helps you analyze, root cause, and fix issues",
		defaultEnabled: true,
		order: 2
	},
	docs: {
		id: "docs",
		name: "Documentation",
		description: "Search and read Sentry SDK documentation",
		defaultEnabled: false,
		order: 3
	},
	triage: {
		id: "triage",
		name: "Triage Issues",
		description: "Resolve, assign, and update issues",
		defaultEnabled: false,
		order: 4
	},
	"project-management": {
		id: "project-management",
		name: "Manage Projects & Teams",
		description: "Create and modify projects, teams, and DSNs",
		defaultEnabled: false,
		order: 5
	}
};
const SKILLS_ARRAY = Object.values(SKILLS).sort((a, b) => a.order - b.order);
const ALL_SKILLS = Object.keys(SKILLS);
const DEFAULT_SKILLS = SKILLS_ARRAY.filter((s) => s.defaultEnabled).map((s) => s.id);
function isValidSkill(skill) {
	return skill in SKILLS;
}
function isEnabledBySkills(grantedSkills, toolSkills) {
	if (!grantedSkills || toolSkills.length === 0) return false;
	return toolSkills.some((skill) => grantedSkills.has(skill));
}
function parseSkills(input) {
	const valid = /* @__PURE__ */ new Set();
	const invalid = [];
	if (!input) return {
		valid,
		invalid
	};
	let skills = [];
	if (typeof input === "string") skills = input.split(",");
	else if (Array.isArray(input)) skills = input.map((v) => typeof v === "string" ? v : "");
	for (const skill of skills) {
		const trimmed = String(skill).trim();
		if (isValidSkill(trimmed)) valid.add(trimmed);
		else if (trimmed) invalid.push(trimmed);
	}
	return {
		valid,
		invalid
	};
}

//#endregion
//#region ../mcp-core/dist/url-utils-hSW2gkfr.js
/**
* Determines if a Sentry instance is SaaS or self-hosted based on the host.
* @param host The Sentry host (e.g., "sentry.io" or "sentry.company.com")
* @returns true if SaaS instance, false if self-hosted
*/
function isSentryHost(host) {
	return host === "sentry.io" || host.endsWith(".sentry.io");
}
/**
* Generates a Sentry issue URL.
* @param host The Sentry host (may include regional subdomain for API access)
* @param organizationSlug Organization identifier
* @param issueId Issue identifier (e.g., "PROJECT-123")
* @returns The complete issue URL
*/
function getIssueUrl(host, organizationSlug, issueId) {
	const isSaas = isSentryHost(host);
	const webHost = isSaas ? "sentry.io" : host;
	return isSaas ? `https://${organizationSlug}.${webHost}/issues/${issueId}` : `https://${host}/organizations/${organizationSlug}/issues/${issueId}`;
}
/**
* Generates a Sentry issues search URL.
* @param host The Sentry host (may include regional subdomain for API access)
* @param organizationSlug Organization identifier
* @param query Optional search query
* @param projectSlugOrId Optional project slug or ID
* @returns The complete issues search URL
*/
function getIssuesSearchUrl(host, organizationSlug, query, projectSlugOrId) {
	const isSaas = isSentryHost(host);
	const webHost = isSaas ? "sentry.io" : host;
	let url = isSaas ? `https://${organizationSlug}.${webHost}/issues/` : `https://${host}/organizations/${organizationSlug}/issues/`;
	const params = new URLSearchParams();
	if (projectSlugOrId) params.append("project", projectSlugOrId);
	if (query) params.append("query", query);
	const queryString = params.toString();
	if (queryString) url += `?${queryString}`;
	return url;
}
/**
* Generates a Sentry trace URL for performance investigation.
* @param host The Sentry host (may include regional subdomain for API access)
* @param organizationSlug Organization identifier
* @param traceId Trace identifier
* @returns The complete trace URL
*/
function getTraceUrl(host, organizationSlug, traceId) {
	const isSaas = isSentryHost(host);
	const webHost = isSaas ? "sentry.io" : host;
	return isSaas ? `https://${organizationSlug}.${webHost}/explore/traces/trace/${traceId}` : `https://${host}/organizations/${organizationSlug}/explore/traces/trace/${traceId}`;
}
/**
* Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).
* Throws an error if validation fails instead of exiting the process.
*
* @param host The hostname to validate
* @throws {Error} If the host contains a protocol
*/
function _validateSentryHostInternal(host) {
	if (host.startsWith("http://") || host.startsWith("https://")) throw new Error("SENTRY_HOST should only contain a hostname (e.g., sentry.example.com). Use SENTRY_URL if you want to provide a full URL.");
}
/**
* Internal validation function that checks if a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.
* Throws an error if validation fails instead of exiting the process.
*
* @param url The HTTPS URL to validate and parse
* @returns The extracted hostname from the URL
* @throws {Error} If the URL is invalid or not HTTPS
*/
function _validateAndParseSentryUrlInternal(url) {
	if (!url.startsWith("https://")) throw new Error("SENTRY_URL must be a full HTTPS URL (e.g., https://sentry.example.com).");
	try {
		const parsedUrl = new URL(url);
		return parsedUrl.host;
	} catch (error) {
		throw new Error("SENTRY_URL must be a valid HTTPS URL (e.g., https://sentry.example.com).");
	}
}
/**
* Validates that a SENTRY_HOST value contains only hostname (no protocol).
* Throws an error instead of exiting the process (for testing).
*
* @param host The hostname to validate
* @throws {Error} If the host contains a protocol
*/
function validateSentryHostThrows(host) {
	_validateSentryHostInternal(host);
}
/**
* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.
* Throws an error instead of exiting the process (for testing).
*
* @param url The HTTPS URL to validate and parse
* @returns The extracted hostname from the URL
* @throws {Error} If the URL is invalid or not HTTPS
*/
function validateAndParseSentryUrlThrows(url) {
	return _validateAndParseSentryUrlInternal(url);
}
/**
* Validates that the provided OpenAI base URL is a valid HTTP(S) URL and returns a normalized string.
*
* @param url The URL to validate and normalize
* @returns The normalized URL string
* @throws {Error} If the URL is empty, invalid, or uses an unsupported protocol
*/
function validateOpenAiBaseUrlThrows(url) {
	const trimmed = url.trim();
	if (trimmed.length === 0) throw new Error("OPENAI base URL must not be empty.");
	let parsed;
	try {
		parsed = new URL(trimmed);
	} catch (error) {
		throw new Error("OPENAI base URL must be a valid HTTP or HTTPS URL (e.g., https://example.com/v1).", { cause: error });
	}
	if (parsed.protocol !== "https:" && parsed.protocol !== "http:") throw new Error("OPENAI base URL must use http or https scheme (e.g., https://example.com/v1).");
	return parsed.toString();
}

//#endregion
//#region src/cli/resolve.ts
function formatInvalidSkills(invalid, envName) {
	const where = envName ? `${envName} provided` : "Invalid skills provided";
	const allSkills = Object.keys(SKILLS).join(", ");
	return `Error: ${where}: ${invalid.join(", ")}\nAvailable skills: ${allSkills}`;
}
function finalize(input) {
	if (!input.accessToken) throw new Error("Error: No access token was provided. Pass one with `--access-token` or via `SENTRY_ACCESS_TOKEN`.");
	let sentryHost = "sentry.io";
	if (input.url) sentryHost = validateAndParseSentryUrlThrows(input.url);
	else if (input.host) {
		validateSentryHostThrows(input.host);
		sentryHost = input.host;
	}
	let finalSkills = void 0;
	if (input.skills) {
		const { valid, invalid } = parseSkills(input.skills);
		if (invalid.length > 0) throw new Error(formatInvalidSkills(invalid));
		if (valid.size === 0) throw new Error("Error: Invalid skills provided. No valid skills found.");
		finalSkills = valid;
	} else {
		const allSkills = Object.keys(SKILLS);
		finalSkills = new Set(allSkills);
	}
	const resolvedOpenAiBaseUrl = input.openaiBaseUrl ? validateOpenAiBaseUrlThrows(input.openaiBaseUrl) : void 0;
	return {
		accessToken: input.accessToken,
		sentryHost,
		mcpUrl: input.mcpUrl,
		sentryDsn: input.sentryDsn,
		openaiBaseUrl: resolvedOpenAiBaseUrl,
		openaiModel: input.openaiModel,
		finalSkills,
		organizationSlug: input.organizationSlug,
		projectSlug: input.projectSlug
	};
}

//#endregion
export { ALL_SKILLS, SKILLS, finalize, formatInvalidSkills, getIssueUrl, getIssuesSearchUrl, getTraceUrl, isEnabledBySkills, isSentryHost };
//# sourceMappingURL=resolve-Cg3SH2zt.js.map