import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
import "../../../chunks/chunk-TG2EQLX2.js";

// builtin/extensions/kimi-attachments/index.ts
function isKimiAttachmentPlatform(model) {
  return model.attachmentPlatform === "kimi" || model.filePlatform === "kimi";
}
function getModality(mimeType) {
  if (mimeType.startsWith("image/")) return "image";
  if (mimeType.startsWith("video/")) return "video";
  return "file";
}
function kimiAttachmentsExtension(ctx) {
  ctx.log("Kimi attachment extension loaded");
  ctx.registerAttachmentHandler({
    name: "kimi-native-attachments",
    priority: 100,
    matches(model, attachment) {
      return isKimiAttachmentPlatform(model) && Boolean(attachment.fileId) && getModality(attachment.mimeType) !== "file";
    },
    async prepare(_model, attachment, prepareCtx) {
      const fileId = attachment.fileId;
      if (!fileId) {
        return {
          items: [{ type: "text", text: `[${attachment.id}]` }],
          warnings: ["\u9644\u4EF6\u7F3A\u5C11 fileId\uFF0C\u65E0\u6CD5\u8D70 Kimi \u539F\u751F\u5F15\u7528"]
        };
      }
      const modality = getModality(attachment.mimeType);
      const url = `ms://${fileId}`;
      prepareCtx.log(`Kimi handler prepared ${modality} reference for ${attachment.id}`);
      return {
        items: [
          {
            type: "file-ref",
            mimeType: attachment.mimeType,
            url,
            modality
          }
        ]
      };
    }
  });
}
export {
  kimiAttachmentsExtension as default
};
