package tech.easyflow.agent.runtime.document;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 已校验并绑定到一次 Agent 调用的文档。
 *
 * @param uploadId 上传 ID
 * @param attachmentRef 稳定附件引用
 * @param readSnapshotId 读取快照 ID
 * @param name 文件名
 * @param mimeType MIME 类型
 * @param size 字节数
 */
public record AgentBoundDocument(String uploadId,
                                 String attachmentRef,
                                 String readSnapshotId,
                                 String name,
                                 String mimeType,
                                 long size) {

    /**
     * 构造安全的 chatlog 展示载荷。
     *
     * @return 展示载荷
     */
    public Map<String, Object> payload() {
        Map<String, Object> payload = new LinkedHashMap<>();
        payload.put("attachmentRef", attachmentRef);
        payload.put("readSnapshotId", readSnapshotId);
        payload.put("name", name);
        payload.put("mimeType", mimeType);
        payload.put("size", size);
        payload.put("status", "AVAILABLE");
        payload.put("downloadUrl", "/api/v1/agent/media/document/content?reference=" + attachmentRef);
        return payload;
    }
}
