import {
  createPrompt
} from "./chunk-CAY57CKF.js";
import "./chunk-KOO5733S.js";

// src/tools/create-prompt.ts
var HANDLE_PATTERN = /^[a-z0-9_-]+(?:\/[a-z0-9_-]+)?$/;
function toHandle(name) {
  return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
}
async function handleCreatePrompt(params) {
  const handle = params.handle?.trim() || toHandle(params.name);
  if (!handle || !HANDLE_PATTERN.test(handle)) {
    throw new Error(
      `Invalid prompt handle "${handle || ""}". Handle must match ${HANDLE_PATTERN}. Provide a valid \`handle\` explicitly.`
    );
  }
  const result = await createPrompt({
    handle,
    messages: params.messages,
    model: params.model,
    ...params.tags ? { tags: params.tags } : {}
  });
  const lines = [];
  lines.push("Prompt created successfully!\n");
  if (result.id) lines.push(`**ID**: ${result.id}`);
  if (result.handle) lines.push(`**Handle**: ${result.handle}`);
  lines.push(`**Name**: ${result.name || params.name}`);
  lines.push(`**Model**: ${params.model}`);
  if (result.latestVersionNumber != null)
    lines.push(`**Version**: v${result.latestVersionNumber}`);
  if (params.tags && params.tags.length > 0)
    lines.push(`**Tags**: ${params.tags.join(", ")}`);
  return lines.join("\n");
}
export {
  handleCreatePrompt
};
//# sourceMappingURL=create-prompt-LZ3QHSU4.js.map