import { join } from 'node:path';
import { readJsonFile, writeJsonFile, getDataDir } from '../storage/json-store.js';
function detailFilePath(workspaceId, channelId) {
    return join(getDataDir(), 'workspaces', workspaceId, 'channels', channelId, 'tool-details.json');
}
export function saveToolDetails(workspaceId, channelId, details) {
    const path = detailFilePath(workspaceId, channelId);
    const existing = readJsonFile(path) || [];
    const nextById = new Map(existing.map((detail) => [detail.id, detail]));
    for (const detail of details) {
        nextById.set(detail.id, detail);
    }
    writeJsonFile(path, Array.from(nextById.values()));
}
export function getToolDetail(workspaceId, channelId, messageId, detailId) {
    const details = readJsonFile(detailFilePath(workspaceId, channelId)) || [];
    return details.find((detail) => detail.messageId === messageId && detail.id === detailId) ?? null;
}
//# sourceMappingURL=tool-detail.js.map